tangram
Version:
WebGL Maps for Vector Tiles
29 lines (24 loc) • 527 kB
JavaScript
// 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";const t={};try{window instanceof Window&&window.document instanceof HTMLDocument&&(t.is_worker=!1,t.is_main=!0);}catch(e){t.is_worker=!0,t.is_main=!1,self.window={document:{}},self.document=self.window.document;}function i(e){return i="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},i(e)}function r(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==i(t)?t:t+""}function n(e,t,i){return (t=r(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var s,o="v0.22.0",a=s={},l=0,u={};function h(e){var t=[];"string"==typeof e&&(t=e.split("."),e=t.pop());var i=s.targets;for(let e=0;e<t.length;e++){if(!i[t[e]])return [];i=i[t[e]];}return [e,i]}function c(e,t=null,i=null,r=[]){if(!e)return r;if(Array.isArray(e))e.forEach(((t,i)=>c(t,e,i,r)));else if("object"==typeof e)if(e instanceof ArrayBuffer)r.push({object:e,parent:t,property:i});else if(e.buffer instanceof ArrayBuffer)r.push({object:e.buffer,parent:t,property:i});else for(let t in e)c(e[t],e,t,r);return r}function d(e){Array.isArray(e)&&e.filter((e=>e.parent&&e.property)).forEach((e=>delete e.parent[e.property]));}s.targets={},s.addTarget=function(e,t){s.targets[e]=t;},s.removeTarget=function(e){e&&delete s.targets[e];},s.withTransferables=function(...e){if(!(this instanceof s.withTransferables))return new s.withTransferables(...e);this.value=e,this.transferables=c(this.value);},t.is_main&&(s.postMessage=function(e,t,...i){if(Array.isArray(e))return Promise.all(e.map((e=>s.postMessage(e,t,...i))));let r={};"object"==typeof t&&(r=t,t=t.method);var n=new Promise(((e,r)=>{u[l]={method:t,message:i,resolve:e,reject:r};}));let o,a=[];return i&&1===i.length&&i[0]instanceof s.withTransferables&&(a=i[0].transferables,i=i[0].value),o={type:"main_send",message_id:l,method:t,message:i},r.stringify&&(o=JSON.stringify(o)),e.postMessage(o,a.map((e=>e.object))),d(a),a.length>0&&m("trace",`'${t}' transferred ${a.length} objects to worker thread`),l++,n},s.addWorker=function(e){if(!(e instanceof Worker))throw Error("Worker broker could not add non-Worker object",e);e.addEventListener("message",(function(t){let i="string"==typeof t.data?JSON.parse(t.data):t.data,r=i.message_id;if("worker_reply"===i.type)u[r]&&(i.error?u[r].reject(i.error):u[r].resolve(i.message),delete u[r]);else if("worker_send"===i.type&&null!=r){let t,n,o,a,l;try{if([a,o]=h(i.method),!o)throw Error(`Worker broker could not dispatch message type ${i.method} on target ${i.target} because no object with that name is registered on main thread`);if(l="function"==typeof o[a]&&o[a],!l)throw Error(`Worker broker could not dispatch message type ${i.method} on target ${i.target} because object has no method with that name`);t=l.apply(o,i.message);}catch(e){n=e;}let u,c=[];t instanceof Promise?t.then((t=>{t instanceof s.withTransferables&&(c=t.transferables,t=t.value[0]),u={type:"main_reply",message_id:r,message:t},e.postMessage(u,c.map((e=>e.object))),d(c),c.length>0&&m("trace",`'${a}' transferred ${c.length} objects to worker thread`);}),(t=>{e.postMessage({type:"main_reply",message_id:r,error:t instanceof Error?`${t.message}: ${t.stack}`:t});})):(t instanceof s.withTransferables&&(c=t.transferables,t=t.value[0]),u={type:"main_reply",message_id:r,message:t,error:n instanceof Error?`${n.message}: ${n.stack}`:n},e.postMessage(u,c.map((e=>e.object))),d(c),c.length>0&&m("trace",`'${a}' transferred ${c.length} objects to worker thread`));}}));},s.getMessages=function(){return u},s.getMessageId=function(){return l}),t.is_worker&&(s.postMessage=function(e,...t){let i={};"object"==typeof e&&(i=e,e=e.method);var r=new Promise(((i,r)=>{u[l]={method:e,message:t,resolve:i,reject:r};}));let n,o=[];return t&&1===t.length&&t[0]instanceof s.withTransferables&&(o=t[0].transferables,t=t[0].value),n={type:"worker_send",message_id:l,method:e,message:t},i.stringify&&(n=JSON.stringify(n)),self.postMessage(n,o.map((e=>e.object))),d(o),o.length>0&&m("trace",`'${e}' transferred ${o.length} objects to main thread`),l++,r},self.addEventListener("message",(function(e){let t="string"==typeof e.data?JSON.parse(e.data):e.data,i=t.message_id;if("main_reply"===t.type)u[i]&&(t.error?u[i].reject(t.error):u[i].resolve(t.message),delete u[i]);else if("main_send"===t.type&&null!=i){let e,r,n,o,a;try{if([o,n]=h(t.method),!n)throw Error(`Worker broker could not dispatch message type ${t.method} on target ${t.target} because no object with that name is registered on main thread`);if(a="function"==typeof n[o]&&n[o],!a)throw Error(`Worker broker could not dispatch message type ${t.method} because worker has no method with that name`);e=a.apply(n,t.message);}catch(e){r=e;}let l,u=[];e instanceof Promise?e.then((e=>{e instanceof s.withTransferables&&(u=e.transferables,e=e.value[0]),l={type:"worker_reply",message_id:i,message:e},self.postMessage(l,u.map((e=>e.object))),d(u),u.length>0&&m("trace",`'${o}' transferred ${u.length} objects to main thread`);}),(e=>{self.postMessage({type:"worker_reply",message_id:i,error:e instanceof Error?`${e.message}: ${e.stack}`:e});})):(e instanceof s.withTransferables&&(u=e.transferables,e=e.value[0]),l={type:"worker_reply",message_id:i,message:e,error:r instanceof Error?`${r.message}: ${r.stack}`:r},self.postMessage(l,u.map((e=>e.object))),d(u),u.length>0&&m("trace",`'${o}' transferred ${u.length} objects to main thread`));}})));const f={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},_={};let p={};function m(e,...i){let r="object"==typeof e?e.level:e;if(f[r]<=f[m.level]){if(t.is_worker)return a.postMessage({method:"_logProxy",stringify:!0},e,...i);{if("object"==typeof e&&!0===e.once){if(p[JSON.stringify(i)])return Promise.resolve(!1);p[JSON.stringify(i)]=!0;}let n=function(e){if(t.is_main)return _[e]=_[e]||(console[e]?console[e]:console.log).bind(console),_[e]}(r);i.length>1?n(`Tangram ${o} [${r}]: ${i[0]}`,...i.slice(1)):n(`Tangram ${o} [${r}]: ${i[0]}`);}return Promise.resolve(!0)}return Promise.resolve(!1)}m.level="info",m.workers=null,m.setLevel=function(e){m.level=e,t.is_main&&Array.isArray(m.workers)&&a.postMessage(m.workers,"_logSetLevelProxy",e);},t.is_main&&(m.setWorkers=function(e){m.workers=e;},m.reset=function(){p={};}),a.addTarget("_logProxy",m),a.addTarget("_logSetLevelProxy",m.setLevel);const g={};let y;a.addTarget("Utils",g),g.isSafari=function(){return /^((?!chrome|android).)*safari/i.test(navigator.userAgent)},g.isMicrosoft=function(){return /(Trident\/7.0|Edge[ /](\d+[.\d]+))/i.test(navigator.userAgent)},g._requests={},g._proxy_requests={},g.io=function(e,i=6e4,r="text",n="GET",s={},o=null,l=!1){if(t.is_worker&&g.isMicrosoft())return m("debug","Proxying request for URL to worker",e),o&&(g._proxy_requests[o]=!0),a.postMessage("Utils.io",e,i,r,n,s,o,!0);var u=new XMLHttpRequest,h=new Promise(((t,o)=>{if(u.open(n,e,!0),u.timeout=i,u.responseType=r,s&&"object"==typeof s)for(let e in s)u.setRequestHeader(e,s[e]);u.onload=()=>{200===u.status?["text","json"].indexOf(u.responseType)>-1?t({body:u.responseText,status:u.status}):t({body:u.response,status:u.status}):204===u.status?t({body:null,status:u.status}):o(Error("Request error with a status of "+u.statusText));},u.onerror=e=>{o(Error("There was a network error"+e.toString()));},u.ontimeout=e=>{o(Error("timeout "+e.toString()));},u.send();}));return h=h.then((e=>(o&&delete g._requests[o],l?a.withTransferables(e):e))),o&&(g._requests[o]=u),h},g.cancelRequest=function(e){if(t.is_worker&&g._proxy_requests[e])return a.postMessage("Utils.cancelRequest",e);g._requests[e]?(m("trace",`Cancelling network request key '${e}'`),g._requests[e].abort(),delete g._requests[e]):m("trace",`Could not find network request key '${e}'`);},g.serializeWithFunctions=function(e){if("function"==typeof e)return e.toString();return JSON.stringify(e,(function(e,t){return "function"==typeof t?t.toString():t}))},g.use_high_density_display=!0,g.updateDevicePixelRatio=function(){let e=g.device_pixel_ratio;return g.device_pixel_ratio=g.use_high_density_display&&window.devicePixelRatio||1,g.device_pixel_ratio!==e},t.is_main&&g.updateDevicePixelRatio(),g.isPowerOf2=function(e){return !(e&e-1)},g.interpolate=function(e,t,i){if(!Array.isArray(t)||!Array.isArray(t[0]))return t;if(t.length<1)return t;var r,n,s,o,a;if(e<=t[0][0])o=t[0][1],"function"==typeof i&&(o=i(o));else if(e>=t[t.length-1][0])o=t[t.length-1][1],"function"==typeof i&&(o=i(o));else for(var l=0;l<t.length-1;l++)if(e>=t[l][0]&&e<t[l+1][0]){if(r=t[l][0],n=t[l+1][0],Array.isArray(t[l][1])){o=[];for(var u=0;u<t[l][1].length;u++)"function"==typeof i?(a=i(t[l][1][u]),s=i(t[l+1][1][u])-a,o[u]=s*(e-r)/(n-r)+a):(s=t[l+1][1][u]-t[l][1][u],o[u]=s*(e-r)/(n-r)+t[l][1][u]);}else "function"==typeof i?(a=i(t[l][1]),o=(s=i(t[l+1][1])-a)*(e-r)/(n-r)+a):o=(s=t[l+1][1]-t[l][1])*(e-r)/(n-r)+t[l][1];break}return o},g.toCSSColor=function(e){if(null!=e)return 1===e[3]?`rgb(${e.slice(0,3).map((e=>Math.round(255*e))).join(", ")})`:`rgba(${e.map(((e,t)=>t<3&&Math.round(255*e)||e)).join(", ")})`};var x=y={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 b(e){if("string"==typeof e&&-1===e.search(/^(data|blob):/)){let t=e.indexOf("?");t>-1&&(e=e.substr(0,t));let i=e.indexOf("#");return i>-1&&(e=e.substr(0,i)),e.substr(0,e.lastIndexOf("/")+1)||""}return ""}function v(e){if("string"==typeof e)return !(e.search(/^(http|https|data|blob):/)>-1||"//"===e.substr(0,2))}let A;function T(e,t){e=e.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var i=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===i?"":decodeURIComponent(i[1].replace(/\+/g," "))}const w={id:0,queue:[],max_time:20,start_time:null,state:{},add(e){e.id=w.id++,e.max_time=e.max_time||w.max_time,e.pause_factor=e.pause_factor||1;let t=new Promise(((t,i)=>{e.resolve=t,e.reject=i;}));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<w.max_time||e.immediate)&&this.process(e),e.promise},remove(e){let t=this.queue.indexOf(e);t>-1&&this.queue.splice(t,1);},process(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(){this.start_time=this.start_time||performance.now();for(let e=0;e<this.queue.length;e++){let 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>=w.max_time){this.start_time=null;break}}},finish(e,t){return e.elapsed=performance.now()-e.start_time,e.total_elapsed+=e.elapsed,this.remove(e),e.resolve(t),e.promise},cancel(e){let t;e.cancel instanceof Function&&(t=e.cancel(e)),e.resolve(t);},shouldContinue(e){return e.elapsed=performance.now()-e.start_time,this.elapsed=performance.now()-this.start_time,e.elapsed<e.max_time&&this.elapsed<w.max_time},removeForTile(e){for(let 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(e){this.state=e;}};function E(e){let t=[];return Object.assign(e,{subscribe(e){-1===t.indexOf(e)&&t.push(e);},unsubscribe(e){let i=t.indexOf(e);i>-1&&t.splice(i,1);},unsubscribeAll(){t=[];},trigger(e,...i){t.forEach((t=>{if("function"==typeof t[e])try{t[e](...i);}catch(t){m("warn",`Caught exception in listener for event '${e}':`,t);}}));},hasSubscribersFor(e){let i=!1;return t.forEach((t=>{"function"==typeof t[e]&&(i=!0);})),i}})}function R(e,t){let i={};return t.forEach((t=>i[t]=e[t])),i}class M{constructor(e,t,i={}){i=M.sliceOptions(i),this.gl=e,this.texture=e.createTexture(),this.texture&&(this.valid=!0),this.bind(),this.name=t,this.retain_count=0,this.config_type=null,this.loading=null,this.loaded=!1,this.filtering=i.filtering,this.density=i.density||1,this.sprites=i.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,M.textures[this.name]&&(this.retain_count=M.textures[this.name].retain_count,M.textures[this.name].retain_count=0,M.textures[this.name].destroy()),M.textures[this.name]=this,M.texture_configs[this.name]=JSON.stringify(Object.assign({name:t},i)),this.load(i),m("trace",`creating Texture ${this.name}`);}destroy({force:e}={}){this.retain_count>0&&!e?m("error",`Texture '${this.name}': destroying texture with retain count of '${this.retain_count}'`):this.valid&&(this.gl.deleteTexture(this.texture),this.texture=null,M.textures[this.name]===this&&(delete M.textures[this.name],delete M.texture_configs[this.name]),this.valid=!1,m("trace",`destroying Texture ${this.name}`));}retain(){this.retain_count++;}release(){this.retain_count<=0&&m("error",`Texture '${this.name}': releasing texture with retain count of '${this.retain_count}'`),this.retain_count--,this.retain_count<=0&&this.destroy();}bind(e=0){this.valid&&(M.activeUnit!==e&&(this.gl.activeTexture(this.gl.TEXTURE0+e),M.activeUnit=e,M.boundTexture=null),M.boundTexture!==this.texture&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),M.boundTexture=this.texture));}load(e){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((()=>(this.calculateSprites(),this)))||Promise.resolve(this),this.loading):this.loading||Promise.resolve(this)}setUrl(e,t={}){if(this.valid)return this.url=e,this.loading=new Promise((e=>{let i=new Image;i.onload=()=>{try{if("data:"===this.url.slice(0,5)){const e=document.createElement("canvas"),r=e.getContext("2d");e.width=i.width,e.height=i.height,r.drawImage(i,0,0),this.setElement(e,t);}else this.setElement(i,t);}catch(e){this.loaded=!1,m("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,e,t),M.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:e,texture:t});}this.loaded=!0,e(this);},i.onerror=i=>{this.loaded=!1,m("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,i,t),M.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:i,texture:t}),e(this);},g.isSafari()&&"data:"===this.url.slice(0,5)||(i.crossOrigin="anonymous"),i.src=this.url;})),this.loading}setData(e,t,i,r={}){return this.width=e,this.height=t,Array.isArray(i)&&(i=new Uint8Array(i)),this.update(i,r),this.setFiltering(r),this.loaded=!0,this.loading=Promise.resolve(this),this.loading}setElement(e,t){let i=e;if("string"==typeof e&&(e=document.querySelector(e)),e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement)this.update(e,t),this.setFiltering(t);else {this.loaded=!1;let e=`the 'element' parameter (\`element: ${JSON.stringify(i)}\`) must be a CSS `;e+="selector string, or a <canvas>, <image> or <video> object",m("warn",`Texture '${this.name}': ${e}`,t),M.trigger("warning",{message:`Failed to load texture because ${e}`,texture:t});}return this.loaded=!0,this.loading=Promise.resolve(this),this.loading}update(e,t={}){this.valid&&(this.bind(),e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLImageElement&&e.complete?(this.width=e.width,this.height=e.height,this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1!==t.UNPACK_FLIP_Y_WEBGL),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e)):(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,e)),M.trigger("update",this));}setFiltering(e={}){if(this.valid){e.filtering=e.filtering||"linear";var t=this.gl;this.bind(),g.isPowerOf2(this.width)&&g.isPowerOf2(this.height)?(this.power_of_2=!0,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,e.TEXTURE_WRAP_S||e.repeat&&t.REPEAT||t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,e.TEXTURE_WRAP_T||e.repeat&&t.REPEAT||t.CLAMP_TO_EDGE),"mipmap"===e.filtering?(this.filtering="mipmap",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.generateMipmap(t.TEXTURE_2D)):"linear"===e.filtering?(this.filtering="linear",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)):"nearest"===e.filtering&&(this.filtering="nearest",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST))):(this.power_of_2=!1,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),"nearest"===e.filtering?(this.filtering="nearest",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)):(this.filtering="linear",t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR))),M.trigger("update",this);}}calculateSprites(){if(this.sprites)for(let e in this.sprites){let t=this.sprites[e];this.texcoords[e]=M.getTexcoordsForSprite([t[0],t[1]],[t[2],t[3]],[this.width,this.height]),this.sizes[e]=[t[2],t[3]],this.css_sizes[e]=[t[2]/this.density,t[3]/this.density],this.aspects[e]=t[2]/t[3];}}byteSize(){return Math.round(this.width*this.height*4*("mipmap"==this.filtering?1.33:1))}}M.create=function(e,t,i){return new M(e,t,i)},M.retain=function(e){M.textures[e]&&M.textures[e].retain();},M.release=function(e){M.textures[e]&&M.textures[e].release();},M.destroy=function(e){Object.keys(M.textures).forEach((t=>{var i=M.textures[t];i.gl===e&&i.destroy({force:!0});}));},M.getSpriteInfo=function(e,t){let i=M.textures[e];return i&&{size:i.sizes[t],css_size:i.css_sizes[t],aspect:i.aspects[t],texcoords:i.texcoords[t]}},M.getTexcoordsForSprite=function(e,t,i){var r=i[1]-e[1]-t[1];return [e[0]/i[0],r/i[1],(t[0]+e[0])/i[0],(t[1]+r)/i[1]]},M.createFromObject=function(e,t){let i=[];if(t)for(let r in t){let n=t[r];if(n.skip_create)continue;if(!M.changed(r,n))continue;let s=M.create(e,r,n);i.push(s.loading);}return Promise.all(i)},M.default="__default",M.createDefault=function(e){return M.create(e,M.default)},M.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}},M.changed=function(e,t){let i=M.textures[e];if(i){if("element"===i.config_type||null!=t.element)return !0;if(t=M.sliceOptions(t),M.texture_configs[e]===JSON.stringify(Object.assign({name:e},t)))return !1}return !0},M.getInfo=function(e){if(e||(e=Object.keys(M.textures)),Array.isArray(e))return Promise.all(e.map((e=>M.getInfo(e))));var t=M.textures[e];return t?(t.loading||Promise.resolve(t)).then((()=>({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)},M.syncTexturesToWorker=function(e){return a.postMessage("Texture.getInfo",e).then((e=>(e&&e.filter((e=>e)).forEach((e=>M.textures[e.name]=e)),M.textures)))},M.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)},M.textures={},M.texture_configs={},M.boundTexture=null,M.activeUnit=null,a.addTarget("Texture",M),E(M);var z={parseUniforms:function(e={}){var t=[];for(const[i,r]of Object.entries(e))if("number"==typeof r)t.push({type:"float",method:"1f",name:i,value:r,path:[i]});else if(Array.isArray(r)){if("number"==typeof r[0])r.length>=2&&r.length<=4?t.push({type:"vec"+r.length,method:r.length+"fv",name:i,value:r,path:[i]}):r.length>4&&t.push({type:"float[]",method:"1fv",name:i+"[0]",value:r,path:[i]});else if("string"==typeof r[0])for(let e=0;e<r.length;e++)t.push({type:"sampler2D",method:"1i",name:i+"["+e+"]",value:r[e],path:[i,e]});else if(Array.isArray(r[0])&&"number"==typeof r[0][0]&&r[0].length>=2&&r[0].length<=4)for(let e=0;e<r.length;e++)t.push({type:"vec"+r[0].length,method:r[0].length+"fv",name:i+"["+e+"]",value:r[e],path:[i,e]});}else "boolean"==typeof r?t.push({type:"bool",method:"1i",name:i,value:r,path:[i]}):"string"==typeof r&&t.push({type:"sampler2D",method:"1i",name:i,value:r,path:[i]});return t},defineVariable:function(e,t){var i,r;if("number"==typeof t)i="float";else if(Array.isArray(t))"number"==typeof t[0]?t.length>=2&&t.length<=4?i="vec"+t.length:(i="float",r=t.length):"string"==typeof t[0]?(i="sampler2D",r=t.length):Array.isArray(t[0])&&"number"==typeof t[0][0]&&t[0].length>=2&&t[0].length<=4&&(i="vec"+t[0].length,r=t.length);else if("boolean"==typeof t)i="bool";else {if("string"!=typeof t)return;i="sampler2D";}var n="";return n+=`${i} ${e}`,r&&(n+=`[${r}]`),n+=";\n"},defineUniform:function(e,t){var i=z.defineVariable(e,t);if(i)return "uniform "+i},expandVec3:function(e,t=1){let i;if(Array.isArray(e)){if(2!==e.length)return e;i=[...e,t].map(parseFloat);}else i=[e,e,e].map(parseFloat);if(i&&i.every((e=>"number"==typeof e&&!isNaN(e))))return i},expandVec4:function(e,t=1){let i;if(Array.isArray(e)){if(3!==e.length)return e;i=[...e,t].map(parseFloat);}else i=[e,e,e,t].map(parseFloat);if(i&&i.every((e=>"number"==typeof e&&!isNaN(e))))return i}};let P=[];function S(e,t){let i=P.filter((t=>t[0]===e))[0];return i=i&&i[1],i||(P.push([e,{}]),i=P[P.length-1][1]),i[t]||(i[t]=e.getExtension(t)),i[t]}function N(e){var t,i,r=0;if(0===e.length)return r;for(t=0,i=e.length;t<i;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return r}function k(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O,L;var I=(L||(L=1,O=function(e){e=String(e);for(var t,i=[];t=e.match(/ERROR\:([^\n]+)/);){e=e.slice(t.index+1);var r=(o=t[1].trim()).split(":"),n=r.slice(2).join(":").trim(),s=parseInt(r[0],10),o=parseInt(r[1],10);i.push({message:n,file:s,line:o});}return i}),O),F=k(I);const D=/^\s*#pragma.*$/gm,U=/\\\s*\n/gm;class G{constructor(e,t,i,r){r=r||{},this.gl=e,this.program=null,this.compiled=!1,this.compiling=!1,this.error=null,this.defines=Object.assign({},r.defines||{}),this.blocks=Object.assign({},r.blocks||{}),this.block_scopes=Object.assign({},r.block_scopes||{}),this.extensions=r.extensions||[],this.dependent_uniforms=r.uniforms,this.uniforms={},this.attribs={},this.vertex_source=t,this.fragment_source=i,this.id=G.id++,this.name=r.name;}destroy(){this.gl.useProgram(null),this.gl.deleteProgram(this.program),this.program=null,this.uniforms={},this.attribs={},this.compiled=!1;}use(){this.compiled&&(G.current!==this&&this.gl.useProgram(this.program),G.current=this);}compile(){if(this.compiling)throw new Error(`ShaderProgram.compile(): skipping for ${this.id} (${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;let e=this.checkExtensions();var t,i=this.buildDefineList(),r=this.buildShaderBlockList();for(var n in r){var s=r[n];if(s&&(!Array.isArray(s)||0!==s.length)){t=new RegExp("^\\s*#pragma\\s+tangram:\\s+"+n+"\\s*$","m");var o=this.computed_vertex_source.match(t),a=this.computed_fragment_source.match(t);if(null!=o||null!=a){var l="";s.forEach((e=>{let t=`${e.scope}, ${e.key}, ${e.num}`;l+=`\n// tangram-block-start: ${t}\n`,l+=e.source,l+=`\n// tangram-block-end: ${t}\n`;})),null!=o&&(this.computed_vertex_source=this.computed_vertex_source.replace(t,l)),null!=a&&(this.computed_fragment_source=this.computed_fragment_source.replace(t,l)),i["TANGRAM_BLOCK_"+n.replace(/[\s-]+/g,"_").toUpperCase()]=!0;}}}this.computed_vertex_source=this.computed_vertex_source.replace(D,""),this.computed_fragment_source=this.computed_fragment_source.replace(D,""),this.ensureUniforms(this.dependent_uniforms);let u="",h=this.gl.getShaderPrecisionFormat(this.gl.FRAGMENT_SHADER,this.gl.HIGH_FLOAT);u=h&&h.precision>0?"precision highp float;\n":"precision mediump float;\n",i.TANGRAM_VERTEX_SHADER=!0,i.TANGRAM_FRAGMENT_SHADER=!1,this.computed_vertex_source=u+G.buildDefineString(i)+this.computed_vertex_source,i.TANGRAM_VERTEX_SHADER=!1,i.TANGRAM_FRAGMENT_SHADER=!0,this.computed_fragment_source=G.buildExtensionString(e)+u+G.buildDefineString(i)+this.computed_fragment_source,this.computed_vertex_source=this.computed_vertex_source.replace(U,""),this.computed_fragment_source=this.computed_fragment_source.replace(U,"");try{this.program=G.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((t=>{t.type=e.type,t.block=this.block(e.type,t.line),t.line=this.block(e.type,t.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();}buildDefineList(){var e,t={};for(e in G.defines)t[e]=G.defines[e];for(e in this.defines)t[e]=this.defines[e];return t}buildShaderBlockList(){let e,t={};for(e in G.blocks)t[e]=[],Array.isArray(G.blocks[e])?t[e].push(...G.blocks[e].map(((t,i)=>({key:e,source:t,num:i,scope:"ShaderProgram"})))):t[e]=[{key:e,source:G.blocks[e],num:0,scope:"ShaderProgram"}];for(e in this.blocks)if(t[e]=t[e]||[],Array.isArray(this.blocks[e])){let i=this.block_scopes&&this.block_scopes[e]||[],r=null,n=0;for(let s=0;s<this.blocks[e].length;s++)i[s]!==r&&(r=i[s],n=0),t[e].push({key:e,source:this.blocks[e][s],num:n,scope:r||this.name}),n++;}else t[e].push({key:e,source:this.blocks[e],num:0,scope:this.name});return t}ensureUniforms(e){if(!e)return;const t=Object.entries(e).map((([e,t])=>z.defineUniform(e,t))).filter((e=>e));this.computed_vertex_source=t.join("\n")+this.computed_vertex_source,this.computed_fragment_source=t.join("\n")+this.computed_fragment_source;}setUniforms(e,t=!0){this.compiled&&(t&&(this.texture_unit=0),z.parseUniforms(e).forEach((({name:e,type:t,value:i,method:r})=>{"sampler2D"===t?this.setTextureUniform(e,i):this.uniform(r,e,i);})));}saveUniforms(e){let t=e||this.uniforms;for(let e in t){let t=this.uniforms[e];t&&(t.saved_value=t.value);}this.saved_texture_unit=this.texture_unit||0;}restoreUniforms(e){let t=e||this.uniforms;for(let e in t){let t=this.uniforms[e];t&&t.saved_value&&(t.value=t.saved_value,this.updateUniform(t));}this.texture_unit=this.saved_texture_unit||0;}setTextureUniform(e,t){var i=M.textures[t];null!=i?(i.bind(this.texture_unit),this.uniform("1i",e,this.texture_unit),this.texture_unit++):m("warn",`Cannot find texture '${t}'`);}uniform(e,t,i){if(!this.compiled)return;this.uniforms[t]=this.uniforms[t]||{};let r=this.uniforms[t];r.name=t,void 0===r.location&&(r.location=this.gl.getUniformLocation(this.program,t)),r.method=e,r.value=i,this.updateUniform(r);}updateUniform(e){this.compiled&&e&&null!=e.location&&(this.use(),this.commitUniform(e));}commitUniform(e){let t=e.location,i=e.value;switch(e.method){case"1i":this.gl.uniform1i(t,i);break;case"1f":this.gl.uniform1f(t,i);break;case"2f":this.gl.uniform2f(t,i[0],i[1]);break;case"3f":this.gl.uniform3f(t,i[0],i[1],i[2]);break;case"4f":this.gl.uniform4f(t,i[0],i[1],i[2],i[3]);break;case"1iv":this.gl.uniform1iv(t,i);break;case"3iv":this.gl.uniform3iv(t,i);break;case"1fv":this.gl.uniform1fv(t,i);break;case"2fv":this.gl.uniform2fv(t,i);break;case"3fv":this.gl.uniform3fv(t,i);break;case"4fv":this.gl.uniform4fv(t,i);break;case"Matrix3fv":this.gl.uniformMatrix3fv(t,!1,i);break;case"Matrix4fv":this.gl.uniformMatrix4fv(t,!1,i);}}refreshUniforms(){if(this.compiled)for(var e in this.uniforms){let t=this.uniforms[e];t.location=this.gl.getUniformLocation(this.program,e),this.updateUniform(t);}}refreshAttributes(){this.attribs={};}attribute(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}}source(e){return "vertex"===e?this.computed_vertex_source:"fragment"===e?this.computed_fragment_source:void 0}lines(e){let t=this.source(e);return t?t.split("\n"):[]}line(e,t){let i=this.lines(e);if(i)return i[t]}block(e,t){let i,r=this.lines(e);for(let e=0;e<t&&e<r.length;e++){let t=r[e],n=t.match(/\/\/ tangram-block-start: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/);n&&n.length>1?i={scope:n[1],name:n[2],num:n[3]}:(n=t.match(/\/\/ tangram-block-end: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/),n&&n.length>1&&(i=null)),i&&(i.line=null==i.line?-1:i.line+1,i.source=t);}return i}checkExtensions(){let e=[];return this.extensions.forEach((t=>{let i=S(this.gl,t),r=`TANGRAM_EXTENSION_${t}`;this.defines[r]=null!=i,i?e.push(t):m("debug",`Could not enable extension '${t}'`);})),e}}G.id=0,G.current=null,G.defines={},G.blocks={},G.reset=function(){G.programs_by_source={},G.shaders_by_source={};},G.reset(),G.buildDefineString=function(e){var t="";for(var i in e)null!=e[i]&&!1!==e[i]&&("boolean"==typeof e[i]&&!0===e[i]?t+="#define "+i+"\n":"number"==typeof e[i]&&Math.floor(e[i])===e[i]?t+="#define "+i+" "+e[i].toFixed(1)+"\n":t+="#define "+i+" "+e[i]+"\n");return t},G.buildExtensionString=function(e){let t="";return (e=e||[]).forEach((e=>{t+=`#ifdef GL_${e}\n#extension GL_${e} : enable\n#endif\n`;})),t},G.addBlock=function(e,...t){G.blocks[e]=G.blocks[e]||[],G.blocks[e].push(...t);},G.removeBlock=function(e){G.blocks[e]=[];},G.replaceBlock=function(e,...t){G.removeBlock(e),G.addBlock(e,...t);},G.updateProgram=function(e,t,i,r){let n=N(e._tangram_id+"::"+i+"::"+r);if(G.programs_by_source[n])return m("trace","Reusing identical source GL program object"),G.programs_by_source[n];var s=G.createShader(e,i,e.VERTEX_SHADER),o=G.createShader(e,r,e.FRAGMENT_SHADER);if(e.useProgram(null),null!=t)for(var a=e.getAttachedShaders(t),l=0;l<a.length;l++)e.detachShader(t,a[l]);else t=e.createProgram();if(null==s||null==o)return t;if(e.attachShader(t,s),e.attachShader(t,o),e.bindAttribLocation(t,0,"a_position"),e.linkProgram(t),!e.getProgramParameter(t,e.LINK_STATUS)){let n=new Error(`WebGL program error:\n VALIDATE_STATUS: ${e.getProgramParameter(t,e.VALIDATE_STATUS)}\n ERROR: ${e.getError()}\n --- Vertex Shader ---\n ${i}\n --- Fragment Shader ---\n ${r}`);throw Object.assign(new Error(n),{type:"program"})}return G.programs_by_source[n]=t,t},G.createShader=function(e,t,i){let r=N(e._tangram_id+"::"+t);if(G.shaders_by_source[r])return m("trace","Reusing identical source GL shader object"),G.shaders_by_source[r];let n=e.createShader(i);if(e.shaderSource(n,t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){let t=i===e.VERTEX_SHADER?"vertex":"fragment",r=e.getShaderInfoLog(n),s=F(r);throw Object.assign(new Error(r),{type:t,errors:s})}return G.shaders_by_source[r]=n,n};var C,j={disabled:!1,bound_vao:[],init(e){let t;!0!==this.disabled&&(t=S(e,"OES_vertex_array_object")),null!=t?m("info","Vertex Array Object extension available"):!0!==this.disabled?m("warn","Vertex Array Object extension NOT available"):m("warn","Vertex Array Object extension force disabled");},getExtension(e,t){if(!0!==this.disabled)return S(e,t)},create(e,t,i){let r={};r.setup=t,r.teardown=i;let n=this.getExtension(e,"OES_vertex_array_object");return null!=n&&(r._vao=n.createVertexArrayOES(),n.bindVertexArrayOES(r._vao)),r.setup(),r},getCurrentBinding(e){let t=this.bound_vao.filter((t=>t[0]===e))[0];return t&&t[1]},setCurrentBinding(e,t){let i=this.bound_vao,r=i.filter((t=>t[0]===e))[0];null==r?i.push([e,t]):r[1]=t;},bind(e,t){let i=this.getExtension(e,"OES_vertex_array_object");if(null!=t)null!=i&&null!=t._vao?(i.bindVertexArrayOES(t._vao),this.setCurrentBinding(e,t)):t.setup();else {let t=this.getCurrentBinding(e);null!=i?i.bindVertexArrayOES(null):null!=t&&"function"==typeof t.teardown&&t.teardown(),this.setCurrentBinding(e,null);}},destroy(e,t){let i=this.getExtension(e,"OES_vertex_array_object");null!=i&&null!=t&&null!=t._vao&&(i.deleteVertexArrayOES(t._vao),t._vao=null);}};function V(e,...t){for(let i=0;i<t.length;i++){let r=t[i];if(r)for(let t in r){let i=r[t];null===i||"object"!=typeof i||Array.isArray(i)?void 0!==i&&(e[t]=i):null===e[t]||"object"!=typeof e[t]||Array.isArray(e[t])?e[t]=V({},i):e[t]=V(e[t],i);}}return e}var $=C={};C.default_source_max_zoom=18,C.default_view_max_zoom=20,C.max_style_zoom=25,C.tile_size=256,C.half_circumference_meters=20037508.342789244,C.circumference_meters=2*C.half_circumference_meters,C.min_zoom_meters_per_pixel=C.circumference_meters/C.tile_size;let B=[];C.metersPerPixel=function(e){return B[e]=B[e]||C.min_zoom_meters_per_pixel/Math.pow(2,e),B[e]};let q=[];C.metersPerTile=function(e){return q[e]=q[e]||C.circumference_meters/Math.pow(2,e),q[e]},C.tile_scale=4096,C.units_per_pixel=C.tile_scale/C.tile_size,C.height_scale=16;let X=[];C.unitsPerMeter=function(e){return X[e]=X[e]||C.tile_scale/(C.tile_size*C.metersPerPixel(e)),X[e]},C.metersForTile=function(e){return {x:e.x*C.circumference_meters/Math.pow(2,e.z)-C.half_circumference_meters,y:-(e.y*C.circumference_meters/Math.pow(2,e.z)-C.half_circumference_meters)}},C.tileForMeters=function([e,t],i){return {x:Math.floor((e+C.half_circumference_meters)/(C.circumference_meters/Math.pow(2,i))),y:Math.floor((-t+C.half_circumference_meters)/(C.circumference_meters/Math.pow(2,i))),z:i}},C.wrapTile=function({x:e,y:t,z:i},r={x:!0,y:!1}){var n=(1<<i)-1;return r.x&&(e&=n),r.y&&(t&=n),{x:e,y:t,z:i}},C.metersToLatLng=function(e){return e[0]/=C.half_circumference_meters,e[1]/=C.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},C.latLngToMeters=function(e){return e[1]=Math.log(Math.tan(e[1]*Math.PI/360+Math.PI/4))/Math.PI,e[1]*=C.half_circumference_meters,e[0]*=C.half_circumference_meters/180,e},C.tileSpaceToLatlng=function(e,t,i){const r=C.unitsPerMeter(t);return C.transformGeometry(e,(e=>{e[0]=e[0]/r+i.x,e[1]=e[1]/r+i.y,C.metersToLatLng(e);})),e},C.copyGeometry=function(e){if(null==e)return;let 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((e=>[e[0],e[1]])):"Polygon"===e.type||"MultiLineString"===e.type?t.coordinates=e.coordinates.map((e=>e.map((e=>[e[0],e[1]])))):"MultiPolygon"===e.type&&(t.coordinates=e.coordinates.map((e=>e.map((e=>e.map((e=>[e[0],e[1]]))))))),t},C.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((e=>e.forEach(t))):"MultiPolygon"===e.type&&e.coordinates.forEach((e=>{e.forEach((e=>e.forEach(t)));})));},C.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)},C.findBoundingBox=function(e){for(var t=1/0,i=-1/0,r=1/0,n=-1/0,s=e[0].length,o=0;o<s;o++){var a=e[0][o];a[0]<t&&(t=a[0]),a[1]<r&&(r=a[1]),a[0]>i&&(i=a[0]),a[1]>n&&(n=a[1]);}return [t,r,i,n]},C.geometryType=function(e){return "Polygon"===e||"MultiPolygon"===e?"polygon":"LineString"===e||"MultiLineString"===e?"line":"Point"===e||"MultiPoint"===e?"point":void 0},C.centroid=function(e,t=!0){if(!e||0===e.length)return;let i,r=0,n=0,s=0,o=e[0],a=o.length;t&&(i=o[0],o=o.map((e=>[e[0]-i[0],e[1]-i[1]])));for(let e=0,t=a-1;e<a;t=e,e++){let i=o[e],a=o[t],l=i[1]*a[0]-a[1]*i[0];r+=(i[0]+a[0])*l,n+=(i[1]+a[1])*l,s+=3*l;}if(!s)return;let l=[r/s,n/s];return t&&(l[0]+=i[0],l[1]+=i[1]),l},C.multiCentroid=function(e){let t=0,i=null;for(let r=0;r<e.length;r++){let n=C.centroid(e[r]);n&&(i=i||[0,0],i[0]+=n[0],i[1]+=n[1],t++);}return t>0&&(i[0]/=t,i[1]/=t),i},C.signedPolygonRingAreaSum=function(e){let t=0,i=e.length;for(let r=0;r<i-1;r++){let i=e[r],n=e[r+1];t+=i[0]*n[1]-n[0]*i[1];}return t+=e[i-1][0]*e[0][1]-e[0][0]*e[i-1][1],t},C.polygonRingArea=function(e){return Math.abs(C.signedPolygonRingAreaSum(e))/2},C.polygonArea=function(e){if(e)return C.polygonRingArea(e[0])},C.multiPolygonArea=function(e){let t=0;for(let i=0;i<e.length;i++)t+=C.polygonArea(e[i]);return t},C.ringWinding=function(e){let t=C.signedPolygonRingAreaSum(e);return t>0?"CW":t<0?"CCW":void 0};const H={functions:{},num_functions:0,num_cached:0};function W(e,t){if("string"==typeof e)e=Y(e,t);else if(null!=e&&"object"==typeof e)for(let i in e)e[i]=W(e[i],t);return e}function Y(e,t){let i="string"==typeof e&&e.match(/^\s*function[^(]*\(([^)]*)\)\s*?\{([\s\S]*)\}$/m);if(i&&i.length>2)try{const e=i[2],r="function"==typeof t?t(e):e,n=N(r);if(void 0===H.functions[n]){let t=i[1].length>0&&i[1].split(",").map((e=>e.trim())).filter((e=>e));t=t.length>0?t:["context"],H.functions[n]=new Function(t.toString(),r),H.functions[n].source=e,H.num_functions++;}else H.num_cached++;return H.functions[n]}catch(t){return e}return e}var Z,J={};var K=k(function(){if(Z)return J;Z=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 i(e){return e<0?0:e>1?1:e}function r(e){return "%"===e[e.length-1]?t(parseFloat(e)/100*255):t(parseInt(e))}function n(e){return "%"===e[e.length-1]?i(parseFloat(e)/100):i(parseFloat(e))}function s(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{J.parseCSSColor=function(i){var o,a=i.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(o=parseInt(a.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===a.length&&(o=parseInt(a.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=a.indexOf("("),u=a.indexOf(")");if(-1!==l&&u+1===a.length){var h=a.substr(0,l),c=a.substr(l+1,u-(l+1)).split(","),d=1;switch(h){case"rgba":if(4!==c.length)return null;d=n(c.pop());case"rgb":return 3!==c.length?null:[r(c[0]),r(c[1]),r(c[2]),d];case"hsla":if(4!==c.length)return null;d=n(c.pop());case"hsl":if(3!==c.length)return null;var f=(parseFloat(c[0])%360+360)%360/360,_=n(c[1]),p=n(c[2]),m=p<=.5?p*(_+1):p+_-p*_,g=2*p-m;return [t(255*s(g,m,f+1/3)),t(255*s(g,m,f)),t(255*s(g,m,f-1/3)),d];default:return null}}return null};}catch(e){}return J}());const Q={},ee=e=>Math.max(e,0),te=e=>isNaN(e)?0:e,ie=e=>Array.isArray(e)?e.map(parseFloat).map(te):te(parseFloat(e)),re=e=>Array.isArray(e)?e.map(ie).map(ee):ee(ie(e));Object.assign(Q,{clampPositive:ee,noNaN:te,parseNumber:ie,parsePositiveNumber:re}),Q.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(){ ${e} }());\n\n if (typeof val === 'number' && isNaN(val)) {\n val = null; // convert NaNs to nulls\n }\n\n return val;\n `},Q.zeroPair=Object.freeze([0,0]),Q.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}},Q.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]}},Q.getFeatureParseContext=function(e,t,i){return {feature:e,id:e.id,tile:t,global:i,zoom:t.style_z,geometry:$.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}};const ne={STATIC:0,DYNAMIC:1,ZOOM:2};Q.CACHE_TYPE=ne,Q.createPropertyCache=function(e,t=null,i=null){if(null==e)return;if(e.value)return {value:e.value,zoom:e.zoom?{}:null,type:e.type};let r={value:e,type:ne.STATIC};return Array.isArray(r.value)&&Array.isArray(r.value[0])?(r.zoom={},r.type=ne.ZOOM):"function"==typeof r.value&&(r.type=ne.DYNAMIC,r.dynamic_transform="function"==typeof i?i:null),"function"==typeof t&&(r.zoom?r.value=r.value.map(((e,i)=>[e[0],t(e[1],i)])):"function"!=typeof r.value&&(r.value=t(r.value,0))),r},Q.createColorPropertyCache=function(e){return Q.createPropertyCache(e,(e=>"Style.color.pseudoRandomColor"===e?Y(Q.wrapFunction(Q.macros["Style.color.pseudoRandomColor"])):"Style.color.randomColor"===e?Q.macros["Style.color.randomColor"]:e))};const se=e=>"string"==typeof e&&"%"===e[e.length-1],oe=e=>"auto"===e,ae=e=>se(e)||oe(e),le="'size' can specify either width or height as derived from aspect ratio, but not both";function ue(e,t){return Q.createPropertyCache(e.value,((i,r)=>(Array.isArray(i)?(i=i.map(((t,i)=>e.has_ratio[r][i]?t:re(t))).map(((i,n)=>e.has_pct[r][n]?t.css_size[n]*i/100:i)),e.has_ratio[r][0]?i[0]=i[1]*t.aspect:e.has_ratio[r][1]&&(i[1]=i[0]/t.aspect)):(i=re(i),i=e.has_pct[r]?t.css_size.map((e=>e*i/100)):[i,i]),i)))}function he(e,t){try{return e(t)}catch(i){m("warn",`Property function in layer '${t.layers[t.layers.length-1]}' failed with\n`,`error ${i.stack}\n`,`function '${e.source}'\n`,t.feature,t);}}Q.createPointSizePropertyCache=function(e,t){let i=null,r=null;if(se(e))i=[!0];else if(Array.isArray(e)){if(Array.isArray(e[0])){if(e.some((e=>Array.isArray(e[1])?e[1].some((e=>ae(e))):se(e[1])))&&(i=e.map((e=>Array.isArray(e[1])?e[1].map((e=>se(e))):se(e[1]))),r=e.map((e=>Array.isArray(e[1])&&e[1].map((e=>oe(e))))),r.some((e=>Array.isArray(e)&&e.every((e=>e))))))throw le}else if(e.some(ae)&&(i=[e.map(se)],r=[e.map(oe)],r[0].every((e=>e))))throw le}else if(oe(e))throw "this value only allowed as half of an array, eg [16px, auto]:";if(i||r){if(!t)throw "% or 'auto' keywords can only be used to specify point size when a texture is defined";(e={value:e}).has_pct=i,e.has_ratio=r,e.sprites={};}else e=Q.createPropertyCache(e,re);return e},Q.evalCachedPointSizeProperty=function(e,t,i,r){if(null!=e)return e.has_pct||e.has_ratio?t?(e.sprites[t.sprite]||(e.sprites[t.sprite]=ue(e,t)),Q.evalCachedProperty(e.sprites[t.sprite],r)):(e.texture=e.texture||ue(e,i),Q.evalCachedProperty(e.texture,r)):Q.evalCachedProperty(e,r)},Q.evalCachedProperty=function(e,t){return null==e?void 0:e.dynamic?he(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,he(e.dynamic,t)):Array.isArray(e.value)&&Array.isArray(e.value[0])?(e.zoom=e.zoom||{},e.zoom[t.zoom]=g.interpolate(t.zoom,e.value),e.zoom[t.zoom]):(e.static=e.value,e.static)},Q.convertUnits=function(e,t){if(null!=e.value)return "px"===e.units?e.value*$.metersPerPixel(t.zoom):e.value;if("string"==typeof e)"px"===e.trim().slice(-2)?(e=ie(e),e*=$.metersPerPixel(t.zoom)):e=ie(e);else if(Array.isArray(e))return Array.isArray(e[0])?e.map((e=>[e[0],Q.convertUnits(e[1],t)])):e.map((e=>Q.convertUnits(e,t)));return e},Q.parseUnits=function(e){var t={value:ie(e)};return 0!==t.value&&"string"==typeof e&&"px"===e.trim().slice(-2)&&(t.units="px"),t},Q.evalCachedDistanceProperty=function(e,t){return null==e?void 0:e.dynamic?he(e.dynamic,t):e.zoom&&e.zoom[t.zoom]?e.zoom[t.zoom]:"function"==typeof e.value?(e.dynamic=e.value,he(e.dynamic,t)):e.zoom?(e.zoom[t.zoom]=g.interpolate(t.zoom,e.value,(e=>Q.convertUnits(e,t))),e.zoom[t.zoom]):Q.convertUnits(e.value,t)},Q.string_colors={},Q.colorForString=function(e){if(Q.string_colors[e])return Q.string_colors[e];let t=K.parseCSSColor(e);return t&&4===t.length?(t[0]/=255,t[1]/=255,t[2]/=255):t=Q.defaults.color,Q.string_colors[e]=t,t},Q.evalCachedColorProperty=function(e,t={}){if(null!=e){if(e.dynamic){let i=he(e.dynamic,t);return "string"==typeof i&&(i=Q.colorForString(i)),i&&null==i[3]&&(i[3]=1),i}if(e.static)return e.static;if(e.zoom&&