UNPKG

tangram

Version:
62 lines 573 kB
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tangram = factory());
})(this, (function () { 'use strict';

// define() gets called for each chunk generated by the first Rollup pass.
            // The order the chunks are called in is controlled by the imports in bundle.js:
            //
            // shared.js: shared dependencies between main and worker threads
            // scene_worker.js: worker thread code
            // index.js: main thread code

            // Once all chunks have been provided, the worker thread code is assembled,
            // incorporating the shared chunk code, then turned into a blob URL which
            // can be used to instantiate the worker.

            var shared, worker, Tangram = {};

            function define(_, chunk) {
                    if (!shared) {
                        shared = chunk;
                    } else if (!worker) {
                        worker = chunk;
                    } else {
                        var worker_bundle = 'var shared_chunk = {}; (' + shared + ')(shared_chunk); (' + worker + ')(shared_chunk);'
                        var shared_chunk = {};
                        shared(shared_chunk);
                        Tangram = chunk(shared_chunk);
                        Tangram.workerURL = window.URL.createObjectURL(new Blob([worker_bundle], { type: 'text/javascript' }));
                    }
            }
        

define(["exports"],(function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return "Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],l=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1;}else for(;!(l=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){u=!0,i=e;}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||r(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i={};try{window instanceof Window&&window.document instanceof HTMLDocument&&(i.is_worker=!1,i.is_main=!0);}catch(e){i.is_worker=!0,i.is_main=!1,self.window={document:{}},self.document=self.window.document;}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e){var t=function(e,t){if("object"!=o(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==o(t)?t:t+""}function s(e,t,r){return (t=a(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||r(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n);}}function h(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var f,d="v0.22.0";function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (_=function(){return !!e})()}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function m(e,t,r){if(_())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&p(i,r.prototype),i}var v=f={},g=0,y={};function x(e){var t=[];"string"==typeof e&&(t=e.split("."),e=t.pop());for(var r=f.targets,n=0;n<t.length;n++){if(!r[t[n]])return [];r=r[t[n]];}return [e,r]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(!e)return n;if(Array.isArray(e))e.forEach((function(t,r){return b(t,e,r,n)}));else if("object"===o(e))if(e instanceof ArrayBuffer)n.push({object:e,parent:t,property:r});else if(e.buffer instanceof ArrayBuffer)n.push({object:e.buffer,parent:t,property:r});else for(var i in e)b(e[i],e,i,n);return n}function A(e){Array.isArray(e)&&e.filter((function(e){return e.parent&&e.property})).forEach((function(e){return delete e.parent[e.property]}));}f.targets={},f.addTarget=function(e,t){f.targets[e]=t;},f.removeTarget=function(e){e&&delete f.targets[e];},f.withTransferables=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(!(this instanceof f.withTransferables))return m(f.withTransferables,t);this.value=t,this.transferables=b(this.value);},i.is_main&&(f.postMessage=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];if(Array.isArray(e))return Promise.all(e.map((function(e){var r;return (r=f).postMessage.apply(r,[e,t].concat(l(n)))})));var a={};"object"===o(t)&&(a=t,t=t.method);var s,u=new Promise((function(e,r){y[g]={method:t,message:n,resolve:e,reject:r};})),c=[];return n&&1===n.length&&n[0]instanceof f.withTransferables&&(c=n[0].transferables,n=n[0].value),s={type:"main_send",message_id:g,method:t,message:n},a.stringify&&(s=JSON.stringify(s)),e.postMessage(s,c.map((function(e){return e.object}))),A(c),c.length>0&&k("trace","'".concat(t,"' transferred ").concat(c.length," objects to worker thread")),g++,u},f.addWorker=function(e){if(!(e instanceof Worker))throw Error("Worker broker could not add non-Worker object",e);e.addEventListener("message",(function(t){var r="string"==typeof t.data?JSON.parse(t.data):t.data,i=r.message_id;if("worker_reply"===r.type)y[i]&&(r.error?y[i].reject(r.error):y[i].resolve(r.message),delete y[i]);else if("worker_send"===r.type&&null!=i){var o,a,s,l,u;try{var c=n(x(r.method),2);if(l=c[0],!(s=c[1]))throw Error("Worker broker could not dispatch message type ".concat(r.method," on target ").concat(r.target," because no object with that name is registered on main thread"));if(!(u="function"==typeof s[l]&&s[l]))throw Error("Worker broker could not dispatch message type ".concat(r.method," on target ").concat(r.target," because object has no method with that name"));o=u.apply(s,r.message);}catch(e){a=e;}var h,d=[];o instanceof Promise?o.then((function(t){t instanceof f.withTransferables&&(d=t.transferables,t=t.value[0]),h={type:"main_reply",message_id:i,message:t},e.postMessage(h,d.map((function(e){return e.object}))),A(d),d.length>0&&k("trace","'".concat(l,"' transferred ").concat(d.length," objects to worker thread"));}),(function(t){e.postMessage({type:"main_reply",message_id:i,error:t instanceof Error?"".concat(t.message,": ").concat(t.stack):t});})):(o instanceof f.withTransferables&&(d=o.transferables,o=o.value[0]),h={type:"main_reply",message_id:i,message:o,error:a instanceof Error?"".concat(a.message,": ").concat(a.stack):a},e.postMessage(h,d.map((function(e){return e.object}))),A(d),d.length>0&&k("trace","'".concat(l,"' transferred ").concat(d.length," objects to worker thread")));}}));},f.getMessages=function(){return y},f.getMessageId=function(){return g}),i.is_worker&&(f.postMessage=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i={};"object"===o(e)&&(i=e,e=e.method);var a,s=new Promise((function(t,n){y[g]={method:e,message:r,resolve:t,reject:n};})),l=[];return r&&1===r.length&&r[0]instanceof f.withTransferables&&(l=r[0].transferables,r=r[0].value),a={type:"worker_send",message_id:g,method:e,message:r},i.stringify&&(a=JSON.stringify(a)),self.postMessage(a,l.map((function(e){return e.object}))),A(l),l.length>0&&k("trace","'".concat(e,"' transferred ").concat(l.length," objects to main thread")),g++,s},self.addEventListener("message",(function(e){var t="string"==typeof e.data?JSON.parse(e.data):e.data,r=t.message_id;if("main_reply"===t.type)y[r]&&(t.error?y[r].reject(t.error):y[r].resolve(t.message),delete y[r]);else if("main_send"===t.type&&null!=r){var i,o,a,s,l;try{var u=n(x(t.method),2);if(s=u[0],!(a=u[1]))throw Error("Worker broker could not dispatch message type ".concat(t.method," on target ").concat(t.target," because no object with that name is registered on main thread"));if(!(l="function"==typeof a[s]&&a[s]))throw Error("Worker broker could not dispatch message type ".concat(t.method," because worker has no method with that name"));i=l.apply(a,t.message);}catch(e){o=e;}var c,h=[];i instanceof Promise?i.then((function(e){e instanceof f.withTransferables&&(h=e.transferables,e=e.value[0]),c={type:"worker_reply",message_id:r,message:e},self.postMessage(c,h.map((function(e){return e.object}))),A(h),h.length>0&&k("trace","'".concat(s,"' transferred ").concat(h.length," objects to main thread"));}),(function(e){self.postMessage({type:"worker_reply",message_id:r,error:e instanceof Error?"".concat(e.message,": ").concat(e.stack):e});})):(i instanceof f.withTransferables&&(h=i.transferables,i=i.value[0]),c={type:"worker_reply",message_id:r,message:i,error:o instanceof Error?"".concat(o.message,": ").concat(o.stack):o},self.postMessage(c,h.map((function(e){return e.object}))),A(h),h.length>0&&k("trace","'".concat(s,"' transferred ").concat(h.length," objects to main thread")));}})));var T={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},w={},E={};function k(e){var t="object"===o(e)?e.level:e;if(T[t]<=T[k.level]){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];if(i.is_worker)return v.postMessage.apply(v,[{method:"_logProxy",stringify:!0},e].concat(n));if("object"===o(e)&&!0===e.once){if(E[JSON.stringify(n)])return Promise.resolve(!1);E[JSON.stringify(n)]=!0;}var s=function(e){if(i.is_main)return w[e]=w[e]||(console[e]?console[e]:console.log).bind(console),w[e]}(t);return n.length>1?s.apply(void 0,["Tangram ".concat(d," [").concat(t,"]: ").concat(n[0])].concat(l(n.slice(1)))):s("Tangram ".concat(d," [").concat(t,"]: ").concat(n[0])),Promise.resolve(!0)}return Promise.resolve(!1)}k.level="info",k.workers=null,k.setLevel=function(e){k.level=e,i.is_main&&Array.isArray(k.workers)&&v.postMessage(k.workers,"_logSetLevelProxy",e);},i.is_main&&(k.setWorkers=function(e){k.workers=e;},k.reset=function(){E={};}),v.addTarget("_logProxy",k),v.addTarget("_logSetLevelProxy",k.setLevel);var R,M={};v.addTarget("Utils",M),M.isSafari=function(){return /^((?!chrome|android).)*safari/i.test(navigator.userAgent)},M.isMicrosoft=function(){return /(Trident\/7.0|Edge[ /](\d+[.\d]+))/i.test(navigator.userAgent)},M._requests={},M._proxy_requests={},M.io=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6e4,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"text",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"GET",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(i.is_worker&&M.isMicrosoft())return k("debug","Proxying request for URL to worker",e),s&&(M._proxy_requests[s]=!0),v.postMessage("Utils.io",e,t,r,n,a,s,!0);var u=new XMLHttpRequest,c=new Promise((function(i,s){if(u.open(n,e,!0),u.timeout=t,u.responseType=r,a&&"object"===o(a))for(var l in a)u.setRequestHeader(l,a[l]);u.onload=function(){200===u.status?["text","json"].indexOf(u.responseType)>-1?i({body:u.responseText,status:u.status}):i({body:u.response,status:u.status}):204===u.status?i({body:null,status:u.status}):s(Error("Request error with a status of "+u.statusText));},u.onerror=function(e){s(Error("There was a network error"+e.toString()));},u.ontimeout=function(e){s(Error("timeout "+e.toString()));},u.send();}));return c=c.then((function(e){return s&&delete M._requests[s],l?v.withTransferables(e):e})),s&&(M._requests[s]=u),c},M.cancelRequest=function(e){if(i.is_worker&&M._proxy_requests[e])return v.postMessage("Utils.cancelRequest",e);M._requests[e]?(k("trace","Cancelling network request key '".concat(e,"'")),M._requests[e].abort(),delete M._requests[e]):k("trace","Could not find network request key '".concat(e,"'"));},M.serializeWithFunctions=function(e){return "function"==typeof e?e.toString():JSON.stringify(e,(function(e,t){return "function"==typeof t?t.toString():t}))},M.use_high_density_display=!0,M.updateDevicePixelRatio=function(){var e=M.device_pixel_ratio;return M.device_pixel_ratio=M.use_high_density_display&&window.devicePixelRatio||1,M.device_pixel_ratio!==e},i.is_main&&M.updateDevicePixelRatio(),M.isPowerOf2=function(e){return !(e&e-1)},M.interpolate=function(e,t,r){if(!Array.isArray(t)||!Array.isArray(t[0]))return t;if(t.length<1)return t;var n,i,o,a,s;if(e<=t[0][0])a=t[0][1],"function"==typeof r&&(a=r(a));else if(e>=t[t.length-1][0])a=t[t.length-1][1],"function"==typeof r&&(a=r(a));else for(var l=0;l<t.length-1;l++)if(e>=t[l][0]&&e<t[l+1][0]){if(n=t[l][0],i=t[l+1][0],Array.isArray(t[l][1])){a=[];for(var u=0;u<t[l][1].length;u++)"function"==typeof r?(s=r(t[l][1][u]),o=r(t[l+1][1][u])-s,a[u]=o*(e-n)/(i-n)+s):(o=t[l+1][1][u]-t[l][1][u],a[u]=o*(e-n)/(i-n)+t[l][1][u]);}else "function"==typeof r?(s=r(t[l][1]),a=(o=r(t[l+1][1])-s)*(e-n)/(i-n)+s):a=(o=t[l+1][1]-t[l][1])*(e-n)/(i-n)+t[l][1];break}return a},M.toCSSColor=function(e){if(null!=e)return 1===e[3]?"rgb(".concat(e.slice(0,3).map((function(e){return Math.round(255*e)})).join(", "),")"):"rgba(".concat(e.map((function(e,t){return t<3&&Math.round(255*e)||e})).join(", "),")")};var z,P=R={draw_label_collision_boxes:!1,draw_label_texture_boxes:!1,suppress_label_fade_in:!1,suppress_label_snap_animation:!1,show_hidden_labels:!1,layer_stats:!1,wireframe:!1};function S(e){if("string"==typeof e&&-1===e.search(/^(data|blob):/)){var t=e.indexOf("?");t>-1&&(e=e.substr(0,t));var r=e.indexOf("#");return r>-1&&(e=e.substr(0,r)),e.substr(0,e.lastIndexOf("/")+1)||""}return ""}function N(e){if("string"==typeof e)return !(e.search(/^(http|https|data|blob):/)>-1||"//"===e.substr(0,2))}function O(e,t){e=e.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===r?"":decodeURIComponent(r[1].replace(/\+/g," "))}var L={id:0,queue:[],max_time:20,start_time:null,state:{},add:function(e){e.id=L.id++,e.max_time=e.max_time||L.max_time,e.pause_factor=e.pause_factor||1;var t=new Promise((function(t,r){e.resolve=t,e.reject=r;}));return e.promise=t,e.elapsed=0,e.total_elapsed=0,e.stats={calls:0},this.queue.push(e),this.start_time=this.start_time||performance.now(),this.elapsed=performance.now()-this.start_time,(this.elapsed<L.max_time||e.immediate)&&this.process(e),e.promise},remove:function(e){var t=this.queue.indexOf(e);t>-1&&this.queue.splice(t,1);},process:function(e){if(!this.state.user_moving_view||!1!==e.user_moving_view)return e.pause?(e.pause--,!0):(e.stats.calls++,e.start_time=performance.now(),e.run(e))},processAll:function(){this.start_time=this.start_time||performance.now();for(var e=0;e<this.queue.length;e++){var t=this.queue[e];if(!0!==this.process(t)&&(t.pause||(t.pause=t.elapsed>t.max_time?t.pause_factor:0),t.total_elapsed+=t.elapsed),this.elapsed=performance.now()-this.start_time,this.elapsed>=L.max_time){this.start_time=null;break}}},finish:function(e,t){return e.elapsed=performance.now()-e.start_time,e.total_elapsed+=e.elapsed,this.remove(e),e.resolve(t),e.promise},cancel:function(e){var t;e.cancel instanceof Function&&(t=e.cancel(e)),e.resolve(t);},shouldContinue:function(e){return e.elapsed=performance.now()-e.start_time,this.elapsed=performance.now()-this.start_time,e.elapsed<e.max_time&&this.elapsed<L.max_time},removeForTile:function(e){for(var t=this.queue.length-1;t>=0;t--)this.queue[t].tile_id===e&&(this.cancel(this.queue[t]),this.queue.splice(t,1));},setState:function(e){this.state=e;}};function I(e){var t=[];return Object.assign(e,{subscribe:function(e){-1===t.indexOf(e)&&t.push(e);},unsubscribe:function(e){var r=t.indexOf(e);r>-1&&t.splice(r,1);},unsubscribeAll:function(){t=[];},trigger:function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];t.forEach((function(t){if("function"==typeof t[e])try{t[e].apply(t,n);}catch(t){k("warn","Caught exception in listener for event '".concat(e,"':"),t);}}));},hasSubscribersFor:function(e){var r=!1;return t.forEach((function(t){"function"==typeof t[e]&&(r=!0);})),r}})}function F(e,t){var r={};return t.forEach((function(t){return r[t]=e[t]})),r}var D=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,e),n=e.sliceOptions(n),this.gl=t,this.texture=t.createTexture(),this.texture&&(this.valid=!0),this.bind(),this.name=r,this.retain_count=0,this.config_type=null,this.loading=null,this.loaded=!1,this.filtering=n.filtering,this.density=n.density||1,this.sprites=n.sprites,this.texcoords={},this.sizes={},this.css_sizes={},this.aspects={},this.setData(1,1,new Uint8Array([0,0,0,0]),{filtering:"nearest"}),this.loaded=!1,e.textures[this.name]&&(this.retain_count=e.textures[this.name].retain_count,e.textures[this.name].retain_count=0,e.textures[this.name].destroy()),e.textures[this.name]=this,e.texture_configs[this.name]=JSON.stringify(Object.assign({name:r},n)),this.load(n),k("trace","creating Texture ".concat(this.name));}return h(e,[{key:"destroy",value:function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).force;this.retain_count>0&&!t?k("error","Texture '".concat(this.name,"': destroying texture with retain count of '").concat(this.retain_count,"'")):this.valid&&(this.gl.deleteTexture(this.texture),this.texture=null,e.textures[this.name]===this&&(delete e.textures[this.name],delete e.texture_configs[this.name]),this.valid=!1,k("trace","destroying Texture ".concat(this.name)));}},{key:"retain",value:function(){this.retain_count++;}},{key:"release",value:function(){this.retain_count<=0&&k("error","Texture '".concat(this.name,"': releasing texture with retain count of '").concat(this.retain_count,"'")),this.retain_count--,this.retain_count<=0&&this.destroy();}},{key:"bind",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.valid&&(e.activeUnit!==t&&(this.gl.activeTexture(this.gl.TEXTURE0+t),e.activeUnit=t,e.boundTexture=null),e.boundTexture!==this.texture&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),e.boundTexture=this.texture));}},{key:"load",value:function(e){var t=this;return e?(this.loading=null,"string"==typeof e.url?(this.config_type="url",this.setUrl(e.url,e)):e.element?(this.config_type="element",this.setElement(e.element,e)):e.data&&e.width&&e.height&&(this.config_type="data",this.setData(e.width,e.height,e.data,e)),this.loading=this.loading&&this.loading.then((function(){return t.calculateSprites(),t}))||Promise.resolve(this),this.loading):this.loading||Promise.resolve(this)}},{key:"setUrl",value:function(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.valid)return this.url=t,this.loading=new Promise((function(t){var i=new Image;i.onload=function(){try{if("data:"===r.url.slice(0,5)){var o=document.createElement("canvas"),a=o.getContext("2d");o.width=i.width,o.height=i.height,a.drawImage(i,0,0),r.setElement(o,n);}else r.setElement(i,n);}catch(t){r.loaded=!1,k("warn","Texture '".concat(r.name,"': failed to load url: '").concat(r.url,"'"),t,n),e.trigger("warning",{message:"Failed to load texture from ".concat(r.url),error:t,texture:n});}r.loaded=!0,t(r);},i.onerror=function(i){r.loaded=!1,k("warn","Texture '".concat(r.name,"': failed to load url: '").concat(r.url,"'"),i,n),e.trigger("warning",{message:"Failed to load texture from ".concat(r.url),error:i,texture:n}),t(r);},M.isSafari()&&"data:"===r.url.slice(0,5)||(i.crossOrigin="anonymous"),i.src=r.url;})),this.loading}},{key:"setData",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.width=e,this.height=t,Array.isArray(r)&&(r=new Uint8Array(r)),this.update(r,n),this.setFiltering(n),this.loaded=!0,this.loading=Promise.resolve(this),this.loading}},{key:"setElement",value:function(t,r){var n=t;if("string"==typeof t&&(t=document.querySelector(t)),t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement)this.update(t,r),this.setFiltering(r);else {this.loaded=!1;var i="the 'element' parameter (`element: ".concat(JSON.stringify(n),"`) must be a CSS ");i+="selector string, or a <canvas>, <image> or <video> object",k("warn","Texture '".concat(this.name,"': ").concat(i),r),e.trigger("warning",{message:"Failed to load texture because ".concat(i),texture:r});}return this.loaded=!0,this.loading=Promise.resolve(this),this.loading}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.valid&&(this.bind(),t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLImageElement&&t.complete?(this.width=t.width,this.height=t.height,this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1!==r.UNPACK_FLIP_Y_WEBGL),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t)):(this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,null),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,null),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.width,this.height,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t)),e.trigger("update",this));}},{key:"setFiltering",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.valid){t.filtering=t.filtering||"linear";var r=this.gl;this.bind(),M.isPowerOf2(this.width)&&M.isPowerOf2(this.height)?(this.power_of_2=!0,r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t.TEXTURE_WRAP_S||t.repeat&&r.REPEAT||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t.TEXTURE_WRAP_T||t.repeat&&r.REPEAT||r.CLAMP_TO_EDGE),"mipmap"===t.filtering?(this.filtering="mipmap",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.generateMipmap(r.TEXTURE_2D)):"linear"===t.filtering?(this.filtering="linear",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR)):"nearest"===t.filtering&&(this.filtering="nearest",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST))):(this.power_of_2=!1,r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),"nearest"===t.filtering?(this.filtering="nearest",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST)):(this.filtering="linear",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR))),e.trigger("update",this);}}},{key:"calculateSprites",value:function(){if(this.sprites)for(var t in this.sprites){var r=this.sprites[t];this.texcoords[t]=e.getTexcoordsForSprite([r[0],r[1]],[r[2],r[3]],[this.width,this.height]),this.sizes[t]=[r[2],r[3]],this.css_sizes[t]=[r[2]/this.density,r[3]/this.density],this.aspects[t]=r[2]/r[3];}}},{key:"byteSize",value:function(){return Math.round(this.width*this.height*4*("mipmap"==this.filtering?1.33:1))}}])}();D.create=function(e,t,r){return new D(e,t,r)},D.retain=function(e){D.textures[e]&&D.textures[e].retain();},D.release=function(e){D.textures[e]&&D.textures[e].release();},D.destroy=function(e){Object.keys(D.textures).forEach((function(t){var r=D.textures[t];r.gl===e&&r.destroy({force:!0});}));},D.getSpriteInfo=function(e,t){var r=D.textures[e];return r&&{size:r.sizes[t],css_size:r.css_sizes[t],aspect:r.aspects[t],texcoords:r.texcoords[t]}},D.getTexcoordsForSprite=function(e,t,r){var n=r[1]-e[1]-t[1];return [e[0]/r[0],n/r[1],(t[0]+e[0])/r[0],(t[1]+n)/r[1]]},D.createFromObject=function(e,t){var r=[];if(t)for(var n in t){var i=t[n];if(!i.skip_create&&D.changed(n,i)){var o=D.create(e,n,i);r.push(o.loading);}}return Promise.all(r)},D.default="__default",D.createDefault=function(e){return D.create(e,D.default)},D.sliceOptions=function(e){return {filtering:e.filtering,sprites:e.sprites,url:e.url,element:e.element,data:e.data,width:e.width,height:e.height,density:e.density,repeat:e.repeat,TEXTURE_WRAP_S:e.TEXTURE_WRAP_S,TEXTURE_WRAP_T:e.TEXTURE_WRAP_T,UNPACK_FLIP_Y_WEBGL:e.UNPACK_FLIP_Y_WEBGL,UNPACK_PREMULTIPLY_ALPHA_WEBGL:e.UNPACK_PREMULTIPLY_ALPHA_WEBGL}},D.changed=function(e,t){var r=D.textures[e];if(r){if("element"===r.config_type||null!=t.element)return !0;if(t=D.sliceOptions(t),D.texture_configs[e]===JSON.stringify(Object.assign({name:e},t)))return !1}return !0},D.getInfo=function(e){if(e||(e=Object.keys(D.textures)),Array.isArray(e))return Promise.all(e.map((function(e){return D.getInfo(e)})));var t=D.textures[e];return t?(t.loading||Promise.resolve(t)).then((function(){return {name:t.name,width:t.width,height:t.height,density:t.density,css_size:[t.width/t.density,t.height/t.density],aspect:t.width/t.height,sprites:t.sprites,texcoords:t.texcoords,sizes:t.sizes,css_sizes:t.css_sizes,aspects:t.aspects,filtering:t.filtering,power_of_2:t.power_of_2,valid:t.valid}})):Promise.resolve(null)},D.syncTexturesToWorker=function(e){return v.postMessage("Texture.getInfo",e).then((function(e){return e&&e.filter((function(e){return e})).forEach((function(e){return D.textures[e.name]=e})),D.textures}))},D.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)},D.textures={},D.texture_configs={},D.boundTexture=null,D.activeUnit=null,v.addTarget("Texture",D),I(D);var U,G,j={parseUniforms:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=0,i=Object.entries(e);r<i.length;r++){var o=n(i[r],2),a=o[0],s=o[1];if("number"==typeof s)t.push({type:"float",method:"1f",name:a,value:s,path:[a]});else if(Array.isArray(s)){if("number"==typeof s[0])s.length>=2&&s.length<=4?t.push({type:"vec"+s.length,method:s.length+"fv",name:a,value:s,path:[a]}):s.length>4&&t.push({type:"float[]",method:"1fv",name:a+"[0]",value:s,path:[a]});else if("string"==typeof s[0])for(var l=0;l<s.length;l++)t.push({type:"sampler2D",method:"1i",name:a+"["+l+"]",value:s[l],path:[a,l]});else if(Array.isArray(s[0])&&"number"==typeof s[0][0]&&s[0].length>=2&&s[0].length<=4)for(var u=0;u<s.length;u++)t.push({type:"vec"+s[0].length,method:s[0].length+"fv",name:a+"["+u+"]",value:s[u],path:[a,u]});}else "boolean"==typeof s?t.push({type:"bool",method:"1i",name:a,value:s,path:[a]}):"string"==typeof s&&t.push({type:"sampler2D",method:"1i",name:a,value:s,path:[a]});}return t},defineVariable:function(e,t){var r,n;if("number"==typeof t)r="float";else if(Array.isArray(t))"number"==typeof t[0]?t.length>=2&&t.length<=4?r="vec"+t.length:(r="float",n=t.length):"string"==typeof t[0]?(r="sampler2D",n=t.length):Array.isArray(t[0])&&"number"==typeof t[0][0]&&t[0].length>=2&&t[0].length<=4&&(r="vec"+t[0].length,n=t.length);else if("boolean"==typeof t)r="bool";else {if("string"!=typeof t)return;r="sampler2D";}var i="";return i+="".concat(r," ").concat(e),n&&(i+="[".concat(n,"]")),i+=";\n"},defineUniform:function(e,t){var r=j.defineVariable(e,t);if(r)return "uniform "+r},expandVec3:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(Array.isArray(e)){if(2!==e.length)return e;t=[].concat(l(e),[r]).map(parseFloat);}else t=[e,e,e].map(parseFloat);if(t&&t.every((function(e){return "number"==typeof e&&!isNaN(e)})))return t},expandVec4:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(Array.isArray(e)){if(3!==e.length)return e;t=[].concat(l(e),[r]).map(parseFloat);}else t=[e,e,e,r].map(parseFloat);if(t&&t.every((function(e){return "number"==typeof e&&!isNaN(e)})))return t}},C=[];function B(e,t){var r=C.filter((function(t){return t[0]===e}))[0];return (r=r&&r[1])||(C.push([e,{}]),r=C[C.length-1][1]),r[t]||(r[t]=e.getExtension(t)),r[t]}function V(e){var t,r,n=0;if(0===e.length)return n;for(t=0,r=e.length;t<r;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return n}function q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var X=(G||(G=1,U=function(e){e=String(e);for(var t,r=[];t=e.match(/ERROR\:([^\n]+)/);){e=e.slice(t.index+1);var n=(a=t[1].trim()).split(":"),i=n.slice(2).join(":").trim(),o=parseInt(n[0],10),a=parseInt(n[1],10);r.push({message:i,file:o,line:a});}return r}),U),H=q(X),W=/^\s*#pragma.*$/gm,Y=/\\\s*\n/gm,Z=function(){function e(t,r,n,i){u(this,e),i=i||{},this.gl=t,this.program=null,this.compiled=!1,this.compiling=!1,this.error=null,this.defines=Object.assign({},i.defines||{}),this.blocks=Object.assign({},i.blocks||{}),this.block_scopes=Object.assign({},i.block_scopes||{}),this.extensions=i.extensions||[],this.dependent_uniforms=i.uniforms,this.uniforms={},this.attribs={},this.vertex_source=r,this.fragment_source=n,this.id=e.id++,this.name=i.name;}return h(e,[{key:"destroy",value:function(){this.gl.useProgram(null),this.gl.deleteProgram(this.program),this.program=null,this.uniforms={},this.attribs={},this.compiled=!1;}},{key:"use",value:function(){this.compiled&&(e.current!==this&&this.gl.useProgram(this.program),e.current=this);}},{key:"compile",value:function(){var t=this;if(this.compiling)throw new Error("ShaderProgram.compile(): skipping for ".concat(this.id," (").concat(this.name,") because already compiling"));this.compiling=!0,this.compiled=!1,this.error=null,this.computed_vertex_source=this.vertex_source,this.computed_fragment_source=this.fragment_source;var r,n=this.checkExtensions(),i=this.buildDefineList(),o=this.buildShaderBlockList();for(var a in o){var s=o[a];if(s&&(!Array.isArray(s)||0!==s.length)){r=new RegExp("^\\s*#pragma\\s+tangram:\\s+"+a+"\\s*$","m");var l=this.computed_vertex_source.match(r),u=this.computed_fragment_source.match(r);if(null!=l||null!=u){var c="";s.forEach((function(e){var t="".concat(e.scope,", ").concat(e.key,", ").concat(e.num);c+="\n// tangram-block-start: ".concat(t,"\n"),c+=e.source,c+="\n// tangram-block-end: ".concat(t,"\n");})),null!=l&&(this.computed_vertex_source=this.computed_vertex_source.replace(r,c)),null!=u&&(this.computed_fragment_source=this.computed_fragment_source.replace(r,c)),i["TANGRAM_BLOCK_"+a.replace(/[\s-]+/g,"_").toUpperCase()]=!0;}}}this.computed_vertex_source=this.computed_vertex_source.replace(W,""),this.computed_fragment_source=this.computed_fragment_source.replace(W,""),this.ensureUniforms(this.dependent_uniforms);var h="",f=this.gl.getShaderPrecisionFormat(this.gl.FRAGMENT_SHADER,this.gl.HIGH_FLOAT);h=f&&f.precision>0?"precision highp float;\n":"precision mediump float;\n",i.TANGRAM_VERTEX_SHADER=!0,i.TANGRAM_FRAGMENT_SHADER=!1,this.computed_vertex_source=h+e.buildDefineString(i)+this.computed_vertex_source,i.TANGRAM_VERTEX_SHADER=!1,i.TANGRAM_FRAGMENT_SHADER=!0,this.computed_fragment_source=e.buildExtensionString(n)+h+e.buildDefineString(i)+this.computed_fragment_source,this.computed_vertex_source=this.computed_vertex_source.replace(Y,""),this.computed_fragment_source=this.computed_fragment_source.replace(Y,"");try{this.program=e.updateProgram(this.gl,this.program,this.computed_vertex_source,this.computed_fragment_source),this.compiled=!0,this.compiling=!1;}catch(e){throw this.program=null,this.compiled=!1,this.compiling=!1,this.error=e,this.error.vertex_shader_source=this.computed_vertex_source,this.error.fragment_shader_source=this.computed_fragment_source,"vertex"!==e.type&&"fragment"!==e.type||(this.shader_errors=e.errors,this.shader_errors.forEach((function(r){r.type=e.type,r.block=t.block(e.type,r.line),r.line=t.block(e.type,r.line);})),this.error.shader_errors=this.shader_errors),e}this.computed_vertex_source=null,this.computed_fragment_source=null,this.use(),this.refreshUniforms(),this.refreshAttributes();}},{key:"buildDefineList",value:function(){var t,r={};for(t in e.defines)r[t]=e.defines[t];for(t in this.defines)r[t]=this.defines[t];return r}},{key:"buildShaderBlockList",value:function(){var t,r={};for(t in e.blocks){var n;if(r[t]=[],Array.isArray(e.blocks[t]))(n=r[t]).push.apply(n,l(e.blocks[t].map((function(e,r){return {key:t,source:e,num:r,scope:"ShaderProgram"}}))));else r[t]=[{key:t,source:e.blocks[t],num:0,scope:"ShaderProgram"}];}for(t in this.blocks)if(r[t]=r[t]||[],Array.isArray(this.blocks[t]))for(var i=this.block_scopes&&this.block_scopes[t]||[],o=null,a=0,s=0;s<this.blocks[t].length;s++)i[s]!==o&&(o=i[s],a=0),r[t].push({key:t,source:this.blocks[t][s],num:a,scope:o||this.name}),a++;else r[t].push({key:t,source:this.blocks[t],num:0,scope:this.name});return r}},{key:"ensureUniforms",value:function(e){if(e){var t=Object.entries(e).map((function(e){var t=n(e,2),r=t[0],i=t[1];return j.defineUniform(r,i)})).filter((function(e){return e}));this.computed_vertex_source=t.join("\n")+this.computed_vertex_source,this.computed_fragment_source=t.join("\n")+this.computed_fragment_source;}}},{key:"setUniforms",value:function(e){var t=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.compiled&&(r&&(this.texture_unit=0),j.parseUniforms(e).forEach((function(e){var r=e.name,n=e.type,i=e.value,o=e.method;"sampler2D"===n?t.setTextureUniform(r,i):t.uniform(o,r,i);})));}},{key:"saveUniforms",value:function(e){var t=e||this.uniforms;for(var r in t){var n=this.uniforms[r];n&&(n.saved_value=n.value);}this.saved_texture_unit=this.texture_unit||0;}},{key:"restoreUniforms",value:function(e){var t=e||this.uniforms;for(var r in t){var n=this.uniforms[r];n&&n.saved_value&&(n.value=n.saved_value,this.updateUniform(n));}this.texture_unit=this.saved_texture_unit||0;}},{key:"setTextureUniform",value:function(e,t){var r=D.textures[t];null!=r?(r.bind(this.texture_unit),this.uniform("1i",e,this.texture_unit),this.texture_unit++):k("warn","Cannot find texture '".concat(t,"'"));}},{key:"uniform",value:function(e,t,r){if(this.compiled){this.uniforms[t]=this.uniforms[t]||{};var n=this.uniforms[t];n.name=t,void 0===n.location&&(n.location=this.gl.getUniformLocation(this.program,t)),n.method=e,n.value=r,this.updateUniform(n);}}},{key:"updateUniform",value:function(e){this.compiled&&e&&null!=e.location&&(this.use(),this.commitUniform(e));}},{key:"commitUniform",value:function(e){var t=e.location,r=e.value;switch(e.method){case"1i":this.gl.uniform1i(t,r);break;case"1f":this.gl.uniform1f(t,r);break;case"2f":this.gl.uniform2f(t,r[0],r[1]);break;case"3f":this.gl.uniform3f(t,r[0],r[1],r[2]);break;case"4f":this.gl.uniform4f(t,r[0],r[1],r[2],r[3]);break;case"1iv":this.gl.uniform1iv(t,r);break;case"3iv":this.gl.uniform3iv(t,r);break;case"1fv":this.gl.uniform1fv(t,r);break;case"2fv":this.gl.uniform2fv(t,r);break;case"3fv":this.gl.uniform3fv(t,r);break;case"4fv":this.gl.uniform4fv(t,r);break;case"Matrix3fv":this.gl.uniformMatrix3fv(t,!1,r);break;case"Matrix4fv":this.gl.uniformMatrix4fv(t,!1,r);}}},{key:"refreshUniforms",value:function(){if(this.compiled)for(var e in this.uniforms){var t=this.uniforms[e];t.location=this.gl.getUniformLocation(this.program,e),this.updateUniform(t);}}},{key:"refreshAttributes",value:function(){this.attribs={};}},{key:"attribute",value:function(e){if(this.compiled){var t=this.attribs[e]=this.attribs[e]||{};return null!=t.location||(t.name=e,t.location=this.gl.getAttribLocation(this.program,e)),t}}},{key:"source",value:function(e){return "vertex"===e?this.computed_vertex_source:"fragment"===e?this.computed_fragment_source:void 0}},{key:"lines",value:function(e){var t=this.source(e);return t?t.split("\n"):[]}},{key:"line",value:function(e,t){var r=this.lines(e);if(r)return r[t]}},{key:"block",value:function(e,t){for(var r,n=this.lines(e),i=0;i<t&&i<n.length;i++){var o=n[i],a=o.match(/\/\/ tangram-block-start: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/);a&&a.length>1?r={scope:a[1],name:a[2],num:a[3]}:(a=o.match(/\/\/ tangram-block-end: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/))&&a.length>1&&(r=null),r&&(r.line=null==r.line?-1:r.line+1,r.source=o);}return r}},{key:"checkExtensions",value:function(){var e=this,t=[];return this.extensions.forEach((function(r){var n=B(e.gl,r),i="TANGRAM_EXTENSION_".concat(r);e.defines[i]=null!=n,n?t.push(r):k("debug","Could not enable extension '".concat(r,"'"));})),t}}])}();Z.id=0,Z.current=null,Z.defines={},Z.blocks={},Z.reset=function(){Z.programs_by_source={},Z.shaders_by_source={};},Z.reset(),Z.buildDefineString=function(e){var t="";for(var r in e)null!=e[r]&&!1!==e[r]&&("boolean"==typeof e[r]&&!0===e[r]?t+="#define "+r+"\n":"number"==typeof e[r]&&Math.floor(e[r])===e[r]?t+="#define "+r+" "+e[r].toFixed(1)+"\n":t+="#define "+r+" "+e[r]+"\n");return t},Z.buildExtensionString=function(e){var t="";return (e=e||[]).forEach((function(e){t+="#ifdef GL_".concat(e,"\n#extension GL_").concat(e," : enable\n#endif\n");})),t},Z.addBlock=function(e){var t;Z.blocks[e]=Z.blocks[e]||[];for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];(t=Z.blocks[e]).push.apply(t,n);},Z.removeBlock=function(e){Z.blocks[e]=[];},Z.replaceBlock=function(e){Z.removeBlock(e);for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];Z.addBlock.apply(Z,[e].concat(r));},Z.updateProgram=function(e,t,r,n){var i=V(e._tangram_id+"::"+r+"::"+n);if(Z.programs_by_source[i])return k("trace","Reusing identical source GL program object"),Z.programs_by_source[i];var o=Z.createShader(e,r,e.VERTEX_SHADER),a=Z.createShader(e,n,e.FRAGMENT_SHADER);if(e.useProgram(null),null!=t)for(var s=e.getAttachedShaders(t),l=0;l<s.length;l++)e.detachShader(t,s[l]);else t=e.createProgram();if(null==o||null==a)return t;if(e.attachShader(t,o),e.attachShader(t,a),e.bindAttribLocation(t,0,"a_position"),e.linkProgram(t),!e.getProgramParameter(t,e.LINK_STATUS)){var u=new Error("WebGL program error:\n            VALIDATE_STATUS: ".concat(e.getProgramParameter(t,e.VALIDATE_STATUS),"\n            ERROR: ").concat(e.getError(),"\n            --- Vertex Shader ---\n            ").concat(r,"\n            --- Fragment Shader ---\n            ").concat(n));throw Object.assign(new Error(u),{type:"program"})}return Z.programs_by_source[i]=t,t},Z.createShader=function(e,t,r){var n=V(e._tangram_id+"::"+t);if(Z.shaders_by_source[n])return k("trace","Reusing identical source GL shader object"),Z.shaders_by_source[n];var i=e.createShader(r);if(e.shaderSource(i,t),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){var o=r===e.VERTEX_SHADER?"vertex":"fragment",a=e.getShaderInfoLog(i),s=H(a);throw Object.assign(new Error(a),{type:o,errors:s})}return Z.shaders_by_source[n]=i,i};var J,K={disabled:!1,bound_vao:[],init:function(e){var t;!0!==this.disabled&&(t=B(e,"OES_vertex_array_object")),null!=t?k("info","Vertex Array Object extension available"):!0!==this.disabled?k("warn","Vertex Array Object extension NOT available"):k("warn","Vertex Array Object extension force disabled");},getExtension:function(e,t){if(!0!==this.disabled)return B(e,t)},create:function(e,t,r){var n={};n.setup=t,n.teardown=r;var i=this.getExtension(e,"OES_vertex_array_object");return null!=i&&(n._vao=i.createVertexArrayOES(),i.bindVertexArrayOES(n._vao)),n.setup(),n},getCurrentBinding:function(e){var t=this.bound_vao.filter((function(t){return t[0]===e}))[0];return t&&t[1]},setCurrentBinding:function(e,t){var r=this.bound_vao,n=r.filter((function(t){return t[0]===e}))[0];null==n?r.push([e,t]):n[1]=t;},bind:function(e,t){var r=this.getExtension(e,"OES_vertex_array_object");if(null!=t)null!=r&&null!=t._vao?(r.bindVertexArrayOES(t._vao),this.setCurrentBinding(e,t)):t.setup();else {var n=this.getCurrentBinding(e);null!=r?r.bindVertexArrayOES(null):null!=n&&"function"==typeof n.teardown&&n.teardown(),this.setCurrentBinding(e,null);}},destroy:function(e,t){var r=this.getExtension(e,"OES_vertex_array_object");null!=r&&null!=t&&null!=t._vao&&(r.deleteVertexArrayOES(t._vao),t._vao=null);}};function $(e){for(var t=0;t<(arguments.length<=1?0:arguments.length-1);t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];if(r)for(var n in r){var i=r[n];null===i||"object"!==o(i)||Array.isArray(i)?void 0!==i&&(e[n]=i):null===e[n]||"object"!==o(e[n])||Array.isArray(e[n])?e[n]=$({},i):e[n]=$(e[n],i);}}return e}var Q=J={};J.default_source_max_zoom=18,J.default_view_max_zoom=20,J.max_style_zoom=25,J.tile_size=256,J.half_circumference_meters=20037508.342789244,J.circumference_meters=2*J.half_circumference_meters,J.min_zoom_meters_per_pixel=J.circumference_meters/J.tile_size;var ee=[];J.metersPerPixel=function(e){return ee[e]=ee[e]||J.min_zoom_meters_per_pixel/Math.pow(2,e),ee[e]};var te=[];J.metersPerTile=function(e){return te[e]=te[e]||J.circumference_meters/Math.pow(2,e),te[e]},J.tile_scale=4096,J.units_per_pixel=J.tile_scale/J.tile_size,J.height_scale=16;var re=[];J.unitsPerMeter=function(e){return re[e]=re[e]||J.tile_scale/(J.tile_size*J.metersPerPixel(e)),re[e]},J.metersForTile=function(e){return {x:e.x*J.circumference_meters/Math.pow(2,e.z)-J.half_circumference_meters,y:-(e.y*J.circumference_meters/Math.pow(2,e.z)-J.half_circumference_meters)}},J.tileForMeters=function(e,t){var r=n(e,2),i=r[0],o=r[1];return {x:Math.floor((i+J.half_circumference_meters)/(J.circumference_meters/Math.pow(2,t))),y:Math.floor((-o+J.half_circumference_meters)/(J.circumference_meters/Math.pow(2,t))),z:t}},J.wrapTile=function(e){var t=e.x,r=e.y,n=e.z,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{x:!0,y:!1},o=(1<<n)-1;return i.x&&(t&=o),i.y&&(r&=o),{x:t,y:r,z:n}},J.metersToLatLng=function(e){return e[0]/=J.half_circumference_meters,e[1]/=J.half_circumference_meters,e[1]=(2*Math.atan(Math.exp(e[1]*Math.PI))-Math.PI/2)/Math.PI,e[0]*=180,e[1]*=180,e},J.latLngToMeters=function(e){return e[1]=Math.log(Math.tan(e[1]*Math.PI/360+Math.PI/4))/Math.PI,e[1]*=J.half_circumference_meters,e[0]*=J.half_circumference_meters/180,e},J.tileSpaceToLatlng=function(e,t,r){var n=J.unitsPerMeter(t);return J.transformGeometry(e,(function(e){e[0]=e[0]/n+r.x,e[1]=e[1]/n+r.y,J.metersToLatLng(e);})),e},J.copyGeometry=function(e){if(null!=e){var t={type:e.type};return "Point"===e.type?t.coordinates=[e.coordinates[0],e.coordinates[1]]:"LineString"===e.type||"MultiPoint"===e.type?t.coordinates=e.coordinates.map((function(e){return [e[0],e[1]]})):"Polygon"===e.type||"MultiLineString"===e.type?t.coordinates=e.coordinates.map((function(e){return e.map((function(e){return [e[0],e[1]]}))})):"MultiPolygon"===e.type&&(t.coordinates=e.coordinates.map((function(e){return e.map((function(e){return e.map((function(e){return [e[0],e[1]]}))}))}))),t}},J.transformGeometry=function(e,t){null!=e&&("Point"===e.type?t(e.coordinates):"LineString"===e.type||"MultiPoint"===e.type?e.coordinates.forEach(t):"Polygon"===e.type||"MultiLineString"===e.type?e.coordinates.forEach((function(e){return e.forEach(t)})):"MultiPolygon"===e.type&&e.coordinates.forEach((function(e){e.forEach((function(e){return e.forEach(t)}));})));},J.boxIntersect=function(e,t){return !(t.sw.x>e.ne.x||t.ne.x<e.sw.x||t.sw.y>e.ne.y||t.ne.y<e.sw.y)},J.findBoundingBox=function(e){for(var t=1/0,r=-1/0,n=1/0,i=-1/0,o=e[0].length,a=0;a<o;a++){var s=e[0][a];s[0]<t&&(t=s[0]),s[1]<n&&(n=s[1]),s[0]>r&&(r=s[0]),s[1]>i&&(i=s[1]);}return [t,n,r,i]},J.geometryType=function(e){return "Polygon"===e||"MultiPolygon"===e?"polygon":"LineString"===e||"MultiLineString"===e?"line":"Point"===e||"MultiPoint"===e?"point":void 0},J.centroid=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e&&0!==e.length){var r,n=0,i=0,o=0,a=e[0],s=a.length;t&&(r=a[0],a=a.map((function(e){return [e[0]-r[0],e[1]-r[1]]})));for(var l=0,u=s-1;l<s;u=l,l++){var c=a[l],h=a[u],f=c[1]*h[0]-h[1]*c[0];n+=(c[0]+h[0])*f,i+=(c[1]+h[1])*f,o+=3*f;}if(o){var d=[n/o,i/o];return t&&(d[0]+=r[0],d[1]+=r[1]),d}}},J.multiCentroid=function(e){for(var t=0,r=null,n=0;n<e.length;n++){var i=J.centroid(e[n]);i&&((r=r||[0,0])[0]+=i[0],r[1]+=i[1],t++);}return t>0&&(r[0]/=t,r[1]/=t),r},J.signedPolygonRingAreaSum=function(e){for(var t=0,r=e.length,n=0;n<r-1;n++){var i=e[n],o=e[n+1];t+=i[0]*o[1]-o[0]*i[1];}return t+=e[r-1][0]*e[0][1]-e[0][0]*e[r-1][1]},J.polygonRingArea=function(e){return Math.abs(J.signedPolygonRingAreaSum(e))/2},J.polygonArea=function(e){if(e)return J.polygonRingArea(e[0])},J.multiPolygonArea=function(e){for(var t=0,r=0;r<e.length;r++)t+=J.polygonArea(e[r]);return t},J.ringWinding=function(e){var t=J.signedPolygonRingAreaSum(e);return t>0?"CW":t<0?"CCW":void 0};var ne={functions:{},num_functions:0,num_cached:0};function ie(e,t){if("string"==typeof e)e=oe(e,t);else if(null!=e&&"object"===o(e))for(var r in e)e[r]=ie(e[r],t);return e}function oe(e,t){var r="string"==typeof e&&e.match(/^\s*function[^(]*\(([^)]*)\)\s*?\{([\s\S]*)\}$/m);if(r&&r.length>2)try{var n=r[2],i="function"==typeof t?t(n):n,o=V(i);if(void 0===ne.functions[o]){var a=r[1].length>0&&r[1].split(",").map((function(e){return e.trim()})).filter((function(e){return e}));a=a.length>0?a:["context"],ne.functions[o]=new Function(a.toString(),i),ne.functions[o].source=n,ne.num_functions++;}else ne.num_cached++;return ne.functions[o]}catch(t){return e}return e}var ae,se={};var le=q(function(){if(ae)return se;ae=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return (e=Math.round(e))<0?0:e>255?255:e}function r(e){return e<0?0:e>1?1:e}function n(e){return "%"===e[e.length-1]?t(parseFloat(e)/100*255):t(parseInt(e))}function i(e){return "%"===e[e.length-1]?r(parseFloat(e)/100):r(parseFloat(e))}function o(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}try{se.parseCSSColor=function(r){var a,s=r.replace(/ /g,"").toLowerCase();if(s in e)return e[s].slice();if("#"===s[0])return 4===s.length?(a=parseInt(s.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===s.length&&(a=parseInt(s.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var l=s.indexOf("("),u=s.indexOf(")");if(-1!==l&&u+1===s.length){var c=s.substr(0,l),h=s.substr(l+1,u-(l+1)).split(","),f=1;switch(c){case"rgba":if(4!==h.length)return null;f=i(h.pop());case"rgb":return 3!==h.length?null:[n(h[0]),n(h[1]),n(h[2]),f];case"hsla":if(4!==h.length)return null;f=i(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,_=i(h[1]),p=i(h[2]),m=p<=.5?p*(_+1):p+_-p*_,v=2*p-m;return [t(255*o(v,m,d+1/3)),t(255*o(v,m,d)),t(255*o(v,m,d-1/3)),f];default:return null}}return null};}catch(e){}return se}()),ue={},ce=function(e){return Math.max(e,0)},he=function(e){return isNaN(e)?0:e},fe=function(e){return Array.isArray(e)?e.map(parseFloat).map(he):he(parseFloat(e))},de=function(e){return Array.isArray(e)?e.map(fe).map(ce):ce(fe(e))};Object.assign(ue,{clampPositive:ce,noNaN:he,parseNumber:fe,parsePositiveNumber:de}),ue.wrapFunction=function(e){return "\n        var feature = context.feature.properties;\n        var global = context.global;\n        var $zoom = context.zoom;\n        var $layer = context.layer;\n        var $source = context.source;\n        var $geometry = context.geometry;\n        var $meters_per_pixel = context.meters_per_pixel;\n        var $id = context.id;\n\n        var val = (function(){ ".concat(e," }());\n\n        if (typeof val === 'number' && isNaN(val)) {\n            val = null; // convert NaNs to nulls\n        }\n\n        return val;\n    ")},ue.zeroPair=Object.freeze([0,0]),ue.defaults={color:[1,1,1,1],width:1,size:1,extrude:!1,height:20,min_height:0,order:0,z:0,outline:{color:[0,0,0,0],width:0},material:{ambient:1,diffuse:1}},ue.macros={"Style.color.pseudoRandomColor":function(){return [parseInt(feature.id,16)/100%1*.7,parseInt(feature.id,16)/1e4%1*.7,parseInt(feature.id,16)/1e6%1*.7,1]},"Style.color.randomColor":function(){return [.7*Math.random(),.7*Math.random(),.7*Math.random(),1]}},ue.getFeatureParseContext=function(e,t,r){return {feature:e,id:e.id,tile:t,global:r,zoom:t.style_z,geometry:Q.geometryType(e.geometry.type),meters_per_pixel:t.meters_per_pixel,meters_per_pixel_sq:t.meters_per_pixel_sq,units_per_meter_overzoom:t.units_per_meter_overzoom}};var _e={STATIC:0,DYNAMIC:1,ZOOM:2};ue.CACHE_TYPE=_e,ue.createPropertyCache=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null!=e){if(e.value)return {value:e.value,zoom:e.zoom?{}:null,type:e.type};var n={value:e,type:_e.STATIC};return Array.isArray(n.value)&&Array.isArray(n.value[0])?(n.zoom={},n.type=_e.ZOOM):"function"==typeof n.value&&(n.type=_e.DYNAMIC,n.dynamic_transform="function"==typeof r?r:null),"function"==typeof t&&(n.zoom?n.value=n.value.map((function(e,r){return [e[0],t(e[1],r)]})):"function"!=typeof n.value&&(n.value=t(n.value,0))),n}},ue.createColorPropertyCache=function(e){return ue.createPropertyCache(e,(function(e){return "Style.color.pseudoRandomColor"===e?oe(ue.wrapFunction(ue.macros["Style.color.pseudoRandomColor"])):"Style.color.randomColor"===e?ue.macros["Style.color.randomColor"]:e}))};var pe=function(e){return "string"==typeof e&&"%"===e[e.length-1]},me=function(e){return "auto"===e},ve=function(e){return pe(e)||me(e)},ge="'size' can specify either width or height as derived from aspect ratio, but not both";function ye(e,t){return ue.createPropertyCache(e.value,(function(r,n){return Array.isArray(r)?(r=r.map((function(t,r){return e.has_ratio[n][r]?t:de(t)})).map((function(r,i){return e.has_pct[n][i]?t.css_size[i]*r/100:r})),e.has_ratio[n][0]?r[0]=r[1]*t.aspect:e.has_ratio[n][1]&&(r[1]=r[0]/t.aspect)):(r=de(r),r=e.has_pct[n]?t.css_size.map((function(e){return e*r/100})):[r,r]),r}))}function xe(e,t){try{return e(t)}catch(r){k("warn","Property function in layer '".concat(t.layers[t.layers.length-1],"' failed with\n"),"error ".concat(r.stack,"\n"),"function '".concat(e.source,"'\n"),t.feature,t);}}ue.createPointSizePropertyCache=function(e,t){var r=null,n=null;if(pe(e))r=[!0];else if(Array.isArray(e)){if(Array.isArray(e[0])){if(e.some((function(e){return Array.isArray(e[1])?e[1].some((function(e){return ve(e)})):pe(e[1])}))&&(r=e.map((function(e){return Array.isArray(e[1])?e[1].map((function(e){return pe(e)})):pe(e[1])})),(n=e.map((function(e){return Array.isArray(e[1])&&e[1].map((function(e){return me(e)}))}))).some((function(e){return Array.isArray(e)&&e.every((function(e){return e}))}))))throw ge}else if(e.some(ve)&&(r=[e.map(pe)],(n=[e.map(me)])[0].every((function(e){return e}))))throw ge}else if(me(e))throw "this value only allowed as half of an array, eg [16px, auto]:";if(r||n){if(!t)throw "% or 'auto' keywords can only be used to specify point size when a texture is defined";(e={value:e}).has_pct=r,e.has_ratio=n,e.sprites={};}else e=ue.createPropertyCache(e,de);return e},ue.evalCachedPointSizeProperty=function(e,t,r,n){if(null!=e)return e.has_pct||e.has_ratio?t?(e.sprites[t.sprite]||(e.sprites[t.sprite]=ye(e,t)),ue.evalCachedProperty(e.sprites[t.sprite],n)):(e.texture=e.texture||ye(e,r),ue.evalCachedProperty(e.texture,n)):ue.evalCachedProperty(e,n)},ue.evalCachedProperty=function(e,t){return null==e?void 0:e.dynamic?xe(e.dynamic,t):e.static?e.static:e.zoom&&e.zoom[t.zoom]?e.zoom[t.zoom]:"function"==typeof e.value?(e.dynamic_transform?e.dynamic=function(t){return e.dynamic_transform(e.value(t))}:e.dynamic=e.value,xe(e.dynamic,t)):Array.isArray(e.value)&&Array.isArray(e.value[0])?(e.zoom=e.zoom||{},e.zoom[t.zoom]=M.interpolate(t.zoom,e.value),e.zoom[t.zoom]):(e.static=e.value,e.static)},ue.convertUnits=function(e,t){if(null!=e.value)return "px"===e.units?e.value*Q.metersPerPixel(t.zoom):e.value;if("string"==typeof e)"px"===e.trim().slice(-2)?(e=fe(e),e*=Q.metersPerPixel(t.zoom)):e=fe(e);else if(Array.isArray(e))return Array.isArray(e[0])?e.map((function(e){return [e[0],ue.convertUnits(e[1],t)]})):e.map((function(e){return ue.convertUnits(e,t)}));return e},ue.parseUnits=function(e){var t={value:fe(e)};return 0!==t.value&&"string"==typeof e&&"px"===e.trim().slice(-2)&&(t.units="px"),t},ue.evalCachedDistanceProperty=function(e,t){return null==e?void 0:e.dynamic?xe(e.dynamic,t):e.zoom&&e.zoom[t.zoom]?e.zoom[t.zoom]:"function"==typeof e.value?(e.dynamic=e.value,xe(e.dynamic,t)):e.zoom?(e.zoom[t.zoom]=M.interpolate(t.zoom,e.value,(function(e){return ue.convertUnits(e,t)})),e.zoom[t.zoom]):ue.convertUnits(e.value,t)},ue.string_colors={},ue.colorForString=function(e){if(ue.string_colors[e])return ue.string_colors[e];var t=le.parseCSSColor(e);return t&&4===t.length?(t[0]/=255,t[1]/=255,t[2]/=255):t=ue.defaults.color,ue.string_colors[e]=t,t},ue.evalCachedColorProperty=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=e){if(e.dynamic){var r=xe(e.dynamic,t);return "string"==typeof r&&(r=ue.colorForString(r)),r&&null==r[3]&&(r[3]=1),r}if(e.static)return e.static;if(e.zoom&&e.zoom[t.zoom])return e.zoom[t.zoom];if("function"==typeof e.value){e.dynamic=e.value;var n=xe(e.dynamic,t);return "string"==typeof n&&(n=ue.colorForString(n)),n&&null==n[3]&&(n[3]=1),n}if("string"==typeof e.value)return e.static=ue.colorForString(e.value),e.static;if(e.zoom){if(!e.zoom_preprocessed){for(var i=0;i<e.value.length;i++){var o=e.value[i];o&&"string"==typeof o[1]&&(o[1]=ue.colorForString(o[1]));}e.zoom_preprocessed=!0;}return e.zoom[t.zoom]=M.interpolate(t.zoom,e.value),e.zoom[t.zoom][3]=e.zoom[t.zoom][3]||1,e.zoom[t.zoom]}return e.static=e.value.map((function(e){return e})),e.static&&null==e.static[3]&&(e.static[3]=1),e.static}},ue.evalCachedColorPropertyWithAlpha=function(e,t,r){var n=ue.evalCachedColorProperty(e,r);if(null!=n&&null!=t){var i=ue.evalCachedProperty(t,r);if(null!=i)return [n[0],n[1],n[2],i]}return n},ue.parseColor=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("function"==typeof e&&(e=xe(e,t)),"string"==typeof e)e=ue.colorForString(e);else if(Array.isArray(e)&&Array.isArray(e[0])){for(var r=0;r<e.length;r++){var n=e[r];"string"==typeof n[1]&&(n[1]=ue.colorForString(n[1]));}t.zoom&&(e=M.interpolate(t.zoom,e));}return Array.isArray(e)?null==(e=e.map((function(e){return e})))[3]&&(e[3]=1):e=[0,0,0,1],e},ue.calculateOrder=function(e,t){return "function"==typeof e?e=xe(e,t):"string"==typeof e&&(e=t.feature.properties[e]?t.feature.properties[e]:de(e)),e},ue.evalProperty=function(e,t){return "function"==typeof e?xe(e,t):e};var be,Ae=function(){function e(t,r,n){u(this,e),this.gl=t,this.workers=r,this._lock_fn="function"==typeof n&&n,this.init();}return h(e,[{key:"init",value:function(){this.requests={},this.feature=null,this.read_delay=0,this.read_delay_timer=null,this.pixels=null,this.fbo=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),this.fbo_size={width:256,height:256};var e=D.create(this.gl,"__selection_fbo",{filtering:"nearest"});e.setData(this.fbo_size.width,this.fbo_size.height,null,{filtering:"nearest"}),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e.texture,0);var t=this.gl.createRenderbuffer();this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,t),this.gl.renderbufferStorage(this.gl.RENDERBUFFER,this.gl.DEPTH_COMPONENT16,this.fbo_size.width,this.fbo_size.height),this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER,this.gl.DEPTH_ATTACHMENT,this.gl.RENDERBUFFER,t),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null);}},{key:"destroy",value:function(){this.gl&&this.fbo&&(this.gl.deleteFramebuffer(this.fbo),this.fbo=null,this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null));}},{key:"locked",get:function(){return this._lock_fn&&this._lock_fn()||!1}},{key:"bind",value:function(){var t;this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),this.gl.viewport(0,0,this.fbo_size.width,this.fbo_size.height),(t=this.gl).clearColor.apply(t,l(e.defaultColor));}},{key:"getFeatureAt",value:function(e,t){var r=this,n=t.radius;return !e||e.x<0||e.y<0||e.x>1||e.y>1?Promise.resolve({feature:null,changed:!1}):new Promise((function(t,i){r.selection_request_id=r.selection_request_id+1||0,r.requests[r.selection_request_id]={id:r.selection_request_id,point:e,radius:n,resolve:t,reject:i};}))}},{key:"pendingRequests",value:function(){return Object.keys(this.requests).length?this.requests:null}},{key:"hasPendingRequests",value:function(){return null!=this.pendingRequests()}},{key:"clearPendingRequests",value:function(){for(var e in this.requests){var t=this.requests[e];t.sent||(t.reject({request:t}),delete this.requests[e]);}}},{key:"read",value:function(){var e=this;null!=this.read_delay_timer&&clearTimeout(this.read_delay_timer),this.read_delay_timer=setTimeout((function(){if(!e.locked){var t=e.gl;for(var r in t.bindFramebuffer(t.FRAMEBUFFER,e.fbo),e.requests){var n=e.requests[r];if(!n.sent){var i=void 0,o=255,a=n,s=a.point,l=a.radius,u=void 0;if(l){var c=Math.min(e.fbo_size.width,e.fbo_size.height);u={x:Math.min(Math.ceil(2*l.x*e.fbo_size.width),c),y:Math.min(Math.ceil(2*l.y*e.fbo_size.height),c)};}else l={x:0,y:0},u={x:1,y:1};if((null==e.pixels||e.pixels.byteLength<u.x*u.y*4)&&(e.pixels=new Uint8Array(u.x*u.y*4)),e.pixels.fill instanceof Function)e.pixels.fill(0);else for(var h=0;h<e.pixels.length;h++)e.pixels[h]=0;t.readPixels(Math.round((s.x-l.x)*e.fbo_size.width),Math.round((1-s.y-l.y)*e.fbo_size.height),u.x,u.y,t.RGBA,t.UNSIGNED_BYTE,e.pixels);var f=4*(Math.round(u.y/2)*u.x+Math.round(u.x/2)),d=e.pixels[f]+(e.pixels[f+1]<<8)+(e.pixels[f+2]<<16);if(d>0)i=d+(e.pixels[f+3]<<24)>>>0,o=e.pixels[f+3];else {var _=-1>>>0;f=0;for(var p=0;p<u.y;p++)for(var m=0;m<u.x;m++,f+=4)if((d=e.pixels[f]+(e.pixels[f+1]<<8)+(e.pixels[f+2]<<16))>0){var g=(m-u.x/2)*(m-u.x/2)+(p-u.y/2)*(p-u.y/2);g<=_&&(i=d+(e.pixels[f+3]<<24)>>>0,o=e.pixels[f+3],_=g);}}255!==o?null!=e.workers[o]&&v.postMessage(e.workers[o],"self.getFeatureSelection",{id:n.id,key:i}).then((function(t){e.finishRead(t);})):e.finishRead({id:n.id}),n.sent=!0;}}t.bindFramebuffer(t.FRAMEBUFFER,null);}}),this.read_delay);}},{key:"finishRead",value:function(e){var t=this.requests[e.id];if(t){var r=e.feature,n=!1;(null!=r&&null==this.feature||null==r&&null!=this.feature||null!=r&&null!=this.feature&&JSON.stringify(r)!==JSON.stringify(this.feature))&&(n=!0),this.feature=r,t.resolve({feature:r,changed:n,request:t}),delete this.requests[e.id];}else k("error","FeatureSelection.finishRead(): could not find message",e);}}],[{key:"makeEntry",value:function(e){this.map_entry++;var t=255&this.map_entry,r=this.map_entry>>8&255,n=this.map_entry>>16&255,i=this.map_prefix,o=t/255,a=r/255,s=n/255,l=i/255,u=t+(r<<8)+(n<<16)+(i<<24)>>>0;return this.map[u]={color:[o,a,s,l]},this.map_size++,this.tiles[e.key]||(this.tiles[e.key]={entries:[],tile:{key:e.key,coords:e.coords,style_z:e.style_z,source:e.source,generation:e.generation}}),this.tiles[e.key].entries.push(u),this.map[u]}},{key:"makeColor",value:function(e,t,r){var n=this.makeEntry(t);return n.feature={id:e.id,properties:e.properties,source_name:r.source,source_layer:r.layer,layers:r.layers,tile:this.tiles[t.key].tile},n.color}},{key:"reset",value:function(e){var t=this;Array.isArray(e)?e.forEach((function(e){return t.clearSource(e)})):(this.tiles={},this.map={},this.map_size=0,this.map_entry=0);}},{key:"clearSource",value:function(e){for(var t in this.tiles)this.tiles[t].tile.source===e&&this.clearTile(t);}},{key:"clearTile",value:function(e){var t=this;this.tiles[e]&&(this.tiles[e].entries.forEach((function(e){return delete t.map[e]})),this.map_size-=this.tiles[e].entries.length,delete this.tiles[e]);}},{key:"getMapSize",value:function(){return this.map_size}},{key:"setPrefix",value:function(e){this.map_prefix=e;}}])}();Ae.map={},Ae.tiles={},Ae.map_size=0,Ae.map_entry=0,Ae.map_prefix=0,Ae.defaultColor=[0,0,0,1];var Te=be={};be.BYTE=5120,be.UNSIGNED_BYTE=5121,be.SHORT=5122,be.UNSIGNED_SHORT=5123,be.INT=5124,be.UNSIGNED_INT=5125,be.FLOAT=5126;var we,Ee=function(){return h((function e(t,r,n,i,o){u(this,e),o=o||{},this.gl=t,this.vertex_data=r,this.element_data=n,this.vertex_layout=i,this.vertex_buffer=this.gl.createBuffer(),this.buffer_size=this.vertex_data.byteLength,this.draw_mode=o.draw_mode||this.gl.TRIANGLES,this.data_usage=o.data_usage||this.gl.STATIC_DRAW,this.vertices_per_geometry=3,this.uniforms=o.uniforms,this.textures=o.textures,this.retain=o.retain||!1,this.created_at=+new Date,this.fade_in_time=o.fade_in_time||0,this.vertex_count=this.vertex_data.byteLength/this.vertex_layout.stride,this.element_count=0,this.vaos={},this.toggle_element_array=!1,this.element_data?(this.toggle_element_array=!0,this.element_count=this.element_data.length,this.geometry_count=this.element_count/this.vertices_per_geometry,this.element_type=this.element_data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT,this.element_buffer=this.gl.createBuffer(),this.buffer_size+=this.element_data.byteLength,this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.element_buffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.element_data,this.data_usage)):this.geometry_count=this.vertex_count/this.vertices_per_geometry,this.upload(),this.retain||(delete this.vertex_data,delete this.element_data),this.valid=!0;}),[{key:"render",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.valid)return !1;var t=e.program||Z.current;t.use(),this.uniforms&&(t.saveUniforms(this.uniforms),t.setUniforms(this.uniforms,!1));var r=(+new Date-this.created_at)/1e3;return t.uniform("1f","u_visible_time",r),this.bind(t),this.toggle_element_array?this.gl.drawElements(this.draw_mode,this.element_count,this.element_type,0):this.gl.drawArrays(this.draw_mode,0,this.vertex_count),K.bind(this.gl,null),this.uniforms&&t.restoreUniforms(this.uniforms),r<this.fade_in_time}},{key:"bind",value:function(e){var t=this,r=this.vaos[e.id];r?K.bind(this.gl,r):this.vaos[e.id]=K.create(this.gl,(function(){t.gl.bindBuffer(t.gl.ARRAY_BUFFER,t.vertex_buffer),t.toggle_element_array&&t.gl.bindBuffer(t.gl.ELEMENT_ARRAY_BUFFER,t.element_buffer),t.vertex_layout.enableDynamicAttributes(t.gl,e);})),this.vertex_layout.enableStaticAttributes(this.gl,e);}},{key:"upload",value:function(){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertex_buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertex_data,this.data_usage);}},{key:"destroy",value:function(){if(!this.valid)return !1;for(var e in this.valid=!1,this.vaos)K.destroy(this.gl,this.vaos[e]);return this.gl.deleteBuffer(this.vertex_buffer),this.vertex_buffer=null,this.element_buffer&&(this.gl.deleteBuffer(this.element_buffer),this.element_buffer=null),delete this.vertex_data,delete this.element_data,this.textures&&this.textures.forEach((function(e){return D.release(e)})),!0}}])}(),ke=["emission","ambient","diffuse","specular"],Re=function(){function e(t){var r=this;u(this,e),t=t||{},ke.forEach((function(e){var n=t[e];null!=n&&(n.texture?r[e]={texture:n.texture,mapping:n.mapping||"spheremap",scale:j.expandVec3(null!=n.scale?n.scale:1),amount:j.expandVec4(null!=n.amount?n.amount:1)}:"number"==typeof n||Array.isArray(n)?r[e]={amount:j.expandVec4(n)}:r[e]="string"==typeof n?{amount:ue.parseColor(n)}:n);})),this.specular&&(this.specular.shininess=t.shininess?parseFloat(t.shininess):.2),null!=t.normal&&(this.normal={texture:t.normal.texture,mapping:t.normal.mapping||"triplanar",scale:j.expandVec3(null!=t.normal.scale?t.normal.scale:1),amount:null!=t.normal.amount?t.normal.amount:1});}return h(e,[{key:"inject",value:function(t){var r=this;ke.forEach((function(e){var n="TANGRAM_MATERIAL_".concat(e.toUpperCase()),i=n+"_TEXTURE";t.defines[n]=null!=r[e],r[e]&&r[e].texture&&(t.defines[i]=!0,t.defines[i+"_"+r[e].mapping.toUpperCase()]=!0,t.defines["TANGRAM_MATERIAL_TEXTURE_".concat(r[e].mapping.toUpperCase())]=!0,t.texcoords=t.texcoords||"uv"===r[e].mapping);})),this.normal&&this.normal.texture&&(t.defines.TANGRAM_MATERIAL_NORMAL_TEXTURE=!0,t.defines["TANGRAM_MATERIAL_NORMAL_TEXTURE_"+this.normal.mapping.toUpperCase()]=!0,t.defines["TANGRAM_MATERIAL_TEXTURE_".concat(this.normal.mapping.toUpperCase())]=!0,t.texcoords=t.texcoords||"uv"===this.normal.mapping),t.replaceShaderBlock(e.block,"/*\n\nDefines globals:\nmaterial\nlight_accumulator_*\n\n*/\n\n\n// MATERIALS\n//\nstruct Material {\n    #ifdef TANGRAM_MATERIAL_EMISSION\n        vec4 emission;\n        #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\n            vec3 emissionScale;\n        #endif\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_AMBIENT\n        vec4 ambient;\n        #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\n            vec3 ambientScale;\n        #endif\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_DIFFUSE\n        vec4 diffuse;\n        #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\n            vec3 diffuseScale;\n        #endif\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_SPECULAR\n        vec4 specular;\n        float shininess;\n        #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\n            vec3 specularScale;\n        #endif\n    #endif\n\n\n    #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\n        vec3 normalScale;\n        float normalAmount;\n    #endif\n};\n\n// Note: uniform is copied to a global instance to allow modification\nuniform Material u_material;\nMaterial material;\n\n#ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\nuniform sampler2D u_material_emission_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\nuniform sampler2D u_material_ambient_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\nuniform sampler2D u_material_diffuse_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\nuniform sampler2D u_material_specular_texture;\n#endif\n\n#ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\nuniform sampler2D u_material_normal_texture;\n#endif\n\n// Global light accumulators for each property\nvec4 light_accumulator_ambient = vec4(vec3(0.0), 1.);\nvec4 light_accumulator_diffuse = vec4(vec3(0.0), 1.);\n#ifdef TANGRAM_MATERIAL_SPECULAR\n    vec4 light_accumulator_specular = vec4(vec3(0.0), 1.);\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_SPHEREMAP\nvec4 getSphereMap (in sampler2D _tex, in vec3 _eyeToPoint, in vec3 _normal, in vec2 _skew) {\n    // Normalized vector from camera to surface\n    vec3 eye = normalize(_eyeToPoint);\n\n    // Adjust for camera skew\n    eye.xy -= _skew;\n    eye = normalize(eye);\n\n    // Reflection of eye off of surface normal\n    vec3 r = reflect(eye, _normal);\n\n    // Map reflected vector onto the surface of a sphere\n    r.z += 1.0;\n    float m = 2. * length(r);\n\n    // Adjust xy to account for spherical shape, and center in middle of texture\n    vec2 uv = r.xy / m + .5;\n\n    // Sample the environment map\n    return texture2D(_tex, uv);\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_TRIPLANAR\nvec3 getTriPlanarBlend (in vec3 _normal) {\n    vec3 blending = abs(_normal);\n    blending = normalize(max(blending, 0.00001));\n    float b = (blending.x + blending.y + blending.z);\n    return blending / b;\n}\n\nvec4 getTriPlanar (in sampler2D _tex, in vec3 _pos, in vec3 _normal, in vec3 _scale) {\n    vec3 blending = getTriPlanarBlend(_normal);\n    vec4 xaxis = texture2D(_tex, fract(_pos.yz * _scale.x));\n    vec4 yaxis = texture2D(_tex, fract(_pos.xz * _scale.y));\n    vec4 zaxis = texture2D(_tex, fract(_pos.xy * _scale.z));\n    return  xaxis * blending.x + yaxis * blending.y + zaxis * blending.z;\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_TEXTURE_PLANAR\nvec4 getPlanar (in sampler2D _tex, in vec3 _pos, in vec2 _scale) {\n    return texture2D( _tex, fract(_pos.xy * _scale.x) );\n}\n#endif\n\n\n#ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE\nvoid calculateNormal (inout vec3 _normal) {\n    // Get NORMALMAP\n    //------------------------------------------------\n    #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_UV\n    _normal += texture2D(u_material_normal_texture, fract(v_texcoord*material.normalScale.xy)).rgb*2.0-1.0;\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_PLANAR\n    vec3 normalTex = getPlanar(u_material_normal_texture, v_world_position.xyz, material.normalScale.xy).rgb*2.0-1.0;\n    _normal += normalTex;\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_NORMAL_TEXTURE_TRIPLANAR\n    vec3 normalTex = getTriPlanar(u_material_normal_texture, v_world_position.xyz, _normal, material.normalScale).rgb*2.0-1.0;\n    _normal += normalTex;\n    #endif\n\n    _normal = normalize(_normal);\n}\n#endif\n\nvoid calculateMaterial (in vec3 _eyeToPoint, inout vec3 _normal) {\n    // get EMISSION TEXTUREMAP\n    //------------------------------------------------\n    #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE\n        #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_UV\n        material.emission *= texture2D(u_material_emission_texture,v_texcoord);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_PLANAR\n        material.emission *= getPlanar(u_material_emission_texture, v_world_position.xyz, material.emissionScale.xy);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_TRIPLANAR\n        material.emission *= getTriPlanar(u_material_emission_texture, v_world_position.xyz, _normal, material.emissionScale);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_EMISSION_TEXTURE_SPHEREMAP\n        material.emission *= getSphereMap(u_material_emission_texture, _eyeToPoint, _normal, u_vanishing_point);\n        #endif\n    #endif\n\n    // get AMBIENT TEXTUREMAP\n    //------------------------------------------------\n    #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE\n        #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_UV\n        material.ambient *= texture2D(u_material_ambient_texture,v_texcoord);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_PLANAR\n        material.ambient *= getPlanar(u_material_ambient_texture, v_world_position.xyz, material.ambientScale.xy);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_TRIPLANAR\n        material.ambient *= getTriPlanar(u_material_ambient_texture, v_world_position.xyz, _normal, material.ambientScale);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_AMBIENT_TEXTURE_SPHEREMAP\n        material.ambient *= getSphereMap(u_material_ambient_texture, _eyeToPoint, _normal, u_vanishing_point);\n        #endif\n    #endif\n\n    // get DIFFUSE TEXTUREMAP\n    //------------------------------------------------\n    #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE\n        #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_UV\n        material.diffuse *= texture2D(u_material_diffuse_texture,v_texcoord);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_PLANAR\n        material.diffuse *= getPlanar(u_material_diffuse_texture, v_world_position.xyz, material.diffuseScale.xy);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_TRIPLANAR\n        material.diffuse *= getTriPlanar(u_material_diffuse_texture, v_world_position.xyz, _normal, material.diffuseScale);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_DIFFUSE_TEXTURE_SPHEREMAP\n        material.diffuse *= getSphereMap(u_material_diffuse_texture, _eyeToPoint, _normal, u_vanishing_point);\n        #endif\n    #endif\n\n    // get SPECULAR TEXTUREMAP\n    //------------------------------------------------\n    #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE\n        #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_UV\n        material.specular *= texture2D(u_material_specular_texture,v_texcoord);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_PLANAR\n        material.specular *= getPlanar(u_material_specular_texture, v_world_position.xyz, material.specularScale.xy);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_TRIPLANAR\n        material.specular *= getTriPlanar(u_material_specular_texture, v_world_position.xyz, _normal, material.specularScale);\n        #endif\n\n        #ifdef TANGRAM_MATERIAL_SPECULAR_TEXTURE_SPHEREMAP\n        material.specular *= getSphereMap(u_material_specular_texture, _eyeToPoint, _normal, u_vanishing_point);\n        #endif\n    #endif\n}\n","Material"),t.addShaderBlock("setup","\nmaterial = u_material;\n","Material");}},{key:"setupProgram",value:function(e){var t=this;ke.forEach((function(r){t[r]&&(t[r].texture?(e.setTextureUniform("u_material_".concat(r,"_texture"),t[r].texture),e.uniform("3fv","u_material.".concat(r,"Scale"),t[r].scale),e.uniform("4fv","u_material.".concat(r),t[r].amount)):t[r].amount&&e.uniform("4fv","u_material.".concat(r),t[r].amount));})),this.specular&&e.uniform("1f","u_material.shininess",this.specular.shininess),this.normal&&this.normal.texture&&(e.setTextureUniform("u_material_normal_texture",this.normal.texture),e.uniform("3fv","u_material.normalScale",this.normal.scale),e.uniform("1f","u_material.normalAmount",this.normal.amount));}}],[{key:"isValid",value:function(e){return null!=e&&(null!=e.emission||null!=e.ambient||null!=e.diffuse||null!=e.specular)}}])}();function Me(e){return Me=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Me(e)}function ze(){return ze="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Me(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},ze.apply(null,arguments)}function Pe(e,t){if(t&&("object"==o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Se(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t);}Re.block="material";var Ne=we={};we.copy=function(e){for(var t=[],r=e.length,n=0;n<r;n++)t[n]=e[n];return t},we.neg=function(e){for(var t=[],r=e.length,n=0;n<r;n++)t[n]=-e[n];return t},we.add=function(e,t){for(var r=[],n=Math.min(e.length,t.length),i=0;i<n;i++)r[i]=e[i]+t[i];return r},we.sub=function(e,t){for(var r=[],n=Math.min(e.length,t.length),i=0;i<n;i++)r[i]=e[i]-t[i];return r},we.signed_area=function(e,t,r){return (t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1])},we.mult=function(e,t){var r,n=[],i=e.length;if("number"==typeof t)for(r=0;r<i;r++)n[r]=e[r]*t;else for(i=Math.min(e.length,t.length),r=0;r<i;r++)n[r]=e[r]*t[r];return n},we.div=function(e,t){var r,n=[];if("number"==typeof t)for(r=0;r<e.length;r++)n[r]=e[r]/t;else {var i=Math.min(e.length,t.length);for(r=0;r<i;r++)n[r]=e[r]/t[r];}return n},we.perp=function(e,t){return [t[1]-e[1],e[0]-t[0]]},we.rot=function(e,t){var r=Math.cos(t),n=Math.sin(t);return [e[0]*r-e[1]*n,e[0]*n+e[1]*r]},we.angle=function(e){var t=n(e,2),r=t[0],i=t[1];return Math.atan2(i,r)},we.angleBetween=function(e,t){var r=we.dot(we.normalize(we.copy(e)),we.normalize(we.copy(t)));return r>1&&(r=1),Math.acos(r)},we.isEqual=function(e,t){for(var r=e.length,n=0;n<r;n++)if(e[n]!==t[n])return !1;return !0},we.lengthSq=function(e){return 2===e.length?e[0]*e[0]+e[1]*e[1]:e.length>=3?e[0]*e[0]+e[1]*e[1]+e[2]*e[2]:0},we.length=function(e){return Math.sqrt(we.lengthSq(e))},we.normalize=function(e){var t;if(2===e.length){if(1===(t=e[0]*e[0]+e[1]*e[1]))return e;0!==(t=Math.sqrt(t))?(e[0]/=t,e[1]/=t):(e[0]=0,e[1]=0);}else if(e.length>=3){if(1===(t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2]))return e;0!==(t=Math.sqrt(t))?(e[0]/=t,e[1]/=t,e[2]/=t):(e[0]=0,e[1]=0,e[2]=0);}return e},we.cross=function(e,t){return 2===e.length?e[0]*t[1]-e[1]*t[0]:3===e.length?[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]:void 0},we.dot=function(e,t){for(var r=0,n=Math.min(e.length,t.length),i=0;i<n;i++)r+=e[i]*t[i];return r};function Oe(e,t,r,n){var i=ze(Me(e.prototype),t,r);return "function"==typeof i?function(e){return i.apply(r,e)}:i}function Le(e,t,r){return t=Me(t),Pe(e,Ie()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function Ie(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (Ie=function(){return !!e})()}var Fe=function(){function e(t,r){u(this,e),this.name=r.name,this.view=t,null==r.ambient||"number"==typeof r.ambient?this.ambient=j.expandVec3(r.ambient||0):this.ambient=ue.parseColor(r.ambient).slice(0,3),null==r.diffuse||"number"==typeof r.diffuse?this.diffuse=j.expandVec3(null!=r.diffuse?r.diffuse:1):this.diffuse=ue.parseColor(r.diffuse).slice(0,3),null==r.specular||"number"==typeof r.specular?this.specular=j.expandVec3(r.specular||0):this.specular=ue.parseColor(r.specular).slice(0,3);}return h(e,[{key:"inject",value:function(){var t="\n            uniform ".concat(this.struct_name," u_").concat(this.name,";\n            ").concat(this.struct_name," ").concat(this.name,";\n            "),r="\n            ".concat(this.name," = u_").concat(this.name,";\n\n        ");Z.addBlock(e.block,t),Z.addBlock("setup",r);}},{key:"update",value:function(){}},{key:"setupProgram",value:function(e){e.uniform("3fv","u_".concat(this.name,".ambient"),this.ambient),e.uniform("3fv","u_".concat(this.name,".diffuse"),this.diffuse),e.uniform("3fv","u_".concat(this.name,".specular"),this.specular);}}],[{key:"create",value:function(t,r){if(e.types[r.type])return new e.types[r.type](t,r)}},{key:"setMode",value:function(t,r){!0===t&&(t="fragment"),t=e.enabled&&(null!=t?t:"fragment"),r.defines.TANGRAM_LIGHTING_FRAGMENT="fragment"===t,r.defines.TANGRAM_LIGHTING_VERTEX="vertex"===t;}},{key:"inject",value:function(t){if(Z.removeBlock(e.block),e.enabled){var r="";if(t&&Object.keys(t).length>0){var n={};for(var i in t)n[t[i].type]=!0;for(var o in n)e.types[o].inject();for(var a in t)t[a].inject(),r+="calculateLight(".concat(a,", _eyeToPoint, _normal);\n");}var s="\n            vec4 calculateLighting(in vec3 _eyeToPoint, in vec3 _normal, in vec4 _color) {\n\n                // Do initial material calculations over normal, emission, ambient, diffuse and specular values\n                calculateMaterial(_eyeToPoint,_normal);\n\n                // Un roll the loop of individual ligths to calculate\n                ".concat(r,"\n\n                //  Final light intensity calculation\n                vec4 color = vec4(vec3(0.), _color.a); // start with vertex color alpha\n\n                #ifdef TANGRAM_MATERIAL_EMISSION\n                    color.rgb = material.emission.rgb;\n                    color.a *= material.emission.a;\n                #endif\n\n                #ifdef TANGRAM_MATERIAL_AMBIENT\n                    color.rgb += light_accumulator_ambient.rgb * _color.rgb * material.ambient.rgb;\n                    color.a *= material.ambient.a;\n                #else\n                    #ifdef TANGRAM_MATERIAL_DIFFUSE\n                        color.rgb += light_accumulator_ambient.rgb * _color.rgb * material.diffuse.rgb;\n                    #endif\n                #endif\n\n                #ifdef TANGRAM_MATERIAL_DIFFUSE\n                    color.rgb += light_accumulator_diffuse.rgb * _color.rgb * material.diffuse.rgb;\n                    color.a *= material.diffuse.a;\n                #endif\n\n                #ifdef TANGRAM_MATERIAL_SPECULAR\n                    color.rgb += light_accumulator_specular.rgb * material.specular.rgb;\n                    color.a *= material.specular.a;\n                #endif\n\n                // Clamp final color\n                color = clamp(color, 0.0, 1.0);\n\n                return color;\n            }");Z.addBlock(e.block,s);}}}])}();Fe.types={},Fe.block="lighting",Fe.enabled=!0;var De=function(e){function t(e,r){var n;return u(this,t),(n=Le(this,t,[e,r])).type="ambient",n.struct_name="AmbientLight",n}return Se(t,e),h(t,[{key:"setupProgram",value:function(e){e.uniform("3fv","u_".concat(this.name,".ambient"),this.ambient);}}],[{key:"inject",value:function(){Z.addBlock(Fe.block,"/*\n\nExpected globals:\nlight_accumulator_*\n\n*/\n\nstruct AmbientLight {\n    vec3 ambient;\n};\n\nvoid calculateLight(in AmbientLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n    light_accumulator_ambient.rgb += _light.ambient;\n}\n");}}])}(Fe);Fe.types.ambient=De;var Ue=function(e){function t(e,r){var n;if(u(this,t),(n=Le(this,t,[e,r])).type="directional",n.struct_name="DirectionalLight",r.direction)n._direction=r.direction;else {var i=Math.sin(60*Math.PI/180);n._direction=[Math.cos(135*Math.PI/180)*i,Math.sin(135*Math.PI/180)*i,-.5],null==r.ambient&&(n.ambient=j.expandVec3(.5));}return n.direction=n._direction.map(parseFloat),n}return Se(t,e),h(t,[{key:"direction",get:function(){return this._direction},set:function(e){this._direction=Ne.normalize(Ne.copy(e));}},{key:"setupProgram",value:function(e){Oe(t,"setupProgram",this)([e]),e.uniform("3fv","u_".concat(this.name,".direction"),this.direction);}}],[{key:"inject",value:function(){Z.addBlock(Fe.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct DirectionalLight {\n    vec3 ambient;\n    vec3 diffuse;\n    vec3 specular;\n    vec3 direction;\n};\n\nvoid calculateLight(in DirectionalLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n    light_accumulator_ambient.rgb += _light.ambient;\n\n    float nDotVP = clamp(dot(_normal, -_light.direction), 0.0, 1.0);\n\n    #ifdef TANGRAM_MATERIAL_DIFFUSE\n        light_accumulator_diffuse.rgb += _light.diffuse * nDotVP;\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_SPECULAR\n        float pf = 0.0;\n        if (nDotVP > 0.0) {\n            vec3 reflectVector = reflect(_light.direction, _normal);\n            float eyeDotR = max(dot(normalize(_eyeToPoint), reflectVector), 0.0);\n            pf = pow(eyeDotR, material.shininess);\n        }\n        light_accumulator_specular.rgb += _light.specular * pf;\n    #endif\n}\n");}}])}(Fe);Fe.types.directional=Ue;var Ge=function(e){function t(e,r){var n;return u(this,t),(n=Le(this,t,[e,r])).type="point",n.struct_name="PointLight",n.position=r.position||[0,0,"100px"],n.position_eye=[],n.origin=r.origin||"ground",n.attenuation=isNaN(parseFloat(r.attenuation))?0:parseFloat(r.attenuation),r.radius?Array.isArray(r.radius)&&2===r.radius.length?n.radius=r.radius:n.radius=[null,r.radius]:n.radius=null,n}return Se(t,e),h(t,[{key:"inject",value:function(){Oe(t,"inject",this)([]),Z.defines.TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT=0!==this.attenuation,Z.defines.TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS=null!=this.radius&&null!=this.radius[0],Z.defines.TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS=null!=this.radius;}},{key:"update",value:function(){this.updateEyePosition();}},{key:"updateEyePosition",value:function(){if("world"===this.origin){var e=Q.latLngToMeters(l(this.position));this.position_eye[0]=e[0]-this.view.camera.position_meters[0],this.position_eye[1]=e[1]-this.view.camera.position_meters[1],this.position_eye[2]=ue.convertUnits(this.position[2],{zoom:this.view.zoom,meters_per_pixel:Q.metersPerPixel(this.view.zoom)}),this.position_eye[2]=this.position_eye[2]-this.view.camera.position_meters[2];}else "ground"!==this.origin&&"camera"!==this.origin||(this.position_eye=ue.convertUnits(this.position,{zoom:this.view.zoom,meters_per_pixel:Q.metersPerPixel(this.view.zoom)}),"ground"===this.origin&&(this.position_eye[2]=this.position_eye[2]-this.view.camera.position_meters[2]));this.position_eye[3]=1;}},{key:"setupProgram",value:function(e){Oe(t,"setupProgram",this)([e]),e.uniform("4fv","u_".concat(this.name,".position"),this.position_eye),Z.defines.TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT&&e.uniform("1f","u_".concat(this.name,".attenuationExponent"),this.attenuation),Z.defines.TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS&&e.uniform("1f","u_".concat(this.name,".innerRadius"),ue.convertUnits(this.radius[0],{zoom:this.view.zoom,meters_per_pixel:Q.metersPerPixel(this.view.zoom)})),Z.defines.TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS&&e.uniform("1f","u_".concat(this.name,".outerRadius"),ue.convertUnits(this.radius[1],{zoom:this.view.zoom,meters_per_pixel:Q.metersPerPixel(this.view.zoom)}));}}],[{key:"inject",value:function(){Z.addBlock(Fe.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct PointLight {\n    vec3 ambient;\n    vec3 diffuse;\n    vec3 specular;\n    vec4 position;\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n    float attenuationExponent;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n    float innerRadius;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n    float outerRadius;\n#endif\n};\n\nvoid calculateLight(in PointLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n    float dist = length(_light.position.xyz - _eyeToPoint);\n\n    // Compute vector from surface to light position\n    vec3 VP = (_light.position.xyz - _eyeToPoint) / dist;\n\n    // Normalize the vector from surface to light position\n    float nDotVP = clamp(dot(VP, _normal), 0.0, 1.0);\n\n    // Attenuation defaults\n    float attenuation = 1.0;\n    #ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n        float Rin = 1.0;\n        float e = _light.attenuationExponent;\n\n        #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n            Rin = _light.innerRadius;\n        #endif\n\n        #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n            float Rdiff = _light.outerRadius-Rin;\n            float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n            attenuation = 1.0-(pow(d,e));\n        #else\n            // If no outer is provide behaves like:\n            // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n            float d = max(0.0,dist-Rin)/Rin+1.0;\n            attenuation = clamp(1.0/(pow(d,e)), 0.0, 1.0);\n        #endif\n    #else\n        float Rin = 0.0;\n\n        #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n            Rin = _light.innerRadius;\n            #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n                float Rdiff = _light.outerRadius-Rin;\n                float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n                attenuation = 1.0-d*d;\n            #else\n                // If no outer is provide behaves like:\n                // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n                float d = max(0.0,dist-Rin)/Rin+1.0;\n                attenuation = clamp(1.0/d, 0.0, 1.0);\n            #endif\n        #else\n            #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n                float d = clamp(dist/_light.outerRadius, 0.0, 1.0);\n                attenuation = 1.0-d*d;\n            #else\n                attenuation = 1.0;\n            #endif\n        #endif\n    #endif\n\n    // Computer accumulators\n    light_accumulator_ambient.rgb += _light.ambient * attenuation;\n\n    #ifdef TANGRAM_MATERIAL_DIFFUSE\n        light_accumulator_diffuse.rgb += _light.diffuse * nDotVP * attenuation;\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_SPECULAR\n        float pf = 0.0; // power factor for shiny speculars\n        if (nDotVP > 0.0) {\n            vec3 reflectVector = reflect(-VP, _normal);\n            float eyeDotR = max(0.0, dot(-normalize(_eyeToPoint), reflectVector));\n            pf = pow(eyeDotR, material.shininess);\n        }\n\n        light_accumulator_specular.rgb += _light.specular * pf * attenuation;\n    #endif\n}\n");}}])}(Fe);Fe.types.point=Ge;var je=function(e){function t(e,r){var n;return u(this,t),(n=Le(this,t,[e,r])).type="spotlight",n.struct_name="SpotLight",n.direction=n._direction=(r.direction||[0,0,-1]).map(parseFloat),n.exponent=r.exponent?parseFloat(r.exponent):.2,n.angle=r.angle?parseFloat(r.angle):20,n}return Se(t,e),h(t,[{key:"direction",get:function(){return this._direction},set:function(e){this._direction=Ne.normalize(Ne.copy(e));}},{key:"setupProgram",value:function(e){Oe(t,"setupProgram",this)([e]),e.uniform("3fv","u_".concat(this.name,".direction"),this.direction),e.uniform("1f","u_".concat(this.name,".spotCosCutoff"),Math.cos(3.14159*this.angle/180)),e.uniform("1f","u_".concat(this.name,".spotExponent"),this.exponent);}}],[{key:"inject",value:function(){Z.addBlock(Fe.block,"/*\n\nExpected globals:\nmaterial\nlight_accumulator_*\n\n*/\n\nstruct SpotLight {\n    vec3 ambient;\n    vec3 diffuse;\n    vec3 specular;\n    vec4 position;\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n    float attenuationExponent;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n    float innerRadius;\n#endif\n\n#ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n    float outerRadius;\n#endif\n\n    vec3 direction;\n    float spotCosCutoff;\n    float spotExponent;\n};\n\nvoid calculateLight(in SpotLight _light, in vec3 _eyeToPoint, in vec3 _normal) {\n\n    float dist = length(_light.position.xyz - _eyeToPoint);\n\n    // Compute vector from surface to light position\n    vec3 VP = (_light.position.xyz - _eyeToPoint) / dist;\n\n    // normal . light direction\n    float nDotVP = clamp(dot(_normal, VP), 0.0, 1.0);\n\n    // Attenuation defaults\n    float attenuation = 1.0;\n    #ifdef TANGRAM_POINTLIGHT_ATTENUATION_EXPONENT\n        float Rin = 1.0;\n        float e = _light.attenuationExponent;\n\n        #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n            Rin = _light.innerRadius;\n        #endif\n\n        #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n            float Rdiff = _light.outerRadius-Rin;\n            float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n            attenuation = 1.0-(pow(d,e));\n        #else\n            // If no outer is provide behaves like:\n            // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n            float d = max(0.0,dist-Rin)/Rin+1.0;\n            attenuation = clamp(1.0/(pow(d,e)), 0.0, 1.0);\n        #endif\n    #else\n        float Rin = 0.0;\n\n        #ifdef TANGRAM_POINTLIGHT_ATTENUATION_INNER_RADIUS\n            Rin = _light.innerRadius;\n            #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n                float Rdiff = _light.outerRadius-Rin;\n                float d = clamp(max(0.0,dist-Rin)/Rdiff, 0.0, 1.0);\n                attenuation = 1.0-d*d;\n            #else\n                // If no outer is provide behaves like:\n                // https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/\n                float d = max(0.0,dist-Rin)/Rin+1.0;\n                attenuation = clamp(1.0/d, 0.0, 1.0);\n            #endif\n        #else\n            #ifdef TANGRAM_POINTLIGHT_ATTENUATION_OUTER_RADIUS\n                float d = clamp(dist/_light.outerRadius, 0.0, 1.0);\n                attenuation = 1.0-d*d;\n            #else\n                attenuation = 1.0;\n            #endif\n        #endif\n    #endif\n\n    // spotlight attenuation factor\n    float spotAttenuation = 0.0;\n\n    // See if point on surface is inside cone of illumination\n    float spotDot = clamp(dot(-VP, _light.direction), 0.0, 1.0);\n\n    if (spotDot >= _light.spotCosCutoff) {\n        spotAttenuation = pow(spotDot, _light.spotExponent);\n    }\n\n    light_accumulator_ambient.rgb += _light.ambient * attenuation * spotAttenuation;\n\n    #ifdef TANGRAM_MATERIAL_DIFFUSE\n        light_accumulator_diffuse.rgb += _light.diffuse * nDotVP * attenuation * spotAttenuation;\n    #endif\n\n    #ifdef TANGRAM_MATERIAL_SPECULAR\n        // Power factor for shiny speculars\n        float pf = 0.0;\n        if (nDotVP > 0.0) {\n            vec3 reflectVector = reflect(-VP, _normal);\n            float eyeDotR = max(dot(-normalize(_eyeToPoint), reflectVector), 0.0);\n            pf = pow(eyeDotR, material.shininess);\n        }\n        light_accumulator_specular.rgb += _light.specular * pf * attenuation * spotAttenuation;\n    #endif\n}\n");}}])}(Ge);function Ce(e){var t="function"==typeof Map?new Map:void 0;return Ce=function(e){if(null===e||!function(e){try{return -1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return "function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r);}function r(){return m(e,arguments,Me(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,e)},Ce(e)}function Be(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (Be=function(){return !!e})()}Fe.types.spotlight=je;var Ve=function(e){function t(e){var r,n,i,o;return u(this,t),n=this,i=Me(i=t),(r=Pe(n,Be()?Reflect.construct(i,[],Me(n).constructor):i.apply(n,o))).name="MethodNotImplemented",r.message="Method "+e+" must be implemented in subclass",r}return Se(t,e),h(t)}(Ce(Error));function qe(e,t,r){return t=Me(t),Pe(e,Xe()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function Xe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (Xe=function(){return !!e})()}var He=function(){function e(t,r){var n=this;(u(this,e),this.validate(t),this.config=t,this.sources=r,this.id=t.id,this.name=t.name,this.pad_scale=t.pad_scale||1e-5,this.default_winding=null,this.rasters=[],Array.isArray(t.rasters)&&t.rasters.forEach((function(e){-1===n.rasters.indexOf(e)&&n.rasters.push(e);})),this.preprocess=t.preprocess,"function"==typeof this.preprocess&&this.preprocess.bind(this),this.transform=t.transform,"function"==typeof this.transform&&this.transform.bind(this),this.extra_data=t.extra_data,this.scripts=t.scripts,this.setZooms(t),this.zoom_offset=null!=t.zoom_offset?t.zoom_offset:0,this.zoom_offset<0)&&(k({level:"warn",once:!0},"Data source '".concat(this.name,"' zoom_offset must not be negative – setting to 0.")),this.zoom_offset=0);this.setTileSize(t.tile_size),this.min_display_zoom=Math.max(t.min_display_zoom||0,this.zooms[0]),this.max_display_zoom=null!=t.max_display_zoom?t.max_display_zoom:null;}return h(e,[{key:"load",value:function(e){var t=this;return e.source_data={},e.source_data.layers={},e.pad_scale=this.pad_scale,e.rasters=l(this.rasters),this._load(e).then((function(e){for(var r in e.source_data.layers){var n=e.source_data.layers[r];n&&n.features&&n.features.forEach((function(e){Q.transformGeometry(e.geometry,(function(e){e[1]=-e[1],t.pad_scale&&(e[0]=Math.round(e[0]*(1+t.pad_scale)-Q.tile_scale*t.pad_scale/2),e[1]=Math.round(e[1]*(1+t.pad_scale)-Q.tile_scale*t.pad_scale/2));})),t.updateDefaultWinding(e.geometry);}));}return e.default_winding=t.default_winding||"CCW",e}))}},{key:"_load",value:function(){throw new Ve("_load")}},{key:"copyTileData",value:function(e,t){return k("trace","Copy tile data from ".concat(e.key," to ").concat(t.key)),t.source_data={layers:e.source_data.layers},t.rasters=l(e.rasters),t.pad_scale=e.pad_scale,t.default_winding=e.default_winding,t}},{key:"setZooms",value:function(e){var t=e.max_zoom,r=e.zooms;if(this.max_zoom=null!=t?t:Q.default_source_max_zoom,Array.isArray(r))this.zooms=r,this.max_zoom=this.zooms[this.zooms.length-1];else {this.zooms=[];for(var n=0;n<=this.max_zoom;n++)this.zooms[n]=n;}}},{key:"setTileSize",value:function(e){this.tile_size=e||256,("number"!=typeof this.tile_size||this.tile_size<256||!M.isPowerOf2(this.tile_size))&&(k({level:"warn",once:!0},"Data source '".concat(this.name,"': 'tile_size' parameter must be a number that is a power of 2 greater than or equal to 256, but was '").concat(e,"'")),this.tile_size=256),this.zoom_bias=Math.log2(this.tile_size)-8+this.zoom_offset;}},{key:"updateDefaultWinding",value:function(e){return null==this.default_winding&&("Polygon"===e.type?this.default_winding=Q.ringWinding(e.coordinates[0]):"MultiPolygon"===e.type&&(this.default_winding=Q.ringWinding(e.coordinates[0][0]))),this.default_winding}},{key:"includesTile",value:function(e,t){if(e.z<this.min_display_zoom||null!=this.max_display_zoom&&t>this.max_display_zoom)return !1;for(var r=0;r<this.rasters.length;r++){var n=this.rasters[r];if(this.sources[n]&&this.sources[n]!==this&&!this.sources[n].includesTile(e,e.z))return !1}return !0}},{key:"validate",value:function(){}}],[{key:"register",value:function(t,r){t&&r&&(e.types[t]=r);}},{key:"create",value:function(t,r){if("function"==typeof e.types[t.type]){var n=e.types[t.type](t);if(n)return new n(t,r)}}},{key:"tileLayoutChanged",value:function(e,t){if(!e||!t)return !0;var r=["max_zoom","zooms","min_display_zoom","max_display_zoom","bounds","tile_size","zoom_offset"],n=F(e.config,r),i=F(t.config,r);return JSON.stringify(n)!==JSON.stringify(i)}},{key:"projectData",value:function(e){var t=+new Date;for(var r in e.layers)for(var n=e.layers[r].features.length,i=0;i<n;i++){var o=e.layers[r].features[i];Q.transformGeometry(o.geometry,this.projectCoord);}void 0!==e.debug&&(e.debug.projection=+new Date-t);}},{key:"projectCoord",value:function(e){Q.latLngToMeters(e);}},{key:"scaleData",value:function(e,t){var r=t.coords.z,n=t.min,i=Q.unitsPerMeter(r);for(var o in e.layers)for(var a=e.layers[o].features.length,s=0;s<a;s++){var l=e.layers[o].features[s];Q.transformGeometry(l.geometry,(function(e){e[0]=(e[0]-n.x)*i,e[1]=(e[1]-n.y)*i*-1;}));}}}])}();He.types={};var We=0,Ye=function(e){function t(e,r){var i;u(this,t),(i=qe(this,t,[e,r])).response_type="";var a=function(e,t){if(!t||0===Object.keys(t).length)return [e,[]];var r=e.indexOf("?"),n=e.indexOf("#"),i="";n>-1&&(i=e.slice(n),e=e.slice(0,n)),-1===r&&(r=e.length,e+="?"),r++;var o="",a=[];for(var s in t)""===O(s,e)?o+="".concat(s,"=").concat(t[s],"&"):a.push([s,t[s]]);return [e=e.slice(0,r)+o+e.slice(r)+i,a]}(e.url,e.url_params),s=n(a,2),l=s[0],c=s[1];return i.url=l,c.forEach((function(t){var r=n(t,2),o=r[0],a=r[1];k({level:"warn",once:!0},"Data source '".concat(i.name,"': parameter '").concat(o,"' already present in URL '").concat(e.url,"', ")+"skipping value '".concat(o,"=").concat(a,"' specified in 'url_params'"));})),e.request_headers&&"object"===o(e.request_headers)&&(i.request_headers=e.request_headers),i}return Se(t,e),h(t,[{key:"_load",value:function(e){var t=this,r=this.formatURL(this.url,e),n=e.source_data;return n.url=r,e.debug=e.debug||{},e.debug.network=+new Date,new Promise((function(i){var o=We+++"-"+r,a=M.io(r,6e4,t.response_type,"GET",t.request_headers,o);n.request_id=o,n.error=null,a.then((function(r){var o=r.body;e.debug.response_size=o&&(o.length||o.byteLength),e.debug.network=+new Date-e.debug.network,e.debug.parsing=+new Date,null!=o&&"function"==typeof t.preprocess&&(o=t.preprocess(o)),(o=o instanceof Promise?o:Promise.resolve(o)).then((function(r){null!=r?t.parseSourceData(e,n,r):n.layers={},e.debug.parsing=+new Date-e.debug.parsing,i(e);}));})).catch((function(t){n.error=t.stack,i(e);}));}))}},{key:"validate",value:function(e){if("string"!=typeof e.url)throw Error("Network data source must provide a string `url` property")}},{key:"formatURL",value:function(){throw new Ve("formatURL")}},{key:"parseSourceData",value:function(){throw new Ve("parseSourceData")}}])}(He),Ze=function(e){function t(e,r){var n;return u(this,t),(n=qe(this,t,[e,r])).tiled=!0,n.bounds=n.parseBounds(e),n.builds_geometry_tiles=!1,n.tms=!0===e.tms,n.url&&n.url.search("{s}")>-1&&(Array.isArray(e.url_subdomains)&&e.url_subdomains.length>0?(n.url_subdomains=e.url_subdomains,n.next_url_subdomain=0):k({level:"warn",once:!0},"Data source '".concat(n.name,"': source URL includes '{s}' subdomain marker ('").concat(n.url,"'), but no subdomains ")+"were specified in 'url_subdomains' parameter")),n.url&&n.url.search("{r}")>-1&&(Array.isArray(e.url_density_scales)&&e.url_density_scales.length>0?n.url_density_scales=e.url_density_scales:n.url_density_scales=[1,2]),n}return Se(t,e),h(t,[{key:"parseBounds",value:function(e){if(Array.isArray(e.bounds)&&4===e.bounds.length){var t=n(e.bounds,4),r=t[0],i=t[1],o=t[2],a=t[3];return {latlng:l(e.bounds),meters:{min:Q.latLngToMeters([r,a]),max:Q.latLngToMeters([o,i])},tiles:{min:{},max:{}}}}}},{key:"checkBounds",value:function(e,t){if(t){e=Q.wrapTile(e);var r=t.tiles.min[e.z];r||(r=t.tiles.min[e.z]=Q.tileForMeters(t.meters.min,e.z));var n=t.tiles.max[e.z];if(n||(n=t.tiles.max[e.z]=Q.tileForMeters(t.meters.max,e.z)),e.y<r.y||e.y>n.y)return !1;if(r.x<=n.x){if(e.x<r.x||e.x>n.x)return !1}else if(e.x>n.x&&e.x<r.x)return !1}return !0}},{key:"includesTile",value:function(e,r){return !!(n=t,i="includesTile",o=this,a=ze(Me(n.prototype),i,o),"function"==typeof a?function(e){return a.apply(o,e)}:a)([e,r])&&!!this.checkBounds(e,this.bounds);var n,i,o,a;}},{key:"formatURL",value:function(e,t){var r=Q.wrapTile(t.coords,{x:!0});this.tms&&(r.y=Math.pow(2,r.z)-1-r.y);var n=e.replace("{x}",r.x).replace("{y}",r.y).replace("{z}",r.z).replace("{r}",this.getDensityModifier()).replace("{q}",this.toQuadKey(r));return null!=this.url_subdomains&&(n=n.replace("{s}",this.url_subdomains[this.next_url_subdomain]),this.next_url_subdomain=(this.next_url_subdomain+1)%this.url_subdomains.length),n}},{key:"getDensityModifier",value:function(){if(this.url_density_scales){var e=M.device_pixel_ratio,t=this.url_density_scales.filter((function(t){return e>=t})).reverse()[0];if((t=null!=t?t:this.url_density_scales[0])>1)return "@".concat(t,"x")}return ""}},{key:"toQuadKey",value:function(e){for(var t=e.x,r=e.y,n="",i=e.z;i>0;i--){var o=0,a=1<<i-1;t&a&&o++,r&a&&(o+=2),n+=o.toString();}return n}}],[{key:"urlHasTilePattern",value:function(e){return e&&(e.search("{x}")>-1&&e.search("{y}")>-1&&e.search("{z}")>-1||e.search("{q}")>-1)}}])}(Ye),Je={coord:function(e){return {x:e.x,y:e.y,z:e.z,key:this.coordKey(e)}},coordKey:function(e){return e.x+"/"+e.y+"/"+e.z},key:function(e,t,r){if(!(e.y<0||e.y>=1<<e.z||e.z<0))return [t.name,e.x,e.y,e.z,r].join("/")},normalizedKey:function(e,t,r){return this.key(this.normalizedCoord(e,t),t,r)},normalizedCoord:function(e,t){return t.zoom_bias&&(e=this.coordAtZoom(e,Math.max(e.z-t.zoom_bias,t.zooms[0]))),this.coordForTileZooms(e,t.zooms)},coordAtZoom:function(e,t){var r=e.x,n=e.y,i=e.z;if(i!==(t=Math.max(0,t))){var o=Math.pow(2,i-t);r=Math.floor(r/o),n=Math.floor(n/o),i=t;}return this.coord({x:r,y:n,z:i})},coordForTileZooms:function(e,t){var r=e.x,n=e.y,i=e.z,o=this.findZoomInRange(i,t);return o!==i?this.coordAtZoom({x:r,y:n,z:i},o):this.coord({x:r,y:n,z:i})},findZoomInRange:function(e,t){return t.filter((function(t){return e>=t})).reverse()[0]||t[0]},isDescendant:function(e,t){if(t.z>e.z){var r=this.coordAtZoom(t,e.z),n=r.x,i=r.y;return e.x===n&&e.y===i}return !1},parent:function(e){var t=e.coords,r=e.source,n=e.style_z;if(n>0){n--;var i=Math.max(n-r.zoom_bias,r.zooms[0]),o=this.coordForTileZooms(this.coordAtZoom(t,i),r.zooms);return o.z>n?null:{key:this.key(o,r,n),coords:o,style_z:n,source:r}}},children:function(e){var t=e.coords,r=e.source,n=e.style_z,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n++;var o=this.coordForTileZooms(this.coordAtZoom(t,n-r.zoom_bias),r.zooms);if(o.z===t.z)return [{key:this.key(o,r,n),coords:o,style_z:n,source:r}];var a=this.key(o,r,n);if(i[r.id]=i[r.id]||{},null==i[r.id][a]){for(var s=Math.pow(2,o.z-t.z),l=t.x*s,u=t.y*s,c=[],h=l;h<l+s;h++)for(var f=u;f<u+s;f++){var d=this.coord({x:h,y:f,z:o.z});c.push({key:this.key(d,r,n),coords:d,style_z:n,source:r});}i[r.id][a]=c;}return i[r.id][a]}};function Ke(e,t,r){return t=Me(t),Pe(e,$e()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function $e(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return ($e=function(){return !!e})()}var Qe=function(e){function t(e,r){var n;return u(this,t),-1===(n=Ke(this,t,[e,r])).rasters.indexOf(n.name)&&n.rasters.unshift(n.name),n.filtering=e.filtering,n.textures={},n}return Se(t,e),h(t,[{key:"load",value:function(e){return new Promise(function(t,r){e.source_data={},e.source_data.layers={},e.pad_scale=this.pad_scale,e.rasters=l(this.rasters);var n=Q.tile_scale;return e.source_data.layers={_default:{type:"FeatureCollection",features:[{geometry:{type:"Polygon",coordinates:[[[0,0],[n,0],[n,-n],[0,-n],[0,0]]]},properties:{}}]}},e.default_winding="CW",t(e)}.bind(this))}},{key:"tileTexture",value:function(e){return new Promise(function(t,r){var n=this.adjustRasterTileZoom(e),i=n.key;if(!this.textures[i]){var o=this.formatURL(this.url,{coords:n});this.textures[i]={name:o,url:o,filtering:this.filtering,coords:n};}return t(this.textures[i])}.bind(this))}},{key:"adjustRasterTileZoom",value:function(e){var t=e.coords,r=this.sources[e.source];if(r!==this){var n=this.zoom_bias-r.zoom_bias;n>0?t=Je.normalizedCoord(e.coords,{zoom_bias:n,zooms:this.zooms}):(n<0&&k({level:"warn",once:!0},"Raster source '".concat(this.name,"' supports higher zoom detail than source '").concat(r.name,"' ")+"it's attached to. Downsampling this source ".concat(-n," extra zoom levels to match.")),t=Je.coordForTileZooms(t,this.zooms));}return t}}])}(Ze),et=function(e){function t(e,r){var n;return u(this,t),(n=Ke(this,t,[e,r])).load_image={},n.alpha=null!=e.alpha?Math.max(Math.min(e.alpha,1),0):null,n.mask_alpha=!0,n.preserve_tiles_within_zoom=0,n.max_display_density=e.max_display_density,Array.isArray(e.composite)?n.images=e.composite.map((function(e){return {url:e.url,bounds:n.parseBounds(e),alpha:null!=e.alpha?Math.max(Math.min(e.alpha,1),0):null}})):n.images=[{url:n.url,bounds:n.bounds,alpha:n.alpha}],n}return Se(t,e),h(t,[{key:"tileTexture",value:function(e,t){return new Promise(function(r,n){var i,o,a,s,l,u,c,h,f,d;return i=this,o=t.blend,a=t.generation,s=this.adjustRasterTileZoom(e),l="opaque"!==o,u="raster-".concat(this.name,"-").concat(s.key,"-").concat(l?"alpha":"opaque","-").concat(a),D.textures[u]?r({name:u,coords:s,skip_create:!0}):(c=M.device_pixel_ratio,this.max_display_density&&(c=Math.min(c,this.max_display_density)),c*=2,h=document.createElement("canvas"),f=h.getContext("2d"),h.width=this.tile_size*c,h.height=this.tile_size*c,f.imageSmoothingEnabled="nearest"!==this.filtering,d=this.images.filter((function(t){return i.checkBounds(e.coords,t.bounds)})),Promise.resolve(Promise.all(d.map((function(t){var r=l?null!=t.alpha?t.alpha:i.alpha:1;return i.drawImage(t.url,t.bounds,r,e,c,f)})))).then(function(e){try{return r({name:u,element:h,filtering:this.filtering,coords:s})}catch(e){return n(e)}}.bind(this),n))}.bind(this))}},{key:"drawImage",value:function(e,t,r,n,i,o){return new Promise(function(a,s){var l,u,c,h,f,d,_;return l=V(e),this.load_image[l]=this.load_image[l]||this.loadImage(e),Promise.resolve(this.load_image[l]).then(function(e){try{return u=e,c=Q.metersPerPixel(n.coords.z)/i/(this.tile_size/Q.tile_size),h=(t.meters.min[0]-n.min.x)/c,f=-(t.meters.min[1]-n.min.y)/c,d=(t.meters.max[0]-t.meters.min[0])/c,_=-(t.meters.max[1]-t.meters.min[1])/c,o.globalAlpha=null!=r?r:1,o.drawImage(u,h,f,d,_),a()}catch(e){return s(e)}}.bind(this),s)}.bind(this))}},{key:"loadImage",value:function(e){var t=this;return new Promise((function(r){var n=new Image;n.onload=function(){return r(n)},n.onerror=function(n){k("warn","Raster source '".concat(t.name,"': failed to load url: '").concat(e,"'"),n),r(null);},M.isSafari()&&"data:"===e.slice(0,5)||(n.crossOrigin="anonymous"),n.src=e;}))}},{key:"includesTile",value:function(e,t){var r=this;return !!He.prototype.includesTile.call(this,e,t)&&this.images.some((function(t){return r.checkBounds(e,t.bounds)}))}},{key:"validate",value:function(e){var t="Raster data source must provide a string `url` parameter, or an array of `composite` raster ";t+="image objects that each have a `url` parameter";var r="Raster data source must provide a `bounds` parameter, or an array of `composite` raster ";r+="image objects that each have a `bounds` parameter";if(Array.isArray(e.composite)){if(e.composite.some((function(e){return "string"!=typeof e.url})))throw Error(t);if(e.composite.some((function(e){return !(Array.isArray(e.bounds)&&4===e.bounds.length)})))throw Error(r);if(null!=e.url||null!=e.bounds)throw Error("Raster data source must have *either* a single image specified as `url` and `bounds `parameters, or an array of `composite` raster image objects, each with `url` and `bounds`.")}else {if("string"!=typeof e.url)throw Error(t);if(!Array.isArray(e.bounds)||4!==e.bounds.length)throw Error(r)}}}])}(Qe);He.register("Raster",(function(e){return Qe.urlHasTilePattern(e.url)?Qe:et}));function tt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function rt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?tt(Object(r),!0).forEach((function(t){s(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}var nt={init:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.generation,r=e.styles,n=e.sources,i=void 0===n?{}:n,o=e.introspection;this.setGeneration(t),this.styles=r,this.sources=i,this.defines=Object.prototype.hasOwnProperty.call(this,"defines")&&this.defines||{},this.shaders=Object.prototype.hasOwnProperty.call(this,"shaders")&&this.shaders||{},this.introspection=o||!1,this.selection=this.selection||this.introspection||!1,this.compile_setup=!1,this.program=null,this.selection_program=null,this.feature_style={},this.vertex_template=[],this.tile_data={},this.stencil_proxy_tiles=!0,this.variants={},this.vertex_layouts={},this.defines.TANGRAM_WORLD_POSITION_WRAP=1e5,this.blend=this.blend||"opaque","opaque"!==this.blend?null==this.blend_order&&(this.blend_order=this.default_blend_orders[this.blend]):this.blend_order=this.default_blend_orders[this.blend],this.defines["TANGRAM_BLEND_".concat(this.blend.toUpperCase())]=!0,this.removeShaderBlock("setup"),this.material instanceof Re||(Re.isValid(this.material)||(this.material=ue.defaults.material),this.material=new Re(this.material)),this.material.inject(this),Fe.setMode(this.lighting,this),this.setupRasters(),this.setupCustomAttributes(),this.initialized=!0;},destroy:function(){this.program&&(this.program.destroy(),this.program=null),this.selection_program&&(this.selection_program.destroy(),this.selection_program=null),v.removeTarget(this.main_thread_target),this.gl=null,this.initialized=!1;},reset:function(){},baseStyle:function(){return this.base||this.name},setGeneration:function(e){this.generation=e,this.main_thread_target=["Style",this.name,this.generation].join("_"),i.is_main&&v.addTarget(this.main_thread_target,this);},startData:function(e){this.tile_data[e.id]=this.tile_data[e.id]||{meshes:{},uniforms:{},textures:[]};},endData:function(e){return new Promise(function(t,r){var n=this.tile_data[e.id];if(this.tile_data[e.id]=null,n&&Object.keys(n.meshes).length>0){for(var i in n.meshes){var o=n.meshes[i];0!==o.vertex_data.vertex_count?(o.vertex_data.end(),o.vertex_elements=o.vertex_data.element_buffer,o.vertex_data=o.vertex_data.vertex_buffer):delete n.meshes[i];}return t(this.buildRasterTextures(e,n))}return t(null)}.bind(this))},hasDataForTile:function(e){return null!=this.tile_data[e.id]},getTileMesh:function(e,t){var r=this.tile_data[e.id].meshes;if(null==r[t.key]){var n=this.vertexLayoutForMeshVariant(t);r[t.key]={variant:t,vertex_data:n.createVertexData()};}return r[t.key]},vertexLayoutForMeshVariant:function(){},meshVariantTypeForDraw:function(){},addFeature:function(e,t,r){var n=r.tile;if(n.generation===this.generation){this.tile_data[n.id]||this.startData(n);var i=this.parseFeature(e,t,r);i&&this.buildGeometry(e.geometry,i,r)>0&&(e.generation=this.generation);}},buildGeometry:function(e,t,r){var n,i=this;if("Polygon"===e.type?n=this.buildPolygons([e.coordinates],t,r):"MultiPolygon"===e.type?n=this.buildPolygons(e.coordinates,t,r):"LineString"===e.type?n=this.buildLines([e.coordinates],t,r):"MultiLineString"===e.type?n=this.buildLines(e.coordinates,t,r):"Point"===e.type?n=this.buildPoints([e.coordinates],t,r):"MultiPoint"===e.type&&(n=this.buildPoints(e.coordinates,t,r)),n>0&&P.layer_stats){var o=r.tile;o.debug.layers=o.debug.layers||{list:{},tree:{}};var a=o.debug.layers.list,l=o.debug.layers.tree,u={};r.layers.forEach((function(e){it(a,e,1,n,s({},i.name,n),s({},i.baseStyle(),n));for(var t=l,r=u,o=e.split(":"),c=0;c<o.length;c++){var h=o[c];t[h]=t[h]||{features:0,geoms:0,styles:{},base:{}},null==r[h]&&(r[h]={},it(t,h,1,n,s({},i.name,n),s({},i.baseStyle(),n))),c<o.length-1&&(t[h].layers=t[h].layers||{}),t=t[h].layers,r=r[h];}}));}return n},parseFeature:function(e,t,r){try{var n=this.feature_style;if(n.order=this.parseOrder(t.order,r),null==n.order&&"overlay"!==this.blend){var i="Layer '".concat(t.layers.join(", "),"', draw group '").concat(t.group,"': ");return i+="'order' parameter is required unless blend mode is 'overlay'",null!=t.order&&(i+="; 'order' was set to a dynamic value (e.g. string tied to feature property, ",i+="or JS function), but evaluated to null for one or more features"),void k({level:"warn",once:!0},i)}if(!(n=this._parseFeature(e,t,r)))return;if(this.shaders.attributes)for(var o in n.attributes=n.attributes||{},this.shaders.attributes)n.attributes[o]=ue.evalCachedProperty(t.attributes&&t.attributes[o],r),"number"!=typeof n.attributes[o]&&(n.attributes[o]=0);return this.selection?n.interactive=ue.evalProperty(t.interactive,r):n.interactive=!1,!0===n.interactive?n.selection_color=Ae.makeColor(e,r.tile,r):n.selection_color=Ae.defaultColor,n}catch(t){k("error","Style.parseFeature: style parsing error",e,n,t.stack);}},_parseFeature:function(){return this.feature_style},preprocess:function(e){if(!e.preprocessed){if(this.draw)for(var t in this.draw){var r=this.draw[t];"object"!==o(r)||Array.isArray(r)?null==e[t]&&(e[t]=r):e[t]=$({},r,e[t]);}if(this.selection?this.introspection&&(e.interactive=!0):e.interactive=!1,!(e=this._preprocess(e)))return;if(this.shaders.attributes)for(var n in e.attributes=e.attributes||{},this.shaders.attributes)e.attributes[n]=ue.createPropertyCache(null!=e.attributes[n]?e.attributes[n]:0);e.preprocessed=!0;}return e},_preprocess:function(e){return e},parseOrder:function(e,t){return "number"!=typeof e?ue.calculateOrder(e,t):e},scaleOrder:function(e){return 2*e},parseColor:function(e,t){return e?ue.evalCachedColorProperty(e,t):this.shaders.blocks.color||this.shaders.blocks.filter?ue.defaults.color:void 0},buildPolygons:function(){return 0},buildLines:function(){return 0},buildPoints:function(){return 0},setGL:function(e){this.gl=e,this.max_texture_size=D.getMaxTextureSize(this.gl);},makeMesh:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.vertexLayoutForMeshVariant(r.variant);return P.wireframe?(t=function(e){for(var t=new Uint16Array(2*e.length),r=0;r<e.length;r+=3)t.set([e[r],e[r+1],e[r+1],e[r+2],e[r+2],e[r]],2*r);return t}(t),new Ee(this.gl,e,t,n,rt(rt({},r),{},{draw_mode:this.gl.LINES}))):new Ee(this.gl,e,t,n,r)},render:function(e){return e.render()},getProgram:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"program";this.compileSetup();var t=this[e];if(t&&!t.error){if(!t.compiled){k("debug","Compiling style '".concat(this.name,"', program key '").concat(e,"'"));try{t.compile();}catch(t){throw k("error","Style: error compiling program for style '".concat(this.name,"' (program key '").concat(e,"')"),this,t.stack,t.type,t.shader_errors),t}}return t}},compileSetup:function(){if(!this.compile_setup){if(!this.gl)throw new Error("style.compile(): skipping for ".concat(this.name," because no GL context"));var e=this.buildDefineList();if(this.selection){var t=Object.assign({},e);t.TANGRAM_FEATURE_SELECTION=!0;}var r=this.shaders&&this.shaders.blocks,n=this.shaders&&this.shaders.block_scopes,i=Object.assign({},this.shaders&&this.shaders.uniforms);for(var o in i)null==i[o]&&k({level:"warn",once:!0},"Style '".concat(this.name,"' has invalid uniform '").concat(o,"': uniform values must be non-null"));var a=this.shaders&&this.shaders.extensions;"string"==typeof a&&(a=[a]),this.program=new Z(this.gl,this.vertex_shader_src,this.fragment_shader_src,{name:this.name,defines:e,uniforms:i,blocks:r,block_scopes:n,extensions:a}),this.selection?this.selection_program=new Z(this.gl,this.vertex_shader_src,"// Fragment shader for feature selection passes\n// Renders in silhouette according to selection (picking) color, or black if none defined\n\n#ifdef TANGRAM_FEATURE_SELECTION\n    varying vec4 v_selection_color;\n#endif\n\nvoid main (void) {\n    #ifdef TANGRAM_FEATURE_SELECTION\n        gl_FragColor = v_selection_color;\n    #else\n        gl_FragColor = vec4(0., 0., 0., 1.);\n    #endif\n}\n",{name:this.name+" (selection)",defines:t,uniforms:i,blocks:r,block_scopes:n,extensions:a}):this.selection_program=null,this.compile_setup=!0;}},addShaderBlock:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.shaders.blocks=this.shaders.blocks||{},this.shaders.blocks[e]=this.shaders.blocks[e]||[],this.shaders.blocks[e].push(t),this.shaders.block_scopes=this.shaders.block_scopes||{},this.shaders.block_scopes[e]=this.shaders.block_scopes[e]||[],this.shaders.block_scopes[e].push(r);},removeShaderBlock:function(e){this.shaders.blocks&&(this.shaders.blocks[e]=null),this.shaders.block_scopes&&(this.shaders.block_scopes[e]=null);},replaceShaderBlock:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.removeShaderBlock(e),this.addShaderBlock(e,t,r);},buildDefineList:function(){var e={};if(null!=this.defines)for(var t in this.defines)e[t]=this.defines[t];if(null!=this.shaders&&null!=this.shaders.defines)for(t in this.shaders.defines)e[t]=this.shaders.defines[t];return e},hasRasters:function(){return ["color","normal","custom"].indexOf(this.raster)>-1},setupRasters:function(){var e=this;if(this.hasRasters()){"color"===this.raster?this.defines.TANGRAM_RASTER_TEXTURE_COLOR=!0:"normal"===this.raster&&(this.defines.TANGRAM_RASTER_TEXTURE_NORMAL=!0);var t=Object.keys(this.sources).filter((function(t){return e.sources[t]instanceof Qe})).length;if(this.defines.TANGRAM_NUM_RASTER_SOURCES="".concat(t),t>0){var r=Object.keys(this.sources).filter((function(t){return e.sources[t].mask_alpha})).length;this.defines.TANGRAM_HAS_MASKED_RASTERS=r>0,this.defines.TANGRAM_ALL_MASKED_RASTERS=r===t,this.defines.TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING=!0,this.replaceShaderBlock("raster","// Uniforms defining raster textures and macros for accessing them\n\n#ifdef TANGRAM_FRAGMENT_SHADER\nuniform sampler2D u_rasters[TANGRAM_NUM_RASTER_SOURCES];    // raster tile texture samplers\nuniform vec2 u_raster_sizes[TANGRAM_NUM_RASTER_SOURCES];    // raster tile texture sizes (width/height in pixels)\nuniform vec3 u_raster_offsets[TANGRAM_NUM_RASTER_SOURCES];  // raster tile texture UV starting offset for tile\n\n// Raster sources can optionally mask by the alpha channel (render with only full or no alpha, based on a threshold),\n// which is used for handling transparency outside the raster image when rendering with opaque blending\n#if defined(TANGRAM_HAS_MASKED_RASTERS) && !defined(TANGRAM_ALL_MASKED_RASTERS) // only add uniform if we need it\nuniform bool u_raster_mask_alpha;\n#endif\n\n// Note: the raster accessors below are #defines rather than functions to\n// avoid issues with constant integer expressions for array indices\n\n// Adjusts UVs in model space to account for raster tile texture overzooming\n// (applies scale and offset adjustments)\n#define adjustRasterUV(raster_index, uv) \\\n    ((uv) * u_raster_offsets[raster_index].z + u_raster_offsets[raster_index].xy)\n\n// Returns the UVs of the current model position for a raster sampler\n#define currentRasterUV(raster_index) \\\n    (adjustRasterUV(raster_index, v_modelpos_base_zoom.xy))\n\n// Returns pixel location in raster tile texture at current model position\n#define currentRasterPixel(raster_index) \\\n    (currentRasterUV(raster_index) * rasterPixelSize(raster_index))\n\n// Samples a raster tile texture for the current model position\n#define sampleRaster(raster_index) \\\n    (texture2D(u_rasters[raster_index], currentRasterUV(raster_index)))\n\n// Samples a raster tile texture for a given pixel\n#define sampleRasterAtPixel(raster_index, pixel) \\\n    (texture2D(u_rasters[raster_index], (pixel) / rasterPixelSize(raster_index)))\n\n// Returns size of raster sampler in pixels\n#define rasterPixelSize(raster_index) \\\n    (u_raster_sizes[raster_index])\n\n#endif\n","Raster");}}},buildRasterTextures:function(e,t){return new Promise(function(r,n){var i,o,a,s;if(!this.hasRasters())return r(t);if(0===e.rasters.length)return r(t);var l=function(){try{return !i||i.length<1?r(t):i.some((function(e){return !e.loaded}))?r(null):(t.uniforms.u_raster_mask_alpha=!0===this.sources[e.rasters[0]].mask_alpha,o=t.uniforms.u_rasters=[],a=t.uniforms.u_raster_sizes=[],s=t.uniforms.u_raster_offsets=[],i.forEach((function(r){var n=r.index;if(o[n]=r.name,t.textures.push(r.name),a[n]=[r.width,r.height],e.coords.z>r.coords.z){var i=e.coords.z-r.coords.z,l=Math.pow(2,i);s[n]=[(e.coords.x%l+l)%l/l,(l-1-e.coords.y%l)/l,1/l];}else s[n]=[0,0,1];})),r(t))}catch(e){return n(e)}}.bind(this),u=function(e){try{return r(t)}catch(e){return n(e)}};try{return Promise.resolve(v.postMessage("".concat(this.main_thread_target,".loadTextures"),{coords:e.coords,source:e.source,rasters:e.rasters,min:e.min,max:e.max})).then((function(e){try{return i=e,l()}catch(e){return u()}}),u)}catch(e){u();}}.bind(this))},loadTextures:function(e){return new Promise(function(t,r){var n,i,o,a,s;return n=this,i={},o={},a=[],e.rasters.map((function(e){return n.sources[e]})).filter((function(e){return e})).forEach((function(t,r){t instanceof Qe&&a.push(t.tileTexture(e,n).then((function(e){i[e.name]=e,o[e.name]=r;})));})),Promise.resolve(Promise.all(a)).then(function(e){try{return Promise.resolve(D.createFromObject(this.gl,i)).then((function(e){try{return Promise.resolve(Promise.all(Object.keys(i).map((function(e){return D.textures[e]&&D.textures[e].load()})).filter((function(e){return e})))).then((function(e){try{return (s=e).forEach((function(e){return e.retain()})),t(s.map((function(e){return {name:e.name,width:e.width,height:e.height,loaded:e.loaded,index:o[e.name],coords:i[e.name].coords}})))}catch(e){return r(e)}}),r)}catch(e){return r(e)}}),r)}catch(e){return r(e)}}.bind(this),r)}.bind(this))},setupCustomAttributes:function(){if(this.shaders.attributes)for(var e=0,t=Object.entries(this.shaders.attributes);e<t.length;e++){var r=n(t[e],2),i=r[0],o=r[1];"float"===o.type&&(!1!==o.varying?(this.addShaderBlock("attributes","\n                            #ifdef TANGRAM_VERTEX_SHADER\n                                attribute float a_".concat(i,";\n                                varying float v_").concat(i,";\n                                #define ").concat(i," a_").concat(i,"\n                            #else\n                                varying float v_").concat(i,";\n                                #define ").concat(i," v_").concat(i,"\n                            #endif\n                        ")),this.addShaderBlock("setup","#ifdef TANGRAM_VERTEX_SHADER\nv_".concat(i," = a_").concat(i,";\n#endif"))):this.addShaderBlock("attributes","\n                            #ifdef TANGRAM_VERTEX_SHADER\n                                attribute float a_".concat(i,";\n                                #define ").concat(i," a_").concat(i,"\n                            #endif\n                        ")));}},addCustomAttributesToAttributeList:function(e){if(this.shaders.attributes)for(var t=0,r=Object.entries(this.shaders.attributes);t<r.length;t++){var i=n(r[t],2),o=i[0];"float"===i[1].type&&e.push({name:"a_".concat(o),size:1,type:Te.FLOAT,normalized:!1});}return e},addCustomAttributesToVertexTemplate:function(e,t){if(this.shaders.attributes)for(var r in this.shaders.attributes)this.vertex_template[t++]=null!=e.attributes[r]?e.attributes[r]:0;},setup:function(){this.setUniforms(),this.material.setupProgram(Z.current);},setUniforms:function(){var e,t=Z.current;t&&t.setUniforms(null===(e=this.shaders)||void 0===e?void 0:e.uniforms,!0);},render_states:{opaque:{depth_test:!0,depth_write:!0},translucent:{depth_test:!0,depth_write:!0},add:{depth_test:!0,depth_write:!1},multiply:{depth_test:!0,depth_write:!1},inlay:{depth_test:!0,depth_write:!1},overlay:{depth_test:!1,depth_write:!1}},default_blend_orders:{opaque:Number.MIN_SAFE_INTEGER,add:1,multiply:2,inlay:3,translucent:4,overlay:5},getBlendOrderForDraw:function(e){return "opaque"!==this.blend&&null!=e.blend_order?e.blend_order:this.blend_order}};function it(e,t,r,n,i,o){for(var a in e[t]=e[t]||{features:0,geoms:0,styles:{},base:{}},e[t].features+=r,e[t].geoms+=n,i)e[t].styles[a]=e[t].styles[a]||0,e[t].styles[a]+=i[a];for(var s in o)e[t].base[s]=e[t].base[s]||0,e[t].base[s]+=o[s];}var ot=Math.pow(2,16)-1,at=!1,st=function(){return h((function e(){u(this,e),this.array=[],this.has_overflown=!1;}),[{key:"push",value:function(e){this.has_overflown&&!at||e>ot&&(this.has_overflown=!0,!at)||this.array.push(e);}},{key:"end",value:function(){if(this.array.length){var e=(t=this.array,new(this.has_overflown&&at?Uint32Array:Uint16Array)(t));return this.array=[],this.has_overflown=!1,e}return !1;var t;}}])}();st.setElementIndexUint=function(e){at=e;};var lt=s(s(s(s(s(s(s({},Te.FLOAT,Float32Array),Te.BYTE,Int8Array),Te.UNSIGNED_BYTE,Uint8Array),Te.INT,Int32Array),Te.UNSIGNED_INT,Uint32Array),Te.SHORT,Int16Array),Te.UNSIGNED_SHORT,Uint16Array),ut=function(){function e(t){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).prealloc,n=void 0===r?500:r;u(this,e),this.vertex_layout=t,this.vertex_elements=new st,this.stride=this.vertex_layout.stride,e.array_pool.length>0?(this.vertex_buffer=e.array_pool.pop(),this.byte_length=this.vertex_buffer.byteLength,this.size=Math.floor(this.byte_length/this.stride),k("trace","VertexData: reused buffer of bytes ".concat(this.byte_length,", ").concat(this.size," vertices"))):(this.size=n,this.byte_length=this.stride*this.size,this.vertex_buffer=new Uint8Array(this.byte_length)),this.offset=0,this.vertex_count=0,this.realloc_count=0,this.setBufferViews(),this.setAddVertexFunction();}return h(e,[{key:"setBufferViews",value:function(){var e=this;this.views={},this.views[Te.UNSIGNED_BYTE]=this.vertex_buffer,this.vertex_layout.dynamic_attribs.forEach((function(t){if(null==e.views[t.type]){var r=lt[t.type];e.views[t.type]=new r(e.vertex_buffer.buffer);}}));}},{key:"checkBufferSize",value:function(){if(this.offset+this.stride>this.byte_length){this.size=Math.floor(1.5*this.size),this.size-=this.size%4,this.byte_length=this.stride*this.size;var t=new Uint8Array(this.byte_length);t.set(this.vertex_buffer),e.array_pool.push(this.vertex_buffer),this.vertex_buffer=t,this.setBufferViews(),this.realloc_count++;}}},{key:"setAddVertexFunction",value:function(){this.vertexLayoutAddVertex=this.vertex_layout.getAddVertexFunction();}},{key:"addVertex",value:function(e){this.checkBufferSize(),this.vertexLayoutAddVertex(e,this.views,this.offset),this.offset+=this.stride,this.vertex_count++;}},{key:"end",value:function(){return this.vertex_buffer=this.vertex_buffer.subarray(0,this.offset),this.element_buffer=this.vertex_elements.end(),k("trace","VertexData: ".concat(this.size," vertices total, realloc count ").concat(this.realloc_count)),this}}])}();ut.array_pool=[];var ct=function(){function e(t){u(this,e),this.attribs=t,this.dynamic_attribs=this.attribs.filter((function(e){return null==e.static})),this.static_attribs=this.attribs.filter((function(e){return null!=e.static})),this.components=[],this.index={},this.offset={},this.stride=0;for(var r=0,n=0,i=0;i<this.attribs.length;i++){var o=this.attribs[i];if(null==o.static){o.offset=this.stride,o.byte_size=o.size;var a=0;switch(o.type){case Te.FLOAT:case Te.INT:case Te.UNSIGNED_INT:o.byte_size*=4,a=2;break;case Te.SHORT:case Te.UNSIGNED_SHORT:o.byte_size*=2,a=1;}3&o.byte_size&&(o.byte_size+=4-(3&o.byte_size)),this.stride+=o.byte_size;for(var s=o.offset>>a,l=0;l<o.size;l++)this.components.push({type:o.type,shift:a,offset:s++,index:n++});this.index[o.name]=r,r+=o.size,this.offset[o.name]=o.offset;}else o.static=Array.isArray(o.static)?o.static:[o.static],o.method="vertexAttrib".concat(o.static.length,"fv");}}return h(e,[{key:"enableDynamicAttributes",value:function(t,r){var n=this;for(var i in e.enabled_attribs)t.disableVertexAttribArray(i);e.enabled_attribs={},this.dynamic_attribs.forEach((function(i){var o=r.attribute(i.name).location;-1!==o&&(t.enableVertexAttribArray(o),t.vertexAttribPointer(o,i.size,i.type,i.normalized,n.stride,i.offset),e.enabled_attribs[o]=r);}));}},{key:"enableStaticAttributes",value:function(e,t){this.static_attribs.forEach((function(r){var n=t.attribute(r.name).location;-1!==n&&e[r.method]instanceof Function&&(e.enableVertexAttribArray(n),e[r.method](n,r.static),e.disableVertexAttribArray(n));}));}},{key:"createVertexData",value:function(){return new ut(this)}},{key:"getAddVertexFunction",value:function(){return null==this.addVertex&&this.createAddVertexFunction(),this.addVertex}},{key:"createAddVertexFunction",value:function(){var t=V(JSON.stringify(this.attribs));if(null==e.add_vertex_funcs[t]){var r,n=["var t, o;"],i=l(this.components);i.sort((function(e,t){return e.type!==t.type?e.type-t.type:e.index-t.index}));for(var o=0;o<i.length;o++){var a=i[o];r!==a.type&&(n.push("t = vs[".concat(a.type,"];")),n.push("o = off".concat(a.shift?" >> "+a.shift:"",";")),r=a.type),n.push("t[o + ".concat(a.offset,"] = v[").concat(a.index,"];"));}n=n.join("\n");var s=new Function("v","vs","off",n);e.add_vertex_funcs[t]=s;}this.addVertex=e.add_vertex_funcs[t];}}])}();ct.enabled_attribs={},ct.add_vertex_funcs={};var ht=[{x:0,y:0},{x:Q.tile_scale,y:-Q.tile_scale}],ft=[0,0,1,1];function dt(e,t,r){var n=ht[0],i=ht[1];return e[0]<=n.x+r&&t[0]<=n.x+r||e[0]>=i.x-r&&t[0]>=i.x-r||e[1]>=n.y-r&&t[1]>=n.y-r||e[1]<=i.y+r&&t[1]<=i.y+r}function _t(e,t){t=t||0;var r=ht[0],n=ht[1];return e[0]<=r.x+t||e[0]>=n.x-t||e[1]>=r.y-t||e[1]<=n.y+t}var pt,mt={exports:{}};var vt=function(){if(pt)return mt.exports;function e(e,i,o){o=o||2;var a,s,c,h,d,_,p,m=i&&i.length,v=m?i[0]*o:e.length,g=t(e,0,v,o,!0),y=[];if(!g||g.next===g.prev)return y;if(m&&(g=function(e,n,i,o){var a,s,c,h=[];for(a=0,s=n.length;a<s;a++)(c=t(e,n[a]*o,a<s-1?n[a+1]*o:e.length,o,!1))===c.next&&(c.steiner=!0),h.push(f(c));for(h.sort(l),a=0;a<h.length;a++)u(h[a],i),i=r(i,i.next);return i}(e,i,g,o)),e.length>80*o){a=c=e[0],s=h=e[1];for(var x=o;x<v;x+=o)(d=e[x])<a&&(a=d),(_=e[x+1])<s&&(s=_),d>c&&(c=d),_>h&&(h=_);p=0!==(p=Math.max(c-a,h-s))?1/p:0;}return n(g,y,o,a,s,p),y}function t(e,t,r,n,i){var o,a;if(i===E(e,t,r,n)>0)for(o=t;o<r;o+=n)a=A(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=A(o,e[o],e[o+1],a);return a&&m(a,a.next)&&(T(a),a=a.next),a}function r(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!m(n,n.next)&&0!==p(n.prev,n,n.next))n=n.next;else {if(T(n),(n=t=n.prev)===n.next)break;r=!0;}}while(r||n!==t);return t}function n(e,t,l,u,c,f,d){if(e){!d&&f&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=h(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,l,u=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;t<u&&(s++,n=n.nextZ);t++);for(l=u;s>0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n;}o.nextZ=null,u*=2;}while(a>1)}(i);}(e,u,c,f);for(var _,p,m=e;e.prev!==e.next;)if(_=e.prev,p=e.next,f?o(e,u,c,f):i(e))t.push(_.i/l),t.push(e.i/l),t.push(p.i/l),T(e),e=p.next,m=p.next;else if((e=p)===m){d?1===d?n(e=a(r(e),t,l),t,l,u,c,f,2):2===d&&s(e,t,l,u,c,f):n(r(e),t,l,u,c,f,1);break}}}function i(e){var t=e.prev,r=e,n=e.next;if(p(t,r,n)>=0)return !1;for(var i=e.next.next;i!==e.prev;){if(d(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&p(i.prev,i,i.next)>=0)return !1;i=i.next;}return !0}function o(e,t,r,n){var i=e.prev,o=e,a=e.next;if(p(i,o,a)>=0)return !1;for(var s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,u=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,f=h(s,l,t,r,n),_=h(u,c,t,r,n),m=e.prevZ,v=e.nextZ;m&&m.z>=f&&v&&v.z<=_;){if(m!==e.prev&&m!==e.next&&d(i.x,i.y,o.x,o.y,a.x,a.y,m.x,m.y)&&p(m.prev,m,m.next)>=0)return !1;if(m=m.prevZ,v!==e.prev&&v!==e.next&&d(i.x,i.y,o.x,o.y,a.x,a.y,v.x,v.y)&&p(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}for(;m&&m.z>=f;){if(m!==e.prev&&m!==e.next&&d(i.x,i.y,o.x,o.y,a.x,a.y,m.x,m.y)&&p(m.prev,m,m.next)>=0)return !1;m=m.prevZ;}for(;v&&v.z<=_;){if(v!==e.prev&&v!==e.next&&d(i.x,i.y,o.x,o.y,a.x,a.y,v.x,v.y)&&p(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}return !0}function a(e,t,n){var i=e;do{var o=i.prev,a=i.next.next;!m(o,a)&&v(o,i,i.next,a)&&x(o,a)&&x(a,o)&&(t.push(o.i/n),t.push(i.i/n),t.push(a.i/n),T(i),T(i.next),i=e=a),i=i.next;}while(i!==e);return r(i)}function s(e,t,i,o,a,s){var l=e;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&_(l,u)){var c=b(l,u);return l=r(l,l.next),c=r(c,c.next),n(l,t,i,o,a,s),void n(c,t,i,o,a,s)}u=u.next;}l=l.next;}while(l!==e)}function l(e,t){return e.x-t.x}function u(e,t){if(t=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x<n.next.x?n:n.next;}}n=n.next;}while(n!==t);if(!r)return null;if(i===a)return r;var l,u=r,h=r.x,f=r.y,_=1/0;n=r;do{i>=n.x&&n.x>=h&&i!==n.x&&d(o<f?i:a,o,h,f,o<f?a:i,o,n.x,n.y)&&(l=Math.abs(o-n.y)/(i-n.x),x(n,e)&&(l<_||l===_&&(n.x>r.x||n.x===r.x&&c(r,n)))&&(r=n,_=l)),n=n.next;}while(n!==u);return r}(e,t),t){var n=b(t,e);r(t,t.next),r(n,n.next);}}function c(e,t){return p(e.prev,e,t.prev)<0&&p(t.next,e,e.next)<0}function h(e,t,r,n,i){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function f(e){var t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;}while(t!==e);return r}function d(e,t,r,n,i,o,a,s){return (i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function _(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&v(r,r.next,e,t))return !0;r=r.next;}while(r!==e);return !1}(e,t)&&(x(e,t)&&x(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==e);return n}(e,t)&&(p(e.prev,e,t.prev)||p(e,t.prev,t))||m(e,t)&&p(e.prev,e,e.next)>0&&p(t.prev,t,t.next)>0)}function p(e,t,r){return (t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function m(e,t){return e.x===t.x&&e.y===t.y}function v(e,t,r,n){var i=y(p(e,t,r)),o=y(p(e,t,n)),a=y(p(r,n,e)),s=y(p(r,n,t));return i!==o&&a!==s||(!(0!==i||!g(e,r,t))||(!(0!==o||!g(e,n,t))||(!(0!==a||!g(r,e,n))||!(0!==s||!g(r,t,n)))))}function g(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function y(e){return e>0?1:e<0?-1:0}function x(e,t){return p(e.prev,e,e.next)<0?p(e,t,e.next)>=0&&p(e,e.prev,t)>=0:p(e,t,e.prev)<0||p(e,e.next,t)<0}function b(e,t){var r=new w(e.i,e.x,e.y),n=new w(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function A(e,t,r,n){var i=new w(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function T(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ);}function w(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1;}function E(e,t,r,n){for(var i=0,o=t,a=r-n;o<r;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}return pt=1,mt.exports=e,mt.exports.default=e,e.deviation=function(e,t,r,n){var i=t&&t.length,o=i?t[0]*r:e.length,a=Math.abs(E(e,0,o,r));if(i)for(var s=0,l=t.length;s<l;s++){var u=t[s]*r,c=s<l-1?t[s+1]*r:e.length;a-=Math.abs(E(e,u,c,r));}var h=0;for(s=0;s<n.length;s+=3){var f=n[s]*r,d=n[s+1]*r,_=n[s+2]*r;h+=Math.abs((e[f]-e[_])*(e[d+1]-e[f+1])-(e[f]-e[d])*(e[_+1]-e[f+1]));}return 0===a&&0===h?0:Math.abs((h-a)/a)},e.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var a=0;a<t;a++)r.vertices.push(e[i][o][a]);i>0&&(n+=e[i-1].length,r.holes.push(n));}return r},mt.exports}(),gt=q(vt);function yt(e,t,r=0,n=e.length-1,i=bt){for(;n>r;){if(n-r>600){const o=n-r+1,a=t-r+1,s=Math.log(o),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(o-l)/o)*(a-o/2<0?-1:1);yt(e,t,Math.max(r,Math.floor(t-a*l/o+u)),Math.min(n,Math.floor(t+(o-a)*l/o+u)),i);}const o=e[t];let a=r,s=n;for(xt(e,r,t),i(e[n],o)>0&&xt(e,r,n);a<s;){for(xt(e,a,s),a++,s--;i(e[a],o)<0;)a++;for(;i(e[s],o)>0;)s--;}0===i(e[r],o)?xt(e,r,s):(s++,xt(e,s,n)),s<=t&&(r=s+1),t<=s&&(n=s-1);}}function xt(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function bt(e,t){return e<t?-1:e>t?1:0}var At=[0,0,1];function Tt(e,t,r,i){var o,a,s,u,c,h,f,d,_,p=i.texcoord_index,m=i.texcoord_scale,v=i.texcoord_normalize,g=t.vertex_elements,y=e.length,x=0;if(p){v=v||1;var b=n(m||ft,4);o=b[0],a=b[1],s=b[2],u=b[3];}for(var A=0;A<y;A++){var T=e[A];T.length>500&&(yt(T=l(T),500,1,T.length-1,(function(e,t){return t.area-e.area})),T=T.slice(0,500));var w=(_=gt.flatten(T),gt(_.vertices,_.holes,_.dimensions)),E=w.length,k=t.vertex_count;if(E){var R;if(p)c=(R=n(Q.findBoundingBox(T),4))[0],h=R[1],f=(s-o)/(R[2]-c),d=(u-a)/(R[3]-h);for(var M=0;M<T.length;M++)for(var z=T[M],P=0;P<z.length;P++){var S=z[P];r[0]=S[0],r[1]=S[1],p&&(r[p+0]=((S[0]-c)*f+o)*v,r[p+1]=((S[1]-h)*d+a)*v),t.addVertex(r);}for(var N=0;N<E;N++)g.push(k+w[N]);x+=E/3;}}return x}var wt='uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_tile_proxy_order_offset;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\n\nuniform mat4 u_model;\nuniform mat4 u_modelView;\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nattribute vec4 a_position;\nattribute vec4 a_color;\n\n// Optional normal attribute, otherwise default to up\n#ifdef TANGRAM_NORMAL_ATTRIBUTE\n    attribute vec3 a_normal;\n    #define TANGRAM_NORMAL a_normal\n#else\n    #define TANGRAM_NORMAL vec3(0., 0., 1.)\n#endif\n\n// Optional dynamic line extrusion\n#ifdef TANGRAM_EXTRUDE_LINES\n    attribute vec2 a_extrude; // extrusion direction in xy plane\n    attribute vec2 a_offset;  // offset direction in xy plane\n\n    // Polygon and line styles have slightly different VBO layouts, saving memory by optimizing vertex packing.\n    // All lines have a width scaling factor, but only some have a height (position.z) or offset.\n    // The vertex height is stored in different attributes to account for this.\n    attribute vec2 a_z_and_offset_scale; // stores vertex height in x, and offset scaling factor in y\n    #define TANGRAM_POSITION_Z a_z_and_offset_scale.x // vertex height is stored in separate line-specific attrib\n    #define TANGRAM_OFFSET_SCALING a_z_and_offset_scale.y // zoom scaling factor for line offset\n    #define TANGRAM_WIDTH_SCALING a_position.z // zoom scaling factor for line width (stored in position attrib)\n\n    uniform float u_v_scale_adjust; // scales texture UVs for line dash patterns w/fractional pixel width\n#else\n    #define TANGRAM_POSITION_Z a_position.z // vertex height\n#endif\n\nvarying vec4 v_position;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvarying vec4 v_world_position;\n\n// Optional texture UVs\n#if defined(TANGRAM_TEXTURE_COORDS) || defined(TANGRAM_EXTRUDE_LINES)\n    attribute vec2 a_texcoord;\n    varying vec2 v_texcoord;\n#endif\n\n// Optional model position varying for tile coordinate zoom\n#ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n    varying vec4 v_modelpos_base_zoom;\n#endif\n\n#if defined(TANGRAM_LIGHTING_VERTEX)\n    varying vec4 v_lighting;\n#endif\n\n#define TANGRAM_UNPACK_SCALING(x) (x / 1024.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvoid main() {\n    // Initialize globals\n    #pragma tangram: setup\n\n    // Texture UVs\n    #ifdef TANGRAM_TEXTURE_COORDS\n        v_texcoord = a_texcoord;\n        #ifdef TANGRAM_EXTRUDE_LINES\n            v_texcoord.y *= u_v_scale_adjust;\n        #endif\n    #endif\n\n    // Pass model position to fragment shader\n    #ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n        v_modelpos_base_zoom = modelPositionBaseZoom();\n    #endif\n\n    // Position\n    vec4 position = vec4(a_position.xy, TANGRAM_POSITION_Z / TANGRAM_HEIGHT_SCALE, 1.); // convert height back to meters\n\n    #ifdef TANGRAM_EXTRUDE_LINES\n        vec2 _extrude = a_extrude.xy;\n        vec2 _offset = a_offset.xy;\n\n        // Adjust line width based on zoom level, to prevent proxied lines\n        // from being either too small or too big.\n        // "Flattens" the zoom between 1-2 to peg it to 1 (keeps lines from\n        // prematurely shrinking), then interpolate and clamp to 4 (keeps lines\n        // from becoming too small when far away).\n        float _dz = clamp(u_map_position.z - u_tile_origin.z, 0., 4.);\n        _dz += step(1., _dz) * (1. - _dz) + mix(0., 2., clamp((_dz - 2.) / 2., 0., 1.));\n\n        // Interpolate line width between zooms\n        float _mdz = (_dz - 0.5) * 2.; // zoom from mid-point\n        _extrude -= _extrude * TANGRAM_UNPACK_SCALING(TANGRAM_WIDTH_SCALING) * _mdz;\n\n        // Interpolate line offset between zooms\n        // Scales from the larger value to the smaller one\n        float _dwdz = TANGRAM_UNPACK_SCALING(TANGRAM_OFFSET_SCALING);\n        float _sdwdz = sign(step(0., _dwdz) - 0.5); // sign indicates "direction" of scaling\n        _offset -= _offset * abs(_dwdz) * ((1.-step(0., _sdwdz)) - (_dz * -_sdwdz)); // scale "up" or "down"\n\n        // Scale line width and offset to be consistent in screen space\n        float _ssz = exp2(-_dz - (u_tile_origin.z - u_tile_origin.w));\n        _extrude *= _ssz;\n        _offset *= _ssz;\n\n        // Modify line width before extrusion\n        #ifdef TANGRAM_BLOCK_WIDTH\n            float width = 1.;\n            #pragma tangram: width\n            _extrude *= width;\n        #endif\n\n        position.xy += _extrude + _offset;\n    #endif\n\n    // World coordinates for 3d procedural textures\n    v_world_position = wrapWorldPosition(u_model * position);\n\n    // Adjust for tile and view position\n    position = u_modelView * position;\n\n    // Modify position before camera projection\n    #pragma tangram: position\n\n    // Setup varyings\n    v_position = position;\n    v_normal = normalize(u_normalMatrix * TANGRAM_NORMAL);\n    v_color = a_color;\n\n    #if defined(TANGRAM_LIGHTING_VERTEX)\n        // Vertex lighting\n        vec3 normal = v_normal;\n\n        // Modify normal before lighting\n        #pragma tangram: normal\n\n        // Pass lighting intensity to fragment shader\n        v_lighting = calculateLighting(position.xyz - u_eye, normal, vec4(1.));\n    #endif\n\n    // Camera\n    cameraProjection(position);\n\n    // +1 is to keep all layers including proxies > 0\n    applyLayerOrder(a_position.w + u_tile_proxy_order_offset + 1., position);\n\n    gl_Position = position;\n}\n',Et="uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\n\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nvarying vec4 v_position;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvarying vec4 v_world_position;\n\n#ifdef TANGRAM_EXTRUDE_LINES\n    uniform bool u_has_line_texture;\n    uniform sampler2D u_texture;\n    uniform float u_texture_ratio;\n    uniform vec4 u_dash_background_color;\n    uniform float u_has_dash;\n#endif\n\n#define TANGRAM_NORMAL v_normal\n\n#if defined(TANGRAM_TEXTURE_COORDS) || defined(TANGRAM_EXTRUDE_LINES)\n    varying vec2 v_texcoord;\n#endif\n\n#ifdef TANGRAM_MODEL_POSITION_BASE_ZOOM_VARYING\n    varying vec4 v_modelpos_base_zoom;\n#endif\n\n#if defined(TANGRAM_LIGHTING_VERTEX)\n    varying vec4 v_lighting;\n#endif\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvoid main (void) {\n    // Initialize globals\n    #pragma tangram: setup\n\n    vec4 color = v_color;\n    vec3 normal = TANGRAM_NORMAL;\n\n    // Apply raster to vertex color\n    #ifdef TANGRAM_RASTER_TEXTURE_COLOR\n        vec4 _raster_color = sampleRaster(0);\n\n        #if defined(TANGRAM_BLEND_OPAQUE) || defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n            // Raster sources can optionally mask by the alpha channel, which will render with only full or no alpha.\n            // This is used for handling transparency outside the raster image in some blend modes,\n            // which either don't support alpha, or would cause transparent pixels to write to the depth buffer,\n            // obscuring geometry underneath.\n            #ifdef TANGRAM_HAS_MASKED_RASTERS   // skip masking logic if no masked raster sources\n            #ifndef TANGRAM_ALL_MASKED_RASTERS  // skip source check for masking if *all* raster sources are masked\n            if (u_raster_mask_alpha) {\n            #else\n            {\n            #endif\n                #if defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n                if (_raster_color.a < TANGRAM_EPSILON) {\n                    discard;\n                }\n                #else // TANGRAM_BLEND_OPAQUE\n                if (_raster_color.a < 1. - TANGRAM_EPSILON) {\n                    discard;\n                }\n                // only allow full alpha in opaque blend mode (avoids artifacts blending w/canvas tile background)\n                _raster_color.a = 1.;\n                #endif\n            }\n            #endif\n        #endif\n\n        color *= _raster_color; // multiplied to tint texture color\n    #endif\n\n    // Apply line texture\n    #ifdef TANGRAM_EXTRUDE_LINES\n    { // enclose in scope to avoid leakage of internal variables\n        if (u_has_line_texture) {\n            vec2 _line_st = vec2(v_texcoord.x, fract(v_texcoord.y / u_texture_ratio));\n            vec4 _line_color = texture2D(u_texture, _line_st);\n\n            // If the line has a dash pattern, the line texture indicates if the current fragment should be\n            // the dash foreground or background color. If the line doesn't have a dash pattern,\n            // the line texture color is used directly (but also tinted by the vertex color).\n            color = mix(\n                color * _line_color, // no dash: tint the line texture with the vertex color\n                mix(u_dash_background_color, color, _line_color.a), // choose dash foreground or background color\n                u_has_dash // 0 if no dash, 1 if has dash\n            );\n\n            // Use alpha discard test as a lower-quality substitute for blending\n            #if defined(TANGRAM_BLEND_OPAQUE)\n                if (color.a < TANGRAM_ALPHA_TEST) {\n                    discard;\n                }\n            #endif\n        }\n    }\n    #endif\n\n    // First, get normal from raster tile (if applicable)\n    #ifdef TANGRAM_RASTER_TEXTURE_NORMAL\n        normal = normalize(sampleRaster(0).rgb * 2. - 1.);\n    #endif\n\n    // Second, alter normal with normal map texture (if applicable)\n    #if defined(TANGRAM_LIGHTING_FRAGMENT) && defined(TANGRAM_MATERIAL_NORMAL_TEXTURE)\n        calculateNormal(normal);\n    #endif\n\n    // Normal modification applied here for fragment lighting or no lighting,\n    // and in vertex shader for vertex lighting\n    #if !defined(TANGRAM_LIGHTING_VERTEX)\n        #pragma tangram: normal\n    #endif\n\n    // Color modification before lighting is applied\n    #pragma tangram: color\n\n    #if defined(TANGRAM_LIGHTING_FRAGMENT)\n        // Calculate per-fragment lighting\n        color = calculateLighting(v_position.xyz - u_eye, normal, color);\n    #elif defined(TANGRAM_LIGHTING_VERTEX)\n        // Apply lighting intensity interpolated from vertex shader\n        color *= v_lighting;\n    #endif\n\n    // Post-processing effects (modify color after lighting)\n    #pragma tangram: filter\n\n    gl_FragColor = color;\n}\n",kt=Object.create(nt);Object.assign(kt,{name:"polygons",built_in:!0,vertex_shader_src:wt,fragment_shader_src:Et,selection:!0,init:function(){nt.init.apply(this,arguments),this.defines.TANGRAM_NORMAL_ATTRIBUTE=!0,this.defines.TANGRAM_TEXTURE_COORDS=this.texcoords;},_parseFeature:function(e,t,r){var n=this.feature_style;return n.color=this.parseColor(t.color,r),n.color?(n.alpha=ue.evalCachedProperty(t.alpha,r),n.variant=t.variant,n.z=ue.evalCachedDistanceProperty(t.z,r)||ue.defaults.z,n.z*=Q.height_scale,n.extrude=ue.evalProperty(t.extrude,r),n.extrude&&(!0===n.extrude?(n.height=e.properties.height||ue.defaults.height,n.min_height=e.properties.min_height||ue.defaults.min_height):"number"==typeof n.extrude?(n.height=n.extrude,n.min_height=0):Array.isArray(n.extrude)&&(n.min_height=n.extrude[0],n.height=n.extrude[1]),n.height*=Q.height_scale,n.min_height*=Q.height_scale),n.tile_edges=t.tile_edges,n):null},_preprocess:function(e){return e.color=ue.createColorPropertyCache(e.color),e.alpha=ue.createPropertyCache(e.alpha),e.z=ue.createPropertyCache(e.z,ue.parseUnits),this.computeVariant(e),e},computeVariant:function(e){var t=e.interactive?1:0,r=null!=e.extrude?1:0,n=this.texcoords?1:0,i=this.getBlendOrderForDraw(e),o=[t,r,n,i].join("/");e.variant=o,null==this.variants[o]&&(this.variants[o]={key:o,blend_order:i,mesh_order:0,selection:t,normal:r,texcoords:n});},vertexLayoutForMeshVariant:function(e){if(null==this.vertex_layouts[e.key]){var t=[{name:"a_position",size:4,type:Te.SHORT,normalized:!1},{name:"a_normal",size:3,type:Te.BYTE,normalized:!0,static:e.normal?null:[0,0,1]},{name:"a_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_texcoord",size:2,type:Te.UNSIGNED_SHORT,normalized:!0,static:e.texcoords?null:[0,0]}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.key]=new ct(t);}return this.vertex_layouts[e.key]},meshVariantTypeForDraw:function(e){return this.variants[e.variant]},makeVertexTemplate:function(e,t){var r=0;return this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=e.z||0,this.vertex_template[r++]=this.scaleOrder(e.order),t.variant.normal&&(this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=127),this.vertex_template[r++]=255*e.color[0],this.vertex_template[r++]=255*e.color[1],this.vertex_template[r++]=255*e.color[2],this.vertex_template[r++]=255*(null!=e.alpha?e.alpha:e.color[3]),t.variant.selection&&(this.vertex_template[r++]=255*e.selection_color[0],this.vertex_template[r++]=255*e.selection_color[1],this.vertex_template[r++]=255*e.selection_color[2],this.vertex_template[r++]=255*e.selection_color[3]),t.variant.texcoords&&(this.vertex_template[r++]=0,this.vertex_template[r++]=0),this.addCustomAttributesToVertexTemplate(e,r),this.vertex_template},buildPolygons:function(e,t,r){var i=this.getTileMesh(r.tile,this.meshVariantTypeForDraw(t)),o=i.vertex_data,a=o.vertex_layout,s=this.makeVertexTemplate(t,i),l={texcoord_index:a.index.a_texcoord,texcoord_normalize:65535,remove_tile_edges:!t.tile_edges,tile_edge_tolerance:Q.tile_scale*r.tile.pad_scale*4,winding:r.winding};return t.extrude&&t.height?function(e,t,r,i,o,a,s,l,u){var c=u.remove_tile_edges,h=u.tile_edge_tolerance,f=u.texcoord_index,d=u.texcoord_scale,_=u.texcoord_normalize,p=u.winding,m=t+(i||0),v=t+r;a[2]=v;var g=Tt(e,o,a,{texcoord_index:f,texcoord_scale:d,texcoord_normalize:_}),y=o.vertex_elements,x=o.vertex_count;if(f){_=_||1;var b=n(d||ft,4),A=b[0],T=b[1],w=b[2],E=b[3],k=[[A,E],[A,T],[w,T],[w,E]];}for(var R=e.length,M=0;M<R;M++)for(var z=e[M],P=0;P<z.length;P++)for(var S=z[P],N=0;N<S.length-1;N++)if(!c||!dt(S[N],S[N+1],h)){var O=void 0,L=void 0;"CCW"===p?(O=N,L=N+1):(O=N+1,L=N);var I=[[S[L][0],S[L][1],v],[S[L][0],S[L][1],m],[S[O][0],S[O][1],m],[S[O][0],S[O][1],v]],F=Ne.normalize([S[L][0]-S[O][0],S[L][1]-S[O][1],0]),D=Ne.cross(At,F);a[s+0]=D[0]*l,a[s+1]=D[1]*l,a[s+2]=D[2]*l;for(var U=0;U<I.length;U++)a[0]=I[U][0],a[1]=I[U][1],a[2]=I[U][2],f&&(a[f+0]=k[U][0]*_,a[f+1]=k[U][1]*_),o.addVertex(a);y.push(x+0),y.push(x+1),y.push(x+2),y.push(x+2),y.push(x+3),y.push(x+0),x+=4,g+=2;}return g}(e,t.z,t.height,t.min_height,o,s,a.index.a_normal,127,l):Tt(e,o,s,l)}});var Rt=[0,0],Mt={butt:0,square:1,round:2},zt={miter:0,bevel:1,round:2},Pt=Q.tile_scale,St=[0,0],Nt=[1,0],Ot=[.5,0];function Lt(e,t){if(!(e.length<2)){var r,n,i,o,a=t.join_type,s=t.cap_type,l=t.closed_polygon,u=t.remove_tile_edges,c=t.tile_edge_tolerance,h=t.v_scale,f=t.miter_len_sq,d=null!=t.texcoord_index,_=0;if(l&&a===zt.miter){var p=function(e){if(_t(e[0]))return 0;for(var t=0;t<e.length;t++){if(_t(e[e.length-1-t]))return e.length-1-t}return 0}(e);if(0!==p){var m=function(e,t){for(var r=[],n=0;n<e.length;n++){var i=(n+t)%e.length;0!==i&&r.push(e[i]);}return r.push(r[0]),r}(e,p);return t.extra_lines=t.extra_lines||[],void t.extra_lines.push(m)}}var v=0,g=e.length-1,y=0;for(r=e[v],n=e[v+1];Ne.isEqual(r,n);)if(r=n,n=e[++v+1],y++,v===e.length-1)return;for(;Ne.isEqual(e[g],e[g-1]);)if(y++,0===--g)return;if(!(e.length<2+y))if(o=Ne.normalize(Ne.perp(r,n)),u&&dt(r,n,c)){var x=It(e,v,c);x&&(t.extra_lines=t.extra_lines||[],t.extra_lines.push(x));}else {l?function(e,t,r,n,i){if(void 0===n||_t(e))jt(e,r,r,1,0,i,1),jt(e,r,r,0,0,i,-1);else {var o=0;n===zt.miter?Dt(o,e,t,r,i.miter_len_sq,!0,i):Ut(n,o,e,t,r,!0,i);}}(r,i=Ne.normalize(Ne.perp(e[g-1],r)),o,a,t):(_t(r)||(Vt(r,_,o,s,!0,t),d&&s!==Mt.butt&&(_+=.5*h*t.texcoord_width)),jt(r,o,o,1,_,t,1),jt(r,o,o,0,_,t,-1)),d&&(_+=h*Ne.length(Ne.sub(n,r)));for(var b=v+1;b<g;b++){var A=b,T=b+1;if(r=e[A],n=e[T],!Ne.isEqual(r,n)){if(u&&dt(r,n,c)){jt(r,o,o,1,_,t,1),jt(r,o,o,0,_,t,-1),Gt(1,t);var w=It(e,A+1,c);return void(w&&(t.extra_lines=t.extra_lines||[],t.extra_lines.push(w)))}i=o,o=Ne.normalize(Ne.perp(r,n)),a===zt.miter?Dt(_,r,i,o,f,!1,t):Ut(a,_,r,i,o,!1,t),d&&(_+=h*Ne.length(Ne.sub(n,r)));}}r=n,i=o,l?function(e,t,r,n,i,o){if(_t(e))jt(e,t,t,1,i,o,1),jt(e,t,t,0,i,o,-1),Gt(1,o);else {var a=Ft(t,r);n===zt.miter&&Ne.lengthSq(a)>o.miter_len_sq&&(n=zt.bevel),n===zt.miter?(jt(e,a,t,1,i,o,1),jt(e,a,t,0,i,o,-1),Gt(1,o)):(jt(e,t,t,1,i,o,1),jt(e,t,t,0,i,o,-1),Gt(1,o));}}(r,i,o=Ne.normalize(Ne.perp(r,e[1])),a,_,t):(jt(r,i,o,1,_,t,1),jt(r,i,o,0,_,t,-1),Gt(1,t),_t(r)||Vt(r,_,i,s,!1,t));}}}function It(e,t,r){for(var n=t;e[n+1]&&dt(e[n],e[n+1],r);)n++;return e.length-n>=2&&e.slice(n)}function Ft(e,t){var r=Ne.normalize(Ne.add(e,t)),n=2/(1+Math.abs(Ne.dot(e,r)));return Ne.mult(r,n*n)}function Dt(e,t,r,n,i,o,a){var s=Ft(r,n);Ne.lengthSq(s)>i?Ut(zt.bevel,e,t,r,n,o,a):(jt(t,s,s,1,e,a,1),jt(t,s,s,0,e,a,-1),o||Gt(1,a));}function Ut(e,t,r,n,i,o,a){var s=Ft(n,i),l=i[0]*n[1]-i[1]*n[0]>0;null!=a.texcoord_index&&(St[1]=t,Nt[1]=t),l?(jt(r,s,s,1,t,a,1),jt(r,n,s,0,t,a,-1),o||Gt(1,a),Bt(r,Ne.neg(n),s,Ne.neg(i),s,St,Nt,St,!1,e===zt.bevel,a),jt(r,s,s,1,t,a,1),jt(r,i,s,0,t,a,-1)):(jt(r,n,s,1,t,a,1),jt(r,s,s,0,t,a,-1),o||Gt(1,a),Bt(r,n,Ne.neg(s),i,s,Nt,St,Nt,!1,e===zt.bevel,a),jt(r,i,s,1,t,a,1),jt(r,s,s,0,t,a,-1));}function Gt(e,t){for(var r=t.vertex_data.vertex_elements,n=t.vertex_data.vertex_count-2*e-2,i=0;i<e;i++)r.push(n+2*i+2),r.push(n+2*i+1),r.push(n+2*i+0),r.push(n+2*i+2),r.push(n+2*i+3),r.push(n+2*i+1),t.geom_count+=2;}function jt(e,t,r,n,i,o,a){var s=o.vertex_template,l=o.vertex_data;s[0]=e[0],s[1]=e[1];var u=o.half_width*a;s[o.extrude_index+0]=t[0]*u,s[o.extrude_index+1]=t[1]*u,o.offset&&(s[o.offset_index+0]=r[0]*o.offset,s[o.offset_index+1]=r[1]*o.offset),null!=o.texcoord_index&&(s[o.texcoord_index+0]=65535*n,s[o.texcoord_index+1]=65535*i),l.addVertex(s);}var Ct=[0,0];function Bt(e,t,r,n,i,o,a,s,l,u,c){for(var h=t[0]*n[1]-t[1]*n[0],f=Ne.dot(t,n),d=Math.atan2(h,f);d>=Math.PI;)d-=2*Math.PI;if(u)_=1;else {var _=function(e,t){e<0&&(e=-e);var r=t>10?Math.log2(t/5):1;return Math.ceil(e/Math.PI*r)}(d,c.half_width);if(_<1)return}var p=c.vertex_data.vertex_count,m=c.vertex_data.vertex_elements;jt(e,r,i,a[0],a[1],c,1),jt(e,t,i,o[0],o[1],c,1);var v=t,g=null!=c.texcoord_index;if(g)if(l)var y=Ne.sub(o,a);else {Ct=Ne.copy(o);var x=Ne.div(Ne.sub(s,o),_);}var b,A,T=d/_,w=d<0?-1:1;h>0?(b=2,A=1):(b=1,A=2);for(var E=0;E<_;E++)0===E&&d<0&&(v=Ne.neg(v)),v=Ne.rot(v,T),g&&(l?(y=Ne.rot(y,T),Ct[0]=y[0]+a[0],Ct[1]=y[1]*c.texcoord_width*c.v_scale+a[1]):Ct=Ne.add(Ct,x)),jt(e,v,i,Ct[0],Ct[1],c,w),m.push(p+E+b),m.push(p),m.push(p+E+A);}function Vt(e,t,r,n,i,o){var a=Ne.neg(r),s=null!=o.texcoord_index;switch(n){case Mt.square:var l;i?(l=[r[1],-r[0]],jt(e,Ne.add(r,l),r,1,t,o,1),jt(e,Ne.add(a,l),r,0,t,o,1),s&&(t+=.5*o.texcoord_width*o.v_scale),jt(e,r,r,1,t,o,1),jt(e,a,r,0,t,o,1)):(l=[-r[1],r[0]],jt(e,r,r,1,t,o,1),jt(e,a,r,0,t,o,1),s&&(t+=.5*o.texcoord_width*o.v_scale),jt(e,Ne.add(r,l),r,1,t,o,1),jt(e,Ne.add(a,l),r,0,t,o,1)),Gt(1,o);break;case Mt.round:var u,c,h=St,f=Nt,d=Ot;i?(u=r,c=a,s&&(t+=.5*o.texcoord_width*o.v_scale,h=Nt,f=St,d=Ot)):(u=a,c=r),s&&(St[1]=t,Nt[1]=t,Ot[1]=t),Bt(e,u,Rt,c,r,h,d,f,!0,!1,o);break;case Mt.butt:return}}var qt=[255,255,255,255],Xt=[0,0,0,0];var Ht=Object.create(nt);Object.assign(Ht,{name:"lines",built_in:!0,vertex_shader_src:wt,fragment_shader_src:Et,selection:!0,init:function(){nt.init.apply(this,arguments),this.defines.TANGRAM_EXTRUDE_LINES=!0,this.defines.TANGRAM_TEXTURE_COORDS=!0,this.outline_feature_style={},this.inline_feature_style=this.feature_style,this.dash_textures={};},calcDistance:function(e,t){return ue.evalCachedDistanceProperty(e,t)||0},calcDistanceNextZoom:function(e,t){t.zoom++;var r=this.calcDistance(e,t);return t.zoom--,r},calcWidth:function(e,t,r){var n=this.calcDistance(e.width,r);if(!(n<0)){var i;if(i=e.next_width?this.calcDistanceNextZoom(e.next_width,r):n/2,0===n&&0===i||i<0)return !1;if(t.width_unscaled=n,t.next_width_unscaled=i,e.next_width){var o=.5*(n+(i*=2));t.width=o*r.units_per_meter_overzoom,t.width_scale=1-i/o;}else t.width=n*r.units_per_meter_overzoom,t.width_scale=0;return e.texcoords&&(e.inline_texcoord_width?t.texcoord_width=e.inline_texcoord_width:t.texcoord_width=(t.width_unscaled||t.next_width_unscaled)*r.units_per_meter_overzoom/r.tile.overzoom2),!0}},calcOffset:function(e,t,r){if(e.offset_precalc)t.offset=e.offset_precalc,t.offset_scale=e.offset_scale_precalc;else if(e.offset){var n=this.calcDistance(e.offset,r);if(e.next_offset){var i=2*this.calcDistanceNextZoom(e.next_offset,r);Math.abs(n)>=Math.abs(i)?(t.offset=n*r.units_per_meter_overzoom,t.offset_scale=0!==n?1-i/n:0):(t.offset=i*r.units_per_meter_overzoom,t.offset_scale=0!==i?-1*(1-n/i):0);}else t.offset=n*r.units_per_meter_overzoom,t.offset_scale=0;}else t.offset=0,t.offset_scale=0;},_parseFeature:function(e,t,r){var n=this.feature_style;if(!1!==this.calcWidth(t,n,r)&&(this.calcOffset(t,n,r),n.color=this.parseColor(t.color,r),n.color)){if(n.alpha=ue.evalCachedProperty(t.alpha,r),n.variant=t.variant,n.z=ue.evalCachedDistanceProperty(t.z,r)||ue.defaults.z,n.height=e.properties.height||ue.defaults.height,n.extrude=ue.evalProperty(t.extrude,r),n.extrude&&("number"==typeof n.extrude?n.height=n.extrude:Array.isArray(n.extrude)&&(n.height=n.extrude[1])),n.extrude&&n.height&&(n.z+=n.height),n.z*=Q.height_scale,n.cap=t.cap,n.join=t.join,n.miter_limit=t.miter_limit,n.tile_edges=t.tile_edges,n.outline=n.outline||{width:{},next_width:{},preprocessed:!0},t.outline&&!1!==t.outline.visible&&t.outline.color&&t.outline.width){var i=2*this.calcDistance(t.outline.width,r),o=2*this.calcDistanceNextZoom(t.outline.next_width,r);0===i&&0===o||i<0||o<0?(n.outline.width.value=null,n.outline.next_width.value=null,n.outline.color=null,n.outline.inline_texcoord_width=null,n.outline.texcoords=!1):(n.outline.width.value=i+n.width_unscaled,n.outline.next_width.value=o+n.next_width_unscaled,n.outline.inline_texcoord_width=n.texcoord_width,n.outline.offset_precalc=n.offset,n.outline.offset_scale_precalc=n.offset_scale,n.outline.color=t.outline.color,n.outline.alpha=t.outline.alpha,n.outline.interactive=t.outline.interactive,n.outline.cap=t.outline.cap,n.outline.join=t.outline.join,n.outline.miter_limit=t.outline.miter_limit,n.outline.texcoords=t.outline.texcoords,n.outline.extrude=t.outline.extrude,n.outline.z=t.outline.z,n.outline.style=t.outline.style,n.outline.variant=t.outline.variant,t.outline.order?n.outline.order=this.parseOrder(t.outline.order,r):n.outline.order=n.order,n.outline.order>n.order&&(n.outline.order=n.order),n.outline.order-=.5);}else n.outline.width.value=null,n.outline.next_width.value=null,n.outline.color=null,n.outline.inline_texcoord_width=null;return n}},_preprocess:function(e){if(e.color=ue.createColorPropertyCache(e.color),e.alpha=ue.createPropertyCache(e.alpha),e.width=ue.createPropertyCache(e.width,ue.parseUnits),e.width&&e.width.type!==ue.CACHE_TYPE.STATIC&&(e.next_width=ue.createPropertyCache(e.width,ue.parseUnits)),e.offset=e.offset&&ue.createPropertyCache(e.offset,ue.parseUnits),e.offset&&e.offset.type!==ue.CACHE_TYPE.STATIC&&(e.next_offset=ue.createPropertyCache(e.offset,ue.parseUnits)),e.z=ue.createPropertyCache(e.z,ue.parseUnits),e.dash=void 0!==e.dash?e.dash:this.dash,e.dash_key=e.dash&&this.dashTextureKey(e.dash),e.dash_background_color=void 0!==e.dash_background_color?e.dash_background_color:this.dash_background_color,e.dash_background_color=e.dash_background_color&&ue.parseColor(e.dash_background_color),e.texture_merged=e.dash_key||(void 0!==e.texture?e.texture:this.texture),e.texcoords=this.texcoords||e.texture_merged?1:0,this.computeVariant(e),e.outline){e.outline.is_outline=!0,e.outline.style=e.outline.style||this.name,e.outline.color=ue.createColorPropertyCache(e.outline.color),e.outline.alpha=ue.createPropertyCache(e.outline.alpha),e.outline.width=ue.createPropertyCache(e.outline.width,ue.parseUnits),e.outline.next_width=ue.createPropertyCache(e.outline.width,ue.parseUnits),e.outline.interactive=null!=e.outline.interactive?e.outline.interactive:e.interactive,e.outline.cap=e.outline.cap||e.cap,e.outline.join=e.outline.join||e.join,e.outline.miter_limit=null!=e.outline.miter_limit?e.outline.miter_limit:e.miter_limit,e.outline.offset=e.offset,e.outline.extrude=e.extrude,e.outline.z=e.z;var t=this.styles[e.outline.style];t?(e.outline.dash=void 0!==e.outline.dash?e.outline.dash:t.dash,e.outline.texture=void 0!==e.outline.texture?e.outline.texture:t.texture,null!=e.outline.dash?(e.outline.dash_key=e.outline.dash&&this.dashTextureKey(e.outline.dash),e.outline.texture_merged=e.outline.dash_key):null===e.outline.dash||null!=e.outline.texture?(e.outline.dash_key=null,e.outline.texture_merged=e.outline.texture):(e.outline.dash=e.dash,e.outline.dash_key=e.outline.dash&&this.dashTextureKey(e.outline.dash),e.outline.texture_merged=e.outline.dash_key),e.outline.dash_background_color=void 0!==e.outline.dash_background_color?e.outline.dash_background_color:t.dash_background_color,e.outline.dash_background_color=void 0!==e.outline.dash_background_color?e.outline.dash_background_color:e.dash_background_color,e.outline.dash_background_color=e.outline.dash_background_color&&ue.parseColor(e.outline.dash_background_color),e.outline.texcoords=t.texcoords||e.outline.texture_merged?1:0,void 0===e.outline.blend_order&&null!=e.blend_order&&(e.outline.blend_order=e.blend_order),t.computeVariant(e.outline)):(k({level:"warn",once:!0},"Layer group '".concat(e.layers.join(", "),"': ")+"line 'outline' specifies non-existent draw style '".concat(e.outline.style,"' (or maybe the style is ")+"defined but is missing a 'base' or has another error), skipping outlines for features matching this layer group"),e.outline=null);}return e},dashTextureKey:function(e){return "__dash_"+JSON.stringify(e)},getDashTexture:function(e){var t=this.dashTextureKey(e);if(null==this.dash_textures[t]){this.dash_textures[t]=!0;var r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.dash_color||qt,n=t.background_color||Xt,i=e,o=t.scale||1;i.length%2==1&&Array.prototype.push.apply(i,i);for(var a=!0,s=[],l=0;l<i.length;l++){for(var u=Math.floor(i[l]*o),c=0;c<u;c++)Array.prototype.push.apply(s,a?r:n);a=!a;}return s.reverse(),{pixels:s=new Uint8Array(s),length:s.length/4}}(e,{scale:20});D.create(this.gl,t,{data:r.pixels,height:r.length,width:1,filtering:"nearest"});}},endData:function(e){return new Promise(function(t,r){var n,i,o,a;return n=this,Promise.resolve(nt.endData.call(this,e)).then(function(e){try{if(i=e){i.uniforms.u_has_line_texture=!1,i.uniforms.u_texture=D.default,i.uniforms.u_v_scale_adjust=Q.tile_scale,o=[],a=function(){return new Promise((function(e,t){var r,a,s;if((r=i.meshes[l].variant).texture){if((a=i.meshes[l].uniforms=i.meshes[l].uniforms||{}).u_has_line_texture=!0,a.u_texture=r.texture,a.u_texture_ratio=1,r.dash&&(a.u_v_scale_adjust=20*Q.tile_scale,a.u_has_dash=null!=r.dash_background_color?1:0,a.u_dash_background_color=r.dash_background_color||[0,0,0,0]),r.dash_key&&null==n.dash_textures[r.dash_key]){n.dash_textures[r.dash_key]=!0;var u=function(){try{return f.call(this)}catch(e){return t(e)}}.bind(this),c=function(e){try{return k("trace","".concat(n.name,": line dash texture create failed because style no longer on main thread")),u()}catch(e){return t(e)}};try{return Promise.resolve(v.postMessage(n.main_thread_target+".getDashTexture",r.dash)).then((function(e){try{return u()}catch(e){return c()}}),c)}catch(d){c();}}function f(){return null==D.textures[r.texture]?o.push(D.syncTexturesToWorker([r.texture]).then((function(e){var t=e[r.texture];t&&(a.u_texture_ratio=t.height/t.width);}))):(s=D.textures[r.texture],a.u_texture_ratio=s.height/s.width),h.call(this)}return f.call(this)}function h(){return e()}return h.call(this)}))};var s,l,u,c=[];for(s in i.meshes)c.push(s);function f(){return c.length?(l=c.shift(),Promise.resolve(a()).then((function(e){try{return f}catch(e){return r(e)}}),r)):[1]}return (u=function(e){for(;e;){if(e.then)return void e.then(u,r);try{if(e.pop){if(e.length)return e.pop()?d.call(this):e;e=f;}else e=e.call(this);}catch(e){return r(e)}}}.bind(this))(f);function d(){return Promise.resolve(Promise.all(o)).then(function(e){try{return h.call(this)}catch(e){return r(e)}}.bind(this),r)}}function h(){return t(i)}return h.call(this)}catch(_){return r(_)}}.bind(this),r)}.bind(this))},computeVariant:function(e){var t=e.offset?1:0;t+="/"+e.texcoords,t+="/"+(e.interactive?1:0),t+="/"+(e.extrude||e.z?1:0),t+="/"+e.is_outline,e.dash_key&&(t+=e.dash_key,e.dash_background_color&&(t+=e.dash_background_color)),e.texture_merged&&(t+=e.texture_merged);var r=this.getBlendOrderForDraw(e);t=V(t+="/"+r),e.variant=t,null==this.variants[t]&&(this.variants[t]={key:t,blend_order:r,mesh_order:e.is_outline?0:1,selection:e.interactive?1:0,offset:e.offset?1:0,z_or_offset:e.offset||e.extrude||e.z?1:0,texcoords:e.texcoords,texture:e.texture_merged,dash:e.dash,dash_key:e.dash_key,dash_background_color:e.dash_background_color});},vertexLayoutForMeshVariant:function(e){if(null==this.vertex_layouts[e.key]){var t=[{name:"a_position",size:4,type:Te.SHORT,normalized:!1},{name:"a_extrude",size:2,type:Te.SHORT,normalized:!1},{name:"a_offset",size:2,type:Te.SHORT,normalized:!1,static:e.offset?null:[0,0]},{name:"a_z_and_offset_scale",size:2,type:Te.SHORT,normalized:!1,static:e.z_or_offset?null:[0,0]},{name:"a_texcoord",size:2,type:Te.UNSIGNED_SHORT,normalized:!0,static:e.texcoords?null:[0,0]},{name:"a_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.key]=new ct(t);}return this.vertex_layouts[e.key]},meshVariantTypeForDraw:function(e){return this.variants[e.variant]},makeVertexTemplate:function(e,t){var r=0;return this.vertex_template[r++]=0,this.vertex_template[r++]=0,this.vertex_template[r++]=1024*e.width_scale,this.vertex_template[r++]=this.scaleOrder(e.order),this.vertex_template[r++]=0,this.vertex_template[r++]=0,t.variant.offset&&(this.vertex_template[r++]=0,this.vertex_template[r++]=0),t.variant.z_or_offset&&(this.vertex_template[r++]=e.z||0,this.vertex_template[r++]=1024*e.offset_scale),t.variant.texcoords&&(this.vertex_template[r++]=0,this.vertex_template[r++]=0),this.vertex_template[r++]=255*e.color[0],this.vertex_template[r++]=255*e.color[1],this.vertex_template[r++]=255*e.color[2],this.vertex_template[r++]=255*(null!=e.alpha?e.alpha:e.color[3]),t.variant.selection&&(this.vertex_template[r++]=255*e.selection_color[0],this.vertex_template[r++]=255*e.selection_color[1],this.vertex_template[r++]=255*e.selection_color[2],this.vertex_template[r++]=255*e.selection_color[3]),this.addCustomAttributesToVertexTemplate(e,r),this.vertex_template},buildLines:function(e,t,r,n){if(this.feature_style=this.outline_feature_style,t.outline&&null!=t.outline.color&&null!=t.outline.width.value){var i=this.styles[t.outline.style];i&&i.addFeature(r.feature,t.outline,r);}this.feature_style=this.inline_feature_style;var o=this.getTileMesh(r.tile,this.meshVariantTypeForDraw(t)),a=o.vertex_data,s=a.vertex_layout;return function(e,t,r,n,i,o,a,s){var l,u=t.cap?Mt[t.cap]:Mt.butt,c=t.join?zt[t.join]:zt.miter;if(c===zt.miter)var h=t.miter_limit||3,f=h*h;i.a_texcoord&&(l=1/(t.texcoord_width*Pt));for(var d={closed_polygon:o,remove_tile_edges:a,tile_edge_tolerance:s,miter_len_sq:f,join_type:c,cap_type:u,vertex_data:r,vertex_template:n,half_width:t.width/2,extrude_index:i.a_extrude,offset_index:i.a_offset,v_scale:l,texcoord_index:i.a_texcoord,texcoord_width:t.texcoord_width,offset:t.offset,geom_count:0},_=0;_<e.length;_++)Lt(e[_],d);if(d.extra_lines)for(var p=0;p<d.extra_lines.length;p++)Lt(d.extra_lines[p],d);return d.geom_count}(e,t,a,this.makeVertexTemplate(t,o),s.index,n&&n.closed_polygon,!t.tile_edges&&n&&n.remove_tile_edges,Q.tile_scale*r.tile.pad_scale*2)},buildPolygons:function(e,t,r){for(var n=0,i=0;i<e.length;i++)n+=this.buildLines(e[i],t,r,{closed_polygon:!0,remove_tile_edges:!0});return n}});var Wt=128/Math.PI,Yt=16384/Math.PI,Zt=[0,2,2,0],Jt=[1,1,3,3],Kt=new Array(4);var $t=["left","top-left","bottom-left"],Qt=["right","top-right","bottom-right"],er=["top","top-left","top-right"],tr=["bottom","bottom-left","bottom-right"],rr={computeOffset:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(!r||"center"===r)return e;var i=[e[0],e[1]];return n=n||this.default_buffer,this.isLeftAnchor(r)?(i[0]-=t[0]/2,"left"===r&&(i[0]-=n[0])):this.isRightAnchor(r)&&(i[0]+=t[0]/2,"right"===r&&(i[0]+=n[1])),this.isTopAnchor(r)?(i[1]-=t[1]/2,"top"===r&&(i[1]-=n[2])):this.isBottomAnchor(r)&&(i[1]+=t[1]/2,"bottom"===r&&(i[1]+=n[3])),i},alignForAnchor:function(e){if(e&&"center"!==e){if(this.isLeftAnchor(e))return "right";if(this.isRightAnchor(e))return "left"}return "center"},isLeftAnchor:function(e){return $t.indexOf(e)>-1},isRightAnchor:function(e){return Qt.indexOf(e)>-1},isTopAnchor:function(e){return er.indexOf(e)>-1},isBottomAnchor:function(e){return tr.indexOf(e)>-1},default_buffer:[2.5,2.5,1.5,.75],zero_buffer:[0,0,0,0]};function nr(e,t){return !(e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3])}var ir,or,ar,sr,lr=[[1,0],[0,1]],ur=[],cr=[],hr=function(){function e(t,r,n,i,o){u(this,e),this.dimension=[i/2,o/2],this.angle=n,this.centroid=[t,r],this.quad=null,this.axis_0=null,this.axis_1=null,this.update();}return h(e,[{key:"toJSON",value:function(){return {x:this.centroid[0],y:this.centroid[1],a:this.angle,w:this.dimension[0],h:this.dimension[1]}}},{key:"getExtent",value:function(){return 0===this.angle?[this.quad[0],this.quad[1],this.quad[4],this.quad[5]]:[Math.min(this.quad[0],this.quad[2],this.quad[4],this.quad[6]),Math.min(this.quad[1],this.quad[3],this.quad[5],this.quad[7]),Math.max(this.quad[0],this.quad[2],this.quad[4],this.quad[6]),Math.max(this.quad[1],this.quad[3],this.quad[5],this.quad[7])]}},{key:"updateAxes",value:function(){this.axis_0=Ne.normalize([this.quad[4]-this.quad[6],this.quad[5]-this.quad[7]]),this.axis_1=Ne.normalize([this.quad[4]-this.quad[2],this.quad[5]-this.quad[3]]);}},{key:"update",value:function(){var e=this.centroid,t=this.dimension[0],r=this.dimension[1];if(0===this.angle)this.quad=[e[0]-t,e[1]-r,e[0]+t,e[1]-r,e[0]+t,e[1]+r,e[0]-t,e[1]+r],this.axis_0=lr[0],this.axis_1=lr[1];else {var n=Math.cos(this.angle)*t,i=Math.sin(this.angle)*t,o=-Math.sin(this.angle)*r,a=Math.cos(this.angle)*r;this.quad=[e[0]-n-o,e[1]-i-a,e[0]+n-o,e[1]+i-a,e[0]+n+o,e[1]+i+a,e[0]-n+o,e[1]-i+a],this.updateAxes();}}}],[{key:"projectToAxis",value:function(e,t,r){var n=e.quad;return ir=n[0]*t[0]+n[1]*t[1],or=n[2]*t[0]+n[3]*t[1],ar=n[4]*t[0]+n[5]*t[1],sr=n[6]*t[0]+n[7]*t[1],r[0]=Math.min(ir,or,ar,sr),r[1]=Math.max(ir,or,ar,sr),r}},{key:"axisCollide",value:function(t,r,n,i){return e.projectToAxis(t,n,ur),e.projectToAxis(r,n,cr),!(cr[0]>ur[1]||cr[1]<ur[0])&&(e.projectToAxis(t,i,ur),e.projectToAxis(r,i,cr),!(cr[0]>ur[1]||cr[1]<ur[0]))}},{key:"intersect",value:function(t,r){return e.axisCollide(t,r,t.axis_0,t.axis_1)&&e.axisCollide(t,r,r.axis_0,r.axis_1)}}])}(),fr=function(){return h((function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u(this,e),this.id=e.nextLabelId(),this.type="",this.size=t,this.layout=r,this.position=null,this.angle=0,this.anchor=Array.isArray(this.layout.anchor)?this.layout.anchor[0]:this.layout.anchor,this.placed=null,this.offset=r.offset,this.unit_scale=this.layout.units_per_pixel,this.aabb=null,this.obb=null,this.align="center",this.throw_away=!1;}),[{key:"toJSON",value:function(){return {id:this.id,type:this.type,obb:this.obb.toJSON(),position:this.position,angle:this.angle,size:this.size,offset:this.offset,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:dr(this.layout)}}},{key:"update",value:function(){this.align=this.layout.align||rr.alignForAnchor(this.anchor);}},{key:"occluded",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=!1,i=e.aabb,o=e.obb;return i.length>0&&function(e,t,r){for(var n=0;n<t.length&&(!nr(e,t[n])||null==r(n));n++);}(this.aabb,i,(function(e){if(!r||i[e]!==r.aabb)return 0===t.obb.angle&&0===o[e].angle||hr.intersect(t.obb,o[e])?(n=!0,!0):void 0})),n}},{key:"inTileBounds",value:function(){return this.aabb[0]>=0&&this.aabb[1]>-Q.tile_scale&&this.aabb[0]<Q.tile_scale&&this.aabb[1]<=0||this.aabb[2]>=0&&this.aabb[3]>-Q.tile_scale&&this.aabb[2]<Q.tile_scale&&this.aabb[3]<=0}},{key:"mayRepeatAcrossTiles",value:function(){if(this.layout.collide)return !0;var e=this.layout.repeat_distance;return 0!==e&&(Math.abs(this.position[0])<e||Math.abs(this.position[0]-Q.tile_scale)<e||Math.abs(this.position[1])<e||Math.abs(-(this.position[1]-Q.tile_scale))<e)}},{key:"discard",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return !!this.throw_away||this.occluded(e,t)}}])}();function dr(e){return {priority:e.priority,collide:e.collide,repeat_distance:e.repeat_distance,repeat_group:e.repeat_group,buffer:e.buffer,italic:e.italic}}fr.add=function(e,t){if(e.placed=!0,e.aabb&&(t.aabb.push(e.aabb),t.obb.push(e.obb)),e.aabbs)for(var r=0;r<e.aabbs.length;r++)t.aabb.push(e.aabbs[r]),t.obb.push(e.obbs[r]);},fr.id=0,fr.id_prefix=0,fr.id_multiplier=0,fr.nextLabelId=function(){return fr.id_prefix+fr.id++*fr.id_multiplier},fr.epsilon=.9999;var _r=function(){function e(t,r){u(this,e),this.key=t,this.repeat_dist=r,this.repeat_dist_sq=this.repeat_dist*this.repeat_dist,this.positions=[];}return h(e,[{key:"check",value:function(e){for(var t=e.position,r=0;r<this.positions.length;r++){var n=this.positions[r],i=t[0]-n[0],o=t[1]-n[1];if(i*i+o*o<this.repeat_dist_sq)return !0}}},{key:"add",value:function(e){e&&e.position&&this.positions.push(e.position);}}],[{key:"clear",value:function(e){this.groups[e]={};}},{key:"check",value:function(e,t,r){if(t.repeat_distance&&t.repeat_group&&this.groups[r][t.repeat_group])return this.groups[r][t.repeat_group].check(e)}},{key:"add",value:function(t,r,n){r.repeat_distance&&r.repeat_group&&(null==this.groups[n][r.repeat_group]&&(this.groups[n][r.repeat_group]=new e(r.repeat_group,r.repeat_distance*r.repeat_scale)),this.groups[n][r.repeat_group].add(t));}}])}();_r.groups={};var pr=function(){return h((function e(t,r){u(this,e),this.anchor=t,this.span=r,this.cells={};}),[{key:"addLabel",value:function(e){var t=this;e.aabb&&this.addLabelBboxes(e,e.aabb),e.aabbs&&e.aabbs.forEach((function(r){return t.addLabelBboxes(e,r)}));}},{key:"addLabelBboxes",value:function(e,t){var r=[Math.max(Math.floor((t[0]-this.anchor.x)/this.span),0),Math.max(Math.floor(-(t[1]-this.anchor.y)/this.span),0),Math.max(Math.floor((t[2]-this.anchor.x)/this.span),0),Math.max(Math.floor(-(t[3]-this.anchor.y)/this.span),0)];e.cells=[];for(var n=r[1];n<=r[3];n++){this.cells[n]=this.cells[n]||{};for(var i=r[0];i<=r[2];i++)this.cells[n][i]=this.cells[n][i]||{aabb:[],obb:[]},e.cells.push(this.cells[n][i]);}}}])}(),mr={tiles:{},grid:null,initGrid:function(e){this.grid=null==e?null:new pr(e.anchor,e.span);},startTile:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.apply_repeat_groups,n=void 0===r||r,i=t.return_hidden,o=void 0!==i&&i,a=this.tiles[e]={bboxes:{aabb:[],obb:[]},objects:{},labels:{},styles:{},repeat:n,return_hidden:o};null==a.complete&&(a.complete=new Promise((function(e,t){a.resolve=e,a.reject=t;})));},resetTile:function(e){delete this.tiles[e];},abortTile:function(e){this.tiles[e]&&this.tiles[e].resolve&&this.tiles[e].resolve([]),this.resetTile(e);},addStyle:function(e,t){this.tiles[t].styles[e]=!0;},collide:function(e,t,r){var n=this.tiles[r];if(!n)return k("trace","Collision.collide() called with null tile",r,this.tiles,t,e),Promise.resolve([]);for(var i=n.objects,o=0;o<e.length;o++){var a=e[o],s=a.label.layout.priority;i[s]=i[s]||{},i[s][t]=i[s][t]||[],i[s][t].push(a);}return delete n.styles[t],0===Object.keys(n.styles).length&&this.endTile(r),n.complete.then((function(){return n.resolve=null,n.labels[t]||[]}))},endTile:function(e){var t=this.tiles[e],r=t.labels;this.grid&&this.addLabelsToGrid(e),t.repeat&&_r.clear(e);for(var n=Object.keys(t.objects).sort((function(e,t){return e-t})),i=0;i<n.length;i++){var o=t.objects[n[i]];if(o)for(var a in o){var s=o[a];r[a]=r[a]||[];for(var l=0;l<s.length;l++){var u=s[l];this.canBePlaced(u,e,u.linked,t)?u.linked?this.canBePlaced(u.linked,e,u,t)?(u.show=!0,(u.label.breach||u.linked.label.breach)&&(u.label.breach=!0,u.linked.label.breach=!0),(u.label.may_repeat_across_tiles||u.linked.label.may_repeat_across_tiles)&&(u.label.may_repeat_across_tiles=!0,u.linked.label.may_repeat_across_tiles=!0),r[a].push(u),this.place(u,e,t),this.place(u.linked,e,t)):t.return_hidden&&(u.show=!1,r[a].push(u)):(u.show=!0,r[a].push(u),this.place(u,e,t)):t.return_hidden&&(u.show=!1,r[a].push(u));}}}delete this.tiles[e],t.resolve();},addLabelsToGrid:function(e){var t=this,r=this.tiles[e];for(var n in r.objects){var i=r.objects[n];if(i)for(var o in i){i[o].forEach((function(e){return t.grid.addLabel(e.label)}));}}},canBePlaced:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).repeat,i=void 0===n||n,o=e.label,a=e.label.layout;if(null!=o.placed)return o.placed;var s=!a.collide;if(s||(s=this.grid&&o.cells?o.cells.reduce((function(e,t){return e&&o.discard(t,r&&r.label)&&(e=!1),e}),!0):!o.discard(this.tiles[t].bboxes,r&&r.label)),s){if(!i||!_r.check(o,a,t))return !0;o.placed=!1;}else a.collide&&(o.placed=!1);return o.placed},place:function(e,t,r){var n=e.label,i=r.repeat,o=void 0===i||i;null==n.placed&&(o&&_r.add(n,n.layout,t),this.grid&&n.cells?n.cells.forEach((function(e){return fr.add(n,e)})):fr.add(n,this.tiles[t].bboxes));}};function vr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (vr=function(){return !!e})()}function gr(e,t,r,n){var i=ze(Me(e.prototype),t,r);return "function"==typeof i?function(e){return i.apply(r,e)}:i}var yr=function(e){function t(e,r,n){var i,o,a,s,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return u(this,t),o=this,s=[r,n],a=Me(a=t),(i=Pe(o,vr()?Reflect.construct(a,s||[],Me(o).constructor):a.apply(o,s))).type="point",i.position=[e[0],e[1]],i.angle=l,i.parent=i.layout.parent,i.update(),i.start_anchor_index=1,i.degenerate=!(i.size[0]||i.size[1]||i.layout.buffer[0]||i.layout.buffer[1]),i.throw_away=!1,i}return Se(t,e),h(t,[{key:"update",value:function(){gr(t,"update",this)([]),this.computeOffset(),this.updateBBoxes();}},{key:"computeOffset",value:function(){if(this.offset=[this.layout.offset[0],this.layout.offset[1]],this.parent){var e=this.parent;this.offset=rr.computeOffset(this.offset,e.size,e.anchor,rr.zero_buffer),this.offset=rr.computeOffset(this.offset,e.size,this.anchor,rr.zero_buffer),e.offset!==ue.zeroPair&&(this.offset===ue.zeroPair?this.offset=e.offset:(this.offset[0]+=e.offset[0],this.offset[1]+=e.offset[1]));}this.offset=rr.computeOffset(this.offset,this.size,this.anchor);}},{key:"updateBBoxes",value:function(){var e=(this.size[0]+2*this.layout.buffer[0])*this.unit_scale*fr.epsilon,t=(this.size[1]+2*this.layout.buffer[1])*this.unit_scale*fr.epsilon;this.layout.italic&&(e+=5*this.unit_scale),this.obb=new hr(this.position[0]+this.offset[0]*this.unit_scale,this.position[1]-this.offset[1]*this.unit_scale,-this.angle,e,t),this.aabb=this.obb.getExtent(),this.inTileBounds&&(this.breach=!this.inTileBounds()),this.mayRepeatAcrossTiles&&(this.may_repeat_across_tiles=this.mayRepeatAcrossTiles());}},{key:"discard",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.degenerate)return !1;if(gr(t,"discard",this)([e,r])){if(Array.isArray(this.layout.anchor))for(var n=this.start_anchor_index;n<this.layout.anchor.length;n++)if(this.anchor=this.layout.anchor[n],this.update(),!gr(t,"discard",this)([e,r]))return !1;return !0}return !1}}])}(fr);yr.PLACEMENT={VERTEX:0,MIDPOINT:1,SPACED:2,CENTROID:3};var xr=yr.PLACEMENT;function br(e,t,r){var n=[],i=r.placement,o=Math.max(t[0],t[1])*r.placement_min_length_ratio*r.units_per_pixel;if(i===xr.SPACED){var a=function(e,t,r){var n=r.units_per_pixel,i=(r.placement_spacing||80)*n,o=function(e){for(var t=0,r=0;r<e.length-1;r++)t+=Tr(e[r],e[r+1]);return t}(e);if(o<=t)return !1;for(var a=Math.max(Math.floor(o/i),1),s=[],l=[],u=.5*(o-(a-1)*i),c=0;c<a;c++){var h=wr(e,u,t,r),f=h.position,d=h.angle;null!=f&&null!=d&&(s.push(f),l.push(d)),u+=i;}return {positions:s,angles:l}}(e,o,r);if(!a)return [];for(var s=a.positions,l=a.angles,u=0;u<s.length;u++){var c=s[u],h=l[u];!0!==r.tile_edges&&_t(c)||n.push(new yr(c,t,r,h));}}else if(i===xr.VERTEX){for(var f,d,_=0;_<e.length-1;_++)if(f=e[_],d=e[_+1],!0===r.tile_edges||!_t(f)){var p=Ar(f,d,r.angle);n.push(new yr(f,t,r,p));}var m=Ar(f,d,r.angle);n.push(new yr(d,t,r,m));}else if(i===xr.MIDPOINT)for(var v=0;v<e.length-1;v++){var g=e[v],y=e[v+1],x=[.5*(g[0]+y[0]),.5*(g[1]+y[1])];if((!0===r.tile_edges||!_t(x))&&(!o||Tr(g,y)>o)){var b=Ar(g,y,r.angle);n.push(new yr(x,t,r,b));}}return n}function Ar(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return "auto"===r?Math.atan2(t[0]-e[0],t[1]-e[1]):r}function Tr(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2))}function wr(e,t,r,n){for(var i,o,a=0,s=0;s<e.length-1;s++){var l=e[s],u=e[s+1],c=Tr(l,u);if(!(c<=r)&&(a+=c)>t){i=Er(l,u,a-t),o=Ar(l,u,n.angle);break}}return {position:i,angle:o}}function Er(e,t,r){var n=r/Tr(e,t);return [n*e[0]+(1-n)*t[0],n*e[1]+(1-n)*t[1]]}var kr,Rr={key:function(e){return [e.style,e.weight,e.family,e.px_size,e.fill,e.stroke,e.stroke_width,e.underline_width,e.background_color,e.background_width,e.background_stroke_color,e.background_stroke_width,e.transform,e.text_wrap,e.max_lines,e.supersample,M.device_pixel_ratio].join("/")},defaults:{style:"normal",weight:"normal",size:"12px",px_size:12,family:"Helvetica",fill:[1,1,1,1],text_wrap:15,max_lines:5,align:"center"},compute:function(e,t){var r={};e.font=e.font||this.defaults,r.supersample=e.supersample_text?1.5:1,r.can_articulate=e.can_articulate,r.fill=ue.evalCachedColorPropertyWithAlpha(e.font.fill,e.font.alpha,t),r.fill=M.toCSSColor(r.fill),e.font.stroke&&e.font.stroke.color&&(r.stroke=ue.evalCachedColorPropertyWithAlpha(e.font.stroke.color,e.font.stroke.alpha,t),r.stroke=M.toCSSColor(r.stroke),r.stroke_width=ue.evalCachedProperty(e.font.stroke.width,t)),!0!==e.font.underline||r.can_articulate||(r.underline_width=1.5*r.supersample),e.font.background&&!r.can_articulate&&(r.background_color=ue.evalCachedColorPropertyWithAlpha(e.font.background.color,e.font.background.alpha,t),r.background_color=M.toCSSColor(r.background_color),r.background_color&&(r.background_width=ue.evalCachedProperty(e.font.background.width,t)),r.background_stroke_color=e.font.background.stroke&&e.font.background.stroke.color&&ue.evalCachedColorPropertyWithAlpha(e.font.background.stroke.color,e.font.background.stroke.alpha,t),r.background_stroke_color&&(r.background_stroke_color=M.toCSSColor(r.background_stroke_color),r.background_stroke_width=null!=e.font.background.stroke.width?ue.evalCachedProperty(e.font.background.stroke.width,t):1)),r.weight=ue.evalCachedProperty(e.font.weight,t)||this.defaults.weight,"number"==typeof r.weight&&(r.weight=Math.min(Math.max(r.weight,1),1e3)),e.font.family?(r.family=e.font.family,r.family!==this.defaults.family&&(r.family+=", "+this.defaults.family)):r.family=this.defaults.family,r.style=e.font.style||this.defaults.style,r.transform=e.font.transform,r.px_size=ue.evalCachedProperty(e.font.px_size,t)*r.supersample,r.font_css=this.fontCSS(r);var n=e.text_wrap;return null!=n||r.can_articulate||(n=!0),!0===n&&(n=this.defaults.text_wrap),r.text_wrap=n,r.max_lines=e.max_lines||this.defaults.max_lines,r},fontCSS:function(e){return [e.style,e.weight,e.px_size+"px",e.family].filter((function(e){return e})).join(" ")}},Mr={exports:{}};var zr,Pr=q((kr||(kr=1,zr=Mr,function(){function e(e,t){document.addEventListener?e.addEventListener("scroll",t,!1):e.attachEvent("scroll",t);}function t(e){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(e)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c);}function r(e,t){e.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font:"+t+";";}function n(e){var t=e.a.offsetWidth,r=t+100;return e.f.style.width=r+"px",e.c.scrollLeft=r,e.b.scrollLeft=e.b.scrollWidth+100,e.g!==t&&(e.g=t,!0)}function i(t,r){function i(){var e=o;n(e)&&e.a.parentNode&&r(e.g);}var o=t;e(t.b,i),e(t.c,i),n(t);}function o(e,t){var r=t||{};this.family=e,this.style=r.style||"normal",this.weight=r.weight||"normal",this.stretch=r.stretch||"normal";}var a=null,s=null,l=null,u=null;function c(){if(null===l){var e=document.createElement("div");try{e.style.font="condensed 100px sans-serif";}catch(e){}l=""!==e.style.font;}return l}function h(e,t){return [e.style,e.weight,c()?e.stretch:"","100px",t].join(" ")}o.prototype.load=function(e,n){var o=this,l=e||"BESbswy",c=0,f=n||3e3,d=(new Date).getTime();return new Promise((function(e,n){var _;if(null===u&&(u=!!document.fonts),(_=u)&&(null===s&&(s=/OS X.*Version\/10\..*Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),_=!s),_){_=new Promise((function(e,t){!function r(){(new Date).getTime()-d>=f?t():document.fonts.load(h(o,'"'+o.family+'"'),l).then((function(t){1<=t.length?e():setTimeout(r,25);}),(function(){t();}));}();}));var p=new Promise((function(e,t){c=setTimeout(t,f);}));Promise.race([p,_]).then((function(){clearTimeout(c),e(o);}),(function(){n(o);}));}else !function(e){document.body?e():document.addEventListener?document.addEventListener("DOMContentLoaded",(function t(){document.removeEventListener("DOMContentLoaded",t),e();})):document.attachEvent("onreadystatechange",(function t(){"interactive"!=document.readyState&&"complete"!=document.readyState||(document.detachEvent("onreadystatechange",t),e());}));}((function(){function s(){var t;(t=-1!=m&&-1!=v||-1!=m&&-1!=g||-1!=v&&-1!=g)&&((t=m!=v&&m!=g&&v!=g)||(null===a&&(t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),a=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))),t=a&&(m==y&&v==y&&g==y||m==x&&v==x&&g==x||m==b&&v==b&&g==b)),t=!t),t&&(A.parentNode&&A.parentNode.removeChild(A),clearTimeout(c),e(o));}var u=new t(l),_=new t(l),p=new t(l),m=-1,v=-1,g=-1,y=-1,x=-1,b=-1,A=document.createElement("div");A.dir="ltr",r(u,h(o,"sans-serif")),r(_,h(o,"serif")),r(p,h(o,"monospace")),A.appendChild(u.a),A.appendChild(_.a),A.appendChild(p.a),document.body.appendChild(A),y=u.a.offsetWidth,x=_.a.offsetWidth,b=p.a.offsetWidth,function e(){if((new Date).getTime()-d>=f)A.parentNode&&A.parentNode.removeChild(A),n(o);else {var t=document.hidden;!0!==t&&void 0!==t||(m=u.a.offsetWidth,v=_.a.offsetWidth,g=p.a.offsetWidth,s()),c=setTimeout(e,50);}}(),i(u,(function(e){m=e,s();})),r(u,h(o,'"'+o.family+'",sans-serif')),i(_,(function(e){v=e,s();})),r(_,h(o,'"'+o.family+'",serif')),i(p,(function(e){g=e,s();})),r(p,h(o,'"'+o.family+'",monospace'));}));}))},zr.exports=o;}()),Mr.exports)),Sr={fonts_loaded:Promise.resolve(),last_loaded:null,loadFonts:function(e){var t=this,r=JSON.stringify(e)===this.last_loaded;if(e&&!r){var n=[],i=function(r){Array.isArray(e[r])?e[r].forEach((function(e){return n.push(t.loadFontFace(r,e))})):n.push(t.loadFontFace(r,e[r]));};for(var o in e)i(o);this.last_loaded=JSON.stringify(e),this.fonts_loaded=Promise.all(n.filter((function(e){return e})));}return this.fonts_loaded},loadFontFace:function(e,t){return new Promise(function(r,n){var i,a;if(null==t||"object"!==o(t)&&"external"!==t)return r();if(i={family:e},"object"===o(t)){if(Object.assign(i,t),"string"==typeof t.url)return Promise.resolve(this.injectFontFace(i)).then(function(e){try{return l.call(this)}catch(e){return n(e)}}.bind(this),n);function l(){return s.call(this)}return l.call(this)}function s(){var t=function(){try{return r()}catch(e){return n(e)}},o=function(r){try{return k("warn","Font face '".concat(e,"' is NOT available"),i,r),t()}catch(e){return n(e)}};try{return i.weight="string"==typeof i.weight?i.weight.split(" ")[0]:i.weight,a=new Pr(e,i),Promise.resolve(a.load()).then((function(r){try{return k("debug","Font face '".concat(e,"' is available"),i),t()}catch(e){return o(e)}}),o)}catch(e){o(e);}}return s.call(this)}.bind(this))},injectFontFace:function(e){return new Promise(function(t,r){var n,i,o,a,s,l,u,c,h,f,d;if(n=e.family,i=e.url,o=e.weight,a=e.style,void 0===this.supports_native_font_loading&&(this.supports_native_font_loading=void 0!==window.FontFace),s=i,"blob:"===i.slice(0,5))return Promise.resolve(M.io(i,6e4,"arraybuffer")).then(function(e){try{if(s=e.body,l=new Uint8Array(s),this.supports_native_font_loading)s=l;else {for(u="",c=0;c<l.length;c++)u+=String.fromCharCode(l[c]);s="data:font/opentype;base64,"+btoa(u);}return _.call(this)}catch(e){return r(e)}}.bind(this),r);function _(){return this.supports_native_font_loading?("string"==typeof s?h=new FontFace(n,"url(".concat(encodeURI(s),")"),{weight:o,style:a}):s instanceof Uint8Array&&(h=new FontFace(n,s,{weight:o,style:a})),document.fonts.add(h),k("trace","Adding FontFace to document.fonts:",h)):(f="\n                @font-face {\n                    font-family: '".concat(n,"';\n                    font-weight: ").concat(o||"normal",";\n                    font-style: ").concat(a||"normal",";\n                    src: url(").concat(encodeURI(s),");\n                }"),(d=document.createElement("style")).appendChild(document.createTextNode("")),document.head.appendChild(d),d.sheet.insertRule(f,0),k("trace","Injecting CSS font face:",f)),t()}return _.call(this)}.bind(this))}},Nr=new RegExp("[֑-߿‏‫‮יִ-﷽ﹰ-ﻼ]");function Or(e){return Nr.test(e)}var Lr="\0-/:-@[-`{-¿×÷ʹ-˿ -⯿‐-\u2029‬ -⯿",Ir=new RegExp("["+Lr+"]+");function Fr(e){return Ir.test(e)}var Dr=new RegExp("^["+Lr+"؀-ۿ]+"),Ur=new RegExp("["+Lr+"آ-إاد-زوٱ-ٷڈ-ڙۄ-ۋۏےۓۮۯ]"),Gr=new RegExp("^[ؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ۭ]+"),jr="[̀-֑ͯ-ׇֽֿׁׂׅׄަ-ްऀ-ःऺ-ौॎॏ॑-ॗॢॣঁ-ঃ়া-ৌৗৢৣਁ-ਃ਼-ੌੑઁ-ઃ઼ા-ૌૢૣଁ-ଃ଼ା-ୌୖୗୢୣஂா-்ௗఀ-ఃా-ౌౕౖౢౣಁ-ಃ಼ಾ-ೌೕೖೢೣഁ-ഃാ-ൌൎൗൢൣංඃ්-ෟෲෳัิ-ฺ็-๎ັິ-ຼ່-ໍ༹༘༙༵༷༾༿ཱ-ྃ྆྇ྍ-ྼ࿆ါ-း်-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ឴-៑៓ᩕ-ᩞᩡ-᩼᷀-᷿⃐-⃿]",Cr=new RegExp("^.(?:".concat(jr,"+)?(").concat("[्্੍્୍్್്྄္្᩠᩿]","\\W(?:").concat(jr,"+)?)*")),Br={Mongolian:"᠀-᢯"},Vr=Object.keys(Br).map((function(e){return Br[e]})).join(""),qr=new RegExp("["+Vr+"]");function Xr(e,t,r){var n=t?1:2;if(e.length<n)return [e];var i=e;if(r.segment[i])return r.stats.segment_hits++,r.segment[i];var o=[];if(Dr.exec(e)){o=e.split(Ur);for(var a=-1,s=0;s<o.length-1;s++){if(s>0){var l=Gr.exec(o[s]);l&&(o[s]=o[s].substring(l[0].length),o[s-1]+=l[0],a+=l[0].length);}a+=1+o[s].length,o[s]+=e.slice(a,a+1);}e="";}for(;e.length;){for(var u="",c=e,h=0;h<n&&c.length;h++){var f=(Cr.exec(c)||c)[0];u+=f,c=c.substring(f.length);}o.push(u),e=e.substring(u.length);}return t&&o.reverse(),r.stats.segment_misses++,r.segment[i]=o,o}var Hr=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0;u(this,e),this.width=0,this.height=0,this.lines=[],this.max_lines=r,this.text_wrap=n,this.context=t;}return h(e,[{key:"createLine",value:function(e){return this.lines.length<this.max_lines&&new Wr(e,this.text_wrap)}},{key:"push",value:function(e){if(this.lines.length<this.max_lines){var t=this.context.measureText(e.text).width;return e.width=t,t>this.width&&(this.width=Math.ceil(t)),this.lines.push(e),this.height+=e.height,!0}return this.addEllipsis(),!1}},{key:"advance",value:function(e,t){return !!this.push(e)&&this.createLine(t)}},{key:"addEllipsis",value:function(){var t=this.lines[this.lines.length-1],r=Math.ceil(this.context.measureText(e.ellipsis).width);t.append(e.ellipsis),t.width+=r,t.width>this.width&&(this.width=t.width);}},{key:"finish",value:function(e){e?this.push(e):this.addEllipsis();}}],[{key:"parse",value:function(t,r,n,i,o){var a;a="number"==typeof r?t.split(" "):[t];for(var s=new e(o,n,r),l=s.createLine(i),u=0;u<a.length;u++){for(var c=a[u].split("\n"),h=0===u,f=0;f<c.length&&l;f++){var d=c[f];Or(d)&&Fr(d[d.length-1])&&(d+="‏");var _=h?d:" "+d;if(r&&u>0&&l.exceedsTextwrap(_)){if(!(l=s.advance(l,i)))break;l.append(d),h=!0;}else l.append(_);f<c.length-1&&(l=s.advance(l,i),h=!0);}u===a.length-1&&s.finish(l);}return s}}])}();Hr.ellipsis="...";var Wr=function(){return h((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;u(this,e),this.chars=0,this.text="",this.height=Math.ceil(t),this.text_wrap=r;}),[{key:"append",value:function(e){this.chars+=e.length,this.text+=e;}},{key:"exceedsTextwrap",value:function(e){return e.length+this.chars>this.text_wrap}}])}();function Yr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function Zr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Yr(Object(r),!0).forEach((function(t){s(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}var Jr=function(){function e(){u(this,e),this.createCanvas(),this.vertical_text_buffer=8,this.horizontal_text_buffer=4,this.background_size=4;}return h(e,[{key:"createCanvas",value:function(){this.canvas=document.createElement("canvas"),this.canvas.style.backgroundColor="transparent",this.context=this.canvas.getContext("2d");}},{key:"resize",value:function(e,t){this.canvas.width=e,this.canvas.height=t,this.context.clearRect(0,0,e,t);}},{key:"setFont",value:function(e){var t=e.font_css,r=e.fill,n=e.stroke,i=e.stroke_width,o=e.px_size,a=e.supersample;this.px_size=o;var s=this.context,l=M.device_pixel_ratio*a;n&&i>0&&(s.strokeStyle=n,s.lineWidth=i*l),s.fillStyle=r,s.font=t,s.miterLimit=2;}},{key:"textSizes",value:function(e,t){return new Promise(function(r,n){return Promise.resolve(Sr.loadFonts()).then(function(i){try{return r(L.add({type:"textSizes",run:this.processTextSizesTask.bind(this),texts:t,tile_id:e,cursor:{styles:Object.keys(t),texts:null,style_idx:null,text_idx:null}}))}catch(e){return n(e)}}.bind(this),n)}.bind(this))}},{key:"processTextSizesTask",value:function(t){var r,n=t.cursor,i=t.texts;for(n.style_idx=n.style_idx||0;n.style_idx<n.styles.length;){var o=n.styles[n.style_idx];null==n.text_idx&&(n.text_idx=0,n.texts=Object.keys(i[o]));for(var a=i[o],s=!0;n.text_idx<n.texts.length;){var l=n.texts[n.text_idx],u=a[l],c=u.text_settings;if(s&&(this.setFont(c),s=!1),u.size=this.textSize(o,l,c).size,c.can_articulate){var h=!1,f=!1;if(Or(l)&&(Fr(l)?h=!0:f=!0),u.isRTL=h,u.no_curving=f||(r=l,qr.test(r)),u.vertical_buffer=this.vertical_text_buffer,u.segment_sizes=[],!u.no_curving){var d=Xr(l,h,e.cache);u.segments=d;for(var _=0;_<d.length;_++)u.segment_sizes.push(this.textSize(o,d[_],c).size);}}if(n.text_idx++,!L.shouldContinue(t))return !1}n.text_idx=null,n.style_idx++;}return L.finish(t,i),!0}},{key:"textSize",value:function(t,r,n){var i=n.transform,o=n.text_wrap,a=n.max_lines,s=n.stroke_width,l=void 0===s?0:s,u=n.background_color,c=n.background_stroke_width,h=void 0===c?0:c,f=n.background_width,d=n.underline_width,_=void 0===d?0:d,p=n.supersample;if(e.cache.text[t]=e.cache.text[t]||{},e.cache.text[t][r])return e.cache.stats.text_hits++,e.cache.text[t][r];e.cache.stats.text_misses++,e.cache.text_count++;var m=M.device_pixel_ratio*p,v=this.applyTextTransform(r,i),g=this.context,y=this.vertical_text_buffer*m,x=(l+this.horizontal_text_buffer)*m;f=null!=f?f:this.background_size;var b=u||h?(f+h)*m:0,A=(2+_+(_?l+1:0))*m,T=this.px_size+A,w=Hr.parse(v,o,a,T,g),E=w.width,k=w.height,R=w.lines,z=[(E+=2*b)/m,(k+=2*b)/m],P=[E+2*x,k+2*y],S=[P[0]/m,P[1]/m];return e.cache.text[t][r]={lines:R,size:{collision_size:z,texture_size:P,logical_size:S,horizontal_buffer:x,vertical_buffer:y,dpr:m,line_height:T,background_size:b}},e.cache.text[t][r]}},{key:"drawTextMultiLine",value:function(e,t,r,i,o){var a=n(t,2),s=a[0],l=a[1],u=r.dpr,c=r.collision_size,h=r.texture_size,f=r.line_height,d=r.horizontal_buffer,_=r.vertical_buffer;if(i.background_color||i.background_stroke_color){var p=i.background_stroke_color,m=(i.background_stroke_width||0)*u;this.context.save(),i.background_color&&(this.context.fillStyle=i.background_color,this.context.fillRect(s+d+("curved"===o?h[0]:0)+m,l+_+m,u*c[0]-2*m,u*c[1]-2*m)),p&&m&&(this.context.strokeStyle=p,this.context.lineWidth=m,this.context.strokeRect(s+d+("curved"===o?h[0]:0)+.5*m,l+_+.5*m,u*c[0]-m,u*c[1]-m)),this.context.restore();}for(var v=i.underline_width||0,g=i.stroke_width||0,y=l-(v?.5*(v+g+1)*u:0),x=0;x<e.length;x++){var b=e[x];this.drawTextLine(b,[s,y],r,i,o),y+=f;}this.drawTextDebug([s,l],r,o);}},{key:"drawTextLine",value:function(e,t,r,i,o){var a,s=n(t,2),l=s[0],u=s[1],c=i.stroke,h=i.stroke_width,f=i.transform,d=i.align,_=void 0===d?"center":d,p=r.horizontal_buffer,m=r.vertical_buffer,v=r.texture_size,g=r.background_size,y=r.line_height,x=r.dpr,b=(i.underline_width||0)*x,A=this.applyTextTransform(e.text,f);"left"===_?a=l+p+g:"center"===_?a=l+v[0]/2-e.width/2:"right"===_&&(a=l+v[0]-e.width-p-g);var T=u+.75*m+y+g-.5*b,w=c&&h>0&&"curved"===o?v[0]:0;if(b){this.context.save(),this.context.strokeStyle=this.context.fillStyle,this.context.lineWidth=b;var E=T+(.5*h+2)*x+.5*this.context.lineWidth;this.context.beginPath(),this.context.moveTo(a+w,E),this.context.lineTo(a+w+e.width,E),this.context.stroke(),this.context.restore();}c&&h>0&&this.context.strokeText(A,a+w,T),this.context.fillText(A,a,T);}},{key:"drawTextDebug",value:function(e,t,r){var i=n(e,2),o=i[0],a=i[1],s=t.dpr,l=t.horizontal_buffer,u=t.vertical_buffer,c=t.texture_size,h=t.collision_size;P.draw_label_collision_boxes&&(this.context.save(),this.context.strokeStyle="blue",this.context.lineWidth=2,this.context.strokeRect(o+l,a+u,s*h[0],s*h[1]),"curved"===r&&this.context.strokeRect(o+c[0]+l,a+u,s*h[0],s*h[1]),this.context.restore()),P.draw_label_texture_boxes&&(this.context.save(),this.context.strokeStyle="green",this.context.lineWidth=2,this.context.strokeRect(o+2,a+2,c[0]-4,c[1]-4),"curved"===r&&this.context.strokeRect(o+2+c[0],a+2,c[0]-4,c[1]-4),this.context.restore());}},{key:"rasterize",value:function(e,t,r,n,i){return L.add({type:"rasterizeLabels",run:this.processRasterizeTask.bind(this),cancel:this.cancelRasterizeTask.bind(this),pause_factor:2,user_moving_view:!1,texts:e,textures:t,texture_prefix:n,gl:i,tile_id:r,cursor:{styles:Object.keys(e),texts:null,style_idx:0,text_idx:null,texture_idx:0,texture_resize:!0,texture_names:[]}})}},{key:"processRasterizeTask",value:function(e){for(var t,r=e.cursor,n=e.texts,i=e.textures;r.texture_idx<e.textures.length;){for(t=i[r.texture_idx],r.texture_resize&&(r.texture_resize=!1,this.resize.apply(this,l(t.texture_size)));r.style_idx<r.styles.length;){var o=r.styles[r.style_idx];null==r.text_idx&&(r.text_idx=0,r.texts=Object.keys(n[o]));for(var a=n[o],s=!0;r.text_idx<r.texts.length;){var u=r.texts[r.text_idx],c=a[u],h=c.text_settings;if(s&&(this.setFont(h),s=!1),h.can_articulate){c.texcoords=c.texcoords||{};for(var f=0;f<c.type.length;f++){var d=c.type[f];if("straight"===d){if(c.textures[f]!==r.texture_idx)continue;var _=c.isRTL?u.split().reverse().join():u,p=t.texcoord_cache[o][_],m=void 0;if(p.texcoord)m=p.texcoord;else {var v=p.texture_position,g=this.textSize(o,_,h),y=g.size,x=g.lines;this.drawTextMultiLine(x,v,y,h,d),m=D.getTexcoordsForSprite(v,y.texture_size,t.texture_size),p.texcoord=m;}c.texcoords[d]={texcoord:m,texture_id:p.texture_id};}else if("curved"===d){var b=c.segments;c.texcoords.curved=c.texcoords.curved||[],c.texcoords_stroke=c.texcoords_stroke||[];for(var A=0;A<b.length;A++)if(c.textures[f][A]===r.texture_idx){var T=b[A],w=t.texcoord_cache[o][T],E=void 0,k=void 0;if(w.texcoord)E=w.texcoord,k=w.texcoord_stroke,c.texcoords_stroke.push(k);else {var R=w.texture_position,M=this.textSize(o,T,h),z=M.size,P=M.lines;this.drawTextMultiLine(P,R,z,h,d),E=D.getTexcoordsForSprite(R,z.texture_size,t.texture_size);var S=[R[0]+z.texture_size[0],R[1]];k=D.getTexcoordsForSprite(S,z.texture_size,t.texture_size),w.texcoord=E,w.texcoord_stroke=k,c.texcoords_stroke.push(k);}c.texcoords.curved.push({texcoord:E,texture_id:w.texture_id});}}}}else {var N=this.textSize(o,u,h).lines,O=Zr({},h);for(var I in c.align)c.align[I].texture_id===r.texture_idx&&(O.align=I,this.drawTextMultiLine(N,c.align[I].texture_position,c.size,O),c.align[I].texcoords=D.getTexcoordsForSprite(c.align[I].texture_position,c.size.texture_size,t.texture_size));}if(r.text_idx++,!L.shouldContinue(e))return !1}r.text_idx=null,r.style_idx++;}var F=e.texture_prefix+r.texture_idx;D.create(e.gl,F,{element:this.canvas,filtering:"linear",UNPACK_PREMULTIPLY_ALPHA_WEBGL:!0}),D.retain(F),r.texture_names.push(F),r.texture_idx++,r.texture_resize=!0,r.style_idx=0;}return L.finish(e,r.texture_names),!0}},{key:"cancelRasterizeTask",value:function(e){k("trace","RasterizeTask: release textures [".concat(e.cursor.texture_names.join(", "),"]")),e.cursor.texture_names.forEach((function(e){return D.release(e)}));}},{key:"setTextureTextPositions",value:function(e,t){var r={cx:0,cy:0,width:0,height:0,column_width:0,texture_id:0,texcoord_cache:{}},n=[];for(var i in e){var o=e[i];for(var a in o){var s=o[a],l=void 0;if(s.text_settings.can_articulate){s.textures=[],r.texcoord_cache[i]=r.texcoord_cache[i]||{};for(var u=0;u<s.type.length;u++){var c=s.type[u];if("straight"===c){var h=s.isRTL?a.split().reverse().join():a;if(!r.texcoord_cache[i][h]){var f=s.size.texture_size;l=this.placeText(f[0],f[1],i,r,n,t),r.texcoord_cache[i][h]={texture_id:r.texture_id,texture_position:l};}s.textures[u]=r.texture_id;}else if("curved"===c){s.textures[u]=[];for(var d=0;d<s.segment_sizes.length;d++){var _=s.segments[d];if(!r.texcoord_cache[i][_]){var p=s.segment_sizes[d].texture_size,m=2*p[0];l=this.placeText(m,p[1],i,r,n,t),r.texcoord_cache[i][_]={texture_id:r.texture_id,texture_position:l};}s.textures[u].push(r.texture_id);}}}}else {var v=s.size.texture_size;for(var g in s.align)l=this.placeText(v[0],v[1],i,r,n,t),s.align[g].texture_id=r.texture_id,s.align[g].texture_position=l;}}}return r.column_width>0&&r.height>0&&(n[r.texture_id]={texture_size:[r.width,r.height],texcoord_cache:r.texcoord_cache}),n}},{key:"placeText",value:function(e,t,r,n,i,o){var a;return n.cy+t>o?(n.cx+=n.column_width,n.cy=0,n.column_width=e):n.column_width=Math.max(n.column_width,e),n.cx+n.column_width<=o?(a=[n.cx,n.cy],n.cy+=t,n.height=Math.max(n.height,n.cy),n.width=Math.max(n.width,n.cx+n.column_width)):(i[n.texture_id]={texture_size:[n.width,n.height],texcoord_cache:n.texcoord_cache},n.texcoord_cache={},n.texcoord_cache[r]={},n.texture_id++,n.cx=0,n.cy=t,n.column_width=e,n.width=e,n.height=t,a=[0,0]),a}},{key:"applyTextTransform",value:function(e,t){return "capitalize"===t?e.replace(/\w\S*/g,(function(e){return e.charAt(0).toUpperCase()+e.substr(1)})):"uppercase"===t?e.toUpperCase():"lowercase"===t?e.toLowerCase():e}}],[{key:"fontPixelSize",value:function(t){if(null!=t){var r=n((t="string"==typeof t?t:String(t)).match(e.font_size_re)||[],3),i=r[1],o=r[2];return "em"===(o=o||"px")?i*=16:"pt"===o?i/=.75:"%"===o&&(i/=6.25),i=ue.parsePositiveNumber(i),i*=M.device_pixel_ratio}}},{key:"pruneTextCache",value:function(){e.cache.text_count>e.cache.text_count_max&&(e.cache.text={},e.cache.text_count=0,k("debug","TextCanvas: pruning text cache")),Object.keys(e.cache.segment).length>e.cache.segment_count_max&&(e.cache.segment={},k("debug","TextCanvas: pruning segment cache"));}}])}();function Kr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}Jr.font_size_re=/((?:[0-9]*\.)?[0-9]+)\s*(px|pt|em|%)?/,Jr.cache={text:{},text_count:0,text_count_max:2e3,segment:{},segment_count_max:2e3,stats:{text_hits:0,text_misses:0,segment_hits:0,segment_misses:0}};var $r,Qr,en=0,tn={resetText:function(){i.is_main?this.canvas=new Jr:i.is_worker&&(this.texts={});},freeText:function(e){delete this.texts[e.id];},parseTextFeature:function(e,t,r,n){var i=this.parseTextSource(e,t,r);if(null!=i&&""!==i){var o=Rr.compute(t,r),a=Rr.key(o);this.texts[n.id]=this.texts[n.id]||{};var s=this.texts[n.id][a]=this.texts[n.id][a]||{};if(i instanceof Object){var l=[],u=i.left+"-"+i.right;for(var c in i){var h=i[c];if(h){var f=this.computeTextLayout({},e,t,r,n,h,o,u,c);s[h]||(s[h]={text_settings:o,ref:0}),l.push({draw:t,text:h,text_settings_key:a,layout:f});}}return l.length>0&&l}var d=this.computeTextLayout({},e,t,r,n,i,o);return s[i]||(s[i]={text_settings:o,ref:0}),{draw:t,text:i,text_settings_key:a,layout:d}}},parseTextSource:function(e,t,r){var n,i=t.text_source||"name";if(null==i||Array.isArray(i)||"object"!==o(i))n=this.parseTextSourceValue(i,e,r);else for(var a in n={},i)n[a]=this.parseTextSourceValue(i[a],e,r);return n},parseTextSourceValue:function(e,t,r){var n;if(Array.isArray(e)){for(var i=0;i<e.length;i++)if("string"==typeof e[i]?n=t.properties[e[i]]:"function"==typeof e[i]&&(n=e[i](r)),n)return n}else "string"==typeof e?n=t.properties[e]:e instanceof Function&&(n=e(r));return n},prepareTextLabels:function(e,t){return new Promise(function(r,n){var i;if(0===Object.keys(this.texts[e.id]||{}).length)return r([]);var o=function(t){try{return mr.abortTile(e.id),r([])}catch(e){return n(e)}};try{return Promise.resolve(v.postMessage(this.main_thread_target+".calcTextSizes",e.id,this.texts[e.id])).then(function(n){try{return i=n,e.canceled?(k("trace","Style ".concat(this.name,": stop tile build because tile was canceled: ").concat(e.key,", post-calcTextSizes()")),r([])):(this.texts[e.id]=i||[],i?r(this.buildTextLabels(e,t)):(mr.abortTile(e.id),r([])))}catch(e){return o()}}.bind(this),o)}catch(e){o();}}.bind(this))},collideAndRenderTextLabels:function(e,t,r){return new Promise(function(n,i){var o,a,l;return Promise.resolve(this.prepareTextLabels(e,r)).then(function(r){try{return 0===(o=r).length?(mr.collide([],t,e.id),n({})):Promise.resolve(mr.collide(o,t,e.id)).then(function(t){try{if(o=t,e.canceled)return k("trace","stop tile build because tile was canceled: ".concat(e.key,", post-collide()")),n({});if(null==(a=this.texts[e.id])||0===o.length)return n({});this.cullTextStyles(a,o),o.forEach((function(e){var t=e.text_settings_key,r=a[t]&&a[t][e.text];r.text_settings.can_articulate?(r.type||(r.type=[]),-1===r.type.indexOf(e.label.type)&&r.type.push(e.label.type)):(r.align=r.align||{},r.align[e.label.align]={});}));var r=function(e){try{return n({})}catch(e){return i(e)}};try{return Promise.resolve(v.postMessage(this.main_thread_target+".rasterizeTexts",e.id,e.key,a)).then((function(t){try{return l=t,e.canceled?(k("trace","stop tile build because tile was canceled: ".concat(e.key,", post-rasterizeTexts()")),n({})):n(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Kr(Object(r),!0).forEach((function(t){s(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Kr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}({labels:o},l))}catch(e){return r()}}),r)}catch(e){r();}}catch(e){return i(e)}}.bind(this),i)}catch(e){return i(e)}}.bind(this),i)}.bind(this))},cullTextStyles:function(e,t){for(var r=0;r<t.length;r++){var n=t[r];e[n.text_settings_key][n.text].ref++;}for(var i in e)for(var o in e[i])e[i][o].ref<1&&delete e[i][o];for(var a in e)0===Object.keys(e[a]).length&&delete e[a];},calcTextSizes:function(e,t){return this.canvas.textSizes(e,t)},rasterizeTexts:function(e,t,r){return new Promise(function(n,i){var o,a,s,l;return o=new Jr,a=Math.min(this.max_texture_size,2048),s=o.setTextureTextPositions(r,a),l=["labels",this.name,t,e,en,""].join("-"),en++,Promise.resolve(o.rasterize(r,s,e,l,this.gl)).then((function(e){try{return n((s=e)?{texts:r,textures:s}:{})}catch(e){return i(e)}}),i)}.bind(this))},preprocessText:function(e){if(e&&e.font&&"object"===o(e.font))return e.font.weight=ue.createPropertyCache(e.font.weight),e.font.fill=ue.createPropertyCache(e.font.fill||Rr.defaults.fill),e.font.alpha=ue.createPropertyCache(e.font.alpha),e.font.stroke&&(e.font.stroke.color=ue.createPropertyCache(e.font.stroke.color),e.font.stroke.alpha=ue.createPropertyCache(e.font.stroke.alpha)),e.font.background&&(e.font.background.color=ue.createPropertyCache(e.font.background.color),e.font.background.alpha=ue.createPropertyCache(e.font.background.alpha),e.font.background.width=ue.createPropertyCache(e.font.background.width,ue.parsePositiveNumber),e.font.background.stroke&&(e.font.background.stroke.color=ue.createPropertyCache(e.font.background.stroke.color),e.font.background.stroke.alpha=ue.createPropertyCache(e.font.background.stroke.alpha))),e.font.px_size=ue.createPropertyCache(e.font.size||Rr.defaults.size,Jr.fontPixelSize,Jr.fontPixelSize),e.font.stroke&&null!=e.font.stroke.width&&(e.font.stroke.width=ue.createPropertyCache(e.font.stroke.width,ue.parsePositiveNumber)),e.font.background&&e.font.background.stroke&&null!=e.font.background.stroke.width&&(e.font.background.stroke.width=ue.createPropertyCache(e.font.background.stroke.width,ue.parsePositiveNumber)),e.offset=ue.createPropertyCache(e.offset,(function(e){return Array.isArray(e)&&e.map(ue.parseNumber)})),e.buffer=ue.createPropertyCache(e.buffer,(function(e){return (Array.isArray(e)?e:[e,e]).map(ue.parsePositiveNumber)})),e.repeat_distance=ue.createPropertyCache(e.repeat_distance,ue.parsePositiveNumber),e},computeTextLayout:function(e,t,r,n,i,o,a,s,l){var u=e||{};return u=this.computeLayout(u,t,r,n,i),null==r.repeat_distance&&(u.repeat_distance="point"===n.geometry?0:Q.tile_size,u.repeat_distance&&(u.repeat_distance*=u.units_per_pixel,u.repeat_scale=1,"function"==typeof r.repeat_group?u.repeat_group=r.repeat_group(n):u.repeat_group=r.repeat_group)),u.repeat_distance&&(s&&(u.repeat_group+="/"+s),u.repeat_group+="/"+o),u.subdiv=i.overzoom2,u.align=r.align,u.italic="normal"!==a.style,"right"===l?u.orientation=1:"left"===l&&(u.orientation=-1),u}};var rn,nn,on=q(Qr?$r:(Qr=1,$r=function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],_=t[12],p=t[13],m=t[14],v=t[15],g=r*s-n*a,y=r*l-i*a,x=r*u-o*a,b=n*l-i*s,A=n*u-o*s,T=i*u-o*l,w=c*p-h*_,E=c*m-f*_,k=c*v-d*_,R=h*m-f*p,M=h*v-d*p,z=f*v-d*m,P=g*z-y*M+x*R+b*k-A*E+T*w;return P?(P=1/P,e[0]=(s*z-l*M+u*R)*P,e[1]=(l*k-a*z-u*E)*P,e[2]=(a*M-s*k+u*w)*P,e[3]=(i*M-n*z-o*R)*P,e[4]=(r*z-i*k+o*E)*P,e[5]=(n*k-r*M-o*w)*P,e[6]=(p*T-m*A+v*b)*P,e[7]=(m*x-_*T-v*y)*P,e[8]=(_*A-p*x+v*g)*P,e):null}));var an,sn,ln=q(nn?rn:(nn=1,rn=function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*a-s*u,f=-c*o+s*l,d=u*o-a*l,_=r*h+n*f+i*d;return _?(_=1/_,e[0]=h*_,e[1]=(-c*n+i*u)*_,e[2]=(s*n-i*a)*_,e[3]=f*_,e[4]=(c*r-i*l)*_,e[5]=(-s*r+i*o)*_,e[6]=d*_,e[7]=(-u*r+n*l)*_,e[8]=(a*r-n*o)*_,e):null}));var un,cn,hn=q(sn?an:(sn=1,an=function(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=t[9],d=t[10],_=t[11],p=t[12],m=t[13],v=t[14],g=t[15],y=r[0],x=r[1],b=r[2],A=r[3];return e[0]=y*n+x*s+b*h+A*p,e[1]=y*i+x*l+b*f+A*m,e[2]=y*o+x*u+b*d+A*v,e[3]=y*a+x*c+b*_+A*g,y=r[4],x=r[5],b=r[6],A=r[7],e[4]=y*n+x*s+b*h+A*p,e[5]=y*i+x*l+b*f+A*m,e[6]=y*o+x*u+b*d+A*v,e[7]=y*a+x*c+b*_+A*g,y=r[8],x=r[9],b=r[10],A=r[11],e[8]=y*n+x*s+b*h+A*p,e[9]=y*i+x*l+b*f+A*m,e[10]=y*o+x*u+b*d+A*v,e[11]=y*a+x*c+b*_+A*g,y=r[12],x=r[13],b=r[14],A=r[15],e[12]=y*n+x*s+b*h+A*p,e[13]=y*i+x*l+b*f+A*m,e[14]=y*o+x*u+b*d+A*v,e[15]=y*a+x*c+b*_+A*g,e}));var fn,dn,_n=q(cn?un:(cn=1,un=function(e,t,r){var n,i,o,a,s,l,u,c,h,f,d,_,p=r[0],m=r[1],v=r[2];return t===e?(e[12]=t[0]*p+t[4]*m+t[8]*v+t[12],e[13]=t[1]*p+t[5]*m+t[9]*v+t[13],e[14]=t[2]*p+t[6]*m+t[10]*v+t[14],e[15]=t[3]*p+t[7]*m+t[11]*v+t[15]):(n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=t[9],d=t[10],_=t[11],e[0]=n,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=f,e[10]=d,e[11]=_,e[12]=n*p+s*m+h*v+t[12],e[13]=i*p+l*m+f*v+t[13],e[14]=o*p+u*m+d*v+t[14],e[15]=a*p+c*m+_*v+t[15]),e}));var pn,mn,vn=q(dn?fn:(dn=1,fn=function(e,t,r){var n=r[0],i=r[1],o=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}));var gn,yn,xn,bn,An=q(mn?pn:(mn=1,pn=function(e,t,r,n,i){var o=1/Math.tan(t/2),a=1/(n-i);return e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*a,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*a,e[15]=0,e}));function Tn(){if(yn)return gn;return yn=1,gn=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}}var wn,En,kn=function(){if(bn)return xn;bn=1;var e=Tn();return xn=function(t,r,n,i){var o,a,s,l,u,c,h,f,d,_,p=r[0],m=r[1],v=r[2],g=i[0],y=i[1],x=i[2],b=n[0],A=n[1],T=n[2];if(Math.abs(p-b)<1e-6&&Math.abs(m-A)<1e-6&&Math.abs(v-T)<1e-6)return e(t);h=p-b,f=m-A,d=v-T,_=1/Math.sqrt(h*h+f*f+d*d),o=y*(d*=_)-x*(f*=_),a=x*(h*=_)-g*d,s=g*f-y*h,(_=Math.sqrt(o*o+a*a+s*s))?(o*=_=1/_,a*=_,s*=_):(o=0,a=0,s=0);l=f*s-d*a,u=d*o-h*s,c=h*a-f*o,(_=Math.sqrt(l*l+u*u+c*c))?(l*=_=1/_,u*=_,c*=_):(l=0,u=0,c=0);return t[0]=o,t[1]=l,t[2]=h,t[3]=0,t[4]=a,t[5]=u,t[6]=f,t[7]=0,t[8]=s,t[9]=c,t[10]=d,t[11]=0,t[12]=-(o*p+a*m+s*v),t[13]=-(l*p+u*m+c*v),t[14]=-(h*p+f*m+d*v),t[15]=1,t}}(),Rn=q(kn),Mn=Tn();var zn=En?wn:(En=1,wn=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}),Pn=function(e,t,r){var n=new Float64Array(3);return n[0]=e,n[1]=t,n[2]=r,n},Sn={normalFromMat4:on,invert:ln},Nn={multiply:hn,translate:_n,scale:vn,perspective:An,lookAt:Rn,identity:q(Mn),copy:q(zn)};function On(e,t,r){return t=Me(t),Pe(e,Ln()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function Ln(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (Ln=function(){return !!e})()}function In(e,t,r,n){var i=ze(Me(e.prototype),t,r);return "function"==typeof i?function(e){return i.apply(r,e)}:i}var Fn=function(){return h((function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,e),this.view=r,this.position=n.position,this.zoom=n.zoom;}),[{key:"update",value:function(){}},{key:"setupProgram",value:function(){}},{key:"updateView",value:function(){if(this.position||this.zoom){var e={};this.position&&(e={lng:this.position[0],lat:this.position[1],zoom:this.position[2]}),this.zoom&&(e.zoom=this.zoom),this.view.setView(e);}}},{key:"setupMatrices",value:function(e,t){Nn.multiply(e.model_view32,this.view_matrix,e.model),t.uniform("Matrix4fv","u_modelView",e.model_view32),Sn.normalFromMat4(e.normal32,e.model_view32),Sn.invert(e.inverse_normal32,e.normal32),t.uniform("Matrix3fv","u_normalMatrix",e.normal32),t.uniform("Matrix3fv","u_inverseNormalMatrix",e.inverse_normal32);}}],[{key:"create",value:function(e,t,r){switch(r.type){case"isometric":return new Un(e,t,r);case"flat":return new Gn(e,t,r);default:return new Dn(e,t,r)}}}])}(),Dn=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,t),(n=On(this,t,[e,r,i])).type="perspective",n.focal_length=i.focal_length,n.fov=i.fov,n.focal_length||n.fov||(n.focal_length=[[16,2],[17,2.5],[18,3],[19,4],[20,6]]),n.vanishing_point=i.vanishing_point||[0,0],n.vanishing_point=n.vanishing_point.map(parseFloat),n.vanishing_point_skew=[],n.position_meters=null,n.view_matrix=new Float64Array(16),n.projection_matrix=new Float32Array(16),Z.replaceBlock("camera","\n            uniform mat4 u_projection;\n            uniform vec3 u_eye;\n            uniform vec2 u_vanishing_point;\n\n            void cameraProjection (inout vec4 position) {\n                position = u_projection * position;\n            }"),n}return Se(t,e),h(t,[{key:"constrainCamera",value:function(e){var t=e.view_height,r=e.height,n=e.focal_length,i=e.fov;return r?(n=2*r/t,i=2*Math.atan(1/n)):(n?i=2*Math.atan(1/n):i&&(i=i*Math.PI/180,n=1/Math.tan(i/2)),r=t/2*n),{view_height:t,height:r,focal_length:n,fov:i}}},{key:"updateMatrices",value:function(){var e=this.view.size.css.height*this.view.meters_per_pixel,t=this.constrainCamera({view_height:e,focal_length:M.interpolate(this.view.zoom,this.focal_length),fov:M.interpolate(this.view.zoom,this.fov)}),r=t.height,n=t.fov,i=[this.view.center.meters.x,this.view.center.meters.y,r];this.position_meters=i,Nn.lookAt(this.view_matrix,Pn(i[0],i[1],0),Pn(i[0],i[1],-1),Pn(0,1,0)),Nn.perspective(this.projection_matrix,n,this.view.aspect,1,2*r),this.vanishing_point_skew[0]=this.vanishing_point[0]/this.view.size.css.width,this.vanishing_point_skew[1]=this.vanishing_point[1]/this.view.size.css.height,this.projection_matrix[8]=2*-this.vanishing_point_skew[0],this.projection_matrix[9]=2*-this.vanishing_point_skew[1],Nn.translate(this.projection_matrix,this.projection_matrix,Pn(e/2*this.view.aspect*(2*-this.vanishing_point_skew[0]),e/2*(2*-this.vanishing_point_skew[1]),0)),Nn.translate(this.projection_matrix,this.projection_matrix,Pn(0,0,-r));}},{key:"update",value:function(){In(t,"update",this)([]),this.updateMatrices();}},{key:"setupProgram",value:function(e){e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3f","u_eye",[0,0,this.position_meters[2]]),e.uniform("2fv","u_vanishing_point",this.vanishing_point_skew);}}])}(Fn),Un=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,t),(n=On(this,t,[e,r,i])).type="isometric",n.axis=i.axis||{x:0,y:1},2===n.axis.length&&(n.axis={x:n.axis[0],y:n.axis[1]}),n.position_meters=null,n.viewport_height=null,n.view_matrix=new Float64Array(16),n.projection_matrix=new Float32Array(16),Z.replaceBlock("camera","\n            uniform mat4 u_projection;\n            uniform vec3 u_eye;\n            uniform vec2 u_vanishing_point;\n\n            void cameraProjection (inout vec4 position) {\n                position = u_projection * position;\n                // position.xy += position.z * u_isometric_axis;\n\n                // Reverse z for depth buffer so up is negative,\n                // and scale down values so objects higher than one screen height will not get clipped\n                // pull forward slightly to avoid going past far clipping plane\n                position.z = -position.z / 100. + 1. - 0.001;\n            }"),n}return Se(t,e),h(t,[{key:"update",value:function(){In(t,"update",this)([]),this.viewport_height=this.view.size.css.height*this.view.meters_per_pixel;var e=[this.view.center.meters.x,this.view.center.meters.y,this.viewport_height];this.position_meters=e,Nn.identity(this.view_matrix),Nn.translate(this.view_matrix,this.view_matrix,Pn(-e[0],-e[1],0)),Nn.identity(this.projection_matrix),this.projection_matrix[8]=this.axis.x/this.view.aspect,this.projection_matrix[9]=this.axis.y,Nn.scale(this.projection_matrix,this.projection_matrix,Pn(2/this.view.size.meters.x,2/this.view.size.meters.y,2/this.view.size.meters.y));}},{key:"setupProgram",value:function(e){e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3fv","u_eye",[0,0,this.viewport_height]),e.uniform("2fv","u_vanishing_point",[0,0]);}}])}(Fn),Gn=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,t),(n=On(this,t,[e,r,i])).type="flat",n}return Se(t,e),h(t,[{key:"update",value:function(){this.axis.x=0,this.axis.y=0,In(t,"update",this)([]);}}])}(Un),jn=function(){return h((function e(t,r){u(this,e),I(this),this.scene=t,this.createMatrices(),this.zoom=null,this.center=null,this.bounds=null,this.meters_per_pixel=null,this.panning=!1,this.panning_stop_at=0,this.pan_snap_timer=0,this.zoom_direction=0,this.user_input_at=0,this.user_input_timeout=50,this.user_input_active=!1,this.size={css:{},device:{},meters:{}},this.aspect=null,this.buffer=0,this.continuous_zoom="boolean"!=typeof r.continuousZoom||r.continuousZoom,this.wrap=!1!==r.wrapView,this.preserve_tiles_within_zoom=1,this.reset();}),[{key:"reset",value:function(){this.createCamera();}},{key:"createCamera",value:function(){var e=this.getActiveCamera();e&&(this.camera=Fn.create(e,this,this.scene.config.cameras[e]),this.camera.updateView());}},{key:"getActiveCamera",value:function(){if(this.scene.config&&this.scene.config.cameras){for(var e in this.scene.config.cameras)if(this.scene.config.cameras[e].active)return e;var t=Object.keys(this.scene.config.cameras);return t.length&&t[0]}}},{key:"setActiveCamera",value:function(e){var t=this.getActiveCamera();return t===e?e:(this.scene.config.cameras[e]&&(this.scene.config.cameras[e].active=!0,t&&this.scene.config.cameras[t]&&delete this.scene.config.cameras[t].active),this.scene.updateConfig({rebuild:!1,normalize:!1}),this.getActiveCamera())}},{key:"update",value:function(){null!=this.camera&&this.ready()&&this.camera.update(),this.pan_snap_timer=(+new Date-this.panning_stop_at)/1e3,this.user_input_active=+new Date-this.user_input_at<this.user_input_timeout;}},{key:"setViewportSize",value:function(e,t){this.size.css={width:e,height:t},this.size.device={width:Math.round(this.size.css.width*M.device_pixel_ratio),height:Math.round(this.size.css.height*M.device_pixel_ratio)},this.aspect=this.size.css.width/this.size.css.height,this.updateBounds();}},{key:"setView",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.lng,r=e.lat,n=e.zoom,i=!1;return "number"==typeof t&&"number"==typeof r&&(this.center&&t===this.center.lng&&r===this.center.lat||(i=!0,this.center={lng:t,lat:r})),"number"==typeof n&&n!==this.zoom&&(i=!0,this.setZoom(n)),i&&this.updateBounds(),i}},{key:"setZoom",value:function(e){var t=this.tile_zoom,r=this.baseZoom(e);this.continuous_zoom||(e=r),r!==t&&(this.zoom_direction=r>t?1:-1),this.zoom=e,this.tile_zoom=r,this.updateBounds(),this.scene.requestRedraw();}},{key:"baseZoom",value:function(e){return Math.floor(e)}},{key:"setPanning",value:function(e){this.panning=e,this.panning||(this.panning_stop_at=+new Date);}},{key:"markUserInput",value:function(){this.user_input_at=+new Date;}},{key:"ready",value:function(){return "number"==typeof this.size.css.width&&"number"==typeof this.size.css.height&&null!=this.center&&"number"==typeof this.zoom}},{key:"updateBounds",value:function(){if(this.ready()){this.meters_per_pixel=Q.metersPerPixel(this.zoom),this.size.meters={x:this.size.css.width*this.meters_per_pixel,y:this.size.css.height*this.meters_per_pixel};var e=Q.latLngToMeters([this.center.lng,this.center.lat]);this.center.meters={x:e[0],y:e[1]},this.center.tile=Q.tileForMeters([this.center.meters.x,this.center.meters.y],this.tile_zoom),this.bounds={sw:{x:this.center.meters.x-this.size.meters.x/2,y:this.center.meters.y-this.size.meters.y/2},ne:{x:this.center.meters.x+this.size.meters.x/2,y:this.center.meters.y+this.size.meters.y/2}},this.scene.tile_manager.updateTilesForView(),this.trigger("move"),this.scene.requestRedraw();}}},{key:"findVisibleTileCoordinates",value:function(){if(!this.bounds)return [];var e=this.tile_zoom,t=Q.tileForMeters([this.bounds.sw.x,this.bounds.sw.y],e),r=Q.tileForMeters([this.bounds.ne.x,this.bounds.ne.y],e),n=[t.x-this.buffer,r.x+this.buffer,r.y-this.buffer,t.y+this.buffer];if(!1===this.wrap){var i=(1<<e)-1;n=n.map((function(e){return Math.min(Math.max(0,e),i)}));}for(var o=[],a=n[0];a<=n[1];a++)for(var s=n[2];s<=n[3];s++)o.push(Je.coord({x:a,y:s,z:e}));return o}},{key:"pruneTilesForView",value:function(){var e=this;this.ready()&&this.scene.tile_manager.removeTiles((function(t){if(t.visible||t.isProxy())return !1;if(t.loading&&t.style_z!==e.tile_zoom)return !0;if(Math.abs(t.style_z-e.tile_zoom)>(null!=t.preserve_tiles_within_zoom?t.preserve_tiles_within_zoom:e.preserve_tiles_within_zoom))return !0;var r=e.meters_per_pixel*Q.tile_size,n=Je.coordAtZoom(Q.tileForMeters([e.center.meters.x-e.size.meters.x/2-r,e.center.meters.y+e.size.meters.y/2+r],e.tile_zoom),t.coords.z),i=Je.coordAtZoom(Q.tileForMeters([e.center.meters.x+e.size.meters.x/2+r,e.center.meters.y-e.size.meters.y/2-r],e.tile_zoom),t.coords.z);return (t.coords.x<n.x||t.coords.x>i.x||t.coords.y<n.y||t.coords.y>i.y)&&(k("trace","View: remove tile ".concat(t.key," (as ").concat(t.coords.key,") ")+"for being too far out of visible area (".concat(n.key,", ").concat(i.key,")")),!0)}));}},{key:"createMatrices",value:function(){this.matrices={},this.matrices.model=new Float64Array(16),this.matrices.model32=new Float32Array(16),this.matrices.model_view=new Float64Array(16),this.matrices.model_view32=new Float32Array(16),this.matrices.normal=new Float64Array(9),this.matrices.normal32=new Float32Array(9),this.matrices.inverse_normal32=new Float32Array(9);}},{key:"setupTile",value:function(e,t){e.setupProgram(this.matrices,t),this.camera.setupMatrices(this.matrices,t);}},{key:"setupProgram",value:function(e){e.uniform("2fv","u_resolution",[this.size.device.width,this.size.device.height]),e.uniform("3fv","u_map_position",[this.center.meters.x,this.center.meters.y,this.zoom]),e.uniform("1f","u_meters_per_pixel",this.meters_per_pixel),e.uniform("1f","u_device_pixel_ratio",M.device_pixel_ratio),e.uniform("1f","u_view_pan_snap_timer",this.pan_snap_timer),e.uniform("1i","u_view_panning",this.panning),this.camera.setupProgram(e);}},{key:"isAnimating",value:function(){return this.pan_snap_timer<=.5}}])}(),Cn=yr.PLACEMENT,Bn=Object.create(nt),Vn="__shader_point";function qn(e,t,r){return t=Me(t),Pe(e,Xn()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function Xn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (Xn=function(){return !!e})()}Object.assign(Bn,tn),Object.assign(Bn,{name:"points",built_in:!0,vertex_shader_src:"uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_tile_proxy_order_offset;\nuniform bool u_tile_fade_in;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\nuniform float u_visible_time;\nuniform bool u_view_panning;\nuniform float u_view_pan_snap_timer;\n\nuniform mat4 u_model;\nuniform mat4 u_modelView;\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nattribute vec4 a_position;\nattribute vec4 a_shape;\nattribute vec4 a_color;\nattribute vec2 a_texcoord;\nattribute vec2 a_offset;\n\nuniform float u_point_type;\n\n#ifdef TANGRAM_CURVED_LABEL\n    attribute vec4 a_offsets;\n    attribute vec4 a_pre_angles;\n    attribute vec4 a_angles;\n#endif\n\nvarying vec4 v_color;\nvarying vec2 v_texcoord;\nvarying vec4 v_world_position;\nvarying float v_alpha_factor;\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n    attribute float a_outline_edge;\n    attribute vec4 a_outline_color;\n\n    varying float v_outline_edge;\n    varying vec4 v_outline_color;\n    varying float v_aa_offset;\n#endif\n\n#ifdef TANGRAM_SHOW_HIDDEN_LABELS\n    varying float v_label_hidden;\n#endif\n\n#define TANGRAM_PI 3.14159265359\n#define TANGRAM_NORMAL vec3(0., 0., 1.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\nvec2 rotate2D(vec2 _st, float _angle) {\n    return mat2(cos(_angle),-sin(_angle),\n                sin(_angle),cos(_angle)) * _st;\n}\n\n#ifdef TANGRAM_CURVED_LABEL\n    // Assumes stops are [0, 0.33, 0.66, 0.99];\n    float mix4linear(vec4 v, float x) {\n        x = clamp(x, 0., 1.);\n        return mix(mix(v[0], v[1], 3. * x),\n                   mix(v[1],\n                       mix(v[2], v[3], 3. * (max(x, .66) - .66)),\n                       3. * (clamp(x, .33, .66) - .33)),\n                   step(0.33, x)\n                );\n    }\n#endif\n\nvoid main() {\n    // Initialize globals\n    #pragma tangram: setup\n\n    // discard hidden labels by collapsing into degenerate triangle\n    #ifndef TANGRAM_SHOW_HIDDEN_LABELS\n        if (a_shape.w == 0.) {\n            gl_Position = vec4(0., 0., 0., 1.);\n            return;\n        }\n    #else\n        // highlight hidden label in fragment shader for debugging\n        if (a_shape.w == 0.) {\n            v_label_hidden = 1.; // label debug testing\n        }\n        else {\n            v_label_hidden = 0.;\n        }\n    #endif\n\n    v_alpha_factor = 1.0;\n    v_color = a_color;\n    v_texcoord = a_texcoord; // UV from vertex attribute\n\n    #ifdef TANGRAM_HAS_SHADER_POINTS\n        v_outline_color = a_outline_color;\n        v_outline_edge = a_outline_edge;\n\n        if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n            // use point dimensions for UVs instead (ignore attribute), add antialiasing info for fragment shader\n            float _size = abs(a_shape.x / 128.); // radius in pixels\n            v_texcoord = sign(a_shape.xy) * (_size + 1.) / _size;\n            _size += 2.;\n            v_aa_offset = 2. / _size;\n        }\n    #endif\n\n    // Position\n    vec4 position = u_modelView * vec4(a_position.xyz, 1.);\n\n    // Apply positioning and scaling in screen space\n    vec2 _shape = a_shape.xy / 256.;                 // values have an 8-bit fraction\n    vec2 _offset = vec2(a_offset.x, -a_offset.y);    // flip y to make it point down\n    float _theta = a_shape.z / 4096.;\n\n    #ifdef TANGRAM_CURVED_LABEL\n        //TODO: potential bug? null is passed in for non-curved labels, otherwise the first offset will be 0\n        if (a_offsets[0] != 0.){\n            vec4 _angles_scaled = (TANGRAM_PI / 16384.) * a_angles;\n            vec4 _pre_angles_scaled = (TANGRAM_PI / 128.) * a_pre_angles;\n            vec4 _offsets_scaled = (1. / 64.) * a_offsets;\n\n            float _zoom = clamp(u_map_position.z - u_tile_origin.z, 0., 1.); //fract(u_map_position.z);\n            float _pre_angle = mix4linear(_pre_angles_scaled, _zoom);\n            float _angle = mix4linear(_angles_scaled, _zoom);\n            float _offset_curve = mix4linear(_offsets_scaled, _zoom);\n\n            _shape = rotate2D(_shape, _pre_angle); // rotate in place\n            _shape.x += _offset_curve;            // offset for curved label segment\n            _shape = rotate2D(_shape, _angle);     // rotate relative to curved label anchor\n            _shape += rotate2D(_offset, _theta);   // offset if specified in the scene file\n        }\n        else {\n            _shape = rotate2D(_shape + _offset, _theta);\n        }\n    #else\n        _shape = rotate2D(_shape + _offset, _theta);\n    #endif\n\n    // Fade in (if requested) based on time mesh has been visible.\n    // Value passed to fragment shader in the v_alpha_factor varying\n    #ifdef TANGRAM_FADE_IN_RATE\n        if (u_tile_fade_in) {\n            v_alpha_factor *= clamp(u_visible_time * TANGRAM_FADE_IN_RATE, 0., 1.);\n        }\n    #endif\n\n    // World coordinates for 3d procedural textures\n    v_world_position = u_model * position;\n    v_world_position.xy += _shape * u_meters_per_pixel;\n    v_world_position = wrapWorldPosition(v_world_position);\n\n    // Modify position before camera projection\n    #pragma tangram: position\n\n    cameraProjection(position);\n\n    #ifdef TANGRAM_LAYER_ORDER\n        // +1 is to keep all layers including proxies > 0\n        applyLayerOrder(a_position.w + u_tile_proxy_order_offset + 1., position);\n    #endif\n\n    // Apply pixel offset in screen-space\n    // Multiply by 2 is because screen is 2 units wide Normalized Device Coords (and u_resolution device pixels wide)\n    // Device pixel ratio adjustment is because shape is in logical pixels\n    position.xy += _shape * position.w * 2. * u_device_pixel_ratio / u_resolution;\n    #ifdef TANGRAM_HAS_SHADER_POINTS\n        if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n            // enlarge by 1px to catch missed MSAA fragments\n            position.xy += sign(_shape) * position.w * u_device_pixel_ratio / u_resolution;\n        }\n    #endif\n\n    // Snap to pixel grid\n    // Only applied to fully upright sprites/labels (not shader-drawn points), while panning is not active\n    #ifdef TANGRAM_HAS_SHADER_POINTS\n    if (!u_view_panning && (abs(_theta) < TANGRAM_EPSILON) && u_point_type != TANGRAM_POINT_TYPE_SHADER) {\n    #else\n    if (!u_view_panning && (abs(_theta) < TANGRAM_EPSILON)) {\n    #endif\n        vec2 _position_fract = fract((((position.xy / position.w) + 1.) * .5) * u_resolution);\n        vec2 _position_snap = position.xy + ((step(0.5, _position_fract) - _position_fract) * position.w * 2. / u_resolution);\n\n        // Animate the snapping to smooth the transition and make it less noticeable\n        #ifdef TANGRAM_VIEW_PAN_SNAP_RATE\n            position.xy = mix(position.xy, _position_snap, clamp(u_view_pan_snap_timer * TANGRAM_VIEW_PAN_SNAP_RATE, 0., 1.));\n        #else\n            position.xy = _position_snap;\n        #endif\n    }\n\n    gl_Position = position;\n}\n",fragment_shader_src:"uniform vec2 u_resolution;\nuniform float u_time;\nuniform vec3 u_map_position;\nuniform vec4 u_tile_origin;\nuniform float u_meters_per_pixel;\nuniform float u_device_pixel_ratio;\nuniform float u_visible_time;\n\nuniform mat3 u_normalMatrix;\nuniform mat3 u_inverseNormalMatrix;\n\nuniform sampler2D u_texture;\nuniform float u_point_type;\nuniform bool u_apply_color_blocks;\n\nvarying vec4 v_color;\nvarying vec2 v_texcoord;\nvarying vec4 v_world_position;\nvarying float v_alpha_factor;\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n    varying vec4 v_outline_color;\n    varying float v_outline_edge;\n    varying float v_aa_offset;\n#endif\n\n#ifdef TANGRAM_SHOW_HIDDEN_LABELS\n    varying float v_label_hidden;\n#endif\n\n#define TANGRAM_NORMAL vec3(0., 0., 1.)\n\n#pragma tangram: attributes\n#pragma tangram: camera\n#pragma tangram: material\n#pragma tangram: lighting\n#pragma tangram: raster\n#pragma tangram: global\n\n#ifdef TANGRAM_HAS_SHADER_POINTS\n    //l is the distance from the center to the fragment, R is the radius of the drawn point\n    float _tangram_antialias(float l, float R){\n        float low  = R - v_aa_offset;\n        float high = R + v_aa_offset;\n        return 1. - smoothstep(low, high, l);\n    }\n#endif\n\nvoid main (void) {\n    // Initialize globals\n    #pragma tangram: setup\n\n    vec4 color = v_color;\n\n    #ifdef TANGRAM_HAS_SHADER_POINTS\n        // Only apply shader blocks to point, not to attached text (N.B.: for compatibility with ES)\n        if (u_point_type == TANGRAM_POINT_TYPE_TEXTURE) { // sprite texture\n            color *= texture2D(u_texture, v_texcoord);\n        }\n        else if (u_point_type == TANGRAM_POINT_TYPE_LABEL) { // label texture\n            color = texture2D(u_texture, v_texcoord);\n            color.rgb /= max(color.a, 0.001); // un-multiply canvas texture\n        }\n        else if (u_point_type == TANGRAM_POINT_TYPE_SHADER) { // shader point\n            // Mask of outermost circle, either outline or point boundary\n            float _d = length(v_texcoord); // distance to this fragment from the point center\n            float _outer_alpha = _tangram_antialias(_d, 1.);\n            float _fill_alpha = _tangram_antialias(_d, 1. - (v_outline_edge * 0.5)) * color.a;\n            float _stroke_alpha = (_outer_alpha - _tangram_antialias(_d, 1. - v_outline_edge)) * v_outline_color.a;\n\n            // Apply alpha compositing with stroke 'over' fill.\n            #ifdef TANGRAM_BLEND_ADD\n                color.a = _stroke_alpha + _fill_alpha;\n                color.rgb = color.rgb * _fill_alpha + v_outline_color.rgb * _stroke_alpha;\n            #else // TANGRAM_BLEND_OVERLAY (and fallback for not implemented blending modes)\n                color.a = _stroke_alpha + _fill_alpha * (1. - _stroke_alpha);\n                color.rgb = mix(color.rgb * _fill_alpha, v_outline_color.rgb, _stroke_alpha) / max(color.a, 0.001); // avoid divide by zero\n            #endif\n        }\n    #else\n        // If shader points not supported, assume label texture\n        color = texture2D(u_texture, v_texcoord);\n        color.rgb /= max(color.a, 0.001); // un-multiply canvas texture\n    #endif\n\n    // Shader blocks for color/filter are only applied for sprites, shader points, and standalone text,\n    // NOT for text attached to a point (N.B.: for compatibility with ES)\n    if (u_apply_color_blocks) {\n        #pragma tangram: color\n        #pragma tangram: filter\n    }\n\n    color.a *= v_alpha_factor;\n\n    // highlight hidden label in fragment shader for debugging\n    #ifdef TANGRAM_SHOW_HIDDEN_LABELS\n        if (v_label_hidden > 0.) {\n            color.a *= 0.5;\n            color.rgb = vec3(1., 0., 0.);\n        }\n    #endif\n\n    // Use alpha test as a lower-quality substitute\n    // For opaque and translucent: avoid transparent pixels writing to depth buffer, obscuring geometry underneath\n    // For multiply: avoid transparent pixels multiplying geometry underneath to zero/full black\n    #if defined(TANGRAM_BLEND_OPAQUE) || defined(TANGRAM_BLEND_TRANSLUCENT) || defined(TANGRAM_BLEND_MULTIPLY)\n        if (color.a < TANGRAM_ALPHA_TEST) {\n            discard;\n        }\n    #endif\n\n    // Make points more visible in wireframe debug mode\n    #ifdef TANGRAM_WIREFRAME\n        color = vec4(vec3(0.5), 1.); // use gray outline for textured points\n        #ifdef TANGRAM_HAS_SHADER_POINTS\n            if (u_point_type == TANGRAM_POINT_TYPE_SHADER) {\n                color = vec4(v_color.rgb, 1.); // use original vertex color outline for shader points\n            }\n        #endif\n    #endif\n\n    gl_FragColor = color;\n}\n",selection:!0,collision:!0,blend:"overlay",init:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};nt.init.call(this,e),this.setupDefines(),this.defines.TANGRAM_HAS_SHADER_POINTS=!0,this.defines.TANGRAM_POINT_TYPE_TEXTURE=1,this.defines.TANGRAM_POINT_TYPE_LABEL=2,this.defines.TANGRAM_POINT_TYPE_SHADER=3,this.collision_group_points=this.name+"-points",this.collision_group_text=this.name+"-text",this.stencil_proxy_tiles=!1,this.reset();},setupDefines:function(){"overlay"!==this.blend&&(this.defines.TANGRAM_LAYER_ORDER=!0),!0===P.suppress_label_fade_in?(this.fade_in_time=0,this.defines.TANGRAM_FADE_IN_RATE=null):(this.fade_in_time=.15,this.defines.TANGRAM_FADE_IN_RATE=1/this.fade_in_time),!0!==P.suppress_label_snap_animation&&(this.defines.TANGRAM_VIEW_PAN_SNAP_RATE=2),!0===P.show_hidden_labels&&(this.defines.TANGRAM_SHOW_HIDDEN_LABELS=!0),!0===P.wireframe&&(this.defines.TANGRAM_WIREFRAME=!0);},reset:function(){this.queues={},this.resetText(),this.texture_missing_sprites={};},addFeature:function(e,t,r){var n=r.tile;if(n.generation===this.generation){var i={};if(i.color=this.parseColor(t.color,r),i.texture=t.texture,i.label_texture=null,i.blend_order=t.blend_order,i.color||i.texture){var o;if(i.alpha=ue.evalCachedProperty(t.alpha,r),this.hasSprites(i)){if(!(o=this.parseSprite(i,t,r)))return void k({level:"debug",once:!0},"Layer group '".concat(t.layers.join(", "),"' ")+"uses a texture '".concat(i.texture,"', but doesn't specify which sprite to draw. ")+"Features that match this layer group won't be drawn without specifying the sprite with the 'sprite' or 'sprite_default' properties. The merged draw parameters for this layer group are:",t).then((function(r){r&&k("debug","Example feature for layer group '".concat(t.layers.join(", "),"'"),e);}));i.texcoords=o.texcoords;}else if(t.sprite)return void k({level:"warn",once:!0},"Layer group '".concat(t.layers.join(", "),"' ")+"specifies sprite '".concat(t.sprite,"', but the texture '").concat(t.texture,"' doesn't define any sprites. ")+"Features that match this layer group won't be drawn. The merged draw parameters for this layer group are:",t);if(this.calcSize(t,i,o,r),t.outline&&(i.outline_width=ue.evalCachedProperty(t.outline.width,r)||ue.defaults.outline.width,i.outline_color=this.parseColor(t.outline.color,r)),i.outline_edge_pct=0,i.outline_width&&i.outline_color){var a=i.outline_width;i.size[0]+=a,i.size[1]+=a,i.outline_edge_pct=a/Math.min(i.size[0],i.size[1])*2,i.outline_alpha=ue.evalCachedProperty(t.outline.alpha,r);}i.size[0]=Math.min(i.size[0],256),i.size[1]=Math.min(i.size[1],256),i.placement=t.placement,i.placement_min_length_ratio=ue.evalCachedProperty(t.placement_min_length_ratio,r),i.placement===Cn.SPACED&&t.placement_spacing&&(i.placement_spacing=ue.evalCachedProperty(t.placement_spacing,r)),i.angle=ue.evalProperty(t.angle,r)||0,i.z=ue.evalCachedDistanceProperty(t.z,r)||ue.defaults.z,i.tile_edges=t.tile_edges,this.computeLayout(i,e,t,r,n);var s=t.text&&!1!==t.text.visible&&this.parseTextFeature(e,t.text,r,n);Array.isArray(s)&&(s=null,k({level:"warn",once:!0},"Layer group '".concat(t.layers.join(", "),"': ")+"cannot use boundary labels (e.g. 'text_source: { left: ..., right: ... }') for 'text' labels attached to 'points'; "+"provided 'text_source' value was ".concat(JSON.stringify(t.text.text_source)))),s&&(s.layout.parent=i,s.layout.priority=t.text.priority?Math.max(s.layout.priority,i.priority+.5):i.priority+.5,mr.addStyle(this.collision_group_text,n.id)),this.queueFeature({feature:e,draw:t,context:r,style:i,text_feature:s},n),mr.addStyle(this.collision_group_points,n.id);}}},calcSize:function(e,t,r,n){if(t.size=e.size,t.size){if(t.size=ue.evalCachedPointSizeProperty(e.size,r,D.textures[t.texture],n),null==t.size)return void k({level:"warn",once:!0},"Layer group '".concat(e.layers.join(", "),"': ")+"'size' (".concat(JSON.stringify(e.size.value),") couldn't be interpreted, features that match ")+"this layer group won't be drawn");"number"==typeof t.size&&(t.size=[t.size,t.size]);}else t.size=r&&r.css_size||[16,16];},hasSprites:function(e){return e.texture&&D.textures[e.texture]&&D.textures[e.texture].sprites},getSpriteInfo:function(e,t){var r=D.textures[e.texture].sprites[t]&&D.getSpriteInfo(e.texture,t);return t&&!r?(this.texture_missing_sprites[e.texture]=this.texture_missing_sprites[e.texture]||{},this.texture_missing_sprites[e.texture][t]||(k("debug","Style: in style '".concat(this.name,"', could not find sprite '").concat(t,"' for texture '").concat(e.texture,"'")),this.texture_missing_sprites[e.texture][t]=!0)):r&&(r.sprite=t),r},parseSprite:function(e,t,r){var n=ue.evalProperty(t.sprite,r);return this.getSpriteInfo(e,n)||this.getSpriteInfo(e,t.sprite_default)},queueFeature:function(e,t){this.tile_data[t.id]&&this.queues[t.id]||this.startData(t),this.queues[t.id]=this.queues[t.id]||[],this.queues[t.id].push(e);},endData:function(e){return new Promise(function(t,r){var i,o,a,s,u,c,h,f,d,_,p;return i=this,e.canceled?(k("trace","Style ".concat(this.name,": stop tile build because tile was canceled: ").concat(e.key)),t(null)):(o=this.queues[e.id],delete this.queues[e.id],a=[],s=[],o.forEach((function(e){for(var t=e.style,r=e.feature,n=r.geometry,o=i.buildLabels(t.size,n,t),l=0;l<o.length;l++){var u=o[l],c={feature:r,draw:e.draw,context:e.context,style:t,label:u};if(s.push(c),e.text_feature){var h={feature:r,draw:e.text_feature.draw,context:e.context,text:e.text_feature.text,text_settings_key:e.text_feature.text_settings_key,layout:e.text_feature.layout,point_label:u,linked:c};a.push(h),e.draw.text.optional||(c.linked=h);}}})),Promise.resolve(Promise.all([mr.collide(s,this.collision_group_points,e.id).then((function(e){e.forEach((function(e){i.feature_style=e.style,i.feature_style.label=e.label,i.feature_style.linked=e.linked,nt.addFeature.call(i,e.feature,e.draw,e.context);}));})),this.collideAndRenderTextLabels(e,this.collision_group_text,a)])).then(function(o){try{return u=n(o,2),c=u[1],h=c.labels,f=c.texts,d=c.textures,h&&f&&h.forEach((function(e){var t=e.text_settings_key,r=f[t]&&f[t][e.text],n=i.feature_style;n.label=e.label,n.linked=e.linked,n.size=r.size.logical_size,n.texcoords=r.align[e.label.align].texcoords,n.label_texture=d[r.align[e.label.align].texture_id],n.blend_order=e.draw.blend_order,nt.addFeature.call(i,e.feature,e.draw,e.context);})),this.freeText(e),Promise.resolve(nt.endData.call(this,e)).then((function(e){try{return (_=e)&&d&&d.length&&(_.textures=_.textures||[],(p=_.textures).push.apply(p,l(d))),t(_)}catch(e){return r(e)}}),r)}catch(e){return r(e)}}.bind(this),r))}.bind(this))},_preprocess:function(e){e.color=ue.createColorPropertyCache(e.color),e.alpha=ue.createPropertyCache(e.alpha),e.texture=void 0!==e.texture?e.texture:this.texture,e.blend_order=this.getBlendOrderForDraw(e),e.outline&&(e.outline.color=ue.createColorPropertyCache(e.outline.color),e.outline.alpha=ue.createPropertyCache(e.outline.alpha),e.outline.width=ue.createPropertyCache(e.outline.width,ue.parsePositiveNumber)),e.z=ue.createPropertyCache(e.z,ue.parseUnits);try{e.size=ue.createPointSizePropertyCache(e.size,e.texture);}catch(t){return k({level:"warn",once:!0},"Layer group '".concat(e.layers.join(", "),"': ")+"".concat(t," (").concat(JSON.stringify(e.size),"), features that match this layer group won't be drawn.")),null}if(e.offset=ue.createPropertyCache(e.offset,(function(e){return Array.isArray(e)&&e.map(ue.parseNumber)})),e.buffer=ue.createPropertyCache(e.buffer,(function(e){return (Array.isArray(e)?e:[e,e]).map(ue.parsePositiveNumber)})),e.repeat_distance=ue.createPropertyCache(e.repeat_distance,ue.parseNumber),e.placement=Cn[e.placement&&e.placement.toUpperCase()],null==e.placement&&(e.placement=Cn.VERTEX),e.placement_spacing=null!=e.placement_spacing?e.placement_spacing:80,e.placement_spacing=ue.createPropertyCache(e.placement_spacing,ue.parsePositiveNumber),e.placement_min_length_ratio=null!=e.placement_min_length_ratio?e.placement_min_length_ratio:1,e.placement_min_length_ratio=ue.createPropertyCache(e.placement_min_length_ratio,ue.parsePositiveNumber),"number"==typeof e.angle)e.angle=e.angle*Math.PI/180;else if("function"==typeof e.angle){var t=e.angle;e.angle=function(e){return t(e)*Math.PI/180};}else e.angle=e.angle||0;return e.text=this.preprocessText(e.text),e.text&&(e.text.key=e.key,e.text.group=e.group,e.text.layers=e.layers,e.text.order=e.order,e.text.blend_order=e.blend_order,e.text.repeat_group=null!=e.text.repeat_group?e.text.repeat_group:e.repeat_group,e.text.anchor=e.text.anchor||this.default_anchor,e.text.optional="boolean"==typeof e.text.optional&&e.text.optional,e.text.interactive=e.text.interactive||e.interactive),e},default_anchor:["bottom","top","right","left"],computeLayout:function(e,t,r,n,i){var o=e||{};o.id=t,o.units_per_pixel=i.units_per_pixel||1,o.collide=!1!==r.collide,o.anchor=r.anchor,o.offset=ue.evalCachedProperty(r.offset,n)||ue.zeroPair,o.buffer=ue.evalCachedProperty(r.buffer,n)||ue.zeroPair,o.repeat_distance=ue.evalCachedProperty(r.repeat_distance,n),o.repeat_distance&&(o.repeat_distance*=o.units_per_pixel,o.repeat_scale=1,"function"==typeof r.repeat_group?o.repeat_group=r.repeat_group(n):o.repeat_group=r.repeat_group||n.layer);var a=r.priority;return null!=a?"function"==typeof a&&(a=a(n)):a=-1>>>0,o.priority=a,o},buildTextLabels:function(e,t){for(var r=[],n=0;n<t.length;n++){var i=t[n],o=this.texts[e.id][i.text_settings_key][i.text].size.collision_size;i.label=new yr(i.point_label.position,o,i.layout),r.push(i);}return r},buildLabels:function(e,t,r){var n=[];if("Point"===t.type)n.push(new yr(t.coordinates,e,r,r.angle));else if("MultiPoint"===t.type)for(var i=t.coordinates,o=0;o<i.length;++o){var a=i[o];n.push(new yr(a,e,r,r.angle));}else if("LineString"===t.type)for(var s=br(t.coordinates,e,r),l=0;l<s.length;++l)n.push(s[l]);else if("MultiLineString"===t.type)for(var u=t.coordinates,c=0;c<u.length;c++)for(var h=br(u[c],e,r),f=0;f<h.length;++f)n.push(h[f]);else if("Polygon"===t.type)if(r.placement===Cn.CENTROID){var d=Q.centroid(t.coordinates);d&&n.push(new yr(d,e,r,r.angle));}else for(var _=t.coordinates,p=0;p<_.length;p++)for(var m=br(_[p],e,r),v=0;v<m.length;++v)n.push(m[v]);else if("MultiPolygon"===t.type)if(r.placement===Cn.CENTROID){var g=Q.multiCentroid(t.coordinates);g&&n.push(new yr(g,e,r,r.angle));}else for(var y=t.coordinates,x=0;x<y.length;x++)for(var b=y[x],A=0;A<b.length;A++)for(var T=br(b[A],e,r),w=0;w<T.length;++w)n.push(T[w]);return n},makeVertexTemplate:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=0;this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=e.z||0,this.vertex_template[n++]=this.scaleOrder(e.order),this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=0,this.vertex_template[n++]=e.label.layout.collide?0:1,t.variant.shader_point||(this.vertex_template[n++]=0,this.vertex_template[n++]=0),this.vertex_template[n++]=0,this.vertex_template[n++]=0;var i=e.color||ue.defaults.color;if(this.vertex_template[n++]=255*i[0],this.vertex_template[n++]=255*i[1],this.vertex_template[n++]=255*i[2],this.vertex_template[n++]=255*(null!=e.alpha?e.alpha:i[3]),t.variant.selection&&(this.vertex_template[n++]=255*e.selection_color[0],this.vertex_template[n++]=255*e.selection_color[1],this.vertex_template[n++]=255*e.selection_color[2],this.vertex_template[n++]=255*e.selection_color[3]),t.variant.shader_point){var o=e.outline_color||ue.defaults.outline.color;this.vertex_template[n++]=255*o[0],this.vertex_template[n++]=255*o[1],this.vertex_template[n++]=255*o[2],this.vertex_template[n++]=255*(null!=e.outline_alpha?e.outline_alpha:o[3]),this.vertex_template[n++]=e.outline_edge_pct||ue.defaults.outline.width;}return r&&this.addCustomAttributesToVertexTemplate(e,n),this.vertex_template},buildQuad:function(e,t,r,n,i,o,a,s,l,u,c){return t[0]<=0||t[1]<=0?0:function(e,t,r,n,i,o,a,s,l,u,c,h){var f=128*i[0],d=128*i[1];Kt[0]=-f,Kt[1]=-d,Kt[2]=f,Kt[3]=d;for(var _=c||ft,p=t.vertex_elements,m=t.vertex_count,v=0;v<4;v++)r[n.a_position+0]=e[0],r[n.a_position+1]=e[1],r[n.a_shape+0]=Kt[Zt[v]],r[n.a_shape+1]=Kt[Jt[v]],r[n.a_shape+2]=l,r[n.a_offset+0]=o[0],r[n.a_offset+1]=o[1],n.a_texcoord&&(r[n.a_texcoord+0]=65535*_[Zt[v]],r[n.a_texcoord+1]=65535*_[Jt[v]]),h&&(r[n.a_pre_angles+0]=Wt*s[0],r[n.a_pre_angles+1]=Wt*s[1],r[n.a_pre_angles+2]=Wt*s[2],r[n.a_pre_angles+3]=Wt*s[3],r[n.a_angles+0]=Yt*u[0],r[n.a_angles+1]=Yt*u[1],r[n.a_angles+2]=Yt*u[2],r[n.a_angles+3]=Yt*u[3],r[n.a_offsets+0]=64*a[0],r[n.a_offsets+1]=64*a[1],r[n.a_offsets+2]=64*a[2],r[n.a_offsets+3]=64*a[3]),t.addVertex(r);return p.push(m+0),p.push(m+1),p.push(m+2),p.push(m+2),p.push(m+3),p.push(m+0),2}(e,u,c,u.vertex_layout.index,t,o,a,i,4096*r,n,s,l)},build:function(e,t){var r=e.label;return "curved"===r.type?this.buildCurvedLabel(r,e,t):this.buildStraightLabel(r,e,t)},buildStraightLabel:function(e,t,r){var n,i,o=this.getTileMesh(r.tile,this.meshVariantTypeForDraw(t)),a=this.makeVertexTemplate(t,o);"point"!==e.type?(n=t.size[e.type],i=t.texcoords[e.type].texcoord):(n=t.size,i=t.texcoords),o.uniforms=o.uniforms||{},t.label_texture?(o.uniforms.u_texture=t.label_texture,o.uniforms.u_point_type=2,o.uniforms.u_apply_color_blocks=!1):t.texture?(o.uniforms.u_texture=t.texture,o.uniforms.u_point_type=1,o.uniforms.u_apply_color_blocks=!0):(o.uniforms.u_texture=D.default,o.uniforms.u_point_type=3,o.uniforms.u_apply_color_blocks=!0);var s=e.offset,l=this.buildQuad(e.position,n,e.angle,null,null,s,null,i,!1,o.vertex_data,a),u=t.linked&&t.linked.label.id;return this.trackLabel(e,u,o,l,r),l},buildCurvedLabel:function(e,t,r){for(var n,i,o=0,a=0;a<e.num_segments;a++){var s=t.size[e.type][a],l=t.texcoords_stroke[a];t.label_texture=t.label_textures[a],n=this.getTileMesh(r.tile,this.meshVariantTypeForDraw(t)),i=this.makeVertexTemplate(t,n),n.uniforms=n.uniforms||{},n.uniforms.u_texture=t.label_texture,n.uniforms.u_point_type=2,n.uniforms.u_apply_color_blocks=!1;var u=e.offset||[0,0],c=e.position,h=e.angles[a],f=e.offsets[a],d=e.pre_angles[a],_=this.buildQuad(c,s,e.angle,h,d,u,f,l,!0,n.vertex_data,i);o+=_;var p=t.linked&&t.linked.label.id;this.trackLabel(e,p,n,_,r);}for(var m=0;m<e.num_segments;m++){var v=t.size[e.type][m],g=t.texcoords[e.type][m].texcoord;t.label_texture=t.label_textures[m],n=this.getTileMesh(r.tile,this.meshVariantTypeForDraw(t)),i=this.makeVertexTemplate(t,n),n.uniforms=n.uniforms||{},n.uniforms.u_texture=t.label_texture,n.uniforms.u_point_type=2,n.uniforms.u_apply_color_blocks=!1;var y=e.offset||[0,0],x=e.position,b=e.angles[m],A=e.offsets[m],T=e.pre_angles[m],w=this.buildQuad(x,v,e.angle,b,T,y,A,g,!0,n.vertex_data,i);o+=w;var E=t.linked&&t.linked.label.id;this.trackLabel(e,E,n,w,r);}return o},trackLabel:function(e,t,r,n){if(e.layout.collide||e.may_repeat_across_tiles){r.labels=r.labels||{},r.labels[e.id]=r.labels[e.id]||{container:{label:e.toJSON(),linked:t},ranges:[]};var i=2*n,o=r.vertex_data.offset-r.vertex_data.stride*i;r.labels[e.id].ranges.push([o,i]);}},buildLines:function(e,t,r){return this.build(t,r)},buildPoints:function(e,t,r){return this.build(t,r)},buildPolygons:function(e,t,r){return this.build(t,r)},vertexLayoutForMeshVariant:function(e){if(null==this.vertex_layouts[e.shader_point]){var t=[{name:"a_position",size:4,type:Te.SHORT,normalized:!1},{name:"a_shape",size:4,type:Te.SHORT,normalized:!1},{name:"a_texcoord",size:2,type:Te.UNSIGNED_SHORT,normalized:!0,static:e.shader_point?[0,0]:null},{name:"a_offset",size:2,type:Te.SHORT,normalized:!1},{name:"a_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_outline_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0,static:e.shader_point?null:[0,0,0,0]},{name:"a_outline_edge",size:1,type:Te.FLOAT,normalized:!1,static:e.shader_point?null:0}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.shader_point]=new ct(t);}return this.vertex_layouts[e.shader_point]},meshVariantTypeForDraw:function(e){var t=e.label_texture||e.texture||Vn,r=t+"/"+e.blend_order;return null==this.variants[r]&&(this.variants[r]={key:r,selection:1,shader_point:t===Vn,blend_order:e.blend_order,mesh_order:e.label_texture?1:0}),this.variants[r]},makeMesh:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r=Object.assign({},r,{fade_in_time:this.fade_in_time}),nt.makeMesh.call(this,e,t,r)}});var Hn=[0,.33,.66,.99],Wn=function(e,t,r,n){for(var i=[{type:"straight",tolerance:n.no_curving?1.8:1.5},{type:"curved"},{type:"straight",tolerance:2.3}],o=0;o<i.length;o++){var a=i[o],s=void 0;if("straight"===a.type?s=new Zn(t,r,n,a.tolerance):"curved"===a.type&&!n.no_curving&&r.length>2&&(s=new Jn(e,r,n)),s&&!s.throw_away)return s}return !1},Yn=function(){return h((function e(t){u(this,e),this.id=fr.nextLabelId(),this.layout=t,this.position=[],this.angle=0,this.offset=t.offset.slice(),this.unit_scale=this.layout.units_per_pixel,this.obbs=[],this.aabbs=[],this.type="",this.throw_away=!1;}),[{key:"toJSON",value:function(){return {id:this.id,type:this.type,position:this.position,size:this.size,offset:this.offset,angle:this.angle,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:dr(this.layout)}}},{key:"discard",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.throw_away)return !0;for(var r=0;r<this.obbs.length;r++){var n={aabb:this.aabbs[r],obb:this.obbs[r]};if(fr.prototype.occluded.call(n,e,t))return !0}return !1}},{key:"inTileBounds",value:function(){for(var e=0;e<this.aabbs.length;e++){var t={aabb:this.aabbs[e]};if(!fr.prototype.inTileBounds.call(t))return !1}return !0}}],[{key:"splitLineByOrientation",value:function(e){for(var t=[e[0]],r=0,n=0,i=0,o=t,a=!1,s=1;s<e.length;s++){var l=e[s],u=e[s-1],c=Ne.length(Ne.sub(l,u));l[0]>u[0]?1===i?(t.push(l),(r+=c)>n&&(o=t,n=r,a=!1)):(t=[u,l],(r=c)>n&&(o=t,n=r,a=!1),i=1):l[0]<u[0]?-1===i?(t.unshift(l),(r+=c)>n&&(o=t,n=r,a=!0)):(t=[l,u],(r=c)>n&&(o=t,n=r,a=!0),i=-1):(-1===i?t.unshift(l):(t.push(l),i=1),(r+=c)>n&&(o=t,n=r,a=-1===i));}return [o,a]}},{key:"createOBB",value:function(e,t,r,n,i,o,a){var s=e[0],l=e[1];return !o||0===o[0]&&0===o[1]||(s+=(o=Ne.rot(o,i))[0]*a,l-=o[1]*a),new hr(s,l,-n,t,r)}}])}(),Zn=function(e){function t(e,r,n,i){var o;return u(this,t),(o=qn(this,t,[n])).type="straight",o.size=e,o.throw_away=!o.fit(e,r,n,i),o}return Se(t,e),h(t,[{key:"fit",value:function(e,t,r,i){var o,a=this.unit_scale,s=n(Yn.splitLineByOrientation(t),2);t=s[0],o=s[1],"number"==typeof r.orientation&&(this.offset[1]+=1.2*(e[1]-r.vertical_buffer),o&&(this.offset[1]*=-1),-1===r.orientation&&(this.offset[1]*=-1));for(var l=Qn(t),u=e[0]*a,c=0;c<t.length-1;c++)for(var h=t[c],f=0,d=0,_=c+1,p=void 0;_<t.length;){var m=t[_-1],v=t[_],g=$n(m,v);if(_!==c+1&&(f+=ei(g,p)),Math.abs(f)>.1)break;if(Kn(d+=l[_-1],u)<i){var y=Ne.mult(Ne.add(h,v),.5);return this.angle=-g,Math.abs(this.angle-Math.PI/2)<.01&&(this.angle=-Math.PI/2,"number"==typeof r.orientation&&(this.offset[1]*=-1)),this.position=y,this.updateBBoxes(this.position,e,this.angle,this.angle,this.offset),!0}p=g,_++;}return !1}},{key:"updateBBoxes",value:function(e,t,r,n,i){var o=this.unit_scale;this.obbs=[],this.aabbs=[];var a=(t[0]+2*this.layout.buffer[0])*o*fr.epsilon,s=(t[1]+2*this.layout.buffer[1])*o*fr.epsilon,l=Yn.createOBB(e,a,s,r,n,i,o),u=l.getExtent();this.obbs.push(l),this.aabbs.push(u),this.inTileBounds&&(this.breach=!this.inTileBounds()),this.mayRepeatAcrossTiles&&(this.may_repeat_across_tiles=this.mayRepeatAcrossTiles());}}])}(Yn),Jn=function(e){function t(e,r,n){var i;return u(this,t),(i=qn(this,t,[n])).type="curved",i.angles=[],i.pre_angles=[],i.offsets=[],i.num_segments=e.length,i.sizes=e,i.throw_away=!i.fit(i.sizes,r,n),i}return Se(t,e),h(t,[{key:"toJSON",value:function(){return {id:this.id,type:this.type,obbs:this.obbs.map((function(e){return e.toJSON()})),position:this.position,breach:this.breach,may_repeat_across_tiles:this.may_repeat_across_tiles,layout:dr(this.layout)}}},{key:"fit",value:function(e,r,i){var o,a=this.unit_scale,s=Math.max.apply(Math,l(e.map((function(e){return e[1]})))),u=s*a,c=n(Yn.splitLineByOrientation(r),2);r=c[0],o=c[1],"number"==typeof i.orientation&&(this.offset[1]+=1.2*(s-i.vertical_buffer),o&&(this.offset[1]*=-1),-1===i.orientation&&(this.offset[1]*=-1));var h=Qn(r),f=e.map((function(e){return e[0]*a})),d=h.reduce((function(e,t){return e+t}),0),_=f.reduce((function(e,t){return e+t}),0);if(_>d)return !1;var p=r.length-1;if(p-0<2)return !1;var m=t.curvaturePlacement(r,d,h,_,0,p),v=r[m];if(-1===m||p-m<2)return !1;this.position=v;for(var g=0;g<f.length;g++){this.offsets[g]=[],this.angles[g]=[],this.pre_angles[g]=[];for(var y=0;y<Hn.length;y++){var x=Hn[y],b=n(t.scaleLine(x,r),2),A=b[0],T=b[1];v=A[m];var w=t.placeAtIndex(m,A,T,f),E=w.positions,k=w.offsets,R=w.angles,M=w.pre_angles,z=k.map((function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])/a}));if(0===x){this.angle=1/R.length*R.reduce((function(e,t){return e+t}));for(var P=0;P<E.length;P++){var S=E[P],N=M[P],O=f[P],L=N+R[P],I=this.angle,F=Yn.createOBB(S,O,u,L,I,this.offset,a),D=F.getExtent();this.obbs.push(F),this.aabbs.push(D);}}this.offsets[g].push(z[g]),this.angles[g].push(R[g]),this.pre_angles[g].push(M[g]);}}return !0}}],[{key:"curvaturePlacement",value:function(e,t,r,n,i,o){i=i||0,o=o||e.length-1;for(var a=[],s=i+1;s<o;s++){var l=e[s-1],u=e[s],c=e[s+1],h=Ne.perp(u,l),f=Ne.perp(c,u),d=Ne.angleBetween(h,f);d>1&&(d=1/0),a.push(d);}a.push(1/0);for(var _=[],p=[],m=i,v=0,g=0;g<i;g++)v+=r[g];for(;v+n<t;){for(var y=v+n,x=v,b=m,A=0;b<o&&x+r[b]<y&&(A+=a[b])!==1/0;)x+=r[b],b++;if(0===A)return m;var T=A/(b-m);_.push(A),p.push(T),v+=r[m],m++;}if(0===_.length)return -1;var w=Math.min.apply(null,_),E=p[_.indexOf(w)];return w<1.3&&E<.4?_.indexOf(w):-1}},{key:"scaleLine",value:function(e,t){var r=[t[0]],n=[];return t.forEach((function(i,o){if(o!==t.length-1){var a=Ne.sub(t[o+1],t[o]),s=Ne.mult(a,1+e);r.push(Ne.add(r[o],s)),n.push(Ne.length(s));}})),[r,n]}},{key:"placeAtIndex",value:function(e,r,i,o){var a=r[e],s=n(t.getIndicesAndOffsets(e,i,o),2),l=s[0],u=s[1],c=t.getPositionsFromIndicesAndOffsets(r,l,u),h=n(t.getAnglesFromIndicesAndOffsets(a,l,r,c),3);return {positions:c,offsets:h[0],angles:h[1],pre_angles:h[2]}}},{key:"getIndicesAndOffsets",value:function(e,t,r){for(var n=r.length,i=[],o=[],a=0,s=0,l=0;a<n;){for(var u=r[a];a<n&&s+.5*u<=l+t[e];){var c=s-l+.5*u;o.push(c),i.push(e),s+=u,u=r[++a];}l+=t[e],e++;}return [i,o]}},{key:"getPositionsFromIndicesAndOffsets",value:function(e,t,r){for(var n=[],i=0;i<t.length;i++){var o=t[i],a=r[i],s=$n(e[o],e[o+1]),l=Ne.rot([a,0],s),u=Ne.add(e[o],l);n.push(u);}return n}},{key:"getAnglesFromIndicesAndOffsets",value:function(e,t,r,n){for(var i,o,a=[],s=[],l=[],u=0;u<n.length;u++){var c=n[u],h=t[u],f=Ne.sub(c,e),d=-Ne.angle(f),_=(i=r[h],o=r[h+1],-$n(i,o))-d;if(u>0){var p=a[u-1],m=s[u-1];Math.abs(d-p)>Math.PI&&(d+=d>p?-2*Math.PI:2*Math.PI),Math.abs(m-_)>Math.PI&&(_+=_>m?-2*Math.PI:2*Math.PI);}a.push(d),s.push(_),l.push(f);}return [l,a,s]}}])}(Yn);function Kn(e,t){return t/e}function $n(e,t){var r=Ne.sub(t,e);return Ne.angle(r)}function Qn(e){for(var t=[],r=0;r<e.length-1;r++){var n=e[r],i=e[r+1],o=Math.hypot(n[0]-i[0],n[1]-i[1]);t.push(o);}return t}function ei(e,t){var r,n;for(e>t?(r=t,n=e):(r=e,n=t);n-r>Math.PI;)r+=2*Math.PI;return Math.abs(n-r)}var ti=Object.create(Bn);Object.assign(ti,{name:"text",super:Bn,built_in:!0,init:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};nt.init.call(this,e),this.setupDefines(),this.defines.TANGRAM_HAS_SHADER_POINTS=!1,this.defines.TANGRAM_CURVED_LABEL=!0,this.reset();},makeVertexTemplate:function(e,t){this.super.makeVertexTemplate.call(this,e,t,!1);for(var r=t.vertex_data.vertex_layout.index.a_pre_angles,n=0;n<12;n++)this.vertex_template[r++]=0;return this.addCustomAttributesToVertexTemplate(e,r),this.vertex_template},reset:function(){this.queues={},this.resetText();},addFeature:function(e,t,r){var n=this,i=r.tile;if(i.generation===this.generation){var o=e.geometry.type;t.can_articulate="LineString"===o||"MultiLineString"===o,t.supersample_text="LineString"===o||"MultiLineString"===o;var a=this.parseTextFeature(e,t,r,i);a&&(a instanceof Array?a.forEach((function(t){t.feature=e,t.context=r,t.layout.vertex=!1,n.queueFeature(t,i);})):(a.feature=e,a.context=r,a.layout.vertex=!1,this.queueFeature(a,i)),mr.addStyle(this.name,i.id));}},endData:function(e){return new Promise(function(t,r){var n,i,o,a,s,u,c,h;return n=this,i=this.queues[e.id],delete this.queues[e.id],Promise.resolve(this.collideAndRenderTextLabels(e,this.name,i)).then(function(i){try{return a=(o=i).labels,s=o.texts,u=o.textures,a&&s&&(this.texts[e.id]=s,a.forEach((function(t){var r=t.text_settings_key,i=n.texts[e.id][r]&&n.texts[e.id][r][t.text],o=n.feature_style;o.label=t.label,i.text_settings.can_articulate?(o.size={},o.texcoords={},"straight"===t.label.type?(o.size.straight=i.size.logical_size,o.texcoords.straight=i.texcoords.straight,o.label_texture=u[i.texcoords.straight.texture_id]):(o.size.curved=i.segment_sizes.map((function(e){return e.logical_size})),o.texcoords_stroke=i.texcoords_stroke,o.texcoords.curved=i.texcoords.curved,o.label_textures=i.texcoords.curved.map((function(e){return u[e.texture_id]})))):(o.size=i.size.logical_size,o.texcoords=i.align[t.label.align].texcoords,o.label_texture=u[i.align[t.label.align].texture_id]),o.blend_order=t.draw.blend_order,nt.addFeature.call(n,t.feature,t.draw,t.context);}))),this.freeText(e),Promise.resolve(nt.endData.call(this,e)).then((function(e){try{if(c=e)for(var n in u&&u.length&&(h=c.textures).push.apply(h,l(u)),c.meshes)c.meshes[n].uniforms.u_apply_color_blocks=!0;return t(c)}catch(e){return r(e)}}),r)}catch(e){return r(e)}}.bind(this),r)}.bind(this))},_preprocess:function(e){return e.blend_order=this.getBlendOrderForDraw(e),this.preprocessText(e)},buildTextLabels:function(e,t){for(var r=[],n=0;n<t.length;n++){var i=t[n],o=this.texts[e.id][i.text_settings_key][i.text],a=void 0;if(i.layout.vertical_buffer=o.vertical_buffer,o.text_settings.can_articulate){var s=o.segment_sizes.map((function(e){return e.collision_size}));i.layout.no_curving=o.no_curving,a=this.buildLabels(s,i.feature.geometry,i.layout,o.size.collision_size);}else a=this.buildLabels(o.size.collision_size,i.feature.geometry,i.layout);for(var l=0;l<a.length;l++){var u=Object.create(i);u.label=a[l],r.push(u);}}return r},buildLabels:function(e,t,r,n){var i=[];if("LineString"===t.type)Array.prototype.push.apply(i,this.buildLineLabels(t.coordinates,e,r,n));else if("MultiLineString"===t.type)for(var o=t.coordinates,a=0;a<o.length;++a)Array.prototype.push.apply(i,this.buildLineLabels(o[a],e,r,n));else if("Point"===t.type)i.push(new yr(t.coordinates,e,r));else if("MultiPoint"===t.type)for(var s=t.coordinates,l=0;l<s.length;++l)i.push(new yr(s[l],e,r));else if("Polygon"===t.type){var u=Q.centroid(t.coordinates);u&&i.push(new yr(u,e,r));}else if("MultiPolygon"===t.type){var c=Q.multiCentroid(t.coordinates);c&&i.push(new yr(c,e,r));}return i},buildLineLabels:function(e,t,r,n){var i=[],o=Math.min(r.subdiv,e.length-1);if(o>1)for(var a=(e.length-1)/o,s=0;s<o;s++){var l=Math.floor(s*a),u=Math.floor((s+1)*a)+1,c=e.slice(l,u),h=Wn(t,n,c,r);h&&i.push(h);}if(i.length<o){var f=Wn(t,n,e,r);f&&i.push(f);}return i},vertexLayoutForMeshVariant:function(e){if(null==this.vertex_layouts[e.shader_point]){var t=[{name:"a_position",size:4,type:Te.SHORT,normalized:!1},{name:"a_shape",size:4,type:Te.SHORT,normalized:!1},{name:"a_texcoord",size:2,type:Te.UNSIGNED_SHORT,normalized:!0},{name:"a_offset",size:2,type:Te.SHORT,normalized:!1},{name:"a_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0},{name:"a_selection_color",size:4,type:Te.UNSIGNED_BYTE,normalized:!0,static:e.selection?null:[0,0,0,0]},{name:"a_pre_angles",size:4,type:Te.BYTE,normalized:!1},{name:"a_angles",size:4,type:Te.SHORT,normalized:!1},{name:"a_offsets",size:4,type:Te.UNSIGNED_SHORT,normalized:!1}];this.addCustomAttributesToAttributeList(t),this.vertex_layouts[e.shader_point]=new ct(t);}return this.vertex_layouts[e.shader_point]}}),ti.texture_id=0;var ri=Object.create(kt);Object.assign(ri,{name:"raster",super:kt,built_in:!0,init:function(){this.raster=this.raster||"color",this.super.init.apply(this,arguments),this.selection=!1;},_preprocess:function(e){return e.color=e.color||ue.defaults.color,this.super._preprocess.apply(this,arguments)}});function ni(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return ii(e,t);var r={}.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ii(e,t):void 0}}(e))||t){r&&(e=r);var n=0,i=function(){};return {s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return {s:function(){r=r.call(e);},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e;},f:function(){try{a||null==r.return||r.return();}finally{if(s)throw o}}}}function ii(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function oi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}var ai=function(){return h((function e(){u(this,e),this.styles={},this.base_styles={},this.active_styles=[],this.active_blend_orders=[],this.register(Object.create(kt)),this.register(Object.create(Ht)),this.register(Object.create(Bn)),this.register(Object.create(ti)),this.register(Object.create(ri));}),[{key:"init",value:function(){Z.removeBlock("global"),Z.removeBlock("setup"),Z.addBlock("global","#ifdef TANGRAM_VERTEX_SHADER\n\n// Apply layer ordering to avoid z-fighting\nvoid applyLayerOrder (float layer, inout vec4 position) {\n    position.z -= layer * TANGRAM_LAYER_DELTA * position.w;\n}\n\n// Vertex position in model space: [0, 1] range over the local tile\n// Note positions can be outside that range due to unclipped geometry, geometry higher than a unit cube, etc.\nvec4 modelPosition() {\n    return\n        vec4(\n            a_position.xyz / TANGRAM_TILE_SCALE         // scale coords to ~0-1 range\n            * exp2(u_tile_origin.z - u_tile_origin.w),  // adjust for tile overzooming\n        1.)\n        + vec4(0., 1., 0., 0.);\n        // NB: additional offset to account for unusual Tangram JS y coords,\n        // should be refactored to remove\n}\n\n// Position in model space as above, but according to tile coordinate (as opposed to style) zoom\n// e.g. unadjusted for tile overzooming\nvec4 modelPositionBaseZoom() {\n    return\n        vec4(\n            a_position.xyz / TANGRAM_TILE_SCALE,    // scale coords to ~0-1 range\n        1.)\n        + vec4(0., 1., 0., 0.); // see note on offset above\n}\n\n#endif\n\n// Vertex position in world coordinates, useful for 3d procedural textures, etc.\nvec4 worldPosition() {\n    return v_world_position;\n}\n\n// Optionally wrap world coordinates (allows more precision at higher zooms)\n// e.g. at wrap 1000, the world space will wrap every 1000 meters\n#ifdef TANGRAM_VERTEX_SHADER\n\nvec4 wrapWorldPosition(vec4 world_position) {\n    #if defined(TANGRAM_WORLD_POSITION_WRAP)\n    vec2 anchor = u_tile_origin.xy - mod(u_tile_origin.xy, TANGRAM_WORLD_POSITION_WRAP);\n        world_position.xy -= anchor;\n    #endif\n    return world_position;\n}\n\n#endif\n\n// Normal in world space\n#if defined(TANGRAM_VERTEX_SHADER)\n\nvec3 worldNormal() {\n    return TANGRAM_NORMAL;\n}\n\n#elif defined(TANGRAM_FRAGMENT_SHADER)\n\nvec3 worldNormal() {\n    return u_inverseNormalMatrix * TANGRAM_NORMAL;\n}\n\n#endif\n"),Z.addBlock("global","// Vertex attribute + varying for feature selection\n#if defined(TANGRAM_FEATURE_SELECTION) && defined(TANGRAM_VERTEX_SHADER)\n    attribute vec4 a_selection_color;\n    varying vec4 v_selection_color;\n#endif\n"),Z.replaceBlock("setup","// Selection pass-specific rendering\n#if defined(TANGRAM_FEATURE_SELECTION) && defined(TANGRAM_VERTEX_SHADER)\n    if (a_selection_color.rgb == vec3(0.)) {\n        // Discard by forcing invalid triangle if we're in the feature\n        // selection pass but have no selection info\n        // TODO: in some cases we may actually want non-selectable features to occlude selectable ones?\n        gl_Position = vec4(0., 0., 0., 1.);\n        return;\n    }\n    v_selection_color = a_selection_color;\n#endif\n"),Z.defines.TANGRAM_EPSILON=1e-5,Z.defines.TANGRAM_LAYER_DELTA=1/16384,Z.defines.TANGRAM_TILE_SCALE="vec3(".concat(Q.tile_scale,"., ").concat(Q.tile_scale,"., u_meters_per_pixel * ").concat(Q.tile_size,".)"),Z.defines.TANGRAM_HEIGHT_SCALE=Q.height_scale,Z.defines.TANGRAM_ALPHA_TEST=.5;}},{key:"destroy",value:function(e){var t=this;Object.keys(this.styles).forEach((function(r){var n=t.styles[r];n.gl===e&&(k("trace","StyleManager.destroy: destroying render style ".concat(n.name)),n.base&&t.remove(n.name),n.destroy());}));}},{key:"register",value:function(e){this.styles[e.name]=e,this.base_styles[e.name]=e;}},{key:"remove",value:function(e){delete this.styles[e];}},{key:"getActiveStyles",value:function(){return this.active_styles}},{key:"updateActiveStyles",value:function(e){return this.active_styles=Object.keys(e.reduce((function(e,t){return Object.keys(t.meshes).forEach((function(t){return e[t]=!0})),e}),{})),this.active_styles}},{key:"getActiveBlendOrders",value:function(){return this.active_blend_orders}},{key:"updateActiveBlendOrders",value:function(e){var t=[];e.forEach((function(e){Object.entries(e.meshes).forEach((function(e){var r=n(e,2),i=r[0];r[1].forEach((function(e){var r=e.variant.blend_order,n=t.findIndex((function(e){return e.blend_order===r}));n=n>-1?n:t.push({blend_order:r,styles:[]})-1,-1===t[n].styles.indexOf(i)&&t[n].styles.push(i);}));}));})),this.active_blend_orders=t.sort((function(e,t){return e.blend_order-t.blend_order}));}},{key:"mix",value:function(e,t){if(e.mixed)return e;e.mixed={};var r=[];if(e.mix){var n;if(Array.isArray(e.mix))(n=r).push.apply(n,l(e.mix));else r.push(e.mix);(r=r.map((function(e){return t[e]})).filter((function(t){return t&&t!==e}))).forEach((function(t){return e.mixed[t.name]=!0}));}r.push(e),e.animated=r.some((function(e){return e&&e.animated})),e.texcoords=r.some((function(e){return e&&e.texcoords})),e.base=r.map((function(e){return e.base})).filter((function(e){return e})).pop(),e.lighting=r.map((function(e){return e.lighting})).filter((function(e){return null!=e})).pop(),e.texture=r.map((function(e){return e.texture})).filter((function(e){return e})).pop(),e.raster=r.map((function(e){return e.raster})).filter((function(e){return null!=e})).pop(),e.dash=r.map((function(e){return e.dash})).filter((function(e){return null!=e})).pop(),e.dash_background_color=r.map((function(e){return e.dash_background_color})).filter((function(e){return null!=e})).pop(),r.some((function(e){return Object.prototype.hasOwnProperty.call(e,"blend")&&e.blend}))&&(e.blend=r.map((function(e){return Object.prototype.hasOwnProperty.call(e,"blend")&&e.blend})).filter((function(e){return e})).pop()),e.blend_order=r.map((function(e){return e.blend_order})).filter((function(e){return null!=e})).pop(),e.defines=Object.assign.apply(Object,[{}].concat(l(r.map((function(e){return e.defines})).filter((function(e){return e}))))),e.material=Object.assign.apply(Object,[{}].concat(l(r.map((function(e){return e.material})).filter((function(e){return e})))));var i=r.map((function(e){return e.draw})).filter((function(e){return e}));return i.length>0&&(e.draw=$.apply(void 0,[{}].concat(l(i)))),this.mixShaders(e,t,r),e}},{key:"mixShaders",value:function(e,t,r){var n={},i=r.map((function(e){return e.shaders})).filter((function(e){return e}));if(n.defines=Object.assign.apply(Object,[{}].concat(l(i.map((function(e){return e.defines})).filter((function(e){return e}))))),n.attributes=Object.assign.apply(Object,[{}].concat(l(i.map((function(e){return e.attributes})).filter((function(e){return e}))))),n.uniforms={},n._uniforms=e.shaders&&e.shaders.uniforms||{},n._uniform_scopes={},r.filter((function(e){return e.shaders&&e.shaders.uniforms})).forEach((function(e){var r=function(r){n._uniform_scopes[r]=e.name,Object.defineProperty(n.uniforms,r,{enumerable:!0,configurable:!0,get:function(){return void 0!==n._uniforms[r]?n._uniforms[r]:t[n._uniform_scopes[r]].shaders.uniforms!==n.uniforms?t[n._uniform_scopes[r]].shaders.uniforms[r]:void 0},set:function(e){n._uniforms[r]=e;}});};for(var i in e.shaders.uniforms)r(i);})),n.extensions=Object.keys(i.map((function(e){return e.extensions})).filter((function(e){return e})).reduce((function(e,t){return "string"==typeof t?e[t]=!0:t.forEach((function(t){return e[t]=!0})),e}),{})||{}),e.shaders&&e.shaders.blocks)for(var o in e.shaders.block_scopes=e.shaders.block_scopes||{},e.shaders.blocks){var a,s=e.shaders.blocks[o];if(e.shaders.block_scopes[o]=e.shaders.block_scopes[o]||[],Array.isArray(s))(a=e.shaders.block_scopes[o]).push.apply(a,l(s.map((function(){return e.name}))));else e.shaders.block_scopes[o].push(e.name);}var u={};return i.forEach((function(e){if(e.blocks){n.blocks=n.blocks||{},n.block_scopes=n.block_scopes||{};var t={};for(var r in e.blocks){var i=e.blocks[r],o=e.block_scopes[r];n.blocks[r]=n.blocks[r]||[],n.block_scopes[r]=n.block_scopes[r]||[],i=Array.isArray(i)?i:[i],o=Array.isArray(o)?o:[o];for(var a=0;a<i.length;a++)u[o[a]]||(t[o[a]]=!0,n.blocks[r].push(i[a]),n.block_scopes[r].push(o[a]));}Object.assign(u,t);}})),Object.assign(e.mixed,u),e.shaders=n,e}},{key:"create",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=$({},t);return n.name=e,(n=this.mix(n,r)).base&&this.base_styles[n.base]?this.styles[e]=n=Object.assign(Object.create(this.base_styles[n.base]),n):n.base=null,n}},{key:"build",value:function(e){var t=this,r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?oi(Object(r),!0).forEach((function(t){s(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oi(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}({},e);this.styles&&Object.values(this.styles).forEach((function(e){return v.removeTarget(e.main_thread_target)}));for(var n=["polygons","lines","points","text","raster"],i=0,o=["opaque","add","multiply","overlay","inlay","translucent"];i<o.length;i++){var a,l=o[i],u=ni(n);try{for(u.s();!(a=u.n()).done;){var c=a.value,h=l+"_"+c;null==r[h]&&(r[h]={base:c,blend:l});}}catch(e){u.e(e);}finally{u.f();}}var f=Object.keys(r).sort((function(e,n){return t.inheritanceDepth(e,r)-t.inheritanceDepth(n,r)}));for(var d in this.styles)this.base_styles[d]?this.styles[d].reset():delete this.styles[d];var _={};return f.forEach((function(e){_[e]=t.create(e,r[e],_);})),this.styles}},{key:"initStyles",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.styles)this.styles[t].init(e);}},{key:"inheritanceDepth",value:function(e,t){for(var r=this,n=0;;){var i=t[e];if(!i)break;if(!i.mix)break;if(n++,Array.isArray(i.mix)){n+=Math.max.apply(Math,l(i.mix.map((function(n){if(e!==n)return r.inheritanceDepth(n,t)}))));break}if(e===i.mix)break;e=i.mix;}return n}}])}();function si(e){return null!=e}function li(e){return "("+e+")"}function ui(e){return "string"==typeof e?'"'+e+'"':e}function ci(e){if("$"===e[0])return "context['"+e.substring(1)+"']";if(e.indexOf(".")>-1){if(-1===e.indexOf("\\."))return "context.feature.properties".concat(e.split(".").map((function(e){return "['"+e+"']"})).join(""));var t=e.replace(/\\\./g,"__TANGRAM_DELIMITER__").split(".").map((function(e){return e.replace(/__TANGRAM_DELIMITER__/g,".")}));return "context.feature.properties".concat(t.map((function(e){return "['"+e+"']"})).join(""))}return "context.feature.properties['"+e+"']"}function hi(e,t){return li(ui(t)+" === "+ci(e))}function fi(e,t){var r="["+t.map(ui).join(",")+"]";return li("".concat(r,".indexOf(").concat(ci(e),") > -1"))}function di(e,t){return li(e.filter(si).map((function(e){return li(e.join(" && "))})).join(" "+t+" "))}function _i(e,t,r){return t&&t.length>0?di(t.map((function(e){return bi(e,r)})),"||"):"true"}function pi(e,t,r){return t&&t.length>0?di(t.map((function(e){return bi(e,r)})),"&&"):"true"}function mi(e,t,r){return "!"+li(bi(t,r).join(" && "))}function vi(e,t,r){return "!"+li(_i(0,t,r))}function gi(e,t){return li(ci(e)+(t?" != ":" == ")+"null")}function yi(e,t,r){var n=[],i=r&&"function"==typeof r.rangeTransform&&r.rangeTransform;if(t.max){var o=i?i(t.max):t.max;n.push(ci(e)+" < "+o);}if(t.min){var a=i?a=i(t.min):t.min;n.push(ci(e)+" >= "+a);}return li(n.join(" && "))}function xi(e,t){var r=[];if(t.includes_any){var n="["+(Array.isArray(t.includes_any)?t.includes_any:[t.includes_any]).map(ui).join(",")+"]";r.push("".concat(ci(e)," != null && ").concat(n,".some(function(v) { return ").concat(ci(e),".indexOf(v) > -1 })"));}if(t.includes_all){var i="["+(Array.isArray(t.includes_all)?t.includes_all:[t.includes_all]).map(ui).join(",")+"]";r.push("".concat(ci(e)," != null && ").concat(i,".every(function(v) { return ").concat(ci(e),".indexOf(v) > -1 })"));}return li(r.join(" && "))}function bi(e,t){var r=[];if("function"==typeof e)return [li(e.toString()+"(context)")];if(Array.isArray(e))return [_i(0,e,t)];if(null==e)return ["true"];for(var n=Object.keys(e),i=0;i<n.length;i++){var a=n[i],s=e[a],l=o(s);if("string"===l||"number"===l)r.push(hi(a,s));else if("boolean"===l)r.push(gi(a,s));else if("not"===a)r.push(mi(0,s,t));else if("any"===a)r.push(_i(0,s,t));else if("all"===a)r.push(pi(0,s,t));else if("none"===a)r.push(vi(0,s,t));else if(Array.isArray(s))r.push(fi(a,s));else if("object"===l&&null!=s)s.max||s.min?r.push(yi(a,s,t)):(s.includes_any||s.includes_all)&&r.push(xi(a,s));else {if(null!=s)throw new Error("Unknown Query syntax: "+s);r.push(" true ");}}return 0===n.length?["true"]:r}function Ai(e,t){return null==e?function(){return !0}:new Function("context","return "+(li(bi(e,t).join(" && "))+";"))}function Ti(e,t,r){return t=Me(t),Pe(e,wi()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function wi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (wi=function(){return !!e})()}var Ei=["filter","draw","visible","enabled","data","exclusive","priority"],ki={};function Ri(e,t){for(var r,n=0,i=0;i<e.length;i++)e[i].length>n&&(n=e[i].length);if(0===n)return null;for(var o={visible:!0},a=function(n){if(r=[],e.forEach((function(e){e[n]&&e[n][t]&&-1===r.indexOf(e[n][t])&&r.push(e[n][t]);})),0===r.length)return 1;$.apply(void 0,[o].concat(l(r)));},s=0;s<n;s++)a(s);return !1===o.visible?null:o}var Mi=["any","all","not","none"],zi=function(){return h((function e(t){var r=t.layer,n=t.name,i=t.parent,a=t.draw,s=t.visible,l=t.enabled,c=t.filter,h=t.exclusive,f=t.priority,d=t.styles;if(u(this,e),this.id=e.id++,this.config_data=r.data,this.parent=i,this.name=n,this.full_name=this.parent?this.parent.full_name+":"+this.name:this.name,this.draw=a,this.filter=c,this.exclusive=!0===h,this.priority=null!=f?f:Number.MAX_SAFE_INTEGER,this.styles=d,this.is_built=!1,l=void 0===l?s:l,this.enabled=!1!==l,this.draw)for(var _ in this.draw)if(this.draw[_]=null==this.draw[_]?{}:this.draw[_],"object"!==o(this.draw[_])){var p="Draw group '".concat(_,"' for layer ").concat(this.full_name," is invalid, must be an object, ");k("warn",p+="but was set to `".concat(_,": ").concat(this.draw[_],"` instead")),delete this.draw[_];}}),[{key:"build",value:function(){k("trace","Building layer '".concat(this.full_name,"'")),this.buildFilter(),this.buildDraw(),this.is_built=!0;}},{key:"buildDraw",value:function(){this.draw=ie(this.draw,ue.wrapFunction),this.calculatedDraw=function(e){var t=[];if(e.parent){var r=e.parent.calculatedDraw||[];t.push.apply(t,l(r));}return t.push(e.draw),t}(this);}},{key:"buildFilter",value:function(){this.filter_original=this.filter,this.filter=ie(this.filter,ue.wrapFunction);var e=o(this.filter);if(null==this.filter||"object"===e||"function"===e)try{this.buildZooms(),this.buildPropMatches(),null!=this.filter&&("function"==typeof this.filter||Object.keys(this.filter).length>0)?this.filter=Ai(this.filter,Ni):this.filter=null;}catch(e){var t="Filter for layer ".concat(this.full_name," is invalid, `filter: ").concat(JSON.stringify(this.filter),"` ");k("warn",t+="failed with error '".concat(e.message,"', stack trace: ").concat(e.stack));}else {var r="Filter for layer ".concat(this.full_name," is invalid, filter value must be an object or function, ");k("warn",r+="but was set to `filter: ".concat(this.filter,"` instead"));}}},{key:"buildZooms",value:function(){var e=this.filter&&this.filter.$zoom,t=o(e);if(null!=e){if(this.zooms={},"number"===t)this.zooms[e]=!0;else if(Array.isArray(e))for(var r=0;r<e.length;r++)this.zooms[e[r]]=!0;else if("object"===t&&(null!=e.min||null!=e.max))for(var n=e.min||0,i=e.max||Q.max_style_zoom,a=n;a<i;a++)this.zooms[a]=!0;delete this.filter.$zoom;}}},{key:"buildPropMatches",value:function(){var e=this;this.filter&&!Array.isArray(this.filter)&&"function"!=typeof this.filter&&Object.keys(this.filter).forEach((function(t){if(-1===Mi.indexOf(t)){var r=e.filter[t],n=o(r),i=Array.isArray(r);if(!i&&"string"!==n&&"number"!==n)return;"$"===t[0]?(e.context_prop_matches=e.context_prop_matches||[],e.context_prop_matches.push([t.substring(1),i?r:[r]]),delete e.filter[t]):-1===t.indexOf(".")&&(e.feature_prop_matches=e.feature_prop_matches||[],e.feature_prop_matches.push([t,i?r:[r]]),delete e.filter[t]);}}));}},{key:"doPropMatches",value:function(e){if(this.feature_prop_matches)for(var t=0;t<this.feature_prop_matches.length;t++){var r=this.feature_prop_matches[t],n=e.feature.properties[r[0]];if(null==n||-1===r[1].indexOf(n))return !1}if(this.context_prop_matches)for(var i=0;i<this.context_prop_matches.length;i++){var o=this.context_prop_matches[i],a=e[o[0]];if(null==a||-1===o[1].indexOf(a))return !1}return !0}},{key:"doesMatch",value:function(e){if(!this.enabled)return !1;if(this.is_built||this.build(),null!=this.zooms&&!this.zooms[e.zoom])return !1;if(!this.doPropMatches(e))return !1;var t;if(this.filter instanceof Function)try{t=this.filter(e);}catch(t){var r="Filter for this ".concat(this.full_name,": `filter: ").concat(this.filter_original,"` ");k("error",r+="failed with error '".concat(t.message,"', stack trace: ").concat(t.stack),e.feature);}else t=null==this.filter;return !!t&&(this.children_to_parse&&(!function(e,t,r){for(var n in t){var i=t[n];if("object"!==o(i)||Array.isArray(i)){var a="Layer value must be an object: cannot create layer '".concat(n,": ").concat(JSON.stringify(i),"'");a+=", under parent layer '".concat(e.full_name,"'."),r[e.name]&&(a+=" The parent name '".concat(e.name,"' is also the name of a style, did you mean to create a 'draw' group"),e.parent&&(a+=" under '".concat(e.parent.name,"'")),a+=" instead?"),k("warn",a);}else Li(n,i,e,r);}e.layers.sort((function(e,t){if(e.exclusive<t.exclusive)return 1;if(e.exclusive>t.exclusive)return -1;var r=e.exclusive?1:-1;return e.priority>t.priority?r:e.priority<t.priority?-r:e.full_name<t.full_name?r:e.full_name>t.full_name?-r:void 0}));}(this,this.children_to_parse,this.styles),delete this.children_to_parse),!0)}}])}();zi.id=0;var Pi=function(e){function t(e){var r;return u(this,t),(r=Ti(this,t,[e])).is_leaf=!0,r}return Se(t,e),h(t)}(zi),Si=function(e){function t(e){var r;return u(this,t),(r=Ti(this,t,[e])).is_tree=!0,r.layers=e.layers||[],r}return Se(t,e),h(t,[{key:"addLayer",value:function(e){this.layers.push(e);}},{key:"buildDrawGroups",value:function(e){var t=[],r=[];if(Ii(e,[this],t,r),t.length>0){var n=function(e){if(e.length>1){for(var t=e[0],r=1;r<e.length;r++)t+="/"+e[r];return t}return e[0]}(r);if(void 0===ki[n]){for(var i=t.map((function(e){return e&&!1!==e.visible&&e.calculatedDraw})),o={},a=0;a<i.length;a++){var s=i[a];if(s)for(var l=0;l<s.length;l++){var u=s[l];for(var c in u)o[c]=!0;}}for(var h in o)ki[n]=ki[n]||{},ki[n][h]=Ri(i,h),ki[n][h]?(ki[n][h].key=n+"/"+h,ki[n][h].layers=t.map((function(e){return e&&e.full_name})),ki[n][h].group=h):delete ki[n][h];ki[n]&&0===Object.keys(ki[n]).length&&(ki[n]=null);}return ki[n]}}}])}(zi),Ni={rangeTransform:function(e){return "string"==typeof e&&"px2"===e.trim().slice(-3)?"".concat(parseFloat(e)," * context.meters_per_pixel_sq"):e}};function Oi(e){return Ei.indexOf(e)>-1}function Li(e,t,r,i){var o,a={name:e,layer:t=null==t?{}:t,parent:r,styles:i},s=function(e){var t={},r={};for(var n in e)Oi(n)?t[n]=e[n]:r[n]=e[n];return [t,r]}(t),l=n(s,2),u=l[0],c=l[1],h=(o=c,0===Object.keys(o).length),f=new(h&&null!=r?Pi:Si)(Object.assign(a,u));return f.enabled&&(r&&r.addLayer(f),f.children_to_parse=h?null:c),f}function Ii(e,t,r,n){var i=!1;if(0!==t.length){for(var o=0;o<t.length;o++){var a=t[o];if(a.is_leaf){if(a.doesMatch(e)&&(i=!0,r.push(a),n.push(a.id),a.exclusive))break}else if(a.is_tree&&a.doesMatch(e)&&(i=!0,Ii(e,a.layers,r,n)||(r.push(a),n.push(a.id)),a.exclusive))break}return i}}function Fi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function Di(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Fi(Object(r),!0).forEach((function(t){s(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Fi(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}var Ui=0,Gi=0,ji=function(){function e(t){var r=t.coords,n=t.style_z,i=t.source,o=t.workers,a=t.view;u(this,e),this.id=Ui++,this.view=a,this.source=i,this.generation=null,this.valid=!0,this.visible=!1,this.proxy_for=null,this.proxied_as=null,this.proxy_level=0,this.proxy_order_offset=0,this.fade_in=!0,this.loading=!1,this.loaded=!1,this.built=!1,this.labeled=!1,this.error=null,this.debug={},this.style_z=n,this.coords=Je.normalizedCoord(r,this.source),this.key=Je.key(this.coords,this.source,this.style_z),this.overzoom=Math.max(this.style_z-this.coords.z,0),this.overzoom2=Math.pow(2,this.overzoom),this.min=Q.metersForTile(this.coords),this.max=Q.metersForTile({x:this.coords.x+1,y:this.coords.y+1,z:this.coords.z}),this.span={x:this.max.x-this.min.x,y:-(this.max.y-this.min.y)},this.bounds={sw:{x:this.min.x,y:this.max.y},ne:{x:this.max.x,y:this.min.y}},this.meters_per_pixel=Q.metersPerPixel(this.style_z),this.meters_per_pixel_sq=this.meters_per_pixel*this.meters_per_pixel,this.units_per_pixel=Q.units_per_pixel/this.overzoom2,this.units_per_meter_overzoom=Q.unitsPerMeter(this.coords.z)*this.overzoom2,this.preserve_tiles_within_zoom=this.source.preserve_tiles_within_zoom,this.meshes={},this.new_mesh_styles=[],this.pending_label_meshes=null,this.setWorker(o);}return h(e,[{key:"freeResources",value:function(){for(var e in this.meshes)this.meshes[e].forEach((function(e){return e.destroy()}));if(this.meshes={},this.pending_label_meshes)for(var t in this.pending_label_meshes)this.pending_label_meshes[t].forEach((function(e){return e.destroy()}));this.pending_label_meshes=null;}},{key:"destroy",value:function(){L.removeForTile(this.id),this.workerMessage("self.removeTile",this.key),this.freeResources(),this.worker=null,this.valid=!1;}},{key:"buildAsMessage",value:function(){return {id:this.id,key:this.key,source:this.source.name,coords:this.coords,min:this.min,max:this.max,units_per_pixel:this.units_per_pixel,meters_per_pixel:this.meters_per_pixel,meters_per_pixel_sq:this.meters_per_pixel_sq,units_per_meter_overzoom:this.units_per_meter_overzoom,style_z:this.style_z,overzoom:this.overzoom,overzoom2:this.overzoom2,generation:this.generation,debug:this.debug}}},{key:"setWorker",value:function(e){this.source.tiled?this.worker_id=Math.abs(this.coords.x+this.coords.y+this.coords.z)%e.length:this.worker_id=this.source.id%e.length,this.worker=e[this.worker_id];}},{key:"workerMessage",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v.postMessage.apply(v,[this.worker].concat(t))}},{key:"build",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).fade_in,r=void 0===t||t;return this.generation=e,this.fade_in=r,this.loaded||(this.loading=!0,this.built=!1,this.labeled=!1),this.workerMessage("self.buildTile",{tile:this.buildAsMessage()}).catch((function(e){throw e}))}},{key:"buildMeshes",value:function(e,t){if(!this.error){this.build_id=Gi++,t.start&&(this.debug.geometry_count=0,this.debug.buffer_size=0);var r={},n=this.mesh_data;if(n)for(var i in n){for(var o in n[i].meshes){var a=n[i].meshes[o];if(a.vertex_data){if(!e[i]){k("warn","Could not create mesh because style '".concat(i,"' not found, for tile ").concat(this.key,", aborting tile"));break}var s=Object.assign({},n[i]);s.uniforms=Object.assign({},s.uniforms,a.uniforms),s.variant=a.variant,a.labels&&(s.retain=!0);var l=e[i].makeMesh(a.vertex_data,a.vertex_elements,s);l.variant=s.variant,l.labels=a.labels,r[i]=r[i]||[],r[i].push(l),null==l.variant.mesh_order&&(l.variant.mesh_order=r[i].length-1),this.debug.buffer_size+=l.buffer_size,this.debug.geometry_count+=l.geometry_count;}}r[i]&&r[i].sort((function(e,t){var r=e.variant.mesh_order,n=t.variant.mesh_order;return null==r?1:null==n||r<n?-1:1}));}for(var u in delete this.mesh_data,r)e[u].collision?(this.pending_label_meshes=this.pending_label_meshes||{},this.pending_label_meshes[u]=r[u]):(this.meshes[u]&&this.meshes[u].forEach((function(e){return e.destroy()})),this.meshes[u]=r[u],this.new_mesh_styles.push(u));if(t.done){for(var c in this.meshes)-1!==this.new_mesh_styles.indexOf(c)||this.pending_label_meshes&&null!=this.pending_label_meshes[c]||(this.meshes[c].forEach((function(e){return e.destroy()})),delete this.meshes[c]);this.new_mesh_styles=[],this.debug.geometry_ratio=(this.debug.geometry_count/this.debug.feature_count).toFixed(1);}this.printDebug(t);}}},{key:"pendingLabelStyleCount",value:function(){return this.pending_label_meshes?Object.keys(this.pending_label_meshes).length:0}},{key:"swapPendingLabels",value:function(){if(this.labeled=!0,this.pending_label_meshes){for(var e in this.pending_label_meshes)this.meshes[e]&&this.meshes[e].forEach((function(e){return e.destroy()})),this.meshes[e]=this.pending_label_meshes[e];this.pending_label_meshes=null;}}},{key:"setProxyFor",value:function(e){e?(this.visible=!0,this.proxy_for=this.proxy_for||[],this.proxy_for.push(e),this.proxy_order_offset=1,e.proxied_as=e.style_z>this.style_z?"child":"parent",this.proxy_level=Math.abs(e.style_z-this.style_z)):(this.proxy_for=null,this.proxy_order_offset=0,this.proxy_level=0);}},{key:"isProxy",value:function(){return null!=this.proxy_for}},{key:"shouldProxyForStyle",value:function(e){return !this.proxy_for||this.proxy_for.some((function(t){return null==t.meshes[e]}))}},{key:"setupProgram",value:function(e,t){var r=e.model,n=e.model32;t.uniform("4fv","u_tile_origin",[this.min.x,this.min.y,this.style_z,this.coords.z]),t.uniform("1f","u_tile_proxy_order_offset",this.proxy_order_offset),Nn.identity(r),Nn.translate(r,r,Pn(this.min.x,this.min.y,0)),Nn.scale(r,r,Pn(this.span.x/Q.tile_scale,this.span.y/Q.tile_scale,1)),Nn.copy(n,r),t.uniform("Matrix4fv","u_model",n),t.uniform("1i","u_tile_fade_in",this.fade_in&&"child"!==this.proxied_as);}},{key:"merge",value:function(e){return this.loading=e.loading,this.loaded=e.loaded,this.generation=e.generation,this.error=e.error,this.mesh_data=e.mesh_data,this.debug=$(this.debug,e.debug),this}},{key:"printDebug",value:function(e){var t=["layers"],r={};for(var n in this.debug)-1===t.indexOf(n)&&(r[n]=this.debug[n]);k("debug","Tile ".concat(e.done?"(done)":"",": debug for ").concat(this.key,": [  ").concat(JSON.stringify(r)," ]"));}}],[{key:"cancel",value:function(t){t&&(t.canceled=!0,t.source_data&&t.source_data.request_id&&(M.cancelRequest(t.source_data.request_id),t.source_data.request_id=null),e.abortBuild(t));}},{key:"buildGeometry",value:function(t,r){var n=r.scene_id,i=r.layers,o=r.styles,a=r.global,s=t.source_data;for(var l in t.debug.building=+new Date,t.debug.feature_count=0,t.debug.layers=null,mr.startTile(t.id,{apply_repeat_groups:!0}),i){var u=i[l];if(u&&u.config_data){if(u.config_data.source===t.source)for(var c=e.getDataForSource(s,u.config_data,l),h=0;h<c.length;h++){var f=c[h],d=f.geom;if(d)for(var _=0;_<d.features.length;_++){var p=d.features[_];if(null!=p.geometry){var m=ue.getFeatureParseContext(p,t,a);m.winding=t.default_winding,m.source=t.source,m.layer=f.layer;var v=u.buildDrawGroups(m,!0);if(v){for(var g in v){var y=v[g],x=y.style||g,b=o[x];b?null!=(y=b.preprocess(y))&&!1!==y.visible&&(m.layers=y.layers,b.addFeature(p,y,m)):k("warn","Style '".concat(x,"' not found, skipping layer '").concat(l,"':"),y,p);}t.debug.feature_count++;}}}}}else k("warn","Layer ".concat(l," was defined without a geometry data source and will not be rendered."));}t.debug.building=+new Date-t.debug.building;var A=this.stylesForTile(t,o).map((function(e){return o[e]}));e.buildStyleGroups(t,A,n,(function(e){return e.collision?"collision":"non-collision"}));}},{key:"stylesForTile",value:function(e,t){var r=[];for(var n in t)t[n].hasDataForTile(e)&&r.push(n);return r}},{key:"buildStyleGroups",value:function(t,r,n,i){var o=r.reduce((function(e,t){var r=i(t);return e[r]=e[r]||[],e[r].push(t),e}),{});if(0===Object.keys(o).length)return v.postMessage("TileManager_".concat(n,".buildTileStylesCompleted"),v.withTransferables({tile:e.slice(t),progress:{start:!0,done:!0}})),void mr.resetTile(t.id);var a={};for(var s in o)e.buildStyleGroup({group_name:s,groups:o,tile:t,progress:a,scene_id:n});}},{key:"buildStyleGroup",value:function(t){return new Promise((function(r,n){var i,o,a,s,l,u,c;i=t.group_name,o=t.groups,a=t.tile,s=t.progress,l=t.scene_id,u=o[i],c={};var h=function(){try{return r()}catch(e){return n(e)}},f=function(e){try{return k("error","Error for style group '".concat(i,"' for tile ").concat(a.key),e&&e.stack||e),h()}catch(e){return n(e)}};try{return Promise.resolve(Promise.all(u.map((function(e){return new Promise((function(t,r){var n;return Promise.resolve(e.endData(a)).then((function(i){try{return (n=i)&&(c[e.name]=n),t()}catch(e){return r(e)}}),r)}))})))).then((function(t){try{return k("trace","Finished style group '".concat(i,"' for tile ").concat(a.key)),o[i]=null,Object.keys(o).every((function(e){return null==o[e]}))&&(s.done=!0),v.postMessage("TileManager_".concat(l,".buildTileStylesCompleted"),v.withTransferables({tile:Di(Di({},e.slice(a)),{},{mesh_data:c}),progress:s})),s.done&&mr.resetTile(a.id),h()}catch(e){return f(e)}}),f)}catch(e){f(e);}}))}},{key:"getDataForSource",value:function(e,t,r){var n=[];if(null!=t&&null!=e&&null!=e.layers)if(!0===t.all_layers){if(null!=t.layer)k({level:"warn",once:!0},"Layer ".concat(r," includes both 'all_layers: true' and an explicit ")+"'layer' keyword in its 'data' block. 'all_layers: true' takes precedence, 'layer' will be ignored.");for(var i in e.layers)n.push({layer:i,geom:e.layers[i]});}else !t.layer&&e.layers._default?n.push({geom:e.layers._default}):!t.layer&&r?n.push({layer:r,geom:e.layers[r]}):"string"==typeof t.layer?n.push({layer:t.layer,geom:e.layers[t.layer]}):Array.isArray(t.layer)&&t.layer.forEach((function(t){n.push({layer:t,geom:e.layers[t]});}));return n}},{key:"abortBuild",value:function(e){if(L.removeForTile(e.id),mr.abortTile(e.id),e.mesh_data)for(var t in e.mesh_data){var r=e.mesh_data[t].textures;r&&r.forEach((function(t){var r=D.textures[t];r&&(k("trace","releasing texture ".concat(t," for tile ").concat(e.key)),r.release());}));}}},{key:"slice",value:function(e,t){var r=["id","key","loading","loaded","generation","error","debug"];Array.isArray(t)&&r.push.apply(r,l(t));for(var n={},i=0;i<r.length;i++){var o=r[i];n[o]=e[o];}return n}}])}();function Ci(e,t){for(var r in e){var n=e[r];it(t,r,n.features,n.geoms,n.styles,n.base),n.layers&&(t[r].layers=t[r].layers||{},Ci(n.layers,t[r].layers));}}ji.coord_children={};var Bi,Vi,qi,Xi={};function Hi(){return Bi||(Bi=1,Xi.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,l=(1<<s)-1,u=l>>1,c=-7,h=r?i-1:0,f=r?-1:1,d=e[t+h];for(h+=f,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+e[t+h],h+=f,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+e[t+h],h+=f,c-=8);if(0===o)o=1-u;else {if(o===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=u;}return (d?-1:1)*a*Math.pow(2,o-n)},Xi.write=function(e,t,r,n,i,o){var a,s,l,u=8*o-i-1,c=(1<<u)-1,h=c>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,_=n?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(t*l-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=_,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;e[r+d]=255&a,d+=_,a/=256,u-=8);e[r+d-_]|=128*p;}),Xi}var Wi,Yi,Zi,Ji,Ki,$i,Qi,eo,to,ro=function(){if(qi)return Vi;qi=1,Vi=t;var e=Hi();function t(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length;}t.Varint=0,t.Fixed64=1,t.Bytes=2,t.Fixed32=5;var r=4294967296,n=1/r;function i(e){return e.type===t.Bytes?e.readVarint()+e.pos:e.pos+1}function o(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function a(e,t,r){var n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.ceil(Math.log(t)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=e;i--)r.buf[i+n]=r.buf[i];}function s(e,t){for(var r=0;r<e.length;r++)t.writeVarint(e[r]);}function l(e,t){for(var r=0;r<e.length;r++)t.writeSVarint(e[r]);}function u(e,t){for(var r=0;r<e.length;r++)t.writeFloat(e[r]);}function c(e,t){for(var r=0;r<e.length;r++)t.writeDouble(e[r]);}function h(e,t){for(var r=0;r<e.length;r++)t.writeBoolean(e[r]);}function f(e,t){for(var r=0;r<e.length;r++)t.writeFixed32(e[r]);}function d(e,t){for(var r=0;r<e.length;r++)t.writeSFixed32(e[r]);}function _(e,t){for(var r=0;r<e.length;r++)t.writeFixed64(e[r]);}function p(e,t){for(var r=0;r<e.length;r++)t.writeSFixed64(e[r]);}function m(e,t){return (e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function v(e,t,r){e[r]=t,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24;}function g(e,t){return (e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}return t.prototype={destroy:function(){this.buf=null;},readFields:function(e,t,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),i=n>>3,o=this.pos;this.type=7&n,e(i,t,this),this.pos===o&&this.skip(n);}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=m(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=g(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=m(this.buf,this.pos)+m(this.buf,this.pos+4)*r;return this.pos+=8,e},readSFixed64:function(){var e=m(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,e},readFloat:function(){var t=e.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=e.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(e){var t,r,n=this.buf;return t=127&(r=n[this.pos++]),r<128?t:(t|=(127&(r=n[this.pos++]))<<7,r<128?t:(t|=(127&(r=n[this.pos++]))<<14,r<128?t:(t|=(127&(r=n[this.pos++]))<<21,r<128?t:function(e,t,r){var n,i,a=r.buf;if(i=a[r.pos++],n=(112&i)>>4,i<128)return o(e,n,t);if(i=a[r.pos++],n|=(127&i)<<3,i<128)return o(e,n,t);if(i=a[r.pos++],n|=(127&i)<<10,i<128)return o(e,n,t);if(i=a[r.pos++],n|=(127&i)<<17,i<128)return o(e,n,t);if(i=a[r.pos++],n|=(127&i)<<24,i<128)return o(e,n,t);if(i=a[r.pos++],n|=(1&i)<<31,i<128)return o(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(r=n[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=function(e,t,r){var n="",i=t;for(;i<r;){var o,a,s,l=e[i],u=null,c=l>239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===c?(o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&((u=(15&l)<<12|(63&o)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&((u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,this.pos,e);return this.pos=e,t},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){var r=i(this);for(e=e||[];this.pos<r;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){var t=i(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var r=7&e;if(r===t.Varint)for(;this.buf[this.pos++]>127;);else if(r===t.Bytes)this.pos=this.readVarint()+this.pos;else if(r===t.Fixed32)this.pos+=4;else {if(r!==t.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(e,t){this.writeVarint(e<<3|t);},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var r=new Uint8Array(t);r.set(this.buf),this.buf=r,this.length=t;}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),v(this.buf,e,this.pos),this.pos+=4;},writeSFixed32:function(e){this.realloc(4),v(this.buf,e,this.pos),this.pos+=4;},writeFixed64:function(e){this.realloc(8),v(this.buf,-1&e,this.pos),v(this.buf,Math.floor(e*n),this.pos+4),this.pos+=8;},writeSFixed64:function(e){this.realloc(8),v(this.buf,-1&e,this.pos),v(this.buf,Math.floor(e*n),this.pos+4),this.pos+=8;},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var r,n;e>=0?(r=e%4294967296|0,n=e/4294967296|0):(n=~(-e/4294967296),4294967295^(r=~(-e%4294967296))?r=r+1|0:(r=0,n=n+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos]=127&e;}(r,0,t),function(e,t){var r=(7&e)<<4;if(t.buf[t.pos++]|=r|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e;}(n,t);}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))));},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e);},writeBoolean:function(e){this.writeVarint(Boolean(e));},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,r){for(var n,i,o=0;o<t.length;o++){if((n=t.charCodeAt(o))>55295&&n<57344){if(!i){n>56319||o+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=n;continue}if(n<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);n<128?e[r++]=n:(n<2048?e[r++]=n>>6|192:(n<65536?e[r++]=n>>12|224:(e[r++]=n>>18|240,e[r++]=n>>12&63|128),e[r++]=n>>6&63|128),e[r++]=63&n|128);}return r}(this.buf,e,this.pos);var r=this.pos-t;r>=128&&a(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(t){this.realloc(4),e.write(this.buf,t,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(t){this.realloc(8),e.write(this.buf,t,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var r=0;r<t;r++)this.buf[this.pos++]=e[r];},writeRawMessage:function(e,t){this.pos++;var r=this.pos;e(t,this);var n=this.pos-r;n>=128&&a(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(e,r,n){this.writeTag(e,t.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(e,t){this.writeMessage(e,s,t);},writePackedSVarint:function(e,t){this.writeMessage(e,l,t);},writePackedBoolean:function(e,t){this.writeMessage(e,h,t);},writePackedFloat:function(e,t){this.writeMessage(e,u,t);},writePackedDouble:function(e,t){this.writeMessage(e,c,t);},writePackedFixed32:function(e,t){this.writeMessage(e,f,t);},writePackedSFixed32:function(e,t){this.writeMessage(e,d,t);},writePackedFixed64:function(e,t){this.writeMessage(e,_,t);},writePackedSFixed64:function(e,t){this.writeMessage(e,p,t);},writeBytesField:function(e,r){this.writeTag(e,t.Bytes),this.writeBytes(r);},writeFixed32Field:function(e,r){this.writeTag(e,t.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(e,r){this.writeTag(e,t.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(e,r){this.writeTag(e,t.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(e,r){this.writeTag(e,t.Fixed64),this.writeSFixed64(r);},writeVarintField:function(e,r){this.writeTag(e,t.Varint),this.writeVarint(r);},writeSVarintField:function(e,r){this.writeTag(e,t.Varint),this.writeSVarint(r);},writeStringField:function(e,r){this.writeTag(e,t.Bytes),this.writeString(r);},writeFloatField:function(e,r){this.writeTag(e,t.Fixed32),this.writeFloat(r);},writeDoubleField:function(e,r){this.writeTag(e,t.Fixed64),this.writeDouble(r);},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t));}},Vi}(),no=q(ro),io={};function oo(){if(Ji)return Zi;Ji=1;var e=function(){if(Yi)return Wi;function e(e,t){this.x=e,this.y=t;}return Yi=1,Wi=e,e.prototype={clone:function(){return new e(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),r=Math.sin(e),n=t*this.x-r*this.y,i=r*this.x+t*this.y;return this.x=n,this.y=i,this},_rotateAround:function(e,t){var r=Math.cos(e),n=Math.sin(e),i=t.x+r*(this.x-t.x)-n*(this.y-t.y),o=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=i,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t},Wi}();function t(e,t,n,i,o){this.properties={},this.extent=n,this.type=0,this._pbf=e,this._geometry=-1,this._keys=i,this._values=o,e.readFields(r,this,t);}function r(e,t,r){1==e?t.id=r.readVarint():2==e?function(e,t){var r=e.readVarint()+e.pos;for(;e.pos<r;){var n=t._keys[e.readVarint()],i=t._values[e.readVarint()];t.properties[n]=i;}}(r,t):3==e?t.type=r.readVarint():4==e&&(t._geometry=r.pos);}function n(e){for(var t,r,n=0,i=0,o=e.length,a=o-1;i<o;a=i++)t=e[i],n+=((r=e[a]).x-t.x)*(t.y+r.y);return n}return Zi=t,t.types=["Unknown","Point","LineString","Polygon"],t.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var r,n=t.readVarint()+t.pos,i=1,o=0,a=0,s=0,l=[];t.pos<n;){if(!o){var u=t.readVarint();i=7&u,o=u>>3;}if(o--,1===i||2===i)a+=t.readSVarint(),s+=t.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new e(a,s));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},t.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,r=1,n=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;e.pos<t;){if(!n){var c=e.readVarint();r=7&c,n=c>>3;}if(n--,1===r||2===r)(i+=e.readSVarint())<a&&(a=i),i>s&&(s=i),(o+=e.readSVarint())<l&&(l=o),o>u&&(u=o);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,s,u]},t.prototype.toGeoJSON=function(e,r,i){var o,a,s=this.extent*Math.pow(2,i),l=this.extent*e,u=this.extent*r,c=this.loadGeometry(),h=t.types[this.type];function f(e){for(var t=0;t<e.length;t++){var r=e[t],n=180-360*(r.y+u)/s;e[t]=[360*(r.x+l)/s-180,360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90];}}switch(this.type){case 1:var d=[];for(o=0;o<c.length;o++)d[o]=c[o][0];f(c=d);break;case 2:for(o=0;o<c.length;o++)f(c[o]);break;case 3:for(c=function(e){var t=e.length;if(t<=1)return [e];for(var r,i,o=[],a=0;a<t;a++){var s=n(e[a]);0!==s&&(void 0===i&&(i=s<0),i===s<0?(r&&o.push(r),r=[e[a]]):r.push(e[a]));}r&&o.push(r);return o}(c),o=0;o<c.length;o++)for(a=0;a<c[o].length;a++)f(c[o][a]);}1===c.length?c=c[0]:h="Multi"+h;var _={type:"Feature",geometry:{type:h,coordinates:c},properties:this.properties};return "id"in this&&(_.id=this.id),_},Zi}function ao(){if($i)return Ki;$i=1;var e=oo();function t(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(r,this,t),this.length=this._features.length;}function r(e,t,r){15===e?t.version=r.readVarint():1===e?t.name=r.readString():5===e?t.extent=r.readVarint():2===e?t._features.push(r.pos):3===e?t._keys.push(r.readString()):4===e&&t._values.push(function(e){var t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){var n=e.readVarint()>>3;t=1===n?e.readString():2===n?e.readFloat():3===n?e.readDouble():4===n?e.readVarint64():5===n?e.readVarint():6===n?e.readSVarint():7===n?e.readBoolean():null;}return t}(r));}return Ki=t,t.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var r=this._pbf.readVarint()+this._pbf.pos;return new e(this._pbf,r,this.extent,this._keys,this._values)},Ki}var so=(to||(to=1,io.VectorTile=function(){if(eo)return Qi;eo=1;var e=ao();function t(t,r,n){if(3===t){var i=new e(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return Qi=function(e,r){this.layers=e.readFields(t,{},r);},Qi}(),io.VectorTileFeature=oo(),io.VectorTileLayer=ao()),io);function lo(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (lo=function(){return !!e})()}var uo=0,co=1,ho=2,fo=["{","["],_o=function(e){function t(e,r){var n,i,o,a;if(u(this,t),i=this,a=[e,r],o=Me(o=t),(n=Pe(i,lo()?Reflect.construct(o,a||[],Me(i).constructor):o.apply(i,a))).response_type="arraybuffer",!0===e.parse_json)n.parse_json_type=co;else if(Array.isArray(e.parse_json))n.parse_json_type=ho,n.parse_json_prop_list=e.parse_json;else {if(null!=e.parse_json)k({level:"warn",once:!0},"Data source '".concat(n.name,"': 'parse_json' parameter should be 'true', or an array of ")+"property names (was '".concat(JSON.stringify(e.parse_json),"')"));n.parse_json_type=uo;}return n}return Se(t,e),h(t,[{key:"parseSourceData",value:function(e,t,r){var n=new Uint8Array(r),i=new no(n);if(t.data=new so.VectorTile(i),t.layers=this.toGeoJSON(t.data),"function"==typeof this.transform){var o={min:Object.assign({},e.min),max:Object.assign({},e.max),coords:Object.assign({},e.coords)};t.layers=this.transform(t.layers,this.extra_data,o);}delete t.data;}},{key:"toGeoJSON",value:function(e){var t={};for(var r in e.layers){for(var n=e.layers[r],i=Q.tile_scale/n.extent,o={type:"FeatureCollection",features:[]},a=0;a<n.length;a++){var s=n.feature(a),l={type:"Feature",geometry:{},id:s.id,properties:s.properties};this.parseJSONProperties(l);for(var u=l.geometry,c=s.loadGeometry(),h=0;h<c.length;h++)for(var f=c[h],d=0;d<f.length;d++)f[d]=[f[d].x*i,f[d].y*i];u.coordinates=c,"Point"===so.VectorTileFeature.types[s.type]?1===c.length?(u.type="Point",u.coordinates=u.coordinates[0][0]):(u.type="MultiPoint",u.coordinates=u.coordinates[0]):"LineString"===so.VectorTileFeature.types[s.type]?1===c.length?(u.type="LineString",u.coordinates=u.coordinates[0]):u.type="MultiLineString":"Polygon"===so.VectorTileFeature.types[s.type]&&(u=po(u)),o.features.push(l);}t[r]=o;}return t}},{key:"parseJSONProperties",value:function(e){if(this.parse_json_type!==uo){var t=e.properties;if(this.parse_json_type===ho)this.parse_json_prop_list.forEach((function(e){try{t[e]=JSON.parse(t[e]);}catch(e){}}));else for(var r in t)if(fo.indexOf(t[r][0])>-1)try{t[r]=JSON.parse(t[r]);}catch(e){}}}}])}(Ze);function po(e){for(var t,r=[],n=[],i=0;i<e.coordinates.length;i++){var o=e.coordinates[i],a=Q.ringWinding(o);null!=a&&(a===(t=t||a)&&n.length>0&&(r.push(n),n=[]),n.push(o));}return n.length>0&&r.push(n),1===r.length?(e.type="Polygon",e.coordinates=r[0]):r.length>1?(e.type="MultiPolygon",e.coordinates=r):e=null,e}function mo(e,t,r,n){for(var i,o=n,a=r-t>>1,s=r-t,l=e[t],u=e[t+1],c=e[r],h=e[r+1],f=t+3;f<r;f+=3){var d=vo(e[f],e[f+1],l,u,c,h);if(d>o)i=f,o=d;else if(d===o){var _=Math.abs(f-a);_<s&&(i=f,s=_);}}o>n&&(i-t>3&&mo(e,t,i,n),e[i+2]=o,r-i>3&&mo(e,i,r,n));}function vo(e,t,r,n,i,o){var a=i-r,s=o-n;if(0!==a||0!==s){var l=((e-r)*a+(t-n)*s)/(a*a+s*s);l>1?(r=i,n=o):l>0&&(r+=a*l,n+=s*l);}return (a=e-r)*a+(s=t-n)*s}function go(e,t,r,n){var i={id:void 0===e?null:e,type:t,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)yo(e,t);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n<t.length;n++)yo(e,t[n]);else if("MultiPolygon"===r)for(n=0;n<t.length;n++)for(var i=0;i<t[n].length;i++)yo(e,t[n][i]);}(i),i}function yo(e,t){for(var r=0;r<t.length;r+=3)e.minX=Math.min(e.minX,t[r]),e.minY=Math.min(e.minY,t[r+1]),e.maxX=Math.max(e.maxX,t[r]),e.maxY=Math.max(e.maxY,t[r+1]);}function xo(e,t,r,n){if(t.geometry){var i=t.geometry.coordinates,o=t.geometry.type,a=Math.pow(r.tolerance/((1<<r.maxZoom)*r.extent),2),s=[],l=t.id;if(r.promoteId?l=t.properties[r.promoteId]:r.generateId&&(l=n||0),"Point"===o)bo(i,s);else if("MultiPoint"===o)for(var u=0;u<i.length;u++)bo(i[u],s);else if("LineString"===o)Ao(i,s,a,!1);else if("MultiLineString"===o){if(r.lineMetrics){for(u=0;u<i.length;u++)s=[],Ao(i[u],s,a,!1),e.push(go(l,"LineString",s,t.properties));return}To(i,s,a,!1);}else if("Polygon"===o)To(i,s,a,!0);else {if("MultiPolygon"!==o){if("GeometryCollection"===o){for(u=0;u<t.geometry.geometries.length;u++)xo(e,{id:l,geometry:t.geometry.geometries[u],properties:t.properties},r,n);return}throw new Error("Input data is not a valid GeoJSON object.")}for(u=0;u<i.length;u++){var c=[];To(i[u],c,a,!0),s.push(c);}}e.push(go(l,o,s,t.properties));}}function bo(e,t){t.push(wo(e[0])),t.push(Eo(e[1])),t.push(0);}function Ao(e,t,r,n){for(var i,o,a=0,s=0;s<e.length;s++){var l=wo(e[s][0]),u=Eo(e[s][1]);t.push(l),t.push(u),t.push(0),s>0&&(a+=n?(i*u-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-o,2))),i=l,o=u;}var c=t.length-3;t[2]=1,mo(t,0,c,r),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size;}function To(e,t,r,n){for(var i=0;i<e.length;i++){var o=[];Ao(e[i],o,r,n),t.push(o);}}function wo(e){return e/360+.5}function Eo(e){var t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function ko(e,t,r,n,i,o,a,s){if(n/=t,o>=(r/=t)&&a<n)return e;if(a<r||o>=n)return null;for(var l=[],u=0;u<e.length;u++){var c=e[u],h=c.geometry,f=c.type,d=0===i?c.minX:c.minY,_=0===i?c.maxX:c.maxY;if(d>=r&&_<n)l.push(c);else if(!(_<r||d>=n)){var p=[];if("Point"===f||"MultiPoint"===f)Ro(h,p,r,n,i);else if("LineString"===f)Mo(h,p,r,n,i,!1,s.lineMetrics);else if("MultiLineString"===f)Po(h,p,r,n,i,!1);else if("Polygon"===f)Po(h,p,r,n,i,!0);else if("MultiPolygon"===f)for(var m=0;m<h.length;m++){var v=[];Po(h[m],v,r,n,i,!0),v.length&&p.push(v);}if(p.length){if(s.lineMetrics&&"LineString"===f){for(m=0;m<p.length;m++)l.push(go(c.id,f,p[m],c.tags));continue}"LineString"!==f&&"MultiLineString"!==f||(1===p.length?(f="LineString",p=p[0]):f="MultiLineString"),"Point"!==f&&"MultiPoint"!==f||(f=3===p.length?"Point":"MultiPoint"),l.push(go(c.id,f,p,c.tags));}}}return l.length?l:null}function Ro(e,t,r,n,i){for(var o=0;o<e.length;o+=3){var a=e[o+i];a>=r&&a<=n&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]));}}function Mo(e,t,r,n,i,o,a){for(var s,l,u=zo(e),c=0===i?No:Oo,h=e.start,f=0;f<e.length-3;f+=3){var d=e[f],_=e[f+1],p=e[f+2],m=e[f+3],v=e[f+4],g=0===i?d:_,y=0===i?m:v,x=!1;a&&(s=Math.sqrt(Math.pow(d-m,2)+Math.pow(_-v,2))),g<r?y>r&&(l=c(u,d,_,m,v,r),a&&(u.start=h+s*l)):g>n?y<n&&(l=c(u,d,_,m,v,n),a&&(u.start=h+s*l)):So(u,d,_,p),y<r&&g>=r&&(l=c(u,d,_,m,v,r),x=!0),y>n&&g<=n&&(l=c(u,d,_,m,v,n),x=!0),!o&&x&&(a&&(u.end=h+s*l),t.push(u),u=zo(e)),a&&(h+=s);}var b=e.length-3;d=e[b],_=e[b+1],p=e[b+2],(g=0===i?d:_)>=r&&g<=n&&So(u,d,_,p),b=u.length-3,o&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&So(u,u[0],u[1],u[2]),u.length&&t.push(u);}function zo(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Po(e,t,r,n,i,o){for(var a=0;a<e.length;a++)Mo(e[a],t,r,n,i,o,!1);}function So(e,t,r,n){e.push(t),e.push(r),e.push(n);}function No(e,t,r,n,i,o){var a=(o-t)/(n-t);return e.push(o),e.push(r+(i-r)*a),e.push(1),a}function Oo(e,t,r,n,i,o){var a=(o-r)/(i-r);return e.push(t+(n-t)*a),e.push(o),e.push(1),a}function Lo(e,t){for(var r=[],n=0;n<e.length;n++){var i,o=e[n],a=o.type;if("Point"===a||"MultiPoint"===a||"LineString"===a)i=Io(o.geometry,t);else if("MultiLineString"===a||"Polygon"===a){i=[];for(var s=0;s<o.geometry.length;s++)i.push(Io(o.geometry[s],t));}else if("MultiPolygon"===a)for(i=[],s=0;s<o.geometry.length;s++){for(var l=[],u=0;u<o.geometry[s].length;u++)l.push(Io(o.geometry[s][u],t));i.push(l);}r.push(go(o.id,a,i,o.tags));}return r}function Io(e,t){var r=[];r.size=e.size,void 0!==e.start&&(r.start=e.start,r.end=e.end);for(var n=0;n<e.length;n+=3)r.push(e[n]+t,e[n+1],e[n+2]);return r}function Fo(e,t){if(e.transformed)return e;var r,n,i,o=1<<e.z,a=e.x,s=e.y;for(r=0;r<e.features.length;r++){var l=e.features[r],u=l.geometry,c=l.type;if(l.geometry=[],1===c)for(n=0;n<u.length;n+=2)l.geometry.push(Do(u[n],u[n+1],t,o,a,s));else for(n=0;n<u.length;n++){var h=[];for(i=0;i<u[n].length;i+=2)h.push(Do(u[n][i],u[n][i+1],t,o,a,s));l.geometry.push(h);}}return e.transformed=!0,e}function Do(e,t,r,n,i,o){return [Math.round(r*(e*n-i)),Math.round(r*(t*n-o))]}function Uo(e,t,r,n,i){for(var o=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),a={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:r,y:n,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},s=0;s<e.length;s++){a.numFeatures++,Go(a,e[s],o,i);var l=e[s].minX,u=e[s].minY,c=e[s].maxX,h=e[s].maxY;l<a.minX&&(a.minX=l),u<a.minY&&(a.minY=u),c>a.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h);}return a}function Go(e,t,r,n){var i=t.geometry,o=t.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s<i.length;s+=3)a.push(i[s]),a.push(i[s+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)jo(a,i,e,r,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(s=0;s<i.length;s++)jo(a,i[s],e,r,"Polygon"===o,0===s);else if("MultiPolygon"===o)for(var l=0;l<i.length;l++){var u=i[l];for(s=0;s<u.length;s++)jo(a,u[s],e,r,!0,0===s);}if(a.length){var c=t.tags||null;if("LineString"===o&&n.lineMetrics){for(var h in c={},t.tags)c[h]=t.tags[h];c.mapbox_clip_start=i.start/i.size,c.mapbox_clip_end=i.end/i.size;}var f={geometry:a,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:c};null!==t.id&&(f.id=t.id),e.features.push(f);}}function jo(e,t,r,n,i,o){var a=n*n;if(n>0&&t.size<(i?a:n))r.numPoints+=t.length/3;else {for(var s=[],l=0;l<t.length;l+=3)(0===n||t[l+2]>a)&&(r.numSimplified++,s.push(t[l]),s.push(t[l+1])),r.numPoints++;i&&function(e,t){for(var r=0,n=0,i=e.length,o=i-2;n<i;o=n,n+=2)r+=(e[n]-e[o])*(e[n+1]+e[o+1]);if(r>0===t)for(n=0,i=e.length;n<i/2;n+=2){var a=e[n],s=e[n+1];e[n]=e[i-2-n],e[n+1]=e[i-1-n],e[i-2-n]=a,e[i-1-n]=s;}}(s,o),e.push(s);}}function Co(e,t){return new Bo(e,t)}function Bo(e,t){var r=(t=this.options=function(e,t){for(var r in t)e[r]=t[r];return e}(Object.create(this.options),t)).debug;if(r&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var n=function(e,t){var r=[];if("FeatureCollection"===e.type)for(var n=0;n<e.features.length;n++)xo(r,e.features[n],t,n);else "Feature"===e.type?xo(r,e,t):xo(r,{geometry:e},t);return r}(e,t);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),n=function(e,t){var r=t.buffer/t.extent,n=e,i=ko(e,1,-1-r,r,0,-1,2,t),o=ko(e,1,1-r,2+r,0,-1,2,t);return (i||o)&&(n=ko(e,1,-r,1+r,0,-1,2,t)||[],i&&(n=Lo(i,1).concat(n)),o&&(n=n.concat(Lo(o,-1)))),n}(n,t),n.length&&this.splitTile(n,0,0,0),r&&(n.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)));}function Vo(e,t,r){return 32*((1<<e)*r+t)+e}function qo(e,t,r){return t=Me(t),Pe(e,Xo()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function Xo(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (Xo=function(){return !!e})()}He.register("MVT",(function(){return _o})),Bo.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Bo.prototype.splitTile=function(e,t,r,n,i,o,a){for(var s=[e,t,r,n],l=this.options,u=l.debug;s.length;){n=s.pop(),r=s.pop(),t=s.pop(),e=s.pop();var c=1<<t,h=Vo(t,r,n),f=this.tiles[h];if(!f&&(u>1&&console.time("creation"),f=this.tiles[h]=Uo(e,t,r,n,l),this.tileCoords.push({z:t,x:r,y:n}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,n,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var d="z"+t;this.stats[d]=(this.stats[d]||0)+1,this.total++;}if(f.source=e,i){if(t===l.maxZoom||t===i)continue;var _=1<<i-t;if(r!==Math.floor(o/_)||n!==Math.floor(a/_))continue}else if(t===l.indexMaxZoom||f.numPoints<=l.indexMaxPoints)continue;if(f.source=null,0!==e.length){u>1&&console.time("clipping");var p,m,v,g,y,x,b=.5*l.buffer/l.extent,A=.5-b,T=.5+b,w=1+b;p=m=v=g=null,y=ko(e,c,r-b,r+T,0,f.minX,f.maxX,l),x=ko(e,c,r+A,r+w,0,f.minX,f.maxX,l),e=null,y&&(p=ko(y,c,n-b,n+T,1,f.minY,f.maxY,l),m=ko(y,c,n+A,n+w,1,f.minY,f.maxY,l),y=null),x&&(v=ko(x,c,n-b,n+T,1,f.minY,f.maxY,l),g=ko(x,c,n+A,n+w,1,f.minY,f.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(p||[],t+1,2*r,2*n),s.push(m||[],t+1,2*r,2*n+1),s.push(v||[],t+1,2*r+1,2*n),s.push(g||[],t+1,2*r+1,2*n+1);}}},Bo.prototype.getTile=function(e,t,r){var n=this.options,i=n.extent,o=n.debug;if(e<0||e>24)return null;var a=1<<e,s=Vo(e,t=(t%a+a)%a,r);if(this.tiles[s])return Fo(this.tiles[s],i);o>1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,u=e,c=t,h=r;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[Vo(u,c,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",u,c,h),o>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,e,t,r),o>1&&console.timeEnd("drilling down"),this.tiles[s]?Fo(this.tiles[s],i):null):null};var Ho=function(e){function t(e,r){var n;return u(this,t),(n=qo(this,t,[e,r])).load_data=null,n.tile_indexes={},n.setTileSize(512),n.pad_scale=0,n}return Se(t,e),h(t,[{key:"_load",value:function(e){var r,n,i,o,a,s=this;return this.load_data||(this.load_data=(r=t,n="_load",i=this,o=3,a=ze(Me(1&o?r.prototype:r),n,i),2&o&&"function"==typeof a?function(e){return a.apply(i,e)}:a)([{source_data:{layers:{}}}]).then((function(e){e.source_data.error&&k("warn","data source load error(s) for source '".concat(s.name,"', URL '").concat(s.url,"': ").concat(e.source_data.error));var t=e.source_data.layers;for(var r in t)s.tile_indexes[r]=Co(t[r],{maxZoom:s.max_zoom,tolerance:1.5,extent:Q.tile_scale,buffer:1e-4});return s.loaded=!0,e}))),this.load_data.then((function(){for(var t in s.tile_indexes)e.source_data.layers[t]=s.getTileFeatures(e,t);return e}))}},{key:"getTileFeatures",value:function(e,t){var r,n=Q.wrapTile(e.coords,{x:!0}),i=this.tile_indexes[t].getTile(n.z,n.x,n.y);if(i&&i.features){r={type:"FeatureCollection",features:[]};for(var o=0;o<i.features.length;o++){var a=i.features[o],s={type:"Feature",geometry:{},id:a.id,properties:a.tags};if(1===a.type)s.geometry.coordinates=a.geometry.map((function(e){return [e[0],e[1]]})),s.geometry.type="MultiPoint";else {if(2!==a.type&&3!==a.type)continue;if(s.geometry.coordinates=a.geometry.map((function(e){return e.map((function(e){return [e[0],e[1]]}))})),2===a.type)s.geometry.type="MultiLineString";else if(s.geometry=po(s.geometry),null==s.geometry)continue}r.features.push(s);}}return r}},{key:"formatURL",value:function(){return this.url}},{key:"parseSourceData",value:function(e,t,r){var n="string"==typeof r?JSON.parse(r):r,i=this.getLayers(n);t.layers=this.preprocessLayers(i,e);}},{key:"preprocessLayers",value:function(e,t){for(var r in e){var n=e[r];n.features=this.preprocessFeatures(n.features);}if("function"==typeof this.transform){var i={min:Object.assign({},t.min),max:Object.assign({},t.max),coords:Object.assign({},t.coords)};1===Object.keys(e).length&&e._default?e._default=this.transform(e._default,this.extra_data,i):e=this.transform(e,this.extra_data,i);}return e}},{key:"preprocessFeatures",value:function(e){if(e=e.filter((function(e){return null!=e.geometry})),this.config.generate_label_centroids){var t=[],r={label_placement:!0};e.forEach((function(e){var n,i;if("Polygon"===e.geometry.type)i=Yo(n=e.geometry.coordinates,e.id,e.properties,r),t.push(i);else if("MultiPolygon"===e.geometry.type){n=e.geometry.coordinates;for(var o=-1/0,a=0,s=0;s<n.length;s++){var l=Q.polygonArea(n[s]);l>o&&(o=l,a=s);}i=Yo(n[a],e.id,e.properties,r),t.push(i);}})),t=t.filter((function(e){return e})),Array.prototype.push.apply(e,t);}return e}},{key:"getLayers",value:function(e){return "Feature"===e.type?{_default:{type:"FeatureCollection",features:[e]}}:"FeatureCollection"===e.type?{_default:e}:e}}])}(Ye),Wo=function(e){function t(e,r){return u(this,t),qo(this,t,[e,r])}return Se(t,e),h(t,[{key:"parseSourceData",value:function(e,t,r){var n="string"==typeof r?JSON.parse(r):r;this.prepareGeoJSON(n,e,t);}},{key:"prepareGeoJSON",value:function(e,t,r){if("function"==typeof this.transform){var n={min:Object.assign({},t.min),max:Object.assign({},t.max),coords:Object.assign({},t.coords)};e=this.transform(e,this.extra_data,n);}r.layers=Ho.prototype.getLayers(e);var i={coords:t.coords,min:Q.metersForTile(Q.wrapTile(t.coords,{x:!0}))};He.projectData(r),He.scaleData(r,i);}}])}(Ze);function Yo(e,t,r,n){var i=Q.centroid(e);if(i){var o={};return Object.assign(o,r,n),{type:"Feature",id:t,properties:o,geometry:{type:"Point",coordinates:i}}}}function Zo(e){return e}function Jo(e,t){var r=t.id,n=t.bbox,i=null==t.properties?{}:t.properties,o=function(e,t){var r=function(e){if(null==(t=e.transform))return Zo;var t,r,n,i=t.scale[0],o=t.scale[1],a=t.translate[0],s=t.translate[1];return function(e,t){return t||(r=n=0),e[0]=(r+=e[0])*i+a,e[1]=(n+=e[1])*o+s,e}}(e),n=e.arcs;function i(e,t){t.length&&t.pop();for(var i=n[e<0?~e:e],o=0,a=i.length;o<a;++o)t.push(r(i[o].slice(),o));e<0&&function(e,t){for(var r,n=e.length,i=n-t;i<--n;)r=e[i],e[i++]=e[n],e[n]=r;}(t,a);}function o(e){return r(e.slice())}function a(e){for(var t=[],r=0,n=e.length;r<n;++r)i(e[r],t);return t.length<2&&t.push(t[0].slice()),t}function s(e){for(var t=a(e);t.length<4;)t.push(t[0].slice());return t}function l(e){return e.map(s)}function u(e){var t,r=e.type;switch(r){case"GeometryCollection":return {type:r,geometries:e.geometries.map(u)};case"Point":t=o(e.coordinates);break;case"MultiPoint":t=e.coordinates.map(o);break;case"LineString":t=a(e.arcs);break;case"MultiLineString":t=e.arcs.map(a);break;case"Polygon":t=l(e.arcs);break;case"MultiPolygon":t=e.arcs.map(l);break;default:return null}return {type:r,coordinates:t}}return u(t)}(e,t);return null==r&&null==n?{type:"Feature",properties:i,geometry:o}:null==n?{type:"Feature",id:r,properties:i,geometry:o}:{type:"Feature",id:r,bbox:n,properties:i,geometry:o}}function Ko(e,t,r){return t=Me(t),Pe(e,$o()?Reflect.construct(t,r||[],Me(e).constructor):t.apply(e,r))}function $o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return ($o=function(){return !!e})()}He.register("GeoJSON",(function(e){return Wo.urlHasTilePattern(e.url)?Wo:Ho}));var Qo=function(e){function t(){return u(this,t),Ko(this,t,arguments)}return Se(t,e),h(t,[{key:"parseSourceData",value:function(e,r,n){var i="string"==typeof n?JSON.parse(n):n;i=this.toGeoJSON(i);var o,a,s,l=this.getLayers(i);(o="preprocessLayers",a=this,"function"==typeof(s=ze(Me(t.prototype),o,a))?function(e){return s.apply(a,e)}:s)([l,e]),r.layers=l;}},{key:"toGeoJSON",value:function(e){if(e.objects&&1===Object.keys(e.objects).length){var t=Object.keys(e.objects)[0];e=ea(e,e.objects[t]);}else {var r={};for(var n in e.objects)r[n]=ea(e,e.objects[n]);e=r;}return e}}])}(Ho);function ea(e,t){var r=function(e,t){return "GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map((function(t){return Jo(e,t)}))}:Jo(e,t)}(e,t);return "Feature"===r.type&&(r={type:"FeatureCollection",features:[r]}),r}var ta=function(e){function t(e,r){return u(this,t),Ko(this,t,[e,r])}return Se(t,e),h(t,[{key:"parseSourceData",value:function(e,t,r){var n="string"==typeof r?JSON.parse(r):r;n=Qo.prototype.toGeoJSON(n),this.prepareGeoJSON(n,e,t);}}])}(Wo);He.register("TopoJSON",(function(e){return ta.urlHasTilePattern(e.url)?ta:Qo})),e.Collision=mr,e.DataSource=He,e.FeatureSelection=Ae,e.FilterOptions=Ni,e.FontManager=Sr,e.GLSL=j,e.Geo=Q,e.Label=fr,e.LabelLineStraight=Zn,e.LabelPoint=yr,e.Light=Fe,e.Material=Re,e.OBB=hr,e.ShaderProgram=Z,e.Style=nt,e.StyleManager=ai,e.StyleParser=ue,e.Task=L,e.TextCanvas=Jr,e.Texture=D,e.Thread=i,e.Tile=ji,e.TileID=Je,e.Utils=M,e.Vector=Ne,e.VertexArrayObject=K,e.VertexData=ut,e.VertexElements=st,e.View=jn,e.WorkerBroker=v,e._classCallCheck=u,e._createClass=h,e._defineProperty=s,e._get=ze,e._getPrototypeOf=Me,e._inherits=Se,e._possibleConstructorReturn=Pe,e._slicedToArray=n,e._toConsumableArray=l,e._typeof=o,e.addBaseURL=function(e,t){if(!e||!N(e))return e;var r,n="/"!==e[0];if(t?(r=document.createElement("a")).href=t:r=window.location,n){e=S(r.href)+e;}else {var i=r.origin;i||(i=r.protocol+"//"+r.host),e=i+e;}return e},e.buildFilter=Ai,e.cache=ne,e.clearFunctionStringCache=function(){ne.functions={},ne.num_functions=0,ne.num_cached=0;},e.compileFunctionStrings=ie,e.createObjectURL=function(e){return void 0===z&&"function"!=typeof(z=window.URL&&window.URL.createObjectURL||window.webkitURL&&window.webkitURL.createObjectURL)&&(z=null,k("warn","window.URL.createObjectURL (or vendor prefix) not found, unable to create local blob URLs")),z?z(e):e},e.debugSettings=P,e.debugSumLayerStats=function(e){var t={},r={};return e.filter((function(e){return e.debug.layers})).forEach((function(e){Object.keys(e.debug.layers.list).forEach((function(r){var n=e.debug.layers.list[r];it(t,r,n.features,n.geoms,n.styles,n.base);})),Ci(e.debug.layers.tree,r);})),{list:t,tree:r}},e.extensionForURL=function(e){var t=(e=e.split("/").pop()).lastIndexOf(".");if(t>-1)return e.substring(t+1)},e.flattenRelativeURL=function(e){for(var t=(e||"").split("/"),r=1;r<t.length;r++)"."===t[r]?(t.splice(r,1),r--):".."===t[r]&&(r+=0,t.splice(r-1,2),r--);return t.join("/")},e.getAugmentedNamespace=function(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype;}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}});})),r},e.getDefaultExportFromCjs=q,e.isLocalURL=function(e){if("string"==typeof e)return e.search(/^(data|blob):/)>-1},e.isRelativeURL=N,e.isReserved=Oi,e.layerCache=function(){return ki},e.log=k,e.mergeDebugSettings=function(e){Object.assign(R,e);},e.mergeObjects=$,e.parseLayers=function(e,t){ki={};var r={};for(var n in e){var i=e[n];i&&(r[n]=Li(n,i,null,t));}return r},e.pathForURL=S,e.sliceObject=F,e.subscribeMixin=I,e.version=d;}));

define(["./shared"],(function(e){"use strict";var t=Object.assign(self,{FeatureSelection:e.FeatureSelection,sources:{},styles:{},layers:{},tiles:{},init:function(t,r,i,o,s,n,a){return this.scene_id=t,this._worker_id=r,this.num_workers=i,e.log.setLevel(o),e.Utils.device_pixel_ratio=s,e.VertexElements.setElementIndexUint(n),e.FeatureSelection.setPrefix(this._worker_id),this.style_manager=new e.StyleManager,this.importExternalScripts(a),e.Label.id_prefix=r,e.Label.id_multiplier=i,r},importExternalScripts:function(t){var r=this;if(0!==t.length){e.log("debug","loading custom data source scripts in worker:",t);var i=Object.getOwnPropertyNames(window);importScripts.apply(void 0,e._toConsumableArray(t)),Object.getOwnPropertyNames(window).forEach((function(e){-1===i.indexOf(e)&&(r[e]=window[e]);}));}},updateConfig:function(t,r){var i=t.config,o=t.generation,s=t.introspection;return i=JSON.parse(i),e.mergeDebugSettings(r),this.generation=o,this.introspection=s,this.global=e.compileFunctionStrings(i.global),this.createDataSources(i),i.styles=e.compileFunctionStrings(i.styles,e.StyleParser.wrapFunction),this.styles=this.style_manager.build(i.styles),this.style_manager.initStyles({generation:this.generation,styles:this.styles,sources:this.sources,introspection:this.introspection}),this.layers=e.parseLayers(i.layers,this.style_manager.styles),this.syncing_textures=this.syncTextures(i.textures),this.configuring=this.syncing_textures.then((function(){e.log("debug","updated config");})),this.configuring},createDataSources:function(t){var r=this;this.last_config_sources=this.config_sources||{},this.config_sources=e.mergeObjects({},t.sources);var i=this.sources,o=[];for(var s in this.sources={},t.sources)if(JSON.stringify(this.last_config_sources[s])!==JSON.stringify(t.sources[s])){t.sources[s]=e.compileFunctionStrings(t.sources[s]);var n=void 0;try{n=e.DataSource.create(Object.assign({},t.sources[s],{name:s}),this.sources);}catch(e){continue}n&&(this.sources[s]=n,o.push(s));}else this.sources[s]=i[s];o.forEach((function(e){for(var t in r.tiles)r.tiles[t].source===e&&delete r.tiles[t];}));},awaitConfiguration:function(){return this.configuring},buildTile:function(t){var r=this,i=t.tile;if(null==this.getTile(i.key)||!0!==this.getTile(i.key).loading)return i=this.tiles[i.key]=Object.assign(this.getTile(i.key)||{},i),this.awaitConfiguration().then((function(){if(!0!==i.loaded)i.loading=!0,i.loaded=!1,i.error=null,r.loadTileSourceData(i).then((function(){r.getTile(i.key)?(i.source_data.error&&e.log("warn","tile load error(s) for ".concat(i.key,": ").concat(i.source_data.error)),i.loading=!1,i.loaded=!0,e.Tile.buildGeometry(i,r)):e.log("trace","stop tile build after data source load because tile was removed: ".concat(i.key));})).catch((function(t){i.loading=!1,i.loaded=!1,i.error=t.stack,e.log("error","tile load error for ".concat(i.key,": ").concat(i.error)),e.WorkerBroker.postMessage("TileManager_".concat(r.scene_id,".buildTileError"),e.Tile.slice(i));}));else {e.log("trace","used worker cache for tile ".concat(i.key));try{e.Tile.buildGeometry(i,r);}catch(t){i.error=t.toString(),e.WorkerBroker.postMessage("TileManager_".concat(r.scene_id,".buildTileError"),e.Tile.slice(i));}}}))},loadTileSourceData:function(e){var t=this.sources[e.source];if(t){for(var r in this.tiles){var i=this.tiles[r];if(i.source===e.source&&i.coords.key===e.coords.key&&i.loaded)return Promise.resolve(t.copyTileData(i,e))}return t.load(e)}return e.source_data={},Promise.resolve(e)},getTile:function(e){return this.tiles[e]},removeTile:function(t){var r=this.tiles[t];null!=r&&(!0===r.loading&&(e.log("trace","cancel tile load for ".concat(t)),r.loading=!1,e.Tile.cancel(r)),e.FeatureSelection.clearTile(t),delete this.tiles[t],e.log("trace","remove tile from cache for ".concat(t)));},queryFeatures:function(t){var r=this,i=t.filter,o=t.visible,s=t.geometry,n=t.tile_keys,a=[],c=n.map((function(e){return r.tiles[e]})).filter((function(e){return e&&e.loaded}));return null!=i&&(i=["{","["].indexOf(i[0])>-1?JSON.parse(i):i,i=e.compileFunctionStrings(i,e.StyleParser.wrapFunction)),i=e.buildFilter(i,e.FilterOptions),c.forEach((function(t){var n,c=function(n){var c=t.source_data.layers[n];if(null==c)return {v:void 0};c.features.forEach((function(c){var l=c.generation===r.generation;if(!(!0===o&&!l||!1===o&&l)){var u=e.StyleParser.getFeatureParseContext(c,t,r.global);if(u.source=t.source,u.layer=n,u.id=c.id,i(u)){var g={type:c.type,id:c.id,properties:Object.assign({},c.properties,{$source:u.source,$layer:u.layer,$geometry:u.geometry,$visible:l})};!0===s&&(g.geometry=e.Geo.copyGeometry(c.geometry),e.Geo.tileSpaceToLatlng(g.geometry,t.coords.z,t.min)),a.push(g);}}}));};for(var l in t.source_data.layers)if(n=c(l))return n.v})),a},getFeatureSelection:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.id,i=t.key,o=e.FeatureSelection.map[i];return {id:r,feature:o&&o.feature}},resetFeatureSelection:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e.FeatureSelection.reset(t);},getFeatureSelectionMapSize:function(){return e.FeatureSelection.getMapSize()},syncTextures:function(t){var r=[];return t&&r.push.apply(r,e._toConsumableArray(Object.keys(t))),e.log("trace","sync textures to worker:",r),r.length>0?e.Texture.syncTexturesToWorker(r):Promise.resolve()},updateDevicePixelRatio:function(t){e.Utils.device_pixel_ratio=t;},clearFunctionStringCache:function(){e.clearFunctionStringCache();},profile:function(e){console.profile("worker ".concat(this._worker_id,": ").concat(e));},profileEnd:function(e){console.profileEnd("worker ".concat(this._worker_id,": ").concat(e));},debug:{debugSettings:e.debugSettings,layerCache:e.layerCache,functionStringCache:e.cache}});e.WorkerBroker.addTarget("self",t);}));

define(["./shared"],(function(e){"use strict";var t,r=t={},n=0;function i(e,t){var r,n=t[t.length-1];return null===(r=s(e,t))||void 0===r?void 0:r[n]}function o(e,t,r){var n=t[t.length-1],i=s(e,t);i&&(i[n]=r);}function s(e,t){if(0!==t.length){for(var r=e,n=0;n<t.length-1;n++){if(null==(r=r[t[n]]))return}return r}}t.getContext=function(e,r){var i=!1;null==e&&((e=document.createElement("canvas")).style.position="absolute",e.style.top=0,e.style.left=0,e.style.zIndex=-1,document.body.appendChild(e),i=!0),e.addEventListener("webglcontextlost",(function(){})),e.addEventListener("webglcontextrestored",(function(){}));var o=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);if(!o)throw new Error("Couldn't create WebGL context.");return o._tangram_id=n++,i?(t.resize(o,window.innerWidth,window.innerHeight,r.device_pixel_ratio),window.addEventListener("resize",(function(){t.resize(o,window.innerWidth,window.innerHeight,r.device_pixel_ratio);}))):t.resize(o,parseFloat(e.style.width),parseFloat(e.style.height),r.device_pixel_ratio),o},t.resize=function(e,t,r,n){n=n||window.devicePixelRatio||1,e.canvas.style.width=t+"px",e.canvas.style.height=r+"px",e.canvas.width=Math.round(t*n),e.canvas.height=Math.round(r*n),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,e.canvas.width,e.canvas.height);};var a="global.",l="__global_prop";function u(e){return (null==e?void 0:e.slice(0,7))===a}function c(e,t){var r,n=Array.isArray(t)?t:[t],i=s(e,n),o=n[n.length-1];return void 0!==(null==i||null===(r=i[l])||void 0===r?void 0:r[o])}function h(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(var i in r=r?r+".":a,t){var o=r+i,s=t[i];n[o]=s,"object"!==e._typeof(s)||Array.isArray(s)||h(s,o,n);}return n}function f(t,r,n,i){var o,s;if(null!=n&&null!==(o=n[l])&&void 0!==o&&o[i]?s=n[l][i]:"string"==typeof r&&r.slice(0,7)===a&&(s=r),s){null==n[l]&&Object.defineProperty(n,l,{value:{}}),n[l][i]=s;for(var u,c=t[s];"string"==typeof c&&c.slice(0,7)===a;){if((u=u||[s]).indexOf(c)>-1){e.log({level:"warn",once:!0},"Global properties: cyclical reference detected",u),c=null;break}u.push(c),c=t[c];}Object.defineProperty(n,i,{enumerable:!0,get:function(){return c},set:function(e){delete n[l][i],delete n[i],n[i]=e;}});}else if(Array.isArray(r))for(var h=0;h<r.length;h++)f(t,r[h],r,h);else if("object"===e._typeof(r))for(var d in r)f(t,r[d],r,d);return r}var d="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},p=[],g=[],m="undefined"!=typeof Uint8Array?Uint8Array:Array,v=!1;function _(){v=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)p[t]=e[t],g[e.charCodeAt(t)]=t;g["-".charCodeAt(0)]=62,g["_".charCodeAt(0)]=63;}function y(e,t,r){for(var n,i,o=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(p[(i=n)>>18&63]+p[i>>12&63]+p[i>>6&63]+p[63&i]);return o.join("")}function b(e){var t;v||_();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,l=r-n;a<l;a+=s)o.push(y(e,a,a+s>l?l:a+s));return 1===n?(t=e[r-1],i+=p[t>>2],i+=p[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=p[t>>10],i+=p[t>>4&63],i+=p[t<<2&63],i+="="),o.push(i),o.join("")}function w(e,t,r,n,i){var o,s,a=8*i-n-1,l=(1<<a)-1,u=l>>1,c=-7,h=r?i-1:0,f=r?-1:1,d=e[t+h];for(h+=f,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+e[t+h],h+=f,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+h],h+=f,c-=8);if(0===o)o=1-u;else {if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u;}return (d?-1:1)*s*Math.pow(2,o-n)}function k(e,t,r,n,i,o){var s,a,l,u=8*o-i-1,c=(1<<u)-1,h=c>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(t*l-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+d]=255&s,d+=p,s/=256,u-=8);e[r+d-p]|=128*g;}var x={}.toString,S=Array.isArray||function(e){return "[object Array]"==x.call(e)};T.TYPED_ARRAY_SUPPORT=void 0===d.TYPED_ARRAY_SUPPORT||d.TYPED_ARRAY_SUPPORT;var A=C();function C(){return T.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function E(e,t){if(C()<t)throw new RangeError("Invalid typed array length");return T.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=T.prototype:(null===e&&(e=new T(t)),e.length=t),e}function T(e,t,r){if(!(T.TYPED_ARRAY_SUPPORT||this instanceof T))return new T(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return R(this,e)}return z(this,e,t,r)}function z(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return "undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);T.TYPED_ARRAY_SUPPORT?(e=t).__proto__=T.prototype:e=I(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!T.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|B(t,r);e=E(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(P(t)){var r=0|F(t.length);return 0===(e=E(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return "number"!=typeof t.length||(n=t.length)!=n?E(e,0):I(e,t);if("Buffer"===t.type&&S(t.data))return I(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function O(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function R(e,t){if(O(t),e=E(e,t<0?0:0|F(t)),!T.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function I(e,t){var r=t.length<0?0:0|F(t.length);e=E(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function F(e){if(e>=C())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C().toString(16)+" bytes");return 0|e}function P(e){return !(null==e||!e._isBuffer)}function B(e,t){if(P(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return le(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ue(e).length;default:if(n)return le(e).length;t=(""+t).toLowerCase(),n=!0;}}function L(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(t>>>=0))return "";for(e||(e="utf8");;)switch(e){case"hex":return X(this,t,r);case"utf8":case"utf-8":return G(this,t,r);case"ascii":return K(this,t,r);case"latin1":case"binary":return J(this,t,r);case"base64":return V(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0;}}function D(e,t,r){var n=e[t];e[t]=e[r],e[r]=n;}function U(e,t,r,n,i){if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return -1;r=e.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof t&&(t=T.from(t,n)),P(t))return 0===t.length?-1:N(e,t,r,n,i);if("number"==typeof t)return t&=255,T.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):N(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function N(e,t,r,n,i){var o,s=1,a=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;s=2,a/=2,l/=2,r/=2;}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===l)return c*s}else -1!==c&&(o-=o-c),c=-1;}else for(r+l>a&&(r=a-l),o=r;o>=0;o--){for(var h=!0,f=0;f<l;f++)if(u(e,o+f)!==u(t,f)){h=!1;break}if(h)return o}return -1}function j(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a;}return s}function M(e,t,r,n){return ce(le(t,e.length-r),e,r,n)}function Z(e,t,r,n){return ce(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function W(e,t,r,n){return Z(e,t,r,n)}function Y(e,t,r,n){return ce(ue(t),e,r,n)}function q(e,t,r,n){return ce(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function V(e,t,r){return 0===t&&r===e.length?b(e):b(e.slice(t,r))}function G(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(o=e[i+1]))&&(l=(31&u)<<6|63&o)>127&&(c=l);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(l=(15&u)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(c=l);}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h;}return function(e){var t=e.length;if(t<=H)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=H));return r}(n)}T.poolSize=8192,T._augment=function(e){return e.__proto__=T.prototype,e},T.from=function(e,t,r){return z(null,e,t,r)},T.TYPED_ARRAY_SUPPORT&&(T.prototype.__proto__=Uint8Array.prototype,T.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&T[Symbol.species]),T.alloc=function(e,t,r){return function(e,t,r,n){return O(t),t<=0?E(e,t):void 0!==r?"string"==typeof n?E(e,t).fill(r,n):E(e,t).fill(r):E(e,t)}(null,e,t,r)},T.allocUnsafe=function(e){return R(null,e)},T.allocUnsafeSlow=function(e){return R(null,e)},T.isBuffer=he,T.compare=function(e,t){if(!P(e)||!P(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},T.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},T.concat=function(e,t){if(!S(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return T.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=T.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!P(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length;}return n},T.byteLength=B,T.prototype._isBuffer=!0,T.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)D(this,t,t+1);return this},T.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)D(this,t,t+3),D(this,t+1,t+2);return this},T.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)D(this,t,t+7),D(this,t+1,t+6),D(this,t+2,t+5),D(this,t+3,t+4);return this},T.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?G(this,0,e):L.apply(this,arguments)},T.prototype.equals=function(e){if(!P(e))throw new TypeError("Argument must be a Buffer");return this===e||0===T.compare(this,e)},T.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},T.prototype.compare=function(e,t,r,n,i){if(!P(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),l=this.slice(n,i),u=e.slice(t,r),c=0;c<a;++c)if(l[c]!==u[c]){o=l[c],s=u[c];break}return o<s?-1:s<o?1:0},T.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},T.prototype.indexOf=function(e,t,r){return U(this,e,t,r,!0)},T.prototype.lastIndexOf=function(e,t,r){return U(this,e,t,r,!1)},T.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else {if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return j(this,e,t,r);case"utf8":case"utf-8":return M(this,e,t,r);case"ascii":return Z(this,e,t,r);case"latin1":case"binary":return W(this,e,t,r);case"base64":return Y(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0;}},T.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var H=4096;function K(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function J(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function X(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=ae(e[o]);return i}function $(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function Q(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function ee(e,t,r,n,i,o){if(!P(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function te(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i);}function re(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255;}function ne(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ie(e,t,r,n,i){return i||ne(e,0,r,4),k(e,t,r,n,23,4),r+4}function oe(e,t,r,n,i){return i||ne(e,0,r,8),k(e,t,r,n,52,8),r+8}T.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),T.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=T.prototype;else {var i=t-e;r=new T(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e];}return r},T.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||Q(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},T.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||Q(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},T.prototype.readUInt8=function(e,t){return t||Q(e,1,this.length),this[e]},T.prototype.readUInt16LE=function(e,t){return t||Q(e,2,this.length),this[e]|this[e+1]<<8},T.prototype.readUInt16BE=function(e,t){return t||Q(e,2,this.length),this[e]<<8|this[e+1]},T.prototype.readUInt32LE=function(e,t){return t||Q(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},T.prototype.readUInt32BE=function(e,t){return t||Q(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},T.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Q(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},T.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Q(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},T.prototype.readInt8=function(e,t){return t||Q(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},T.prototype.readInt16LE=function(e,t){t||Q(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},T.prototype.readInt16BE=function(e,t){t||Q(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},T.prototype.readInt32LE=function(e,t){return t||Q(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},T.prototype.readInt32BE=function(e,t){return t||Q(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},T.prototype.readFloatLE=function(e,t){return t||Q(e,4,this.length),w(this,e,!0,23,4)},T.prototype.readFloatBE=function(e,t){return t||Q(e,4,this.length),w(this,e,!1,23,4)},T.prototype.readDoubleLE=function(e,t){return t||Q(e,8,this.length),w(this,e,!0,52,8)},T.prototype.readDoubleBE=function(e,t){return t||Q(e,8,this.length),w(this,e,!1,52,8)},T.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ee(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},T.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ee(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},T.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,1,255,0),T.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},T.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,2,65535,0),T.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},T.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,2,65535,0),T.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},T.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,4,4294967295,0),T.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):re(this,e,t,!0),t+4},T.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,4,4294967295,0),T.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):re(this,e,t,!1),t+4},T.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ee(this,e,t,r,i-1,-i);}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},T.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ee(this,e,t,r,i-1,-i);}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},T.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,1,127,-128),T.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},T.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,2,32767,-32768),T.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},T.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,2,32767,-32768),T.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},T.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,4,2147483647,-2147483648),T.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):re(this,e,t,!0),t+4},T.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ee(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),T.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):re(this,e,t,!1),t+4},T.prototype.writeFloatLE=function(e,t,r){return ie(this,e,t,!0,r)},T.prototype.writeFloatBE=function(e,t,r){return ie(this,e,t,!1,r)},T.prototype.writeDoubleLE=function(e,t,r){return oe(this,e,t,!0,r)},T.prototype.writeDoubleBE=function(e,t,r){return oe(this,e,t,!1,r)},T.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!T.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},T.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i);}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!T.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else "number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else {var s=P(e)?e:le(new T(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a];}return this};var se=/[^+\/0-9A-Za-z-_]/g;function ae(e){return e<16?"0"+e.toString(16):e.toString(16)}function le(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r);}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function ue(e){return function(e){var t,r,n,i,o,s;v||_();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new m(3*a/4-o),n=o>0?a-4:a;var l=0;for(t=0,r=0;t<n;t+=4,r+=3)i=g[e.charCodeAt(t)]<<18|g[e.charCodeAt(t+1)]<<12|g[e.charCodeAt(t+2)]<<6|g[e.charCodeAt(t+3)],s[l++]=i>>16&255,s[l++]=i>>8&255,s[l++]=255&i;return 2===o?(i=g[e.charCodeAt(t)]<<2|g[e.charCodeAt(t+1)]>>4,s[l++]=255&i):1===o&&(i=g[e.charCodeAt(t)]<<10|g[e.charCodeAt(t+1)]<<4|g[e.charCodeAt(t+2)]>>2,s[l++]=i>>8&255,s[l++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(se,"")).length<2)return "";for(;e.length%4!=0;)e+="=";return e}(e))}function ce(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function he(e){return null!=e&&(!!e._isBuffer||fe(e)||function(e){return "function"==typeof e.readFloatLE&&"function"==typeof e.slice&&fe(e.slice(0,0))}(e))}function fe(e){return !!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var de=Object.freeze({__proto__:null,Buffer:T,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return +e!=e&&(e=0),T.alloc(+e)},isBuffer:he,kMaxLength:A});function pe(){throw new Error("setTimeout has not been defined")}function ge(){throw new Error("clearTimeout has not been defined")}var me=pe,ve=ge;function _e(e){if(me===setTimeout)return setTimeout(e,0);if((me===pe||!me)&&setTimeout)return me=setTimeout,setTimeout(e,0);try{return me(e,0)}catch(t){try{return me.call(null,e,0)}catch(t){return me.call(this,e,0)}}}"function"==typeof d.setTimeout&&(me=setTimeout),"function"==typeof d.clearTimeout&&(ve=clearTimeout);var ye,be=[],we=!1,ke=-1;function xe(){we&&ye&&(we=!1,ye.length?be=ye.concat(be):ke=-1,be.length&&Se());}function Se(){if(!we){var e=_e(xe);we=!0;for(var t=be.length;t;){for(ye=be,be=[];++ke<t;)ye&&ye[ke].run();ke=-1,t=be.length;}ye=null,we=!1,function(e){if(ve===clearTimeout)return clearTimeout(e);if((ve===ge||!ve)&&clearTimeout)return ve=clearTimeout,clearTimeout(e);try{return ve(e)}catch(t){try{return ve.call(null,e)}catch(t){return ve.call(this,e)}}}(e);}}function Ae(e,t){this.fun=e,this.array=t;}Ae.prototype.run=function(){this.fun.apply(null,this.array);};var Ce=d.performance||{};function Ee(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}Ce.now||Ce.mozNow||Ce.msNow||Ce.oNow||Ce.webkitNow;var Te,ze={exports:{}};var Oe,Re,Ie,Fe,Pe,Be,Le,De,Ue,Ne,je,Me,Ze,We,Ye,qe,Ve,Ge,He,Ke,Je,Xe,$e,Qe,et,tt,rt,nt,it,ot,st,at,lt,ut=(Te||(Te=1,ze.exports=function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){if(!a&&Ee)return Ee(s);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,r,n);}return r[s].exports}for(var o=Ee,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){var n=e("./utils"),i=e("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(e){for(var t,r,i,s,a,l,u,c=[],h=0,f=e.length,d=f,p="string"!==n.getTypeOf(e);h<e.length;)d=f-h,i=p?(t=e[h++],r=h<f?e[h++]:0,h<f?e[h++]:0):(t=e.charCodeAt(h++),r=h<f?e.charCodeAt(h++):0,h<f?e.charCodeAt(h++):0),s=t>>2,a=(3&t)<<4|r>>4,l=1<d?(15&r)<<2|i>>6:64,u=2<d?63&i:64,c.push(o.charAt(s)+o.charAt(a)+o.charAt(l)+o.charAt(u));return c.join("")},r.decode=function(e){var t,r,n,s,a,l,u=0,c=0,h="data:";if(e.substr(0,h.length)===h)throw new Error("Invalid base64 input, it looks like a data url.");var f,d=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===o.charAt(64)&&d--,e.charAt(e.length-2)===o.charAt(64)&&d--,d%1!=0)throw new Error("Invalid base64 input, bad content length.");for(f=i.uint8array?new Uint8Array(0|d):new Array(0|d);u<e.length;)t=o.indexOf(e.charAt(u++))<<2|(s=o.indexOf(e.charAt(u++)))>>4,r=(15&s)<<4|(a=o.indexOf(e.charAt(u++)))>>2,n=(3&a)<<6|(l=o.indexOf(e.charAt(u++))),f[c++]=t,64!==a&&(f[c++]=r),64!==l&&(f[c++]=n);return f};},{"./support":30,"./utils":32}],2:[function(e,t,r){var n=e("./external"),i=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),s=e("./stream/DataLengthProbe");function a(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i;}a.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,r){return e.pipe(new o).pipe(new s("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new s("compressedSize")).withStreamInfo("compression",t)},t.exports=a;},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate");},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){var n=e("./utils"),i=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e;}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r,n){var o=i,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^o[255&(e^t[a])];return ~e}(0|t,e,e.length,0):function(e,t,r,n){var o=i,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^o[255&(e^t.charCodeAt(a))];return ~e}(0|t,e,e.length,0):0};},{"./utils":32}],5:[function(e,t,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null;},{}],6:[function(e,t,r){var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n};},{lie:37}],7:[function(e,t,r){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),o=e("./utils"),s=e("./stream/GenericWorker"),a=n?"uint8array":"array";function l(e,t){s.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={};}r.magic="\b\0",o.inherits(l,s),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(a,e.data),!1);},l.prototype.flush=function(){s.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0);},l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null;},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta});};},r.compressWorker=function(e){return new l("Deflate",e)},r.uncompressWorker=function(){return new l("Inflate",{})};},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){function n(e,t){var r,n="";for(r=0;r<t;r++)n+=String.fromCharCode(255&e),e>>>=8;return n}function i(e,t,r,i,s,c){var h,f,d=e.file,p=e.compression,g=c!==a.utf8encode,m=o.transformTo("string",c(d.name)),v=o.transformTo("string",a.utf8encode(d.name)),_=d.comment,y=o.transformTo("string",c(_)),b=o.transformTo("string",a.utf8encode(_)),w=v.length!==d.name.length,k=b.length!==_.length,x="",S="",A="",C=d.dir,E=d.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var z=0;t&&(z|=8),g||!w&&!k||(z|=2048);var O=0,R=0;C&&(O|=16),"UNIX"===s?(R=798,O|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(d.unixPermissions,C)):(R=20,O|=function(e){return 63&(e||0)}(d.dosPermissions)),h=E.getUTCHours(),h<<=6,h|=E.getUTCMinutes(),h<<=5,h|=E.getUTCSeconds()/2,f=E.getUTCFullYear()-1980,f<<=4,f|=E.getUTCMonth()+1,f<<=5,f|=E.getUTCDate(),w&&(S=n(1,1)+n(l(m),4)+v,x+="up"+n(S.length,2)+S),k&&(A=n(1,1)+n(l(y),4)+b,x+="uc"+n(A.length,2)+A);var I="";return I+="\n\0",I+=n(z,2),I+=p.magic,I+=n(h,2),I+=n(f,2),I+=n(T.crc32,4),I+=n(T.compressedSize,4),I+=n(T.uncompressedSize,4),I+=n(m.length,2),I+=n(x.length,2),{fileRecord:u.LOCAL_FILE_HEADER+I+m+x,dirRecord:u.CENTRAL_FILE_HEADER+n(R,2)+I+n(y.length,2)+"\0\0\0\0"+n(O,4)+n(i,4)+m+x+y}}var o=e("../utils"),s=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),u=e("../signature");function c(e,t,r,n){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[];}o.inherits(c,s),c.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,s.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}));},c.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}});}else this.accumulate=!0;},c.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return u.DATA_DESCRIPTOR+n(e.crc32,4)+n(e.compressedSize,4)+n(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null;},c.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r=this.bytesWritten-e,i=function(e,t,r,i,s){var a=o.transformTo("string",s(i));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(e,2)+n(e,2)+n(t,4)+n(r,4)+n(a.length,2)+a}(this.dirRecords.length,r,e,this.zipComment,this.encodeFileName);this.push({data:i,meta:{percent:100}});},c.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume();},c.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",(function(e){t.processChunk(e);})),e.on("end",(function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end();})),e.on("error",(function(e){t.error(e);})),this},c.prototype.resume=function(){return !!s.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},c.prototype.error=function(e){var t=this._sources;if(!s.prototype.error.call(this,e))return !1;for(var r=0;r<t.length;r++)try{t[r].error(e);}catch(e){}return !0},c.prototype.lock=function(){s.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock();},t.exports=c;},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,r){var n=e("../compressions"),i=e("./ZipFileWorker");r.generateWorker=function(e,t,r){var o=new i(t.streamFiles,r,t.platform,t.encodeFileName),s=0;try{e.forEach((function(e,r){s++;var i=function(e,t){var r=e||t,i=n[r];if(!i)throw new Error(r+" is not a valid compression method !");return i}(r.options.compression,t.compression),a=r.options.compressionOptions||t.compressionOptions||{},l=r.dir,u=r.date;r._compressWorker(i,a).withStreamInfo("file",{name:e,dir:l,date:u,comment:r.comment||"",unixPermissions:r.unixPermissions,dosPermissions:r.dosPermissions}).pipe(o);})),o.entriesCount=s;}catch(e){o.error(e);}return o};},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,r){function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new n;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e};}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.10.1",n.loadAsync=function(e,t){return (new n).loadAsync(e,t)},n.external=e("./external"),t.exports=n;},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,r){var n=e("./utils"),i=e("./external"),o=e("./utf8"),s=e("./zipEntries"),a=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function u(e){return new i.Promise((function(t,r){var n=e.decompressed.getContentWorker().pipe(new a);n.on("error",(function(e){r(e);})).on("end",(function(){n.streamInfo.crc32!==e.decompressed.crc32?r(new Error("Corrupted zip : CRC32 mismatch")):t();})).resume();}))}t.exports=function(e,t){var r=this;return t=n.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),l.isNode&&l.isStream(e)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then((function(e){var r=new s(t);return r.load(e),r})).then((function(e){var r=[i.Promise.resolve(e)],n=e.files;if(t.checkCRC32)for(var o=0;o<n.length;o++)r.push(u(n[o]));return i.Promise.all(r)})).then((function(e){for(var i=e.shift(),o=i.files,s=0;s<o.length;s++){var a=o[s],l=a.fileNameStr,u=n.resolve(a.fileNameStr);r.file(u,a.decompressed,{binary:!0,optimizedBinaryString:!0,date:a.date,dir:a.dir,comment:a.fileCommentStr.length?a.fileCommentStr:null,unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions,createFolders:t.createFolders}),a.dir||(r.file(u).unsafeOriginalName=l);}return i.zipComment.length&&(r.comment=i.zipComment),r}))};},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,r){var n=e("../utils"),i=e("../stream/GenericWorker");function o(e,t){i.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t);}n.inherits(o,i),o.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",(function(e){t.push({data:e,meta:{percent:0}});})).on("error",(function(e){t.isPaused?this.generatedError=e:t.error(e);})).on("end",(function(){t.isPaused?t._upstreamEnded=!0:t.end();}));},o.prototype.pause=function(){return !!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return !!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=o;},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,r){var n=e("readable-stream").Readable;function i(e,t,r){n.call(this,t),this._helper=e;var i=this;e.on("data",(function(e,t){i.push(e)||i._helper.pause(),r&&r(t);})).on("error",(function(e){i.emit("error",e);})).on("end",(function(){i.push(null);}));}e("../utils").inherits(i,n),i.prototype._read=function(){this._helper.resume();},t.exports=i;},{"../utils":32,"readable-stream":16}],14:[function(e,t,r){t.exports={isNode:void 0!==T,newBufferFrom:function(e,t){if(T.from&&T.from!==Uint8Array.from)return T.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new T(e,t)},allocBuffer:function(e){if(T.alloc)return T.alloc(e);var t=new T(e);return t.fill(0),t},isBuffer:function(e){return he(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}};},{}],15:[function(e,t,r){function n(e,t,r){var n,i=o.getTypeOf(t),a=o.extend(r||{},l);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(e=g(e)),a.createFolders&&(n=p(e))&&m.call(this,n,!0);var h="string"===i&&!1===a.binary&&!1===a.base64;r&&void 0!==r.binary||(a.binary=!h),(t instanceof u&&0===t.uncompressedSize||a.dir||!t||0===t.length)&&(a.base64=!1,a.binary=!0,t="",a.compression="STORE",i="string");var v=null;v=t instanceof u||t instanceof s?t:f.isNode&&f.isStream(t)?new d(e,t):o.prepareContent(e,t,a.binary,a.optimizedBinaryString,a.base64);var _=new c(e,v,a);this.files[e]=_;}var i=e("./utf8"),o=e("./utils"),s=e("./stream/GenericWorker"),a=e("./stream/StreamHelper"),l=e("./defaults"),u=e("./compressedObject"),c=e("./zipObject"),h=e("./generate"),f=e("./nodejsUtils"),d=e("./nodejs/NodejsStreamInputAdapter"),p=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},g=function(e){return "/"!==e.slice(-1)&&(e+="/"),e},m=function(e,t){return t=void 0!==t?t:l.createFolders,e=g(e),this.files[e]||n.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function v(e){return "[object RegExp]"===Object.prototype.toString.call(e)}var _={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)n=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,n);},filter:function(e){var t=[];return this.forEach((function(r,n){e(r,n)&&t.push(n);})),t},file:function(e,t,r){if(1!==arguments.length)return e=this.root+e,n.call(this,e,t,r),this;if(v(e)){var i=e;return this.filter((function(e,t){return !t.dir&&i.test(e)}))}var o=this.files[this.root+e];return o&&!o.dir?o:null},folder:function(e){if(!e)return this;if(v(e))return this.filter((function(t,r){return r.dir&&e.test(t)}));var t=this.root+e,r=m.call(this,t),n=this.clone();return n.root=r.name,n},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var r=this.filter((function(t,r){return r.name.slice(0,e.length)===e})),n=0;n<r.length;n++)delete this.files[r[n].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if((r=o.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");o.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";t=h.generateWorker(this,r,n);}catch(e){(t=new s("error")).error(e);}return new a(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return (e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=_;},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,r){t.exports=e("stream");},{stream:void 0}],17:[function(e,t,r){var n=e("./DataReader");function i(e){n.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t];}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data[this.zero+e]},i.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),o=this.length-4;0<=o;--o)if(this.data[o]===t&&this.data[o+1]===r&&this.data[o+2]===n&&this.data[o+3]===i)return o-this.zero;return -1},i.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),o=this.readData(4);return t===o[0]&&r===o[1]&&n===o[2]&&i===o[3]},i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return [];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i;},{"../utils":32,"./DataReader":18}],18:[function(e,t,r){var n=e("../utils");function i(e){this.data=e,this.length=e.length,this.index=0,this.zero=0;}i.prototype={checkOffset:function(e){this.checkIndex(this.index+e);},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e;},skip:function(e){this.setIndex(this.index+e);},byteAt:function(){},readInt:function(e){var t,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i;},{"../utils":32}],19:[function(e,t,r){var n=e("./Uint8ArrayReader");function i(e){n.call(this,e);}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i;},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){var n=e("./DataReader");function i(e){n.call(this,e);}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i;},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){var n=e("./ArrayReader");function i(e){n.call(this,e);}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i;},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){var n=e("../utils"),i=e("../support"),o=e("./ArrayReader"),s=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new l(n.transformTo("uint8array",e)):new o(n.transformTo("array",e)):new s(e)};},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b";},{}],24:[function(e,t,r){var n=e("./GenericWorker"),i=e("../utils");function o(e){n.call(this,"ConvertWorker to "+e),this.destType=e;}i.inherits(o,n),o.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta});},t.exports=o;},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){var n=e("./GenericWorker"),i=e("../crc32");function o(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0);}e("../utils").inherits(o,n),o.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e);},t.exports=o;},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){var n=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0);}n.inherits(o,i),o.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length;}i.prototype.processChunk.call(this,e);},t.exports=o;},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){var n=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat();}),(function(e){t.error(e);}));}n.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null;},o.prototype.resume=function(){return !!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0));},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return !1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t);}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o;},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null;}n.prototype={push:function(e){this.emit("data",e);},end:function(){if(this.isFinished)return !1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0;}catch(e){this.emit("error",e);}return !0},error:function(e){return !this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[];},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t);},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",(function(e){t.processChunk(e);})),e.on("end",(function(){t.end();})),e.on("error",(function(e){t.error(e);})),this},pause:function(){return !this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return !1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e);},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e]);},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock();},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=n;},{}],29:[function(e,t,r){var n=e("../utils"),i=e("./ConvertWorker"),o=e("./GenericWorker"),s=e("../base64"),a=e("../support"),l=e("../external"),u=null;if(a.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter");}catch(e){}function c(e,t){return new l.Promise((function(r,i){var o=[],a=e._internalType,l=e._outputType,u=e._mimeType;e.on("data",(function(e,r){o.push(e),t&&t(r);})).on("error",(function(e){o=[],i(e);})).on("end",(function(){try{var e=function(e,t,r){switch(e){case"blob":return n.newBlob(n.transformTo("arraybuffer",t),r);case"base64":return s.encode(t);default:return n.transformTo(e,t)}}(l,function(e,t){var r,n=0,i=null,o=0;for(r=0;r<t.length;r++)o+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(o),r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return T.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(a,o),u);r(e);}catch(e){i(e);}o=[];})).resume();}))}function h(e,t,r){var s=t;switch(t){case"blob":case"arraybuffer":s="uint8array";break;case"base64":s="string";}try{this._internalType=s,this._outputType=t,this._mimeType=r,n.checkSupport(s),this._worker=e.pipe(new i(s)),e.lock();}catch(e){this._worker=new o("error"),this._worker.error(e);}}h.prototype={accumulate:function(e){return c(this,e)},on:function(e,t){var r=this;return "data"===e?this._worker.on(e,(function(e){t.call(r,e.data,e.meta);})):this._worker.on(e,(function(){n.delay(t,arguments,r);})),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(n.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=h;},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer=void 0!==T,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else {var n=new ArrayBuffer(0);try{r.blob=0===new Blob([n],{type:"application/zip"}).size;}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(n),r.blob=0===i.getBlob("application/zip").size;}catch(e){r.blob=!1;}}}try{r.nodestream=!!e("readable-stream").Readable;}catch(e){r.nodestream=!1;}},{"readable-stream":16}],31:[function(e,t,r){for(var n=e("./utils"),i=e("./support"),o=e("./nodejsUtils"),s=e("./stream/GenericWorker"),a=new Array(256),l=0;l<256;l++)a[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function u(){s.call(this,"utf-8 decode"),this.leftOver=null;}function c(){s.call(this,"utf-8 encode");}a[254]=a[254]=1,r.utf8encode=function(e){return i.nodebuffer?o.newBufferFrom(e,"utf-8"):function(e){var t,r,n,o,s,a=e.length,l=0;for(o=0;o<a;o++)55296==(64512&(r=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(n=e.charCodeAt(o+1)))&&(r=65536+(r-55296<<10)+(n-56320),o++),l+=r<128?1:r<2048?2:r<65536?3:4;for(t=i.uint8array?new Uint8Array(l):new Array(l),o=s=0;s<l;o++)55296==(64512&(r=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(n=e.charCodeAt(o+1)))&&(r=65536+(r-55296<<10)+(n-56320),o++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},r.utf8decode=function(e){return i.nodebuffer?n.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,i,o,s=e.length,l=new Array(2*s);for(t=r=0;t<s;)if((i=e[t++])<128)l[r++]=i;else if(4<(o=a[i]))l[r++]=65533,t+=o-1;else {for(i&=2===o?31:3===o?15:7;1<o&&t<s;)i=i<<6|63&e[t++],o--;1<o?l[r++]=65533:i<65536?l[r++]=i:(i-=65536,l[r++]=55296|i>>10&1023,l[r++]=56320|1023&i);}return l.length!==r&&(l.subarray?l=l.subarray(0,r):l.length=r),n.applyFromCharCode(l)}(e=n.transformTo(i.uint8array?"uint8array":"array",e))},n.inherits(u,s),u.prototype.processChunk=function(e){var t=n.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var o=t;(t=new Uint8Array(o.length+this.leftOver.length)).set(this.leftOver,0),t.set(o,this.leftOver.length);}else t=this.leftOver.concat(t);this.leftOver=null;}var s=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0||0===r?t:r+a[e[r]]>t?r:t}(t),l=t;s!==t.length&&(i.uint8array?(l=t.subarray(0,s),this.leftOver=t.subarray(s,t.length)):(l=t.slice(0,s),this.leftOver=t.slice(s,t.length))),this.push({data:r.utf8decode(l),meta:e.meta});},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null);},r.Utf8DecodeWorker=u,n.inherits(c,s),c.prototype.processChunk=function(e){this.push({data:r.utf8encode(e.data),meta:e.meta});},r.Utf8EncodeWorker=c;},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,r){var n=e("./support"),i=e("./base64"),o=e("./nodejsUtils"),s=e("./external");function a(e){return e}function l(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e("setimmediate"),r.newBlob=function(e,t){r.checkSupport("blob");try{return new Blob([e],{type:t})}catch(r){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(e),n.getBlob(t)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(e,t,r){var n=[],i=0,o=e.length;if(o<=r)return String.fromCharCode.apply(null,e);for(;i<o;)"array"===t||"nodebuffer"===t?n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,o)))):n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,o)))),i+=r;return n.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return n.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return !1}}(),nodebuffer:function(){try{return n.nodebuffer&&1===String.fromCharCode.apply(null,o.allocBuffer(1)).length}catch(e){return !1}}()}};function c(e){var t=65536,n=r.getTypeOf(e),i=!0;if("uint8array"===n?i=u.applyCanBeUsed.uint8array:"nodebuffer"===n&&(i=u.applyCanBeUsed.nodebuffer),i)for(;1<t;)try{return u.stringifyByChunk(e,n,t)}catch(e){t=Math.floor(t/2);}return u.stringifyByChar(e)}function h(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}r.applyFromCharCode=c;var f={};f.string={string:a,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return f.string.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:function(e){return l(e,o.allocBuffer(e.length))}},f.array={string:c,array:a,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return o.newBufferFrom(e)}},f.arraybuffer={string:function(e){return c(new Uint8Array(e))},array:function(e){return h(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:a,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return o.newBufferFrom(new Uint8Array(e))}},f.uint8array={string:c,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:a,nodebuffer:function(e){return o.newBufferFrom(e)}},f.nodebuffer={string:c,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return f.nodebuffer.uint8array(e).buffer},uint8array:function(e){return h(e,new Uint8Array(e.length))},nodebuffer:a},r.transformTo=function(e,t){if(t=t||"",!e)return t;r.checkSupport(e);var n=r.getTypeOf(t);return f[n][e](t)},r.resolve=function(e){for(var t=e.split("/"),r=[],n=0;n<t.length;n++){var i=t[n];"."===i||""===i&&0!==n&&n!==t.length-1||(".."===i?r.pop():r.push(i));}return r.join("/")},r.getTypeOf=function(e){return "string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":n.nodebuffer&&o.isBuffer(e)?"nodebuffer":n.uint8array&&e instanceof Uint8Array?"uint8array":n.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(e){if(!n[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(e){var t,r,n="";for(r=0;r<(e||"").length;r++)n+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return n},r.delay=function(e,t,r){setImmediate((function(){e.apply(r||null,t||[]);}));},r.inherits=function(e,t){function r(){}r.prototype=t.prototype,e.prototype=new r;},r.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},r.prepareContent=function(e,t,o,a,u){return s.Promise.resolve(t).then((function(e){return n.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new s.Promise((function(t,r){var n=new FileReader;n.onload=function(e){t(e.target.result);},n.onerror=function(e){r(e.target.error);},n.readAsArrayBuffer(e);})):e})).then((function(t){var c=r.getTypeOf(t);return c?("arraybuffer"===c?t=r.transformTo("uint8array",t):"string"===c&&(u?t=i.decode(t):o&&!0!==a&&(t=function(e){return l(e,n.uint8array?new Uint8Array(e.length):new Array(e.length))}(t))),t):s.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))}))};},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,r){var n=e("./reader/readerFor"),i=e("./utils"),o=e("./signature"),s=e("./zipEntry"),a=e("./support");function l(e){this.files=[],this.loadOptions=e;}l.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(t)+", expected "+i.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4)===t;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=a.uint8array?"uint8array":"array",r=i.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r);},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,r,n=this.zip64EndOfCentralSize-44;0<n;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r};},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes();},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(e=new s({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(e);var t=e;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral();}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=t-r;if(0<n)this.isSignature(t,o.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(e){this.reader=n(e);},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles();}},t.exports=l;},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,r){var n=e("./reader/readerFor"),i=e("./utils"),o=e("./compressedObject"),s=e("./crc32"),a=e("./utf8"),l=e("./compressions"),u=e("./support");function c(e,t){this.options=e,this.loadOptions=t;}c.prototype={isEncrypted:function(){return !(1&~this.bitFlag)},useUTF8:function(){return !(2048&~this.bitFlag)},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in l)if(Object.prototype.hasOwnProperty.call(l,t)&&l[t].magic===e)return l[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize));},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength);},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0);},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4));}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),r=e.readInt(2),n=e.readData(r),this.extraFields[t]={id:t,length:r,value:n};e.setIndex(i);},handleUTF8:function(){var e=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=a.utf8decode(this.fileName),this.fileCommentStr=a.utf8decode(this.fileComment);else {var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else {var r=i.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r);}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else {var o=i.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(o);}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=n(e.value);return 1!==t.readInt(1)||s(this.fileName)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=n(e.value);return 1!==t.readInt(1)||s(this.fileComment)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null}},t.exports=c;},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,r){function n(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions};}var i=e("./stream/StreamHelper"),o=e("./stream/DataWorker"),s=e("./utf8"),a=e("./compressedObject"),l=e("./stream/GenericWorker");n.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var n="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var o=!this._dataBinary;o&&!n&&(t=t.pipe(new s.Utf8EncodeWorker)),!o&&n&&(t=t.pipe(new s.Utf8DecodeWorker));}catch(e){(t=new l("error")).error(e);}return new i(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof a&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new s.Utf8EncodeWorker)),a.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof a?this._data.getContentWorker():this._data instanceof l?this._data:new o(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],c=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<u.length;h++)n.prototype[u[h]]=c;t.exports=n;},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,r){(function(e){var r,n,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var o=0,s=new i(c),a=e.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=o=++o%2;};}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){c(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null;},e.document.documentElement.appendChild(t);}:function(){setTimeout(c,0);};else {var l=new e.MessageChannel;l.port1.onmessage=c,r=function(){l.port2.postMessage(0);};}var u=[];function c(){var e,t;n=!0;for(var r=u.length;r;){for(t=u,u=[],e=-1;++e<r;)t[e]();r=u.length;}n=!1;}t.exports=function(e){1!==u.push(e)||n||r();};}).call(this,void 0!==d?d:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});},{}],37:[function(e,t,r){var n=e("immediate");function i(){}var o={},s=["REJECTED"],a=["FULFILLED"],l=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,e!==i&&d(this,e);}function c(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected);}function h(e,t,r){n((function(){var n;try{n=t(r);}catch(n){return o.reject(e,n)}n===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,n);}));}function f(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments);}}function d(e,t){var r=!1;function n(t){r||(r=!0,o.reject(e,t));}function i(t){r||(r=!0,o.resolve(e,t));}var s=p((function(){t(i,n);}));"error"===s.status&&n(s.value);}function p(e,t){var r={};try{r.value=e(t),r.status="success";}catch(e){r.status="error",r.value=e;}return r}(t.exports=u).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then((function(r){return t.resolve(e()).then((function(){return r}))}),(function(r){return t.resolve(e()).then((function(){throw r}))}))},u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(i);return this.state!==l?h(r,this.state===a?e:t,this.outcome):this.queue.push(new c(r,e,t)),r},c.prototype.callFulfilled=function(e){o.resolve(this.promise,e);},c.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e);},c.prototype.callRejected=function(e){o.reject(this.promise,e);},c.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e);},o.resolve=function(e,t){var r=p(f,t);if("error"===r.status)return o.reject(e,r.value);var n=r.value;if(n)d(e,n);else {e.state=a,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callFulfilled(t);}return e},o.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},u.resolve=function(e){return e instanceof this?e:o.resolve(new this(i),e)},u.reject=function(e){var t=new this(i);return o.reject(t,e)},u.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var s=new Array(r),a=0,l=-1,u=new this(i);++l<r;)c(e[l],l);return u;function c(e,i){t.resolve(e).then((function(e){s[i]=e,++a!==r||n||(n=!0,o.resolve(u,s));}),(function(e){n||(n=!0,o.reject(u,e));}));}},u.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var s,a=-1,l=new this(i);++a<r;)s=e[a],t.resolve(s).then((function(e){n||(n=!0,o.resolve(l,e));}),(function(e){n||(n=!0,o.reject(l,e));}));return l};},{immediate:36}],38:[function(e,t,r){var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=n;},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,r){var n=e("./zlib/deflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/messages"),a=e("./zlib/zstream"),l=Object.prototype.toString,u=0,c=-1,h=0,f=8;function d(e){if(!(this instanceof d))return new d(e);this.options=i.assign({level:c,method:f,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var r=n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==u)throw new Error(s[r]);if(t.header&&n.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=n.deflateSetDictionary(this.strm,p))!==u)throw new Error(s[r]);this._dict_set=!0;}}function p(e,t){var r=new d(t);if(r.push(e,!0),r.err)throw r.msg||s[r.err];return r.result}d.prototype.push=function(e,t){var r,s,a=this.strm,c=this.options.chunkSize;if(this.ended)return !1;s=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=o.string2buf(e):"[object ArrayBuffer]"===l.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(c),a.next_out=0,a.avail_out=c),1!==(r=n.deflate(a,s))&&r!==u)return this.onEnd(r),!(this.ended=!0);0!==a.avail_out&&(0!==a.avail_in||4!==s&&2!==s)||("string"===this.options.to?this.onData(o.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)));}while((0<a.avail_in||0===a.avail_out)&&1!==r);return 4===s?(r=n.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===u):2!==s||(this.onEnd(u),!(a.avail_out=0))},d.prototype.onData=function(e){this.chunks.push(e);},d.prototype.onEnd=function(e){e===u&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg;},r.Deflate=d,r.deflate=p,r.deflateRaw=function(e,t){return (t=t||{}).raw=!0,p(e,t)},r.gzip=function(e,t){return (t=t||{}).gzip=!0,p(e,t)};},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,r){var n=e("./zlib/inflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/constants"),a=e("./zlib/messages"),l=e("./zlib/zstream"),u=e("./zlib/gzheader"),c=Object.prototype.toString;function h(e){if(!(this instanceof h))return new h(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var r=n.inflateInit2(this.strm,t.windowBits);if(r!==s.Z_OK)throw new Error(a[r]);this.header=new u,n.inflateGetHeader(this.strm,this.header);}function f(e,t){var r=new h(t);if(r.push(e,!0),r.err)throw r.msg||a[r.err];return r.result}h.prototype.push=function(e,t){var r,a,l,u,h,f,d=this.strm,p=this.options.chunkSize,g=this.options.dictionary,m=!1;if(this.ended)return !1;a=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,"string"==typeof e?d.input=o.binstring2buf(e):"[object ArrayBuffer]"===c.call(e)?d.input=new Uint8Array(e):d.input=e,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new i.Buf8(p),d.next_out=0,d.avail_out=p),(r=n.inflate(d,s.Z_NO_FLUSH))===s.Z_NEED_DICT&&g&&(f="string"==typeof g?o.string2buf(g):"[object ArrayBuffer]"===c.call(g)?new Uint8Array(g):g,r=n.inflateSetDictionary(this.strm,f)),r===s.Z_BUF_ERROR&&!0===m&&(r=s.Z_OK,m=!1),r!==s.Z_STREAM_END&&r!==s.Z_OK)return this.onEnd(r),!(this.ended=!0);d.next_out&&(0!==d.avail_out&&r!==s.Z_STREAM_END&&(0!==d.avail_in||a!==s.Z_FINISH&&a!==s.Z_SYNC_FLUSH)||("string"===this.options.to?(l=o.utf8border(d.output,d.next_out),u=d.next_out-l,h=o.buf2string(d.output,l),d.next_out=u,d.avail_out=p-u,u&&i.arraySet(d.output,d.output,l,u,0),this.onData(h)):this.onData(i.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(m=!0);}while((0<d.avail_in||0===d.avail_out)&&r!==s.Z_STREAM_END);return r===s.Z_STREAM_END&&(a=s.Z_FINISH),a===s.Z_FINISH?(r=n.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===s.Z_OK):a!==s.Z_SYNC_FLUSH||(this.onEnd(s.Z_OK),!(d.avail_out=0))},h.prototype.onData=function(e){this.chunks.push(e);},h.prototype.onEnd=function(e){e===s.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg;},r.Inflate=h,r.inflate=f,r.inflateRaw=function(e,t){return (t=t||{}).raw=!0,f(e,t)},r.ungzip=f;},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,r){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n]);}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o];},flattenChunks:function(e){var t,r,n,i,o,s;for(t=n=0,r=e.length;t<r;t++)n+=e[t].length;for(s=new Uint8Array(n),t=i=0,r=e.length;t<r;t++)o=e[t],s.set(o,i),i+=o.length;return s}},o={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o];},flattenChunks:function(e){return [].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,o));},r.setTyped(n);},{}],42:[function(e,t,r){var n=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0]);}catch(e){i=!1;}try{String.fromCharCode.apply(null,new Uint8Array(1));}catch(e){o=!1;}for(var s=new n.Buf8(256),a=0;a<256;a++)s[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function l(e,t){if(t<65537&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var r="",s=0;s<t;s++)r+=String.fromCharCode(e[s]);return r}s[254]=s[254]=1,r.string2buf=function(e){var t,r,i,o,s,a=e.length,l=0;for(o=0;o<a;o++)55296==(64512&(r=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(r=65536+(r-55296<<10)+(i-56320),o++),l+=r<128?1:r<2048?2:r<65536?3:4;for(t=new n.Buf8(l),o=s=0;s<l;o++)55296==(64512&(r=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(r=65536+(r-55296<<10)+(i-56320),o++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new n.Buf8(e.length),r=0,i=t.length;r<i;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,n,i,o,a=t||e.length,u=new Array(2*a);for(r=n=0;r<a;)if((i=e[r++])<128)u[n++]=i;else if(4<(o=s[i]))u[n++]=65533,r+=o-1;else {for(i&=2===o?31:3===o?15:7;1<o&&r<a;)i=i<<6|63&e[r++],o--;1<o?u[n++]=65533:i<65536?u[n++]=i:(i-=65536,u[n++]=55296|i>>10&1023,u[n++]=56320|1023&i);}return l(u,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0||0===r?t:r+s[e[r]]>t?r:t};},{"./common":41}],43:[function(e,t,r){t.exports=function(e,t,r,n){for(var i=65535&e,o=e>>>16&65535,s=0;0!==r;){for(r-=s=2e3<r?2e3:r;o=o+(i=i+t[n++]|0)|0,--s;);i%=65521,o%=65521;}return i|o<<16};},{}],44:[function(e,t,r){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};},{}],45:[function(e,t,r){var n=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e;}return t}();t.exports=function(e,t,r,i){var o=n,s=i+r;e^=-1;for(var a=i;a<s;a++)e=e>>>8^o[255&(e^t[a])];return ~e};},{}],46:[function(e,t,r){var n,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),l=e("./messages"),u=0,c=4,h=0,f=-2,d=-1,p=4,g=2,m=8,v=9,_=286,y=30,b=19,w=2*_+1,k=15,x=3,S=258,A=S+x+1,C=42,E=113,T=1,z=2,O=3,R=4;function I(e,t){return e.msg=l[t],t}function F(e){return (e<<1)-(4<e?9:0)}function P(e){for(var t=e.length;0<=--t;)e[t]=0;}function B(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(i.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0));}function L(e,t){o._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,B(e.strm);}function D(e,t){e.pending_buf[e.pending++]=t;}function U(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t;}function N(e,t){var r,n,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-A?e.strstart-(e.w_size-A):0,u=e.window,c=e.w_mask,h=e.prev,f=e.strstart+S,d=u[o+s-1],p=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(r=t)+s]===p&&u[r+s-1]===d&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<f);if(n=S-(f-o),o=f-S,s<n){if(e.match_start=t,a<=(s=n))break;d=u[o+s-1],p=u[o+s];}}}while((t=h[t&c])>l&&0!=--i);return s<=e.lookahead?s:e.lookahead}function j(e){var t,r,n,o,l,u,c,h,f,d,p=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=p+(p-A)){for(i.arraySet(e.window,e.window,p,p,0),e.match_start-=p,e.strstart-=p,e.block_start-=p,t=r=e.hash_size;n=e.head[--t],e.head[t]=p<=n?n-p:0,--r;);for(t=r=p;n=e.prev[--t],e.prev[t]=p<=n?n-p:0,--r;);o+=p;}if(0===e.strm.avail_in)break;if(u=e.strm,c=e.window,h=e.strstart+e.lookahead,d=void 0,(f=o)<(d=u.avail_in)&&(d=f),r=0===d?0:(u.avail_in-=d,i.arraySet(c,u.input,u.next_in,d,h),1===u.state.wrap?u.adler=s(u.adler,c,d,h):2===u.state.wrap&&(u.adler=a(u.adler,c,d,h)),u.next_in+=d,u.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=x)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+x-1])&e.hash_mask,e.prev[l&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=l,l++,e.insert--,!(e.lookahead+e.insert<x)););}while(e.lookahead<A&&0!==e.strm.avail_in)}function M(e,t){for(var r,n;;){if(e.lookahead<A){if(j(e),e.lookahead<A&&t===u)return T;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-A&&(e.match_length=N(e,r)),e.match_length>=x)if(n=o._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++;}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(L(e,!1),0===e.strm.avail_out))return T}return e.insert=e.strstart<x-1?e.strstart:x-1,t===c?(L(e,!0),0===e.strm.avail_out?O:R):e.last_lit&&(L(e,!1),0===e.strm.avail_out)?T:z}function Z(e,t){for(var r,n,i;;){if(e.lookahead<A){if(j(e),e.lookahead<A&&t===u)return T;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=x-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-A&&(e.match_length=N(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===x&&4096<e.strstart-e.match_start)&&(e.match_length=x-1)),e.prev_length>=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=x-1,e.strstart++,n&&(L(e,!1),0===e.strm.avail_out))return T}else if(e.match_available){if((n=o._tr_tally(e,0,e.window[e.strstart-1]))&&L(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return T}else e.match_available=1,e.strstart++,e.lookahead--;}return e.match_available&&(n=o._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<x-1?e.strstart:x-1,t===c?(L(e,!0),0===e.strm.avail_out?O:R):e.last_lit&&(L(e,!1),0===e.strm.avail_out)?T:z}function W(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i;}function Y(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=m,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(2*w),this.dyn_dtree=new i.Buf16(2*(2*y+1)),this.bl_tree=new i.Buf16(2*(2*b+1)),P(this.dyn_ltree),P(this.dyn_dtree),P(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(k+1),this.heap=new i.Buf16(2*_+1),P(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*_+1),P(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0;}function q(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=g,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?C:E,e.adler=2===t.wrap?0:1,t.last_flush=u,o._tr_init(t),h):I(e,f)}function V(e){var t=q(e);return t===h&&function(e){e.window_size=2*e.w_size,P(e.head),e.max_lazy_match=n[e.level].max_lazy,e.good_match=n[e.level].good_length,e.nice_match=n[e.level].nice_length,e.max_chain_length=n[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=x-1,e.match_available=0,e.ins_h=0;}(e.state),t}function G(e,t,r,n,o,s){if(!e)return f;var a=1;if(t===d&&(t=6),n<0?(a=0,n=-n):15<n&&(a=2,n-=16),o<1||v<o||r!==m||n<8||15<n||t<0||9<t||s<0||p<s)return I(e,f);8===n&&(n=9);var l=new Y;return (e.state=l).strm=e,l.wrap=a,l.gzhead=null,l.w_bits=n,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=o+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+x-1)/x),l.window=new i.Buf8(2*l.w_size),l.head=new i.Buf16(l.hash_size),l.prev=new i.Buf16(l.w_size),l.lit_bufsize=1<<o+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new i.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=s,l.method=r,V(e)}n=[new W(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===u)return T;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,L(e,!1),0===e.strm.avail_out))return T;if(e.strstart-e.block_start>=e.w_size-A&&(L(e,!1),0===e.strm.avail_out))return T}return e.insert=0,t===c?(L(e,!0),0===e.strm.avail_out?O:R):(e.strstart>e.block_start&&(L(e,!1),e.strm.avail_out),T)})),new W(4,4,8,4,M),new W(4,5,16,8,M),new W(4,6,32,32,M),new W(4,4,16,16,Z),new W(8,16,32,32,Z),new W(8,16,128,128,Z),new W(8,32,128,256,Z),new W(32,128,258,1024,Z),new W(32,258,258,4096,Z)],r.deflateInit=function(e,t){return G(e,t,m,15,8,0)},r.deflateInit2=G,r.deflateReset=V,r.deflateResetKeep=q,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?f:(e.state.gzhead=t,h):f},r.deflate=function(e,t){var r,i,s,l;if(!e||!e.state||5<t||t<0)return e?I(e,f):f;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==c)return I(e,0===e.avail_out?-5:f);if(i.strm=e,r=i.last_flush,i.last_flush=t,i.status===C)if(2===i.wrap)e.adler=0,D(i,31),D(i,139),D(i,8),i.gzhead?(D(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),D(i,255&i.gzhead.time),D(i,i.gzhead.time>>8&255),D(i,i.gzhead.time>>16&255),D(i,i.gzhead.time>>24&255),D(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),D(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(D(i,255&i.gzhead.extra.length),D(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(D(i,0),D(i,0),D(i,0),D(i,0),D(i,0),D(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),D(i,3),i.status=E);else {var d=m+(i.w_bits-8<<4)<<8;d|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(d|=32),d+=31-d%31,i.status=E,U(i,d),0!==i.strstart&&(U(i,e.adler>>>16),U(i,65535&e.adler)),e.adler=1;}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),B(e),s=i.pending,i.pending!==i.pending_buf_size));)D(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73);}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),B(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,D(i,l);}while(0!==l);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.gzindex=0,i.status=91);}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),B(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,D(i,l);}while(0!==l);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.status=103);}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&B(e),i.pending+2<=i.pending_buf_size&&(D(i,255&e.adler),D(i,e.adler>>8&255),e.adler=0,i.status=E)):i.status=E),0!==i.pending){if(B(e),0===e.avail_out)return i.last_flush=-1,h}else if(0===e.avail_in&&F(t)<=F(r)&&t!==c)return I(e,-5);if(666===i.status&&0!==e.avail_in)return I(e,-5);if(0!==e.avail_in||0!==i.lookahead||t!==u&&666!==i.status){var p=2===i.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===u)return T;break}if(e.match_length=0,r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(L(e,!1),0===e.strm.avail_out))return T}return e.insert=0,t===c?(L(e,!0),0===e.strm.avail_out?O:R):e.last_lit&&(L(e,!1),0===e.strm.avail_out)?T:z}(i,t):3===i.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===u)return T;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0<e.strstart&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){s=e.strstart+S;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<s);e.match_length=S-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead);}if(e.match_length>=x?(r=o._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(L(e,!1),0===e.strm.avail_out))return T}return e.insert=0,t===c?(L(e,!0),0===e.strm.avail_out?O:R):e.last_lit&&(L(e,!1),0===e.strm.avail_out)?T:z}(i,t):n[i.level].func(i,t);if(p!==O&&p!==R||(i.status=666),p===T||p===O)return 0===e.avail_out&&(i.last_flush=-1),h;if(p===z&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(P(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),B(e),0===e.avail_out))return i.last_flush=-1,h}return t!==c?h:i.wrap<=0?1:(2===i.wrap?(D(i,255&e.adler),D(i,e.adler>>8&255),D(i,e.adler>>16&255),D(i,e.adler>>24&255),D(i,255&e.total_in),D(i,e.total_in>>8&255),D(i,e.total_in>>16&255),D(i,e.total_in>>24&255)):(U(i,e.adler>>>16),U(i,65535&e.adler)),B(e),0<i.wrap&&(i.wrap=-i.wrap),0!==i.pending?h:1)},r.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==C&&69!==t&&73!==t&&91!==t&&103!==t&&t!==E&&666!==t?I(e,f):(e.state=null,t===E?I(e,-3):h):f},r.deflateSetDictionary=function(e,t){var r,n,o,a,l,u,c,d,p=t.length;if(!e||!e.state)return f;if(2===(a=(r=e.state).wrap)||1===a&&r.status!==C||r.lookahead)return f;for(1===a&&(e.adler=s(e.adler,t,p,0)),r.wrap=0,p>=r.w_size&&(0===a&&(P(r.head),r.strstart=0,r.block_start=0,r.insert=0),d=new i.Buf8(r.w_size),i.arraySet(d,t,p-r.w_size,r.w_size,0),t=d,p=r.w_size),l=e.avail_in,u=e.next_in,c=e.input,e.avail_in=p,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,o=r.lookahead-(x-1);r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+x-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++,--o;);r.strstart=n,r.lookahead=x-1,j(r);}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=x-1,r.match_available=0,e.next_in=u,e.input=c,e.avail_in=l,r.wrap=a,h},r.deflateInfo="pako deflate (from Nodeca project)";},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,r){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1;};},{}],48:[function(e,t,r){t.exports=function(e,t){var r,n,i,o,s,a,l,u,c,h,f,d,p,g,m,v,_,y,b,w,k,x,S,A,C;r=e.state,n=e.next_in,A=e.input,i=n+(e.avail_in-5),o=e.next_out,C=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),l=r.dmax,u=r.wsize,c=r.whave,h=r.wnext,f=r.window,d=r.hold,p=r.bits,g=r.lencode,m=r.distcode,v=(1<<r.lenbits)-1,_=(1<<r.distbits)-1;e:do{p<15&&(d+=A[n++]<<p,p+=8,d+=A[n++]<<p,p+=8),y=g[d&v];t:for(;;){if(d>>>=b=y>>>24,p-=b,0==(b=y>>>16&255))C[o++]=65535&y;else {if(!(16&b)){if(!(64&b)){y=g[(65535&y)+(d&(1<<b)-1)];continue t}if(32&b){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}w=65535&y,(b&=15)&&(p<b&&(d+=A[n++]<<p,p+=8),w+=d&(1<<b)-1,d>>>=b,p-=b),p<15&&(d+=A[n++]<<p,p+=8,d+=A[n++]<<p,p+=8),y=m[d&_];r:for(;;){if(d>>>=b=y>>>24,p-=b,!(16&(b=y>>>16&255))){if(!(64&b)){y=m[(65535&y)+(d&(1<<b)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&y,p<(b&=15)&&(d+=A[n++]<<p,(p+=8)<b&&(d+=A[n++]<<p,p+=8)),l<(k+=d&(1<<b)-1)){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=b,p-=b,(b=o-s)<k){if(c<(b=k-b)&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=f,(x=0)===h){if(x+=u-b,b<w){for(w-=b;C[o++]=f[x++],--b;);x=o-k,S=C;}}else if(h<b){if(x+=u+h-b,(b-=h)<w){for(w-=b;C[o++]=f[x++],--b;);if(x=0,h<w){for(w-=b=h;C[o++]=f[x++],--b;);x=o-k,S=C;}}}else if(x+=h-b,b<w){for(w-=b;C[o++]=f[x++],--b;);x=o-k,S=C;}for(;2<w;)C[o++]=S[x++],C[o++]=S[x++],C[o++]=S[x++],w-=3;w&&(C[o++]=S[x++],1<w&&(C[o++]=S[x++]));}else {for(x=o-k;C[o++]=C[x++],C[o++]=C[x++],C[o++]=C[x++],2<(w-=3););w&&(C[o++]=C[x++],1<w&&(C[o++]=C[x++]));}break}}break}}while(n<i&&o<a);n-=w=p>>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<a?a-o+257:257-(o-a),r.hold=d,r.bits=p;};},{}],49:[function(e,t,r){var n=e("../utils/common"),i=e("./adler32"),o=e("./crc32"),s=e("./inffast"),a=e("./inftrees"),l=1,u=2,c=0,h=-2,f=1,d=852,p=592;function g(e){return (e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0;}function v(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=f,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(d),t.distcode=t.distdyn=new n.Buf32(p),t.sane=1,t.back=-1,c):h}function _(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,v(e)):h}function y(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?h:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,_(e))):h}function b(e,t){var r,n;return e?(n=new m,(e.state=n).window=null,(r=y(e,t))!==c&&(e.state=null),r):h}var w,k,x=!0;function S(e){if(x){var t;for(w=new n.Buf32(512),k=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(l,e.lens,0,288,w,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(u,e.lens,0,32,k,0,e.work,{bits:5}),x=!1;}e.lencode=w,e.lenbits=9,e.distcode=k,e.distbits=5;}function A(e,t,r,i){var o,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new n.Buf8(s.wsize)),i>=s.wsize?(n.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i<(o=s.wsize-s.wnext)&&(o=i),n.arraySet(s.window,t,r-i,o,s.wnext),(i-=o)?(n.arraySet(s.window,t,r-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0}r.inflateReset=_,r.inflateReset2=y,r.inflateResetKeep=v,r.inflateInit=function(e){return b(e,15)},r.inflateInit2=b,r.inflate=function(e,t){var r,d,p,m,v,_,y,b,w,k,x,C,E,T,z,O,R,I,F,P,B,L,D,U,N=0,j=new n.Buf8(4),M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return h;12===(r=e.state).mode&&(r.mode=13),v=e.next_out,p=e.output,y=e.avail_out,m=e.next_in,d=e.input,_=e.avail_in,b=r.hold,w=r.bits,k=_,x=y,L=c;e:for(;;)switch(r.mode){case f:if(0===r.wrap){r.mode=13;break}for(;w<16;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(2&r.wrap&&35615===b){j[r.check=0]=255&b,j[1]=b>>>8&255,r.check=o(r.check,j,2,0),w=b=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&b)<<8)+(b>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&b)){e.msg="unknown compression method",r.mode=30;break}if(w-=4,B=8+(15&(b>>>=4)),0===r.wbits)r.wbits=B;else if(B>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<B,e.adler=r.check=1,r.mode=512&b?10:12,w=b=0;break;case 2:for(;w<16;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(r.flags=b,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=b>>8&1),512&r.flags&&(j[0]=255&b,j[1]=b>>>8&255,r.check=o(r.check,j,2,0)),w=b=0,r.mode=3;case 3:for(;w<32;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}r.head&&(r.head.time=b),512&r.flags&&(j[0]=255&b,j[1]=b>>>8&255,j[2]=b>>>16&255,j[3]=b>>>24&255,r.check=o(r.check,j,4,0)),w=b=0,r.mode=4;case 4:for(;w<16;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}r.head&&(r.head.xflags=255&b,r.head.os=b>>8),512&r.flags&&(j[0]=255&b,j[1]=b>>>8&255,r.check=o(r.check,j,2,0)),w=b=0,r.mode=5;case 5:if(1024&r.flags){for(;w<16;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}r.length=b,r.head&&(r.head.extra_len=b),512&r.flags&&(j[0]=255&b,j[1]=b>>>8&255,r.check=o(r.check,j,2,0)),w=b=0;}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(_<(C=r.length)&&(C=_),C&&(r.head&&(B=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,d,m,C,B)),512&r.flags&&(r.check=o(r.check,d,C,m)),_-=C,m+=C,r.length-=C),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===_)break e;for(C=0;B=d[m+C++],r.head&&B&&r.length<65536&&(r.head.name+=String.fromCharCode(B)),B&&C<_;);if(512&r.flags&&(r.check=o(r.check,d,C,m)),_-=C,m+=C,B)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===_)break e;for(C=0;B=d[m+C++],r.head&&B&&r.length<65536&&(r.head.comment+=String.fromCharCode(B)),B&&C<_;);if(512&r.flags&&(r.check=o(r.check,d,C,m)),_-=C,m+=C,B)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;w<16;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(b!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}w=b=0;}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;w<32;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}e.adler=r.check=g(b),w=b=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=v,e.avail_out=y,e.next_in=m,e.avail_in=_,r.hold=b,r.bits=w,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){b>>>=7&w,w-=7&w,r.mode=27;break}for(;w<3;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}switch(r.last=1&b,w-=1,3&(b>>>=1)){case 0:r.mode=14;break;case 1:if(S(r),r.mode=20,6!==t)break;b>>>=2,w-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30;}b>>>=2,w-=2;break;case 14:for(b>>>=7&w,w-=7&w;w<32;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if((65535&b)!=(b>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&b,w=b=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(C=r.length){if(_<C&&(C=_),y<C&&(C=y),0===C)break e;n.arraySet(p,d,m,C,v),_-=C,m+=C,y-=C,v+=C,r.length-=C;break}r.mode=12;break;case 17:for(;w<14;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(r.nlen=257+(31&b),b>>>=5,w-=5,r.ndist=1+(31&b),b>>>=5,w-=5,r.ncode=4+(15&b),b>>>=4,w-=4,286<r.nlen||30<r.ndist){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;w<3;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}r.lens[M[r.have++]]=7&b,b>>>=3,w-=3;}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,D={bits:r.lenbits},L=a(0,r.lens,0,19,r.lencode,0,r.work,D),r.lenbits=D.bits,L){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;O=(N=r.lencode[b&(1<<r.lenbits)-1])>>>16&255,R=65535&N,!((z=N>>>24)<=w);){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(R<16)b>>>=z,w-=z,r.lens[r.have++]=R;else {if(16===R){for(U=z+2;w<U;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(b>>>=z,w-=z,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}B=r.lens[r.have-1],C=3+(3&b),b>>>=2,w-=2;}else if(17===R){for(U=z+3;w<U;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}w-=z,B=0,C=3+(7&(b>>>=z)),b>>>=3,w-=3;}else {for(U=z+7;w<U;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}w-=z,B=0,C=11+(127&(b>>>=z)),b>>>=7,w-=7;}if(r.have+C>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;C--;)r.lens[r.have++]=B;}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,D={bits:r.lenbits},L=a(l,r.lens,0,r.nlen,r.lencode,0,r.work,D),r.lenbits=D.bits,L){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,D={bits:r.distbits},L=a(u,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,D),r.distbits=D.bits,L){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=_&&258<=y){e.next_out=v,e.avail_out=y,e.next_in=m,e.avail_in=_,r.hold=b,r.bits=w,s(e,x),v=e.next_out,p=e.output,y=e.avail_out,m=e.next_in,d=e.input,_=e.avail_in,b=r.hold,w=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;O=(N=r.lencode[b&(1<<r.lenbits)-1])>>>16&255,R=65535&N,!((z=N>>>24)<=w);){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(O&&!(240&O)){for(I=z,F=O,P=R;O=(N=r.lencode[P+((b&(1<<I+F)-1)>>I)])>>>16&255,R=65535&N,!(I+(z=N>>>24)<=w);){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}b>>>=I,w-=I,r.back+=I;}if(b>>>=z,w-=z,r.back+=z,r.length=R,0===O){r.mode=26;break}if(32&O){r.back=-1,r.mode=12;break}if(64&O){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&O,r.mode=22;case 22:if(r.extra){for(U=r.extra;w<U;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}r.length+=b&(1<<r.extra)-1,b>>>=r.extra,w-=r.extra,r.back+=r.extra;}r.was=r.length,r.mode=23;case 23:for(;O=(N=r.distcode[b&(1<<r.distbits)-1])>>>16&255,R=65535&N,!((z=N>>>24)<=w);){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(!(240&O)){for(I=z,F=O,P=R;O=(N=r.distcode[P+((b&(1<<I+F)-1)>>I)])>>>16&255,R=65535&N,!(I+(z=N>>>24)<=w);){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}b>>>=I,w-=I,r.back+=I;}if(b>>>=z,w-=z,r.back+=z,64&O){e.msg="invalid distance code",r.mode=30;break}r.offset=R,r.extra=15&O,r.mode=24;case 24:if(r.extra){for(U=r.extra;w<U;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}r.offset+=b&(1<<r.extra)-1,b>>>=r.extra,w-=r.extra,r.back+=r.extra;}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===y)break e;if(C=x-y,r.offset>C){if((C=r.offset-C)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}E=C>r.wnext?(C-=r.wnext,r.wsize-C):r.wnext-C,C>r.length&&(C=r.length),T=r.window;}else T=p,E=v-r.offset,C=r.length;for(y<C&&(C=y),y-=C,r.length-=C;p[v++]=T[E++],--C;);0===r.length&&(r.mode=21);break;case 26:if(0===y)break e;p[v++]=r.length,y--,r.mode=21;break;case 27:if(r.wrap){for(;w<32;){if(0===_)break e;_--,b|=d[m++]<<w,w+=8;}if(x-=y,e.total_out+=x,r.total+=x,x&&(e.adler=r.check=r.flags?o(r.check,p,x,v-x):i(r.check,p,x,v-x)),x=y,(r.flags?b:g(b))!==r.check){e.msg="incorrect data check",r.mode=30;break}w=b=0;}r.mode=28;case 28:if(r.wrap&&r.flags){for(;w<32;){if(0===_)break e;_--,b+=d[m++]<<w,w+=8;}if(b!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}w=b=0;}r.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return -4;default:return h}return e.next_out=v,e.avail_out=y,e.next_in=m,e.avail_in=_,r.hold=b,r.bits=w,(r.wsize||x!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&A(e,e.output,e.next_out,x-e.avail_out)?(r.mode=31,-4):(k-=e.avail_in,x-=e.avail_out,e.total_in+=k,e.total_out+=x,r.total+=x,r.wrap&&x&&(e.adler=r.check=r.flags?o(r.check,p,x,e.next_out-x):i(r.check,p,x,e.next_out-x)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==k&&0===x||4===t)&&L===c&&(L=-5),L)},r.inflateEnd=function(e){if(!e||!e.state)return h;var t=e.state;return t.window&&(t.window=null),e.state=null,c},r.inflateGetHeader=function(e,t){var r;return e&&e.state&&2&(r=e.state).wrap?((r.head=t).done=!1,c):h},r.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?h:11===r.mode&&i(1,t,n,0)!==r.check?-3:A(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,c):h},r.inflateInfo="pako inflate (from Nodeca project)";},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,r){var n=e("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,r,l,u,c,h,f){var d,p,g,m,v,_,y,b,w,k=f.bits,x=0,S=0,A=0,C=0,E=0,T=0,z=0,O=0,R=0,I=0,F=null,P=0,B=new n.Buf16(16),L=new n.Buf16(16),D=null,U=0;for(x=0;x<=15;x++)B[x]=0;for(S=0;S<l;S++)B[t[r+S]]++;for(E=k,C=15;1<=C&&0===B[C];C--);if(C<E&&(E=C),0===C)return u[c++]=20971520,u[c++]=20971520,f.bits=1,0;for(A=1;A<C&&0===B[A];A++);for(E<A&&(E=A),x=O=1;x<=15;x++)if(O<<=1,(O-=B[x])<0)return -1;if(0<O&&(0===e||1!==C))return -1;for(L[1]=0,x=1;x<15;x++)L[x+1]=L[x]+B[x];for(S=0;S<l;S++)0!==t[r+S]&&(h[L[t[r+S]]++]=S);if(_=0===e?(F=D=h,19):1===e?(F=i,P-=257,D=o,U-=257,256):(F=s,D=a,-1),x=A,v=c,z=S=I=0,g=-1,m=(R=1<<(T=E))-1,1===e&&852<R||2===e&&592<R)return 1;for(;;){for(y=x-z,w=h[S]<_?(b=0,h[S]):h[S]>_?(b=D[U+h[S]],F[P+h[S]]):(b=96,0),d=1<<x-z,A=p=1<<T;u[v+(I>>z)+(p-=d)]=y<<24|b<<16|w,0!==p;);for(d=1<<x-1;I&d;)d>>=1;if(0!==d?(I&=d-1,I+=d):I=0,S++,0==--B[x]){if(x===C)break;x=t[r+h[S]];}if(E<x&&(I&m)!==g){for(0===z&&(z=E),v+=A,O=1<<(T=x-z);T+z<C&&!((O-=B[T+z])<=0);)T++,O<<=1;if(R+=1<<T,1===e&&852<R||2===e&&592<R)return 1;u[g=I&m]=E<<24|T<<16|v-c;}}return 0!==I&&(u[v+I]=x-z<<24|64<<16),f.bits=E,0};},{"../utils/common":41}],51:[function(e,t,r){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};},{}],52:[function(e,t,r){var n=e("../utils/common"),i=0,o=1;function s(e){for(var t=e.length;0<=--t;)e[t]=0;}var a=0,l=29,u=256,c=u+1+l,h=30,f=19,d=2*c+1,p=15,g=16,m=7,v=256,_=16,y=17,b=18,w=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=new Array(2*(c+2));s(A);var C=new Array(2*h);s(C);var E=new Array(512);s(E);var T=new Array(256);s(T);var z=new Array(l);s(z);var O,R,I,F=new Array(h);function P(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length;}function B(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t;}function L(e){return e<256?E[e]:E[256+(e>>>7)]}function D(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255;}function U(e,t,r){e.bi_valid>g-r?(e.bi_buf|=t<<e.bi_valid&65535,D(e,e.bi_buf),e.bi_buf=t>>g-e.bi_valid,e.bi_valid+=r-g):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r);}function N(e,t,r){U(e,r[2*t],r[2*t+1]);}function j(e,t){for(var r=0;r|=1&e,e>>>=1,r<<=1,0<--t;);return r>>>1}function M(e,t,r){var n,i,o=new Array(p+1),s=0;for(n=1;n<=p;n++)o[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=j(o[a]++,a));}}function Z(e){var t;for(t=0;t<c;t++)e.dyn_ltree[2*t]=0;for(t=0;t<h;t++)e.dyn_dtree[2*t]=0;for(t=0;t<f;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*v]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0;}function W(e){8<e.bi_valid?D(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0;}function Y(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function q(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&Y(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Y(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n;}function V(e,t,r){var n,i,o,s,a=0;if(0!==e.last_lit)for(;n=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],i=e.pending_buf[e.l_buf+a],a++,0===n?N(e,i,t):(N(e,(o=T[i])+u+1,t),0!==(s=w[o])&&U(e,i-=z[o],s),N(e,o=L(--n),r),0!==(s=k[o])&&U(e,n-=F[o],s)),a<e.last_lit;);N(e,v,t);}function G(e,t){var r,n,i,o=t.dyn_tree,s=t.stat_desc.static_tree,a=t.stat_desc.has_stree,l=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=d,r=0;r<l;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=s[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;1<=r;r--)q(e,o,r);for(i=l;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],q(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,q(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,s,a,l=t.dyn_tree,u=t.max_code,c=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,g=t.stat_desc.extra_base,m=t.stat_desc.max_length,v=0;for(o=0;o<=p;o++)e.bl_count[o]=0;for(l[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<d;r++)m<(o=l[2*l[2*(n=e.heap[r])+1]+1]+1)&&(o=m,v++),l[2*n+1]=o,u<n||(e.bl_count[o]++,s=0,g<=n&&(s=f[n-g]),a=l[2*n],e.opt_len+=a*(o+s),h&&(e.static_len+=a*(c[2*n+1]+s)));if(0!==v){do{for(o=m-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[m]--,v-=2;}while(0<v);for(o=m;0!==o;o--)for(n=e.bl_count[o];0!==n;)u<(i=e.heap[--r])||(l[2*i+1]!==o&&(e.opt_len+=(o-l[2*i+1])*l[2*i],l[2*i+1]=o),n--);}}(e,t),M(o,u,e.bl_count);}function H(e,t,r){var n,i,o=-1,s=t[1],a=0,l=7,u=4;for(0===s&&(l=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=t[2*(n+1)+1],++a<l&&i===s||(a<u?e.bl_tree[2*i]+=a:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[2*_]++):a<=10?e.bl_tree[2*y]++:e.bl_tree[2*b]++,o=i,u=(a=0)===s?(l=138,3):i===s?(l=6,3):(l=7,4));}function K(e,t,r){var n,i,o=-1,s=t[1],a=0,l=7,u=4;for(0===s&&(l=138,u=3),n=0;n<=r;n++)if(i=s,s=t[2*(n+1)+1],!(++a<l&&i===s)){if(a<u)for(;N(e,i,e.bl_tree),0!=--a;);else 0!==i?(i!==o&&(N(e,i,e.bl_tree),a--),N(e,_,e.bl_tree),U(e,a-3,2)):a<=10?(N(e,y,e.bl_tree),U(e,a-3,3)):(N(e,b,e.bl_tree),U(e,a-11,7));o=i,u=(a=0)===s?(l=138,3):i===s?(l=6,3):(l=7,4);}}s(F);var J=!1;function X(e,t,r,i){U(e,(a<<1)+(i?1:0),3),function(e,t,r){W(e),D(e,r),D(e,~r),n.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r;}(e,t,r);}r._tr_init=function(e){J||(function(){var e,t,r,n,i,o=new Array(p+1);for(n=r=0;n<l-1;n++)for(z[n]=r,e=0;e<1<<w[n];e++)T[r++]=n;for(T[r-1]=n,n=i=0;n<16;n++)for(F[n]=i,e=0;e<1<<k[n];e++)E[i++]=n;for(i>>=7;n<h;n++)for(F[n]=i<<7,e=0;e<1<<k[n]-7;e++)E[256+i++]=n;for(t=0;t<=p;t++)o[t]=0;for(e=0;e<=143;)A[2*e+1]=8,e++,o[8]++;for(;e<=255;)A[2*e+1]=9,e++,o[9]++;for(;e<=279;)A[2*e+1]=7,e++,o[7]++;for(;e<=287;)A[2*e+1]=8,e++,o[8]++;for(M(A,c+1,o),e=0;e<h;e++)C[2*e+1]=5,C[2*e]=j(e,5);O=new P(A,w,u+1,c,p),R=new P(C,k,0,h,p),I=new P(new Array(0),x,0,f,m);}(),J=!0),e.l_desc=new B(e.dyn_ltree,O),e.d_desc=new B(e.dyn_dtree,R),e.bl_desc=new B(e.bl_tree,I),e.bi_buf=0,e.bi_valid=0,Z(e);},r._tr_stored_block=X,r._tr_flush_block=function(e,t,r,n){var s,a,l=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return i;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return o;for(t=32;t<u;t++)if(0!==e.dyn_ltree[2*t])return o;return i}(e)),G(e,e.l_desc),G(e,e.d_desc),l=function(e){var t;for(H(e,e.dyn_ltree,e.l_desc.max_code),H(e,e.dyn_dtree,e.d_desc.max_code),G(e,e.bl_desc),t=f-1;3<=t&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),s=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=s&&(s=a)):s=a=r+5,r+4<=s&&-1!==t?X(e,t,r,n):4===e.strategy||a===s?(U(e,2+(n?1:0),3),V(e,A,C)):(U(e,4+(n?1:0),3),function(e,t,r,n){var i;for(U(e,t-257,5),U(e,r-1,5),U(e,n-4,4),i=0;i<n;i++)U(e,e.bl_tree[2*S[i]+1],3);K(e,e.dyn_ltree,t-1),K(e,e.dyn_dtree,r-1);}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),V(e,e.dyn_ltree,e.dyn_dtree)),Z(e),n&&W(e);},r._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(T[r]+u+1)]++,e.dyn_dtree[2*L(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){U(e,2,3),N(e,v,A),function(e){16===e.bi_valid?(D(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8);}(e);};},{"../utils/common":41}],53:[function(e,t,r){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0;};},{}],54:[function(e,t,r){(function(e){!function(e,t){if(!e.setImmediate){var r,n,i,o,s=1,a={},l=!1,u=e.document,c=Object.getPrototypeOf&&Object.getPrototypeOf(e);c=c&&c.setTimeout?c:e,r="[object process]"==={}.toString.call(e.process)?function(e){!function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];be.push(new Ae(e,t)),1!==be.length||we||_e(Se);}((function(){f(e);}));}:function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1;},e.postMessage("","*"),e.onmessage=r,t}}()?(o="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",d,!1):e.attachEvent("onmessage",d),function(t){e.postMessage(o+t,"*");}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){f(e.data);},function(e){i.port2.postMessage(e);}):u&&"onreadystatechange"in u.createElement("script")?(n=u.documentElement,function(e){var t=u.createElement("script");t.onreadystatechange=function(){f(e),t.onreadystatechange=null,n.removeChild(t),t=null;},n.appendChild(t);}):function(e){setTimeout(f,0,e);},c.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return a[s]=i,r(s),s++},c.clearImmediate=h;}function h(e){delete a[e];}function f(e){if(l)setTimeout(f,0,e);else {var r=a[e];if(r){l=!0;try{!function(e){var r=e.callback,n=e.args;switch(n.length){case 0:r();break;case 1:r(n[0]);break;case 2:r(n[0],n[1]);break;case 3:r(n[0],n[1],n[2]);break;default:r.apply(t,n);}}(r);}finally{h(e),l=!1;}}}}function d(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(o)&&f(+t.data.slice(o.length));}}("undefined"==typeof self?void 0===e?this:e:self);}).call(this,void 0!==d?d:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});},{}]},{},[10])(10)),ze.exports),ct=e.getDefaultExportFromCjs(ut),ht={},ft={},dt={};function pt(){if(Oe)return dt;function e(e){return null==e}return Oe=1,dt.isNothing=e,dt.isObject=function(e){return "object"==typeof e&&null!==e},dt.toArray=function(t){return Array.isArray(t)?t:e(t)?[]:[t]},dt.repeat=function(e,t){var r,n="";for(r=0;r<t;r+=1)n+=e;return n},dt.isNegativeZero=function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},dt.extend=function(e,t){var r,n,i,o;if(t)for(r=0,n=(o=Object.keys(t)).length;r<n;r+=1)e[i=o[r]]=t[i];return e},dt}function gt(){if(Ie)return Re;function e(e,t){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||"",this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():"");}return Ie=1,e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(e){var t=this.name+": ";return t+=this.reason||"(unknown reason)",!e&&this.mark&&(t+=" "+this.mark.toString()),t},Re=e}function mt(){if(Le)return Be;Le=1;var e=gt(),t=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],r=["scalar","sequence","mapping"];return Be=function(n,i){if(i=i||{},Object.keys(i).forEach((function(r){if(-1===t.indexOf(r))throw new e('Unknown option "'+r+'" is met in definition of "'+n+'" YAML type.')})),this.tag=n,this.kind=i.kind||null,this.resolve=i.resolve||function(){return !0},this.construct=i.construct||function(e){return e},this.instanceOf=i.instanceOf||null,this.predicate=i.predicate||null,this.represent=i.represent||null,this.defaultStyle=i.defaultStyle||null,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(r){e[r].forEach((function(e){t[String(e)]=r;}));})),t}(i.styleAliases||null),-1===r.indexOf(this.kind))throw new e('Unknown kind "'+this.kind+'" is specified for "'+n+'" YAML type.')},Be}function vt(){if(Ue)return De;Ue=1;var e=pt(),t=gt(),r=mt();function n(e,t,r){var i=[];return e.include.forEach((function(e){r=n(e,t,r);})),e[t].forEach((function(e){r.forEach((function(t,r){t.tag===e.tag&&i.push(r);})),r.push(e);})),r.filter((function(e,t){return -1===i.indexOf(t)}))}function i(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach((function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new t("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")})),this.compiledImplicit=n(this,"implicit",[]),this.compiledExplicit=n(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,r={};function n(e){r[e.tag]=e;}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(n);return r}(this.compiledImplicit,this.compiledExplicit);}return i.DEFAULT=null,i.create=function(){var n,o;switch(arguments.length){case 1:n=i.DEFAULT,o=arguments[0];break;case 2:n=arguments[0],o=arguments[1];break;default:throw new t("Wrong number of arguments for Schema.create function")}if(n=e.toArray(n),o=e.toArray(o),!n.every((function(e){return e instanceof i})))throw new t("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!o.every((function(e){return e instanceof r})))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new i({include:n,explicit:o})},De=i}function _t(){if(je)return Ne;je=1;var e=mt();return Ne=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}})}function yt(){if(Ze)return Me;Ze=1;var e=mt();return Me=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}})}function bt(){if(Ye)return We;Ye=1;var e=mt();return We=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})}function wt(){if(Ve)return qe;Ve=1;var e=vt();return qe=new e({explicit:[_t(),yt(),bt()]})}function kt(){if(He)return Ge;He=1;var e=mt();return Ge=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return !0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return "~"},lowercase:function(){return "null"},uppercase:function(){return "NULL"},camelcase:function(){return "Null"}},defaultStyle:"lowercase"})}function xt(){if(Je)return Ke;Je=1;var e=mt();return Ke=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return !1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return "true"===e||"True"===e||"TRUE"===e},predicate:function(e){return "[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})}function St(){if($e)return Xe;$e=1;var e=pt(),t=mt();function r(e){return 48<=e&&e<=55}function n(e){return 48<=e&&e<=57}return Xe=new t("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return !1;var t,i,o=e.length,s=0,a=!1;if(!o)return !1;if("-"!==(t=e[s])&&"+"!==t||(t=e[++s]),"0"===t){if(s+1===o)return !0;if("b"===(t=e[++s])){for(s++;s<o;s++)if("_"!==(t=e[s])){if("0"!==t&&"1"!==t)return !1;a=!0;}return a}if("x"===t){for(s++;s<o;s++)if("_"!==(t=e[s])){if(!(48<=(i=e.charCodeAt(s))&&i<=57||65<=i&&i<=70||97<=i&&i<=102))return !1;a=!0;}return a}for(;s<o;s++)if("_"!==(t=e[s])){if(!r(e.charCodeAt(s)))return !1;a=!0;}return a}for(;s<o;s++)if("_"!==(t=e[s])){if(":"===t)break;if(!n(e.charCodeAt(s)))return !1;a=!0;}return !!a&&(":"!==t||/^(:[0-5]?[0-9])+$/.test(e.slice(s)))},construct:function(e){var t,r,n=e,i=1,o=[];return -1!==n.indexOf("_")&&(n=n.replace(/_/g,"")),"-"!==(t=n[0])&&"+"!==t||("-"===t&&(i=-1),t=(n=n.slice(1))[0]),"0"===n?0:"0"===t?"b"===n[1]?i*parseInt(n.slice(2),2):"x"===n[1]?i*parseInt(n,16):i*parseInt(n,8):-1!==n.indexOf(":")?(n.split(":").forEach((function(e){o.unshift(parseInt(e,10));})),n=0,r=1,o.forEach((function(e){n+=e*r,r*=60;})),i*n):i*parseInt(n,10)},predicate:function(t){return "[object Number]"===Object.prototype.toString.call(t)&&t%1==0&&!e.isNegativeZero(t)},represent:{binary:function(e){return "0b"+e.toString(2)},octal:function(e){return "0"+e.toString(8)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return "0x"+e.toString(16).toUpperCase()}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Xe}function At(){if(et)return Qe;et=1;var e=pt(),t=mt(),r=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?|\\.[0-9_]+(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var n=/^[-+]?[0-9]+e/;return Qe=new t("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!!r.test(e)},construct:function(e){var t,r,n,i;return r="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===r?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:t.indexOf(":")>=0?(t.split(":").forEach((function(e){i.unshift(parseFloat(e,10));})),t=0,n=1,i.forEach((function(e){t+=e*n,n*=60;})),r*t):r*parseFloat(t,10)},predicate:function(t){return "[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||e.isNegativeZero(t))},represent:function(t,r){var i;if(isNaN(t))switch(r){case"lowercase":return ".nan";case"uppercase":return ".NAN";case"camelcase":return ".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(r){case"lowercase":return ".inf";case"uppercase":return ".INF";case"camelcase":return ".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(r){case"lowercase":return "-.inf";case"uppercase":return "-.INF";case"camelcase":return "-.Inf"}else if(e.isNegativeZero(t))return "-0.0";return i=t.toString(10),n.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"})}function Ct(){if(rt)return tt;rt=1;var e=vt();return tt=new e({include:[wt()],implicit:[kt(),xt(),St(),At()]})}function Et(){if(it)return nt;it=1;var e=vt();return nt=new e({include:[Ct()]})}function Tt(){if(st)return ot;st=1;var e=mt(),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$");return ot=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&null!==t.exec(e)},construct:function(e){var r,n,i,o,s,a,l,u,c=0,h=null;if(null===(r=t.exec(e)))throw new Error("Date resolve error");if(n=+r[1],i=+r[2]-1,o=+r[3],!r[4])return new Date(Date.UTC(n,i,o));if(s=+r[4],a=+r[5],l=+r[6],r[7]){for(c=r[7].slice(0,3);c.length<3;)c+="0";c=+c;}return r[9]&&(h=6e4*(60*+r[10]+ +(r[11]||0)),"-"===r[9]&&(h=-h)),u=new Date(Date.UTC(n,i,o,s,a,l,c)),h&&u.setTime(u.getTime()-h),u},instanceOf:Date,represent:function(e){return e.toISOString()}})}function zt(){if(lt)return at;lt=1;var e=mt();return at=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return "<<"===e||null===e}})}var Ot,Rt,It,Ft,Pt,Bt,Lt,Dt,Ut,Nt,jt,Mt,Zt,Wt,Yt,qt,Vt,Gt,Ht,Kt,Jt,Xt,$t=e.getAugmentedNamespace(de);function Qt(){if(Rt)return Ot;Rt=1;var e=$t.Buffer,t=mt(),r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";return Ot=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return !1;var t,n,i=0,o=e.length,s=r;for(n=0;n<o;n++)if(!((t=s.indexOf(e.charAt(n)))>64)){if(t<0)return !1;i+=6;}return i%8==0},construct:function(t){var n,i,o=t.replace(/[\r\n=]/g,""),s=o.length,a=r,l=0,u=[];for(n=0;n<s;n++)n%4==0&&n&&(u.push(l>>16&255),u.push(l>>8&255),u.push(255&l)),l=l<<6|a.indexOf(o.charAt(n));return 0===(i=s%4*6)?(u.push(l>>16&255),u.push(l>>8&255),u.push(255&l)):18===i?(u.push(l>>10&255),u.push(l>>2&255)):12===i&&u.push(l>>4&255),e?new e(u):u},predicate:function(t){return e&&e.isBuffer(t)},represent:function(e){var t,n,i="",o=0,s=e.length,a=r;for(t=0;t<s;t++)t%3==0&&t&&(i+=a[o>>18&63],i+=a[o>>12&63],i+=a[o>>6&63],i+=a[63&o]),o=(o<<8)+e[t];return 0===(n=s%3)?(i+=a[o>>18&63],i+=a[o>>12&63],i+=a[o>>6&63],i+=a[63&o]):2===n?(i+=a[o>>10&63],i+=a[o>>4&63],i+=a[o<<2&63],i+=a[64]):1===n&&(i+=a[o>>2&63],i+=a[o<<4&63],i+=a[64],i+=a[64]),i}}),Ot}function er(){if(Ft)return It;Ft=1;var e=mt(),t=Object.prototype.hasOwnProperty,r=Object.prototype.toString;return It=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return !0;var n,i,o,s,a,l=[],u=e;for(n=0,i=u.length;n<i;n+=1){if(o=u[n],a=!1,"[object Object]"!==r.call(o))return !1;for(s in o)if(t.call(o,s)){if(a)return !1;a=!0;}if(!a)return !1;if(-1!==l.indexOf(s))return !1;l.push(s);}return !0},construct:function(e){return null!==e?e:[]}}),It}function tr(){if(Bt)return Pt;Bt=1;var e=mt(),t=Object.prototype.toString;return Pt=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return !0;var r,n,i,o,s,a=e;for(s=new Array(a.length),r=0,n=a.length;r<n;r+=1){if(i=a[r],"[object Object]"!==t.call(i))return !1;if(1!==(o=Object.keys(i)).length)return !1;s[r]=[o[0],i[o[0]]];}return !0},construct:function(e){if(null===e)return [];var t,r,n,i,o,s=e;for(o=new Array(s.length),t=0,r=s.length;t<r;t+=1)n=s[t],i=Object.keys(n),o[t]=[i[0],n[i[0]]];return o}}),Pt}function rr(){if(Dt)return Lt;Dt=1;var e=mt(),t=Object.prototype.hasOwnProperty;return Lt=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return !0;var r,n=e;for(r in n)if(t.call(n,r)&&null!==n[r])return !1;return !0},construct:function(e){return null!==e?e:{}}})}function nr(){if(Nt)return Ut;Nt=1;var e=vt();return Ut=new e({include:[Et()],implicit:[Tt(),zt()],explicit:[Qt(),er(),tr(),rr()]})}function ir(){if(Mt)return jt;Mt=1;var e=mt();return jt=new e("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:function(){return !0},construct:function(){},predicate:function(e){return void 0===e},represent:function(){return ""}})}function or(){if(Wt)return Zt;Wt=1;var e=mt();return Zt=new e("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:function(e){if(null===e)return !1;if(0===e.length)return !1;var t=e,r=/\/([gim]*)$/.exec(e),n="";if("/"===t[0]){if(r&&(n=r[1]),n.length>3)return !1;if("/"!==t[t.length-n.length-1])return !1}return !0},construct:function(e){var t=e,r=/\/([gim]*)$/.exec(e),n="";return "/"===t[0]&&(r&&(n=r[1]),t=t.slice(1,t.length-n.length-1)),new RegExp(t,n)},predicate:function(e){return "[object RegExp]"===Object.prototype.toString.call(e)},represent:function(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}})}function sr(){if(qt)return Yt;var e;qt=1;try{e=Ee("esprima");}catch(t){"undefined"!=typeof window&&(e=window.esprima);}var t=mt();return Yt=new t("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:function(t){if(null===t)return !1;try{var r="("+t+")",n=e.parse(r,{range:!0});return "Program"===n.type&&1===n.body.length&&"ExpressionStatement"===n.body[0].type&&"FunctionExpression"===n.body[0].expression.type}catch(e){return !1}},construct:function(t){var r,n="("+t+")",i=e.parse(n,{range:!0}),o=[];if("Program"!==i.type||1!==i.body.length||"ExpressionStatement"!==i.body[0].type||"FunctionExpression"!==i.body[0].expression.type)throw new Error("Failed to resolve function");return i.body[0].expression.params.forEach((function(e){o.push(e.name);})),r=i.body[0].expression.body.range,new Function(o,n.slice(r[0]+1,r[1]-1))},predicate:function(e){return "[object Function]"===Object.prototype.toString.call(e)},represent:function(e){return e.toString()}})}function ar(){if(Gt)return Vt;Gt=1;var e=vt();return Vt=e.DEFAULT=new e({include:[nr()],explicit:[ir(),or(),sr()]})}function lr(){if(Ht)return ft;Ht=1;var e=pt(),t=gt(),r=function(){if(Pe)return Fe;Pe=1;var e=pt();function t(e,t,r,n,i){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=i;}return t.prototype.getSnippet=function(t,r){var n,i,o,s,a;if(!this.buffer)return null;for(t=t||4,r=r||75,n="",i=this.position;i>0&&-1==="\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(i-1));)if(i-=1,this.position-i>r/2-1){n=" ... ",i+=5;break}for(o="",s=this.position;s<this.buffer.length&&-1==="\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(s));)if((s+=1)-this.position>r/2-1){o=" ... ",s-=5;break}return a=this.buffer.slice(i,s),e.repeat(" ",t)+n+a+o+"\n"+e.repeat(" ",t+this.position-i+n.length)+"^"},t.prototype.toString=function(e){var t,r="";return this.name&&(r+='in "'+this.name+'" '),r+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(r+=":\n"+t),r},Fe=t}(),n=nr(),i=ar(),o=Object.prototype.hasOwnProperty,s=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,a=/[\x85\u2028\u2029]/,l=/[,\[\]\{\}]/,u=/^(?:!|!!|![a-z\-]+!)$/i,c=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function h(e){return 10===e||13===e}function f(e){return 9===e||32===e}function d(e){return 9===e||32===e||10===e||13===e}function p(e){return 44===e||91===e||93===e||123===e||125===e}function g(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function m(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"…":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function v(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var _=new Array(256),y=new Array(256),b=0;b<256;b++)_[b]=m(b)?1:0,y[b]=m(b);function w(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||i,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[];}function k(e,n){return new t(n,new r(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function x(e,t){throw k(e,t)}function S(e,t){e.onWarning&&e.onWarning.call(null,k(e,t));}var A={YAML:function(e,t,r){var n,i,o;null!==e.version&&x(e,"duplication of %YAML directive"),1!==r.length&&x(e,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(r[0]))&&x(e,"ill-formed argument of the YAML directive"),i=parseInt(n[1],10),o=parseInt(n[2],10),1!==i&&x(e,"unacceptable YAML version of the document"),e.version=r[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&S(e,"unsupported YAML version of the document");},TAG:function(e,t,r){var n,i;2!==r.length&&x(e,"TAG directive accepts exactly two arguments"),n=r[0],i=r[1],u.test(n)||x(e,"ill-formed tag handle (first argument) of the TAG directive"),o.call(e.tagMap,n)&&x(e,'there is a previously declared suffix for "'+n+'" tag handle'),c.test(i)||x(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagMap[n]=i;}};function C(e,t,r,n){var i,o,a,l;if(t<r){if(l=e.input.slice(t,r),n)for(i=0,o=l.length;i<o;i+=1)9===(a=l.charCodeAt(i))||32<=a&&a<=1114111||x(e,"expected valid JSON character");else s.test(l)&&x(e,"the stream contains non-printable characters");e.result+=l;}}function E(t,r,n,i){var s,a,l,u;for(e.isObject(n)||x(t,"cannot merge mappings; the provided source object is unacceptable"),l=0,u=(s=Object.keys(n)).length;l<u;l+=1)a=s[l],o.call(r,a)||(r[a]=n[a],i[a]=!0);}function T(e,t,r,n,i,s){var a,l;if(i=String(i),null===t&&(t={}),"tag:yaml.org,2002:merge"===n)if(Array.isArray(s))for(a=0,l=s.length;a<l;a+=1)E(e,t,s[a],r);else E(e,t,s,r);else e.json||o.call(r,i)||!o.call(t,i)||x(e,"duplicated mapping key"),t[i]=s,delete r[i];return t}function z(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):x(e,"a line break is expected"),e.line+=1,e.lineStart=e.position;}function O(e,t,r){for(var n=0,i=e.input.charCodeAt(e.position);0!==i;){for(;f(i);)i=e.input.charCodeAt(++e.position);if(t&&35===i)do{i=e.input.charCodeAt(++e.position);}while(10!==i&&13!==i&&0!==i);if(!h(i))break;for(z(e),i=e.input.charCodeAt(e.position),n++,e.lineIndent=0;32===i;)e.lineIndent++,i=e.input.charCodeAt(++e.position);}return -1!==r&&0!==n&&e.lineIndent<r&&S(e,"deficient indentation"),n}function R(e){var t,r=e.position;return !(45!==(t=e.input.charCodeAt(r))&&46!==t||t!==e.input.charCodeAt(r+1)||t!==e.input.charCodeAt(r+2)||(r+=3,0!==(t=e.input.charCodeAt(r))&&!d(t)))}function I(t,r){1===r?t.result+=" ":r>1&&(t.result+=e.repeat("\n",r-1));}function F(e,t){var r,n,i=e.tag,o=e.anchor,s=[],a=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=s),n=e.input.charCodeAt(e.position);0!==n&&45===n&&d(e.input.charCodeAt(e.position+1));)if(a=!0,e.position++,O(e,!0,-1)&&e.lineIndent<=t)s.push(null),n=e.input.charCodeAt(e.position);else if(r=e.line,L(e,t,3,!1,!0),s.push(e.result),O(e,!0,-1),n=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>t)&&0!==n)x(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return !!a&&(e.tag=i,e.anchor=o,e.kind="sequence",e.result=s,!0)}function P(e){var t,r,n,i,s=!1,a=!1;if(33!==(i=e.input.charCodeAt(e.position)))return !1;if(null!==e.tag&&x(e,"duplication of a tag property"),60===(i=e.input.charCodeAt(++e.position))?(s=!0,i=e.input.charCodeAt(++e.position)):33===i?(a=!0,r="!!",i=e.input.charCodeAt(++e.position)):r="!",t=e.position,s){do{i=e.input.charCodeAt(++e.position);}while(0!==i&&62!==i);e.position<e.length?(n=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):x(e,"unexpected end of the stream within a verbatim tag");}else {for(;0!==i&&!d(i);)33===i&&(a?x(e,"tag suffix cannot contain exclamation marks"):(r=e.input.slice(t-1,e.position+1),u.test(r)||x(e,"named tag handle cannot contain such characters"),a=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);n=e.input.slice(t,e.position),l.test(n)&&x(e,"tag suffix cannot contain flow indicator characters");}return n&&!c.test(n)&&x(e,"tag name cannot contain such characters: "+n),s?e.tag=n:o.call(e.tagMap,r)?e.tag=e.tagMap[r]+n:"!"===r?e.tag="!"+n:"!!"===r?e.tag="tag:yaml.org,2002:"+n:x(e,'undeclared tag handle "'+r+'"'),!0}function B(e){var t,r;if(38!==(r=e.input.charCodeAt(e.position)))return !1;for(null!==e.anchor&&x(e,"duplication of an anchor property"),r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!d(r)&&!p(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&x(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function L(t,r,n,i,s){var a,l,u,c,m,b,w,k,S=1,A=!1,E=!1;if(null!==t.listener&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null,a=l=u=4===n||3===n,i&&O(t,!0,-1)&&(A=!0,t.lineIndent>r?S=1:t.lineIndent===r?S=0:t.lineIndent<r&&(S=-1)),1===S)for(;P(t)||B(t);)O(t,!0,-1)?(A=!0,u=a,t.lineIndent>r?S=1:t.lineIndent===r?S=0:t.lineIndent<r&&(S=-1)):u=!1;if(u&&(u=A||s),1!==S&&4!==n||(w=1===n||2===n?r:r+1,k=t.position-t.lineStart,1===S?u&&(F(t,k)||function(e,t,r){var n,i,o,s,a=e.tag,l=e.anchor,u={},c={},h=null,p=null,g=null,m=!1,v=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=u),s=e.input.charCodeAt(e.position);0!==s;){if(n=e.input.charCodeAt(e.position+1),o=e.line,63!==s&&58!==s||!d(n)){if(!L(e,r,2,!1,!0))break;if(e.line===o){for(s=e.input.charCodeAt(e.position);f(s);)s=e.input.charCodeAt(++e.position);if(58===s)d(s=e.input.charCodeAt(++e.position))||x(e,"a whitespace character is expected after the key-value separator within a block mapping"),m&&(T(e,u,c,h,p,null),h=p=g=null),v=!0,m=!1,i=!1,h=e.tag,p=e.result;else {if(!v)return e.tag=a,e.anchor=l,!0;x(e,"can not read an implicit mapping pair; a colon is missed");}}else {if(!v)return e.tag=a,e.anchor=l,!0;x(e,"can not read a block mapping entry; a multiline key may not be an implicit key");}}else 63===s?(m&&(T(e,u,c,h,p,null),h=p=g=null),v=!0,m=!0,i=!0):m?(m=!1,i=!0):x(e,"incomplete explicit mapping pair; a key node is missed"),e.position+=1,s=n;if((e.line===o||e.lineIndent>t)&&(L(e,t,4,!0,i)&&(m?p=e.result:g=e.result),m||(T(e,u,c,h,p,g),h=p=g=null),O(e,!0,-1),s=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==s)x(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return m&&T(e,u,c,h,p,null),v&&(e.tag=a,e.anchor=l,e.kind="mapping",e.result=u),v}(t,k,w))||function(e,t){var r,n,i,o,s,a,l,u,c,h,f=!0,p=e.tag,g=e.anchor,m={};if(91===(h=e.input.charCodeAt(e.position)))i=93,a=!1,n=[];else {if(123!==h)return !1;i=125,a=!0,n={};}for(null!==e.anchor&&(e.anchorMap[e.anchor]=n),h=e.input.charCodeAt(++e.position);0!==h;){if(O(e,!0,t),(h=e.input.charCodeAt(e.position))===i)return e.position++,e.tag=p,e.anchor=g,e.kind=a?"mapping":"sequence",e.result=n,!0;f||x(e,"missed comma between flow collection entries"),c=null,o=s=!1,63===h&&d(e.input.charCodeAt(e.position+1))&&(o=s=!0,e.position++,O(e,!0,t)),r=e.line,L(e,t,1,!1,!0),u=e.tag,l=e.result,O(e,!0,t),h=e.input.charCodeAt(e.position),!s&&e.line!==r||58!==h||(o=!0,h=e.input.charCodeAt(++e.position),O(e,!0,t),L(e,t,1,!1,!0),c=e.result),a?T(e,n,m,u,l,c):o?n.push(T(e,null,m,u,l,c)):n.push(l),O(e,!0,t),44===(h=e.input.charCodeAt(e.position))?(f=!0,h=e.input.charCodeAt(++e.position)):f=!1;}x(e,"unexpected end of the stream within a flow collection");}(t,w)?E=!0:(l&&function(t,r){var n,i,o,s,a,l=1,u=!1,c=r,d=0,p=!1;if(124===(s=t.input.charCodeAt(t.position)))i=!1;else {if(62!==s)return !1;i=!0;}for(t.kind="scalar",t.result="";0!==s;)if(43===(s=t.input.charCodeAt(++t.position))||45===s)1===l?l=43===s?3:2:x(t,"repeat of a chomping mode identifier");else {if(!((o=48<=(a=s)&&a<=57?a-48:-1)>=0))break;0===o?x(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?x(t,"repeat of an indentation width identifier"):(c=r+o-1,u=!0);}if(f(s)){do{s=t.input.charCodeAt(++t.position);}while(f(s));if(35===s)do{s=t.input.charCodeAt(++t.position);}while(!h(s)&&0!==s)}for(;0!==s;){for(z(t),t.lineIndent=0,s=t.input.charCodeAt(t.position);(!u||t.lineIndent<c)&&32===s;)t.lineIndent++,s=t.input.charCodeAt(++t.position);if(!u&&t.lineIndent>c&&(c=t.lineIndent),h(s))d++;else {if(t.lineIndent<c){3===l?t.result+=e.repeat("\n",d):1===l&&u&&(t.result+="\n");break}for(i?f(s)?(p=!0,t.result+=e.repeat("\n",d+1)):p?(p=!1,t.result+=e.repeat("\n",d+1)):0===d?u&&(t.result+=" "):t.result+=e.repeat("\n",d):t.result+=u?e.repeat("\n",d+1):e.repeat("\n",d),u=!0,d=0,n=t.position;!h(s)&&0!==s;)s=t.input.charCodeAt(++t.position);C(t,n,t.position,!1);}}return !0}(t,w)||function(e,t){var r,n,i;if(39!==(r=e.input.charCodeAt(e.position)))return !1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(r=e.input.charCodeAt(e.position));)if(39===r){if(C(e,n,e.position,!0),39!==(r=e.input.charCodeAt(++e.position)))return !0;n=i=e.position,e.position++;}else h(r)?(C(e,n,i,!0),I(e,O(e,!1,t)),n=i=e.position):e.position===e.lineStart&&R(e)?x(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);x(e,"unexpected end of the stream within a single quoted scalar");}(t,w)||function(e,t){var r,n,i,o,s,a,l;if(34!==(a=e.input.charCodeAt(e.position)))return !1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;0!==(a=e.input.charCodeAt(e.position));){if(34===a)return C(e,r,e.position,!0),e.position++,!0;if(92===a){if(C(e,r,e.position,!0),h(a=e.input.charCodeAt(++e.position)))O(e,!1,t);else if(a<256&&_[a])e.result+=y[a],e.position++;else if((s=120===(l=a)?2:117===l?4:85===l?8:0)>0){for(i=s,o=0;i>0;i--)(s=g(a=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+s:x(e,"expected hexadecimal character");e.result+=v(o),e.position++;}else x(e,"unknown escape sequence");r=n=e.position;}else h(a)?(C(e,r,n,!0),I(e,O(e,!1,t)),r=n=e.position):e.position===e.lineStart&&R(e)?x(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position);}x(e,"unexpected end of the stream within a double quoted scalar");}(t,w)?E=!0:!function(e){var t,r,n;if(42!==(n=e.input.charCodeAt(e.position)))return !1;for(n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!d(n)&&!p(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&x(e,"name of an alias node must contain at least one character"),r=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(r)||x(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],O(e,!0,-1),!0}(t)?function(e,t,r){var n,i,o,s,a,l,u,c,g=e.kind,m=e.result;if(d(c=e.input.charCodeAt(e.position))||p(c)||35===c||38===c||42===c||33===c||124===c||62===c||39===c||34===c||37===c||64===c||96===c)return !1;if((63===c||45===c)&&(d(n=e.input.charCodeAt(e.position+1))||r&&p(n)))return !1;for(e.kind="scalar",e.result="",i=o=e.position,s=!1;0!==c;){if(58===c){if(d(n=e.input.charCodeAt(e.position+1))||r&&p(n))break}else if(35===c){if(d(e.input.charCodeAt(e.position-1)))break}else {if(e.position===e.lineStart&&R(e)||r&&p(c))break;if(h(c)){if(a=e.line,l=e.lineStart,u=e.lineIndent,O(e,!1,-1),e.lineIndent>=t){s=!0,c=e.input.charCodeAt(e.position);continue}e.position=o,e.line=a,e.lineStart=l,e.lineIndent=u;break}}s&&(C(e,i,o,!1),I(e,e.line-a),i=o=e.position,s=!1),f(c)||(o=e.position+1),c=e.input.charCodeAt(++e.position);}return C(e,i,o,!1),!!e.result||(e.kind=g,e.result=m,!1)}(t,w,1===n)&&(E=!0,null===t.tag&&(t.tag="?")):(E=!0,null===t.tag&&null===t.anchor||x(t,"alias node should not have any properties")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===S&&(E=u&&F(t,k))),null!==t.tag&&"!"!==t.tag)if("?"===t.tag){for(c=0,m=t.implicitTypes.length;c<m;c+=1)if((b=t.implicitTypes[c]).resolve(t.result)){t.result=b.construct(t.result),t.tag=b.tag,null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);break}}else o.call(t.typeMap,t.tag)?(b=t.typeMap[t.tag],null!==t.result&&b.kind!==t.kind&&x(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+b.kind+'", not "'+t.kind+'"'),b.resolve(t.result)?(t.result=b.construct(t.result),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):x(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")):x(t,"unknown tag !<"+t.tag+">");return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||E}function D(e){var t,r,n,i,s=e.position,l=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(i=e.input.charCodeAt(e.position))&&(O(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==i));){for(l=!0,i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!d(i);)i=e.input.charCodeAt(++e.position);for(n=[],(r=e.input.slice(t,e.position)).length<1&&x(e,"directive name must not be less than one character in length");0!==i;){for(;f(i);)i=e.input.charCodeAt(++e.position);if(35===i){do{i=e.input.charCodeAt(++e.position);}while(0!==i&&!h(i));break}if(h(i))break;for(t=e.position;0!==i&&!d(i);)i=e.input.charCodeAt(++e.position);n.push(e.input.slice(t,e.position));}0!==i&&z(e),o.call(A,r)?A[r](e,r,n):S(e,'unknown document directive "'+r+'"');}O(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,O(e,!0,-1)):l&&x(e,"directives end mark is expected"),L(e,e.lineIndent-1,4,!1,!0),O(e,!0,-1),e.checkLineBreaks&&a.test(e.input.slice(s,e.position))&&S(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&R(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,O(e,!0,-1)):e.position<e.length-1&&x(e,"end of the stream or a document separator is expected");}function U(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var r=new w(e,t);for(r.input+="\0";32===r.input.charCodeAt(r.position);)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)D(r);return r.documents}function N(e,t,r){var n,i,o=U(e,r);for(n=0,i=o.length;n<i;n+=1)t(o[n]);}function j(e,r){var n=U(e,r);if(0!==n.length){if(1===n.length)return n[0];throw new t("expected a single document in the stream, but found more")}}return ft.loadAll=N,ft.load=j,ft.safeLoadAll=function(t,r,i){N(t,r,e.extend({schema:n},i));},ft.safeLoad=function(t,r){return j(t,e.extend({schema:n},r))},ft}var ur=function(){if(Xt)return Jt;Xt=1;var e=function(){if(Kt)return ht;Kt=1;var e=lr();function t(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}return ht.Type=mt(),ht.Schema=vt(),ht.FAILSAFE_SCHEMA=wt(),ht.JSON_SCHEMA=Ct(),ht.CORE_SCHEMA=Et(),ht.DEFAULT_SAFE_SCHEMA=nr(),ht.DEFAULT_FULL_SCHEMA=ar(),ht.load=e.load,ht.loadAll=e.loadAll,ht.safeLoad=e.safeLoad,ht.safeLoadAll=e.safeLoadAll,ht.YAMLException=gt(),ht.MINIMAL_SCHEMA=wt(),ht.SAFE_SCHEMA=nr(),ht.DEFAULT_SCHEMA=ar(),ht.scan=t("scan"),ht.parse=t("parse"),ht.compose=t("compose"),ht.addConstructor=t("addConstructor"),ht}();return Jt=e}(),cr=e.getDefaultExportFromCjs(ur);function hr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (hr=function(){return !!e})()}function fr(t,r,n,i){var o=e._get(e._getPrototypeOf(1&i?t.prototype:t),r,n);return 2&i&&"function"==typeof o?function(e){return o.apply(n,e)}:o}var dr=function(){return e._createClass((function t(r,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;e._classCallCheck(this,t),this.url=r,!n||e.isRelativeURL(n)&&!e.isRelativeURL(this.url)?this.path=e.pathForURL(this.url):this.path=n,this.path_for_parent=n||this.path,this.parent=i,this.container=null,this.parent&&(this.parent.container?this.container=this.parent.container:this.parent.isContainer()&&(this.container=this.parent));}),[{key:"load",value:function(){return gr(this.url)}},{key:"resourceFor",value:function(e){return {url:this.urlFor(e),path:this.pathFor(e),type:this.typeFor(e)}}},{key:"urlFor",value:function(t){return u(t)?t:e.isRelativeURL(t)&&this.container?this.parent.urlFor(this.path_for_parent+t):e.addBaseURL(t,this.path)}},{key:"pathFor",value:function(t){return e.pathForURL(t)}},{key:"typeFor",value:function(t){return e.extensionForURL(t)}},{key:"isContainer",value:function(){return !1}}])}(),pr=function(t){function r(t,n,i){var o,s,a,l;return e._classCallCheck(this,r),s=this,a=r,l=[t,n,i],a=e._getPrototypeOf(a),(o=e._possibleConstructorReturn(s,hr()?Reflect.construct(a,l||[],e._getPrototypeOf(s).constructor):a.apply(s,l))).zip=null,o.files={},o.root=null,o.path="",o}return e._inherits(r,t),e._createClass(r,[{key:"isContainer",value:function(){return !0}},{key:"load",value:function(){return new Promise(function(t,r){var n;return this.zip=new ct,"string"==typeof this.url?Promise.resolve(e.Utils.io(this.url,6e4,"arraybuffer")).then(function(e){try{return n=e.body,Promise.resolve(this.zip.loadAsync(n)).then(function(e){try{return Promise.resolve(this.parseZipFiles()).then(function(e){try{return t(this.loadRoot())}catch(e){return r(e)}}.bind(this),r)}catch(e){return r(e)}}.bind(this),r)}catch(e){return r(e)}}.bind(this),r):t(this)}.bind(this))}},{key:"urlFor",value:function(t){return u(t)?t:e.isRelativeURL(t)?this.urlForZipFile(e.flattenRelativeURL(t)):fr(r,"urlFor",this,3)([t])}},{key:"typeFor",value:function(t){return e.isRelativeURL(t)?this.typeForZipFile(t):fr(r,"typeFor",this,3)([t])}},{key:"loadRoot",value:function(){return this.findRoot(),gr(this.urlForZipFile(this.root))}},{key:"findRoot",value:function(){var t=this,r=Object.keys(this.files).filter((function(e){return 0===t.files[e].depth})).filter((function(t){return "yaml"===e.extensionForURL(t)}));if(1===r.length&&(this.root=r[0]),!this.root){var n="Could not find root scene for bundle '".concat(this.url,"': ");throw n+="The zip archive's root level must contain a single scene file with the '.yaml' extension. ",r.length>0?n+="Found multiple YAML files at the root level: ".concat(r.map((function(e){return "'"+e+"'"})).join(", "),"."):n+="Found NO YAML files at the root level.",Error(n)}}},{key:"parseZipFiles",value:function(){return new Promise(function(t,r){var n,i,o,s,a,l;return n=[],i=[],this.zip.forEach((function(e,t){t.dir||(n.push(e),i.push(t.async("arraybuffer")));})),Promise.resolve(Promise.all(i)).then(function(i){try{for(o=i,s=0;s<o.length;s++)a=n[s],l=a.split("/").length-1,this.files[a]={data:o[s],type:e.extensionForURL(a),depth:l};return t()}catch(e){return r(e)}}.bind(this),r)}.bind(this))}},{key:"urlForZipFile",value:function(t){if(this.files[t])return this.files[t].url||(this.files[t].url=e.createObjectURL(new Blob([this.files[t].data]))),this.files[t].url}},{key:"typeForZipFile",value:function(e){return this.files[e]&&this.files[e].type}}])}(dr);function gr(t){return new Promise((function(r,n){"string"==typeof t?e.Utils.io(t).then((function(e){var t=e.body;try{r(function(e){return cr.safeLoad(e,{json:!0})}(t));}catch(e){n(e);}}),n):(t=Object.assign({},t),r(t));}))}function mr(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return vr(e,t);var r={}.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vr(e,t):void 0}}(e))||t){r&&(e=r);var n=0,i=function(){};return {s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return {s:function(){r=r.call(e);},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e;},f:function(){try{s||null==r.return||r.return();}finally{if(a)throw o}}}}function vr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var _r={loadScene:function(t){var r=arguments;return new Promise(function(n,i){var o,s,a,l,u,c,h,f,d,p;return o=this,a=(s=r.length>1&&void 0!==r[1]?r[1]:{}).path,l=s.type,u=[],c={},Promise.resolve(this.loadSceneRecursive({url:t,path:a,type:l},null,c,u)).then(function(t){try{return h=t,f=this.finalize(h),d=f.config,p=f.bundle,d?(u.length>0&&u.forEach((function(t){var r="Failed to import scene: ".concat(t.url);e.log("error",r,t),o.trigger("error",{type:"scene_import",message:r,error:t,url:t.url});})),n({config:d,bundle:p,texture_nodes:c})):i(u[0])}catch(e){return i(e)}}.bind(this),i)}.bind(this))},loadSceneRecursive:function(t,r){var n=arguments;return new Promise(function(i,o){var s,a,l,u,c,h,f,d,p,g,m;if(s=this,a=t.url,l=t.path,u=t.type,c=n.length>2&&void 0!==n[2]?n[2]:{},h=n.length>3&&void 0!==n[3]?n[3]:[],!a)return i({});f=function(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return null!=i&&"zip"===i||"string"==typeof t&&!e.isLocalURL(t)&&"zip"===e.extensionForURL(t)?new pr(t,r,n):new dr(t,r,n)}(a,l,r,u);var v=function(e){try{return e.url=a,h.push(e),i({})}catch(e){return o(e)}};try{return Promise.resolve(f.load()).then(function(t){try{return null==(d=t).import?(this.normalize(d,f,c),i({config:d,bundle:f})):(Array.isArray(d.import)||(d.import=[d.import]),p=[],d.import.forEach((function(t){"object"===e._typeof(t)&&(t=e.createObjectURL(new Blob([JSON.stringify(t)]))),p.push(f.resourceFor(t));})),delete d.import,g=p.map((function(e){return s.loadSceneRecursive(e,f,c,h)})),Promise.resolve(Promise.all(g)).then(function(t){try{return m=t.map((function(e){return s.normalize(e.config,e.bundle,c)})).map((function(e){return e.config})),this.normalize(d,f,c),d=e.mergeObjects.apply(void 0,e._toConsumableArray(m).concat([d])),i({config:d,bundle:f,texture_nodes:c})}catch(e){return v(e)}}.bind(this),v))}catch(e){return v(e)}}.bind(this),v)}catch(e){v(e);}}.bind(this))},normalize:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.normalizeDataSources(e,t),this.normalizeFonts(e,t),this.normalizeTextures(e,t),this.collectTextures(e,t,r),{config:e,bundle:t,texture_nodes:r}},normalizeDataSources:function(e,t){for(var r in e.sources=e.sources||{},e.sources)this.normalizeDataSource(e.sources[r],t);return e},normalizeDataSource:function(e,t){if(e.url=t.urlFor(e.url),Array.isArray(e.composite)&&e.composite.forEach((function(e){return e.url=t.urlFor(e.url)})),e.scripts)for(var r in Array.isArray(e.scripts)&&(e.scripts=e.scripts.reduce((function(e,t){return e[t]=t,e}),{})),e.scripts)e.scripts[r]=t.urlFor(e.scripts[r]);return e},normalizeFonts:function(e,t){e.fonts=e.fonts||{};var r,n=Object.values(e.fonts).filter((function(e){return "external"!==e})),i=mr(n);try{for(i.s();!(r=i.n()).done;){var o=r.value;(Array.isArray(o)?o:[o]).forEach((function(e){return e.url=t.urlFor(e.url)}));}}catch(e){i.e(e);}finally{i.f();}return e},normalizeTextures:function(e,t){if(e.textures=e.textures||{},e.textures)for(var r in e.textures){var n=e.textures[r];n.url&&(n.url=t.urlFor(n.url));}},collectTextures:function(t,r,n){var i=this;if(t.styles){var o=function(e){var o=t.styles[e],s=o.texture;if("string"==typeof s&&!t.textures[s]){var a=["styles",e,"texture"];i.addTextureNode(a,r,n);}o.material&&["emission","ambient","diffuse","specular","normal"].forEach((function(s){var a=null!=o.material[s]&&o.material[s].texture;if("string"==typeof a&&!t.textures[a]){var l=["styles",e,"material",s,"texture"];i.addTextureNode(l,r,n);}}));};for(var s in t.styles)o(s);}if(t.styles){var a=function(o){var s=t.styles[o];s.shaders&&s.shaders.uniforms&&e.GLSL.parseUniforms(s.shaders.uniforms).forEach((function(s){var a=s.type,l=s.value,u=s.path;if("sampler2D"===a&&"string"==typeof l&&!t.textures[l]){var c=["styles",o,"shaders","uniforms"].concat(e._toConsumableArray(u));i.addTextureNode(c,r,n);}}));};for(var l in t.styles)a(l);}if(t.layers)for(var u=[t.layers],c=[["layers"]];u.length>0;){var h=u.pop(),f=c.pop();if("object"===e._typeof(h)&&!Array.isArray(h))for(var d in h)if("draw"===d){var p=h[d];for(var g in p){if(p[g].texture){var m=p[g].texture;if("string"==typeof m&&!t.textures[m]){var v=[].concat(e._toConsumableArray(f),[d,"draw",g,"texture"]);this.addTextureNode(v,r,n);}}if(p[g].outline&&p[g].outline.texture){var _=p[g].outline.texture;if("string"==typeof _&&!t.textures[_]){var y=[].concat(e._toConsumableArray(f),[d,"draw",g,"outline","texture"]);this.addTextureNode(y,r,n);}}}}else {if(e.isReserved(d))continue;u.push(h[d]),c.push([].concat(e._toConsumableArray(f),[d]));}}},addTextureNode:function(e,t,r){r[JSON.stringify(e)]={path:e,bundle:t};},hoistTextureNodes:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=0,s=Object.values(r);n<s.length;n++){var a=s[n],l=a.path,u=a.bundle,h=i(e,l);if("string"==typeof h&&null==e.textures[h])if(c(e,l)){var f=t.urlFor(h);e.textures[h]={url:f};}else {var d=u.urlFor(h);e.textures[d]={url:d},o(e,l,d);}}},applyGlobalProperties:function(e){return e.global&&0!==Object.keys(e.global).length?f(h(e.global),e):e},finalize:function(e){var t=e.config,r=e.bundle;return t?(t.global=t.global||{},t.scene=t.scene||{},t.cameras=t.cameras||{},t.lights=t.lights||{},t.styles=t.styles||{},t.layers=t.layers||{},t.camera&&(t.cameras.default=t.camera),0===Object.keys(t.cameras).length&&(t.cameras.default={}),(0===Object.keys(t.lights).length||Object.keys(t.lights).every((function(e){return !1===t.lights[e].visible})))&&(t.lights.default_light={type:"directional"}),{config:t,bundle:r}):{}}};e.subscribeMixin(_r);var yr=function(){return e._createClass((function t(){e._classCallCheck(this,t),this.tiles={},this.max_proxy_descendant_depth=6,this.max_proxy_ancestor_depth=7,this.children_cache={};}),[{key:"addTile",value:function(t){for(this.tiles[t.key]=this.tiles[t.key]||{descendants:0},this.tiles[t.key].tile=t;t.style_z>=0;){if(!(t=e.TileID.parent(t)))return;this.tiles[t.key]||(this.tiles[t.key]={descendants:0}),this.tiles[t.key].descendants++;}}},{key:"removeTile",value:function(t){for(this.tiles[t.key]&&(delete this.tiles[t.key].tile,0===this.tiles[t.key].descendants&&delete this.tiles[t.key]);t.style_z>=0;){if(!(t=e.TileID.parent(t)))return;this.tiles[t.key]&&this.tiles[t.key].descendants>0&&(this.tiles[t.key].descendants--,0!==this.tiles[t.key].descendants||this.tiles[t.key].tile||delete this.tiles[t.key]);}}},{key:"getAncestor",value:function(t){for(var r=0;r<this.max_proxy_ancestor_depth;){if(!(t=e.TileID.parent(t)))return;if(this.tiles[t.key]&&this.tiles[t.key].tile&&this.tiles[t.key].tile.loaded)return this.tiles[t.key].tile;r++;}}},{key:"getDescendants",value:function(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=[];if(n<this.max_proxy_descendant_depth){var o=e.TileID.children(t,this.children_cache);if(!o)return;o.forEach((function(t){r.tiles[t.key]&&(r.tiles[t.key].tile&&r.tiles[t.key].tile.loaded?i.push(r.tiles[t.key].tile):r.tiles[t.key].descendants>0&&i.push.apply(i,e._toConsumableArray(r.getDescendants(t,n+1))));}));}return i}}])}(),br={},wr={};function kr(t,r){var n=arguments;return new Promise((function(i,o){var s,a,l,u,c,h;return s=n.length>2&&void 0!==n[2]&&n[2],wr=br,br={},a=function(t,r){var n={};for(var i in t.forEach((function(t){var i=e.Geo.unitsPerMeter(t.coords.z),o=Math.pow(2,r-t.style_z),s=i*o,a=e.Geo.metersPerPixel(r),l=Object.assign({},t.meshes,t.pending_label_meshes);for(var u in l){l[u].forEach((function(r){if(r.labels)for(var o in r.labels)if(!t.isProxy()||wr[o]){var l=r.labels[o].container.label,u=r.labels[o].container.linked,c=r.labels[o].ranges,h={};if(h.discard=xr.bind(h),h.build_id=t.build_id,Object.assign(h,l),h.layout=Object.assign({},l.layout),h.layout.repeat_scale=.75,h.layout.repeat_distance=h.layout.repeat_distance||0,h.layout.repeat_distance/=s,h.position=[h.position[0]/i+t.min.x,h.position[1]/i+t.min.y],h.unit_scale=a,"point"===h.type)e.LabelPoint.prototype.updateBBoxes.call(h);else if("straight"===h.type)e.LabelLineStraight.prototype.updateBBoxes.call(h,h.position,h.size,h.angle,h.angle,h.offset);else if(l.obbs){var f=l.obbs.map((function(r){var n=r.x,o=r.y,a=r.a,l=r.w,u=r.h;return n=n/i+t.min.x,o=o/i+t.min.y,l/=s,u/=s,new e.OBB(n,o,a,l,u)}));h.obbs=f,h.aabbs=f.map((function(e){return e.getExtent()}));}n[o]={label:h,linked:u,ranges:c,mesh:r};}}));}})),n){var o=n[i];o.linked&&(o.linked=n[o.linked]);}return n=Object.keys(n).map((function(e){return n[e]})),n}(t,r),e.Collision.startTile("main",{apply_repeat_groups:!0,return_hidden:!0}),e.Collision.addStyle("main","main"),l=Math.max.apply(Math,[0].concat(e._toConsumableArray(Object.values(t).map((function(e){return Object.values(e.meshes)})).flat().map((function(t){return Math.max.apply(Math,[0].concat(e._toConsumableArray(t.map((function(e){return e.labels?Object.keys(e.labels).length:0})))))}))))),(u=Math.floor(l/e.Geo.tile_size))>0?e.Collision.initGrid({anchor:{x:Math.min.apply(Math,e._toConsumableArray(t.map((function(e){return e.min.x})))),y:Math.min.apply(Math,e._toConsumableArray(t.map((function(e){return e.min.y}))))},span:t[0].span.x/u}):e.Collision.initGrid(),Promise.resolve(e.Collision.collide(a,"main","main")).then((function(e){try{return h=[],(c=e).forEach((function(e){var t=0;!0!==e.show||s&&e.label.breach&&!wr[e.label.id]||(t=1),t&&(br[e.label.id]=!0);var r=!0;e.ranges.forEach((function(n){if(r){var i=e.mesh;if(i.valid){for(var o=i.vertex_layout.offset.a_shape,s=i.vertex_layout.stride,a=0;a<n[1];a++){if(i.vertex_data[n[0]+a*s+o+6]===t)return void(r=!1);i.vertex_data[n[0]+a*s+o+6]=t;}-1===h.indexOf(i)&&h.push(i);}}}));})),h.forEach((function(e){return e.upload()})),t.forEach((function(e){return e.swapPendingLabels()})),i({labels:c,containers:a})}catch(e){return o(e)}}),o)}))}function xr(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.obb)return e.Label.prototype.occluded.call(this,t,r);if(this.obbs)for(var n=0;n<this.obbs.length;n++){var i={aabb:this.aabbs[n],obb:this.obbs[n]};if(e.Label.prototype.occluded.call(i,t,r))return !0}return !1}var Sr=function(){return e._createClass((function t(r){var n=r.scene;e._classCallCheck(this,t),this.scene=n,this.tiles={},this.pyramid=new yr,this.visible_coords={},this.queued_coords=[],this.building_tiles=null,this.renderable_tiles=[],this.collision={tile_keys:null,mesh_set:null,zoom:null,zoom_steps:3},this.main_thread_target=["TileManager",this.scene.id].join("_"),e.WorkerBroker.addTarget(this.main_thread_target,this);}),[{key:"destroy",value:function(){this.forEachTile((function(e){return e.destroy()})),this.tiles={},this.pyramid=null,this.visible_coords={},this.queued_coords=[],this.scene=null,e.WorkerBroker.removeTarget(this.main_thread_target);}},{key:"view",get:function(){return this.scene.view}},{key:"style_manager",get:function(){return this.scene.style_manager}},{key:"keepTile",value:function(e){this.tiles[e.key]=e,this.pyramid.addTile(e);}},{key:"hasTile",value:function(e){return void 0!==this.tiles[e]}},{key:"forgetTile",value:function(e){if(this.hasTile(e)){var t=this.tiles[e];this.pyramid.removeTile(t);}delete this.tiles[e],this.tileBuildStop(e);}},{key:"removeTile",value:function(t){e.log("trace","tile unload for ".concat(t));var r=this.tiles[t];null!=r&&r.destroy(),this.forgetTile(r.key),this.scene.requestRedraw();}},{key:"forEachTile",value:function(e){for(var t in this.tiles)e(this.tiles[t]);}},{key:"removeTiles",value:function(e){var t=[];for(var r in this.tiles){e(this.tiles[r])&&t.push(r);}for(var n=0;n<t.length;n++){var i=t[n];this.removeTile(i);}}},{key:"updateTilesForView",value:function(){this.visible_coords={};for(var e=this.view.findVisibleTileCoordinates(),t=0;t<e.length;t++){var r=e[t];this.queueCoordinate(r),this.visible_coords[r.key]=r;}this.updateTileStates();}},{key:"updateTileStates",value:function(){var e=this;return this.forEachTile((function(t){e.updateVisibility(t);})),this.loadQueuedCoordinates(),this.updateProxyTiles(),this.view.pruneTilesForView(),this.updateRenderableTiles(),this.style_manager.updateActiveStyles(this.renderable_tiles),this.style_manager.updateActiveBlendOrders(this.renderable_tiles),this.updateLabels()}},{key:"updateLabels",value:function(){var t=this;if(this.scene.building&&!this.scene.building.initial)return Promise.resolve({});var r=this.renderable_tiles.filter((function(e){return e.valid})).filter((function(e){return e.built}));return 0===r.length?Promise.resolve({}):(r.sort((function(e,t){return e.build_id<t.build_id?-1:e.build_id>t.build_id?1:0})),this.collision.zoom===Ar(this.view.zoom,this.collision.zoom_steps)&&this.collision.tile_keys===JSON.stringify(r.map((function(e){return e.key})))&&this.collision.mesh_set===Cr(r)?Promise.resolve({}):(this.collision.task||(this.collision.zoom=Ar(this.view.zoom,this.collision.zoom_steps),this.collision.tile_keys=JSON.stringify(r.map((function(e){return e.key}))),this.collision.mesh_set=Cr(r),this.collision.task={type:"tileManagerUpdateLabels",run:function(n){return new Promise((function(i,o){var s;return Promise.resolve(kr(r,t.collision.zoom,t.isLoadingVisibleTiles())).then((function(r){try{return s=r,t.scene.requestRedraw(),t.collision.task=null,e.Task.finish(n,s),t.updateTileStates(),i()}catch(e){return o(e)}}),o)}))},immediate:!0},e.Task.add(this.collision.task)),this.collision.task.promise))}},{key:"updateProxyTiles",value:function(){var e=this;if(0!==this.view.zoom_direction){this.forEachTile((function(e){return e.setProxyFor(null)}));var t=!1;this.forEachTile((function(r){if(r.visible&&!r.labeled){var n=e.pyramid.getAncestor(r);if(n)n.setProxyFor(r),t=!0;else for(var i=e.pyramid.getDescendants(r),o=0;o<i.length;o++)i[o].setProxyFor(r),t=!0;}})),t||(this.view.zoom_direction=0);}}},{key:"updateVisibility",value:function(t){if(t.visible=!1,t.style_z===this.view.tile_zoom)if(this.visible_coords[t.coords.key])t.visible=!0;else for(var r in this.visible_coords)if(e.TileID.isDescendant(t.coords,this.visible_coords[r])){t.visible=!0;break}}},{key:"pruneToVisibleTiles",value:function(){this.removeTiles((function(e){return !e.visible}));}},{key:"getRenderableTiles",value:function(){return this.renderable_tiles}},{key:"updateRenderableTiles",value:function(){for(var e in this.renderable_tiles=[],this.tiles){var t=this.tiles[e];t.visible&&t.loaded&&this.renderable_tiles.push(t);}return this.renderable_tiles}},{key:"isLoadingVisibleTiles",value:function(){var e=this;return Object.keys(this.tiles).some((function(t){return e.tiles[t].visible&&!e.tiles[t].built}))}},{key:"allVisibleTilesLabeled",value:function(){return this.renderable_tiles.every((function(e){return e.labeled}))}},{key:"queueCoordinate",value:function(e){this.queued_coords[this.queued_coords.length]=e;}},{key:"loadQueuedCoordinates",value:function(){var t=this;0!==this.queued_coords.length&&(this.queued_coords.sort((function(r,n){var i=t.view.center.meters,o=e.Geo.metersPerTile(r.z)/2,s=e.Geo.metersForTile(r);s.x+=o,s.y-=o;var a=e.Geo.metersForTile(n);a.x+=o,a.y-=o;var l=Math.abs(i.x-s.x)+Math.abs(i.y-s.y),u=Math.abs(i.x-a.x)+Math.abs(i.y-a.y);return r.center_dist=l,n.center_dist=u,u>l?-1:u===l?0:1})),this.queued_coords.forEach((function(e){return t.loadCoordinate(e)})),this.queued_coords=[]);}},{key:"loadCoordinate",value:function(t){if(t.z===this.view.center.tile.z)for(var r in this.scene.sources){var n=this.scene.sources[r];if(n.builds_geometry_tiles&&n.includesTile(t,this.view.tile_zoom)){var i=e.TileID.normalizedKey(t,n,this.view.tile_zoom);if(i&&!this.hasTile(i)){e.log("trace","load tile ".concat(i,", distance from view center: ").concat(t.center_dist));var o=new e.Tile({source:n,coords:t,workers:this.scene.workers,style_z:this.view.baseZoom(t.z),view:this.view});this.keepTile(o),this.buildTile(o);}}}}},{key:"buildTile",value:function(e,t){this.tileBuildStart(e.key),this.updateVisibility(e),e.build(this.scene.generation,t);}},{key:"buildTileStylesCompleted",value:function(t){var r=t.tile,n=t.progress;if(null==this.tiles[r.key])e.log("trace","discarded tile ".concat(r.key," in TileManager.buildTileStylesCompleted because previously removed")),e.Tile.abortBuild(r),this.updateTileStates();else if(r.generation!==this.scene.generation)e.log("trace","discarded tile ".concat(r.key," in TileManager.buildTileStylesCompleted because built with ")+"scene config gen ".concat(r.generation,", current ").concat(this.scene.generation)),e.Tile.abortBuild(r),this.updateTileStates();else {if(this.tiles[r.key]){if(r.id<this.tiles[r.key].id)return e.log("trace","discarded tile ".concat(r.key," for id ").concat(r.id," in TileManager.buildTileStylesCompleted because built for discarded tile id")),void e.Tile.abortBuild(r);r=this.tiles[r.key].merge(r);}n.done&&(r.built=!0),r.buildMeshes(this.scene.styles,n),this.updateTileStates(),this.scene.requestRedraw();}n.done&&this.tileBuildStop(r.key);}},{key:"buildTileError",value:function(t){e.log("error","Error building tile ".concat(t.key,":"),t.error),this.forgetTile(t.key),e.Tile.abortBuild(t);}},{key:"tileBuildStart",value:function(t){this.building_tiles=this.building_tiles||{},this.building_tiles[t]=!0,e.log("trace","tileBuildStart for ".concat(t,": ").concat(Object.keys(this.building_tiles).length));}},{key:"tileBuildStop",value:function(t){this.building_tiles&&(e.log("trace","tileBuildStop for ".concat(t,": ").concat(Object.keys(this.building_tiles).length)),delete this.building_tiles[t],this.checkBuildQueue());}},{key:"checkBuildQueue",value:function(){this.building_tiles&&0!==Object.keys(this.building_tiles).length||(this.building_tiles=null,this.scene.tileManagerBuildDone());}},{key:"getDebugProp",value:function(e,t){var r=[];for(var n in this.tiles)null==this.tiles[n].debug[e]||"function"==typeof t&&!0!==t(this.tiles[n])||r.push(this.tiles[n].debug[e]);return r}},{key:"getDebugSum",value:function(e,t){var r=0;for(var n in this.tiles)null==this.tiles[n].debug[e]||"function"==typeof t&&!0!==t(this.tiles[n])||(r+=this.tiles[n].debug[e]);return r}},{key:"getDebugAverage",value:function(e,t){return this.getDebugSum(e,t)/Object.keys(this.tiles).length}}])}();function Ar(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return (Math.floor(e*t)/t).toFixed(r)}function Cr(t){return JSON.stringify(Object.entries(t).map((function(t){var r=e._slicedToArray(t,2)[1];return Object.entries(r.meshes).map((function(t){return e._slicedToArray(t,2)[1].map((function(e){return e.created_at}))}))})))}var Er=function(){return e._createClass((function t(r,n){e._classCallCheck(this,t),n(r),this.value=r,this.setup=n;}),[{key:"set",value:function(e){JSON.stringify(this.value)!==JSON.stringify(e)&&(this.setup(e),this.value=e);}}])}(),Tr=e._createClass((function t(r){e._classCallCheck(this,t),this.defaults={},this.defaults.culling=!0,this.defaults.culling_face=r.BACK,this.defaults.blending=!1,this.defaults.blending_src=r.ONE_MINUS_SRC_ALPHA,this.defaults.blending_dst=r.ONE_MINUS_SRC_ALPHA,this.defaults.blending_src_alpha=r.ONE,this.defaults.blending_dst_alpha=r.ONE_MINUS_SRC_ALPHA,this.defaults.depth_write=!0,this.defaults.depth_test=!0,r.depthFunc(r.LESS),this.culling=new Er({cull:this.defaults.culling,face:this.defaults.culling_face},(function(e){e.cull?(r.enable(r.CULL_FACE),r.cullFace(e.face)):r.disable(r.CULL_FACE);})),this.blending=new Er({blend:this.defaults.blending,src:this.defaults.blending_src,dst:this.defaults.blending_dst,src_alpha:this.defaults.blending_src_alpha,dst_alpha:this.defaults.blending_dst_alpha},(function(e){e.blend?(r.enable(r.BLEND),e.src_alpha&&e.dst_alpha?r.blendFuncSeparate(e.src,e.dst,e.src_alpha,e.dst_alpha):r.blendFunc(e.src,e.dst)):r.disable(r.BLEND);})),this.depth_write=new Er({depth_write:this.defaults.depth_write},(function(e){r.depthMask(e.depth_write);})),this.depth_test=new Er({depth_test:this.defaults.depth_test},(function(e){e.depth_test?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST);}));})),zr=function(){return e._createClass((function t(){e._classCallCheck(this,t),this.canvas=null,this.gl=null,this.screenshot_canvas=null,this.screenshot_context=null,this.queue_screenshot=null,this.video_capture=null;}),[{key:"setCanvas",value:function(e,t){this.canvas=e,this.gl=t;}},{key:"screenshot",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).background;return null!=this.queue_screenshot||(this.queue_screenshot={background:t},this.queue_screenshot.promise=new Promise((function(t,r){e.queue_screenshot.resolve=t,e.queue_screenshot.reject=r;}))),this.queue_screenshot.promise}},{key:"completeScreenshot",value:function(){if(null!=this.queue_screenshot){var t=this.canvas.width,r=this.canvas.height,n=new Uint8Array(t*r*4);this.gl.readPixels(0,0,t,r,this.gl.RGBA,this.gl.UNSIGNED_BYTE,n);var i=this.queue_screenshot.background;i=i&&"transparent"!==i?e.StyleParser.parseColor(i).slice(0,3).map((function(e){return 255*e})):null;for(var o=new Uint8ClampedArray(t*r*4),s=0;s<r;s++)for(var a=0;a<t;a++){var l=4*((r-s-1)*t+a),u=4*(s*t+a),c=n[l+3];o[u+0]=255*n[l+0]/c,o[u+1]=255*n[l+1]/c,o[u+2]=255*n[l+2]/c,o[u+3]=c,i&&(c/=255,o[u+0]=o[u+0]*c+i[0]*(1-c),o[u+1]=o[u+1]*c+i[1]*(1-c),o[u+2]=o[u+2]*c+i[2]*(1-c),o[u+3]=255);}this.screenshot_canvas=this.screenshot_canvas||document.createElement("canvas");var h=this.screenshot_canvas;h.width=t,h.height=r,this.screenshot_context=this.screenshot_context||h.getContext("2d");var f=this.screenshot_context,d=new ImageData(o,t,r);f.putImageData(d,0,0);for(var p=h.toDataURL("image/png"),g=atob(p.slice(22)),m=new Uint8Array(g.length),v=0;v<g.length;++v)m[v]=g.charCodeAt(v);var _=new Blob([m],{type:"image/png"});this.queue_screenshot.resolve({url:p,blob:_,type:"png"}),this.queue_screenshot=null;}}},{key:"startVideoCapture",value:function(){var t=this;if("function"!=typeof window.MediaRecorder||!this.canvas||"function"!=typeof this.canvas.captureStream)return e.log("warn","Video capture (Canvas.captureStream and/or MediaRecorder APIs) not supported by browser"),!1;if(this.video_capture)return e.log("warn","Video capture already in progress, call Scene.stopVideoCapture() first"),!1;try{var r=this.video_capture={};r.chunks=[],r.stream=this.canvas.captureStream(),r.options={mimeType:"video/webm"},r.media_recorder=new MediaRecorder(r.stream,r.options),r.media_recorder.ondataavailable=function(n){if(n.data.size>0&&r.chunks.push(n.data),r.resolve){var i=new Blob(r.chunks,{type:r.options.mimeType}),o=e.createObjectURL(i);if(r.stream)(r.stream.getTracks()||[]).forEach((function(e){e.stop(),r.stream.removeTrack(e);}));r.stream=null,r.media_recorder=null,t.video_capture=null,r.resolve({url:o,blob:i,type:"webm"});}},r.media_recorder.start();}catch(t){return this.video_capture=null,e.log("error","Scene video capture failed",t),!1}return !0}},{key:"stopVideoCapture",value:function(){var t=this;return this.video_capture?(this.video_capture.promise=new Promise((function(e,r){t.video_capture.resolve=e,t.video_capture.reject=r;})),this.video_capture.media_recorder.stop(),this.video_capture.promise):(e.log("warn","No scene video capture in progress, call Scene.startVideoCapture() first"),Promise.resolve({}))}}])}();function Or(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function Rr(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?Or(Object(n),!0).forEach((function(r){e._defineProperty(t,r,n[r]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Or(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));}));}return t}function Ir(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Fr(e,t);var r={}.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fr(e,t):void 0}}(e))||t){r&&(e=r);var n=0,i=function(){};return {s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return {s:function(){r=r.call(e);},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e;},f:function(){try{s||null==r.return||r.return();}finally{if(a)throw o}}}}function Fr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Pr,Br=function(){function t(r,n){var i;e._classCallCheck(this,t),n=n||{},e.subscribeMixin(this),this.id=t.id++,this.initialized=!1,this.initializing=null,this.sources={},this.view=new e.View(this,n),this.tile_manager=new Sr({scene:this}),this.num_workers=n.numWorkers||2,!0===n.disableVertexArrayObjects&&(e.VertexArrayObject.disabled=!0),e.Utils.use_high_density_display=void 0===n.highDensityDisplay||n.highDensityDisplay,e.Utils.updateDevicePixelRatio(),this.config=null,this.config_source=r,this.config_bundle=null,this.last_valid_config_source=null,this.styles=null,this.style_manager=new e.StyleManager,this.building=null,this.dirty=!0,n.preUpdate&&this.subscribe({pre_update:n.preUpdate}),n.postUpdate&&this.subscribe({post_update:n.postUpdate}),this.render_loop=!n.disableRenderLoop,this.render_loop_active=!1,this.render_loop_stop=!1,this.render_count=0,this.last_render_count=0,this.render_count_changed=!1,this.frame=0,this.last_main_render=-1,this.last_selection_render=-1,this.media_capture=new zr,this.selection=null,this.selection_feature_count=0,this.fetching_selection_map=null,this.prev_textures=null,this.introspection=!0===n.introspection,this.times={},this.resetTime(),this.container=n.container,this.canvas=null,this.contextOptions=n.webGLContextOptions,this.lights=null,this.background=null,this.createListeners(),this.updating=0,this.generation=t.generation,this.last_complete_generation=t.generation,(i=this).debug={profile:function(t){console.profile("main thread: ".concat(t)),e.WorkerBroker.postMessage(i.workers,"self.profile",t);},profileEnd:function(t){console.profileEnd("main thread: ".concat(t)),e.WorkerBroker.postMessage(i.workers,"self.profileEnd",t);},timeRebuild:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[],o=function(){var s=+new Date;i.rebuild(r).then((function(){if(n.push(+new Date-s),n.length<t)o();else {var r=~~(n.reduce((function(e,t){return e+t}))/n.length);e.log("info","Profiled rebuild ".concat(t," times: ").concat(r," avg (").concat(Math.min.apply(Math,n)," min, ").concat(Math.max.apply(Math,n)," max)"));}}));};o();},geometryCountByStyle:function(){var e={};return i.tile_manager.getRenderableTiles().forEach((function(t){var r=function(r){e[r]=e[r]||0,t.meshes[r].forEach((function(t){e[r]+=t.geometry_count;}));};for(var n in t.meshes)r(n);})),e},geometryCountByBaseStyle:function(){var e=i.debug.geometryCountByStyle(),t={};for(var r in e){var n=i.styles[r].baseStyle();t[n]=t[n]||0,t[n]+=e[r];}return t},geometryCountTotal:function(){var e=i.debug.geometryCountByStyle();return Object.keys(e).reduce((function(t,r){return e[r]+t}),0)},geometrySizeByStyle:function(){var e={};return i.tile_manager.getRenderableTiles().forEach((function(t){var r=function(r){e[r]=e[r]||0,t.meshes[r].forEach((function(t){e[r]+=t.buffer_size;}));};for(var n in t.meshes)r(n);})),e},geometrySizeByBaseStyle:function(){var e=i.debug.geometrySizeByStyle(),t={};for(var r in e){var n=i.styles[r].baseStyle();t[n]=t[n]||0,t[n]+=e[r];}return t},geometrySizeTotal:function(){var e=i.debug.geometrySizeByStyle();return Object.keys(e).reduce((function(t,r){return e[r]+t}),0)},textureSizeTotal:function(){return Object.values(e.Texture.textures).map((function(e){return e.byteSize()})).reduce((function(e,t){return e+t}))},layerStats:function(){return e.debugSettings.layer_stats?e.debugSumLayerStats(i.tile_manager.getRenderableTiles()):(e.log("warn","Enable the 'layer_stats' debug setting to collect layer stats"),{})},renderableTilesCount:function(){return i.tile_manager.getRenderableTiles().length}},this.log_level=n.logLevel||"warn",e.log.setLevel(this.log_level),e.log.reset();}return e._createClass(t,[{key:"load",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initializing||(e.log.reset(),this.updating++,this.initialized=!1,this.view_complete=!1,this.times.frame=null,this.times.build=null,(n="string"==typeof n?{base_path:n}:n).blocking=void 0===n.blocking||n.blocking,!1!==this.render_loop&&this.setupRenderLoop(),this.createCanvas(),this.prev_textures=this.config&&Object.keys(this.config.textures),this.initializing=this.loadScene(r,n).then((function(r){return new Promise((function(i,o){var s,a,l;return s=r.texture_nodes,Promise.resolve(t.createWorkers()).then(function(r){try{if(t.destroyFeatureSelection(),e.WorkerBroker.postMessage(t.workers,"self.clearFunctionStringCache"),a="object"===e._typeof(t.config_source)||t.hasSubscribersFor("load"),l=t.updateConfig({texture_nodes:s,serialize_funcs:a,normalize:!1,loading:!0,fade_in:!0}),!0===n.blocking)return Promise.resolve(l).then(function(e){try{return u.call(this)}catch(e){return o(e)}}.bind(this),o);function u(){return t.freePreviousTextures(),t.updating--,t.initializing=null,t.initialized=!0,t.last_valid_config_source=t.config_source,t.last_valid_options={base_path:n.base_path,file_type:n.file_type},t.requestRedraw(),i()}return u.call(this)}catch(c){return o(c)}}.bind(this),o)}))})).catch((function(r){var n,i;if(t.initializing=null,t.updating=0,"YAMLException"===r.name?(n="yaml",i="Error parsing scene YAML"):i="Error initializing scene",t.trigger("error",{type:n,message:i,error:r,url:t.config_source}),i="Scene.load() failed to load ".concat(JSON.stringify(t.config_source),": ").concat(r.message),t.last_valid_config_source)return e.log("warn",i,r),e.log("info","Scene.load() reverting to last valid configuration"),t.load(t.last_valid_config_source,t.last_valid_base_path);throw e.log("error",i,r),r}))),this.initializing}},{key:"destroy",value:function(){if(this.initialized=!1,this.render_loop_stop=!0,this.destroyListeners(),this.destroyFeatureSelection(),this.canvas&&this.canvas.parentNode&&(this.canvas.parentNode.removeChild(this.canvas),this.canvas=null),this.container=null,this.gl){e.Texture.destroy(this.gl),this.style_manager.destroy(this.gl),this.styles={},e.ShaderProgram.reset();var t=this.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this.gl=null;}this.sources={},this.destroyWorkers(),this.tile_manager.destroy(),this.tile_manager=null,e.log.reset();}},{key:"createCanvas",value:function(){if(!this.canvas){this.container=this.container||document.body,this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.top=0,this.canvas.style.left=0,this.container.style.backgroundColor="transparent",this.container.appendChild(this.canvas);try{this.gl=r.getContext(this.canvas,Object.assign({alpha:!0,premultipliedAlpha:!0,stencil:!0,device_pixel_ratio:e.Utils.device_pixel_ratio,powerPreference:"high-performance"},this.contextOptions));}catch(e){throw new Error("Couldn't create WebGL context. Your browser may not support WebGL, or it's turned off? Visit http://webglreport.com/ for more info.")}this.resizeMap(this.container.clientWidth,this.container.clientHeight),e.VertexArrayObject.init(this.gl),this.render_states=new Tr(this.gl),this.media_capture.setCanvas(this.canvas,this.gl);}}},{key:"updateExternalScripts",value:function(){var t=e._toConsumableArray(this.external_scripts||[]),r=[];if(this.config.scene.scripts)for(var n in this.config.scene.scripts)-1===r.indexOf(this.config.scene.scripts[n])&&r.push(this.config.scene.scripts[n]);for(var i in this.config.sources){var o=this.config.sources[i];if(o.scripts)for(var s in o.scripts)-1===r.indexOf(o.scripts[s])&&r.push(o.scripts[s]);}return this.external_scripts=r,!(this.external_scripts.length===t.length&&this.external_scripts.every((function(e,r){return e===t[r]})))}},{key:"createWorkers",value:function(){return this.updateExternalScripts()&&this.destroyWorkers(),this.workers?Promise.resolve():this.makeWorkers()}},{key:"makeWorkers",value:function(){var t=this,r=!!this.gl.getExtension("OES_element_index_uint"),n=[];this.workers=[];for(var i=function(){var i=new Worker(Tangram.workerURL);t.workers[o]=i,e.WorkerBroker.addWorker(i),e.log("debug","Scene.makeWorkers: initializing worker ".concat(o));var s=o;n.push(e.WorkerBroker.postMessage(i,"self.init",t.id,o,t.num_workers,t.log_level,e.Utils.device_pixel_ratio,r,t.external_scripts).then((function(t){return e.log("debug","Scene.makeWorkers: initialized worker ".concat(t)),t}),(function(t){return e.log("error","Scene.makeWorkers: failed to initialize worker ".concat(s,":"),t),Promise.reject(t)})));},o=0;o<this.num_workers;o++)i();return this.next_worker=0,Promise.all(n).then((function(){e.log.setWorkers(t.workers);}))}},{key:"destroyWorkers",value:function(){this.selection=null,Array.isArray(this.workers)&&(e.log.setWorkers(null),this.workers.forEach((function(e){e.terminate();})),this.workers=null);}},{key:"ready",value:function(){return !(!this.view.ready()||0===Object.keys(this.sources).length)}},{key:"updateDevicePixelRatio",value:function(){var t=this;e.Utils.updateDevicePixelRatio()&&e.WorkerBroker.postMessage(this.workers,"self.updateDevicePixelRatio",e.Utils.device_pixel_ratio).then((function(){return t.rebuild()})).then((function(){return t.resizeMap(t.view.size.css.width,t.view.size.css.height)}));}},{key:"resizeMap",value:function(t,n){0===t&&0===n||(this.dirty=!0,this.view.setViewportSize(t,n),this.gl&&r.resize(this.gl,t,n,e.Utils.device_pixel_ratio));}},{key:"requestRedraw",value:function(){this.dirty=!0;}},{key:"immediateRedraw",value:function(){this.dirty=!0,this.update();}},{key:"renderLoop",value:function(){this.render_loop_active=!0,this.update(),e.Task.setState({user_moving_view:this.view.user_input_active}),e.Task.processAll(),this.render_loop_stop?(this.render_loop_stop=!1,this.render_loop_active=!1):window.requestAnimationFrame(this.renderLoop.bind(this));}},{key:"setupRenderLoop",value:function(){var e=this;this.render_loop_active||setTimeout((function(){e.renderLoop();}),0);}},{key:"update",value:function(){var t=this.dirty,r=!!this.selection&&this.selection.hasPendingRequests(),n=!(!1===t&&!1===r||!1===this.initialized||this.updating>0||!1===this.ready());return this.trigger("pre_update",n),this.view.update(),!!n&&(this.dirty=!1,this.updateDevicePixelRatio(),this.render({main:t,selection:r}),this.updateViewComplete(),this.media_capture.completeScreenshot(),this.trigger("post_update",n),(!0===this.animated||this.view.isAnimating())&&(this.dirty=!0),this.frame++,e.log("trace","Scene.render()"),!0)}},{key:"render",value:function(t){var r=this,n=t.main,i=t.selection,o=this.gl;if(this.updateBackground(),Object.keys(this.lights).forEach((function(e){return r.lights[e].update()})),this.render_count_changed=!1,n&&(this.render_count=this.renderPass(),this.last_main_render=this.frame,this.render_count!==this.last_render_count&&(this.render_count_changed=!0,this.logFirstFrame(),this.getFeatureSelectionMapSize().then((function(t){r.selection_feature_count=t,e.log("info","Scene: rendered ".concat(r.render_count," primitives (").concat(t," features in selection map)"));}))),this.last_render_count=this.render_count),i){if(this.view.panning||this.view.user_input_active)return void this.selection.clearPendingRequests();!this.selection.locked&&this.last_selection_render<this.last_main_render&&(this.selection.bind(),this.renderPass("selection_program",{allow_blend:!1}),o.bindFramebuffer(o.FRAMEBUFFER,null),o.viewport(0,0,this.canvas.width,this.canvas.height),o.clearColor.apply(o,e._toConsumableArray(this.background.computed_color)),this.last_selection_render=this.frame),this.selection.read();}return !0}},{key:"renderPass",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"program",n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allow_blend;n=null==n||n,this.clearFrame();var i,o,s=0,a=Ir(this.style_manager.getActiveBlendOrders());try{for(a.s();!(o=a.n()).done;)for(var l=o.value,u=l.blend_order,c=l.styles,h=function(){var o=t.styles[c[f]];if(null==o)return 1;if(o.blend!==i){var a=Object.assign({},e.Style.render_states[o.blend],{blend:n&&o.blend});t.setRenderState(a);}var l=n&&o.blend;if("translucent"===l)t.gl.colorMask(!1,!1,!1,!1),t.renderStyle(o.name,r,u),t.gl.colorMask(!0,!0,!0,!0),t.gl.depthFunc(t.gl.EQUAL),t.gl.enable(t.gl.STENCIL_TEST),t.gl.clearStencil(0),t.gl.clear(t.gl.STENCIL_BUFFER_BIT),t.gl.stencilFunc(t.gl.EQUAL,t.gl.ZERO,255),t.gl.stencilOp(t.gl.KEEP,t.gl.KEEP,t.gl.INCR),s+=t.renderStyle(o.name,r,u),t.gl.disable(t.gl.STENCIL_TEST),t.gl.depthFunc(t.gl.LESS);else if("opaque"!==l&&!0===o.stencil_proxy_tiles){var h=t.tile_manager.getRenderableTiles().filter((function(e){return e.meshes[o.name]})).map((function(e){return e.proxy_level})).reduce((function(e,t){return e.indexOf(t)>-1||e.push(t),e}),[]).sort();if(h.length>1){t.gl.enable(t.gl.STENCIL_TEST),t.gl.clearStencil(0),t.gl.clear(t.gl.STENCIL_BUFFER_BIT),t.gl.stencilOp(t.gl.KEEP,t.gl.KEEP,t.gl.REPLACE);for(var d=0;d<h.length;d++)t.gl.stencilFunc(t.gl.GEQUAL,h.length-d,255),s+=t.renderStyle(o.name,r,u,h[d]);t.gl.disable(t.gl.STENCIL_TEST);}else s+=t.renderStyle(o.name,r,u);}else s+=t.renderStyle(o.name,r,u);i=o.blend;},f=0;f<c.length;f++)h();}catch(e){a.e(e);}finally{a.f();}return s}},{key:"renderStyle",value:function(t,r,n){for(var i,o,s=this,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=this.styles[t],u=!0,c=0,h=this.tile_manager.getRenderableTiles().filter((function(e){return "number"!=typeof a||e.proxy_level===a})).map((function(e){if(e.meshes[t])return [e,e.meshes[t].filter((function(e){return e.variant.blend_order===n}))]})).filter((function(e){return e})),f=Math.max.apply(Math,e._toConsumableArray(h.map((function(t){var r=e._slicedToArray(t,2)[1];return Math.max.apply(Math,e._toConsumableArray(r.map((function(e){return e.variant.mesh_order}))))})))),d=function(n){var o,a=Ir(h);try{var f,d=function(){var a=e._slicedToArray(o.value,2),h=a[0],f=a[1],d=!0;if(!h.shouldProxyForStyle(t))return 0;var p=f.filter((function(e){return e.variant.mesh_order===n}));return 0===p.length?0:!0!==u||(u=!1,i=s.setupStyle(l,r))?void p.forEach((function(e){!0===d&&(d=!1,s.view.setupTile(h,i)),l.render(e)&&s.requestRedraw(),c+=e.geometry_count;})):{v:{v:0}}};for(a.s();!(o=a.n()).done;)if(0!==(f=d())&&f)return f.v}catch(e){a.e(e);}finally{a.f();}},p=0;p<f+1;p++)if(o=d(p))return o.v;return c}},{key:"setupStyle",value:function(e,t){var r;try{if(!(r=e.getProgram(t)))return}catch(t){return void this.trigger("warning",{type:"styles",message:"Error compiling style ".concat(e.name),style:e,shader_errors:e.program&&e.program.shader_errors})}for(var n in r.use(),e.setup(),r.uniform("1f","u_time",this.animated?(+new Date-this.start_time)/1e3:0),this.view.setupProgram(r),this.lights)this.lights[n].setupProgram(r);return r}},{key:"clearFrame",value:function(){this.initialized&&(this.render_states.depth_write.set({depth_write:!0}),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT|this.gl.STENCIL_BUFFER_BIT));}},{key:"setRenderState",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.depth_test,r=e.depth_write,n=e.cull_face,i=e.blend;if(this.initialized){var o=this.render_states;t=!1!==t&&o.defaults.depth_test,r=!1!==r&&o.defaults.depth_write,n=!1!==n&&o.defaults.culling,i=null!=i?i:o.defaults.blending;var s=this.gl;o.depth_test.set({depth_test:t}),o.depth_write.set({depth_write:r}),o.culling.set({cull:n,face:o.defaults.culling_face}),i?"opaque"===i?o.blending.set({blend:!1}):"overlay"===i||"inlay"===i||"translucent"===i?o.blending.set({blend:!0,src:s.SRC_ALPHA,dst:s.ONE_MINUS_SRC_ALPHA,src_alpha:s.ONE,dst_alpha:s.ONE_MINUS_SRC_ALPHA}):"add"===i?o.blending.set({blend:!0,src:s.ONE,dst:s.ONE}):"multiply"===i&&o.blending.set({blend:!0,src:s.ZERO,dst:s.SRC_COLOR}):o.blending.set({blend:!1});}}},{key:"getFeatureAt",value:function(t){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).radius;if(!this.initialized)return e.log("debug","Scene.getFeatureAt() called before scene was initialized"),Promise.resolve();if(0===this.selection_feature_count)return Promise.resolve();this.selection||this.resetFeatureSelection();var n={x:t.x/this.view.size.css.width,y:t.y/this.view.size.css.height};return r=r>0?{x:r/this.view.size.css.width,y:r/this.view.size.css.height}:null,this.selection.getFeatureAt(n,{radius:r}).then((function(e){return Object.assign(e,{pixel:t})})).catch((function(e){return Promise.resolve({error:e})}))}},{key:"queryFeatures",value:function(){var t=arguments;return new Promise(function(r,n){var i,o,s,a,l,u,c,h,f,d,p,g,m,v,_,y,b;return o=(i=t.length>0&&void 0!==t[0]?t[0]:{}).filter,s=i.unique,a=void 0===s||s,l=i.group_by,u=void 0===l?null:l,h=void 0===(c=i.visible)?null:c,f=i.geometry,d=void 0!==f&&f,this.initialized?(o=e.Utils.serializeWithFunctions(o),p=!0===(a="string"==typeof a?[a]:a)||Array.isArray(a)&&a.indexOf("$id")>-1,g=a&&function(t){var r=Array.isArray(a)?e.sliceObject(t.properties,a):t.properties,n=p?t.id:null;return d?JSON.stringify({geometry:t.geometry,properties:r,id:n}):JSON.stringify({properties:r,id:n})},u=("string"==typeof u||Array.isArray(u))&&u,m=u&&function(t){return Array.isArray(u)?JSON.stringify(e.sliceObject(t,u)):t[u]},v=this.tile_manager.getRenderableTiles().map((function(e){return e.key})),Promise.resolve(e.WorkerBroker.postMessage(this.workers,"self.queryFeatures",{filter:o,visible:h,geometry:d,tile_keys:v})).then((function(e){try{return _=[],y={},b={},e.forEach((function(e){return e.forEach((function(e){if(g){var t=g(e);if(y[t])return;y[t]=!0;}if(m){var r=m(e.properties);b[r]=b[r]||[],b[r].push(e);}else _.push(e);}))})),r(m?b:_)}catch(e){return n(e)}}),n)):r([])}.bind(this))}},{key:"rebuild",value:function(){var r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.initial,o=void 0!==i&&i,s=n.new_generation,a=void 0===s||s,l=n.sources,u=void 0===l?null:l,c=n.serialize_funcs,h=n.profile,f=void 0!==h&&h,d=n.fade_in,p=void 0!==d&&d;return new Promise((function(n,i){if(r.building){r.building.queued&&r.building.queued.reject&&(e.log("debug","Scene.rebuild: request superceded by a newer call"),r.building.queued.resolve(!1));var s={initial:o,new_generation:a,sources:u,serialize_funcs:c,profile:f,fade_in:p};return r.building.queued={resolve:n,reject:i,options:s},void e.log("trace","Scene.rebuild(): queuing request")}if(r.building={resolve:n,reject:i,initial:o},f&&r.debug.profile("Scene.rebuild"),a)for(var l in r.generation=++t.generation,r.styles)r.styles[l].setGeneration(r.generation);r.syncConfigToWorker({serialize_funcs:c}),r.resetWorkerFeatureSelection(u),r.resetTime(),r.tile_manager.pruneToVisibleTiles(),r.tile_manager.forEachTile((function(e){(!u||u.indexOf(e.source.name)>-1)&&r.tile_manager.buildTile(e,{fade_in:p});})),r.tile_manager.updateTilesForView(),r.tile_manager.checkBuildQueue();})).then((function(){f&&r.debug.profileEnd("Scene.rebuild");}))}},{key:"tileManagerBuildDone",value:function(){if(e.TextCanvas.pruneTextCache(),this.building){e.log("info","Scene: build geometry finished"),this.building.resolve&&(this.logFirstBuild(),this.building.resolve(!0));var t=this.building.queued;this.building=null,t?(e.log("debug","Scene: starting queued rebuild() request"),this.rebuild(t.options).then(t.resolve,t.reject)):this.tile_manager.updateLabels();}}},{key:"loadScene",value:function(){var t=arguments;return new Promise(function(r,n){var i,o,s,a,l,u,c,h;return i=t.length>0&&void 0!==t[0]?t[0]:null,s=(o=t.length>1&&void 0!==t[1]?t[1]:{}).base_path,a=o.file_type,this.config_source=i||this.config_source,"string"==typeof this.config_source?this.base_path=e.pathForURL(s||this.config_source):this.base_path=e.pathForURL(s),this.config_path=this.base_path,Promise.resolve(_r.loadScene(this.config_source,{path:this.base_path,type:a})).then(function(e){try{return u=(l=e).config,c=l.bundle,h=l.texture_nodes,this.config=u,this.config_bundle=c,r({texture_nodes:h})}catch(e){return n(e)}}.bind(this),n)}.bind(this))}},{key:"setDataSource",value:function(t,r){if(t&&r&&r.type&&(r.url||r.data)){var n=null==this.config.sources[t],i=this.config.sources[t]=Object.assign({},r);return i.data&&"object"===e._typeof(i.data)&&(i.url=e.createObjectURL(new Blob([JSON.stringify(i.data)],{type:"application/json"})),delete i.data),n?this.updateConfig({rebuild:{sources:[t]}}):this.rebuild({sources:[t]})}e.log("error","No name provided or not a valid config:",t,r);}},{key:"createDataSources",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=[],i=Object.keys(this.sources),o=0;for(var s in this.config.sources){var a=this.config.sources[s],l=this.sources[s];try{var u=Rr(Rr({},a),{},{name:s,id:o++});if(this.sources[s]=e.DataSource.create(u,this.sources),!this.sources[s])throw {}}catch(t){delete this.sources[s];var c="Could not create data source: ".concat(t.message);e.log("warn","Scene: ".concat(c),a),this.trigger("warning",{type:"sources",source:a,message:c});}(r||e.DataSource.tileLayoutChanged(this.sources[s],l))&&n.push(s);}for(var h in i.forEach((function(e){t.config.sources[e]||(delete t.sources[e],n.push(e));})),n.length>0&&this.tile_manager.removeTiles((function(e){return n.indexOf(e.source.name)>-1})),this.config.layers){var f=this.config.layers[h];!1!==f.enabled&&f.data&&this.sources[f.data.source]&&(this.sources[f.data.source].builds_geometry_tiles=!0);}}},{key:"loadTextures",value:function(){var t=this;return e.Texture.createFromObject(this.gl,this.config.textures).then((function(){return e.Texture.createDefault(t.gl)}))}},{key:"freePreviousTextures",value:function(){var t=this;this.prev_textures&&(this.prev_textures.forEach((function(r){!t.config.textures[r]&&e.Texture.textures[r]&&e.Texture.textures[r].destroy();})),this.prev_textures=null);}},{key:"updateStyles",value:function(){if(!this.initialized&&!this.initializing)throw new Error("Scene.updateStyles() called before scene was initialized");for(var e in this.styles=this.style_manager.build(this.config.styles),this.style_manager.initStyles(this),this.styles)this.styles[e].setGL(this.gl);this.dirty=!0;}},{key:"animated",get:function(){var e=this;return !1!==this.config.scene.animated&&this.style_manager.getActiveStyles().some((function(t){return e.styles[t].animated}))}},{key:"getActiveCamera",value:function(){return this.view.getActiveCamera()}},{key:"setActiveCamera",value:function(e){return this.view.setActiveCamera(e)}},{key:"createLights",value:function(){for(var t in this.lights={},e.debugSettings.wireframe&&(e.Light.enabled=!1),this.config.lights)if(this.config.lights[t]&&"object"===e._typeof(this.config.lights[t])){var r=this.config.lights[t];r.name=t.replace("-","_"),r.visible=!1!==r.visible,r.visible&&(this.lights[r.name]=e.Light.create(this.view,r));}e.Light.inject(this.lights);}},{key:"setBackground",value:function(){var t=this.config.scene.background;this.background={},t&&t.color&&(this.background.color=e.StyleParser.createColorPropertyCache(t.color)),this.background.color||(this.background.color=e.StyleParser.createColorPropertyCache([0,0,0,0]));}},{key:"updateBackground",value:function(){var t,r=this.background.computed_color,n=this.background.computed_color=e.StyleParser.evalCachedColorProperty(this.background.color,{zoom:this.view.tile_zoom});r&&!n.some((function(e,t){return r[t]!==e}))||(1===n[3]?this.canvas.style.backgroundColor="rgba(".concat(n.map((function(e){return Math.floor(255*e)})).join(", "),")"):this.canvas.style.backgroundColor="transparent",(t=this.gl).clearColor.apply(t,e._toConsumableArray(n)));}},{key:"setIntrospection",value:function(e){var t=this;return e!==this.introspection?(this.introspection=null!=e&&e,this.updating++,this.updateConfig({normalize:!1}).then((function(){return t.updating--}))):Promise.resolve()}},{key:"updateConfig",value:function(){var r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.loading,o=void 0!==i&&i,s=n.rebuild,a=void 0===s||s,l=n.serialize_funcs,u=n.texture_nodes,c=void 0===u?{}:u,h=n.normalize,f=void 0===h||h,d=n.fade_in,p=void 0!==d&&d;this.generation=++t.generation,this.updating++,this.config=_r.applyGlobalProperties(this.config),f&&_r.normalize(this.config,this.config_bundle,c),_r.hoistTextureNodes(this.config,this.config_bundle,c),this.trigger(o?"load":"update",{config:this.config}),this.style_manager.init(),this.view.reset(),this.createLights(),this.createDataSources(o),this.loadTextures(),this.setBackground(),e.FontManager.loadFonts(this.config.fonts),this.updateStyles();var g=a?this.rebuild(Object.assign({initial:o,new_generation:!1,serialize_funcs:l,fade_in:p},"object"===e._typeof(a)&&a)):this.syncConfigToWorker({serialize_funcs:l});return this.updating--,this.view.updateBounds(),this.requestRedraw(),g.then((function(){r.last_render_count=0,r.requestRedraw();}))}},{key:"syncConfigToWorker",value:function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).serialize_funcs,r=void 0===t||t?e.Utils.serializeWithFunctions(this.config):JSON.stringify(this.config);return e.WorkerBroker.postMessage(this.workers,"self.updateConfig",{config:r,generation:this.generation,introspection:this.introspection},e.debugSettings)}},{key:"createListeners",value:function(){var t=this;this.listeners={},this.listeners.view={move:function(){return t.trigger("move")}},this.view.subscribe(this.listeners.view),this.listeners.texture={update:function(){return t.dirty=!0},warning:function(e){return t.trigger("warning",Object.assign({type:"textures"},e))}},e.Texture.subscribe(this.listeners.texture),this.listeners.scene_loader={error:function(e){return t.trigger("error",Object.assign({type:"scene"},e))}},_r.subscribe(this.listeners.scene_loader);}},{key:"destroyListeners",value:function(){this.unsubscribeAll(),this.view.unsubscribe(this.listeners.view),e.Texture.unsubscribe(this.listeners.texture),_r.unsubscribe(this.listeners.scene_loader),this.listeners=null;}},{key:"destroyFeatureSelection",value:function(){this.selection&&(this.selection.destroy(),this.selection=null);}},{key:"resetFeatureSelection",value:function(){var t=this;this.selection=new e.FeatureSelection(this.gl,this.workers,(function(){return t.building})),this.last_render_count=0;}},{key:"resetWorkerFeatureSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.workers&&e.WorkerBroker.postMessage(this.workers,"self.resetFeatureSelection",t);}},{key:"getFeatureSelectionMapSize",value:function(){var t=this;return null==this.fetching_selection_map&&(this.fetching_selection_map=e.WorkerBroker.postMessage(this.workers,"self.getFeatureSelectionMapSize").then((function(e){return t.fetching_selection_map=null,e.reduce((function(e,t){return e+t}))}))),this.fetching_selection_map}},{key:"resetTime",value:function(){this.start_time=+new Date;}},{key:"updateViewComplete",value:function(){!this.render_count_changed&&this.generation===this.last_complete_generation||this.building||this.tile_manager.isLoadingVisibleTiles()||!this.tile_manager.allVisibleTilesLabeled()||(this.tile_manager.updateLabels(),this.last_complete_generation=this.generation,this.trigger("view_complete",{first:!0!==this.view_complete}),this.view_complete=!0);}},{key:"resetViewComplete",value:function(){this.last_complete_generation=null;}},{key:"screenshot",value:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).background,t=void 0===e?"white":e;return this.requestRedraw(),this.media_capture.screenshot({background:t})}},{key:"startVideoCapture",value:function(){return this.requestRedraw(),this.media_capture.startVideoCapture()}},{key:"stopVideoCapture",value:function(){return this.media_capture.stopVideoCapture()}},{key:"logFirstFrame",value:function(){0!==this.last_render_count||this.times.first_frame||(this.times.first_frame=+new Date-this.start_time,e.log("debug","Scene: initial frame time: ".concat(this.times.first_frame)));}},{key:"logFirstBuild",value:function(){null==this.times.first_build&&(this.times.first_build=+new Date-this.start_time,e.log("debug","Scene: initial build time: ".concat(this.times.first_build)));}}],[{key:"create",value:function(e){return new t(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}}])}();Br.id=0,Br.generation=0;var Lr={map:{},scrollWheelZoom:{},doubleClickZoom:{}};var Dr={leafletLayer:function(t){return function(t){if(void 0!==Pr)return new Pr(t);if(e.Thread.is_main){var r,n=t.leaflet||window.L,i=n.GridLayer?n.GridLayer:n.TileLayer,o=i===n.GridLayer?"1.x":"0.7.x",s={};return i===n.TileLayer&&(s._addTile=function(){},s._removeTile=function(){},s._reset=function(){i.prototype._reset.apply(this,arguments),this.scene&&this.scene.container&&this.scene.canvas&&this.scene.container.appendChild(this.scene.canvas);}),Object.assign(s,{initialize:function(e){e.showDebug=!!e.showDebug,n.setOptions(this,e),this.updateTangramDebugSettings(),this.createScene(),this.hooks={},this._updating_tangram=!1;},createScene:function(){this.scene=Br.create(this.options.scene,{numWorkers:this.options.numWorkers,preUpdate:this.options.preUpdate,postUpdate:this.options.postUpdate,continuousZoom:"1.x"===Pr.leafletVersion,wrapView:!0!==this.options.noWrap,highDensityDisplay:this.options.highDensityDisplay,logLevel:this.options.logLevel,introspection:this.options.introspection,webGLContextOptions:this.options.webGLContextOptions,disableRenderLoop:this.options.disableRenderLoop});},onAdd:function(t){var r=this;this.scene||this.createScene(),i.prototype.onAdd.apply(this,arguments),this.hooks.resize=function(){r._updating_tangram=!0,r.updateSize(),r._updating_tangram=!1;},t.on("resize",this.hooks.resize),this.hooks.move=function(){if(!r._updating_tangram){r._updating_tangram=!0,r.scene.view.setPanning(!0);var n=t.getCenter();n.zoom=Math.max(Math.min(t.getZoom(),t.getMaxZoom()||e.Geo.default_view_max_zoom),t.getMinZoom()),r.scene.view.setView(n),r._mapLayerCount>1&&r.scene.immediateRedraw(),r._updating_tangram=!1;}},t.on("move",this.hooks.move),this.hooks.moveend=function(){r.scene.view.setPanning(!1),r.scene.requestRedraw();},t.on("moveend",this.hooks.moveend),this.hooks.drag=function(){r.scene.view.markUserInput();},t.on("drag",this.hooks.drag),this._map_pane_observer=new MutationObserver((function(e){e.forEach((function(){return r.reverseTransform()}));})),this._map_pane_observer.observe(t.getPanes().mapPane,{attributes:!0}),this.modifyScrollWheelBehavior(t),this.modifyZoomBehavior(t),this.trackMapLayerCounts(t),this.setupSelectionEventHandlers(t),this.setSelectionEvents(this.options.events,{radius:this.options.selectionRadius}),this.scene.container=this.getContainer(),this.updateSize(),this.updateView(),this.resizeOnFirstVisible(),this.scene.subscribe({move:this.onTangramViewUpdate.bind(this)}),this.scene.load(this.options.scene,{base_path:this.options.sceneBasePath,file_type:this.options.sceneFileType,blocking:!1}).then((function(){if(!r.options.attribution)for(var n=0,i=Object.entries(r.scene.config.sources);n<i.length;n++){var o=e._slicedToArray(i[n],2)[1];o.attribution&&t.attributionControl.addAttribution(o.attribution);}r._updating_tangram=!0,r.updateSize(),r.updateView(),r.reverseTransform(),r._updating_tangram=!1,r.fire("init");})).catch((function(e){r.fire("error",e);}));},onRemove:function(e){i.prototype.onRemove.apply(this,arguments),e.off("layeradd layerremove overlayadd overlayremove",this._updateMapLayerCount),e.off("resize",this.hooks.resize),e.off("move",this.hooks.move),e.off("moveend",this.hooks.moveend),e.off("drag",this.hooks.drag),e.off("click",this.hooks.click),e.off("mousemove",this.hooks.mousemove),e.off("mouseout",this.hooks.mouseout),document.removeEventListener("visibilitychange",this.hooks.visibilitychange),this.hooks={},this._map_pane_observer.disconnect(),this.scene&&(this.scene.destroy(),this.scene=null);},createTile:function(e){var t=e.x+"/"+e.y+"/"+e.z,r=document.createElement("div");if(r.setAttribute("data-tile-key",t),r.style.width="256px",r.style.height="256px",this.options.showDebug){var n=document.createElement("div");n.textContent=t,n.style.position="absolute",n.style.left=0,n.style.top=0,n.style.color="white",n.style.fontSize="16px",n.style.textOutline="1px #000000",n.style.padding="8px",r.appendChild(n),r.style.borderStyle="solid",r.style.borderColor="white",r.style.borderWidth="1px";}return r},modifyScrollWheelBehavior:function(e){if(this.scene.view.continuous_zoom&&e.scrollWheelZoom&&!1!==this.options.modifyScrollWheel){e.options.zoomSnap=0;var t=e.scrollWheelZoom.enabled();e.scrollWheelZoom.disable(),n.Browser.chrome||n.Browser.safari?e.scrollWheelZoom._onWheelScroll=function(e){var t=n.DomEvent.getWheelDelta(e);this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._performZoom(),n.DomEvent.stop(e);}:e.options.wheelDebounceTime=20;var i=(s=function(e){e._moveEnd(!0),e.fire("viewreset");},a=2*e.options.wheelDebounceTime,function(){var e=this,t=arguments;clearTimeout(l),l=setTimeout((function(){l=null,s.apply(e,t);}),a);});Lr.scrollWheelZoom._performZoom||(Lr.scrollWheelZoom._performZoom=e.scrollWheelZoom._performZoom);var o=this;e.scrollWheelZoom._performZoom=function(){if(this._map===o._map){var e=this._map,t=e.getZoom();e._stop();var n=this._delta/(4*this._map.options.wheelPxPerZoomLevel);this._delta=0,t+n>=this._map.getMaxZoom()?n=this._map.getMaxZoom()-t:t+n<=this._map.getMinZoom()&&(n=this._map.getMinZoom()-t),n&&("center"===e.options.scrollWheelZoom?r(o,e.getCenter(),t+n):r(o,this._lastMousePos,t+n),i(e));}else Lr.scrollWheelZoom._performZoom.call(this);},t&&e.scrollWheelZoom.enable();}var s,a,l;},modifyZoomBehavior:function(e){if(this.scene.view.continuous_zoom&&!1!==this.options.modifyZoomBehavior){var t=this,i=function(t,i,o){e._stop();var s=e._zoom;i=n.latLng(i),o=void 0===o?s:o,o=Math.min(o,e.getMaxZoom());var a=Date.now(),l=75;function u(){var c=(Date.now()-a)/l;c<=1?(e._flyToFrame=n.Util.requestAnimFrame(u,e),r(t,i,s+(o-s)*c)):r(t,i,o)._moveEnd(!0);}return e._moveStart(!0),u.call(e),e};if(e.doubleClickZoom){var o=e.doubleClickZoom.enabled();e.doubleClickZoom.disable(),Lr.doubleClickZoom._onDoubleClick||(Lr.doubleClickZoom._onDoubleClick=e.doubleClickZoom._onDoubleClick),e.doubleClickZoom._onDoubleClick=function(e){if(this._map===t._map){var r=this._map,n=r.getZoom(),o=r.options.zoomDelta,s=e.originalEvent.shiftKey?n-o:n+o;"center"===r.options.doubleClickZoom?i(t,r.getCenter(),s):i(t,r.containerPointToLatLng(e.containerPoint),s);}else Lr.doubleClickZoom._onDoubleClick.call(this,e);},o&&e.doubleClickZoom.enable();}e._zoomAnimated&&(Lr.map._animateZoom||(Lr.map._animateZoom=e._animateZoom),e._animateZoom=function(e,r,o,s){this===t._map?(o&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=r,i(t,e,r)),setTimeout(n.Util.bind(this._onZoomTransitionEnd,this),250)):Lr.map._animateZoom.call(this,e,r,o,s);});}},updateView:function(){var t=this._map.getCenter();t.zoom=Math.max(Math.min(this._map.getZoom(),this._map.getMaxZoom()||e.Geo.default_view_max_zoom),this._map.getMinZoom()),this.scene.view.setView(t);},updateSize:function(){var e=this._map.getSize();this.scene.resizeMap(e.x,e.y);},resizeOnFirstVisible:function(){var e=this,t=!0;this.hooks.visibilitychange=function(){t&&(t=!1,e.updateSize());},document.addEventListener("visibilitychange",this.hooks.visibilitychange);},onTangramViewUpdate:function(){if(this._map&&!this._updating_tangram){var e=this._map.getCenter(),t=this.scene.view.center;e.lng===t.lng&&e.lat===t.lat&&this._map.getZoom()===this.scene.view.zoom||(this._updating_tangram=!0,this._map.setView([this.scene.view.center.lat,this.scene.view.center.lng],this.scene.view.zoom,{animate:!1}),this._updating_tangram=!1);}},render:function(){this.scene&&this.scene.update();},reverseTransform:function(){if(this._map&&this.scene&&this.scene.container){var e=this._map.containerPointToLayerPoint([0,0]);n.DomUtil.setPosition(this.scene.container,e);}},setupSelectionEventHandlers:function(e){var t=this;this._selection_events={},this._selection_radius=null,this.hooks.click=function(e){"function"==typeof t._selection_events.click&&t.scene.getFeatureAt(e.containerPoint,{radius:t._selection_radius}).then((function(r){var n=Object.assign({},r,{leaflet_event:e});t._selection_events.click(n);}));},e.on("click",this.hooks.click),this.hooks.mousemove=function(e){"function"==typeof t._selection_events.hover&&t.scene.getFeatureAt(e.containerPoint,{radius:t._selection_radius}).then((function(r){var n=Object.assign({},r,{leaflet_event:e});t._selection_events.hover(n);}));},e.on("mousemove",this.hooks.mousemove),this.hooks.mouseout=function(e){"function"==typeof t._selection_events.hover&&t._selection_events.hover({changed:!0,leaflet_event:e});},e.on("mouseout",this.hooks.mouseout);},setSelectionEvents:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).radius;this._selection_events=Object.assign(this._selection_events,e),this._selection_radius=void 0!==t?t:this._selection_radius;},trackMapLayerCounts:function(e){var t=this;this._updateMapLayerCount=function(){var r=e.getPanes().mapPane.childNodes;t._mapLayerCount=0;for(var n=0;n<r.length;n++)t._mapLayerCount+=r[n].childNodes.length;},e.on("layeradd layerremove overlayadd overlayremove",this._updateMapLayerCount),this._updateMapLayerCount();},updateTangramDebugSettings:function(){e.mergeDebugSettings(this.options.debug||{});}}),r=function(e,t,r){var i=e._map,o=e.scene,s=i.getZoomScale(r),a=i.getSize().divideBy(2),l=(t instanceof n.Point?t:i.latLngToContainerPoint(t)).subtract(a).multiplyBy(1-1/s),u=i.containerPointToLatLng(a.add(l));return o&&o.view.markUserInput(),i._move(u,r,{flyTo:!0})},"function"!=typeof(Pr=i.extend(s)).remove&&(Pr.prototype.remove=function(){this._map&&this._map.removeLayer(this),this.fire("remove");}),Pr.layerBaseClass=i,Pr.leafletVersion=o,new Pr(t)}}(t)},debug:{log:e.log,yaml:cr,Utils:e.Utils,Geo:e.Geo,Vector:e.Vector,DataSource:e.DataSource,GLSL:e.GLSL,ShaderProgram:e.ShaderProgram,VertexData:e.VertexData,Texture:e.Texture,Material:e.Material,Light:e.Light,Scene:Br,WorkerBroker:e.WorkerBroker,Task:e.Task,StyleManager:e.StyleManager,StyleParser:e.StyleParser,TileID:e.TileID,Collision:e.Collision,FeatureSelection:e.FeatureSelection,TextCanvas:e.TextCanvas,debugSettings:e.debugSettings},version:e.version};return Dr}));

// Loads each of the chunks produced by the first Rollup pass.
// The custom AMD define() in intro.js will combined the shared
// and worker chunks into a worker bundle that can be instantiated
// via blob URL.


// This allows the rollup ESM build to work within a <script type="module"> tag
// Script modules can't expose exports
try {
	Tangram.debug.ESM = false; // mark build as ES module
	Tangram.debug.SHA = 'd0b887d09a3645aad91a18bd3bd0362d74627da3';
	if (false === true && typeof window === 'object') {
	    window.Tangram = Tangram;
	}
} catch(e) {}

var Tangram$1 = Tangram;

return Tangram$1;

}));