mx3d 0.0.51 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +88 -68
- package/mx3d.js +1 -1
- package/mx3d.min.js +7 -7
- package/package.json +4 -2
package/mx3d.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("TWEEN"),require("h337"),require("BABYLON"),require("babylonjs-materials"),require("BABYLON.GUI"),require("BABYLON.SceneLoader"),require("babylonjs-serializers")):"function"==typeof define&&define.amd?define(["TWEEN","h337","BABYLON","babylonjs-materials","BABYLON.GUI","BABYLON.SceneLoader","babylonjs-serializers"],t):"object"==typeof exports?exports.MX3D=t(require("TWEEN"),require("h337"),require("BABYLON"),require("babylonjs-materials"),require("BABYLON.GUI"),require("BABYLON.SceneLoader"),require("babylonjs-serializers")):e.MX3D=t(e.TWEEN,e.h337,e.BABYLON,e["babylonjs-materials"],e["BABYLON.GUI"],e["BABYLON.SceneLoader"],e["babylonjs-serializers"])}(window,function(i,n,r,s,o,a,c){return l=[function(e,t,i){"use strict";var n;i.d(t,"a",function(){return n}),(t=n=n||{})[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"},function(e,m,v){"use strict";!function(t,e){v.d(m,"a",function(){return r}),v.d(m,"c",function(){return s}),v.d(m,"f",function(){return l}),v.d(m,"j",function(){return u}),v.d(m,"k",function(){return o}),v.d(m,"e",function(){return a}),v.d(m,"d",function(){return c}),v.d(m,"b",function(){return p}),v.d(m,"i",function(){return d}),v.d(m,"g",function(){return f}),v.d(m,"h",function(){return g});var h=v(0),i=v(11);const n="6.0.7";class r{static isRequired(e,t){if(null==e)throw new Error(`The '${t}' argument is required.`)}static isNotEmpty(e,t){if(!e||e.match(/^\s*$/))throw new Error(`The '${t}' argument should not be empty.`)}static isIn(e,t,i){if(!(e in t))throw new Error(`Unknown ${i} value: ${e}.`)}}class s{static get isBrowser(){return"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return"object"==typeof self&&"importScripts"in self}static get isReactNative(){return"object"==typeof window&&void 0===window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function l(e,t){let i="";return u(e)?(i=`Binary data of length ${e.byteLength}`,t&&(i+=`. Content: '${function(e){const t=new Uint8Array(e);let i="";return t.forEach(e=>{var t=e<16?"0":"";i+=`0x${t}${e.toString(16)} `}),i.substr(0,i.length-1)}(e)}'`)):"string"==typeof e&&(i=`String data of length ${e.length}`,t&&(i+=`. Content: '${e}'`)),i}function u(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}async function o(e,t,i,n,r,s,o){let a={};!r||(c=await r())&&(a={Authorization:`Bearer ${c}`});var[r,c]=d();a[r]=c,e.log(h.a.Trace,`(${t} transport) sending data. ${l(s,o.logMessageContent)}.`);c=u(s)?"arraybuffer":"text",o=await i.post(n,{content:s,headers:{...a,...o.headers},responseType:c,timeout:o.timeout,withCredentials:o.withCredentials});e.log(h.a.Trace,`(${t} transport) request complete. Response status: ${o.statusCode}.`)}function a(e){return void 0===e?new p(h.a.Information):null===e?i.a.instance:void 0!==e.log?e:new p(e)}class c{constructor(e,t){this._subject=e,this._observer=t}dispose(){var e=this._subject.observers.indexOf(this._observer);-1<e&&this._subject.observers.splice(e,1),0===this._subject.observers.length&&this._subject.cancelCallback&&this._subject.cancelCallback().catch(e=>{})}}class p{constructor(e){this._minLevel=e,this.out=console}log(e,t){if(e>=this._minLevel){var i=`[${(new Date).toISOString()}] ${h.a[e]}: ${t}`;switch(e){case h.a.Critical:case h.a.Error:this.out.error(i);break;case h.a.Warning:this.out.warn(i);break;case h.a.Information:this.out.info(i);break;default:this.out.log(i)}}}}function d(){let e="X-SignalR-User-Agent";return s.isNode&&(e="User-Agent"),[e,function(e,t,i,n){let r="Microsoft SignalR/";var s=e.split(".");r+=`${s[0]}.${s[1]}`,r+=` (${e}; `,r+=t&&""!==t?`${t}; `:"Unknown OS; ";r+=`${i}`,r+=n?`; ${n}`:"; Unknown Runtime Version";return r+=")",r}(n,function(){{if(!s.isNode)return"";switch(t.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return t.platform}}}(),s.isNode?"NodeJS":"Browser",function(){if(s.isNode)return t.versions.node;return}())]}function f(e){return e.stack||e.message||`${e}`}function g(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("could not find global")}}.call(this,v(21),v(16))},function(t,e,g){!function(f){var e;t.exports=(e=function(h){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),!(n=!(n=!(n="undefined"!=typeof globalThis&&globalThis.crypto?globalThis.crypto:n)&&"undefined"!=typeof window&&window.msCrypto?window.msCrypto:n)&&void 0!==f&&f.crypto?f.crypto:n))try{n=g(59)}catch(e){}var i=Object.create||function(e){return t.prototype=e,e=new t,t.prototype=null,e};function t(){}var e={},r=e.lib={},s=r.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},l=r.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,i=e.words,n=this.sigBytes,r=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<r;s++){var o=i[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=o<<24-(n+s)%4*8}else for(var a=0;a<r;a+=4)t[n+a>>>2]=i[a>>>2];return this.sigBytes+=r,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=h.ceil(t/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],i=0;i<e;i+=4)t.push(function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")}());return new l.init(t,e)}}),o=e.enc={},a=o.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,n=[],r=0;r<i;r++){var s=t[r>>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n+=2)i[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new l.init(i,t/2)}},c=o.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,n=[],r=0;r<i;r++){var s=t[r>>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n++)i[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new l.init(i,t)}},u=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t,i=this._data,n=i.words,r=i.sigBytes,s=this.blockSize,o=r/(4*s),a=(o=e?h.ceil(o):h.max((0|o)-this._minBufferSize,0))*s,r=h.min(4*a,r);if(a){for(var c=0;c<a;c+=s)this._doProcessBlock(n,c);t=n.splice(0,a),i.sigBytes-=r}return new l.init(t,r)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(r.Hasher=p.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(i){return function(e,t){return new i.init(t).finalize(e)}},_createHmacHelper:function(i){return function(e,t){return new d.HMAC.init(i,t).finalize(e)}}}),e.algo={});return e}(Math),e)}.call(this,g(16))},function(e,t,i){"use strict";var n,r=i(19),s=Object.prototype.toString,o=(n=Object.create(null),function(e){e=s.call(e);return n[e]||(n[e]=e.slice(8,-1).toLowerCase())});function a(t){return t=t.toLowerCase(),function(e){return o(e)===t}}function c(e){return Array.isArray(e)}function h(e){return void 0===e}var l=a("ArrayBuffer");function u(e){return null!==e&&"object"==typeof e}function p(e){if("object"!==o(e))return!1;e=Object.getPrototypeOf(e);return null===e||e===Object.prototype}var d=a("Date"),f=a("File"),g=a("Blob"),m=a("FileList");function v(e){return"[object Function]"===s.call(e)}var y=a("URLSearchParams");function b(e,t){if(null!=e)if(c(e="object"!=typeof e?[e]:e))for(var i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(null,e[r],r,e)}var w,i=(w="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return w&&e instanceof w});e.exports={isArray:c,isArrayBuffer:l,isBuffer:function(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||s.call(e)===t||v(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&l(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:u,isPlainObject:p,isUndefined:h,isDate:d,isFile:f,isBlob:g,isFunction:v,isStream:function(e){return u(e)&&v(e.pipe)},isURLSearchParams:y,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:b,merge:function i(){var n={};function e(e,t){p(n[t])&&p(e)?n[t]=i(n[t],e):p(e)?n[t]=i({},e):c(e)?n[t]=e.slice():n[t]=e}for(var t=0,r=arguments.length;t<r;t++)b(arguments[t],e);return n},extend:function(i,e,n){return b(e,function(e,t){i[t]=n&&"function"==typeof e?r(e,n):e}),i},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return e=65279===e.charCodeAt(0)?e.slice(1):e},inherits:function(e,t,i,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,i&&Object.assign(e.prototype,i)},toFlatObject:function(e,t,i){var n,r,s,o={};t=t||{};do{for(r=(n=Object.getOwnPropertyNames(e)).length;0<r--;)o[s=n[r]]||(t[s]=e[s],o[s]=!0)}while((e=Object.getPrototypeOf(e))&&(!i||i(e,t))&&e!==Object.prototype);return t},kindOf:o,kindOfTest:a,endsWith:function(e,t,i){return e=String(e),(void 0===i||i>e.length)&&(i=e.length),i-=t.length,-1!==(t=e.indexOf(t,i))&&t===i},toArray:function(e){if(!e)return null;var t=e.length;if(h(t))return null;for(var i=new Array(t);0<t--;)i[t]=e[t];return i},isTypedArray:i,isFileList:m}},function(e,t,i){var g;e.exports=(g=i(2),i(7),void(g.lib.Cipher||function(){var e=g,t=e.lib,i=t.Base,o=t.WordArray,n=t.BufferedBlockAlgorithm,r=e.enc,s=(r.Utf8,r.Base64),a=e.algo.EvpKDF,c=t.Cipher=n.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){n.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(n){return{encrypt:function(e,t,i){return h(t).encrypt(n,e,t,i)},decrypt:function(e,t,i){return h(t).decrypt(n,e,t,i)}}}});function h(e){return"string"==typeof e?f:d}t.StreamCipher=c.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=e.mode={},r=t.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),r=l.CBC=((l=r.extend()).Encryptor=l.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize;u.call(this,e,t,n),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}),l.Decryptor=l.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,r=e.slice(t,t+n);i.decryptBlock(e,t),u.call(this,e,t,n),this._prevBlock=r}}),l);function u(e,t,i){var n,r=this._iv;r?(n=r,this._iv=void 0):n=this._prevBlock;for(var s=0;s<i;s++)e[t+s]^=n[s]}var l=(e.pad={}).Pkcs7={pad:function(e,t){for(var t=4*t,i=t-e.sigBytes%t,n=i<<24|i<<16|i<<8|i,r=[],s=0;s<i;s+=4)r.push(n);t=o.create(r,i);e.concat(t)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},p=(t.BlockCipher=c.extend({cfg:c.cfg.extend({mode:r,padding:l}),reset:function(){var e;c.reset.call(this);var t=this.cfg,i=t.iv,t=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=t.createEncryptor:(e=t.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,i&&i.words):(this._mode=e.call(t,this,i&&i.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),t.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),l=(e.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,e=e.salt,t=e?o.create([1398893684,1701076831]).concat(e).concat(t):t;return t.toString(s)},parse:function(e){var t,i=s.parse(e),e=i.words;return 1398893684==e[0]&&1701076831==e[1]&&(t=o.create(e.slice(2,4)),e.splice(0,4),i.sigBytes-=16),p.create({ciphertext:i,salt:t})}},d=t.SerializableCipher=i.extend({cfg:i.extend({format:l}),encrypt:function(e,t,i,n){n=this.cfg.extend(n);var r=e.createEncryptor(i,n),t=r.finalize(t),r=r.cfg;return p.create({ciphertext:t,key:i,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,i,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(i,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),e=(e.kdf={}).OpenSSL={execute:function(e,t,i,n){n=n||o.random(8);e=a.create({keySize:t+i}).compute(e,n),i=o.create(e.words.slice(t),4*i);return e.sigBytes=4*t,p.create({key:e,iv:i,salt:n})}},f=t.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:e}),encrypt:function(e,t,i,n){i=(n=this.cfg.extend(n)).kdf.execute(i,e.keySize,e.ivSize);n.iv=i.iv;n=d.encrypt.call(this,e,t,i.key,n);return n.mixIn(i),n},decrypt:function(e,t,i,n){n=this.cfg.extend(n),t=this._parse(t,n.format);i=n.kdf.execute(i,e.keySize,e.ivSize,t.salt);return n.iv=i.iv,d.decrypt.call(this,e,t,i.key,n)}})}()))},function(e,t){e.exports=i},function(e,t,i){e.exports=(e=i(2),i(13),i(60),i(61),i(9),i(62),i(10),i(17),i(29),i(63),i(30),i(64),i(65),i(66),i(18),i(67),i(7),i(4),i(68),i(69),i(70),i(71),i(72),i(73),i(74),i(75),i(76),i(77),i(78),i(79),i(80),i(81),i(82),i(83),e)},function(e,t,i){var s;e.exports=(s=i(2),i(17),i(18),function(){var e=s,t=e.lib,i=t.Base,l=t.WordArray,n=e.algo,t=n.MD5,r=n.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:t,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i,n=this.cfg,r=n.hasher.create(),s=l.create(),o=s.words,a=n.keySize,c=n.iterations;o.length<a;){i&&r.update(i),i=r.update(e).finalize(t),r.reset();for(var h=1;h<c;h++)i=r.finalize(i),r.reset();s.concat(i)}return s.sigBytes=4*a,s}});e.EvpKDF=function(e,t,i){return r.create(i).compute(e,t)}}(),s.EvpKDF)},function(e,t,i){"use strict";var a=i(3);function c(e,t,i,n,r){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),n&&(this.request=n),r&&(this.response=r)}a.inherits(c,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var h=c.prototype,n={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach(function(e){n[e]={value:e}}),Object.defineProperties(c,n),Object.defineProperty(h,"isAxiosError",{value:!0}),c.from=function(e,t,i,n,r,s){var o=Object.create(h);return a.toFlatObject(e,o,function(e){return e!==Error.prototype}),c.call(o,e.message,t,i,n,r),o.name=e.name,s&&Object.assign(o,s),o},e.exports=c},function(e,t,i){var n;e.exports=(n=i(2),function(){var c=n.lib.WordArray;n.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,n=this._map;e.clamp();for(var r=[],s=0;s<i;s+=3)for(var o=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<i;a++)r.push(n.charAt(o>>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;r.length%4;)r.push(c);return r.join("")},parse:function(e){var t=e.length,i=this._map;if(!(n=this._reverseMap))for(var n=this._reverseMap=[],r=0;r<i.length;r++)n[i.charCodeAt(r)]=r;var s=i.charAt(64);return!s||-1!==(s=e.indexOf(s))&&(t=s),function(e,t,i){for(var n=[],r=0,s=0;s<t;s++){var o,a;s%4&&(o=i[e.charCodeAt(s-1)]<<s%4*2,a=i[e.charCodeAt(s)]>>>6-s%4*2,a=o|a,n[r>>>2]|=a<<24-r%4*8,r++)}return c.create(n,r)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),n.enc.Base64)},function(e,t,i){var r;e.exports=(r=i(2),function(c){var e=r,t=e.lib,i=t.WordArray,n=t.Hasher,t=e.algo,E=[];!function(){for(var e=0;e<64;e++)E[e]=4294967296*c.abs(c.sin(e+1))|0}();t=t.MD5=n.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var n=t+i,r=e[n];e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var s=this._hash.words,o=e[t+0],a=e[t+1],c=e[t+2],h=e[t+3],l=e[t+4],u=e[t+5],p=e[t+6],d=e[t+7],f=e[t+8],g=e[t+9],m=e[t+10],v=e[t+11],y=e[t+12],b=e[t+13],w=e[t+14],_=e[t+15],A=S(A=s[0],x=s[1],C=s[2],B=s[3],o,7,E[0]),B=S(B,A,x,C,a,12,E[1]),C=S(C,B,A,x,c,17,E[2]),x=S(x,C,B,A,h,22,E[3]);A=S(A,x,C,B,l,7,E[4]),B=S(B,A,x,C,u,12,E[5]),C=S(C,B,A,x,p,17,E[6]),x=S(x,C,B,A,d,22,E[7]),A=S(A,x,C,B,f,7,E[8]),B=S(B,A,x,C,g,12,E[9]),C=S(C,B,A,x,m,17,E[10]),x=S(x,C,B,A,v,22,E[11]),A=S(A,x,C,B,y,7,E[12]),B=S(B,A,x,C,b,12,E[13]),C=S(C,B,A,x,w,17,E[14]),A=T(A,x=S(x,C,B,A,_,22,E[15]),C,B,a,5,E[16]),B=T(B,A,x,C,p,9,E[17]),C=T(C,B,A,x,v,14,E[18]),x=T(x,C,B,A,o,20,E[19]),A=T(A,x,C,B,u,5,E[20]),B=T(B,A,x,C,m,9,E[21]),C=T(C,B,A,x,_,14,E[22]),x=T(x,C,B,A,l,20,E[23]),A=T(A,x,C,B,g,5,E[24]),B=T(B,A,x,C,w,9,E[25]),C=T(C,B,A,x,h,14,E[26]),x=T(x,C,B,A,f,20,E[27]),A=T(A,x,C,B,b,5,E[28]),B=T(B,A,x,C,c,9,E[29]),C=T(C,B,A,x,d,14,E[30]),A=M(A,x=T(x,C,B,A,y,20,E[31]),C,B,u,4,E[32]),B=M(B,A,x,C,f,11,E[33]),C=M(C,B,A,x,v,16,E[34]),x=M(x,C,B,A,w,23,E[35]),A=M(A,x,C,B,a,4,E[36]),B=M(B,A,x,C,l,11,E[37]),C=M(C,B,A,x,d,16,E[38]),x=M(x,C,B,A,m,23,E[39]),A=M(A,x,C,B,b,4,E[40]),B=M(B,A,x,C,o,11,E[41]),C=M(C,B,A,x,h,16,E[42]),x=M(x,C,B,A,p,23,E[43]),A=M(A,x,C,B,g,4,E[44]),B=M(B,A,x,C,y,11,E[45]),C=M(C,B,A,x,_,16,E[46]),A=k(A,x=M(x,C,B,A,c,23,E[47]),C,B,o,6,E[48]),B=k(B,A,x,C,d,10,E[49]),C=k(C,B,A,x,w,15,E[50]),x=k(x,C,B,A,u,21,E[51]),A=k(A,x,C,B,y,6,E[52]),B=k(B,A,x,C,h,10,E[53]),C=k(C,B,A,x,m,15,E[54]),x=k(x,C,B,A,a,21,E[55]),A=k(A,x,C,B,f,6,E[56]),B=k(B,A,x,C,_,10,E[57]),C=k(C,B,A,x,p,15,E[58]),x=k(x,C,B,A,b,21,E[59]),A=k(A,x,C,B,l,6,E[60]),B=k(B,A,x,C,v,10,E[61]),C=k(C,B,A,x,c,15,E[62]),x=k(x,C,B,A,g,21,E[63]),s[0]=s[0]+A|0,s[1]=s[1]+x|0,s[2]=s[2]+C|0,s[3]=s[3]+B|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32;var r=c.floor(i/4294967296),i=i;t[15+(64+n>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t[14+(64+n>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var t=this._hash,s=t.words,o=0;o<4;o++){var a=s[o];s[o]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return t},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function S(e,t,i,n,r,s,o){o=e+(t&i|~t&n)+r+o;return(o<<s|o>>>32-s)+t}function T(e,t,i,n,r,s,o){o=e+(t&n|i&~n)+r+o;return(o<<s|o>>>32-s)+t}function M(e,t,i,n,r,s,o){o=e+(t^i^n)+r+o;return(o<<s|o>>>32-s)+t}function k(e,t,i,n,r,s,o){o=e+(i^(t|~n))+r+o;return(o<<s|o>>>32-s)+t}e.MD5=n._createHelper(t),e.HmacMD5=n._createHmacHelper(t)}(Math),r.MD5)},function(e,t,i){"use strict";i.d(t,"a",function(){return n});class n{constructor(){}log(e,t){}}n.instance=new n},function(e,t,i){"use strict";var n=i(8);function r(e){n.call(this,null==e?"canceled":e,n.ERR_CANCELED),this.name="CanceledError"}i(3).inherits(r,n,{__CANCEL__:!0}),e.exports=r},function(e,t,i){var n;e.exports=(n=i(2),function(){var e=n,t=e.lib,r=t.Base,s=t.WordArray,e=e.x64={};e.Word=r.extend({init:function(e,t){this.high=e,this.low=t}}),e.WordArray=r.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],n=0;n<t;n++){var r=e[n];i.push(r.high),i.push(r.low)}return s.create(i,this.sigBytes)},clone:function(){for(var e=r.clone.call(this),t=e.words=this.words.slice(0),i=t.length,n=0;n<i;n++)t[n]=t[n].clone();return e}})}(),n)},function(e,t){e.exports=n},function(l,e,u){"use strict";!function(e){var o=u(3),a=u(42),n=u(8),t=u(22),c=u(23),i={"Content-Type":"application/x-www-form-urlencoded"};function h(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var r,s={transitional:t,adapter:r="undefined"!=typeof XMLHttpRequest||void 0!==e&&"[object process]"===Object.prototype.toString.call(e)?u(24):r,transformRequest:[function(e,t){if(a(t,"Accept"),a(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e))return e;if(o.isArrayBufferView(e))return e.buffer;if(o.isURLSearchParams(e))return h(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var i,n=o.isObject(e),r=t&&t["Content-Type"];if((i=o.isFileList(e))||n&&"multipart/form-data"===r){var s=this.env&&this.env.FormData;return c(i?{"files[]":e}:e,s&&new s)}return n||"application/json"===r?(h(t,"application/json"),function(e,t,i){if(o.isString(e))try{return(t||JSON.parse)(e),o.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(i||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||s.transitional,i=t&&t.silentJSONParsing,t=t&&t.forcedJSONParsing,i=!i&&"json"===this.responseType;if(i||t&&o.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw n.from(e,n.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:u(54)},validateStatus:function(e){return 200<=e&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};o.forEach(["delete","get","head"],function(e){s.headers[e]={}}),o.forEach(["post","put","patch"],function(e){s.headers[e]=o.merge(i)}),l.exports=s}.call(this,u(21))},function(e,t){var i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){var r;e.exports=(r=i(2),function(){var e=r,t=e.lib,i=t.WordArray,n=t.Hasher,t=e.algo,l=[],t=t.SHA1=n.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],c=0;c<80;c++){c<16?l[c]=0|e[t+c]:(h=l[c-3]^l[c-8]^l[c-14]^l[c-16],l[c]=h<<1|h>>>31);var h=(n<<5|n>>>27)+a+l[c];h+=c<20?1518500249+(r&s|~r&o):c<40?1859775393+(r^s^o):c<60?(r&s|r&o|s&o)-1894007588:(r^s^o)-899497514,a=o,o=s,s=r<<30|r>>>2,r=n,n=h}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(64+n>>>9<<4)]=Math.floor(i/4294967296),t[15+(64+n>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=n._createHelper(t),e.HmacSHA1=n._createHmacHelper(t)}(),r.SHA1)},function(e,t,i){var n;e.exports=(n=i(2),void function(){var e=n.lib.Base,a=n.enc.Utf8;n.algo.HMAC=e.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=a.parse(t));var i=e.blockSize,n=4*i;(t=t.sigBytes>n?e.finalize(t):t).clamp();for(var e=this._oKey=t.clone(),t=this._iKey=t.clone(),r=e.words,s=t.words,o=0;o<i;o++)r[o]^=1549556828,s[o]^=909522486;e.sigBytes=t.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,e=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(e))}})}())},function(e,t,i){"use strict";e.exports=function(i,n){return function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];return i.apply(n,e)}}},function(e,t,i){"use strict";var r=i(3);function s(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,i){if(!t)return e;var n,i=i?i(t):r.isURLSearchParams(t)?t.toString():(n=[],r.forEach(t,function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),n.push(s(t)+"="+s(e))}))}),n.join("&"));return i&&(-1!==(t=e.indexOf("#"))&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i),e}},function(e,t){var i,n,e=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(e){i=r}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var a,c=[],h=!1,l=-1;function u(){h&&a&&(h=!1,a.length?c=a.concat(c):l=-1,c.length&&p())}function p(){if(!h){var e=o(u);h=!0;for(var t=c.length;t;){for(a=c,c=[];++l<t;)a&&a[l].run();l=-1,t=c.length}a=null,h=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function f(){}e.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];c.push(new d(e,t)),1!==c.length||h||o(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=f,e.addListener=f,e.once=f,e.off=f,e.removeListener=f,e.removeAllListeners=f,e.emit=f,e.prependListener=f,e.prependOnceListener=f,e.listeners=function(e){return[]},e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},function(e,t,i){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,n){"use strict";!function(i){var c=n(3);e.exports=function(e,o){o=o||new FormData;var t=[];function a(e){return null===e?"":c.isDate(e)?e.toISOString():c.isArrayBuffer(e)||c.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):i.from(e):e}return function r(e,s){if(c.isPlainObject(e)||c.isArray(e)){if(-1!==t.indexOf(e))throw Error("Circular reference detected in "+s);t.push(e),c.forEach(e,function(e,t){if(!c.isUndefined(e)){var i,n=s?s+"."+t:t;if(e&&!s&&"object"==typeof e)if(c.endsWith(t,"{}"))e=JSON.stringify(e);else if(c.endsWith(t,"[]")&&(i=c.toArray(e)))return void i.forEach(function(e){c.isUndefined(e)||o.append(n,a(e))});r(e,n)}}),t.pop()}else o.append(s,a(e))}(e),o}}.call(this,n(43).Buffer)},function(e,t,i){"use strict";var p=i(3),d=i(47),f=i(48),g=i(20),m=i(25),v=i(51),y=i(52),b=i(22),w=i(8),_=i(12),A=i(53);e.exports=function(u){return new Promise(function(t,i){var e,n=u.data,r=u.headers,s=u.responseType;function o(){u.cancelToken&&u.cancelToken.unsubscribe(e),u.signal&&u.signal.removeEventListener("abort",e)}p.isFormData(n)&&p.isStandardBrowserEnv()&&delete r["Content-Type"];var a=new XMLHttpRequest;u.auth&&(h=u.auth.username||"",c=u.auth.password?unescape(encodeURIComponent(u.auth.password)):"",r.Authorization="Basic "+btoa(h+":"+c));var c,h=m(u.baseURL,u.url);function l(){var e;a&&(e="getAllResponseHeaders"in a?v(a.getAllResponseHeaders()):null,e={data:s&&"text"!==s&&"json"!==s?a.response:a.responseText,status:a.status,statusText:a.statusText,headers:e,config:u,request:a},d(function(e){t(e),o()},function(e){i(e),o()},e),a=null)}a.open(u.method.toUpperCase(),g(h,u.params,u.paramsSerializer),!0),a.timeout=u.timeout,"onloadend"in a?a.onloadend=l:a.onreadystatechange=function(){a&&4===a.readyState&&(0!==a.status||a.responseURL&&0===a.responseURL.indexOf("file:"))&&setTimeout(l)},a.onabort=function(){a&&(i(new w("Request aborted",w.ECONNABORTED,u,a)),a=null)},a.onerror=function(){i(new w("Network Error",w.ERR_NETWORK,u,a,a)),a=null},a.ontimeout=function(){var e=u.timeout?"timeout of "+u.timeout+"ms exceeded":"timeout exceeded",t=u.transitional||b;u.timeoutErrorMessage&&(e=u.timeoutErrorMessage),i(new w(e,t.clarifyTimeoutError?w.ETIMEDOUT:w.ECONNABORTED,u,a)),a=null},!p.isStandardBrowserEnv()||(c=(u.withCredentials||y(h))&&u.xsrfCookieName?f.read(u.xsrfCookieName):void 0)&&(r[u.xsrfHeaderName]=c),"setRequestHeader"in a&&p.forEach(r,function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete r[t]:a.setRequestHeader(t,e)}),p.isUndefined(u.withCredentials)||(a.withCredentials=!!u.withCredentials),s&&"json"!==s&&(a.responseType=u.responseType),"function"==typeof u.onDownloadProgress&&a.addEventListener("progress",u.onDownloadProgress),"function"==typeof u.onUploadProgress&&a.upload&&a.upload.addEventListener("progress",u.onUploadProgress),(u.cancelToken||u.signal)&&(e=function(e){a&&(i(!e||e.type?new _:e),a.abort(),a=null)},u.cancelToken&&u.cancelToken.subscribe(e),u.signal&&(u.signal.aborted?e():u.signal.addEventListener("abort",e)));n=n||null,h=A(h);h&&-1===["http","https","file"].indexOf(h)?i(new w("Unsupported protocol "+h+":",w.ERR_BAD_REQUEST,u)):a.send(n)})}},function(e,t,i){"use strict";var n=i(49),r=i(50);e.exports=function(e,t){return e&&!n(t)?r(e,t):t}},function(e,t,i){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,i){"use strict";var h=i(3);e.exports=function(t,i){i=i||{};var n={};function r(e,t){return h.isPlainObject(e)&&h.isPlainObject(t)?h.merge(e,t):h.isPlainObject(t)?h.merge({},t):h.isArray(t)?t.slice():t}function s(e){return h.isUndefined(i[e])?h.isUndefined(t[e])?void 0:r(void 0,t[e]):r(t[e],i[e])}function e(e){if(!h.isUndefined(i[e]))return r(void 0,i[e])}function o(e){return h.isUndefined(i[e])?h.isUndefined(t[e])?void 0:r(void 0,t[e]):r(void 0,i[e])}function a(e){return e in i?r(t[e],i[e]):e in t?r(void 0,t[e]):void 0}var c={url:e,method:e,data:e,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a};return h.forEach(Object.keys(t).concat(Object.keys(i)),function(e){var t=c[e]||s,i=t(e);h.isUndefined(i)&&t!==a||(n[e]=i)}),n}},function(e,t){e.exports={version:"0.27.2"}},function(e,t,i){var o;e.exports=(o=i(2),function(r){var e=o,t=e.lib,i=t.WordArray,n=t.Hasher,t=e.algo,s=[],f=[];!function(){function e(e){return 4294967296*(e-(0|e))|0}for(var t=2,i=0;i<64;)!function(e){for(var t=r.sqrt(e),i=2;i<=t;i++)if(!(e%i))return;return 1}(t)||(i<8&&(s[i]=e(r.pow(t,.5))),f[i]=e(r.pow(t,1/3)),i++),t++}();var g=[],t=t.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],c=i[5],h=i[6],l=i[7],u=0;u<64;u++){u<16?g[u]=0|e[t+u]:(p=g[u-15],d=g[u-2],g[u]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+g[u-7]+((d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10)+g[u-16]);var p=n&r^n&s^r&s,d=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&c^~a&h)+f[u]+g[u],l=h,h=c,c=a,a=o+d|0,o=s,s=r,r=n,n=d+(((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+p)|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+a|0,i[5]=i[5]+c|0,i[6]=i[6]+h|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(64+n>>>9<<4)]=r.floor(i/4294967296),t[15+(64+n>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA256=n._createHelper(t),e.HmacSHA256=n._createHmacHelper(t)}(Math),o.SHA256)},function(e,t,i){var o;e.exports=(o=i(2),i(13),function(){var e=o,t=e.lib.Hasher,i=e.x64,n=i.Word,r=i.WordArray,i=e.algo;function s(){return n.create.apply(n,arguments)}var ee=[s(1116352408,3609767458),s(1899447441,602891725),s(3049323471,3964484399),s(3921009573,2173295548),s(961987163,4081628472),s(1508970993,3053834265),s(2453635748,2937671579),s(2870763221,3664609560),s(3624381080,2734883394),s(310598401,1164996542),s(607225278,1323610764),s(1426881987,3590304994),s(1925078388,4068182383),s(2162078206,991336113),s(2614888103,633803317),s(3248222580,3479774868),s(3835390401,2666613458),s(4022224774,944711139),s(264347078,2341262773),s(604807628,2007800933),s(770255983,1495990901),s(1249150122,1856431235),s(1555081692,3175218132),s(1996064986,2198950837),s(2554220882,3999719339),s(2821834349,766784016),s(2952996808,2566594879),s(3210313671,3203337956),s(3336571891,1034457026),s(3584528711,2466948901),s(113926993,3758326383),s(338241895,168717936),s(666307205,1188179964),s(773529912,1546045734),s(1294757372,1522805485),s(1396182291,2643833823),s(1695183700,2343527390),s(1986661051,1014477480),s(2177026350,1206759142),s(2456956037,344077627),s(2730485921,1290863460),s(2820302411,3158454273),s(3259730800,3505952657),s(3345764771,106217008),s(3516065817,3606008344),s(3600352804,1432725776),s(4094571909,1467031594),s(275423344,851169720),s(430227734,3100823752),s(506948616,1363258195),s(659060556,3750685593),s(883997877,3785050280),s(958139571,3318307427),s(1322822218,3812723403),s(1537002063,2003034995),s(1747873779,3602036899),s(1955562222,1575990012),s(2024104815,1125592928),s(2227730452,2716904306),s(2361852424,442776044),s(2428436474,593698344),s(2756734187,3733110249),s(3204031479,2999351573),s(3329325298,3815920427),s(3391569614,3928383900),s(3515267271,566280711),s(3940187606,3454069534),s(4118630271,4000239992),s(116418474,1914138554),s(174292421,2731055270),s(289380356,3203993006),s(460393269,320620315),s(685471733,587496836),s(852142971,1086792851),s(1017036298,365543100),s(1126000580,2618297676),s(1288033470,3409855158),s(1501505948,4234509866),s(1607167915,987167468),s(1816402316,1246189591)],te=[];!function(){for(var e=0;e<80;e++)te[e]=s()}();i=i.SHA512=t.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],c=i[5],h=i[6],l=i[7],u=n.high,p=n.low,d=r.high,f=r.low,g=s.high,m=s.low,v=o.high,y=o.low,b=a.high,w=a.low,_=c.high,A=c.low,B=h.high,C=h.low,x=l.high,i=l.low,E=u,S=p,T=d,M=f,k=g,O=m,R=v,L=y,P=b,N=w,I=_,D=A,Y=B,j=C,z=x,U=i,F=0;F<80;F++){var H,V,G=te[F];F<16?(V=G.high=0|e[t+2*F],H=G.low=0|e[t+2*F+1]):(Q=(W=te[F-15]).high,K=W.low,X=(J=te[F-2]).high,q=J.low,$=(Z=te[F-7]).high,W=Z.low,Z=(J=te[F-16]).high,V=(V=((Q>>>1|K<<31)^(Q>>>8|K<<24)^Q>>>7)+$+((H=($=(K>>>1|Q<<31)^(K>>>8|Q<<24)^(K>>>7|Q<<25))+W)>>>0<$>>>0?1:0))+((X>>>19|q<<13)^(X<<3|q>>>29)^X>>>6)+((H+=K=(q>>>19|X<<13)^(q<<3|X>>>29)^(q>>>6|X<<26))>>>0<K>>>0?1:0),H+=Q=J.low,G.high=V=V+Z+(H>>>0<Q>>>0?1:0),G.low=H);var W=P&I^~P&Y,$=N&D^~N&j,q=E&T^E&k^T&k,X=(S>>>28|E<<4)^(S<<30|E>>>2)^(S<<25|E>>>7),K=ee[F],J=K.high,Z=K.low,Q=U+((N>>>14|P<<18)^(N>>>18|P<<14)^(N<<23|P>>>9)),G=z+((P>>>14|N<<18)^(P>>>18|N<<14)^(P<<23|N>>>9))+(Q>>>0<U>>>0?1:0),K=X+(S&M^S&O^M&O),z=Y,U=j,Y=I,j=D,I=P,D=N,P=R+(G=(G=(G=G+W+((Q=Q+$)>>>0<$>>>0?1:0))+J+((Q=Q+Z)>>>0<Z>>>0?1:0))+V+((Q=Q+H)>>>0<H>>>0?1:0))+((N=L+Q|0)>>>0<L>>>0?1:0)|0,R=k,L=O,k=T,O=M,T=E,M=S,E=G+(((E>>>28|S<<4)^(E<<30|S>>>2)^(E<<25|S>>>7))+q+(K>>>0<X>>>0?1:0))+((S=Q+K|0)>>>0<Q>>>0?1:0)|0}p=n.low=p+S,n.high=u+E+(p>>>0<S>>>0?1:0),f=r.low=f+M,r.high=d+T+(f>>>0<M>>>0?1:0),m=s.low=m+O,s.high=g+k+(m>>>0<O>>>0?1:0),y=o.low=y+L,o.high=v+R+(y>>>0<L>>>0?1:0),w=a.low=w+N,a.high=b+P+(w>>>0<N>>>0?1:0),A=c.low=A+D,c.high=_+I+(A>>>0<D>>>0?1:0),C=h.low=C+j,h.high=B+Y+(C>>>0<j>>>0?1:0),i=l.low=i+U,l.high=x+z+(i>>>0<U>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(128+n>>>10<<5)]=Math.floor(i/4294967296),t[31+(128+n>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(i),e.HmacSHA512=t._createHmacHelper(i)}(),o.SHA512)},function(e,t,i){e.exports=i(37)},function(e,t){e.exports=r},function(e,t){e.exports=s},function(e,t){e.exports=o},function(e,t){e.exports=a},function(e,t){e.exports=c},function(e,t,i){"use strict";var r=i(3),s=i(19),o=i(38),a=i(27);var n=function t(i){var e=new o(i),n=s(o.prototype.request,e);return r.extend(n,o.prototype,e),r.extend(n,e),n.create=function(e){return t(a(i,e))},n}(i(15));n.Axios=o,n.CanceledError=i(12),n.CancelToken=i(56),n.isCancel=i(26),n.VERSION=i(28).version,n.toFormData=i(23),n.AxiosError=i(8),n.Cancel=n.CanceledError,n.all=function(e){return Promise.all(e)},n.spread=i(57),n.isAxiosError=i(58),e.exports=n,e.exports.default=n},function(e,t,i){"use strict";var n=i(3),r=i(20),s=i(39),l=i(40),u=i(27),o=i(25),p=i(55),d=p.validators;function a(e){this.defaults=e,this.interceptors={request:new s,response:new s}}a.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=u(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";e=t.transitional;void 0!==e&&p.assertOptions(e,{silentJSONParsing:d.transitional(d.boolean),forcedJSONParsing:d.transitional(d.boolean),clarifyTimeoutError:d.transitional(d.boolean)},!1);var i=[],n=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(n=n&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});var r,s=[];if(this.interceptors.response.forEach(function(e){s.push(e.fulfilled,e.rejected)}),!n){var o=[l,void 0];for(Array.prototype.unshift.apply(o,i),o=o.concat(s),r=Promise.resolve(t);o.length;)r=r.then(o.shift(),o.shift());return r}for(var a=t;i.length;){var c=i.shift(),h=i.shift();try{a=c(a)}catch(e){h(e);break}}try{r=l(a)}catch(e){return Promise.reject(e)}for(;s.length;)r=r.then(s.shift(),s.shift());return r},a.prototype.getUri=function(e){e=u(this.defaults,e);var t=o(e.baseURL,e.url);return r(t,e.params,e.paramsSerializer)},n.forEach(["delete","get","head","options"],function(i){a.prototype[i]=function(e,t){return this.request(u(t||{},{method:i,url:e,data:(t||{}).data}))}}),n.forEach(["post","put","patch"],function(r){function e(n){return function(e,t,i){return this.request(u(i||{},{method:r,headers:n?{"Content-Type":"multipart/form-data"}:{},url:e,data:t}))}}a.prototype[r]=e(),a.prototype[r+"Form"]=e(!0)}),e.exports=a},function(e,t,i){"use strict";var n=i(3);function r(){this.handlers=[]}r.prototype.use=function(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(t){n.forEach(this.handlers,function(e){null!==e&&t(e)})},e.exports=r},function(e,t,i){"use strict";var n=i(3),r=i(41),s=i(26),o=i(15),a=i(12);function c(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a}e.exports=function(t){return c(t),t.headers=t.headers||{},t.data=r.call(t,t.data,t.headers,t.transformRequest),t.headers=n.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),n.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||o.adapter)(t).then(function(e){return c(t),e.data=r.call(t,e.data,e.headers,t.transformResponse),e},function(e){return s(e)||(c(t),e&&e.response&&(e.response.data=r.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(e,t,i){"use strict";var r=i(3),s=i(15);e.exports=function(t,i,e){var n=this||s;return r.forEach(e,function(e){t=e.call(n,t,i)}),t}},function(e,t,i){"use strict";var r=i(3);e.exports=function(i,n){r.forEach(i,function(e,t){t!==n&&t.toUpperCase()===n.toUpperCase()&&(i[n]=e,delete i[t])})}},function(e,R,L){"use strict";!function(e){var a=L(44),s=L(45),o=L(46);function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function r(e,t){if(i()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(e=null===e?new u(t):e).length=t,e}function u(e,t,i){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,i);if("number"!=typeof e)return n(this,e,t,i);if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}function n(e,t,i,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,i,n){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===i&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,i):new Uint8Array(t,i,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=l(e,t);return e}(e,t,i,n):"string"==typeof t?function(e,t,i){"string"==typeof i&&""!==i||(i="utf8");if(!u.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(t,i),i=(e=r(e,n)).write(t,i);i!==n&&(e=e.slice(0,i));return e}(e,t,i):function(e,t){if(u.isBuffer(t)){var i=0|p(t.length);return 0===(e=r(e,i)).length?e:(t.copy(e,0,0,i),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||function(e){return e!=e}(t.length)?r(e,0):l(e,t);if("Buffer"===t.type&&o(t.data))return l(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function c(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 h(e,t){if(c(t),e=r(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function l(e,t){var i=t.length<0?0:0|p(t.length);e=r(e,i);for(var n=0;n<i;n+=1)e[n]=255&t[n];return e}function p(e){if(e>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;var i=(e="string"!=typeof e?""+e:e).length;if(0===i)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return M(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return k(e).length;default:if(n)return M(e).length;t=(""+t).toLowerCase(),n=!0}}function t(e,t,i){var n,r,s,o=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((i=void 0===i||i>this.length?this.length:i)<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":return function(e,t,i){var n=e.length;(!t||t<0)&&(t=0);(!i||i<0||n<i)&&(i=n);for(var r="",s=t;s<i;++s)r+=function(e){return e<16?"0"+e.toString(16):e.toString(16)}(e[s]);return r}(this,t,i);case"utf8":case"utf-8":return b(this,t,i);case"ascii":return function(e,t,i){var n="";i=Math.min(e.length,i);for(var r=t;r<i;++r)n+=String.fromCharCode(127&e[r]);return n}(this,t,i);case"latin1":case"binary":return function(e,t,i){var n="";i=Math.min(e.length,i);for(var r=t;r<i;++r)n+=String.fromCharCode(e[r]);return n}(this,t,i);case"base64":return n=this,s=i,0===(r=t)&&s===n.length?a.fromByteArray(n):a.fromByteArray(n.slice(r,s));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,i){for(var n=e.slice(t,i),r="",s=0;s<n.length;s+=2)r+=String.fromCharCode(n[s]+256*n[s+1]);return r}(this,t,i);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function f(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function g(e,t,i,n,r){if(0===e.length)return-1;if("string"==typeof i?(n=i,i=0):2147483647<i?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,(i=(i=isNaN(i)?r?0:e.length-1:i)<0?e.length+i:i)>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,i,n,r);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(r?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,i):m(e,[t],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(e,t,i,n,r){var s=1,o=e.length,a=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;o/=s=2,a/=2,i/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(r)for(var h=-1,l=i;l<o;l++)if(c(e,l)===c(t,-1===h?0:l-h)){if(l-(h=-1===h?l:h)+1===a)return h*s}else-1!==h&&(l-=l-h),h=-1;else for(l=i=o<i+a?o-a:i;0<=l;l--){for(var u=!0,p=0;p<a;p++)if(c(e,l+p)!==c(t,p)){u=!1;break}if(u)return l}return-1}function v(e,t,i,n){return O(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,n)}function y(e,t,i,n){return O(function(e,t){for(var i,n,r=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),i=n>>8,n=n%256,r.push(n),r.push(i);return r}(t,e.length-i),e,i,n)}function b(e,t,i){i=Math.min(e.length,i);for(var n=[],r=t;r<i;){var s,o,a,c,h=e[r],l=null,u=239<h?4:223<h?3:191<h?2:1;if(r+u<=i)switch(u){case 1:h<128&&(l=h);break;case 2:128==(192&(s=e[r+1]))&&127<(c=(31&h)<<6|63&s)&&(l=c);break;case 3:s=e[r+1],o=e[r+2],128==(192&s)&&128==(192&o)&&2047<(c=(15&h)<<12|(63&s)<<6|63&o)&&(c<55296||57343<c)&&(l=c);break;case 4:s=e[r+1],o=e[r+2],a=e[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&65535<(c=(15&h)<<18|(63&s)<<12|(63&o)<<6|63&a)&&c<1114112&&(l=c)}null===l?(l=65533,u=1):65535<l&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),r+=u}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);var i="",n=0;for(;n<t;)i+=String.fromCharCode.apply(String,e.slice(n,n+=w));return i}(n)}R.Buffer=u,R.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},R.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),R.kMaxLength=i(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,i){return n(null,e,t,i)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,i){return n=null,t=t,i=i,c(e=e),!(e<=0)&&void 0!==t?"string"==typeof i?r(n,e).fill(t,i):r(n,e).fill(t):r(n,e);var n},u.allocUnsafe=function(e){return h(null,e)},u.allocUnsafeSlow=function(e){return h(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,n=t.length,r=0,s=Math.min(i,n);r<s;++r)if(e[r]!==t[r]){i=e[r],n=t[r];break}return i<n?-1:n<i?1:0},u.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}},u.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);if(void 0===t)for(r=t=0;r<e.length;++r)t+=e[r].length;for(var i=u.allocUnsafe(t),n=0,r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,n),n+=s.length}return i},u.byteLength=d,u.prototype._isBuffer=!0,u.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)f(this,t,t+1);return this},u.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)f(this,t,t+3),f(this,t+1,t+2);return this},u.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)f(this,t,t+7),f(this,t+1,t+6),f(this,t+2,t+5),f(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0==e?"":0===arguments.length?b(this,0,e):t.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",t=R.INSPECT_MAX_BYTES;return 0<this.length&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,i,n,r){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),(t=void 0===t?0:t)<0||i>e.length||n<0||r>this.length)throw new RangeError("out of range index");if(r<=n&&i<=t)return 0;if(r<=n)return-1;if(i<=t)return 1;if(this===e)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0),a=Math.min(s,o),c=this.slice(n,r),h=e.slice(t,i),l=0;l<a;++l)if(c[l]!==h[l]){s=c[l],o=h[l];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},u.prototype.indexOf=function(e,t,i){return g(this,e,t,i,!0)},u.prototype.lastIndexOf=function(e,t,i){return g(this,e,t,i,!1)},u.prototype.write=function(e,t,i,n){if(void 0===t)n="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)n=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}var r=this.length-t;if((void 0===i||r<i)&&(i=r),0<e.length&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var s,o,a,c=!1;;)switch(n){case"hex":return function(e,t,i,n){i=Number(i)||0;var r=e.length-i;if((!n||r<(n=Number(n)))&&(n=r),(r=t.length)%2!=0)throw new TypeError("Invalid hex string");r/2<n&&(n=r/2);for(var s=0;s<n;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[i+s]=o}return s}(this,e,t,i);case"utf8":case"utf-8":return o=t,a=i,O(M(e,(s=this).length-o),s,o,a);case"ascii":return v(this,e,t,i);case"latin1":case"binary":return v(this,e,t,i);case"base64":return s=this,o=t,a=i,O(k(e),s,o,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y(this,e,t,i);default:if(c)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),c=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function _(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(i<e+t)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,i,n,r,s){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r<t||t<s)throw new RangeError('"value" argument is out of bounds');if(i+n>e.length)throw new RangeError("Index out of range")}function B(e,t,i,n){t<0&&(t=65535+t+1);for(var r=0,s=Math.min(e.length-i,2);r<s;++r)e[i+r]=(t&255<<8*(n?r:1-r))>>>8*(n?r:1-r)}function C(e,t,i,n){t<0&&(t=4294967295+t+1);for(var r=0,s=Math.min(e.length-i,4);r<s;++r)e[i+r]=t>>>8*(n?r:3-r)&255}function x(e,t,i,n){if(i+n>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function E(e,t,i,n,r){return r||x(e,0,i,4),s.write(e,t,i,n,23,4),i+4}function S(e,t,i,n,r){return r||x(e,0,i,8),s.write(e,t,i,n,52,8),i+8}u.prototype.slice=function(e,t){var i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):i<e&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):i<t&&(t=i),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else for(var n=t-e,r=new u(n,void 0),s=0;s<n;++s)r[s]=this[s+e];return r},u.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||_(e,t,this.length);for(var n=this[e],r=1,s=0;++s<t&&(r*=256);)n+=this[e+s]*r;return n},u.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||_(e,t,this.length);for(var n=this[e+--t],r=1;0<t&&(r*=256);)n+=this[e+--t]*r;return n},u.prototype.readUInt8=function(e,t){return t||_(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||_(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||_(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||_(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||_(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||_(e,t,this.length);for(var n=this[e],r=1,s=0;++s<t&&(r*=256);)n+=this[e+s]*r;return(r*=128)<=n&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||_(e,t,this.length);for(var n=t,r=1,s=this[e+--n];0<n&&(r*=256);)s+=this[e+--n]*r;return(r*=128)<=s&&(s-=Math.pow(2,8*t)),s},u.prototype.readInt8=function(e,t){return t||_(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||_(e,2,this.length);e=this[e]|this[e+1]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt16BE=function(e,t){t||_(e,2,this.length);e=this[e+1]|this[e]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt32LE=function(e,t){return t||_(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||_(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||_(e,4,this.length),s.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||_(e,4,this.length),s.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||_(e,8,this.length),s.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||_(e,8,this.length),s.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,i,n){e=+e,t|=0,i|=0,n||A(this,e,t,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[t]=255&e;++s<i&&(r*=256);)this[t+s]=e/r&255;return t+i},u.prototype.writeUIntBE=function(e,t,i,n){e=+e,t|=0,i|=0,n||A(this,e,t,i,Math.pow(2,8*i)-1,0);var r=i-1,s=1;for(this[t+r]=255&e;0<=--r&&(s*=256);)this[t+r]=e/s&255;return t+i},u.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):B(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):B(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):C(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,i,n){e=+e,t|=0,n||A(this,e,t,i,(n=Math.pow(2,8*i-1))-1,-n);var r=0,s=1,o=0;for(this[t]=255&e;++r<i&&(s*=256);)e<0&&0===o&&0!==this[t+r-1]&&(o=1),this[t+r]=(e/s>>0)-o&255;return t+i},u.prototype.writeIntBE=function(e,t,i,n){e=+e,t|=0,n||A(this,e,t,i,(n=Math.pow(2,8*i-1))-1,-n);var r=i-1,s=1,o=0;for(this[t+r]=255&e;0<=--r&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s>>0)-o&255;return t+i},u.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&(e=e<0?255+e+1:e),t+1},u.prototype.writeInt16LE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):B(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):B(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):C(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,i){return E(this,e,t,!0,i)},u.prototype.writeFloatBE=function(e,t,i){return E(this,e,t,!1,i)},u.prototype.writeDoubleLE=function(e,t,i){return S(this,e,t,!0,i)},u.prototype.writeDoubleBE=function(e,t,i){return S(this,e,t,!1,i)},u.prototype.copy=function(e,t,i,n){if(i=i||0,n||0===n||(n=this.length),t>=e.length&&(t=e.length),(n=0<n&&n<i?i:n)===i)return 0;if(0===e.length||0===this.length)return 0;if((t=t||0)<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=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);var r,s=(n=e.length-t<n-i?e.length-t+i:n)-i;if(this===e&&i<t&&t<n)for(r=s-1;0<=r;--r)e[r+t]=this[r+i];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(r=0;r<s;++r)e[r+t]=this[r+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+s),t);return s},u.prototype.fill=function(e,t,i,n){if("string"==typeof e){var r;if("string"==typeof t?(n=t,t=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),1!==e.length||(r=e.charCodeAt(0))<256&&(e=r),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;if(t>>>=0,i=void 0===i?this.length:i>>>0,"number"==typeof(e=e||0))for(a=t;a<i;++a)this[a]=e;else for(var s=u.isBuffer(e)?e:M(new u(e,n).toString()),o=s.length,a=0;a<i-t;++a)this[a+t]=s[a%o];return this};var T=/[^+\/0-9A-Za-z-_]/g;function M(e,t){var i;t=t||1/0;for(var n=e.length,r=null,s=[],o=0;o<n;++o){if(55295<(i=e.charCodeAt(o))&&i<57344){if(!r){if(56319<i){-1<(t-=3)&&s.push(239,191,189);continue}if(o+1===n){-1<(t-=3)&&s.push(239,191,189);continue}r=i;continue}if(i<56320){-1<(t-=3)&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&-1<(t-=3)&&s.push(239,191,189);if(r=null,i<128){if(--t<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function k(e){return a.toByteArray(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function O(e,t,i,n){for(var r=0;r<n&&!(r+i>=t.length||r>=e.length);++r)t[r+i]=e[r];return r}}.call(this,L(16))},function(e,t,i){"use strict";t.byteLength=function(e){var t=l(e),e=t[0],t=t[1];return 3*(e+t)/4-t},t.toByteArray=function(e){var t,i,n=l(e),r=n[0],n=n[1],s=new h(function(e,t){return 3*(e+t)/4-t}(r,n)),o=0,a=0<n?r-4:r;for(i=0;i<a;i+=4)t=c[e.charCodeAt(i)]<<18|c[e.charCodeAt(i+1)]<<12|c[e.charCodeAt(i+2)]<<6|c[e.charCodeAt(i+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=255&t;2===n&&(t=c[e.charCodeAt(i)]<<2|c[e.charCodeAt(i+1)]>>4,s[o++]=255&t);1===n&&(t=c[e.charCodeAt(i)]<<10|c[e.charCodeAt(i+1)]<<4|c[e.charCodeAt(i+2)]>>2,s[o++]=t>>8&255,s[o++]=255&t);return s},t.fromByteArray=function(e){for(var t,i=e.length,n=i%3,r=[],s=0,o=i-n;s<o;s+=16383)r.push(function(e,t,i){for(var n,r=[],s=t;s<i;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),r.push(function(e){return a[e>>18&63]+a[e>>12&63]+a[e>>6&63]+a[63&e]}(n));return r.join("")}(e,s,o<s+16383?o:s+16383));1==n?(t=e[i-1],r.push(a[t>>2]+a[t<<4&63]+"==")):2==n&&(t=(e[i-2]<<8)+e[i-1],r.push(a[t>>10]+a[t>>4&63]+a[t<<2&63]+"="));return r.join("")};for(var a=[],c=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,s=n.length;r<s;++r)a[r]=n[r],c[n.charCodeAt(r)]=r;function l(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");e=e.indexOf("=");return[e=-1===e?t:e,e===t?0:4-e%4]}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<<a)-1,h=c>>1,l=-7,u=i?r-1:0,p=i?-1:1,i=e[t+u];for(u+=p,s=i&(1<<-l)-1,i>>=-l,l+=a;0<l;s=256*s+e[t+u],u+=p,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;0<l;o=256*o+e[t+u],u+=p,l-=8);if(0===s)s=1-h;else{if(s===c)return o?NaN:1/0*(i?-1:1);o+=Math.pow(2,n),s-=h}return(i?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,i,n,r,s){var o,a,c=8*s-r-1,h=(1<<c)-1,l=h>>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,s=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(n=Math.pow(2,-o))<1&&(o--,n*=2),2<=(t+=1<=o+l?u/n:u*Math.pow(2,1-l))*n&&(o++,n/=2),h<=o+l?(a=0,o=h):1<=o+l?(a=(t*n-1)*Math.pow(2,r),o+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,r),o=0));8<=r;e[i+p]=255&a,p+=d,a/=256,r-=8);for(o=o<<r|a,c+=r;0<c;e[i+p]=255&o,p+=d,o/=256,c-=8);e[i+p-d]|=128*s}},function(e,t){var i={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==i.call(e)}},function(e,t,i){"use strict";var r=i(8);e.exports=function(e,t,i){var n=i.config.validateStatus;i.status&&n&&!n(i.status)?t(new r("Request failed with status code "+i.status,[r.ERR_BAD_REQUEST,r.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):e(i)}},function(e,t,i){"use strict";var a=i(3);e.exports=a.isStandardBrowserEnv()?{write:function(e,t,i,n,r,s){var o=[];o.push(e+"="+encodeURIComponent(t)),a.isNumber(i)&&o.push("expires="+new Date(i).toGMTString()),a.isString(n)&&o.push("path="+n),a.isString(r)&&o.push("domain="+r),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){e=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,i){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,i){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,i){"use strict";var r=i(3),s=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,i,n={};return e&&r.forEach(e.split("\n"),function(e){i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),i=r.trim(e.substr(i+1)),t&&(n[t]&&0<=s.indexOf(t)||(n[t]="set-cookie"===t?(n[t]||[]).concat([i]):n[t]?n[t]+", "+i:i))}),n}},function(e,t,i){"use strict";var n,r,s,o=i(3);function a(e){return r&&(s.setAttribute("href",e),e=s.href),s.setAttribute("href",e),{href:s.href,protocol:s.protocol?s.protocol.replace(/:$/,""):"",host:s.host,search:s.search?s.search.replace(/^\?/,""):"",hash:s.hash?s.hash.replace(/^#/,""):"",hostname:s.hostname,port:s.port,pathname:"/"===s.pathname.charAt(0)?s.pathname:"/"+s.pathname}}e.exports=o.isStandardBrowserEnv()?(r=/(msie|trident)/i.test(navigator.userAgent),s=document.createElement("a"),n=a(window.location.href),function(e){e=o.isString(e)?a(e):e;return e.protocol===n.protocol&&e.host===n.host}):function(){return!0}},function(e,t,i){"use strict";e.exports=function(e){e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return e&&e[1]||""}},function(e,t){e.exports=null},function(e,t,i){"use strict";var o=i(28).version,c=i(8),n={};["object","boolean","number","function","string","symbol"].forEach(function(t,i){n[t]=function(e){return typeof e===t||"a"+(i<1?"n ":" ")+t}});var a={};n.transitional=function(n,r,i){function s(e,t){return"[Axios v"+o+"] Transitional option '"+e+"'"+t+(i?". "+i:"")}return function(e,t,i){if(!1===n)throw new c(s(t," has been removed"+(r?" in "+r:"")),c.ERR_DEPRECATED);return r&&!a[t]&&(a[t]=!0,console.warn(s(t," has been deprecated since v"+r+" and will be removed in the near future"))),!n||n(e,t,i)}},e.exports={assertOptions:function(e,t,i){if("object"!=typeof e)throw new c("options must be an object",c.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),r=n.length;0<r--;){var s=n[r],o=t[s];if(o){var a=e[s],a=void 0===a||o(a,s,e);if(!0!==a)throw new c("option "+s+" must be "+a,c.ERR_BAD_OPTION_VALUE)}else if(!0!==i)throw new c("Unknown option "+s,c.ERR_BAD_OPTION)}},validators:n}},function(e,t,i){"use strict";var r=i(12);function n(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;this.promise.then(function(e){if(n._listeners){for(var t=n._listeners.length,i=0;i<t;i++)n._listeners[i](e);n._listeners=null}}),this.promise.then=function(e){var t,e=new Promise(function(e){n.subscribe(e),t=e}).then(e);return e.cancel=function(){n.unsubscribe(t)},e},e(function(e){n.reason||(n.reason=new r(e),t(n.reason))})}n.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},n.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},n.prototype.unsubscribe=function(e){!this._listeners||-1!==(e=this._listeners.indexOf(e))&&this._listeners.splice(e,1)},n.source=function(){var t;return{token:new n(function(e){t=e}),cancel:t}},e.exports=n},function(e,t,i){"use strict";e.exports=function(t){return function(e){return t.apply(null,e)}}},function(e,t,i){"use strict";var n=i(3);e.exports=function(e){return n.isObject(e)&&!0===e.isAxiosError}},function(e,t){},function(e,t,i){var n;e.exports=(n=i(2),function(){var e,r;"function"==typeof ArrayBuffer&&(e=n.lib.WordArray,r=e.init,(e.init=function(e){if((e=(e=e instanceof ArrayBuffer?new Uint8Array(e):e)instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e)instanceof Uint8Array){for(var t=e.byteLength,i=[],n=0;n<t;n++)i[n>>>2]|=e[n]<<24-n%4*8;r.call(this,i,t)}else r.apply(this,arguments)}).prototype=e)}(),n.lib.WordArray)},function(e,t,i){var n;e.exports=(n=i(2),function(){var r=n.lib.WordArray,e=n.enc;e.Utf16=e.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,n=[],r=0;r<i;r+=2){var s=t[r>>>2]>>>16-r%4*8&65535;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n++)i[n>>>1]|=e.charCodeAt(n)<<16-n%2*16;return r.create(i,2*t)}};function o(e){return e<<8&4278255360|e>>>8&16711935}e.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,n=[],r=0;r<i;r+=2){var s=o(t[r>>>2]>>>16-r%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n++)i[n>>>1]|=o(e.charCodeAt(n)<<16-n%2*16);return r.create(i,2*t)}}}(),n.enc.Utf16)},function(e,t,i){var n;e.exports=(n=i(2),function(){var c=n.lib.WordArray;n.enc.Base64url={stringify:function(e,t=!0){var i=e.words,n=e.sigBytes,r=t?this._safe_map:this._map;e.clamp();for(var s=[],o=0;o<n;o+=3)for(var a=(i[o>>>2]>>>24-o%4*8&255)<<16|(i[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|i[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c<n;c++)s.push(r.charAt(a>>>6*(3-c)&63));var h=r.charAt(64);if(h)for(;s.length%4;)s.push(h);return s.join("")},parse:function(e,t=!0){var i=e.length,n=t?this._safe_map:this._map;if(!(r=this._reverseMap))for(var r=this._reverseMap=[],s=0;s<n.length;s++)r[n.charCodeAt(s)]=s;t=n.charAt(64);return!t||-1!==(t=e.indexOf(t))&&(i=t),function(e,t,i){for(var n=[],r=0,s=0;s<t;s++){var o,a;s%4&&(o=i[e.charCodeAt(s-1)]<<s%4*2,a=i[e.charCodeAt(s)]>>>6-s%4*2,a=o|a,n[r>>>2]|=a<<24-r%4*8,r++)}return c.create(n,r)}(e,i,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),n.enc.Base64url)},function(e,t,i){var r;e.exports=(r=i(2),i(29),function(){var e=r,t=e.lib.WordArray,i=e.algo,n=i.SHA256,i=i.SHA224=n.extend({_doReset:function(){this._hash=new t.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=n._doFinalize.call(this);return e.sigBytes-=4,e}});e.SHA224=n._createHelper(i),e.HmacSHA224=n._createHmacHelper(i)}(),r.SHA224)},function(e,t,i){var s;e.exports=(s=i(2),i(13),i(30),function(){var e=s,t=e.x64,i=t.Word,n=t.WordArray,t=e.algo,r=t.SHA512,t=t.SHA384=r.extend({_doReset:function(){this._hash=new n.init([new i.init(3418070365,3238371032),new i.init(1654270250,914150663),new i.init(2438529370,812702999),new i.init(355462360,4144912697),new i.init(1731405415,4290775857),new i.init(2394180231,1750603025),new i.init(3675008525,1694076839),new i.init(1203062813,3204075428)])},_doFinalize:function(){var e=r._doFinalize.call(this);return e.sigBytes-=16,e}});e.SHA384=r._createHelper(t),e.HmacSHA384=r._createHmacHelper(t)}(),s.SHA384)},function(e,t,i){var r;e.exports=(r=i(2),i(13),function(l){var e=r,t=e.lib,u=t.WordArray,n=t.Hasher,p=e.x64.Word,t=e.algo,E=[],S=[],T=[];!function(){for(var e=1,t=0,i=0;i<24;i++){E[e+5*t]=(i+1)*(i+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(e=0;e<5;e++)for(t=0;t<5;t++)S[e+5*t]=t+(2*e+3*t)%5*5;for(var r=1,s=0;s<24;s++){for(var o,a=0,c=0,h=0;h<7;h++)1&r&&((o=(1<<h)-1)<32?c^=1<<o:a^=1<<o-32),128&r?r=r<<1^113:r<<=1;T[s]=p.create(a,c)}}();var M=[];!function(){for(var e=0;e<25;e++)M[e]=p.create()}();t=t.SHA3=n.extend({cfg:n.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new p.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,n=this.blockSize/2,r=0;r<n;r++){var s=e[t+2*r],o=e[t+2*r+1],s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8);(A=i[r]).high^=o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),A.low^=s}for(var a=0;a<24;a++){for(var c=0;c<5;c++){for(var h=0,l=0,u=0;u<5;u++)h^=(A=i[c+5*u]).high,l^=A.low;var p=M[c];p.high=h,p.low=l}for(c=0;c<5;c++)for(var d=M[(c+4)%5],f=M[(c+1)%5],g=f.high,f=f.low,h=d.high^(g<<1|f>>>31),l=d.low^(f<<1|g>>>31),u=0;u<5;u++)(A=i[c+5*u]).high^=h,A.low^=l;for(var m=1;m<25;m++){var v=(A=i[m]).high,y=A.low,b=E[m];l=b<32?(h=v<<b|y>>>32-b,y<<b|v>>>32-b):(h=y<<b-32|v>>>64-b,v<<b-32|y>>>64-b);b=M[S[m]];b.high=h,b.low=l}var w=M[0],_=i[0];w.high=_.high,w.low=_.low;for(c=0;c<5;c++)for(u=0;u<5;u++){var A=i[m=c+5*u],B=M[m],C=M[(c+1)%5+5*u],x=M[(c+2)%5+5*u];A.high=B.high^~C.high&x.high,A.low=B.low^~C.low&x.low}A=i[0],_=T[a];A.high^=_.high,A.low^=_.low}},_doFinalize:function(){var e=this._data,t=e.words,i=(this._nDataBytes,8*e.sigBytes),n=32*this.blockSize;t[i>>>5]|=1<<24-i%32,t[(l.ceil((1+i)/n)*n>>>5)-1]|=128,e.sigBytes=4*t.length,this._process();for(var r=this._state,t=this.cfg.outputLength/8,s=t/8,o=[],a=0;a<s;a++){var c=r[a],h=c.high,c=c.low,h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8);o.push(c=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)),o.push(h)}return new u.init(o,t)},clone:function(){for(var e=n.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});e.SHA3=n._createHelper(t),e.HmacSHA3=n._createHmacHelper(t)}(Math),r.SHA3)},function(e,t,i){var r;e.exports=(r=i(2),function(){var e=r,t=e.lib,i=t.WordArray,n=t.Hasher,t=e.algo,B=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),C=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),x=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),E=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),S=i.create([0,1518500249,1859775393,2400959708,2840853838]),T=i.create([1352829926,1548603684,1836072691,2053994217,0]),t=t.RIPEMD160=n.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var n=t+i,r=e[n];e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}for(var s,o,a,c,h,l,u=this._hash.words,p=S.words,d=T.words,f=B.words,g=C.words,m=x.words,v=E.words,y=s=u[0],b=o=u[1],w=a=u[2],_=c=u[3],A=h=u[4],i=0;i<80;i+=1)l=s+e[t+f[i]]|0,l+=i<16?(o^a^c)+p[0]:i<32?M(o,a,c)+p[1]:i<48?((o|~a)^c)+p[2]:i<64?k(o,a,c)+p[3]:(o^(a|~c))+p[4],l=(l=O(l|=0,m[i]))+h|0,s=h,h=c,c=O(a,10),a=o,o=l,l=y+e[t+g[i]]|0,l+=i<16?(b^(w|~_))+d[0]:i<32?k(b,w,_)+d[1]:i<48?((b|~w)^_)+d[2]:i<64?M(b,w,_)+d[3]:(b^w^_)+d[4],l=(l=O(l|=0,v[i]))+A|0,y=A,A=_,_=O(w,10),w=b,b=l;l=u[1]+a+_|0,u[1]=u[2]+c+A|0,u[2]=u[3]+h+y|0,u[3]=u[4]+s+b|0,u[4]=u[0]+o+w|0,u[0]=l},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(64+n>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var t=this._hash,r=t.words,s=0;s<5;s++){var o=r[s];r[s]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}return t},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function M(e,t,i){return e&t|~e&i}function k(e,t,i){return e&i|t&~i}function O(e,t){return e<<t|e>>>32-t}e.RIPEMD160=n._createHelper(t),e.HmacRIPEMD160=n._createHmacHelper(t)}(Math),r.RIPEMD160)},function(e,t,i){var s;e.exports=(s=i(2),i(17),i(18),function(){var e=s,t=e.lib,i=t.Base,v=t.WordArray,n=e.algo,t=n.SHA1,y=n.HMAC,r=n.PBKDF2=i.extend({cfg:i.extend({keySize:4,hasher:t,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,n=y.create(i.hasher,e),r=v.create(),s=v.create([1]),o=r.words,a=s.words,c=i.keySize,h=i.iterations;o.length<c;){var l=n.update(t).finalize(s);n.reset();for(var u=l.words,p=u.length,d=l,f=1;f<h;f++){d=n.finalize(d),n.reset();for(var g=d.words,m=0;m<p;m++)u[m]^=g[m]}r.concat(l),a[0]++}return r.sigBytes=4*c,r}});e.PBKDF2=function(e,t,i){return r.create(i).compute(e,t)}}(),s.PBKDF2)},function(e,t,i){var n;e.exports=(n=i(2),i(4),n.mode.CFB=function(){var e=n.lib.BlockCipherMode.extend();function s(e,t,i,n){var r,s=this._iv;s?(r=s.slice(0),this._iv=void 0):r=this._prevBlock,n.encryptBlock(r,0);for(var o=0;o<i;o++)e[t+o]^=r[o]}return e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize;s.call(this,e,t,n,i),this._prevBlock=e.slice(t,t+n)}}),e.Decryptor=e.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,r=e.slice(t,t+n);s.call(this,e,t,n,i),this._prevBlock=r}}),e}(),n.mode.CFB)},function(e,t,i){var n;e.exports=(n=i(2),i(4),n.mode.CTR=function(){var e=n.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,r=this._iv,s=this._counter;r&&(s=this._counter=r.slice(0),this._iv=void 0);var o=s.slice(0);i.encryptBlock(o,0),s[n-1]=s[n-1]+1|0;for(var a=0;a<n;a++)e[t+a]^=o[a]}});return e.Decryptor=t,e}(),n.mode.CTR)},function(e,t,i){var n;e.exports=(n=i(2),i(4),n.mode.CTRGladman=function(){var e=n.lib.BlockCipherMode.extend();function c(e){var t,i,n;return 255==(e>>24&255)?(i=e>>8&255,n=255&e,255===(t=e>>16&255)?(t=0,255===i?(i=0,255===n?n=0:++n):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=n):e+=1<<24,e}var t=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,r=this._iv,s=this._counter;r&&(s=this._counter=r.slice(0),this._iv=void 0),0===((r=s)[0]=c(r[0]))&&(r[1]=c(r[1]));var o=s.slice(0);i.encryptBlock(o,0);for(var a=0;a<n;a++)e[t+a]^=o[a]}});return e.Decryptor=t,e}(),n.mode.CTRGladman)},function(e,t,i){var n;e.exports=(n=i(2),i(4),n.mode.OFB=function(){var e=n.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,r=this._iv,s=this._keystream;r&&(s=this._keystream=r.slice(0),this._iv=void 0),i.encryptBlock(s,0);for(var o=0;o<n;o++)e[t+o]^=s[o]}});return e.Decryptor=t,e}(),n.mode.OFB)},function(e,t,i){var n;e.exports=(n=i(2),i(4),n.mode.ECB=function(){var e=n.lib.BlockCipherMode.extend();return e.Encryptor=e.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),e.Decryptor=e.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),e}(),n.mode.ECB)},function(e,t,i){e.exports=(e=i(2),i(4),e.pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,t=4*t,t=t-i%t,i=i+t-1;e.clamp(),e.words[i>>>2]|=t<<24-i%4*8,e.sigBytes+=t},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923)},function(e,t,i){var n;e.exports=(n=i(2),i(4),n.pad.Iso10126={pad:function(e,t){t*=4,t-=e.sigBytes%t;e.concat(n.lib.WordArray.random(t-1)).concat(n.lib.WordArray.create([t<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.pad.Iso10126)},function(e,t,i){var n;e.exports=(n=i(2),i(4),n.pad.Iso97971={pad:function(e,t){e.concat(n.lib.WordArray.create([2147483648],1)),n.pad.ZeroPadding.pad(e,t)},unpad:function(e){n.pad.ZeroPadding.unpad(e),e.sigBytes--}},n.pad.Iso97971)},function(e,t,i){e.exports=(e=i(2),i(4),e.pad.ZeroPadding={pad:function(e,t){t*=4;e.clamp(),e.sigBytes+=t-(e.sigBytes%t||t)},unpad:function(e){for(var t=e.words,i=e.sigBytes-1,i=e.sigBytes-1;0<=i;i--)if(t[i>>>2]>>>24-i%4*8&255){e.sigBytes=i+1;break}}},e.pad.ZeroPadding)},function(e,t,i){e.exports=(e=i(2),i(4),e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding)},function(e,t,i){var n;e.exports=(n=i(2),i(4),function(){var t=n.lib.CipherParams,i=n.enc.Hex;n.format.Hex={stringify:function(e){return e.ciphertext.toString(i)},parse:function(e){e=i.parse(e);return t.create({ciphertext:e})}}}(),n.format.Hex)},function(e,t,i){var n;e.exports=(n=i(2),i(9),i(10),i(7),i(4),function(){var e=n,t=e.lib.BlockCipher,i=e.algo,h=[],l=[],u=[],p=[],d=[],f=[],g=[],m=[],v=[],y=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var i=0,n=0,t=0;t<256;t++){var r=n^n<<1^n<<2^n<<3^n<<4;h[i]=r=r>>>8^255&r^99;var s=e[l[r]=i],o=e[s],a=e[o],c=257*e[r]^16843008*r;u[i]=c<<24|c>>>8,p[i]=c<<16|c>>>16,d[i]=c<<8|c>>>24,f[i]=c,g[r]=(c=16843009*a^65537*o^257*s^16843008*i)<<24|c>>>8,m[r]=c<<16|c>>>16,v[r]=c<<8|c>>>24,y[r]=c,i?(i=s^e[e[e[a^s]]],n^=e[e[n]]):i=n=1}}();var b=[0,1,2,4,8,16,32,64,128,27,54],i=i.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,n=4*(1+(this._nRounds=6+i)),r=this._keySchedule=[],s=0;s<n;s++)s<i?r[s]=t[s]:(c=r[s-1],s%i?6<i&&s%i==4&&(c=h[c>>>24]<<24|h[c>>>16&255]<<16|h[c>>>8&255]<<8|h[255&c]):(c=h[(c=c<<8|c>>>24)>>>24]<<24|h[c>>>16&255]<<16|h[c>>>8&255]<<8|h[255&c],c^=b[s/i|0]<<24),r[s]=r[s-i]^c);for(var o=this._invKeySchedule=[],a=0;a<n;a++){var c,s=n-a;c=a%4?r[s]:r[s-4],o[a]=a<4||s<=4?c:g[h[c>>>24]]^m[h[c>>>16&255]]^v[h[c>>>8&255]]^y[h[255&c]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,u,p,d,f,h)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,g,m,v,y,l);i=e[t+1];e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,n,r,s,o,a){for(var c=this._nRounds,h=e[t]^i[0],l=e[t+1]^i[1],u=e[t+2]^i[2],p=e[t+3]^i[3],d=4,f=1;f<c;f++)var g=n[h>>>24]^r[l>>>16&255]^s[u>>>8&255]^o[255&p]^i[d++],m=n[l>>>24]^r[u>>>16&255]^s[p>>>8&255]^o[255&h]^i[d++],v=n[u>>>24]^r[p>>>16&255]^s[h>>>8&255]^o[255&l]^i[d++],y=n[p>>>24]^r[h>>>16&255]^s[l>>>8&255]^o[255&u]^i[d++],h=g,l=m,u=v,p=y;g=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&p])^i[d++],m=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^i[d++],v=(a[u>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^i[d++],y=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^i[d++];e[t]=g,e[t+1]=m,e[t+2]=v,e[t+3]=y},keySize:8});e.AES=t._createHelper(i)}(),n.AES)},function(e,t,i){var s;e.exports=(s=i(2),i(9),i(10),i(7),i(4),function(){var e=s,t=e.lib,n=t.WordArray,i=t.BlockCipher,t=e.algo,h=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],l=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],p=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],d=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],r=t.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var n=h[i]-1;t[i]=e[n>>>5]>>>31-n%32&1}for(var r=this._subKeys=[],s=0;s<16;s++){for(var o=r[s]=[],a=u[s],i=0;i<24;i++)o[i/6|0]|=t[(l[i]-1+a)%28]<<31-i%6,o[4+(i/6|0)]|=t[28+(l[i+24]-1+a)%28]<<31-i%6;o[0]=o[0]<<1|o[0]>>>31;for(i=1;i<7;i++)o[i]=o[i]>>>4*(i-1)+3;o[7]=o[7]<<5|o[7]>>>27}for(var c=this._invSubKeys=[],i=0;i<16;i++)c[i]=r[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],f.call(this,4,252645135),f.call(this,16,65535),g.call(this,2,858993459),g.call(this,8,16711935),f.call(this,1,1431655765);for(var n=0;n<16;n++){for(var r=i[n],s=this._lBlock,o=this._rBlock,a=0,c=0;c<8;c++)a|=p[c][((o^r[c])&d[c])>>>0];this._lBlock=o,this._rBlock=s^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,f.call(this,1,1431655765),g.call(this,8,16711935),g.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function f(e,t){t=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=t,this._lBlock^=t<<e}function g(e,t){t=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=t,this._rBlock^=t<<e}e.DES=i._createHelper(r);t=t.TripleDES=i.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),i=e.length<4?e.slice(0,2):e.slice(2,4),e=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=r.createEncryptor(n.create(t)),this._des2=r.createEncryptor(n.create(i)),this._des3=r.createEncryptor(n.create(e))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=i._createHelper(t)}(),s.TripleDES)},function(e,t,i){var s;e.exports=(s=i(2),i(9),i(10),i(7),i(4),function(){var e=s,t=e.lib.StreamCipher,i=e.algo,n=i.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,n=this._S=[],r=0;r<256;r++)n[r]=r;for(var r=0,s=0;r<256;r++){var o=r%i,o=t[o>>>2]>>>24-o%4*8&255,s=(s+n[r]+o)%256,o=n[r];n[r]=n[s],n[s]=o}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=r.call(this)},keySize:8,ivSize:0});function r(){for(var e=this._S,t=this._i,i=this._j,n=0,r=0;r<4;r++){var i=(i+e[t=(t+1)%256])%256,s=e[t];e[t]=e[i],e[i]=s,n|=e[(e[t]+e[i])%256]<<24-8*r}return this._i=t,this._j=i,n}e.RC4=t._createHelper(n);i=i.RC4Drop=n.extend({cfg:n.cfg.extend({drop:192}),_doReset:function(){n._doReset.call(this);for(var e=this.cfg.drop;0<e;e--)r.call(this)}});e.RC4Drop=t._createHelper(i)}(),s.RC4)},function(e,t,i){var n;e.exports=(n=i(2),i(9),i(10),i(7),i(4),function(){var e=n,t=e.lib.StreamCipher,i=e.algo,r=[],o=[],a=[],i=i.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);for(var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]],i=this._b=0;i<4;i++)c.call(this);for(i=0;i<8;i++)r[i]^=n[i+4&7];if(t){var s=t.words,o=s[0],a=s[1],t=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),o=t>>>16|4294901760&s,a=s<<16|65535&t;r[0]^=t,r[1]^=o,r[2]^=s,r[3]^=a,r[4]^=t,r[5]^=o,r[6]^=s,r[7]^=a;for(i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),r[0]=i[0]^i[5]>>>16^i[3]<<16,r[1]=i[2]^i[7]>>>16^i[5]<<16,r[2]=i[4]^i[1]>>>16^i[7]<<16,r[3]=i[6]^i[3]>>>16^i[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),e[t+n]^=r[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)o[i]=t[i];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0;for(i=0;i<8;i++){var n=e[i]+t[i],r=65535&n,s=n>>>16;a[i]=((r*r>>>17)+r*s>>>15)+s*s^((4294901760&n)*n|0)+((65535&n)*n|0)}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.Rabbit=t._createHelper(i)}(),n.Rabbit)},function(e,t,i){var n;e.exports=(n=i(2),i(9),i(10),i(7),i(4),function(){var e=n,t=e.lib.StreamCipher,i=e.algo,r=[],o=[],a=[],i=i.RabbitLegacy=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]],r=this._b=0;r<4;r++)c.call(this);for(r=0;r<8;r++)n[r]^=i[r+4&7];if(t){var s=t.words,o=s[0],e=s[1],t=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),o=t>>>16|4294901760&s,e=s<<16|65535&t;n[0]^=t,n[1]^=o,n[2]^=s,n[3]^=e,n[4]^=t,n[5]^=o,n[6]^=s,n[7]^=e;for(r=0;r<4;r++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),r[0]=i[0]^i[5]>>>16^i[3]<<16,r[1]=i[2]^i[7]>>>16^i[5]<<16,r[2]=i[4]^i[1]>>>16^i[7]<<16,r[3]=i[6]^i[3]>>>16^i[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),e[t+n]^=r[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)o[i]=t[i];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0;for(i=0;i<8;i++){var n=e[i]+t[i],r=65535&n,s=n>>>16;a[i]=((r*r>>>17)+r*s>>>15)+s*s^((4294901760&n)*n|0)+((65535&n)*n|0)}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.RabbitLegacy=t._createHelper(i)}(),n.RabbitLegacy)},function(e,t,i){"use strict";i.r(t),i.d(t,"default",function(){return Oe});var r;i(32),i(33),i(34),i(35),i(36);class n{constructor(e){this.app=e}runRender(){}onPointer(e){switch(e.type){case BABYLON.PointerEventTypes.POINTERMOVE:if(!this.app.ToolTips)return;e.pickInfo&&e.pickInfo.pickedPoint?this.app.ToolTips.update(e):this.app.ToolTips.close();break;case BABYLON.PointerEventTypes.POINTERWHEEL:this.app.CameraController._wheel(e.event),e.event.preventDefault()}}onKeyboard(e){e.type===BABYLON.KeyboardEventTypes.KEYDOWN&&70===e.event.keyCode&&prompt("请复制输入框内的视角参数",this.app.CameraController.getSightJson())}}class s{constructor(e){this.isFPS=!1,this.angle=Math.PI/2,this.direction=new BABYLON.Vector3(Math.cos(this.angle),0,Math.sin(this.angle)),this.isMoveLeft=!1,this.isMoveRight=!1,this.isMoveDown=!1,this.isMoveUp=!1,this.app=e,this.isFPS=!1}runRender(){var e;this.app.scene.activeCamera instanceof BABYLON.FreeCamera&&(this.isMoveDown||this.isMoveLeft||this.isMoveRight||this.isMoveUp)&&(e=this.app.CameraController.freeCamera.speed,this.isMoveLeft?(this.app.CameraController.freeCamera.rotation.y+=e,this.direction.copyFromFloats(0,0,0)):this.isMoveUp?this.direction.copyFromFloats(0,0,e):this.isMoveRight?(this.app.CameraController.freeCamera.rotation.y-=e,this.direction.copyFromFloats(0,0,0)):this.isMoveDown&&this.direction.copyFromFloats(0,0,-e),this.app.CameraController.freeCamera.getScene().useRightHandedSystem&&(this.direction.z*=-1),this.app.CameraController.freeCamera.getViewMatrix().invertToRef(this.app.CameraController.freeCamera._cameraTransformMatrix),BABYLON.Vector3.TransformNormalToRef(this.direction,this.app.CameraController.freeCamera._cameraTransformMatrix,this.app.CameraController.freeCamera._transformedDirection),this.app.CameraController.freeCamera.cameraDirection.addInPlace(this.app.CameraController.freeCamera._transformedDirection))}onPointer(e){switch(e.type){case BABYLON.PointerEventTypes.POINTERUP:if(this.isFPS)return;this.app.CameraController.freeCamera.position=BABYLON.Vector3.Zero(),this.app.CameraController.freeCamera.position.y=this.app.Project.current.height+1.5,this.app.scene.activeCamera=this.app.CameraController.freeCamera,this.app.CameraController.freeCamera.attachControl(this.app.canvas,!0),this.isFPS=!0;break;case BABYLON.PointerEventTypes.POINTERMOVE:break;case BABYLON.PointerEventTypes.POINTERWHEEL:e.event.preventDefault()}}onKeyboard(e){}}class p{static vector3ToJson(e){return{x:Math.floor(1e3*e.x)/1e3,y:Math.floor(1e3*e.y)/1e3,z:Math.floor(1e3*e.z)/1e3}}static vector3ARRToJson(e){let t=[];return e.forEach(e=>t.push({x:Math.floor(1e3*e.x)/1e3,y:Math.floor(1e3*e.y)/1e3,z:Math.floor(1e3*e.z)/1e3})),t}static ToVector3(e){return new BABYLON.Vector3(Math.floor(1e3*e.x)/1e3,Math.floor(1e3*e.y)/1e3,Math.floor(1e3*e.z)/1e3)}static ToARRVector3(e){let t=[];return e.forEach(e=>t.push(new BABYLON.Vector3(Math.floor(1e3*e.x)/1e3,Math.floor(1e3*e.y)/1e3,Math.floor(1e3*e.z)/1e3))),t}static computeBounds(e){let t=e.getChildMeshes(),i=e.getBoundingInfo();if(0<t.length){for(var n=t[0].getBoundingInfo(),r=n.minimum.add(t[0].position),s=n.maximum.add(t[0].position),o=1;o<t.length;o++)n=t[o].getBoundingInfo(),r=BABYLON.Vector3.Minimize(r,n.minimum.add(t[o].position)),s=BABYLON.Vector3.Maximize(s,n.maximum.add(t[o].position));i=new BABYLON.BoundingInfo(r,s)}return i}static computeBoundsToARR(e){for(var t=e[0].getBoundingInfo(),i=t.minimum.add(e[0].position),n=t.maximum.add(e[0].position),r=1;r<e.length;r++)t=e[r].getBoundingInfo(),i=BABYLON.Vector3.Minimize(i,t.minimum.add(e[r].position)),n=BABYLON.Vector3.Maximize(n,t.maximum.add(e[r].position));return new BABYLON.BoundingInfo(i,n)}static Expand(n,r){let s=new Array;var o=n.length;for(let i=0;i<o;i++){var a=n[i],c=n[0==i?o-1:i-1],h=n[i==o-1?0:i+1],l=c.x-a.x,u=c.z-a.z,p=this.norm(l,u);l/=p,u/=p;c=h.x-a.x,p=h.z-a.z,h=this.norm(c,p);c/=h,p/=h;h=-r/Math.sqrt((1-(l*c+u*p))/2);let e=l+c,t=u+p;h=0==this.norm(e,t)?0:h/this.norm(e,t);e*=h,t*=h,s[i]=new BABYLON.Vector3(e+a.x,0,t+a.z)}return s}static norm(e,t){return Math.sqrt(e*e+t*t)}static MergeMeshes(s,e){let o=new BABYLON.Mesh((new Date).getDate().toString(),e.scene);return setTimeout(()=>{let t=null,i;for(let e=0;e<s.length;e++){var n,r;s[e]&&(r=(n=s[e]).computeWorldMatrix(!0),i=BABYLON.VertexData.ExtractFromMesh(n,!0,!0),i.transform(r),t?t.merge(i,!0):t=i,n.dispose(!1,!0))}t.applyToMesh(o)}),o}static DeconsTructMesh(e,t,i){if(1<e.subMeshes.length){for(var n=BABYLON.VertexData.ExtractFromMesh(e,!0,!0),r=n.indices,s=n.normals,o=n.positions,a=n.uvs,c=new Array,h=0;h<e.subMeshes.length;h++){for(var l=new BABYLON.VertexData,u=r.slice(e.subMeshes[h].indexStart,e.subMeshes[h].indexStart+e.subMeshes[h].indexCount),p=s.slice(3*e.subMeshes[h].verticesStart,3*e.subMeshes[h].verticesStart+3*e.subMeshes[h].verticesCount),d=o.slice(3*e.subMeshes[h].verticesStart,3*e.subMeshes[h].verticesStart+3*e.subMeshes[h].verticesCount),f=a.slice(2*e.subMeshes[h].verticesStart,2*e.subMeshes[h].verticesStart+2*e.subMeshes[h].verticesCount),g=0;g<u.length;g++)u[g]=u[g]-e.subMeshes[h].verticesStart;l.indices=u,l.normals=p,l.positions=d,l.uvs=f;f=new BABYLON.Mesh(e.id+"-"+h,i.scene);l.applyToMesh(f),f.position.y=parseFloat(t),f.setEnabled(!1),c.push(f)}return e.dispose(!1,!0),c}return[e]}static getVisualAngle(e,t){let i={};var n=e.boundingSphere.radiusWorld,r=t.engine.getAspectRatio(t.CameraController.arcRotateCamera);let s=t.CameraController.arcRotateCamera.fov/1.2;return r<1&&(s=Math.atan(r*Math.tan(t.CameraController.arcRotateCamera.fov/2))),i.radius=1.1*Math.abs(n/Math.sin(s)),i.alpha=Math.PI/2,i.beta=Math.PI/4,i.focus=e.boundingSphere.center.clone(),i}static pathTransformation(i,n){let e=new BABYLON.Path3D(i);var r=e.getTangents();let s=[];for(let t=0;t<i.length;t++)if(0<t&&t<i.length-1){var o=i[t-1],a=i[t+1],c=i[t];let e=r[t-1];var h=r[t];if(!e.equals(h)){o=BABYLON.Vector3.Lerp(c,o,n/BABYLON.Vector3.Distance(o,c)),a=BABYLON.Vector3.Lerp(c,a,n/BABYLON.Vector3.Distance(a,c));let e=BABYLON.Curve3.CreateQuadraticBezier(o,c,a,10);s=s.concat(e.getPoints())}}else s.push(i[t]);return s}static createTube(e,t,i=.05,n){return BABYLON.MeshBuilder.CreateTube(e,{path:this.pathTransformation(t,i),radius:i/2},n.scene)}static getAngleFromVector2(e,t,i){var n=(e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y),t=(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x),n=Math.atan2(t,n);return Math.PI-n}static getAngleFromVector3(e,t,i){return this.getAngleFromVector2(new BABYLON.Vector2(e.x,e.z),new BABYLON.Vector2(t.x,t.z),new BABYLON.Vector2(i.x,i.z))}static RandomNumBoth(e,t){var i=t-e,t=Math.random();return e+Math.round(t*i)}}class o{constructor(e){this.app=e,this.arcRotateCamera=new BABYLON.ArcRotateCamera("arcRotateCamera",-Math.PI/4,Math.PI/4,50,new BABYLON.Vector3(0,0,0),this.app.scene),this.arcRotateCamera.pinchPrecision=200,this.arcRotateCamera.minZ=.3,this.arcRotateCamera.wheelDeltaPercentage=.01,this.frustrum=5,this.freeCamera=new BABYLON.FreeCamera("FreeCamera",BABYLON.Vector3.Zero(),this.app.scene),this.freeCamera.minZ=.45,this.freeCamera.speed=.01,this.freeCamera.keysUp=[87],this.freeCamera.keysDown=[83],this.freeCamera.keysLeft=[65],this.freeCamera.keysRight=[68],this.switchArcRotateCamera()}orthographic(){this.arcRotateCamera.lowerBetaLimit=0,this.arcRotateCamera.upperBetaLimit=0,this.arcRotateCamera.lowerAlphaLimit=Math.PI/2,this.arcRotateCamera.upperAlphaLimit=Math.PI/2,this.arcRotateCamera.mode=BABYLON.Camera.ORTHOGRAPHIC_CAMERA;var e=this.app.Project.current.Sight;this.arcRotateCamera.lowerRadiusLimit=2*e.radius,this.arcRotateCamera.radius=e.radius,this.arcRotateCamera.target=e.focus.clone(),this.frustrum=.5*e.radius,this.computeCameraView()}perspective(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e=e||this.app.Project.current.Sight,this.arcRotateCamera.lowerRadiusLimit=e.minimumLimit||1,this.arcRotateCamera.upperRadiusLimit=e.maximumLimit||3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.minBeta||.01,this.arcRotateCamera.upperBetaLimit=e.maxBeta||Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=BABYLON.Camera.PERSPECTIVE_CAMERA,this.arcRotateCamera.target=e.focus.clone(),(this.arcRotateCamera.alpha>2*Math.PI||this.arcRotateCamera.alpha<-2*Math.PI)&&(this.arcRotateCamera.alpha=this.arcRotateCamera.alpha-Math.floor(this.arcRotateCamera.alpha/(2*Math.PI))*(2*Math.PI));var t=new BABYLON.Animation("camAlpha","alpha",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);t.setKeys([{frame:0,value:this.arcRotateCamera.alpha},{frame:30,value:e.alpha}]);var i=new BABYLON.Animation("camRadius","radius",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30,value:e.radius}]);var n=new BABYLON.Animation("camBeta","beta",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);n.setKeys([{frame:0,value:this.arcRotateCamera.beta},{frame:30,value:e.beta}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[t,i,n],0,60,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}flyTo(e,t=.5){e=e||this.app.Project.current.Sight,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.arcRotateCamera.lowerRadiusLimit=e.minimumLimit||1,this.arcRotateCamera.upperRadiusLimit=e.maximumLimit||3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.minBeta||.01,this.arcRotateCamera.upperBetaLimit=e.maxBeta||Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=BABYLON.Camera.PERSPECTIVE_CAMERA;var i=new BABYLON.Animation("camtarget","target",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:30*t,value:e.focus.clone()}]);var n=new BABYLON.Animation("camradius","radius",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);n.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30*t,value:e.radius}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[i,n],0,30*t,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}lookToTheFront(e,t=.5){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.arcRotateCamera.lowerRadiusLimit=e.Sight.minimumLimit||1,this.arcRotateCamera.upperRadiusLimit=e.Sight.maximumLimit||3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.Sight.minBeta||.01,this.arcRotateCamera.upperBetaLimit=e.Sight.maxBeta||Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=BABYLON.Camera.PERSPECTIVE_CAMERA;var i=Math.atan2(-e.instance.forward.z,-e.instance.forward.x);(this.arcRotateCamera.alpha>2*Math.PI||this.arcRotateCamera.alpha<-2*Math.PI)&&(this.arcRotateCamera.alpha=this.arcRotateCamera.alpha-Math.floor(this.arcRotateCamera.alpha/(2*Math.PI))*(2*Math.PI));var n=new BABYLON.Animation("camtarget","target",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);n.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:30*t,value:e.Sight.focus.clone()}]);var r=new BABYLON.Animation("camAlpha","alpha",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);r.setKeys([{frame:0,value:this.arcRotateCamera.alpha},{frame:30*t,value:i}]);i=new BABYLON.Animation("camRadius","radius",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30*t,value:e.Sight.radius/1.2}]);e=new BABYLON.Animation("camBeta","beta",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);e.setKeys([{frame:0,value:this.arcRotateCamera.beta},{frame:30*t,value:Math.PI/2}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[n,r,i,e],0,30*t,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}getSightJson(){return JSON.stringify({alpha:this.arcRotateCamera.alpha,focus:p.vector3ToJson(this.arcRotateCamera.target),radius:this.arcRotateCamera.radius,beta:this.arcRotateCamera.beta,minimumLimit:this.arcRotateCamera.lowerRadiusLimit,maximumLimit:this.arcRotateCamera.upperRadiusLimit,minBeta:this.arcRotateCamera.lowerBetaLimit,maxBeta:this.arcRotateCamera.upperBetaLimit})}computeCameraView(){var e=this.app.canvas.clientWidth/this.app.canvas.clientHeight;this.arcRotateCamera.orthoLeft=-e*this.frustrum,this.arcRotateCamera.orthoRight=e*this.frustrum,this.arcRotateCamera.orthoTop=this.frustrum,this.arcRotateCamera.orthoBottom=-this.frustrum;e=1e3/(this.frustrum/20);this.arcRotateCamera.panningSensibility=2e3<e?2e3:e<10?10:e}_wheel(e){var t;this.arcRotateCamera.mode!=BABYLON.Camera.PERSPECTIVE_CAMERA?(t=(e.wheelDelta||24*-e.detail)<0?1.1:.9,this.frustrum*=t,this.computeCameraView()):(t=1e3/(this.app.CameraController.arcRotateCamera.radius/20),this.app.CameraController.arcRotateCamera.panningSensibility=2e3<t?2e3:t<10?10:t)}switchArcRotateCamera(){this.app.scene.activeCamera=this.arcRotateCamera,this.arcRotateCamera.attachControl(this.app.canvas,!0,!0),this.app.IEvent=new n(this.app)}switchFPSCamera(){this.app.IEvent=new s(this.app)}}class d{constructor(){this.map={}}add(e,t){this.map[e]=t}find(e){return this.map[e]}remove(e){delete this.map[e]}termRemove(e){for(var t in this.map)e(this.map[t])&&delete this.map[t]}showAll(){for(var e in this.map)this.map[e]}count(){var e,t=0;for(e in Object.keys(this.map))++t;return t}clear(){for(var e in this.map)delete this.map[e]}}class a{static getGUID(e){var t,i,n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=[],s=n.length;if(e)for(t=0;t<e;t++)r[t]=n[0|Math.random()*s];else for(r[8]=r[13]=r[18]=r[23]="-",r[14]="4",t=0;t<36;t++)r[t]||(i=0|16*Math.random(),r[t]=n[19==t?3&i|8:i]);return r.join("")}}class c{constructor(e){this.objectType="Light",this.app=e}load(){}}class h extends c{load(){this.light=new BABYLON.DirectionalLight(this.id,this.direction,this.app.scene),this.light.position=this.position,this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}class l extends c{load(){this.light=new BABYLON.HemisphericLight(this.id,this.direction,this.app.scene),this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}(t=r=r||{}).Point="Point",t.Spot="Spot",t.Directional="Directional",t.Hemispheric="Hemispheric";var f;class u extends c{load(){this.light=new BABYLON.PointLight(this.id,this.position.clone(),this.app.scene),this.light.range=this.range,this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}class g extends c{load(){this.light=new BABYLON.SpotLight(this.id,this.position.clone(),this.direction.clone(),this.angle*Math.PI/180,this.exponent,this.app.scene),this.light.range=this.range,this.light.position=this.position,this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}class m{constructor(e){this.isOK=!1,this.app=e,this.ele=document.createElement("div"),this.ele.style.cssText="position: absolute;z-index:999999999; font-size: 10px;color: rgb(211, 211, 211);text-shadow:rgba(0, 0, 0, 0.2) 1px 1px 0; padding: 5px 8px;",this.app.canvas.parentElement.appendChild(this.ele),this.close(),setInterval(()=>{var e;1e3<(new Date).getTime()-this.time&&this.isOK&&!this.text&&((e=this.app.Project.objectDatas.find(this.id))&&(this.text=e.name))},100)}set text(e){this._text=e,(this.ele.innerText=e)&&(this.ele.style.display=null)}update(e){e.pickInfo.pickedMesh?e.pickInfo.pickedMesh.id!=this.id?(this.close(),this.id=e.pickInfo.pickedMesh.id,this.time=(new Date).getTime()):this.isOK=!0:this.close(),this.ele.style.top=e.event.offsetY+"px",this.ele.style.left=e.event.offsetX+20+"px"}close(){this.isOK=!1,this.time=(new Date).getTime(),this.ele.style.display="none",this.text=""}setBackground(e){this.url=e,this.ele.style.background="url("+this.url+") no-repeat",this.ele.style.backgroundSize="cover"}dispose(){clearInterval(this.interval),this.app.canvas.parentElement.removeChild(this.ele),this.ele=null}}class v{constructor(e){this.lights=new d,this.reflexEnabled=!0,this.reflexIntensity=.5,this.app=e,this.color=new BABYLON.Color4(0,.0588,.1176,1),this.reflex(Oe.rl+"resources/environment.env",.5),this.app.scene.fogEnabled=!0,this.app.scene.fogMode=2,this.fogDistance=500,BABYLON.Effect.IncludesShadersStore.fogVertex=`
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("TWEEN"),require("h337"),require("BABYLON"),require("babylonjs-materials"),require("BABYLON.GUI"),require("BABYLON.SceneLoader"),require("babylonjs-serializers")):"function"==typeof define&&define.amd?define(["TWEEN","h337","BABYLON","babylonjs-materials","BABYLON.GUI","BABYLON.SceneLoader","babylonjs-serializers"],t):"object"==typeof exports?exports.MX3D=t(require("TWEEN"),require("h337"),require("BABYLON"),require("babylonjs-materials"),require("BABYLON.GUI"),require("BABYLON.SceneLoader"),require("babylonjs-serializers")):e.MX3D=t(e.TWEEN,e.h337,e.BABYLON,e["babylonjs-materials"],e["BABYLON.GUI"],e["BABYLON.SceneLoader"],e["babylonjs-serializers"])}(window,function(i,r,n,o,s,a,l){return h=[function(e,t,i){"use strict";var r;i.d(t,"a",function(){return r}),(t=r=r||{})[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"},function(e,_,g){"use strict";!function(t,e){g.d(_,"a",function(){return n}),g.d(_,"c",function(){return o}),g.d(_,"f",function(){return h}),g.d(_,"j",function(){return u}),g.d(_,"k",function(){return s}),g.d(_,"e",function(){return a}),g.d(_,"d",function(){return l}),g.d(_,"b",function(){return p}),g.d(_,"i",function(){return d}),g.d(_,"g",function(){return f}),g.d(_,"h",function(){return m});var c=g(0),i=g(11);const r="6.0.7";class n{static isRequired(e,t){if(null==e)throw new Error(`The '${t}' argument is required.`)}static isNotEmpty(e,t){if(!e||e.match(/^\s*$/))throw new Error(`The '${t}' argument should not be empty.`)}static isIn(e,t,i){if(!(e in t))throw new Error(`Unknown ${i} value: ${e}.`)}}class o{static get isBrowser(){return"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return"object"==typeof self&&"importScripts"in self}static get isReactNative(){return"object"==typeof window&&void 0===window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function h(e,t){let i="";return u(e)?(i=`Binary data of length ${e.byteLength}`,t&&(i+=`. Content: '${function(e){const t=new Uint8Array(e);let i="";return t.forEach(e=>{var t=e<16?"0":"";i+=`0x${t}${e.toString(16)} `}),i.substr(0,i.length-1)}(e)}'`)):"string"==typeof e&&(i=`String data of length ${e.length}`,t&&(i+=`. Content: '${e}'`)),i}function u(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}async function s(e,t,i,r,n,o,s){let a={};!n||(l=await n())&&(a={Authorization:`Bearer ${l}`});var[n,l]=d();a[n]=l,e.log(c.a.Trace,`(${t} transport) sending data. ${h(o,s.logMessageContent)}.`);l=u(o)?"arraybuffer":"text",s=await i.post(r,{content:o,headers:{...a,...s.headers},responseType:l,timeout:s.timeout,withCredentials:s.withCredentials});e.log(c.a.Trace,`(${t} transport) request complete. Response status: ${s.statusCode}.`)}function a(e){return void 0===e?new p(c.a.Information):null===e?i.a.instance:void 0!==e.log?e:new p(e)}class l{constructor(e,t){this._subject=e,this._observer=t}dispose(){var e=this._subject.observers.indexOf(this._observer);-1<e&&this._subject.observers.splice(e,1),0===this._subject.observers.length&&this._subject.cancelCallback&&this._subject.cancelCallback().catch(e=>{})}}class p{constructor(e){this._minLevel=e,this.out=console}log(e,t){if(e>=this._minLevel){var i=`[${(new Date).toISOString()}] ${c.a[e]}: ${t}`;switch(e){case c.a.Critical:case c.a.Error:this.out.error(i);break;case c.a.Warning:this.out.warn(i);break;case c.a.Information:this.out.info(i);break;default:this.out.log(i)}}}}function d(){let e="X-SignalR-User-Agent";return o.isNode&&(e="User-Agent"),[e,function(e,t,i,r){let n="Microsoft SignalR/";var o=e.split(".");n+=`${o[0]}.${o[1]}`,n+=` (${e}; `,n+=t&&""!==t?`${t}; `:"Unknown OS; ";n+=`${i}`,n+=r?`; ${r}`:"; Unknown Runtime Version";return n+=")",n}(r,function(){{if(!o.isNode)return"";switch(t.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return t.platform}}}(),o.isNode?"NodeJS":"Browser",function(){if(o.isNode)return t.versions.node;return}())]}function f(e){return e.stack||e.message||`${e}`}function m(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("could not find global")}}.call(this,g(17),g(18))},function(t,e,m){!function(f){var e;t.exports=(e=function(c){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),!(r=!(r=!(r="undefined"!=typeof globalThis&&globalThis.crypto?globalThis.crypto:r)&&"undefined"!=typeof window&&window.msCrypto?window.msCrypto:r)&&void 0!==f&&f.crypto?f.crypto:r))try{r=m(60)}catch(e){}var i=Object.create||function(e){return t.prototype=e,e=new t,t.prototype=null,e};function t(){}var e={},n=e.lib={},o=n.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},h=n.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,i=e.words,r=this.sigBytes,n=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<n;o++){var s=i[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(var a=0;a<n;a+=4)t[r+a>>>2]=i[a>>>2];return this.sigBytes+=n,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=c.ceil(t/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],i=0;i<e;i+=4)t.push(function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")}());return new h.init(t,e)}}),s=e.enc={},a=s.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r+=2)i[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new h.init(i,t/2)}},l=s.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new h.init(i,t)}},u=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},p=n.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t,i=this._data,r=i.words,n=i.sigBytes,o=this.blockSize,s=n/(4*o),a=(s=e?c.ceil(s):c.max((0|s)-this._minBufferSize,0))*o,n=c.min(4*a,n);if(a){for(var l=0;l<a;l+=o)this._doProcessBlock(r,l);t=r.splice(0,a),i.sigBytes-=n}return new h.init(t,n)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(n.Hasher=p.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(i){return function(e,t){return new i.init(t).finalize(e)}},_createHmacHelper:function(i){return function(e,t){return new d.HMAC.init(i,t).finalize(e)}}}),e.algo={});return e}(Math),e)}.call(this,m(18))},function(e,t,i){"use strict";var r,n=i(21),o=Object.prototype.toString,s=(r=Object.create(null),function(e){e=o.call(e);return r[e]||(r[e]=e.slice(8,-1).toLowerCase())});function a(t){return t=t.toLowerCase(),function(e){return s(e)===t}}function l(e){return Array.isArray(e)}function c(e){return void 0===e}var h=a("ArrayBuffer");function u(e){return null!==e&&"object"==typeof e}function p(e){if("object"!==s(e))return!1;e=Object.getPrototypeOf(e);return null===e||e===Object.prototype}var d=a("Date"),f=a("File"),m=a("Blob"),_=a("FileList");function g(e){return"[object Function]"===o.call(e)}var y=a("URLSearchParams");function x(e,t){if(null!=e)if(l(e="object"!=typeof e?[e]:e))for(var i=0,r=e.length;i<r;i++)t.call(null,e[i],i,e);else for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.call(null,e[n],n,e)}var v,i=(v="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return v&&e instanceof v});e.exports={isArray:l,isArrayBuffer:h,isBuffer:function(e){return null!==e&&!c(e)&&null!==e.constructor&&!c(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||o.call(e)===t||g(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:u,isPlainObject:p,isUndefined:c,isDate:d,isFile:f,isBlob:m,isFunction:g,isStream:function(e){return u(e)&&g(e.pipe)},isURLSearchParams:y,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:x,merge:function i(){var r={};function e(e,t){p(r[t])&&p(e)?r[t]=i(r[t],e):p(e)?r[t]=i({},e):l(e)?r[t]=e.slice():r[t]=e}for(var t=0,n=arguments.length;t<n;t++)x(arguments[t],e);return r},extend:function(i,e,r){return x(e,function(e,t){i[t]=r&&"function"==typeof e?n(e,r):e}),i},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return e=65279===e.charCodeAt(0)?e.slice(1):e},inherits:function(e,t,i,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,i&&Object.assign(e.prototype,i)},toFlatObject:function(e,t,i){var r,n,o,s={};t=t||{};do{for(n=(r=Object.getOwnPropertyNames(e)).length;0<n--;)s[o=r[n]]||(t[o]=e[o],s[o]=!0)}while((e=Object.getPrototypeOf(e))&&(!i||i(e,t))&&e!==Object.prototype);return t},kindOf:s,kindOfTest:a,endsWith:function(e,t,i){return e=String(e),(void 0===i||i>e.length)&&(i=e.length),i-=t.length,-1!==(t=e.indexOf(t,i))&&t===i},toArray:function(e){if(!e)return null;var t=e.length;if(c(t))return null;for(var i=new Array(t);0<t--;)i[t]=e[t];return i},isTypedArray:i,isFileList:_}},function(e,t,i){var m;e.exports=(m=i(2),i(7),void(m.lib.Cipher||function(){var e=m,t=e.lib,i=t.Base,s=t.WordArray,r=t.BufferedBlockAlgorithm,n=e.enc,o=(n.Utf8,n.Base64),a=e.algo.EvpKDF,l=t.Cipher=r.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){r.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(r){return{encrypt:function(e,t,i){return c(t).encrypt(r,e,t,i)},decrypt:function(e,t,i){return c(t).decrypt(r,e,t,i)}}}});function c(e){return"string"==typeof e?f:d}t.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=e.mode={},n=t.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),n=h.CBC=((h=n.extend()).Encryptor=h.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize;u.call(this,e,t,r),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+r)}}),h.Decryptor=h.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=e.slice(t,t+r);i.decryptBlock(e,t),u.call(this,e,t,r),this._prevBlock=n}}),h);function u(e,t,i){var r,n=this._iv;n?(r=n,this._iv=void 0):r=this._prevBlock;for(var o=0;o<i;o++)e[t+o]^=r[o]}var h=(e.pad={}).Pkcs7={pad:function(e,t){for(var t=4*t,i=t-e.sigBytes%t,r=i<<24|i<<16|i<<8|i,n=[],o=0;o<i;o+=4)n.push(r);t=s.create(n,i);e.concat(t)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},p=(t.BlockCipher=l.extend({cfg:l.cfg.extend({mode:n,padding:h}),reset:function(){var e;l.reset.call(this);var t=this.cfg,i=t.iv,t=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=t.createEncryptor:(e=t.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,i&&i.words):(this._mode=e.call(t,this,i&&i.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),t.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),h=(e.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,e=e.salt,t=e?s.create([1398893684,1701076831]).concat(e).concat(t):t;return t.toString(o)},parse:function(e){var t,i=o.parse(e),e=i.words;return 1398893684==e[0]&&1701076831==e[1]&&(t=s.create(e.slice(2,4)),e.splice(0,4),i.sigBytes-=16),p.create({ciphertext:i,salt:t})}},d=t.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(e,t,i,r){r=this.cfg.extend(r);var n=e.createEncryptor(i,r),t=n.finalize(t),n=n.cfg;return p.create({ciphertext:t,key:i,iv:n.iv,algorithm:e,mode:n.mode,padding:n.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(i,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),e=(e.kdf={}).OpenSSL={execute:function(e,t,i,r){r=r||s.random(8);e=a.create({keySize:t+i}).compute(e,r),i=s.create(e.words.slice(t),4*i);return e.sigBytes=4*t,p.create({key:e,iv:i,salt:r})}},f=t.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:e}),encrypt:function(e,t,i,r){i=(r=this.cfg.extend(r)).kdf.execute(i,e.keySize,e.ivSize);r.iv=i.iv;r=d.encrypt.call(this,e,t,i.key,r);return r.mixIn(i),r},decrypt:function(e,t,i,r){r=this.cfg.extend(r),t=this._parse(t,r.format);i=r.kdf.execute(i,e.keySize,e.ivSize,t.salt);return r.iv=i.iv,d.decrypt.call(this,e,t,i.key,r)}})}()))},function(e,t){e.exports=i},function(e,t,i){e.exports=(e=i(2),i(14),i(61),i(62),i(9),i(63),i(10),i(19),i(30),i(64),i(31),i(65),i(66),i(67),i(20),i(68),i(7),i(4),i(69),i(70),i(71),i(72),i(73),i(74),i(75),i(76),i(77),i(78),i(79),i(80),i(81),i(82),i(83),i(84),e)},function(e,t,i){var o;e.exports=(o=i(2),i(19),i(20),function(){var e=o,t=e.lib,i=t.Base,h=t.WordArray,r=e.algo,t=r.MD5,n=r.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:t,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i,r=this.cfg,n=r.hasher.create(),o=h.create(),s=o.words,a=r.keySize,l=r.iterations;s.length<a;){i&&n.update(i),i=n.update(e).finalize(t),n.reset();for(var c=1;c<l;c++)i=n.finalize(i),n.reset();o.concat(i)}return o.sigBytes=4*a,o}});e.EvpKDF=function(e,t,i){return n.create(i).compute(e,t)}}(),o.EvpKDF)},function(e,t,i){"use strict";var a=i(3);function l(e,t,i,r,n){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),r&&(this.request=r),n&&(this.response=n)}a.inherits(l,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var c=l.prototype,r={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach(function(e){r[e]={value:e}}),Object.defineProperties(l,r),Object.defineProperty(c,"isAxiosError",{value:!0}),l.from=function(e,t,i,r,n,o){var s=Object.create(c);return a.toFlatObject(e,s,function(e){return e!==Error.prototype}),l.call(s,e.message,t,i,r,n),s.name=e.name,o&&Object.assign(s,o),s},e.exports=l},function(e,t,i){var r;e.exports=(r=i(2),function(){var l=r.lib.WordArray;r.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,r=this._map;e.clamp();for(var n=[],o=0;o<i;o+=3)for(var s=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<i;a++)n.push(r.charAt(s>>>6*(3-a)&63));var l=r.charAt(64);if(l)for(;n.length%4;)n.push(l);return n.join("")},parse:function(e){var t=e.length,i=this._map;if(!(r=this._reverseMap))for(var r=this._reverseMap=[],n=0;n<i.length;n++)r[i.charCodeAt(n)]=n;var o=i.charAt(64);return!o||-1!==(o=e.indexOf(o))&&(t=o),function(e,t,i){for(var r=[],n=0,o=0;o<t;o++){var s,a;o%4&&(s=i[e.charCodeAt(o-1)]<<o%4*2,a=i[e.charCodeAt(o)]>>>6-o%4*2,a=s|a,r[n>>>2]|=a<<24-n%4*8,n++)}return l.create(r,n)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)},function(e,t,i){var n;e.exports=(n=i(2),function(l){var e=n,t=e.lib,i=t.WordArray,r=t.Hasher,t=e.algo,S=[];!function(){for(var e=0;e<64;e++)S[e]=4294967296*l.abs(l.sin(e+1))|0}();t=t.MD5=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,n=e[r];e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,s=e[t+0],a=e[t+1],l=e[t+2],c=e[t+3],h=e[t+4],u=e[t+5],p=e[t+6],d=e[t+7],f=e[t+8],m=e[t+9],_=e[t+10],g=e[t+11],y=e[t+12],x=e[t+13],v=e[t+14],b=e[t+15],w=C(w=o[0],A=o[1],E=o[2],T=o[3],s,7,S[0]),T=C(T,w,A,E,a,12,S[1]),E=C(E,T,w,A,l,17,S[2]),A=C(A,E,T,w,c,22,S[3]);w=C(w,A,E,T,h,7,S[4]),T=C(T,w,A,E,u,12,S[5]),E=C(E,T,w,A,p,17,S[6]),A=C(A,E,T,w,d,22,S[7]),w=C(w,A,E,T,f,7,S[8]),T=C(T,w,A,E,m,12,S[9]),E=C(E,T,w,A,_,17,S[10]),A=C(A,E,T,w,g,22,S[11]),w=C(w,A,E,T,y,7,S[12]),T=C(T,w,A,E,x,12,S[13]),E=C(E,T,w,A,v,17,S[14]),w=M(w,A=C(A,E,T,w,b,22,S[15]),E,T,a,5,S[16]),T=M(T,w,A,E,p,9,S[17]),E=M(E,T,w,A,g,14,S[18]),A=M(A,E,T,w,s,20,S[19]),w=M(w,A,E,T,u,5,S[20]),T=M(T,w,A,E,_,9,S[21]),E=M(E,T,w,A,b,14,S[22]),A=M(A,E,T,w,h,20,S[23]),w=M(w,A,E,T,m,5,S[24]),T=M(T,w,A,E,v,9,S[25]),E=M(E,T,w,A,c,14,S[26]),A=M(A,E,T,w,f,20,S[27]),w=M(w,A,E,T,x,5,S[28]),T=M(T,w,A,E,l,9,S[29]),E=M(E,T,w,A,d,14,S[30]),w=I(w,A=M(A,E,T,w,y,20,S[31]),E,T,u,4,S[32]),T=I(T,w,A,E,f,11,S[33]),E=I(E,T,w,A,g,16,S[34]),A=I(A,E,T,w,v,23,S[35]),w=I(w,A,E,T,a,4,S[36]),T=I(T,w,A,E,h,11,S[37]),E=I(E,T,w,A,d,16,S[38]),A=I(A,E,T,w,_,23,S[39]),w=I(w,A,E,T,x,4,S[40]),T=I(T,w,A,E,s,11,S[41]),E=I(E,T,w,A,c,16,S[42]),A=I(A,E,T,w,p,23,S[43]),w=I(w,A,E,T,m,4,S[44]),T=I(T,w,A,E,y,11,S[45]),E=I(E,T,w,A,b,16,S[46]),w=B(w,A=I(A,E,T,w,l,23,S[47]),E,T,s,6,S[48]),T=B(T,w,A,E,d,10,S[49]),E=B(E,T,w,A,v,15,S[50]),A=B(A,E,T,w,u,21,S[51]),w=B(w,A,E,T,y,6,S[52]),T=B(T,w,A,E,c,10,S[53]),E=B(E,T,w,A,_,15,S[54]),A=B(A,E,T,w,a,21,S[55]),w=B(w,A,E,T,f,6,S[56]),T=B(T,w,A,E,b,10,S[57]),E=B(E,T,w,A,p,15,S[58]),A=B(A,E,T,w,x,21,S[59]),w=B(w,A,E,T,h,6,S[60]),T=B(T,w,A,E,g,10,S[61]),E=B(E,T,w,A,l,15,S[62]),A=B(A,E,T,w,m,21,S[63]),o[0]=o[0]+w|0,o[1]=o[1]+A|0,o[2]=o[2]+E|0,o[3]=o[3]+T|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32;var n=l.floor(i/4294967296),i=i;t[15+(64+r>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t[14+(64+r>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var t=this._hash,o=t.words,s=0;s<4;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return t},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function C(e,t,i,r,n,o,s){s=e+(t&i|~t&r)+n+s;return(s<<o|s>>>32-o)+t}function M(e,t,i,r,n,o,s){s=e+(t&r|i&~r)+n+s;return(s<<o|s>>>32-o)+t}function I(e,t,i,r,n,o,s){s=e+(t^i^r)+n+s;return(s<<o|s>>>32-o)+t}function B(e,t,i,r,n,o,s){s=e+(i^(t|~r))+n+s;return(s<<o|s>>>32-o)+t}e.MD5=r._createHelper(t),e.HmacMD5=r._createHmacHelper(t)}(Math),n.MD5)},function(e,t,i){"use strict";i.d(t,"a",function(){return r});class r{constructor(){}log(e,t){}}r.instance=new r},function(e,t,i){!function(qf){e.exports=function(){"use strict";var n,o,s,e;function t(e,t){if(!n)n=t;else if(!o)o=t;else{var i="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+n+")(sharedChunk); ("+o+")(sharedChunk); self.onerror = null;";var r={};n(r);s=t(r);if(typeof window!=="undefined"&&window&&window.URL&&window.URL.createObjectURL)s.workerUrl=window.URL.createObjectURL(new Blob([i],{type:"text/javascript"}))}}return t(["exports"],function(l){"use strict";var p="undefined"!=typeof self?self:{},s=e;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=i,this.p2y=r}e.prototype.sampleCurveX=function(e){return((this.ax*e+this.bx)*e+this.cx)*e},e.prototype.sampleCurveY=function(e){return((this.ay*e+this.by)*e+this.cy)*e},e.prototype.sampleCurveDerivativeX=function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},e.prototype.solveCurveX=function(e,t){var i,r,n,o,s;for(void 0===t&&(t=1e-6),n=e,s=0;s<8;s++){if(o=this.sampleCurveX(n)-e,Math.abs(o)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=o/a}if((n=e)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(o=this.sampleCurveX(n),Math.abs(o-e)<t)return n;e>o?i=n:r=n,n=.5*(r-i)+i}return n},e.prototype.solve=function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))};var F=t;function t(e,t){this.x=e,this.y=t}t.prototype={clone:function(){return new t(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,i=e.y-this.y;return t*t+i*i},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[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,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),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e};const i=Math.PI/180,r=180/Math.PI;function z(e){return e*i}function S(e){return e*r}const n=[[0,0],[1,0],[1,1],[0,1]];function a(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function o(e,t,i,r){const n=new s(e,t,i,r);return function(e){return n.solve(e)}}const c=o(.25,.1,.25,1);function C(e,t,i){return Math.min(i,Math.max(t,e))}function h(e,t,i){return(i=C((i-e)/(t-e),0,1))*i*(3-2*i)}function d(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function u(e,t,r){if(!e.length)return r(null,[]);let n=e.length;const o=new Array(e.length);let s=null;e.forEach((e,i)=>{t(e,(e,t)=>{e&&(s=e),o[i]=t,0==--n&&r(s,o)})})}function v(e){const t=[];for(const i in e)t.push(e[i]);return t}function b(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let f=1;function m(){return f++}function _(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function g(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function y(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function x(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function w(e,t){return-1!==e.indexOf(t,e.length-t.length)}function T(e,t,i){const r={};for(const n in e)r[n]=t.call(i||this,e[n],n,e);return r}function E(e,t,i){const r={};for(const n in e)t.call(i||this,e[n],n,e)&&(r[n]=e[n]);return r}function A(e){return Array.isArray(e)?e.map(A):"object"==typeof e&&e?T(e,A):e}const M={};function Y(e){M[e]||("undefined"!=typeof console&&console.warn(e),M[e]=!0)}function I(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function B(o){let s=0;for(let e,t,i=0,r=o.length,n=r-1;i<r;n=i++)e=o[i],t=o[n],s+=(t.x-e.x)*(e.y+t.y);return s}function k(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function P(e){const o={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,t,i,r)=>{const n=i||r;return o[t]=!n||n.toLowerCase(),""}),o["max-age"]){const e=parseInt(o["max-age"],10);isNaN(e)?delete o["max-age"]:o["max-age"]=e}return o}let L=null;function D(e){if(null==L){const t=e.navigator?e.navigator.userAgent:null;L=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return L}function R(e){try{const t=p[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function O(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const N=p.performance;function U(e){const t=e?e.url.toString():void 0;return N.getEntriesByName(t)}var j="2.9.1";let V,G,$,q;const Z={now:()=>void 0!==$?$:p.performance.now(),setNow(e){$=e},restoreNow(){$=void 0},frame(e){const t=p.requestAnimationFrame(e);return{cancel:()=>p.cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:r}=e;q||(q=p.document.createElement("canvas"));const n=q.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return(i>q.width||r>q.height)&&(q.width=i,q.height=r),n.clearRect(-t,-t,i+2*t,r+2*t),n.drawImage(e,0,0,i,r),n.getImageData(-t,-t,i+2*t,r+2*t)},resolveURL:e=>(V||(V=p.document.createElement("a")),V.href=e,V.href),get devicePixelRatio(){return p.devicePixelRatio},get prefersReducedMotion(){return!!p.matchMedia&&(null==G&&(G=p.matchMedia("(prefers-reduced-motion: reduce)")),G.matches)}};let W;const X={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==W){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{W=null!=qf.env.API_URL_REGEX?new RegExp(qf.env.API_URL_REGEX):t}catch(e){W=t}}return W},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},H={supported:!1,testSupport:function(e){!Q&&J&&(ee?te(e):K=e)}};let K,J,Q=!1,ee=!1;function te(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,J),e.isContextLost())return;H.supported=!0}catch(e){}e.deleteTexture(t),Q=!0}p.document&&(J=p.document.createElement("img"),J.onload=function(){K&&te(K),K=null,ee=!0},J.onerror=function(){Q=!0,K=null},J.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const ie="01",re="NO_ACCESS_TOKEN";function ne(e){return 0===e.indexOf("mapbox:")}function oe(e){return X.API_URL_REGEX.test(e)}const se=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ae(e){const t=e.match(se);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function le(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}function ce(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(p.atob(t[1]).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(e){return null}}class he{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=ce(X.ACCESS_TOKEN);let i="";return i=t&&t.u?p.btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t)))):X.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${i}`:`mapbox.eventData:${i}`}fetchEventData(){const e=R("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{const e=p.localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const r=p.localStorage.getItem(i);r&&(this.anonId=r)}catch(e){Y("Unable to read from LocalStorage")}}saveEventData(){const e=R("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{p.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&p.localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){Y("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,r){if(!X.EVENTS_URL)return;const n=ae(X.EVENTS_URL);n.params.push(`access_token=${r||X.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:j,skuId:ie,userId:this.anonId},s=t?b(o,t):o,a={url:le(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=ze(a,e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const ue=new class extends he{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){X.EVENTS_URL&&X.ACCESS_TOKEN&&Array.isArray(e)&&e.some(e=>ne(e)||oe(e))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=ce(X.ACCESS_TOKEN),i=t?t.u:X.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;y(this.anonId)||(this.anonId=_(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||e.getDate()!==t.getDate()}else r=!0;r?this.postEvent(n,{"enabled.telemetry":!1},e=>{e||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)},e):this.processRequests()}},pe=ue.postTurnstileEvent.bind(ue),de=new class extends he{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,r){this.skuToken=t,this.errorCb=r,X.EVENTS_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(re)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),y(this.anonId)||(this.anonId=_()),this.postEvent(i,{skuToken:this.skuToken},e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e))}},fe=de.postMapLoadEvent.bind(de),me=new class extends he{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,r){if(!X.API_URL||!X.SESSION_PATH)return;const n=ae(X.API_URL+X.SESSION_PATH);n.params.push(`sku=${t||""}`),n.params.push(`access_token=${r||X.ACCESS_TOKEN||""}`);const o={url:le(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=Pe(o,e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(e,t,i,r){this.skuToken=t,this.errorCb=r,X.SESSION_PATH&&X.API_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(re)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}},_e=me.getSessionAPI.bind(me),ge=new Set;let ye,xe=500,ve=50,be={};function we(e){const t=Ee(e);let i,r;t&&t.forEach(e=>{const t=e.split("=");"language"===t[0]?i=t[1]:"worldview"===t[0]&&(r=t[1])});let n="mapbox-tiles";return i&&(n+=`-${i}`),r&&(n+=`-${r}`),n}function Te(e){p.caches&&!be[e]&&(be[e]=p.caches.open(e))}function Ee(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}function Ae(e){const t=e.indexOf("?");if(t<0)return e;const i=Ee(e).filter(e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]});return i.length?`${e.slice(0,t)}?${i.join("&")}`:e.slice(0,t)}let Se=1/0;const Ce={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Ce);class Me extends Error{constructor(e,t,i){401===t&&oe(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ie=k()?()=>self.worker&&self.worker.referrer:()=>("blob:"===p.location.protocol?p.parent:p).location.href;const Be=function(e,t){if(!(/^file:/.test(i=e.url)||/^file:/.test(Ie())&&!/^\w+:/.test(i))){if(p.fetch&&p.Request&&p.AbortController&&p.Request.prototype.hasOwnProperty("signal"))return function(n,o){const e=new p.AbortController,s=new p.Request(n.url,{method:n.method||"GET",body:n.body,credentials:n.credentials,headers:n.headers,referrer:Ie(),signal:e.signal});let a=!1,l=!1;const c=(t=s.url).indexOf("sku=")>0&&oe(t);var t;"json"===n.type&&s.headers.set("Accept","application/json");const i=(e,t,i)=>{if(l)return;if(e&&"SecurityError"!==e.message&&Y(e),t&&i)return h(t);const r=Date.now();p.fetch(s).then(e=>{if(e.ok){const n=c?e.clone():null;return h(e,n,r)}return o(new Me(e.statusText,e.status,n.url))}).catch(e=>{20!==e.code&&o(new Error(e.message))})},h=(t,i,r)=>{("arrayBuffer"===n.type?t.arrayBuffer():"json"===n.type?t.json():t.text()).then(e=>{l||(i&&r&&function(i,e,t){const r=we(i.url);if(Te(r),!be[r])return;const n={status:e.status,statusText:e.statusText,headers:new p.Headers};e.headers.forEach((e,t)=>n.headers.set(t,e));const o=P(e.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&n.headers.set("Expires",new Date(t+1e3*o["max-age"]).toUTCString());const s=n.headers.get("Expires");s&&(new Date(s).getTime()-t<42e4||function(e,t){if(void 0===ye)try{new Response(new ReadableStream),ye=!0}catch(e){ye=!1}ye?t(e.body):e.blob().then(t)}(e,e=>{const t=new p.Response(e,n);Te(r),be[r]&&be[r].then(e=>e.put(Ae(i.url),t)).catch(e=>Y(e.message))}))}(s,i,r),a=!0,o(null,e,t.headers.get("Cache-Control"),t.headers.get("Expires")))}).catch(e=>{l||o(new Error(e.message))})};return c?function(e,r){const t=we(e.url);if(Te(t),!be[t])return r(null);const n=Ae(e.url);be[t].then(i=>{i.match(n).then(e=>{const t=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=P(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(e);i.delete(n),t&&i.put(n,e.clone()),r(null,e,t)}).catch(r)}).catch(r)}(s,i):i(null,null),{cancel:()=>{l=!0,a||e.abort()}}}(e,t);if(k()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var i;return function(t,i){const r=new p.XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const p in t.headers)r.setRequestHeader(p,t.headers[p]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{i(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let e=r.response;if("json"===t.type)try{e=JSON.parse(r.response)}catch(e){return i(e)}i(null,e,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else i(new Me(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(e,t)},ke=function(e,t){return Be(b(e,{type:"arrayBuffer"}),t)},ze=function(e,t){return Be(b(e,{method:"POST"}),t)},Pe=function(e,t){return Be(b(e,{method:"GET"}),t)};function Le(e){const t=p.document.createElement("a");return t.href=e,t.protocol===p.document.location.protocol&&t.host===p.document.location.host}const De="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Re,Oe;Re=[],Oe=0;const Fe=function(e,n){if(H.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Oe>=X.MAX_PARALLEL_IMAGE_REQUESTS){const p={requestParameters:e,callback:n,cancelled:!1,cancel(){this.cancelled=!0}};return Re.push(p),p}Oe++;let r=!1;const o=()=>{if(!r)for(r=!0,Oe--;Re.length&&Oe<X.MAX_PARALLEL_IMAGE_REQUESTS;){const e=Re.shift(),{requestParameters:t,callback:i,cancelled:r}=e;r||(e.cancel=Fe(t,i).cancel)}},t=ke(e,(e,t,i,r)=>{o(),e?n(e):t&&(p.createImageBitmap?function(e,t){const i=new p.Blob([new Uint8Array(e)],{type:"image/png"});p.createImageBitmap(i).then(e=>{t(null,e)}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(t,(e,t)=>n(e,t,i,r)):function(e,t){const i=new p.Image,r=p.URL;i.onload=()=>{t(null,i),r.revokeObjectURL(i.src),i.onload=null,p.requestAnimationFrame(()=>{i.src=De})},i.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new p.Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?r.createObjectURL(n):De}(t,(e,t)=>n(e,t,i,r)))});return{cancel:()=>{t.cancel(),o()}}};function Ne(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function Ue(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class je{constructor(e,t={}){b(this,t),this.type=e}}class Ve extends je{constructor(e,t={}){super("error",b({error:e},t))}}class Ge{on(e,t){return this._listeners=this._listeners||{},Ne(e,t,this._listeners),this}off(e,t){return Ue(e,t,this._listeners),Ue(e,t,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Ne(t,e,this._oneTimeListeners),this):new Promise(e=>this.once(t,e))}fire(e,t){"string"==typeof e&&(e=new je(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)Ue(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(b(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof Ve&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var $e=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function qe(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function Ze(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ye(e){if(Array.isArray(e))return e.map(Ye);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Ye(e[i]);return t}return Ze(e)}class We extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var Xe=We;class He{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new He(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var Ke=He;const Je={kind:"null"},Qe={kind:"number"},et={kind:"string"},tt={kind:"boolean"},it={kind:"color"},rt={kind:"object"},nt={kind:"value"},ot={kind:"collator"},st={kind:"formatted"},at={kind:"resolvedImage"};function lt(e,t){return{kind:"array",itemType:e,N:t}}function ct(e){if("array"===e.kind){const t=ct(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const ht=[Je,Qe,et,tt,it,st,rt,lt(nt),at];function ut(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ut(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of ht)if(!ut(e,t))return null}return`Expected ${ct(e)} but found ${ct(t)} instead.`}function pt(t,e){return e.some(e=>e.kind===t.kind)}function dt(t,e){return e.some(e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t)}function ft(e){var t={exports:{}};return e(t,t.exports),t.exports}var mt=ft(function(e,t){var d={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 f(e){return(e=Math.round(e))<0?0:e>255?255:e}function m(e){return f("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function _(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function g(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{t.parseCSSColor=function(e){var t,i=e.replace(/ /g,"").toLowerCase();if(i in d)return d[i].slice();if("#"===i[0])return 4===i.length?(t=parseInt(i.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===i.length&&(t=parseInt(i.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=i.indexOf("("),n=i.indexOf(")");if(-1!==r&&n+1===i.length){var o=i.substr(0,r),s=i.substr(r+1,n-(r+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=_(s.pop());case"rgb":return 3!==s.length?null:[m(s[0]),m(s[1]),m(s[2]),a];case"hsla":if(4!==s.length)return null;a=_(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=_(s[1]),h=_(s[2]),u=h<=.5?h*(c+1):h+c-h*c,p=2*h-u;return[f(255*g(p,u,l+1/3)),f(255*g(p,u,l)),f(255*g(p,u,l-1/3)),a];default:return null}}return null}}catch(e){}});class _t{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof _t)return e;if("string"!=typeof e)return;const t=mt.parseCSSColor(e);return t?new _t(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}}_t.black=new _t(0,0,0,1),_t.white=new _t(1,1,1,1),_t.transparent=new _t(0,0,0,0),_t.red=new _t(1,0,0,1),_t.blue=new _t(0,0,1,1);var gt=_t;class yt{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class xt{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class vt{constructor(e){this.sections=e}static fromString(e){return new vt([new xt(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof vt?e:vt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i)}return e}}class bt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new bt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function wt(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Tt(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof gt)return!0;if(e instanceof yt)return!0;if(e instanceof vt)return!0;if(e instanceof bt)return!0;if(Array.isArray(e)){for(const t of e)if(!Tt(t))return!1;return!0}if("object"==typeof e){for(const i in e)if(!Tt(e[i]))return!1;return!0}return!1}function Et(t){if(null===t)return Je;if("string"==typeof t)return et;if("boolean"==typeof t)return tt;if("number"==typeof t)return Qe;if(t instanceof gt)return it;if(t instanceof yt)return ot;if(t instanceof vt)return st;if(t instanceof bt)return at;if(Array.isArray(t)){const i=t.length;let e;for(const r of t){const t=Et(r);if(e){if(e===t)continue;e=nt;break}e=t}return lt(e||nt,i)}return rt}function At(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof gt||e instanceof vt||e instanceof bt?e.toString():JSON.stringify(e)}class St{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Tt(e[1]))return t.error("invalid value");const i=e[1];let r=Et(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new St(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof gt?["rgba"].concat(this.value.toArray()):this.value instanceof vt?this.value.serialize():this.value}}var Ct=St,Mt=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const It={string:et,number:Qe,boolean:tt,object:rt};class Bt{constructor(e,t){this.type=e,this.args=t}static parse(i,r){if(i.length<2)return r.error("Expected at least one argument.");let n,o=1;const e=i[0];if("array"===e){let e,t;if(i.length>2){const n=i[1];if("string"!=typeof n||!(n in It)||"object"===n)return r.error('The item type argument of "array" must be one of string, number, boolean',1);e=It[n],o++}else e=nt;if(i.length>3){if(null!==i[2]&&("number"!=typeof i[2]||i[2]<0||i[2]!==Math.floor(i[2])))return r.error('The length argument to "array" must be a positive integer literal',2);t=i[2],o++}n=lt(e,t)}else n=It[e];const t=[];for(;o<i.length;o++){const n=r.parse(i[o],o,nt);if(!n)return null;t.push(n)}return new Bt(n,t)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!ut(this.type,Et(i)))return i;if(e===this.args.length-1)throw new Mt(`Expected value to be of type ${ct(this.type)}, but found ${ct(Et(i))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(e=>e.serialize()))}}var kt=Bt;class zt{constructor(e){this.type=st,this.sections=e}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");const e=t[1];if(!Array.isArray(e)&&"object"==typeof e)return r.error("First argument must be an image or text section.");const n=[];let o=!1;for(let e=1;e<=t.length-1;++e){const s=t[e];if(o&&"object"==typeof s&&!Array.isArray(s)){o=!1;let e=null;if(s["font-scale"]&&(e=r.parse(s["font-scale"],1,Qe),!e))return null;let t=null;if(s["text-font"]&&(t=r.parse(s["text-font"],1,lt(et)),!t))return null;let i=null;if(s["text-color"]&&(i=r.parse(s["text-color"],1,it),!i))return null;const a=n[n.length-1];a.scale=e,a.font=t,a.textColor=i}else{const i=r.parse(t[e],1,nt);if(!i)return null;const l=i.type.kind;if("string"!==l&&"value"!==l&&"null"!==l&&"resolvedImage"!==l)return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");o=!0,n.push({content:i,scale:null,font:null,textColor:null})}}return new zt(n)}evaluate(i){return new vt(this.sections.map(e=>{const t=e.content.evaluate(i);return Et(t)===at?new xt("",t,null,null,null):new xt(At(t),null,e.scale?e.scale.evaluate(i):null,e.font?e.font.evaluate(i).join(","):null,e.textColor?e.textColor.evaluate(i):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class Pt{constructor(e){this.type=at,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,et);return i?new Pt(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=bt.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Lt={"to-boolean":tt,"to-color":it,"to-number":Qe,"to-string":et};class Dt{constructor(e,t){this.type=e,this.args=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const e=t[0];if(("to-boolean"===e||"to-string"===e)&&2!==t.length)return i.error("Expected one argument.");const r=Lt[e],n=[];for(let e=1;e<t.length;e++){const r=i.parse(t[e],e,nt);if(!r)return null;n.push(r)}return new Dt(r,n)}evaluate(i){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(i));if("color"===this.type.kind){let e,t;for(const r of this.args){if(e=r.evaluate(i),t=null,e instanceof gt)return e;if("string"==typeof e){const n=i.parseColor(e);if(n)return n}else if(Array.isArray(e)&&(t=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:wt(e[0],e[1],e[2],e[3]),!t))return new gt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Mt(t||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const t of this.args){if(e=t.evaluate(i),null===e)return 0;const o=Number(e);if(!isNaN(o))return o}throw new Mt(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?vt.fromString(At(this.args[0].evaluate(i))):"resolvedImage"===this.type.kind?bt.fromString(At(this.args[0].evaluate(i))):At(this.args[0].evaluate(i))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new zt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Pt(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild(e=>{t.push(e.serialize())}),t}}var Rt=Dt;const Ot=["Unknown","Point","LineString","Polygon"];var Ft=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ot[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=gt.parse(e)),t}};class Nt{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(i,r){const n=i[0],o=Nt.definitions[n];if(!o)return r.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(o)?o[0]:o.type,a=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,l=a.filter(([e])=>!Array.isArray(e)||e.length===i.length-1);let c=null;for(const[o,a]of l){c=new pi(r.registry,r.path,null,r.scope);const l=[];let t=!1;for(let e=1;e<i.length;e++){const n=i[e],s=Array.isArray(o)?o[e-1]:o.type,a=c.parse(n,1+l.length,s);if(!a){t=!0;break}l.push(a)}if(!t)if(Array.isArray(o)&&o.length!==l.length)c.error(`Expected ${o.length} arguments, but found ${l.length} instead.`);else{for(let e=0;e<l.length;e++){const r=Array.isArray(o)?o[e]:o.type,n=l[e];c.concat(e+1).checkSubtype(r,n.type)}if(0===c.errors.length)return new Nt(n,s,a,l)}}if(1===l.length)r.errors.push(...c.errors);else{const n=(l.length?l:a).map(([e])=>{return t=e,Array.isArray(t)?`(${t.map(ct).join(", ")})`:`(${ct(t.type)}...)`;var t}).join(" | "),o=[];for(let e=1;e<i.length;e++){const s=r.parse(i[e],1+o.length);if(!s)return null;o.push(ct(s.type))}r.error(`Expected arguments of type ${n}, but found (${o.join(", ")}) instead.`)}return null}static register(e,t){Nt.definitions=t;for(const i in t)e[i]=Nt}}var Ut=Nt;class jt{constructor(e,t,i){this.type=ot,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,tt);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,tt);if(!n)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,et),!o)?null:new jt(r,n,o)}evaluate(e){return new yt(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Vt=8192;function Gt(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function $t(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function qt(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*Vt),Math.round(r*n*Vt)]}function Zt(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Yt(i,r){let n=!1;for(let e=0,t=r.length;e<t;e++){const l=r[e];for(let e=0,t=l.length;e<t-1;e++){if(Zt(i,l[e],l[e+1]))return!1;(s=l[e])[1]>(o=i)[1]!=(a=l[e+1])[1]>o[1]&&o[0]<(a[0]-s[0])*(o[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n)}}var o,s,a;return n}function Wt(t,i){for(let e=0;e<i.length;e++)if(Yt(t,i[e]))return!0;return!1}function Xt(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Ht(t,i,e){for(const c of e)for(let e=0;e<c.length-1;++e)if(0!=(a=[(s=c[e+1])[0]-(o=c[e])[0],s[1]-o[1]])[0]*(l=[(n=i)[0]-(r=t)[0],n[1]-r[1]])[1]-a[1]*l[0]&&Xt(r,n,o,s)&&Xt(o,s,r,n))return!0;var r,n,o,s,a,l;return!1}function Kt(t,i){for(let e=0;e<t.length;++e)if(!Yt(t[e],i))return!1;for(let e=0;e<t.length-1;++e)if(Ht(t[e],t[e+1],i))return!1;return!0}function Jt(t,i){for(let e=0;e<i.length;e++)if(Kt(t,i[e]))return!0;return!1}function Qt(i,r,n){const e=[];for(let t=0;t<i.length;t++){const o=[];for(let e=0;e<i[t].length;e++){const s=qt(i[t][e],n);Gt(r,s),o.push(s)}e.push(o)}return e}function ei(t,i,r){const n=[];for(let e=0;e<t.length;e++){const o=Qt(t[e],i,r);n.push(o)}return n}function ti(t,i,r,n){if(t[0]<r[0]||t[0]>r[2]){const i=.5*n;let e=t[0]-r[0]>i?-n:r[0]-t[0]>i?n:0;0===e&&(e=t[0]-r[2]>i?-n:r[2]-t[0]>i?n:0),t[0]+=e}Gt(i,t)}function ii(e,t,i,r){const n=Math.pow(2,r.z)*Vt,o=[r.x*Vt,r.y*Vt],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];ti(r,t,i,n),s.push(r)}return s}function ri(e,t,i,r){const n=Math.pow(2,r.z)*Vt,o=[r.x*Vt,r.y*Vt],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Gt(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)ti(r,t,i,n)}var a;return s}class ni{constructor(e,t){this.type=tt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Tt(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new ni(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new ni(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new ni(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=Qt(t.coordinates,r,n),s=ii(e.geometry(),i,r,n);if(!$t(i,r))return!1;for(const e of s)if(!Yt(e,o))return!1}if("MultiPolygon"===t.type){const a=ei(t.coordinates,r,n),l=ii(e.geometry(),i,r,n);if(!$t(i,r))return!1;for(const e of l)if(!Wt(e,a))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=Qt(t.coordinates,r,n),s=ri(e.geometry(),i,r,n);if(!$t(i,r))return!1;for(const e of s)if(!Kt(e,o))return!1}if("MultiPolygon"===t.type){const a=ei(t.coordinates,r,n),l=ri(e.geometry(),i,r,n);if(!$t(i,r))return!1;for(const e of l)if(!Jt(e,a))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var oi=ni;function si(e){if(e instanceof Ut){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof oi)return!1;let t=!0;return e.eachChild(e=>{t&&!si(e)&&(t=!1)}),t}function ai(e){if(e instanceof Ut&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!ai(e)&&(t=!1)}),t}function li(e,t){if(e instanceof Ut&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!li(e,t)&&(i=!1)}),i}class ci{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new ci(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var hi=ci;class ui{constructor(e,t=[],i,r=new Ke,n=[]){this.registry=e,this.path=t,this.key=t.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(e,t,i,r,n={}){return t?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(t,i){function r(e,t,i){return"assert"===i?new kt(t,[e]):"coerce"===i?new Rt(t,[e]):e}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const e=t[0];if("string"!=typeof e)return this.error(`Expression name must be a string, but found ${typeof e} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[e];if(n){let e=n.parse(t,this);if(!e)return null;if(this.expectedType){const t=this.expectedType,o=e.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==o.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(t,o))return null}else e=r(e,t,i.typeAnnotation||"coerce");else e=r(e,t,i.typeAnnotation||"assert")}if(!(e instanceof Ct)&&"resolvedImage"!==e.type.kind&&di(e)){const t=new Ft;try{e=new Ct(e.type,e.evaluate(t))}catch(t){return this.error(t.message),null}}return e}return this.error(`Unknown expression "${e}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new ui(this.registry,r,t||null,n,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Xe(i,e))}checkSubtype(e,t){const i=ut(e,t);return i&&this.error(i),i}}var pi=ui;function di(e){if(e instanceof hi)return di(e.boundExpression);if(e instanceof Ut&&"error"===e.name)return!1;if(e instanceof jt)return!1;if(e instanceof oi)return!1;const t=e instanceof Rt||e instanceof kt;let i=!0;return e.eachChild(e=>{i=t?i&&di(e):i&&e instanceof Ct}),!!i&&si(e)&&li(e,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function fi(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||t<n)return a;o=a+1}else{if(!(r>t))throw new Mt("Input is not a number.");s=a-1}return 0}class mi{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");const e=i.parse(t[1],1,Qe);if(!e)return null;const r=[];let n=null;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);for(let e=1;e<t.length;e+=2){const o=1===e?-1/0:t[e],s=t[e+1],a=e,l=e+1;if("number"!=typeof o)return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=i.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new mi(n,e,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[fi(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var _i=mi;function gi(e,t,i){return e*(1-i)+t*i}var yi=Object.freeze({__proto__:null,number:gi,color:function(e,t,i){return new gt(gi(e.r,t.r,i),gi(e.g,t.g,i),gi(e.b,t.b,i),gi(e.a,t.a,i))},array:function(e,i,r){return e.map((e,t)=>gi(e,i[t],r))}});const xi=.95047,vi=1.08883,bi=4/29,wi=6/29,Ti=3*wi*wi,Ei=Math.PI/180,Ai=180/Math.PI;function Si(e){return e>.008856451679035631?Math.pow(e,1/3):e/Ti+bi}function Ci(e){return e>wi?e*e*e:Ti*(e-bi)}function Mi(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Ii(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Bi(e){const t=Ii(e.r),i=Ii(e.g),r=Ii(e.b),n=Si((.4124564*t+.3575761*i+.1804375*r)/xi),o=Si((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-Si((.0193339*t+.119192*i+.9503041*r)/vi)),alpha:e.a}}function ki(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*Ci(t),i=xi*Ci(i),r=vi*Ci(r),new gt(Mi(3.2404542*i-1.5371385*t-.4985314*r),Mi(-.969266*i+1.8760108*t+.041556*r),Mi(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function zi(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Pi={forward:Bi,reverse:ki,interpolate:function(e,t,i){return{l:gi(e.l,t.l,i),a:gi(e.a,t.a,i),b:gi(e.b,t.b,i),alpha:gi(e.alpha,t.alpha,i)}}},Li={forward:function(e){const{l:t,a:i,b:r}=Bi(e),n=Math.atan2(r,i)*Ai;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Ei,i=e.c;return ki({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:zi(e.h,t.h,i),c:gi(e.c,t.c,i),l:gi(e.l,t.l,i),alpha:gi(e.alpha,t.alpha,i)}}};var Di=Object.freeze({__proto__:null,lab:Pi,hcl:Li});class Ri{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=Oi(t,e.base,i,r);else if("linear"===e.name)n=Oi(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new s(o[0],o[1],o[2],o[3]).solve(Oi(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Qe),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=it:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Ri(a,i,r,n,s):t.error(`Type ${ct(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=fi(t,r),s=Ri.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?yi[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Li.reverse(Li.interpolate(Li.forward(a),Li.forward(l),s)):Pi.reverse(Pi.interpolate(Pi.forward(a),Pi.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function Oi(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}var Fi=Ri;class Ni{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}const o=r&&n.some(e=>ut(r,e.type));return new Ni(o?nt:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof bt&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const t=["coalesce"];return this.eachChild(e=>{t.push(e.serialize())}),t}}var Ui=Ni;class ji{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let e=1;e<t.length-1;e+=2){const n=t[e];if("string"!=typeof n)return i.error(`Expected string, but found ${typeof n} instead.`,e);if(/[^a-zA-Z0-9_]/.test(n))return i.error("Variable names must contain only alphanumeric characters or '_'.",e);const o=i.parse(t[e+1],e+1);if(!o)return null;r.push([n,o])}const e=i.parse(t[t.length-1],t.length-1,i.expectedType,r);return e?new ji(r,e):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}var Vi=ji;class Gi{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Qe),r=t.parse(e[2],2,lt(t.expectedType||nt));return i&&r?new Gi(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Mt(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new Mt(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Mt(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var $i=Gi;class qi{constructor(e,t){this.type=tt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,nt),r=t.parse(e[2],2,nt);return i&&r?pt(i.type,[tt,et,Qe,Je,nt])?new qi(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!dt(t,["boolean","string","number","null"]))throw new Mt(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Et(t))} instead.`);if(!dt(i,["string","array"]))throw new Mt(`Expected second argument to be of type array or string, but found ${ct(Et(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Zi=qi;class Yi{constructor(e,t,i){this.type=Qe,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,nt),r=t.parse(e[2],2,nt);if(!i||!r)return null;if(!pt(i.type,[tt,et,Qe,Je,nt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Qe);return n?new Yi(i,r,n):null}return new Yi(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!dt(t,["boolean","string","number","null"]))throw new Mt(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Et(t))} instead.`);if(!dt(i,["string","array"]))throw new Mt(`Expected second argument to be of type array or string, but found ${ct(Et(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Wi=Yi;class Xi{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(i,r){if(i.length<5)return r.error(`Expected at least 4 arguments, but found only ${i.length-1}.`);if(i.length%2!=1)return r.error("Expected an even number of arguments.");let n,o;r.expectedType&&"value"!==r.expectedType.kind&&(o=r.expectedType);const s={},a=[];for(let t=2;t<i.length-1;t+=2){let e=i[t];const l=i[t+1];Array.isArray(e)||(e=[e]);const c=r.concat(t);if(0===e.length)return c.error("Expected at least one branch label.");for(const i of e){if("number"!=typeof i&&"string"!=typeof i)return c.error("Branch labels must be numbers or strings.");if("number"==typeof i&&Math.abs(i)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof i&&Math.floor(i)!==i)return c.error("Numeric branch labels must be integer values.");if(n){if(c.checkSubtype(n,Et(i)))return null}else n=Et(i);if(void 0!==s[String(i)])return c.error("Branch labels must be unique.");s[String(i)]=a.length}const h=r.parse(l,t,o);if(!h)return null;o=o||h.type,a.push(h)}const e=r.parse(i[1],1,nt);if(!e)return null;const t=r.parse(i[i.length-1],i.length-1,o);return t?"value"!==e.type.kind&&r.concat(1).checkSubtype(n,e.type)?null:new Xi(n,o,e,s,a,t):null}evaluate(e){const t=this.input.evaluate(e);return(Et(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var Hi=Xi;class Ki{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&"value"!==i.expectedType.kind&&(r=i.expectedType);const n=[];for(let e=1;e<t.length-1;e+=2){const o=i.parse(t[e],e,tt);if(!o)return null;const s=i.parse(t[e+1],e+1,r);if(!s)return null;n.push([o,s]),r=r||s.type}const e=i.parse(t[t.length-1],t.length-1,r);return e?new Ki(r,n,e):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild(e=>{t.push(e.serialize())}),t}}var Ji=Ki;class Qi{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,nt),r=t.parse(e[2],2,Qe);if(!i||!r)return null;if(!pt(i.type,[lt(nt),et,nt]))return t.error(`Expected first argument to be of type array or string, but found ${ct(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Qe);return n?new Qi(i.type,i,r,n):null}return new Qi(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!dt(t,["string","array"]))throw new Mt(`Expected first argument to be of type array or string, but found ${ct(Et(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var er=Qi;function tr(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function ir(e,t,i,r){return 0===r.compare(t,i)}function rr(r,n,o){const s="=="!==r&&"!="!==r;return class a{constructor(e,t,i){this.type=tt,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let r=t.parse(e[1],1,nt);if(!r)return null;if(!tr(i,r.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${ct(r.type)}'.`);let n=t.parse(e[2],2,nt);if(!n)return null;if(!tr(i,n.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${ct(n.type)}'.`);if(r.type.kind!==n.type.kind&&"value"!==r.type.kind&&"value"!==n.type.kind)return t.error(`Cannot compare types '${ct(r.type)}' and '${ct(n.type)}'.`);s&&("value"===r.type.kind&&"value"!==n.type.kind?r=new kt(n.type,[r]):"value"!==r.type.kind&&"value"===n.type.kind&&(n=new kt(r.type,[n])));let o=null;if(4===e.length){if("string"!==r.type.kind&&"string"!==n.type.kind&&"value"!==r.type.kind&&"value"!==n.type.kind)return t.error("Cannot use collator to compare non-string types.");if(o=t.parse(e[3],3,ot),!o)return null}return new a(r,n,o)}evaluate(e){const t=this.lhs.evaluate(e),i=this.rhs.evaluate(e);if(s&&this.hasUntypedArgument){const n=Et(t),o=Et(i);if(n.kind!==o.kind||"string"!==n.kind&&"number"!==n.kind)throw new Mt(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${n.kind}, ${o.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const r=Et(t),o=Et(i);if("string"!==r.kind||"string"!==o.kind)return n(e,t,i)}return this.collator?o(e,t,i,this.collator.evaluate(e)):n(e,t,i)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[r];return this.eachChild(e=>{t.push(e.serialize())}),t}}}const nr=rr("==",function(e,t,i){return t===i},ir),or=rr("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!ir(0,t,i,r)}),sr=rr("<",function(e,t,i){return t<i},function(e,t,i,r){return r.compare(t,i)<0}),ar=rr(">",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),lr=rr("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0}),cr=rr(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0});class hr{constructor(e,t,i,r,n){this.type=et,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Qe);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,et),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,et),!o))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,Qe),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=t.parse(r["max-fraction-digits"],1,Qe),!a)?null:new hr(i,n,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class ur{constructor(e){this.type=Qe,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${ct(i.type)} instead.`):new ur(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Mt(`Expected value to be of type string or array, but found ${ct(Et(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild(e=>{t.push(e.serialize())}),t}}const pr={"==":nr,"!=":or,">":ar,"<":sr,">=":cr,"<=":lr,array:kt,at:$i,boolean:kt,case:Ji,coalesce:Ui,collator:jt,format:zt,image:Pt,in:Zi,"index-of":Wi,interpolate:Fi,"interpolate-hcl":Fi,"interpolate-lab":Fi,length:ur,let:Vi,literal:Ct,match:Hi,number:kt,"number-format":hr,object:kt,slice:er,step:_i,string:kt,"to-boolean":Rt,"to-color":Rt,"to-number":Rt,"to-string":Rt,var:hi,within:oi};function dr(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=wt(t,i,r,o);if(s)throw new Mt(s);return new gt(t/255*o,i/255*o,r/255*o,o)}function fr(e,t){return e in t}function mr(e,t){const i=t[e];return void 0===i?null:i}function _r(e){return{type:e}}Ut.register(pr,{error:[{kind:"error"},[et],(e,[t])=>{throw new Mt(t.evaluate(e))}],typeof:[et,[nt],(e,[t])=>ct(Et(t.evaluate(e)))],"to-rgba":[lt(Qe,4),[it],(e,[t])=>t.evaluate(e).toArray()],rgb:[it,[Qe,Qe,Qe],dr],rgba:[it,[Qe,Qe,Qe,Qe],dr],has:{type:tt,overloads:[[[et],(e,[t])=>fr(t.evaluate(e),e.properties())],[[et,rt],(e,[t,i])=>fr(t.evaluate(e),i.evaluate(e))]]},get:{type:nt,overloads:[[[et],(e,[t])=>mr(t.evaluate(e),e.properties())],[[et,rt],(e,[t,i])=>mr(t.evaluate(e),i.evaluate(e))]]},"feature-state":[nt,[et],(e,[t])=>mr(t.evaluate(e),e.featureState||{})],properties:[rt,[],e=>e.properties()],"geometry-type":[et,[],e=>e.geometryType()],id:[nt,[],e=>e.id()],zoom:[Qe,[],e=>e.globals.zoom],pitch:[Qe,[],e=>e.globals.pitch||0],"distance-from-center":[Qe,[],e=>e.distanceFromCenter()],"heatmap-density":[Qe,[],e=>e.globals.heatmapDensity||0],"line-progress":[Qe,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[Qe,[],e=>e.globals.skyRadialProgress||0],accumulated:[nt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Qe,_r(Qe),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Qe,_r(Qe),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Qe,overloads:[[[Qe,Qe],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Qe],(e,[t])=>-t.evaluate(e)]]},"/":[Qe,[Qe,Qe],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Qe,[Qe,Qe],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Qe,[],()=>Math.LN2],pi:[Qe,[],()=>Math.PI],e:[Qe,[],()=>Math.E],"^":[Qe,[Qe,Qe],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Qe,[Qe],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Qe,[Qe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Qe,[Qe],(e,[t])=>Math.log(t.evaluate(e))],log2:[Qe,[Qe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Qe,[Qe],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Qe,[Qe],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Qe,[Qe],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Qe,[Qe],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Qe,[Qe],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Qe,[Qe],(e,[t])=>Math.atan(t.evaluate(e))],min:[Qe,_r(Qe),(t,e)=>Math.min(...e.map(e=>e.evaluate(t)))],max:[Qe,_r(Qe),(t,e)=>Math.max(...e.map(e=>e.evaluate(t)))],abs:[Qe,[Qe],(e,[t])=>Math.abs(t.evaluate(e))],round:[Qe,[Qe],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Qe,[Qe],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Qe,[Qe],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[tt,[et,nt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[tt,[nt],(e,[t])=>e.id()===t.value],"filter-type-==":[tt,[et],(e,[t])=>e.geometryType()===t.value],"filter-<":[tt,[et,nt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[tt,[nt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[tt,[et,nt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[tt,[nt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[tt,[et,nt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[tt,[nt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[tt,[et,nt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[tt,[nt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[tt,[nt],(e,[t])=>t.value in e.properties()],"filter-has-id":[tt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[tt,[lt(et)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[tt,[lt(nt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[tt,[et,lt(nt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[tt,[et,lt(nt)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:tt,overloads:[[[tt,tt],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[_r(tt),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:tt,overloads:[[[tt,tt],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[_r(tt),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[tt,[tt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[tt,[et],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[et,[et],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[et,[et],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[et,_r(nt),(t,e)=>e.map(e=>At(e.evaluate(t))).join("")],"resolved-locale":[et,[ot],(e,[t])=>t.evaluate(e).resolvedLocale()]});var gr=pr;function yr(e){return{result:"success",value:e}}function xr(e){return{result:"error",value:e}}function vr(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function br(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function wr(e){return!!e.expression&&e.expression.interpolated}function Tr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Er(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ar(e){return e}function Sr(r,n){const t="color"===n.type,i=r.stops&&"object"==typeof r.stops[0][0],o=i||!(i||void 0!==r.property),s=r.type||(wr(n)?"exponential":"interval");if(t&&((r=qe({},r)).stops&&(r.stops=r.stops.map(e=>[e[0],gt.parse(e[1])])),r.default=gt.parse(r.default?r.default:n.default)),r.colorSpace&&"rgb"!==r.colorSpace&&!Di[r.colorSpace])throw new Error(`Unknown color space: ${r.colorSpace}`);let a,l,c;if("exponential"===s)a=Br;else if("interval"===s)a=Ir;else if("categorical"===s){a=Mr,l=Object.create(null);for(const n of r.stops)l[n[0]]=n[1];c=typeof r.stops[0][0]}else{if("identity"!==s)throw new Error(`Unknown function type "${s}"`);a=kr}if(i){const t={},i=[];for(let e=0;e<r.stops.length;e++){const o=r.stops[e],s=o[0].zoom;void 0===t[s]&&(t[s]={zoom:s,type:r.type,property:r.property,default:r.default,stops:[]},i.push(s)),t[s].stops.push([o[0].value,o[1]])}const o=[];for(const r of i)o.push([t[r].zoom,Sr(t[r],n)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:Fi.interpolationFactor.bind(void 0,s),zoomStops:o.map(e=>e[0]),evaluate:({zoom:e},t)=>Br({stops:o,base:r.base},n,e).evaluate(e,t)}}if(o){const t="exponential"===s?{name:"exponential",base:void 0!==r.base?r.base:1}:null;return{kind:"camera",interpolationType:t,interpolationFactor:Fi.interpolationFactor.bind(void 0,t),zoomStops:r.stops.map(e=>e[0]),evaluate:({zoom:e})=>a(r,n,e,l,c)}}return{kind:"source",evaluate(e,t){const i=t&&t.properties?t.properties[r.property]:void 0;return void 0===i?Cr(r.default,n.default):a(r,n,i,l,c)}}}function Cr(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Mr(e,t,i,r,n){return Cr(typeof i===n?r[i]:void 0,e.default,t.default)}function Ir(e,t,i){if("number"!==Tr(i))return Cr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=fi(e.stops.map(e=>e[0]),i);return e.stops[n][1]}function Br(e,i,t){const r=void 0!==e.base?e.base:1;if("number"!==Tr(t))return Cr(e.default,i.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(t<=e.stops[0][0])return e.stops[0][1];if(t>=e.stops[n-1][0])return e.stops[n-1][1];const o=fi(e.stops.map(e=>e[0]),t),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(t,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=yi[i.type]||Ar;if(e.colorSpace&&"rgb"!==e.colorSpace){const i=Di[e.colorSpace];c=(e,t)=>i.reverse(i.interpolate(i.forward(e),i.forward(t),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function kr(e,t,i){return"color"===t.type?i=gt.parse(i):"formatted"===t.type?i=vt.fromString(i.toString()):"resolvedImage"===t.type?i=bt.fromString(i.toString()):Tr(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Cr(i,e.default,t.default)}class zr{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Ft,this._defaultValue=t?function(e){return"color"===e.type&&(Er(e.default)||Array.isArray(e.default))?new gt(0,0,0,0):"color"===e.type?gt.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,r,n,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Mt(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Pr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in gr}function Lr(e,t){const i=new pi(gr,[],t?function(e){const t={color:it,string:et,number:Qe,enum:et,boolean:tt,formatted:st,resolvedImage:at};return"array"===e.type?lt(t[e.value]||nt,e.length):t[e.type]}(t):void 0),r=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?yr(new zr(r,t)):xr(i.errors)}class Dr{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!ai(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class Rr{constructor(e,t,i,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!ai(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?Fi.interpolationFactor(this.interpolationType,e,t,i):0}}function Or(e,t){if("error"===(e=Lr(e,t)).result)return e;const i=e.value.expression,r=si(i);if(!r&&!vr(t))return xr([new Xe("","data expressions not supported")]);const n=li(i,["zoom","pitch","distance-from-center"]);if(!n&&!br(t))return xr([new Xe("","zoom expressions not supported")]);const o=Nr(i);return o||n?o instanceof Xe?xr([o]):o instanceof Fi&&!wr(t)?xr([new Xe("",'"interpolate" expressions cannot be used with this property')]):yr(o?new Rr(r?"camera":"composite",e.value,o.labels,o instanceof Fi?o.interpolation:void 0):new Dr(r?"constant":"source",e.value)):xr([new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Fr{constructor(e,t){this._parameters=e,this._specification=t,qe(this,Sr(this._parameters,this._specification))}static deserialize(e){return new Fr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Nr(e){let i=null;if(e instanceof Vi)i=Nr(e.result);else if(e instanceof Ui){for(const t of e.args)if(i=Nr(t),i)break}else(e instanceof _i||e instanceof Fi)&&e.input instanceof Ut&&"zoom"===e.input.name&&(i=e);return i instanceof Xe||e.eachChild(e=>{const t=Nr(e);t instanceof Xe?i=t:!i&&t?i=new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):i&&t&&i!==t&&(i=new Xe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),i}class Ur{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function jr(t){const i=t.key,r=t.value,n=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;let l=[];const c=Tr(r);if("object"!==c)return[new Ur(i,r,`object expected, ${c} found`)];for(const t in r){const c=t.split(".")[0],h=n[c]||n["*"];let e;o[c]?e=o[c]:n[c]?e=bn:o["*"]?e=o["*"]:n["*"]&&(e=bn),e?l=l.concat(e({key:(i?`${i}.`:i)+t,value:r[t],valueSpec:h,style:s,styleSpec:a,object:r,objectKey:t},r)):l.push(new Ur(i,r[t],`unknown property "${t}"`))}for(const t in n)o[t]||n[t].required&&void 0===n[t].default&&void 0===r[t]&&l.push(new Ur(i,r,`missing required property "${t}"`));return l}function Vr(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||bn;if("array"!==Tr(t))return[new Ur(o,t,`array expected, ${Tr(t)} found`)];if(i.length&&t.length!==i.length)return[new Ur(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new Ur(o,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};n.$version<7&&(a.function=i.function),"object"===Tr(i.value)&&(a=i.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(s({array:t,arrayIndex:e,value:t[e],valueSpec:a,style:r,styleSpec:n,key:`${o}[${e}]`}));return l}function Gr(t){const i=t.key,r=t.value,n=t.valueSpec;let e=Tr(r);if("number"===e&&r!=r&&(e="NaN"),"number"!==e)return[new Ur(i,r,`number expected, ${e} found`)];if("minimum"in n){let e=n.minimum;if("array"===Tr(n.minimum)&&(e=n.minimum[t.arrayIndex]),r<e)return[new Ur(i,r,`${r} is less than the minimum value ${e}`)]}if("maximum"in n){let e=n.maximum;if("array"===Tr(n.maximum)&&(e=n.maximum[t.arrayIndex]),r>e)return[new Ur(i,r,`${r} is greater than the maximum value ${e}`)]}return[]}function $r(e){const o=e.valueSpec,s=Ze(e.value.type);let a,l,n,c={};const t="categorical"!==s&&void 0===e.value.property,i=!t,h="array"===Tr(e.value.stops)&&"array"===Tr(e.value.stops[0])&&"object"===Tr(e.value.stops[0][0]),r=jr({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===s)return[new Ur(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(Vr({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:u})),"array"===Tr(i)&&0===i.length&&t.push(new Ur(e.key,i,"array must have at least one stop")),t},default:function(e){return bn({key:e.key,value:e.value,valueSpec:o,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===s&&t&&r.push(new Ur(e.key,e.value,'missing required property "property"')),"identity"===s||e.value.stops||r.push(new Ur(e.key,e.value,'missing required property "stops"')),"exponential"===s&&e.valueSpec.expression&&!wr(e.valueSpec)&&r.push(new Ur(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(i&&!vr(e.valueSpec)?r.push(new Ur(e.key,e.value,"property functions not supported")):t&&!br(e.valueSpec)&&r.push(new Ur(e.key,e.value,"zoom functions not supported"))),"categorical"!==s&&!h||void 0!==e.value.property||r.push(new Ur(e.key,e.value,'"property" property is required')),r;function u(e){let t=[];const i=e.value,r=e.key;if("array"!==Tr(i))return[new Ur(r,i,`array expected, ${Tr(i)} found`)];if(2!==i.length)return[new Ur(r,i,`array length 2 expected, length ${i.length} found`)];if(h){if("object"!==Tr(i[0]))return[new Ur(r,i,`object expected, ${Tr(i[0])} found`)];if(void 0===i[0].zoom)return[new Ur(r,i,"object stop key must have zoom")];if(void 0===i[0].value)return[new Ur(r,i,"object stop key must have value")];const o=Ze(i[0].zoom);if("number"!=typeof o)return[new Ur(r,i[0].zoom,"stop zoom values must be numbers")];if(n&&n>o)return[new Ur(r,i[0].zoom,"stop zoom values must appear in ascending order")];o!==n&&(n=o,l=void 0,c={}),t=t.concat(jr({key:`${r}[0]`,value:i[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Gr,value:p}}))}else t=t.concat(p({key:`${r}[0]`,value:i[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},i));return Pr(Ye(i[1]))?t.concat([new Ur(`${r}[1]`,i[1],"expressions are not allowed in function stops.")]):t.concat(bn({key:`${r}[1]`,value:i[1],valueSpec:o,style:e.style,styleSpec:e.styleSpec}))}function p(t,e){const i=Tr(t.value),r=Ze(t.value),n=null!==t.value?t.value:e;if(a){if(i!==a)return[new Ur(t.key,n,`${i} stop domain type must match previous stop domain type ${a}`)]}else a=i;if("number"!==i&&"string"!==i&&"boolean"!==i&&"number"!=typeof r&&"string"!=typeof r&&"boolean"!=typeof r)return[new Ur(t.key,n,"stop domain value must be a number, string, or boolean")];if("number"!==i&&"categorical"!==s){let e=`number expected, ${i} found`;return vr(o)&&void 0===s&&(e+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ur(t.key,n,e)]}return"categorical"!==s||"number"!==i||"number"==typeof r&&isFinite(r)&&Math.floor(r)===r?"categorical"!==s&&"number"===i&&"number"==typeof r&&"number"==typeof l&&void 0!==l&&r<l?[new Ur(t.key,n,"stop domain values must appear in ascending order")]:(l=r,"categorical"===s&&r in c?[new Ur(t.key,n,"stop domain values must be unique")]:(c[r]=!0,[])):[new Ur(t.key,n,`integer expected, found ${String(r)}`)]}}function qr(t){const e=("property"===t.expressionContext?Or:Lr)(Ye(t.value),t.valueSpec);if("error"===e.result)return e.value.map(e=>new Ur(`${t.key}${e.key}`,t.value,e.message));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new Ur(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!ai(i))return[new Ur(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return Zr(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!li(i,["zoom","feature-state"]))return[new Ur(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!si(i))return[new Ur(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Zr(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const r=[];return e instanceof Ut&&i.has(e.name)?[new Ur(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild(e=>{r.push(...Zr(e,t))}),r)}function Yr(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Ze(i))&&n.push(new Ur(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Ze(i))&&n.push(new Ur(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Wr(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Wr(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Xr(o,e="fill"){if(null==o)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Wr(o)||(o=rn(o));const t=o;let i=!0;try{i=function(e){if(!Jr(e))return e;let t=Ye(e);return Kr(t),t=Hr(t),t}(t)}catch(o){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(t,null,2)}\n `)}const r=$e[`filter_${e}`],n=Lr(i,r);let s=null;if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(e,t,i)=>n.value.evaluate(e,t,{},i);let a=null,l=null;if(i!==t){const o=Lr(t,r);if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(e,t,i,r,n)=>o.value.evaluate(e,t,{},i,void 0,void 0,r,n),l=!si(o.value.expression)}return s=s,{filter:s,dynamicFilter:a||void 0,needGeometry:tn(i),needFeature:!!l}}function Hr(e){if(!Array.isArray(e))return e;const t=function(t){if(Qr.has(t[0]))for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return t}(e);return!0===t?t:t.map(e=>Hr(e))}function Kr(t){let i=!1;const r=[];if("case"===t[0]){for(let e=1;e<t.length-1;e+=2)i=i||Jr(t[e]),r.push(t[e+1]);r.push(t[t.length-1])}else if("match"===t[0]){i=i||Jr(t[1]);for(let e=2;e<t.length-1;e+=2)r.push(t[e+1]);r.push(t[t.length-1])}else if("step"===t[0]){i=i||Jr(t[1]);for(let e=1;e<t.length-1;e+=2)r.push(t[e+1])}i&&(t.length=0,t.push("any",...r));for(let e=1;e<t.length;e++)Kr(t[e])}function Jr(t){if(!Array.isArray(t))return!1;if("pitch"===(e=t[0])||"distance-from-center"===e)return!0;var e;for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return!1}const Qr=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function en(e,t){return e<t?-1:e>t?1:0}function tn(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(tn(t[e]))return!0;return!1}function rn(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?nn(e[1],e[2],"=="):"!="===t?an(nn(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?nn(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(rn))):"all"===t?["all"].concat(e.slice(1).map(rn)):"none"===t?["all"].concat(e.slice(1).map(rn).map(an)):"in"===t?on(e[1],e.slice(2)):"!in"===t?an(on(e[1],e.slice(2))):"has"===t?sn(e[1]):"!has"===t?an(sn(e[1])):"within"!==t||e;var i}function nn(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function on(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(en)]]:["filter-in-small",e,["literal",t]]}}function sn(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function an(e){return["!",e]}function ln(e){return Wr(Ye(e.value))?qr(qe({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):cn(e)}function cn(t){const i=t.value,r=t.key;if("array"!==Tr(i))return[new Ur(r,i,`array expected, ${Tr(i)} found`)];const n=t.styleSpec;let o,s=[];if(i.length<1)return[new Ur(r,i,"filter array must have at least 1 element")];switch(s=s.concat(Yr({key:`${r}[0]`,value:i[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),Ze(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===Ze(i[1])&&s.push(new Ur(r,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&s.push(new Ur(r,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(o=Tr(i[1]),"string"!==o&&s.push(new Ur(`${r}[1]`,i[1],`string expected, ${o} found`)));for(let e=2;e<i.length;e++)o=Tr(i[e]),"$type"===Ze(i[1])?s=s.concat(Yr({key:`${r}[${e}]`,value:i[e],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==o&&"number"!==o&&"boolean"!==o&&s.push(new Ur(`${r}[${e}]`,i[e],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let e=1;e<i.length;e++)s=s.concat(cn({key:`${r}[${e}]`,value:i[e],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":o=Tr(i[1]),2!==i.length?s.push(new Ur(r,i,`filter array for "${i[0]}" operator must have 2 elements`)):"string"!==o&&s.push(new Ur(`${r}[1]`,i[1],`string expected, ${o} found`));break;case"within":o=Tr(i[1]),2!==i.length?s.push(new Ur(r,i,`filter array for "${i[0]}" operator must have 2 elements`)):"object"!==o&&s.push(new Ur(`${r}[1]`,i[1],`object expected, ${o} found`))}return s}function hn(e,t){const i=e.key,r=e.style,n=e.styleSpec,o=e.value,s=e.objectKey,a=n[`${t}_${e.layerType}`];if(!a)return[];const l=s.match(/^(.*)-transition$/);if("paint"===t&&l&&a[l[1]]&&a[l[1]].transition)return bn({key:i,value:o,valueSpec:n.transition,style:r,styleSpec:n});const c=e.valueSpec||a[s];if(!c)return[new Ur(i,o,`unknown property "${s}"`)];let h;if("string"===Tr(o)&&vr(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(o)))return[new Ur(i,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===e.layerType&&("text-field"===s&&r&&!r.glyphs&&u.push(new Ur(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===s&&Er(Ye(o))&&"identity"===Ze(o.type)&&u.push(new Ur(i,o,'"text-font" does not support identity functions'))),u.concat(bn({key:e.key,value:o,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:s}))}function un(e){return hn(e,"paint")}function pn(e){return hn(e,"layout")}function dn(t){let i=[];const r=t.value,n=t.key,o=t.style,s=t.styleSpec;r.type||r.ref||i.push(new Ur(n,r,'either "type" or "ref" is required'));let a=Ze(r.type);const l=Ze(r.ref);if(r.id){const s=Ze(r.id);for(let e=0;e<t.arrayIndex;e++){const t=o.layers[e];Ze(t.id)===s&&i.push(new Ur(n,r.id,`duplicate layer id "${r.id}", previously used at line ${t.id.__line__}`))}}if("ref"in r){let t;["type","source","source-layer","filter","layout"].forEach(e=>{e in r&&i.push(new Ur(n,r[e],`"${e}" is prohibited for ref layers`))}),o.layers.forEach(e=>{Ze(e.id)===l&&(t=e)}),t?t.ref?i.push(new Ur(n,r.ref,"ref cannot reference another ref layer")):a=Ze(t.type):"string"==typeof l&&i.push(new Ur(n,r.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a)if(r.source){const t=o.sources&&o.sources[r.source],s=t&&Ze(t.type);t?"vector"===s&&"raster"===a?i.push(new Ur(n,r.source,`layer "${r.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new Ur(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new Ur(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||"geojson"===s&&t.lineMetrics||i.push(new Ur(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):i.push(new Ur(n,r,`layer "${r.id}" must specify a "source-layer"`)):i.push(new Ur(n,r.source,`source "${r.source}" not found`))}else i.push(new Ur(n,r,'missing required property "source"'));return i=i.concat(jr({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>bn({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:e=>ln(qe({layerType:a},e)),layout:e=>jr({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>pn(qe({layerType:a},e))}}),paint:e=>jr({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>un(qe({layerType:a},e))}})}})),i}function fn(e){const t=e.value,i=e.key,r=Tr(t);return"string"!==r?[new Ur(i,t,`string expected, ${r} found`)]:[]}const mn={promoteId:function({key:e,value:t}){if("string"===Tr(t))return fn({key:e,value:t});{const i=[];for(const r in t)i.push(...fn({key:`${e}.${r}`,value:t[r]}));return i}}};function _n(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!t.type)return[new Ur(i,t,'"type" is required')];const o=Ze(t.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=jr({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:mn}),s;case"geojson":if(s=jr({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:mn}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;s.push(...qr({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),s.push(...qr({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return jr({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return jr({key:i,value:t,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new Ur(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Yr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function gn(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const s=Tr(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Ur("light",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?bn({key:e,value:t[e],valueSpec:i.transition,style:n,styleSpec:i}):r[e]?bn({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}):[new Ur(e,t[e],`unknown property "${e}"`)])}return o}function yn(e){const t=e.value,i=e.key,r=e.style,n=e.styleSpec,o=n.terrain;let s=[];const a=Tr(t);if(void 0===t)return s;if("object"!==a)return s=s.concat([new Ur("terrain",t,`object expected, ${a} found`)]),s;for(const e in t){const i=e.match(/^(.*)-transition$/);s=s.concat(i&&o[i[1]]&&o[i[1]].transition?bn({key:e,value:t[e],valueSpec:n.transition,style:r,styleSpec:n}):o[e]?bn({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:n}):[new Ur(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],n=e&&Ze(e.type);e?"raster-dem"!==n&&s.push(new Ur(i,t.source,`terrain cannot be used with a source of type ${String(n)}, it only be used with a "raster-dem" source type`)):s.push(new Ur(i,t.source,`source "${t.source}" not found`))}else s.push(new Ur(i,t,'terrain is missing required property "source"'));return s}function xn(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.fog;let o=[];const s=Tr(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Ur("fog",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?bn({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r}):n[e]?bn({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r}):[new Ur(e,t[e],`unknown property "${e}"`)])}return o}const vn={"*":()=>[],array:Vr,boolean:function(e){const t=e.value,i=e.key,r=Tr(t);return"boolean"!==r?[new Ur(i,t,`boolean expected, ${r} found`)]:[]},number:Gr,color:function(e){const t=e.key,i=e.value,r=Tr(i);return"string"!==r?[new Ur(t,i,`color expected, ${r} found`)]:null===mt.parseCSSColor(i)?[new Ur(t,i,`color expected, "${i}" found`)]:[]},enum:Yr,filter:ln,function:$r,layer:dn,object:jr,source:_n,light:gn,terrain:yn,fog:xn,string:fn,formatted:function(e){return 0===fn(e).length?[]:qr(e)},resolvedImage:function(e){return 0===fn(e).length?[]:qr(e)},projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style;let o=[];const s=Tr(t);if("object"===s)for(const e in t)o=o.concat(bn({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}));else"string"!==s&&(o=o.concat([new Ur("projection",t,`object or string expected, ${s} found`)]));return o}};function bn(e){const t=e.value,i=e.valueSpec,r=e.styleSpec;return i.expression&&Er(Ze(t))?$r(e):i.expression&&Pr(Ye(t))?qr(e):i.type&&vn[i.type]?vn[i.type](e):jr(qe({},e,{valueSpec:i.type?r[i.type]:i}))}function wn(e){const t=e.value,i=e.key,r=fn(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new Ur(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new Ur(i,t,'"glyphs" url must include a "{range}" token'))),r}function Tn(e,t=$e){return Sn(bn({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:wn,"*":()=>[]}}))}const En=e=>Sn(un(e)),An=e=>Sn(pn(e));function Sn(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Cn(e,t){let i=!1;if(t&&t.length)for(const r of t)e.fire(new Ve(new Error(r.message))),i=!0;return i}var Mn=In;function In(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(var o=0;o<this.d*this.d;o++){var s=n[3+o],a=n[3+o+1];r.push(s===a?null:n.subarray(s,a))}var l=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],l),this.bboxes=n.subarray(l),this.insert=this._insertReadonly}else{this.d=t+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;var h=i/t*e;this.min=-h,this.max=e+h}In.prototype.insert=function(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},In.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},In.prototype._insertCell=function(e,t,i,r,n,o){this.cells[n].push(o)},In.prototype.query=function(e,t,i,r,n){var o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(e,t,i,r,this._queryCell,a,{},n),a},In.prototype._queryCell=function(e,t,i,r,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,h=this.bboxes,u=0;u<l.length;u++){var p=l[u];if(void 0===s[p]){var d=4*p;(a?a(h[d+0],h[d+1],h[d+2],h[d+3]):e<=h[d+2]&&t<=h[d+3]&&i>=h[d+0]&&r>=h[d+1])?(s[p]=!0,o.push(c[p])):s[p]=!1}}},In.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),p=l;p<=h;p++)for(var d=c;d<=u;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},In.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},In.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},In.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(t+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=t,s=0;s<e.length;s++){var a=e[s];n[3+s]=o,n.set(a,o),o+=a.length}return n[3+e.length]=o,n.set(this.keys,o),n[3+e.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};const Bn={};function kn(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Bn[t]={klass:e,omit:i.omit||[]}}kn(Object,"Object"),Mn.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}},Mn.deserialize=function(e){return new Mn(e.buffer)},Object.defineProperty(Mn,"name",{value:"Grid"}),kn(Mn,"Grid"),kn(gt,"Color"),kn(Error,"Error"),kn(Me,"AJAXError"),kn(bt,"ResolvedImage"),kn(Fr,"StylePropertyFunction"),kn(zr,"StyleExpression",{omit:["_evaluator"]}),kn(Rr,"ZoomDependentExpression"),kn(Dr,"ZoomConstantExpression"),kn(Ut,"CompoundExpression",{omit:["_evaluate"]});for(const l in gr)Bn[gr[l]._classRegistryKey]||kn(gr[l],`Expression${l}`);function zn(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function Pn(e){return p.ImageBitmap&&e instanceof p.ImageBitmap}function Ln(e,t){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(zn(e)||Pn(e))return t&&t.push(e),e;if(ArrayBuffer.isView(e)){const p=e;return t&&t.push(p.buffer),p}if(e instanceof p.ImageData)return t&&t.push(e.data.buffer),e;if(Array.isArray(e)){const p=[];for(const i of e)p.push(Ln(i,t));return p}if("object"==typeof e){const p=e.constructor,r=p._classRegistryKey;if(!r)throw new Error(`can't serialize object of unregistered class ${r}`);const n=p.serialize?p.serialize(e,t):{};if(!p.serialize){for(const p in e)e.hasOwnProperty(p)&&(Bn[r].omit.indexOf(p)>=0||(n[p]=Ln(e[p],t)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function Dn(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||zn(e)||Pn(e)||ArrayBuffer.isView(e)||e instanceof p.ImageData)return e;if(Array.isArray(e))return e.map(Dn);if("object"==typeof e){const p=e.$name||"Object",{klass:t}=Bn[p];if(!t)throw new Error(`can't deserialize unregistered class ${p}`);if(t.deserialize)return t.deserialize(e);const i=Object.create(t.prototype);for(const p of Object.keys(e))"$name"!==p&&(i[p]=Dn(e[p]));return i}throw new Error("can't deserialize object of type "+typeof e)}class Rn{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}}const On=e=>e>=1536&&e<=1791,Fn=e=>e>=1872&&e<=1919,Nn=e=>e>=2208&&e<=2303,Un=e=>e>=11904&&e<=12031,jn=e=>e>=12032&&e<=12255,Vn=e=>e>=12272&&e<=12287,Gn=e=>e>=12288&&e<=12351,$n=e=>e>=12352&&e<=12447,qn=e=>e>=12448&&e<=12543,Zn=e=>e>=12544&&e<=12591,Yn=e=>e>=12704&&e<=12735,Wn=e=>e>=12736&&e<=12783,Xn=e=>e>=12784&&e<=12799,Hn=e=>e>=12800&&e<=13055,Kn=e=>e>=13056&&e<=13311,Jn=e=>e>=13312&&e<=19903,Qn=e=>e>=19968&&e<=40959,eo=e=>e>=40960&&e<=42127,to=e=>e>=42128&&e<=42191,io=e=>e>=44032&&e<=55215,ro=e=>e>=63744&&e<=64255,no=e=>e>=64336&&e<=65023,oo=e=>e>=65040&&e<=65055,so=e=>e>=65072&&e<=65103,ao=e=>e>=65104&&e<=65135,lo=e=>e>=65136&&e<=65279,co=e=>e>=65280&&e<=65519;function ho(e){for(const t of e)if(fo(t.charCodeAt(0)))return!0;return!1}function uo(e){for(const t of e)if(!po(t.charCodeAt(0)))return!1;return!0}function po(e){return!(On(e)||Fn(e)||Nn(e)||no(e)||lo(e))}function fo(e){return!(746!==e&&747!==e&&(e<4352||!(Yn(e)||Zn(e)||so(e)&&!(e>=65097&&e<=65103)||ro(e)||Kn(e)||Un(e)||Wn(e)||!(!Gn(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Jn(e)||Qn(e)||Hn(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||io(e)||$n(e)||Vn(e)||(e=>e>=12688&&e<=12703)(e)||jn(e)||Xn(e)||qn(e)&&12540!==e||!(!co(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!ao(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||oo(e)||(e=>e>=19904&&e<=19967)(e)||eo(e)||to(e))))}function mo(e){return!(fo(e)||function(e){return!!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Gn(e)||qn(e)||(e=>e>=57344&&e<=63743)(e)||so(e)||ao(e)||co(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function _o(e){return e>=1424&&e<=2303||no(e)||lo(e)}function go(e,t){return!(!t&&_o(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function yo(e){for(const t of e)if(_o(t.charCodeAt(0)))return!0;return!1}const xo="deferred",vo="loading",bo="loaded";let wo=null,To="unavailable",Eo=null;const Ao=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(To="error"),wo&&wo(e)};function So(){Co.fire(new je("pluginStateChange",{pluginStatus:To,pluginURL:Eo}))}const Co=new Ge,Mo=function(){return To},Io=function(){if(To!==xo||!Eo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");To=vo,So(),Eo&&ke({url:Eo},e=>{e?Ao(e):(To=bo,So())})},Bo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>To===bo||null!=Bo.applyArabicShaping,isLoading:()=>To===vo,setState(e){To=e.pluginStatus,Eo=e.pluginURL},isParsed:()=>null!=Bo.applyArabicShaping&&null!=Bo.processBidirectionalText&&null!=Bo.processStyledBidirectionalText,getPluginURL:()=>Eo};class ko{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.zoomHistory=t.zoomHistory,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Rn,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!go(i.charCodeAt(0),t))return!1;return!0}(e,Bo.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}class zo{constructor(e,t){this.property=e,this.value=t,this.expression=function(t,i){if(Er(t))return new Fr(t,i);if(Pr(t)){const e=Or(t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));return e.value}{let e=t;return"string"==typeof t&&"color"===i.type&&(e=gt.parse(t)),{kind:"constant",evaluate:()=>e}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Po{constructor(e){this.property=e,this.value=new zo(e,void 0)}transitioned(e,t){return new Do(this.property,this.value,t,b({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class Lo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return A(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Po(this._values[e].property)),this._values[e].value=new zo(this._values[e].property,null===t?void 0:A(t))}getTransition(e){return A(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Po(this._values[e].property)),this._values[e].transition=A(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Ro(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Ro(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Do{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,a(s))}}return n}}class Ro{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new No(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Oo{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return A(this._values[e].value)}setValue(e,t){this._values[e]=new zo(this._values[e].property,null===t?void 0:A(t))}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const r=new No(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class Fo{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}}class No{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Uo{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const r=yi[this.specification.type];return r?r(e,t,i):e}}class jo{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r){return new Fo(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)}:e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new Fo(this,{kind:"constant",value:void 0},e.parameters);const r=yi[this.specification.type];return r?new Fo(this,{kind:"constant",value:r(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,r,n,o){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,o)}}class Vo extends jo{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new Fo(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r),o="resolvedImage"===e.property.specification.type&&"string"!=typeof n?n.name:n,s=this._calculate(o,o,o,t);return new Fo(this,{kind:"constant",value:s},t)}if("camera"===e.expression.kind){const i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Fo(this,{kind:"constant",value:i},t)}return new Fo(this,e.expression,t)}evaluate(e,t,i,r,n,o){if("source"===e.kind){const s=e.evaluate(t,i,r,n,o);return this._calculate(s,s,s,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t,other:i}:{from:i,to:t,other:e}}interpolate(e){return e}}class Go{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new ko(Math.floor(t.zoom-1),t)),e.expression.evaluate(new ko(Math.floor(t.zoom),t)),e.expression.evaluate(new ko(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class $o{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class qo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new ko(0,{});for(const i in e){const r=e[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new zo(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new Po(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(t)}}}function Zo(e,t){return 256*(e=C(Math.floor(e),0,255))+C(Math.floor(t),0,255)}kn(jo,"DataDrivenProperty"),kn(Uo,"DataConstantProperty"),kn(Vo,"CrossFadedDataDrivenProperty"),kn(Go,"CrossFadedProperty"),kn($o,"ColorRampProperty");const Yo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Wo{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ho(e,n=1){let o=0,s=0;return{members:e.map(e=>{const t=Yo[e.type].BYTES_PER_ELEMENT,i=o=Ko(o,Math.max(n,t)),r=e.components||1;return s=Math.max(s,t),o+=t*r,{name:e.name,type:e.type,components:r,offset:i}}),size:Ko(o,Math.max(s,n)),alignment:n}}function Ko(e,t){return Math.ceil(e/t)*t}class Jo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}Jo.prototype.bytesPerElement=4,kn(Jo,"StructArrayLayout2i4");class Qo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}Qo.prototype.bytesPerElement=6,kn(Qo,"StructArrayLayout3i6");class es extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}es.prototype.bytesPerElement=8,kn(es,"StructArrayLayout4i8");class ts extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,h=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,e}}ts.prototype.bytesPerElement=12,kn(ts,"StructArrayLayout2i4ub1f12");class is extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}is.prototype.bytesPerElement=16,kn(is,"StructArrayLayout4f16");class rs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,n,o,s,a,l,c)}emplace(e,t,i,r,n,o,s,a,l,c,h){const u=10*e;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=o,this.uint16[u+5]=s,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,e}}rs.prototype.bytesPerElement=20,kn(rs,"StructArrayLayout10ui20");class ns extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,n,o,s,a)}emplace(e,t,i,r,n,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}ns.prototype.bytesPerElement=16,kn(ns,"StructArrayLayout8ui16");class os extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,kn(os,"StructArrayLayout6i12");class ss extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,h,u)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=n,this.uint16[d+4]=o,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=h,this.int16[d+10]=u,this.int16[d+11]=p,e}}ss.prototype.bytesPerElement=24,kn(ss,"StructArrayLayout4i4ui4i24");class as extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}as.prototype.bytesPerElement=20,kn(as,"StructArrayLayout3i3f20");class ls extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}ls.prototype.bytesPerElement=4,kn(ls,"StructArrayLayout1ul4");class cs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,h,u,p)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=p,this.uint16[f+19]=d,e}}cs.prototype.bytesPerElement=40,kn(cs,"StructArrayLayout5i4f1i1ul2ui40");class hs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}hs.prototype.bytesPerElement=16,kn(hs,"StructArrayLayout3i2i2i16");class us extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}us.prototype.bytesPerElement=16,kn(us,"StructArrayLayout2f1f2i16");class ps extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,e}}ps.prototype.bytesPerElement=12,kn(ps,"StructArrayLayout2ub2f12");class ds extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}ds.prototype.bytesPerElement=12,kn(ds,"StructArrayLayout3f12");class fs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}fs.prototype.bytesPerElement=6,kn(fs,"StructArrayLayout3ui6");class ms extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}ms.prototype.bytesPerElement=60,kn(ms,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class _s extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,A,S,C,M,I){const B=this.length;return this.resize(B+1),this.emplace(B,e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,A,S,C,M,I)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,A,S,C,M,I,B){const k=38*e,z=19*e;return this.int16[k+0]=t,this.int16[k+1]=i,this.int16[k+2]=r,this.float32[z+2]=n,this.float32[z+3]=o,this.int16[k+8]=s,this.int16[k+9]=a,this.int16[k+10]=l,this.int16[k+11]=c,this.int16[k+12]=h,this.int16[k+13]=u,this.uint16[k+14]=p,this.uint16[k+15]=d,this.uint16[k+16]=f,this.uint16[k+17]=m,this.uint16[k+18]=_,this.uint16[k+19]=g,this.uint16[k+20]=y,this.uint16[k+21]=x,this.uint16[k+22]=v,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=A,this.uint16[k+28]=S,this.uint32[z+15]=C,this.float32[z+16]=M,this.float32[z+17]=I,this.float32[z+18]=B,e}}_s.prototype.bytesPerElement=76,kn(_s,"StructArrayLayout3i2f6i15ui1ul3f76");class gs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}gs.prototype.bytesPerElement=4,kn(gs,"StructArrayLayout1f4");class ys extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}ys.prototype.bytesPerElement=28,kn(ys,"StructArrayLayout7f28");class xs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}xs.prototype.bytesPerElement=20,kn(xs,"StructArrayLayout5f20");class vs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}vs.prototype.bytesPerElement=12,kn(vs,"StructArrayLayout1ul3ui12");class bs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}bs.prototype.bytesPerElement=4,kn(bs,"StructArrayLayout2ui4");class ws extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}ws.prototype.bytesPerElement=2,kn(ws,"StructArrayLayout1ui2");class Ts extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}Ts.prototype.bytesPerElement=8,kn(Ts,"StructArrayLayout2f8");class Es extends Wo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Es.prototype.size=12;class As extends os{get(e){return new Es(this,e)}}kn(As,"FillExtrusionExtArray");class Ss extends Wo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Ss.prototype.size=40;class Cs extends cs{get(e){return new Ss(this,e)}}kn(Cs,"CollisionBoxArray");class Ms extends Wo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}Ms.prototype.size=60;class Is extends ms{get(e){return new Ms(this,e)}}kn(Is,"PlacedSymbolArray");class Bs extends Wo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}Bs.prototype.size=76;class ks extends _s{get(e){return new Bs(this,e)}}kn(ks,"SymbolInstanceArray");class zs extends gs{getoffsetX(e){return this.float32[1*e+0]}}kn(zs,"GlyphOffsetArray");class Ps extends Qo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}kn(Ps,"SymbolLineVertexArray");class Ls extends Wo{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Ls.prototype.size=12;class Ds extends vs{get(e){return new Ls(this,e)}}kn(Ds,"FeatureIndexArray");class Rs extends Wo{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Rs.prototype.size=4;class Os extends bs{get(e){return new Rs(this,e)}}kn(Os,"FillExtrusionCentroidArray");class Fs extends Wo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Fs.prototype.size=12;class Ns extends os{get(e){return new Fs(this,e)}}kn(Ns,"CircleGlobeExtArray");const Us=Ho([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),js=Ho([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Vs=ft(function(e){e.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}}),Gs=ft(function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}}),$s=Vs,qs=Gs;$s.murmur3=Vs,$s.murmur2=qs;class Zs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(Ys(e)),this.positions.push(t,i,r)}getPositions(e){const t=Ys(e);let i=0,r=this.ids.length-1;for(;i<r;){const e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}const n=[];for(;this.ids[i]===t;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Ws(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){const t=new Zs;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function Ys(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:$s(String(e))}function Ws(i,r,n,o){for(;n<o;){const s=i[n+o>>1];let e=n-1,t=o+1;for(;;){do{e++}while(i[e]<s);do{t--}while(i[t]>s);if(e>=t)break;Xs(i,e,t),Xs(r,3*e,3*t),Xs(r,3*e+1,3*t+1),Xs(r,3*e+2,3*t+2)}t-n<o-t?(Ws(i,r,n,t),n=t+1):(Ws(i,r,t+1,o),o=t)}}function Xs(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}kn(Zs,"FeaturePositionMap");class Hs{constructor(e,t){this.gl=e.gl,this.location=t}}class Ks extends Hs{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Js extends Hs{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class Qs extends Hs{constructor(e,t){super(e,t),this.current=gt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const ea=new Float32Array(16),ta=new Float32Array(9),ia=new Float32Array(4);function ra(e){return[Zo(255*e.r,255*e.g),Zo(255*e.b,255*e.a)]}class na{constructor(e,t,i){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new Qs(e,t):new Ks(e,t)}}class oa{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio||1,this.pixelRatioTo=e.pixelRatio||1,this.patternFrom=t.tl.concat(t.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,t,i,r){const n="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&e.set(n)}getBinding(e,t,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Js(e,t):new Ks(e,t)}}class sa{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new ko(0),t,{},n,r,o);this.paintVertexArray.resize(e),this._setPaintValue(s,e,a)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:0},i,r,void 0,n);this._setPaintValue(e,t,o)}_setPaintValue(t,i,r){if("color"===this.type){const n=ra(r);for(let e=t;e<i;e++)this.paintVertexArray.emplace(e,n[0],n[1])}else{for(let e=t;e<i;e++)this.paintVertexArray.emplace(e,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class aa{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o){const s=this.expression.evaluate(new ko(this.zoom),t,{},n,r,o),a=this.expression.evaluate(new ko(this.zoom+1),t,{},n,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,s,a)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:this.zoom},i,r,void 0,n),s=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,n);this._setPaintValue(e,t,o,s)}_setPaintValue(t,i,r,n){if("color"===this.type){const o=ra(r),s=ra(n);for(let e=t;e<i;e++)this.paintVertexArray.emplace(e,o[0],o[1],s[0],s[1])}else{for(let e=t;e<i;e++)this.paintVertexArray.emplace(e,r,n);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(n))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){const i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=C(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new Ks(e,t)}}class la{constructor(e,t,i,r,n,o,s){this.expression=e,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=s,this.paintVertexAttributes=("array"===i?js:Us).members;for(let e=0;e<t.length;++e);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(e,t,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,r,n,o){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(t,i,e,r){if(!r||!e)return;const{min:n,mid:o,max:s}=e,a=r[n],l=r[o],c=r[s];if(a&&l&&c)for(let e=t;e<i;e++)this._setPaintValue(this.zoomInPaintVertexArray,e,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,e,l,c)}_setPaintValue(e,t,i,r){e.emplace(t,i.tl[0],i.tl[1],i.br[0],i.br[1],r.tl[0],r.tl[1],r.br[0],r.br[1],i.pixelRatio,r.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ca{constructor(e,t,i=()=>!0){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){if(!i(n))continue;const o=e.paint.get(n);if(!(o instanceof Fo&&vr(o.property.specification)))continue;const s=pa(n,e.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,h=o.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h,p="line-dasharray"===String(n)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||u){const i=ma(n,l,"source");this.binders[n]=u?new la(a,s,l,c,t,i,e.id):new sa(a,s,l,i),r.push(`/a_${n}`)}else{const e=ma(n,l,"composite");this.binders[n]=new aa(a,s,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=u?new oa(a.value,s):new na(a.value,s,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof sa||t instanceof aa?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o){for(const s in this.binders){const a=this.binders[s];(a instanceof sa||a instanceof aa||a instanceof la)&&a.populatePaintArray(e,t,i,r,n,o)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof oa&&r.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,i,r,n,o){let s=!1;for(const a in e){const l=t.getPositions(a);for(const t of l){const c=i.feature(t.index);for(const i in this.binders){const h=this.binders[i];if((h instanceof sa||h instanceof aa||h instanceof la)&&!0===h.expression.isStateDependent){const u=r.paint.get(i);h.expression=u.value,h.updatePaintArray(t.start,t.end,c,e[a],n,o),s=!0}}}}return s}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof na||i instanceof oa)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof sa||i instanceof aa||i instanceof la)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name)}return t}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof na||i instanceof oa||i instanceof aa)for(const r of i.uniformNames)e.push(r)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof na||n instanceof oa||n instanceof aa)for(const o of n.uniformNames)if(t[o]){const s=n.getBinding(e,t[o],o);i.push({name:o,property:r,binding:s})}}return i}setUniforms(e,t,i,r){for(const{name:e,property:n,binding:o}of t)this.binders[n].setUniform(o,r,i.get(n),e)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof la){const r=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;r&&this._buffers.push(r)}else(i instanceof sa||i instanceof aa)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof sa||i instanceof aa||i instanceof la)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof sa||t instanceof aa||t instanceof la)&&t.destroy()}}}class ha{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new ca(r,t,i);this.needsUpload=!1,this._featureMap=new Zs,this._bufferOffset=0}populatePaintArrays(e,t,i,r,n,o,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,n)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const ua={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function pa(e,t){return ua[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const da={"line-pattern":{source:rs,composite:rs},"fill-pattern":{source:rs,composite:rs},"fill-extrusion-pattern":{source:rs,composite:rs},"line-dasharray":{source:ns,composite:ns}},fa={color:{source:Ts,composite:is},number:{source:gs,composite:Ts}};function ma(e,t,i){const r=da[e];return r&&r[i]||fa[t][i]}kn(na,"ConstantBinder"),kn(oa,"CrossFadedConstantBinder"),kn(sa,"SourceExpressionBinder"),kn(la,"CrossFadedCompositeBinder"),kn(aa,"CompositeExpressionBinder"),kn(ca,"ProgramConfiguration",{omit:["_buffers"]}),kn(ha,"ProgramConfigurationSet");const _a="-transition";class ga extends Ge{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=(e=e).metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Oo(t.layout)),t.paint)){this._transitionablePaint=new Lo(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new No(t.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,i={}){null!=t&&this._validate(An,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return w(e,_a)?this._transitionablePaint.getTransition(e.slice(0,-_a.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(En,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(w(e,_a))return this._transitionablePaint.setTransition(e.slice(0,-_a.length),t||void 0),!1;{const i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),E(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&Cn(this,e.call(Tn,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:$e,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Fo&&vr(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Xr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ya=Ho([{name:"a_pos",components:2,type:"Int16"}],4),xa=Ho([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class va{constructor(e=[]){this.segments=e}prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>va.MAX_VERTEX_ARRAY_LENGTH&&Y(`Max vertices per segment is ${va.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>va.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new va([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}va.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,kn(va,"SegmentVector");var ba=8192;class wa{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof Ea?new Ea(e.lng,e.lat):Ea.convert(e),this}setSouthWest(e){return this._sw=e instanceof Ea?new Ea(e.lng,e.lat):Ea.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof Ea)r=e,n=e;else{if(!(e instanceof wa))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(wa.convert(e)):this.extend(Ea.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Ea(r.lng,r.lat),this._ne=new Ea(n.lng,n.lat)),this}getCenter(){return new Ea((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Ea(this.getWest(),this.getNorth())}getSouthEast(){return new Ea(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=Ea.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){return!e||e instanceof wa?e:new wa(e)}}const Ta=6371008.8;class Ea{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ea(d(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return Ta*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new wa(new Ea(this.lng-i,this.lat-t),new Ea(this.lng+i,this.lat+t))}static convert(e){if(e instanceof Ea)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Ea(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Ea(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Aa=2*Math.PI*Ta;function Sa(e){return Aa*Math.cos(e*Math.PI/180)}function Ca(e){return(180+e)/360}function Ma(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ia(e,t){return e/Sa(t)}function Ba(e){return 360*e-180}function ka(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function za(e,t){return e*Sa(ka(t))}const Pa=85.051129;class La{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=Ea.convert(e);return new La(Ca(i.lng),Ma(i.lat),Ia(t,i.lat))}toLngLat(){return new Ea(Ba(this.x),ka(this.y))}toAltitude(){return za(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Aa*(e=ka(this.y),1/Math.cos(e*Math.PI/180));var e}}function Da(e,t,i,r,n,o,s,a,l){const c=(t+r)/2,h=(i+n)/2,u=new F(c,h);a(u),function(e,t,i,r,n,o){const s=i-n,a=r-o;return Math.abs((r-t)*s-(i-e)*a)/Math.hypot(s,a)}(u.x,u.y,o.x,o.y,s.x,s.y)>=l?(Da(e,t,i,c,h,o,u,a,l),Da(e,c,h,r,n,u,s,a,l)):e.push(s)}function Ra(t,i,r){let n=t[0],o=n.x,s=n.y;i(n);const a=[n];for(let e=1;e<t.length;e++){const l=t[e],{x:c,y:h}=l;i(l),Da(a,o,s,c,h,n,l,i,r),o=c,s=h,n=l}return a}function Oa(e,t,i,r,n){if(n(t,i)){const o=t.add(i).mult(.5);r(o),Oa(e,t,o,r,n),Oa(e,o,i,r,n)}else e.push(i)}function Fa(t,i,r){let n=t[0];i(n);const o=[n];for(let e=1;e<t.length;e++){const s=t[e];i(s),Oa(o,n,s,i,r),n=s}return o}const Na=Math.pow(2,14)-1,Ua=-Na-1;function ja(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=C(i,Ua,Na),e.y=C(r,Ua,Na),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&Y("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Va(t,n,i){const r=t.loadGeometry(),o=t.extent,s=ba/o;if(n&&i&&i.projection.isReprojectedInTileSpace){const s=1<<n.z,{scale:a,x:l,y:c,projection:h}=i,u=e=>{const t=Ba((n.x+e.x/o)/s),i=ka((n.y+e.y/o)/s),r=h.project(t,i);e.x=(r.x*a-l)*o,e.y=(r.y*a-c)*o};for(let e=0;e<r.length;e++)if(1!==t.type)r[e]=Ra(r[e],u,1);else{const t=[];for(const i of r[e])i.x<0||i.x>=o||i.y<0||i.y>=o||(u(i),t.push(i));r[e]=t}}for(const t of r)for(const n of t)ja(n,s);return r}function Ga(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Va(e):[]}}function $a(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}function qa(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class Za{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Jo,this.indexArray=new fs,this.segments=new va,this.programConfigurations=new ha(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ga(t,e);if(!this.layers[0]._featureFilter.filter(new ko(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,i,r),patterns:{},sortKey:h};o.push(u)}s&&o.sort((e,t)=>e.sortKey-t.sortKey);let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Ns,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,p=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a),t.featureIndex.insert(p,n,o,s,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ya.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,xa.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,i,r,n,o){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=ba||r<0||r>=ba)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),l=this.globeExtVertexArray;qa(l,e,t),qa(l,e,t),qa(l,e,t),qa(l,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;$a(this.layoutVertexArray,i,r,-1,-1),$a(this.layoutVertexArray,i,r,1,-1),$a(this.layoutVertexArray,i,r,1,1),$a(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n)}}function Ya(t,i){for(let e=0;e<t.length;e++)if(il(i,t[e]))return!0;for(let e=0;e<i.length;e++)if(il(t,i[e]))return!0;return!!Ka(t,i)}function Wa(e,t,i){return!!il(e,t)||!!Qa(t,e,i)}function Xa(t,i){if(1===t.length)return tl(i,t[0]);for(let e=0;e<i.length;e++){const r=i[e];for(let e=0;e<r.length;e++)if(il(t,r[e]))return!0}for(let e=0;e<t.length;e++)if(tl(i,t[e]))return!0;for(let e=0;e<i.length;e++)if(Ka(t,i[e]))return!0;return!1}function Ha(t,i,r){if(t.length>1){if(Ka(t,i))return!0;for(let e=0;e<i.length;e++)if(Qa(i[e],t,r))return!0}for(let e=0;e<t.length;e++)if(Qa(t[e],i,r))return!0;return!1}function Ka(t,i){if(0===t.length||0===i.length)return!1;for(let e=0;e<t.length-1;e++){const r=t[e],n=t[e+1];for(let e=0;e<i.length-1;e++)if(Ja(r,n,i[e],i[e+1]))return!0}return!1}function Ja(e,t,i,r){return I(e,i,r)!==I(t,i,r)&&I(e,t,i)!==I(e,t,r)}function Qa(t,i,e){const r=e*e;if(1===i.length)return t.distSqr(i[0])<r;for(let e=1;e<i.length;e++)if(el(t,i[e-1],i[e])<r)return!0;return!1}function el(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function tl(t,i){let r,n,o,s=!1;for(let e=0;e<t.length;e++){r=t[e];for(let e=0,t=r.length-1;e<r.length;t=e++)n=r[e],o=r[t],n.y>i.y!=o.y>i.y&&i.x<(o.x-n.x)*(i.y-n.y)/(o.y-n.y)+n.x&&(s=!s)}return s}function il(i,r){let n=!1;for(let e=0,t=i.length-1;e<i.length;t=e++){const o=i[e],s=i[t];o.y>r.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(n=!n)}return n}function rl(t,e,i,r,n){for(const F of t)if(e<=F.x&&i<=F.y&&r>=F.x&&n>=F.y)return!0;const o=[new F(e,i),new F(e,n),new F(r,n),new F(r,i)];if(t.length>2)for(const e of o)if(il(t,e))return!0;for(let e=0;e<t.length-1;e++)if(nl(t[e],t[e+1],o))return!0;return!1}function nl(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const o=I(e,t,i[0]);return o!==I(e,t,i[1])||o!==I(e,t,i[2])||o!==I(e,t,i[3])}function ol(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function sl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function al(t,e,i,r,n){if(!e[0]&&!e[1])return t;const o=F.convert(e)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let e=0;e<t.length;e++)s.push(t[e].sub(o));return s}function ll(e,t,i,r){const n=F.convert(e)._mult(r);return"viewport"===t&&n._rotate(-i),n}kn(Za,"CircleBucket",{omit:["layers"]});const cl=new qo({"circle-sort-key":new jo($e.layout_circle["circle-sort-key"])});var hl={paint:new qo({"circle-radius":new jo($e.paint_circle["circle-radius"]),"circle-color":new jo($e.paint_circle["circle-color"]),"circle-blur":new jo($e.paint_circle["circle-blur"]),"circle-opacity":new jo($e.paint_circle["circle-opacity"]),"circle-translate":new Uo($e.paint_circle["circle-translate"]),"circle-translate-anchor":new Uo($e.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Uo($e.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Uo($e.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new jo($e.paint_circle["circle-stroke-width"]),"circle-stroke-color":new jo($e.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new jo($e.paint_circle["circle-stroke-opacity"])}),layout:cl},ul=1e-6,pl="undefined"!=typeof Float32Array?Float32Array:Array;function dl(){var e=new pl(9);return pl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function fl(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}function ml(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],p=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*u+w*m,e[1]=x*n+v*l+b*p+w*_,e[2]=x*o+v*c+b*d+w*g,e[3]=x*s+v*h+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,e[5]=x*n+v*l+b*p+w*_,e[6]=x*o+v*c+b*d+w*g,e[7]=x*s+v*h+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,e[9]=x*n+v*l+b*p+w*_,e[10]=x*o+v*c+b*d+w*g,e[11]=x*s+v*h+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,e[13]=x*n+v*l+b*p+w*_,e[14]=x*o+v*c+b*d+w*g,e[15]=x*s+v*h+b*f+w*y,e}function _l(e,t,i){var r,n,o,s,a,l,c,h,u,p,d,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],p=t[9],d=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=h,e[8]=u,e[9]=p,e[10]=d,e[11]=f,e[12]=r*m+a*_+u*g+t[12],e[13]=n*m+l*_+p*g+t[13],e[14]=o*m+c*_+d*g+t[14],e[15]=s*m+h*_+f*g+t[15]),e}function gl(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,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}function yl(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],h=t[9],u=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*n+c*r,e[5]=s*n+h*r,e[6]=a*n+u*r,e[7]=l*n+p*r,e[8]=c*n-o*r,e[9]=h*n-s*r,e[10]=u*n-a*r,e[11]=p*n-l*r,e}function xl(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],h=t[9],u=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-c*r,e[1]=s*n-h*r,e[2]=a*n-u*r,e[3]=l*n-p*r,e[8]=o*r+c*n,e[9]=s*r+h*n,e[10]=a*r+u*n,e[11]=l*r+p*n,e}function vl(e,t,i){var r,n,o,s=i[0],a=i[1],l=i[2],c=Math.hypot(s,a,l);return c<ul?null:(s*=c=1/c,a*=c,l*=c,r=Math.sin(t),n=Math.cos(t),e[0]=s*s*(o=1-n)+n,e[1]=a*s*o+l*r,e[2]=l*s*o-a*r,e[3]=0,e[4]=s*a*o-l*r,e[5]=a*a*o+n,e[6]=l*a*o+s*r,e[7]=0,e[8]=s*l*o+a*r,e[9]=a*l*o-s*r,e[10]=l*l*o+n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var bl=ml;function wl(){var e=new pl(3);return pl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Tl(e){var t=new pl(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function El(e){return Math.hypot(e[0],e[1],e[2])}function Al(e,t,i){var r=new pl(3);return r[0]=e,r[1]=t,r[2]=i,r}function Sl(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function Cl(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function Ml(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function Il(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e}function Bl(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function kl(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function zl(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function Pl(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Ll(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Dl(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e}function Rl(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e}function Ol(e,t,i){var r=i[0],n=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=n*l-o*a,h=o*s-r*l,u=r*a-n*s,p=n*u-o*h,d=o*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,d*=2,f*=2,e[0]=s+(c*=m)+(p*=2),e[1]=a+h+d,e[2]=l+u+f,e}var Fl,Nl=Cl,Ul=Ml,jl=El;function Vl(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function Gl(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e}function $l(){var e=new pl(4);return pl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ql(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Zl(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e}function Yl(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e}wl(),Fl=new pl(4),pl!=Float32Array&&(Fl[0]=0,Fl[1]=0,Fl[2]=0,Fl[3]=0),wl(),Al(1,0,0),Al(0,1,0),$l(),$l(),dl();class Wl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const r=Ll(t,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,t,i){if(function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(i-o)<=ul*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=ul*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=ul*Math.max(1,Math.abs(n),Math.abs(a))}(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[r,n,o]=this.dir,s=this.pos[0]-e[0],a=this.pos[1]-e[1],l=this.pos[2]-e[2],c=r*r+n*n+o*o,h=2*(s*r+a*n+l*o),u=h*h-4*c*(s*s+a*a+l*l-t*t);if(u<0){const e=Math.max(-h/2,0),c=s+r*e,u=a+n*e,p=l+o*e,d=Math.hypot(c,u,p);return i[0]=c*t/d,i[1]=u*t/d,i[2]=p*t/d,!1}{const e=(-h-Math.sqrt(u))/(2*c);if(e<0){const e=Math.hypot(s,a,l);return i[0]=s*t/e,i[1]=a*t/e,i[2]=l*t/e,!1}return i[0]=s+r*e,i[1]=a+n*e,i[2]=l+o*e,!0}}}class Xl{constructor(e,t,i,r,n){this.TL=e,this.TR=t,this.BR=i,this.BL=r,this.horizon=n}static fromInvProjectionMatrix(e,t,i){const r=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Rl(r,r,e),l=Rl(n,n,e),c=Rl(o,o,e),h=Rl(s,s,e);return new Xl(a,l,c,h,t/i)}}class Hl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(r,n,e,o){const s=Math.pow(2,e),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(e=>{const t=Gl([],e,r),i=1/t[3]/n*s;return function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}(t,t,[i,i,o?1/t[3]:i,i])}),t=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=Pl([],Dl([],Nl([],a[e[0]],a[e[1]]),Nl([],a[e[2]],a[e[1]]))),i=-Ll(t,a[e[1]]);return t.concat(i)});return new Hl(a,t)}}class Kl{constructor(e,t){this.min=e,this.max=t,this.center=kl([],Sl([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=Tl(this.min),r=Tl(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new Kl(i,r)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(n){const i=this.getCorners();let r=!0;for(let e=0;e<n.planes.length;e++){const o=n.planes[e];let t=0;for(let e=0;e<i.length;e++)t+=Ll(o,i[e])+o[3]>=0;if(0===t)return 0;t!==i.length&&(r=!1)}if(r)return 2;for(let r=0;r<3;r++){let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let e=0;e<n.points.length;e++){const s=n.points[e][r]-this.min[r];t=Math.min(t,s),i=Math.max(i,s)}if(i<0||t>this.max[r]-this.min[r])return 0}return 1}}function Jl(e,t,i,r,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of t)for(const t of u){const p=t.add(a),d=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(p.x,p.y,!0):0,f=i.projection.projectTilePoint(p.x,p.y,c);if(d>0){const e=i.projection.upVector(c,p.x,p.y);f.x+=e[0]*h*d,f.y+=e[1]*h*d,f.z+=e[2]*h*d}const m=o?p:Ql(f.x,f.y,f.z,r),_=o?e.tilespaceRays.map(e=>ic(e,d)):e.queryGeometry.screenGeometry,g=Gl([],[f.x,f.y,f.z,1],r);if(!s&&o?l*=g[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/g[3]),o){const e=ka((t.y/ba+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/Ia(1,e)}if(Wa(_,m,l))return!0}return!1}function Ql(e,t,i,r){const n=Gl([],[e,t,i,1],r);return new F(n[0]/n[3],n[1]/n[3])}const ec=Al(0,0,0),tc=Al(0,0,1);function ic(e,t){const i=wl();return ec[2]=t,e.intersectsPlane(ec,tc,i),new F(i[0],i[1])}class rc extends Za{}function nc(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function oc(e,t,i){const{width:r,height:n}=t;r===e.width&&n===e.height||(sc(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,n)},i),e.width=r,e.height=n,e.data=t.data)}function sc(t,i,r,n,o,s){if(0===o.width||0===o.height)return i;if(o.width>t.width||o.height>t.height||r.x>t.width-o.width||r.y>t.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>i.width||o.height>i.height||n.x>i.width-o.width||n.y>i.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,l=i.data;for(let e=0;e<o.height;e++){const c=((r.y+e)*t.width+r.x)*s,h=((n.y+e)*i.width+n.x)*s;for(let e=0;e<o.width*s;e++)l[h+e]=a[c+e]}return i}kn(rc,"HeatmapBucket",{omit:["layers"]});class ac{constructor(e,t){nc(this,e,1,t)}resize(e){oc(this,new ac(e),1)}clone(){return new ac({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){sc(e,t,i,r,n,1)}}class lc{constructor(e,t){nc(this,e,4,t)}resize(e){oc(this,new lc(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new lc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){sc(e,t,i,r,n,4)}}kn(ac,"AlphaImage"),kn(lc,"RGBAImage");var cc={paint:new qo({"heatmap-radius":new jo($e.paint_heatmap["heatmap-radius"]),"heatmap-weight":new jo($e.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Uo($e.paint_heatmap["heatmap-intensity"]),"heatmap-color":new $o($e.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Uo($e.paint_heatmap["heatmap-opacity"])})};function hc(n){const o={},s=n.resolution||256,e=n.clips?n.clips.length:1,a=n.image||new lc({width:s,height:e}),l=(e,t,i)=>{o[n.evaluationKey]=i;const r=n.expression.evaluate(o);a.data[e+t+0]=Math.floor(255*r.r/r.a),a.data[e+t+1]=Math.floor(255*r.g/r.a),a.data[e+t+2]=Math.floor(255*r.b/r.a),a.data[e+t+3]=Math.floor(255*r.a)};if(n.clips)for(let i=0,r=0;i<e;++i,r+=4*s)for(let e=0,t=0;e<s;e++,t+=4){const c=e/(s-1),{start:h,end:u}=n.clips[i];l(r,t,h*(1-c)+u*c)}else for(let e=0,t=0;e<s;e++,t+=4)l(0,t,e/(s-1));return a}var uc={paint:new qo({"hillshade-illumination-direction":new Uo($e.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Uo($e.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Uo($e.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Uo($e.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Uo($e.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Uo($e.paint_hillshade["hillshade-accent-color"])})};const pc=Ho([{name:"a_pos",components:2,type:"Int16"}],4),{members:dc}=pc;var fc=_c,mc=_c;function _c(e,t,i){i=i||2;var r,n,o,s,a,l,c,h=t&&t.length,u=h?t[0]*i:e.length,p=gc(e,0,u,i,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(e,t,i,r){var n,o,s,a=[];for(n=0,o=t.length;n<o;n++)(s=gc(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1))===s.next&&(s.steiner=!0),a.push(Mc(s));for(a.sort(Ec),n=0;n<a.length;n++)i=yc(i=Ac(a[n],i),i.next);return i}(e,t,p,i)),e.length>80*i){r=o=e[0],n=s=e[1];for(var f=i;f<u;f+=i)(a=e[f])<r&&(r=a),(l=e[f+1])<n&&(n=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-r,s-n))?1/c:0}return xc(p,d,i,r,n,c),d}function gc(e,t,i,r,n){var o,s;if(n===jc(e,t,i,r)>0)for(o=t;o<i;o+=r)s=Fc(o,e[o],e[o+1],s);else for(o=i-r;o>=t;o-=r)s=Fc(o,e[o],e[o+1],s);return s&&zc(s,s.next)&&(Nc(s),s=s.next),s}function yc(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!zc(r,r.next)&&0!==kc(r.prev,r,r.next))r=r.next;else{if(Nc(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function xc(e,t,i,r,n,o,s){if(e){!s&&o&&function(e,t,i,r){var n=e;do{null===n.z&&(n.z=Cc(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t<c&&(a++,r=r.nextZ);t++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(s>1)}(n)}(e,r,n,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?bc(e,r,n,o):vc(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),Nc(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?xc(e=wc(yc(e),t,i),t,i,r,n,o,2):2===s&&Tc(e,t,i,r,n,o):xc(yc(e),t,i,r,n,o,1);break}}}function vc(e){var t=e.prev,i=e,r=e.next;if(kc(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(Ic(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&kc(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function bc(e,t,i,r){var n=e.prev,o=e,s=e.next;if(kc(n,o,s)>=0)return!1;for(var a=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,l=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,c=Cc(n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,t,i,r),h=Cc(a,l,t,i,r),u=e.prevZ,p=e.nextZ;u&&u.z>=c&&p&&p.z<=h;){if(u!==e.prev&&u!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,u.x,u.y)&&kc(u.prev,u,u.next)>=0)return!1;if(u=u.prevZ,p!==e.prev&&p!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&kc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;u&&u.z>=c;){if(u!==e.prev&&u!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,u.x,u.y)&&kc(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;p&&p.z<=h;){if(p!==e.prev&&p!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&kc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function wc(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!zc(n,o)&&Pc(n,r,r.next,o)&&Rc(n,o)&&Rc(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),Nc(r),Nc(r.next),r=e=o),r=r.next}while(r!==e);return yc(r)}function Tc(e,t,i,r,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Bc(s,a)){var l=Oc(s,a);return s=yc(s,s.next),l=yc(l,l.next),xc(s,t,i,r,n,o),void xc(l,t,i,r,n,o)}a=a.next}s=s.next}while(s!==e)}function Ec(e,t){return e.x-t.x}function Ac(e,t){var i=function(e,t){var i,r=t,n=e.x,o=e.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!i)return null;if(n===s)return i;var l,c=i,h=i.x,u=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=h&&n!==r.x&&Ic(o<u?n:s,o,h,u,o<u?s:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),Rc(r,e)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&Sc(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(e,t);if(!i)return t;var r=Oc(i,e),n=yc(i,i.next);return yc(r,r.next),t===i?n:t}function Sc(e,t){return kc(e.prev,e,t.prev)<0&&kc(t.next,e,e.next)<0}function Cc(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Mc(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Ic(e,t,i,r,n,o,s,a){return(n-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function Bc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Pc(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Rc(e,t)&&Rc(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(kc(e.prev,e,t.prev)||kc(e,t.prev,t))||zc(e,t)&&kc(e.prev,e,e.next)>0&&kc(t.prev,t,t.next)>0)}function kc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function zc(e,t){return e.x===t.x&&e.y===t.y}function Pc(e,t,i,r){var n=Dc(kc(e,t,i)),o=Dc(kc(e,t,r)),s=Dc(kc(i,r,e)),a=Dc(kc(i,r,t));return n!==o&&s!==a||!(0!==n||!Lc(e,i,t))||!(0!==o||!Lc(e,r,t))||!(0!==s||!Lc(i,e,r))||!(0!==a||!Lc(i,t,r))}function Lc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Dc(e){return e>0?1:e<0?-1:0}function Rc(e,t){return kc(e.prev,e,e.next)<0?kc(e,t,e.next)>=0&&kc(e,e.prev,t)>=0:kc(e,t,e.prev)<0||kc(e,e.next,t)<0}function Oc(e,t){var i=new Uc(e.i,e.x,e.y),r=new Uc(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Fc(e,t,i,r){var n=new Uc(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Nc(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 Uc(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function jc(e,t,i,r){for(var n=0,o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}function Vc(e,t,i,r,n){Gc(e,t,i||0,r||e.length-1,n||qc)}function Gc(e,t,i,r,n){for(;r>i;){if(r-i>600){var o=r-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Gc(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(r,Math.floor(t+(o-s)*l/o+c)),n)}var h=e[t],u=i,p=r;for($c(e,i,t),n(e[r],h)>0&&$c(e,i,r);u<p;){for($c(e,u,p),u++,p--;n(e[u],h)<0;)u++;for(;n(e[p],h)>0;)p--}0===n(e[i],h)?$c(e,i,p):$c(e,++p,r),p<=t&&(i=p+1),t<=p&&(r=p-1)}}function $c(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function qc(e,t){return e<t?-1:e>t?1:0}function Zc(t,i){const r=t.length;if(r<=1)return[t];const n=[];let o,s;for(let e=0;e<r;e++){const r=B(t[e]);0!==r&&(t[e].area=Math.abs(r),void 0===s&&(s=r<0),s===r<0?(o&&n.push(o),o=[t[e]]):o.push(t[e]))}if(o&&n.push(o),i>1)for(let e=0;e<n.length;e++)n[e].length<=i||(Vc(n[e],i,1,n[e].length-1,Yc),n[e]=n[e].slice(0,i));return n}function Yc(e,t){return t.area-e.area}function Wc(e,t,i){const r=i.patternDependencies;let n=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const o=t.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function Xc(e,r,n,o,s){const a=s.patternDependencies;for(const l of r){const r=l.paint.get(`${e}-pattern`).value;if("constant"!==r.kind){let e=r.evaluate({zoom:o-1},n,{},s.availableImages),t=r.evaluate({zoom:o},n,{},s.availableImages),i=r.evaluate({zoom:o+1},n,{},s.availableImages);e=e&&e.name?e.name:e,t=t&&t.name?t.name:t,i=i&&i.name?i.name:i,a[e]=!0,a[t]=!0,a[i]=!0,n.patterns[l.id]={min:e,mid:t,max:i}}}return n}_c.deviation=function(e,t,i,r){var n=t&&t.length,o=Math.abs(jc(e,0,n?t[0]*i:e.length,i));if(n)for(var s=0,a=t.length;s<a;s++)o-=Math.abs(jc(e,t[s]*i,s<a-1?t[s+1]*i:e.length,i));var l=0;for(s=0;s<r.length;s+=3){var c=r[s]*i,h=r[s+1]*i,u=r[s+2]*i;l+=Math.abs((e[c]-e[u])*(e[h+1]-e[c+1])-(e[c]-e[h])*(e[u+1]-e[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},_c.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},r=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var s=0;s<t;s++)i.vertices.push(e[n][o][s]);n>0&&i.holes.push(r+=e[n-1].length)}return i},fc.default=mc;class Hc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Jo,this.indexArray=new fs,this.indexArray2=new bs,this.programConfigurations=new ha(e.layers,e.zoom),this.segments=new va,this.segments2=new va,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection}populate(e,t,i,r){this.hasPattern=Wc("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=Ga(s,e);if(!this.layers[0]._featureFilter.filter(new ko(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,t.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:Va(s,i,r),patterns:{},sortKey:u};o.push(p)}n&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:d}=r;if(this.hasPattern){const e=Xc("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages);t.featureIndex.insert(e[o].feature,n,o,d,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,dc),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,i,r,n,o,s=[]){for(const t of Zc(i,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,o=[],s=[];for(const i of t){if(0===i.length)continue;i!==t[0]&&s.push(o.length/2);const r=this.segments2.prepareSegment(i.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(i[0].x,i[0].y),this.indexArray2.emplaceBack(n+i.length-1,n),o.push(i[0].x),o.push(i[0].y);for(let e=1;e<i.length;e++)this.layoutVertexArray.emplaceBack(i[e].x,i[e].y),this.indexArray2.emplaceBack(n+e-1,n+e),o.push(i[e].x),o.push(i[e].y);r.vertexLength+=i.length,r.primitiveLength+=i.length}const a=fc(o,s);for(let e=0;e<a.length;e+=3)this.indexArray.emplaceBack(n+a[e],n+a[e+1],n+a[e+2]);r.vertexLength+=e,r.primitiveLength+=a.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,o,s,n)}}kn(Hc,"FillBucket",{omit:["layers","patternFeatures"]});const Kc=new qo({"fill-sort-key":new jo($e.layout_fill["fill-sort-key"])});var Jc={paint:new qo({"fill-antialias":new Uo($e.paint_fill["fill-antialias"]),"fill-opacity":new jo($e.paint_fill["fill-opacity"]),"fill-color":new jo($e.paint_fill["fill-color"]),"fill-outline-color":new jo($e.paint_fill["fill-outline-color"]),"fill-translate":new Uo($e.paint_fill["fill-translate"]),"fill-translate-anchor":new Uo($e.paint_fill["fill-translate-anchor"]),"fill-pattern":new Vo($e.paint_fill["fill-pattern"])}),layout:Kc};const Qc=Ho([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),eh=Ho([{name:"a_centroid_pos",components:2,type:"Uint16"}]),th=Ho([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:ih}=Qc;var rh=nh;function nh(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(oh,this,t)}function oh(e,t,i){1==e?t.id=i.readVarint():2==e?function(e,t){for(var i=e.readVarint()+e.pos;e.pos<i;){var r=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[r]=n}}(i,t):3==e?t.type=i.readVarint():4==e&&(t._geometry=i.pos)}function sh(e){for(var t,i,r=0,n=0,o=e.length,s=o-1;n<o;s=n++)r+=((i=e[s]).x-(t=e[n]).x)*(t.y+i.y);return r}nh.types=["Unknown","Point","LineString","Polygon"],nh.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,i=e.readVarint()+e.pos,r=1,n=0,o=0,s=0,a=[];e.pos<i;){if(n<=0){var l=e.readVarint();r=7&l,n=l>>3}if(n--,1===r||2===r)o+=e.readSVarint(),s+=e.readSVarint(),1===r&&(t&&a.push(t),t=[]),t.push(new F(o,s));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&a.push(t),a},nh.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos<t;){if(r<=0){var h=e.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=e.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=e.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},nh.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=nh.types[this.type];function h(e){for(var t=0;t<e.length;t++){var i=e[t];e[t]=[360*(i.x+s)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+a)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(e){var t=e.length;if(t<=1)return[e];for(var i,r,n=[],o=0;o<t;o++){var s=sh(e[o]);0!==s&&(void 0===r&&(r=s<0),r===s<0?(i&&n.push(i),i=[e[o]]):i.push(e[o]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)h(l[r][n])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var ah=lh;function lh(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(ch,this,t),this.length=this._features.length}function ch(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){for(var t=null,i=e.readVarint()+e.pos;e.pos<i;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(i))}function hh(e,t,i){if(3===e){var r=new ah(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r)}}lh.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new rh(this._pbf,t,this.extent,this._keys,this._values)};var uh={VectorTile:function(e,t){this.layers=e.readFields(hh,{},t)},VectorTileFeature:rh,VectorTileLayer:ah};function ph(t,i,r,n){const o=[],s=0===n?(e,t,i,r,n,o)=>{e.push(new F(o,i+(o-t)/(r-t)*(n-i)))}:(e,t,i,r,n,o)=>{e.push(new F(t+(o-i)/(n-i)*(r-t),o))};for(const F of t){const t=[];for(const o of F){if(o.length<=2)continue;const F=[];for(let e=0;e<o.length-1;e++){const l=o[e].x,c=o[e].y,h=o[e+1].x,u=o[e+1].y,p=0===n?l:c,d=0===n?h:u;p<i?d>i&&s(F,l,c,h,u,i):p>r?d<r&&s(F,l,c,h,u,r):F.push(o[e]),d<i&&p>=i&&s(F,l,c,h,u,i),d>r&&p<=r&&s(F,l,c,h,u,r)}let e=o[o.length-1];const a=0===n?e.x:e.y;a>=i&&a<=r&&F.push(e),F.length&&(e=F[F.length-1],F[0].x===e.x&&F[0].y===e.y||F.push(F[0]),t.push(F))}t.length&&o.push(t)}return o}const dh=uh.VectorTileFeature.types,fh=Math.pow(2,13);function mh(e,t,i,r,n,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(r*fh)<<1)+n,Math.round(a))}function _h(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class gh{constructor(){this.acc=new F(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new F(e.x,e.y),this.max=new F(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const i=this.min,r=this.max;e.x<i.x?i.x=e.x:e.x>r.x&&(r.x=e.x),e.y<i.y?i.y=e.y:e.y>r.y&&(r.y=e.y),((0===e.x||e.x===ba)&&e.x===t.x)!=((0===e.y||e.y===ba)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,gi(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ba!=e.x>ba&&this.addBorderIntersection(1,gi(t.y,e.y,(ba-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,gi(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ba!=e.y>ba&&this.addBorderIntersection(3,gi(t.x,e.x,(ba-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const r=0===e.y?2:3;this.addBorderIntersection(r,t.x),this.addBorderIntersection(r,e.x)}}centroid(){const e=this.polyCount.reduce((e,t)=>e+t.edges,0);return 0!==e?this.acc.div(e)._round():new F(0,0)}span(){return new F(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0)}}class yh{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new es,this.centroidVertexArray=new Os,this.indexArray=new fs,this.programConfigurations=new ha(e.layers,e.zoom),this.segments=new va,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.enableTerrain=e.enableTerrain}populate(e,t,i,r){this.features=[],this.hasPattern=Wc("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<<e.z)*2));return 80150034*t/(t*t+1)/ba/(1<<e.z)}(i);for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ga(n,e);if(!this.layers[0]._featureFilter.filter(new ko(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Va(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length;this.hasPattern?this.features.push(Xc("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,s,i,{},t.availableImages,r),t.featureIndex.insert(n,c.geometry,s,a,this.index,h)}this.sortBorders()}addFeatures(e,t,i,r,n){for(const e of this.features){const{geometry:o}=e;this.addFeature(e,o,e.index,t,i,r,n)}this.sortBorders()}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ih),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,th.members,!0))),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,eh.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(n,o,s,a,l,c,h){const u=[new F(0,0),new F(ba,ba)],p=h.projection,d="globe"===p.name,f=this.enableTerrain&&!d?new gh:null;d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new As);const m=Zc(o,500);for(let e=m.length-1;e>=0;e--){const o=m[e];(0===o.length||(t=o[0]).every(e=>e.x<=0)||t.every(e=>e.x>=ba)||t.every(e=>e.y<=0)||t.every(e=>e.y>=ba))&&m.splice(e,1)}var t;let e;if(d)e=bh(m,u,a);else{e=[];for(const n of m)e.push({polygon:n,bounds:u})}for(const o of e){const s=o.polygon;let i=0,r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let e=0;e<s.length;e++){const c=s[e];if(0===c.length)continue;i+=c.length;let t=0;f&&f.startRing(c[0]);for(let e=0;e<c.length;e++){const s=c[e];if(e>=1){const F=c[e-1];if(!xh(s,F,o.bounds)){f&&f.append(s,F),r.vertexLength+4>va.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const n=s.sub(F)._perp(),o=n.x/(Math.abs(n.x)+Math.abs(n.y)),c=n.y>0?1:0,u=F.dist(s);t+u>32768&&(t=0),mh(this.layoutVertexArray,s.x,s.y,o,c,0,0,t),mh(this.layoutVertexArray,s.x,s.y,o,c,0,1,t),t+=u,mh(this.layoutVertexArray,F.x,F.y,o,c,0,0,t),mh(this.layoutVertexArray,F.x,F.y,o,c,0,1,t);const m=r.vertexLength;if(this.indexArray.emplaceBack(m,m+2,m+1),this.indexArray.emplaceBack(m+1,m+2,m+3),r.vertexLength+=4,r.primitiveLength+=2,d){const n=this.layoutVertexExtArray,o=p.projectTilePoint(s.x,s.y,a),l=p.projectTilePoint(F.x,F.y,a),c=p.upVector(a,s.x,s.y),h=p.upVector(a,F.x,F.y);_h(n,o,c),_h(n,o,c),_h(n,l,h),_h(n,l,h)}}}}}if(r.vertexLength+i>va.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(i,this.layoutVertexArray,this.indexArray)),"Polygon"!==dh[n.type])continue;const c=[],h=[],u=r.vertexLength;for(let e=0;e<s.length;e++){const o=s[e];if(0!==o.length){o!==s[0]&&h.push(c.length/2);for(let e=0;e<o.length;e++){const s=o[e];mh(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),c.push(s.x),c.push(s.y),f&&f.currentPolyCount.top++,d&&_h(this.layoutVertexExtArray,p.projectTilePoint(s.x,s.y,a),p.upVector(a,s.x,s.y))}}}const m=fc(c,h);for(let e=0;e<m.length;e+=3)this.indexArray.emplaceBack(u+m[e],u+m[e+2],u+m[e+1]);r.primitiveLength+=m.length/3,r.vertexLength+=i}if(f&&f.polyCount.length>0){if(f.borders){f.vertexArrayOffset=this.centroidVertexArray.length;const n=f.borders,o=this.featuresOnBorder.push(f)-1;for(let e=0;e<4;e++)n[e][0]!==Number.MAX_VALUE&&this.borders[e].push(o)}this.encodeCentroid(f.borders?void 0:f.centroid(),f)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,s,l,c,a)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((e,t)=>this.featuresOnBorder[e].borders[i][0]-this.featuresOnBorder[t].borders[i][0])}encodeCentroid(t,e,i=!0){let r,n;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);r=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(t.x+450)),n=0;else r=0,n=+i;let o=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(o++,0,n),this.centroidVertexArray.emplace(o++,r,n);for(let e=0;e<t.top;e++)this.centroidVertexArray.emplace(o++,r,n)}}}function xh(e,t,i){return e.x===t.x&&(e.x<i[0].x||e.x>i[1].x)||e.y===t.y&&(e.y<i[0].y||e.y>i[1].y)}function vh(){const e=Math.PI/32,t=Math.tan(e),i=Ta;return i*Math.sqrt(1+2*t*t)-i}function bh(e,t,r){const n=1<<r.z,i=Ba(r.x/n),o=Ba((r.x+1)/n),s=ka(r.y/n),a=ka((r.y+1)/n);return function(e,t,i,r,n=0,o){const s=[];if(!e.length||!i||!r)return s;const a=(e,t)=>{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),h=l-c,u=[];for(let e=0;e<Math.abs(h);e++)u.push(h>0?0:1);for(let e=0;e<Math.min(l,c);e++)u.push(0),u.push(1);let p=e;if(p=ph(p,t[0].y-n,t[1].y+n,1),p=ph(p,t[0].x-n,t[1].x+n,0),!p.length)return s;const d=[];for(u.length?d.push({polygons:p,bounds:t,depth:0}):a(p,t);d.length;){const e=d.pop(),t=e.depth,i=u[t],r=e.bounds[0],s=e.bounds[1],l=0===i?r.x:r.y,c=0===i?s.x:s.y,h=o?o(i,l,c):.5*(l+c),p=ph(e.polygons,l-n,h+n,i),f=ph(e.polygons,h-n,c+n,i);if(p.length){const e=[r,new F(0===i?h:s.x,1===i?h:s.y)];u.length>t+1?d.push({polygons:p,bounds:e,depth:t+1}):a(p,e)}if(f.length){const e=[new F(0===i?h:r.x,1===i?h:r.y),s];u.length>t+1?d.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s}(e,t,Math.ceil((o-i)/11.25),Math.ceil((s-a)/11.25),1,(e,t,i)=>{if(0===e)return.5*(t+i);{const e=ka((r.y+t/ba)/n);return(Ma(.5*(ka((r.y+i/ba)/n)+e))*n-r.y)*ba}})}kn(yh,"FillExtrusionBucket",{omit:["layers","features"]}),kn(gh,"PartMetadata");var wh={paint:new qo({"fill-extrusion-opacity":new Uo($e["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new jo($e["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Uo($e["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Uo($e["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Vo($e["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new jo($e["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new jo($e["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Uo($e["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Th(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Eh{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Ch(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=function(e,t,i){var r=Th(256*e,256*(t=Math.pow(2,i)-t-1),i),n=Th(256*(e+1),256*(t+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(t,i,r){let n,o="";for(let e=t;e>0;e--)n=1<<e-1,o+=(i&n?1:0)+(r&n?2:0);return o}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",r).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ah{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Ch(e,t.z,t.z,t.x,t.y)}}class Sh{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new Eh(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:Ch(t,e,i,r,n)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new Sh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Sh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Ch(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Ch(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Sh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Sh(t,this.wrap,t,i,r),new Sh(t,this.wrap,t,i+1,r),new Sh(t,this.wrap,t,i,r+1),new Sh(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Sh(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Sh(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Ah(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Ch(e,t,i,r,n){const o=1<<Math.min(i,22);let s=o*(n%o)+r%o;return e&&i<22&&(s+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*s+i)+(t-i)}function Mh(e,t){return e.x*t.x+e.y*t.y}function Ih(i,r){if(1===i.length){let e=0;const n=r[e++];let t;for(;!t||n.equals(t);)if(t=r[e++],!t)return 1/0;for(;e<r.length;e++){const o=r[e],s=i[0],a=t.sub(n),l=o.sub(n),c=s.sub(n),h=Mh(a,a),u=Mh(a,l),p=Mh(l,l),d=Mh(c,a),f=Mh(c,l),m=h*p-u*u,_=(p*d-u*f)/m,g=(h*f-u*d)/m,y=n.z*(1-_-g)+t.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const t of r)e=Math.min(e,t.z);return e}}function Bh(e){const t=new F(e[0],e[1]);return t.z=e[2],t}function kh(e,t,i,r,n,o,s,a){const l=s*n.getElevationAt(e,t,!0,!0),c=0!==o[0],h=c?0===o[1]?s*(o[0]/7-450):s*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),s=10*(t[1]-8*n),a=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),h=Math.floor(.5*(s*l-1)),u=e.tileCoordToPixel(r,n),p=2*c+1,d=2*h+1,f=function(e,t,i,r,n){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,u.x-c,u.y-h,p,d),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/p),x=Math.min(.25,.5*l*g/d);return a+Math.max(y*o,x*s)}(n,o,a):l;return{base:l+(0===i)?-1:i,top:c?Math.max(h+r,l+i+2):l+r}}kn(Eh,"CanonicalTileID"),kn(Sh,"OverscaledTileID",{omit:["projMatrix"]});const zh=Ho([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Ph}=zh,Lh=Ho([{name:"a_packed",components:4,type:"Float32"}]),{members:Dh}=Lh,Rh=uh.VectorTileFeature.types,Oh=Math.cos(Math.PI/180*37.5);class Fh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new ts,this.layoutVertexArray2=new is,this.indexArray=new fs,this.programConfigurations=new ha(e.layers,e.zoom),this.segments=new va,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i,r){this.hasPattern=Wc("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ga(t,e);if(!this.layers[0]._featureFilter.filter(new ko(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,i,r),patterns:{},sortKey:h};o.push(u)}n&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:p}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const e=Xc("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,s.positions,t.availableImages);a.insert(e[o].feature,n,o,p,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,o=r.value;if(!o)continue;e.addDash(o.from,t),e.addDash(o.to,t),o.other&&e.addDash(o.other,t)}}return t}addFeatureDashes(s,a){const l=this.zoom;for(const c of this.layers){const h=c.paint.get("line-dasharray").value,u=c.layout.get("line-cap").value;if("constant"===h.kind&&"constant"===u.kind)continue;let e,t,i,r,n,o;if("constant"===h.kind){const s=h.value;if(!s)continue;e=s.other||s.to,t=s.to,i=s.from}else e=h.evaluate({zoom:l-1},s),t=h.evaluate({zoom:l},s),i=h.evaluate({zoom:l+1},s);"constant"===u.kind?r=n=o=u.value:(r=u.evaluate({zoom:l-1},s),n=u.evaluate({zoom:l},s),o=u.evaluate({zoom:l+1},s)),a.addDash(e,r),a.addDash(t,n),a.addDash(i,o);const p=a.getKey(e,r),d=a.getKey(t,n),f=a.getKey(i,o);s.patterns[c.id]={min:p,mid:d,max:f}}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Dh)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ph),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(e,{}),l=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),h=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,a,l,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}addLine(r,n,o,s,a,l){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<r.length-1;e++)this.totalDistance+=r[e].dist(r[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const c="Polygon"===Rh[n.type];let h=r.length;for(;h>=2&&r[h-1].equals(r[h-2]);)h--;let u=0;for(;u<h-1&&r[u].equals(r[u+1]);)u++;if(h<(c?3:2))return;"bevel"===o&&(a=1.05);const p=this.overscaling<=16?122880/(512*this.overscaling):0,d=this.segments.prepareSegment(10*h,this.layoutVertexArray,this.indexArray);let f,m,_,g,y;this.e1=this.e2=-1,c&&(f=r[h-2],y=r[u].sub(f)._unit()._perp());for(let i=u;i<h;i++){if(_=i===h-1?c?r[u+1]:void 0:r[i+1],_&&r[i].equals(_))continue;y&&(g=y),f&&(m=f),f=r[i],y=_?_.sub(f)._unit()._perp():g,g=g||y;let e=g.add(y);0===e.x&&0===e.y||e._unit();const x=g.x*y.x+g.y*y.y,v=e.x*y.x+e.y*y.y,b=0!==v?1/v:1/0,w=2*Math.sqrt(2-2*v),T=v<Oh&&m&&_,E=g.x*y.y-g.y*y.x>0;if(T&&i>u){const r=f.dist(m);if(r>2*p){const n=f.sub(f.sub(m)._mult(p/r)._round());this.updateDistance(m,n),this.addCurrentVertex(n,g,0,0,d),m=n}}const A=m&&_;let t=A?o:c?"butt":s;if(A&&"round"===t&&(b<l?t="miter":b<=2&&(t="fakeround")),"miter"===t&&b>a&&(t="bevel"),"bevel"===t&&(b>2&&(t="flipbevel"),b<a&&(t="miter")),m&&this.updateDistance(m,f),"miter"===t)e._mult(b),this.addCurrentVertex(f,e,0,0,d);else if("flipbevel"===t){if(b>100)e=y.mult(-1);else{const r=b*g.add(y).mag()/g.sub(y).mag();e._perp()._mult(r*(E?-1:1))}this.addCurrentVertex(f,e,0,0,d),this.addCurrentVertex(f,e.mult(-1),0,0,d)}else if("bevel"===t||"fakeround"===t){const r=-Math.sqrt(b*b-1),n=E?r:0,o=E?0:r;if(m&&this.addCurrentVertex(f,g,n,o,d),"fakeround"===t){const r=Math.round(180*w/Math.PI/20);for(let t=1;t<r;t++){let e=t/r;if(.5!==e){const r=e-.5;e+=e*r*(e-1)*((1.0904+x*(x*(3.55645-1.43519*x)-3.2452))*r*r+(.848013+x*(.215638*x-1.06021)))}const s=y.sub(g)._mult(e)._add(g)._unit()._mult(E?-1:1);this.addHalfVertex(f,s.x,s.y,!1,E,0,d)}}_&&this.addCurrentVertex(f,y,-n,-o,d)}else if("butt"===t)this.addCurrentVertex(f,e,0,0,d);else if("square"===t){const r=m?1:-1;m||this.addCurrentVertex(f,e,r,r,d),this.addCurrentVertex(f,e,0,0,d),m&&this.addCurrentVertex(f,e,r,r,d)}else"round"===t&&(m&&(this.addCurrentVertex(f,g,0,0,d),this.addCurrentVertex(f,g,1,1,d,!0)),_&&(this.addCurrentVertex(f,y,-1,-1,d,!0),this.addCurrentVertex(f,y,0,0,d)));if(T&&i<h-1){const r=f.dist(_);if(r>2*p){const n=f.add(_.sub(f)._mult(p/r)._round());this.updateDistance(f,n),this.addCurrentVertex(n,y,0,0,d),f=n}}}}addCurrentVertex(e,t,i,r,n,o=!1){const s=t.y*r-t.x,a=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,s,a,o,!0,-r,n)}addHalfVertex({x:e,y:t},i,r,n,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}kn(Fh,"LineBucket",{omit:["layers","patternFeatures"]});const Nh=new qo({"line-cap":new jo($e.layout_line["line-cap"]),"line-join":new jo($e.layout_line["line-join"]),"line-miter-limit":new Uo($e.layout_line["line-miter-limit"]),"line-round-limit":new Uo($e.layout_line["line-round-limit"]),"line-sort-key":new jo($e.layout_line["line-sort-key"])});var Uh={paint:new qo({"line-opacity":new jo($e.paint_line["line-opacity"]),"line-color":new jo($e.paint_line["line-color"]),"line-translate":new Uo($e.paint_line["line-translate"]),"line-translate-anchor":new Uo($e.paint_line["line-translate-anchor"]),"line-width":new jo($e.paint_line["line-width"]),"line-gap-width":new jo($e.paint_line["line-gap-width"]),"line-offset":new jo($e.paint_line["line-offset"]),"line-blur":new jo($e.paint_line["line-blur"]),"line-dasharray":new Vo($e.paint_line["line-dasharray"]),"line-pattern":new Vo($e.paint_line["line-pattern"]),"line-gradient":new $o($e.paint_line["line-gradient"]),"line-trim-offset":new Uo($e.paint_line["line-trim-offset"])}),layout:Nh};const jh=new class extends jo{possiblyEvaluate(e,t){return t=new ko(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=b({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}(Uh.paint.properties["line-width"].specification);function Vh(e,t){return t>0?t+2*e:e}jh.useIntegerZoom=!0;const Gh=Ho([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),$h=Ho([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),qh=Ho([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ho([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Zh=Ho([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Yh=Ho([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ho([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Wh=Ho([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Xh=Ho([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ho([{name:"triangle",components:3,type:"Uint16"}]),Ho([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Ho([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Ho([{type:"Float32",name:"offsetX"}]),Ho([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Hh=24;const Kh=128;function Jh(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new ko(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:r,interpolationType:o}=n;let e=0;for(;e<r.length&&r[e]<=i;)e++;e=Math.max(0,e-1);let t=e;for(;t<r.length&&r[t]<i+1;)t++;t=Math.min(r.length-1,t);const s=r[e],a=r[t];return"composite"===n.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:o}:{kind:"camera",minZoom:s,maxZoom:a,minSize:n.evaluate(new ko(s)),maxSize:n.evaluate(new ko(a)),interpolationType:o}}}function Qh(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/Kh:"composite"===e.kind?gi(r/Kh,n/Kh,i):t}function eu(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=e,a=n?C(Fi.interpolationFactor(n,t,o,s),0,1):0;"camera"===e.kind?r=gi(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:r}}var tu=Object.freeze({__proto__:null,getSizeData:Jh,evaluateSizeForFeature:Qh,evaluateSizeForZoom:eu,SIZE_PACK_FACTOR:Kh});function iu(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Bo.applyArabicShaping&&(e=Bo.applyArabicShaping(e)),e}(e.text,t,i)}),e}const ru={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function nu(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function ou(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var su=function(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,p=i?-1:1,d=e[t+u];for(u+=p,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+u],u+=p,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+u],u+=p,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},au=function(e,t,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<<c)-1,u=h>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=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=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(t*l-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+d]=255&a,d+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;e[i+d]=255&s,d+=f,s/=256,c-=8);e[i+d-f]|=128*m},lu=cu;function cu(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}cu.Varint=0,cu.Fixed64=1,cu.Bytes=2,cu.Fixed32=5;var hu=4294967296,uu=1/hu,pu="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function du(e){return e.type===cu.Bytes?e.readVarint()+e.pos:e.pos+1}function fu(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function mu(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function _u(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function gu(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function yu(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function xu(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function vu(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function bu(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function wu(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Tu(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function Eu(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Au(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Su(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Cu(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Mu(e,t,i){t.glyphs=[],1===e&&i.readMessage(Iu,t)}function Iu(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Bu,{});t.glyphs.push({id:e,bitmap:new ac({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Bu(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function ku(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();e<r.length&&(r[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:n,h:o,fill:t/(n*o)||0}}cu.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Au(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Cu(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Au(this.buf,this.pos)+Au(this.buf,this.pos+4)*hu;return this.pos+=8,e},readSFixed64:function(){var e=Au(this.buf,this.pos)+Cu(this.buf,this.pos+4)*hu;return this.pos+=8,e},readFloat:function(){var e=su(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=su(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return fu(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return fu(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return fu(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return fu(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return fu(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return fu(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[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=this.pos;return this.pos=e,e-t>=12&&pu?function(e,t,i){return pu.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var r="",n=t;n<i;){var o,s,a,l=e[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(s=e[n+2],128==(192&(o=e[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(s=e[n+2],a=e[n+3],128==(192&(o=e[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==cu.Bytes)return e.push(this.readVarint(t));var i=du(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==cu.Bytes)return e.push(this.readSVarint());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==cu.Bytes)return e.push(this.readBoolean());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==cu.Bytes)return e.push(this.readFloat());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==cu.Bytes)return e.push(this.readDouble());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==cu.Bytes)return e.push(this.readFixed32());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==cu.Bytes)return e.push(this.readSFixed32());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==cu.Bytes)return e.push(this.readFixed64());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==cu.Bytes)return e.push(this.readSFixed64());var t=du(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===cu.Varint)for(;this.buf[this.pos++]>127;);else if(t===cu.Bytes)this.pos=this.readVarint()+this.pos;else if(t===cu.Fixed32)this.pos+=4;else{if(t!==cu.Fixed64)throw new Error("Unimplemented type: "+t);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 i=new Uint8Array(t);i.set(this.buf),this.buf=i,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),Su(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Su(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Su(this.buf,-1&e,this.pos),Su(this.buf,Math.floor(e*uu),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Su(this.buf,-1&e,this.pos),Su(this.buf,Math.floor(e*uu),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,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,i){for(var r,n,o=0;o<t.length;o++){if((r=t.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&mu(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),au(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),au(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&mu(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,cu.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,_u,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,gu,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,vu,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,yu,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,xu,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,bu,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,wu,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Tu,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Eu,t)},writeBytesField:function(e,t){this.writeTag(e,cu.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,cu.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,cu.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,cu.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,cu.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,cu.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,cu.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,cu.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,cu.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,cu.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class zu{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Pu{constructor(e,t){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,i,n),this.addImages(t,r,n);const{w:o,h:s}=ku(n),a=new lc({width:o||1,height:s||1});for(const t in e){const r=e[t],n=i[t].paddedRect;lc.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const e in t){const i=t[e],n=r[e].paddedRect,o=n.x+1,s=n.y+1,l=i.data.width,c=i.data.height;lc.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),lc.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),lc.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),lc.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),lc.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(const r in e){const n=e[r],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(o),t[r]=new zu(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(e=>t.hasImage(e)),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n})}}kn(zu,"ImagePosition"),kn(Pu,"ImageAtlas");const Lu={horizontal:1,vertical:2,horizontalOnly:3};class Du{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const i=new Du;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new Du;return t.imageName=e,t}}class Ru{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,i){const r=new Ru;for(let e=0;e<t.sections.length;e++){const n=t.sections[e];n.image?r.addImageSection(n):r.addTextSection(n,i)}return r}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(e){this.text=function(t,i){let r="";for(let e=0;e<t.length;e++){const n=t.charCodeAt(e+1)||null,o=t.charCodeAt(e-1)||null;r+=!i&&(n&&mo(n)&&!ru[t[e+1]]||o&&mo(o)&&!ru[t[e-1]])||!ru[t[e]]?t[e]:ru[t[e]]}return r}(this.text,e)}trim(){let t=0;for(let e=0;e<this.text.length&&Fu[this.text.charCodeAt(e)];e++)t++;let i=this.text.length;for(let e=this.text.length-1;e>=0&&e>=t&&Fu[this.text.charCodeAt(e)];e--)i--;this.text=this.text.substring(t,i),this.sectionIndex=this.sectionIndex.slice(t,i)}substring(e,t){const i=new Ru;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Du.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(i)}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void Y("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(Du.forImage(t)),this.sectionIndex.push(this.sections.length-1)):Y("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ou(t,i,e,r,n,o,s,a,l,c,h,u,p,d,f,m){const _=Ru.fromFeature(t,n);let g;u===Lu.vertical&&_.verticalizePunctuation(p);const{processBidirectionalText:y,processStyledBidirectionalText:x}=Bo;if(y&&1===_.sections.length){g=[];const t=y(_.toString(),qu(_,c,o,i,r,d,f));for(const i of t){const t=new Ru;t.text=i,t.sections=_.sections;for(let e=0;e<i.length;e++)t.sectionIndex.push(0);g.push(t)}}else if(x){g=[];const t=x(_.text,_.sectionIndex,qu(_,c,o,i,r,d,f));for(const i of t){const t=new Ru;t.text=i[0],t.sectionIndex=i[1],t.sections=_.sections,g.push(t)}}else g=function(e,t){const i=[],r=e.text;let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return n<r.length&&i.push(e.substring(n,r.length)),i}(_,qu(_,c,o,i,r,d,f));const v=[],b={positionedLines:v,text:_.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:u,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(h,u,p,d,f,m,_,g,y,x,v,b){let w=0,T=0,E=0;const A="right"===g?1:"left"===g?0:.5;let S=!1;for(const h of f){const p=h.getSections();for(const h of p){if(h.imageName)continue;const p=u[h.fontStack];if(p&&(S=void 0!==p.ascender&&void 0!==p.descender,!S))break}if(!S)break}let e=0;for(const _ of f){_.trim();const f=_.getMaxScale(),g=(f-1)*Hh,t={positionedGlyphs:[],lineOffset:0};h.positionedLines[e]=t;const M=t.positionedGlyphs;let a=0;if(!_.length()){T+=m,++e;continue}let l=0,c=0;for(let s=0;s<_.length();s++){const g=_.getSection(s),E=_.getSectionIndex(s),A=_.getCharCode(s);let e=g.scale,t=null,i=null,r=null,n=Hh,o=0;const I=!(y===Lu.horizontal||!v&&!fo(A)||v&&(Fu[A]||(C=A,On(C)||Fn(C)||Nn(C)||no(C)||lo(C))));if(g.imageName){const u=d[g.imageName];if(!u)continue;r=g.imageName,h.iconsInText=h.iconsInText||!0,i=u.paddedRect;const p=u.displaySize;e=e*Hh/b,t={width:p[0],height:p[1],left:1,top:-3,advance:I?p[1]:p[0],localGlyph:!1},o=S?-t.height*e:f*Hh-17-p[1]*e,n=t.advance;const m=(I?p[0]:p[1])*e-Hh*f;m>0&&m>a&&(a=m)}else{const h=p[g.fontStack];if(!h)continue;h[A]&&(i=h[A]);const d=u[g.fontStack];if(!d)continue;const m=d.glyphs[A];if(!m)continue;if(t=m.metrics,n=8203!==A?Hh:0,S){const h=void 0!==d.ascender?Math.abs(d.ascender):0,u=void 0!==d.descender?Math.abs(d.descender):0,p=(h+u)*e;l<p&&(l=p,c=(h-u)/2*e),o=-h*e}else o=(f-e)*Hh-17}I?(h.verticalizable=!0,M.push({glyph:A,imageName:r,x:w,y:T+o,vertical:I,scale:e,localGlyph:t.localGlyph,fontStack:g.fontStack,sectionIndex:E,metrics:t,rect:i}),w+=n*e+x):(M.push({glyph:A,imageName:r,x:w,y:T+o,vertical:I,scale:e,localGlyph:t.localGlyph,fontStack:g.fontStack,sectionIndex:E,metrics:t,rect:i}),w+=t.advance*e+x)}0!==M.length&&(E=Math.max(w-x,E),S?Yu(M,A,a,c,m*f/2):Yu(M,A,a,0,m/2)),w=0;const r=m*f+a;t.lineOffset=Math.max(a,g),T+=r,++e}var C;const t=T,{horizontalAlign:M,verticalAlign:i}=Zu(_);(function(e,t,i,r,n,o){const s=(t-i)*n,a=-o*r;for(const t of e)for(const e of t.positionedGlyphs)e.x+=s,e.y+=a})(h.positionedLines,A,M,i,E,t),h.top+=-i*t,h.bottom=h.top+t,h.left+=-M*E,h.right=h.left+E,h.hasBaseline=S}(b,i,e,r,g,s,a,l,u,c,p,m),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(v)&&b}const Fu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Nu={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Uu(e,t,i,r,n,o){if(t.imageName){const e=r[t.imageName];return e?e.displaySize[0]*t.scale*Hh/o+n:0}{const r=i[t.fontStack],o=r&&r.glyphs[e];return o?o.metrics.advance*t.scale+n:0}}function ju(e,t,i,r){const n=Math.pow(e-t,2);return r?e<t?n/2:2*n:n+Math.abs(i)*i}function Vu(e,t,i){let r=0;return 10===e&&(r-=1e4),i&&(r+=150),40!==e&&65288!==e||(r+=50),41!==t&&65289!==t||(r+=50),r}function Gu(e,t,i,r,n,o){let s=null,a=ju(t,i,n,o);for(const e of r){const r=ju(t-e.x,i,n,o)+e.badness;r<=a&&(s=e,a=r)}return{index:e,x:t,priorBreak:s,badness:a}}function $u(e){return e?$u(e.priorBreak).concat(e.index):[]}function qu(t,i,e,r,n,o,s){if("point"!==o)return[];if(!t)return[];const a=[],l=function(t,i,e,r,n,o){let s=0;for(let e=0;e<t.length();e++){const a=t.getSection(e);s+=Uu(t.getCharCode(e),a,r,n,i,o)}return s/Math.max(1,Math.ceil(s/e))}(t,i,e,r,n,s),c=t.text.indexOf("")>=0;let h=0;for(let e=0;e<t.length();e++){const o=t.getSection(e),p=t.getCharCode(e);if(Fu[p]||(h+=Uu(p,o,r,n,i,s)),e<t.length()-1){const i=!((u=p)<11904||!(Yn(u)||Zn(u)||so(u)||ro(u)||Kn(u)||Un(u)||Wn(u)||Gn(u)||Jn(u)||Qn(u)||Hn(u)||co(u)||$n(u)||Vn(u)||jn(u)||Xn(u)||qn(u)||oo(u)||to(u)||eo(u)));(Nu[p]||i||o.imageName)&&a.push(Gu(e+1,h,l,a,Vu(p,t.getCharCode(e+1),i&&c),!1))}}var u;return $u(Gu(t.length(),h,l,a,0,!0))}function Zu(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function Yu(t,e,i,r,n){if(!(e||i||r||n))return;const o=t.length-1,s=t[o],a=(s.x+s.metrics.advance*s.scale)*e;for(let e=0;e<=o;e++)t[e].x-=a,t[e].y+=i+r+n}function Wu(e,t,i){const{horizontalAlign:r,verticalAlign:n}=Zu(i),o=t[0]-e.displaySize[0]*r,s=t[1]-e.displaySize[1]*n;return{image:e,top:s,bottom:s+e.displaySize[1],left:o,right:o+e.displaySize[0]}}function Xu(e,t,i,r,n,o){const s=e.image;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let h,u,p,d;"width"===i||"both"===i?(d=n[0]+l-r[3],u=n[0]+c+r[1]):(d=n[0]+(l+c-s.displaySize[0])/2,u=d+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(h=n[1]+f-r[0],p=n[1]+m+r[2]):(h=n[1]+(f+m-s.displaySize[1])/2,p=h+s.displaySize[1]),{image:s,top:h,right:u,bottom:p,left:d,collisionPadding:a}}class Hu extends F{constructor(e,t,i,r,n){super(e,t),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new Hu(this.x,this.y,this.z,this.angle,this.segment)}}function Ku(t,i,r,n,o){if(void 0===i.segment)return!0;let e=i,s=i.segment+1,a=0;for(;a>-r/2;){if(s--,s<0)return!1;a-=t[s].dist(e),e=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;a<r/2;){const i=t[s],r=t[s+1];if(!r)return!1;let e=t[s-1].angleTo(i)-i.angleTo(r);for(e=Math.abs((e+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:e}),c+=e;a-l[0].distance>n;)c-=l.shift().angleDelta;if(c>o)return!1;s++,a+=i.dist(r)}return!0}function Ju(t){let i=0;for(let e=0;e<t.length-1;e++)i+=t[e].dist(t[e+1]);return i}function Qu(e,t,i){return e?.6*t*i:0}function ep(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function tp(t,i,e,r,n,o){const s=Qu(e,n,o),a=ep(e,r)*o;let l=0;const c=Ju(t)/2;for(let e=0;e<t.length-1;e++){const r=t[e],n=t[e+1],o=r.dist(n);if(l+o>c){const h=(c-l)/o,u=gi(r.x,n.x,h),p=gi(r.y,n.y,h),d=new Hu(u,p,0,n.angleTo(r),e);return!s||Ku(t,d,a,s,i)?d:void 0}l+=o}}function ip(e,t,i,r,n,o,s,a,l){const c=Qu(r,o,s),h=ep(r,n),u=h*s,p=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-u<t/4&&(t=u+t/4),rp(e,p?t/2*a%t:(h/2+2*o)*s*a%t,t,c,i,u,p,!1,l)}function rp(t,e,i,r,n,o,s,a,l){const c=o/2,h=Ju(t);let u=0,p=e-i,d=[];for(let e=0;e<t.length-1;e++){const s=t[e],a=t[e+1],f=s.dist(a),m=a.angleTo(s);for(;p+i<u+f;){p+=i;const _=(p-u)/f,g=gi(s.x,a.x,_),y=gi(s.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&p-c>=0&&p+c<=h){const i=new Hu(g,y,0,m,e);i._round(),r&&!Ku(t,i,o,r,n)||d.push(i)}}u+=f}return a||d.length||s||(d=rp(t,u/2,i,r,n,o,s,!0,l)),d}function np(t,n,o,s,a){const l=[];for(let e=0;e<t.length;e++){const c=t[e];let r;for(let i=0;i<c.length-1;i++){let e=c[i],t=c[i+1];e.x<n&&t.x<n||(e.x<n?e=new F(n,e.y+(n-e.x)/(t.x-e.x)*(t.y-e.y))._round():t.x<n&&(t=new F(n,e.y+(n-e.x)/(t.x-e.x)*(t.y-e.y))._round()),e.y<o&&t.y<o||(e.y<o?e=new F(e.x+(o-e.y)/(t.y-e.y)*(t.x-e.x),o)._round():t.y<o&&(t=new F(e.x+(o-e.y)/(t.y-e.y)*(t.x-e.x),o)._round()),e.x>=s&&t.x>=s||(e.x>=s?e=new F(s,e.y+(s-e.x)/(t.x-e.x)*(t.y-e.y))._round():t.x>=s&&(t=new F(s,e.y+(s-e.x)/(t.x-e.x)*(t.y-e.y))._round()),e.y>=a&&t.y>=a||(e.y>=a?e=new F(e.x+(a-e.y)/(t.y-e.y)*(t.x-e.x),a)._round():t.y>=a&&(t=new F(e.x+(a-e.y)/(t.y-e.y)*(t.x-e.x),a)._round()),r&&e.equals(r[r.length-1])||(r=[e],l.push(r)),r.push(t)))))}}return l}kn(Hu,"Anchor");const op=1e20;function sp(t,i,r,n,o,s,a,l,c){for(let e=i;e<i+n;e++)ap(t,r*s+e,s,o,a,l,c);for(let e=r;e<r+o;e++)ap(t,e*s+i,1,n,a,l,c)}function ap(r,n,o,s,a,l,c){l[0]=0,c[0]=-op,c[1]=op,a[0]=r[n];for(let e=1,t=0,i=0;e<s;e++){a[e]=r[n+e*o];const s=e*e;do{const r=l[t];i=(a[e]-a[r]+s-r*r)/(e-r)/2}while(i<=c[t]&&--t>-1);t++,l[t]=e,c[t]=i,c[t+1]=op}for(let e=0,t=0;e<s;e++){for(;c[t+1]<e;)t++;const s=l[t],i=e-s;r[n+e*o]=a[s]+i*i}}const lp={none:0,ideographs:1,all:2};class cp{constructor(e,t,i){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,n){const t=[];for(const n in e)for(const i of e[n])t.push({stack:n,id:i});u(t,({stack:i,id:r},n)=>{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let e=o.glyphs[r];if(void 0!==e)return void n(null,{stack:i,id:r,glyph:e});if(e=this._tinySDF(o,i,r),e)return o.glyphs[r]=e,void n(null,{stack:i,id:r,glyph:e});const s=Math.floor(r/256);if(256*s>65535)return void n(new Error("glyphs > 65535 not supported"));if(o.ranges[s])return void n(null,{stack:i,id:r,glyph:e});let a=o.requests[s];a||(a=o.requests[s]=[],cp.loadGlyphRange(i,s,this.url,this.requestManager,(e,t)=>{if(t){o.ascender=t.ascender,o.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(o.glyphs[+e]=t.glyphs[+e]);o.ranges[s]=!0}for(const i of a)i(e,t);delete o.requests[s]})),a.push((e,t)=>{e?n(e):t&&n(null,{stack:i,id:r,glyph:t.glyphs[r]||null})})},(e,t)=>{if(e)n(e);else if(t){const e={};for(const{stack:n,id:i,glyph:r}of t)void 0===e[n]&&(e[n]={}),void 0===e[n].glyphs&&(e[n].glyphs={}),e[n].glyphs[i]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},e[n].ascender=this.entries[n].ascender,e[n].descender=this.entries[n].descender;n(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==lp.none&&(this.localGlyphMode===lp.all?!!this.localFontFamily:!!this.localFontFamily&&(Qn(e)||io(e)||$n(e)||qn(e)||Gn(e)))}_tinySDF(t,i,e){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(e))return;let n=t.tinySDF;if(!n){let e="400";/bold/i.test(i)?e="900":/medium/i.test(i)?e="500":/light/i.test(i)&&(e="200"),n=t.tinySDF=new cp.TinySDF({fontFamily:r,fontWeight:e,fontSize:48,buffer:6,radius:16}),n.fontWeight=e}if(this.localGlyphs[n.fontWeight][e])return this.localGlyphs[n.fontWeight][e];const o=String.fromCharCode(e),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:p,glyphAdvance:d}=n.draw(o);return this.localGlyphs[n.fontWeight][e]={id:e,bitmap:new ac({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function hp(b,w,T,t){const i=[],E=b.image,A=E.pixelRatio,e=E.paddedRect.w-2,r=E.paddedRect.h-2,S=b.right-b.left,C=b.bottom-b.top,n=E.stretchX||[[0,e]],o=E.stretchY||[[0,r]],s=(e,t)=>e+t[1]-t[0],M=n.reduce(s,0),I=o.reduce(s,0),a=e-M,l=r-I;let B=0,k=M,z=0,P=I,L=0,D=a,R=0,O=l;if(E.content&&t){const b=E.content;B=up(n,0,b[0]),z=up(o,0,b[1]),k=up(n,b[0],b[2]),P=up(o,b[1],b[3]),L=b[0]-B,R=b[1]-z,D=b[2]-b[0]-k,O=b[3]-b[1]-P}const c=(e,t,i,r)=>{const n=dp(e.stretch-B,k,S,b.left),o=fp(e.fixed-L,D,e.stretch,M),s=dp(t.stretch-z,P,C,b.top),a=fp(t.fixed-R,O,t.stretch,I),l=dp(i.stretch-B,k,S,b.left),c=fp(i.fixed-L,D,i.stretch,M),h=dp(r.stretch-z,P,C,b.top),u=fp(r.fixed-R,O,r.stretch,I),p=new F(n,s),d=new F(l,s),f=new F(l,h),m=new F(n,h),_=new F(o/A,a/A),g=new F(c/A,u/A),y=w*Math.PI/180;if(y){const b=Math.sin(y),w=Math.cos(y),T=[w,-b,b,w];p._matMult(T),d._matMult(T),m._matMult(T),f._matMult(T)}const x=e.stretch+e.fixed,v=t.stretch+t.fixed;return{tl:p,tr:d,bl:m,br:f,tex:{x:E.paddedRect.x+1+x,y:E.paddedRect.y+1+v,w:i.stretch+i.fixed-x,h:r.stretch+r.fixed-v},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:_,pixelOffsetBR:g,minFontScaleX:D/A/S,minFontScaleY:O/A/C,isSDF:T}};if(t&&(E.stretchX||E.stretchY)){const b=pp(n,a,M),w=pp(o,l,I);for(let e=0;e<b.length-1;e++){const t=b[e],F=b[e+1];for(let e=0;e<w.length-1;e++)i.push(c(t,w[e],F,w[e+1]))}}else i.push(c({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:e+1},{fixed:0,stretch:r+1}));return i}function up(e,t,i){let r=0;for(const n of e)r+=Math.max(t,Math.min(i,n[1]))-Math.max(t,Math.min(i,n[0]));return r}function pp(e,t,i){const r=[{fixed:-1,stretch:0}];for(const[t,i]of e){const e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return r.push({fixed:t+1,stretch:i}),r}function dp(e,t,i,r){return e/t*i+r}function fp(e,t,i,r){return e-t*i/r}function mp(e,t,i,r){const n=t+e.positionedLines[r].lineOffset;return 0===r?i+n/2:i+(n+(t+e.positionedLines[r-1].lineOffset))/2}cp.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),Ce.Glyphs);ke(a,(e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new lu(e).readFields(Mu,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}})},cp.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(i){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:e,actualBoundingBoxRight:o}=this.ctx.measureText(i),s=Math.ceil(r),a=Math.min(this.size-this.buffer,Math.ceil(o-e)),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),p=new Uint8ClampedArray(u),d={data:p,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(i,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(op,0,u),_.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const r=y.data[4*(t*a+e)+3]/255;if(0===r)continue;const n=(t+m)*c+e+m;if(1===r)g[n]=0,_[n]=op;else{const i=.5-r;g[n]=i>0?i*i:0,_[n]=i<0?i*i:0}}sp(g,0,0,c,h,c,this.f,this.v,this.z),sp(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e<u;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);p[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return d}};class _p{constructor(e=[],t=gp){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(i){const{data:r,compare:n}=this,e=this.length>>1,o=r[i];for(;i<e;){let e=1+(i<<1),t=r[e];const s=e+1;if(s<this.length&&n(r[s],t)<0&&(e=s,t=r[s]),n(t,o)>=0)break;r[i]=t,i=e}r[i]=o}}function gp(e,t){return e<t?-1:e>t?1:0}function yp(i,t=1,e=!1){let r=1/0,n=1/0,o=-1/0,s=-1/0;const a=i[0];for(let e=0;e<a.length;e++){const t=a[e];(!e||t.x<r)&&(r=t.x),(!e||t.y<n)&&(n=t.y),(!e||t.x>o)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-r,s-n);let c=l/2;const h=new _p([],xp);if(0===l)return new F(r,n);for(let t=r;t<o;t+=l)for(let e=n;e<s;e+=l)h.push(new vp(t+c,e+c,c,i));let u=function(e){let r=0,n=0,o=0;const s=e[0];for(let e=0,t=s.length,i=t-1;e<t;i=e++){const a=s[e],l=s[i],c=a.x*l.y-l.x*a.y;n+=(a.x+l.x)*c,o+=(a.y+l.y)*c,r+=3*c}return new vp(n/r,o/r,0,e)}(i),p=h.length;for(;h.length;){const r=h.pop();(r.d>u.d||!u.d)&&(u=r,e&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,p)),r.max-u.d<=t||(c=r.h/2,h.push(new vp(r.p.x-c,r.p.y-c,c,i)),h.push(new vp(r.p.x+c,r.p.y-c,c,i)),h.push(new vp(r.p.x-c,r.p.y+c,c,i)),h.push(new vp(r.p.x+c,r.p.y+c,c,i)),p+=4)}return e&&(console.log(`num probes: ${p}`),console.log(`best distance: ${u.d}`)),u.p}function xp(e,t){return t.max-e.max}function vp(e,t,i,r){this.p=new F(e,t),this.h=i,this.d=function(r,t){let n=!1,o=1/0;for(let e=0;e<t.length;e++){const s=t[e];for(let e=0,t=s.length,i=t-1;e<t;i=e++){const a=s[e],l=s[i];a.y>r.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n),o=Math.min(o,el(r,a,l))}}return(n?1:-1)*Math.sqrt(o)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const bp=Number.POSITIVE_INFINITY,wp=Math.sqrt(2);function Tp(e,t){return t[1]!==bp?function(e,t,i){let r=0,n=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,n]}(e,t[0],t[1]):function(e,t){let i=0,r=0;t<0&&(t=0);const n=t/wp;switch(e){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0])}function Ep(r,n,o,s,a,l,c,h,u,p){r.createArrays(),r.tilePixelRatio=ba/(512*r.overscaling),r.compareText={},r.iconsNeedLinear=!1;const d=r.layers[0].layout,f=r.layers[0]._unevaluatedLayout._values,m={};if("composite"===r.textSizeData.kind){const{minZoom:n,maxZoom:o}=r.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new ko(n),h),f["text-size"].possiblyEvaluate(new ko(o),h)]}if("composite"===r.iconSizeData.kind){const{minZoom:n,maxZoom:o}=r.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new ko(n),h),f["icon-size"].possiblyEvaluate(new ko(o),h)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new ko(u+1),h),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new ko(u+1),h),m.textMaxSize=f["text-size"].possiblyEvaluate(new ko(18),h);const _="map"===d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),g=d.get("text-size");for(const l of r.features){const u=d.get("text-font").evaluate(l,{},h).join(","),f=g.evaluate(l,{},h),y=m.layoutTextSize.evaluate(l,{},h),x=(m.layoutIconSize.evaluate(l,{},h),{horizontal:{},vertical:void 0}),v=l.text;let e,i=[0,0];if(v){const s=v.toString(),c=d.get("text-letter-spacing").evaluate(l,{},h)*Hh,p=d.get("text-line-height").evaluate(l,{},h)*Hh,m=uo(s)?c:0,g=d.get("text-anchor").evaluate(l,{},h),w=d.get("text-variable-anchor");if(!w){const r=d.get("text-radial-offset").evaluate(l,{},h);i=r?Tp(g,[r*Hh,bp]):d.get("text-offset").evaluate(l,{},h).map(e=>e*Hh)}let e=_?"center":d.get("text-justify").evaluate(l,{},h);const T=d.get("symbol-placement"),E="point"===T,A="point"===T?d.get("text-max-width").evaluate(l,{},h)*Hh:0,S=e=>{r.allowVerticalPlacement&&ho(s)&&(x.vertical=Ou(v,n,o,a,u,A,p,g,e,m,i,Lu.vertical,!0,T,y,f))};if(!_&&w){const r="auto"===e?w.map(e=>Ap(e)):[e];let t=!1;for(let e=0;e<r.length;e++){const c=r[e];if(!x.horizontal[c])if(t)x.horizontal[c]=x.horizontal[0];else{const r=Ou(v,n,o,a,u,A,p,"center",c,m,i,Lu.horizontal,!1,T,y,f);r&&(x.horizontal[c]=r,t=1===r.positionedLines.length)}}S("left")}else{if("auto"===e&&(e=Ap(g)),E||d.get("text-writing-mode").indexOf("horizontal")>=0||!ho(s)){const r=Ou(v,n,o,a,u,A,p,g,e,m,i,Lu.horizontal,!1,T,y,f);r&&(x.horizontal[e]=r)}S("point"===T?"left":e)}}let t=!1;if(l.icon&&l.icon.name){const n=s[l.icon.name];n&&(e=Wu(a[l.icon.name],d.get("icon-offset").evaluate(l,{},h),d.get("icon-anchor").evaluate(l,{},h)),t=n.sdf,void 0===r.sdfIcons?r.sdfIcons=n.sdf:r.sdfIcons!==n.sdf&&Y("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(n.pixelRatio!==r.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(r.iconsNeedLinear=!0))}const b=Ip(x.horizontal)||x.vertical;r.iconsInText||(r.iconsInText=!!b&&b.iconsInText),(b||e)&&Sp(r,l,x,e,s,m,y,0,i,t,c,h,p)}l&&r.generateCollisionDebugBuffers(u,r.collisionBoxArray)}function Ap(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Sp(n,o,s,a,l,c,e,t,h,u,p,d,f){let i=c.textMaxSize.evaluate(o,{},d);void 0===i&&(i=e);const r=n.layers[0].layout,m=r.get("icon-offset").evaluate(o,{},d),_=Ip(s.horizontal)||s.vertical,g="globe"===f.name,y=e/24,x=n.tilePixelRatio*i/24,v=(M=n.overscaling,n.zoom>18&&M>2&&(M>>=1),Math.max(ba/(512*M),1)*r.get("symbol-spacing")),b=r.get("text-padding")*n.tilePixelRatio,w=r.get("icon-padding")*n.tilePixelRatio,T=z(r.get("text-max-angle")),E="map"===r.get("text-rotation-alignment")&&"point"!==r.get("symbol-placement"),A="map"===r.get("icon-rotation-alignment")&&"point"!==r.get("symbol-placement"),S=r.get("symbol-placement"),C=v/2;var M;const I=r.get("icon-text-fit");let B;a&&"none"!==I&&(n.allowVerticalPlacement&&s.vertical&&(B=Xu(a,s.vertical,I,r.get("icon-text-fit-padding"),m,y)),_&&(a=Xu(a,_,I,r.get("icon-text-fit-padding"),m,y)));const k=(e,t,i)=>{if(t.x<0||t.x>=ba||t.y<0||t.y>=ba)return;let r=null;if(g){const{x:n,y:o,z:s}=f.projectTilePoint(t.x,t.y,i);r={anchor:new Hu(n,o,s,0,void 0),up:f.upVector(i,t.x,t.y)}}!function(t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,e,_,g,y,x,v,b,w,T,E){const A=t.addToLineVertexArray(i,n);let S,C,M,I,B,k,z,P=0,L=0,D=0,R=0,O=-1,F=-1;const N={};let U=$s("");const j=r?r.anchor:i;let V=0,G=0;if(void 0===c._unevaluatedLayout.getValue("text-radial-offset")?[V,G]=c.layout.get("text-offset").evaluate(v,{},E).map(e=>e*Hh):(V=c.layout.get("text-radial-offset").evaluate(v,{},E)*Hh,G=bp),t.allowVerticalPlacement&&o.vertical){const t=o.vertical;if(m)k=kp(t),l&&(z=kp(l));else{const r=c.layout.get("text-rotate").evaluate(v,{},E)+90;M=Bp(h,j,i,u,p,d,t,f,r,e),l&&(I=Bp(h,j,i,u,p,d,l,g,r))}}if(s){const n=c.layout.get("icon-rotate").evaluate(v,{},E),o="none"!==c.layout.get("icon-text-fit"),a=hp(s,n,w,o),f=l?hp(l,n,w,o):void 0;C=Bp(h,j,i,u,p,d,s,g,n),P=4*a.length;const m=t.iconSizeData;let e=null;"source"===m.kind?(e=[Kh*c.layout.get("icon-size").evaluate(v,{},E)],e[0]>Cp&&Y(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===m.kind&&(e=[Kh*b.compositeIconSizes[0].evaluate(v,{},E),Kh*b.compositeIconSizes[1].evaluate(v,{},E)],(e[0]>Cp||e[1]>Cp)&&Y(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,a,e,x,y,v,!1,r,i,A.lineStartIndex,A.lineLength,-1,T,E),O=t.icon.placedSymbolArray.length-1,f&&(L=4*f.length,t.addSymbols(t.icon,f,e,x,y,v,Lu.vertical,r,i,A.lineStartIndex,A.lineLength,-1,T,E),F=t.icon.placedSymbolArray.length-1)}for(const n in o.horizontal){const s=o.horizontal[n];S||(U=$s(s.text),m?B=kp(s):S=Bp(h,j,i,u,p,d,s,f,c.layout.get("text-rotate").evaluate(v,{},E),e));const l=1===s.positionedLines.length;if(D+=Mp(t,r,i,s,a,c,m,v,e,A,o.vertical?Lu.horizontal:Lu.horizontalOnly,l?Object.keys(o.horizontal):[n],N,O,b,T,E),l)break}o.vertical&&(R+=Mp(t,r,i,o.vertical,a,c,m,v,e,A,Lu.vertical,["vertical"],N,F,b,T,E));let $=-1;const q=(e,t)=>e?Math.max(e,t):t;$=q(B,$),$=q(k,$),$=q(z,$);const Z=$>-1?1:0;t.glyphOffsetArray.length>=Fd.MAX_GLYPHS&&Y("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey),t.symbolInstances.emplaceBack(j.x,j.y,j.z,i.x,i.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,O,F,U,void 0!==S?S:t.collisionBoxArray.length,void 0!==S?S+1:t.collisionBoxArray.length,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,void 0!==C?C:t.collisionBoxArray.length,void 0!==C?C+1:t.collisionBoxArray.length,I||t.collisionBoxArray.length,I?I+1:t.collisionBoxArray.length,u,D,R,P,L,Z,0,V,G,$)}(n,t,r,e,s,a,l,B,n.layers[0],n.collisionBoxArray,o.index,o.sourceLayerIndex,n.index,b,E,h,0,w,A,m,o,c,u,p,d)};if("line"===S)for(const l of np(o.geometry,0,0,ba,ba)){const o=ip(l,v,T,s.vertical||_,a,24,x,n.overscaling,ba);for(const s of o){const o=_;o&&zp(n,o.text,C,s)||k(l,s,d)}}else if("line-center"===S){for(const n of o.geometry)if(n.length>1){const o=tp(n,T,s.vertical||_,a,24,x);o&&k(n,o,d)}}else if("Polygon"===o.type)for(const n of Zc(o.geometry,0)){const o=yp(n,16);k(n[0],new Hu(o.x,o.y,0,0,void 0),d)}else if("LineString"===o.type)for(const n of o.geometry)k(n,new Hu(n[0].x,n[0].y,0,0,void 0),d);else if("Point"===o.type)for(const n of o.geometry)for(const o of n)k([o],new Hu(o.x,o.y,0,0,void 0),d)}const Cp=32640;function Mp(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_){const g=function(u,p,d,f,m,e,_,g){const y=[];if(0===p.positionedLines.length)return y;const x=f.layout.get("text-rotate").evaluate(e,{})*Math.PI/180,v=function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]}(d);let t=Math.abs(p.top-p.bottom);for(const u of p.positionedLines)t-=u.lineOffset;const i=p.positionedLines.length,r=t/i;let b=p.top-d[1];for(let e=0;e<i;++e){const f=p.positionedLines[e];b=mp(p,r,b,e);for(const u of f.positionedGlyphs){if(!u.rect)continue;const f=u.rect||{};let e=4,t=!0,i=1,r=0;if(u.imageName){const p=_[u.imageName];if(!p)continue;if(p.sdf){Y("SDF images are not supported in formatted text and will be ignored.");continue}t=!1,i=p.pixelRatio,e=1/i}const w=(m||g)&&u.vertical,T=u.metrics.advance*u.scale/2,E=u.metrics,A=u.rect;if(null===A)continue;g&&p.verticalizable&&(r=u.imageName?T-u.metrics.width*u.scale/2:0);const S=m?[u.x+T,u.y]:[0,0];let n=[0,0],o=[0,0],s=!1;m||(w?(o=[u.x+T+v[0],u.y+v[1]-r],s=!0):n=[u.x+T+d[0],u.y+d[1]-r]);const C=A.w*u.scale/(i*(u.localGlyph?2:1)),M=A.h*u.scale/(i*(u.localGlyph?2:1));let a,l,c,h;if(w){const p=u.y-b,d=new F(-T,T-p),f=-Math.PI/2,m=new F(...o);a=new F(-T+n[0],n[1]),a._rotateAround(f,d)._add(m),a.x+=-p+T,a.y-=(E.left-e)*u.scale;const _=u.imageName?E.advance*u.scale:Hh*u.scale,g=String.fromCharCode(u.glyph);nu(g)?a.x+=(1-e)*u.scale:ou(g)?a.x+=_-E.height*u.scale+(-e-1)*u.scale:a.x+=u.imageName||E.width+2*e===A.w&&E.height+2*e===A.h?(_-M)/2:(_-(E.height+2*e)*u.scale)/2,l=new F(a.x,a.y-C),c=new F(a.x+M,a.y),h=new F(a.x+M,a.y-C)}else{const p=(E.left-e)*u.scale-T+n[0],d=(-E.top-e)*u.scale+n[1],f=p+C,m=d+M;a=new F(p,d),l=new F(f,d),c=new F(p,m),h=new F(f,m)}if(x){let e;e=m?new F(0,0):s?new F(v[0],v[1]):new F(d[0],d[1]),a._rotateAround(x,e),l._rotateAround(x,e),c._rotateAround(x,e),h._rotateAround(x,e)}const I=new F(0,0),B=new F(0,0);y.push({tl:a,tr:l,bl:c,br:h,tex:f,writingMode:p.writingMode,glyphOffset:S,sectionIndex:u.sectionIndex,isSDF:t,pixelOffsetTL:I,pixelOffsetBR:B,minFontScaleX:0,minFontScaleY:0})}}return y}(0,r,l,o,s,a,n,e.allowVerticalPlacement),y=e.textSizeData;let x=null;"source"===y.kind?(x=[Kh*o.layout.get("text-size").evaluate(a,{},_)],x[0]>Cp&&Y(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===y.kind&&(x=[Kh*f.compositeTextSizes[0].evaluate(a,{},_),Kh*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Cp||x[1]>Cp)&&Y(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,x,l,s,a,h,t,i,c.lineStartIndex,c.lineLength,d,m,_);for(const t of u)p[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function Ip(e){for(const t in e)return e[t];return null}function Bp(t,i,r,n,o,e,s,a,l,c){let h=s.top,u=s.bottom,p=s.left,d=s.right;const f=s.collisionPadding;if(f&&(p-=f[0],h-=f[1],d+=f[2],u+=f[3]),l){const t=new F(p,h),i=new F(d,h),r=new F(p,u),n=new F(d,u),o=z(l);let e=new F(0,0);c&&(e=new F(c[0],c[1])),t._rotateAround(o,e),i._rotateAround(o,e),r._rotateAround(o,e),n._rotateAround(o,e),p=Math.min(t.x,i.x,r.x,n.x),d=Math.max(t.x,i.x,r.x,n.x),h=Math.min(t.y,i.y,r.y,n.y),u=Math.max(t.y,i.y,r.y,n.y)}return t.emplaceBack(i.x,i.y,i.z,r.x,r.y,p,h,d,u,a,n,o,e),t.length-1}function kp(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function zp(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<i)return!0}else n[e]=[];return n[e].push(r),!1}const Pp=Ho([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),{members:Lp}=Pp,Dp=Ho([{name:"a_pos_3",components:3,type:"Int16"}]);var Rp=Ho([{name:"a_pos",type:"Int16",components:2}]);const Op=ba/Math.PI/2,Fp=2*Ia(1,0)*Op*Math.PI,Np=[64,32,16],Up=-Op,jp=Op,Vp=[new Kl([Up,Up,Up],[jp,jp,jp]),new Kl([Up,Up,Up],[0,0,jp]),new Kl([0,Up,Up],[jp,0,jp]),new Kl([Up,0,Up],[0,jp,jp]),new Kl([0,0,Up],[jp,jp,jp])];function Gp(e,t,i,r=!0){const n=kl([],e._camera.position,e.worldSize),o=[t,i,1,1];Gl(o,o,e.pixelMatrixInverse),Vl(o,o,1/o[3]);const s=Pl([],Nl([],o,n)),a=e.globeMatrix,l=[a[12],a[13],a[14]],c=Nl([],l,n),h=El(c),u=Pl([],c),p=e.worldSize/(2*Math.PI),d=Ll(u,s),f=Math.asin(p/h);if(f<Math.acos(d)){if(!r)return null;const e=[],t=[];kl(e,s,h/d),Pl(t,Nl(t,e,c)),Pl(s,Sl(s,c,kl(s,t,Math.tan(f)*h)))}const m=[];new Wl(n,s).closestPointOnSphere(l,p,m);const _=Pl([],O(a,0)),g=Pl([],O(a,1)),y=Pl([],O(a,2)),x=Ll(_,m),v=Ll(g,m),b=Ll(y,m),w=S(Math.asin(-v/p));let T=S(Math.atan2(x,b));T=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,T);const E=Ca(T),A=C(Ma(w),0,1);return new La(E,A)}class $p{constructor(e,t,i){this.a=Nl([],e,i),this.b=Nl([],t,i),this.center=i;const r=Pl([],this.a),n=Pl([],this.b);this.angle=Math.acos(Ll(r,n))}}function qp(e,t){if(0===e.angle)return null;let i;return i=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),i<0||i>1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,C(i,0,1))+e.center[t]}function Zp(e){if(e.z<=1)return Vp[e.z+2*e.y+e.x];const[t,i]=Wp(e),r=[Hp(t[0],t[1]),Hp(t[0],i[1]),Hp(i[0],t[1]),Hp(i[0],i[1])],n=[jp,jp,jp],o=[Up,Up,Up];for(const e of r)n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.min(n[2],e[2]),o[0]=Math.max(o[0],e[0]),o[1]=Math.max(o[1],e[1]),o[2]=Math.max(o[2],e[2]);return new Kl(n,o)}function Yp(t,e,i){const r=e/t.worldSize,n=Number.MAX_VALUE,o=[-n,-n,-n],s=[n,n,n],a=fl(new Float64Array(16));if(gl(a,a,[r,r,r]),ml(a,a,t.globeMatrix),i.z<=1){const t=Zp(i).getCorners();for(let e=0;e<t.length;e++)Rl(t[e],t[e],a),Il(s,s,t[e]),Bl(o,o,t[e]);return new Kl(s,o)}const[l,c]=Wp(i),h=new wa;h.setSouthWest([l[1],c[0]]),h.setNorthEast([c[1],l[0]]);const u=[Hp(h.getSouth(),h.getWest()),Hp(h.getSouth(),h.getEast()),Hp(h.getNorth(),h.getEast()),Hp(h.getNorth(),h.getWest())];for(let e=0;e<u.length;e++)Rl(u[e],u[e],a),Il(s,s,u[e]),Bl(o,o,u[e]);if(h.contains(t.center)){o[2]=0;const e=t.point,i=[e.x*r,e.y*r,0];return Il(s,s,i),Bl(o,o,i),new Kl(s,o)}const p=[a[12],a[13],a[14]],d=t.center.lng,f=C(t.center.lat,-85.051129,Pa),m=[Ca(d),Ma(f)],_=h.getCenter().lng,g=C(h.getCenter().lat,-85.051129,Pa),y=[Ca(_),Ma(g)];let x=new Array(3),v=0,b=m[0]-y[0];const w=m[1]-y[1];if(b>.5?b-=1:b<-.5&&(b+=1),Math.abs(b)>Math.abs(w))v=b>=0?1:3,x=p;else{v=w>=0?0:2;const t=[a[4],a[5],a[6]];let e;e=w>=0?-Math.sin(z(h.getSouth()))*Op:-Math.sin(z(h.getNorth()))*Op,x=zl(x,p,t,e)}const T=u[v],E=u[(v+1)%4],A=new $p(T,E,x),S=[qp(A,0)||T[0],qp(A,1)||T[1],qp(A,2)||T[2]];return s[2]=Math.min(T[2],E[2]),Il(s,s,S),Bl(o,o,S),new Kl(s,o)}function Wp(e){const t=1<<e.z,i=e.x/t,r=(e.x+1)/t,n=(e.y+1)/t;return[[ka(e.y/t),Ba(i)],[ka(n),Ba(r)]]}function Xp(e,t,i,r=Op){return i=z(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function Hp(e,t,i){return Xp(Math.cos(z(e)),Math.sin(z(e)),t,i)}function Kp(e,t,i){const r=Math.pow(2,i.z),n=(e/ba+i.x)/r;return Hp(ka((t/ba+i.y)/r),Ba(n))}function Jp(e){return 16383/Math.max(...Nl([],e.max,e.min))}function Qp(e){const t=fl(new Float64Array(16)),i=Jp(e);var r,n;return gl(t,t,[i,i,i]),_l(t,t,((r=[])[0]=-(n=e.min)[0],r[1]=-n[1],r[2]=-n[2],r)),t}function ed(e){const t=fl(new Float64Array(16)),i=1/Jp(e);return _l(t,t,e.min),gl(t,t,[i,i,i]),t}function td(e,t,i,r,n){const o=function(e){const t=ba/(2*Math.PI);return e/(2*Math.PI)/t}(i),s=[e,t,-i/(2*Math.PI)],a=fl(new Float64Array(16));return _l(a,a,s),gl(a,a,[o,o,o]),yl(a,a,z(-n)),xl(a,a,z(-r)),a}function id(e){return h(5,6,e)}function rd(e,t){const i=Hp(t.lat,t.lng);return o=(r=Cl([],function(e){const t=Hp(e._center.lat,e._center.lng);let i=Dl([],Al(0,1,0),t);const r=vl([],-e.angle,t);i=Rl(i,i,r),vl(r,-e._pitch,i);const n=Pl([],t);return kl(n,n,e.cameraToCenterDistance/e.pixelsPerMeter*Fp),Rl(n,n,r),Sl([],t,n)}(e),i))[0],s=r[1],a=r[2],l=(n=i)[0],c=n[1],h=n[2],p=(u=Math.sqrt(o*o+s*s+a*a)*Math.sqrt(l*l+c*c+h*h))&&Ll(r,n)/u,Math.acos(Math.min(Math.max(p,-1),1));var r,n,o,s,a,l,c,h,u,p}const nd=z(85),od=Math.cos(nd),sd=Math.sin(nd);function ad(e,t){const i=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01)),s=Math.sin(e._pitch)*o+n;return Math.min(1.01*s,n*(1/e._horizonShift))}function ld(e,h){if(!h.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:h};const t=Math.pow(2,-e.z),i=e.x*t,r=(e.x+1)*t,n=e.y*t,o=(e.y+1)*t,s=Ba(i),a=Ba(r),l=ka(n),c=ka(o),u=h.project(s,l),p=h.project(a,l),d=h.project(a,c),f=h.project(s,c);let m=Math.min(u.x,p.x,d.x,f.x),_=Math.min(u.y,p.y,d.y,f.y),g=Math.max(u.x,p.x,d.x,f.x),y=Math.max(u.y,p.y,d.y,f.y);const x=t/16;function v(e,t,i,r,n,o){const s=(i+n)/2,a=(r+o)/2,l=h.project(Ba(s),ka(a)),c=Math.max(0,m-l.x,_-l.y,l.x-g,l.y-y);m=Math.min(m,l.x),g=Math.max(g,l.x),_=Math.min(_,l.y),y=Math.max(y,l.y),c>x&&(v(e,l,i,r,s,a),v(l,t,s,a,n,o))}v(u,p,i,n,r,n),v(p,d,r,n,r,o),v(d,f,r,o,i,o),v(f,u,i,o,i,n),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:h}}const cd=fl(new Float32Array(16));class hd{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new Ea(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return Ia(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return ad(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new F(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new F(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return cd}createTileMatrix(e,t,i){let r,n,o;const s=i.canonical,a=fl(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=ld(s,this);r=1,n=l.x+i.wrap*l.scale,o=l.y,gl(a,a,[r/l.scale,r/l.scale,e.pixelsPerMeter/t])}else r=t/e.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return _l(a,a,[n,o,0]),gl(a,a,[r/ba,r/ba,1]),a}upVector(e,t,i){return[0,0,1]}upVectorScale(e,t,i){return{metersToTile:1}}}class ud extends hd{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],r=Math.sin(z(t));this.n=(r+Math.sin(z(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:i,c:r,r0:n}=this,o=z(e-this.center[0]),s=z(t),a=Math.sqrt(r-2*i*Math.sin(s))/i;return{x:a*Math.sin(o*i),y:a*Math.cos(o*i)-n,z:0}}unproject(e,t){const{n:i,c:r,r0:n}=this,o=n+t;let s=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(s-=Math.PI*Math.sign(e)*Math.sign(o));const a=z(this.center[0])*i;s=d(s,-Math.PI-a,Math.PI-a);const l=S(s/i)+this.center[0],c=Math.asin(C((r-(e*e+o*o)*i*i)/(2*i),-1,1)),h=C(S(c),-85.051129,Pa);return new Ea(l,h)}}const pd=1.340264,dd=-.081106,fd=893e-6,md=.003796,_d=Math.sqrt(3)/2;class gd extends hd{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(_d*Math.sin(t)),r=i*i,n=r*r*r;return{x:.5*(e*Math.cos(i)/(_d*(pd+3*dd*r+n*(7*fd+9*md*r)))/Math.PI+.5),y:1-.5*(i*(pd+dd*r+n*(fd+md*r))/Math.PI+1),z:0}}unproject(e,n){e=(2*e-.5)*Math.PI;let o=n=(2*(1-n)-1)*Math.PI,s=o*o,a=s*s*s;for(let e,t,i,r=0;r<12&&(t=o*(pd+dd*s+a*(fd+md*s))-n,i=pd+3*dd*s+a*(7*fd+9*md*s),e=t/i,o=C(o-e,-Math.PI/3,Math.PI/3),s=o*o,a=s*s*s,!(Math.abs(e)<1e-12));++r);const t=_d*e*(pd+3*dd*s+a*(7*fd+9*md*s))/Math.cos(o),i=Math.asin(Math.sin(o)/_d),r=C(180*t/Math.PI,-180,180),l=C(180*i/Math.PI,-85.051129,Pa);return new Ea(r,l)}}class yd extends hd{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const i=360*(e-.5),r=C(360*(.5-t),-85.051129,Pa);return new Ea(i,r)}}const xd=Math.PI/2;function vd(e){return Math.tan((xd+e)/2)}class bd extends hd{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30],r=z(t),n=z(i),o=Math.cos(r);this.n=r===n?Math.sin(r):Math.log(o/Math.cos(n))/Math.log(vd(n)/vd(r)),this.f=o*Math.pow(vd(r),this.n)/this.n}project(e,t){t=z(t),e=z(e-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?t<-xd+i&&(t=-xd+i):t>xd-i&&(t=xd-i);const o=n/Math.pow(vd(t),r),s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=C(S(a/i)+this.center[0],-180,180),c=C(S(2*Math.atan(Math.pow(r/s,1/i))-xd),-85.051129,Pa);return new Ea(l,c)}}class wd extends hd{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Ca(e),y:Ma(t),z:0}}unproject(e,t){const i=Ba(e),r=ka(t);return new Ea(i,r)}}const Td=z(Pa);class Ed extends hd{project(e,t){const i=(t=z(t))*t,r=i*i;return{x:.5*((e=z(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=C(i-n,-Td,Td)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=C(S(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=S(i);return new Ea(s,a)}}const Ad=z(Pa);class Sd extends hd{project(e,t){t=z(t),e=z(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,S=o*o,c=n*n,h=Math.cos(i/2),u=Math.sin(i/2),p=2*h*u,d=u*u,f=1-c*h*h,m=f?1/f:0,_=f?Math.acos(n*h)*Math.sqrt(1/f):0,g=.5*(2*_*n*u+2*i/Math.PI)-e,y=.5*(_*o+r)-t,x=.5*m*(c*d+_*n*h*S)+1/Math.PI,v=m*(p*l/4-_*o*u),b=.125*m*(l*u-_*o*c*p),w=.5*m*(S*h+_*d*n)+.5,T=v*b-w*x;s=(y*v-g*w)/T,a=(g*b-y*x)/T,i=C(i-s,-Math.PI,Math.PI),r=C(r-a,-Ad,Ad)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new Ea(S(i),S(r))}}class Cd extends hd{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(z(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:r}=this;return{x:z(e)*r*i+.5,y:-Math.sin(z(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=C(S((e-.5)/i)/r,-180,180),s=Math.asin(C(n*r,-1,1)),a=C(S(s),-85.051129,Pa);return new Ea(o,a)}}class Md extends wd{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(e,t,i){const r=Math.pow(2,i.z),n=(e/ba+i.x)/r,o=Hp(ka((t/ba+i.y)/r),Ba(n));return Rl(o,o,Qp(Zp(i))),{x:o[0],y:o[1],z:o[2]}}locationPoint(e,t){const i=Hp(t.lat,t.lng),r=Pl([],i),n=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;zl(i,i,r,Ia(1,0)*ba*n);const o=fl(new Float64Array(16));return ml(o,e.pixelMatrix,e.globeMatrix),Rl(i,i,o),new F(i[0],i[1])}pixelsPerMeter(e,t){return Ia(1,0)*t}pixelSpaceConversion(e,t,i){const r=gi(Ia(1,45)*t,Ia(1,e)*t,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const r=ed(Zp(i.canonical));return ml(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=fl(new Float64Array(16));return ml(r,r,Qp(Zp(t))),xl(r,r,z(i.lng)),yl(r,r,z(i.lat)),gl(r,r,[e._projectionScaler,e._projectionScaler,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return Gp(e,t,i,!0)||new La(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Gp(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=Sl([],kl([],o,-i),[0,0,r]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),u=kl([],n.up(),h),p=kl([],n.right(),h*c),d=Pl([],Sl([],Sl([],o,u),p)),f=[];let m;if(new Wl(s,d).closestPointOnSphere(l,a,f)){const t=Sl([],f,l),i=Nl([],t,s);m=Math.cos(e.fovAboveCenter)*El(i)}else{const e=Nl([],s,l),t=Nl([],l,s);Pl(t,t);const i=El(e)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(Ll(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=id(e.zoom);if(i>0){const r=ad(e,Ia(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return gi(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){const r=1<<e.z,n=(t/ba+e.x)/r;return Hp(ka((i/ba+e.y)/r),Ba(n),1)}upVectorScale(e){return{metersToTile:Fp*Jp(Zp(e))}}}function Id(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new wd(e);case"equirectangular":return new yd(e);case"naturalEarth":return new Ed(e);case"equalEarth":return new gd(e);case"winkelTripel":return new Sd(e);case"albers":return i?new Cd(e):new ud(e);case"lambertConformalConic":return i?new Cd(e):new bd(e);case"globe":return new Md(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Bd=uh.VectorTileFeature.types,kd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function zd(e,t,i,r,n,o,s,a,l,c,h,u,p){const d=a?Math.min(Cp,Math.round(a[0])):0,f=a?Math.min(Cp,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(d<<1)+(l?1:0),f,16*c,16*h,256*u,256*p)}function Pd(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s)}function Ld(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n)}function Dd(e){for(const t of e.sections)if(yo(t.text))return!0;return!1}class Rd{constructor(e){this.layoutVertexArray=new ss,this.indexArray=new fs,this.programConfigurations=e,this.segments=new va,this.dynamicLayoutVertexArray=new is,this.opacityVertexArray=new ls,this.placedSymbolArray=new Is,this.globeExtVertexArray=new as}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,qh.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,kd,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,$h.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}kn(Rd,"SymbolBuffers");class Od{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new va,this.collisionVertexArray=new ps,this.collisionVertexArrayExt=new ds}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Zh.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Yh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}kn(Od,"CollisionBuffers");class Fd{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=fl([]),this.placementViewportMatrix=fl([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Jh(this.zoom,t["text-size"]),this.iconSizeData=Jh(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(e=>Lu[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Rd(new ha(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Rd(new ha(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new zs,this.lineVertexArray=new Ps,this.symbolInstances=new ks}calculateGlyphDependencies(t,i,e,r,n){for(let e=0;e<t.length;e++)if(i[t.charCodeAt(e)]=!0,r&&n){const r=ru[t.charAt(e)];r&&(i[r.charCodeAt(0)]=!0)}}populate(i,r,n,o){const s=this.layers[0],a=s.layout,l="globe"===this.projection.name,c=a.get("text-font"),h=a.get("text-field"),u=a.get("icon-image"),p=("constant"!==h.value.kind||h.value.value instanceof vt&&!h.value.value.isEmpty()||h.value.value.toString().length>0)&&("constant"!==c.value.kind||c.value.value.length>0),d="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,f=a.get("symbol-sort-key");if(this.features=[],!p&&!d)return;const m=r.iconDependencies,_=r.glyphDependencies,g=r.availableImages,y=new ko(this.zoom);for(const{feature:r,id:h,index:u,sourceLayerIndex:x}of i){const i=s._featureFilter.needGeometry,v=Ga(r,i);if(!s._featureFilter.filter(y,v,n))continue;if(i||(v.geometry=Va(r,n,o)),l&&1!==r.type&&n.z<=5){const i=v.geometry,r=1<<n.z,o=n.x,s=n.y,a=.98078528056;for(let e=0;e<i.length;e++)i[e]=Fa(i[e],e=>e,(e,t)=>Ll(Hp(ka((e.y/ba+s)/r),Ba((e.x/ba+o)/r),1),Hp(ka((t.y/ba+s)/r),Ba((t.x/ba+o)/r),1))<a)}let e,t;if(p){const i=s.getValueAndResolveTokens("text-field",v,n,g),r=vt.factory(i);Dd(r)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Mo()||this.hasRTLText&&Bo.isParsed())&&(e=iu(r,s,v))}if(d){const i=s.getValueAndResolveTokens("icon-image",v,n,g);t=i instanceof bt?i:bt.fromString(i)}if(!e&&!t)continue;const b=this.sortFeaturesByKey?f.evaluate(v,{},n):void 0;if(this.features.push({id:h,text:e,icon:t,index:u,sourceLayerIndex:x,geometry:v.geometry,properties:r.properties,type:Bd[r.type],sortKey:b}),t&&(m[t.name]=!0),e){const i=c.evaluate(v,{},n).join(","),r="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Lu.vertical)>=0;for(const n of e.sections)if(n.image)m[n.image.name]=!0;else{const o=ho(e.toString()),s=n.fontStack||i,a=_[s]=_[s]||{};this.calculateGlyphDependencies(n.text,a,r,this.allowVerticalPlacement,o)}}}"line"===a.get("symbol-placement")&&(this.features=function(t){const n={},o={},s=[];let i=0;function r(e){s.push(t[e]),i++}function a(e,t,i){const r=o[e];return delete o[e],o[t]=r,s[r].geometry[0].pop(),s[r].geometry[0]=s[r].geometry[0].concat(i[0]),r}function l(e,t,i){const r=n[t];return delete n[t],n[e]=r,s[r].geometry[0].shift(),s[r].geometry[0]=i[0].concat(s[r].geometry[0]),r}function c(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let e=0;e<t.length;e++){const h=t[e],u=h.geometry,p=h.text?h.text.toString():null;if(!p){r(e);continue}const d=c(p,u),f=c(p,u,!0);if(d in o&&f in n&&o[d]!==n[f]){const t=l(d,f,u),i=a(d,f,s[t].geometry);delete n[d],delete o[f],o[c(p,s[i].geometry,!0)]=i,s[t].geometry=null}else d in o?a(d,f,u):f in n?l(d,f,u):(r(e),n[d]=i-1,o[f]=i-1)}return s.filter(e=>e.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Id(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const t=this.lineVertexArray.length,n=e.segment;if(void 0!==n){let t=e.dist(r[n+1]),i=e.dist(r[n]);const o={};for(let e=n+1;e<r.length;e++)o[e]={x:r[e].x,y:r[e].y,tileUnitDistanceFromAnchor:t},e<r.length-1&&(t+=r[e+1].dist(r[e]));for(let e=n||0;e>=0;e--)o[e]={x:r[e].x,y:r[e].y,tileUnitDistanceFromAnchor:i},e>0&&(i+=r[e-1].dist(r[e]));for(let e=0;e<r.length;e++){const r=o[e];this.lineVertexArray.emplaceBack(r.x,r.y,r.tileUnitDistanceFromAnchor)}}return{lineStartIndex:t,lineLength:this.lineVertexArray.length-t}}addSymbols(t,i,r,e,n,o,s,a,l,c,h,u,p,d){const f=t.indexArray,m=t.layoutVertexArray,_=t.globeExtVertexArray,g=t.segments.prepareSegment(4*i.length,m,f,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,x=g.vertexLength,v=this.allowVerticalPlacement&&s===Lu.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let e=0;e<i.length;e++){const{tl:n,tr:s,bl:c,br:h,tex:u,pixelOffsetTL:y,pixelOffsetBR:x,minFontScaleX:w,minFontScaleY:T,glyphOffset:E,isSDF:A,sectionIndex:S}=i[e],C=g.vertexLength,M=E[1];if(zd(m,l.x,l.y,n.x,M+n.y,u.x,u.y,r,A,y.x,y.y,w,T),zd(m,l.x,l.y,s.x,M+s.y,u.x+u.w,u.y,r,A,x.x,y.y,w,T),zd(m,l.x,l.y,c.x,M+c.y,u.x,u.y+u.h,r,A,y.x,x.y,w,T),zd(m,l.x,l.y,h.x,M+h.y,u.x+u.w,u.y+u.h,r,A,x.x,x.y,w,T),a){const i=a.anchor,r=a.up;Pd(_,i.x,i.y,i.z,r[0],r[1],r[2]),Pd(_,i.x,i.y,i.z,r[0],r[1],r[2]),Pd(_,i.x,i.y,i.z,r[0],r[1],r[2]),Pd(_,i.x,i.y,i.z,r[0],r[1],r[2]),Ld(t.dynamicLayoutVertexArray,i.x,i.y,i.z,v)}else Ld(t.dynamicLayoutVertexArray,l.x,l.y,l.z,v);f.emplaceBack(C,C+1,C+2),f.emplaceBack(C+1,C+2,C+3),g.vertexLength+=4,g.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),e!==i.length-1&&S===i[e+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,o,o.index,{},p,d,b&&b[S])}const w=a?a.anchor:l;t.placedSymbolArray.emplaceBack(w.x,w.y,w.z,l.x,l.y,y,this.glyphOffsetArray.length-y,x,c,h,l.segment,r?r[0]:0,r?r[1]:0,e[0],e[1],s,0,!1,0,u,0)}_commitLayoutVertex(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(e,t,i,r,n,o,s){const a=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),l=a.vertexLength,c=s.tileAnchorX,h=s.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(t,-e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,e.padding),i.collisionVertexArrayExt.emplaceBack(t,-e.padding,e.padding),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new F(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new F(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new F(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new F(e.x1,e.y2)),a.vertexLength+=4;const u=i.indexArray;u.emplaceBack(l,l+1),u.emplaceBack(l+1,l+2),u.emplaceBack(l+2,l+3),u.emplaceBack(l+3,l),a.primitiveLength+=4}_addTextDebugCollisionBoxes(t,i,r,n,o,s){for(let e=n;e<o;e++){const n=r.get(e),o=this.getSymbolInstanceTextSize(t,s,i,e);this._addCollisionDebugVertices(n,o,this.textCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,s)}}_addIconDebugCollisionBoxes(t,i,r,n,o,s){for(let e=n;e<o;e++){const n=r.get(e),o=this.getSymbolInstanceIconSize(t,i,e);this._addCollisionDebugVertices(n,o,this.iconCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,s)}}generateCollisionDebugBuffers(t,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Od(hs,Wh.members,bs),this.iconCollisionBox=new Od(hs,Wh.members,bs);const r=eu(this.iconSizeData,t),n=eu(this.textSizeData,t);for(let e=0;e<this.symbolInstances.length;e++){const o=this.symbolInstances.get(e);this._addTextDebugCollisionBoxes(n,t,i,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(n,t,i,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,t,i,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,t,i,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,i,r){const n=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=Qh(this.textSizeData,e,n)/Hh;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=Qh(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i){e.emplaceBack(t,-i,-i),e.emplaceBack(t,i,-i),e.emplaceBack(t,i,i),e.emplaceBack(t,-i,i)}_updateTextDebugCollisionBoxes(t,i,r,n,o,s){for(let e=n;e<o;e++){const n=r.get(e),o=this.getSymbolInstanceTextSize(t,s,i,e);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,o,n.padding)}}_updateIconDebugCollisionBoxes(t,i,r,n,o){for(let e=n;e<o;e++){const n=r.get(e),o=this.getSymbolInstanceIconSize(t,i,e);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,o,n.padding)}}updateCollisionDebugBuffers(t,i){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const r=eu(this.iconSizeData,t),n=eu(this.textSizeData,t);for(let e=0;e<this.symbolInstances.length;e++){const o=this.symbolInstances.get(e);this._updateTextDebugCollisionBoxes(n,t,i,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(n,t,i,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(r,t,i,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(r,t,i,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(t,i,r,n,o,s,a,l,c){const h={};for(let e=i;e<r;e++){const i=t.get(e);h.textBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},h.textFeatureIndex=i.featureIndex;break}for(let e=n;e<o;e++){const r=t.get(e);h.verticalTextBox={x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,padding:r.padding,projectedAnchorX:r.projectedAnchorX,projectedAnchorY:r.projectedAnchorY,projectedAnchorZ:r.projectedAnchorZ,tileAnchorX:r.tileAnchorX,tileAnchorY:r.tileAnchorY},h.verticalTextFeatureIndex=r.featureIndex;break}for(let e=s;e<a;e++){const r=t.get(e);h.iconBox={x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,padding:r.padding,projectedAnchorX:r.projectedAnchorX,projectedAnchorY:r.projectedAnchorY,projectedAnchorZ:r.projectedAnchorZ,tileAnchorX:r.tileAnchorX,tileAnchorY:r.tileAnchorY},h.iconFeatureIndex=r.featureIndex;break}for(let e=l;e<c;e++){const r=t.get(e);h.verticalIconBox={x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,padding:r.padding,projectedAnchorX:r.projectedAnchorX,projectedAnchorY:r.projectedAnchorY,projectedAnchorZ:r.projectedAnchorZ,tileAnchorX:r.tileAnchorX,tileAnchorY:r.tileAnchorY},h.verticalIconFeatureIndex=r.featureIndex;break}return h}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);r.push(0|Math.round(t*s.tileAnchorX+i*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort((e,t)=>r[e]-r[t]||n[t]-n[e]),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}kn(Fd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Fd.MAX_GLYPHS=65535,Fd.addDynamicAttributes=Ld;const Nd=new qo({"symbol-placement":new Uo($e.layout_symbol["symbol-placement"]),"symbol-spacing":new Uo($e.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Uo($e.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo($e.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Uo($e.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Uo($e.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Uo($e.layout_symbol["icon-ignore-placement"]),"icon-optional":new Uo($e.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Uo($e.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo($e.layout_symbol["icon-size"]),"icon-text-fit":new Uo($e.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Uo($e.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo($e.layout_symbol["icon-image"]),"icon-rotate":new jo($e.layout_symbol["icon-rotate"]),"icon-padding":new Uo($e.layout_symbol["icon-padding"]),"icon-keep-upright":new Uo($e.layout_symbol["icon-keep-upright"]),"icon-offset":new jo($e.layout_symbol["icon-offset"]),"icon-anchor":new jo($e.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Uo($e.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Uo($e.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Uo($e.layout_symbol["text-rotation-alignment"]),"text-field":new jo($e.layout_symbol["text-field"]),"text-font":new jo($e.layout_symbol["text-font"]),"text-size":new jo($e.layout_symbol["text-size"]),"text-max-width":new jo($e.layout_symbol["text-max-width"]),"text-line-height":new jo($e.layout_symbol["text-line-height"]),"text-letter-spacing":new jo($e.layout_symbol["text-letter-spacing"]),"text-justify":new jo($e.layout_symbol["text-justify"]),"text-radial-offset":new jo($e.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Uo($e.layout_symbol["text-variable-anchor"]),"text-anchor":new jo($e.layout_symbol["text-anchor"]),"text-max-angle":new Uo($e.layout_symbol["text-max-angle"]),"text-writing-mode":new Uo($e.layout_symbol["text-writing-mode"]),"text-rotate":new jo($e.layout_symbol["text-rotate"]),"text-padding":new Uo($e.layout_symbol["text-padding"]),"text-keep-upright":new Uo($e.layout_symbol["text-keep-upright"]),"text-transform":new jo($e.layout_symbol["text-transform"]),"text-offset":new jo($e.layout_symbol["text-offset"]),"text-allow-overlap":new Uo($e.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Uo($e.layout_symbol["text-ignore-placement"]),"text-optional":new Uo($e.layout_symbol["text-optional"])});var Ud={paint:new qo({"icon-opacity":new jo($e.paint_symbol["icon-opacity"]),"icon-color":new jo($e.paint_symbol["icon-color"]),"icon-halo-color":new jo($e.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo($e.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo($e.paint_symbol["icon-halo-blur"]),"icon-translate":new Uo($e.paint_symbol["icon-translate"]),"icon-translate-anchor":new Uo($e.paint_symbol["icon-translate-anchor"]),"text-opacity":new jo($e.paint_symbol["text-opacity"]),"text-color":new jo($e.paint_symbol["text-color"],{runtimeType:it,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new jo($e.paint_symbol["text-halo-color"]),"text-halo-width":new jo($e.paint_symbol["text-halo-width"]),"text-halo-blur":new jo($e.paint_symbol["text-halo-blur"]),"text-translate":new Uo($e.paint_symbol["text-translate"]),"text-translate-anchor":new Uo($e.paint_symbol["text-translate-anchor"])}),layout:Nd};class jd{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Je,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}kn(jd,"FormatSectionOverride",{omit:["defaultValue"]});class Vd extends ga{constructor(e){super(e,Ud)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||Pr(o.value)||!n?n:function(i,e){return e.replace(/{([^{}]+)}/g,(e,t)=>t in i?String(i[t]):"")}(t.properties,n)}createBucket(e){return new Fd(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Ud.paint.overridableProperties){if(!Vd.hasPaintOverride(this.layout,t))continue;const i=this.paint.get(t),r=new jd(i),n=new zr(r,i.property.specification);let e=null;e="constant"===i.value.kind||"source"===i.value.kind?new Dr("source",n):new Rr("composite",n,i.value.zoomStops,i.value._interpolationType),this.paint._values[t]=new Fo(i.property,e,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Vd.hasPaintOverride(this.layout,e)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Ud.paint.properties[e];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof vt)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof Ct&&Et(e.value)===st?o(e.value.sections):e instanceof zt?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}getProgramConfiguration(e){return new ca(this,e)}}var Gd={paint:new qo({"background-color":new Uo($e.paint_background["background-color"]),"background-pattern":new Go($e.paint_background["background-pattern"]),"background-opacity":new Uo($e.paint_background["background-opacity"])})},$d={paint:new qo({"raster-opacity":new Uo($e.paint_raster["raster-opacity"]),"raster-hue-rotate":new Uo($e.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Uo($e.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Uo($e.paint_raster["raster-brightness-max"]),"raster-saturation":new Uo($e.paint_raster["raster-saturation"]),"raster-contrast":new Uo($e.paint_raster["raster-contrast"]),"raster-resampling":new Uo($e.paint_raster["raster-resampling"]),"raster-fade-duration":new Uo($e.paint_raster["raster-fade-duration"])})};class qd extends ga{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var Zd={paint:new qo({"sky-type":new Uo($e.paint_sky["sky-type"]),"sky-atmosphere-sun":new Uo($e.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Uo($e.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Uo($e.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Uo($e.paint_sky["sky-gradient-radius"]),"sky-gradient":new $o($e.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Uo($e.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Uo($e.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Uo($e.paint_sky["sky-opacity"])})};function Yd(e,t,i){const r=[0,0,1],n=ql([]);return Yl(n,n,i?-z(e)+Math.PI:z(e)),Zl(n,n,-z(t)),Ol(r,r,n),Pl(r,r)}const Wd={circle:class extends ga{constructor(e){super(e,hl)}createBucket(e){return new Za(e)}queryRadius(e){const t=e;return ol("circle-radius",this,t)+ol("circle-stroke-width",this,t)+sl(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=ll(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return Jl(e,r,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ca(this,e)}},heatmap:class extends ga{createBucket(e){return new rc(e)}constructor(e){super(e,cc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=hc({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(e){return ol("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(t,i);return Jl(e,r,o,s,a,!0,!0,new F(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ca(this,e)}},hillshade:class extends ga{constructor(e){super(e,uc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends ga{constructor(e){super(e,Jc)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(e){return new ca(this,e)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Hc(e)}queryRadius(){return sl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return!e.queryGeometry.isAboveHorizon&&Xa(al(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends ga{constructor(e){super(e,wh)}createBucket(e){return new yh(e)}queryRadius(){return sl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new ca(this,e)}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){const c=ll(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),u=this.paint.get("fill-extrusion-base").evaluate(t,i),p=[0,0],d=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,m=e.tile.getBucket(this);if(d&&m instanceof yh){const e=m.centroidVertexArray,t=l+1;if(t<e.length){const i=e.get(t);p[0]=i.a_centroid_pos0,p[1]=i.a_centroid_pos1}}if(0===p[0]&&1===p[1])return!1;"globe"===o.projection.name&&(r=bh([r],[new F(0,0),new F(ba,ba)],e.tileID.canonical).map(e=>e.polygon).flat());const _=function(e,t,i,r,n,o,s,a,l,c,h){return"globe"===e.projection.name?function(i,r,n,o,s,a,l,c,h,u,p){const d=[],f=[],m=i.projection.upVectorScale(p,i.center.lat,i.worldSize).metersToTile,_=[0,0,0,1],g=[0,0,0,1],y=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1},x=vh();n>0&&(n+=x),o+=x;for(const x of r){const r=[],v=[];for(const d of x){const f=d.x+s.x,x=d.y+s.y,b=i.projection.projectTilePoint(f,x,p),w=i.projection.upVector(p,d.x,d.y);let e=n,t=o;if(l){const i=kh(f,x,n,o,l,c,h,u);e+=i.base,t+=i.top}0!==n?y(_,b.x+w[0]*m*e,b.y+w[1]*m*e,b.z+w[2]*m*e):y(_,b.x,b.y,b.z),y(g,b.x+w[0]*m*t,b.y+w[1]*m*t,b.z+w[2]*m*t),Rl(_,_,a),Rl(g,g,a),r.push(Bh(_)),v.push(Bh(g))}d.push(r),f.push(v)}return[d,f]}(e,t,i,r,n,o,s,a,l,c,h):s?function(e,t,i,r,n,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const p of e){const e=[],d=[];for(const c of p){const h=c.x+r.x,f=c.y+r.y,m=kh(h,f,t,i,o,s,a,l);u[0]=h,u[1]=f,u[2]=m.base,u[3]=1,Gl(u,u,n),u[3]=Math.max(u[3],1e-5);const _=Bh([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);u[0]=h,u[1]=f,u[2]=m.top,u[3]=1,Gl(u,u,n),u[3]=Math.max(u[3],1e-5);const g=Bh([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);e.push(_),d.push(g)}c.push(e),h.push(d)}return[c,h]}(t,i,r,n,o,s,a,l,c):function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,h=n[11]*t,u=n[8]*i,p=n[9]*i,d=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],_=n[1]*t+n[5]*s+n[13],g=n[2]*t+n[6]*s+n[14],y=n[3]*t+n[7]*s+n[15],x=m+a,v=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,E=_+p,A=g+d,S=Math.max(y+f,1e-5),C=new F(x/w,v/w);C.z=b/w,e.push(C);const M=new F(T/S,E/S);M.z=A/S,i.push(M)}o.push(e),s.push(i)}return[o,s]}(t,i,r,n,o)}(o,r,u,h,c,s,d?a:null,p,f,o.center.lat,e.tileID.canonical),g=e.queryGeometry;return function(t,i,r){let n=1/0;Xa(r,i)&&(n=Ih(r,i[0]));for(let e=0;e<i.length;e++){const o=i[e],s=t[e];for(let e=0;e<o.length-1;e++){const i=o[e],a=[i,o[e+1],s[e+1],s[e],i];Ya(r,a)&&(n=Math.min(n,Ih(r,a)))}}return n!==1/0&&n}(_[0],_[1],g.isPointQuery()?g.screenBounds:g.screenGeometry)}},line:class extends ga{constructor(e){super(e,Uh),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof _i,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=jh.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Fh(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(e){return new ca(this,e)}queryRadius(e){const t=e,i=Vh(ol("line-width",this,t),ol("line-gap-width",this,t)),r=ol("line-offset",this,t);return i/2+Math.abs(r)+sl(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,r,n,o){if(e.queryGeometry.isAboveHorizon)return!1;const s=al(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*Vh(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=function(t,i){const r=[],n=new F(0,0);for(let e=0;e<t.length;e++){const o=t[e],s=[];for(let e=0;e<o.length;e++){const r=o[e-1],F=o[e],a=o[e+1],l=0===e?n:F.sub(r)._unit()._perp(),c=e===o.length-1?n:a.sub(F)._unit()._perp(),h=l._add(c)._unit();h._mult(1/(h.x*c.x+h.y*c.y)),s.push(h._mult(i)._add(F))}r.push(s)}return r}(r,l*e.pixelToTileUnitsFactor)),function(t,i,r){for(let e=0;e<i.length;e++){const n=i[e];if(t.length>=3)for(let e=0;e<n.length;e++)if(il(t,n[e]))return!0;if(Ha(t,n,r))return!0}return!1}(s,r,a)}isTileClipped(){return!0}},symbol:Vd,background:class extends ga{constructor(e){super(e,Gd)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends ga{constructor(e){super(e,$d)}getProgramIds(){return["raster"]}},sky:class extends ga{constructor(e){super(e,Zd),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=hc({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=e.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&Y("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?Yd(o.azimuthal,90-o.polar,t):Yd(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return Yd(i[0],90-i[1],t)}is3D(){return!1}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}}};class Xd{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,i){const{width:r,height:n}=e,{context:o}=this,{gl:s}=o,{HTMLImageElement:a,HTMLCanvasElement:l,HTMLVideoElement:c,ImageData:h,ImageBitmap:u}=p;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!t||!1!==t.premultiply)),i||this.size&&this.size[0]===r&&this.size[1]===n){const{x:p,y:t}=i||{x:0,y:0};e instanceof a||e instanceof l||e instanceof c||e instanceof h||u&&e instanceof u?s.texSubImage2D(s.TEXTURE_2D,0,p,t,s.RGBA,s.UNSIGNED_BYTE,e):s.texSubImage2D(s.TEXTURE_2D,0,p,t,r,n,s.RGBA,s.UNSIGNED_BYTE,e.data)}else this.size=[r,n],e instanceof a||e instanceof l||e instanceof c||e instanceof h||u&&e instanceof u?s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,s.UNSIGNED_BYTE,e):s.texImage2D(s.TEXTURE_2D,0,this.format,r,n,0,this.format,s.UNSIGNED_BYTE,e.data);this.useMipmap=Boolean(t&&t.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.filter=e),t!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Hd{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new ac({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=g(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,o=t[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){s=!s;const l=t[e];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(o,e,s){const a=e/2;for(let n=-s;n<=s;n++){const l=this.width*(this.nextRow+s+n);let i=0,r=o[i];for(let t=0;t<this.width;t++){t/r.right>1&&(r=o[++i]);const c=Math.abs(t-r.left),h=Math.abs(t-r.right),u=Math.min(c,h);let e;const p=n/s*(a+1);if(r.isDash){const o=a-Math.abs(p);e=Math.sqrt(u*u+o*o)}else e=a-Math.sqrt(u*u+p*p);this.image.data[l+t]=Math.max(0,Math.min(255,e+128))}}}addRegularDash(t,i){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1))}const r=t[0],n=t[t.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const o=this.width*this.nextRow;let s=0,a=t[s];for(let e=0;e<this.width;e++){e/a.right>1&&(a=t[++s]);const n=Math.abs(e-a.left),l=Math.abs(e-a.right),c=Math.min(n,l);this.image.data[o+e]=Math.max(0,Math.min(255,(a.isDash?c:-c)+i+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return Y("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e<t.length;e++)t[e]<0&&(Y("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),s+=t[e];if(0!==s){const i=this.width/s,o=this.getDashRanges(t,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===e?.5*i:0)}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[i]=l,l}}kn(Hd,"LineAtlas");class Kd{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Jd{constructor(){this.tasks={},this.taskQueue=[],x(["process"],this),this.invoker=new Kd(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){k();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){k();try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let t=null,i=1/0;for(let e=0;e<this.taskQueue.length;e++){const r=this.tasks[this.taskQueue[e]];r.priority<i&&(i=r.priority,t=e)}if(null===t)return null;const e=this.taskQueue[t];return this.taskQueue.splice(t,1),e}remove(){this.invoker.remove()}}class Qd{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const ef=["tile","layer","source","sourceLayer","state"];class tf{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of ef)void 0!==this[t]&&(e[t]=this[t]);return e}}const rf=32,nf=33,of=new Uint16Array(8184);for(let a=0;a<2046;a++){let e=a+2,t=0,i=0,r=0,n=0,o=0,s=0;for(1&e?r=n=o=rf:t=i=s=rf;(e>>=1)>1;){const l=t+r>>1,z=i+n>>1;1&e?(r=t,n=i,t=o,i=s):(t=r,i=n,r=o,n=s),o=l,s=z}const z=4*a;of[z+0]=t,of[z+1]=i,of[z+2]=r,of[z+3]=n}const sf=new Uint16Array(2178),af=new Uint8Array(1089),lf=new Uint16Array(1089);function cf(e){return 0===e?-.03125:32===e?.03125:0}var hf=Ho([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const uf={type:2,extent:ba,loadGeometry:()=>[[new F(0,0),new F(8193,0),new F(8193,8193),new F(0,8193),new F(0,0)]]};class pf{constructor(e,t,i,r,n){this.tileID=e,this.uid=m(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<Z.now()||this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=ld(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=r}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Fd){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Fd&&t.hasRTLText){this.hasRTLText=!0,Bo.isLoading()||Bo.isLoaded()||"deferred"!==Mo()||Io();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new Cs}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Xd(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Xd(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Xd(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,n,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=e?e.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=Xr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let e=0;e<o.length;e++){const r=o.feature(e);if(s.needGeometry){const t=Ga(r,!0);if(!s.filter(new ko(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!s.filter(new ko(this.tileID.overscaledZ),r))continue;const u=i.getId(r,n),p=new tf(r,a,l,c,u);p.tile=h,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=P(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let e=!1;if(this.expirationTime>t)e=!1;else if(i)if(this.expirationTime<i)e=!0;else{const r=this.expirationTime-i;r?this.expirationTime=t+Math.max(r,3e4):e=!0}else e=!0;e?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length||!t)return;const i=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages();for(const n in this.buckets){if(!t.style.hasLayer(n))continue;const o=this.buckets[n],s=o.layers[0].sourceLayer||"_geojsonTileLayer",a=i[s],l=e[s];if(!a||!l||0===Object.keys(l).length)continue;if(o.update(l,a,r,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof Fh||o instanceof Hc){const e=t.style._getSourceCache(o.layers[0].source);t._terrain&&t._terrain.enabled&&e&&o.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(e.id,this.tileID)}const c=t&&t.style&&t.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Z.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Z.now()+e}setTexture(e,t){const i=t.context,r=i.gl;this.texture=t.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new Xd(i,e,r.RGBA,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax))}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const r of t)if(e[r])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=Va(uf,this.tileID.canonical,this.tileTransform)[0],r=new Jo,n=new ws;for(let e=0;e<i.length;e++){const{x:t,y:o}=i[e];r.emplaceBack(t,o),n.emplaceBack(e)}n.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(r,Rp.members),this._tileDebugSegments=va.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(t,e){if(this._tileBoundsBuffer||!e||"mercator"===e.name)return;const i=Va(uf,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const t=function(i,r){const n=ld(i,r),o=Math.pow(2,i.z);for(let t=0;t<nf;t++)for(let e=0;e<nf;e++){const a=Ba((i.x+(e+cf(e))/rf)/o),c=ka((i.y+(t+cf(t))/rf)/o),h=r.project(a,c),u=t*nf+e;sf[2*u+0]=Math.round((h.x*n.scale-n.x)*ba),sf[2*u+1]=Math.round((h.y*n.scale-n.y)*ba)}af.fill(0),lf.fill(0);for(let e=2045;e>=0;e--){const r=4*e,n=of[r+0],o=of[r+1],s=of[r+2],l=of[r+3],a=n+s>>1,c=o+l>>1,h=a+c-o,t=c+n-a,p=o*nf+n,d=l*nf+s,f=c*nf+a,m=Math.hypot((sf[2*p+0]+sf[2*d+0])/2-sf[2*f+0],(sf[2*p+1]+sf[2*d+1])/2-sf[2*f+1])>=16;if(af[f]=af[f]||(m?1:0),e<1022){const i=(o+t>>1)*nf+(n+h>>1),r=(l+t>>1)*nf+(s+h>>1);af[f]=af[f]||af[i]||af[r]}}const s=new es,l=new fs;let a=0;function c(e,t){const i=t*nf+e;return 0===lf[i]&&(s.emplaceBack(sf[2*i+0],sf[2*i+1],e*ba/rf,t*ba/rf),lf[i]=++a),lf[i]-1}function h(e,t,i,r,n,o){const s=e+i>>1,a=t+r>>1;if(Math.abs(e-n)+Math.abs(t-o)>1&&af[a*nf+s])h(n,o,e,t,s,a),h(i,r,n,o,s,a);else{const h=c(e,t),s=c(i,r),a=c(n,o);l.emplaceBack(h,s,a)}}return h(0,0,rf,rf,rf,0),h(rf,rf,0,0,0,rf),{vertices:s,indices:l}}(this.tileID.canonical,e);r=t.vertices,n=t.indices}else{r=new es,n=new fs;for(const{x:t,y:e}of i)r.emplaceBack(t,e,0,0);const t=fc(r.int16,void 0,4);for(let e=0;e<t.length;e+=3)n.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(r,hf.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(n),this._tileBoundsSegments=va.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugBuffers(e,t){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!t||"globe"!==t.name)return;const i=this.tileID.canonical,r=Qp(Zp(i));this._makeGlobeTileDebugBorderBuffer(e,i,r),this._makeGlobeTileDebugTextBuffer(e,i,r)}_makeGlobeTileDebugBorderBuffer(e,h,u){const p=new Jo,d=new ws,f=new Qo,t=(t,i,e,r,n)=>{const o=(e-t)/(n-1),s=(r-i)/(n-1),a=p.length;for(let e=0;e<n;e++){const r=t+e*o,n=i+e*s;p.emplaceBack(r,n);const l=Kp(r,n,h),c=Rl(l,l,u);f.emplaceBack(c[0],c[1],c[2]),d.emplaceBack(a+e)}},i=ba;t(0,0,i,0,16),t(i,0,i,i,16),t(i,i,0,i,16),t(0,i,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(d),this._tileDebugBuffer=e.createVertexBuffer(p,Rp.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(f,Dp.members),this._tileDebugSegments=va.simpleSegment(0,0,p.length,d.length)}_makeGlobeTileDebugTextBuffer(e,t,i){const r=new Jo,n=new fs,o=new Qo,s=25;n.reserve(32),r.reserve(s),o.reserve(s);const a=(e,t)=>s*e+t;for(let e=0;e<s;e++){const n=2048*e;for(let e=0;e<s;e++){const s=2048*e;r.emplaceBack(s,n);const a=Kp(s,n,t),l=Rl(a,a,i);o.emplaceBack(l[0],l[1],l[2])}}for(let t=0;t<4;t++)for(let e=0;e<4;e++){const i=a(t,e),r=a(t,e+1),o=a(t+1,e),s=a(t+1,e+1);n.emplaceBack(i,r,o),n.emplaceBack(o,r,s)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(n),this._tileDebugTextBuffer=e.createVertexBuffer(r,Rp.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(o,Dp.members),this._tileDebugTextSegments=va.simpleSegment(0,0,s,32)}}class df{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},b(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const i=String(t),r=b({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return{};for(const e in i)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),b(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i]}i[e]=i[e]||{},b(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in e)e[r].setFeatureState(i,t)}}class ff{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function mf(r,n,o,s){let a=0,l=Number.MAX_VALUE;for(let i=0;i<3;i++)if(Math.abs(s[i])<1e-15){if(o[i]<r[i]||o[i]>n[i])return null}else{const c=1/s[i];let e=(r[i]-o[i])*c,t=(n[i]-o[i])*c;if(e>t){const r=e;e=t,t=r}if(e>a&&(a=e),t<l&&(l=t),a>l)return null}return a}function _f(e,t,i,r,n,o,s,a,l,c,h){const u=r-e,p=n-t,d=o-i,f=s-e,m=a-t,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+p*y+d*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,A=(w*g+T*y+E*x)*b;if(A<0||A>1)return null;const S=T*d-E*p,C=E*u-w*d,M=w*p-T*u,I=(h[0]*S+h[1]*C+h[2]*M)*b;return I<0||A+I>1?null:(f*S+m*C+_*M)*b}function gf(e,t,i){return(e-t)/(i-t)}function yf(e,t,i,r,n,o,s,a,l){const c=1<<i,h=o-r,u=s-n,p=(e+1)/c*h+r,d=(t+0)/c*u+n,f=(t+1)/c*u+n;a[0]=(e+0)/c*h+r,a[1]=d,l[0]=p,l[1]=f}class xf{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(t){const e=Math.ceil(Math.log2(t.dim/8)),i=[];let r=Math.ceil(Math.pow(2,e));const n=1/r,o=(e,t,i,r,n)=>{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l};let s=new ff(r);const a=[];for(let e=0;e<r*r;e++){o(e%r,Math.floor(e/r),n,!1,a);const i=bf(a[0],a[1],t),l=bf(a[2],a[1],t),c=bf(a[2],a[3],t),h=bf(a[0],a[3],t);s.minimums.push(Math.min(i,l,c,h)),s.maximums.push(Math.max(i,l,c,h)),s.leaves.push(1)}for(i.push(s),r/=2;r>=1;r/=2){const t=i[i.length-1];s=new ff(r);for(let e=0;e<r*r;e++){o(e%r,Math.floor(e/r),2,!0,a);const i=t.getElevation(a[0],a[1]),n=t.getElevation(a[2],a[1]),u=t.getElevation(a[2],a[3]),p=t.getElevation(a[0],a[3]),d=t.isLeaf(a[0],a[1]),f=t.isLeaf(a[2],a[1]),m=t.isLeaf(a[2],a[3]),_=t.isLeaf(a[0],a[3]),g=Math.min(i.min,n.min,u.min,p.min),y=Math.max(i.max,n.max,u.max,p.max),x=d&&f&&m&&_;s.maximums.push(y),s.minimums.push(g),s.leaves.push(y-g<=5&&x?1:0)}i.push(s)}return i}(this.dem),i=t.length-1,r=t[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,r,n,o,s=1){return mf([e,t,-100],[i,r,this.maximums[0]*s],n,o)}raycast(n,t,e,o,s,a,l=1){if(!this.nodeCount)return null;const c=this.raycastRoot(n,t,e,o,s,a,l);if(null==c)return null;const h=[],u=[],p=[],d=[],i=[{idx:0,t:c,nodex:0,nodey:0,depth:0}];for(;i.length>0;){const{idx:c,t:f,nodex:m,nodey:_,depth:g}=i.pop();if(this.leaves[c]){yf(m,_,g,n,t,e,o,p,d);const c=1<<g,h=(m+0)/c,u=(m+1)/c,i=(_+0)/c,y=(_+1)/c,x=bf(h,i,this.dem)*l,v=bf(u,i,this.dem)*l,b=bf(u,y,this.dem)*l,w=bf(h,y,this.dem)*l,T=_f(p[0],p[1],x,d[0],p[1],v,d[0],d[1],b,s,a),E=_f(d[0],d[1],b,p[0],d[1],w,p[0],p[1],x,s,a),A=Math.min(null!==T?T:Number.MAX_VALUE,null!==E?E:Number.MAX_VALUE);if(A!==Number.MAX_VALUE)return A;{const n=zl([],s,a,f);if(vf(x,v,w,b,gf(n[0],p[0],d[0]),gf(n[1],p[1],d[1]))>=n[2])return f}continue}let r=0;for(let i=0;i<this._siblingOffset.length;i++){yf((m<<1)+this._siblingOffset[i][0],(_<<1)+this._siblingOffset[i][1],g+1,n,t,e,o,p,d),p[2]=-100,d[2]=this.maximums[this.childOffsets[c]+i]*l;const S=mf(p,d,s,a);if(null!=S){const n=S;h[i]=n;let t=!1;for(let e=0;e<r&&!t;e++)n>=h[u[e]]&&(u.splice(e,0,i),t=!0);t||(u[r]=i),r++}}for(let e=0;e<r;e++){const t=u[e];i.push({idx:this.childOffsets[c]+t,t:h[t],nodex:(m<<1)+this._siblingOffset[t][0],nodey:(_<<1)+this._siblingOffset[t][1],depth:g+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(t,i,r,n,o){if(1===t[n].isLeaf(i,r))return;this.childOffsets[o]||(this.childOffsets[o]=this.nodeCount);const s=n-1,a=t[s];let l=0,c=0;for(let e=0;e<this._siblingOffset.length;e++){const n=2*i+this._siblingOffset[e][0],o=2*r+this._siblingOffset[e][1],s=a.getElevation(n,o),h=a.isLeaf(n,o),u=this._addNode(s.min,s.max,h);h&&(l|=1<<e),c||(c=u)}for(let e=0;e<this._siblingOffset.length;e++)l&1<<e||this._construct(t,2*i+this._siblingOffset[e][0],2*r+this._siblingOffset[e][1],s,c+e)}}function vf(e,t,i,r,n,o){return gi(gi(e,i,o),gi(t,r,o),n)}function bf(e,t,i){const r=i.dim,n=C(e*r-.5,0,r-1),o=C(t*r-.5,0,r-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,r-1),c=Math.min(a+1,r-1);return vf(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),n-s,o-a)}const wf={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Tf{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,r=!1,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return Y(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const o=this.dim=t.height-2,s=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let e=0;e<o;e++)s[this._idx(-1,e)]=s[this._idx(0,e)],s[this._idx(o,e)]=s[this._idx(o-1,e)],s[this._idx(e,-1)]=s[this._idx(e,0)],s[this._idx(e,o)]=s[this._idx(e,o-1)];s[this._idx(-1,-1)]=s[this._idx(0,0)],s[this._idx(o,-1)]=s[this._idx(o-1,0)],s[this._idx(-1,o)]=s[this._idx(0,o-1)],s[this._idx(o,o)]=s[this._idx(o-1,o-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new xf(this)}get(e,t,i=!1){i&&(e=C(e,-1,this.dim),t=C(t,-1,this.dim));const r=4*this._idx(e,t);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[r],this.pixels[r+1],this.pixels[r+2])}static getUnpackVector(e){return wf[e]}get unpackVector(){return wf[this.encoding]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}_unpackMapbox(e,t,i){return(256*e*256+256*t+i)/10-1e4}_unpackTerrarium(e,t,i){return 256*e+t+i/256-32768}static pack(e,t){const i=[0,0,0,0],r=Tf.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new lc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(i,e,t){if(this.dim!==i.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,o=t*this.dim,s=t*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(t){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-t*this.dim;for(let t=o;t<s;t++)for(let e=r;e<n;e++){const r=4*this._idx(e,t),n=4*this._idx(e+a,t+l);this.pixels[r+0]=i.pixels[n+0],this.pixels[r+1]=i.pixels[n+1],this.pixels[r+2]=i.pixels[n+2],this.pixels[r+3]=i.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}kn(Tf,"DEMData"),kn(xf,"DemMinMaxQuadTree",{omit:["dem"]});class Ef{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout(()=>{this.remove(e,n)},i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Af{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Af.ReadOnly=!1,Af.ReadWrite=!0,Af.disabled=new Af(519,Af.ReadOnly,[0,1]);const Sf=7680;class Cf{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Cf.disabled=new Cf({func:519,mask:0},0,0,Sf,Sf,Sf);class Mf{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}Mf.Replace=[1,0],Mf.disabled=new Mf(Mf.Replace,gt.transparent,[!1,!1,!1,!1]),Mf.unblended=new Mf(Mf.Replace,gt.transparent,[!0,!0,!0,!0]),Mf.alphaBlended=new Mf([1,771],gt.transparent,[!0,!0,!0,!0]);const If=1029,Bf=2305;class kf{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}kf.disabled=new kf(!1,If,Bf),kf.backCCW=new kf(!0,If,Bf),kf.backCW=new kf(!0,If,2304),kf.frontCW=new kf(!0,1028,2304),kf.frontCCW=new kf(!0,1028,Bf);class zf extends Ge{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new Ef(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new df,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const t in this._tiles){const i=this._tiles[t];this._source.prepareTile(i)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,i.tileID),i.upload(e),i.prepare(this.map.style.imageManager)}else for(const r in this._tiles){const n=this._tiles[r];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return v(this._tiles).map(e=>e.tileID).sort(Pf).map(e=>e.key)}getRenderableIds(e){const t=[];for(const i in this._tiles)this._isIdRenderable(+i,e)&&t.push(this._tiles[i]);return e?t.sort((e,t)=>{const i=e.tileID,r=t.tileID,n=new F(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new F(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||o.y-n.y||o.x-n.x}).map(e=>e.tileID.key):t.map(e=>e.tileID).sort(Pf).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(e,t,i,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new Ve(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=Z.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new je("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const i=this.getRenderableIds();for(let e=0;e<i.length;e++){const n=i[e];if(t.neighboringTiles&&t.neighboringTiles[n]){const i=this.getTileByID(n);r(t,i),r(i,t)}}function r(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const r=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(r,n,o,s){for(const a in this._tiles){let e=this._tiles[a];if(s[a]||!e.hasData()||e.tileID.overscaledZ<=n||e.tileID.overscaledZ>o)continue;let t=e.tileID;for(;e&&e.tileID.overscaledZ>n+1;){const r=e.tileID.scaledTo(e.tileID.overscaledZ-1);e=this._tiles[r.key],e&&e.hasData()&&(t=r)}let i=t;for(;i.overscaledZ>n;)if(i=i.scaledTo(i.overscaledZ-1),r[i.key]){s[t.key]=t;break}}}findLoadedParent(t,i){if(t.key in this._loadedParentTiles){const e=this._loadedParentTiles[t.key];return e&&e.tileID.overscaledZ>=i?e:null}for(let e=t.overscaledZ-1;e>=i;e--){const i=t.scaledTo(e),r=this._getLoadedTile(i);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(t,i,r){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;let e;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?e=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new Sh(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(e=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(e=e.filter(e=>this._source.hasTile(e)))):e=[];const n=this._updateRetainedTiles(e);if(Lf(this._source.type)&&0!==e.length){const t={},i={},r=Object.keys(n);for(const e of r){const r=n[e],o=this._tiles[e];if(!o||o.fadeEndTime&&o.fadeEndTime<=Z.now())continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-zf.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[e]=r}const o=e[e.length-1].overscaledZ;for(const t in this._tiles){const r=this._tiles[t];if(n[t]||!r.hasData())continue;let e=r.tileID;for(;e.overscaledZ>o;){e=e.scaledTo(e.overscaledZ-1);const o=this._tiles[e.key];if(o&&o.hasData()&&i[e.key]){n[t]=r.tileID;break}}}for(const i in t)n[i]||(this._coveredTiles[i]=!0,n[i]=t[i])}for(const t in n)this._tiles[t].clearFadeHold();const o=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i}(this._tiles,n);for(const t of o){const i=this._tiles[t];i.hasSymbolBuckets&&!i.holdingForFade()?i.setHoldDuration(this.map._fadeDuration):i.hasSymbolBuckets&&!i.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const r={};if(0===e.length)return r;const n={},o=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),t=e[0].overscaledZ,s=Math.max(t-zf.maxOverzooming,this._source.minzoom),i=Math.max(t+zf.maxUnderzooming,this._source.minzoom),a={};for(const n of e){const e=this._addTile(n);r[n.key]=n,e.hasData()||o<this._source.maxzoom&&(a[n.key]=n)}this._retainLoadedChildren(a,o,i,r);for(const o of e){let t=this._tiles[o.key];if(t.hasData())continue;if(o.canonical.z>=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],n=this.getTile(e);if(n&&n.hasData()){r[e.key]=e;continue}}else{const e=o.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let i=t.wasRequested();for(let e=o.overscaledZ-1;e>=s;--e){const s=o.scaledTo(e);if(n[s.key])break;if(n[s.key]=!0,t=this.getTile(s),!t&&i&&(t=this._addTile(s)),t&&(r[s.key]=s,i=t.wasRequested(),t.hasData()))break}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const i in this._tiles){const r=[];let e,t=this._tiles[i].tileID;for(;t.overscaledZ>0;){if(t.key in this._loadedParentTiles){e=this._loadedParentTiles[t.key];break}r.push(t.key);const n=t.scaledTo(t.overscaledZ-1);if(e=this._getLoadedTile(n),e)break;t=n}for(const o of r)this._loadedParentTiles[o]=e}}_addTile(e){let t=this._tiles[e.key];if(t)return this._source.prepareTile&&this._source.prepareTile(t),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null;t=new pf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(t)||this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new je("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,i,r){const n=[],o=this.transform;if(!o)return n;const s="globe"===o.projection.name,a=Ca(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(r&&c.clearQueryDebugViz(),c.holdingForFade())continue;let e;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(C(a,...Df(t,-1))-a),Math.abs(C(a,...Df(t,1))-a)];e=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(C(a,...Df(t,-1))-a),Math.abs(C(a,...Df(t,0))-a),Math.abs(C(a,...Df(t,1))-a)];e=[i.indexOf(Math.min(...i))-1]}}else e=[0];for(const r of e){const s=t.containsTile(c,o,i,r);s&&n.push(s)}}return n}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(Lf(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=Z.now())return!0}return!1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i)}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i)}reloadTilesForDependencies(t,i){for(const e in this._tiles)this._tiles[e].hasDependency(t,i)&&this._reloadTile(+e,"reloading");this._cache.filter(e=>!e.hasDependency(t,i))}_preloadTiles(e,t){const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}u(Array.from(i.values()),(e,t)=>{const i=new pf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)})},t)}}function Pf(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Lf(e){return"raster"===e||"image"===e||"video"===e}function Df(e,t){const i=1<<e.z;return[e.x/i+t,(e.x+1)/i+t]}zf.maxOverzooming=10,zf.maxUnderzooming=3;class Rf{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<<t.canonical.z-o.canonical.z;return new Rf(r,r.tileSize/ba/s,[(t.canonical.x/s-o.canonical.x)*n.dim,(t.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1],r=Math.floor(e*this._scale+this._offset[0]),n=Math.floor(i);return new F(r,n)}getElevationAt(e,t,i,r){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return r=!!r,i?gi(gi(l.get(s,a,r),l.get(s,a+1,r),o-a),gi(l.get(s+1,a,r),l.get(s+1,a+1,r),o-a),n-s):l.get(s,a,r)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Ia(1,e)*this._dem.stride}}class Of{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Mn(ba,16,0),this.featureIndexArray=new Ds,this.promoteId=t}insert(e,t,i,r,n,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const a=this.grid;for(let e=0;e<t.length;e++){const i=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];r[0]=Math.min(r[0],t.x),r[1]=Math.min(r[1],t.y),r[2]=Math.max(r[2],t.x),r[3]=Math.max(r[3],t.y)}r[0]<ba&&r[1]<ba&&r[2]>=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new uh.VectorTile(new lu(this.rawTileData)).layers,this.sourceLayerCoder=new Qd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(o,t,i,r){this.loadVTLayers();const s=o.params||{},a=Xr(s.filter),l=o.tileResult,e=o.transform,c=l.bufferedTilespaceBounds,h=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,(e,t,i,r)=>rl(l.bufferedTilespaceGeometry,e,t,i,r));h.sort(Nf);let u=null;e.elevation&&h.length>0&&(u=Rf.create(e.elevation,this.tileID));const p={};let d;for(let e=0;e<h.length;e++){const c=h[e];if(c===d)continue;d=c;const f=this.featureIndexArray.get(c);let n=null;this.loadMatchingFeature(p,f,a,s.layers,s.availableImages,t,i,r,(e,t,i,r=0)=>(n||(n=Va(e,this.tileID.canonical,o.tileTransform)),t.queryIntersectsFeature(l,e,i,n,this.z,o.transform,o.pixelPosMatrix,u,r)))}return p}loadMatchingFeature(r,e,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:p,sourceLayerIndex:t,layoutVertexArrayOffset:d}=e,f=this.bucketLayerIDs[p];if(o&&!function(t,i){for(let e=0;e<t.length;e++)if(i.indexOf(t[e])>=0)return!0;return!1}(o,f))return;const m=this.sourceLayerCoder.decode(t),_=this.vtLayers[m].feature(u);if(n.needGeometry){const r=Ga(_,!0);if(!n.filter(new ko(this.tileID.overscaledZ),r,this.tileID.canonical))return}else if(!n.filter(new ko(this.tileID.overscaledZ),_))return;const g=this.getId(_,m);for(let i=0;i<f.length;i++){const n=f[i];if(o&&o.indexOf(n)<0)continue;const p=a[n];if(!p)continue;let e={};void 0!==g&&c&&(e=c.getState(p.sourceLayer||"_geojsonTileLayer",g));const m=b({},l[n]);m.paint=Ff(m.paint,p.paint,_,e,s),m.layout=Ff(m.layout,p.layout,_,e,s);const y=!h||h(_,p,e,d);if(!y)continue;const x=new tf(_,this.z,this.x,this.y,g);x.layer=m;let t=r[n];void 0===t&&(t=r[n]=[]),t.push({featureIndex:u,feature:x,intersectionZ:y})}}lookupSymbolFeatures(e,t,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=Xr(n);for(const n of e)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,o,s,a,t);return l}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[t])return n[t];const o=this.vtLayers[r].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;return this.promoteId&&(i=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[t]],"boolean"==typeof i&&(i=Number(i))),i}}function Ff(e,r,n,o,s){return T(e,(e,t)=>{const i=r instanceof No?r.get(t):null;return i&&i.evaluate?i.evaluate(n,o,s):i})}function Nf(e,t){return t-e}kn(Of,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Uf{constructor(e){const t={},i=[];for(const r in e){const n=e[r],o=t[r]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const r=t.metrics.localGlyph?2:1,s={x:0,y:0,w:t.bitmap.width+2*r,h:t.bitmap.height+2*r};i.push(s),o[e]=s}}const{w:r,h:n}=ku(i),o=new ac({width:r||1,height:n||1});for(const i in e){const r=e[i];for(const e in r.glyphs){const n=r.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const a=t[i][e],l=n.metrics.localGlyph?2:1;ac.copy(n.bitmap,o,{x:0,y:0},{x:a.x+l,y:a.y+l},n.bitmap)}}this.image=o,this.positions=t}}kn(Uf,"GlyphAtlas");class jf{constructor(e){this.tileID=new Sh(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=ld(e.tileID.canonical,e.projection),this.projection=e.projection}parse(i,r,n,o,s){this.status="parsing",this.data=i,this.collisionBoxArray=new Cs;const a=new Qd(Object.keys(i.layers).sort()),l=new Of(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},h=new Hd(256,256),u={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:h,availableImages:n},p=r.familiesBySource[this.source];for(const r in p){const o=i.layers[r];if(!o)continue;let e=!1,t=!1;for(const i of p[r])"symbol"===i[0].type?e=!0:t=!0;if(!0===this.isSymbolTile&&!e)continue;if(!1===this.isSymbolTile&&!t)continue;1===o.version&&Y(`Vector tile source "${this.source}" layer "${r}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const d=a.encode(r),f=[];for(let e=0;e<o.length;e++){const n=o.feature(e),s=l.getId(n,r);f.push({feature:n,id:s,index:e,sourceLayerIndex:d})}for(const i of p[r]){const r=i[0];void 0!==this.isSymbolTile&&"symbol"===r.type!==this.isSymbolTile||r.minzoom&&this.zoom<Math.floor(r.minzoom)||r.maxzoom&&this.zoom>=r.maxzoom||"none"!==r.visibility&&(Vf(i,this.zoom,n),(c[r.id]=r.createBucket({index:l.bucketLayerIDs.length,layers:i,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:n})).populate(f,u,this.tileID.canonical,this.tileTransform),l.bucketLayerIDs.push(i.map(e=>e.id)))}}let d,f,m,_;h.trim();const e={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},t=T(u.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(t).length?o.send("getGlyphs",{uid:this.uid,stacks:t},(e,t)=>{d||(d=e,f=t,x.call(this))},void 0,!1,e):f={};const g=Object.keys(u.iconDependencies);g.length?o.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},(e,t)=>{d||(d=e,m=t,x.call(this))},void 0,!1,e):m={};const y=Object.keys(u.patternDependencies);function x(){if(d)return s(d);if(f&&m&&_){const e=new Uf(f),t=new Pu(m,_);for(const i in c){const s=c[i];s instanceof Fd?(Vf(s.layers,this.zoom,n),Ep(s,f,e.positions,m,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):s.hasPattern&&(s instanceof Fh||s instanceof Hc||s instanceof yh)&&(Vf(s.layers,this.zoom,n),s.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform))}this.status="done",s(null,{buckets:v(c).filter(e=>!e.isEmpty()),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:h,imageAtlas:t,glyphMap:this.returnDependencies?f:null,iconMap:this.returnDependencies?m:null,glyphPositions:this.returnDependencies?e.positions:null})}}y.length?o.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},(e,t)=>{d||(d=e,_=t,x.call(this))},void 0,!1,e):_={},x.call(this)}}function Vf(e,t,i){const r=new ko(t);for(const t of e)t.recalculate(r,i)}class Gf{constructor(e){this.entries={},this.scheduler=e}request(i,r,e,t){const n=this.entries[i]=this.entries[i]||{callbacks:[]};if(n.result){const[i,e]=n.result;return this.scheduler?this.scheduler.add(()=>{t(i,e)},r):t(i,e),()=>{}}return n.callbacks.push(t),n.cancel||(n.cancel=e((e,t)=>{n.result=[e,t];for(const i of n.callbacks)this.scheduler?this.scheduler.add(()=>{i(e,t)},r):i(e,t);setTimeout(()=>delete this.entries[i],3e3)})),()=>{n.result||(n.callbacks=n.callbacks.filter(e=>e!==t),n.callbacks.length||(n.cancel(),delete this.entries[i]))}}}function $f(t,e,o){const i=JSON.stringify(t.request);return t.data&&(this.deduped.entries[i]={result:[null,t.data]}),this.deduped.request(i,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},n=>{const e=ke(t.request,(e,t,i,r)=>{e?n(e):t&&n(null,{vectorTile:o?void 0:new uh.VectorTile(new lu(t)),rawData:t,cacheControl:i,expires:r})});return()=>{e.cancel(),n()}},e)}l.ARRAY_TYPE=pl,l.AUTH_ERR_MSG=re,l.Aabb=Kl,l.Actor=class{constructor(e,t,i){this.target=e,this.parent=t,this.mapId=i,this.callbacks={},this.cancelCallbacks={},x(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=k()?e:p,this.scheduler=new Jd}send(e,t,i,r,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=D(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:e,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Ln(t,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||k()){const e=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add(()=>this.processTask(i,t),e&&e.metadata||{type:"message"})}else this.processTask(i,t)}processTask(i,e){if("<response>"===e.type){const t=this.callbacks[i];delete this.callbacks[i],t&&(e.error?t(Dn(e.error)):t(null,Dn(e.data)))}else{const r=D(this.globalScope)?void 0:[],n=e.hasCallback?(e,t)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"<response>",sourceMapId:this.mapId,error:e?Ln(e):null,data:Ln(t,r)},r)}:e=>{},o=Dn(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,o,n);else if(this.parent.getWorkerSource){const i=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,i[0],o.source)[i[1]](o,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},l.CanonicalTileID=Eh,l.Color=gt,l.ColorMode=Mf,l.CullFaceMode=kf,l.DEMData=Tf,l.DataConstantProperty=Uo,l.DedupedRequest=Gf,l.DepthMode=Af,l.EXTENT=ba,l.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,r=1<<i,n=Math.floor(e.x),o=Math.floor((e.x-n)*r),s=Math.floor(e.y*r),a=this.findDEMTileFor(new Sh(i,n,i,o,s));return!(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const n=r.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new Sh(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const h=c.dem,u=1<<c.tileID.canonical.z,p=(a*u-c.tileID.canonical.x)*h.dim,d=(e.y*u-c.tileID.canonical.y)*h.dim,f=Math.floor(p),m=Math.floor(d);return(i?this.exaggeration():1)*gi(gi(h.get(f,m),h.get(f,m+1),d-m),gi(h.get(f+1,m),h.get(f+1,m+1),d-m),p-f)}getAtTileOffset(e,t,i){const r=1<<e.canonical.z;return this.getAtPointOrZero(new La(e.wrap+(e.canonical.x+t/ba)/r,(e.canonical.y+i/ba)/r))}getAtTileOffsetFunc(r,n,o,s){return e=>{const t=this.getAtTileOffset(r,e.x,e.y),i=s.upVector(r.canonical,e.x,e.y);return kl(i,i,t*s.upVectorScale(r.canonical,n,o).metersToTile),i}}getForTilePoints(e,t,i,r){const n=Rf.create(this,e,r);return!!n&&(t.forEach(e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)}),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,n=1<<t.canonical.z-r.canonical.z;let o=t.canonical.x/n-r.canonical.x,s=t.canonical.y/n-r.canonical.y,a=0;for(let e=0;e<t.canonical.z-r.canonical.z&&!i.leaves[a];e++){o*=2,s*=2;const t=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+t,o%=1,s%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},l.ErrorEvent=Ve,l.EvaluationParameters=ko,l.Event=je,l.Evented=Ge,l.FillExtrusionBucket=yh,l.Frustum=Hl,l.FrustumCorners=Xl,l.GLOBE_METERS_TO_ECEF=Fp,l.GLOBE_RADIUS=Op,l.GLOBE_SCALE_MATCH_LATITUDE=45,l.GLOBE_ZOOM_THRESHOLD_MAX=6,l.GLOBE_ZOOM_THRESHOLD_MIN=5,l.GlobeSharedBuffers=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const t of this._gridSegments)t.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const i of this._wireframeSegments)i.destroy()}}_createGrid(e){const i=new Jo,r=new fs,n=65;for(let t=0;t<n;t++)for(let e=0;e<n;e++)i.emplaceBack(e,t);this._gridSegments=[];for(let e=0,t=0;e<Np.length;e++){const o=Np[e];for(let t=0;t<o;t++)for(let e=0;e<64;e++){const a=t*n+e;r.emplaceBack(a+1,a,a+n),r.emplaceBack(a+n,a+n+1,a+1)}const s=64*o*2;this._gridSegments.push(va.simpleSegment(0,t,(o+1)*n,s)),t+=s}this._gridBuffer=e.createVertexBuffer(i,Rp.members),this._gridIndexBuffer=e.createIndexBuffer(r,!0)}_createPoles(e){const i=new fs;for(let e=0;e<=64;e++)i.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(i,!0);const r=new ys,n=new ys;this._poleSegments=[];for(let e=0,t=0;e<5;e++){const o=1<<e,s=512*o/Math.PI/2,a=360/o;r.emplaceBack(0,-s,0,0,0,.5,0),n.emplaceBack(0,-s,0,0,0,.5,1);for(let e=0;e<=64;e++){const i=e/64,l=gi(0,a,i),[c,h,u]=Xp(od,sd,l,s);r.emplaceBack(c,h,u,0,0,i,0),n.emplaceBack(c,h,u,0,0,i,1)}this._poleSegments.push(va.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(r,Lp,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(n,Lp,!1)}getGridBuffers(e){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments[e]]}getPoleBuffers(e){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}getWirefameBuffers(e,i){if(!this._wireframeSegments){const i=new bs,r=64,n=r+1;this._wireframeSegments=[];for(let e=0,t=0;e<Np.length;e++){const o=Np[e];for(let t=0;t<o;t++)for(let e=0;e<r;e++){const a=t*n+e;i.emplaceBack(a,a+1),i.emplaceBack(a,a+n),i.emplaceBack(a,a+n+1)}const s=o*r*3;this._wireframeSegments.push(va.simpleSegment(0,t,(o+1)*n,s)),t+=s}this._wireframeIndexBuffer=e.createIndexBuffer(i)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[i]]}},l.GlyphManager=cp,l.ImagePosition=zu,l.LineAtlas=Hd,l.LngLat=Ea,l.LngLatBounds=wa,l.LocalGlyphMode=lp,l.MAX_MERCATOR_LATITUDE=Pa,l.MercatorCoordinate=La,l.ONE_EM=Hh,l.OverscaledTileID=Sh,l.Properties=qo,l.RGBAImage=lc,l.Ray=Wl,l.RequestManager=class{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let t="";for(let e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",ie,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!ne(e))return e;const i=ae(e);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!ne(e))return e;const i=ae(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!ne(e))return e;const n=ae(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=ae(e);return ne(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,le(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!ne(e))return e;const r=ae(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==r.authority&&512===i?"@2x":""}${H.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${X.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${X.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||X.ACCESS_TOKEN;return X.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(e,t){const i=ae(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${X.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${X.TILE_URL_VERSION}/`,"")}`;let n=i.params;return t&&(n=n.filter(e=>!e.match(/^access_token=/))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(e,t){const i=!!t&&ne(t),r=[];for(const t of e.tiles||[])oe(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=ae(X.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!X.REQUIRE_ACCESS_TOKEN)return le(e);if(t=t||X.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter(e=>-1===e.indexOf("access_token")),e.params.push(`access_token=${t||""}`),le(e)}},l.ResourceType=Ce,l.SegmentVector=va,l.SourceCache=zf,l.StencilMode=Cf,l.StructArrayLayout1ui2=ws,l.StructArrayLayout2f1f2i16=us,l.StructArrayLayout2i4=Jo,l.StructArrayLayout2ui4=bs,l.StructArrayLayout3f12=ds,l.StructArrayLayout3ui6=fs,l.StructArrayLayout4i8=es,l.StructArrayLayout5f20=xs,l.Texture=Xd,l.Tile=pf,l.Transitionable=Lo,l.Uniform1f=Ks,l.Uniform1i=class extends Hs{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},l.Uniform2f=class extends Hs{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},l.Uniform3f=class extends Hs{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},l.Uniform4f=Js,l.UniformColor=Qs,l.UniformMatrix2f=class extends Hs{constructor(e,t){super(e,t),this.current=ia}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}},l.UniformMatrix3f=class extends Hs{constructor(e,t){super(e,t),this.current=ta}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}},l.UniformMatrix4f=class extends Hs{constructor(e,t){super(e,t),this.current=ea}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},l.UnwrappedTileID=Ah,l.ValidationError=Ur,l.VectorTileWorkerSource=class extends Ge{constructor(e,t,i,r,n){super(),this.actor=e,this.layerIndex=t,this.availableImages=i,this.loadVectorData=n||$f,this.loading={},this.loaded={},this.deduped=new Gf(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler}loadTile(s,a){const l=s.uid,c=s&&s.request,h=c&&c.collectResourceTiming,u=this.loading[l]=new jf(s);u.abort=this.loadVectorData(s,(e,t)=>{const i=!this.loading[l];if(delete this.loading[l],i||e||!t)return u.status="done",i||(this.loaded[l]=u),a(e);const r=t.rawData,n={};t.expires&&(n.expires=t.expires),t.cacheControl&&(n.cacheControl=t.cacheControl),u.vectorTile=t.vectorTile||new uh.VectorTile(new lu(r));const o=()=>{u.parse(u.vectorTile,this.layerIndex,this.availableImages,this.actor,(e,t)=>{if(e||!t)return a(e);const i={};if(h){const e=U(c);e.length>0&&(i.resourceTiming=JSON.parse(JSON.stringify(e)))}a(null,b({rawTileData:r.slice(0)},t,n,i))})};this.isSpriteLoaded?o():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(o,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom}):o()}),this.loaded=this.loaded||{},this.loaded[l]=u})}reloadTile(e,r){const t=this.loaded,i=e.uid,n=this;if(t&&t[i]){const o=t[i];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=ld(e.tileID.canonical,e.projection);const s=(e,t)=>{const i=o.reloadCallback;i&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,i)),r(e,t)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}},l.WritingMode=Lu,l.ZoomHistory=Rn,l.add=Sl,l.addDynamicAttributes=Ld,l.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e[0]=s*h-a*c,e[1]=n*c-r*h,e[2]=r*a-n*s,e[3]=a*l-o*h,e[4]=i*h-n*l,e[5]=n*o-i*a,e[6]=o*c-s*l,e[7]=r*l-i*c,e[8]=i*s-r*o,e},l.asyncAll=u,l.bezier=o,l.bindAll=x,l.boundsAttributes=hf,l.bufferConvexPolygon=function(t,i){const r=[];for(let e=0;e<t.length;e++){const n=d(e-1,-1,t.length-1),o=d(e+1,-1,t.length-1),s=t[e],a=t[o],l=t[n].sub(s).unit(),c=a.sub(s).unit(),h=c.angleWithSep(l.x,l.y),u=l.add(c).unit().mult(-1*i/Math.sin(h/2));r.push(s.add(u))}return r},l.cacheEntryPossiblyAdded=function(e){Se++,Se>ve&&(e.getActor().send("enforceCacheSizeLimit",xe),Se=0)},l.calculateGlobeLabelMatrix=function(e,t){const{x:i,y:r}=e.point,n=td(i,r,e.worldSize/e._projectionScaler,0,0);return ml(n,n,ed(Zp(t)))},l.calculateGlobeMatrix=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return td(t,i,e.worldSize,r,n)},l.calculateGlobeMercatorMatrix=function(e){const t=e.worldSize,i=e.point,r=Ia(1,e.center.lat)*t,n=e.pixelsPerMeter,o=t/(r/e.pixelsPerMeter),s=fl(new Float64Array(16));return _l(s,s,[i.x,i.y,0]),gl(s,s,[o,o,n]),Float32Array.from(s)},l.circumferenceAtLatitude=Sa,l.clamp=C,l.clearTileCache=function(e){const t=[];for(const e in be)t.push(p.caches.delete(e)),delete be[e];e&&Promise.all(t).catch(e).then(()=>e())},l.clipLine=np,l.clone=function(e){var t=new pl(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},l.clone$1=A,l.collisionCircleLayout=Xh,l.config=X,l.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},l.create=function(){var e=new pl(16);return pl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},l.create$1=dl,l.createExpression=Lr,l.createLayout=Ho,l.createStyleLayer=function(e){return"custom"===e.type?new qd(e):new Wd[e.type](e)},l.cross=Dl,l.degToRad=z,l.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},l.div=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},l.dot=Ll,l.ease=c,l.easeCubicInOut=a,l.emitValidationErrors=Cn,l.endsWith=w,l.enforceCacheSizeLimit=function(r){for(const e in be)Te(e),be[e].then(i=>{i.keys().then(t=>{for(let e=0;e<t.length-r;e++)i.delete(t[e])})})},l.evaluateSizeForFeature=Qh,l.evaluateSizeForZoom=eu,l.evaluateVariableOffset=Tp,l.evented=Co,l.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},l.exactEquals$1=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},l.exported=Z,l.exported$1=H,l.extend=b,l.extend$1=qe,l.fillExtrusionHeightLift=vh,l.filterObject=E,l.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},l.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,p=n*s,d=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[1]=h+g,e[2]=p-_,e[3]=0,e[4]=h-g,e[5]=1-c-f,e[6]=d+m,e[7]=0,e[8]=p+_,e[9]=d-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},l.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},l.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},l.furthestTileCorner=function(e){const t=Math.round((e+45+360)%360/90)%4;return n[t]},l.getAABBPointSquareDist=function(t,i,r){let n=0;for(let e=0;e<2;++e){const o=r?r[e]:0;t[e]>o&&(n+=(t[e]-o)*(t[e]-o)),i[e]<o&&(n+=(o-i[e])*(o-i[e]))}return n},l.getAnchorAlignment=Zu,l.getAnchorJustification=Ap,l.getBounds=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const F of e)t=Math.min(t,F.x),i=Math.min(i,F.y),r=Math.max(r,F.x),n=Math.max(n,F.y);return{min:new F(t,i),max:new F(r,n)}},l.getColumn=O,l.getGridMatrix=function(e,t,i){const[r,n]=t,o=.015625;return[0,(n[1]-r[1])*o,1<<e.z,(n[0]-r[0])/Np[i],0,e.y,r[0],r[1],o]},l.getImage=Fe,l.getJSON=function(e,t){return Be(b(e,{type:"json"}),t)},l.getLatitudinalLod=function(e){const t=80.051129;e=C(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(z(e))),3);return Math.round(i*(Np.length-1))},l.getMapSessionAPI=_e,l.getPerformanceMeasurement=U,l.getProjection=Id,l.getRTLTextPluginStatus=Mo,l.getReferrer=Ie,l.getTilePoint=function(e,{x:t,y:i},r=0){return new F(((t-r)*e.scale-e.x)*ba,(i*e.scale-e.y)*ba)},l.getTileVec3=function(e,t,i=0){return Al(((t.x-i)*e.scale-e.x)*ba,(t.y*e.scale-e.y)*ba,za(t.z,t.y))},l.getVideo=function(t,e){const i=p.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e<t.length;e++){const r=p.document.createElement("source");Le(t[e])||(i.crossOrigin="Anonymous"),r.src=t[e],i.appendChild(r)}return{cancel:()=>{}}},l.globeCenterToScreenPoint=function(e){const t=[0,0,0],i=fl(new Float64Array(16));return ml(i,e.pixelMatrix,e.globeMatrix),Rl(t,t,i),new F(t[0],t[1])},l.globeECEFOrigin=function(e,t){const i=[0,0,0];return Rl(i,i,Qp(Zp(t.canonical))),Rl(i,i,e),i},l.globeNormalizeECEF=Qp,l.globePixelsToTileUnits=function(e,t){return ba/(512*Math.pow(2,e))*Jp(Zp(t))},l.globePoleMatrixForTile=function(e,t,i){const r=fl(new Float64Array(16)),n=1<<e,o=360*(t/n-.5),s=i.point,a=i.worldSize/(i.tileSize*n);return _l(r,r,[s.x,s.y,-i.worldSize/Math.PI/2]),gl(r,r,[a,a,a]),yl(r,r,z(-i._center.lat)),xl(r,r,z(-i._center.lng+o)),Float32Array.from(r)},l.globeTileBounds=Zp,l.globeTileLatLngCorners=Wp,l.globeTiltAtLngLat=rd,l.globeToMercatorTransition=id,l.globeUseCustomAntiAliasing=function(e,t,i){const r=id(i.zoom),n=e.style.map._antialias,o=!!t.extStandardDerivatives,s=t.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!s&&o},l.identity=fl,l.identity$1=ql,l.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],p=t[10],d=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=h*m-u*f,A=h*_-p*f,S=h*g-d*f,C=u*_-p*m,M=u*g-d*m,I=p*g-d*_,B=y*I-x*M+v*C+b*S-w*A+T*E;return B?(e[0]=(a*I-l*M+c*C)*(B=1/B),e[1]=(n*M-r*I-o*C)*B,e[2]=(m*T-_*w+g*b)*B,e[3]=(p*w-u*T-d*b)*B,e[4]=(l*S-s*I-c*A)*B,e[5]=(i*I-n*S+o*A)*B,e[6]=(_*v-f*T-g*x)*B,e[7]=(h*T-p*v+d*x)*B,e[8]=(s*M-a*S+c*E)*B,e[9]=(r*S-i*M-o*E)*B,e[10]=(f*w-m*v+g*y)*B,e[11]=(u*v-h*w-d*y)*B,e[12]=(a*A-s*C-l*E)*B,e[13]=(i*C-r*A+n*E)*B,e[14]=(m*x-f*b-_*y)*B,e[15]=(h*b-u*x+p*y)*B,e):null},l.isLngLatBehindGlobe=function(e,t){return rd(e,t)>Math.PI/2*1.01},l.isMapAuthenticated=function(e){return ge.has(e)},l.isMapboxURL=ne,l.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!D(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},l.latFromMercatorY=ka,l.len=jl,l.length=El,l.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},l.loadVectorTile=$f,l.makeRequest=Be,l.mapValue=function(e,t,i,r,n){return C((e-t)/(i-t)*(n-r)+r,r,n)},l.mercatorXfromLng=Ca,l.mercatorYfromLat=Ma,l.mercatorZfromAltitude=Ia,l.mul=bl,l.mul$1=Ul,l.multiply=ml,l.multiply$1=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],p=i[0],d=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=p*r+d*s+f*c,e[1]=p*n+d*a+f*h,e[2]=p*o+d*l+f*u,e[3]=m*r+_*s+g*c,e[4]=m*n+_*a+g*h,e[5]=m*o+_*l+g*u,e[6]=y*r+x*s+v*c,e[7]=y*n+x*a+v*h,e[8]=y*o+x*l+v*u,e},l.multiply$2=Ml,l.nextPowerOfTwo=g,l.normalize=Pl,l.normalize$1=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},l.number=gi,l.ortho=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e},l.pbf=lu,l.perspective=function(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e},l.pick=function(t,i){const r={};for(let e=0;e<i.length;e++){const n=i[e];n in t&&(r[n]=t[n])}return r},l.plugin=Bo,l.pointGeometry=F,l.polygonContainsPoint=il,l.polygonIntersectsBox=rl,l.polygonIntersectsPolygon=Ya,l.polygonizeBounds=function(e,t,i=0,r=!0){const n=new F(i,i),o=e.sub(n),s=t.add(n),a=[o,new F(s.x,o.y),s,new F(o.x,s.y)];return r&&a.push(o.clone()),a},l.posAttributes=Rp,l.postMapLoadEvent=fe,l.postTurnstileEvent=pe,l.potpack=ku,l.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},l.radToDeg=S,l.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],l.registerForPluginStateChange=function(e){return e({pluginStatus:To,pluginURL:Eo}),Co.on("pluginStateChange",e),e},l.removeAuthState=function(e){ge.delete(e)},l.renderColorRamp=hc,l.resample=Ra,l.rotateX=yl,l.rotateX$1=Zl,l.rotateY=xl,l.rotateY$1=Yl,l.rotateZ=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],h=t[5],u=t[6],p=t[7];return t!==e&&(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[0]=o*n+c*r,e[1]=s*n+h*r,e[2]=a*n+u*r,e[3]=l*n+p*r,e[4]=c*n-o*r,e[5]=h*n-s*r,e[6]=u*n-a*r,e[7]=p*n-l*r,e},l.rotateZ$1=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},l.scale=gl,l.scale$1=Vl,l.scale$2=kl,l.scaleAndAdd=zl,l.setCacheLimits=function(e,t){xe=e,ve=t},l.setColumn=function(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]},l.setRTLTextPlugin=function(e,t,i=!1){if(To===xo||To===vo||To===bo)throw new Error("setRTLTextPlugin cannot be called multiple times.");Eo=Z.resolveURL(e),To=xo,wo=t,So(),i||Io()},l.smoothstep=h,l.spec=$e,l.storeAuthState=function(e,t){t?ge.add(e):ge.delete(e)},l.sub=Nl,l.subtract=Cl,l.symbolSize=tu,l.tileAABB=function(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return Yp(e,t,new Eh(i,r,n));const c=ld({z:i,x:r,y:n},l);return new Kl([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},l.tileTransform=ld,l.transformMat3=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},l.transformMat4=Rl,l.transformMat4$1=Gl,l.transformQuat=Ol,l.translate=_l,l.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},l.triggerPluginCompletionEvent=Ao,l.uniqueId=m,l.updateGlobeVertexNormal=function(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n},l.validateCustomStyleLayer=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},l.validateFilter=e=>Sn(ln(e)),l.validateFog=e=>Sn(xn(e)),l.validateLayer=e=>Sn(dn(e)),l.validateLight=e=>Sn(gn(e)),l.validateSource=e=>Sn(_n(e)),l.validateStyle=Tn,l.validateTerrain=e=>Sn(yn(e)),l.values=v,l.vectorTile=uh,l.version=j,l.warnOnce=Y,l.window=p,l.wrap=d}),t(["./shared"],function(l){"use strict";function n(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const i of t)e+=`${n(i)},`;return`${e}]`}let e="{";for(const r of Object.keys(t).sort())e+=`${r}:${n(t[r])},`;return`${e}}`}function s(e){let t="";for(const i of l.refProperties)t+=`/${n(e[i])}`;return t}class i{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(i,r){for(const s of i)this._layerConfigs[s.id]=s,(this._layers[s.id]=l.createStyleLayer(s)).compileFilter(),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const l of r)delete this.keyCache[l],delete this._layerConfigs[l],delete this._layers[l];this.familiesBySource={};const e=function(i,r){const n={};for(let t=0;t<i.length;t++){const o=r&&r[i[t].id]||s(i[t]);r&&(r[i[t].id]=o);let e=n[o];e||(e=n[o]=[]),e.push(i[t])}const e=[];for(const i in n)e.push(n[i]);return e}(l.values(this._layerConfigs),this.keyCache);for(const l of e){const i=l.map(e=>this._layers[e.id]),s=i[0];if("none"===s.visibility)continue;const r=s.source||"";let e=this.familiesBySource[r];e||(e=this.familiesBySource[r]={});const n=s.sourceLayer||"_geojsonTileLayer";let t=e[n];t||(t=e[n]=[]),t.push(i)}}}class r{loadTile(e,t){const{uid:i,encoding:r,rawImageData:n,padding:o,buildQuadTree:s}=e,a=l.window.ImageBitmap&&n instanceof l.window.ImageBitmap?this.getImageData(n,o):n;t(null,new l.DEMData(i,a,r,o<1,s))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const i=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}var a=function e(t,i){var r,n=t&&t.type;if("FeatureCollection"===n)for(r=0;r<t.features.length;r++)e(t.features[r],i);else if("GeometryCollection"===n)for(r=0;r<t.geometries.length;r++)e(t.geometries[r],i);else if("Feature"===n)e(t.geometry,i);else if("Polygon"===n)o(t.coordinates,i);else if("MultiPolygon"===n)for(r=0;r<t.coordinates.length;r++)o(t.coordinates[r],i);return t};function o(e,t){if(0!==e.length){c(e[0],t);for(var i=1;i<e.length;i++)c(e[i],!t)}}function c(e,t){for(var i=0,r=0,n=0,o=e.length,s=o-1;n<o;s=n++){var a=(e[n][0]-e[s][0])*(e[s][1]+e[n][1]),l=i+a;r+=Math.abs(i)>=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!t&&e.reverse()}const h=l.vectorTile.VectorTileFeature.prototype.toGeoJSON;class t{constructor(e){this._feature=e,this.extent=l.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const t of this._feature.geometry)e.push([new l.pointGeometry(t[0],t[1])]);return e}{const i=[];for(const r of this._feature.geometry){const n=[];for(const o of r)n.push(new l.pointGeometry(o[0],o[1]));i.push(n)}return i}}toGeoJSON(e,t,i){return h.call(this,e,t,i)}}class u{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=l.EXTENT,this.length=e.length,this._features=e}feature(e){return new t(this._features[e])}}var e=l.vectorTile.VectorTileFeature,p=d;function d(e,t){this.options=t||{},this.features=e,this.length=e.length}function f(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}d.prototype.feature=function(e){return new f(this.features[e],this.options.extent)},f.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t<e.length;t++){for(var i=e[t],r=[],n=0;n<i.length;n++)r.push(new l.pointGeometry(i[n][0],i[n][1]));this.geometry.push(r)}return this.geometry},f.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,i=-1/0,r=1/0,n=-1/0,o=0;o<e.length;o++)for(var s=e[o],a=0;a<s.length;a++){var l=s[a];t=Math.min(t,l.x),i=Math.max(i,l.x),r=Math.min(r,l.y),n=Math.max(n,l.y)}return[t,r,i,n]},f.prototype.toGeoJSON=e.prototype.toGeoJSON;var m=g,_=p;function g(e){var t=new l.pbf;return function(e,t){for(var i in e.layers)t.writeMessage(3,y,e.layers[i])}(e,t),t.finish()}function y(e,t){var i;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<e.length;i++)r.feature=e.feature(i),t.writeMessage(2,x,r);var n=r.keys;for(i=0;i<n.length;i++)t.writeStringField(3,n[i]);var o=r.values;for(i=0;i<o.length;i++)t.writeMessage(4,E,o[i])}function x(e,t){var i=e.feature;void 0!==i.id&&t.writeVarintField(1,i.id),t.writeMessage(2,v,e),t.writeVarintField(3,i.type),t.writeMessage(4,T,i)}function v(e,t){var i=e.feature,r=e.keys,n=e.values,o=e.keycache,s=e.valuecache;for(var a in i.properties){var l=i.properties[a],c=o[a];if(null!==l){void 0===c&&(r.push(a),o[a]=c=r.length-1),t.writeVarint(c);var h=typeof l;"string"!==h&&"boolean"!==h&&"number"!==h&&(l=JSON.stringify(l));var u=h+":"+l,p=s[u];void 0===p&&(n.push(l),s[u]=p=n.length-1),t.writeVarint(p)}}}function b(e,t){return(t<<3)+(7&e)}function w(e){return e<<1^e>>31}function T(e,t){for(var i=e.loadGeometry(),r=e.type,n=0,o=0,s=i.length,a=0;a<s;a++){var l=i[a],c=1;1===r&&(c=l.length),t.writeVarint(b(1,c));for(var h=3===r?l.length-1:l.length,u=0;u<h;u++){1===u&&1!==r&&t.writeVarint(b(2,h-1));var p=l[u].x-n,d=l[u].y-o;t.writeVarint(w(p)),t.writeVarint(w(d)),n+=p,o+=d}3===r&&t.writeVarint(b(7,1))}}function E(e,t){var i=typeof e;"string"===i?t.writeStringField(1,e):"boolean"===i?t.writeBooleanField(7,e):"number"===i&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}function A(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;S(e,t,s,r,n,o%2),A(e,t,i,r,s-1,o+1),A(e,t,i,s+1,n,o+1)}function S(i,r,n,o,s,a){for(;s>o;){if(s-o>600){const c=s-o+1,h=n-o+1,u=Math.log(c),p=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*p*(c-p)/c)*(h-c/2<0?-1:1);S(i,r,n,Math.max(o,Math.floor(n-h*p/c+d)),Math.min(s,Math.floor(n+(c-h)*p/c+d)),a)}const l=r[2*n+a];let e=o,t=s;for(C(i,r,o,n),r[2*s+a]>l&&C(i,r,o,s);e<t;){for(C(i,r,e,t),e++,t--;r[2*e+a]<l;)e++;for(;r[2*t+a]>l;)t--}r[2*o+a]===l?C(i,r,o,t):(t++,C(i,r,t,s)),t<=n&&(o=t+1),n<=t&&(s=t-1)}}function C(e,t,i,r){M(e,i,r),M(t,2*i,2*r),M(t,2*i+1,2*r+1)}function M(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function I(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}m.fromVectorTileJs=g,m.fromGeojsonVt=function(e,t){t=t||{};var i={};for(var r in e)i[r]=new p(e[r].features,t),i[r].name=r,i[r].version=t.version,i[r].extent=t.extent;return g({layers:i})},m.GeoJSONWrapper=_;const B=e=>e[0],k=e=>e[1];class z{constructor(t,i=B,r=k,e=64,n=Float64Array){this.nodeSize=e,this.points=t;const o=t.length<65536?Uint16Array:Uint32Array,s=this.ids=new o(t.length),a=this.coords=new n(2*t.length);for(let e=0;e<t.length;e++)s[e]=e,a[2*e]=i(t[e]),a[2*e+1]=r(t[e]);A(s,a,e,0,s.length-1,0)}range(e,t,i,r){return function(t,i,r,n,o,s,e){const a=[0,t.length-1,0],l=[];let c,h;for(;a.length;){const u=a.pop(),p=a.pop(),d=a.pop();if(p-d<=e){for(let e=d;e<=p;e++)c=i[2*e],h=i[2*e+1],c>=r&&c<=o&&h>=n&&h<=s&&l.push(t[e]);continue}const f=Math.floor((d+p)/2);c=i[2*f],h=i[2*f+1],c>=r&&c<=o&&h>=n&&h<=s&&l.push(t[f]);const m=(u+1)%2;(0===u?r<=c:n<=h)&&(a.push(d),a.push(f-1),a.push(m)),(0===u?o>=c:s>=h)&&(a.push(f+1),a.push(p),a.push(m))}return l}(this.ids,this.coords,e,t,i,r,this.nodeSize)}within(e,t,i){return function(t,i,r,n,e,o){const s=[0,t.length-1,0],a=[],l=e*e;for(;s.length;){const c=s.pop(),h=s.pop(),u=s.pop();if(h-u<=o){for(let e=u;e<=h;e++)I(i[2*e],i[2*e+1],r,n)<=l&&a.push(t[e]);continue}const p=Math.floor((u+h)/2),d=i[2*p],f=i[2*p+1];I(d,f,r,n)<=l&&a.push(t[p]);const m=(c+1)%2;(0===c?r-e<=d:n-e<=f)&&(s.push(u),s.push(p-1),s.push(m)),(0===c?r+e>=d:n+e>=f)&&(s.push(p+1),s.push(h),s.push(m))}return a}(this.ids,this.coords,e,t,i,this.nodeSize)}}const P={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},L=Math.fround||(D=new Float32Array(1),e=>(D[0]=+e,D[0]));var D;class R{constructor(e){this.options=$(Object.create(P),e),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:i,minZoom:r,maxZoom:n,nodeSize:o}=this.options;i&&console.time("total time");const e=`prepare ${t.length} points`;i&&console.time(e),this.points=t;let s=[];for(let e=0;e<t.length;e++)t[e].geometry&&s.push(F(t[e],e));this.trees[n+1]=new z(s,q,Z,o,Float32Array),i&&console.timeEnd(e);for(let e=n;e>=r;e--){const r=+Date.now();s=this._cluster(s,e),this.trees[e]=new z(s,q,Z,o,Float32Array),i&&console.log("z%d: %d clusters in %dms",e,s.length,+Date.now()-r)}return i&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),s=this.getClusters([-180,r,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(j(i),V(o),j(n),V(r)),l=[];for(const e of a){const t=s.points[e];l.push(t.numPoints?N(t):this.points[t.index])}return l}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.points[t];if(!o)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o.x,o.y,s),l=[];for(const t of a){const i=n.points[t];i.parentId===e&&l.push(i.numPoints?N(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,i){const r=[];return this._appendLeaves(r,e,t=t||10,i=i||0,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,h={features:[]};return this._addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.points,t,i,n,h),0===t&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.points,n,i,n,h),t===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.points,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n<r?n++:e.push(t),e.length===i)break}return n}_addTileFeatures(n,o,s,a,l,c){for(const h of n){const n=o[h],u=n.numPoints;let e,t,i;if(u)e=U(n),t=n.x,i=n.y;else{const o=this.points[n.index];e=o.properties,t=j(o.geometry.coordinates[0]),i=V(o.geometry.coordinates[1])}const p={type:1,geometry:[[Math.round(this.options.extent*(t*l-s)),Math.round(this.options.extent*(i*l-a))]],tags:e};let r;u?r=n.id:this.options.generateId?r=n.index:this.points[n.index].id&&(r=this.points[n.index].id),void 0!==r&&(p.id=r),c.features.push(p)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(+e,this.options.maxZoom+1))}_cluster(e,o){const s=[],{radius:a,extent:l,reduce:c,minPoints:t}=this.options,i=a/(l*Math.pow(2,o));for(let n=0;n<e.length;n++){const l=e[n];if(l.zoom<=o)continue;l.zoom=o;const h=this.trees[o+1],u=h.within(l.x,l.y,i),p=l.numPoints||1;let r=p;for(const e of u){const s=h.points[e];s.zoom>o&&(r+=s.numPoints||1)}if(r>p&&r>=t){let e=l.x*p,t=l.y*p,i=c&&p>1?this._map(l,!0):null;const d=(n<<5)+(o+1)+this.points.length;for(const s of u){const a=h.points[s];if(a.zoom<=o)continue;a.zoom=o;const f=a.numPoints||1;e+=a.x*f,t+=a.y*f,a.parentId=d,c&&(i||(i=this._map(l,!0)),c(i,this._map(a)))}l.parentId=d,s.push(O(e/r,t/r,d,r,i))}else if(s.push(l),r>1)for(const e of u){const a=h.points[e];a.zoom<=o||(a.zoom=o,s.push(a))}}return s}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?$({},e.properties):e.properties;const i=this.points[e.index].properties,r=this.options.map(i);return t&&r===i?$({},r):r}}function O(e,t,i,r,n){return{x:L(e),y:L(t),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:n}}function F(e,t){const[i,r]=e.geometry.coordinates;return{x:L(j(i)),y:L(V(r)),zoom:1/0,index:t,parentId:-1}}function N(e){return{type:"Feature",id:e.id,properties:U(e),geometry:{type:"Point",coordinates:[(t=e.x,360*(t-.5)),G(e.y)]}};var t}function U(e){const t=e.numPoints,i=t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?Math.round(t/100)/10+"k":t;return $($({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:i})}function j(e){return e/360+.5}function V(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function G(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function $(e,t){for(const i in t)e[i]=t[i];return e}function q(e){return e.x}function Z(e){return e.y}function Y(e,t,i,r){for(var n,o=r,s=i-t>>1,a=i-t,l=e[t],c=e[t+1],h=e[i],u=e[i+1],p=t+3;p<i;p+=3){var d=W(e[p],e[p+1],l,c,h,u);if(d>o)n=p,o=d;else if(d===o){var f=Math.abs(p-s);f<a&&(n=p,a=f)}}o>r&&(n-t>3&&Y(e,t,n,r),e[n+2]=o,i-n>3&&Y(e,n,i,r))}function W(e,t,i,r,n,o){var s=n-i,a=o-r;if(0!==s||0!==a){var l=((e-i)*s+(t-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return(s=e-i)*s+(a=t-r)*a}function X(e,t,i,r){var n={id:void 0===e?null:e,type:t,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,i=e.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)H(e,t);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r<t.length;r++)H(e,t[r]);else if("MultiPolygon"===i)for(r=0;r<t.length;r++)for(var n=0;n<t[r].length;n++)H(e,t[r][n])}(n),n}function H(e,t){for(var i=0;i<t.length;i+=3)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function K(e,t,i,r){if(t.geometry){var n=t.geometry.coordinates,o=t.geometry.type,s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2),a=[],l=t.id;if(i.promoteId?l=t.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)J(n,a);else if("MultiPoint"===o)for(var c=0;c<n.length;c++)J(n[c],a);else if("LineString"===o)Q(n,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(c=0;c<n.length;c++)Q(n[c],a=[],s,!1),e.push(X(l,"LineString",a,t.properties));return}ee(n,a,s,!1)}else if("Polygon"===o)ee(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<t.geometry.geometries.length;c++)K(e,{id:l,geometry:t.geometry.geometries[c],properties:t.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<n.length;c++){var h=[];ee(n[c],h,s,!0),a.push(h)}}e.push(X(l,o,a,t.properties))}}function J(e,t){t.push(te(e[0])),t.push(ie(e[1])),t.push(0)}function Q(e,t,i,r){for(var n,o,s=0,a=0;a<e.length;a++){var l=te(e[a][0]),c=ie(e[a][1]);t.push(l),t.push(c),t.push(0),a>0&&(s+=r?(n*c-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-o,2))),n=l,o=c}var h=t.length-3;t[2]=1,Y(t,0,h,i),t[h+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function ee(e,t,i,r){for(var n=0;n<e.length;n++){var o=[];Q(e[n],o,i,r),t.push(o)}}function te(e){return e/360+.5}function ie(e){var t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function re(e,t,i,r,n,o,s,a){if(r/=t,o>=(i/=t)&&s<r)return e;if(s<i||o>=r)return null;for(var l=[],c=0;c<e.length;c++){var h=e[c],u=h.geometry,p=h.type,d=0===n?h.minX:h.minY,f=0===n?h.maxX:h.maxY;if(d>=i&&f<r)l.push(h);else if(!(f<i||d>=r)){var m=[];if("Point"===p||"MultiPoint"===p)ne(u,m,i,r,n);else if("LineString"===p)oe(u,m,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===p)ae(u,m,i,r,n,!1);else if("Polygon"===p)ae(u,m,i,r,n,!0);else if("MultiPolygon"===p)for(var _=0;_<u.length;_++){var g=[];ae(u[_],g,i,r,n,!0),g.length&&m.push(g)}if(m.length){if(a.lineMetrics&&"LineString"===p){for(_=0;_<m.length;_++)l.push(X(h.id,p,m[_],h.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===m.length?(p="LineString",m=m[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===m.length?"Point":"MultiPoint"),l.push(X(h.id,p,m,h.tags))}}}return l.length?l:null}function ne(e,t,i,r,n){for(var o=0;o<e.length;o+=3){var s=e[o+n];s>=i&&s<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function oe(e,t,i,r,n,o,s){for(var a,l,c=se(e),h=0===n?ce:he,u=e.start,p=0;p<e.length-3;p+=3){var d=e[p],f=e[p+1],m=e[p+2],_=e[p+3],g=e[p+4],y=0===n?d:f,x=0===n?_:g,v=!1;s&&(a=Math.sqrt(Math.pow(d-_,2)+Math.pow(f-g,2))),y<i?x>i&&(l=h(c,d,f,_,g,i),s&&(c.start=u+a*l)):y>r?x<r&&(l=h(c,d,f,_,g,r),s&&(c.start=u+a*l)):le(c,d,f,m),x<i&&y>=i&&(l=h(c,d,f,_,g,i),v=!0),x>r&&y<=r&&(l=h(c,d,f,_,g,r),v=!0),!o&&v&&(s&&(c.end=u+a*l),t.push(c),c=se(e)),s&&(u+=a)}var b=e.length-3;d=e[b],f=e[b+1],m=e[b+2],(y=0===n?d:f)>=i&&y<=r&&le(c,d,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&le(c,c[0],c[1],c[2]),c.length&&t.push(c)}function se(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ae(e,t,i,r,n,o){for(var s=0;s<e.length;s++)oe(e[s],t,i,r,n,o,!1)}function le(e,t,i,r){e.push(t),e.push(i),e.push(r)}function ce(e,t,i,r,n,o){var s=(o-t)/(r-t);return e.push(o),e.push(i+(n-i)*s),e.push(1),s}function he(e,t,i,r,n,o){var s=(o-i)/(n-i);return e.push(t+(r-t)*s),e.push(o),e.push(1),s}function ue(e,t){for(var i=[],r=0;r<e.length;r++){var n,o=e[r],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)n=pe(o.geometry,t);else if("MultiLineString"===s||"Polygon"===s){n=[];for(var a=0;a<o.geometry.length;a++)n.push(pe(o.geometry[a],t))}else if("MultiPolygon"===s)for(n=[],a=0;a<o.geometry.length;a++){for(var l=[],c=0;c<o.geometry[a].length;c++)l.push(pe(o.geometry[a][c],t));n.push(l)}i.push(X(o.id,s,n,o.tags))}return i}function pe(e,t){var i=[];i.size=e.size,void 0!==e.start&&(i.start=e.start,i.end=e.end);for(var r=0;r<e.length;r+=3)i.push(e[r]+t,e[r+1],e[r+2]);return i}function de(e,t){if(e.transformed)return e;var i,r,n,o=1<<e.z,s=e.x,a=e.y;for(i=0;i<e.features.length;i++){var l=e.features[i],c=l.geometry,h=l.type;if(l.geometry=[],1===h)for(r=0;r<c.length;r+=2)l.geometry.push(fe(c[r],c[r+1],t,o,s,a));else for(r=0;r<c.length;r++){var u=[];for(n=0;n<c[r].length;n+=2)u.push(fe(c[r][n],c[r][n+1],t,o,s,a));l.geometry.push(u)}}return e.transformed=!0,e}function fe(e,t,i,r,n,o){return[Math.round(i*(e*r-n)),Math.round(i*(t*r-o))]}function me(e,t,i,r,n){for(var o=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:i,y:r,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){s.numFeatures++,_e(s,e[a],o,n);var l=e[a].minX,c=e[a].minY,h=e[a].maxX,u=e[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),h>s.maxX&&(s.maxX=h),u>s.maxY&&(s.maxY=u)}return s}function _e(e,t,i,r){var n=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<n.length;a+=3)s.push(n[a]),s.push(n[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)ge(s,n,e,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<n.length;a++)ge(s,n[a],e,i,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(a=0;a<c.length;a++)ge(s,c[a],e,i,!0,0===a)}if(s.length){var h=t.tags||null;if("LineString"===o&&r.lineMetrics){for(var u in h={},t.tags)h[u]=t.tags[u];h.mapbox_clip_start=n.start/n.size,h.mapbox_clip_end=n.end/n.size}var p={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:h};null!==t.id&&(p.id=t.id),e.features.push(p)}}function ge(e,t,i,r,n,o){var s=r*r;if(r>0&&t.size<(n?s:r))i.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===r||t[l+2]>s)&&(i.numSimplified++,a.push(t[l]),a.push(t[l+1])),i.numPoints++;n&&function(e,t){for(var i=0,r=0,n=e.length,o=n-2;r<n;o=r,r+=2)i+=(e[r]-e[o])*(e[r+1]+e[o+1]);if(i>0===t)for(r=0,n=e.length;r<n/2;r+=2){var s=e[r],a=e[r+1];e[r]=e[n-2-r],e[r+1]=e[n-1-r],e[n-2-r]=s,e[n-1-r]=a}}(a,o),e.push(a)}}function ye(e,t){var i=(t=this.options=function(e,t){for(var i in t)e[i]=t[i];return e}(Object.create(this.options),t)).debug;if(i&&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 r=function(e,t){var i=[];if("FeatureCollection"===e.type)for(var r=0;r<e.features.length;r++)K(i,e.features[r],t,r);else K(i,"Feature"===e.type?e:{geometry:e},t);return i}(e,t);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(r=function(e,t){var i=t.buffer/t.extent,r=e,n=re(e,1,-1-i,i,0,-1,2,t),o=re(e,1,1-i,2+i,0,-1,2,t);return(n||o)&&(r=re(e,1,-i,1+i,0,-1,2,t)||[],n&&(r=ue(n,1).concat(r)),o&&(r=r.concat(ue(o,-1)))),r}(r,t)).length&&this.splitTile(r,0,0,0),i&&(r.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 xe(e,t,i){return 32*((1<<e)*i+t)+e}function ve(e,t){const i=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return t(null,null);const n=new u(r.features);let o=m(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:n,rawData:o.buffer})}ye.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ye.prototype.splitTile=function(e,t,i,r,n,o,s){for(var a=[e,t,i,r],l=this.options,c=l.debug;a.length;){r=a.pop(),i=a.pop(),t=a.pop(),e=a.pop();var h=1<<t,u=xe(t,i,r),p=this.tiles[u];if(!p&&(c>1&&console.time("creation"),p=this.tiles[u]=me(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+t;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=e,n){if(t===l.maxZoom||t===n)continue;var f=1<<n-t;if(i!==Math.floor(o/f)||r!==Math.floor(s/f))continue}else if(t===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue;if(p.source=null,0!==e.length){c>1&&console.time("clipping");var m,_,g,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;m=_=g=y=null,x=re(e,h,i-b,i+T,0,p.minX,p.maxX,l),v=re(e,h,i+w,i+E,0,p.minX,p.maxX,l),e=null,x&&(m=re(x,h,r-b,r+T,1,p.minY,p.maxY,l),_=re(x,h,r+w,r+E,1,p.minY,p.maxY,l),x=null),v&&(g=re(v,h,r-b,r+T,1,p.minY,p.maxY,l),y=re(v,h,r+w,r+E,1,p.minY,p.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*i,2*r),a.push(_||[],t+1,2*i,2*r+1),a.push(g||[],t+1,2*i+1,2*r),a.push(y||[],t+1,2*i+1,2*r+1)}}},ye.prototype.getTile=function(e,t,i){var r=this.options,n=r.extent,o=r.debug;if(e<0||e>24)return null;var s=1<<e,a=xe(e,t=(t%s+s)%s,i);if(this.tiles[a])return de(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",e,t,i);for(var l,c=e,h=t,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[xe(c,h,u)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,h,u),o>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?de(this.tiles[a],n):null):null};class be extends l.VectorTileWorkerSource{constructor(e,t,i,r,n){super(e,t,i,r,ve),n&&(this.loadGeoJSON=n)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(e,t)=>{if(e||!t)return n(e);if("object"!=typeof t)return n(new Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(t,!0);try{if(r.filter){const n=l.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));const o=t.features.filter(e=>n.value.evaluate({zoom:0},e));t={type:"FeatureCollection",features:o}}this._geoJSONIndex=r.cluster?new R(function({superclusterOptions:e,clusterProperties:t}){if(!t||!e)return e;const i={},r={},n={accumulated:null,zoom:0},o={properties:null},s=Object.keys(t);for(const e of s){const[n,o]=t[e],s=l.createExpression(o),a=l.createExpression("string"==typeof n?[n,["accumulated"],["get",e]]:n);i[e]=s.value,r[e]=a.value}return e.map=e=>{o.properties=e;const t={};for(const e of s)t[e]=i[e].evaluate(n,o);return t},e.reduce=(e,t)=>{o.properties=t;for(const t of s)n.accumulated=e[t],e[t]=r[t].evaluate(n,o)},e}(r)).load(t.features):function(e,t){return new ye(e,t)}(t,r.geojsonVtOptions)}catch(e){return n(e)}this.loaded={};const i={};if(s){const n=l.getPerformanceMeasurement(o);n&&(i.resourceTiming={},i.resourceTiming[r.source]=JSON.parse(JSON.stringify(n)))}n(null,i)}})}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)l.getJSON(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class we{constructor(e){this.self=e,this.actor=new l.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=l.getProjection({name:"mercator"}),this.workerSourceTypes={vector:l.VectorTileWorkerSource,geojson:be},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=e=>{if(l.plugin.isParsed())throw new Error("RTL text plugin already registered.");l.plugin.applyArabicShaping=e.applyArabicShaping,l.plugin.processBidirectionalText=e.processBidirectionalText,l.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(e,t){this.isSpriteLoaded[e]=t;for(const i in this.workerSources[e]){const r=this.workerSources[e][i];for(const e in r)r[e]instanceof l.VectorTileWorkerSource&&(r[e].isSpriteLoaded=t,r[e].fire(new l.Event("isSpriteLoaded")))}}setImages(e,t,i){this.availableImages[e]=t;for(const i in this.workerSources[e]){const r=this.workerSources[e][i];for(const e in r)r[e].availableImages=t}i()}enableTerrain(e,t,i){this.terrain=t,i()}setProjection(e,t){this.projections[e]=l.getProjection(t)}setLayers(e,t,i){this.getLayerIndex(e).replace(t),i()}updateLayers(e,t,i){this.getLayerIndex(e).update(t.layers,t.removedIds),i()}loadTile(e,t,i){const r=this.enableTerrain?l.extend({enableTerrain:this.terrain},t):t;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source).loadTile(r,i)}loadDEMTile(e,t,i){const r=this.enableTerrain?l.extend({buildQuadTree:this.terrain},t):t;this.getDEMWorkerSource(e,t.source).loadTile(r,i)}reloadTile(e,t,i){const r=this.enableTerrain?l.extend({enableTerrain:this.terrain},t):t;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source).reloadTile(r,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source).removeTile(t,i)}removeSource(e,t,i){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const r=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(e,t,i){try{l.plugin.setState(t);const e=l.plugin.getPluginURL();if(l.plugin.isLoaded()&&!l.plugin.isParsed()&&null!=e){this.self.importScripts(e);const t=l.plugin.isParsed();i(t?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),t)}}catch(e){i(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new i),t}getWorkerSource(s,e,t){return this.workerSources[s]||(this.workerSources[s]={}),this.workerSources[s][e]||(this.workerSources[s][e]={}),this.workerSources[s][e][t]||(this.workerSources[s][e][t]=new this.workerSourceTypes[e]({send:(e,t,i,r,n,o)=>{this.actor.send(e,t,i,s,n,o)},scheduler:this.actor.scheduler},this.getLayerIndex(s),this.getAvailableImages(s),this.isSpriteLoaded[s])),this.workerSources[s][e][t]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new r),this.demWorkerSources[e][t]}enforceCacheSizeLimit(e,t){l.enforceCacheSizeLimit(t)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new we(self)),we}),t(["./shared"],function(te){"use strict";function _(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let e=0;e<t.length;e++)if(!_(t[e],i[e]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(t).length!==Object.keys(i).length)return!1;for(const e in t)if(!_(t[e],i[e]))return!1;return!0}return t===i}var i=r;function r(e){return!function(e){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===n[t=e&&e.failIfMajorPerformanceCaveat]&&(n[t]=function(e){var t,i=function(e){var t=document.createElement("canvas"),i=Object.create(r.webGLContextAttributes);return i.failIfMajorPerformanceCaveat=e,t.getContext("webgl",i)||t.getContext("experimental-webgl",i)}(e);if(!i)return!1;try{t=i.createShader(i.VERTEX_SHADER)}catch(e){return!1}return!(!t||i.isContextLost())&&(i.shaderSource(t,"void main() {}"),i.compileShader(t),!0===i.getShaderParameter(t,i.COMPILE_STATUS))}(t)),n[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var t}(e)}var n={};function l(e,t,i){const r=te.window.document.createElement(e);return void 0!==t&&(r.className=t),i&&i.appendChild(r),r}function o(e,t,i){const r=te.window.document.createElementNS("http://www.w3.org/2000/svg",e);for(const te of Object.keys(t))r.setAttributeNS(null,te,t[te]);return i&&i.appendChild(r),r}r.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const e=te.window.document&&te.window.document.documentElement.style,t=e&&void 0!==e.userSelect?"userSelect":"WebkitUserSelect";let s;function a(){e&&t&&(s=e[t],e[t]="none")}function c(){e&&t&&(e[t]=s)}function h(e){e.preventDefault(),e.stopPropagation(),te.window.removeEventListener("click",h,!0)}function u(){te.window.addEventListener("click",h,!0),te.window.setTimeout(()=>{te.window.removeEventListener("click",h,!0)},0)}function p(e,t){const i=e.getBoundingClientRect();return m(e,i,t)}function d(t,i){const r=t.getBoundingClientRect(),n=[];for(let e=0;e<i.length;e++)n.push(m(t,r,i[e]));return n}function f(e){return void 0!==te.window.InstallTrigger&&2===e.button&&e.ctrlKey&&te.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function m(e,t,i){const r=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new te.pointGeometry((i.clientX-t.left)*r,(i.clientY-t.top)*r)}function v(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*o-n*r;return s?(e[0]=o*(s=1/s),e[1]=-r*s,e[2]=-n*s,e[3]=i*s,e):null}function g(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class y extends te.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new te.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(e,t){let i=!0;return this._validateStretch(t.stretchX,t.data&&t.data.width)||(this.fire(new te.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,t.data&&t.data.height)||(this.fire(new te.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new te.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){return!(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t){t.version=this.images[e].version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){const t=this.images[e];delete this.images[e],delete this.patterns[e],t.userImage&&t.userImage.onRemove&&t.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e,t){let i=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(i=!1);this.isLoaded()||i?this._notify(e,t):this.requestors.push({ids:e,callback:t})}_notify(e,t){const i={};for(const t of e){this.images[t]||this.fire(new te.Event("styleimagemissing",{id:t}));const e=this.images[t];e?i[t]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:te.warnOnce(`Image "${t}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}t(null,i)}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const t=this.patterns[e],i=this.getImage(e);if(!i)return null;if(t&&t.position.version===i.version)return t.position;if(t)t.position.version=i.version;else{const t={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new te.ImagePosition(t,i);this.patterns[e]={bin:t,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new te.Texture(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const te in this.patterns)e.push(this.patterns[te].bin);const{w:t,h:i}=te.potpack(e),r=this.atlasImage;r.resize({width:t||1,height:i||1});for(const e in this.patterns){const{bin:t}=this.patterns[e],i=t.x+1,n=t.y+1,o=this.images[e].data,s=o.width,a=o.height;te.RGBAImage.copy(o,r,{x:0,y:0},{x:i,y:n},{width:s,height:a}),te.RGBAImage.copy(o,r,{x:0,y:a-1},{x:i,y:n-1},{width:s,height:1}),te.RGBAImage.copy(o,r,{x:0,y:0},{x:i,y:n+a},{width:s,height:1}),te.RGBAImage.copy(o,r,{x:s-1,y:0},{x:i-1,y:n},{width:1,height:a}),te.RGBAImage.copy(o,r,{x:0,y:0},{x:i+s,y:n},{width:1,height:a})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const t of e){if(this.callbackDispatchedThisFrame[t])continue;this.callbackDispatchedThisFrame[t]=!0;const e=this.images[t];g(e)&&this.updateImage(t,e)}}}const x=new te.Properties({anchor:new te.DataConstantProperty(te.spec.light.anchor),position:new class{constructor(){this.specification=te.spec.light.position}possiblyEvaluate(e,t){return function([e,t,i]){const r=te.degToRad(t+90),n=te.degToRad(i);return{x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n),azimuthal:t,polar:i}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:te.number(e.x,t.x,i),y:te.number(e.y,t.y,i),z:te.number(e.z,t.z,i),azimuthal:te.number(e.azimuthal,t.azimuthal,i),polar:te.number(e.polar,t.polar,i)}}},color:new te.DataConstantProperty(te.spec.light.color),intensity:new te.DataConstantProperty(te.spec.light.intensity)}),b="-transition";class w extends te.Evented{constructor(e){super(),this._transitionable=new te.Transitionable(x),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t={}){if(!this._validate(te.validateLight,e,t))for(const t in e){const i=e[t];te.endsWith(t,b)?this._transitionable.setTransition(t.slice(0,-b.length),i):this._transitionable.setValue(t,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return(!i||!1!==i.validate)&&te.emitValidationErrors(this,e.call(te.validateStyle,te.extend({value:t,style:{glyphs:!0,sprite:!0},styleSpec:te.spec})))}}const T=new te.Properties({source:new te.DataConstantProperty(te.spec.terrain.source),exaggeration:new te.DataConstantProperty(te.spec.terrain.exaggeration)}),E="-transition";class A extends te.Evented{constructor(e,t){super(),this._transitionable=new te.Transitionable(T),this.set(e),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t}get(){return this._transitionable.serialize()}set(e){for(const t in e){const i=e[t];te.endsWith(t,E)?this._transitionable.setTransition(t.slice(0,-E.length),i):this._transitionable.setValue(t,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}}function S(e,t,i,r){const n=te.smoothstep(45,65,i),[o,s]=C(e,r),a=te.length(t);let l=1-Math.min(1,Math.exp((a-o)/(s-o)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*n*e.alpha}function C(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}const M=new te.Properties({range:new te.DataConstantProperty(te.spec.fog.range),color:new te.DataConstantProperty(te.spec.fog.color),"high-color":new te.DataConstantProperty(te.spec.fog["high-color"]),"space-color":new te.DataConstantProperty(te.spec.fog["space-color"]),"horizon-blend":new te.DataConstantProperty(te.spec.fog["horizon-blend"]),"star-intensity":new te.DataConstantProperty(te.spec.fog["star-intensity"])}),I="-transition";class B extends te.Evented{constructor(e,t){super(),this._transitionable=new te.Transitionable(M),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=t}get state(){const e=this._transform,t="globe"===e.projection.name,i=te.globeToMercatorTransition(e.zoom),r=this.properties.get("range"),n=[.5,3];return{range:t?[te.number(n[0],r[0],i),te.number(n[1],r[1],i)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t={}){if(!this._validate(te.validateFog,e,t)){for(const t of Object.keys(te.spec.fog))e&&void 0===e[t]&&(e[t]=te.spec.fog[t].default);for(const t in e){const i=e[t];te.endsWith(t,I)?this._transitionable.setTransition(t.slice(0,-I.length),i):this._transitionable.setValue(t,i)}}}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const t=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:te.smoothstep(45,65,e))*t.a}getOpacityAtLatLng(e,t){return this._transform.projection.supportsFog?function(e,t,i){const r=te.MercatorCoordinate.fromLngLat(t),n=i.elevation?i.elevation.getAtPointOrZero(r):0,o=[r.x,r.y,n];return te.transformMat4(o,o,i.mercatorFogMatrix),S(e,o,i.pitch,i._fov)}(this.state,e,t):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?C(this.state,e):[0,1]}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return(!i||!1!==i.validate)&&te.emitValidationErrors(this,e.call(te.validateStyle,te.extend({value:t,style:{glyphs:!0,sprite:!0},styleSpec:te.spec})))}}class k{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=te.uniqueId();const r=this.workerPool.acquire(this.id);for(let e=0;e<r.length;e++){const t=new k.Actor(r[e],i,this.id);t.name=`Worker ${e}`,this.actors.push(t)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(i,r,e){te.asyncAll(this.actors,(e,t)=>{e.send(i,r,t)},e=e||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}function z(e,t,i){return t*(te.EXTENT/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}k.Actor=te.Actor;class P{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(e,t){let i,r;if(e instanceof te.pointGeometry||"number"==typeof e[0]){const n=te.pointGeometry.convert(e);i=[te.pointGeometry.convert(e)],r=t.isPointAboveHorizon(n)}else{const o=te.pointGeometry.convert(e[0]),s=te.pointGeometry.convert(e[1]);i=[o,s],r=te.polygonizeBounds(o,s).every(e=>t.isPointAboveHorizon(e))}return new P(i,t.getCameraPoint(),r,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return te.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new te.pointGeometry(1,1)):this.screenBounds[1],r=te.polygonizeBounds(t,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x<i.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?r[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(r[3]=this.cameraPoint)),te.bufferConvexPolygon(r,e)}bufferedCameraGeometryGlobe(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new te.pointGeometry(1,1)):this.screenBounds[1],r=te.polygonizeBounds(t,i,e),n=this.cameraPoint.clone();switch(3*((n.y>t.y)+(n.y>i.y))+((n.x>t.x)+(n.x>i.x))){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n}return r}containsTile(t,e,i,r=0){const n=t.queryPadding/e._projectionScaler+1,o=i?this._bufferedCameraMercator(n,e):this._bufferedScreenMercator(n,e);let s=t.tileID.wrap+(o.unwrapped?r:0);const a=o.polygon.map(e=>te.getTilePoint(t.tileTransform,e,s));if(!te.polygonIntersectsBox(a,0,0,te.EXTENT,te.EXTENT))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const l=this.screenGeometryMercator.polygon.map(e=>te.getTileVec3(t.tileTransform,e,s)),c=l.map(e=>new te.pointGeometry(e[0],e[1])),h=e.getFreeCameraOptions().position||new te.MercatorCoordinate(0,0,0),u=te.getTileVec3(t.tileTransform,h,s),p=l.map(e=>{const t=te.sub(e,e,u);return te.normalize(t,t),new te.Ray(u,t)}),d=z(t,1,e.zoom)*e._projectionScaler;return{queryGeometry:this,tilespaceGeometry:c,tilespaceRays:p,bufferedTilespaceGeometry:a,bufferedTilespaceBounds:(f=te.getBounds(a),f.min.x=te.clamp(f.min.x,0,te.EXTENT),f.min.y=te.clamp(f.min.y,0,te.EXTENT),f.max.x=te.clamp(f.max.x,0,te.EXTENT),f.max.y=te.clamp(f.max.y,0,te.EXTENT),f),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:d};var f}_bufferedScreenMercator(t,i){const r=R(t);if(this._screenRaycastCache[r])return this._screenRaycastCache[r];{let e;return e="globe"===i.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),i):{polygon:this.bufferedScreenGeometry(t).map(e=>i.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[r]=e,e}}_bufferedCameraMercator(t,i){const r=R(t);if(this._cameraRaycastCache[r])return this._cameraRaycastCache[r];{let e;return e="globe"===i.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),i):{polygon:this.bufferedCameraGeometry(t).map(e=>i.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[r]=e,e}}_projectAndResample(e,t){const i=function(e,t){const i=te.multiply([],t.pixelMatrix,t.globeMatrix),r=[0,-te.GLOBE_RADIUS,0,1],n=[0,te.GLOBE_RADIUS,0,1],o=[0,0,0,1];te.transformMat4$1(r,r,i),te.transformMat4$1(n,n,i),te.transformMat4$1(o,o,i);const s=new te.pointGeometry(r[0]/r[3],r[1]/r[3]),a=new te.pointGeometry(n[0]/n[3],n[1]/n[3]),l=te.polygonContainsPoint(e,s)&&r[3]<o[3],c=te.polygonContainsPoint(e,a)&&n[3]<o[3];if(!l&&!c)return null;const h=function(t,i,r){for(let e=1;e<t.length;e++){const n=D(i.pointCoordinate3D(t[e-1]).x),o=D(i.pointCoordinate3D(t[e]).x);if(r<0){if(n<o)return{idx:e,t:-n/(o-1-n)}}else if(o<n)return{idx:e,t:(1-n)/(o+1-n)}}return null}(e,t,l?-1:1);if(!h)return null;const{idx:u,t:p}=h;let d=u>1?L(e.slice(0,u),t):[],f=u<e.length?L(e.slice(u),t):[];d=d.map(e=>new te.pointGeometry(D(e.x),e.y)),f=f.map(e=>new te.pointGeometry(D(e.x),e.y));const m=[...d];0===m.length&&m.push(f[f.length-1]);const _=te.number(m[m.length-1].y,(0===f.length?d[0]:f[0]).y,p);let g;return g=l?[new te.pointGeometry(0,_),new te.pointGeometry(0,0),new te.pointGeometry(1,0),new te.pointGeometry(1,_)]:[new te.pointGeometry(1,_),new te.pointGeometry(1,1),new te.pointGeometry(0,1),new te.pointGeometry(0,_)],m.push(...g),0===f.length?m.push(d[0]):m.push(...f),{polygon:m.map(e=>new te.MercatorCoordinate(e.x,e.y)),unwrapped:!1}}(e,t);if(i)return i;const r=function(t,i){let r=!1,n=-1/0,o=0;for(let e=0;e<t.length-1;e++)t[e].x>n&&(n=t[e].x,o=e);for(let e=0;e<t.length-1;e++){const i=(o+e)%(t.length-1),n=t[i],s=t[i+1];Math.abs(n.x-s.x)>.5&&(n.x<s.x?(n.x+=1,0===i&&(t[t.length-1].x+=1)):(s.x+=1,i+1===t.length-1&&(t[0].x+=1)),r=!0)}const s=te.mercatorXfromLng(i.center.lng);return r&&s<Math.abs(s-1)&&t.forEach(e=>{e.x-=1}),{polygon:t,unwrapped:r}}(L(e,t).map(e=>new te.pointGeometry(D(e.x),e.y)),t);return{polygon:r.polygon.map(e=>new te.MercatorCoordinate(e.x,e.y)),unwrapped:r.unwrapped}}}function L(e,i){return te.resample(e,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function D(e){return e<0?1+e%1:e%1}function R(e){return 100*e|0}function O(i,r,e,t,n){const o=function(e,t){if(e)return n(e);if(t){const e=te.pick(te.extend(t,i),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);t.vector_layers&&(e.vectorLayers=t.vector_layers,e.vectorLayerIds=e.vectorLayers.map(e=>e.id)),t.language_options&&(e.languageOptions=t.language_options),t.language&&t.language[t.id]&&(e.language=t.language[t.id]),t.worldview_options&&(e.worldviewOptions=t.worldview_options),t.worldview?e.worldview=t.worldview[t.id]:t.worldview_default&&(e.worldview=t.worldview_default),e.tiles=r.canonicalizeTileset(e,i.url),n(null,e)}};return i.url?te.getJSON(r.transformRequest(r.normalizeSourceURL(i.url,null,e,t),te.ResourceType.Source),o):te.exported.frame(()=>o(null,i))}class F{constructor(e,t,i){this.bounds=te.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const t=Math.pow(2,e.z),i=Math.floor(te.mercatorXfromLng(this.bounds.getWest())*t),r=Math.floor(te.mercatorYfromLat(this.bounds.getNorth())*t),n=Math.ceil(te.mercatorXfromLng(this.bounds.getEast())*t),o=Math.ceil(te.mercatorYfromLat(this.bounds.getSouth())*t);return e.x>=i&&e.x<n&&e.y>=r&&e.y<o}}class N{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const U={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class j{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(t,i){for(let e=0;e<this.attributes.length;e++){const r=i.attributes[this.attributes[e].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,i,r){for(let e=0;e<this.attributes.length;e++){const n=this.attributes[e],o=i.attributes[n.name];void 0!==o&&t.vertexAttribPointer(o,n.components,t[U[n.type]],!1,this.itemSize,n.offset+this.itemSize*(r||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class V{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class G extends V{getDefault(){return te.Color.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class $ extends V{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class q extends V{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class Z extends V{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Y extends V{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class W extends V{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class X extends V{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class H extends V{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class K extends V{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class J extends V{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Q extends V{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class ee extends V{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class ie extends V{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class re extends V{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class ne extends V{getDefault(){return te.Color.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class oe extends V{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class se extends V{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class ae extends V{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class le extends V{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class ce extends V{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class he extends V{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ue extends V{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class pe extends V{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class de extends V{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class fe extends V{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class me extends V{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class _e extends V{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ge extends V{constructor(e){super(e),this.vao=e.extVertexArrayObject}getDefault(){return null}set(e){this.vao&&(e!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(e),this.current=e,this.dirty=!1)}}class ye extends V{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class xe extends V{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class ve extends V{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class be extends V{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class we extends be{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Te extends be{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Ee extends Te{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Ae{constructor(e,t,i,r){this.context=e,this.width=t,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();this.colorAttachment=new we(e,n),r&&(this.depthAttachment=new Te(e,n))}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class Se{constructor(e){this.gl=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new G(this),this.clearDepth=new $(this),this.clearStencil=new q(this),this.colorMask=new Z(this),this.depthMask=new Y(this),this.stencilMask=new W(this),this.stencilFunc=new X(this),this.stencilOp=new H(this),this.stencilTest=new K(this),this.depthRange=new J(this),this.depthTest=new Q(this),this.depthFunc=new ee(this),this.blend=new ie(this),this.blendFunc=new re(this),this.blendColor=new ne(this),this.blendEquation=new oe(this),this.cullFace=new se(this),this.cullFaceSide=new ae(this),this.frontFace=new le(this),this.program=new ce(this),this.activeTexture=new he(this),this.viewport=new ue(this),this.bindFramebuffer=new pe(this),this.bindRenderbuffer=new de(this),this.bindTexture=new fe(this),this.bindVertexBuffer=new me(this),this.bindElementBuffer=new _e(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ge(this),this.pixelStoreUnpack=new ye(this),this.pixelStoreUnpackPremultiplyAlpha=new xe(this),this.pixelStoreUnpackFlipY=new ve(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extTextureHalfFloat=e.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(e.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=e.getExtension("OES_standard_derivatives"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new N(this,e,t)}createVertexBuffer(e,t,i){return new j(this,e,t,i)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i){return new Ae(this,e,t,i)}clear({color:e,depth:t,stencil:i}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){_(e.blendFunction,te.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class Ce extends te.Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=te.extend({type:"raster"},t),te.extend(this,te.pick(t,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new te.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=O(this._options,this.map._requestManager,null,null,(e,t)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new te.ErrorEvent(e)):t&&(te.extend(this,t),t.bounds&&(this.tileBounds=new F(t.bounds,this.minzoom,this.maxzoom)),te.postTurnstileEvent(t.tiles),this.fire(new te.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new te.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return te.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(n,o){const e=te.exported.devicePixelRatio>=2,t=this.map._requestManager.normalizeTileURL(n.tileID.canonical.url(this.tiles,this.scheme),e,this.tileSize);n.request=te.getImage(this.map._requestManager.transformRequest(t,te.ResourceType.Tile),(e,t,i,r)=>(delete n.request,n.aborted?(n.state="unloaded",o(null)):e?(n.state="errored",o(e)):t?(this.map._refreshExpiredTiles&&n.setExpiryData({cacheControl:i,expires:r}),n.setTexture(t,this.map.painter),n.state="loaded",te.cacheEntryPossiblyAdded(this.dispatcher),void o(null)):o(null)))}static loadTileData(e,t,i){e.setTexture(t,i)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}}let Me;function Ie(e,t,i,r,n,o,s,a){const l=[e,i,n,t,r,o,1,1,1],c=[s,a,1],h=te.adjoint([],l),[u,p,d]=te.transformMat3(c,c,te.transpose(h,h));return te.multiply$1(l,[u,0,0,0,p,0,0,0,d],l)}class Be extends te.Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}load(i,e){this._loaded=e||!1,this.fire(new te.Event("dataloading",{dataType:"source"})),this.url=this.options.url,te.getImage(this.map._requestManager.transformRequest(this.url,te.ResourceType.Image),(e,t)=>{if(this._loaded=!0,e)this.fire(new te.ErrorEvent(e));else if(t){const{HTMLImageElement:e}=te.window;this.image=t instanceof e?te.exported.getImageData(t):t,this.width=this.image.width,this.height=this.image.height,i&&(this.coordinates=i),this._finishLoading()}})}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new te.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const t=e.map(te.MercatorCoordinate.fromLngLat);return this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const te of e)t=Math.min(t,te.x),i=Math.min(i,te.y),r=Math.max(r,te.x),n=Math.max(n,te.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new te.CanonicalTileID(s,Math.floor((t+r)/2*a),Math.floor((i+n)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new te.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const te in this.tiles){const e=this.tiles[te];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const i=te.tileTransform(this.tileID,this.map.transform.projection),[t,r,n,o]=this.coordinates.map(e=>{const t=i.projection.project(e[0],e[1]);return te.getTilePoint(i,t)._round()});this.perspectiveTransform=function(e,t,i,r,n,o,s,a,l,c){const h=Ie(0,0,e,0,0,t,e,t),u=Ie(i,r,n,o,s,a,l,c);return te.multiply$1(u,te.adjoint(h,h),u),[u[6]/u[8]*e/te.EXTENT,u[7]/u[8]*t/te.EXTENT]}(this.width,this.height,t.x,t.y,r.x,r.y,o.x,o.y,n.x,n.y);const s=this._boundsArray=new te.StructArrayLayout4i8;s.emplaceBack(t.x,t.y,0,0),s.emplaceBack(r.x,r.y,te.EXTENT,0),s.emplaceBack(o.x,o.y,0,te.EXTENT),s.emplaceBack(n.x,n.y,te.EXTENT,te.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(s,te.boundsAttributes.members),this.boundsSegments=te.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,t=e.gl;this.texture?this.texture.update(this.image):(this.texture=new te.Texture(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._prepareData(e)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const ke={vector:class extends te.Evented{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,te.extend(this,te.pick(t,["url","scheme","tileSize","promoteId"])),this._options=te.extend({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new te.DedupedRequest}load(i){this._loaded=!1,this.fire(new te.Event("dataloading",{dataType:"source"}));const r=this.language||this.map._language,n=this.worldview||this.map._worldview;this._tileJSONRequest=O(this._options,this.map._requestManager,r,n,(e,t)=>{this._tileJSONRequest=null,this._loaded=!0,e?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${r}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new te.ErrorEvent(e))):t&&(te.extend(this,t),t.bounds&&(this.tileBounds=new F(t.bounds,this.minzoom,this.maxzoom)),te.postTurnstileEvent(t.tiles,this.map._requestManager._customAccessToken),this.fire(new te.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new te.Event("data",{dataType:"source",sourceDataType:"content"}))),i&&i(e)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.cancel(),e(),this.load(()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles()})}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}_setLanguage(e){return e===this.language||this.setSourceProperty(()=>{this.language=e}),this}_setWorldview(e){return e===this.worldview?this:this.worldviewOptions&&e&&!this.worldviewOptions[e]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${e}".`),this):(this.setSourceProperty(()=>{this.worldview=e}),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return te.extend({},this._options)}loadTile(i,r){const e=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(e,te.ResourceType.Tile),data:void 0,uid:i.uid,tileID:i.tileID,tileZoom:i.tileZoom,zoom:i.tileID.overscaledZ,tileSize:this.tileSize*i.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:te.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:i.isSymbolTile};if(n.request.collectResourceTiming=this._collectResourceTiming,i.actor&&"expired"!==i.state)"loading"===i.state?i.reloadCallback=r:i.request=i.actor.send("reloadTile",n,o.bind(this));else if(i.actor=this._tileWorkers[e]=this._tileWorkers[e]||this.dispatcher.getActor(),this.dispatcher.ready)i.request=i.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const r=te.loadVectorTile.call({deduped:this._deduped},n,(e,t)=>{e||!t?o.call(this,e):(n.data={cacheControl:t.cacheControl,expires:t.expires,rawData:t.rawData.slice(0)},i.actor&&i.actor.send("loadTile",n,o.bind(this),void 0,!0))},!0);i.request={cancel:r}}function o(e,t){return delete i.request,i.aborted?r(null):e&&404!==e.status?r(e):(t&&t.resourceTiming&&(i.resourceTiming=t.resourceTiming),this.map._refreshExpiredTiles&&t&&i.setExpiryData(t),i.loadVectorData(t,this.map.painter),te.cacheEntryPossiblyAdded(this.dispatcher),r(null),void(i.reloadCallback&&(this.loadTile(i,i.reloadCallback),i.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Ce,"raster-dem":class extends Ce{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=te.extend({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(s,a){const e=this.map._requestManager.normalizeTileURL(s.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function l(e,t){e&&(s.state="errored",a(e)),t&&(s.dem=t,s.dem.onDeserialize(),s.needsHillshadePrepare=!0,s.needsDEMTextureUpload=!0,s.state="loaded",a(null))}s.request=te.getImage(this.map._requestManager.transformRequest(e,te.ResourceType.Tile),function(e,t,i,r){if(delete s.request,s.aborted)s.state="unloaded",a(null);else if(e)s.state="errored",a(e);else if(t){this.map._refreshExpiredTiles&&s.setExpiryData({cacheControl:i,expires:r});const a=te.window.ImageBitmap&&t instanceof te.window.ImageBitmap&&(null==Me&&(Me=te.window.OffscreenCanvas&&new te.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof te.window.createImageBitmap),Me),e=1-(t.width-te.prevPowerOfTwo(t.width))/2;e<1||s.neighboringTiles||(s.neighboringTiles=this._getNeighboringTiles(s.tileID));const n=a?t:te.exported.getImageData(t,e),o={uid:s.uid,coord:s.tileID,source:this.id,rawImageData:n,encoding:this.encoding,padding:e};s.actor&&"expired"!==s.state||(s.actor=this.dispatcher.getActor(),s.actor.send("loadDEMTile",o,l.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(e){const t=e.canonical,i=Math.pow(2,t.z),r=(t.x-1+i)%i,n=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+i)%i,s=t.x+1===i?e.wrap+1:e.wrap,a={};return a[new te.OverscaledTileID(e.overscaledZ,n,t.z,r,t.y).key]={backfilled:!1},a[new te.OverscaledTileID(e.overscaledZ,s,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(a[new te.OverscaledTileID(e.overscaledZ,n,t.z,r,t.y-1).key]={backfilled:!1},a[new te.OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},a[new te.OverscaledTileID(e.overscaledZ,s,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1<i&&(a[new te.OverscaledTileID(e.overscaledZ,n,t.z,r,t.y+1).key]={backfilled:!1},a[new te.OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},a[new te.OverscaledTileID(e.overscaledZ,s,t.z,o,t.y+1).key]={backfilled:!1}),a}unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded"}},geojson:class extends te.Evented{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(r),this._data=t.data,this._options=te.extend({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;const n=te.EXTENT/this.tileSize;this.workerOptions=te.extend({source:this.id,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(void 0!==t.buffer?t.buffer:128)*n,tolerance:(void 0!==t.tolerance?t.tolerance:.375)*n,extent:te.EXTENT,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:void 0!==t.clusterMaxZoom?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:te.EXTENT,radius:(void 0!==t.clusterRadius?t.clusterRadius:50)*n,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id},t),this}getClusterLeaves(e,t,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:e,limit:t,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new te.Event("dataloading",{dataType:"source"})),this._loaded=!1;const e=te.extend({},this.workerOptions),t=this._data;"string"==typeof t?(e.request=this.map._requestManager.transformRequest(te.exported.resolveURL(t),te.ResourceType.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(t),this._pendingLoad=this.actor.send(`${this.type}.loadData`,e,(e,t)=>{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new te.ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&t&&t.resourceTiming&&t.resourceTiming[this.id]&&(e.resourceTiming=t.resourceTiming[this.id]),this.fire(new te.Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(i,r){const n=i.actor?"reloadTile":"loadTile";i.actor=this.actor,i.request=this.actor.send(n,{type:this.type,uid:i.uid,tileID:i.tileID,tileZoom:i.tileZoom,zoom:i.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:te.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(e,t)=>(delete i.request,i.unloadVectorData(),i.aborted?r(null):e?r(e):(i.loadVectorData(t,this.map.painter,"reloadTile"===n),r(null))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return te.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Be{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,te.ResourceType.Source).url);te.getVideo(this.urls,(e,t)=>{this._loaded=!0,e?this.fire(new te.ErrorEvent(e)):t&&(this.video=t,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new te.ErrorEvent(new te.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new te.Texture(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Be,canvas:class extends Be{constructor(e,t,i,r){super(e,t,i,r),t.coordinates?Array.isArray(t.coordinates)&&4===t.coordinates.length&&!t.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new te.ErrorEvent(new te.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new te.ErrorEvent(new te.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new te.ErrorEvent(new te.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"==typeof t.canvas||t.canvas instanceof te.window.HTMLCanvasElement||this.fire(new te.ErrorEvent(new te.ValidationError(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new te.ErrorEvent(new te.ValidationError(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof te.window.HTMLCanvasElement?this.options.canvas:te.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new te.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new te.Texture(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends te.Evented{constructor(e,t,i,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=t,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new te.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new te.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new F(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.coveringTiles=this._coveringTiles.bind(this),te.extend(this,te.pick(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return te.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new te.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new te.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new te.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const{x:e,y:r,z:n}=t.tileID.canonical,o=new te.window.AbortController,s=this._implementation.loadTile({x:e,y:r,z:n},{signal:o.signal});if(!s)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null);s.cancel=()=>o.abort(),t.request=s.then(function(e){return delete t.request,t.aborted?(t.state="unloaded",i(null)):e?function(e){return e instanceof te.window.ImageData||e instanceof te.window.ImageBitmap||e instanceof te.window.HTMLCanvasElement}(e)?(this.loadTileData(t,e),t.state="loaded",void i(null)):(t.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null))}.bind(this)).catch(e=>{20!==e.code&&(t.state="errored",i(e))})}loadTileData(e,t){Ce.loadTileData(e,t,this._map.painter)}unloadTileData(e){Ce.unloadTileData(e,this._map.painter)}prepareTile(e){if(!this._implementation.prepareTile)return null;const{x:t,y:i,z:r}=e.tileID.canonical,n=this._implementation.prepareTile({x:t,y:i,z:r});return n?(this.loadTileData(e,n),e.state="loaded",n):null}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:r})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_update(){this.fire(new te.Event("data",{dataType:"source",sourceDataType:"content"}))}}},ze=function(e,t,i,r){const n=new ke[t.type](e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return te.bindAll(["load","abort","unload","serialize","prepare"],n),n};function Pe(e,t){const i=te.identity([]);return te.scale(i,i,[.5*e.width,.5*-e.height,1]),te.translate(i,i,[1,-1,0]),te.multiply(i,i,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(i)}function Le(r,e,t,i,n,o,s,a=!1){const l=r.tilesIn(i,s,a);l.sort(Re);const c=[];for(const i of l)c.push({wrappedTileID:i.tile.tileID.wrapped().key,queryResults:i.tile.queryRenderedFeatures(e,t,r._state,i,n,o,Pe(r.transform,i.tile.tileID),a)});const h=function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const s=e[i],a=o[i]=o[i]||{},l=t[i]=t[i]||[];for(const e of s)a[e.featureIndex]||(a[e.featureIndex]=!0,l.push(e))}}return t}(c);for(const e in h)h[e].forEach(e=>{const t=e.feature,i=t.layer;i&&"background"!==i.type&&"sky"!==i.type&&(t.source=i.source,i["source-layer"]&&(t.sourceLayer=i["source-layer"]),t.state=void 0!==t.id?r.getFeatureState(i["source-layer"],t.id):{})});return h}function De(t,i){const r=t.getRenderableIds().map(e=>t.getTileByID(e)),n=[],o={};for(let e=0;e<r.length;e++){const s=r[e],a=s.tileID.canonical.key;o[a]||(o[a]=!0,s.querySourceFeatures(n,i))}return n}function Re(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Oe(){return null!=ho.workerClass?new ho.workerClass:new te.window.Worker(ho.workerUrl)}const Fe="mapboxgl_preloaded_worker_pool";class Ne{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Ne.workerCount;)this.workers.push(new Oe);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],0===this.numActive()&&(this.workers.forEach(e=>{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Fe]}numActive(){return Object.keys(this.active).length}}let Ue;function je(){return Ue||(Ue=new Ne),Ue}function Ve(e,t){const i={};for(const te in e)"ref"!==te&&(i[te]=e[te]);return te.refProperties.forEach(e=>{e in t&&(i[e]=t[e])}),i}function Ge(t){t=t.slice();const i=Object.create(null);for(let e=0;e<t.length;e++)i[t[e].id]=t[e];for(let e=0;e<t.length;e++)"ref"in t[e]&&(t[e]=Ve(t[e],i[t[e].ref]));return t}Ne.workerCount=2;const $e={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function qe(e,t,i){i.push({command:$e.addSource,args:[e,t[e]]})}function Ze(e,t,i){t.push({command:$e.removeSource,args:[e]}),i[e]=!0}function Ye(e,t,i,r){Ze(e,i,r),qe(e,t,i)}function We(e,t,i){let r;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!_(e[i][r],t[i][r]))return!1;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!_(e[i][r],t[i][r]))return!1;return!0}function Xe(e,t,i,r,n,o){let s;for(s in t=t||{},e=e||{})e.hasOwnProperty(s)&&(_(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}));for(s in t)t.hasOwnProperty(s)&&!e.hasOwnProperty(s)&&(_(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}))}function He(e){return e.id}function Ke(e,t){return e[t.id]=t,e}class Je{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=te.clamp(e,0,1);let t=1,i=this._distances[t];const r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];const n=t-1,o=this._distances[n],s=i-o,a=s>0?(r-o)/s:0;return this.points[n].mult(1-a).add(this.points[t].mult(a))}}class Qe{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o)}_query(e,t,i,r,n,o){if(i<0||e>this.width||r<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}return o?s.filter(o):s}return this._forEachCell(e,t,i,r,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[h],t=n[h+1],i=n[h+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[n];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const e=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r),u=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let t=e;t<=u;t++)for(let e=h;e<=p;e++)if(s.call(this,i,r,n,o,this.xCellCount*e+t,a,l,c))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,p=h-c;return u*u+p*p<=i*i}}const et=Math.tan(85*Math.PI/180);function tt(e,t,i,r,n,o,s){const a=te.create();if(i)if("globe"===o.name){const e=te.calculateGlobeLabelMatrix(n,t);te.multiply(a,a,e)}else{const e=v([],s);a[0]=e[0],a[1]=e[1],a[4]=e[2],a[5]=e[3],r||te.rotateZ(a,a,n.angle)}else te.multiply(a,n.labelPlaneMatrix,e);return a}function it(e,t,i,r,n,o,s){const a=tt(e,t,i,r,n,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function rt(e,t,i,r,n,o,s){if(i){if("globe"===o.name){const a=tt(e,t,i,r,n,o,s);return te.invert(a,a),te.multiply(a,e,a),a}{const t=te.clone(e),i=te.identity([]);return i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3],te.multiply(t,t,i),r||te.rotateZ(t,t,-n.angle),t}}return n.glCoordMatrix}function nt(e,t,i=0){const r=[e.x,e.y,i,1];i?te.transformMat4$1(r,r,t):gt(r,r,t);const n=r[3];return{point:[r[0]/n,r[1]/n,r[2]/n],signedDistanceFromCamera:n}}function ot(e,t){const i=[e[0],e[1],e[2],1];te.transformMat4$1(i,i,t);const r=i[3];return{point:[i[0]/r,i[1]/r,i[2]/r],signedDistanceFromCamera:r}}function st(e,t){return Math.min(.5+e/t*.5,1.5)}function at(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function lt(i,r,n,e,o,s,a,l,c,h){const u=n.transform,p=e?i.textSizeData:i.iconSizeData,d=te.evaluateSizeForZoom(p,n.transform.zoom),f="globe"===u.projection.name,m=[256/n.width*2+1,256/n.height*2+1],_=e?i.text.dynamicLayoutVertexArray:i.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=e?i.text.globeExtVertexArray:i.icon.globeExtVertexArray);const y=i.lineVertexArray,x=e?i.text.placedSymbolArray:i.icon.placedSymbolArray,v=n.transform.width/n.transform.height;let b=!1;for(let t=0;t<x.length;t++){const f=x.get(t);if(f.writingMode!==te.WritingMode.vertical||b||0!==t&&x.get(t-1).writingMode===te.WritingMode.horizontal||(b=!0),(f.hidden||f.writingMode===te.WritingMode.vertical)&&!b){_t(f.numGlyphs,_);continue}b=!1;const w=new te.pointGeometry(f.tileAnchorX,f.tileAnchorY),T=c?c(w):[0,0,0],E=u.projection.projectTilePoint(w.x,w.y,h.canonical),A=[E.x+T[0],E.y+T[1],E.z+T[2]],S=[...A,1];if(te.transformMat4$1(S,S,r),!at(S,m)){_t(f.numGlyphs,_);continue}const C=st(n.transform.cameraToCenterDistance,S[3]),M=te.evaluateSizeForFeature(p,d,f),I=a?M/C:M*C,B=nt(new te.pointGeometry(A[0],A[1]),o,A[2]);if(B.signedDistanceFromCamera<=0){_t(f.numGlyphs,_);continue}let e={};const k=a?null:c,z=ut(f,I,!1,l,r,o,s,i.glyphOffsetArray,y,_,g,B.point,w,e,v,k,u.projection,h,a);b=z.useVertical,k&&z.needsFlipping&&(e={}),(z.notEnoughRoom||b||z.needsFlipping&&ut(f,I,!0,l,r,o,s,i.glyphOffsetArray,y,_,g,B.point,w,e,v,k,u.projection,h,a).notEnoughRoom)&&_t(f.numGlyphs,_)}e?(i.text.dynamicLayoutVertexBuffer.updateData(_),g&&i.text.globeExtVertexBuffer.updateData(g)):(i.icon.dynamicLayoutVertexBuffer.updateData(_),g&&i.icon.globeExtVertexBuffer.updateData(g))}function ct(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m){const _=a.glyphStartIndex+a.numGlyphs,g=a.lineStartIndex,y=a.lineStartIndex+a.lineLength,x=t.getoffsetX(a.glyphStartIndex),v=t.getoffsetX(_-1),b=ft(e*x,i,r,n,o,s,a.segment,g,y,l,c,h,u,p,!0,d,f,m);if(!b)return null;const w=ft(e*v,i,r,n,o,s,a.segment,g,y,l,c,h,u,p,!0,d,f,m);return w?{first:b,last:w}:null}function ht(e,t,i,r){return e.writingMode===te.WritingMode.horizontal&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:e.writingMode===te.WritingMode.vertical?t.y<i.y?{needsFlipping:!0}:null:0!==e.flipState&&function(e,t,i){const r=(t.x-e.x)*i;return 0===r||Math.abs((t.y-e.y)/r)>et}(t,i,r)?1===e.flipState?{needsFlipping:!0}:null:t.x>i.x?{needsFlipping:!0}:null}function ut(t,i,r,e,n,o,s,a,l,c,h,u,p,d,f,m,_,g,y){const x=i/24,v=t.lineOffsetX*x,b=t.lineOffsetY*x;let w;if(t.numGlyphs>1){const i=t.glyphStartIndex+t.numGlyphs,n=t.lineStartIndex,c=t.lineStartIndex+t.lineLength,h=ct(x,a,v,b,r,u,p,t,l,o,d,m,!1,_,g,y);if(!h)return{notEnoughRoom:!0};const T=ot(h.first.point,s).point,E=ot(h.last.point,s).point,A=new te.pointGeometry(T[0],T[1]),S=new te.pointGeometry(E[0],E[1]);if(e&&!r){const te=ht(t,A,S,f);if(t.flipState=te&&te.needsFlipping?1:2,te)return te}w=[h.first];for(let e=t.glyphStartIndex+1;e<i-1;e++)w.push(ft(x*a.getoffsetX(e),v,b,r,u,p,t.segment,n,c,l,o,d,m,!1,!1,_,g,y));w.push(h.last)}else{if(e&&!r){const i=nt(p,n).point,r=t.lineStartIndex+t.segment+1,e=new te.pointGeometry(l.getx(r),l.gety(r)),o=nt(e,n),s=o.signedDistanceFromCamera>0?o.point:dt(p,e,i,1,n,void 0,_,g.canonical),a=ht(t,new te.pointGeometry(i[0],i[1]),new te.pointGeometry(s[0],s[1]),f);if(t.flipState=a&&a.needsFlipping?1:2,a)return a}const i=ft(x*a.getoffsetX(t.glyphStartIndex),v,b,r,u,p,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,l,o,d,m,!1,!1,_,g,y);if(!i)return{notEnoughRoom:!0};w=[i]}if(h)for(const t of w)te.updateGlobeVertexNormal(h,c.length+0,t.up[0],t.up[1],t.up[2]),te.updateGlobeVertexNormal(h,c.length+1,t.up[0],t.up[1],t.up[2]),te.updateGlobeVertexNormal(h,c.length+2,t.up[0],t.up[1],t.up[2]),te.updateGlobeVertexNormal(h,c.length+3,t.up[0],t.up[1],t.up[2]),te.addDynamicAttributes(c,t.point[0],t.point[1],t.point[2],t.angle);else for(const t of w)te.addDynamicAttributes(c,t.point[0],t.point[1],t.point[2],t.angle);return{}}function pt(e,t,i,r,n){const o=r.projectTilePoint(e.x,e.y,t);if(!n)return nt(o,i,o.z);const s=n(e);return nt(new te.pointGeometry(o.x+s[0],o.y+s[1]),i,o.z+s[2])}function dt(e,t,i,r,n,o,s,a){const l=pt(e.add(e.sub(t)._unit()),a,n,s,o).point,c=te.sub([],i,l);return te.scaleAndAdd([],i,c,r/te.length(c))}function ft(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g){const y=r?e-t:e+t;let x=y>0?1:-1,v=0;r&&(x*=-1,v=Math.PI),x<0&&(v+=Math.PI);let b=x>0?a+s:a+s+1,w=n,T=n,E=0,A=0;const S=Math.abs(y),C=[],M=[];let I=o;const B=()=>{const e=b-x;return 0===E?o:new te.pointGeometry(c.getx(e),c.gety(e))},k=()=>dt(B(),I,T,S-E+1,h,p,m,_.canonical);for(;E+A<=S;){if(b+=x,b<a||b>=l)return null;if(T=w,C.push(w),d&&M.push(I||B()),w=u[b],void 0===w){I=new te.pointGeometry(c.getx(b),c.gety(b));const e=pt(I,_.canonical,h,m,p);w=e.signedDistanceFromCamera>0?u[b]=e.point:k()}else I=null;E+=A,A=te.distance(T,w)}I=I||new te.pointGeometry(c.getx(b),c.gety(b));const z=B();f&&p&&(u[b]=w=void 0===u[b]?w:k(),A=te.distance(T,w));const P=(S-E)/A,L=I.sub(z).mult(P)._add(z),D=te.sub([],w,T),R=te.scaleAndAdd([],T,D,P);let O=[0,0,1],F=D[0],N=D[1];if(g&&(O=m.upVector(_.canonical,L.x,L.y),0!==O[0]||0!==O[1]||1!==O[2])){const e=[1,0,0],t=[0,1,0];e[0]=O[2],e[1]=0,e[2]=-O[0],te.cross(t,O,e),te.normalize(e,e),te.normalize(t,t),F=te.dot(D,e),N=te.dot(D,t)}if(i){const e=te.cross([],O,D);te.normalize(e,e),te.scaleAndAdd(R,R,e,i*x)}const U=v+Math.atan2(N,F);return C.push(R),d&&M.push(L),{point:R,angle:U,path:C,tilePath:M,up:O}}const mt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function _t(t,i){for(let e=0;e<t;e++){const t=i.length;i.resize(t+4),i.float32.set(mt,4*t)}}function gt(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const yt=100;class xt{constructor(e,t,i=new Qe(e.width+200,e.height+200,25),r=new Qe(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+yt,this.screenBottomBoundary=e.height+yt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,p=i.tileID;if(u&&p){const t=e.getProjection().upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),r=e.getProjection().upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=t[0]*u*r,c+=t[1]*u*r,h+=t[2]*u*r}const d=this.projectAndGetPerspectiveRatio(s,[l,c,h],i.tileID,"globe"===e.projection.name||!!u||this.transform.pitch>0,e.getProjection()),f=o*d.perspectiveRatio,m=(i.x1*t+r.x-i.padding)*f+d.point.x,_=(i.y1*t+r.y-i.padding)*f+d.point.y,g=(i.x2*t+r.x+i.padding)*f+d.point.x,y=(i.y2*t+r.y+i.padding)*f+d.point.y,x=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,_,g,y)||!n&&this.grid.hitTest(m,_,g,y,a)||x?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(s,i,a,l,r,n,c,h,u,p,d,f,m,_,e){const g=[],t=this.transform.elevation,y=t?t.getAtTileOffsetFunc(e,this.transform.center.lat,this.transform.worldSize,s.getProjection()):e=>[0,0,0],o=new te.pointGeometry(a.tileAnchorX,a.tileAnchorY),x=s.getProjection().projectTilePoint(a.tileAnchorX,a.tileAnchorY,e.canonical),v=y(o),b=[x.x+v[0],x.y+v[1],x.z+v[2]],w="globe"===s.projection.name,T=this.projectAndGetPerspectiveRatio(c,[b[0],b[1],b[2]],e,w||!!t||this.transform.pitch>0,s.getProjection()),{perspectiveRatio:E}=T,A=(d?n/E:n*E)/te.ONE_EM,S=nt(new te.pointGeometry(b[0],b[1]),h,b[2]).point,C=T.signedDistanceFromCamera>0?ct(A,r,a.lineOffsetX*A,a.lineOffsetY*A,!1,S,o,a,l,h,{},t&&!d?y:null,d&&!!t,s.getProjection(),e,d):null;let M=!1,I=!1,B=!0;if(C&&!T.occluded){const s=.5*m*E+_,a=new te.pointGeometry(-100,-100),l=new te.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),r=new Je,n=C.first,c=C.last;let o=[];for(let e=n.path.length-1;e>=1;e--)o.push(n.path[e]);for(let e=1;e<c.path.length;e++)o.push(c.path[e]);const d=2.5*s;if(u){const te=o.map(t&&!w?(e,t)=>{const i=y(t<n.path.length-1?n.tilePath[n.path.length-1-t]:c.tilePath[t-n.path.length+2]);return e[2]=i[2],ot(e,u)}:e=>ot(e,u));o=te.some(e=>e.signedDistanceFromCamera<=0)?[]:te.map(e=>e.point)}let e=[];if(o.length>0){const s=o.map(e=>new te.pointGeometry(e[0],e[1]));let t=1/0,i=-1/0,r=1/0,n=-1/0;for(let e=0;e<s.length;e++)t=Math.min(t,s[e].x),r=Math.min(r,s[e].y),i=Math.max(i,s[e].x),n=Math.max(n,s[e].y);e=t>=a.x&&i<=l.x&&r>=a.y&&n<=l.y?[s]:i<a.x||t>l.x||n<a.y||r>l.y?[]:te.clipLine([s],a.x,a.y,l.x,l.y)}for(const te of e){r.reset(te,.25*s);let t=0;t=r.length<=.5*s?1:Math.ceil(r.paddedLength/d)+1;for(let e=0;e<t;e++){const l=e/Math.max(t-1,1),n=r.lerp(l),c=n.x+yt,h=n.y+yt;g.push(c,h,s,0);const u=c-s,d=h-s,m=c+s,_=h+s;if(B=B&&this.isOffscreen(u,d,m,_),I=I||this.isInsideGrid(u,d,m,_),!i&&this.grid.hitTestCircle(c,h,s,f)&&(M=!0,!p))return{circles:[],offscreen:!1,collisionDetected:M,occluded:!1}}}}return{circles:!p&&M||!I?[]:g,offscreen:B,collisionDetected:M,occluded:T.occluded}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const t=[];let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const s of e){const e=new te.pointGeometry(s.x+yt,s.y+yt);i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y),t.push(e)}const s=this.grid.query(i,r,n,o).concat(this.ignoredGrid.query(i,r,n,o)),a={},l={};for(const e of s){const i=e.key;if(void 0===a[i.bucketInstanceId]&&(a[i.bucketInstanceId]={}),a[i.bucketInstanceId][i.featureIndex])continue;const r=[new te.pointGeometry(e.x1,e.y1),new te.pointGeometry(e.x2,e.y1),new te.pointGeometry(e.x2,e.y2),new te.pointGeometry(e.x1,e.y2)];te.polygonIntersectsPolygon(t,r)&&(a[i.bucketInstanceId][i.featureIndex]=!0,void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]=[]),l[i.bucketInstanceId].push(i.featureIndex))}return l}insertCollisionBox(e,t,i,r,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(t,e,i,r,n){const o=e?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let e=0;e<t.length;e+=4)o.insertCircle(s,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(e,t,i,r,n){const o=[t[0],t[1],t[2],1];let s=!1;if(t[2]||this.transform.pitch>0){te.transformMat4$1(o,o,e);const r="globe"===n.name;this.fogState&&i&&!r&&(s=function(e,t,i,r,n,o){const s=o.calculateFogTileMatrix(n),a=[t,i,r];return te.transformMat4(a,a,s),S(e,a,o.pitch,o._fov)}(this.fogState,t[0],t[1],t[2],i.toUnwrapped(),this.transform)>.9)}else gt(o,o,e);return{point:new te.pointGeometry((o[0]/o[3]+1)/2*this.transform.width+yt,(-o[1]/o[3]+1)/2*this.transform.height+yt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(n)/o[3]*.5,1.5),signedDistanceFromCamera:o[3],occluded:r&&o[2]>o[3]||s}}isOffscreen(e,t,i,r){return i<yt||e>=this.screenRightBoundary||r<yt||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=te.identity([]);return te.translate(e,e,[-100,-100,0]),e}}function vt(e,t,i){const r=t.createTileMatrix(e,e.worldSize,i.toUnwrapped());return te.multiply(new Float32Array(16),e.projMatrix,r)}function bt(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const r=i.clone();return r.setProjection(t.projection),vt(r,t.getProjection(),e)}function wt(e,t,i){return t.name===i.projection.name?e.projMatrix:vt(i,t,e)}class Tt{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Et{constructor(e,t,i,r,n,o=!1){this.text=new Tt(e?e.text:null,t,i,n),this.icon=new Tt(e?e.icon:null,t,r,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class At{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r}}class St{constructor(){this.invProjMatrix=te.create(),this.viewportMatrix=te.create(),this.circles=[]}}class Ct{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class Mt{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function It(e,t,i,r,n){const{horizontalAlign:o,verticalAlign:s}=te.getAnchorAlignment(e),a=-(o-.5)*t,l=-(s-.5)*i,c=te.evaluateVariableOffset(e,r);return new te.pointGeometry(a+c[0]*n,l+c[1]*n)}function Bt(e,t,i,r,n){const o=new te.pointGeometry(e,t);return i&&o._rotate(r?n:-n),o}class kt{constructor(e,t,i,r,n){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new xt(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Mt(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,t,i,r){const n=i.getBucket(t),o=i.latestFeatureIndex;if(!n||!o||t.id!==n.layerIds[0])return;const s=n.layers[0].layout,a=i.collisionBoxArray,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/te.EXTENT,h=i.tileID.toUnwrapped();this.transform.setProjection(n.projection);const u=(p=i.tileID,d=n.getProjection(),f=this.transform,d.name===this.projection?f.calculateProjMatrix(p.toUnwrapped()):vt(f,d,p));var p,d,f;const m="map"===s.get("text-pitch-alignment"),_="map"===s.get("text-rotation-alignment");t.compileFilter();const g=t.dynamicFilter(),y=t.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),v=it(u,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);let b=null;if(m){const e=rt(u,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);b=te.multiply([],this.transform.labelPlaneMatrix,e)}let w=null;g&&i.latestFeatureIndex&&(w={unwrappedTileID:h,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new Ct(n.bucketInstanceId,o,n.sourceLayerIndex,n.index,i.tileID);const T={bucket:n,layout:s,posMatrix:u,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:w,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:te.evaluateSizeForZoom(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:te.evaluateSizeForZoom(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const te of n.sortKeyRanges){const{sortKey:t,symbolInstanceStart:i,symbolInstanceEnd:r}=te;e.push({sortKey:t,symbolInstanceStart:i,symbolInstanceEnd:r,parameters:T})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:T})}attemptAnchorPlacement(t,e,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_,g){const y=[u.textOffset0,u.textOffset1],x=It(t,i,r,y,n),v=this.collisionIndex.placeCollisionBox(d,n,e,Bt(x.x,x.y,o,s,this.transform.angle),h,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,Bt(x.x,x.y,o,s,this.transform.angle),h,a,l,c.predicate).box.length)&&v.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:y,width:i,height:r,anchor:t,textScale:n,prevAnchor:e},this.markUsedJustification(d,t,u,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,u),this.placedOrientations[u.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(t,w,T,e){const{bucket:E,layout:A,posMatrix:S,textLabelPlaneMatrix:C,labelToScreenMatrix:M,clippingData:I,textPixelRatio:B,holdingForFade:k,collisionBoxArray:i,partiallyEvaluatedTextSize:z,partiallyEvaluatedIconSize:P,collisionGroup:L}=t.parameters,D=A.get("text-optional"),R=A.get("icon-optional"),O=A.get("text-allow-overlap"),F=A.get("icon-allow-overlap"),N="map"===A.get("text-rotation-alignment"),U="map"===A.get("text-pitch-alignment"),j="none"!==A.get("icon-text-fit"),r="viewport-y"===A.get("symbol-z-order");this.transform.setProjection(E.projection);let V=O&&(F||!E.hasIconData()||R),G=F&&(O||!E.hasTextData()||D);!E.collisionArrays&&i&&E.deserializeCollisionBoxes(i),T&&e&&E.updateCollisionDebugBuffers(this.transform.zoom,i);const n=(h,u,i)=>{if(I){const T={zoom:this.transform.zoom,pitch:this.transform.pitch};let e=null;if(I.dynamicFilterNeedsFeature){const te=this.retainedQueryData[E.bucketInstanceId];e=I.featureIndex.loadFeature({featureIndex:h.featureIndex,bucketIndex:te.bucketIndex,sourceLayerIndex:te.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,I.dynamicFilter)(T,e,this.retainedQueryData[E.bucketInstanceId].tileID.canonical,new te.pointGeometry(h.tileAnchorX,h.tileAnchorY),this.transform.calculateDistanceTileData(I.unwrappedTileID)))return this.placements[h.crossTileID]=new At(!1,!1,!1,!0),void(w[h.crossTileID]=!0)}if(w[h.crossTileID])return;if(k)return void(this.placements[h.crossTileID]=new At(!1,!1,!1));let p=!1,e=!1,t=!0,r=!1,n=!1,d=null,o={box:null,offscreen:null,occluded:null},s={box:null,offscreen:null,occluded:null},a=null,l=null,c=null,f=0,m=0,_=0;i.textFeatureIndex?f=i.textFeatureIndex:h.useRuntimeCollisionCircles&&(f=h.featureIndex),i.verticalTextFeatureIndex&&(m=i.verticalTextFeatureIndex);const g=e=>{e.tileID=this.retainedQueryData[E.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[E.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},y=i.textBox;if(y){g(y);const w=e=>{let t=te.WritingMode.horizontal;if(E.allowVerticalPlacement&&!e&&this.prevPlacement){const te=this.prevPlacement.placedOrientations[h.crossTileID];te&&(this.placedOrientations[h.crossTileID]=te,t=te,this.markUsedOrientation(E,t,h))}return t},T=(e,t)=>{if(E.allowVerticalPlacement&&h.numVerticalGlyphVertices>0&&i.verticalTextBox){for(const h of E.writingModes)if(h===te.WritingMode.vertical?(o=t(),s=o):o=e(),o&&o.box&&o.box.length)break}else o=e()};if(A.get("text-variable-anchor")){let c=A.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]){const te=this.prevPlacement.variableOffsets[h.crossTileID];c.indexOf(te.anchor)>0&&(c=c.filter(e=>e!==te.anchor),c.unshift(te.anchor))}const M=(t,e,i)=>{const r=E.getSymbolInstanceTextSize(z,h,this.transform.zoom,u),n=(t.x2-t.x1)*r+2*t.padding,o=(t.y2-t.y1)*r+2*t.padding,s=j&&!F?e:null;s&&g(s);let a={box:[],offscreen:!1,occluded:!1};const l=O?2*c.length:c.length;for(let e=0;e<l;++e){const l=this.attemptAnchorPlacement(c[e%c.length],t,n,o,r,N,U,B,S,L,e>=c.length,h,u,E,i,s,z,P);if(l&&(a=l.placedGlyphBoxes,a&&a.box&&a.box.length)){p=!0,d=l.shift;break}}return a};T(()=>M(y,i.iconBox,te.WritingMode.horizontal),()=>{const e=i.verticalTextBox;return e&&g(e),E.allowVerticalPlacement&&!(o&&o.box&&o.box.length)&&h.numVerticalGlyphVertices>0&&e?M(e,i.verticalIconBox,te.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),o&&(p=o.box,t=o.offscreen,r=o.occluded);const I=w(o&&o.box);if(!p&&this.prevPlacement){const te=this.prevPlacement.variableOffsets[h.crossTileID];te&&(this.variableOffsets[h.crossTileID]=te,this.markUsedJustification(E,te.anchor,h,I))}}else{const A=(e,t)=>{const i=E.getSymbolInstanceTextSize(z,h,this.transform.zoom,u),r=this.collisionIndex.placeCollisionBox(E,i,e,new te.pointGeometry(0,0),O,B,S,L.predicate);return r&&r.box&&r.box.length&&(this.markUsedOrientation(E,t,h),this.placedOrientations[h.crossTileID]=t),r};T(()=>A(y,te.WritingMode.horizontal),()=>{const e=i.verticalTextBox;return E.allowVerticalPlacement&&h.numVerticalGlyphVertices>0&&e?(g(e),A(e,te.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),w(o&&o.box&&o.box.length)}}if(a=o,p=a&&a.box&&a.box.length>0,t=a&&a.offscreen,r=a&&a.occluded,h.useRuntimeCollisionCircles){const w=E.text.placedSymbolArray.get(h.centerJustifiedTextSymbolIndex>=0?h.centerJustifiedTextSymbolIndex:h.verticalPlacedTextSymbolIndex),u=te.evaluateSizeForFeature(E.textSizeData,z,w),I=A.get("text-padding");l=this.collisionIndex.placeCollisionCircles(E,O,w,E.lineVertexArray,E.glyphOffsetArray,u,S,C,M,T,U,L.predicate,h.collisionCircleDiameter*u/te.ONE_EM,I,this.retainedQueryData[E.bucketInstanceId].tileID),p=O||l.circles.length>0&&!l.collisionDetected,t=t&&l.offscreen,r=l.occluded}if(i.iconFeatureIndex&&(_=i.iconFeatureIndex),i.iconBox){const h=e=>{g(e);const t=j&&d?Bt(d.x,d.y,N,U,this.transform.angle):new te.pointGeometry(0,0),i=E.getSymbolInstanceIconSize(P,this.transform.zoom,u);return this.collisionIndex.placeCollisionBox(E,i,e,t,F,B,S,L.predicate)};s&&s.box&&s.box.length&&i.verticalIconBox?(c=h(i.verticalIconBox),e=c.box.length>0):(c=h(i.iconBox),e=c.box.length>0),t=t&&c.offscreen,n=c.occluded}const x=D||0===h.numHorizontalGlyphVertices&&0===h.numVerticalGlyphVertices,v=R||0===h.numIconVertices;if(x||v?v?x||(e=e&&p):p=e&&p:e=p=e&&p,p&&a&&a.box&&this.collisionIndex.insertCollisionBox(a.box,A.get("text-ignore-placement"),E.bucketInstanceId,s&&s.box&&m?m:f,L.ID),e&&c&&this.collisionIndex.insertCollisionBox(c.box,A.get("icon-ignore-placement"),E.bucketInstanceId,_,L.ID),l&&(p&&this.collisionIndex.insertCollisionCircles(l.circles,A.get("text-ignore-placement"),E.bucketInstanceId,f,L.ID),T)){const te=E.bucketInstanceId;let t=this.collisionCircleArrays[te];void 0===t&&(t=this.collisionCircleArrays[te]=new St);for(let e=0;e<l.circles.length;e+=4)t.circles.push(l.circles[e+0]),t.circles.push(l.circles[e+1]),t.circles.push(l.circles[e+2]),t.circles.push(l.collisionDetected?1:0)}const b="globe"!==E.projection.name;V=V&&(b||!r),G=G&&(b||!n),this.placements[h.crossTileID]=new At(p||V,e||G,t||E.justReloaded),w[h.crossTileID]=!0};if(r){const te=E.getSortedSymbolIndexes(this.transform.angle);for(let e=te.length-1;e>=0;--e){const w=te[e];n(E.symbolInstances.get(w),w,E.collisionArrays[w])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)n(E.symbolInstances.get(e),e,E.collisionArrays[e]);if(T&&E.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[E.bucketInstanceId];te.invert(t.invProjMatrix,S),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}E.justReloaded=!1}markUsedJustification(e,t,i,r){let n;n=r===te.WritingMode.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[te.getAnchorJustification(t)];const o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const te of o)te>=0&&(e.text.placedSymbolArray.get(te).crossTileID=n>=0&&te!==n?0:i.crossTileID)}markUsedOrientation(e,t,i){const r=t===te.WritingMode.horizontal||t===te.WritingMode.horizontalOnly?t:0,n=t===te.WritingMode.vertical?t:0,o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const te of o)e.text.placedSymbolArray.get(te).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new Et(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Et(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new Et(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i,r.collisionBoxArray)}}updateBucketOpacities(r,n,t){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const o=r.layers[0].layout,s=!!r.layers[0].dynamicFilter(),a=new Et(null,0,!1,!1,!0),l=o.get("text-allow-overlap"),c=o.get("icon-allow-overlap"),h=o.get("text-variable-anchor"),u="map"===o.get("text-rotation-alignment"),p="map"===o.get("text-pitch-alignment"),d="none"!==o.get("icon-text-fit"),f=new Et(null,0,l&&(c||!r.hasIconData()||o.get("icon-optional")),c&&(l||!r.hasTextData()||o.get("text-optional")),!0);!r.collisionArrays&&t&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(t);const m=(t,i,r)=>{for(let e=0;e<i/4;e++)t.opacityVertexArray.emplaceBack(r)};let _=0;for(let e=0;e<r.symbolInstances.length;e++){const o=r.symbolInstances.get(e),{numHorizontalGlyphVertices:l,numVerticalGlyphVertices:c,crossTileID:g}=o;let i=this.opacities[g];n[g]?i=a:i||(i=f,this.opacities[g]=i),n[g]=!0;const y=l>0||c>0,x=o.numIconVertices>0,v=this.placedOrientations[o.crossTileID],b=v===te.WritingMode.vertical,w=v===te.WritingMode.horizontal||v===te.WritingMode.horizontalOnly;if(!y&&!x||i.isHidden()||_++,y){const te=Ut(i.text);m(r.text,l,b?jt:te),m(r.text,c,w?jt:te);const n=i.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach(e=>{e>=0&&(r.text.placedSymbolArray.get(e).hidden=n||b?1:0)}),o.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=n||w?1:0);const t=this.variableOffsets[o.crossTileID];t&&this.markUsedJustification(r,t.anchor,o,v);const s=this.placedOrientations[o.crossTileID];s&&(this.markUsedJustification(r,"left",o,s),this.markUsedOrientation(r,s,o))}if(x){const te=Ut(i.icon);o.placedIconSymbolIndex>=0&&(m(r.icon,o.numIconVertices,b?jt:te),r.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=i.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(r.icon,o.numVerticalIconVertices,w?jt:te),r.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=i.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const n=r.collisionArrays[e];if(n){let e=new te.pointGeometry(0,0),t=!0;if(n.textBox||n.verticalTextBox){if(h){const te=this.variableOffsets[g];te?(e=It(te.anchor,te.width,te.height,te.textOffset,te.textScale),u&&e._rotate(p?this.transform.angle:-this.transform.angle)):t=!1}s&&(t=!i.clipped),n.textBox&&zt(r.textCollisionBox.collisionVertexArray,i.text.placed,!t||b,e.x,e.y),n.verticalTextBox&&zt(r.textCollisionBox.collisionVertexArray,i.text.placed,!t||w,e.x,e.y)}const a=t&&Boolean(!w&&n.verticalIconBox);n.iconBox&&zt(r.iconCollisionBox.collisionVertexArray,i.icon.placed,a,d?e.x:0,d?e.y:0),n.verticalIconBox&&zt(r.iconCollisionBox.collisionVertexArray,i.icon.placed,!a,d?e.x:0,d?e.y:0)}}}if(r.fullyClipped=0===_,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const te=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=te.invProjMatrix,r.placementViewportMatrix=te.viewportMatrix,r.collisionCircleArray=te.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function zt(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0)}const Pt=Math.pow(2,25),Lt=Math.pow(2,24),Dt=Math.pow(2,17),Rt=Math.pow(2,16),Ot=Math.pow(2,9),Ft=Math.pow(2,8),Nt=Math.pow(2,1);function Ut(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Pt+t*Lt+i*Dt+t*Rt+i*Ot+t*Ft+i*Nt+t}const jt=0;class Vt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class Gt{constructor(e,t,i,r,n,o,s,a){this.placement=new kt(e,n,o,s,a),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){const r=te.exported.now(),n=()=>{const e=te.exported.now()-r;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const te=t[e[this._currentPlacementIndex]],r=this.placement.collisionIndex.transform.zoom;if("symbol"===te.type&&(!te.minzoom||te.minzoom<=r)&&(!te.maxzoom||te.maxzoom>r)){if(this._inProgressLayer||(this._inProgressLayer=new Vt(te)),this._inProgressLayer.continuePlacement(i[te.source],this.placement,this._showCollisionBoxes,te,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const $t=512/te.EXTENT/2;class qt{constructor(t,i,e){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=e;for(let e=0;e<i.length;e++){const r=i.get(e),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(e,t){const i=$t/Math.pow(2,t.canonical.z-this.tileID.canonical.z);return{x:Math.floor((t.canonical.x*te.EXTENT+e.tileAnchorX)*i),y:Math.floor((t.canonical.y*te.EXTENT+e.tileAnchorY)*i)}}findMatches(t,i,r){const n=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z);for(let e=0;e<t.length;e++){const o=t.get(e);if(o.crossTileID)continue;const s=this.indexedSymbolInstances[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,i);for(const t of s)if(Math.abs(t.coord.x-a.x)<=n&&Math.abs(t.coord.y-a.y)<=n&&!r[t.crossTileID]){r[t.crossTileID]=!0,o.crossTileID=t.crossTileID;break}}}}class Zt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Yt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const r=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const s=n[e.scaledTo(Number(i)).key];s&&s.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){const a=t.symbolInstances.get(e);a.crossTileID||(a.crossTileID=i.generate(),r[a.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new qt(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i in t.indexedSymbolInstances)for(const r of t.indexedSymbolInstances[i])delete this.usedCrossTileIDs[e][r.crossTileID]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class Wt{constructor(){this.layerIndexes={},this.crossTileIDs=new Zt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,r){let n=this.layerIndexes[e.id];void 0===n&&(n=this.layerIndexes[e.id]=new Yt);let o=!1;const s={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach(e=>{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Xt=(e,t)=>te.emitValidationErrors(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Ht=te.pick($e,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Kt=te.pick($e,["setCenter","setZoom","setBearing","setPitch"]),Jt={version:8,layers:[],sources:{}},Qt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class ei extends te.Evented{constructor(e,t={}){super(),this.map=e,this.dispatcher=new k(je(),this),this.imageManager=new y,this.imageManager.setEventedParent(this),this.glyphManager=new te.GlyphManager(e._requestManager,t.localFontFamily?te.LocalGlyphMode.all:t.localIdeographFontFamily?te.LocalGlyphMode.ideographs:te.LocalGlyphMode.none,t.localFontFamily||t.localIdeographFontFamily),this.lineAtlas=new te.LineAtlas(256,512),this.crossTileSymbolIndex=new Wt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new te.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",te.getReferrer());const i=this;this._rtlTextPluginCallback=ei.registerForPluginStateChange(e=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},(e,t)=>{if(te.triggerPluginCompletionEvent(e),t&&t.every(e=>e))for(const te in i._sourceCaches){const e=i._sourceCaches[te],t=e.getSource().type;"vector"!==t&&"geojson"!==t||e.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}})}loadURL(e,t={}){this.fire(new te.Event("dataloading",{dataType:"style"}));const i="boolean"==typeof t.validate?t.validate:!te.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,t.accessToken);const r=this.map._requestManager.transformRequest(e,te.ResourceType.Style);this._request=te.getJSON(r,(e,t)=>{this._request=null,e?this.fire(new te.ErrorEvent(e)):t&&this._load(t,i)})}loadJSON(e,t={}){this.fire(new te.Event("dataloading",{dataType:"style"})),this._request=te.exported.frame(()=>{this._request=null,this._load(e,!1!==t.validate)})}loadEmpty(){this.fire(new te.Event("dataloading",{dataType:"style"})),this._load(Jt,!1)}_updateLayerCount(e,t){const i=t?1:-1;e.is3D()&&(this._num3DLayers+=i),"circle"===e.type&&(this._numCircleLayers+=i),"symbol"===e.type&&(this._numSymbolLayers+=i)}_load(e,t){if(t&&Xt(this,te.validateStyle(e)))return;this._loaded=!0,this.stylesheet=te.clone$1(e),this._updateMapProjection();for(const te in e.sources)this.addSource(te,e.sources[te],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const i=Ge(this.stylesheet.layers);this._order=i.map(e=>e.id),this._layers={},this._serializedLayers={};for(let e of i)e=te.createStyleLayer(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize(),this._updateLayerCount(e,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new w(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new te.Event("data",{dataType:"style"})),this.fire(new te.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(e){this._spriteRequest=function(e,t,h){let u,p,d;const i=te.exported.devicePixelRatio>1?"@2x":"";let r=te.getJSON(t.transformRequest(t.normalizeSpriteURL(e,i,".json"),te.ResourceType.SpriteJSON),(e,t)=>{r=null,d||(d=e,u=t,o())}),n=te.getImage(t.transformRequest(t.normalizeSpriteURL(e,i,".png"),te.ResourceType.SpriteImage),(e,t)=>{n=null,d||(d=e,p=t,o())});function o(){if(d)h(d);else if(u&&p){const e=te.exported.getImageData(p),t={};for(const h in u){const{width:p,height:d,x:i,y:r,sdf:n,pixelRatio:o,stretchX:s,stretchY:a,content:l}=u[h],c=new te.RGBAImage({width:p,height:d});te.RGBAImage.copy(e,c,{x:i,y:r},{x:0,y:0},{width:p,height:d}),t[h]={data:c,pixelRatio:o,sdf:n,stretchX:s,stretchY:a,content:l}}h(null,t)}}return{cancel(){r&&(r.cancel(),r=null),n&&(n.cancel(),n=null)}}}(e,this.map._requestManager,(e,t)=>{if(this._spriteRequest=null,e)this.fire(new te.ErrorEvent(e));else if(t)for(const te in t)this.imageManager.addImage(te,t[te]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new te.Event("data",{dataType:"style"}))})}_validateLayer(e){const t=this.getSource(e.source);if(!t)return;const i=e.sourceLayer;i&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(i))&&this.fire(new te.ErrorEvent(new Error(`Source layer "${i}" does not exist on source "${t.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Qt[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const t=this._changed;if(this._changed){const te=Object.keys(this._updatedLayers),t=Object.keys(this._removedLayers);(te.length||t.length)&&this._updateWorkerLayers(te,t);for(const te in this._updatedSources){const e=this._updatedSources[te];"reload"===e?this._reloadSource(te):"clear"===e&&this._clearSource(te)}this._updateTilesForChangedImages();for(const te in this._updatedPaintProps)this._layers[te].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const i={};for(const te in this._sourceCaches){const e=this._sourceCaches[te];i[te]=e.used,e.used=!1}for(const te of this._order){const t=this._layers[te];if(t.recalculate(e,this._availableImages),!t.isHidden(e.zoom)){const te=this._getLayerSourceCache(t);te&&(te.used=!0)}const i=this.map.painter;if(i){const te=t.getProgramIds();if(!te)continue;const r=t.getProgramConfiguration(e.zoom);for(const e of te)i.useProgram(e,r)}}for(const e in i){const t=this._sourceCaches[e];i[e]!==t.used&&t.getSource().fire(new te.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),t&&this.fire(new te.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(e){if(this._checkLoaded(),Xt(this,te.validateStyle(e)))return!1;(e=te.clone$1(e)).layers=Ge(e.layers);const t=function(t,i){if(!t)return[{command:$e.setStyle,args:[i]}];let r=[];try{if(!_(t.version,i.version))return[{command:$e.setStyle,args:[i]}];_(t.center,i.center)||r.push({command:$e.setCenter,args:[i.center]}),_(t.zoom,i.zoom)||r.push({command:$e.setZoom,args:[i.zoom]}),_(t.bearing,i.bearing)||r.push({command:$e.setBearing,args:[i.bearing]}),_(t.pitch,i.pitch)||r.push({command:$e.setPitch,args:[i.pitch]}),_(t.sprite,i.sprite)||r.push({command:$e.setSprite,args:[i.sprite]}),_(t.glyphs,i.glyphs)||r.push({command:$e.setGlyphs,args:[i.glyphs]}),_(t.transition,i.transition)||r.push({command:$e.setTransition,args:[i.transition]}),_(t.light,i.light)||r.push({command:$e.setLight,args:[i.light]}),_(t.fog,i.fog)||r.push({command:$e.setFog,args:[i.fog]}),_(t.projection,i.projection)||r.push({command:$e.setProjection,args:[i.projection]});const n={},o=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||Ze(n,i,r));for(n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n)?_(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&We(e,t,n)?i.push({command:$e.setGeoJSONSourceData,args:[n,t[n].data]}):Ye(n,t,i,r)):qe(n,t,i))}(t.sources,i.sources,o,n);const s=[];t.layers&&t.layers.forEach(e=>{e.source&&n[e.source]?r.push({command:$e.removeLayer,args:[e.id]}):s.push(e)});let e=t.terrain;e&&n[e.source]&&(r.push({command:$e.setTerrain,args:[void 0]}),e=void 0),r=r.concat(o),_(e,i.terrain)||r.push({command:$e.setTerrain,args:[i.terrain]}),function(e,t,i){t=t||[];const r=(e=e||[]).map(He),n=t.map(He),o=e.reduce(Ke,{}),s=t.reduce(Ke,{}),a=r.slice(),l=Object.create(null);let c,h,u,p,d,f,m;for(c=0,h=0;c<r.length;c++)u=r[c],s.hasOwnProperty(u)?h++:(i.push({command:$e.removeLayer,args:[u]}),a.splice(a.indexOf(u,h),1));for(c=0,h=0;c<n.length;c++)u=n[n.length-1-c],a[a.length-1-c]!==u&&(o.hasOwnProperty(u)?(i.push({command:$e.removeLayer,args:[u]}),a.splice(a.lastIndexOf(u,a.length-h),1)):h++,f=a[a.length-c],i.push({command:$e.addLayer,args:[s[u],f]}),a.splice(a.length-c,0,u),l[u]=!0);for(c=0;c<n.length;c++)if(u=n[c],p=o[u],d=s[u],!l[u]&&!_(p,d))if(_(p.source,d.source)&&_(p["source-layer"],d["source-layer"])&&_(p.type,d.type)){for(m in Xe(p.layout,d.layout,i,u,null,$e.setLayoutProperty),Xe(p.paint,d.paint,i,u,null,$e.setPaintProperty),_(p.filter,d.filter)||i.push({command:$e.setFilter,args:[u,d.filter]}),_(p.minzoom,d.minzoom)&&_(p.maxzoom,d.maxzoom)||i.push({command:$e.setLayerZoomRange,args:[u,d.minzoom,d.maxzoom]}),p)p.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&(0===m.indexOf("paint.")?Xe(p[m],d[m],i,u,m.slice(6),$e.setPaintProperty):_(p[m],d[m])||i.push({command:$e.setLayerProperty,args:[u,m,d[m]]}));for(m in d)d.hasOwnProperty(m)&&!p.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&(0===m.indexOf("paint.")?Xe(p[m],d[m],i,u,m.slice(6),$e.setPaintProperty):_(p[m],d[m])||i.push({command:$e.setLayerProperty,args:[u,m,d[m]]}))}else i.push({command:$e.removeLayer,args:[u]}),f=a[a.lastIndexOf(u)+1],i.push({command:$e.addLayer,args:[d,f]})}(s,i.layers,r)}catch(t){console.warn("Unable to compute style diff:",t),r=[{command:$e.setStyle,args:[i]}]}return r}(this.serialize(),e).filter(e=>!(e.command in Kt));if(0===t.length)return!1;const i=t.filter(e=>!(e.command in Ht));if(i.length>0)throw new Error(`Unimplemented: ${i.map(e=>e.command).join(", ")}.`);return t.forEach(e=>{"setTransition"!==e.command&&this[e.command].apply(this,e.args)}),this.stylesheet=e,this._updateMapProjection(),!0}addImage(e,t){return this.getImage(e)?this.fire(new te.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,t),this._afterImageUpdated(e),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new te.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new te.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,e,t={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw new Error("There is already a source with this ID");if(!e.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(e.type)>=0&&this._validate(te.validateSource,`sources.${r}`,e,null,t))return;this.map&&this.map._collectResourceTiming&&(e.collectResourceTiming=!0);const n=ze(r,e,this.dispatcher,this);n.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r),source:n.serialize(),sourceId:r}));const i=e=>{const t=(e?"symbol:":"other:")+r,i=this._sourceCaches[t]=new te.SourceCache(t,n,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[r]=i,i.style=this,i.onAdd(this.map)};i(!1),"vector"!==e.type&&"geojson"!==e.type||i(!0),n.onAdd&&n.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const t=this.getSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new te.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new te.ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const i=this._getSourceCaches(e);for(const e of i)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new te.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],t.setEventedParent(null),t.onRemove&&t.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}addLayer(e,t,i={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new te.ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===e.type){if(Xt(this,te.validateCustomStyleLayer(e)))return;n=te.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=te.clone$1(e),e=te.extend(e,{source:r})),this._validate(te.validateLayer,`layers.${r}`,e,{arrayIndex:-1},i))return;n=te.createStyleLayer(e),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}const o=t?this._order.indexOf(t):this._order.length;if(t&&-1===o)return void this.fire(new te.ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`)));this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const s=this._getLayerSourceCache(n);if(this._removedLayers[r]&&n.source&&s&&"custom"!==n.type){const te=this._removedLayers[r];delete this._removedLayers[r],te.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",s.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;const i=this._order.indexOf(e);this._order.splice(i,1);const r=t?this._order.indexOf(t):this._order.length;t&&-1===r?this.fire(new te.ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const t=this._layers[e];if(!t)return void this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));t.setEventedParent(null),this._updateLayerCount(t,!1);const i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.onRemove&&t.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(e,t,i={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!_(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(te.validateFilter,`layers.${r.id}.filter`,t,{layerType:r.type},i)||(r.filter=te.clone$1(t),this._updateLayer(r)))}else this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const t=this.getLayer(e);return t&&te.clone$1(t.filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?_(n.getLayoutProperty(t),i)||(n.setLayoutProperty(t,i,r),this._updateLayer(n)):this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,t){const i=this.getLayer(e);if(i)return i.getLayoutProperty(t);this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?_(n.getPaintProperty(t),i)||(n.setPaintProperty(t,i,r)&&this._updateLayer(n),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const i=this.getLayer(e);return i&&i.getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.getSource(i);if(!n)return void this.fire(new te.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const o=n.type;if("geojson"===o&&r)return void this.fire(new te.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new te.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new te.ErrorEvent(new Error("The feature id parameter must be provided.")));const s=this._getSourceCaches(i);for(const te of s)te.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();const i=e.source,r=this.getSource(i);if(!r)return void this.fire(new te.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const n=r.type,o="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!o)return void this.fire(new te.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new te.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const s=this._getSourceCaches(i);for(const te of s)te.removeFeatureState(o,e.id,t)}getFeatureState(e){this._checkLoaded();const t=e.source,i=e.sourceLayer,r=this.getSource(t);if(r){if("vector"!==r.type||i)return void 0===e.id&&this.fire(new te.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(t)[0].getFeatureState(i,e.id);this.fire(new te.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new te.ErrorEvent(new Error(`The source '${t}' does not exist in the map's style.`)))}getTransition(){return te.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const te in this._sourceCaches){const t=this._sourceCaches[te].getSource();e[t.id]||(e[t.id]=t.serialize())}return te.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:e,layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r=e=>"fill-extrusion"===this._layers[e].type,n={},o=[];for(let e=this._order.length-1;e>=0;e--){const t=this._order[e];if(r(t)){n[t]=e;for(const r of i){const i=r[t];if(i)for(const r of i)o.push(r)}}}o.sort((e,t)=>t.intersectionZ-e.intersectionZ);const s=[];for(let t=this._order.length-1;t>=0;t--){const e=this._order[t];if(r(e))for(let e=o.length-1;e>=0;e--){const r=o[e].feature;if(n[r.layer.id]<t)break;s.push(r),o.pop()}else for(const r of i){const i=r[e];if(i)for(const r of i)s.push(r.feature)}}return s}queryRenderedFeatures(e,t,i){t&&t.filter&&this._validate(te.validateFilter,"queryRenderedFeatures.filter",t.filter,null,t);const r={};if(t&&t.layers){if(!Array.isArray(t.layers))return this.fire(new te.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of t.layers){const t=this._layers[e];if(!t)return this.fire(new te.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[t.source]=!0}}const n=[];t.availableImages=this._availableImages;const o=t&&t.layers?t.layers.some(e=>{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),s=P.createFromScreenPoints(e,i);for(const te in this._sourceCaches){const e=this._sourceCaches[te].getSource().id;t.layers&&!r[e]||n.push(Le(this._sourceCaches[te],this._layers,this._serializedLayers,s,t,i,o,!!this.map._showQueryGeometry))}return this.placement&&n.push(function(r,n,o,e,t,i,s){const a={},l=i.queryRenderedSymbols(e),c=[];for(const r of Object.keys(l).map(Number))c.push(s[r]);c.sort(Re);for(const o of c){const e=o.featureIndex.lookupSymbolFeatures(l[o.bucketInstanceId],n,o.bucketIndex,o.sourceLayerIndex,t.filter,t.layers,t.availableImages,r);for(const r in e){const n=a[r]=a[r]||[],t=e[r];t.sort((e,t)=>{const i=o.featureSortOrder;if(i){const o=i.indexOf(e.featureIndex);return i.indexOf(t.featureIndex)-o}return t.featureIndex-e.featureIndex});for(const r of t)n.push(r)}}for(const n in a)a[n].forEach(e=>{const t=e.feature,i=o(r[n]).getFeatureState(t.layer["source-layer"],t.id);t.source=t.layer.source,t.layer["source-layer"]&&(t.sourceLayer=t.layer["source-layer"]),t.state=i});return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),s.screenGeometry,t,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,t){t&&t.filter&&this._validate(te.validateFilter,"querySourceFeatures.filter",t.filter,null,t);const i=this._getSourceCaches(e);let r=[];for(const te of i)r=r.concat(De(te,t));return r}addSourceType(e,t,i){return ei.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(ei.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const t in e)if(!_(e[t],i[t])){r=!0;break}if(!r)return;const n=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,t),this.light.updateTransitions(n)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(e,t=1){if(this._checkLoaded(),!e)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===t){if("object"==typeof e.source){const _="terrain-dem-src";this.addSource(_,e.source),e=te.clone$1(e),e=te.extend(e,{source:_})}if(this._validate(te.validateTerrain,"terrain",e))return}if(!this.terrain||this.terrain&&t!==this.terrain.drapeRenderMode)this._createTerrain(e,t);else{const t=this.terrain,i=t.get();for(const _ of Object.keys(te.spec.terrain))!e.hasOwnProperty(_)&&te.spec.terrain[_].default&&(e[_]=te.spec.terrain[_].default);for(const te in e)if(!_(e[te],i[te])){t.set(e),this.stylesheet.terrain=e;const te=this._setTransitionParameters({duration:0});t.updateTransitions(te);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new B(e,this.map.transform);this.stylesheet.fog=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const t=this.fog,i=t.get();0===Object.keys(e).length&&t.set(e);for(const r in e)if(!_(e[r],i[r])){t.set(e),this.stylesheet.fog=e;const _=this._setTransitionParameters({duration:0});t.updateTransitions(_);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:te.exported.now(),transition:te.extend(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter(e=>this.isLayerDraped(this._layers[e])),t=this._order.filter(e=>!this.isLayerDraped(this._layers[e]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const i=this.terrain=new A(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&Xt(this,e.call(te.validateStyle,te.extend({key:t,style:this.serialize(),value:i,styleSpec:te.spec},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),te.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const te in this._layers)this._layers[te].setEventedParent(null);for(const te in this._sourceCaches)this._sourceCaches[te].clearTiles(),this._sourceCaches[te].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(e,t,i,r,n=!1){let o=!1,s=!1;const a={};for(const te of this._order){const t=this._layers[te];if("symbol"!==t.type)continue;if(!a[t.source]){const te=this._getLayerSourceCache(t);if(!te)continue;a[t.source]=te.getRenderableIds(!0).map(e=>te.getTileByID(e)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const i=this.crossTileSymbolIndex.addLayer(t,a[t.source],e.center.lng,e.projection);o=o||i}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n=n||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new te.Event("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(te.exported.now(),e.zoom))&&(this.pauseablePlacement=new Gt(e,this._order,n,t,i,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(te.exported.now()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const te of this._order){const e=this._layers[te];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(te.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,i){this.imageManager.getImages(t.icons,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(e,t,i){return te.makeRequest(t,i)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(e){const t=this._getSourceCaches(e);return 0===t.length?(this.fire(new te.ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):t.every(e=>e.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}ei.getSourceType=function(e){return ke[e]},ei.setSourceType=function(e,t){ke[e]=t},ei.registerForPluginStateChange=te.registerForPluginStateChange;var ti="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",ii="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let ri={},ni={};ri=ci("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),ni=ci("#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const oi=ci("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),si=ti,ai="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var li={background:ci("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:ci("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:ci("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:ci("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ci("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:ci("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:ci("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ci("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ci("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:ci("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:ci("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:ci("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:ci("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ci("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:ci("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:ci("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:ci("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:ci("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:ci("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:ci("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:ci("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxGradient:ci("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxCapture:ci("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector.xyz*height;vec4 globe=u_globe_matrix*vec4(globe_pos,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:ci("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));float horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nfloat horizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function ci(e,t,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,o=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=e.match(n),a=t.match(n),l=ti.match(n);let c=a?a.concat(s):s;i||(ri.staticUniforms&&(c=ri.staticUniforms.concat(c)),ni.staticUniforms&&(c=ni.staticUniforms.concat(c))),c&&(c=c.concat(l));const h={};return{fragmentSource:e=e.replace(r,(e,t,i,r,n)=>(h[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`)),vertexSource:t=t.replace(r,(e,t,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return h[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`}),staticAttributes:o,staticUniforms:c}}class hi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,n,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(c=!0);e.extVertexArrayObject&&this.vao&&this.boundProgram===t&&this.boundLayoutVertexBuffer===i&&!c&&this.boundIndexBuffer===n&&this.boundVertexOffset===o&&this.boundDynamicVertexBuffer===s&&this.boundDynamicVertexBuffer2===a&&this.boundDynamicVertexBuffer3===l?(e.bindVertexArrayOES.set(this.vao),s&&s.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind(),l&&l.bind()):this.freshBind(t,i,r,n,o,s,a,l)}freshBind(e,t,i,r,n,o,s,a){let l;const c=e.numAttributes,h=this.context,u=h.gl;if(h.extVertexArrayObject)this.vao&&this.destroy(),this.vao=h.extVertexArrayObject.createVertexArrayOES(),h.bindVertexArrayOES.set(this.vao),l=0,this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a;else{l=h.currentNumAttributes||0;for(let e=c;e<l;e++)u.disableVertexAttribArray(e)}t.enableAttributes(u,e);for(const t of i)t.enableAttributes(u,e);o&&o.enableAttributes(u,e),s&&s.enableAttributes(u,e),a&&a.enableAttributes(u,e),t.bind(),t.setVertexAttribPointers(u,e,n);for(const t of i)t.bind(),t.setVertexAttribPointers(u,e,n);o&&(o.bind(),o.setVertexAttribPointers(u,e,n)),r&&r.bind(),s&&(s.bind(),s.setVertexAttribPointers(u,e,n)),a&&(a.bind(),a.setVertexAttribPointers(u,e,n)),h.currentNumAttributes=c}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function ui(e,t){const i=Math.pow(2,t.canonical.z),r=t.canonical.y;return[new te.MercatorCoordinate(0,r/i).toLngLat().lat,new te.MercatorCoordinate(0,(r+1)/i).toLngLat().lat]}function pi(e,t,i,r,n,o,s){const a=e.context,l=a.gl,c=i.fbo;if(!c)return;e.prepareDrawTile();const h=e.useProgram("hillshade");a.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get());const u=((e,t,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:ui(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:n,u_highlight:o,u_accent:s}})(e,i,r,e.terrain?t.projMatrix:null);e.prepareDrawProgram(a,h,t.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=e.getTileBoundsBuffers(i);h.draw(a,l.TRIANGLES,n,o,s,te.CullFaceMode.disabled,u,r.id,p,d,f)}function di(e,t,i){if(!t.needsDEMTextureUpload)return;const r=e.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(i.stride);const o=i.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new te.Texture(r,o,n.RGBA,{premultiply:!1}),t.needsDEMTextureUpload=!1}function fi(e,t,i,r,n,o){const s=e.context,a=s.gl;if(!t.dem)return;const l=t.dem;if(s.activeTexture.set(a.TEXTURE1),di(e,t,l),!t.demTexture)return;t.demTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE);const c=l.dim;s.activeTexture.set(a.TEXTURE0);let h=t.fbo;if(!h){const e=new te.Texture(s,{width:c,height:c,data:null},a.RGBA);e.bind(a.LINEAR,a.CLAMP_TO_EDGE),h=t.fbo=s.createFramebuffer(c,c,!0),h.colorAttachment.set(e.texture)}s.bindFramebuffer.set(h.framebuffer),s.viewport.set([0,0,c,c]);const{tileBoundsBuffer:u,tileBoundsIndexBuffer:p,tileBoundsSegments:d}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(s,a.TRIANGLES,r,n,o,te.CullFaceMode.disabled,((e,t)=>{const i=t.stride,r=te.create();return te.ortho(r,0,te.EXTENT,-te.EXTENT,0,0,1),te.translate(r,r,[0,-te.EXTENT,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.unpackVector}})(t.tileID,l),i.id,u,p,d),t.needsHillshadePrepare=!1}const mi=(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_image0:new te.Uniform1i(e,t.u_image0),u_skirt_height:new te.Uniform1f(e,t.u_skirt_height)}),_i=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),gi=(e,t,i,r,n,o,s,a,l,c,h,u,p,d)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function yi(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const xi=new class{constructor(){this.operations={}}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},vi={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bi(e,t){const i=1<<e.z;return!t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}const wi=e=>({u_matrix:e});function Ti(e,t,i,r,n){if(n>0){const o=te.exported.now(),s=(o-e.timeAdded)/n,a=t?(o-t.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),h=!t||Math.abs(t.tileID.overscaledZ-c)>Math.abs(e.tileID.overscaledZ-c),u=h&&e.refreshedUponExpiration?1:te.clamp(h?s:1-a,0,1);return e.refreshedUponExpiration&&s>=1&&(e.refreshedUponExpiration=!1),t?{opacity:1,mix:1-u}:{opacity:u,mix:0}}return{opacity:1,mix:0}}class Ei extends te.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new k(je(),null),r=ze("mock-dem",t,i,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Ai extends te.SourceCache{constructor(e){const t=ze("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new k(je(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(i,e,t){if(i.freezeTileCoverage)return;this.transform=i;const r=i.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((e,t)=>{if(e[t.key]="",!this._tiles[t.key]){const e=new te.Tile(t,this._source.tileSize*t.overscaleFactor(),i.tileZoom);e.state="loaded",this._tiles[t.key]=e}return e},{});for(const te in this._tiles)te in r||(this.freeFBO(te),this._tiles[te].unloadVectorData(),delete this._tiles[te])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Si extends te.OverscaledTileID{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class Ci extends te.Elevation{constructor(e,t){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(e){const i=new te.StructArrayLayout4i8,r=new te.StructArrayLayout3ui6,n=131;i.reserve(17161),r.reserve(33800);const o=te.EXTENT/128,s=te.EXTENT+o/2,a=s+o;for(let t=-o;t<a;t+=o)for(let e=-o;e<a;e+=o){const n=e<0||e>s||t<0||t>s?24575:0,o=te.clamp(Math.round(e),0,te.EXTENT),a=te.clamp(Math.round(t),0,te.EXTENT);i.emplaceBack(o+n,a,o,a)}const l=(e,t)=>{const i=t*n+e;r.emplaceBack(i+1,i,i+n),r.emplaceBack(i+n,i+n+1,i+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)l(e,t);return[0,129].forEach(t=>{for(let e=0;e<130;e++)l(e,t),l(t,e)}),[i,r,32768]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(i,te.boundsAttributes.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=te.SegmentVector.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=te.SegmentVector.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ai(t.map),this.orthoMatrix=te.create(),te.ortho(this.orthoMatrix,0,te.EXTENT,0,te.EXTENT,0,1);const s=o.gl;this._overlapStencilMode=new te.StencilMode({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Ei(t.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(e,t,i){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const r=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const n=()=>{this.sourceCache.used&&te.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,n(),this._initializing=!0),n(),t.updateElevation(!i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&te.warnOnce(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(te.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const t=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t});!function(e,t){const i=t.transform.pointCoordinate(t.transform.getCameraPoint()),o=new te.pointGeometry(i.x,i.y);e.sort((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const i=new te.pointGeometry(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),r=new te.pointGeometry(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),n=o.mult(1<<e.canonical.z);return n.x-=.5,n.y-=.5,n.distSqr(i)-n.distSqr(r)})}(t,this.painter),this._previousZoom=r.zoom;const n=this.proxyToSource||{};this.proxyToSource={},t.forEach(e=>{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const o=this._style._sourceCaches;for(const te in o){const i=o[te];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[te],n),i.usedForTerrain)continue;const r=e[te];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=t.map(e=>new Si(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(t),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1,this._updateTimestamp=te.exported.now();const s={};this._visibleDemTiles=[];for(const te of this.proxyCoords){const e=this.terrainTileForTile[te.key];if(!e)continue;const i=e.tileID.key;i in s||(this._visibleDemTiles.push(e),s[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)})}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),di(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,t=e.gl;if(!this._emptyDepthBufferTexture){const i=new te.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new te.Texture(e,i,t.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let r=0;const e=this._visibleDemTiles.reduce((e,t)=>{if(!t.dem)return e;const i=t.dem.tree.minimums[0];return i>0&&r++,e+i},0);return r?e/r:0}_updateEmptyDEMTexture(){const e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const i=this._getLoadedAreaMinimum(),r=new te.RGBAImage({width:1,height:1},new Uint8Array(te.DEMData.pack(i,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new te.Texture(e,r,t.RGBA,{premultiply:!1}),n}setupElevationDraw(e,t,i){const r=this.painter.context,n=r.gl,o=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:te.DEMData.getUnpackVector(s),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var s;o.u_dem_size=this.sourceCache.getSource().tileSize,o.u_exaggeration=this.exaggeration();const a=this.painter.transform,l=a.projection,c=e.tileID.canonical;o.u_tile_tl_up=l.upVector(c,0,0),o.u_tile_tr_up=l.upVector(c,te.EXTENT,0),o.u_tile_br_up=l.upVector(c,te.EXTENT,te.EXTENT),o.u_tile_bl_up=l.upVector(c,0,te.EXTENT),o.u_tile_up_scale=i&&i.useDenormalizedUpVectorScale?te.GLOBE_METERS_TO_ECEF:l.upVectorScale(c,a.center.lat,a.worldSize).metersToTile;let h=null,u=null,p=1;if(i&&i.morphing&&this._useVertexMorphing){const te=i.morphing.srcDemTile,t=i.morphing.dstDemTile;p=i.morphing.phase,te&&t&&(this._prepareDemTileUniforms(e,te,o,"_prev")&&(u=te),this._prepareDemTileUniforms(e,t,o)&&(h=t))}if(u&&h?(r.activeTexture.set(n.TEXTURE2),h.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),r.activeTexture.set(n.TEXTURE4),u.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),o.u_dem_lerp=p):(h=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(n.TEXTURE2),(this._prepareDemTileUniforms(e,h,o)?h.demTexture:this.emptyDEMTexture).bind(n.NEAREST,n.CLAMP_TO_EDGE)),r.activeTexture.set(n.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),this._depthFBO&&(o.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),o.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&h){const e=(1<<h.tileID.canonical.z)*te.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;o.u_meter_to_dem=e}i&&i.labelPlaneMatrixInv&&(o.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),t.setTerrainUniformValues(r,o)}renderToBackBuffer(e){const t=this.painter,i=this.painter.context;0!==e.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),t.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(d,f,m,_,g){if("globe"===d.transform.projection.name)!function(f,m,_,g,y){const x=f.context,v=x.gl;let b,w;const r=f.options.showTerrainWireframe?2:0,T=f.transform,n=te.globeUseCustomAntiAliasing(f,x,T),E=(e,t)=>{if(w===e)return;const i=[vi[e],"PROJECTION_GLOBE_VIEW"];n&&i.push("CUSTOM_ANTIALIASING"),t&&i.push(vi[r]),b=f.useProgram("globeRaster",null,i),w=e},A=f.colorModeForRenderPass(),S=new te.DepthMode(v.LEQUAL,te.DepthMode.ReadWrite,f.depthRangeFor3D);xi.update(y);const C=te.calculateGlobeMercatorMatrix(T),M=[te.mercatorXfromLng(T.center.lng),te.mercatorYfromLat(T.center.lat)],I=f.globeSharedBuffers,B=[T.width*te.exported.devicePixelRatio,T.height*te.exported.devicePixelRatio];if((r?[!1,!0]:[!1]).forEach(e=>{w=-1;const t=e?v.LINES:v.TRIANGLES;for(const w of g){const g=_.getTile(w),i=te.StencilMode.disabled,r=m.prevTerrainTileForTile[w.key],n=m.terrainTileForTile[w.key];yi(r,n)&&xi.newMorphing(w.key,r,n,y,250),x.activeTexture.set(v.TEXTURE0),g.texture.bind(v.LINEAR,v.CLAMP_TO_EDGE);const o=xi.getMorphValuesForProxy(w.key),s=o?1:0,a={useDenormalizedUpVectorScale:!0};o&&te.extend$1(a,{morphing:{srcDemTile:o.from,dstDemTile:o.to,phase:te.easeCubicInOut(o.phase)}});const l=Float32Array.from(T.globeMatrix),c=te.globeTileLatLngCorners(w.canonical),h=te.getLatitudinalLod((c[0][0]+c[1][0])/2),u=te.getGridMatrix(w.canonical,c,h),p=te.globeNormalizeECEF(te.globeTileBounds(w.canonical)),d=gi(T.projMatrix,l,C,p,te.globeToMercatorTransition(T.zoom),M,T.frustumCorners.TL,T.frustumCorners.TR,T.frustumCorners.BR,T.frustumCorners.BL,T.globeCenterInViewSpace,T.globeRadius,B,u);if(E(s,e),m.setupElevationDraw(g,b,a),f.prepareDrawProgram(x,b,w.toUnwrapped()),I){const[m,_,g]=e?I.getWirefameBuffers(f.context,h):I.getGridBuffers(h);b.draw(x,t,S,i,A,te.CullFaceMode.backCCW,d,"globe_raster",m,_,g)}}}),I){const y=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];n&&y.push("CUSTOM_ANTIALIASING"),b=f.useProgram("globeRaster",null,y);for(const y of g){const{x:g,y:w,z:r}=y.canonical,n=0===w,E=w===(1<<r)-1,[C,e,o,s]=I.getPoleBuffers(r);if(s&&(n||E)){const w=_.getTile(y);x.activeTexture.set(v.TEXTURE0),w.texture.bind(v.LINEAR,v.CLAMP_TO_EDGE);let i=te.globePoleMatrixForTile(r,g,T);const a=te.globeNormalizeECEF(te.globeTileBounds(y.canonical)),t=(e,t)=>e.draw(x,v.TRIANGLES,S,te.StencilMode.disabled,A,te.CullFaceMode.disabled,gi(T.projMatrix,i,i,a,0,M,T.frustumCorners.TL,T.frustumCorners.TR,T.frustumCorners.BR,T.frustumCorners.BL,T.globeCenterInViewSpace,T.globeRadius,B),"globe_pole_raster",t,o,s);m.setupElevationDraw(w,b,{}),f.prepareDrawProgram(x,b,y.toUnwrapped()),n&&t(b,C),E&&(i=te.scale(te.create(),i,[1,-1,1]),t(b,e))}}}}(d,f,m,_,g);else{const y=d.context,x=y.gl;let u,p;const r=d.options.showTerrainWireframe?2:0,v=(e,t)=>{if(p===e)return;const i=[vi[e]];t&&i.push(vi[r]),u=d.useProgram("terrainRaster",null,i),p=e},b=d.colorModeForRenderPass(),w=new te.DepthMode(x.LEQUAL,te.DepthMode.ReadWrite,d.depthRangeFor3D);xi.update(g);const T=d.transform,E=6*Math.pow(1.5,22-T.zoom)*f.exaggeration();(r?[!1,!0]:[!1]).forEach(t=>{p=-1;const i=t?x.LINES:x.TRIANGLES,[r,n]=t?f.getWirefameBuffer():[f.gridIndexBuffer,f.gridSegments];for(const p of _){const _=m.getTile(p),o=te.StencilMode.disabled,s=f.prevTerrainTileForTile[p.key],a=f.terrainTileForTile[p.key];yi(s,a)&&xi.newMorphing(p.key,s,a,g,250),y.activeTexture.set(x.TEXTURE0),_.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE,x.LINEAR_MIPMAP_NEAREST);const l=xi.getMorphValuesForProxy(p.key),c=l?1:0;let e;l&&(e={morphing:{srcDemTile:l.from,dstDemTile:l.to,phase:te.easeCubicInOut(l.phase)}});const h=_i(p.projMatrix,bi(p.canonical,T.renderWorldCopies)?E/10:E);v(c,t),f.setupElevationDraw(_,u,e),d.prepareDrawProgram(y,u,p.toUnwrapped()),u.draw(y,i,w,o,b,te.CullFaceMode.backCCW,h,"terrain_raster",f.gridBuffer,r,n)}})}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(i){if(0===this._drapedRenderBatches.length)return i+1;this.renderingToTexture=!0;const r=this.painter,n=this.painter.context,o=this.proxySourceCache,s=this.proxiedCoords[o.id],a=this._drapedRenderBatches.shift(),e=[],l=r.style.order;let c=0;for(const h of s){const s=o.getTileByID(h.proxyTileKey),u=o.proxyCachedFBO[h.key]?o.proxyCachedFBO[h.key][i]:void 0,p=void 0!==u?o.renderCache[u]:this.pool[c++],d=void 0!==u;if(s.texture=p.tex,d&&!p.dirty){e.push(s.tileID);continue}let t;n.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(n.clear({color:te.Color.transparent,stencil:0}),p.dirty=!1);for(let e=a.start;e<=a.end;++e){const i=r.style._layers[l[e]];if(i.isHidden(r.transform.zoom))continue;const o=r.style._getLayerSourceCache(i),s=o?this.proxyToSource[h.key][o.id]:[h];if(!s)continue;const a=s;n.viewport.set([0,0,p.fb.width,p.fb.height]),t!==(o?o.id:null)&&(this._setupStencil(p,s,i,o),t=o?o.id:null),r.renderLayer(r,o,i,a)}this.renderedToTile?(p.dirty=!0,e.push(s.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(e))}return this.renderToBackBuffer(e),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,r.width,r.height]),a.end+1}postRender(){}renderCacheEfficiency(t){const i=t.order.length;if(0===i)return{efficiency:100};let r,n=0,o=0,s=!1;for(let e=0;e<i;++e){const i=t._layers[t.order[e]];this._style.isLayerDraped(i)?(s&&++n,++o):s||(s=!0,r=i.id)}return 0===o?{efficiency:100}:{efficiency:100*(1-n/o),firstUndrapedLayer:r}}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(e=>{t=Math.min(t,e.dem.tree.minimums[0])}),0===t?t:(t-30)*this._exaggeration}raycast(c,h,u){if(!this._visibleDemTiles)return null;const e=this._visibleDemTiles.filter(e=>e.dem).map(e=>{const t=e.tileID,i=Math.pow(2,t.overscaledZ),{x:r,y:n}=t.canonical,o=r/i,s=(r+1)/i,a=n/i,l=(n+1)/i;return{minx:o,miny:a,maxx:s,maxy:l,t:e.dem.tree.raycastRoot(o,a,s,l,c,h,u),tile:e}});e.sort((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const t of e){if(null==t.t)return null;const e=t.tile.dem.tree.raycast(t.minx,t.miny,t.maxx,t.maxy,c,h,u);if(null!=e)return e}return null}_createFBO(){const e=this.painter.context,t=e.gl,i=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new te.Texture(e,{width:i[0],height:i[1],data:null},t.RGBA);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const n=e.createFramebuffer(i[0],i[1],!1);return n.colorAttachment.set(r.texture),n.depthAttachment=new Ee(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e].hasTransition())return!0;return this._style.order.some(e=>{const t=this._style._layers[e],i=t.isHidden(this.painter.transform.zoom),r=t.getCrossfadeParameters(),n=!!r&&1!==r.t,o=t.hasTransition();return"custom"!==t.type&&!i&&(n||o)})}_clearRasterFadeFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof Ce){t=!0;break}if(t)for(let e=0;e<this._style.order.length;++e){const i=this._style._layers[this._style.order[e]],r=i.isHidden(this.painter.transform.zoom),n=this._style._getLayerSourceCache(i);if("raster"!==i.type||r||!n)continue;const o=i.paint.get("raster-fade-duration");for(const t of this.proxyCoords){const s=this.proxyToSource[t.key][n.id];if(s)for(const t of s){const a=Ti(n.getTile(t),n.findLoadedParent(t,0),n,this.painter.transform,o);(1!==a.opacity||0!==a.mix)&&this._clearRenderCacheForTile(n.id,t)}}}}_setupDrapedRenderBatches(){const e=this._style.order,t=e.length;if(0===t)return;const i=[];let r,n=0,o=this._style._layers[e[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<t;)o=this._style._layers[e[n]];for(;n<t;++n){const t=this._style._layers[e[n]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===r&&(r=n):void 0!==r&&(i.push({start:r,end:n-1}),r=void 0))}void 0!==r&&i.push({start:r,end:n-1}),this._drapedRenderBatches=i}_setupRenderCache(i){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const i=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let e=0;e<i.length;++e){const n=Object.values(i[e]);t.renderCachePool.push(...n)}}return}this._clearRasterFadeFromRenderCache();const r=this.proxyCoords,n=this._tilesDirty;for(let e=r.length-1;e>=0;e--){const s=r[e];if(t.getTileByID(s.key),void 0!==t.proxyCachedFBO[s.key]){const r=i[s.key],o=this.proxyToSource[s.key];let e=0;for(const i in o){const t=o[i],a=r[i];if(!a||a.length!==t.length||t.some((e,t)=>e!==a[t]||n[i]&&n[i].hasOwnProperty(e.key))){e=-1;break}++e}for(const i in t.proxyCachedFBO[s.key])t.renderCache[t.proxyCachedFBO[s.key][i]].dirty=e<0||e!==Object.values(r).length}}const o=[...this._drapedRenderBatches];o.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const i of o)for(const n of r){if(t.proxyCachedFBO[n.key])continue;let e=t.renderCachePool.pop();void 0===e&&t.renderCache.length<50&&(e=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==e&&(t.proxyCachedFBO[n.key]={},t.proxyCachedFBO[n.key][i.start]=e,t.renderCache[e].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):te.StencilMode.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(te.ColorMode.disabled),r.setDepthMode(te.DepthMode.disabled);const o=i.useProgram("clippingMask");for(const s of e){const e=i._tileClippingMaskIDs[s.key]=--t;o.draw(r,n.TRIANGLES,te.DepthMode.disabled,new te.StencilMode({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),te.ColorMode.disabled,te.CullFaceMode.disabled,wi(s.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const i=[e.x,e.y,1,1];te.transformMat4$1(i,i,t.pixelMatrixInverse),te.scale$1(i,i,1/i[3]),i[0]/=t.worldSize,i[1]/=t.worldSize;const r=t._camera.position,n=te.mercatorZfromAltitude(1,t.center.lat),o=[r[0],r[1],r[2]/n,0],s=te.subtract([],i.slice(0,3),o);te.normalize(s,s);const a=this.raycast(o,s,this._exaggeration);return null!==a&&a?(te.scaleAndAdd(o,o,s,a),o[3]=o[2],o[2]*=n,o):null}drawDepth(){const e=this.painter,t=e.context,i=this.proxySourceCache,r=Math.ceil(e.width),n=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===n||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=t.gl,i=t.createFramebuffer(r,n,!0);t.activeTexture.set(e.TEXTURE0);const o=new te.Texture(t,{width:r,height:n,data:null},e.RGBA);o.bind(e.NEAREST,e.CLAMP_TO_EDGE),i.colorAttachment.set(o.texture);const s=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,r,n);i.depthAttachment.set(s),this._depthFBO=i,this._depthTexture=o}t.bindFramebuffer.set(this._depthFBO.framebuffer),t.viewport.set([0,0,r,n]),function(e,t,i,r){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const s=e.useProgram("terrainDepth"),a=new te.DepthMode(o.LESS,te.DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of r){const r=i.getTile(e),l=_i(e.projMatrix,0);t.setupElevationDraw(r,s),s.draw(n,o.TRIANGLES,a,te.StencilMode.disabled,te.ColorMode.unblended,te.CullFaceMode.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,i,r){if(t.getSource()instanceof Be)return this._setupProxiedCoordsForImageSource(t,i,r);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;e<o.length;e++){const s=o[e],a=this._findTileCoveringTileID(s,t);if(a){const i=this._createProxiedId(s,a,r[s.key]&&r[s.key][t.id]);n.push(i),this.proxyToSource[s.key][t.id]=[i]}}let s=!1;for(let e=0;e<i.length;e++){const l=t.getTile(i[e]);if(!l||!l.hasData())continue;const c=this._findTileCoveringTileID(l.tileID,this.proxySourceCache);if(c&&c.tileID.canonical.z!==l.tileID.canonical.z){const i=this.proxyToSource[c.tileID.key][t.id],o=this._createProxiedId(c.tileID,l,r[c.tileID.key]&&r[c.tileID.key][t.id]);i?i.splice(i.length-1,0,o):this.proxyToSource[c.tileID.key][t.id]=[o],n.push(o),s=!0}}this._sourceTilesOverlap[t.id]=s}_setupProxiedCoordsForImageSource(t,i,r){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=new te.pointGeometry(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(te.MercatorCoordinate.fromLngLat).reduce((e,t)=>(e.min.x=Math.min(e.min.x,t.x-a.x),e.min.y=Math.min(e.min.y,t.y-a.y),e.max.x=Math.max(e.max.x,t.x-a.x),e.max.y=Math.max(e.max.y,t.y-a.y),e),{min:new te.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new te.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,t)=>{const i=e.wrap+e.canonical.x/(1<<e.canonical.z),r=e.canonical.y/(1<<e.canonical.z),n=te.EXTENT/(1<<e.canonical.z),o=t.wrap+t.canonical.x/(1<<t.canonical.z),s=t.canonical.y/(1<<t.canonical.z);return i+n<o+l.min.x||i>o+l.max.x||r+n<s+l.min.y||r>s+l.max.y};for(let e=0;e<o.length;e++){const s=o[e];for(let e=0;e<i.length;e++){const o=t.getTile(i[e]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,r[s.key]&&r[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],n.push(a)}}}_createProxiedId(r,n,o){let s=this.orthoMatrix;if(o){const te=o.find(e=>e.key===n.tileID.key);if(te)return te}if(n.tileID.key!==r.key){const o=r.canonical.z-n.tileID.canonical.z;let e,t,i;s=te.create();const a=n.tileID.wrap-r.wrap<<r.overscaledZ;o>0?(e=te.EXTENT>>o,t=e*((n.tileID.canonical.x<<o)-r.canonical.x+a),i=e*((n.tileID.canonical.y<<o)-r.canonical.y)):(e=te.EXTENT<<-o,t=te.EXTENT*(n.tileID.canonical.x-(r.canonical.x+a<<-o)),i=te.EXTENT*(n.tileID.canonical.y-(r.canonical.y<<-o))),te.ortho(s,0,e,0,e,0,1),te.translate(s,s,[t,i,0])}return new Si(n.tileID,r.key,s)}_findTileCoveringTileID(e,t){let i=t.getTile(e);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[t.id],n=r[e.key];if(i=n?t.getTileByID(n):null,i&&i.hasData()||null===n)return i;let o=i?i.tileID:e,s=o.overscaledZ;const a=t.getSource().minzoom,l=[];if(!n){const r=t.getSource().maxzoom;if(e.canonical.z>=r){const i=e.canonical.z-r;t.getSource().reparseOverscaled?(s=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new te.OverscaledTileID(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i)):0!==i&&(s=r,o=new te.OverscaledTileID(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i))}o.key!==e.key&&(l.push(o.key),i=t.getTile(o))}const c=t=>{l.forEach(e=>{r[e]=t}),l.length=0};for(s-=1;s>=a&&(!i||!i.hasData());s--){i&&c(i.tileID.key);const te=o.calculateScaledKey(s);if(i=t.getTileByID(te),i&&i.hasData())break;const e=r[te];if(null===e)break;void 0===e?l.push(te):i=t.getTileByID(e)}return c(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let i=0;const r=new te.StructArrayLayout2ui4,n=131;for(let t=1;t<129;t++){for(let e=1;e<129;e++)i=t*n+e,r.emplaceBack(i,i+1),r.emplaceBack(i,i+n),r.emplaceBack(i+1,i+n),128===t&&r.emplaceBack(i+n,i+n+1);r.emplaceBack(i+1,i+1+n)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=te.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function Mi(t){const i=[];for(let e=0;e<t.length;e++){if(null===t[e])continue;const r=t[e].split(" ");i.push(r.pop())}return i}class Ii{static cacheKey(e,t,i){let r=`${e}${i?i.cacheKey:""}`;for(const e of t)r+=`/${e}`;return r}constructor(t,e,i,r,n,o){const s=t.gl;this.program=s.createProgram();const a=Mi(i.staticAttributes),l=r?r.getBinderAttributes():[],c=a.concat(l),h=i.staticUniforms?Mi(i.staticUniforms):[],u=r?r.getBinderUniforms():[],p=h.concat(u),d=[];for(const te of p)d.indexOf(te)<0&&d.push(te);let f=r?r.defines():[];f=f.concat(o.map(e=>`#define ${e}`));const m=f.concat(t.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(ai):ai,ai,si,oi.fragmentSource,ni.fragmentSource,i.fragmentSource).join("\n"),_=f.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",si,oi.vertexSource,ni.vertexSource,ri.vertexSource,i.vertexSource).join("\n"),g=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(g,m),s.compileShader(g),s.attachShader(this.program,g);const y=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(y,_),s.compileShader(y),s.attachShader(this.program,y),this.attributes={};const x={};this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)c[e]&&(s.bindAttribLocation(this.program,e,c[e]),this.attributes[c[e]]=e);s.linkProgram(this.program),s.deleteShader(y),s.deleteShader(g);for(let e=0;e<d.length;e++){const t=d[e];if(t&&!x[t]){const te=s.getUniformLocation(this.program,t);te&&(x[t]=te)}}this.fixedUniforms=n(t,x),this.binderUniforms=r?r.getUniforms(t,x):[],-1!==o.indexOf("TERRAIN")&&(this.terrainUniforms=((e,t)=>({u_dem:new te.Uniform1i(e,t.u_dem),u_dem_prev:new te.Uniform1i(e,t.u_dem_prev),u_dem_unpack:new te.Uniform4f(e,t.u_dem_unpack),u_dem_tl:new te.Uniform2f(e,t.u_dem_tl),u_dem_scale:new te.Uniform1f(e,t.u_dem_scale),u_dem_tl_prev:new te.Uniform2f(e,t.u_dem_tl_prev),u_dem_scale_prev:new te.Uniform1f(e,t.u_dem_scale_prev),u_dem_size:new te.Uniform1f(e,t.u_dem_size),u_dem_lerp:new te.Uniform1f(e,t.u_dem_lerp),u_exaggeration:new te.Uniform1f(e,t.u_exaggeration),u_depth:new te.Uniform1i(e,t.u_depth),u_depth_size_inv:new te.Uniform2f(e,t.u_depth_size_inv),u_meter_to_dem:new te.Uniform1f(e,t.u_meter_to_dem),u_label_plane_matrix_inv:new te.UniformMatrix4f(e,t.u_label_plane_matrix_inv),u_tile_tl_up:new te.Uniform3f(e,t.u_tile_tl_up),u_tile_tr_up:new te.Uniform3f(e,t.u_tile_tr_up),u_tile_br_up:new te.Uniform3f(e,t.u_tile_br_up),u_tile_bl_up:new te.Uniform3f(e,t.u_tile_bl_up),u_tile_up_scale:new te.Uniform1f(e,t.u_tile_up_scale)}))(t,x)),-1!==o.indexOf("FOG")&&(this.fogUniforms=((e,t)=>({u_fog_matrix:new te.UniformMatrix4f(e,t.u_fog_matrix),u_fog_range:new te.Uniform2f(e,t.u_fog_range),u_fog_color:new te.Uniform4f(e,t.u_fog_color),u_fog_horizon_blend:new te.Uniform1f(e,t.u_fog_horizon_blend),u_fog_temporal_offset:new te.Uniform1f(e,t.u_fog_temporal_offset),u_frustum_tl:new te.Uniform3f(e,t.u_frustum_tl),u_frustum_tr:new te.Uniform3f(e,t.u_frustum_tr),u_frustum_br:new te.Uniform3f(e,t.u_frustum_br),u_frustum_bl:new te.Uniform3f(e,t.u_frustum_bl),u_globe_pos:new te.Uniform3f(e,t.u_globe_pos),u_globe_radius:new te.Uniform1f(e,t.u_globe_radius),u_globe_transition:new te.Uniform1f(e,t.u_globe_transition),u_is_globe:new te.Uniform1i(e,t.u_is_globe),u_viewport:new te.Uniform2f(e,t.u_viewport)}))(t,x))}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].location&&i[e].set(t[e])}}draw(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_){const g=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(n),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(s[e]);d&&d.setUniforms(e,this.binderUniforms,u,{zoom:p});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];for(const i of h.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new hi)).bind(e,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m,_),g.drawElements(t,i.primitiveLength*y,g.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function Bi(e,t,i){const r=1/z(i,1,t.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/n,s=o*(i.tileID.canonical.x+i.tileID.wrap*n),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const ki=te.create(),zi=(e,t,i,r,n,o,s,a,l)=>{const c=t.style.light,h=c.properties.get("position"),u=[h.x,h.y,h.z],p=te.create$1();"viewport"===c.properties.get("anchor")&&(te.fromRotation(p,-t.transform.angle),te.transformMat3(u,u,p));const d=c.properties.get("color"),f=t.transform,m={u_matrix:e,u_lightpos:u,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[d.r,d.g,d.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ki,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===f.projection.name&&(m.u_tile_id=[n.canonical.x,n.canonical.y,1<<n.canonical.z],m.u_zoom_transition=s,m.u_inv_rot_matrix=l,m.u_merc_center=a,m.u_up_dir=f.projection.upVector(new te.CanonicalTileID(0,0,0),a[0]*te.EXTENT,a[1]*te.EXTENT),m.u_height_lift=o),m},Pi=(e,t,i,r,n,o,s,a,l,c,h)=>{const u=zi(e,t,i,r,n,a,l,c,h),p={u_height_factor:-Math.pow(2,n.overscaledZ)/s.tileSize/8};return te.extend(u,Bi(o,t,s),p)},Li=e=>({u_matrix:e}),Di=(e,t,i,r)=>te.extend(Li(e),Bi(i,t,r)),Ri=(e,t)=>({u_matrix:e,u_world:t}),Oi=(e,t,i,r,n)=>te.extend(Di(e,t,i,r),{u_world:n}),Fi=te.create(),Ni=(e,t,i,r,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=te.globePixelsToTileUnits(s.zoom,t.canonical)*s._projectionScaler;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:s.cameraToCenterDistance,u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:te.exported.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Fi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=te.globeToMercatorTransition(s.zoom);const e=n[0]*te.EXTENT,i=n[1]*te.EXTENT;c.u_up_dir=s.projection.upVector(new te.CanonicalTileID(0,0,0),e,i)}return c},Ui=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},ji=(e,t,i,r)=>{const n=te.EXTENT/i.tileSize;return{u_matrix:e,u_camera_to_center_distance:t.getCameraToCenterDistance(r),u_extrude_scale:[t.pixelsToGLUnits[0]/n,t.pixelsToGLUnits[1]/n]}},Vi=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Gi=te.create(),$i=(e,t,i,r,n,o,s)=>{const a=e.transform,l="globe"===a.projection.name,c=l?te.globePixelsToTileUnits(a.zoom,t.canonical)*a._projectionScaler:z(i,1,o),h={u_matrix:t.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:Gi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){h.u_inv_rot_matrix=r,h.u_merc_center=n,h.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],h.u_zoom_transition=te.globeToMercatorTransition(a.zoom);const e=n[0]*te.EXTENT,i=n[1]*te.EXTENT;h.u_up_dir=a.projection.upVector(new te.CanonicalTileID(0,0,0),e,i)}return h},qi=(e,t,i,r,n,o,s,a)=>{const l=e.transform,c=l.calculatePixelsToTileUnitsMatrix(t),h={u_matrix:Wi(e,t,i,n),u_pixels_to_tile_units:c,u_device_pixel_ratio:s,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:a};if(Xi(i)){const i=Yi(t,e.transform);h.u_texsize=t.lineAtlasTexture.size,h.u_scale=[i,r.fromScale,r.toScale],h.u_mix=r.t}return h},Zi=(e,t,i,r,n,o)=>{const s=e.transform,a=Yi(t,s);return{u_matrix:Wi(e,t,i,n),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:o,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Yi(e,t){return 1/z(e,1,t.tileZoom)}function Wi(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function Xi(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Hi=(e,t,i,r,n,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:i,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(a=n.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=n.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Ki(n.paint.get("raster-hue-rotate")),u_perspective_transform:o};var s,a};function Ki(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Ji=te.create(),Qi=(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m)=>{const _=n.transform,g={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:s,u_coord_matrix:a,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ji,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ji,u_up_vector:[0,-1,0]};return"globe"===m.name&&(g.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],g.u_zoom_transition=u,g.u_inv_rot_matrix=d,g.u_merc_center=p,g.u_camera_forward=_._camera.forward(),g.u_ecef_origin=te.globeECEFOrigin(_.globeMatrix,h.toUnwrapped()),g.u_tile_matrix=Float32Array.from(_.globeMatrix),g.u_up_vector=f),g},er=(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m,_)=>te.extend(Qi(e,t,i,r,n,o,s,a,l,c,u,p,d,f,m,_),{u_gamma_scale:r?n.transform.cameraToCenterDistance*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:te.exported.devicePixelRatio,u_is_halo:+h}),tr=(e,t,i,r,n,o,s,a,l,c,h,u,p,d,f,m)=>te.extend(er(e,t,i,r,n,o,s,a,!0,l,!0,h,u,p,d,f,m),{u_texsize_icon:c,u_texture_icon:1}),ir=(e,t,i)=>({u_matrix:e,u_opacity:t,u_color:i}),rr=(e,t,i,r,n,o)=>te.extend(function(e,t,i,r){const n=i.imageManager.getPattern(e.from.toString()),o=i.imageManager.getPattern(e.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,a],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/z(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(r,o,i,n),{u_matrix:e,u_opacity:t}),nr={fillExtrusion:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_lightpos:new te.Uniform3f(e,t.u_lightpos),u_lightintensity:new te.Uniform1f(e,t.u_lightintensity),u_lightcolor:new te.Uniform3f(e,t.u_lightcolor),u_vertical_gradient:new te.Uniform1f(e,t.u_vertical_gradient),u_opacity:new te.Uniform1f(e,t.u_opacity),u_tile_id:new te.Uniform3f(e,t.u_tile_id),u_zoom_transition:new te.Uniform1f(e,t.u_zoom_transition),u_inv_rot_matrix:new te.UniformMatrix4f(e,t.u_inv_rot_matrix),u_merc_center:new te.Uniform2f(e,t.u_merc_center),u_up_dir:new te.Uniform3f(e,t.u_up_dir),u_height_lift:new te.Uniform1f(e,t.u_height_lift)}),fillExtrusionPattern:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_lightpos:new te.Uniform3f(e,t.u_lightpos),u_lightintensity:new te.Uniform1f(e,t.u_lightintensity),u_lightcolor:new te.Uniform3f(e,t.u_lightcolor),u_vertical_gradient:new te.Uniform1f(e,t.u_vertical_gradient),u_height_factor:new te.Uniform1f(e,t.u_height_factor),u_tile_id:new te.Uniform3f(e,t.u_tile_id),u_zoom_transition:new te.Uniform1f(e,t.u_zoom_transition),u_inv_rot_matrix:new te.UniformMatrix4f(e,t.u_inv_rot_matrix),u_merc_center:new te.Uniform2f(e,t.u_merc_center),u_up_dir:new te.Uniform3f(e,t.u_up_dir),u_height_lift:new te.Uniform1f(e,t.u_height_lift),u_image:new te.Uniform1i(e,t.u_image),u_texsize:new te.Uniform2f(e,t.u_texsize),u_pixel_coord_upper:new te.Uniform2f(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new te.Uniform2f(e,t.u_pixel_coord_lower),u_scale:new te.Uniform3f(e,t.u_scale),u_fade:new te.Uniform1f(e,t.u_fade),u_opacity:new te.Uniform1f(e,t.u_opacity)}),fill:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix)}),fillPattern:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_image:new te.Uniform1i(e,t.u_image),u_texsize:new te.Uniform2f(e,t.u_texsize),u_pixel_coord_upper:new te.Uniform2f(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new te.Uniform2f(e,t.u_pixel_coord_lower),u_scale:new te.Uniform3f(e,t.u_scale),u_fade:new te.Uniform1f(e,t.u_fade)}),fillOutline:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_world:new te.Uniform2f(e,t.u_world)}),fillOutlinePattern:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_world:new te.Uniform2f(e,t.u_world),u_image:new te.Uniform1i(e,t.u_image),u_texsize:new te.Uniform2f(e,t.u_texsize),u_pixel_coord_upper:new te.Uniform2f(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new te.Uniform2f(e,t.u_pixel_coord_lower),u_scale:new te.Uniform3f(e,t.u_scale),u_fade:new te.Uniform1f(e,t.u_fade)}),circle:(e,t)=>({u_camera_to_center_distance:new te.Uniform1f(e,t.u_camera_to_center_distance),u_extrude_scale:new te.UniformMatrix2f(e,t.u_extrude_scale),u_device_pixel_ratio:new te.Uniform1f(e,t.u_device_pixel_ratio),u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_inv_rot_matrix:new te.UniformMatrix4f(e,t.u_inv_rot_matrix),u_merc_center:new te.Uniform2f(e,t.u_merc_center),u_tile_id:new te.Uniform3f(e,t.u_tile_id),u_zoom_transition:new te.Uniform1f(e,t.u_zoom_transition),u_up_dir:new te.Uniform3f(e,t.u_up_dir)}),collisionBox:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_camera_to_center_distance:new te.Uniform1f(e,t.u_camera_to_center_distance),u_extrude_scale:new te.Uniform2f(e,t.u_extrude_scale)}),collisionCircle:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_inv_matrix:new te.UniformMatrix4f(e,t.u_inv_matrix),u_camera_to_center_distance:new te.Uniform1f(e,t.u_camera_to_center_distance),u_viewport_size:new te.Uniform2f(e,t.u_viewport_size)}),debug:(e,t)=>({u_color:new te.UniformColor(e,t.u_color),u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_overlay:new te.Uniform1i(e,t.u_overlay),u_overlay_scale:new te.Uniform1f(e,t.u_overlay_scale)}),clippingMask:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix)}),heatmap:(e,t)=>({u_extrude_scale:new te.Uniform1f(e,t.u_extrude_scale),u_intensity:new te.Uniform1f(e,t.u_intensity),u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_inv_rot_matrix:new te.UniformMatrix4f(e,t.u_inv_rot_matrix),u_merc_center:new te.Uniform2f(e,t.u_merc_center),u_tile_id:new te.Uniform3f(e,t.u_tile_id),u_zoom_transition:new te.Uniform1f(e,t.u_zoom_transition),u_up_dir:new te.Uniform3f(e,t.u_up_dir)}),heatmapTexture:(e,t)=>({u_image:new te.Uniform1i(e,t.u_image),u_color_ramp:new te.Uniform1i(e,t.u_color_ramp),u_opacity:new te.Uniform1f(e,t.u_opacity)}),hillshade:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_image:new te.Uniform1i(e,t.u_image),u_latrange:new te.Uniform2f(e,t.u_latrange),u_light:new te.Uniform2f(e,t.u_light),u_shadow:new te.UniformColor(e,t.u_shadow),u_highlight:new te.UniformColor(e,t.u_highlight),u_accent:new te.UniformColor(e,t.u_accent)}),hillshadePrepare:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_image:new te.Uniform1i(e,t.u_image),u_dimension:new te.Uniform2f(e,t.u_dimension),u_zoom:new te.Uniform1f(e,t.u_zoom),u_unpack:new te.Uniform4f(e,t.u_unpack)}),line:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_pixels_to_tile_units:new te.UniformMatrix2f(e,t.u_pixels_to_tile_units),u_device_pixel_ratio:new te.Uniform1f(e,t.u_device_pixel_ratio),u_units_to_pixels:new te.Uniform2f(e,t.u_units_to_pixels),u_dash_image:new te.Uniform1i(e,t.u_dash_image),u_gradient_image:new te.Uniform1i(e,t.u_gradient_image),u_image_height:new te.Uniform1f(e,t.u_image_height),u_texsize:new te.Uniform2f(e,t.u_texsize),u_scale:new te.Uniform3f(e,t.u_scale),u_mix:new te.Uniform1f(e,t.u_mix),u_alpha_discard_threshold:new te.Uniform1f(e,t.u_alpha_discard_threshold),u_trim_offset:new te.Uniform2f(e,t.u_trim_offset)}),linePattern:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_texsize:new te.Uniform2f(e,t.u_texsize),u_pixels_to_tile_units:new te.UniformMatrix2f(e,t.u_pixels_to_tile_units),u_device_pixel_ratio:new te.Uniform1f(e,t.u_device_pixel_ratio),u_image:new te.Uniform1i(e,t.u_image),u_units_to_pixels:new te.Uniform2f(e,t.u_units_to_pixels),u_scale:new te.Uniform3f(e,t.u_scale),u_fade:new te.Uniform1f(e,t.u_fade),u_alpha_discard_threshold:new te.Uniform1f(e,t.u_alpha_discard_threshold)}),raster:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_tl_parent:new te.Uniform2f(e,t.u_tl_parent),u_scale_parent:new te.Uniform1f(e,t.u_scale_parent),u_fade_t:new te.Uniform1f(e,t.u_fade_t),u_opacity:new te.Uniform1f(e,t.u_opacity),u_image0:new te.Uniform1i(e,t.u_image0),u_image1:new te.Uniform1i(e,t.u_image1),u_brightness_low:new te.Uniform1f(e,t.u_brightness_low),u_brightness_high:new te.Uniform1f(e,t.u_brightness_high),u_saturation_factor:new te.Uniform1f(e,t.u_saturation_factor),u_contrast_factor:new te.Uniform1f(e,t.u_contrast_factor),u_spin_weights:new te.Uniform3f(e,t.u_spin_weights),u_perspective_transform:new te.Uniform2f(e,t.u_perspective_transform)}),symbolIcon:(e,t)=>({u_is_size_zoom_constant:new te.Uniform1i(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new te.Uniform1i(e,t.u_is_size_feature_constant),u_size_t:new te.Uniform1f(e,t.u_size_t),u_size:new te.Uniform1f(e,t.u_size),u_camera_to_center_distance:new te.Uniform1f(e,t.u_camera_to_center_distance),u_rotate_symbol:new te.Uniform1i(e,t.u_rotate_symbol),u_aspect_ratio:new te.Uniform1f(e,t.u_aspect_ratio),u_fade_change:new te.Uniform1f(e,t.u_fade_change),u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_label_plane_matrix:new te.UniformMatrix4f(e,t.u_label_plane_matrix),u_coord_matrix:new te.UniformMatrix4f(e,t.u_coord_matrix),u_is_text:new te.Uniform1i(e,t.u_is_text),u_pitch_with_map:new te.Uniform1i(e,t.u_pitch_with_map),u_texsize:new te.Uniform2f(e,t.u_texsize),u_tile_id:new te.Uniform3f(e,t.u_tile_id),u_zoom_transition:new te.Uniform1f(e,t.u_zoom_transition),u_inv_rot_matrix:new te.UniformMatrix4f(e,t.u_inv_rot_matrix),u_merc_center:new te.Uniform2f(e,t.u_merc_center),u_camera_forward:new te.Uniform3f(e,t.u_camera_forward),u_tile_matrix:new te.UniformMatrix4f(e,t.u_tile_matrix),u_up_vector:new te.Uniform3f(e,t.u_up_vector),u_ecef_origin:new te.Uniform3f(e,t.u_ecef_origin),u_texture:new te.Uniform1i(e,t.u_texture)}),symbolSDF:(e,t)=>({u_is_size_zoom_constant:new te.Uniform1i(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new te.Uniform1i(e,t.u_is_size_feature_constant),u_size_t:new te.Uniform1f(e,t.u_size_t),u_size:new te.Uniform1f(e,t.u_size),u_camera_to_center_distance:new te.Uniform1f(e,t.u_camera_to_center_distance),u_rotate_symbol:new te.Uniform1i(e,t.u_rotate_symbol),u_aspect_ratio:new te.Uniform1f(e,t.u_aspect_ratio),u_fade_change:new te.Uniform1f(e,t.u_fade_change),u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_label_plane_matrix:new te.UniformMatrix4f(e,t.u_label_plane_matrix),u_coord_matrix:new te.UniformMatrix4f(e,t.u_coord_matrix),u_is_text:new te.Uniform1i(e,t.u_is_text),u_pitch_with_map:new te.Uniform1i(e,t.u_pitch_with_map),u_texsize:new te.Uniform2f(e,t.u_texsize),u_texture:new te.Uniform1i(e,t.u_texture),u_gamma_scale:new te.Uniform1f(e,t.u_gamma_scale),u_device_pixel_ratio:new te.Uniform1f(e,t.u_device_pixel_ratio),u_tile_id:new te.Uniform3f(e,t.u_tile_id),u_zoom_transition:new te.Uniform1f(e,t.u_zoom_transition),u_inv_rot_matrix:new te.UniformMatrix4f(e,t.u_inv_rot_matrix),u_merc_center:new te.Uniform2f(e,t.u_merc_center),u_camera_forward:new te.Uniform3f(e,t.u_camera_forward),u_tile_matrix:new te.UniformMatrix4f(e,t.u_tile_matrix),u_up_vector:new te.Uniform3f(e,t.u_up_vector),u_ecef_origin:new te.Uniform3f(e,t.u_ecef_origin),u_is_halo:new te.Uniform1i(e,t.u_is_halo)}),symbolTextAndIcon:(e,t)=>({u_is_size_zoom_constant:new te.Uniform1i(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new te.Uniform1i(e,t.u_is_size_feature_constant),u_size_t:new te.Uniform1f(e,t.u_size_t),u_size:new te.Uniform1f(e,t.u_size),u_camera_to_center_distance:new te.Uniform1f(e,t.u_camera_to_center_distance),u_rotate_symbol:new te.Uniform1i(e,t.u_rotate_symbol),u_aspect_ratio:new te.Uniform1f(e,t.u_aspect_ratio),u_fade_change:new te.Uniform1f(e,t.u_fade_change),u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_label_plane_matrix:new te.UniformMatrix4f(e,t.u_label_plane_matrix),u_coord_matrix:new te.UniformMatrix4f(e,t.u_coord_matrix),u_is_text:new te.Uniform1i(e,t.u_is_text),u_pitch_with_map:new te.Uniform1i(e,t.u_pitch_with_map),u_texsize:new te.Uniform2f(e,t.u_texsize),u_texsize_icon:new te.Uniform2f(e,t.u_texsize_icon),u_texture:new te.Uniform1i(e,t.u_texture),u_texture_icon:new te.Uniform1i(e,t.u_texture_icon),u_gamma_scale:new te.Uniform1f(e,t.u_gamma_scale),u_device_pixel_ratio:new te.Uniform1f(e,t.u_device_pixel_ratio),u_is_halo:new te.Uniform1i(e,t.u_is_halo)}),background:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_opacity:new te.Uniform1f(e,t.u_opacity),u_color:new te.UniformColor(e,t.u_color)}),backgroundPattern:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_opacity:new te.Uniform1f(e,t.u_opacity),u_image:new te.Uniform1i(e,t.u_image),u_pattern_tl_a:new te.Uniform2f(e,t.u_pattern_tl_a),u_pattern_br_a:new te.Uniform2f(e,t.u_pattern_br_a),u_pattern_tl_b:new te.Uniform2f(e,t.u_pattern_tl_b),u_pattern_br_b:new te.Uniform2f(e,t.u_pattern_br_b),u_texsize:new te.Uniform2f(e,t.u_texsize),u_mix:new te.Uniform1f(e,t.u_mix),u_pattern_size_a:new te.Uniform2f(e,t.u_pattern_size_a),u_pattern_size_b:new te.Uniform2f(e,t.u_pattern_size_b),u_scale_a:new te.Uniform1f(e,t.u_scale_a),u_scale_b:new te.Uniform1f(e,t.u_scale_b),u_pixel_coord_upper:new te.Uniform2f(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new te.Uniform2f(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new te.Uniform1f(e,t.u_tile_units_to_pixels)}),terrainRaster:mi,terrainDepth:mi,skybox:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_sun_direction:new te.Uniform3f(e,t.u_sun_direction),u_cubemap:new te.Uniform1i(e,t.u_cubemap),u_opacity:new te.Uniform1f(e,t.u_opacity),u_temporal_offset:new te.Uniform1f(e,t.u_temporal_offset)}),skyboxGradient:(e,t)=>({u_matrix:new te.UniformMatrix4f(e,t.u_matrix),u_color_ramp:new te.Uniform1i(e,t.u_color_ramp),u_center_direction:new te.Uniform3f(e,t.u_center_direction),u_radius:new te.Uniform1f(e,t.u_radius),u_opacity:new te.Uniform1f(e,t.u_opacity),u_temporal_offset:new te.Uniform1f(e,t.u_temporal_offset)}),skyboxCapture:(e,t)=>({u_matrix_3f:new te.UniformMatrix3f(e,t.u_matrix_3f),u_sun_direction:new te.Uniform3f(e,t.u_sun_direction),u_sun_intensity:new te.Uniform1f(e,t.u_sun_intensity),u_color_tint_r:new te.Uniform4f(e,t.u_color_tint_r),u_color_tint_m:new te.Uniform4f(e,t.u_color_tint_m),u_luminance:new te.Uniform1f(e,t.u_luminance)}),globeRaster:(e,t)=>({u_proj_matrix:new te.UniformMatrix4f(e,t.u_proj_matrix),u_globe_matrix:new te.UniformMatrix4f(e,t.u_globe_matrix),u_normalize_matrix:new te.UniformMatrix4f(e,t.u_normalize_matrix),u_merc_matrix:new te.UniformMatrix4f(e,t.u_merc_matrix),u_zoom_transition:new te.Uniform1f(e,t.u_zoom_transition),u_merc_center:new te.Uniform2f(e,t.u_merc_center),u_image0:new te.Uniform1i(e,t.u_image0),u_grid_matrix:new te.UniformMatrix3f(e,t.u_grid_matrix),u_frustum_tl:new te.Uniform3f(e,t.u_frustum_tl),u_frustum_tr:new te.Uniform3f(e,t.u_frustum_tr),u_frustum_br:new te.Uniform3f(e,t.u_frustum_br),u_frustum_bl:new te.Uniform3f(e,t.u_frustum_bl),u_globe_pos:new te.Uniform3f(e,t.u_globe_pos),u_globe_radius:new te.Uniform1f(e,t.u_globe_radius),u_viewport:new te.Uniform2f(e,t.u_viewport)}),globeAtmosphere:(e,t)=>({u_frustum_tl:new te.Uniform3f(e,t.u_frustum_tl),u_frustum_tr:new te.Uniform3f(e,t.u_frustum_tr),u_frustum_br:new te.Uniform3f(e,t.u_frustum_br),u_frustum_bl:new te.Uniform3f(e,t.u_frustum_bl),u_horizon:new te.Uniform1f(e,t.u_horizon),u_transition:new te.Uniform1f(e,t.u_transition),u_fadeout_range:new te.Uniform1f(e,t.u_fadeout_range),u_color:new te.Uniform4f(e,t.u_color),u_high_color:new te.Uniform4f(e,t.u_high_color),u_space_color:new te.Uniform4f(e,t.u_space_color),u_star_intensity:new te.Uniform1f(e,t.u_star_intensity),u_star_density:new te.Uniform1f(e,t.u_star_density),u_star_size:new te.Uniform1f(e,t.u_star_size),u_temporal_offset:new te.Uniform1f(e,t.u_temporal_offset),u_horizon_angle:new te.Uniform1f(e,t.u_horizon_angle),u_rotation_matrix:new te.UniformMatrix4f(e,t.u_rotation_matrix)})};let or;function sr(i,r,n,o,s,a,l){const c=i.context,h=c.gl,u=i.transform,p=i.useProgram("collisionBox"),d=[];let f=0,m=0;for(let t=0;t<o.length;t++){const _=o[t],g=r.getTile(_),y=g.getBucket(n);if(!y)continue;const x=bt(_,y,u);let e=x;0===s[0]&&0===s[1]||(e=i.translatePosMatrix(x,g,s,a));const v=l?y.textCollisionBox:y.iconCollisionBox,b=y.collisionCircleArray;if(b.length>0){const i=te.create(),r=e;te.mul(i,y.placementInvProjMatrix,u.glCoordMatrix),te.mul(i,i,y.placementViewportMatrix),d.push({circleArray:b,circleOffset:m,transform:r,invTransform:i,projection:y.getProjection()}),f+=b.length/4,m=f}v&&(i.terrain&&i.terrain.setupElevationDraw(g,p),p.draw(c,h.LINES,te.DepthMode.disabled,te.StencilMode.disabled,i.colorModeForRenderPass(),te.CullFaceMode.disabled,ji(e,u,g,y.getProjection()),n.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,u.zoom,null,v.collisionVertexBuffer,v.collisionVertexBufferExt))}if(!l||!d.length)return;const e=i.useProgram("collisionCircle"),_=new te.StructArrayLayout2f1f2i16;_.resize(4*f),_._trim();let g=0;for(const te of d)for(let e=0;e<te.circleArray.length/4;e++){const r=4*e,n=te.circleArray[r+0],o=te.circleArray[r+1],s=te.circleArray[r+2],a=te.circleArray[r+3];_.emplace(g++,n,o,s,a,0),_.emplace(g++,n,o,s,a,1),_.emplace(g++,n,o,s,a,2),_.emplace(g++,n,o,s,a,3)}(!or||or.length<2*f)&&(or=function(t){const i=2*t,r=new te.StructArrayLayout3ui6;r.resize(i),r._trim();for(let e=0;e<i;e++){const t=6*e;r.uint16[t+0]=4*e+0,r.uint16[t+1]=4*e+1,r.uint16[t+2]=4*e+2,r.uint16[t+3]=4*e+2,r.uint16[t+4]=4*e+3,r.uint16[t+5]=4*e+0}return r}(f));const y=c.createIndexBuffer(or,!0),x=c.createVertexBuffer(_,te.collisionCircleLayout.members,!0);for(const r of d){const o={u_matrix:r.transform,u_inv_matrix:r.invTransform,u_camera_to_center_distance:(t=u).getCameraToCenterDistance(r.projection),u_viewport_size:[t.width,t.height]};e.draw(c,h.TRIANGLES,te.DepthMode.disabled,te.StencilMode.disabled,i.colorModeForRenderPass(),te.CullFaceMode.disabled,o,n.id,x,y,te.SegmentVector.simpleSegment(0,2*r.circleOffset,r.circleArray.length,r.circleArray.length/2),null,u.zoom)}var t;x.destroy(),y.destroy()}const ar=te.create();function lr(e,t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=te.getAnchorAlignment(e),l=-(s-.5)*t,c=-(a-.5)*i,h=te.evaluateVariableOffset(e,r);return new te.pointGeometry((l/n+h[0])*o,(c/n+h[1])*o)}function cr(i,r,n,o,s,a,l,c,h,u,p){const d=i.text.placedSymbolArray,f=i.text.dynamicLayoutVertexArray,m=i.icon.dynamicLayoutVertexArray,_={},g=wt(c,i.getProjection(),a),y=a.elevation,x=i.getProjection().upVectorScale(c.canonical,a.center.lat,a.worldSize);f.clear();for(let e=0;e<d.length;e++){const v=d.get(e),t=i.allowVerticalPlacement&&!v.placedOrientation,b=v.hidden||!v.crossTileID||t?null:o[v.crossTileID];if(b){const o=new te.pointGeometry(v.tileAnchorX,v.tileAnchorY),d=i.getProjection().upVector(c.canonical,o.x,o.y),m=y?y.getAtTileOffset(c,o.x,o.y):0,w=ot([v.projectedAnchorX+m*d[0]*x.metersToTile,v.projectedAnchorY+m*d[1]*x.metersToTile,v.projectedAnchorZ+m*d[2]*x.metersToTile],n?g:l),T=st(a.getCameraToCenterDistance(i.getProjection()),w.signedDistanceFromCamera);let e=s.evaluateSizeForFeature(i.textSizeData,u,v)*T/te.ONE_EM;n&&(e*=i.tilePixelRatio/h);const{width:E,height:A,anchor:S,textOffset:C,textScale:M}=b,I=lr(S,E,A,C,M,e);let t;if(n){const te=o.add(I),{x:r,y:n,z:s}=i.getProjection().projectTilePoint(te.x,te.y,c.canonical);t=ot([r+m*d[0]*x.metersToTile,n+m*d[1]*x.metersToTile,s+m*d[2]*x.metersToTile],l).point}else{const te=r?I.rotate(-a.angle):I;t=[w.point[0]+te.x,w.point[1]+te.y,0]}const B=i.allowVerticalPlacement&&v.placedOrientation===te.WritingMode.vertical?Math.PI/2:0;for(let e=0;e<v.numGlyphs;e++)te.addDynamicAttributes(f,t[0],t[1],t[2],B);p&&v.associatedIconIndex>=0&&(_[v.associatedIconIndex]={shiftedAnchor:t,angle:B})}else _t(v.numGlyphs,f)}if(p){m.clear();const r=i.icon.placedSymbolArray;for(let e=0;e<r.length;e++){const n=r.get(e);if(n.hidden)_t(n.numGlyphs,m);else{const r=_[e];if(r)for(let e=0;e<n.numGlyphs;e++)te.addDynamicAttributes(m,r.shiftedAnchor[0],r.shiftedAnchor[1],r.shiftedAnchor[2],r.angle);else _t(n.numGlyphs,m)}}i.icon.dynamicLayoutVertexBuffer.updateData(m)}i.text.dynamicLayoutVertexBuffer.updateData(f)}function hr(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function ur(a,l,c,h,u,p,d,f,m,_,g,y){const x=a.context,v=x.gl,b=a.transform,w="map"===f,T="map"===m,E=w&&"point"!==c.layout.get("symbol-placement"),A=w&&!T&&!E,S=void 0!==c.layout.get("symbol-sort-key").constantOr(1);let C=!1;const M=a.depthModeForSublayer(0,te.DepthMode.ReadOnly),I=[te.mercatorXfromLng(b.center.lng),te.mercatorYfromLat(b.center.lat)],B=c.layout.get("text-variable-anchor"),k="globe"===b.projection.name,z=[],P=[0,-1,0];let L=P;!k&&!b.mercatorFromTransition||w||(L=function(e){const t=e._camera.getWorldToCamera(e.worldSize,1),i=te.multiply([],t,e.globeMatrix);te.invert(i,i);const r=[0,0,0],n=[0,1,0,0];return te.transformMat4$1(n,n,i),r[0]=n[0],r[1]=n[1],r[2]=n[2],te.normalize(r,r),r}(b));for(const f of h){const h=l.getTile(f),m=h.getBucket(c);if(!m)continue;if("mercator"===m.projection.name&&k)continue;const g=u?m.text:m.icon;if(!g||m.fullyClipped||!g.segments.get().length)continue;const y=g.programConfigurations.get(c.id),x=u||m.sdfIcons,M=u?m.textSizeData:m.iconSizeData,D=T||0!==b.pitch,R=te.evaluateSizeForZoom(M,b.zoom);let e,t,i,r,n=[0,0],o=null;if(u){if(t=h.glyphAtlasTexture,i=v.LINEAR,e=h.glyphAtlasTexture.size,m.iconsInText){n=h.imageAtlasTexture.size,o=h.imageAtlasTexture;const te="composite"===M.kind||"camera"===M.kind;r=D||a.options.rotating||a.options.zooming||te?v.LINEAR:v.NEAREST}}else{const te=1!==c.layout.get("icon-size").constantOr(0)||m.iconsNeedLinear;t=h.imageAtlasTexture,i=x||a.options.rotating||a.options.zooming||te||D?v.LINEAR:v.NEAREST,e=h.imageAtlasTexture.size}const O="globe"===m.projection.name,F=O?L:P,N=O?te.globeToMercatorTransition(b.zoom):0,U=wt(f,m.getProjection(),b),j=b.calculatePixelsToTileUnitsMatrix(h),V=tt(U,h.tileID.canonical,T,w,b,m.getProjection(),j),G=a.terrain&&T&&E?te.invert(te.create(),V):ar,$=rt(U,h.tileID.canonical,T,w,b,m.getProjection(),j),q=B&&m.hasTextData(),Z="none"!==c.layout.get("icon-text-fit")&&q&&m.hasIconData();if(E){const te=b.elevation,l=te?te.getAtTileOffsetFunc(f,b.center.lat,b.worldSize,m.getProjection()):e=>[0,0,0],c=it(U,h.tileID.canonical,T,w,b,m.getProjection(),j);lt(m,U,a,u,c,$,T,_,l,f)}const Y=E||u&&B||Z,W=a.translatePosMatrix(U,h,p,d),X=Y?ar:V,H=a.translatePosMatrix($,h,p,d,!0),K=m.getProjection().createInversionMatrix(b,f.canonical),J=[];a.terrain&&T&&J.push("PITCH_WITH_MAP_TERRAIN"),O&&J.push("PROJECTION_GLOBE_VIEW"),Y&&J.push("PROJECTED_POS_ON_VIEWPORT");const Q=x&&0!==c.paint.get(u?"text-halo-width":"icon-halo-width").constantOr(1);let s;s=x?m.iconsInText?tr(M.kind,R,A,T,a,W,X,H,e,n,f,N,I,K,F,m.getProjection()):er(M.kind,R,A,T,a,W,X,H,u,e,!0,f,N,I,K,F,m.getProjection()):Qi(M.kind,R,A,T,a,W,X,H,u,e,f,N,I,K,F,m.getProjection());const ee={program:a.useProgram(hr(x,u,m),y,J),buffers:g,uniformValues:s,atlasTexture:t,atlasTextureIcon:o,atlasInterpolation:i,atlasInterpolationIcon:r,isSDF:x,hasHalo:Q,tile:h,labelPlaneMatrixInv:G};if(S&&m.canOverlap){C=!0;const a=g.segments.get();for(const l of a)z.push({segments:new te.SegmentVector([l]),sortKey:l.sortKey,state:ee})}else z.push({segments:g.segments,sortKey:0,state:ee})}C&&z.sort((e,t)=>e.sortKey-t.sortKey);for(const te of z){const l=te.state;if(a.terrain&&a.terrain.setupElevationDraw(l.tile,l.program,{useDepthForOcclusion:!k,labelPlaneMatrixInv:l.labelPlaneMatrixInv}),x.activeTexture.set(v.TEXTURE0),l.atlasTexture.bind(l.atlasInterpolation,v.CLAMP_TO_EDGE),l.atlasTextureIcon&&(x.activeTexture.set(v.TEXTURE1),l.atlasTextureIcon&&l.atlasTextureIcon.bind(l.atlasInterpolationIcon,v.CLAMP_TO_EDGE)),l.isSDF){const h=l.uniformValues;l.hasHalo&&(h.u_is_halo=1,pr(l.buffers,te.segments,c,a,l.program,M,g,y,h)),h.u_is_halo=0}pr(l.buffers,te.segments,c,a,l.program,M,g,y,l.uniformValues)}}function pr(e,t,i,r,n,o,s,a,l){const c=r.context;n.draw(c,c.gl.TRIANGLES,o,s,a,te.CullFaceMode.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer)}function dr(e,t,i,r,n,o,s){const a=e.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),h=i.getCrossfadeParameters();let u,p,d,f,m;s?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=a.LINES):(p=c?"fillPattern":"fill",u=a.TRIANGLES);for(const _ of r){const r=t.getTile(_);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(i);if(!g)continue;e.prepareDrawTile();const y=g.programConfigurations.get(i.id),x=e.useProgram(p,y);c&&(e.context.activeTexture.set(a.TEXTURE0),r.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),y.updatePaintBuffers(h));const v=l.constantOr(null);if(v&&r.imageAtlas){const te=r.imageAtlas,e=te.patternPositions[v.to.toString()],t=te.patternPositions[v.from.toString()];e&&t&&y.setConstantPatternPositions(e,t)}const b=e.translatePosMatrix(_.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(s){f=g.indexBuffer2,m=g.segments2;const te=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===p&&c?Oi(b,e,h,r,te):Ri(b,te)}else f=g.indexBuffer,m=g.segments,d=c?Di(b,e,h,r):Li(b);e.prepareDrawProgram(e.context,x,_.toUnwrapped()),x.draw(e.context,u,n,e.stencilModeForClipping(_),o,te.CullFaceMode.disabled,d,i.id,g.layoutVertexBuffer,f,m,i.paint,e.transform.zoom,y)}}function fr(e,t,i,r,n,o,s){const a=e.context,l=a.gl,c=e.transform,h=i.paint.get("fill-extrusion-pattern"),u=h.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),f="globe"===c.projection.name?te.fillExtrusionHeightLift():0,m="globe"===c.projection.name,_=m?te.globeToMercatorTransition(c.zoom):0,g=[te.mercatorXfromLng(c.center.lng),te.mercatorYfromLat(c.center.lat)],y=[];m&&y.push("PROJECTION_GLOBE_VIEW");for(const x of r){const r=t.getTile(x),v=r.getBucket(i);if(!v||v.projection.name!==c.projection.name)continue;const b=v.programConfigurations.get(i.id),w=e.useProgram(u?"fillExtrusionPattern":"fillExtrusion",b,y);if(e.terrain){const te=e.terrain;if(e.style.terrainSetForDrapingOnly())te.setupElevationDraw(r,w,{useMeterToDem:!0});else{if(!v.enableTerrain)continue;if(te.setupElevationDraw(r,w,{useMeterToDem:!0}),mr(a,t,x,v,i,te),!v.centroidVertexBuffer){const te=w.attributes.a_centroid_pos;void 0!==te&&l.vertexAttrib2f(te,0,0)}}}u&&(e.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const T=h.constantOr(null);if(T&&r.imageAtlas){const te=r.imageAtlas,e=te.patternPositions[T.to.toString()],t=te.patternPositions[T.from.toString()];e&&t&&b.setConstantPatternPositions(e,t)}const E=e.translatePosMatrix(x.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),A=c.projection.createInversionMatrix(c,x.canonical),S=i.paint.get("fill-extrusion-vertical-gradient"),C=u?Pi(E,e,S,d,x,p,r,f,_,g,A):zi(E,e,S,d,x,f,_,g,A);e.prepareDrawProgram(a,w,x.toUnwrapped()),w.draw(a,a.gl.TRIANGLES,n,o,s,te.CullFaceMode.backCCW,C,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,e.transform.zoom,b,e.terrain?v.centroidVertexBuffer:null,m?v.layoutVertexExtBuffer:null)}}function mr(e,n,l,o,s,c){const a=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new te.OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new te.OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new te.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new te.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)],t=e=>{const t=n.getSource().minzoom,i=e=>{const t=n.getTileByID(e);if(t&&t.hasData())return t.getBucket(s)},r=[0,-1,1];for(const n of r){if(e.overscaledZ+n<t)continue;const r=i(e.calculateScaledKey(e.overscaledZ+n));if(r)return r}},h=[0,0,0],u=(e,t)=>(h[0]=Math.min(e.min.y,t.min.y),h[1]=Math.max(e.max.y,t.max.y),h[2]=te.EXTENT-t.min.x>e.max.x?t.min.x-te.EXTENT:e.max.x,h),p=(e,t)=>(h[0]=Math.min(e.min.x,t.min.x),h[1]=Math.max(e.max.x,t.max.x),h[2]=te.EXTENT-t.min.y>e.max.y?t.min.y-te.EXTENT:e.max.y,h),d=[(e,t)=>u(e,t),(e,t)=>u(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],f=new te.pointGeometry(0,0);let m,_,g;const y=(e,t,i,r,n)=>{const o=[[r?i:e,r?e:i,0],[r?i:t,r?t:i,0]],s=n<0?te.EXTENT+n:n,a=[r?s:(e+t)/2,r?(e+t)/2:s,0];return 0===i&&n<0||0!==i&&n>0?c.getForTilePoints(g,[a],!0,_):o.push(a),c.getForTilePoints(l,o,!0,m),Math.max(o[0][2],o[1][2],a[2])/c.exaggeration()};for(let r=0;r<4;r++){const n=(r<2?1:5)-r,s=o.borders[r];if(0===s.length)continue;const h=g=a[r](l),u=t(h);if(!(u&&u instanceof te.FillExtrusionBucket&&u.enableTerrain))continue;if(o.borderDoneWithNeighborZ[r]===u.canonical.z&&u.borderDoneWithNeighborZ[n]===o.canonical.z)continue;if(_=c.findDEMTileFor(h),!_||!_.dem)continue;if(!m){const te=c.findDEMTileFor(l);if(!te||!te.dem)return;m=te}const p=u.borders[n];let i=0;const x=u.borderDoneWithNeighborZ[n]!==o.canonical.z;if(o.canonical.z===u.canonical.z){for(let e=0;e<s.length;e++){const c=o.featuresOnBorder[s[e]],a=c.borders[r];let t;for(;i<p.length&&(t=u.featuresOnBorder[p[i]],!(t.borders[n][1]>a[0]+3));)x&&u.encodeCentroid(void 0,t,!1),i++;if(t&&i<p.length){const l=i;let e=0;for(;!(t.borders[n][0]>a[1]-3)&&(e++,++i!==p.length);)t=u.featuresOnBorder[p[i]];if(t=u.featuresOnBorder[p[l]],c.intersectsCount()>1||t.intersectsCount()>1||1!==e){1!==e&&(i=l),o.encodeCentroid(void 0,c,!1),x&&u.encodeCentroid(void 0,t,!1);continue}const h=d[r](c,t),m=r%2?te.EXTENT-1:0;f.x=y(h[0],Math.min(te.EXTENT-1,h[1]),m,r<2,h[2]),f.y=0,o.encodeCentroid(f,c,!1),x&&u.encodeCentroid(f,t,!1)}else o.encodeCentroid(void 0,c,!1)}o.borderDoneWithNeighborZ[r]=u.canonical.z,o.needsCentroidUpdate=!0,x&&(u.borderDoneWithNeighborZ[n]=o.canonical.z,u.needsCentroidUpdate=!0)}else{for(const te of s)o.encodeCentroid(void 0,o.featuresOnBorder[te],!1);if(x){for(const te of p)u.encodeCentroid(void 0,u.featuresOnBorder[te],!1);u.borderDoneWithNeighborZ[n]=o.canonical.z,u.needsCentroidUpdate=!0}o.borderDoneWithNeighborZ[r]=u.canonical.z,o.needsCentroidUpdate=!0}}(o.needsCentroidUpdate||!o.centroidVertexBuffer&&0!==o.centroidVertexArray.length)&&o.uploadCentroid(e)}const _r=new te.Color(1,0,0,1),gr=new te.Color(0,1,0,1),yr=new te.Color(0,0,1,1),xr=new te.Color(1,0,1,1),vr=new te.Color(0,1,1,1);function br(e,t,i,r){Tr(e,0,t+i/2,e.transform.width,i,r)}function wr(e,t,i,r){Tr(e,t-i/2,0,i,e.transform.height,r)}function Tr(e,t,i,r,n,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*te.exported.devicePixelRatio,i*te.exported.devicePixelRatio,r*te.exported.devicePixelRatio,n*te.exported.devicePixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Er(e,t,i){const r=e.context,n=r.gl,o="globe"===e.transform.projection.name,s=i.projMatrix,a=e.useProgram("debug",null,o?["PROJECTION_GLOBE_VIEW"]:null),l=t.getTileByID(i.key);e.terrain&&e.terrain.setupElevationDraw(l,a);const c=te.DepthMode.disabled,h=te.StencilMode.disabled,u=e.colorModeForRenderPass(),p="$debug";r.activeTexture.set(n.TEXTURE0),e.emptyTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),o?l._makeGlobeTileDebugBuffers(e.context,e.transform.projection):l._makeDebugTileBoundsBuffers(e.context,e.transform.projection);const d=l._tileDebugBuffer||e.debugBuffer,f=l._tileDebugIndexBuffer||e.debugIndexBuffer,m=l._tileDebugSegments||e.debugSegments;a.draw(r,n.LINE_STRIP,c,h,u,te.CullFaceMode.disabled,Vi(s,te.Color.red),p,d,f,m,null,null,null,l._globeTileDebugBorderBuffer);const _=l.latestRawTileData,g=Math.floor((_&&_.byteLength||0)/1024),y=t.getTile(i).tileSize,x=512/Math.min(y,512)*(i.overscaledZ/e.transform.zoom)*.5;let v=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(v+=` => ${i.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${v} ${g}kb`);const b=l._tileDebugTextBuffer||e.debugBuffer,w=l._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,T=l._tileDebugTextSegments||e.debugSegments;a.draw(r,n.TRIANGLES,c,h,te.ColorMode.alphaBlended,te.CullFaceMode.disabled,Vi(s,te.Color.transparent,x),p,b,w,T,null,null,null,l._globeTileDebugTextBuffer)}const Ar=te.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Sr}=Ar;function Cr(e,t,i,r){e.emplaceBack(t,i,r)}class Mr{constructor(e){this.vertexArray=new te.StructArrayLayout3f12,this.indices=new te.StructArrayLayout3ui6,Cr(this.vertexArray,-1,-1,1),Cr(this.vertexArray,1,-1,1),Cr(this.vertexArray,-1,1,1),Cr(this.vertexArray,1,1,1),Cr(this.vertexArray,-1,-1,-1),Cr(this.vertexArray,1,-1,-1),Cr(this.vertexArray,-1,1,-1),Cr(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Sr),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=te.SegmentVector.simpleSegment(0,0,36,12)}}function Ir(e,t,i,r,n,o){const s=e.gl,a=t.paint.get("sky-atmosphere-color"),l=t.paint.get("sky-atmosphere-halo-color"),c=t.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(te.fromMat4(te.create$1(),r),n,c,a,l);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+o,t.skyboxTexture,0),i.draw(e,s.TRIANGLES,te.DepthMode.disabled,te.StencilMode.disabled,te.ColorMode.unblended,te.CullFaceMode.frontCW,h,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const Br=te.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class kr{constructor(e){const t=new te.StructArrayLayout5f20;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const i=new te.StructArrayLayout3ui6;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,Br.members),this.indexBuffer=e.createIndexBuffer(i),this.segments=te.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const zr={symbol:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;const o=te.StencilMode.disabled,s=e.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(e,t,i,r,n,o,s){const a=t.transform,l="map"===n,c="map"===o;for(const t of e){const e=r.getTile(t),n=e.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const o=te.evaluateSizeForZoom(n.textSizeData,a.zoom),h=wt(t,n.getProjection(),a),u=a.calculatePixelsToTileUnitsMatrix(e),p=tt(h,e.tileID.canonical,c,l,a,n.getProjection(),u),d="none"!==i.layout.get("icon-text-fit")&&n.hasIconData();if(o){const i=Math.pow(2,a.zoom-e.tileID.overscaledZ);cr(n,l,c,s,te.symbolSize,a,p,t,i,o,d)}}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&ur(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),o,s),0!==i.paint.get("text-opacity").constantOr(1)&&ur(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),o,s),t.map.showCollisionBoxes&&(sr(e,t,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),sr(e,t,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,r,n){if("translucent"!==t.renderPass)return;const e=r.paint.get("circle-opacity"),o=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),a=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===e.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;const l=t.context,c=l.gl,h=t.transform,u=t.depthModeForSublayer(0,te.DepthMode.ReadOnly),p=te.StencilMode.disabled,d=t.colorModeForRenderPass(),f="globe"===h.projection.name,m=[te.mercatorXfromLng(h.center.lng),te.mercatorYfromLat(h.center.lat)],_=[];for(let e=0;e<n.length;e++){const o=n[e],s=i.getTile(o),l=s.getBucket(r);if(!l||l.projection.name!==h.projection.name)continue;const c=l.programConfigurations.get(r.id),u=Ui(r);f&&u.push("PROJECTION_GLOBE_VIEW");const p=t.useProgram("circle",c,u),d=l.layoutVertexBuffer,g=l.globeExtVertexBuffer,y=l.indexBuffer,x=h.projection.createInversionMatrix(h,o.canonical),v={programConfiguration:c,program:p,layoutVertexBuffer:d,globeExtVertexBuffer:g,indexBuffer:y,uniformValues:Ni(t,o,s,x,m,r),tile:s};if(a){const t=l.segments.get();for(const i of t)_.push({segments:new te.SegmentVector([i]),sortKey:i.sortKey,state:v})}else _.push({segments:l.segments,sortKey:0,state:v})}a&&_.sort((e,t)=>e.sortKey-t.sortKey);const g={useDepthForOcclusion:!f};for(const i of _){const{programConfiguration:n,program:e,layoutVertexBuffer:o,globeExtVertexBuffer:s,indexBuffer:a,uniformValues:m,tile:_}=i.state,b=i.segments;t.terrain&&t.terrain.setupElevationDraw(_,e,g),t.prepareDrawProgram(l,e,_.tileID.toUnwrapped()),e.draw(l,c.TRIANGLES,u,p,d,te.CullFaceMode.disabled,m,r.id,o,a,b,r.paint,h.zoom,n,f?s:null)}},heatmap:function(t,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=te.StencilMode.disabled,l=new te.ColorMode([s.ONE,s.ONE],te.Color.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!1),function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:te.Color.transparent});const c=t.transform,h="globe"===c.projection.name,u=h?["PROJECTION_GLOBE_VIEW"]:null,p=h?te.CullFaceMode.frontCCW:te.CullFaceMode.disabled,d=[te.mercatorXfromLng(c.center.lng),te.mercatorYfromLat(c.center.lat)];for(let e=0;e<n.length;e++){const f=n[e];if(i.hasRenderableParent(f))continue;const m=i.getTile(f),_=m.getBucket(r);if(!_||_.projection.name!==c.projection.name)continue;const g=_.programConfigurations.get(r.id),y=t.useProgram("heatmap",g,u),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(m,y),t.prepareDrawProgram(o,y,f.toUnwrapped());const v=c.projection.createInversionMatrix(c,f.canonical);y.draw(o,s.TRIANGLES,te.DepthMode.disabled,a,l,p,$i(t,f,m,v,d,x,r.paint.get("heatmap-intensity")),r.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,r.paint,t.transform.zoom,g,h?_.globeExtVertexBuffer:null)}o.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(e,t){const i=e.context,r=i.gl,n=t.heatmapFbo;if(!n)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let o=t.colorRampTexture;o||(o=t.colorRampTexture=new te.Texture(i,t.colorRamp,r.RGBA)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,te.DepthMode.disabled,te.StencilMode.disabled,e.colorModeForRenderPass(),te.CullFaceMode.disabled,((e,t,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom)}(t,r))},line:function(i,r,n,o){if("translucent"!==i.renderPass)return;const s=n.paint.get("line-opacity"),a=n.paint.get("line-width");if(0===s.constantOr(1)||0===a.constantOr(1))return;const l=i.depthModeForSublayer(0,te.DepthMode.ReadOnly),c=i.colorModeForRenderPass(),h=i.terrain&&i.terrain.renderingToTexture?1:te.exported.devicePixelRatio,u=n.paint.get("line-dasharray"),p=u.constantOr(1),d=n.layout.get("line-cap"),f=n.paint.get("line-pattern"),m=f.constantOr(1),_=n.paint.get("line-gradient"),g=n.getCrossfadeParameters(),y=m?"linePattern":"line",x=i.context,v=x.gl,b=(e=>{const t=[];Xi(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET");const r=e.paint.get("line-pattern").constantOr(1),n=1!==e.paint.get("line-opacity").constantOr(1);return!r&&n&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(n);let w=b.includes("RENDER_LINE_ALPHA_DISCARD");i.terrain&&i.terrain.clipOrMaskOverlapStencilType()&&(w=!1);for(const s of o){const o=r.getTile(s);if(m&&!o.patternsLoaded())continue;const a=o.getBucket(n);if(!a)continue;i.prepareDrawTile();const T=a.programConfigurations.get(n.id),E=i.useProgram(y,T,b),A=f.constantOr(null);if(A&&o.imageAtlas){const te=o.imageAtlas,i=te.patternPositions[A.to.toString()],r=te.patternPositions[A.from.toString()];i&&r&&T.setConstantPatternPositions(i,r)}const S=u.constantOr(null),C=d.constantOr(null);if(!m&&S&&C&&o.lineAtlas){const te=o.lineAtlas,i=te.getDash(S.to,C),r=te.getDash(S.from,C);i&&r&&T.setConstantPatternPositions(i,r)}let[e,t]=n.paint.get("line-trim-offset");if("round"===C||"square"===C){const te=1;e!==t&&(0===e&&(e-=te),1===t&&(t+=te))}const M=i.terrain?s.projMatrix:null,I=m?Zi(i,o,n,g,M,h):qi(i,o,n,g,M,a.lineClipsArray.length,h,[e,t]);if(_){const o=a.gradients[n.id];let t=o.texture;if(n.gradientVersion!==o.version){let e=256;if(n.stepInterpolant){const n=r.getSource().maxzoom,o=s.canonical.z===n?Math.ceil(1<<i.transform.maxZoom-s.canonical.z):1;e=te.clamp(te.nextPowerOfTwo(a.maxLineLength/te.EXTENT*1024*o),256,x.maxTextureSize)}o.gradient=te.renderColorRamp({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:e,image:o.gradient||void 0,clips:a.lineClipsArray}),o.texture?o.texture.update(o.gradient):o.texture=new te.Texture(x,o.gradient,v.RGBA),o.version=n.gradientVersion,t=o.texture}x.activeTexture.set(v.TEXTURE1),t.bind(n.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}p&&(x.activeTexture.set(v.TEXTURE0),o.lineAtlasTexture.bind(v.LINEAR,v.REPEAT),T.updatePaintBuffers(g)),m&&(x.activeTexture.set(v.TEXTURE0),o.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),T.updatePaintBuffers(g)),i.prepareDrawProgram(x,E,s.toUnwrapped());const B=e=>{E.draw(x,v.TRIANGLES,l,e,c,te.CullFaceMode.disabled,I,n.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,n.paint,i.transform.zoom,T,a.layoutVertexBuffer2)};if(w){const r=i.stencilModeForClipping(s).ref;0===r&&i.terrain&&x.clear({stencil:0});const n={func:v.EQUAL,mask:255};I.u_alpha_discard_threshold=.8,B(new te.StencilMode(n,r,255,v.KEEP,v.KEEP,v.INVERT)),I.u_alpha_discard_threshold=0,B(new te.StencilMode(n,r,255,v.KEEP,v.KEEP,v.KEEP))}else B(i.stencilModeForClipping(s))}w&&(i.resetStencilClippingMasks(),i.terrain&&x.clear({stencil:0}))},fill:function(e,t,i,r){const n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity");if(0===o.constantOr(1))return;const s=e.colorModeForRenderPass(),a=i.paint.get("fill-pattern"),l=e.opaquePassEnabledForLayer()&&!a.constantOr(1)&&1===n.constantOr(te.Color.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(e.renderPass===l){const n=e.depthModeForSublayer(1,"opaque"===e.renderPass?te.DepthMode.ReadWrite:te.DepthMode.ReadOnly);dr(e,t,i,r,n,s,!1)}if("translucent"===e.renderPass&&i.paint.get("fill-antialias")){const n=e.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,te.DepthMode.ReadOnly);dr(e,t,i,r,n,s,!0)}},"fill-extrusion":function(e,t,i,r){const n=i.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===e.renderPass){const o=new te.DepthMode(e.context.gl.LEQUAL,te.DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))fr(e,t,i,r,o,te.StencilMode.disabled,te.ColorMode.disabled),fr(e,t,i,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const n=e.colorModeForRenderPass();fr(e,t,i,r,o,te.StencilMode.disabled,n)}}},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const n=e.context,o=e.depthModeForSublayer(0,te.DepthMode.ReadOnly),s=e.colorModeForRenderPass(),a=e.terrain&&e.terrain.renderingToTexture,[l,c]="translucent"!==e.renderPass||a?[{},r]:e.stencilConfigForOverlap(r);for(const r of c){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)fi(e,n,i,o,te.StencilMode.disabled,s);else if("translucent"===e.renderPass){const te=a&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):l[r.overscaledZ];pi(e,r,n,i,o,te,s)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(i,r,n,o,s,a){if("translucent"!==i.renderPass)return;if(0===n.paint.get("raster-opacity"))return;if(!o.length)return;const l=i.context,c=l.gl,h=r.getSource(),u=i.useProgram("raster"),p=i.colorModeForRenderPass(),d=i.terrain&&i.terrain.renderingToTexture,[f,m]=h instanceof Be||d?[{},o]:i.stencilConfigForOverlap(o),_=m[m.length-1].overscaledZ,g=!i.options.moving;for(const o of m){const s=d?te.DepthMode.disabled:i.depthModeForSublayer(o.overscaledZ-_,1===n.paint.get("raster-opacity")?te.DepthMode.ReadWrite:te.DepthMode.ReadOnly,c.LESS),m=o.toUnwrapped(),y=r.getTile(o);if(d&&(!y||!y.hasData()))continue;const x=d?o.projMatrix:i.transform.calculateProjMatrix(m,g),v=i.terrain&&d?i.terrain.stencilModeForRTTOverlap(o):f[o.overscaledZ],b=a?0:n.paint.get("raster-fade-duration");y.registerFadeDuration(b);const w=r.findLoadedParent(o,0),T=Ti(y,w,r,i.transform,b);let e,t;i.terrain&&i.terrain.prepareDrawTile();const E="nearest"===n.paint.get("raster-resampling")?c.NEAREST:c.LINEAR;l.activeTexture.set(c.TEXTURE0),y.texture.bind(E,c.CLAMP_TO_EDGE),l.activeTexture.set(c.TEXTURE1),w?(w.texture.bind(E,c.CLAMP_TO_EDGE),e=Math.pow(2,w.tileID.overscaledZ-y.tileID.overscaledZ),t=[y.tileID.canonical.x*e%1,y.tileID.canonical.y*e%1]):y.texture.bind(E,c.CLAMP_TO_EDGE);const A=Hi(x,t||[0,0],e||1,T,n,h instanceof Be?h.perspectiveTransform:[0,0]);if(i.prepareDrawProgram(l,u,m),h instanceof Be)h.boundsBuffer&&h.boundsSegments&&u.draw(l,c.TRIANGLES,s,te.StencilMode.disabled,p,te.CullFaceMode.disabled,A,n.id,h.boundsBuffer,i.quadTriangleIndexBuffer,h.boundsSegments);else{const{tileBoundsBuffer:r,tileBoundsIndexBuffer:o,tileBoundsSegments:a}=i.getTileBoundsBuffers(y);u.draw(l,c.TRIANGLES,s,v,p,te.CullFaceMode.disabled,A,n.id,r,o,a)}}i.resetStencilClippingMasks()},background:function(e,t,i,r){const n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;const s=e.context,a=s.gl,l=e.transform,c=l.tileSize,h=i.paint.get("background-pattern");if(e.isPatternMissing(h))return;const u=!h&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==u)return;const p=te.StencilMode.disabled,d=e.depthModeForSublayer(0,"opaque"===u?te.DepthMode.ReadWrite:te.DepthMode.ReadOnly),f=e.colorModeForRenderPass(),m=e.useProgram(h?"backgroundPattern":"background");let _,g=r;g||(_=e.getBackgroundTiles(),g=Object.values(_).map(e=>e.tileID)),h&&(s.activeTexture.set(a.TEXTURE0),e.imageManager.bind(e.context));const y=i.getCrossfadeParameters();for(const u of g){const g=u.toUnwrapped(),x=r?u.projMatrix:e.transform.calculateProjMatrix(g);e.prepareDrawTile();const v=t?t.getTile(u):_?_[u.key]:new te.Tile(u,c,l.zoom,e),b=h?rr(x,o,e,h,{tileID:u,tileSize:c},y):ir(x,o,n);e.prepareDrawProgram(s,m,g);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=e.getTileBoundsBuffers(v);m.draw(s,a.TRIANGLES,d,p,f,te.CullFaceMode.disabled,b,i.id,w,T,E)}},sky:function(e,t,i){const r=e.transform,n="mercator"===r.projection.name||"globe"===r.projection.name?1:te.smoothstep(7,8,r.zoom),o=i.paint.get("sky-opacity")*n;if(0===o)return;const s=e.context,a=i.paint.get("sky-type"),l=new te.DepthMode(s.gl.LEQUAL,te.DepthMode.ReadOnly,[0,1]),c=e.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===e.renderPass?i.needsSkyboxCapture(e)&&(function(e,t,i,r){const n=e.context,o=n.gl;let s=t.skyboxFbo;if(!s){s=t.skyboxFbo=n.createFramebuffer(32,32,!1),t.skyboxGeometry=new Mr(n),t.skyboxTexture=n.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(s.framebuffer),n.viewport.set([0,0,32,32]);const a=t.getCenter(e,!0),l=e.useProgram("skyboxCapture"),c=new Float64Array(16);te.identity(c),te.rotateY(c,c,.5*-Math.PI),Ir(n,t,l,c,a,0),te.identity(c),te.rotateY(c,c,.5*Math.PI),Ir(n,t,l,c,a,1),te.identity(c),te.rotateX(c,c,.5*-Math.PI),Ir(n,t,l,c,a,2),te.identity(c),te.rotateX(c,c,.5*Math.PI),Ir(n,t,l,c,a,3),te.identity(c),Ir(n,t,l,c,a,4),te.identity(c),te.rotateY(c,c,Math.PI),Ir(n,t,l,c,a,5),n.viewport.set([0,0,e.width,e.height])}(e,i),i.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.useProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.prepareDrawProgram(o,l),l.draw(o,s.TRIANGLES,i,te.StencilMode.disabled,e.colorModeForRenderPass(),te.CullFaceMode.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,l,o,c):"gradient"===a&&"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.useProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new Mr(o)),o.activeTexture.set(s.TEXTURE0);let c=t.colorRampTexture;c||(c=t.colorRampTexture=new te.Texture(o,t.colorRamp,s.RGBA)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((e,t,i,r,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:te.degToRad(i),u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,n);e.prepareDrawProgram(o,l),l.draw(o,s.TRIANGLES,i,te.StencilMode.disabled,e.colorModeForRenderPass(),te.CullFaceMode.backCW,h,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,l,o,c)},debug:function(t,i,r){for(let e=0;e<r.length;e++)Er(t,i,r[e])},custom:function(e,t,i){const r=e.context,n=i.implementation;if(e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes("custom"))te.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===e.renderPass){const te=n.prerender;te&&(e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),te.call(n,r.gl,e.transform.customLayerMatrix()),r.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),r.setStencilMode(te.StencilMode.disabled);const t="3d"===n.renderingMode?new te.DepthMode(e.context.gl.LEQUAL,te.DepthMode.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,te.DepthMode.ReadOnly);r.setDepthMode(t),n.render(r.gl,e.transform.customLayerMatrix()),r.setDirty(),e.setBaseState(),r.bindFramebuffer.set(null)}}};class Pr{constructor(e,t){this.context=new Se(e),this.transform=t,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=te.SourceCache.maxUnderzooming+te.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Wt,this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Ci(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,t){if(this.width=e*te.exported.devicePixelRatio,this.height=t*te.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const te of this.style.order)this.style._layers[te].resize()}setup(){const e=this.context,t=new te.StructArrayLayout2i4;t.emplaceBack(0,0),t.emplaceBack(te.EXTENT,0),t.emplaceBack(0,te.EXTENT),t.emplaceBack(te.EXTENT,te.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(t,te.posAttributes.members),this.tileExtentSegments=te.SegmentVector.simpleSegment(0,0,4,2);const i=new te.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(te.EXTENT,0),i.emplaceBack(0,te.EXTENT),i.emplaceBack(te.EXTENT,te.EXTENT),this.debugBuffer=e.createVertexBuffer(i,te.posAttributes.members),this.debugSegments=te.SegmentVector.simpleSegment(0,0,4,5);const r=new te.StructArrayLayout2i4;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(r,te.posAttributes.members),this.viewportSegments=te.SegmentVector.simpleSegment(0,0,4,2);const n=new te.StructArrayLayout4i8;n.emplaceBack(0,0,0,0),n.emplaceBack(te.EXTENT,0,te.EXTENT,0),n.emplaceBack(0,te.EXTENT,0,te.EXTENT),n.emplaceBack(te.EXTENT,te.EXTENT,te.EXTENT,te.EXTENT),this.mercatorBoundsBuffer=e.createVertexBuffer(n,te.boundsAttributes.members),this.mercatorBoundsSegments=te.SegmentVector.simpleSegment(0,0,4,2);const o=new te.StructArrayLayout3ui6;o.emplaceBack(0,1,2),o.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(o);const s=new te.StructArrayLayout1ui2;for(const te of[0,1,3,2,0])s.emplaceBack(te);this.debugIndexBuffer=e.createIndexBuffer(s),this.emptyTexture=new te.Texture(e,new te.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=te.create();const a=this.context.gl;this.stencilClearMode=new te.StencilMode({func:a.ALWAYS,mask:0},0,255,a.ZERO,a.ZERO,a.ZERO),this.loadTimeStamps.push(te.window.performance.now()),this.atmosphereBuffer=new kr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,t=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,t.TRIANGLES,te.DepthMode.disabled,this.stencilClearMode,te.ColorMode.disabled,te.CullFaceMode.disabled,wi(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,e,i){if(!e||this.currentStencilSource===e.id||!t.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=e.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(te.ColorMode.disabled),r.setDepthMode(te.DepthMode.disabled);const o=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of i){const i=e.getTile(t),s=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:a,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=this.getTileBoundsBuffers(i);o.draw(r,n.TRIANGLES,te.DepthMode.disabled,new te.StencilMode({func:n.ALWAYS,mask:0},s,255,n.KEEP,n.KEEP,n.REPLACE),te.ColorMode.disabled,te.CullFaceMode.disabled,wi(t.projMatrix),"$clipping",a,l,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new te.StencilMode({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new te.StencilMode({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(t){const i=this.context.gl,e=t.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=e[e.length-1].overscaledZ,n=e[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const t={};for(let e=0;e<n;e++)t[e+r]=new te.StencilMode({func:i.GEQUAL,mask:255},e+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=n,[t,e]}return[{[r]:te.StencilMode.disabled},e]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const t=1/8;return new te.ColorMode([e.CONSTANT_COLOR,e.ONE],new te.Color(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?te.ColorMode.unblended:te.ColorMode.alphaBlended}depthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return te.DepthMode.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new te.DepthMode(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(r,e){this.style=r,this.options=e,this.lineAtlas=r.lineAtlas,this.imageManager=r.imageManager,this.glyphManager=r.glyphManager,this.symbolFadeChange=r.placement.symbolFadeChange(te.exported.now()),this.imageManager.beginFrame();const t=this.style.order,i=this.style._sourceCaches;for(const te in i){const r=i[te];r.used&&r.prepare(this.context)}const n={},o={},s={};for(const te in i){const r=i[te];n[te]=r.getVisibleCoordinates(),o[te]=n[te].slice().reverse(),s[te]=r.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<t.length;e++)if(this.style._layers[t[e]].is3D()){this.opaquePassCutoff=e;break}if(this.terrain&&(this.terrain.updateTileBinding(s),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new te.GlobeSharedBuffers(this.context)),te.isMapAuthenticated(this.context.gl)){this.renderPass="offscreen";for(const te of t){const e=this.style._layers[te],t=r._getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=t?o[t.id]:void 0;("custom"===e.type||e.isSky()||i&&i.length)&&this.renderLayer(this,t,e,i)}if(this.depthRangeFor3D=[0,1-(r.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:e.showOverdrawInspector?te.Color.black:te.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=e.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=t.length-1;this.currentLayer>=0;this.currentLayer--){const te=this.style._layers[t[this.currentLayer]],e=r._getLayerSourceCache(te);if(te.isSky())continue;const i=e?o[e.id]:void 0;this._renderTileClippingMasks(te,e,i),this.renderLayer(this,e,te,i)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,t){const i=e.context,r=i.gl,n=e.transform,o=new te.DepthMode(r.LEQUAL,te.DepthMode.ReadOnly,[0,1]),s=e.useProgram("globeAtmosphere",null,"globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),a=te.globeToMercatorTransition(n.zoom),l=t.properties.get("color").toArray01(),c=t.properties.get("high-color").toArray01(),h=t.properties.get("space-color").toArray01PremultipliedAlpha(),u=te.identity$1([]);te.rotateY$1(u,u,-te.degToRad(n._center.lng)),te.rotateX$1(u,u,te.degToRad(n._center.lat)),te.rotateZ$1(u,u,n.angle),te.rotateX$1(u,u,-n._pitch);const p=te.fromQuat(new Float32Array(16),u),d=te.mapValue(t.properties.get("star-intensity"),0,1,0,.25),f=5e-4,m=te.mapValue(t.properties.get("horizon-blend"),0,1,f,.25),_=te.globeUseCustomAntiAliasing(e,i,n)&&m===f?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,g=e.frameCounter/1e3%1,y=te.length(n.globeCenterInViewSpace),x=Math.sqrt(Math.pow(y,2)-Math.pow(_,2)),v=Math.acos(x/y),b=((e,t,i,r,n,o,s,a,l,c,h,u,p,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_star_intensity:h,u_star_size:5*te.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:u,u_horizon_angle:p,u_rotation_matrix:d}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,a,m,l,c,h,d,g,v,p);e.prepareDrawProgram(i,s);const w=e.atmosphereBuffer;w&&s.draw(i,r.TRIANGLES,o,te.StencilMode.disabled,te.ColorMode.alphaBlended,te.CullFaceMode.backCW,b,"skybox",w.vertexBuffer,w.indexBuffer,w.segments)}(this,this.style.fog),this.renderPass="sky",(te.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<t.length;this.currentLayer++){const te=this.style._layers[t[this.currentLayer]],e=r._getLayerSourceCache(te);te.isSky()&&this.renderLayer(this,e,te,e?o[e.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<t.length;){const te=this.style._layers[t[this.currentLayer]],e=r._getLayerSourceCache(te);if(te.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(te)){if(te.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const i=e?("symbol"===te.type?s:o)[e.id]:void 0;this._renderTileClippingMasks(te,e,e?n[e.id]:void 0),this.renderLayer(this,e,te,i),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let i=null;te.values(this.style._layers).forEach(e=>{const t=r._getLayerSourceCache(e);t&&!e.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)}),i&&this.options.showTileBoundaries&&zr.debug(this,i,i.getVisibleCoordinates())}this.options.showPadding&&function(e){const t=e.transform.padding;br(e,e.transform.height-(t.top||0),3,_r),br(e,t.bottom||0,3,gr),wr(e,t.left||0,3,yr),wr(e,e.transform.width-(t.right||0),3,xr);const i=e.transform.centerPoint;!function(e,t,i,r){Tr(e,t-1,i-10,2,20,r),Tr(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,vr)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(te.window.performance.now()),this.saveCanvasCopy())}}renderLayer(e,t,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)||zr[i.type](e,t,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;let i=this.gpuTimers[e.id];i||(i=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:t.createQueryEXT()}),i.calls++,t.beginQueryEXT(t.TIME_ELAPSED_EXT,i.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=e.createQueryEXT();this.deferredRenderGpuTimeQueries.push(t),e.beginQueryEXT(e.TIME_ELAPSED_EXT,t)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const r=e[i],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),t[i]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery;let i=0;for(const r of e)i+=t.getQueryObjectEXT(r,t.QUERY_RESULT_EXT)/1e6,t.deleteQueryEXT(r);return i}translatePosMatrix(e,t,i,r,n){if(!i[0]&&!i[1])return e;const o=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){const te=Math.sin(o),e=Math.cos(o);i=[i[0]*e-i[1]*te,i[0]*te+i[1]*e]}const s=[n?i[0]:z(t,i[0],this.transform.zoom),n?i[1]:z(t,i[1],this.transform.zoom),0],a=new Float32Array(16);return te.translate(a,e,s),a}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),t&&!e&&0!==t.getOpacity(this.transform.pitch)&&i.push("FOG"),e&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(e,t,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),o=Ii.cacheKey(e,n,t);return this.cache[o]||(this.cache[o]=new Ii(this.context,e,li[e],t,nr[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=te.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new te.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,t,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const n=r.getOpacity(this.transform.pitch),o=((e,t,i,r,n,o,s,a,l,c,h)=>{const u=e.transform,p=t.properties.get("color").toArray01();p[3]=r;const d=e.frameCounter/1e3%1;return{u_fog_matrix:i?u.calculateFogTileMatrix(i):e.identityMat,u_fog_range:t.getFovAdjustedRange(u._fov),u_fog_color:p,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_temporal_offset:d,u_frustum_tl:n,u_frustum_tr:o,u_frustum_br:s,u_frustum_bl:a,u_globe_pos:l,u_globe_radius:c,u_viewport:h,u_globe_transition:te.globeToMercatorTransition(u.zoom),u_is_globe:+("globe"===u.projection.name)}})(this,r,i,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*te.exported.devicePixelRatio,this.transform.height*te.exported.devicePixelRatio]);t.setFogUniformValues(e,o)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new te.Tile(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}}class Lr{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=te.number(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=te.number(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=te.number(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=te.number(e.right,t.right,i)),this}getCenter(e,t){const i=te.clamp((this.left+e-this.right)/2,0,e),r=te.clamp((this.top+t-this.bottom)/2,0,t);return new te.pointGeometry(i,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Lr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Dr(e,t){const i=te.getColumn(e,3);te.fromQuat(e,t),te.setColumn(e,3,i)}function Rr(e,t){const i=te.identity$1([]);return te.rotateZ$1(i,i,-t),te.rotateX$1(i,i,-e),i}function Or(e,t){const i=[e[0],e[1],0],r=[t[0],t[1],0];if(te.length(i)>=1e-15){const e=te.normalize([],i);te.scale$2(r,e,te.dot(r,e)),t[0]=r[0],t[1]=r[1]}const n=te.cross([],t,e);if(te.len(n)<1e-15)return null;const o=Math.atan2(-n[1],n[0]);return Rr(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class Fr{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(e){if(e){const t=e instanceof te.MercatorCoordinate?e:new te.MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=te.wrap(t.x,0,1)),this._position=t}else this._position=null}lookAtPoint(e,t){if(this.orientation=null,!this.position)return;const i=this._elevation?this._elevation.getAtPointOrZero(te.MercatorCoordinate.fromLngLat(e)):0,r=this.position,n=te.MercatorCoordinate.fromLngLat(e,i),o=[n.x-r.x,n.y-r.y,n.z-r.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Or(o,t)}setPitchBearing(e,t){this.orientation=Rr(te.degToRad(e),te.degToRad(-t))}}class Nr{constructor(e,t){this._transform=te.identity([]),this.orientation=t,this.position=e}get mercatorPosition(){const e=this.position;return new te.MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=te.getColumn(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var t;e&&te.setColumn(this._transform,3,[(t=e)[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||te.identity$1([]),e&&Dr(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Rr(e,t),Dr(this._transform,this._orientation)}forward(){const e=te.getColumn(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=te.getColumn(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=te.getColumn(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,t){const i=new Float64Array(16);return te.invert(i,this.getWorldToCamera(e,t)),i}getWorldToCameraPosition(e,t,i){const r=this.position;te.scale$2(r,r,-e);const n=new Float64Array(16);return te.fromScaling(n,[i,i,i]),te.translate(n,n,r),n[10]*=t,n}getWorldToCamera(e,t){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;return te.conjugate(r,this._orientation),te.scale$2(n,n,-e),te.fromQuat(i,r),te.translate(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=t,i[9]*=t,i[10]*=t,i[11]*=t,i}getCameraToClipPerspective(e,t,i,r){const n=new Float64Array(16);return te.perspective(n,e,t,i,r),n}getDistanceToElevation(e){const t=0===e?0:te.mercatorZfromAltitude(e,this.position[1]),i=this.forward();return(t-this.position[2])/i[2]}clone(){return new Nr([...this.position],[...this.orientation])}}function Ur(e,t){const i=Vr(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new te.LngLat(i.lng-180*Gr,i.lat),s=new te.LngLat(i.lng+180*Gr,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=te.MercatorCoordinate.fromLngLat(i);h.y=te.clamp(h.y,-.999975,.999975);const u=h.toLngLat(),p=e.project(u.lng,u.lat),d=te.MercatorCoordinate.fromLngLat(u);d.x+=Gr;const f=d.toLngLat(),m=e.project(f.lng,f.lat),_=qr(m.x-p.x,m.y-p.y,c),g=te.MercatorCoordinate.fromLngLat(u);g.y+=Gr;const y=g.toLngLat(),x=e.project(y.lng,y.lat),v=qr(x.x-p.x,x.y-p.y,c),b=Math.abs(_.x)/Math.abs(v.y),w=te.identity([]);te.rotateZ(w,w,-c*(1-(n?0:r)));const T=te.identity([]);return te.scale(T,T,[1,1-(1-b)*r,1]),T[4]=-v.x/v.y*r,te.rotateZ(T,T,c),te.multiply(T,w,T),T}(e.projection,0,e.center,i,t),n=jr(e);return te.scale(r,r,[n,n,1]),r}function jr(e){const t=e.projection,i=Vr(e.projection,e.zoom,e.width,e.height),r=$r(t,e.center),n=$r(t,te.LngLat.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function Vr(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const s=Math.min(n,Math.max(i,r)),a=Math.log(s/1024)/Math.LN2;return te.smoothstep(o[0]+a,o[1]+a,t)}const Gr=1/4e4;function $r(e,t){const i=te.clamp(t.lat,-te.MAX_MERCATOR_LATITUDE,te.MAX_MERCATOR_LATITUDE),r=new te.LngLat(t.lng-180*Gr,i),n=new te.LngLat(t.lng+180*Gr,i),o=e.project(r.lng,i),s=e.project(n.lng,i),a=te.MercatorCoordinate.fromLngLat(r),l=te.MercatorCoordinate.fromLngLat(n),c=s.x-o.x,h=s.y-o.y,u=l.x-a.x,p=l.y-a.y,d=Math.sqrt((u*u+p*p)/(c*c+h*h));return Math.log(d)/Math.LN2}function qr(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}class Zr{constructor(e,t,i,r,n,o,s){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(o),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new te.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Lr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Nr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Zr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e){const t=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||t)&&this._updateCameraOnTerrain(),(e||t)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return te.pick(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=te.getProjection(this.projectionOptions);const i=!_(t,this.getProjection());return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return te.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new te.pointGeometry(this.width,this.height)}get bearing(){return te.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;var i;this.angle!==t&&(this._unmodified=!1,this.angle=t,this._calcMatrices(),this.rotationMatrix=(i=new te.ARRAY_TYPE(4),te.ARRAY_TYPE!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=r*l+o*a,e[1]=n*l+s*a,e[2]=r*-a+o*l,e[3]=n*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=te.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let n=0,o=0;for(let e=0;e<i.length;e++){const s=new te.pointGeometry(i[e][0]*this.width,r+i[e][1]*(this.height-r)),a=t.pointCoordinate(s);if(!a)continue;const l=1/Math.hypot(a[0]-this._camera.position[0],a[1]-this._camera.position[1]);n+=a[3]*l,o+=l}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,r=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(e){const t=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[t.x,t.y,t.z]:[e.x,e.y,e.z];const r=te.length(te.sub([],this._camera.position,i));return te.clamp(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let t=!1;if(e.orientation&&!te.exactEquals(e.orientation,this._camera.orientation)&&(t=this._setCameraOrientation(e.orientation)),e.position){const i=[e.position.x,e.position.y,e.position.z];te.exactEquals$1(i,this._camera.position)||(this._setCameraPosition(i),t=!0)}t&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,t=new Fr;return t.position=new te.MercatorCoordinate(e[0],e[1],e[2]),t.orientation=this._camera.orientation,t._elevation=this.elevation,t._renderWorldCopies=this.renderWorldCopies,t}_setCameraOrientation(e){if(!te.length$1(e))return!1;te.normalize$1(e,e);const t=te.transformQuat([],[0,0,-1],e),i=te.transformQuat([],[0,-1,0],e);if(i[2]<0)return!1;const r=Or(t,i);return!!r&&(this._camera.orientation=r,!0)}_setCameraPosition(e){const t=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;e[2]=te.clamp(e[2],r/i,r/t),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const i=[new te.UnwrappedTileID(0,t)];if(this.renderWorldCopies){const e=this.pointCoordinate(new te.pointGeometry(0,0)),r=this.pointCoordinate(new te.pointGeometry(this.width,0)),n=this.pointCoordinate(new te.pointGeometry(this.width,this.height)),o=this.pointCoordinate(new te.pointGeometry(0,this.height)),s=Math.floor(Math.min(e.x,r.x,n.x,o.x)),a=Math.floor(Math.max(e.x,r.x,n.x,o.x)),l=1;for(let e=s-l;e<=a+l;e++)0!==e&&i.push(new te.UnwrappedTileID(e,t))}return i}coveringTiles(a){let l=this.coveringZoomLevel(a);const c=l,s=this.elevation&&!a.isTerrainDEM,r="mercator"===this.projection.name;if(void 0!==a.minzoom&&l<a.minzoom)return[];void 0!==a.maxzoom&&l>a.maxzoom&&(l=a.maxzoom);const i=this.locationCoordinate(this.center),h=this.center.lat,n=1<<l,o=[n*i.x,n*i.y,0],u="globe"===this.projection.name,e=!u,p=te.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,l,e),t=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),d=n*te.mercatorZfromAltitude(1,this.center.lat),f=this._camera.position[2]/te.mercatorZfromAltitude(1,this.center.lat),m=[n*t.x,n*t.y,f*(e?1:d)],_=this.cameraToCenterDistance/a.tileSize*(a.roundZoom?1:.502),g=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?l:0,y=a.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,x=a.isTerrainDEM?-y:this._elevation?this._elevation.getMinElevationBelowMSL():0,v=this.projection.isReprojectedInTileSpace?jr(this):1,b=e=>{const t=1/4e4,i=new te.MercatorCoordinate(e.x+t,e.y,e.z),r=new te.MercatorCoordinate(e.x,e.y+t,e.z),n=e.toLngLat(),o=i.toLngLat(),s=r.toLngLat(),a=this.locationCoordinate(n),l=this.locationCoordinate(o),c=this.locationCoordinate(s),h=Math.hypot(l.x-a.x,l.y-a.y),u=Math.hypot(c.x-a.x,c.y-a.y);return Math.sqrt(h*u)*v/t},w=e=>{const t=y,i=x;return{aabb:te.tileAABB(this,n,0,0,0,e,i,t,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:t,wrap:e,fullyVisible:!1}},T=[];let E=[];const A=l,S=a.reparseOverscaled?c:l,C=e=>e*e,M=C((f-this._centerAltitude)*d),I=e=>{if(!this._elevation||!e.tileID||!r)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=B(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},B=e=>{if(e.zoom<g)return!0;if(e.zoom===A)return!1;if(null!=e.shouldSplit)return e.shouldSplit;const t=e.aabb.distanceX(m),i=e.aabb.distanceY(m);let r=M,n=1;if(u){r=C(e.aabb.distanceZ(m));const t=Math.pow(2,e.zoom),c=te.latFromMercatorY((e.y+1)/t),s=te.latFromMercatorY(e.y/t),i=Math.min(Math.max(h,c),s),o=te.circumferenceAtLatitude(i)/te.circumferenceAtLatitude(h);if(n=i===h?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,o/this._mercatorScaleRatio),this.zoom<=te.GLOBE_ZOOM_THRESHOLD_MIN&&e.zoom===A-1&&o>=.9)return!0}else if(s&&(r=C(e.aabb.distanceZ(m)*d)),this.projection.isReprojectedInTileSpace&&c<=5){const t=Math.pow(2,e.zoom),c=b(new te.MercatorCoordinate((e.x+.5)/t,(e.y+.5)/t));n=c>.85?1:c}const o=t*t+i*i+r;return o<C((1<<A-e.zoom)*_*n*((e,t)=>{if(t*C(.707)<e)return 1;const i=Math.sqrt(t/e);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(r,M),o))};if(this.renderWorldCopies)for(let e=1;e<=3;e++)T.push(w(-e)),T.push(w(e));for(T.push(w(0));T.length>0;){const c=T.pop(),i=c.x,h=c.y;let t=c.fullyVisible;if(!t){const te=c.aabb.intersects(p);if(0===te)continue;t=2===te}if(c.zoom!==A&&B(c))for(let e=0;e<4;e++){const l=(i<<1)+e%2,o=(h<<1)+(e>>1),p={aabb:r?c.aabb.quadrant(e):te.tileAABB(this,n,c.zoom+1,l,o,c.wrap,c.minZ,c.maxZ,this.projection),zoom:c.zoom+1,x:l,y:o,wrap:c.wrap,fullyVisible:t,tileID:void 0,shouldSplit:void 0,minZ:c.minZ,maxZ:c.maxZ};s&&!u&&(p.tileID=new te.OverscaledTileID(c.zoom+1===A?S:c.zoom+1,c.wrap,c.zoom+1,l,o),I(p)),T.push(p)}else{const s=c.zoom===A?S:c.zoom;if(a.minzoom&&a.minzoom>s)continue;const r=o[0]-(.5+i+(c.wrap<<c.zoom))*(1<<l-c.zoom),n=o[1]-.5-h,u=c.tileID?c.tileID:new te.OverscaledTileID(s,c.wrap,c.zoom,i,h);E.push({tileID:u,distanceSq:r*r+n*n})}}if(this.fogCullDistSq){const l=this.fogCullDistSq,c=this.horizonLineFromTop();E=E.filter(t=>{const e=[0,0,0,1],i=[te.EXTENT,te.EXTENT,0,1],r=this.calculateFogTileMatrix(t.tileID.toUnwrapped());te.transformMat4$1(e,e,r),te.transformMat4$1(i,i,r);const n=te.getAABBPointSquareDist(e,i);if(0===n)return!0;let o=!1;const s=this._elevation;if(s&&n>l&&0!==c){const l=this.calculateProjMatrix(t.tileID.toUnwrapped());let e;a.isTerrainDEM||(e=s.getMinMaxForTile(t.tileID)),e||(e={min:x,max:y});const i=te.furthestTileCorner(this.rotation),r=[i[0]*te.EXTENT,i[1]*te.EXTENT,e.max];te.transformMat4(r,r,l),o=(1-r[1])*this.height*.5<c}return n<l||o})}return E.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const t=te.clamp(e.lat,-te.MAX_MERCATOR_LATITUDE,te.MAX_MERCATOR_LATITUDE),i=this.projection.project(e.lng,t);return new te.pointGeometry(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,t){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const te=this.worldSize;i=(t.x-n.x)/te,r=(t.y-n.y)/te}else{const te=this.pointCoordinate(t),e=this.pointCoordinate(n);i=te.x-e.x,r=te.y-e.y}const o=this.locationCoordinate(e);this.setLocation(new te.MercatorCoordinate(o.x-i,o.y-r))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(e,t){const i=t?te.mercatorZfromAltitude(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new te.MercatorCoordinate(r.x,r.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const i=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];te.transformMat4$1(r,r,this.pixelMatrixInverse),te.transformMat4$1(n,n,this.pixelMatrixInverse);const o=n[3];te.scale$1(r,r,1/r[3]),te.scale$1(n,n,1/o);const s=r[2],a=n[2];return{p0:r,p1:n,t:s===a?0:(i-s)/(a-s)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return te.transformMat4$1(t,t,this.pixelMatrixInverse),te.transformMat4$1(i,i,this.pixelMatrixInverse),te.scale$1(t,t,1/t[3]),te.scale$1(i,i,1/i[3]),t[2]=te.mercatorZfromAltitude(t[2],this._center.lat)*this.worldSize,i[2]=te.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,te.scale$1(t,t,1/this.worldSize),te.scale$1(i,i,1/this.worldSize),new te.Ray([t[0],t[1],t[2]],te.normalize([],te.sub([],i,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:i,t:r}=e,n=te.mercatorZfromAltitude(t[2],this._center.lat),o=te.mercatorZfromAltitude(i[2],this._center.lat);return new te.MercatorCoordinate(te.number(t[0],i[0],r)/this.worldSize,te.number(t[1],i[1],r)/this.worldSize,te.number(n,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new te.MercatorCoordinate(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const o=.02*n,s=t.clone();for(let e=0;e<10&&n-r>o;e++){s.y=te.number(r,n,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,i=t):r=s.y}return i?new te.MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(e,t){const i=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return te.transformMat4$1(r,r,this.pixelMatrix),r[3]>0?new te.pointGeometry(r[0]/r[3],r[1]/r[3]):new te.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(e,t){const i=new te.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),r=new te.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),n=new te.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),o=new te.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let s=this.pointCoordinate(i,e),a=this.pointCoordinate(r,e);const l=this.pointCoordinate(n,t),c=this.pointCoordinate(o,t),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return s.y>1&&a.y>=0?s=new te.MercatorCoordinate((1-c.y)/h(c,s)+c.x,1):s.y<0&&a.y<=1&&(s=new te.MercatorCoordinate(-c.y/h(c,s)+c.x,0)),a.y>1&&s.y>=0?a=new te.MercatorCoordinate((1-l.y)/h(l,a)+l.x,1):a.y<0&&s.y<=1&&(a=new te.MercatorCoordinate(-l.y/h(l,a)+l.x,0)),(new te.LngLatBounds).extend(this.coordinateLocation(s)).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(l))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length)return this._getBounds(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-te.MAX_MERCATOR_LATITUDE,this.maxLat=te.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=te.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=te.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=te.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=te.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(e){const t=e.key,i=this._distanceTileDataCache;if(i[t])return i[t];const r=e.canonical,n=1/this.height,o=this.cameraWorldSize/this.zoomScale(r.z),s=(r.x+Math.pow(2,r.z)*e.wrap)*o,a=r.y*o,l=this.point,c=this.angle,h=Math.sin(-c),u=-Math.cos(-c);return i[t]={bearing:[h,u],center:[(l.x-s)*n,(l.y-a)*n],scale:o/te.EXTENT*n},i[t]}calculateFogTileMatrix(e){const t=e.key,i=this._fogTileMatrixCache;if(i[t])return i[t];const r=this.projection.createTileMatrix(this,this.cameraWorldSize,e);return te.multiply(r,this.worldToFogMatrix,r),i[t]=new Float32Array(r),i[t]}calculateProjMatrix(e,t=!1){const i=e.key,r=t?this._alignedProjMatrixCache:this._projMatrixCache;if(r[i])return r[i];const n=this.calculatePosMatrix(e,this.worldSize);return te.multiply(n,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:t?this.alignedProjMatrix:this.projMatrix,n),r[i]=new Float32Array(n),r[i]}calculatePixelsToTileUnitsMatrix(e){const t=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[t])return i[t];const r=function(e,t){const{scale:i}=e.tileTransform,r=i*te.EXTENT/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return n=new Float32Array(4),a=(o=t.inverseAdjustmentMatrix)[1],l=o[2],c=o[3],u=(s=[r,r])[1],n[0]=o[0]*(h=s[0]),n[1]=a*h,n[2]=l*u,n[3]=c*u,n;var n,o,s,a,l,c,h,u}(e,this);return i[t]=r,i[t]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const t=te.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=this._camera.forward(),n=te.mercatorZfromAltitude(1,this._center.lat);i[2]/=n,r[2]/=n,te.normalize(r,r);const o=e.raycast(i,r,e.exaggeration());if(o){const e=te.scaleAndAdd([],i,r,o),t=new te.MercatorCoordinate(e[0],e[1],te.mercatorZfromAltitude(e[2],te.latFromMercatorY(e[1]))),s=(t.z+te.length([t.x-i[0],t.y-i[1],t.z-i[2]*n]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(s),this._centerAltitude=t.toAltitude(),this._center=this.coordinateLocation(t),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const e=this._elevation;this._updateCameraState();const t=te.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=e.getAtPointOrZero(new te.MercatorCoordinate(...i)),n=this._minimumHeightOverTerrain()*Math.cos(te.degToRad(this._maxPitch)),o=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*r;if(o<n){const e=this.locationCoordinate(this._center,this._centerAltitude),t=[e.x-i[0],e.y-i[1],e.z-i[2]],r=te.length(t);t[2]-=(n-o)/this._projectionScaler;const s=te.length(t);if(0===s)return;te.scale$2(t,t,r/s*this._projectionScaler),this._camera.position=[e.x-t[0],e.y-t[1],e.z*this._projectionScaler-t[2]],this._camera.orientation=Or(t,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const e=this.center;return e.lat=te.clamp(e.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(e.lng=te.clamp(e.lng,this.minLng,this.maxLng)),this.center=e,void(this._constraining=!1)}const e=this._unmodified,{x:t,y:i}=this.point;let r=0,n=t,o=i;const s=this.width/2,a=this.height/2,l=this.worldMinY*this.scale,c=this.worldMaxY*this.scale;if(i-a<l&&(o=l+a),i+a>c&&(o=c-a),c-l<this.height&&(r=Math.max(r,this.height/(c-l)),o=(c+l)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const te=this.worldMinX*this.scale,e=this.worldMaxX*this.scale,i=this.worldSize/2-(te+e)/2;n=(t+i+this.worldSize)%this.worldSize-i,n-s<te&&(n=te+s),n+s>e&&(n=e-s),e-te<this.width&&(r=Math.max(r,this.width/(e-te)),n=(e+te)/2)}n===t&&o===i||(this.center=this.unproject(new te.pointGeometry(n,o))),r&&(this.zoom+=this.scaleZoom(r)),this._constrainCameraAltitude(),this._unmodified=e,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,t=this.pixelsPerMeter;if("globe"===this.projection.name){const e=te.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,t=te.mercatorZfromAltitude(1,te.GLOBE_SCALE_MATCH_LATITUDE)*this.worldSize;this._mercatorScaleRatio=e/t}const i=Vr(this.projection,this.zoom,this.width,this.height,1024);this._projectionScaler=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,i),this.cameraToCenterDistance=this.getCameraToCenterDistance(this.projection),this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const r=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?t:1),n=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);n[8]=2*-e.x/this.width,n[9]=2*e.y/this.height;let o=te.mul([],n,r);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=te.identity([]);te.translate(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),te.multiply(t,t,Ur(this)),te.translate(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),te.multiply(o,o,t),this.inverseAdjustmentMatrix=function(e){const t=Ur(e,!0);return v([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=te.scale([],o,[this.worldSize,this.worldSize,this.worldSize/t,1]),this.projMatrix=o,this.invProjMatrix=te.invert(new Float64Array(16),this.projMatrix);const s=te.invert([],n);this.frustumCorners=te.FrustumCorners.fromInvProjectionMatrix(s,this.horizonLineFromTop(),this.height);const a=new Float32Array(16);te.identity(a),te.scale(a,a,[1,-1,1]),te.rotateX(a,a,this._pitch),te.rotateZ(a,a,this.angle);const l=te.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),c=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;l[8]=2*-e.x/this.width,l[9]=2*(e.y+c)/this.height,this.skyboxMatrix=te.multiply(a,l,a);const h=this.point,u=h.x,p=h.y,d=this.width%2/2,f=this.height%2/2,m=Math.cos(this.angle),_=Math.sin(this.angle),g=u-Math.round(u)+m*d+_*f,y=p-Math.round(p)+m*f+_*d,x=new Float64Array(o);if(te.translate(x,x,[g>.5?g-1:g,y>.5?y-1:y,0]),this.alignedProjMatrix=x,o=te.create(),te.scale(o,o,[this.width/2,-this.height/2,1]),te.translate(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=te.create(),te.scale(o,o,[1,-1,1]),te.translate(o,o,[-1,-1,0]),te.scale(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o,this.pixelMatrix=te.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},o=te.invert(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=o,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=te.calculateGlobeMatrix(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=te.transformMat4(e,e,r),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=o;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,t=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height/this._projectionScaler,n=[e,e,t];te.scale$2(n,n,r),te.scale$2(i,i,-1),te.multiply$2(i,i,n);const o=te.create();te.translate(o,o,i),te.scale(o,o,n),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=e[2];let r=1;i>0&&(r=Math.min((t-this._camera.position[2])/i,1)),this._camera.position=te.scaleAndAdd([],this._camera.position,e,r),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=te.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(te.degToRad(this._maxPitch)),s=Math.max((e[2]-n)/Math.cos(i),o),a=this._zoomFromMercatorZ(s);te.scaleAndAdd(e,e,t,s),this._pitch=te.clamp(i,te.degToRad(this.minPitch),te.degToRad(this.maxPitch)),this.angle=te.wrap(r,-Math.PI,Math.PI),this._setZoom(te.clamp(a,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new te.MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(te.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,t){const i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.y,t.y),o=Math.max(e.y,t.y);if(n<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const s=[new te.pointGeometry(i,n),new te.pointGeometry(r,o),new te.pointGeometry(i,o),new te.pointGeometry(r,n)],a=this.renderWorldCopies?-3:0,l=this.renderWorldCopies?4:1;for(const te of s){const e=this.pointRayIntersection(te);if(e.t<0)return!0;const t=this.rayIntersectionCoordinate(e);if(t.x<a||t.y<0||t.x>l||t.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+te.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new te.pointGeometry(0,0),new te.pointGeometry(this.width,this.height))}zoomDeltaToMovement(e,t){const i=te.length(te.sub([],this._camera.position,e)),r=this._zoomFromMercatorZ(i)+t;return i-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function(e,t){const i=[e[0],e[1],e[2],1];te.transformMat4$1(i,i,t);const r=Math.max(i[3],1e-6);return[i[0]/r,i[1]/r,i[2]/r,r]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new te.pointGeometry(e[0],e[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new te.pointGeometry(0,t))}}getCameraToCenterDistance(e){const t=Vr(e,this.zoom,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,this.worldSize,t);return.5/Math.tan(.5*this._fov)*this.height*i}}function Yr(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class Wr{constructor(e){this._hashName=e&&encodeURIComponent(e),te.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Yr(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,te.window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),te.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(r){const e=this._map;if(!e)return"";const t=e.getCenter(),i=Math.round(100*e.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(t.lng*o)/o,a=Math.round(t.lat*o)/o,l=e.getBearing(),c=e.getPitch();let h="";if(h+=r?`/${s}/${a}/${i}`:`${i}/${a}/${s}`,(l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),this._hashName){const r=this._hashName;let i=!1;const t=te.window.location.hash.slice(1).split("&").map(e=>{const t=e.split("=")[0];return t===r?(i=!0,`${t}=${h}`):e}).filter(e=>e);return i||t.push(`${r}=${h}`),`#${t.join("&")}`}return`#${h}`}_getCurrentHash(){const e=te.window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e)}),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(e))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const e=te.window.location.href.replace(/(#.+)?$/,this.getHashString());te.window.history.replaceState(te.window.history.state,null,e)}}const Xr={linearity:.3,easing:te.bezier(0,0,.3,1)},Hr=te.extend({deceleration:2500,maxSpeed:1400},Xr),Kr=te.extend({deceleration:20,maxSpeed:1400},Xr),Jr=te.extend({deceleration:1e3,maxSpeed:360},Xr),Qr=te.extend({deceleration:1e3,maxSpeed:90},Xr);class en{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:te.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=te.exported.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new te.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:te}of this._inertiaBuffer)t.zoom+=te.zoomDelta||0,t.bearing+=te.bearingDelta||0,t.pitch+=te.pitchDelta||0,te.panDelta&&t.pan._add(te.panDelta),te.around&&(t.around=te.around),te.pinchAround&&(t.pinchAround=te.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(t.pan.mag()){const n=rn(t.pan.mag(),i,te.extend({},Hr,e||{}));r.offset=t.pan.mult(n.amount/t.pan.mag()),r.center=this._map.transform.center,tn(r,n)}if(t.zoom){const te=rn(t.zoom,i,Kr);r.zoom=this._map.transform.zoom+te.amount,tn(r,te)}if(t.bearing){const e=rn(t.bearing,i,Jr);r.bearing=this._map.transform.bearing+te.clamp(e.amount,-179,179),tn(r,e)}if(t.pitch){const te=rn(t.pitch,i,Qr);r.pitch=this._map.transform.pitch+te.amount,tn(r,te)}if(r.zoom||r.bearing){const te=void 0===t.pinchAround?t.around:t.pinchAround;r.around=te?this._map.unproject(te):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function tn(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function rn(e,t,i){const{maxSpeed:r,linearity:n,deceleration:o}=i,s=te.clamp(e*n/(t/1e3),-r,r),a=Math.abs(s)/(o*n);return{easing:i.easing,duration:1e3*a,amount:s*(a/2)}}class nn extends te.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){const n=p(t.getCanvasContainer(),i),o=t.unproject(n);super(e,te.extend({point:n,lngLat:o,originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}}class on extends te.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){const r="touchend"===e?i.changedTouches:i.touches,n=d(t.getCanvasContainer(),r),o=n.map(e=>t.unproject(e)),s=n.reduce((e,t,i,r)=>e.add(t.div(r.length)),new te.pointGeometry(0,0));super(e,{points:n,point:s,lngLats:o,lngLat:t.unproject(s),originalEvent:i}),this._defaultPrevented=!1}}class sn extends te.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class an{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new sn(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new nn(e.type,this._map,e))}mouseup(e){this._map.fire(new nn(e.type,this._map,e))}preclick(e){const t=te.extend({},e);t.type="preclick",this._map.fire(new nn(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new nn(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new nn(e.type,this._map,e))}mouseover(e){this._map.fire(new nn(e.type,this._map,e))}mouseout(e){this._map.fire(new nn(e.type,this._map,e))}touchstart(e){return this._firePreventable(new on(e.type,this._map,e))}touchmove(e){this._map.fire(new on(e.type,this._map,e))}touchend(e){this._map.fire(new on(e.type,this._map,e))}touchcancel(e){this._map.fire(new on(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ln{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new nn(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new nn("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new nn(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cn{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(a(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=l("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),s=Math.min(r.y,i.y),a=Math.max(r.y,i.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${n}px,${s}px)`,this._box.style.width=o-n+"px",this._box.style.height=a-s+"px")})}mouseupWindow(e,t){if(!this._active)return;if(0!==e.button)return;const i=this._startPos,r=t;if(this.reset(),u(),i.x!==r.x||i.y!==r.y)return this._map.fire(new te.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),c(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new te.Event(e,{originalEvent:t}))}}function hn(t,i){const r={};for(let e=0;e<t.length;e++)r[t[e].identifier]=i[e];return r}class un{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){const t=new te.pointGeometry(0,0);for(const te of e)t._add(te);return t.div(e.length)}(t),this.touches=hn(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=hn(i,t);for(const e in this.touches){const t=this.touches[e],i=r[e];(!i||i.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class pn{constructor(e){this.singleTap=new un(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class dn{constructor(){this._zoomIn=new pn({numTouches:1,numTaps:2}),this._zoomOut=new pn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(n)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const fn={0:1,2:2};class mn{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=f(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=fn[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&f(e)===this._eventButton&&(this._moved&&u(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _n extends mn{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class gn extends mn{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){e.preventDefault()}}class yn extends mn{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){e.preventDefault()}}class xn{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset(),te.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new te.pointGeometry(0,0)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);const r=hn(i,t),n=new te.pointGeometry(0,0),o=new te.pointGeometry(0,0);let s=0;for(const te in r){const e=r[te],t=this._touches[te];t&&(n._add(e),o._add(e.sub(t)),s++,r[te]=e)}if(this._touches=r,s<this._minTouches||!o.mag())return;const a=o.div(s);return this._sum._add(a),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(s),panDelta:a}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class vn{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=bn(i,t,n),a=bn(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=bn(i,t,r),s=bn(i,t,n);o&&s||(this._active&&u(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function bn(t,i,r){for(let e=0;e<t.length;e++)if(t[e].identifier===r)return i[e]}function wn(e,t){return Math.log(e/t)/Math.LN2}class Tn extends vn{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(wn(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:wn(this._distance,i),pinchAround:t}}}function En(e,t){return 180*e.angleWith(t)/Math.PI}class An extends vn{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:En(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=En(e,this._startVector);return Math.abs(i)<t}}function Sn(e){return Math.abs(e.y)>Math.abs(e.x)}class Cn extends vn{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Sn(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){const r=this._lastPoints;if(!r)return;const n=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Sn(e)&&Sn(t)&&o}}const Mn={panStep:100,bearingStep:15,pitchStep:10};class In{constructor(){const e=Mn;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(i){if(i.altKey||i.ctrlKey||i.metaKey)return;let r=0,n=0,o=0,s=0,a=0;switch(i.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:i.shiftKey?n=-1:(i.preventDefault(),s=-1);break;case 39:i.shiftKey?n=1:(i.preventDefault(),s=1);break;case 38:i.shiftKey?o=1:(i.preventDefault(),a=-1);break;case 40:i.shiftKey?o=-1:(i.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(n=0,o=0),{cameraAnimation:e=>{const t=e.getZoom();e.easeTo({duration:300,easeId:"keyboardHandler",easing:Bn,zoom:r?Math.round(t)+r*(i.shiftKey?2:1):t,bearing:e.getBearing()+n*this._bearingStep,pitch:e.getPitch()+o*this._pitchStep,offset:[-s*this._panStep,-a*this._panStep],center:e.getCenter()},{originalEvent:i})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Bn(e){return e*(2-e)}const kn=4.000244140625;class zn{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,te.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let t=e.deltaMode===te.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=te.exported.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%kn==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=p(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform,i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const te="wheel"===this._type&&Math.abs(this._delta)>kn?this._wheelZoomRate:this._defaultZoomRate;let e=2/(1+Math.exp(-Math.abs(this._delta*te)));this._delta<0&&0!==e&&(e=1/e);const r=i(),n=Math.pow(2,r),o="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):n;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(o*e))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const e="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,n=this._easing;let o,s=!1;if("wheel"===this._type&&r&&n){const t=Math.min((te.exported.now()-this._lastWheelEventTime)/200,1),i=n(t);o=te.number(r,e,i),t<1?this._frameId||(this._frameId=!0):s=!0}else o=e,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=te.ease;if(this._prevEase){const e=this._prevEase,i=(te.exported.now()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01,o=Math.sqrt(.0729-n*n);t=te.bezier(n,o,.25,1)}return this._prevEase={start:te.exported.now(),duration:e,easing:t},t}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(te.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!te.window.document.fullscreenElement||!!te.window.document.webkitFullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class Pn{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ln{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,i){return t.preventDefault(),{cameraAnimation:e=>{e.easeTo({duration:300,zoom:e.getZoom()+(t.shiftKey?-1:1),around:e.unproject(i)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dn{constructor(){this._tap=new pn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Rn{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class On{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Fn{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Nn=e=>e.zoom||e.drag||e.pitch||e.rotate;class Un extends te.Event{}class jn{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,t){const i=te.sub([],t,e);this.radius=te.length(i[2]<0?te.div([],i,this.constants):[i[0],i[1],0])}projectRay(e){te.div(e,e,this.constants),te.normalize(e,e),te.mul$1(e,e,this.constants);const t=te.scale$2([],e,this.radius);if(t[2]>0){const e=te.scale$2([],[0,0,1],te.dot(t,[0,0,1])),i=te.scale$2([],te.normalize([],[t[0],t[1],0]),this.radius),r=te.add([],t,te.scale$2([],te.sub([],te.add([],i,e),t),2));t[0]=r[0],t[1]=r[1]}return t}}function Vn(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Gn{constructor(e,t){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new en(e),this._bearingSnap=t.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new jn,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(t),te.bindAll(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[te.window.document,"mousemove",{capture:!0}],[te.window.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[te.window,"blur",void 0]];for(const[e,t,i]of this._listeners)e.addEventListener(t,e===te.window.document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)e.removeEventListener(t,e===te.window.document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new an(t,e));const r=t.boxZoom=new cn(t,e);this._add("boxZoom",r);const n=new dn,o=new Ln;t.doubleClickZoom=new Pn(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new Dn;this._add("tapDragZoom",s);const a=t.touchPitch=new Cn(t);this._add("touchPitch",a);const l=new gn(e),c=new yn(e);t.dragRotate=new On(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new _n(e),u=new xn(t,e);t.dragPan=new Rn(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const p=new An,d=new Tn;t.touchZoomRotate=new Fn(i,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ln(t));const f=t.scrollZoom=new zn(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new In;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i])}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Nn(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(t,i){this._updatingCamera=!0;const r="renderFrame"===t.type,n=r?void 0:t,o={needsRenderFrame:!1},s={},a={},l=t.touches?this._getMapTouches(t.touches):void 0,c=l?d(this._el,l):r?void 0:p(this._el,t);for(const{handlerName:r,handler:h,allowed:u}of this._handlers){if(!h.isEnabled())continue;let e;this._blockedByActive(a,u,r)?h.reset():h[i||t.type]&&(e=h[i||t.type](t,c,l),this.mergeHandlerResult(o,s,e,r,n),e&&e.needsRenderFrame&&this._triggerRenderFrame()),(e||h.isActive())&&(a[r]=h)}const h={};for(const t in this._previousActiveHandlers)a[t]||(h[t]=n);this._previousActiveHandlers=a,(Object.keys(h).length||Vn(o))&&(this._changes.push([o,s,h]),this._triggerRenderFrame()),(Object.keys(a).length||Vn(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=o;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,r,n){if(!i)return;te.extend(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o)}_applyChanges(){const e={},t={},i={};for(const[r,n,o]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new te.pointGeometry(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),te.extend(t,n),te.extend(i,o);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){const r=this._map,n=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Vn(e)){const te=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",te!==n.zoom&&this._map._update(!0)}if(!Vn(e))return void this._fireEvents(t,i,!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,around:h,aroundCoord:u,pinchAround:p}=e;void 0!==p&&(h=p),(e=>t.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=o(n.pointCoordinate3D(h)),this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const d=[0,0,0];if(s){const e=n.pointCoordinate(h);if("globe"===n.projection.name){const t=te.latFromMercatorY(e.y),i=n.center.lat,r=Math.min(te.mercatorZfromAltitude(1,t)/te.mercatorZfromAltitude(1,i),2);s=s.rotate(-n.angle),d[0]=-s.x/n.worldSize*r,d[1]=-s.y/n.worldSize*r}else{const te=n.pointCoordinate(h.sub(s));e&&te&&(d[0]=te.x-e.x,d[1]=te.y-e.y)}}const f=n.zoom,m=[0,0,0];if(a){const e=o(u||n.pointCoordinate3D(h)),t={dir:te.normalize([],te.sub([],e,n._camera.position))};if(t.dir[2]<0){const i=n.zoomDeltaToMovement(e,a);te.scale$2(m,t.dir,i)}}const _=te.add(d,d,m);n._translateCameraConstrained(_),a&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_fireEvents(e,t,i){const r=Nn(this._eventsInProgress),n=Nn(e),o={};for(const te in e){const{originalEvent:t}=e[te];this._eventsInProgress[te]||(o[`${te}start`]=t),this._eventsInProgress[te]=e[te]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const te in o)this._fireEvent(te,o[te]);n&&this._fireEvent("move",n.originalEvent);for(const te in e){const{originalEvent:t}=e[te];this._fireEvent(te,t)}const s={};let a;for(const te in this._eventsInProgress){const{handlerName:e,originalEvent:i}=this._eventsInProgress[te];this._handlersById[e].isActive()||(delete this._eventsInProgress[te],a=t[e]||i,s[`${te}end`]=a)}for(const te in s)this._fireEvent(te,s[te]);const l=Nn(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;e?(t(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:a})):(this._map.fire(new te.Event("moveend",{originalEvent:a})),t(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new te.Event(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{this._frameId=void 0,this.handleEvent(new Un("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const $n="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class qn extends te.Evented{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,te.bindAll(["_renderFrameCallback"],this)}getCenter(){return new te.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,i){return e=te.pointGeometry.convert(e).mult(-1),this.panTo(this.transform.center,te.extend({offset:e},t),i)}panTo(e,t,i){return this.easeTo(te.extend({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(te.extend({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(te.extend({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,te.extend({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(te.extend({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(e,t){"globe"===this.transform.projection.name&&te.warnOnce('Globe projection does not support cameraForBounds API, this API may behave unexpectedly."'),e=te.LngLatBounds.convert(e);const i=t&&t.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_extendCameraOptions(e){const t={top:0,bottom:0,right:0,left:0};if("number"==typeof(e=te.extend({padding:t,offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding){const te=e.padding;e.padding={top:te,bottom:te,right:te,left:te}}return e.padding=te.extend(t,e.padding),e}_cameraForBoxAndBearing(e,t,i,r){const n=this._extendCameraOptions(r),o=this.transform,s=o.padding,a=o.project(te.LngLat.convert(e)),l=o.project(te.LngLat.convert(t)),c=new te.pointGeometry(a.x,l.y),h=new te.pointGeometry(l.x,a.y),u=-te.degToRad(i),p=a.rotate(u),d=l.rotate(u),f=c.rotate(u),m=h.rotate(u),_=new te.pointGeometry(Math.max(p.x,d.x,f.x,m.x),Math.max(p.y,d.y,f.y,m.y)),g=new te.pointGeometry(Math.min(p.x,d.x,f.x,m.x),Math.min(p.y,d.y,f.y,m.y)),y=_.sub(g),x=(o.width-((s.left||0)+(s.right||0)+n.padding.left+n.padding.right))/y.x,v=(o.height-((s.top||0)+(s.bottom||0)+n.padding.top+n.padding.bottom))/y.y;if(v<0||x<0)return void te.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const b=Math.min(o.scaleZoom(o.scale*Math.min(x,v)),n.maxZoom),w="number"==typeof n.offset.x&&"number"==typeof n.offset.y?new te.pointGeometry(n.offset.x,n.offset.y):te.pointGeometry.convert(n.offset),T=new te.pointGeometry((n.padding.left-n.padding.right)/2,(n.padding.top-n.padding.bottom)/2).rotate(i*Math.PI/180),E=w.add(T).mult(o.scale/o.zoomScale(b));return{center:o.unproject(a.add(l).div(2).sub(E)),zoom:b,bearing:i}}_cameraForBox(e,t,i,r,n){const o=this._extendCameraOptions(n);i=i||0,r=r||0,e=te.LngLat.convert(e),t=te.LngLat.convert(t);const s=this.transform.clone();s.padding=o.padding;const a=this.getFreeCameraOptions(),l=new te.LngLat(.5*(e.lng+t.lng),.5*(e.lat+t.lat)),c=.5*(i+r);if(s._camera.position[2]<te.mercatorZfromAltitude(c,l.lat))return void te.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");a.lookAtPoint(l),s.setFreeCameraOptions(a);const h=te.MercatorCoordinate.fromLngLat(e),u=te.MercatorCoordinate.fromLngLat(t),p=s.pointRayIntersection(s.centerPoint,c),d=[(f=s.rayIntersectionCoordinate(p)).x,f.y,f.z];var f;const m=s.screenPointToMercatorRay(s.centerPoint),_="globe"!==s.projection.name;let g,y=0;do{const e=Math.floor(s.zoom),t=1<<e,n=Math.min(t*h.x,t*u.x),o=Math.min(t*h.y,t*u.y),a=Math.max(t*h.x,t*u.x),l=Math.max(t*h.y,t*u.y),c=new te.Aabb([n,o,i],[a,l,r]),p=te.Frustum.fromInvProjectionMatrix(s.invProjMatrix,s.worldSize,e,_);if(2!==c.intersects(p)){g&&(s._camera.position=te.scaleAndAdd([],s._camera.position,m.dir,-g),s._updateStateFromCamera());break}const f=te.sub([],s._camera.position,d);g=.5*te.length(f),s._camera.position=te.scaleAndAdd([],s._camera.position,m.dir,g);try{s._updateStateFromCamera()}catch(e){return void te.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++y<10);return{center:s.center,zoom:s.zoom,bearing:s.bearing,pitch:s.pitch}}fitBounds(e,t,i){return"globe"===this.transform.projection.name&&te.warnOnce("Globe projection does not support fitBounds API, this API may behave unexpectedly."),this._fitInternal(this.cameraForBounds(e,t),t,i)}_raycastElevationBox(e,t){const i=this.transform.elevation;if(!i)return;const r=new te.pointGeometry(e.x,t.y),n=new te.pointGeometry(t.x,e.y),o=i.pointCoordinate(e);if(!o)return;const s=i.pointCoordinate(t);if(!s)return;const a=i.pointCoordinate(r);if(!a)return;const l=i.pointCoordinate(n);if(!l)return;const c=new te.MercatorCoordinate(o[0],o[1]).toLngLat(),h=new te.MercatorCoordinate(s[0],s[1]).toLngLat(),u=new te.MercatorCoordinate(a[0],a[1]).toLngLat(),p=new te.MercatorCoordinate(l[0],l[1]).toLngLat(),d=Math.min(c.lng,Math.min(h.lng,Math.min(u.lng,p.lng))),f=Math.min(c.lat,Math.min(h.lat,Math.min(u.lat,p.lat))),m=Math.max(c.lng,Math.max(h.lng,Math.max(u.lng,p.lng))),_=Math.max(c.lat,Math.max(h.lat,Math.max(u.lat,p.lat))),g=Math.min(o[3],Math.min(s[3],Math.min(a[3],l[3]))),y=Math.max(o[3],Math.max(s[3],Math.max(a[3],l[3])));return{minLngLat:new te.LngLat(d,f),maxLngLat:new te.LngLat(m,_),minAltitude:g,maxAltitude:y}}fitScreenCoordinates(e,t,i,r,n){let o,s,a,l;"globe"===this.transform.projection.name&&te.warnOnce("Globe projection does not support fitScreenCoordinates API, this API may behave unexpectedly.");const c=te.pointGeometry.convert(e),h=te.pointGeometry.convert(t),u=this._raycastElevationBox(c,h);if(u)o=u.minLngLat,s=u.maxLngLat,a=u.minAltitude,l=u.maxAltitude;else{if(this.transform.anyCornerOffEdge(c,h))return this;o=this.transform.pointLocation(c),s=this.transform.pointLocation(h)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(te.pointGeometry.convert(e)),this.transform.pointLocation(te.pointGeometry.convert(t)),i,r):this._cameraForBox(o,s,a,l,r),r,n)}_fitInternal(e,t,i){return e?(delete(t=te.extend(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop();const i=e.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,o=!1;return"zoom"in e&&i.zoom!==+e.zoom&&(r=!0,i.zoom=+e.zoom),void 0!==e.center&&(i.center=te.LngLat.convert(e.center)),"bearing"in e&&i.bearing!==+e.bearing&&(n=!0,i.bearing=+e.bearing),"pitch"in e&&i.pitch!==+e.pitch&&(o=!0,i.pitch=+e.pitch),null==e.padding||i.isPaddingEqual(e.padding)||(i.padding=e.padding),e.preloadOnly?(this._preloadTiles(i),this):(this.fire(new te.Event("movestart",t)).fire(new te.Event("move",t)),r&&this.fire(new te.Event("zoomstart",t)).fire(new te.Event("zoom",t)).fire(new te.Event("zoomend",t)),n&&this.fire(new te.Event("rotatestart",t)).fire(new te.Event("rotate",t)).fire(new te.Event("rotateend",t)),o&&this.fire(new te.Event("pitchstart",t)).fire(new te.Event("pitch",t)).fire(new te.Event("pitchend",t)),this.fire(new te.Event("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||te.warnOnce($n),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const i=this.transform;if(!i.projection.supportsFreeCamera)return te.warnOnce($n),this;this.stop();const r=i.zoom,n=i.pitch,o=i.bearing;i.setFreeCameraOptions(e);const s=r!==i.zoom,a=n!==i.pitch,l=o!==i.bearing;return this.fire(new te.Event("movestart",t)).fire(new te.Event("move",t)),s&&this.fire(new te.Event("zoomstart",t)).fire(new te.Event("zoom",t)).fire(new te.Event("zoomend",t)),l&&this.fire(new te.Event("rotatestart",t)).fire(new te.Event("rotate",t)).fire(new te.Event("rotateend",t)),a&&this.fire(new te.Event("pitchstart",t)).fire(new te.Event("pitch",t)).fire(new te.Event("pitchend",t)),this.fire(new te.Event("moveend",t)),this}easeTo(i,r){this._stop(!1,i.easeId),(!1===(i=te.extend({offset:[0,0],duration:500,easing:te.ease},i)).animate||!i.essential&&te.exported.prefersReducedMotion)&&(i.duration=0);const t=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in i?+i.zoom:n,c="bearing"in i?this._normalizeBearing(i.bearing,o):o,h="pitch"in i?+i.pitch:s,u="padding"in i?i.padding:t.padding,p=te.pointGeometry.convert(i.offset);let d,f,m;if("globe"===t.projection.name){const r=te.MercatorCoordinate.fromLngLat(t.center),n=p.rotate(-t.angle);r.x+=n.x/t.worldSize,r.y+=n.y/t.worldSize;const o=r.toLngLat(),s=te.LngLat.convert(i.center||o);this._normalizeCenter(s),d=t.centerPoint.add(n),f=new te.pointGeometry(r.x,r.y).mult(t.worldSize),m=new te.pointGeometry(te.mercatorXfromLng(s.lng),te.mercatorYfromLat(s.lat)).mult(t.worldSize).sub(f)}else{d=t.centerPoint.add(p);const r=t.pointLocation(d),n=te.LngLat.convert(i.center||r);this._normalizeCenter(n),f=t.project(r),m=t.project(n).sub(f)}const _=t.zoomScale(l-n);let g,y;i.around&&(g=te.LngLat.convert(i.around),y=t.locationPoint(g));const x=this._zooming||l!==n,v=this._rotating||o!==c,b=this._pitching||h!==s,w=!t.isPaddingEqual(u),e=t=>e=>{if(x&&(t.zoom=te.number(n,l,e)),v&&(t.bearing=te.number(o,c,e)),b&&(t.pitch=te.number(s,h,e)),w&&(t.interpolatePadding(a,u,e),d=t.centerPoint.add(p)),g)t.setLocationAtPoint(g,y);else{const te=t.zoomScale(t.zoom-n),i=l>n?Math.min(2,_):Math.max(.5,_),r=Math.pow(i,1-e),o=t.unproject(f.add(m.mult(e*r)).mult(te));t.setLocationAtPoint(t.renderWorldCopies?o.wrap():o,d)}return i.preloadOnly||this._fireMoveEvents(r),t};if(i.preloadOnly){const te=this._emulate(e,i.duration,t);return this._preloadTiles(te),this}const T={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=i.easeId,this._prepareEase(r,i.noMoveStart,T),this._ease(e(t),e=>{t.recenterOnTerrain(),this._afterEase(r,e)},i),this}_prepareEase(e,t,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",t||i.moving||this.fire(new te.Event("movestart",e)),this._zooming&&!i.zooming&&this.fire(new te.Event("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new te.Event("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new te.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new te.Event("move",e)),this._zooming&&this.fire(new te.Event("zoom",e)),this._rotating&&this.fire(new te.Event("rotate",e)),this._pitching&&this.fire(new te.Event("pitch",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new te.Event("zoomend",e)),r&&this.fire(new te.Event("rotateend",e)),n&&this.fire(new te.Event("pitchend",e)),this.fire(new te.Event("moveend",e))}flyTo(o,s){if(!o.essential&&te.exported.prefersReducedMotion){const e=te.pick(o,["center","zoom","bearing","pitch","around"]);return this.jumpTo(e,s)}this.stop(),o=te.extend({offset:[0,0],speed:1.2,curve:1.42,easing:te.ease},o);const e=this.transform,a=this.getZoom(),l=this.getBearing(),c=this.getPitch(),h=this.getPadding(),u="zoom"in o?te.clamp(+o.zoom,e.minZoom,e.maxZoom):a,p="bearing"in o?this._normalizeBearing(o.bearing,l):l,d="pitch"in o?+o.pitch:c,f="padding"in o?o.padding:e.padding,t=e.zoomScale(u-a),m=te.pointGeometry.convert(o.offset);let _=e.centerPoint.add(m);const i=e.pointLocation(_),g=te.LngLat.convert(o.center||i);this._normalizeCenter(g);const y=e.project(i),x=e.project(g).sub(y);let r=o.curve;const n=Math.max(e.width,e.height),v=n/t,b=x.mag();if("minZoom"in o){const s=te.clamp(Math.min(o.minZoom,a,u),e.minZoom,e.maxZoom),l=n/e.zoomScale(s-a);r=Math.sqrt(l/b*2)}const w=r*r;function T(e){const t=(v*v-n*n+(e?-1:1)*w*w*b*b)/(2*(e?v:n)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function A(e){return(Math.exp(e)+Math.exp(-e))/2}const S=T(0);let C=function(e){return A(S)/A(S+r*e)},M=function(e){return n*((A(S)*(E(t=S+r*e)/A(t))-E(S))/w)/b;var t},I=(T(1)-S)/r;if(Math.abs(b)<1e-6||!isFinite(I)){if(Math.abs(n-v)<1e-6)return this.easeTo(o,s);const te=v<n?-1:1;I=Math.abs(Math.log(v/n))/r,M=function(){return 0},C=function(e){return Math.exp(te*r*e)}}o.duration="duration"in o?+o.duration:1e3*I/("screenSpeed"in o?+o.screenSpeed/r:+o.speed),o.maxDuration&&o.duration>o.maxDuration&&(o.duration=0);const B=l!==p,k=d!==c,z=!e.isPaddingEqual(f),P=n=>e=>{const t=e*I,i=1/C(t);n.zoom=1===e?u:a+n.scaleZoom(i),B&&(n.bearing=te.number(l,p,e)),k&&(n.pitch=te.number(c,d,e)),z&&(n.interpolatePadding(h,f,e),_=n.centerPoint.add(m));const r=1===e?g:n.unproject(y.add(x.mult(M(t))).mult(i));return n.setLocationAtPoint(n.renderWorldCopies?r.wrap():r,_),n._updateCameraOnTerrain(),o.preloadOnly||this._fireMoveEvents(s),n};if(o.preloadOnly){const te=this._emulate(P,o.duration,e);return this._preloadTiles(te),this}return this._zooming=!0,this._rotating=B,this._pitching=k,this._padding=z,this._prepareEase(s,!1),this._ease(P(e),()=>this._afterEase(s),o),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=te.exported.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((te.exported.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,t){e=te.wrap(e,-180,180);const i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}_normalizeCenter(e){const t=this.transform;if(!t.renderWorldCopies||t.maxBounds)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}}class Zn{constructor(e={}){this.options=e,te.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),l("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=l("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.setAttribute("aria-label",i),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const r=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||te.config.ACCESS_TOKEN}];if(e){const t=r.reduce((e,t,i)=>(t.value&&(e+=`${t.key}=${t.value}${i<r.length-1?"&":""}`),e),"?");e.href=`${te.config.FEEDBACK_URL}/${t}${this._map._hash?this._map._hash.getHashString(!0):""}`,e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let r=[];if(this._map.style.stylesheet){const r=this._map.style.stylesheet;this.styleOwner=r.owner,this.styleId=r.id}const e=this._map.style._sourceCaches;for(const t in e){const i=e[t];if(i.used){const e=i.getSource();e.attribution&&r.indexOf(e.attribution)<0&&r.push(e.attribution)}}r.sort((e,t)=>e.length-t.length),r=r.filter((t,i)=>{for(let e=i+1;e<r.length;e++)if(r[e].indexOf(t)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=[...this.options.customAttribution,...r]:r.unshift(this.options.customAttribution));const t=r.join(" | ");t!==this._attribHTML&&(this._attribHTML=t,r.length?(this._innerContainer.innerHTML=t,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Yn{constructor(){te.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Wn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Xn(e,t,i){if(e=new te.LngLat(e.lng,e.lat),t){const r=new te.LngLat(e.lng-360,e.lat),n=new te.LngLat(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-i.center.lng)/360),s=i.locationPoint(e).distSqr(t),a=t.x<0||t.y<0||t.x>i.width||t.y>i.height;i.locationPoint(r).distSqr(t)<s&&(a||Math.abs(r.lng-i.center.lng)<o)?e=r:i.locationPoint(n).distSqr(t)<s&&(a||Math.abs(n.lng-i.center.lng)<o)&&(e=n)}for(;Math.abs(e.lng-i.center.lng)>180;){const te=i.locationPoint(e);if(te.x>=0&&te.y>=0&&te.x<=i.width&&te.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e}const Hn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class Kn extends te.Evented{constructor(e,t){if(super(),(e instanceof te.window.HTMLElement||t)&&(e=te.extend({element:e},t)),te.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),e&&e.element)this._element=e.element,this._offset=te.pointGeometry.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=l("div");const t=41,i=27,r=o("svg",{display:"block",height:t*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${t}`},this._element),n=o("radialGradient",{id:"shadowGradient"},o("defs",{},r));o("stop",{offset:"10%","stop-opacity":.4},n),o("stop",{offset:"100%","stop-opacity":.05},n),o("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),o("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},r),o("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},r),o("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=te.pointGeometry.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()});const i=this._element.classList;for(const te in Hn)i.remove(`mapboxgl-marker-anchor-${te}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=te.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map;if(!e)return!1;const t=e.unproject(this._pos),i=e.getFreeCameraOptions();if(!i.position)return!1;const r=i.position.toLngLat();return r.distanceTo(t)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const i=e.unproject(t);let r;e._usingGlobe()&&te.isLngLatBehindGlobe(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(i),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=.2)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._calculateXYTransform()+this._calculateZTransform(),i=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px) ${Hn[this._anchor]}\n ${t}\n translate(${i.x}px,${i.y}px)\n `}_calculateXYTransform(){const e=this._pos,t=this._map;if("map"!==this.getPitchAlignment()||!t||!e)return"";if(!t._usingGlobe()){const te=t.getPitch();return te?`rotateX(${te}deg)`:""}const i=te.radToDeg(te.globeTiltAtLngLat(t.transform,this._lngLat)),r=e.sub(te.globeCenterToScreenPoint(t.transform)),n=i/(Math.abs(r.x)+Math.abs(r.y)),o=r.x*n,s=-r.y*n;return s||o?`rotateX(${s}deg) rotateY(${o}deg)`:""}_calculateZTransform(){const e=this._calculateRotation();return e?`rotateZ(${e}deg)`:""}_calculateRotation(){if("viewport"===this._rotationAlignment||"auto"===this._rotationAlignment)return this._rotation;if(this._map&&"map"===this._rotationAlignment){const e=this._map;if(this._pos&&e&&e._usingGlobe()){const t=e.project(new te.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),i=e.project(new te.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);return this._rotation+te.radToDeg(Math.atan2(i.y,i.x))-90}return this._rotation-this._map.getBearing()}return 0}_update(e){te.window.cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Xn(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=te.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._usingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(e){return this._offset=te.pointGeometry.convert(e),this._update(),this}_onMove(e){const t=this._map;if(t){if(!this._isDragging){const te=this._clickTolerance||t._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=te}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=t.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new te.Event("dragstart"))),this.fire(new te.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new te.Event("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map;t&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class Jn{constructor(e){this.jumpTo(e)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const t=te.easeCubicInOut((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const Qn={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},eo={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function to(e){e.parentNode&&e.parentNode.removeChild(e)}const io={showCompass:!0,showZoom:!0,visualizePitch:!1};class ro{constructor(e,t,i=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new gn({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new yn({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),te.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),a()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){c(),te.window.removeEventListener("mousemove",this.mousemove),te.window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(te.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),p(this.element,e)),te.window.addEventListener("mousemove",this.mousemove),te.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,p(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=d(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=d(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const no={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},oo={maxWidth:100,unit:"metric"};function so(e,t,i,r,n,o){const s=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i),a=s/i;o._requestDomTask(()=>{e.style.width=t*a+"px",e.innerHTML="nautical-mile"!==n?new Intl.NumberFormat(r,{style:"unit",unitDisplay:"narrow",unit:n}).format(s):`${s} nm`})}const ao={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},lo=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function co(e=new te.pointGeometry(0,0),t="bottom"){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(t){case"top":return new te.pointGeometry(0,e);case"top-left":return new te.pointGeometry(i,i);case"top-right":return new te.pointGeometry(-i,i);case"bottom":return new te.pointGeometry(0,-e);case"bottom-left":return new te.pointGeometry(i,-i);case"bottom-right":return new te.pointGeometry(-i,-i);case"left":return new te.pointGeometry(e,0);case"right":return new te.pointGeometry(-e,0)}return new te.pointGeometry(0,0)}return e instanceof te.pointGeometry||Array.isArray(e)?te.pointGeometry.convert(e):te.pointGeometry.convert(e[t]||[0,0])}const ho={version:te.version,supported:i,setRTLTextPlugin:te.setRTLTextPlugin,getRTLTextPluginStatus:te.getRTLTextPluginStatus,Map:class extends qn{constructor(e){if(null!=(e=te.extend({},eo,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&te.isSafariWithAntialiasingBug(te.window)&&(e.antialias=!1,te.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Zr(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._optimizeForTerrain=e.optimizeForTerrain,this._language="auto"===e.language?te.window.navigator.language:e.language,this._worldview=e.worldview,this._renderTaskQueue=new Wn,this._domRenderTaskQueue=new Wn,this._controls=[],this._markers=[],this._mapId=te.uniqueId(),this._locale=te.extend({},Qn,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Jn(0),this._explicitProjection=null,this._requestManager=new te.RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"string"==typeof e.container){if(this._container=te.window.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof te.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&te.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),te.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==te.window&&(te.window.addEventListener("online",this._onWindowOnline,!1),te.window.addEventListener("resize",this._onWindowResize,!1),te.window.addEventListener("orientationchange",this._onWindowResize,!1),te.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new Gn(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),this._hash=e.hash&&new Wr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,te.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),e.attributionControl&&this.addControl(new Zn({customAttribution:e.customAttribution})),this._logoControl=new Yn,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new te.Event(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new te.Event(`${e.dataType}dataloading`,e))})}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new te.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return-1!==t.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new te.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const t=!this._moving;return t&&this.fire(new te.Event("movestart",e)).fire(new te.Event("move",e)),this.fire(new te.Event("resize",e)),t&&this.fire(new te.Event("moveend",e)),this}getBounds(){return"globe"===this.transform.projection.name&&te.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(te.LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()<e?this.setZoom(e):this.fire(new te.Event("zoomstart")).fire(new te.Event("zoom")).fire(new te.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new te.Event("zoomstart")).fire(new te.Event("zoom")).fire(new te.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()<e?this.setPitch(e):this.fire(new te.Event("pitchstart")).fire(new te.Event("pitch")).fire(new te.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?85:e)>85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new te.Event("pitchstart")).fire(new te.Event("pitch")).fire(new te.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this._update()}getLanguage(){return this._language}setLanguage(e){if(this._language="auto"===e?te.window.navigator.language:e,this.style)for(const te in this.style._sourceCaches){const e=this.style._sourceCaches[te]._source;e._setLanguage&&e._setLanguage(this._language)}for(const te of this._controls)te._setLanguage&&te._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){if(this._worldview=e,this.style)for(const t in this.style._sourceCaches){const i=this.style._sourceCaches[t]._source;i._setWorldview&&i._setWorldview(e)}return this}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}_usingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._updateProjection(e)}_updateProjection(e){const t=this.getProjection();null===e&&(this._explicitProjection=null);const i=e||this.getProjection();let r;if(i&&"globe"===i.name&&this.transform.zoom>=te.GLOBE_ZOOM_THRESHOLD_MAX?(r=this.transform.setProjection({name:"mercator"}),this.transform.mercatorFromTransition=!0):(r=this.transform.setProjection(i),this.transform.mercatorFromTransition=!1),e&&(this._explicitProjection="globe"===e.name?{name:"globe",center:[0,0]}:this.transform.getProjection()),this.style.applyProjectionUpdate(),r){if("globe"===t.name&&"globe"===this.getProjection().name)this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const te in this.style._sourceCaches)this.style._sourceCaches[te].clearTiles()}this._update(!0)}return this}project(e){return this.transform.locationPoint3D(te.LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(te.pointGeometry.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(n,o,s){if("mouseenter"===n||"mouseover"===n){let r=!1;const e=e=>{const t=o.filter(e=>this.getLayer(e)),i=t.length?this.queryRenderedFeatures(e.point,{layers:t}):[];i.length?r||(r=!0,s.call(this,new nn(n,this,e.originalEvent,{features:i}))):r=!1},t=()=>{r=!1};return{layers:new Set(o),listener:s,delegates:{mousemove:e,mouseout:t}}}if("mouseleave"===n||"mouseout"===n){let i=!1;const r=e=>{const t=o.filter(e=>this.getLayer(e));(t.length?this.queryRenderedFeatures(e.point,{layers:t}):[]).length?i=!0:i&&(i=!1,s.call(this,new nn(n,this,e.originalEvent)))},a=e=>{i&&(i=!1,s.call(this,new nn(n,this,e.originalEvent)))};return{layers:new Set(o),listener:s,delegates:{mousemove:r,mouseout:a}}}{const i=e=>{const t=o.filter(e=>this.getLayer(e)),i=t.length?this.queryRenderedFeatures(e.point,{layers:t}):[];i.length&&(e.features=i,s.call(this,e),delete e.features)};return{layers:new Set(o),listener:s,delegates:{[n]:i}}}}on(e,t,i){if(void 0===i)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,r,n){if(void 0===n)return super.off(e,r);r=new Set(Array.isArray(r)?r:[r]);const o=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},t=this._delegatedListeners?this._delegatedListeners[e]:void 0;return t&&(t=>{for(let e=0;e<t.length;e++){const i=t[e];if(i.listener===n&&o(i.layers,r)){for(const t in i.delegates)this.off(t,i.delegates[t]);return t.splice(e,1),this}}})(t),this}queryRenderedFeatures(e,t){return this.style?(void 0!==t||void 0===e||e instanceof te.pointGeometry||Array.isArray(e)||(t=e,e=void 0),this.style.queryRenderedFeatures(e=e||[[0,0],[this.transform.width,this.transform.height]],t=t||{},this.transform)):[]}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}queryTerrainElevation(e,t){const i=this.transform.elevation;return i?(t=te.extend({},{exaggerated:!0},t),i.getAtPoint(te.MercatorCoordinate.fromLngLat(e),null,t.exaggerated)):null}setStyle(e,t){return!1!==(t=te.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},t)).diff&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.localFontFamily===this._localFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._updateStyle(e,t))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e&&(this.style=new ei(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e):this.style.loadJSON(e)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new ei(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const t=this._requestManager.normalizeStyleURL(e),r=this._requestManager.transformRequest(t,te.ResourceType.Style);te.getJSON(r,(e,t)=>{e?this.fire(new te.ErrorEvent(e)):t&&this._updateDiff(t,i)})}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(t,i){try{this.style.setState(t)&&this._update(!0)}catch(e){te.warnOnce(`Unable to perform style diff: ${e.message||e.error||e}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(te.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const r=i[e];if("loaded"!==r.state&&"errored"!==r.state)return!1}}return!0}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(e,t,{pixelRatio:i=1,sdf:r=!1,stretchX:n,stretchY:o,content:s}={}){if(this._lazyInitEmptyStyle(),t instanceof te.window.HTMLImageElement||te.window.ImageBitmap&&t instanceof te.window.ImageBitmap){const{width:a,height:l,data:c}=te.exported.getImageData(t);this.style.addImage(e,{data:new te.RGBAImage({width:a,height:l},c),pixelRatio:i,stretchX:n,stretchY:o,content:s,sdf:r,version:0})}else if(void 0===t.width||void 0===t.height)this.fire(new te.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:h,height:u}=t,p=t;this.style.addImage(e,{data:new te.RGBAImage({width:h,height:u},new Uint8Array(p.data)),pixelRatio:i,stretchX:n,stretchY:o,content:s,sdf:r,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e)}}updateImage(e,t){const i=this.style.getImage(e);if(!i)return void this.fire(new te.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=t instanceof te.window.HTMLImageElement||te.window.ImageBitmap&&t instanceof te.window.ImageBitmap?te.exported.getImageData(t):t,{width:n,height:o}=r;void 0!==n&&void 0!==o?n===i.data.width&&o===i.data.height?(i.data.replace(r.data,!(t instanceof te.window.HTMLImageElement||te.window.ImageBitmap&&t instanceof te.window.ImageBitmap)),this.style.updateImage(e,i)):this.fire(new te.ErrorEvent(new Error(`The width and height of the updated image (${n}, ${o})\n must be that same as the previous version of the image\n (${i.data.width}, ${i.data.height})`))):this.fire(new te.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new te.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e,i){te.getImage(this._requestManager.transformRequest(e,te.ResourceType.Image),(e,t)=>{i(e,t instanceof te.window.HTMLImageElement?te.exported.getImageData(t):t)})}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(te.LngLat.convert(e),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,r,n,o=this._container;for(;o&&(!r||!n);){const e=te.window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(r=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(n=i[3])),o=o.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=n?Math.abs(t/n):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==te.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&te.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=l("canvas","mapboxgl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=l("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=l("div",`mapboxgl-ctrl-${e}`,i)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t){const i=te.exported.devicePixelRatio||1;this._canvas.width=i*Math.ceil(e),this._canvas.height=i*Math.ceil(t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_setupPainter(){const e=te.extend({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);t?(te.storeAuthState(t,!0),this.painter=new Pr(t,this.transform),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),te.exported$1.testSupport(t)):this.fire(new te.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new te.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new te.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let i;const r=this.painter.context.extTimerQuery,n=te.exported.now();if(this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=te.GLOBE_ZOOM_THRESHOLD_MAX?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let e=!1;const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,r=te.exported.now();this.style.zoomHistory.update(t,r);const n=new te.EvaluationParameters(t,{now:r,fadeDuration:o,pitch:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),s=n.crossFadingFactor();1===s&&s===this._crossFadingFactor||(e=!0,this._crossFadingFactor=s),this.style.update(n)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(n),this.style._updateSources(this.transform),this._forceMarkerUpdate()):s=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:o,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new te.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new te.Event("load"))),this.style&&(this.style.hasTransitions()||e)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=te.exported.now()-n;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout(()=>{const e=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new te.Event("gpu-timing-frame",{cpuTime:t,gpuTime:e})),te.window.performance.mark("frame-gpu",{startTime:n,detail:{gpuTime:e}})},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const e=this.painter.queryGpuTimers(t);this.fire(new te.Event("gpu-timing-layer",{layerTimes:e}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const e=this.painter.queryGpuTimeDeferredRender(t);this.fire(new te.Event("gpu-timing-deferred-render",{gpuTime:e}))},50)}const a=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(a||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(s=this._updateAverageElevation(n,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new te.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new te.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const e of this._markers)e._update()}_updateAverageElevation(i,r=!1){const n=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((r||i-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(i)){const r=this.transform.averageElevation;let e=this.transform.sampleAverageElevation(),t=!1;this.transform.elevation&&(t=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(e)?e=0:this._averageElevationLastSampledAt=i;const o=Math.abs(r-e);if(o>1){if(this._isInitialLoad||t)return this._averageElevation.jumpTo(e),n(e);this._averageElevation.easeTo(e,i,300)}else if(o>1e-4)return this._averageElevation.jumpTo(e),n(e)}return!!this._averageElevation.isEasing(i)&&n(this._averageElevation.getValue(i))}_authenticate(){te.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,e=>{if(e&&(e.message===te.AUTH_ERR_MSG||401===e.status)){const e=this.painter.context.gl;te.storeAuthState(e,!1),this._logoControl instanceof Yn&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new te.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),te.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(i,r,n){let o=n[1]-n[0];const s=i.length/4;for(let e=0;e<r.length;e++){const a=r[e];let t=0;for(let e=0;e<a.length;e+=4)a[e]===i[e]&&a[e+1]===i[e+1]&&a[e+2]===i[e+2]&&a[e+3]===i[e+3]&&(t+=1);o+=(n[e+2]-n[e+1])*(1-t/s)}return o}remove(){this._hash&&this._hash.remove();for(const te of this._controls)te.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),void 0!==te.window&&(te.window.removeEventListener("resize",this._onWindowResize,!1),te.window.removeEventListener("orientationchange",this._onWindowResize,!1),te.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),te.window.removeEventListener("online",this._onWindowOnline,!1));const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),to(this._canvasContainer),to(this._controlContainer),to(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),te.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new te.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=te.exported.frame(e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(i){const e=this.style?Object.values(this.style._sourceCaches):[];return te.asyncAll(e,(e,t)=>e._preloadTiles(i,t),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}_setCacheLimits(e,t){te.setCacheLimits(e,t)}get version(){return te.version}},NavigationControl:class{constructor(e){this.options=te.extend({},io,e),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(te.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),l("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e})}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(te.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))}),this._compassIcon=l("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ro(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends te.Evented{constructor(e){super(),this.options=te.extend({geolocation:te.window.navigator.geolocation},no,e),te.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Yr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(t){void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==te.window.navigator.permissions?te.window.navigator.permissions.query({name:"geolocation"}).then(e=>{this._supportsGeolocation="denied"!==e.state,t(this._supportsGeolocation)}):(this._supportsGeolocation=!!this.geolocation,t(this._supportsGeolocation))}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new te.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new te.Event("geolocate",e)),this._finish()}}_updateCamera(e){const t=new te.LngLat(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=this._map.getBearing(),n=te.extend({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(i),n,{geolocateSource:!0})}_updateMarker(e){if(e){const t=new te.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,t=te.mercatorZfromAltitude(1,e._center.lat)*e.worldSize,i=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const te=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",te),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",te),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new te.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){te.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const te=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",te),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",te)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Kn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Kn({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new te.Event("trackuserlocationend")))})}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return te.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new te.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new te.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new te.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{te.window.addEventListener("ondeviceorientationabsolute"in te.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==te.window.DeviceMotionEvent&&"function"==typeof te.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(e=>{"granted"===e&&t()}).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),te.window.removeEventListener("deviceorientation",this._onDeviceOrientation),te.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Zn,ScaleControl:class{constructor(e){this.options=te.extend({},oo,e),te.bindAll(["_update","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){!function(e,t,i,r){const n=r&&r.maxWidth||100,o=e._containerHeight/2,s=e._containerWidth/2-n/2,a=e.unproject([s,o]),l=e.unproject([s+n,o]),c=a.distanceTo(l);if(r&&"imperial"===r.unit){const r=3.2808*c;r>5280?so(t,n,r/5280,i,"mile",e):so(t,n,r,i,"foot",e)}else r&&"nautical"===r.unit?so(t,n,c/1852,i,"nautical-mile",e):c>=1e3?so(t,n,c/1e3,i,"kilometer",e):so(t,n,c,i,"meter",e)}(this._map,this._container,this._language,this.options)}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof te.window.HTMLElement?this._container=e.container:te.warnOnce("Full screen control 'container' must be a DOM element.")),te.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in te.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in te.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",te.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,te.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!te.window.document.fullscreenEnabled&&!te.window.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),te.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(te.window.document.fullscreenElement||te.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?te.window.document.exitFullscreen?te.window.document.exitFullscreen():te.window.document.webkitCancelFullScreen&&te.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends te.Evented{constructor(e){super(),this.options=te.extend(Object.create(ao),e),te.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new te.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new te.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=te.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(te.window.document.createTextNode(e))}setHTML(e){const t=te.window.document.createDocumentFragment(),i=te.window.document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.x<n/2,a=r.x>t.transform.width-n/2;if(r.y+e<o)return s?"top-left":a?"top-right":"top";if(r.y>t.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(e){const t=this._map,i=this._content;if(!t||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=l("div","mapboxgl-popup",t.getContainer()),this._tip=l("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Xn(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const te=this._pos=this._trackPointer&&e?e:t.project(this._lngLat),i=co(this.options.offset),r=this._anchor=this._getAnchor(i.y),l=co(this.options.offset,r),n=te.add(l).round();t._requestDomTask(()=>{this._container&&r&&(this._container.style.transform=`${Hn[r]} translate(${n.x}px,${n.y}px)`)})}if(!this._marker&&t._usingGlobe()){const e=te.isLngLatBehindGlobe(t.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(lo);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:Kn,Style:ei,LngLat:te.LngLat,LngLatBounds:te.LngLatBounds,Point:te.pointGeometry,MercatorCoordinate:te.MercatorCoordinate,FreeCameraOptions:Fr,Evented:te.Evented,config:te.config,prewarm:function(){je().acquire(Fe)},clearPrewarmedResources:function(){const e=Ue;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Fe),Ue=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return te.config.ACCESS_TOKEN},set accessToken(e){te.config.ACCESS_TOKEN=e},get baseApiUrl(){return te.config.API_URL},set baseApiUrl(e){te.config.API_URL=e},get workerCount(){return Ne.workerCount},set workerCount(e){Ne.workerCount=e},get maxParallelImageRequests(){return te.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){te.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){te.clearTileCache(e)},workerUrl:"",workerClass:null,setNow:te.exported.setNow,restoreNow:te.exported.restoreNow};return ho}),s}()}.call(this,i(17))},function(e,t,i){"use strict";var r=i(8);function n(e){r.call(this,null==e?"canceled":e,r.ERR_CANCELED),this.name="CanceledError"}i(3).inherits(n,r,{__CANCEL__:!0}),e.exports=n},function(e,t,i){var r;e.exports=(r=i(2),function(){var e=r,t=e.lib,n=t.Base,o=t.WordArray,e=e.x64={};e.Word=n.extend({init:function(e,t){this.high=e,this.low=t}}),e.WordArray=n.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],r=0;r<t;r++){var n=e[r];i.push(n.high),i.push(n.low)}return o.create(i,this.sigBytes)},clone:function(){for(var e=n.clone.call(this),t=e.words=this.words.slice(0),i=t.length,r=0;r<i;r++)t[r]=t[r].clone();return e}})}(),r)},function(e,t){e.exports=r},function(h,e,u){"use strict";!function(e){var s=u(3),a=u(43),r=u(8),t=u(23),l=u(24),i={"Content-Type":"application/x-www-form-urlencoded"};function c(e,t){!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var n,o={transitional:t,adapter:n="undefined"!=typeof XMLHttpRequest||void 0!==e&&"[object process]"===Object.prototype.toString.call(e)?u(25):n,transformRequest:[function(e,t){if(a(t,"Accept"),a(t,"Content-Type"),s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e))return e;if(s.isArrayBufferView(e))return e.buffer;if(s.isURLSearchParams(e))return c(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var i,r=s.isObject(e),n=t&&t["Content-Type"];if((i=s.isFileList(e))||r&&"multipart/form-data"===n){var o=this.env&&this.env.FormData;return l(i?{"files[]":e}:e,o&&new o)}return r||"application/json"===n?(c(t,"application/json"),function(e,t,i){if(s.isString(e))try{return(t||JSON.parse)(e),s.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(i||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||o.transitional,i=t&&t.silentJSONParsing,t=t&&t.forcedJSONParsing,i=!i&&"json"===this.responseType;if(i||t&&s.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw r.from(e,r.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:u(55)},validateStatus:function(e){return 200<=e&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};s.forEach(["delete","get","head"],function(e){o.headers[e]={}}),s.forEach(["post","put","patch"],function(e){o.headers[e]=s.merge(i)}),h.exports=o}.call(this,u(17))},function(e,t){var i,r,e=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(i===setTimeout)return setTimeout(t,0);if((i===n||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:n}catch(e){i=n}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,l=[],c=!1,h=-1;function u(){c&&a&&(c=!1,a.length?l=a.concat(l):h=-1,l.length&&p())}function p(){if(!c){var e=s(u);c=!0;for(var t=l.length;t;){for(a=l,l=[];++h<t;)a&&a[h].run();h=-1,t=l.length}a=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function f(){}e.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];l.push(new d(e,t)),1!==l.length||c||s(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=f,e.addListener=f,e.once=f,e.off=f,e.removeListener=f,e.removeAllListeners=f,e.emit=f,e.prependListener=f,e.prependOnceListener=f,e.listeners=function(e){return[]},e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},function(e,t){var i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){var n;e.exports=(n=i(2),function(){var e=n,t=e.lib,i=t.WordArray,r=t.Hasher,t=e.algo,h=[],t=t.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],l=0;l<80;l++){l<16?h[l]=0|e[t+l]:(c=h[l-3]^h[l-8]^h[l-14]^h[l-16],h[l]=c<<1|c>>>31);var c=(r<<5|r>>>27)+a+h[l];c+=l<20?1518500249+(n&o|~n&s):l<40?1859775393+(n^o^s):l<60?(n&o|n&s|o&s)-1894007588:(n^o^s)-899497514,a=s,s=o,o=n<<30|n>>>2,n=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+n|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=Math.floor(i/4294967296),t[15+(64+r>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA1=r._createHelper(t),e.HmacSHA1=r._createHmacHelper(t)}(),n.SHA1)},function(e,t,i){var r;e.exports=(r=i(2),void function(){var e=r.lib.Base,a=r.enc.Utf8;r.algo.HMAC=e.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=a.parse(t));var i=e.blockSize,r=4*i;(t=t.sigBytes>r?e.finalize(t):t).clamp();for(var e=this._oKey=t.clone(),t=this._iKey=t.clone(),n=e.words,o=t.words,s=0;s<i;s++)n[s]^=1549556828,o[s]^=909522486;e.sigBytes=t.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,e=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(e))}})}())},function(e,t,i){"use strict";e.exports=function(i,r){return function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];return i.apply(r,e)}}},function(e,t,i){"use strict";var n=i(3);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,i){if(!t)return e;var r,i=i?i(t):n.isURLSearchParams(t)?t.toString():(r=[],n.forEach(t,function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),r.push(o(t)+"="+o(e))}))}),r.join("&"));return i&&(-1!==(t=e.indexOf("#"))&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i),e}},function(e,t,i){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,r){"use strict";!function(i){var l=r(3);e.exports=function(e,s){s=s||new FormData;var t=[];function a(e){return null===e?"":l.isDate(e)?e.toISOString():l.isArrayBuffer(e)||l.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):i.from(e):e}return function n(e,o){if(l.isPlainObject(e)||l.isArray(e)){if(-1!==t.indexOf(e))throw Error("Circular reference detected in "+o);t.push(e),l.forEach(e,function(e,t){if(!l.isUndefined(e)){var i,r=o?o+"."+t:t;if(e&&!o&&"object"==typeof e)if(l.endsWith(t,"{}"))e=JSON.stringify(e);else if(l.endsWith(t,"[]")&&(i=l.toArray(e)))return void i.forEach(function(e){l.isUndefined(e)||s.append(r,a(e))});n(e,r)}}),t.pop()}else s.append(o,a(e))}(e),s}}.call(this,r(44).Buffer)},function(e,t,i){"use strict";var p=i(3),d=i(48),f=i(49),m=i(22),_=i(26),g=i(52),y=i(53),x=i(23),v=i(8),b=i(13),w=i(54);e.exports=function(u){return new Promise(function(t,i){var e,r=u.data,n=u.headers,o=u.responseType;function s(){u.cancelToken&&u.cancelToken.unsubscribe(e),u.signal&&u.signal.removeEventListener("abort",e)}p.isFormData(r)&&p.isStandardBrowserEnv()&&delete n["Content-Type"];var a=new XMLHttpRequest;u.auth&&(c=u.auth.username||"",l=u.auth.password?unescape(encodeURIComponent(u.auth.password)):"",n.Authorization="Basic "+btoa(c+":"+l));var l,c=_(u.baseURL,u.url);function h(){var e;a&&(e="getAllResponseHeaders"in a?g(a.getAllResponseHeaders()):null,e={data:o&&"text"!==o&&"json"!==o?a.response:a.responseText,status:a.status,statusText:a.statusText,headers:e,config:u,request:a},d(function(e){t(e),s()},function(e){i(e),s()},e),a=null)}a.open(u.method.toUpperCase(),m(c,u.params,u.paramsSerializer),!0),a.timeout=u.timeout,"onloadend"in a?a.onloadend=h:a.onreadystatechange=function(){a&&4===a.readyState&&(0!==a.status||a.responseURL&&0===a.responseURL.indexOf("file:"))&&setTimeout(h)},a.onabort=function(){a&&(i(new v("Request aborted",v.ECONNABORTED,u,a)),a=null)},a.onerror=function(){i(new v("Network Error",v.ERR_NETWORK,u,a,a)),a=null},a.ontimeout=function(){var e=u.timeout?"timeout of "+u.timeout+"ms exceeded":"timeout exceeded",t=u.transitional||x;u.timeoutErrorMessage&&(e=u.timeoutErrorMessage),i(new v(e,t.clarifyTimeoutError?v.ETIMEDOUT:v.ECONNABORTED,u,a)),a=null},!p.isStandardBrowserEnv()||(l=(u.withCredentials||y(c))&&u.xsrfCookieName?f.read(u.xsrfCookieName):void 0)&&(n[u.xsrfHeaderName]=l),"setRequestHeader"in a&&p.forEach(n,function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete n[t]:a.setRequestHeader(t,e)}),p.isUndefined(u.withCredentials)||(a.withCredentials=!!u.withCredentials),o&&"json"!==o&&(a.responseType=u.responseType),"function"==typeof u.onDownloadProgress&&a.addEventListener("progress",u.onDownloadProgress),"function"==typeof u.onUploadProgress&&a.upload&&a.upload.addEventListener("progress",u.onUploadProgress),(u.cancelToken||u.signal)&&(e=function(e){a&&(i(!e||e.type?new b:e),a.abort(),a=null)},u.cancelToken&&u.cancelToken.subscribe(e),u.signal&&(u.signal.aborted?e():u.signal.addEventListener("abort",e)));r=r||null,c=w(c);c&&-1===["http","https","file"].indexOf(c)?i(new v("Unsupported protocol "+c+":",v.ERR_BAD_REQUEST,u)):a.send(r)})}},function(e,t,i){"use strict";var r=i(50),n=i(51);e.exports=function(e,t){return e&&!r(t)?n(e,t):t}},function(e,t,i){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,i){"use strict";var c=i(3);e.exports=function(t,i){i=i||{};var r={};function n(e,t){return c.isPlainObject(e)&&c.isPlainObject(t)?c.merge(e,t):c.isPlainObject(t)?c.merge({},t):c.isArray(t)?t.slice():t}function o(e){return c.isUndefined(i[e])?c.isUndefined(t[e])?void 0:n(void 0,t[e]):n(t[e],i[e])}function e(e){if(!c.isUndefined(i[e]))return n(void 0,i[e])}function s(e){return c.isUndefined(i[e])?c.isUndefined(t[e])?void 0:n(void 0,t[e]):n(void 0,i[e])}function a(e){return e in i?n(t[e],i[e]):e in t?n(void 0,t[e]):void 0}var l={url:e,method:e,data:e,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return c.forEach(Object.keys(t).concat(Object.keys(i)),function(e){var t=l[e]||o,i=t(e);c.isUndefined(i)&&t!==a||(r[e]=i)}),r}},function(e,t){e.exports={version:"0.27.2"}},function(e,t,i){var s;e.exports=(s=i(2),function(n){var e=s,t=e.lib,i=t.WordArray,r=t.Hasher,t=e.algo,o=[],f=[];!function(){function e(e){return 4294967296*(e-(0|e))|0}for(var t=2,i=0;i<64;)!function(e){for(var t=n.sqrt(e),i=2;i<=t;i++)if(!(e%i))return;return 1}(t)||(i<8&&(o[i]=e(n.pow(t,.5))),f[i]=e(n.pow(t,1/3)),i++),t++}();var m=[],t=t.SHA256=r.extend({_doReset:function(){this._hash=new i.init(o.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],l=i[5],c=i[6],h=i[7],u=0;u<64;u++){u<16?m[u]=0|e[t+u]:(p=m[u-15],d=m[u-2],m[u]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+m[u-7]+((d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10)+m[u-16]);var p=r&n^r&o^n&o,d=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&c)+f[u]+m[u],h=c,c=l,l=a,a=s+d|0,s=o,o=n,n=r,r=d+(((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+p)|0}i[0]=i[0]+r|0,i[1]=i[1]+n|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0,i[5]=i[5]+l|0,i[6]=i[6]+c|0,i[7]=i[7]+h|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=n.floor(i/4294967296),t[15+(64+r>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});e.SHA256=r._createHelper(t),e.HmacSHA256=r._createHmacHelper(t)}(Math),s.SHA256)},function(e,t,i){var s;e.exports=(s=i(2),i(14),function(){var e=s,t=e.lib.Hasher,i=e.x64,r=i.Word,n=i.WordArray,i=e.algo;function o(){return r.create.apply(r,arguments)}var ee=[o(1116352408,3609767458),o(1899447441,602891725),o(3049323471,3964484399),o(3921009573,2173295548),o(961987163,4081628472),o(1508970993,3053834265),o(2453635748,2937671579),o(2870763221,3664609560),o(3624381080,2734883394),o(310598401,1164996542),o(607225278,1323610764),o(1426881987,3590304994),o(1925078388,4068182383),o(2162078206,991336113),o(2614888103,633803317),o(3248222580,3479774868),o(3835390401,2666613458),o(4022224774,944711139),o(264347078,2341262773),o(604807628,2007800933),o(770255983,1495990901),o(1249150122,1856431235),o(1555081692,3175218132),o(1996064986,2198950837),o(2554220882,3999719339),o(2821834349,766784016),o(2952996808,2566594879),o(3210313671,3203337956),o(3336571891,1034457026),o(3584528711,2466948901),o(113926993,3758326383),o(338241895,168717936),o(666307205,1188179964),o(773529912,1546045734),o(1294757372,1522805485),o(1396182291,2643833823),o(1695183700,2343527390),o(1986661051,1014477480),o(2177026350,1206759142),o(2456956037,344077627),o(2730485921,1290863460),o(2820302411,3158454273),o(3259730800,3505952657),o(3345764771,106217008),o(3516065817,3606008344),o(3600352804,1432725776),o(4094571909,1467031594),o(275423344,851169720),o(430227734,3100823752),o(506948616,1363258195),o(659060556,3750685593),o(883997877,3785050280),o(958139571,3318307427),o(1322822218,3812723403),o(1537002063,2003034995),o(1747873779,3602036899),o(1955562222,1575990012),o(2024104815,1125592928),o(2227730452,2716904306),o(2361852424,442776044),o(2428436474,593698344),o(2756734187,3733110249),o(3204031479,2999351573),o(3329325298,3815920427),o(3391569614,3928383900),o(3515267271,566280711),o(3940187606,3454069534),o(4118630271,4000239992),o(116418474,1914138554),o(174292421,2731055270),o(289380356,3203993006),o(460393269,320620315),o(685471733,587496836),o(852142971,1086792851),o(1017036298,365543100),o(1126000580,2618297676),o(1288033470,3409855158),o(1501505948,4234509866),o(1607167915,987167468),o(1816402316,1246189591)],te=[];!function(){for(var e=0;e<80;e++)te[e]=o()}();i=i.SHA512=t.extend({_doReset:function(){this._hash=new n.init([new r.init(1779033703,4089235720),new r.init(3144134277,2227873595),new r.init(1013904242,4271175723),new r.init(2773480762,1595750129),new r.init(1359893119,2917565137),new r.init(2600822924,725511199),new r.init(528734635,4215389547),new r.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],l=i[5],c=i[6],h=i[7],u=r.high,p=r.low,d=n.high,f=n.low,m=o.high,_=o.low,g=s.high,y=s.low,x=a.high,v=a.low,b=l.high,w=l.low,T=c.high,E=c.low,A=h.high,i=h.low,S=u,C=p,M=d,I=f,B=m,k=_,z=g,P=y,L=x,D=v,R=b,O=w,F=T,N=E,U=A,j=i,V=0;V<80;V++){var G,$,q=te[V];V<16?($=q.high=0|e[t+2*V],G=q.low=0|e[t+2*V+1]):(Q=(Z=te[V-15]).high,H=Z.low,X=(K=te[V-2]).high,W=K.low,Y=(J=te[V-7]).high,Z=J.low,J=(K=te[V-16]).high,$=($=((Q>>>1|H<<31)^(Q>>>8|H<<24)^Q>>>7)+Y+((G=(Y=(H>>>1|Q<<31)^(H>>>8|Q<<24)^(H>>>7|Q<<25))+Z)>>>0<Y>>>0?1:0))+((X>>>19|W<<13)^(X<<3|W>>>29)^X>>>6)+((G+=H=(W>>>19|X<<13)^(W<<3|X>>>29)^(W>>>6|X<<26))>>>0<H>>>0?1:0),G+=Q=K.low,q.high=$=$+J+(G>>>0<Q>>>0?1:0),q.low=G);var Z=L&R^~L&F,Y=D&O^~D&N,W=S&M^S&B^M&B,X=(C>>>28|S<<4)^(C<<30|S>>>2)^(C<<25|S>>>7),H=ee[V],K=H.high,J=H.low,Q=j+((D>>>14|L<<18)^(D>>>18|L<<14)^(D<<23|L>>>9)),q=U+((L>>>14|D<<18)^(L>>>18|D<<14)^(L<<23|D>>>9))+(Q>>>0<j>>>0?1:0),H=X+(C&I^C&k^I&k),U=F,j=N,F=R,N=O,R=L,O=D,L=z+(q=(q=(q=q+Z+((Q=Q+Y)>>>0<Y>>>0?1:0))+K+((Q=Q+J)>>>0<J>>>0?1:0))+$+((Q=Q+G)>>>0<G>>>0?1:0))+((D=P+Q|0)>>>0<P>>>0?1:0)|0,z=B,P=k,B=M,k=I,M=S,I=C,S=q+(((S>>>28|C<<4)^(S<<30|C>>>2)^(S<<25|C>>>7))+W+(H>>>0<X>>>0?1:0))+((C=Q+H|0)>>>0<Q>>>0?1:0)|0}p=r.low=p+C,r.high=u+S+(p>>>0<C>>>0?1:0),f=n.low=f+I,n.high=d+M+(f>>>0<I>>>0?1:0),_=o.low=_+k,o.high=m+B+(_>>>0<k>>>0?1:0),y=s.low=y+P,s.high=g+z+(y>>>0<P>>>0?1:0),v=a.low=v+D,a.high=x+L+(v>>>0<D>>>0?1:0),w=l.low=w+O,l.high=b+R+(w>>>0<O>>>0?1:0),E=c.low=E+N,c.high=T+F+(E>>>0<N>>>0?1:0),i=h.low=i+j,h.high=A+U+(i>>>0<j>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(128+r>>>10<<5)]=Math.floor(i/4294967296),t[31+(128+r>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(i),e.HmacSHA512=t._createHmacHelper(i)}(),s.SHA512)},function(e,t,i){e.exports=i(38)},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t){e.exports=a},function(e,t){e.exports=l},function(e,t,i){"use strict";var n=i(3),o=i(21),s=i(39),a=i(28);var r=function t(i){var e=new s(i),r=o(s.prototype.request,e);return n.extend(r,s.prototype,e),n.extend(r,e),r.create=function(e){return t(a(i,e))},r}(i(16));r.Axios=s,r.CanceledError=i(13),r.CancelToken=i(57),r.isCancel=i(27),r.VERSION=i(29).version,r.toFormData=i(24),r.AxiosError=i(8),r.Cancel=r.CanceledError,r.all=function(e){return Promise.all(e)},r.spread=i(58),r.isAxiosError=i(59),e.exports=r,e.exports.default=r},function(e,t,i){"use strict";var r=i(3),n=i(22),o=i(40),h=i(41),u=i(28),s=i(26),p=i(56),d=p.validators;function a(e){this.defaults=e,this.interceptors={request:new o,response:new o}}a.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=u(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";e=t.transitional;void 0!==e&&p.assertOptions(e,{silentJSONParsing:d.transitional(d.boolean),forcedJSONParsing:d.transitional(d.boolean),clarifyTimeoutError:d.transitional(d.boolean)},!1);var i=[],r=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});var n,o=[];if(this.interceptors.response.forEach(function(e){o.push(e.fulfilled,e.rejected)}),!r){var s=[h,void 0];for(Array.prototype.unshift.apply(s,i),s=s.concat(o),n=Promise.resolve(t);s.length;)n=n.then(s.shift(),s.shift());return n}for(var a=t;i.length;){var l=i.shift(),c=i.shift();try{a=l(a)}catch(e){c(e);break}}try{n=h(a)}catch(e){return Promise.reject(e)}for(;o.length;)n=n.then(o.shift(),o.shift());return n},a.prototype.getUri=function(e){e=u(this.defaults,e);var t=s(e.baseURL,e.url);return n(t,e.params,e.paramsSerializer)},r.forEach(["delete","get","head","options"],function(i){a.prototype[i]=function(e,t){return this.request(u(t||{},{method:i,url:e,data:(t||{}).data}))}}),r.forEach(["post","put","patch"],function(n){function e(r){return function(e,t,i){return this.request(u(i||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:e,data:t}))}}a.prototype[n]=e(),a.prototype[n+"Form"]=e(!0)}),e.exports=a},function(e,t,i){"use strict";var r=i(3);function n(){this.handlers=[]}n.prototype.use=function(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1},n.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},n.prototype.forEach=function(t){r.forEach(this.handlers,function(e){null!==e&&t(e)})},e.exports=n},function(e,t,i){"use strict";var r=i(3),n=i(42),o=i(27),s=i(16),a=i(13);function l(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a}e.exports=function(t){return l(t),t.headers=t.headers||{},t.data=n.call(t,t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),r.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||s.adapter)(t).then(function(e){return l(t),e.data=n.call(t,e.data,e.headers,t.transformResponse),e},function(e){return o(e)||(l(t),e&&e.response&&(e.response.data=n.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(e,t,i){"use strict";var n=i(3),o=i(16);e.exports=function(t,i,e){var r=this||o;return n.forEach(e,function(e){t=e.call(r,t,i)}),t}},function(e,t,i){"use strict";var n=i(3);e.exports=function(i,r){n.forEach(i,function(e,t){t!==r&&t.toUpperCase()===r.toUpperCase()&&(i[r]=e,delete i[t])})}},function(e,z,P){"use strict";!function(e){var a=P(45),o=P(46),s=P(47);function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function n(e,t){if(i()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(e=null===e?new u(t):e).length=t,e}function u(e,t,i){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,i);if("number"!=typeof e)return r(this,e,t,i);if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return c(this,e)}function r(e,t,i,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,i,r){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===i&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,i):new Uint8Array(t,i,r);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,i,r):"string"==typeof t?function(e,t,i){"string"==typeof i&&""!==i||(i="utf8");if(!u.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,i),i=(e=n(e,r)).write(t,i);i!==r&&(e=e.slice(0,i));return e}(e,t,i):function(e,t){if(u.isBuffer(t)){var i=0|p(t.length);return 0===(e=n(e,i)).length?e:(t.copy(e,0,0,i),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||function(e){return e!=e}(t.length)?n(e,0):h(e,t);if("Buffer"===t.type&&s(t.data))return h(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(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 c(e,t){if(l(t),e=n(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function h(e,t){var i=t.length<0?0:0|p(t.length);e=n(e,i);for(var r=0;r<i;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;var i=(e="string"!=typeof e?""+e:e).length;if(0===i)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return I(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return B(e).length;default:if(r)return I(e).length;t=(""+t).toLowerCase(),r=!0}}function t(e,t,i){var r,n,o,s=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((i=void 0===i||i>this.length?this.length:i)<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":return function(e,t,i){var r=e.length;(!t||t<0)&&(t=0);(!i||i<0||r<i)&&(i=r);for(var n="",o=t;o<i;++o)n+=function(e){return e<16?"0"+e.toString(16):e.toString(16)}(e[o]);return n}(this,t,i);case"utf8":case"utf-8":return x(this,t,i);case"ascii":return function(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(127&e[n]);return r}(this,t,i);case"latin1":case"binary":return function(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(e[n]);return r}(this,t,i);case"base64":return r=this,o=i,0===(n=t)&&o===r.length?a.fromByteArray(r):a.fromByteArray(r.slice(n,o));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,i){for(var r=e.slice(t,i),n="",o=0;o<r.length;o+=2)n+=String.fromCharCode(r[o]+256*r[o+1]);return n}(this,t,i);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function f(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function m(e,t,i,r,n){if(0===e.length)return-1;if("string"==typeof i?(r=i,i=0):2147483647<i?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,(i=(i=isNaN(i)?n?0:e.length-1:i)<0?e.length+i:i)>=e.length){if(n)return-1;i=e.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:_(e,t,i,r,n);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(n?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,i):_(e,[t],i,r,n);throw new TypeError("val must be string, number or Buffer")}function _(e,t,i,r,n){var o=1,s=e.length,a=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s/=o=2,a/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n)for(var c=-1,h=i;h<s;h++)if(l(e,h)===l(t,-1===c?0:h-c)){if(h-(c=-1===c?h:c)+1===a)return c*o}else-1!==c&&(h-=h-c),c=-1;else for(h=i=s<i+a?s-a:i;0<=h;h--){for(var u=!0,p=0;p<a;p++)if(l(e,h+p)!==l(t,p)){u=!1;break}if(u)return h}return-1}function g(e,t,i,r){return k(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,r)}function y(e,t,i,r){return k(function(e,t){for(var i,r,n=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),i=r>>8,r=r%256,n.push(r),n.push(i);return n}(t,e.length-i),e,i,r)}function x(e,t,i){i=Math.min(e.length,i);for(var r=[],n=t;n<i;){var o,s,a,l,c=e[n],h=null,u=239<c?4:223<c?3:191<c?2:1;if(n+u<=i)switch(u){case 1:c<128&&(h=c);break;case 2:128==(192&(o=e[n+1]))&&127<(l=(31&c)<<6|63&o)&&(h=l);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&2047<(l=(15&c)<<12|(63&o)<<6|63&s)&&(l<55296||57343<l)&&(h=l);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&65535<(l=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)&&l<1114112&&(h=l)}null===h?(h=65533,u=1):65535<h&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),n+=u}return function(e){var t=e.length;if(t<=v)return String.fromCharCode.apply(String,e);var i="",r=0;for(;r<t;)i+=String.fromCharCode.apply(String,e.slice(r,r+=v));return i}(r)}z.Buffer=u,z.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},z.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),z.kMaxLength=i(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,i){return r(null,e,t,i)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,i){return r=null,t=t,i=i,l(e=e),!(e<=0)&&void 0!==t?"string"==typeof i?n(r,e).fill(t,i):n(r,e).fill(t):n(r,e);var r},u.allocUnsafe=function(e){return c(null,e)},u.allocUnsafeSlow=function(e){return c(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,r=t.length,n=0,o=Math.min(i,r);n<o;++n)if(e[n]!==t[n]){i=e[n],r=t[n];break}return i<r?-1:r<i?1:0},u.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}},u.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);if(void 0===t)for(n=t=0;n<e.length;++n)t+=e[n].length;for(var i=u.allocUnsafe(t),r=0,n=0;n<e.length;++n){var o=e[n];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,r),r+=o.length}return i},u.byteLength=d,u.prototype._isBuffer=!0,u.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)f(this,t,t+1);return this},u.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)f(this,t,t+3),f(this,t+1,t+2);return this},u.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)f(this,t,t+7),f(this,t+1,t+6),f(this,t+2,t+5),f(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0==e?"":0===arguments.length?x(this,0,e):t.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",t=z.INSPECT_MAX_BYTES;return 0<this.length&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,i,r,n){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===i&&(i=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),(t=void 0===t?0:t)<0||i>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(n<=r&&i<=t)return 0;if(n<=r)return-1;if(i<=t)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(r>>>=0),s=(i>>>=0)-(t>>>=0),a=Math.min(o,s),l=this.slice(r,n),c=e.slice(t,i),h=0;h<a;++h)if(l[h]!==c[h]){o=l[h],s=c[h];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},u.prototype.indexOf=function(e,t,i){return m(this,e,t,i,!0)},u.prototype.lastIndexOf=function(e,t,i){return m(this,e,t,i,!1)},u.prototype.write=function(e,t,i,r){if(void 0===t)r="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)r=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-t;if((void 0===i||n<i)&&(i=n),0<e.length&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r=r||"utf8";for(var o,s,a,l=!1;;)switch(r){case"hex":return function(e,t,i,r){i=Number(i)||0;var n=e.length-i;if((!r||n<(r=Number(r)))&&(r=n),(n=t.length)%2!=0)throw new TypeError("Invalid hex string");n/2<r&&(r=n/2);for(var o=0;o<r;++o){var s=parseInt(t.substr(2*o,2),16);if(isNaN(s))return o;e[i+o]=s}return o}(this,e,t,i);case"utf8":case"utf-8":return s=t,a=i,k(I(e,(o=this).length-s),o,s,a);case"ascii":return g(this,e,t,i);case"latin1":case"binary":return g(this,e,t,i);case"base64":return o=this,s=t,a=i,k(B(e),o,s,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y(this,e,t,i);default:if(l)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),l=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var v=4096;function b(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(i<e+t)throw new RangeError("Trying to access beyond buffer length")}function w(e,t,i,r,n,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n<t||t<o)throw new RangeError('"value" argument is out of bounds');if(i+r>e.length)throw new RangeError("Index out of range")}function T(e,t,i,r){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(e.length-i,2);n<o;++n)e[i+n]=(t&255<<8*(r?n:1-n))>>>8*(r?n:1-n)}function E(e,t,i,r){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(e.length-i,4);n<o;++n)e[i+n]=t>>>8*(r?n:3-n)&255}function A(e,t,i,r){if(i+r>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function S(e,t,i,r,n){return n||A(e,0,i,4),o.write(e,t,i,r,23,4),i+4}function C(e,t,i,r,n){return n||A(e,0,i,8),o.write(e,t,i,r,52,8),i+8}u.prototype.slice=function(e,t){var i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):i<e&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):i<t&&(t=i),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else for(var r=t-e,n=new u(r,void 0),o=0;o<r;++o)n[o]=this[o+e];return n},u.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||b(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return r},u.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||b(e,t,this.length);for(var r=this[e+--t],n=1;0<t&&(n*=256);)r+=this[e+--t]*n;return r},u.prototype.readUInt8=function(e,t){return t||b(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||b(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||b(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||b(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||b(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||b(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return(n*=128)<=r&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||b(e,t,this.length);for(var r=t,n=1,o=this[e+--r];0<r&&(n*=256);)o+=this[e+--r]*n;return(n*=128)<=o&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return t||b(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||b(e,2,this.length);e=this[e]|this[e+1]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt16BE=function(e,t){t||b(e,2,this.length);e=this[e+1]|this[e]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt32LE=function(e,t){return t||b(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||b(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||b(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||b(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||b(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||b(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,i,r){e=+e,t|=0,i|=0,r||w(this,e,t,i,Math.pow(2,8*i)-1,0);var n=1,o=0;for(this[t]=255&e;++o<i&&(n*=256);)this[t+o]=e/n&255;return t+i},u.prototype.writeUIntBE=function(e,t,i,r){e=+e,t|=0,i|=0,r||w(this,e,t,i,Math.pow(2,8*i)-1,0);var n=i-1,o=1;for(this[t+n]=255&e;0<=--n&&(o*=256);)this[t+n]=e/o&255;return t+i},u.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):E(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):E(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,i,r){e=+e,t|=0,r||w(this,e,t,i,(r=Math.pow(2,8*i-1))-1,-r);var n=0,o=1,s=0;for(this[t]=255&e;++n<i&&(o*=256);)e<0&&0===s&&0!==this[t+n-1]&&(s=1),this[t+n]=(e/o>>0)-s&255;return t+i},u.prototype.writeIntBE=function(e,t,i,r){e=+e,t|=0,r||w(this,e,t,i,(r=Math.pow(2,8*i-1))-1,-r);var n=i-1,o=1,s=0;for(this[t+n]=255&e;0<=--n&&(o*=256);)e<0&&0===s&&0!==this[t+n+1]&&(s=1),this[t+n]=(e/o>>0)-s&255;return t+i},u.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&(e=e<0?255+e+1:e),t+1},u.prototype.writeInt16LE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):E(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||w(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):E(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,i){return S(this,e,t,!0,i)},u.prototype.writeFloatBE=function(e,t,i){return S(this,e,t,!1,i)},u.prototype.writeDoubleLE=function(e,t,i){return C(this,e,t,!0,i)},u.prototype.writeDoubleBE=function(e,t,i){return C(this,e,t,!1,i)},u.prototype.copy=function(e,t,i,r){if(i=i||0,r||0===r||(r=this.length),t>=e.length&&(t=e.length),(r=0<r&&r<i?i:r)===i)return 0;if(0===e.length||0===this.length)return 0;if((t=t||0)<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length);var n,o=(r=e.length-t<r-i?e.length-t+i:r)-i;if(this===e&&i<t&&t<r)for(n=o-1;0<=n;--n)e[n+t]=this[n+i];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)e[n+t]=this[n+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+o),t);return o},u.prototype.fill=function(e,t,i,r){if("string"==typeof e){var n;if("string"==typeof t?(r=t,t=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),1!==e.length||(n=e.charCodeAt(0))<256&&(e=n),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;if(t>>>=0,i=void 0===i?this.length:i>>>0,"number"==typeof(e=e||0))for(a=t;a<i;++a)this[a]=e;else for(var o=u.isBuffer(e)?e:I(new u(e,r).toString()),s=o.length,a=0;a<i-t;++a)this[a+t]=o[a%s];return this};var M=/[^+\/0-9A-Za-z-_]/g;function I(e,t){var i;t=t||1/0;for(var r=e.length,n=null,o=[],s=0;s<r;++s){if(55295<(i=e.charCodeAt(s))&&i<57344){if(!n){if(56319<i){-1<(t-=3)&&o.push(239,191,189);continue}if(s+1===r){-1<(t-=3)&&o.push(239,191,189);continue}n=i;continue}if(i<56320){-1<(t-=3)&&o.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&-1<(t-=3)&&o.push(239,191,189);if(n=null,i<128){if(--t<0)break;o.push(i)}else if(i<2048){if((t-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function B(e){return a.toByteArray(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function k(e,t,i,r){for(var n=0;n<r&&!(n+i>=t.length||n>=e.length);++n)t[n+i]=e[n];return n}}.call(this,P(18))},function(e,t,i){"use strict";t.byteLength=function(e){var t=h(e),e=t[0],t=t[1];return 3*(e+t)/4-t},t.toByteArray=function(e){var t,i,r=h(e),n=r[0],r=r[1],o=new c(function(e,t){return 3*(e+t)/4-t}(n,r)),s=0,a=0<r?n-4:n;for(i=0;i<a;i+=4)t=l[e.charCodeAt(i)]<<18|l[e.charCodeAt(i+1)]<<12|l[e.charCodeAt(i+2)]<<6|l[e.charCodeAt(i+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=255&t;2===r&&(t=l[e.charCodeAt(i)]<<2|l[e.charCodeAt(i+1)]>>4,o[s++]=255&t);1===r&&(t=l[e.charCodeAt(i)]<<10|l[e.charCodeAt(i+1)]<<4|l[e.charCodeAt(i+2)]>>2,o[s++]=t>>8&255,o[s++]=255&t);return o},t.fromByteArray=function(e){for(var t,i=e.length,r=i%3,n=[],o=0,s=i-r;o<s;o+=16383)n.push(function(e,t,i){for(var r,n=[],o=t;o<i;o+=3)r=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),n.push(function(e){return a[e>>18&63]+a[e>>12&63]+a[e>>6&63]+a[63&e]}(r));return n.join("")}(e,o,s<o+16383?s:o+16383));1==r?(t=e[i-1],n.push(a[t>>2]+a[t<<4&63]+"==")):2==r&&(t=(e[i-2]<<8)+e[i-1],n.push(a[t>>10]+a[t>>4&63]+a[t<<2&63]+"="));return n.join("")};for(var a=[],l=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=r.length;n<o;++n)a[n]=r[n],l[r.charCodeAt(n)]=n;function h(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");e=e.indexOf("=");return[e=-1===e?t:e,e===t?0:4-e%4]}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,p=i?-1:1,i=e[t+u];for(u+=p,o=i&(1<<-h)-1,i>>=-h,h+=a;0<h;o=256*o+e[t+u],u+=p,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;0<h;s=256*s+e[t+u],u+=p,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(i?-1:1);s+=Math.pow(2,r),o-=c}return(i?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,i,r,n,o){var s,a,l=8*o-n-1,c=(1<<l)-1,h=c>>1,u=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,o=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*(r=Math.pow(2,-s))<1&&(s--,r*=2),2<=(t+=1<=s+h?u/r:u*Math.pow(2,1-h))*r&&(s++,r/=2),c<=s+h?(a=0,s=c):1<=s+h?(a=(t*r-1)*Math.pow(2,n),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,n),s=0));8<=n;e[i+p]=255&a,p+=d,a/=256,n-=8);for(s=s<<n|a,l+=n;0<l;e[i+p]=255&s,p+=d,s/=256,l-=8);e[i+p-d]|=128*o}},function(e,t){var i={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==i.call(e)}},function(e,t,i){"use strict";var n=i(8);e.exports=function(e,t,i){var r=i.config.validateStatus;i.status&&r&&!r(i.status)?t(new n("Request failed with status code "+i.status,[n.ERR_BAD_REQUEST,n.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):e(i)}},function(e,t,i){"use strict";var a=i(3);e.exports=a.isStandardBrowserEnv()?{write:function(e,t,i,r,n,o){var s=[];s.push(e+"="+encodeURIComponent(t)),a.isNumber(i)&&s.push("expires="+new Date(i).toGMTString()),a.isString(r)&&s.push("path="+r),a.isString(n)&&s.push("domain="+n),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){e=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,i){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,i){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,i){"use strict";var n=i(3),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,i,r={};return e&&n.forEach(e.split("\n"),function(e){i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),i=n.trim(e.substr(i+1)),t&&(r[t]&&0<=o.indexOf(t)||(r[t]="set-cookie"===t?(r[t]||[]).concat([i]):r[t]?r[t]+", "+i:i))}),r}},function(e,t,i){"use strict";var r,n,o,s=i(3);function a(e){return n&&(o.setAttribute("href",e),e=o.href),o.setAttribute("href",e),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}e.exports=s.isStandardBrowserEnv()?(n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a"),r=a(window.location.href),function(e){e=s.isString(e)?a(e):e;return e.protocol===r.protocol&&e.host===r.host}):function(){return!0}},function(e,t,i){"use strict";e.exports=function(e){e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return e&&e[1]||""}},function(e,t){e.exports=null},function(e,t,i){"use strict";var s=i(29).version,l=i(8),r={};["object","boolean","number","function","string","symbol"].forEach(function(t,i){r[t]=function(e){return typeof e===t||"a"+(i<1?"n ":" ")+t}});var a={};r.transitional=function(r,n,i){function o(e,t){return"[Axios v"+s+"] Transitional option '"+e+"'"+t+(i?". "+i:"")}return function(e,t,i){if(!1===r)throw new l(o(t," has been removed"+(n?" in "+n:"")),l.ERR_DEPRECATED);return n&&!a[t]&&(a[t]=!0,console.warn(o(t," has been deprecated since v"+n+" and will be removed in the near future"))),!r||r(e,t,i)}},e.exports={assertOptions:function(e,t,i){if("object"!=typeof e)throw new l("options must be an object",l.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),n=r.length;0<n--;){var o=r[n],s=t[o];if(s){var a=e[o],a=void 0===a||s(a,o,e);if(!0!==a)throw new l("option "+o+" must be "+a,l.ERR_BAD_OPTION_VALUE)}else if(!0!==i)throw new l("Unknown option "+o,l.ERR_BAD_OPTION)}},validators:r}},function(e,t,i){"use strict";var n=i(13);function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var r=this;this.promise.then(function(e){if(r._listeners){for(var t=r._listeners.length,i=0;i<t;i++)r._listeners[i](e);r._listeners=null}}),this.promise.then=function(e){var t,e=new Promise(function(e){r.subscribe(e),t=e}).then(e);return e.cancel=function(){r.unsubscribe(t)},e},e(function(e){r.reason||(r.reason=new n(e),t(r.reason))})}r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},r.prototype.unsubscribe=function(e){!this._listeners||-1!==(e=this._listeners.indexOf(e))&&this._listeners.splice(e,1)},r.source=function(){var t;return{token:new r(function(e){t=e}),cancel:t}},e.exports=r},function(e,t,i){"use strict";e.exports=function(t){return function(e){return t.apply(null,e)}}},function(e,t,i){"use strict";var r=i(3);e.exports=function(e){return r.isObject(e)&&!0===e.isAxiosError}},function(e,t){},function(e,t,i){var r;e.exports=(r=i(2),function(){var e,n;"function"==typeof ArrayBuffer&&(e=r.lib.WordArray,n=e.init,(e.init=function(e){if((e=(e=e instanceof ArrayBuffer?new Uint8Array(e):e)instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e)instanceof Uint8Array){for(var t=e.byteLength,i=[],r=0;r<t;r++)i[r>>>2]|=e[r]<<24-r%4*8;n.call(this,i,t)}else n.apply(this,arguments)}).prototype=e)}(),r.lib.WordArray)},function(e,t,i){var r;e.exports=(r=i(2),function(){var n=r.lib.WordArray,e=r.enc;e.Utf16=e.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n+=2){var o=t[n>>>2]>>>16-n%4*8&65535;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>1]|=e.charCodeAt(r)<<16-r%2*16;return n.create(i,2*t)}};function s(e){return e<<8&4278255360|e>>>8&16711935}e.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n+=2){var o=s(t[n>>>2]>>>16-n%4*8&65535);r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>1]|=s(e.charCodeAt(r)<<16-r%2*16);return n.create(i,2*t)}}}(),r.enc.Utf16)},function(e,t,i){var r;e.exports=(r=i(2),function(){var l=r.lib.WordArray;r.enc.Base64url={stringify:function(e,t=!0){var i=e.words,r=e.sigBytes,n=t?this._safe_map:this._map;e.clamp();for(var o=[],s=0;s<r;s+=3)for(var a=(i[s>>>2]>>>24-s%4*8&255)<<16|(i[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|i[s+2>>>2]>>>24-(s+2)%4*8&255,l=0;l<4&&s+.75*l<r;l++)o.push(n.charAt(a>>>6*(3-l)&63));var c=n.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e,t=!0){var i=e.length,r=t?this._safe_map:this._map;if(!(n=this._reverseMap))for(var n=this._reverseMap=[],o=0;o<r.length;o++)n[r.charCodeAt(o)]=o;t=r.charAt(64);return!t||-1!==(t=e.indexOf(t))&&(i=t),function(e,t,i){for(var r=[],n=0,o=0;o<t;o++){var s,a;o%4&&(s=i[e.charCodeAt(o-1)]<<o%4*2,a=i[e.charCodeAt(o)]>>>6-o%4*2,a=s|a,r[n>>>2]|=a<<24-n%4*8,n++)}return l.create(r,n)}(e,i,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),r.enc.Base64url)},function(e,t,i){var n;e.exports=(n=i(2),i(30),function(){var e=n,t=e.lib.WordArray,i=e.algo,r=i.SHA256,i=i.SHA224=r.extend({_doReset:function(){this._hash=new t.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=r._doFinalize.call(this);return e.sigBytes-=4,e}});e.SHA224=r._createHelper(i),e.HmacSHA224=r._createHmacHelper(i)}(),n.SHA224)},function(e,t,i){var o;e.exports=(o=i(2),i(14),i(31),function(){var e=o,t=e.x64,i=t.Word,r=t.WordArray,t=e.algo,n=t.SHA512,t=t.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new i.init(3418070365,3238371032),new i.init(1654270250,914150663),new i.init(2438529370,812702999),new i.init(355462360,4144912697),new i.init(1731405415,4290775857),new i.init(2394180231,1750603025),new i.init(3675008525,1694076839),new i.init(1203062813,3204075428)])},_doFinalize:function(){var e=n._doFinalize.call(this);return e.sigBytes-=16,e}});e.SHA384=n._createHelper(t),e.HmacSHA384=n._createHmacHelper(t)}(),o.SHA384)},function(e,t,i){var n;e.exports=(n=i(2),i(14),function(h){var e=n,t=e.lib,u=t.WordArray,r=t.Hasher,p=e.x64.Word,t=e.algo,S=[],C=[],M=[];!function(){for(var e=1,t=0,i=0;i<24;i++){S[e+5*t]=(i+1)*(i+2)/2%64;var r=(2*e+3*t)%5;e=t%5,t=r}for(e=0;e<5;e++)for(t=0;t<5;t++)C[e+5*t]=t+(2*e+3*t)%5*5;for(var n=1,o=0;o<24;o++){for(var s,a=0,l=0,c=0;c<7;c++)1&n&&((s=(1<<c)-1)<32?l^=1<<s:a^=1<<s-32),128&n?n=n<<1^113:n<<=1;M[o]=p.create(a,l)}}();var I=[];!function(){for(var e=0;e<25;e++)I[e]=p.create()}();t=t.SHA3=r.extend({cfg:r.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new p.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,r=this.blockSize/2,n=0;n<r;n++){var o=e[t+2*n],s=e[t+2*n+1],o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);(w=i[n]).high^=s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),w.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var c=0,h=0,u=0;u<5;u++)c^=(w=i[l+5*u]).high,h^=w.low;var p=I[l];p.high=c,p.low=h}for(l=0;l<5;l++)for(var d=I[(l+4)%5],f=I[(l+1)%5],m=f.high,f=f.low,c=d.high^(m<<1|f>>>31),h=d.low^(f<<1|m>>>31),u=0;u<5;u++)(w=i[l+5*u]).high^=c,w.low^=h;for(var _=1;_<25;_++){var g=(w=i[_]).high,y=w.low,x=S[_];h=x<32?(c=g<<x|y>>>32-x,y<<x|g>>>32-x):(c=y<<x-32|g>>>64-x,g<<x-32|y>>>64-x);x=I[C[_]];x.high=c,x.low=h}var v=I[0],b=i[0];v.high=b.high,v.low=b.low;for(l=0;l<5;l++)for(u=0;u<5;u++){var w=i[_=l+5*u],T=I[_],E=I[(l+1)%5+5*u],A=I[(l+2)%5+5*u];w.high=T.high^~E.high&A.high,w.low=T.low^~E.low&A.low}w=i[0],b=M[a];w.high^=b.high,w.low^=b.low}},_doFinalize:function(){var e=this._data,t=e.words,i=(this._nDataBytes,8*e.sigBytes),r=32*this.blockSize;t[i>>>5]|=1<<24-i%32,t[(h.ceil((1+i)/r)*r>>>5)-1]|=128,e.sigBytes=4*t.length,this._process();for(var n=this._state,t=this.cfg.outputLength/8,o=t/8,s=[],a=0;a<o;a++){var l=n[a],c=l.high,l=l.low,c=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8);s.push(l=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)),s.push(c)}return new u.init(s,t)},clone:function(){for(var e=r.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});e.SHA3=r._createHelper(t),e.HmacSHA3=r._createHmacHelper(t)}(Math),n.SHA3)},function(e,t,i){var n;e.exports=(n=i(2),function(){var e=n,t=e.lib,i=t.WordArray,r=t.Hasher,t=e.algo,T=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),E=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),A=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),S=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),C=i.create([0,1518500249,1859775393,2400959708,2840853838]),M=i.create([1352829926,1548603684,1836072691,2053994217,0]),t=t.RIPEMD160=r.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,n=e[r];e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}for(var o,s,a,l,c,h,u=this._hash.words,p=C.words,d=M.words,f=T.words,m=E.words,_=A.words,g=S.words,y=o=u[0],x=s=u[1],v=a=u[2],b=l=u[3],w=c=u[4],i=0;i<80;i+=1)h=o+e[t+f[i]]|0,h+=i<16?(s^a^l)+p[0]:i<32?I(s,a,l)+p[1]:i<48?((s|~a)^l)+p[2]:i<64?B(s,a,l)+p[3]:(s^(a|~l))+p[4],h=(h=k(h|=0,_[i]))+c|0,o=c,c=l,l=k(a,10),a=s,s=h,h=y+e[t+m[i]]|0,h+=i<16?(x^(v|~b))+d[0]:i<32?B(x,v,b)+d[1]:i<48?((x|~v)^b)+d[2]:i<64?I(x,v,b)+d[3]:(x^v^b)+d[4],h=(h=k(h|=0,g[i]))+w|0,y=w,w=b,b=k(v,10),v=x,x=h;h=u[1]+a+b|0,u[1]=u[2]+l+w|0,u[2]=u[3]+c+y|0,u[3]=u[4]+o+x|0,u[4]=u[0]+s+v|0,u[0]=h},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var t=this._hash,n=t.words,o=0;o<5;o++){var s=n[o];n[o]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return t},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function I(e,t,i){return e&t|~e&i}function B(e,t,i){return e&i|t&~i}function k(e,t){return e<<t|e>>>32-t}e.RIPEMD160=r._createHelper(t),e.HmacRIPEMD160=r._createHmacHelper(t)}(Math),n.RIPEMD160)},function(e,t,i){var o;e.exports=(o=i(2),i(19),i(20),function(){var e=o,t=e.lib,i=t.Base,g=t.WordArray,r=e.algo,t=r.SHA1,y=r.HMAC,n=r.PBKDF2=i.extend({cfg:i.extend({keySize:4,hasher:t,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=y.create(i.hasher,e),n=g.create(),o=g.create([1]),s=n.words,a=o.words,l=i.keySize,c=i.iterations;s.length<l;){var h=r.update(t).finalize(o);r.reset();for(var u=h.words,p=u.length,d=h,f=1;f<c;f++){d=r.finalize(d),r.reset();for(var m=d.words,_=0;_<p;_++)u[_]^=m[_]}n.concat(h),a[0]++}return n.sigBytes=4*l,n}});e.PBKDF2=function(e,t,i){return n.create(i).compute(e,t)}}(),o.PBKDF2)},function(e,t,i){var r;e.exports=(r=i(2),i(4),r.mode.CFB=function(){var e=r.lib.BlockCipherMode.extend();function o(e,t,i,r){var n,o=this._iv;o?(n=o.slice(0),this._iv=void 0):n=this._prevBlock,r.encryptBlock(n,0);for(var s=0;s<i;s++)e[t+s]^=n[s]}return e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize;o.call(this,e,t,r,i),this._prevBlock=e.slice(t,t+r)}}),e.Decryptor=e.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=e.slice(t,t+r);o.call(this,e,t,r,i),this._prevBlock=n}}),e}(),r.mode.CFB)},function(e,t,i){var r;e.exports=(r=i(2),i(4),r.mode.CTR=function(){var e=r.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0);var s=o.slice(0);i.encryptBlock(s,0),o[r-1]=o[r-1]+1|0;for(var a=0;a<r;a++)e[t+a]^=s[a]}});return e.Decryptor=t,e}(),r.mode.CTR)},function(e,t,i){var r;e.exports=(r=i(2),i(4),r.mode.CTRGladman=function(){var e=r.lib.BlockCipherMode.extend();function l(e){var t,i,r;return 255==(e>>24&255)?(i=e>>8&255,r=255&e,255===(t=e>>16&255)?(t=0,255===i?(i=0,255===r?r=0:++r):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=r):e+=1<<24,e}var t=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0),0===((n=o)[0]=l(n[0]))&&(n[1]=l(n[1]));var s=o.slice(0);i.encryptBlock(s,0);for(var a=0;a<r;a++)e[t+a]^=s[a]}});return e.Decryptor=t,e}(),r.mode.CTRGladman)},function(e,t,i){var r;e.exports=(r=i(2),i(4),r.mode.OFB=function(){var e=r.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=this._iv,o=this._keystream;n&&(o=this._keystream=n.slice(0),this._iv=void 0),i.encryptBlock(o,0);for(var s=0;s<r;s++)e[t+s]^=o[s]}});return e.Decryptor=t,e}(),r.mode.OFB)},function(e,t,i){var r;e.exports=(r=i(2),i(4),r.mode.ECB=function(){var e=r.lib.BlockCipherMode.extend();return e.Encryptor=e.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),e.Decryptor=e.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),e}(),r.mode.ECB)},function(e,t,i){e.exports=(e=i(2),i(4),e.pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,t=4*t,t=t-i%t,i=i+t-1;e.clamp(),e.words[i>>>2]|=t<<24-i%4*8,e.sigBytes+=t},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923)},function(e,t,i){var r;e.exports=(r=i(2),i(4),r.pad.Iso10126={pad:function(e,t){t*=4,t-=e.sigBytes%t;e.concat(r.lib.WordArray.random(t-1)).concat(r.lib.WordArray.create([t<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Iso10126)},function(e,t,i){var r;e.exports=(r=i(2),i(4),r.pad.Iso97971={pad:function(e,t){e.concat(r.lib.WordArray.create([2147483648],1)),r.pad.ZeroPadding.pad(e,t)},unpad:function(e){r.pad.ZeroPadding.unpad(e),e.sigBytes--}},r.pad.Iso97971)},function(e,t,i){e.exports=(e=i(2),i(4),e.pad.ZeroPadding={pad:function(e,t){t*=4;e.clamp(),e.sigBytes+=t-(e.sigBytes%t||t)},unpad:function(e){for(var t=e.words,i=e.sigBytes-1,i=e.sigBytes-1;0<=i;i--)if(t[i>>>2]>>>24-i%4*8&255){e.sigBytes=i+1;break}}},e.pad.ZeroPadding)},function(e,t,i){e.exports=(e=i(2),i(4),e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding)},function(e,t,i){var r;e.exports=(r=i(2),i(4),function(){var t=r.lib.CipherParams,i=r.enc.Hex;r.format.Hex={stringify:function(e){return e.ciphertext.toString(i)},parse:function(e){e=i.parse(e);return t.create({ciphertext:e})}}}(),r.format.Hex)},function(e,t,i){var r;e.exports=(r=i(2),i(9),i(10),i(7),i(4),function(){var e=r,t=e.lib.BlockCipher,i=e.algo,c=[],h=[],u=[],p=[],d=[],f=[],m=[],_=[],g=[],y=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var i=0,r=0,t=0;t<256;t++){var n=r^r<<1^r<<2^r<<3^r<<4;c[i]=n=n>>>8^255&n^99;var o=e[h[n]=i],s=e[o],a=e[s],l=257*e[n]^16843008*n;u[i]=l<<24|l>>>8,p[i]=l<<16|l>>>16,d[i]=l<<8|l>>>24,f[i]=l,m[n]=(l=16843009*a^65537*s^257*o^16843008*i)<<24|l>>>8,_[n]=l<<16|l>>>16,g[n]=l<<8|l>>>24,y[n]=l,i?(i=o^e[e[e[a^o]]],r^=e[e[r]]):i=r=1}}();var x=[0,1,2,4,8,16,32,64,128,27,54],i=i.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,r=4*(1+(this._nRounds=6+i)),n=this._keySchedule=[],o=0;o<r;o++)o<i?n[o]=t[o]:(l=n[o-1],o%i?6<i&&o%i==4&&(l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[255&l]):(l=c[(l=l<<8|l>>>24)>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[255&l],l^=x[o/i|0]<<24),n[o]=n[o-i]^l);for(var s=this._invKeySchedule=[],a=0;a<r;a++){var l,o=r-a;l=a%4?n[o]:n[o-4],s[a]=a<4||o<=4?l:m[c[l>>>24]]^_[c[l>>>16&255]]^g[c[l>>>8&255]]^y[c[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,u,p,d,f,c)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,m,_,g,y,h);i=e[t+1];e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,r,n,o,s,a){for(var l=this._nRounds,c=e[t]^i[0],h=e[t+1]^i[1],u=e[t+2]^i[2],p=e[t+3]^i[3],d=4,f=1;f<l;f++)var m=r[c>>>24]^n[h>>>16&255]^o[u>>>8&255]^s[255&p]^i[d++],_=r[h>>>24]^n[u>>>16&255]^o[p>>>8&255]^s[255&c]^i[d++],g=r[u>>>24]^n[p>>>16&255]^o[c>>>8&255]^s[255&h]^i[d++],y=r[p>>>24]^n[c>>>16&255]^o[h>>>8&255]^s[255&u]^i[d++],c=m,h=_,u=g,p=y;m=(a[c>>>24]<<24|a[h>>>16&255]<<16|a[u>>>8&255]<<8|a[255&p])^i[d++],_=(a[h>>>24]<<24|a[u>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^i[d++],g=(a[u>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&h])^i[d++],y=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[h>>>8&255]<<8|a[255&u])^i[d++];e[t]=m,e[t+1]=_,e[t+2]=g,e[t+3]=y},keySize:8});e.AES=t._createHelper(i)}(),r.AES)},function(e,t,i){var o;e.exports=(o=i(2),i(9),i(10),i(7),i(4),function(){var e=o,t=e.lib,r=t.WordArray,i=t.BlockCipher,t=e.algo,c=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],h=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],p=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],d=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],n=t.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var r=c[i]-1;t[i]=e[r>>>5]>>>31-r%32&1}for(var n=this._subKeys=[],o=0;o<16;o++){for(var s=n[o]=[],a=u[o],i=0;i<24;i++)s[i/6|0]|=t[(h[i]-1+a)%28]<<31-i%6,s[4+(i/6|0)]|=t[28+(h[i+24]-1+a)%28]<<31-i%6;s[0]=s[0]<<1|s[0]>>>31;for(i=1;i<7;i++)s[i]=s[i]>>>4*(i-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(var l=this._invSubKeys=[],i=0;i<16;i++)l[i]=n[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],f.call(this,4,252645135),f.call(this,16,65535),m.call(this,2,858993459),m.call(this,8,16711935),f.call(this,1,1431655765);for(var r=0;r<16;r++){for(var n=i[r],o=this._lBlock,s=this._rBlock,a=0,l=0;l<8;l++)a|=p[l][((s^n[l])&d[l])>>>0];this._lBlock=s,this._rBlock=o^a}var c=this._lBlock;this._lBlock=this._rBlock,this._rBlock=c,f.call(this,1,1431655765),m.call(this,8,16711935),m.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function f(e,t){t=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=t,this._lBlock^=t<<e}function m(e,t){t=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=t,this._rBlock^=t<<e}e.DES=i._createHelper(n);t=t.TripleDES=i.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),i=e.length<4?e.slice(0,2):e.slice(2,4),e=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=n.createEncryptor(r.create(t)),this._des2=n.createEncryptor(r.create(i)),this._des3=n.createEncryptor(r.create(e))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=i._createHelper(t)}(),o.TripleDES)},function(e,t,i){var o;e.exports=(o=i(2),i(9),i(10),i(7),i(4),function(){var e=o,t=e.lib.StreamCipher,i=e.algo,r=i.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,r=this._S=[],n=0;n<256;n++)r[n]=n;for(var n=0,o=0;n<256;n++){var s=n%i,s=t[s>>>2]>>>24-s%4*8&255,o=(o+r[n]+s)%256,s=r[n];r[n]=r[o],r[o]=s}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=n.call(this)},keySize:8,ivSize:0});function n(){for(var e=this._S,t=this._i,i=this._j,r=0,n=0;n<4;n++){var i=(i+e[t=(t+1)%256])%256,o=e[t];e[t]=e[i],e[i]=o,r|=e[(e[t]+e[i])%256]<<24-8*n}return this._i=t,this._j=i,r}e.RC4=t._createHelper(r);i=i.RC4Drop=r.extend({cfg:r.cfg.extend({drop:192}),_doReset:function(){r._doReset.call(this);for(var e=this.cfg.drop;0<e;e--)n.call(this)}});e.RC4Drop=t._createHelper(i)}(),o.RC4)},function(e,t,i){var r;e.exports=(r=i(2),i(9),i(10),i(7),i(4),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,n=[],s=[],a=[],i=i.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);for(var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]],i=this._b=0;i<4;i++)l.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var o=t.words,s=o[0],a=o[1],t=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),o=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),s=t>>>16|4294901760&o,a=o<<16|65535&t;n[0]^=t,n[1]^=s,n[2]^=o,n[3]^=a,n[4]^=t,n[5]^=s,n[6]^=o,n[7]^=a;for(i=0;i<4;i++)l.call(this)}},_doProcessBlock:function(e,t){var i=this._X;l.call(this),n[0]=i[0]^i[5]>>>16^i[3]<<16,n[1]=i[2]^i[7]>>>16^i[5]<<16,n[2]=i[4]^i[1]>>>16^i[7]<<16,n[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8),e[t+r]^=n[r]},blockSize:4,ivSize:2});function l(){for(var e=this._X,t=this._C,i=0;i<8;i++)s[i]=t[i];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<s[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<s[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<s[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<s[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<s[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<s[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<s[6]>>>0?1:0)|0,this._b=t[7]>>>0<s[7]>>>0?1:0;for(i=0;i<8;i++){var r=e[i]+t[i],n=65535&r,o=r>>>16;a[i]=((n*n>>>17)+n*o>>>15)+o*o^((4294901760&r)*r|0)+((65535&r)*r|0)}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.Rabbit=t._createHelper(i)}(),r.Rabbit)},function(e,t,i){var r;e.exports=(r=i(2),i(9),i(10),i(7),i(4),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,n=[],s=[],a=[],i=i.RabbitLegacy=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]],n=this._b=0;n<4;n++)l.call(this);for(n=0;n<8;n++)r[n]^=i[n+4&7];if(t){var o=t.words,s=o[0],e=o[1],t=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),o=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),s=t>>>16|4294901760&o,e=o<<16|65535&t;r[0]^=t,r[1]^=s,r[2]^=o,r[3]^=e,r[4]^=t,r[5]^=s,r[6]^=o,r[7]^=e;for(n=0;n<4;n++)l.call(this)}},_doProcessBlock:function(e,t){var i=this._X;l.call(this),n[0]=i[0]^i[5]>>>16^i[3]<<16,n[1]=i[2]^i[7]>>>16^i[5]<<16,n[2]=i[4]^i[1]>>>16^i[7]<<16,n[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8),e[t+r]^=n[r]},blockSize:4,ivSize:2});function l(){for(var e=this._X,t=this._C,i=0;i<8;i++)s[i]=t[i];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<s[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<s[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<s[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<s[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<s[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<s[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<s[6]>>>0?1:0)|0,this._b=t[7]>>>0<s[7]>>>0?1:0;for(i=0;i<8;i++){var r=e[i]+t[i],n=65535&r,o=r>>>16;a[i]=((n*n>>>17)+n*o>>>15)+o*o^((4294901760&r)*r|0)+((65535&r)*r|0)}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.RabbitLegacy=t._createHelper(i)}(),r.RabbitLegacy)},function(e,t,i){"use strict";i.r(t),i.d(t,"default",function(){return Pe});var n;i(33),i(34),i(35),i(36),i(37);class r{constructor(e){this.app=e}runRender(){}onPointer(e){switch(e.type){case BABYLON.PointerEventTypes.POINTERMOVE:if(!this.app.ToolTips)return;e.pickInfo&&e.pickInfo.pickedPoint?this.app.ToolTips.update(e):this.app.ToolTips.close();break;case BABYLON.PointerEventTypes.POINTERWHEEL:this.app.CameraController._wheel(e.event),e.event.preventDefault()}}onKeyboard(e){e.type===BABYLON.KeyboardEventTypes.KEYDOWN&&70===e.event.keyCode&&prompt("请复制输入框内的视角参数",this.app.CameraController.getSightJson())}}class o{constructor(e){this.isFPS=!1,this.angle=Math.PI/2,this.direction=new BABYLON.Vector3(Math.cos(this.angle),0,Math.sin(this.angle)),this.isMoveLeft=!1,this.isMoveRight=!1,this.isMoveDown=!1,this.isMoveUp=!1,this.app=e,this.isFPS=!1}runRender(){var e;this.app.scene.activeCamera instanceof BABYLON.FreeCamera&&(this.isMoveDown||this.isMoveLeft||this.isMoveRight||this.isMoveUp)&&(e=this.app.CameraController.freeCamera.speed,this.isMoveLeft?(this.app.CameraController.freeCamera.rotation.y+=e,this.direction.copyFromFloats(0,0,0)):this.isMoveUp?this.direction.copyFromFloats(0,0,e):this.isMoveRight?(this.app.CameraController.freeCamera.rotation.y-=e,this.direction.copyFromFloats(0,0,0)):this.isMoveDown&&this.direction.copyFromFloats(0,0,-e),this.app.CameraController.freeCamera.getScene().useRightHandedSystem&&(this.direction.z*=-1),this.app.CameraController.freeCamera.getViewMatrix().invertToRef(this.app.CameraController.freeCamera._cameraTransformMatrix),BABYLON.Vector3.TransformNormalToRef(this.direction,this.app.CameraController.freeCamera._cameraTransformMatrix,this.app.CameraController.freeCamera._transformedDirection),this.app.CameraController.freeCamera.cameraDirection.addInPlace(this.app.CameraController.freeCamera._transformedDirection))}onPointer(e){switch(e.type){case BABYLON.PointerEventTypes.POINTERUP:if(this.isFPS)return;this.app.CameraController.freeCamera.position=BABYLON.Vector3.Zero(),this.app.CameraController.freeCamera.position.y=this.app.Project.current.height+1.5,this.app.scene.activeCamera=this.app.CameraController.freeCamera,this.app.CameraController.freeCamera.attachControl(this.app.canvas,!0),this.isFPS=!0;break;case BABYLON.PointerEventTypes.POINTERMOVE:break;case BABYLON.PointerEventTypes.POINTERWHEEL:e.event.preventDefault()}}onKeyboard(e){}}class p{static vector3ToJson(e){return{x:Math.floor(1e3*e.x)/1e3,y:Math.floor(1e3*e.y)/1e3,z:Math.floor(1e3*e.z)/1e3}}static vector3ARRToJson(e){let t=[];return e.forEach(e=>t.push({x:Math.floor(1e3*e.x)/1e3,y:Math.floor(1e3*e.y)/1e3,z:Math.floor(1e3*e.z)/1e3})),t}static ToVector3(e){return new BABYLON.Vector3(Math.floor(1e3*e.x)/1e3,Math.floor(1e3*e.y)/1e3,Math.floor(1e3*e.z)/1e3)}static ToARRVector3(e){let t=[];return e.forEach(e=>t.push(new BABYLON.Vector3(Math.floor(1e3*e.x)/1e3,Math.floor(1e3*e.y)/1e3,Math.floor(1e3*e.z)/1e3))),t}static computeBounds(e){let t=e.getChildMeshes(),i=e.getBoundingInfo();if(0<t.length){for(var r=t[0].getBoundingInfo(),n=r.minimum.add(t[0].position),o=r.maximum.add(t[0].position),s=1;s<t.length;s++)r=t[s].getBoundingInfo(),n=BABYLON.Vector3.Minimize(n,r.minimum.add(t[s].position)),o=BABYLON.Vector3.Maximize(o,r.maximum.add(t[s].position));i=new BABYLON.BoundingInfo(n,o)}return i}static computeBoundsToARR(e){for(var t=e[0].getBoundingInfo(),i=t.minimum.add(e[0].position),r=t.maximum.add(e[0].position),n=1;n<e.length;n++)t=e[n].getBoundingInfo(),i=BABYLON.Vector3.Minimize(i,t.minimum.add(e[n].position)),r=BABYLON.Vector3.Maximize(r,t.maximum.add(e[n].position));return new BABYLON.BoundingInfo(i,r)}static Expand(r,n){let o=new Array;var s=r.length;for(let i=0;i<s;i++){var a=r[i],l=r[0==i?s-1:i-1],c=r[i==s-1?0:i+1],h=l.x-a.x,u=l.z-a.z,p=this.norm(h,u);h/=p,u/=p;l=c.x-a.x,p=c.z-a.z,c=this.norm(l,p);l/=c,p/=c;c=-n/Math.sqrt((1-(h*l+u*p))/2);let e=h+l,t=u+p;c=0==this.norm(e,t)?0:c/this.norm(e,t);e*=c,t*=c,o[i]=new BABYLON.Vector3(e+a.x,0,t+a.z)}return o}static norm(e,t){return Math.sqrt(e*e+t*t)}static MergeMeshes(o,e){let s=new BABYLON.Mesh((new Date).getDate().toString(),e.scene);return setTimeout(()=>{let t=null,i;for(let e=0;e<o.length;e++){var r,n;o[e]&&(n=(r=o[e]).computeWorldMatrix(!0),i=BABYLON.VertexData.ExtractFromMesh(r,!0,!0),i.transform(n),t?t.merge(i,!0):t=i,r.dispose(!1,!0))}t.applyToMesh(s)}),s}static DeconsTructMesh(e,t,i){if(1<e.subMeshes.length){for(var r=BABYLON.VertexData.ExtractFromMesh(e,!0,!0),n=r.indices,o=r.normals,s=r.positions,a=r.uvs,l=new Array,c=0;c<e.subMeshes.length;c++){for(var h=new BABYLON.VertexData,u=n.slice(e.subMeshes[c].indexStart,e.subMeshes[c].indexStart+e.subMeshes[c].indexCount),p=o.slice(3*e.subMeshes[c].verticesStart,3*e.subMeshes[c].verticesStart+3*e.subMeshes[c].verticesCount),d=s.slice(3*e.subMeshes[c].verticesStart,3*e.subMeshes[c].verticesStart+3*e.subMeshes[c].verticesCount),f=a.slice(2*e.subMeshes[c].verticesStart,2*e.subMeshes[c].verticesStart+2*e.subMeshes[c].verticesCount),m=0;m<u.length;m++)u[m]=u[m]-e.subMeshes[c].verticesStart;h.indices=u,h.normals=p,h.positions=d,h.uvs=f;f=new BABYLON.Mesh(e.id+"-"+c,i.scene);h.applyToMesh(f),f.position.y=parseFloat(t),f.setEnabled(!1),l.push(f)}return e.dispose(!1,!0),l}return[e]}static getVisualAngle(e,t){let i={};var r=e.boundingSphere.radiusWorld,n=t.engine.getAspectRatio(t.CameraController.arcRotateCamera);let o=t.CameraController.arcRotateCamera.fov/1.2;return n<1&&(o=Math.atan(n*Math.tan(t.CameraController.arcRotateCamera.fov/2))),i.radius=1.1*Math.abs(r/Math.sin(o)),i.alpha=Math.PI/2,i.beta=Math.PI/4,i.focus=e.boundingSphere.center.clone(),i}static pathTransformation(i,r){let e=new BABYLON.Path3D(i);var n=e.getTangents();let o=[];for(let t=0;t<i.length;t++)if(0<t&&t<i.length-1){var s=i[t-1],a=i[t+1],l=i[t];let e=n[t-1];var c=n[t];if(!e.equals(c)){s=BABYLON.Vector3.Lerp(l,s,r/BABYLON.Vector3.Distance(s,l)),a=BABYLON.Vector3.Lerp(l,a,r/BABYLON.Vector3.Distance(a,l));let e=BABYLON.Curve3.CreateQuadraticBezier(s,l,a,10);o=o.concat(e.getPoints())}}else o.push(i[t]);return o}static createTube(e,t,i=.05,r){return BABYLON.MeshBuilder.CreateTube(e,{path:this.pathTransformation(t,i),radius:i/2},r.scene)}static getAngleFromVector2(e,t,i){var r=(e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y),t=(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x),r=Math.atan2(t,r);return Math.PI-r}static getAngleFromVector3(e,t,i){return this.getAngleFromVector2(new BABYLON.Vector2(e.x,e.z),new BABYLON.Vector2(t.x,t.z),new BABYLON.Vector2(i.x,i.z))}static RandomNumBoth(e,t){var i=t-e,t=Math.random();return e+Math.round(t*i)}}class s{constructor(e){this.app=e,this.arcRotateCamera=new BABYLON.ArcRotateCamera("arcRotateCamera",-Math.PI/4,Math.PI/4,50,new BABYLON.Vector3(0,0,0),this.app.scene),this.arcRotateCamera.pinchPrecision=200,this.arcRotateCamera.minZ=.3,this.arcRotateCamera.wheelDeltaPercentage=.01,this.frustrum=5,this.freeCamera=new BABYLON.FreeCamera("FreeCamera",BABYLON.Vector3.Zero(),this.app.scene),this.freeCamera.minZ=.45,this.freeCamera.speed=.01,this.freeCamera.keysUp=[87],this.freeCamera.keysDown=[83],this.freeCamera.keysLeft=[65],this.freeCamera.keysRight=[68],this.switchArcRotateCamera()}orthographic(){this.arcRotateCamera.lowerBetaLimit=0,this.arcRotateCamera.upperBetaLimit=0,this.arcRotateCamera.lowerAlphaLimit=Math.PI/2,this.arcRotateCamera.upperAlphaLimit=Math.PI/2,this.arcRotateCamera.mode=BABYLON.Camera.ORTHOGRAPHIC_CAMERA;var e=this.app.Project.current.Sight;this.arcRotateCamera.lowerRadiusLimit=2*e.radius,this.arcRotateCamera.radius=e.radius,this.arcRotateCamera.target=e.focus.clone(),this.frustrum=.5*e.radius,this.computeCameraView()}perspective(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e=e||this.app.Project.current.Sight,this.arcRotateCamera.lowerRadiusLimit=e.minimumLimit||1,this.arcRotateCamera.upperRadiusLimit=e.maximumLimit||3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.minBeta||.01,this.arcRotateCamera.upperBetaLimit=e.maxBeta||Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=BABYLON.Camera.PERSPECTIVE_CAMERA,this.arcRotateCamera.target=e.focus.clone(),(this.arcRotateCamera.alpha>2*Math.PI||this.arcRotateCamera.alpha<-2*Math.PI)&&(this.arcRotateCamera.alpha=this.arcRotateCamera.alpha-Math.floor(this.arcRotateCamera.alpha/(2*Math.PI))*(2*Math.PI));var t=new BABYLON.Animation("camAlpha","alpha",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);t.setKeys([{frame:0,value:this.arcRotateCamera.alpha},{frame:30,value:e.alpha}]);var i=new BABYLON.Animation("camRadius","radius",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30,value:e.radius}]);var r=new BABYLON.Animation("camBeta","beta",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);r.setKeys([{frame:0,value:this.arcRotateCamera.beta},{frame:30,value:e.beta}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[t,i,r],0,60,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}flyTo(e,t=.5){e=e||this.app.Project.current.Sight,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.arcRotateCamera.lowerRadiusLimit=e.minimumLimit||1,this.arcRotateCamera.upperRadiusLimit=e.maximumLimit||3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.minBeta||.01,this.arcRotateCamera.upperBetaLimit=e.maxBeta||Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=BABYLON.Camera.PERSPECTIVE_CAMERA;var i=new BABYLON.Animation("camtarget","target",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:30*t,value:e.focus.clone()}]);var r=new BABYLON.Animation("camradius","radius",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);r.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30*t,value:e.radius}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[i,r],0,30*t,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}lookToTheFront(e,t=.5){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.arcRotateCamera.lowerRadiusLimit=e.Sight.minimumLimit||1,this.arcRotateCamera.upperRadiusLimit=e.Sight.maximumLimit||3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.Sight.minBeta||.01,this.arcRotateCamera.upperBetaLimit=e.Sight.maxBeta||Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=BABYLON.Camera.PERSPECTIVE_CAMERA;var i=Math.atan2(-e.instance.forward.z,-e.instance.forward.x);(this.arcRotateCamera.alpha>2*Math.PI||this.arcRotateCamera.alpha<-2*Math.PI)&&(this.arcRotateCamera.alpha=this.arcRotateCamera.alpha-Math.floor(this.arcRotateCamera.alpha/(2*Math.PI))*(2*Math.PI));var r=new BABYLON.Animation("camtarget","target",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);r.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:30*t,value:e.Sight.focus.clone()}]);var n=new BABYLON.Animation("camAlpha","alpha",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);n.setKeys([{frame:0,value:this.arcRotateCamera.alpha},{frame:30*t,value:i}]);i=new BABYLON.Animation("camRadius","radius",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30*t,value:e.Sight.radius/1.2}]);e=new BABYLON.Animation("camBeta","beta",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);e.setKeys([{frame:0,value:this.arcRotateCamera.beta},{frame:30*t,value:Math.PI/2}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[r,n,i,e],0,30*t,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}getSightJson(){return JSON.stringify({alpha:this.arcRotateCamera.alpha,focus:p.vector3ToJson(this.arcRotateCamera.target),radius:this.arcRotateCamera.radius,beta:this.arcRotateCamera.beta,minimumLimit:this.arcRotateCamera.lowerRadiusLimit,maximumLimit:this.arcRotateCamera.upperRadiusLimit,minBeta:this.arcRotateCamera.lowerBetaLimit,maxBeta:this.arcRotateCamera.upperBetaLimit})}computeCameraView(){var e=this.app.canvas.clientWidth/this.app.canvas.clientHeight;this.arcRotateCamera.orthoLeft=-e*this.frustrum,this.arcRotateCamera.orthoRight=e*this.frustrum,this.arcRotateCamera.orthoTop=this.frustrum,this.arcRotateCamera.orthoBottom=-this.frustrum;e=1e3/(this.frustrum/20);this.arcRotateCamera.panningSensibility=2e3<e?2e3:e<10?10:e}_wheel(e){var t;this.arcRotateCamera.mode!=BABYLON.Camera.PERSPECTIVE_CAMERA?(t=(e.wheelDelta||24*-e.detail)<0?1.1:.9,this.frustrum*=t,this.computeCameraView()):(t=1e3/(this.app.CameraController.arcRotateCamera.radius/20),this.app.CameraController.arcRotateCamera.panningSensibility=2e3<t?2e3:t<10?10:t)}switchArcRotateCamera(){this.app.scene.activeCamera=this.arcRotateCamera,this.arcRotateCamera.attachControl(this.app.canvas,!0,!0),this.app.IEvent=new r(this.app)}switchFPSCamera(){this.app.IEvent=new o(this.app)}}class d{constructor(){this.map={}}add(e,t){this.map[e]=t}find(e){return this.map[e]}remove(e){delete this.map[e]}termRemove(e){for(var t in this.map)e(this.map[t])&&delete this.map[t]}showAll(){for(var e in this.map)this.map[e]}count(){var e,t=0;for(e in Object.keys(this.map))++t;return t}clear(){for(var e in this.map)delete this.map[e]}}class a{static getGUID(e){var t,i,r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[],o=r.length;if(e)for(t=0;t<e;t++)n[t]=r[0|Math.random()*o];else for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",t=0;t<36;t++)n[t]||(i=0|16*Math.random(),n[t]=r[19==t?3&i|8:i]);return n.join("")}}class l{constructor(e){this.objectType="Light",this.app=e}load(){}}class c extends l{load(){this.light=new BABYLON.DirectionalLight(this.id,this.direction,this.app.scene),this.light.position=this.position,this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}class h extends l{load(){this.light=new BABYLON.HemisphericLight(this.id,this.direction,this.app.scene),this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}(t=n=n||{}).Point="Point",t.Spot="Spot",t.Directional="Directional",t.Hemispheric="Hemispheric";var f;class u extends l{load(){this.light=new BABYLON.PointLight(this.id,this.position.clone(),this.app.scene),this.light.range=this.range,this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}class m extends l{load(){this.light=new BABYLON.SpotLight(this.id,this.position.clone(),this.direction.clone(),this.angle*Math.PI/180,this.exponent,this.app.scene),this.light.range=this.range,this.light.position=this.position,this.light.intensity=this.intensity,this.light.diffuse=BABYLON.Color3.FromHexString(this.color),this.light.specular=BABYLON.Color3.Black()}}class _{constructor(e){this.isOK=!1,this.app=e,this.ele=document.createElement("div"),this.ele.style.cssText="position: absolute;z-index:999999999; font-size: 10px;color: rgb(211, 211, 211);text-shadow:rgba(0, 0, 0, 0.2) 1px 1px 0; padding: 5px 8px;",this.app.canvas.parentElement.appendChild(this.ele),this.close(),setInterval(()=>{var e;1e3<(new Date).getTime()-this.time&&this.isOK&&!this.text&&((e=this.app.Project.objectDatas.find(this.id))&&(this.text=e.name))},100)}set text(e){this._text=e,(this.ele.innerText=e)&&(this.ele.style.display=null)}update(e){e.pickInfo.pickedMesh?e.pickInfo.pickedMesh.id!=this.id?(this.close(),this.id=e.pickInfo.pickedMesh.id,this.time=(new Date).getTime()):this.isOK=!0:this.close(),this.ele.style.top=e.event.offsetY+"px",this.ele.style.left=e.event.offsetX+20+"px"}close(){this.isOK=!1,this.time=(new Date).getTime(),this.ele.style.display="none",this.text=""}setBackground(e){this.url=e,this.ele.style.background="url("+this.url+") no-repeat",this.ele.style.backgroundSize="cover"}dispose(){clearInterval(this.interval),this.app.canvas.parentElement.removeChild(this.ele),this.ele=null}}class g{constructor(e){this.lights=new d,this.reflexEnabled=!0,this.reflexIntensity=.5,this.app=e,this.color=new BABYLON.Color4(0,.0588,.1176,1),this.reflex(Pe.rl+"resources/environment.env",.5),this.app.scene.fogEnabled=!0,this.app.scene.fogMode=2,this.fogDistance=500,BABYLON.Effect.IncludesShadersStore.fogVertex=`
|
|
2
2
|
#ifdef FOG
|
|
3
3
|
vFogDistance=(worldPos).xyz;
|
|
4
4
|
#endif
|
|
5
|
-
`}set fogDistance(e){this.app.scene.fogDensity=1/e}set color(e){this._color=new BABYLON.Color4(e.r,e.g,e.b,e.a),this.app.scene.clearColor=this._color,this.app.scene.fogColor=new BABYLON.Color3(...this._color.asArray())}reflex(e,t){e=new BABYLON.CubeTexture(e,this.app.scene);this.app.scene.environmentTexture=e,this.app.scene.environmentIntensity=t}setBackground(e){this.background&&this.background.dispose(),this.background=new BABYLON.Layer("background",e,this.app.scene),this.background.isBackground=!0}setReflexEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.reflexEnabled=e,this.app.scene.environmentIntensity=this.reflexEnabled?this.reflexIntensity:0,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setFlexIntensity(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.reflexIntensity=e,this.app.scene.environmentIntensity=this.reflexIntensity,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}defaultLights(){let e=new l(this.app);e.id=a.getGUID(12),e.lightType="Hemispheric",e.name="半球光_"+this.lights.count(),e.direction=new BABYLON.Vector3(1,1,0),e.color="#FFFFFF",e.intensity=1,this.lights.add(e.id,e);let t=new l(this.app);t.id=a.getGUID(12),t.lightType="Hemispheric",t.name="半球光_"+this.lights.count(),t.direction=new BABYLON.Vector3(-1,1,0),t.color="#FFFFFF",t.intensity=.7,this.lights.add(t.id,t)}offAllLight(){for(const e in this.lights.map)this.lights.find(e).light&&(this.lights.find(e).light.intensity=0,this.app.scene.removeLight(this.lights.find(e).light),this.lights.find(e).light.dispose()),this.lights.find(e).light=null}openAllLight(){for(const e in this.lights.map)this.lights.find(e).load()}loadLight(i){for(let t=0;t<i.length;t++){var n=i[t];let e;n.lightType==r.Hemispheric?(e=new l(this.app),e.id=n.id,e.lightType=n.lightType,e.name=n.name,e.direction=p.ToVector3(n.direction),e.color=n.color,e.intensity=n.intensity):n.lightType==r.Directional?(e=new h(this.app),e.id=n.id,e.lightType=n.lightType,e.name=n.name,e.direction=p.ToVector3(n.direction),e.position=p.ToVector3(n.position),e.color=n.color,e.intensity=n.intensity):n.lightType==r.Spot?(e=new g(this.app),e.id=n.id,e.lightType=n.lightType,e.name=n.name,e.direction=p.ToVector3(n.direction),e.position=p.ToVector3(n.position),e.angle=n.angle,e.exponent=n.exponent,e.range=n.range,e.color=n.color,e.intensity=n.intensity):n.lightType==r.Point&&(e=new u(this.app),e.id=n.id,e.lightType=n.lightType,e.name=n.name,e.position=p.ToVector3(n.position),e.range=n.range,e.color=n.color,e.intensity=n.intensity),e&&this.lights.add(e.id,e)}this.lights.count()<1&&this.defaultLights(),this.openAllLight()}setLightIntensity(e=1){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const t in this.lights.map)this.lights.find(t).light.intensity=this.lights.find(t).intensity*e;this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}showTips(){this.app.ToolTips=new m(this.app)}closeTips(){this.app.ToolTips&&this.app.ToolTips.dispose(),this.app.ToolTips=null}showFps(e="position: absolute;left: 5px;bottom: 5px;z-index:999999999; font-size: 10px;color: rgb(0, 255, 0);text-shadow:rgba(0, 0, 0, 0.2) 1px 1px 0;"){this.app.fps||(this.app.fps=document.createElement("div"),this.app.canvas.parentElement.appendChild(this.app.fps)),this.app.fps.style.cssText=e}hideFps(){this.app.fps&&this.app.canvas.parentElement.removeChild(this.app.fps),this.app.fps=null}showDebug(){this.app.scene.debugLayer.show()}}(t=f=f||{}).Region="Region",t.Cabinet="Cabinet",t.Corner="Corner",t.Other="Other",t.Door="Door",t.Floor="Floor",t.LeakWater="LeakWater",t.UI3D="UI3D",t.VirtualBox="VirtualBox",t.Wall="Wall",t.Window="Window",t.Conduit="Conduit";var y,b,t=i(5),w=i.n(t);class _{static init(){let e=new w.a.Tween(this.colors[1]).to({r:1,g:0,b:0},500),t=new w.a.Tween(this.colors[1]).to({r:1,g:.5,b:.5},500);t.chain(e),e.chain(t),e.start();let i=new w.a.Tween(this.colors[2]).to({r:1,g:.55,b:0},500),n=new w.a.Tween(this.colors[2]).to({r:0,g:0,b:0},500);i.chain(n),n.chain(i),i.start();let r=new w.a.Tween(this.colors[3]).to({r:1,g:.84,b:0},500),s=new w.a.Tween(this.colors[3]).to({r:0,g:0,b:0},500);r.chain(s),s.chain(r),r.start();let o=new w.a.Tween(this.colors[4]).to({r:0,g:.75,b:1},500),a=new w.a.Tween(this.colors[4]).to({r:0,g:0,b:0},500);o.chain(a),a.chain(o),o.start();let c=new w.a.Tween(this.colors[5]).to({r:.53,g:.8,b:0},500),h=new w.a.Tween(this.colors[5]).to({r:0,g:0,b:0},500);c.chain(h),h.chain(c),c.start();let l=new w.a.Tween(this.colors[6]).to({r:.8,g:.8,b:.8},500),u=new w.a.Tween(this.colors[6]).to({r:0,g:0,b:0},500);l.chain(u),u.chain(l),l.start()}}_.colors={1:BABYLON.Color3.Red(),2:new BABYLON.Color3(1,.5,0),3:BABYLON.Color3.Yellow(),4:new BABYLON.Color3(0,1,1),5:BABYLON.Color3.Green(),6:BABYLON.Color3.Gray()},(t=y=y||{})[t.Opaque=0]="Opaque",t[t.Flash=1]="Flash",t[t.Transparent=2]="Transparent",(t=b=b||{}).leftClick="leftClick",t.rightClick="rightClick",t.doubleClick="doubleClick",t.eover="eover",t.longPress="longPress",t.out="out";class A{toJosn(e){e=JSON.parse(e);this.alpha=e.alpha,this.beta=e.beta,this.radius=e.radius,this.minimumLimit=e.minimumLimit,this.maximumLimit=e.maximumLimit,this.minBeta=e.minBeta,this.maxBeta=e.maxBeta,this.focus=p.ToVector3(e.focus)}toString(){return JSON.stringify({alpha:this.alpha,focus:p.vector3ToJson(this.focus),radius:this.radius,beta:this.beta,minimumLimit:this.minimumLimit,maximumLimit:this.maximumLimit,minBeta:this.minBeta,maxBeta:this.maxBeta})}setLimit(e,t){this.minimumLimit=e+.3,this.maximumLimit=t}setBeta(e,t){this.minBeta=e,this.maxBeta=t}}class B{constructor(e){this.executes=new d,this.clickEvents=new d,this.touchtime=(new Date).getTime(),this.effectType=y.Opaque,this.app=e}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(b.eover)||this.executes.find(b.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set showBoundingBox(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.showBoundingBox=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}get showBoundingBox(){return this.instance.showBoundingBox}bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.animation=e.animation,this.isAutoPlay=e.isAutoPlay,this.isloop=e.isloop,this.objectType=f.Other;let t=new BABYLON.Mesh(this.id,this.app.scene),i=this.app.Resources.resources.find(this.modelId);i.meshes[0].getChildMeshes().forEach(e=>{e=e.createInstance(this.id);e.isPickable=!1,e.enablePointerMoveEvents=!1,e.parent=t}),t.rotation=p.ToVector3(e.rotation),t.position=p.ToVector3(e.position),t.scaling=p.ToVector3(e.scaling);e=p.computeBounds(t);t.setBoundingInfo(e),this.instance=this.app.Resources.BOX.clone(this.id),this.instance.id=this.id,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.scaling=new BABYLON.Vector3((e.maximum.x-e.minimum.x)*t.scaling.x,(e.maximum.y-e.minimum.y)*t.scaling.y,(e.maximum.z-e.minimum.z)*t.scaling.z),0==this.instance.scaling.y&&(this.instance.scaling.y=.01),this.instance.position=t.position.clone(),this.instance.position.y=(e.maximum.y-e.minimum.y)/2+t.position.y,this.instance.rotation=t.rotation.clone(),t.setParent(this.instance),this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}computeView(){this.Sight=new A;var e=this.instance.getBoundingInfo(),t=p.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=this.instance.getAbsolutePosition(),this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}optimization(t){this.instance.getChildMeshes().forEach(e=>{t?e.freezeWorldMatrix():e.unfreezeWorldMatrix()}),t?this.instance.freezeWorldMatrix():this.instance.unfreezeWorldMatrix(),this.instance.material&&(t?this.instance.material.freeze():this.instance.material.unfreeze())}alwaysActive(){this.instance.getChildMeshes().forEach(e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0}),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var n;e==b.leftClick||e==b.rightClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(b.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(b.rightClick);i&&2==e.sourceEvent.button&&i(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==b.doubleClick?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger,e=>t(this,e)):e==b.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==b.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==b.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(n=this.executes.find(e))&&this.action.unregisterAction(n),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==b.leftClick||e==b.rightClick||e==b.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setFlash(t){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.instancedBuffers&&(e.instancedBuffers.color=_.colors[t])}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Flash)}setOpaque(){this.effectType!=y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.setEnabled(!0),e.instancedBuffers&&(e.instancedBuffers.color=new BABYLON.Color4(1,1,1,1))}),this.instance.disableEdgesRendering(),this.instance.visibility=0,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Opaque)}setTransparent(e=.3){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>e.setEnabled(!1)),this.instance.visibility=e,this.instance.enableEdgesRendering(),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Transparent)}play(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("open")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,this.isloop):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],0,10*e.getKeys().length,this.isloop))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}stop(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("close")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,!1):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],10*e.getKeys().length,0,!1))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class C extends B{constructor(){super(...arguments),this.baseModel=null}bind(e){this.id=a.getGUID(12),this.objectType=f.Wall,this.name="墙体",this.instance=Oe.Tools.MergeMeshes(e.walls,this.app),this.instance.setEnabled(!1),this.instance.receiveShadows=!0,e.t&&""!=e.t?(this.modelId=e.t.modelId,this.baseModel=e.t,this.baseModel.length||(this.baseModel.length=3.1),this.nativeMaterial=this.app.Resources.GetMergeMaterial(e.t,this.app.scene)):this.nativeMaterial=null,this.instance.material=this.nativeMaterial,this.instance.id=this.id,this.instance.name=this.id,this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height,this.alwaysActive(),this.optimization(!0)}}class x extends B{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=f.Window,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=p.computeBounds(this.instance);this.instance.rotation=p.ToVector3(e.rotation),this.instance.position=p.ToVector3(e.position),this.Sight=p.getVisualAngle(i,this.app);let n=this.app.Resources.BOX.createInstance(this.id);n.setBoundingInfo(i),n.enablePointerMoveEvents=!1,n.isPickable=!1,n.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),n.position=this.instance.position.clone(),n.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,n.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(n)),this.instance.dispose(),this.instance=n,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class E extends B{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=f.Door,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=p.computeBounds(this.instance);this.instance.rotation=p.ToVector3(e.rotation),this.instance.position=p.ToVector3(e.position);let n=this.app.Resources.BOX.createInstance(this.id);n.setBoundingInfo(i),n.enablePointerMoveEvents=!1,n.isPickable=!1,n.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),n.position=this.instance.position.clone(),n.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,n.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(n)),this.instance.dispose(),this.instance=n,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class S extends B{computeView(){this.objectType=f.Cabinet,this.Sight=new A;var e=this.instance.getBoundingInfo(),t=p.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=this.instance.getAbsolutePosition(),this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}}class T extends B{bind(e){let t=p.ToARRVector3(e.lines);this.Sight.focus=t[0].clone(),this.instance=p.createTube(e.id,t,.02,this.app),this.instance.setEnabled(!1),this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=f.LeakWater;e=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(this.id);BABYLON.Animation.CreateAndStartAnimation("u",e.diffuseTexture,"vOffset",15,30,0,1,1),e.diffuseTexture.vScale=this.instance.getTotalVertices()/50,this.instance.material=e,this.alwaysActive(),this.computeView()}computeView(){this.Sight=new A;var e=this.instance.getBoundingInfo(),t=p.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var n;e==b.leftClick||e==b.rightClick||e==b.doubleClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(b.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(b.rightClick);i&&2==e.sourceEvent.button&&i(this,e);let n=this.clickEvents.find(b.doubleClick);n&&0==e.sourceEvent.button&&(new Date).getTime()-this.touchtime<500&&n(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==b.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==b.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==b.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(n=this.executes.find(e))&&this.action.unregisterAction(n),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==b.leftClick||e==b.rightClick||e==b.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action,this.instance.getChildMeshes().forEach(e=>e.actionManager=this.action)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class M extends B{async bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=f.VirtualBox,"Cylinder"==e.virtualType?this.instance=BABYLON.MeshBuilder.CreateCylinder(this.id,{height:1,diameterTop:1,diameterBottom:1},this.app.scene):this.instance=BABYLON.MeshBuilder.CreateBox(this.id,{size:1},this.app.scene),this.instance.setEnabled(!1),this.instance.id=this.id;let t=new BABYLON.StandardMaterial(this.id,this.app.scene);t.diffuseColor=BABYLON.Color3.FromHexString(e.color),e.alpha<.98&&(t.alpha=e.alpha,t.alphaMode=2,t.useAlphaFromDiffuseTexture=!0),this.instance.material=t,e.isEdges&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=1,this.instance.edgesColor=new BABYLON.Color4(0,1,1,1)),e.edgesWidth&&0<e.edgesWidth&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=e.edgesWidth,this.instance.edgesColor=BABYLON.Color3.FromHexString(e.edgesColor).toColor4(1)),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.rotation=Oe.Tools.ToVector3(e.rotation),this.instance.position=Oe.Tools.ToVector3(e.position),this.instance.scaling=Oe.Tools.ToVector3(e.scaling),this.alwaysActive(),this.optimization(!0),this.computeView()}}class k extends B{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=f.UI3D;let t={};t.color=e.color,e.size?(t.clearColor=null,t.position=Oe.Tools.ToVector3(e.position),r=Oe.Tools.ToVector3(e.rotation),t.rotation=new BABYLON.Vector3(r.x+Math.PI,r.y,r.z),i=Number.parseInt(e.size.replace("px",""))/40,r=e.scaling?Oe.Tools.ToVector3(e.scaling):BABYLON.Vector3.One(),t.scaling=new BABYLON.Vector3(14*i/50*r.x,1,14*i/50*r.z)):(t.clearColor=e.clearColor,t.position=Oe.Tools.ToVector3(e.position),t.rotation=Oe.Tools.ToVector3(e.rotation),t.scaling=Oe.Tools.ToVector3(e.scaling));var i="bold 100px Arial";let n=new BABYLON.DynamicTexture(this.id,64,this.app.scene,!1);var r=n.getContext();r.font=i;e=r.measureText(this.name).width+8,r=.02*e;n=new BABYLON.DynamicTexture(this.id,{width:e,height:150},this.app.scene,!1);e=new BABYLON.StandardMaterial(this.id,this.app.scene);e.backFaceCulling=!1,e.diffuseTexture=n,t.clearColor||(n.hasAlpha=!0),n.drawText(this.name,null,null,i,t.color,t.clearColor,!1),this.instance=BABYLON.Mesh.CreateGround(this.id,r,3,1,this.app.scene),this.instance.setEnabled(!1),this.instance.scaling=t.scaling,this.instance.position=t.position,this.instance.rotation=t.rotation,this.instance.material=e,this.alwaysActive(),this.optimization(!0),this.computeView()}}class O extends B{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=f.Conduit,this.color=e.color,this.instance=new BABYLON.Mesh(this.id);var t=p.ToARRVector3(e.pints);let i=p.createTube(e.id,t,e.radius,this.app);this.instance.position=i.getBoundingInfo().boundingBox.center.clone(),this.instance.addChild(i),e.rotation&&(this.instance.rotation=p.ToVector3(e.rotation)),e.position&&(this.instance.position=p.ToVector3(e.position)),i.setParent(this.instance.parent),this.instance.dispose(),this.instance=i;let n=new BABYLON.StandardMaterial(e.id,this.app.scene);n.diffuseColor=BABYLON.Color3.FromHexString(e.color),n.alpha=e.alpha,this.alpha=e.alpha,this.instance.material=n,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.setEnabled(!1),this.alwaysActive(),this.optimization(!0),this.computeView()}setColor(e,t,i){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=new BABYLON.Color3(e/255,i/255,t/255),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}reColor(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}computeView(){this.Sight=new A;var e=this.instance.getBoundingInfo(),e=p.getVisualAngle(e,this.app);this.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}setFlash(e=1){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.emissiveColor=_.colors[e],this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Flash)}setOpaque(){this.effectType!=y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!0),this.instance.material.alpha=this.alpha,this.instance.material.emissiveColor=null,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Opaque)}setTransparent(e=.3){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.alpha=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Transparent)}}class R extends B{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=f.Floor,this.instance=BABYLON.MeshBuilder.CreatePolygon("地板",{shape:p.Expand(e.vectors,-.01),holes:e.buckles,sideOrientation:BABYLON.Mesh.DOUBLESIDE},this.app.scene),this.alwaysActive(),this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height-.01,this.instance.id=e.id,this.instance.name="地板";var t=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(e.id),i=this.instance.getBoundingInfo();this.Sight=p.getVisualAngle(i,this.app),e.baseModel.isTiling&&(t.diffuseTexture.uScale=(i.maximum.x-i.minimum.x)/e.baseModel.width,t.diffuseTexture.vScale=(i.maximum.z-i.minimum.z)/e.baseModel.length),this.instance.material=t,this.optimization(!0),this.computeView()}}class L extends B{bind(i){let e=!1;this.id=a.getGUID(12),this.name="墙角",this.objectType=f.Corner;let n=new Array;for(let t=0;t<i.length;t++)if(2<i[t].pints.length){let e=BABYLON.MeshBuilder.CreatePolygon(this.id,{shape:i[t].pints,sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);e.setEnabled(!1),e.position.y=i[t].height,e.isPickable=!0,e.enablePointerMoveEvents=!1,n.push(e)}return n.length<1||(1<n.length?this.instance=p.MergeMeshes(n,this.app):this.instance=n[0],this.instance.id=this.id,this.instance.name=this.id,this.instance.position.y=this.height,this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.alwaysActive(),this.optimization(!0),e=!0),e}}class P extends B{constructor(e,t){super(e),this.height=0,this.id=t.id,this.objectType=t.objectType,this.customNumber=t.customNumber,this.customType=t.customType,this.name=t.name,this.parentId=t.parentId,this.height=t.height,this.index=t.index}bind(r,e=0){let o=new Array;for(let t=0;t<r.length;t++){let e=r[t];e.objectType==f.Wall&&(e.height||(e.height=3.1),e.ply||(e.ply=.09),o.push(e))}let s=new d;for(let e=0;e<r.length;e++){let i=r[e];i.objectType==f.Corner&&(s.add(i.id,i.corner),2<i.pints.length&&(i.height=3.1,i.walls.forEach(t=>{o.forEach(e=>{t==e.id&&parseFloat(e.height)<i.height&&(i.height=parseFloat(e.height))})})))}{let t=new Array;for(let e=0;e<r.length;e++){var i=r[e];i.objectType==f.Corner&&t.push(i)}let e=new L(this.app);e.height=this.height,e.bind(t)?(e.parentId=this.id,this.app.Project.objectDatas.add(e.id,e)):e=null}for(let i=0;i<r.length;i++){let n=r[i];if(n.objectType==f.Floor){n.vectors=new Array;let e=r[i];e.pints.forEach(e=>{s.find(e)||console.log(e),n.vectors.push(s.find(e))}),n.buckles=new Array,e.holes&&e.holes.forEach(e=>{let t=new Array;e.forEach(e=>t.push(s.find(e))),n.buckles.push(t)}),e.middles&&e.middles.forEach(t=>{let i=Array();for(let e=0;e<r.length;e++)r[e].id==t&&r[e].pints.forEach(e=>{e=s.find(e);i.push(new BABYLON.Vector3(e.x,0,e.z))});n.buckles.push(i)});let t=new R(this.app);t.height=this.height,t.bind(n),this.app.Project.objectDatas.add(t.id,t)}}s=null;for(let t=0;t<r.length;t++){var n=r[t];let e;if(n.objectType==f.Window)e=new x(this.app);else if(n.objectType==f.Door)e=new E(this.app);else if(n.objectType==f.Cabinet)e=new S(this.app);else if(n.objectType==f.LeakWater)e=new T(this.app);else if(n.objectType==f.VirtualBox)e=new M(this.app);else if(n.objectType==f.UI3D)e=new k(this.app);else if(n.objectType==f.Conduit)e=new O(this.app);else{if(n.objectType==f.Wall)continue;if(n.objectType==f.Corner)continue;if(n.objectType==f.Floor)continue;e=new B(this.app)}e.bind(n),this.app.Project.objectDatas.add(e.id,e)}{let s=new d;s.add("body",{t:"",walls:new Array});for(let r=0;r<o.length;r++){let n=BABYLON.MeshBuilder.ExtrudePolygon(o[r].id,{shape:[p.ToVector3(o[r].wtop),p.ToVector3(o[r].wleft),p.ToVector3(o[r].wbottom),p.ToVector3(o[r].wright)],depth:parseFloat(o[r].height),sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);n.setEnabled(!1),n.position.y=parseFloat(o[r].height),n.subMeshes=[];var a=n.getTotalVertices();n.subMeshes.push(new BABYLON.SubMesh(0,0,a,0,6,n)),n.subMeshes.push(new BABYLON.SubMesh(0,1,a,18,6,n)),n.subMeshes.push(new BABYLON.SubMesh(0,2,a,30,6,n));for(let i=0;i<o[r].wallwindows.length;i++){const u=BABYLON.CSG.FromMesh(n);let e=this.app.Project.objectDatas.find(o[r].wallwindows[i]);var c=e.instance.getBoundingInfo(),h=BABYLON.MeshBuilder.CreateBox((new Date).getTime().toString(),{height:c.maximum.y-c.minimum.y,width:c.maximum.x-c.minimum.x,depth:2*parseFloat(o[r].ply)+.1},this.app.scene);h.position=e.instance.position.clone(),h.position.y=(c.maximum.y-c.minimum.y)/2+e.height,h.rotation=e.instance.rotation.clone();c=BABYLON.CSG.FromMesh(h);let t=u.subtract(c);h.dispose(),n.dispose(),n=t.toMesh(o[r].id,null,this.app.scene,!0),n.setEnabled(!1)}let t=s.find(o[r].leftMap.modelId);t||(t={t:o[r].leftMap,walls:new Array},s.add(o[r].leftMap.modelId,t));let i=s.find(o[r].rightMap.modelId);i||(i={t:o[r].rightMap,walls:new Array},s.add(o[r].rightMap.modelId,i));var l=p.DeconsTructMesh(n,parseFloat(o[r].height),this.app);for(let e=0;e<l.length;e++)(2==e||3==e?t:4==e||5==e?i:s.find("body")).walls.push(l[e])}for(const t in s.map)if(0<s.find(t).walls.length){let e=new C(this.app);e.parentId=this.id,e.height=this.height,e.bind(s.find(t)),this.app.Project.objectDatas.add(e.id,e)}}o=null,this.computeView()}computeView(){this.Sight=new A;var e=this.getBounding(),e=p.getVisualAngle(e,this.app);this.Sight.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.focus.y=this.height}flyTo(){this.app.CameraController.flyTo(this.Sight,500)}focus(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const t in this.app.Project.objectDatas.map){let e=this.app.Project.objectDatas.find(t);e.setEnabled(!0)}(this.app.Project.current=this).app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setEnabled(e){}getBounding(){var i,n;for(const e in this.app.Project.objectDatas.map){let t=this.app.Project.objectDatas.find(e);if(t.objectType!=f.Region){let e=t.instance.getBoundingInfo();i&&n||(i=n=e.boundingBox.center.clone()),i=BABYLON.Vector3.Minimize(i,e.minimum.add(t.instance.position)),n=BABYLON.Vector3.Maximize(n,e.maximum.add(t.instance.position))}}return i&&n||(i=BABYLON.Vector3.Zero(),n=new BABYLON.Vector3(12,this.height,8)),new BABYLON.BoundingInfo(i,n)}dispose(){}}class N{constructor(e){this.objectDatas=new d,this.app=e}clear(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const e in this.objectDatas.map)this.objectDatas.find(e).instance&&this.objectDatas.find(e).instance.dispose();this.objectDatas.clear(),this.current=null,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}optimization(){this.app.scene.freezeActiveMeshes()}getChildsById(e=this.root.id,n=!1){e=e||this.root.id;let r=new Array;const s=e=>{for(const i in this.objectDatas.map){var t=this.objectDatas.find(i);t.parentId==e&&(r.push(t),n&&s(t.id))}};return s(e),r}getSceneTree(e=this.root.id,r=[]){e=e||this.root.id;const s=(e,i)=>{for(const t in this.objectDatas.map){var n=this.objectDatas.find(t);if(n.parentId==e){let t=!1;for(let e=0;e<r.length;e++)n.customType!=r[e]||(t=!0);t||(i.push({name:n.name,id:n.id,customNumber:n.customNumber,modelType:n.objectType,customType:n.customType,children:[]}),s(n.id,i[i.length-1].children))}}};e=this.objectDatas.find(e);if(e){e={name:e.name,id:e.id,customNumber:e.customNumber,modelType:e.objectType,customType:e.customType,children:[]};return s(this.root.id,e.children),e}console.error("指定的层级不存在")}findObjectById(e){return this.objectDatas.find(e)}findObjectByCustomNumber(e){let t=[];for(const n in this.objectDatas.map){var i=this.objectDatas.find(n);i.customNumber==e&&t.push(i)}return 0==t.length?null:(1<t.length&&console.log("存在编号重复对象,重复个数:"+t.length),t[0])}findObjectsByCustomType(t,i={isCurrent:!1,isEnabled:!1}){let n=[];for(const r in this.objectDatas.map){let e=this.objectDatas.find(r);e.customType==t&&(i.isCurrent&&e.parentId!=this.current.id||i.isEnabled&&1!=e.instance.isEnabled()||n.push(e))}return n}findObjectsByType(e){let t=new Array;for(const n in this.objectDatas.map){var i=this.objectDatas.find(n);i.objectType==e&&t.push(i)}return t}computeSight(i){var n=BABYLON.Vector3.Zero(),r=BABYLON.Vector3.Zero();for(let e=0;e<i.length;e++){let t=i[e];if(t.objectType!=f.Region){let e=t.instance.getBoundingInfo();n&&r||(n=r=e.boundingBox.center.clone()),n=BABYLON.Vector3.Minimize(n,e.minimum.add(t.instance.position)),r=BABYLON.Vector3.Maximize(r,e.maximum.add(t.instance.position))}}return n&&r||(n=BABYLON.Vector3.Zero(),r=new BABYLON.Vector3(12,0,8)),p.getVisualAngle(new BABYLON.BoundingInfo(n,r),this.app)}switchLevel(t=this.root.id,i=!1,n=!0){t=t||this.root.id;var r=this.objectDatas.find(t);if(r&&r instanceof P){let e=this.getChildsById(t,n);e.forEach(e=>e.setEnabled(!0)),this.current=r,i&&this.app.CameraController.perspective(this.computeSight(e))}else console.error("层级不存在")}}class I{constructor(e){this.walls=new d,this.resources=new d,this.ndoeMats=new d,this.Materials=new d,this.Textures=new d,this.MergeMaterials=new d,this.app=e;e=a.getGUID(12);this.transparentBox=BABYLON.MeshBuilder.CreateBox(e,{size:1},this.app.scene),this.transparentBox.alwaysSelectAsActiveMesh=!0;let t=new BABYLON.StandardMaterial(e,this.app.scene);t.diffuseTexture=new BABYLON.Texture(Oe.rl+"resources/white.jpg",this.app.scene,!0,!1),t.alphaMode=BABYLON.Engine.ALPHA_COMBINE,t.emissiveColor=BABYLON.Color3.Green(),this.transparentBox.material=t,this.transparentBox.setEnabled(!1),this.transparentBox.visibility=.3;e=a.getGUID(12);this.BOX=BABYLON.MeshBuilder.CreateBox(e,{size:1},this.app.scene),this.BOX.edgesColor=BABYLON.Color4.FromHexString("#4ba3fff2"),this.BOX.setEnabled(!1),this.BOX.visibility=0,this.FogTex=new BABYLON.Texture(Oe.rl+"resources/fogtex.png",this.app.scene,!0,!1)}async loadModelMesh(t){let i=this.resources.find(t.modelId);if(!i)try{i=await BABYLON.SceneLoader.LoadAssetContainerAsync(Oe.rl+"bundle/"+t.modelId+"/",t.modelId+t.extension,this.app.scene),0<i.animationGroups.length&&i.animationGroups[0].stop(),i.addAllToScene(),i.meshes[0].setEnabled(!1),i.meshes[0].getChildMeshes().forEach(e=>{e.metadata&&e.metadata.gltf&&e.metadata.gltf.extras&&(i.isExtras=!0,e.metadata.gltf.extras.U&&BABYLON.Animation.CreateAndStartAnimation("u",e.material.albedoTexture,"uOffset",30*e.metadata.gltf.extras.Uspeed,30,0,1,1),e.metadata.gltf.extras.V&&BABYLON.Animation.CreateAndStartAnimation("v",e.material.albedoTexture,"vOffset",30*e.metadata.gltf.extras.Vspeed,30,0,1,1))}),i.isExtras||i.meshes[0].getChildMeshes().forEach(e=>{e.registerInstancedBuffer("color",4),e.instancedBuffers.color=new BABYLON.Color4(1,1,1,1)}),this.resources.add(t.modelId,i)}catch(e){console.error("模型下载失败!模型编号:"+t.modelId+";错误信息:"+e)}return i}loadModelMeshAsync(t,i){var e=this.resources.find(t.modelId);e?i(e):BABYLON.SceneLoader.LoadAssetContainerAsync(Oe.rl+"bundle/"+t.modelId+"/",t.modelId+t.extension,this.app.scene).then(e=>{0<e.animationGroups.length&&e.animationGroups[0].stop(),this.resources.add(t.modelId,e),i(e)}).catch(()=>{console.error("模型下载失败!模型编号:"+t.modelId)})}GetMaterial(e,t){let i=this.Materials.find(e.modelId);var n;return void 0===i&&(n=this.GetTexture(e,t),i=new BABYLON.StandardMaterial(e.modelId,t),i.alphaMode=BABYLON.Engine.ALPHA_COMBINE,i.diffuseTexture=n,this.Materials.add(e.modelId,i)),i}GetTexture(e,t){let i=this.Textures.find(e.modelId);return void 0===i&&(i=new BABYLON.Texture(Oe.rl+"texture/"+e.modelId+e.extension,t,!1),".png"==e.extension&&(i.hasAlpha=!0),this.Textures.add(e.modelId,i)),i}GetMergeMaterial(t,i){let n=this.MergeMaterials.find(t.modelId);if(void 0===n){n=new BABYLON.CustomMaterial(t.modelId,i),n.alphaMode=2,this.MergeMaterials.add(t.modelId,n),n.AddUniform("textureData","sampler2D",null),n.Vertex_Definitions(`
|
|
5
|
+
`}set fogDistance(e){this.app.scene.fogDensity=1/e}set color(e){this._color=new BABYLON.Color4(e.r,e.g,e.b,e.a),this.app.scene.clearColor=this._color,this.app.scene.fogColor=new BABYLON.Color3(...this._color.asArray())}reflex(e,t){e=new BABYLON.CubeTexture(e,this.app.scene);this.app.scene.environmentTexture=e,this.app.scene.environmentIntensity=t}setBackground(e){this.background&&this.background.dispose(),this.background=new BABYLON.Layer("background",e,this.app.scene),this.background.isBackground=!0}setReflexEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.reflexEnabled=e,this.app.scene.environmentIntensity=this.reflexEnabled?this.reflexIntensity:0,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setFlexIntensity(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.reflexIntensity=e,this.app.scene.environmentIntensity=this.reflexIntensity,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}defaultLights(){let e=new h(this.app);e.id=a.getGUID(12),e.lightType="Hemispheric",e.name="半球光_"+this.lights.count(),e.direction=new BABYLON.Vector3(1,1,0),e.color="#FFFFFF",e.intensity=1,this.lights.add(e.id,e);let t=new h(this.app);t.id=a.getGUID(12),t.lightType="Hemispheric",t.name="半球光_"+this.lights.count(),t.direction=new BABYLON.Vector3(-1,1,0),t.color="#FFFFFF",t.intensity=.7,this.lights.add(t.id,t)}offAllLight(){for(const e in this.lights.map)this.lights.find(e).light&&(this.lights.find(e).light.intensity=0,this.app.scene.removeLight(this.lights.find(e).light),this.lights.find(e).light.dispose()),this.lights.find(e).light=null}openAllLight(){for(const e in this.lights.map)this.lights.find(e).load()}loadLight(i){for(let t=0;t<i.length;t++){var r=i[t];let e;r.lightType==n.Hemispheric?(e=new h(this.app),e.id=r.id,e.lightType=r.lightType,e.name=r.name,e.direction=p.ToVector3(r.direction),e.color=r.color,e.intensity=r.intensity):r.lightType==n.Directional?(e=new c(this.app),e.id=r.id,e.lightType=r.lightType,e.name=r.name,e.direction=p.ToVector3(r.direction),e.position=p.ToVector3(r.position),e.color=r.color,e.intensity=r.intensity):r.lightType==n.Spot?(e=new m(this.app),e.id=r.id,e.lightType=r.lightType,e.name=r.name,e.direction=p.ToVector3(r.direction),e.position=p.ToVector3(r.position),e.angle=r.angle,e.exponent=r.exponent,e.range=r.range,e.color=r.color,e.intensity=r.intensity):r.lightType==n.Point&&(e=new u(this.app),e.id=r.id,e.lightType=r.lightType,e.name=r.name,e.position=p.ToVector3(r.position),e.range=r.range,e.color=r.color,e.intensity=r.intensity),e&&this.lights.add(e.id,e)}this.lights.count()<1&&this.defaultLights(),this.openAllLight()}setLightIntensity(e=1){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const t in this.lights.map)this.lights.find(t).light.intensity=this.lights.find(t).intensity*e;this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}showTips(){this.app.ToolTips=new _(this.app)}closeTips(){this.app.ToolTips&&this.app.ToolTips.dispose(),this.app.ToolTips=null}showFps(e="position: absolute;left: 5px;bottom: 5px;z-index:999999999; font-size: 10px;color: rgb(0, 255, 0);text-shadow:rgba(0, 0, 0, 0.2) 1px 1px 0;"){this.app.fps||(this.app.fps=document.createElement("div"),this.app.canvas.parentElement.appendChild(this.app.fps)),this.app.fps.style.cssText=e}hideFps(){this.app.fps&&this.app.canvas.parentElement.removeChild(this.app.fps),this.app.fps=null}showDebug(){this.app.scene.debugLayer.show()}}(t=f=f||{}).Region="Region",t.Cabinet="Cabinet",t.Corner="Corner",t.Other="Other",t.Door="Door",t.Floor="Floor",t.LeakWater="LeakWater",t.UI3D="UI3D",t.VirtualBox="VirtualBox",t.Wall="Wall",t.Window="Window",t.Conduit="Conduit";var y,x,t=i(5),v=i.n(t);class b{static init(){let e=new v.a.Tween(this.colors[1]).to({r:1,g:0,b:0},500),t=new v.a.Tween(this.colors[1]).to({r:1,g:.5,b:.5},500);t.chain(e),e.chain(t),e.start();let i=new v.a.Tween(this.colors[2]).to({r:1,g:.55,b:0},500),r=new v.a.Tween(this.colors[2]).to({r:0,g:0,b:0},500);i.chain(r),r.chain(i),i.start();let n=new v.a.Tween(this.colors[3]).to({r:1,g:.84,b:0},500),o=new v.a.Tween(this.colors[3]).to({r:0,g:0,b:0},500);n.chain(o),o.chain(n),n.start();let s=new v.a.Tween(this.colors[4]).to({r:0,g:.75,b:1},500),a=new v.a.Tween(this.colors[4]).to({r:0,g:0,b:0},500);s.chain(a),a.chain(s),s.start();let l=new v.a.Tween(this.colors[5]).to({r:.53,g:.8,b:0},500),c=new v.a.Tween(this.colors[5]).to({r:0,g:0,b:0},500);l.chain(c),c.chain(l),l.start();let h=new v.a.Tween(this.colors[6]).to({r:.8,g:.8,b:.8},500),u=new v.a.Tween(this.colors[6]).to({r:0,g:0,b:0},500);h.chain(u),u.chain(h),h.start()}}b.colors={1:BABYLON.Color3.Red(),2:new BABYLON.Color3(1,.5,0),3:BABYLON.Color3.Yellow(),4:new BABYLON.Color3(0,1,1),5:BABYLON.Color3.Green(),6:BABYLON.Color3.Gray()},(t=y=y||{})[t.Opaque=0]="Opaque",t[t.Flash=1]="Flash",t[t.Transparent=2]="Transparent",(t=x=x||{}).leftClick="leftClick",t.rightClick="rightClick",t.doubleClick="doubleClick",t.eover="eover",t.longPress="longPress",t.out="out";class w{toJosn(e){e=JSON.parse(e);this.alpha=e.alpha,this.beta=e.beta,this.radius=e.radius,this.minimumLimit=e.minimumLimit,this.maximumLimit=e.maximumLimit,this.minBeta=e.minBeta,this.maxBeta=e.maxBeta,this.focus=p.ToVector3(e.focus)}toString(){return JSON.stringify({alpha:this.alpha,focus:p.vector3ToJson(this.focus),radius:this.radius,beta:this.beta,minimumLimit:this.minimumLimit,maximumLimit:this.maximumLimit,minBeta:this.minBeta,maxBeta:this.maxBeta})}setLimit(e,t){this.minimumLimit=e+.3,this.maximumLimit=t}setBeta(e,t){this.minBeta=e,this.maxBeta=t}}class T{constructor(e){this.executes=new d,this.clickEvents=new d,this.touchtime=(new Date).getTime(),this.effectType=y.Opaque,this.app=e}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(x.eover)||this.executes.find(x.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set showBoundingBox(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.showBoundingBox=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}get showBoundingBox(){return this.instance.showBoundingBox}bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.animation=e.animation,this.isAutoPlay=e.isAutoPlay,this.isloop=e.isloop,this.objectType=f.Other;let t=new BABYLON.Mesh(this.id,this.app.scene),i=this.app.Resources.resources.find(this.modelId);i.meshes[0].getChildMeshes().forEach(e=>{e=e.createInstance(this.id);e.isPickable=!1,e.enablePointerMoveEvents=!1,e.parent=t}),t.rotation=p.ToVector3(e.rotation),t.position=p.ToVector3(e.position),t.scaling=p.ToVector3(e.scaling);e=p.computeBounds(t);t.setBoundingInfo(e),this.instance=this.app.Resources.BOX.clone(this.id),this.instance.id=this.id,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.scaling=new BABYLON.Vector3((e.maximum.x-e.minimum.x)*t.scaling.x,(e.maximum.y-e.minimum.y)*t.scaling.y,(e.maximum.z-e.minimum.z)*t.scaling.z),0==this.instance.scaling.y&&(this.instance.scaling.y=.01),this.instance.position=t.position.clone(),this.instance.position.y=(e.maximum.y-e.minimum.y)/2+t.position.y,this.instance.rotation=t.rotation.clone(),t.setParent(this.instance),this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}computeView(){this.Sight=new w;var e=this.instance.getBoundingInfo(),t=p.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=this.instance.getAbsolutePosition(),this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}optimization(t){this.instance.getChildMeshes().forEach(e=>{t?e.freezeWorldMatrix():e.unfreezeWorldMatrix()}),t?this.instance.freezeWorldMatrix():this.instance.unfreezeWorldMatrix(),this.instance.material&&(t?this.instance.material.freeze():this.instance.material.unfreeze())}alwaysActive(){this.instance.getChildMeshes().forEach(e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0}),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var r;e==x.leftClick||e==x.rightClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(x.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(x.rightClick);i&&2==e.sourceEvent.button&&i(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==x.doubleClick?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger,e=>t(this,e)):e==x.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==x.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==x.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(r=this.executes.find(e))&&this.action.unregisterAction(r),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==x.leftClick||e==x.rightClick||e==x.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setFlash(t){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.instancedBuffers&&(e.instancedBuffers.color=b.colors[t])}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Flash)}setOpaque(){this.effectType!=y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.setEnabled(!0),e.instancedBuffers&&(e.instancedBuffers.color=new BABYLON.Color4(1,1,1,1))}),this.instance.disableEdgesRendering(),this.instance.visibility=0,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Opaque)}setTransparent(e=.3){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>e.setEnabled(!1)),this.instance.visibility=e,this.instance.enableEdgesRendering(),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Transparent)}play(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("open")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,this.isloop):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],0,10*e.getKeys().length,this.isloop))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}stop(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("close")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,!1):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],10*e.getKeys().length,0,!1))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class E extends T{constructor(){super(...arguments),this.baseModel=null}bind(e){this.id=a.getGUID(12),this.objectType=f.Wall,this.name="墙体",this.instance=Pe.Tools.MergeMeshes(e.walls,this.app),this.instance.setEnabled(!1),this.instance.receiveShadows=!0,e.t&&""!=e.t?(this.modelId=e.t.modelId,this.baseModel=e.t,this.baseModel.length||(this.baseModel.length=3.1),this.nativeMaterial=this.app.Resources.GetMergeMaterial(e.t,this.app.scene)):this.nativeMaterial=null,this.instance.material=this.nativeMaterial,this.instance.id=this.id,this.instance.name=this.id,this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height,this.alwaysActive(),this.optimization(!0)}}class A extends T{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=f.Window,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=p.computeBounds(this.instance);this.instance.rotation=p.ToVector3(e.rotation),this.instance.position=p.ToVector3(e.position),this.Sight=p.getVisualAngle(i,this.app);let r=this.app.Resources.BOX.createInstance(this.id);r.setBoundingInfo(i),r.enablePointerMoveEvents=!1,r.isPickable=!1,r.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),r.position=this.instance.position.clone(),r.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,r.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(r)),this.instance.dispose(),this.instance=r,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class S extends T{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=f.Door,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=p.computeBounds(this.instance);this.instance.rotation=p.ToVector3(e.rotation),this.instance.position=p.ToVector3(e.position);let r=this.app.Resources.BOX.createInstance(this.id);r.setBoundingInfo(i),r.enablePointerMoveEvents=!1,r.isPickable=!1,r.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),r.position=this.instance.position.clone(),r.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,r.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(r)),this.instance.dispose(),this.instance=r,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class C extends T{computeView(){this.objectType=f.Cabinet,this.Sight=new w;var e=this.instance.getBoundingInfo(),t=p.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=this.instance.getAbsolutePosition(),this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}}class M extends T{bind(e){let t=p.ToARRVector3(e.lines);this.Sight.focus=t[0].clone(),this.instance=p.createTube(e.id,t,.02,this.app),this.instance.setEnabled(!1),this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=f.LeakWater;e=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(this.id);BABYLON.Animation.CreateAndStartAnimation("u",e.diffuseTexture,"vOffset",15,30,0,1,1),e.diffuseTexture.vScale=this.instance.getTotalVertices()/50,this.instance.material=e,this.alwaysActive(),this.computeView()}computeView(){this.Sight=new w;var e=this.instance.getBoundingInfo(),t=p.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var r;e==x.leftClick||e==x.rightClick||e==x.doubleClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(x.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(x.rightClick);i&&2==e.sourceEvent.button&&i(this,e);let r=this.clickEvents.find(x.doubleClick);r&&0==e.sourceEvent.button&&(new Date).getTime()-this.touchtime<500&&r(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==x.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==x.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==x.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(r=this.executes.find(e))&&this.action.unregisterAction(r),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==x.leftClick||e==x.rightClick||e==x.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action,this.instance.getChildMeshes().forEach(e=>e.actionManager=this.action)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class I extends T{async bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=f.VirtualBox,"Cylinder"==e.virtualType?this.instance=BABYLON.MeshBuilder.CreateCylinder(this.id,{height:1,diameterTop:1,diameterBottom:1},this.app.scene):this.instance=BABYLON.MeshBuilder.CreateBox(this.id,{size:1},this.app.scene),this.instance.setEnabled(!1),this.instance.id=this.id;let t=new BABYLON.StandardMaterial(this.id,this.app.scene);t.diffuseColor=BABYLON.Color3.FromHexString(e.color),e.alpha<.98&&(t.alpha=e.alpha,t.alphaMode=2,t.useAlphaFromDiffuseTexture=!0),this.instance.material=t,e.isEdges&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=1,this.instance.edgesColor=new BABYLON.Color4(0,1,1,1)),e.edgesWidth&&0<e.edgesWidth&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=e.edgesWidth,this.instance.edgesColor=BABYLON.Color3.FromHexString(e.edgesColor).toColor4(1)),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.rotation=Pe.Tools.ToVector3(e.rotation),this.instance.position=Pe.Tools.ToVector3(e.position),this.instance.scaling=Pe.Tools.ToVector3(e.scaling),this.alwaysActive(),this.optimization(!0),this.computeView()}}class B extends T{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=f.UI3D;let t={};t.color=e.color,e.size?(t.clearColor=null,t.position=Pe.Tools.ToVector3(e.position),n=Pe.Tools.ToVector3(e.rotation),t.rotation=new BABYLON.Vector3(n.x+Math.PI,n.y,n.z),i=Number.parseInt(e.size.replace("px",""))/40,n=e.scaling?Pe.Tools.ToVector3(e.scaling):BABYLON.Vector3.One(),t.scaling=new BABYLON.Vector3(14*i/50*n.x,1,14*i/50*n.z)):(t.clearColor=e.clearColor,t.position=Pe.Tools.ToVector3(e.position),t.rotation=Pe.Tools.ToVector3(e.rotation),t.scaling=Pe.Tools.ToVector3(e.scaling));var i="bold 100px Arial";let r=new BABYLON.DynamicTexture(this.id,64,this.app.scene,!1);var n=r.getContext();n.font=i;e=n.measureText(this.name).width+8,n=.02*e;r=new BABYLON.DynamicTexture(this.id,{width:e,height:150},this.app.scene,!1);e=new BABYLON.StandardMaterial(this.id,this.app.scene);e.backFaceCulling=!1,e.diffuseTexture=r,t.clearColor||(r.hasAlpha=!0),r.drawText(this.name,null,null,i,t.color,t.clearColor,!1),this.instance=BABYLON.Mesh.CreateGround(this.id,n,3,1,this.app.scene),this.instance.setEnabled(!1),this.instance.scaling=t.scaling,this.instance.position=t.position,this.instance.rotation=t.rotation,this.instance.material=e,this.alwaysActive(),this.optimization(!0),this.computeView()}}class k extends T{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=f.Conduit,this.color=e.color,this.instance=new BABYLON.Mesh(this.id);var t=p.ToARRVector3(e.pints);let i=p.createTube(e.id,t,e.radius,this.app);this.instance.position=i.getBoundingInfo().boundingBox.center.clone(),this.instance.addChild(i),e.rotation&&(this.instance.rotation=p.ToVector3(e.rotation)),e.position&&(this.instance.position=p.ToVector3(e.position)),i.setParent(this.instance.parent),this.instance.dispose(),this.instance=i;let r=new BABYLON.StandardMaterial(e.id,this.app.scene);r.diffuseColor=BABYLON.Color3.FromHexString(e.color),r.alpha=e.alpha,this.alpha=e.alpha,this.instance.material=r,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.setEnabled(!1),this.alwaysActive(),this.optimization(!0),this.computeView()}setColor(e,t,i){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=new BABYLON.Color3(e/255,i/255,t/255),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}reColor(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}computeView(){this.Sight=new w;var e=this.instance.getBoundingInfo(),e=p.getVisualAngle(e,this.app);this.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}setFlash(e=1){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.emissiveColor=b.colors[e],this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Flash)}setOpaque(){this.effectType!=y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!0),this.instance.material.alpha=this.alpha,this.instance.material.emissiveColor=null,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Opaque)}setTransparent(e=.3){this.effectType==y.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.alpha=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=y.Transparent)}}class z extends T{bind(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=f.Floor,this.instance=BABYLON.MeshBuilder.CreatePolygon("地板",{shape:p.Expand(e.vectors,-.01),holes:e.buckles,sideOrientation:BABYLON.Mesh.DOUBLESIDE},this.app.scene),this.alwaysActive(),this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height-.01,this.instance.id=e.id,this.instance.name="地板";var t=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(e.id),i=this.instance.getBoundingInfo();this.Sight=p.getVisualAngle(i,this.app),e.baseModel.isTiling&&(t.diffuseTexture.uScale=(i.maximum.x-i.minimum.x)/e.baseModel.width,t.diffuseTexture.vScale=(i.maximum.z-i.minimum.z)/e.baseModel.length),this.instance.material=t,this.optimization(!0),this.computeView()}}class P extends T{bind(i){let e=!1;this.id=a.getGUID(12),this.name="墙角",this.objectType=f.Corner;let r=new Array;for(let t=0;t<i.length;t++)if(2<i[t].pints.length){let e=BABYLON.MeshBuilder.CreatePolygon(this.id,{shape:i[t].pints,sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);e.setEnabled(!1),e.position.y=i[t].height,e.isPickable=!0,e.enablePointerMoveEvents=!1,r.push(e)}return r.length<1||(1<r.length?this.instance=p.MergeMeshes(r,this.app):this.instance=r[0],this.instance.id=this.id,this.instance.name=this.id,this.instance.position.y=this.height,this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.alwaysActive(),this.optimization(!0),e=!0),e}}class L extends T{constructor(e,t){super(e),this.height=0,this.id=t.id,this.objectType=t.objectType,this.customNumber=t.customNumber,this.customType=t.customType,this.name=t.name,this.parentId=t.parentId,this.height=t.height,this.index=t.index}bind(n,e=0){let s=new Array;for(let t=0;t<n.length;t++){let e=n[t];e.objectType==f.Wall&&(e.height||(e.height=3.1),e.ply||(e.ply=.09),s.push(e))}let o=new d;for(let e=0;e<n.length;e++){let i=n[e];i.objectType==f.Corner&&(o.add(i.id,i.corner),2<i.pints.length&&(i.height=3.1,i.walls.forEach(t=>{s.forEach(e=>{t==e.id&&parseFloat(e.height)<i.height&&(i.height=parseFloat(e.height))})})))}{let t=new Array;for(let e=0;e<n.length;e++){var i=n[e];i.objectType==f.Corner&&t.push(i)}let e=new P(this.app);e.height=this.height,e.bind(t)?(e.parentId=this.id,this.app.Project.objectDatas.add(e.id,e)):e=null}for(let i=0;i<n.length;i++){let r=n[i];if(r.objectType==f.Floor){r.vectors=new Array;let e=n[i];e.pints.forEach(e=>{o.find(e)||console.log(e),r.vectors.push(o.find(e))}),r.buckles=new Array,e.holes&&e.holes.forEach(e=>{let t=new Array;e.forEach(e=>t.push(o.find(e))),r.buckles.push(t)}),e.middles&&e.middles.forEach(t=>{let i=Array();for(let e=0;e<n.length;e++)n[e].id==t&&n[e].pints.forEach(e=>{e=o.find(e);i.push(new BABYLON.Vector3(e.x,0,e.z))});r.buckles.push(i)});let t=new z(this.app);t.height=this.height,t.bind(r),this.app.Project.objectDatas.add(t.id,t)}}o=null;for(let t=0;t<n.length;t++){var r=n[t];let e;if(r.objectType==f.Window)e=new A(this.app);else if(r.objectType==f.Door)e=new S(this.app);else if(r.objectType==f.Cabinet)e=new C(this.app);else if(r.objectType==f.LeakWater)e=new M(this.app);else if(r.objectType==f.VirtualBox)e=new I(this.app);else if(r.objectType==f.UI3D)e=new B(this.app);else if(r.objectType==f.Conduit)e=new k(this.app);else{if(r.objectType==f.Wall)continue;if(r.objectType==f.Corner)continue;if(r.objectType==f.Floor)continue;e=new T(this.app)}e.bind(r),this.app.Project.objectDatas.add(e.id,e)}{let o=new d;o.add("body",{t:"",walls:new Array});for(let n=0;n<s.length;n++){let r=BABYLON.MeshBuilder.ExtrudePolygon(s[n].id,{shape:[p.ToVector3(s[n].wtop),p.ToVector3(s[n].wleft),p.ToVector3(s[n].wbottom),p.ToVector3(s[n].wright)],depth:parseFloat(s[n].height),sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);r.setEnabled(!1),r.position.y=parseFloat(s[n].height),r.subMeshes=[];var a=r.getTotalVertices();r.subMeshes.push(new BABYLON.SubMesh(0,0,a,0,6,r)),r.subMeshes.push(new BABYLON.SubMesh(0,1,a,18,6,r)),r.subMeshes.push(new BABYLON.SubMesh(0,2,a,30,6,r));for(let i=0;i<s[n].wallwindows.length;i++){const u=BABYLON.CSG.FromMesh(r);let e=this.app.Project.objectDatas.find(s[n].wallwindows[i]);var l=e.instance.getBoundingInfo(),c=BABYLON.MeshBuilder.CreateBox((new Date).getTime().toString(),{height:l.maximum.y-l.minimum.y,width:l.maximum.x-l.minimum.x,depth:2*parseFloat(s[n].ply)+.1},this.app.scene);c.position=e.instance.position.clone(),c.position.y=(l.maximum.y-l.minimum.y)/2+e.height,c.rotation=e.instance.rotation.clone();l=BABYLON.CSG.FromMesh(c);let t=u.subtract(l);c.dispose(),r.dispose(),r=t.toMesh(s[n].id,null,this.app.scene,!0),r.setEnabled(!1)}let t=o.find(s[n].leftMap.modelId);t||(t={t:s[n].leftMap,walls:new Array},o.add(s[n].leftMap.modelId,t));let i=o.find(s[n].rightMap.modelId);i||(i={t:s[n].rightMap,walls:new Array},o.add(s[n].rightMap.modelId,i));var h=p.DeconsTructMesh(r,parseFloat(s[n].height),this.app);for(let e=0;e<h.length;e++)(2==e||3==e?t:4==e||5==e?i:o.find("body")).walls.push(h[e])}for(const t in o.map)if(0<o.find(t).walls.length){let e=new E(this.app);e.parentId=this.id,e.height=this.height,e.bind(o.find(t)),this.app.Project.objectDatas.add(e.id,e)}}s=null,this.computeView()}computeView(){this.Sight=new w;var e=this.getBounding(),e=p.getVisualAngle(e,this.app);this.Sight.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.focus.y=this.height}flyTo(){this.app.CameraController.flyTo(this.Sight,500)}focus(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const t in this.app.Project.objectDatas.map){let e=this.app.Project.objectDatas.find(t);e.setEnabled(!0)}(this.app.Project.current=this).app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setEnabled(e){}getBounding(){var i,r;for(const e in this.app.Project.objectDatas.map){let t=this.app.Project.objectDatas.find(e);if(t.objectType!=f.Region){let e=t.instance.getBoundingInfo();i&&r||(i=r=e.boundingBox.center.clone()),i=BABYLON.Vector3.Minimize(i,e.minimum.add(t.instance.position)),r=BABYLON.Vector3.Maximize(r,e.maximum.add(t.instance.position))}}return i&&r||(i=BABYLON.Vector3.Zero(),r=new BABYLON.Vector3(12,this.height,8)),new BABYLON.BoundingInfo(i,r)}dispose(){}}class D{constructor(e){this.objectDatas=new d,this.app=e}clear(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const e in this.objectDatas.map)this.objectDatas.find(e).instance&&this.objectDatas.find(e).instance.dispose();this.objectDatas.clear(),this.current=null,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}optimization(){this.app.scene.freezeActiveMeshes()}getChildsById(e=this.root.id,r=!1){e=e||this.root.id;let n=new Array;const o=e=>{for(const i in this.objectDatas.map){var t=this.objectDatas.find(i);t.parentId==e&&(n.push(t),r&&o(t.id))}};return o(e),n}getSceneTree(e=this.root.id,n=[]){e=e||this.root.id;const o=(e,i)=>{for(const t in this.objectDatas.map){var r=this.objectDatas.find(t);if(r.parentId==e){let t=!1;for(let e=0;e<n.length;e++)r.customType!=n[e]||(t=!0);t||(i.push({name:r.name,id:r.id,customNumber:r.customNumber,modelType:r.objectType,customType:r.customType,children:[]}),o(r.id,i[i.length-1].children))}}};e=this.objectDatas.find(e);if(e){e={name:e.name,id:e.id,customNumber:e.customNumber,modelType:e.objectType,customType:e.customType,children:[]};return o(this.root.id,e.children),e}console.error("指定的层级不存在")}findObjectById(e){return this.objectDatas.find(e)}findObjectByCustomNumber(e){let t=[];for(const r in this.objectDatas.map){var i=this.objectDatas.find(r);i.customNumber==e&&t.push(i)}return 0==t.length?null:(1<t.length&&console.log("存在编号重复对象,重复个数:"+t.length),t[0])}findObjectsByCustomType(t,i={isCurrent:!1,isEnabled:!1}){let r=[];for(const n in this.objectDatas.map){let e=this.objectDatas.find(n);e.customType==t&&(i.isCurrent&&e.parentId!=this.current.id||i.isEnabled&&1!=e.instance.isEnabled()||r.push(e))}return r}findObjectsByType(e){let t=new Array;for(const r in this.objectDatas.map){var i=this.objectDatas.find(r);i.objectType==e&&t.push(i)}return t}computeSight(i){var r=BABYLON.Vector3.Zero(),n=BABYLON.Vector3.Zero();for(let e=0;e<i.length;e++){let t=i[e];if(t.objectType!=f.Region){let e=t.instance.getBoundingInfo();r&&n||(r=n=e.boundingBox.center.clone()),r=BABYLON.Vector3.Minimize(r,e.minimum.add(t.instance.position)),n=BABYLON.Vector3.Maximize(n,e.maximum.add(t.instance.position))}}return r&&n||(r=BABYLON.Vector3.Zero(),n=new BABYLON.Vector3(12,0,8)),p.getVisualAngle(new BABYLON.BoundingInfo(r,n),this.app)}switchLevel(t=this.root.id,i=!1,r=!0){t=t||this.root.id;var n=this.objectDatas.find(t);if(n&&n instanceof L){let e=this.getChildsById(t,r);e.forEach(e=>e.setEnabled(!0)),this.current=n,i&&this.app.CameraController.perspective(this.computeSight(e))}else console.error("层级不存在")}}class R{constructor(e){this.walls=new d,this.resources=new d,this.ndoeMats=new d,this.Materials=new d,this.Textures=new d,this.MergeMaterials=new d,this.app=e;e=a.getGUID(12);this.transparentBox=BABYLON.MeshBuilder.CreateBox(e,{size:1},this.app.scene),this.transparentBox.alwaysSelectAsActiveMesh=!0;let t=new BABYLON.StandardMaterial(e,this.app.scene);t.diffuseTexture=new BABYLON.Texture(Pe.rl+"resources/white.jpg",this.app.scene,!0,!1),t.alphaMode=BABYLON.Engine.ALPHA_COMBINE,t.emissiveColor=BABYLON.Color3.Green(),this.transparentBox.material=t,this.transparentBox.setEnabled(!1),this.transparentBox.visibility=.3;e=a.getGUID(12);this.BOX=BABYLON.MeshBuilder.CreateBox(e,{size:1},this.app.scene),this.BOX.edgesColor=BABYLON.Color4.FromHexString("#4ba3fff2"),this.BOX.setEnabled(!1),this.BOX.visibility=0,this.FogTex=new BABYLON.Texture(Pe.rl+"resources/fogtex.png",this.app.scene,!0,!1)}async loadModelMesh(t){let i=this.resources.find(t.modelId);if(!i)try{i=await BABYLON.SceneLoader.LoadAssetContainerAsync(Pe.rl+"bundle/"+t.modelId+"/",t.modelId+t.extension,this.app.scene),0<i.animationGroups.length&&i.animationGroups[0].stop(),i.addAllToScene(),i.meshes[0].setEnabled(!1),i.meshes[0].getChildMeshes().forEach(e=>{e.metadata&&e.metadata.gltf&&e.metadata.gltf.extras&&(i.isExtras=!0,e.metadata.gltf.extras.U&&BABYLON.Animation.CreateAndStartAnimation("u",e.material.albedoTexture,"uOffset",30*e.metadata.gltf.extras.Uspeed,30,0,1,1),e.metadata.gltf.extras.V&&BABYLON.Animation.CreateAndStartAnimation("v",e.material.albedoTexture,"vOffset",30*e.metadata.gltf.extras.Vspeed,30,0,1,1))}),i.isExtras||i.meshes[0].getChildMeshes().forEach(e=>{e.registerInstancedBuffer("color",4),e.instancedBuffers.color=new BABYLON.Color4(1,1,1,1)}),this.resources.add(t.modelId,i)}catch(e){console.error("模型下载失败!模型编号:"+t.modelId+";错误信息:"+e)}return i}loadModelMeshAsync(t,i){var e=this.resources.find(t.modelId);e?i(e):BABYLON.SceneLoader.LoadAssetContainerAsync(Pe.rl+"bundle/"+t.modelId+"/",t.modelId+t.extension,this.app.scene).then(e=>{0<e.animationGroups.length&&e.animationGroups[0].stop(),this.resources.add(t.modelId,e),i(e)}).catch(()=>{console.error("模型下载失败!模型编号:"+t.modelId)})}GetMaterial(e,t){let i=this.Materials.find(e.modelId);var r;return void 0===i&&(r=this.GetTexture(e,t),i=new BABYLON.StandardMaterial(e.modelId,t),i.alphaMode=BABYLON.Engine.ALPHA_COMBINE,i.diffuseTexture=r,this.Materials.add(e.modelId,i)),i}GetTexture(e,t){let i=this.Textures.find(e.modelId);return void 0===i&&(i=new BABYLON.Texture(Pe.rl+"texture/"+e.modelId+e.extension,t,!1),".png"==e.extension&&(i.hasAlpha=!0),this.Textures.add(e.modelId,i)),i}GetMergeMaterial(t,i){let r=this.MergeMaterials.find(t.modelId);if(void 0===r){r=new BABYLON.CustomMaterial(t.modelId,i),r.alphaMode=2,this.MergeMaterials.add(t.modelId,r),r.AddUniform("textureData","sampler2D",null),r.Vertex_Definitions(`
|
|
6
6
|
varying vec3 localPos ;
|
|
7
7
|
varying vec3 localNrm ;
|
|
8
|
-
`),
|
|
8
|
+
`),r.Fragment_Definitions(`
|
|
9
9
|
varying vec3 localPos ;
|
|
10
|
-
varying vec3 localNrm ;`),
|
|
10
|
+
varying vec3 localNrm ;`),r.Vertex_Before_PositionUpdated(`
|
|
11
11
|
localPos = position.xyz;
|
|
12
12
|
localNrm = normal;
|
|
13
|
-
`);let e=this.GetTexture(t,i);".png"==t.extension&&(e.hasAlpha=!0,
|
|
13
|
+
`);let e=this.GetTexture(t,i);".png"==t.extension&&(e.hasAlpha=!0,r.alpha=.9),t.length||(t.length=3.1),t.width||(t.width=1.6),r.onBindObservable.add(()=>r.getEffect().setTexture("textureData",e)),r.Fragment_Custom_Diffuse(`
|
|
14
14
|
vec3 newUV = vec3(abs(localPos.x)/`+t.width+",abs(localPos.y)/"+t.length+",abs(localPos.z)/"+t.width+`);
|
|
15
15
|
if(abs(localNrm.z)>abs(localNrm.x)){
|
|
16
16
|
vec4 res = texture2D(textureData,newUV.xy);
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
diffuseColor = res.rgb;
|
|
23
23
|
alpha = res.a;
|
|
24
24
|
}
|
|
25
|
-
`),n.freeze()}return n}delete(e=!1){if(this.BOX&&this.BOX.dispose(),this.transparentBox&&this.transparentBox.dispose(!0,!0),this.BOX=null,this.transparentBox=null,e){for(const t in this.resources.map)this.resources.find(t).removeAllFromScene(),this.resources.remove(t);this.resources.clear()}}async GetWalls(e,t){let i=await BABYLON.SceneLoader.LoadAssetContainerAsync(e,t+".gltf",this.app.scene);if(i.meshes){var n=i.meshes[0].getChildMeshes();for(let e=0;e<n.length;e++)this.walls.add(n[e].id,n[e])}}}t=i(31);const D=i.n(t).a.create();D.defaults.headers.post["Content-Type"]="application/json",D.interceptors.request.use(e=>{var t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e},e=>Promise.reject(e)),D.interceptors.response.use(e=>e,e=>{if(e.response)switch(e.response.status){case 401:console.error("开发者授权码异常");break;case 403:console.error("当前用户没有权限");break;case 400:console.error(e.response.data.message)}return Promise.reject(e)});var Y=D,t=i(6),j=i.n(t);class z{constructor(e,t){this.textDics=new Array,this.id=e,this.scene=t}set background(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._background&&this._background.dispose(),this._background=new BABYLON.GUI.Image(a.getGUID(12)+"_Image",e),this._background.width=this.size.width+"px",this._background.height=this.size.height+"px",this.rect.addControl(this._background),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this._background.isPointerBlocker=!1,this._background.onPointerClickObservable.add(()=>{e(this.id)})):this._background.onPointerClickObservable.clear(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setTexts(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach(e=>e.dispose());for(let t=this.textDics.length=0;t<i.length;t++){let e=new BABYLON.GUI.TextBlock;e.text=i[t].text,e.fontSize=i[t].fontSize||"20px",e.color=i[t].color||"white",e.top=i[t].top||0,e.left=i[t].left||0,this.rect.addControl(e),this.textDics.push(e)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new BABYLON.GUI.Line,this._line.lineWidth=e.width||1.5,this._line.color=e.color||"green",this._line.y2=this.size.height/2,this.container.addControl(this._line),this._line.linkWithMesh(this.pint),this._line.connectedControl=this.rect,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&this.rect.dispose(),this._line&&this._line.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&(this.rect.isVisible=e),this._line&&(this._line.isVisible=e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class U{constructor(e,t,i,n,r,s){this.id=e,this.scene=s,this.url=i,this.scaling=n,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=BABYLON.Mesh.CreatePlane(this.id,n,this.scene,!0,BABYLON.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=t.clone(),this.instance.position.y+=r,this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y;let o=new BABYLON.StandardMaterial("Mat_"+this.id,this.scene);o.diffuseColor=BABYLON.Color3.White(),o.emissiveColor=BABYLON.Color3.White(),this.instance.material=o,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let i=new Image;i.src=this.url,i.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(i.width/i.height)/this.scaling;let e=new BABYLON.DynamicTexture(this.id,{width:i.width,height:i.height},this.scene,!1);e.hasAlpha=!0,this.instance.material.diffuseTexture=e;let t=e.getContext();t.drawImage(i,0,0),e.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}addEventListener(t){if(this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),this.instance.material.emissiveColor=BABYLON.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let n=new Image;n.src=this.url,n.onload=()=>{this.instance.scaling.y=this.scaling/(n.width/n.height)/this.scaling;let t=new BABYLON.DynamicTexture(this.id,{width:n.width,height:n.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t;let e=t.getContext();e.drawImage(n,0,0),i.forEach(e=>t.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color||"#fffffb","",!0,!0)),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class F{constructor(){this.color="#00ff00",this.width=5,this.isDotted=!1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.instance=new BABYLON.GUI.MultiLine,this.objs[0].app.container.addControl(this.instance),this.instance.lineWidth=this.width,this.instance.color=this.color,this.isDotted&&(this.instance.dash=[1]),this.objs.forEach(e=>this.instance.add(e.instance)),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this.instance.isPointerBlocker=!1,this.instance.onPointerClickObservable.add(()=>{e(this.id)})):this.instance.onPointerClickObservable.clear(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.isVisible=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class H{constructor(){this.color="#00ff00",this.width=1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose();let t=[];this.objs.forEach(e=>t.push(e.instance.getAbsolutePosition().clone())),this.instance=p.createTube(this.id,t,this.width/100,this.objs[0].app);let e=new BABYLON.StandardMaterial("mat_"+this.id,this.objs[0].app.scene);e.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.instance.material=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(t){if(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.objs[0].app.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class V{constructor(e){this.displayValue=!1,this.anchor=e,this.id=a.getGUID(12),this.texts=new Array}isEnabled(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh.setEnabled(t),this.texts.forEach(e=>e.isVisible=!!t&&this.displayValue),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set displayValues(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.texts.forEach(e=>e.isVisible=t),this.displayValue=t,this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose();for(let e=0;e<this.texts.length;e++)this.texts[e].linkedMesh&&this.texts[e].linkedMesh.dispose(),this.texts[e].dispose();this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}var G=i(14);class W{constructor(e,t){this.anchor=e,this.ratio=t}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose(),this.textMesh&&this.textMesh.dispose(),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}const $=[0,2e3,1e4,3e4,null];class q{constructor(e){this._retryDelays=void 0!==e?[...e,null]:$}nextRetryDelayInMilliseconds(e){return this._retryDelays[e.previousRetryCount]}}class X extends Error{constructor(e,t){var i=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=i}}class K extends Error{constructor(e="A timeout occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class J extends Error{constructor(e="An abort occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class Z extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=i}}class Q extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=i}}class ee extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=i}}class te extends Error{constructor(e){var t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class ie extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=i}}class ne{constructor(e,t,i){this.statusCode=e,this.statusText=t,this.content=i}}class re{get(e,t){return this.send({...t,method:"GET",url:e})}post(e,t){return this.send({...t,method:"POST",url:e})}delete(e,t){return this.send({...t,method:"DELETE",url:e})}getCookieString(e){return""}}var se,oe,ae,ce,he=i(0),le=i(1);class ue extends re{constructor(e){if(super(),this._logger=e,"undefined"==typeof fetch){const t=require;this._jar=new(t("tough-cookie").CookieJar),this._fetchType=t("node-fetch"),this._fetchType=t("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(Object(le.h)());if("undefined"==typeof AbortController){const i=require;this._abortControllerType=i("abort-controller")}else this._abortControllerType=AbortController}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new J;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let i;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),i=new J});let n=null;e.timeout&&(s=e.timeout,n=setTimeout(()=>{t.abort(),this._logger.log(he.a.Warning,"Timeout from HTTP request."),i=new K},s));let r;try{r=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:!0===e.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(e){if(i)throw i;throw this._logger.log(he.a.Warning,`Error from HTTP request. ${e}.`),e}finally{n&&clearTimeout(n),e.abortSignal&&(e.abortSignal.onabort=null)}if(!r.ok){var s=await pe(r,"text");throw new X(s||r.statusText,r.status)}e=await pe(r,e.responseType);return new ne(r.status,r.statusText,e)}getCookieString(e){let i="";return le.c.isNode&&this._jar&&this._jar.getCookies(e,(e,t)=>i=t.join("; ")),i}}function pe(e,t){let i;switch(t){case"arraybuffer":i=e.arrayBuffer();break;case"text":i=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`);default:i=e.text()}return i}class de extends re{constructor(e){super(),this._logger=e}send(r){return r.abortSignal&&r.abortSignal.aborted?Promise.reject(new J):r.method?r.url?new Promise((e,t)=>{const i=new XMLHttpRequest;i.open(r.method,r.url,!0),i.withCredentials=void 0===r.withCredentials||r.withCredentials,i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const n=r.headers;n&&Object.keys(n).forEach(e=>{i.setRequestHeader(e,n[e])}),r.responseType&&(i.responseType=r.responseType),r.abortSignal&&(r.abortSignal.onabort=()=>{i.abort(),t(new J)}),r.timeout&&(i.timeout=r.timeout),i.onload=()=>{r.abortSignal&&(r.abortSignal.onabort=null),200<=i.status&&i.status<300?e(new ne(i.status,i.statusText,i.response||i.responseText)):t(new X(i.response||i.responseText||i.statusText,i.status))},i.onerror=()=>{this._logger.log(he.a.Warning,`Error from HTTP request. ${i.status}: ${i.statusText}.`),t(new X(i.statusText,i.status))},i.ontimeout=()=>{this._logger.log(he.a.Warning,"Timeout from HTTP request."),t(new K)},i.send(r.content||"")}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class fe extends re{constructor(e){if(super(),"undefined"!=typeof fetch||le.c.isNode)this._httpClient=new ue(e);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new de(e)}}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new J):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}class ge{}ge.Authorization="Authorization",ge.Cookie="Cookie",(t=se=se||{})[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling",(t=oe=oe||{})[t.Text=1]="Text",t[t.Binary=2]="Binary";class me{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class ve{constructor(e,t,i,n){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._pollAbort=new me,this._options=n,this._running=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this._pollAbort.aborted}async connect(e,t){if(le.a.isRequired(e,"url"),le.a.isRequired(t,"transferFormat"),le.a.isIn(t,oe,"transferFormat"),this._url=e,this._logger.log(he.a.Trace,"(LongPolling transport) Connecting."),t===oe.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");var[i,n]=Object(le.i)(),n={[i]:n,...this._options.headers};const r={abortSignal:this._pollAbort.signal,headers:n,timeout:1e5,withCredentials:this._options.withCredentials};t===oe.Binary&&(r.responseType="arraybuffer");t=await this._getAccessToken();this._updateHeaderToken(r,t);e=`${e}&_=${Date.now()}`;this._logger.log(he.a.Trace,`(LongPolling transport) polling: ${e}.`);e=await this._httpClient.get(e,r);200!==e.statusCode?(this._logger.log(he.a.Error,`(LongPolling transport) Unexpected response code: ${e.statusCode}.`),this._closeError=new X(e.statusText||"",e.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,r)}async _getAccessToken(){return this._accessTokenFactory?this._accessTokenFactory():null}_updateHeaderToken(e,t){e.headers||(e.headers={}),t?e.headers[ge.Authorization]=`Bearer ${t}`:e.headers[ge.Authorization]&&delete e.headers[ge.Authorization]}async _poll(e,t){try{for(;this._running;){var i=await this._getAccessToken();this._updateHeaderToken(t,i);try{var n=`${e}&_=${Date.now()}`;this._logger.log(he.a.Trace,`(LongPolling transport) polling: ${n}.`);var r=await this._httpClient.get(n,t);204===r.statusCode?(this._logger.log(he.a.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==r.statusCode?(this._logger.log(he.a.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this._closeError=new X(r.statusText||"",r.statusCode),this._running=!1):r.content?(this._logger.log(he.a.Trace,`(LongPolling transport) data received. ${Object(le.f)(r.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this._logger.log(he.a.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(e){this._running?e instanceof K?this._logger.log(he.a.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=e,this._running=!1):this._logger.log(he.a.Trace,`(LongPolling transport) Poll errored after shutdown: ${e.message}`)}}}finally{this._logger.log(he.a.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?Object(le.k)(this._logger,"LongPolling",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(he.a.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(he.a.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const r={};var[e,t]=Object(le.i)();r[e]=t;var i={headers:{...r,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials},n=await this._getAccessToken();this._updateHeaderToken(i,n),await this._httpClient.delete(this._url,i),this._logger.log(he.a.Trace,"(LongPolling transport) DELETE request sent.")}finally{this._logger.log(he.a.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(he.a.Trace,e),this.onclose(this._closeError)}}}class ye{constructor(e,t,i,n){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._options=n,this.onreceive=null,this.onclose=null}async connect(a,e){var t;return le.a.isRequired(a,"url"),le.a.isRequired(e,"transferFormat"),le.a.isIn(e,oe,"transferFormat"),this._logger.log(he.a.Trace,"(SSE transport) Connecting."),this._url=a,!this._accessTokenFactory||(t=await this._accessTokenFactory())&&(a+=(a.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(t)}`),new Promise((t,i)=>{let n=!1;if(e===oe.Text){let e;if(le.c.isBrowser||le.c.isWebWorker)e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials});else{var r=this._httpClient.getCookieString(a);const o={};o.Cookie=r;var[s,r]=Object(le.i)();o[s]=r,e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials,headers:{...o,...this._options.headers}})}try{e.onmessage=e=>{if(this.onreceive)try{this._logger.log(he.a.Trace,`(SSE transport) data received. ${Object(le.f)(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(e){return void this._close(e)}},e.onerror=e=>{n?this._close():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},e.onopen=()=>{this._logger.log(he.a.Information,`SSE connected to ${this._url}`),this._eventSource=e,n=!0,t()}}catch(e){return void i(e)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))})}async send(e){return this._eventSource?Object(le.k)(this._logger,"SSE",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class be{constructor(e,t,i,n,r,s){this._logger=i,this._accessTokenFactory=t,this._logMessageContent=n,this._webSocketConstructor=r,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=s}async connect(c,h){var e;return le.a.isRequired(c,"url"),le.a.isRequired(h,"transferFormat"),le.a.isIn(h,oe,"transferFormat"),this._logger.log(he.a.Trace,"(WebSockets transport) Connecting."),!this._accessTokenFactory||(e=await this._accessTokenFactory())&&(c+=(c.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`),new Promise((t,i)=>{c=c.replace(/^http/,"ws");let n;var e=this._httpClient.getCookieString(c);let r=!1;if(le.c.isNode){const a={};var[s,o]=Object(le.i)();a[s]=o,e&&(a[ge.Cookie]=`${e}`),n=new this._webSocketConstructor(c,void 0,{headers:{...a,...this._headers}})}n=n||new this._webSocketConstructor(c),h===oe.Binary&&(n.binaryType="arraybuffer"),n.onopen=e=>{this._logger.log(he.a.Information,`WebSocket connected to ${c}.`),this._webSocket=n,r=!0,t()},n.onerror=e=>{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"There was an error with the transport",this._logger.log(he.a.Information,`(WebSockets transport) ${t}.`)},n.onmessage=e=>{if(this._logger.log(he.a.Trace,`(WebSockets transport) data received. ${Object(le.f)(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(e){return void this._close(e)}},n.onclose=t=>{if(r)this._close(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",i(new Error(e))}}})}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(he.a.Trace,`(WebSockets transport) sending data. ${Object(le.f)(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(he.a.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(e)||!1!==e.wasClean&&1e3===e.code?e instanceof Error?this.onclose(e):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)))}_isCloseEvent(e){return e&&"boolean"==typeof e.wasClean&&"number"==typeof e.code}}class we{constructor(e,t={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,le.a.isRequired(e,"url"),this._logger=Object(le.e)(t.logger),this.baseUrl=this._resolveUrl(e),(t=t||{}).logMessageContent=void 0!==t.logMessageContent&&t.logMessageContent,"boolean"!=typeof t.withCredentials&&void 0!==t.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.withCredentials=void 0===t.withCredentials||t.withCredentials,t.timeout=void 0===t.timeout?1e5:t.timeout;let i=null,n=null;if(le.c.isNode){const r=require;i=r("ws"),n=r("eventsource")}le.c.isNode||"undefined"==typeof WebSocket||t.WebSocket?le.c.isNode&&!t.WebSocket&&i&&(t.WebSocket=i):t.WebSocket=WebSocket,le.c.isNode||"undefined"==typeof EventSource||t.EventSource?le.c.isNode&&!t.EventSource&&void 0!==n&&(t.EventSource=n):t.EventSource=EventSource,this._httpClient=t.httpClient||new fe(this._logger),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||oe.Binary,le.a.isIn(e,oe,"transferFormat"),this._logger.log(he.a.Debug,`Starting connection with transfer format '${oe[e]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,"Disconnecting"===this._connectionState){var t="Failed to start the HttpConnection before stop() was called.";return this._logger.log(he.a.Error,t),await this._stopPromise,Promise.reject(new Error(t))}if("Connected"!==this._connectionState){t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(he.a.Error,t),Promise.reject(new Error(t))}this._connectionStarted=!0}send(e){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new _e(this.transport)),this._sendQueue.send(e))}async stop(e){return"Disconnected"===this._connectionState?(this._logger.log(he.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(he.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise(e=>{this._stopPromiseResolver=e}),await this._stopInternal(e),void await this._stopPromise)}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch(e){}if(this.transport){try{await this.transport.stop()}catch(e){this._logger.log(he.a.Error,`HttpConnection.transport.stop() threw error '${e}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(he.a.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(i){let n=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==se.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(se.WebSockets),await this._startTransport(n,i)}else{let e=null,t=0;do{if(e=await this._getNegotiationResponse(n),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new Error("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(n=e.url),e.accessToken){const r=e.accessToken;this._accessTokenFactory=()=>r}}while(t++,e.url&&t<100);if(100===t&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(n,this._options.transport,e,i)}this.transport instanceof ve&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(he.a.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(e){return this._logger.log(he.a.Error,"Failed to start the connection: "+e),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(e)}}async _getNegotiationResponse(e){const t={};!this._accessTokenFactory||(n=await this._accessTokenFactory())&&(t[ge.Authorization]=`Bearer ${n}`);var[i,n]=Object(le.i)();t[i]=n;e=this._resolveNegotiateUrl(e);this._logger.log(he.a.Debug,`Sending negotiation request: ${e}.`);try{var r=await this._httpClient.post(e,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==r.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${r.statusCode}'`));const s=JSON.parse(r.content);return(!s.negotiateVersion||s.negotiateVersion<1)&&(s.connectionToken=s.connectionId),s}catch(e){let t="Failed to complete negotiation with the server: "+e;return e instanceof X&&404===e.statusCode&&(t+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(he.a.Error,t),Promise.reject(new te(t))}}_createConnectUrl(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+`id=${t}`:e}async _createTransport(e,t,i,n){let r=this._createConnectUrl(e,i.connectionToken);if(this._isITransport(t))return this._logger.log(he.a.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(r,n),void(this.connectionId=i.connectionId);const s=[];let o=i;for(const c of i.availableTransports||[]){var a=this._resolveTransportOrError(c,t,n);if(a instanceof Error)s.push(`${c.transport} failed:`),s.push(a);else if(this._isITransport(a)){if(this.transport=a,!o){try{o=await this._getNegotiationResponse(e)}catch(e){return Promise.reject(e)}r=this._createConnectUrl(e,o.connectionToken)}try{return await this._startTransport(r,n),void(this.connectionId=o.connectionId)}catch(e){if(this._logger.log(he.a.Error,`Failed to start the transport '${c.transport}': ${e}`),o=void 0,s.push(new ee(`${c.transport} failed: ${e}`,se[c.transport])),"Connecting"!==this._connectionState){a="Failed to select transport before stop() was called.";return this._logger.log(he.a.Debug,a),Promise.reject(new Error(a))}}}}return 0<s.length?Promise.reject(new ie(`Unable to connect to the server with any of the available transports. ${s.join(" ")}`,s)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case se.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new be(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case se.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new ye(this._httpClient,this._accessTokenFactory,this._logger,this._options);case se.LongPolling:return new ve(this._httpClient,this._accessTokenFactory,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,i){var n,r=se[e.transport];if(null==r)return this._logger.log(he.a.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(n=r,(t=t)&&0==(n&t))return this._logger.log(he.a.Debug,`Skipping transport '${se[r]}' because it was disabled by the client.`),new Q(`'${se[r]}' is disabled by the client.`,r);{const s=e.transferFormats.map(e=>oe[e]);if(!(0<=s.indexOf(i)))return this._logger.log(he.a.Debug,`Skipping transport '${se[r]}' because it does not support the requested transfer format '${oe[i]}'.`),new Error(`'${se[r]}' does not support ${oe[i]}.`);if(r===se.WebSockets&&!this._options.WebSocket||r===se.ServerSentEvents&&!this._options.EventSource)return this._logger.log(he.a.Debug,`Skipping transport '${se[r]}' because it is not supported in your environment.'`),new Z(`'${se[r]}' is not supported in your environment.`,r);this._logger.log(he.a.Debug,`Selecting transport '${se[r]}'.`);try{return this._constructTransport(r)}catch(e){return e}}}_isITransport(e){return e&&"object"==typeof e&&"connect"in e}_stopConnection(t){if(this._logger.log(he.a.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this._connectionState}.`),this.transport=void 0,t=this._stopError||t,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(he.a.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),t?this._logger.log(he.a.Error,`Connection disconnected with error '${t}'.`):this._logger.log(he.a.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch(e=>{this._logger.log(he.a.Error,`TransportSendQueue.stop() threw error '${e}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(t)}catch(e){this._logger.log(he.a.Error,`HttpConnection.onclose(${t}) threw error '${e}'.`)}}}else this._logger.log(he.a.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!le.c.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(he.a.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){var t=e.indexOf("?");let i=e.substring(0,-1===t?e.length:t);return"/"!==i[i.length-1]&&(i+="/"),i+="negotiate",i+=-1===t?"":e.substring(t),-1===i.indexOf("negotiateVersion")&&(i+=-1===t?"?":"&",i+="negotiateVersion="+this._negotiateVersion),i}}class _e{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new Ae,this._transportResult=new Ae,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new Ae),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new Ae;const t=this._transportResult;this._transportResult=void 0;var e="string"==typeof this._buffer[0]?this._buffer.join(""):_e._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(e),t.resolve()}catch(e){t.reject(e)}}}static _concatBuffers(e){var t=e.map(e=>e.byteLength).reduce((e,t)=>e+t);const i=new Uint8Array(t);let n=0;for(const r of e)i.set(new Uint8Array(r),n),n+=r.byteLength;return i.buffer}}class Ae{constructor(){this.promise=new Promise((e,t)=>[this._resolver,this._rejecter]=[e,t])}resolve(){this._resolver()}reject(e){this._rejecter(e)}}class Be{static write(e){return`${e}${Be.RecordSeparator}`}static parse(e){if(e[e.length-1]!==Be.RecordSeparator)throw new Error("Message is incomplete.");const t=e.split(Be.RecordSeparator);return t.pop(),t}}Be.RecordSeparatorCode=30,Be.RecordSeparator=String.fromCharCode(Be.RecordSeparatorCode);class Ce{writeHandshakeRequest(e){return Be.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,i;if(Object(le.j)(e)){const s=new Uint8Array(e);var n=s.indexOf(Be.RecordSeparatorCode);if(-1===n)throw new Error("Message is incomplete.");n=n+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(s.slice(0,n))),i=s.byteLength>n?s.slice(n).buffer:null}else{const o=e;var r=o.indexOf(Be.RecordSeparator);if(-1===r)throw new Error("Message is incomplete.");r=r+1;t=o.substring(0,r),i=o.length>r?o.substring(r):null}r=Be.parse(t),r=JSON.parse(r[0]);if(r.type)throw new Error("Expected a handshake response from the server.");return[i,r]}}(t=ae=ae||{})[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close";class xe{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new le.d(this,e)}}(t=ce=ce||{}).Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting";class Ee{constructor(e,t,i,n){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(he.a.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},le.a.isRequired(e,"connection"),le.a.isRequired(t,"logger"),le.a.isRequired(i,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this._logger=t,this._protocol=i,this.connection=e,this._reconnectPolicy=n,this._handshakeProtocol=new Ce,this.connection.onreceive=e=>this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=ce.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:ae.Ping})}static create(e,t,i,n){return new Ee(e,t,i,n)}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==ce.Disconnected&&this._connectionState!==ce.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==ce.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=ce.Connecting,this._logger.log(he.a.Debug,"Starting HubConnection.");try{await this._startInternal(),le.c.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=ce.Connected,this._connectionStarted=!0,this._logger.log(he.a.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=ce.Disconnected,this._logger.log(he.a.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;var e=new Promise((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t});await this.connection.start(this._protocol.transferFormat);try{var t={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(he.a.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(t)),this._logger.log(he.a.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError}catch(e){throw this._logger.log(he.a.Debug,`Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(e),e}}async stop(){var e=this._startPromise;this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch(e){}}_stopInternal(e){return this._connectionState===ce.Disconnected?(this._logger.log(he.a.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve()):this._connectionState===ce.Disconnecting?(this._logger.log(he.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState=ce.Disconnecting,this._logger.log(he.a.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(he.a.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new Error("The connection was stopped before the hub handshake could complete."),this.connection.stop(e)))}stream(e,...t){var[i,n]=this._replaceStreamingParams(t);const r=this._createStreamInvocation(e,t,n);let s;const o=new xe;return o.cancelCallback=()=>{const e=this._createCancelInvocation(r.invocationId);return delete this._callbacks[r.invocationId],s.then(()=>this._sendWithProtocol(e))},this._callbacks[r.invocationId]=(e,t)=>{t?o.error(t):e&&(e.type===ae.Completion?e.error?o.error(new Error(e.error)):o.complete():o.next(e.item))},s=this._sendWithProtocol(r).catch(e=>{o.error(e),delete this._callbacks[r.invocationId]}),this._launchStreams(i,s),o}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){var[i,n]=this._replaceStreamingParams(t),n=this._sendWithProtocol(this._createInvocation(e,t,!0,n));return this._launchStreams(i,n),n}invoke(e,...t){const[r,i]=this._replaceStreamingParams(t),s=this._createInvocation(e,t,!1,i);return new Promise((i,n)=>{this._callbacks[s.invocationId]=(e,t)=>{t?n(t):e&&(e.type===ae.Completion?e.error?n(new Error(e.error)):i(e.result):n(new Error(`Unexpected message type: ${e.type}`)))};var e=this._sendWithProtocol(s).catch(e=>{n(e),delete this._callbacks[s.invocationId]});this._launchStreams(r,e)})}on(e,t){e&&t&&(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),-1===this._methods[e].indexOf(t)&&this._methods[e].push(t))}off(e,t){if(e){e=e.toLowerCase();const i=this._methods[e];i&&(t?-1!==(t=i.indexOf(t))&&(i.splice(t,1),0===i.length&&delete this._methods[e]):delete this._methods[e])}}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e)for(const i of this._protocol.parseMessages(e,this._logger))switch(i.type){case ae.Invocation:this._invokeClientMethod(i);break;case ae.StreamItem:case ae.Completion:{const n=this._callbacks[i.invocationId];if(n){i.type===ae.Completion&&delete this._callbacks[i.invocationId];try{n(i)}catch(e){this._logger.log(he.a.Error,`Stream callback threw error: ${Object(le.g)(e)}`)}}break}case ae.Ping:break;case ae.Close:this._logger.log(he.a.Information,"Close message received from server.");var t=i.error?new Error("Server returned an error on close: "+i.error):void 0;!0===i.allowReconnect?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break;default:this._logger.log(he.a.Warning,`Invalid message type: ${i.type}.`)}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,i;try{[i,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(e){var n="Error parsing handshake response: "+e;this._logger.log(he.a.Error,n);n=new Error(n);throw this._handshakeRejecter(n),n}if(t.error){n="Server returned handshake error: "+t.error;this._logger.log(he.a.Error,n);n=new Error(n);throw this._handshakeRejecter(n),n}return this._logger.log(he.a.Debug,"Server handshake complete."),this._handshakeResolver(),i}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds),void 0!==this._pingServerHandle))){let e=this._nextKeepAlive-(new Date).getTime();e<0&&(e=0),this._pingServerHandle=setTimeout(async()=>{if(this._connectionState===ce.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}},e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}_invokeClientMethod(t){const e=this._methods[t.target.toLowerCase()];if(e){try{e.forEach(e=>e.apply(this,t.arguments))}catch(e){this._logger.log(he.a.Error,`A callback for the method ${t.target.toLowerCase()} threw error '${e}'.`)}var i;t.invocationId&&(this._logger.log(he.a.Error,i="Server requested a response, which is not supported in this version of the client."),this._stopPromise=this._stopInternal(new Error(i)))}else this._logger.log(he.a.Warning,`No client method with the name '${t.target}' found.`)}_connectionClosed(e){this._logger.log(he.a.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new Error("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===ce.Disconnecting?this._completeClose(e):this._connectionState===ce.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===ce.Connected&&this._completeClose(e)}_completeClose(t){if(this._connectionStarted){this._connectionState=ce.Disconnected,this._connectionStarted=!1,le.c.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(he.a.Error,`An onclose callback called with error '${t}' threw error '${e}'.`)}}}async _reconnect(t){var i=Date.now();let n=0;var r=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error.");let s=this._getNextRetryDelay(n++,0,r);if(null===s)return this._logger.log(he.a.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(t);if(this._connectionState=ce.Reconnecting,t?this._logger.log(he.a.Information,`Connection reconnecting because of error '${t}'.`):this._logger.log(he.a.Information,"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(he.a.Error,`An onreconnecting callback called with error '${t}' threw error '${e}'.`)}if(this._connectionState!==ce.Reconnecting)return void this._logger.log(he.a.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==s;){if(this._logger.log(he.a.Information,`Reconnect attempt number ${n} will start in ${s} ms.`),await new Promise(e=>{this._reconnectDelayHandle=setTimeout(e,s)}),this._reconnectDelayHandle=void 0,this._connectionState!==ce.Reconnecting)return void this._logger.log(he.a.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=ce.Connected,this._logger.log(he.a.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach(e=>e.apply(this,[this.connection.connectionId]))}catch(e){this._logger.log(he.a.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`)}return}catch(e){if(this._logger.log(he.a.Information,`Reconnect attempt failed because of error '${e}'.`),this._connectionState!==ce.Reconnecting)return this._logger.log(he.a.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===ce.Disconnecting&&this._completeClose());r=e instanceof Error?e:new Error(e.toString()),s=this._getNextRetryDelay(n++,Date.now()-i,r)}}this._logger.log(he.a.Information,`Reconnect retries have been exhausted after ${Date.now()-i} ms and ${n} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(t,i,e){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:i,previousRetryCount:t,retryReason:e})}catch(e){return this._logger.log(he.a.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${i}) threw error '${e}'.`),null}}_cancelCallbacksWithError(i){const n=this._callbacks;this._callbacks={},Object.keys(n).forEach(e=>{const t=n[e];try{t(null,i)}catch(e){this._logger.log(he.a.Error,`Stream 'error' callback called with '${i}' threw error: ${Object(le.g)(e)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,i,n){if(i)return 0!==n.length?{arguments:t,streamIds:n,target:e,type:ae.Invocation}:{arguments:t,target:e,type:ae.Invocation};{const r=this._invocationId;return this._invocationId++,0!==n.length?{arguments:t,invocationId:r.toString(),streamIds:n,target:e,type:ae.Invocation}:{arguments:t,invocationId:r.toString(),target:e,type:ae.Invocation}}}_launchStreams(e,i){if(0!==e.length){i=i||Promise.resolve();for(const n in e)e[n].subscribe({complete:()=>{i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(n)))},error:e=>{let t;t=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(n,t)))},next:e=>{i=i.then(()=>this._sendWithProtocol(this._createStreamItemMessage(n,e)))}})}}_replaceStreamingParams(t){const i=[],n=[];for(let e=0;e<t.length;e++){var r=t[e];if(this._isObservable(r)){const s=this._invocationId;this._invocationId++,i[s]=r,n.push(s.toString()),t.splice(e,1)}}return[i,n]}_isObservable(e){return e&&e.subscribe&&"function"==typeof e.subscribe}_createStreamInvocation(e,t,i){const n=this._invocationId;return this._invocationId++,0!==i.length?{arguments:t,invocationId:n.toString(),streamIds:i,target:e,type:ae.StreamInvocation}:{arguments:t,invocationId:n.toString(),target:e,type:ae.StreamInvocation}}_createCancelInvocation(e){return{invocationId:e,type:ae.CancelInvocation}}_createStreamItemMessage(e,t){return{invocationId:e,item:t,type:ae.StreamItem}}_createCompletionMessage(e,t,i){return t?{error:t,invocationId:e,type:ae.Completion}:{invocationId:e,result:i,type:ae.Completion}}}var Se=i(11);class Te{constructor(){this.name="json",this.version=1,this.transferFormat=oe.Text}parseMessages(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=Se.a.instance);const i=[];for(const r of Be.parse(e)){var n=JSON.parse(r);if("number"!=typeof n.type)throw new Error("Invalid payload.");switch(n.type){case ae.Invocation:this._isInvocationMessage(n);break;case ae.StreamItem:this._isStreamItemMessage(n);break;case ae.Completion:this._isCompletionMessage(n);break;case ae.Ping:case ae.Close:break;default:t.log(he.a.Information,"Unknown message type '"+n.type+"' ignored.");continue}i.push(n)}return i}writeMessage(e){return Be.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this._assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this._assertNotEmptyString(e.error,"Invalid payload for Completion message."),this._assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")}_assertNotEmptyString(e,t){if("string"!=typeof e||""===e)throw new Error(t)}}const Me={trace:he.a.Trace,debug:he.a.Debug,info:he.a.Information,information:he.a.Information,warn:he.a.Warning,warning:he.a.Warning,error:he.a.Error,critical:he.a.Critical,none:he.a.None};class ke{configureLogging(e){var t;return le.a.isRequired(e,"logging"),void 0!==e.log?this.logger=e:"string"==typeof e?(t=function(e){var t=Me[e.toLowerCase()];if(void 0!==t)return t;throw new Error(`Unknown log level: ${e}`)}(e),this.logger=new le.b(t)):this.logger=new le.b(e),this}withUrl(e,t){return le.a.isRequired(e,"url"),le.a.isNotEmpty(e,"url"),this.url=e,this.httpConnectionOptions="object"==typeof t?{...this.httpConnectionOptions,...t}:{...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return le.a.isRequired(e,"protocol"),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new q(e):this.reconnectPolicy=e:this.reconnectPolicy=new q,this}build(){const e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");var t=new we(this.url,e);return Ee.create(t,this.logger||Se.a.instance,this.protocol||new Te,this.reconnectPolicy)}}class Oe{}Oe.sl="https://www.wodashijie.com/",Oe.rl="https://models.wodashijie.com/",Oe.App=class{constructor(e){e.sl&&(Oe.sl=e.sl),e.rl&&(Oe.rl=e.rl),Y.defaults.baseURL=Oe.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;",e.container.appendChild(this.canvas),this.engine=new BABYLON.Engine(this.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0}),this.engine.setHardwareScalingLevel(.5),this.engine.enableOfflineSupport=!1,this.scene=new BABYLON.Scene(this.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),this.scene.useRightHandedSystem=!0,this.scene.getBoundingBoxRenderer().frontColor=BABYLON.Color3.Green(),this.scene.getBoundingBoxRenderer().showBackLines=!1,this.CameraController=new o(this),this.HighlightLayer=new BABYLON.HighlightLayer("highlightLayer",this.scene),this.IEvent=new n(this),this.container=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.Environment=new v(this),this.Environment.defaultLights(),this.Environment.openAllLight(),this.Resources=new I(this),this.Project=new N(this),Oe.EffectMgr.init(),this.engine.runRenderLoop(()=>{this.fps&&(this.fps.innerText=this.engine.getFps().toFixed()+" fps"),this.scene.render(),w.a.update(),this.IEvent&&this.IEvent.runRender()}),window.addEventListener("resize",()=>{this.engine.resize()}),this.scene.onPointerObservable.add(e=>{this.IEvent&&this.IEvent.onPointer(e)}),this.scene.onKeyboardObservable.add(e=>{this.IEvent&&this.IEvent.onKeyboard(e)})}async load(u){if(u){u.isDefaultLevel=null==u.isDefaultLevel||u.isDefaultLevel,Oe.pk=u.pk;var e=await Y.get(`api/service/GetToken?accessToken=${Oe.accessToken}`);if(200==e.status){localStorage.setItem("mx3d-token",e.data);e=await Y.get("api/service");if(200==e.status){localStorage.setItem("mx3d-long",e.data);e=await Y.get(`api/service/${Oe.pk}`);if(200==e.status){let l=JSON.parse(class{static de(e){let t=localStorage.getItem("mx3d-long");var i=j.a.enc.Utf8.parse(t.substring(0,32)),n=j.a.enc.Utf8.parse(t.substring(32,48)),e=j.a.enc.Hex.parse(e),e=j.a.enc.Base64.stringify(e);return j.a.AES.decrypt(e,i,{iv:n,mode:j.a.mode.CBC,padding:j.a.pad.Pkcs7}).toString(j.a.enc.Utf8).toString()}}.de(e.data));return new Promise(async(n,t)=>{try{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let t=new d;for(let e=0;e<l.length;e++){const a=l[e];!a.baseModel||".gltf"!=a.baseModel.extension||t.find(a.baseModel.modelId)||this.Resources.resources.find(a.baseModel.modelId)||(a.baseModel.objectType=a.objectType,t.add(a.baseModel.modelId,a.baseModel))}let e=0;for(const c in t.map)await this.Resources.loadModelMesh(t.find(c)),e++,u&&u.progress&&u.progress(e/t.count()*.3);e=0,t=null;let i=new d;for(let e=0;e<l.length;e++){var r,s=l[e];s.objectType==f.Region&&(r=new P(this,s),this.Project.objectDatas.add(r.id,r),i.add(r.id,new Array),"0"==r.parentId&&(this.Project.root=r))}for(let e=0;e<l.length;e++){var o=l[e];if(o.objectType!=f.Region){let e=i.find(o.parentId);e.push(o)}}for(const h in i.map)await this.Project.objectDatas.find(h).bind(i.find(h)),e++,u&&u.progress&&u.progress(.3+e/i.count()*.7);i=null,this.Project.optimization(),u.isDefaultLevel&&this.Project.switchLevel(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,n(null),this.engine.resize(),u&&u.complete&&u.complete()}catch(e){t(e)}})}}}}else console.error("场景编号不能为空!")}dispose(){this.Environment.hideFps(),this.Project.clear(),this.Resources.delete(),this.engine.dispose()}},Oe.Tools=p,Oe.EffectMgr=_,Oe.HubService=class{static async listener(e){this.connection=(new ke).withUrl(e).configureLogging(he.a.Error).build(),this.connection.onclose(async()=>{await this.start()}),await this.start()}static async start(){try{await this.connection.start()}catch(e){console.log("无法连接服务器"),setTimeout(this.start,5e3)}}},Oe.UI=class{static createIconFromMesh(e,t,i,n,r){let s=t.Sight.focus.clone();var o=t.instance.getBoundingInfo();return s.y+=(o.boundingBox.maximum.y-o.boundingBox.minimum.y)/2,new U(e,s,i,n,r,t.app.scene)}static createIcon(e,t,i,n){let r;t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,r=new z(e,t.app.scene),r.size=i,r.height=n,r.pint=new BABYLON.Mesh(e+"_pint");e=t.Sight.focus.clone();return r.pint.position=e,r.pint.position.y+=n,r.rect=new BABYLON.GUI.Rectangle,r.rect.isPointerBlocker=!1,r.rect.width=i.width+"px",r.rect.height=i.height+"px",r.rect.thickness=0,t.app.container.addControl(r.rect),r.rect.linkWithMesh(r.pint),t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,r}static create2DLine(t,i,n){if(!(i.length<2)){let e=new F;return e.id=t,e.objs=i,n&&n.width&&(e.width=n.width),n&&n.color&&(e.color=n.color),n&&n.isDotted&&(e.isDotted=n.isDotted),e.update(),e}console.error("要连线的对象不能少于2个。")}static create3DLine(t,i,n){if(!(i.length<2)){let e=new H;return e.id=t,e.objs=i,n&&n.width&&(e.width=n.width),n&&n.color&&(e.color=n.color),e.update(),e}console.error("要连线的对象不能少于2个。")}},Oe.HeatMapBuilder=class{static createMatrixCloud(r){r.displayValues=null!=r.displayValues&&r.displayValues,r.isAlpha=null==r.isAlpha||r.isAlpha,r.isParticle=null==r.isParticle||r.isParticle,r.height=r.height||.5,r.radius=r.radius||2.8,r.isLevelRender=null==r.isLevelRender||r.isLevelRender,r.range=r.range||{max:30,min:16};let s;if(!(r.value||r.value.maxX||r.value.maxY||r.value.data||r.anchor))return s;r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,s=new V(r.anchor);var o=r.anchor.instance.getBoundingInfo();s.mesh=r.anchor.instance.clone(s.id),s.mesh.position.y+=r.height;var a=o.maximum.x-o.minimum.x,c=a/(2*r.value.maxX),h=o.maximum.z-o.minimum.z,l=h/(2*r.value.maxY);let e=new Array;for(let n=0;n<2*r.value.maxX;n++)for(let i=0;i<2*r.value.maxY;i++){let t={x:n,y:i,value:r.range.min};for(let e=0;e<r.value.data.length;e++){var u=r.value.data[e];2*u.x+1==n&&2*u.y+1==i&&(t.value=u.value,u=new BABYLON.Vector3(o.boundingSphere.center.x-(a/2-c*n),s.mesh.position.y,o.boundingSphere.center.z-(h/2-l*i)),s.texts.push(this.createTempVlaue(t.value+"℃",u,r.anchor.app.scene,r.anchor.app.container)))}e.push(t)}s.displayValues=r.displayValues;let t=G.create({width:2*r.value.maxX,height:2*r.value.maxY,radius:r.radius});t.setData({min:r.range.min,max:r.range.max,data:e});let i=new BABYLON.StandardMaterial(s.id,r.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),r.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,r.isAlpha&&(i.diffuseTexture.hasAlpha=!0),r.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getMatrixParticleTex(Oe.rl,r.anchor.app.Resources.FogTex,i.diffuseTexture,s.mesh,r.anchor.app.scene,r.isLevelRender),s.mesh.isVisible=!1),r.isLevelRender&&(s.mesh.renderingGroupId=1),s.mesh.material=i,s.mesh.alwaysSelectAsActiveMesh=!0,s.mesh.freezeWorldMatrix(),r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,s}static _getMatrixParticleTex(e,t,i,n,r,s){let o,a=t.clone(),c=n.getBoundingInfo().boundingBox;var h=(c.extendSizeWorld.x+c.extendSizeWorld.z)/9,t=1500*h*h;c.minimumWorld.subtract(new BABYLON.Vector3(-0,0,-0)),c.maximumWorld.subtract(new BABYLON.Vector3(0,0,0));o&&o.dispose(),BABYLON.GPUParticleSystem.IsSupported&&(o=new BABYLON.GPUParticleSystem("particles",{capacity:t},r),o.activeParticleCount=t,o.manualEmitCount=o.activeParticleCount,o.minEmitBox=c.minimumWorld,o.maxEmitBox=c.maximumWorld),o.particleTexture=a,o.emitter=n,s&&(o.renderingGroupId=1),o.isLocal=!0;let l=new BABYLON.NodeMaterial("nm_heatmapBox_"+n.id,r);return l.loadAsync(e+"resources/horizontalNodeMat.json").then(()=>{l.build(!1),l.getBlockByName("boxTex").texture=i,l.getBlockByName("emitXMin").value=o.minEmitBox.x,l.getBlockByName("emitXMax").value=o.maxEmitBox.x,l.getBlockByName("emitYMin").value=o.minEmitBox.z,l.getBlockByName("emitYMax").value=o.maxEmitBox.z,l.createEffectForParticles(o)}),n.onDispose=()=>{o&&o.dispose()},o.onDispose=()=>{l&&l.dispose(),a&&a.dispose()},o.color1=new BABYLON.Color4(.8,.8,.8,.1),o.color2=new BABYLON.Color4(.95,.95,.95,.15),o.colorDead=new BABYLON.Color4(.9,.9,.9,.1),o.minSize=1.4,o.maxSize=2,o.minLifeTime=Number.MAX_SAFE_INTEGER,o.emitRate=5e4*h,o.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,o.gravity=new BABYLON.Vector3(0,0,0),o.direction1=new BABYLON.Vector3(0,0,0),o.direction2=new BABYLON.Vector3(0,0,0),o.minAngularSpeed=-2,o.maxAngularSpeed=2,o.minEmitPower=.5,o.maxEmitPower=1,o.updateSpeed=.005,o.start(),o}static createPunctateCloud(n){if(n.displayValues=null!=n.displayValues&&n.displayValues,n.isAlpha=null==n.isAlpha||n.isAlpha,n.isParticle=null==n.isParticle||n.isParticle,n.radius=n.radius||1,n.isLevelRender=null==n.isLevelRender||n.isLevelRender,n.range=n.range||{max:30,min:16},!n.value&&!n.anchor)return console.error("要创建的云图数值为空!"),null;let e;n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e=new V(n.anchor),e.mesh=BABYLON.MeshBuilder.CreatePlane(e.id,{width:1,height:1,sideOrientation:2},n.anchor.app.scene),e.mesh.scaling=new BABYLON.Vector3(n.radius,n.radius,n.radius),e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.enablePointerMoveEvents=!1,e.mesh.isPickable=!1,e.mesh.position=n.anchor.instance.position.clone(),e.mesh.rotation.x=Math.PI/2;let r=[];for(let i=0;i<6;i++)for(let t=0;t<6;t++){let e={x:i,y:t,value:n.range.min};2==i&&2==t||3==i&&2==t||2==i&&3==t||3==i&&3==t?e.value=n.value:e.value=n.value-2*(Math.abs(2-i)+Math.abs(2-t)),r.push(e)}e.displayValues=n.displayValues;let t=G.create({width:5,height:5,radius:2});t.setData({min:n.range.min,max:n.range.max,data:r});let i=new BABYLON.StandardMaterial(e.id,n.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),n.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,n.isAlpha&&(i.diffuseTexture.hasAlpha=!0),n.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(i.diffuseTexture,e.mesh,n.anchor.app.scene,e.anchor.app.Resources.FogTex,n.isLevelRender),e.mesh.isVisible=!1),n.isLevelRender&&(e.mesh.renderingGroupId=1),e.mesh.material=i,e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.freezeWorldMatrix(),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,e}static createColumnCloud(r){if(r.displayValues=null!=r.displayValues&&r.displayValues,r.isAlpha=null==r.isAlpha||r.isAlpha,r.isParticle=null==r.isParticle||r.isParticle,r.radius=r.radius||4,r.isLevelRender=null==r.isLevelRender||r.isLevelRender,r.range=r.range||{max:30,min:16},!r.data&&r.data.length<1&&!r.anchor)return console.error("要创建的云图数值为空!"),null;let i;r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,i=new V(r.anchor);var n=.98*r.anchor.instance.scaling.y;i.mesh=BABYLON.MeshBuilder.CreatePlane(i.id,{width:.98*r.anchor.instance.scaling.x,height:n,sideOrientation:2},r.anchor.app.scene),i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.enablePointerMoveEvents=!1,i.mesh.isPickable=!1,i.mesh.position=r.anchor.instance.position.clone(),i.mesh.rotation.z=Math.PI,i.mesh.rotation.y=r.anchor.instance.rotation.y,r.isLevelRender&&(i.mesh.renderingGroupId=1);let e=[];for(let n=0;n<4;n++)for(let i=0;i<3*r.data.length;i++){let t={x:n,y:i,value:r.range.min};for(let e=0;e<r.data.length;e++){var s=r.data[e];2==n&&3*e+2==i&&(t.value=s.value)}e.push(t)}var o=n/r.data.length;for(let t=0;t<r.data.length;t++){let e=i.mesh.position.clone();e.y=e.y-n/2+(n-o*t-o/2),i.texts.push(this.createTempVlaue(r.data[t].value+"℃",e,r.anchor.app.scene,i.anchor.app.container))}i.displayValues=r.displayValues;let t=G.create({width:4,height:3*r.data.length,radius:r.radius});t.setData({min:r.range.min,max:r.range.max,data:e});let a=new BABYLON.StandardMaterial(i.id,r.anchor.app.scene);return a.diffuseTexture=new BABYLON.Texture(t.getDataURL(),r.anchor.app.scene,!1,!1),a.specularColor=new BABYLON.Color3(0,0,0),a.alpha=.5,r.isAlpha&&(a.diffuseTexture.hasAlpha=!0),r.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(a.diffuseTexture,i.mesh,r.anchor.app.scene,i.anchor.app.Resources.FogTex,r.isLevelRender),i.mesh.isVisible=!1),i.mesh.material=a,i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.freezeWorldMatrix(),r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,i}static _getColumnarParticleTex(e,t,i,n,r){let s,o=n.clone();n=t.getBoundingInfo().boundingBox,n.extendSizeWorld.x,n.extendSizeWorld.z;BABYLON.Effect.ShadersStore.particlesVertexShader=`
|
|
25
|
+
`),r.freeze()}return r}delete(e=!1){if(this.BOX&&this.BOX.dispose(),this.transparentBox&&this.transparentBox.dispose(!0,!0),this.BOX=null,this.transparentBox=null,e){for(const t in this.resources.map)this.resources.find(t).removeAllFromScene(),this.resources.remove(t);this.resources.clear()}}async GetWalls(e,t){let i=await BABYLON.SceneLoader.LoadAssetContainerAsync(e,t+".gltf",this.app.scene);if(i.meshes){var r=i.meshes[0].getChildMeshes();for(let e=0;e<r.length;e++)this.walls.add(r[e].id,r[e])}}}t=i(32);const O=i.n(t).a.create();O.defaults.headers.post["Content-Type"]="application/json",O.interceptors.request.use(e=>{var t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e},e=>Promise.reject(e)),O.interceptors.response.use(e=>e,e=>{if(e.response)switch(e.response.status){case 401:console.error("开发者授权码异常");break;case 403:console.error("当前用户没有权限");break;case 400:console.error(e.response.data.message)}return Promise.reject(e)});var F=O,t=i(6),N=i.n(t);class U{constructor(e,t){this.textDics=new Array,this.id=e,this.scene=t}set background(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._background&&this._background.dispose(),this._background=new BABYLON.GUI.Image(a.getGUID(12)+"_Image",e),this._background.width=this.size.width+"px",this._background.height=this.size.height+"px",this.rect.addControl(this._background),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this._background.isPointerBlocker=!1,this._background.onPointerClickObservable.add(()=>{e(this.id)})):this._background.onPointerClickObservable.clear(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setTexts(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach(e=>e.dispose());for(let t=this.textDics.length=0;t<i.length;t++){let e=new BABYLON.GUI.TextBlock;e.text=i[t].text,e.fontSize=i[t].fontSize||"20px",e.color=i[t].color||"white",e.top=i[t].top||0,e.left=i[t].left||0,this.rect.addControl(e),this.textDics.push(e)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new BABYLON.GUI.Line,this._line.lineWidth=e.width||1.5,this._line.color=e.color||"green",this._line.y2=this.size.height/2,this.container.addControl(this._line),this._line.linkWithMesh(this.pint),this._line.connectedControl=this.rect,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&this.rect.dispose(),this._line&&this._line.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&(this.rect.isVisible=e),this._line&&(this._line.isVisible=e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class j{constructor(e,t,i,r,n,o){this.id=e,this.scene=o,this.url=i,this.scaling=r,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=BABYLON.Mesh.CreatePlane(this.id,r,this.scene,!0,BABYLON.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=t.clone(),this.instance.position.y+=n,this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y;let s=new BABYLON.StandardMaterial("Mat_"+this.id,this.scene);s.diffuseColor=BABYLON.Color3.White(),s.emissiveColor=BABYLON.Color3.White(),this.instance.material=s,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let i=new Image;i.src=this.url,i.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(i.width/i.height)/this.scaling;let e=new BABYLON.DynamicTexture(this.id,{width:i.width,height:i.height},this.scene,!1);e.hasAlpha=!0,this.instance.material.diffuseTexture=e;let t=e.getContext();t.drawImage(i,0,0),e.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}addEventListener(t){if(this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),this.instance.material.emissiveColor=BABYLON.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let r=new Image;r.src=this.url,r.onload=()=>{this.instance.scaling.y=this.scaling/(r.width/r.height)/this.scaling;let t=new BABYLON.DynamicTexture(this.id,{width:r.width,height:r.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t;let e=t.getContext();e.drawImage(r,0,0),i.forEach(e=>t.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color||"#fffffb","",!0,!0)),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class V{constructor(e,t){this.anchor=e,this.ratio=t}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose(),this.textMesh&&this.textMesh.dispose(),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class G{constructor(e){this.displayValue=!1,this.anchor=e,this.id=a.getGUID(12),this.texts=new Array}isEnabled(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh.setEnabled(t),this.texts.forEach(e=>e.isVisible=!!t&&this.displayValue),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set displayValues(t){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.texts.forEach(e=>e.isVisible=t),this.displayValue=t,this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose();for(let e=0;e<this.texts.length;e++)this.texts[e].linkedMesh&&this.texts[e].linkedMesh.dispose(),this.texts[e].dispose();this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}var $=i(15);class q{constructor(){this.color="#00ff00",this.width=1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose();let t=[];this.objs.forEach(e=>t.push(e.instance.getAbsolutePosition().clone())),this.instance=p.createTube(this.id,t,this.width/100,this.objs[0].app);let e=new BABYLON.StandardMaterial("mat_"+this.id,this.objs[0].app.scene);e.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.instance.material=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(t){if(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.objs[0].app.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class Z{constructor(){this.color="#00ff00",this.width=5,this.isDotted=!1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.instance=new BABYLON.GUI.MultiLine,this.objs[0].app.container.addControl(this.instance),this.instance.lineWidth=this.width,this.instance.color=this.color,this.isDotted&&(this.instance.dash=[1]),this.objs.forEach(e=>this.instance.add(e.instance)),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e?(this.instance.isPointerBlocker=!1,this.instance.onPointerClickObservable.add(()=>{e(this.id)})):this.instance.onPointerClickObservable.clear(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.instance&&(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.isVisible=e,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}dispose(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose(),this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}const Y=[0,2e3,1e4,3e4,null];class W{constructor(e){this._retryDelays=void 0!==e?[...e,null]:Y}nextRetryDelayInMilliseconds(e){return this._retryDelays[e.previousRetryCount]}}class X extends Error{constructor(e,t){var i=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=i}}class H extends Error{constructor(e="A timeout occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class K extends Error{constructor(e="An abort occurred."){var t=new.target.prototype;super(e),this.__proto__=t}}class J extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=i}}class Q extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=i}}class ee extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=i}}class te extends Error{constructor(e){var t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class ie extends Error{constructor(e,t){var i=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=i}}class re{constructor(e,t,i){this.statusCode=e,this.statusText=t,this.content=i}}class ne{get(e,t){return this.send({...t,method:"GET",url:e})}post(e,t){return this.send({...t,method:"POST",url:e})}delete(e,t){return this.send({...t,method:"DELETE",url:e})}getCookieString(e){return""}}var oe,se,ae,le,ce=i(0),he=i(1);class ue extends ne{constructor(e){if(super(),this._logger=e,"undefined"==typeof fetch){const t=require;this._jar=new(t("tough-cookie").CookieJar),this._fetchType=t("node-fetch"),this._fetchType=t("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(Object(he.h)());if("undefined"==typeof AbortController){const i=require;this._abortControllerType=i("abort-controller")}else this._abortControllerType=AbortController}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new K;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let i;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),i=new K});let r=null;e.timeout&&(o=e.timeout,r=setTimeout(()=>{t.abort(),this._logger.log(ce.a.Warning,"Timeout from HTTP request."),i=new H},o));let n;try{n=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:!0===e.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(e){if(i)throw i;throw this._logger.log(ce.a.Warning,`Error from HTTP request. ${e}.`),e}finally{r&&clearTimeout(r),e.abortSignal&&(e.abortSignal.onabort=null)}if(!n.ok){var o=await pe(n,"text");throw new X(o||n.statusText,n.status)}e=await pe(n,e.responseType);return new re(n.status,n.statusText,e)}getCookieString(e){let i="";return he.c.isNode&&this._jar&&this._jar.getCookies(e,(e,t)=>i=t.join("; ")),i}}function pe(e,t){let i;switch(t){case"arraybuffer":i=e.arrayBuffer();break;case"text":i=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`);default:i=e.text()}return i}class de extends ne{constructor(e){super(),this._logger=e}send(n){return n.abortSignal&&n.abortSignal.aborted?Promise.reject(new K):n.method?n.url?new Promise((e,t)=>{const i=new XMLHttpRequest;i.open(n.method,n.url,!0),i.withCredentials=void 0===n.withCredentials||n.withCredentials,i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const r=n.headers;r&&Object.keys(r).forEach(e=>{i.setRequestHeader(e,r[e])}),n.responseType&&(i.responseType=n.responseType),n.abortSignal&&(n.abortSignal.onabort=()=>{i.abort(),t(new K)}),n.timeout&&(i.timeout=n.timeout),i.onload=()=>{n.abortSignal&&(n.abortSignal.onabort=null),200<=i.status&&i.status<300?e(new re(i.status,i.statusText,i.response||i.responseText)):t(new X(i.response||i.responseText||i.statusText,i.status))},i.onerror=()=>{this._logger.log(ce.a.Warning,`Error from HTTP request. ${i.status}: ${i.statusText}.`),t(new X(i.statusText,i.status))},i.ontimeout=()=>{this._logger.log(ce.a.Warning,"Timeout from HTTP request."),t(new H)},i.send(n.content||"")}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class fe extends ne{constructor(e){if(super(),"undefined"!=typeof fetch||he.c.isNode)this._httpClient=new ue(e);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new de(e)}}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new K):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}class me{}me.Authorization="Authorization",me.Cookie="Cookie",(t=oe=oe||{})[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling",(t=se=se||{})[t.Text=1]="Text",t[t.Binary=2]="Binary";class _e{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class ge{constructor(e,t,i,r){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._pollAbort=new _e,this._options=r,this._running=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this._pollAbort.aborted}async connect(e,t){if(he.a.isRequired(e,"url"),he.a.isRequired(t,"transferFormat"),he.a.isIn(t,se,"transferFormat"),this._url=e,this._logger.log(ce.a.Trace,"(LongPolling transport) Connecting."),t===se.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");var[i,r]=Object(he.i)(),r={[i]:r,...this._options.headers};const n={abortSignal:this._pollAbort.signal,headers:r,timeout:1e5,withCredentials:this._options.withCredentials};t===se.Binary&&(n.responseType="arraybuffer");t=await this._getAccessToken();this._updateHeaderToken(n,t);e=`${e}&_=${Date.now()}`;this._logger.log(ce.a.Trace,`(LongPolling transport) polling: ${e}.`);e=await this._httpClient.get(e,n);200!==e.statusCode?(this._logger.log(ce.a.Error,`(LongPolling transport) Unexpected response code: ${e.statusCode}.`),this._closeError=new X(e.statusText||"",e.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,n)}async _getAccessToken(){return this._accessTokenFactory?this._accessTokenFactory():null}_updateHeaderToken(e,t){e.headers||(e.headers={}),t?e.headers[me.Authorization]=`Bearer ${t}`:e.headers[me.Authorization]&&delete e.headers[me.Authorization]}async _poll(e,t){try{for(;this._running;){var i=await this._getAccessToken();this._updateHeaderToken(t,i);try{var r=`${e}&_=${Date.now()}`;this._logger.log(ce.a.Trace,`(LongPolling transport) polling: ${r}.`);var n=await this._httpClient.get(r,t);204===n.statusCode?(this._logger.log(ce.a.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==n.statusCode?(this._logger.log(ce.a.Error,`(LongPolling transport) Unexpected response code: ${n.statusCode}.`),this._closeError=new X(n.statusText||"",n.statusCode),this._running=!1):n.content?(this._logger.log(ce.a.Trace,`(LongPolling transport) data received. ${Object(he.f)(n.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(n.content)):this._logger.log(ce.a.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(e){this._running?e instanceof H?this._logger.log(ce.a.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=e,this._running=!1):this._logger.log(ce.a.Trace,`(LongPolling transport) Poll errored after shutdown: ${e.message}`)}}}finally{this._logger.log(ce.a.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?Object(he.k)(this._logger,"LongPolling",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(ce.a.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(ce.a.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const n={};var[e,t]=Object(he.i)();n[e]=t;var i={headers:{...n,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials},r=await this._getAccessToken();this._updateHeaderToken(i,r),await this._httpClient.delete(this._url,i),this._logger.log(ce.a.Trace,"(LongPolling transport) DELETE request sent.")}finally{this._logger.log(ce.a.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(ce.a.Trace,e),this.onclose(this._closeError)}}}class ye{constructor(e,t,i,r){this._httpClient=e,this._accessTokenFactory=t,this._logger=i,this._options=r,this.onreceive=null,this.onclose=null}async connect(a,e){var t;return he.a.isRequired(a,"url"),he.a.isRequired(e,"transferFormat"),he.a.isIn(e,se,"transferFormat"),this._logger.log(ce.a.Trace,"(SSE transport) Connecting."),this._url=a,!this._accessTokenFactory||(t=await this._accessTokenFactory())&&(a+=(a.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(t)}`),new Promise((t,i)=>{let r=!1;if(e===se.Text){let e;if(he.c.isBrowser||he.c.isWebWorker)e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials});else{var n=this._httpClient.getCookieString(a);const s={};s.Cookie=n;var[o,n]=Object(he.i)();s[o]=n,e=new this._options.EventSource(a,{withCredentials:this._options.withCredentials,headers:{...s,...this._options.headers}})}try{e.onmessage=e=>{if(this.onreceive)try{this._logger.log(ce.a.Trace,`(SSE transport) data received. ${Object(he.f)(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(e){return void this._close(e)}},e.onerror=e=>{r?this._close():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},e.onopen=()=>{this._logger.log(ce.a.Information,`SSE connected to ${this._url}`),this._eventSource=e,r=!0,t()}}catch(e){return void i(e)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))})}async send(e){return this._eventSource?Object(he.k)(this._logger,"SSE",this._httpClient,this._url,this._accessTokenFactory,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class xe{constructor(e,t,i,r,n,o){this._logger=i,this._accessTokenFactory=t,this._logMessageContent=r,this._webSocketConstructor=n,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=o}async connect(l,c){var e;return he.a.isRequired(l,"url"),he.a.isRequired(c,"transferFormat"),he.a.isIn(c,se,"transferFormat"),this._logger.log(ce.a.Trace,"(WebSockets transport) Connecting."),!this._accessTokenFactory||(e=await this._accessTokenFactory())&&(l+=(l.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`),new Promise((t,i)=>{l=l.replace(/^http/,"ws");let r;var e=this._httpClient.getCookieString(l);let n=!1;if(he.c.isNode){const a={};var[o,s]=Object(he.i)();a[o]=s,e&&(a[me.Cookie]=`${e}`),r=new this._webSocketConstructor(l,void 0,{headers:{...a,...this._headers}})}r=r||new this._webSocketConstructor(l),c===se.Binary&&(r.binaryType="arraybuffer"),r.onopen=e=>{this._logger.log(ce.a.Information,`WebSocket connected to ${l}.`),this._webSocket=r,n=!0,t()},r.onerror=e=>{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"There was an error with the transport",this._logger.log(ce.a.Information,`(WebSockets transport) ${t}.`)},r.onmessage=e=>{if(this._logger.log(ce.a.Trace,`(WebSockets transport) data received. ${Object(he.f)(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(e){return void this._close(e)}},r.onclose=t=>{if(n)this._close(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",i(new Error(e))}}})}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(ce.a.Trace,`(WebSockets transport) sending data. ${Object(he.f)(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(ce.a.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(e)||!1!==e.wasClean&&1e3===e.code?e instanceof Error?this.onclose(e):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)))}_isCloseEvent(e){return e&&"boolean"==typeof e.wasClean&&"number"==typeof e.code}}class ve{constructor(e,t={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,he.a.isRequired(e,"url"),this._logger=Object(he.e)(t.logger),this.baseUrl=this._resolveUrl(e),(t=t||{}).logMessageContent=void 0!==t.logMessageContent&&t.logMessageContent,"boolean"!=typeof t.withCredentials&&void 0!==t.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.withCredentials=void 0===t.withCredentials||t.withCredentials,t.timeout=void 0===t.timeout?1e5:t.timeout;let i=null,r=null;if(he.c.isNode){const n=require;i=n("ws"),r=n("eventsource")}he.c.isNode||"undefined"==typeof WebSocket||t.WebSocket?he.c.isNode&&!t.WebSocket&&i&&(t.WebSocket=i):t.WebSocket=WebSocket,he.c.isNode||"undefined"==typeof EventSource||t.EventSource?he.c.isNode&&!t.EventSource&&void 0!==r&&(t.EventSource=r):t.EventSource=EventSource,this._httpClient=t.httpClient||new fe(this._logger),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||se.Binary,he.a.isIn(e,se,"transferFormat"),this._logger.log(ce.a.Debug,`Starting connection with transfer format '${se[e]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,"Disconnecting"===this._connectionState){var t="Failed to start the HttpConnection before stop() was called.";return this._logger.log(ce.a.Error,t),await this._stopPromise,Promise.reject(new Error(t))}if("Connected"!==this._connectionState){t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(ce.a.Error,t),Promise.reject(new Error(t))}this._connectionStarted=!0}send(e){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new be(this.transport)),this._sendQueue.send(e))}async stop(e){return"Disconnected"===this._connectionState?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise(e=>{this._stopPromiseResolver=e}),await this._stopInternal(e),void await this._stopPromise)}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch(e){}if(this.transport){try{await this.transport.stop()}catch(e){this._logger.log(ce.a.Error,`HttpConnection.transport.stop() threw error '${e}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(ce.a.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(i){let r=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==oe.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(oe.WebSockets),await this._startTransport(r,i)}else{let e=null,t=0;do{if(e=await this._getNegotiationResponse(r),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new Error("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(r=e.url),e.accessToken){const n=e.accessToken;this._accessTokenFactory=()=>n}}while(t++,e.url&&t<100);if(100===t&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(r,this._options.transport,e,i)}this.transport instanceof ge&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(ce.a.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(e){return this._logger.log(ce.a.Error,"Failed to start the connection: "+e),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(e)}}async _getNegotiationResponse(e){const t={};!this._accessTokenFactory||(r=await this._accessTokenFactory())&&(t[me.Authorization]=`Bearer ${r}`);var[i,r]=Object(he.i)();t[i]=r;e=this._resolveNegotiateUrl(e);this._logger.log(ce.a.Debug,`Sending negotiation request: ${e}.`);try{var n=await this._httpClient.post(e,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==n.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${n.statusCode}'`));const o=JSON.parse(n.content);return(!o.negotiateVersion||o.negotiateVersion<1)&&(o.connectionToken=o.connectionId),o}catch(e){let t="Failed to complete negotiation with the server: "+e;return e instanceof X&&404===e.statusCode&&(t+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(ce.a.Error,t),Promise.reject(new te(t))}}_createConnectUrl(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+`id=${t}`:e}async _createTransport(e,t,i,r){let n=this._createConnectUrl(e,i.connectionToken);if(this._isITransport(t))return this._logger.log(ce.a.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(n,r),void(this.connectionId=i.connectionId);const o=[];let s=i;for(const l of i.availableTransports||[]){var a=this._resolveTransportOrError(l,t,r);if(a instanceof Error)o.push(`${l.transport} failed:`),o.push(a);else if(this._isITransport(a)){if(this.transport=a,!s){try{s=await this._getNegotiationResponse(e)}catch(e){return Promise.reject(e)}n=this._createConnectUrl(e,s.connectionToken)}try{return await this._startTransport(n,r),void(this.connectionId=s.connectionId)}catch(e){if(this._logger.log(ce.a.Error,`Failed to start the transport '${l.transport}': ${e}`),s=void 0,o.push(new ee(`${l.transport} failed: ${e}`,oe[l.transport])),"Connecting"!==this._connectionState){a="Failed to select transport before stop() was called.";return this._logger.log(ce.a.Debug,a),Promise.reject(new Error(a))}}}}return 0<o.length?Promise.reject(new ie(`Unable to connect to the server with any of the available transports. ${o.join(" ")}`,o)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case oe.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new xe(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case oe.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new ye(this._httpClient,this._accessTokenFactory,this._logger,this._options);case oe.LongPolling:return new ge(this._httpClient,this._accessTokenFactory,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,i){var r,n=oe[e.transport];if(null==n)return this._logger.log(ce.a.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(r=n,(t=t)&&0==(r&t))return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it was disabled by the client.`),new Q(`'${oe[n]}' is disabled by the client.`,n);{const o=e.transferFormats.map(e=>se[e]);if(!(0<=o.indexOf(i)))return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it does not support the requested transfer format '${se[i]}'.`),new Error(`'${oe[n]}' does not support ${se[i]}.`);if(n===oe.WebSockets&&!this._options.WebSocket||n===oe.ServerSentEvents&&!this._options.EventSource)return this._logger.log(ce.a.Debug,`Skipping transport '${oe[n]}' because it is not supported in your environment.'`),new J(`'${oe[n]}' is not supported in your environment.`,n);this._logger.log(ce.a.Debug,`Selecting transport '${oe[n]}'.`);try{return this._constructTransport(n)}catch(e){return e}}}_isITransport(e){return e&&"object"==typeof e&&"connect"in e}_stopConnection(t){if(this._logger.log(ce.a.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this._connectionState}.`),this.transport=void 0,t=this._stopError||t,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(ce.a.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),t?this._logger.log(ce.a.Error,`Connection disconnected with error '${t}'.`):this._logger.log(ce.a.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch(e=>{this._logger.log(ce.a.Error,`TransportSendQueue.stop() threw error '${e}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(t)}catch(e){this._logger.log(ce.a.Error,`HttpConnection.onclose(${t}) threw error '${e}'.`)}}}else this._logger.log(ce.a.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!he.c.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(ce.a.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){var t=e.indexOf("?");let i=e.substring(0,-1===t?e.length:t);return"/"!==i[i.length-1]&&(i+="/"),i+="negotiate",i+=-1===t?"":e.substring(t),-1===i.indexOf("negotiateVersion")&&(i+=-1===t?"?":"&",i+="negotiateVersion="+this._negotiateVersion),i}}class be{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new we,this._transportResult=new we,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new we),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new we;const t=this._transportResult;this._transportResult=void 0;var e="string"==typeof this._buffer[0]?this._buffer.join(""):be._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(e),t.resolve()}catch(e){t.reject(e)}}}static _concatBuffers(e){var t=e.map(e=>e.byteLength).reduce((e,t)=>e+t);const i=new Uint8Array(t);let r=0;for(const n of e)i.set(new Uint8Array(n),r),r+=n.byteLength;return i.buffer}}class we{constructor(){this.promise=new Promise((e,t)=>[this._resolver,this._rejecter]=[e,t])}resolve(){this._resolver()}reject(e){this._rejecter(e)}}class Te{static write(e){return`${e}${Te.RecordSeparator}`}static parse(e){if(e[e.length-1]!==Te.RecordSeparator)throw new Error("Message is incomplete.");const t=e.split(Te.RecordSeparator);return t.pop(),t}}Te.RecordSeparatorCode=30,Te.RecordSeparator=String.fromCharCode(Te.RecordSeparatorCode);class Ee{writeHandshakeRequest(e){return Te.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,i;if(Object(he.j)(e)){const o=new Uint8Array(e);var r=o.indexOf(Te.RecordSeparatorCode);if(-1===r)throw new Error("Message is incomplete.");r=r+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(o.slice(0,r))),i=o.byteLength>r?o.slice(r).buffer:null}else{const s=e;var n=s.indexOf(Te.RecordSeparator);if(-1===n)throw new Error("Message is incomplete.");n=n+1;t=s.substring(0,n),i=s.length>n?s.substring(n):null}n=Te.parse(t),n=JSON.parse(n[0]);if(n.type)throw new Error("Expected a handshake response from the server.");return[i,n]}}(t=ae=ae||{})[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close";class Ae{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new he.d(this,e)}}(t=le=le||{}).Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting";class Se{constructor(e,t,i,r){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(ce.a.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},he.a.isRequired(e,"connection"),he.a.isRequired(t,"logger"),he.a.isRequired(i,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this._logger=t,this._protocol=i,this.connection=e,this._reconnectPolicy=r,this._handshakeProtocol=new Ee,this.connection.onreceive=e=>this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=le.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:ae.Ping})}static create(e,t,i,r){return new Se(e,t,i,r)}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==le.Disconnected&&this._connectionState!==le.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==le.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=le.Connecting,this._logger.log(ce.a.Debug,"Starting HubConnection.");try{await this._startInternal(),he.c.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=le.Connected,this._connectionStarted=!0,this._logger.log(ce.a.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=le.Disconnected,this._logger.log(ce.a.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;var e=new Promise((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t});await this.connection.start(this._protocol.transferFormat);try{var t={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(ce.a.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(t)),this._logger.log(ce.a.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError}catch(e){throw this._logger.log(ce.a.Debug,`Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(e),e}}async stop(){var e=this._startPromise;this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch(e){}}_stopInternal(e){return this._connectionState===le.Disconnected?(this._logger.log(ce.a.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve()):this._connectionState===le.Disconnecting?(this._logger.log(ce.a.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState=le.Disconnecting,this._logger.log(ce.a.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(ce.a.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new Error("The connection was stopped before the hub handshake could complete."),this.connection.stop(e)))}stream(e,...t){var[i,r]=this._replaceStreamingParams(t);const n=this._createStreamInvocation(e,t,r);let o;const s=new Ae;return s.cancelCallback=()=>{const e=this._createCancelInvocation(n.invocationId);return delete this._callbacks[n.invocationId],o.then(()=>this._sendWithProtocol(e))},this._callbacks[n.invocationId]=(e,t)=>{t?s.error(t):e&&(e.type===ae.Completion?e.error?s.error(new Error(e.error)):s.complete():s.next(e.item))},o=this._sendWithProtocol(n).catch(e=>{s.error(e),delete this._callbacks[n.invocationId]}),this._launchStreams(i,o),s}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){var[i,r]=this._replaceStreamingParams(t),r=this._sendWithProtocol(this._createInvocation(e,t,!0,r));return this._launchStreams(i,r),r}invoke(e,...t){const[n,i]=this._replaceStreamingParams(t),o=this._createInvocation(e,t,!1,i);return new Promise((i,r)=>{this._callbacks[o.invocationId]=(e,t)=>{t?r(t):e&&(e.type===ae.Completion?e.error?r(new Error(e.error)):i(e.result):r(new Error(`Unexpected message type: ${e.type}`)))};var e=this._sendWithProtocol(o).catch(e=>{r(e),delete this._callbacks[o.invocationId]});this._launchStreams(n,e)})}on(e,t){e&&t&&(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),-1===this._methods[e].indexOf(t)&&this._methods[e].push(t))}off(e,t){if(e){e=e.toLowerCase();const i=this._methods[e];i&&(t?-1!==(t=i.indexOf(t))&&(i.splice(t,1),0===i.length&&delete this._methods[e]):delete this._methods[e])}}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e)for(const i of this._protocol.parseMessages(e,this._logger))switch(i.type){case ae.Invocation:this._invokeClientMethod(i);break;case ae.StreamItem:case ae.Completion:{const r=this._callbacks[i.invocationId];if(r){i.type===ae.Completion&&delete this._callbacks[i.invocationId];try{r(i)}catch(e){this._logger.log(ce.a.Error,`Stream callback threw error: ${Object(he.g)(e)}`)}}break}case ae.Ping:break;case ae.Close:this._logger.log(ce.a.Information,"Close message received from server.");var t=i.error?new Error("Server returned an error on close: "+i.error):void 0;!0===i.allowReconnect?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break;default:this._logger.log(ce.a.Warning,`Invalid message type: ${i.type}.`)}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,i;try{[i,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(e){var r="Error parsing handshake response: "+e;this._logger.log(ce.a.Error,r);r=new Error(r);throw this._handshakeRejecter(r),r}if(t.error){r="Server returned handshake error: "+t.error;this._logger.log(ce.a.Error,r);r=new Error(r);throw this._handshakeRejecter(r),r}return this._logger.log(ce.a.Debug,"Server handshake complete."),this._handshakeResolver(),i}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds),void 0!==this._pingServerHandle))){let e=this._nextKeepAlive-(new Date).getTime();e<0&&(e=0),this._pingServerHandle=setTimeout(async()=>{if(this._connectionState===le.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}},e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}_invokeClientMethod(t){const e=this._methods[t.target.toLowerCase()];if(e){try{e.forEach(e=>e.apply(this,t.arguments))}catch(e){this._logger.log(ce.a.Error,`A callback for the method ${t.target.toLowerCase()} threw error '${e}'.`)}var i;t.invocationId&&(this._logger.log(ce.a.Error,i="Server requested a response, which is not supported in this version of the client."),this._stopPromise=this._stopInternal(new Error(i)))}else this._logger.log(ce.a.Warning,`No client method with the name '${t.target}' found.`)}_connectionClosed(e){this._logger.log(ce.a.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new Error("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===le.Disconnecting?this._completeClose(e):this._connectionState===le.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===le.Connected&&this._completeClose(e)}_completeClose(t){if(this._connectionStarted){this._connectionState=le.Disconnected,this._connectionStarted=!1,he.c.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(ce.a.Error,`An onclose callback called with error '${t}' threw error '${e}'.`)}}}async _reconnect(t){var i=Date.now();let r=0;var n=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error.");let o=this._getNextRetryDelay(r++,0,n);if(null===o)return this._logger.log(ce.a.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(t);if(this._connectionState=le.Reconnecting,t?this._logger.log(ce.a.Information,`Connection reconnecting because of error '${t}'.`):this._logger.log(ce.a.Information,"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach(e=>e.apply(this,[t]))}catch(e){this._logger.log(ce.a.Error,`An onreconnecting callback called with error '${t}' threw error '${e}'.`)}if(this._connectionState!==le.Reconnecting)return void this._logger.log(ce.a.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==o;){if(this._logger.log(ce.a.Information,`Reconnect attempt number ${r} will start in ${o} ms.`),await new Promise(e=>{this._reconnectDelayHandle=setTimeout(e,o)}),this._reconnectDelayHandle=void 0,this._connectionState!==le.Reconnecting)return void this._logger.log(ce.a.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=le.Connected,this._logger.log(ce.a.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach(e=>e.apply(this,[this.connection.connectionId]))}catch(e){this._logger.log(ce.a.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`)}return}catch(e){if(this._logger.log(ce.a.Information,`Reconnect attempt failed because of error '${e}'.`),this._connectionState!==le.Reconnecting)return this._logger.log(ce.a.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===le.Disconnecting&&this._completeClose());n=e instanceof Error?e:new Error(e.toString()),o=this._getNextRetryDelay(r++,Date.now()-i,n)}}this._logger.log(ce.a.Information,`Reconnect retries have been exhausted after ${Date.now()-i} ms and ${r} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(t,i,e){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:i,previousRetryCount:t,retryReason:e})}catch(e){return this._logger.log(ce.a.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${i}) threw error '${e}'.`),null}}_cancelCallbacksWithError(i){const r=this._callbacks;this._callbacks={},Object.keys(r).forEach(e=>{const t=r[e];try{t(null,i)}catch(e){this._logger.log(ce.a.Error,`Stream 'error' callback called with '${i}' threw error: ${Object(he.g)(e)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,i,r){if(i)return 0!==r.length?{arguments:t,streamIds:r,target:e,type:ae.Invocation}:{arguments:t,target:e,type:ae.Invocation};{const n=this._invocationId;return this._invocationId++,0!==r.length?{arguments:t,invocationId:n.toString(),streamIds:r,target:e,type:ae.Invocation}:{arguments:t,invocationId:n.toString(),target:e,type:ae.Invocation}}}_launchStreams(e,i){if(0!==e.length){i=i||Promise.resolve();for(const r in e)e[r].subscribe({complete:()=>{i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(r)))},error:e=>{let t;t=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(r,t)))},next:e=>{i=i.then(()=>this._sendWithProtocol(this._createStreamItemMessage(r,e)))}})}}_replaceStreamingParams(t){const i=[],r=[];for(let e=0;e<t.length;e++){var n=t[e];if(this._isObservable(n)){const o=this._invocationId;this._invocationId++,i[o]=n,r.push(o.toString()),t.splice(e,1)}}return[i,r]}_isObservable(e){return e&&e.subscribe&&"function"==typeof e.subscribe}_createStreamInvocation(e,t,i){const r=this._invocationId;return this._invocationId++,0!==i.length?{arguments:t,invocationId:r.toString(),streamIds:i,target:e,type:ae.StreamInvocation}:{arguments:t,invocationId:r.toString(),target:e,type:ae.StreamInvocation}}_createCancelInvocation(e){return{invocationId:e,type:ae.CancelInvocation}}_createStreamItemMessage(e,t){return{invocationId:e,item:t,type:ae.StreamItem}}_createCompletionMessage(e,t,i){return t?{error:t,invocationId:e,type:ae.Completion}:{invocationId:e,result:i,type:ae.Completion}}}var Ce=i(11);class Me{constructor(){this.name="json",this.version=1,this.transferFormat=se.Text}parseMessages(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=Ce.a.instance);const i=[];for(const n of Te.parse(e)){var r=JSON.parse(n);if("number"!=typeof r.type)throw new Error("Invalid payload.");switch(r.type){case ae.Invocation:this._isInvocationMessage(r);break;case ae.StreamItem:this._isStreamItemMessage(r);break;case ae.Completion:this._isCompletionMessage(r);break;case ae.Ping:case ae.Close:break;default:t.log(ce.a.Information,"Unknown message type '"+r.type+"' ignored.");continue}i.push(r)}return i}writeMessage(e){return Te.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this._assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this._assertNotEmptyString(e.error,"Invalid payload for Completion message."),this._assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")}_assertNotEmptyString(e,t){if("string"!=typeof e||""===e)throw new Error(t)}}const Ie={trace:ce.a.Trace,debug:ce.a.Debug,info:ce.a.Information,information:ce.a.Information,warn:ce.a.Warning,warning:ce.a.Warning,error:ce.a.Error,critical:ce.a.Critical,none:ce.a.None};class Be{configureLogging(e){var t;return he.a.isRequired(e,"logging"),void 0!==e.log?this.logger=e:"string"==typeof e?(t=function(e){var t=Ie[e.toLowerCase()];if(void 0!==t)return t;throw new Error(`Unknown log level: ${e}`)}(e),this.logger=new he.b(t)):this.logger=new he.b(e),this}withUrl(e,t){return he.a.isRequired(e,"url"),he.a.isNotEmpty(e,"url"),this.url=e,this.httpConnectionOptions="object"==typeof t?{...this.httpConnectionOptions,...t}:{...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return he.a.isRequired(e,"protocol"),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new W(e):this.reconnectPolicy=e:this.reconnectPolicy=new W,this}build(){const e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");var t=new ve(this.url,e);return Se.create(t,this.logger||Ce.a.instance,this.protocol||new Me,this.reconnectPolicy)}}var t=i(12),ke=i.n(t);class ze{constructor(e,t="540E5CBA3D09480F8CDE2F69C55934EF",i=[117.28688541016095,39.094144209740534]){this.type="custom",this.renderingMode="3d",this.drones={x:39.094144209740534,y:117.28688541016095,z:0},this.onAdd=(e,t)=>{this.map=e;const i=new BABYLON.Engine(t,!0,{useHighPrecisionMatrix:!0},!0);this.scene=new BABYLON.Scene(i),this.scene.autoClear=!1,this.scene.detachControl(),this.scene.beforeRender=function(){i.wipeCaches(!0)},this.camera=new BABYLON.Camera("mapbox-camera",new BABYLON.Vector3,this.scene);let r=new BABYLON.HemisphericLight("light",new BABYLON.Vector3(1,1,0),this.scene);r.intensity=1,r.diffuse=BABYLON.Color3.FromHexString("#FFFFFF"),r.specular=BABYLON.Color3.Black();let n=new BABYLON.HemisphericLight("light1",new BABYLON.Vector3(-1,1,0),this.scene);n.intensity=.7,n.diffuse=BABYLON.Color3.FromHexString("#FFFFFF"),n.specular=BABYLON.Color3.Black(),e.on("click",e=>{console.log(e)}),this.recalculateProjectionMatrix(this.initialCoordinates),BABYLON.SceneLoader.LoadAssetContainerAsync(Pe.rl+"bundle/"+this.modelsId+"/",this.modelsId+".gltf",this.scene).then(e=>{e.addAllToScene();const t=e.meshes[0];e=ke.a.MercatorCoordinate.fromLngLat(this.initialCoordinates,0);t.position=new BABYLON.Vector3((e.x-this.sceneOrigin.x)/this.modelScale,0,-(e.y-this.sceneOrigin.y)/this.modelScale),t.rotation=new BABYLON.Vector3(0,Math.PI/13,0)})},this.render=(e,t)=>{t=BABYLON.Matrix.FromArray(t),t=this.modelMatrix.multiply(t);this.camera.freezeProjectionMatrix(t),this.scene.render(!1),this.map.triggerRepaint()},this.id=e,this.modelsId=t,this.initialCoordinates=i}recalculateProjectionMatrix(e){var t=[Math.PI/2,0,0];const i=ke.a.MercatorCoordinate.fromLngLat(e,0);this.modelScale=i.meterInMercatorCoordinateUnits(),this.sceneOrigin=new BABYLON.Vector3(i.x,i.y,i.z),this.modelMatrix=BABYLON.Matrix.Compose(new BABYLON.Vector3(this.modelScale,this.modelScale,this.modelScale),BABYLON.Quaternion.FromEulerAngles(t[0],t[1],t[2]),this.sceneOrigin)}}class Pe{}Pe.sl="https://www.wodashijie.com/",Pe.rl="https://models.wodashijie.com/",Pe.App=class{constructor(e){e.sl&&(Pe.sl=e.sl),e.rl&&(Pe.rl=e.rl),F.defaults.baseURL=Pe.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;",e.container.appendChild(this.canvas),this.engine=new BABYLON.Engine(this.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0,doNotHandleContextLost:!1}),this.engine.setHardwareScalingLevel(.5),this.scene=new BABYLON.Scene(this.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),this.scene.useRightHandedSystem=!0,this.scene.getBoundingBoxRenderer().frontColor=BABYLON.Color3.Green(),this.scene.getBoundingBoxRenderer().showBackLines=!1,this.CameraController=new s(this),this.HighlightLayer=new BABYLON.HighlightLayer("highlightLayer",this.scene),this.IEvent=new r(this),this.container=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.Environment=new g(this),this.Environment.defaultLights(),this.Environment.openAllLight(),this.Resources=new R(this),this.Project=new D(this),Pe.EffectMgr.init(),this.engine.runRenderLoop(()=>{this.fps&&(this.fps.innerText=this.engine.getFps().toFixed()+" fps"),this.scene.render(),v.a.update(),this.IEvent&&this.IEvent.runRender()}),window.addEventListener("resize",()=>{this.engine.resize()}),this.scene.onPointerObservable.add(e=>{this.IEvent&&this.IEvent.onPointer(e)}),this.scene.onKeyboardObservable.add(e=>{this.IEvent&&this.IEvent.onKeyboard(e)})}async load(u){if(u){u.isDefaultLevel=null==u.isDefaultLevel||u.isDefaultLevel,Pe.pk=u.pk;var e=await F.get(`api/service/GetToken?accessToken=${Pe.accessToken}`);if(200==e.status){localStorage.setItem("mx3d-token",e.data);e=await F.get("api/service");if(200==e.status){localStorage.setItem("mx3d-long",e.data);e=await F.get(`api/service/${Pe.pk}`);if(200==e.status){let h=JSON.parse(class{static de(e){let t=localStorage.getItem("mx3d-long");var i=N.a.enc.Utf8.parse(t.substring(0,32)),r=N.a.enc.Utf8.parse(t.substring(32,48)),e=N.a.enc.Hex.parse(e),e=N.a.enc.Base64.stringify(e);return N.a.AES.decrypt(e,i,{iv:r,mode:N.a.mode.CBC,padding:N.a.pad.Pkcs7}).toString(N.a.enc.Utf8).toString()}}.de(e.data));return new Promise(async(r,t)=>{try{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let t=new d;for(let e=0;e<h.length;e++){const a=h[e];!a.baseModel||".gltf"!=a.baseModel.extension||t.find(a.baseModel.modelId)||this.Resources.resources.find(a.baseModel.modelId)||(a.baseModel.objectType=a.objectType,t.add(a.baseModel.modelId,a.baseModel))}let e=0;for(const l in t.map)await this.Resources.loadModelMesh(t.find(l)),e++,u&&u.progress&&u.progress(e/t.count()*.3);e=0,t=null;let i=new d;for(let e=0;e<h.length;e++){var n,o=h[e];o.objectType==f.Region&&(n=new L(this,o),this.Project.objectDatas.add(n.id,n),i.add(n.id,new Array),"0"==n.parentId&&(this.Project.root=n))}for(let e=0;e<h.length;e++){var s=h[e];if(s.objectType!=f.Region){let e=i.find(s.parentId);e.push(s)}}for(const c in i.map)await this.Project.objectDatas.find(c).bind(i.find(c)),e++,u&&u.progress&&u.progress(.3+e/i.count()*.7);i=null,this.Project.optimization(),u.isDefaultLevel&&this.Project.switchLevel(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,r(null),this.engine.resize(),u&&u.complete&&u.complete()}catch(e){t(e)}})}}}}else console.error("场景编号不能为空!")}dispose(){this.Environment.hideFps(),this.Project.clear(),this.Resources.delete(),this.engine.dispose()}},Pe.Earth=class{constructor(e,t=[117.28688541016095,39.094144209740534]){this.initialCoordinates=[117.28688541016095,39.094144209740534],this.initialCoordinates=t,ke.a.accessToken="pk.eyJ1IjoibGl1ayIsImEiOiJjanczNmJoZjkwY3IxM3lxcTd1NmMwZWxjIn0.11SpcY8De0c1q6S3a-2Qcg",this.map=new ke.a.Map({container:e,style:"mapbox://styles/mapbox/satellite-streets-v11",zoom:1.5,center:this.initialCoordinates,projection:"globe"})}load(e){this.map.on("style.load",()=>{this.map.setFog({color:"rgb(220, 159, 159)","high-color":"rgb(36, 92, 223)","horizon-blend":.4}),this.map.addSource("mapbox-dem",{type:"raster-dem",url:"mapbox://mapbox.terrain-rgb"}),this.map.setTerrain({source:"mapbox-dem",exaggeration:1.5}),e&&e()})}laodScene(e,t=this.initialCoordinates){t=new ze("babylon-layer",e,t);this.map.addLayer(t)}flyTo(e=this.initialCoordinates,t=18,i=130,r=75,n=12e3){this.map.flyTo({center:e,zoom:t,bearing:i,pitch:r,duration:n,essential:!0})}},Pe.Tools=p,Pe.EffectMgr=b,Pe.HubService=class{static async listener(e){this.connection=(new Be).withUrl(e).configureLogging(ce.a.Error).build(),this.connection.onclose(async()=>{await this.start()}),await this.start()}static async start(){try{await this.connection.start()}catch(e){console.log("无法连接服务器"),setTimeout(this.start,5e3)}}},Pe.UI=class{static createIconFromMesh(e,t,i,r,n){let o=t.Sight.focus.clone();var s=t.instance.getBoundingInfo();return o.y+=(s.boundingBox.maximum.y-s.boundingBox.minimum.y)/2,new j(e,o,i,r,n,t.app.scene)}static createIcon(e,t,i,r){let n;t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,n=new U(e,t.app.scene),n.size=i,n.height=r,n.pint=new BABYLON.Mesh(e+"_pint");e=t.Sight.focus.clone();return n.pint.position=e,n.pint.position.y+=r,n.rect=new BABYLON.GUI.Rectangle,n.rect.isPointerBlocker=!1,n.rect.width=i.width+"px",n.rect.height=i.height+"px",n.rect.thickness=0,t.app.container.addControl(n.rect),n.rect.linkWithMesh(n.pint),t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,n}},Pe.Builder=class{static createMatrixCloud(n){n.displayValues=null!=n.displayValues&&n.displayValues,n.isAlpha=null==n.isAlpha||n.isAlpha,n.isParticle=null==n.isParticle||n.isParticle,n.height=n.height||.5,n.radius=n.radius||2.8,n.isLevelRender=null==n.isLevelRender||n.isLevelRender,n.range=n.range||{max:30,min:16};let o;if(!(n.value||n.value.maxX||n.value.maxY||n.value.data||n.anchor))return o;n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,o=new G(n.anchor);var s=n.anchor.instance.getBoundingInfo();o.mesh=n.anchor.instance.clone(o.id),o.mesh.position.y+=n.height;var a=s.maximum.x-s.minimum.x,l=a/(2*n.value.maxX),c=s.maximum.z-s.minimum.z,h=c/(2*n.value.maxY);let e=new Array;for(let r=0;r<2*n.value.maxX;r++)for(let i=0;i<2*n.value.maxY;i++){let t={x:r,y:i,value:n.range.min};for(let e=0;e<n.value.data.length;e++){var u=n.value.data[e];2*u.x+1==r&&2*u.y+1==i&&(t.value=u.value,u=new BABYLON.Vector3(s.boundingSphere.center.x-(a/2-l*r),o.mesh.position.y,s.boundingSphere.center.z-(c/2-h*i)),o.texts.push(this.createTempVlaue(t.value+"℃",u,n.anchor.app.scene,n.anchor.app.container)))}e.push(t)}o.displayValues=n.displayValues;let t=$.create({width:2*n.value.maxX,height:2*n.value.maxY,radius:n.radius});t.setData({min:n.range.min,max:n.range.max,data:e});let i=new BABYLON.StandardMaterial(o.id,n.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),n.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,n.isAlpha&&(i.diffuseTexture.hasAlpha=!0),n.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getMatrixParticleTex(Pe.rl,n.anchor.app.Resources.FogTex,i.diffuseTexture,o.mesh,n.anchor.app.scene,n.isLevelRender),o.mesh.isVisible=!1),n.isLevelRender&&(o.mesh.renderingGroupId=1),o.mesh.material=i,o.mesh.alwaysSelectAsActiveMesh=!0,o.mesh.freezeWorldMatrix(),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,o}static _getMatrixParticleTex(e,t,i,r,n,o){let s,a=t.clone(),l=r.getBoundingInfo().boundingBox;var c=(l.extendSizeWorld.x+l.extendSizeWorld.z)/9,t=1500*c*c;l.minimumWorld.subtract(new BABYLON.Vector3(-0,0,-0)),l.maximumWorld.subtract(new BABYLON.Vector3(0,0,0));s&&s.dispose(),BABYLON.GPUParticleSystem.IsSupported&&(s=new BABYLON.GPUParticleSystem("particles",{capacity:t},n),s.activeParticleCount=t,s.manualEmitCount=s.activeParticleCount,s.minEmitBox=l.minimumWorld,s.maxEmitBox=l.maximumWorld),s.particleTexture=a,s.emitter=r,o&&(s.renderingGroupId=1),s.isLocal=!0;let h=new BABYLON.NodeMaterial("nm_heatmapBox_"+r.id,n);return h.loadAsync(e+"resources/horizontalNodeMat.json").then(()=>{h.build(!1),h.getBlockByName("boxTex").texture=i,h.getBlockByName("emitXMin").value=s.minEmitBox.x,h.getBlockByName("emitXMax").value=s.maxEmitBox.x,h.getBlockByName("emitYMin").value=s.minEmitBox.z,h.getBlockByName("emitYMax").value=s.maxEmitBox.z,h.createEffectForParticles(s)}),r.onDispose=()=>{s&&s.dispose()},s.onDispose=()=>{h&&h.dispose(),a&&a.dispose()},s.color1=new BABYLON.Color4(.8,.8,.8,.1),s.color2=new BABYLON.Color4(.95,.95,.95,.15),s.colorDead=new BABYLON.Color4(.9,.9,.9,.1),s.minSize=1.4,s.maxSize=2,s.minLifeTime=Number.MAX_SAFE_INTEGER,s.emitRate=5e4*c,s.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,s.gravity=new BABYLON.Vector3(0,0,0),s.direction1=new BABYLON.Vector3(0,0,0),s.direction2=new BABYLON.Vector3(0,0,0),s.minAngularSpeed=-2,s.maxAngularSpeed=2,s.minEmitPower=.5,s.maxEmitPower=1,s.updateSpeed=.005,s.start(),s}static createPunctateCloud(r){if(r.displayValues=null!=r.displayValues&&r.displayValues,r.isAlpha=null==r.isAlpha||r.isAlpha,r.isParticle=null==r.isParticle||r.isParticle,r.radius=r.radius||1,r.isLevelRender=null==r.isLevelRender||r.isLevelRender,r.range=r.range||{max:30,min:16},!r.value&&!r.anchor)return console.error("要创建的云图数值为空!"),null;let e;r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,e=new G(r.anchor),e.mesh=BABYLON.MeshBuilder.CreatePlane(e.id,{width:1,height:1,sideOrientation:2},r.anchor.app.scene),e.mesh.scaling=new BABYLON.Vector3(r.radius,r.radius,r.radius),e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.enablePointerMoveEvents=!1,e.mesh.isPickable=!1,e.mesh.position=r.anchor.instance.position.clone(),e.mesh.rotation.x=Math.PI/2;let n=[];for(let i=0;i<6;i++)for(let t=0;t<6;t++){let e={x:i,y:t,value:r.range.min};2==i&&2==t||3==i&&2==t||2==i&&3==t||3==i&&3==t?e.value=r.value:e.value=r.value-2*(Math.abs(2-i)+Math.abs(2-t)),n.push(e)}e.displayValues=r.displayValues;let t=$.create({width:5,height:5,radius:2});t.setData({min:r.range.min,max:r.range.max,data:n});let i=new BABYLON.StandardMaterial(e.id,r.anchor.app.scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),r.anchor.app.scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,r.isAlpha&&(i.diffuseTexture.hasAlpha=!0),r.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(i.diffuseTexture,e.mesh,r.anchor.app.scene,e.anchor.app.Resources.FogTex,r.isLevelRender),e.mesh.isVisible=!1),r.isLevelRender&&(e.mesh.renderingGroupId=1),e.mesh.material=i,e.mesh.alwaysSelectAsActiveMesh=!0,e.mesh.freezeWorldMatrix(),r.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,e}static createColumnCloud(n){if(n.displayValues=null!=n.displayValues&&n.displayValues,n.isAlpha=null==n.isAlpha||n.isAlpha,n.isParticle=null==n.isParticle||n.isParticle,n.radius=n.radius||4,n.isLevelRender=null==n.isLevelRender||n.isLevelRender,n.range=n.range||{max:30,min:16},!n.data&&n.data.length<1&&!n.anchor)return console.error("要创建的云图数值为空!"),null;let i;n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,i=new G(n.anchor);var r=.98*n.anchor.instance.scaling.y;i.mesh=BABYLON.MeshBuilder.CreatePlane(i.id,{width:.98*n.anchor.instance.scaling.x,height:r,sideOrientation:2},n.anchor.app.scene),i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.enablePointerMoveEvents=!1,i.mesh.isPickable=!1,i.mesh.position=n.anchor.instance.position.clone(),i.mesh.rotation.z=Math.PI,i.mesh.rotation.y=n.anchor.instance.rotation.y,n.isLevelRender&&(i.mesh.renderingGroupId=1);let e=[];for(let r=0;r<4;r++)for(let i=0;i<3*n.data.length;i++){let t={x:r,y:i,value:n.range.min};for(let e=0;e<n.data.length;e++){var o=n.data[e];2==r&&3*e+2==i&&(t.value=o.value)}e.push(t)}var s=r/n.data.length;for(let t=0;t<n.data.length;t++){let e=i.mesh.position.clone();e.y=e.y-r/2+(r-s*t-s/2),i.texts.push(this.createTempVlaue(n.data[t].value+"℃",e,n.anchor.app.scene,i.anchor.app.container))}i.displayValues=n.displayValues;let t=$.create({width:4,height:3*n.data.length,radius:n.radius});t.setData({min:n.range.min,max:n.range.max,data:e});let a=new BABYLON.StandardMaterial(i.id,n.anchor.app.scene);return a.diffuseTexture=new BABYLON.Texture(t.getDataURL(),n.anchor.app.scene,!1,!1),a.specularColor=new BABYLON.Color3(0,0,0),a.alpha=.5,n.isAlpha&&(a.diffuseTexture.hasAlpha=!0),n.isParticle&&BABYLON.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(a.diffuseTexture,i.mesh,n.anchor.app.scene,i.anchor.app.Resources.FogTex,n.isLevelRender),i.mesh.isVisible=!1),i.mesh.material=a,i.mesh.alwaysSelectAsActiveMesh=!0,i.mesh.freezeWorldMatrix(),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,i}static _getColumnarParticleTex(e,t,i,r,n){let o,s=r.clone();r=t.getBoundingInfo().boundingBox,r.extendSizeWorld.x,r.extendSizeWorld.z;BABYLON.Effect.ShadersStore.particlesVertexShader=`
|
|
26
26
|
precision highp float;
|
|
27
27
|
in vec3 position;
|
|
28
28
|
in vec4 color;
|
|
@@ -106,4 +106,4 @@
|
|
|
106
106
|
|
|
107
107
|
gl_FragColor = vec4(baseTex.xyz, resAlpha.a);
|
|
108
108
|
}
|
|
109
|
-
`;var a=i.getEngine().createEffectForParticles(t.id+"myParticle",["time","u_emitXMin","u_emitYMin","u_emitXMax","u_emitYMax","emitBox_WorldM"],["boxTexSampler"],"");return t.onAfterWorldMatrixUpdateObservable.add(()=>{}),a.onCompileObservable.add(()=>{a.setMatrix("emitBox_WorldM",t.getWorldMatrix()),a.setFloat("u_emitXMin",
|
|
109
|
+
`;var a=i.getEngine().createEffectForParticles(t.id+"myParticle",["time","u_emitXMin","u_emitYMin","u_emitXMax","u_emitYMax","emitBox_WorldM"],["boxTexSampler"],"");return t.onAfterWorldMatrixUpdateObservable.add(()=>{}),a.onCompileObservable.add(()=>{a.setMatrix("emitBox_WorldM",t.getWorldMatrix()),a.setFloat("u_emitXMin",o.minEmitBox.x),a.setFloat("u_emitYMin",o.minEmitBox.y),a.setFloat("u_emitXMax",o.maxEmitBox.x),a.setFloat("u_emitYMax",o.maxEmitBox.y)}),a.onBind=function(){a.setTexture("boxTexSampler",e)},o&&o.dispose(),BABYLON.GPUParticleSystem.IsSupported&&(o=new BABYLON.ParticleSystem("particles",200,i,a),o.manualEmitCount=o.getCapacity(),o.minEmitBox=r.minimum,o.maxEmitBox=r.maximum),t.onDispose=()=>{o&&o.dispose()},o.onDispose=()=>{s&&s.dispose()},o.particleTexture=s.clone(),o.emitter=t,n&&(o.renderingGroupId=1),o.isLocal=!0,o.color1=new BABYLON.Color4(.8,.8,.8,.1),o.color2=new BABYLON.Color4(.95,.95,.95,.15),o.colorDead=new BABYLON.Color4(.9,.9,.9,.1),o.minSize=.7,o.maxSize=1,o.minLifeTime=Number.MAX_SAFE_INTEGER,o.emitRate=50,o.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,o.gravity=new BABYLON.Vector3(0,0,0),o.direction1=new BABYLON.Vector3(0,0,0),o.direction2=new BABYLON.Vector3(0,0,0),o.minAngularSpeed=-2,o.maxAngularSpeed=2,o.minEmitPower=.5,o.maxEmitPower=1,o.updateSpeed=.005,o.start(),o}static createTempVlaue(e,t,i,r){let n=new BABYLON.Mesh("temp_"+a.getGUID(12),i);n.position=t;let o=new BABYLON.GUI.TextBlock;return o.isPointerBlocker=!1,o.text="默认提示",o.color="white",o.resizeToFit=!0,o.fontSize="20px",o.text=e,r.addControl(o),o.linkWithMesh(n),o}static createCapacity(e,t,i,r="200px"){let n=new V(e,t);n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,n.mesh=BABYLON.MeshBuilder.CreateBox("RATIO_"+n.anchor.id,{size:1}),n.mesh.position=n.anchor.instance.position.clone(),n.mesh.position.y-=n.mesh.scaling.y/2,n.mesh.scaling=n.anchor.instance.scaling.clone(),n.mesh.scaling.x=.98*n.mesh.scaling.x,n.mesh.scaling.z=.98*n.mesh.scaling.z,n.mesh.rotation=n.anchor.instance.rotation.clone(),n.mesh.alwaysSelectAsActiveMesh=!0,n.mesh.visibility=1;let o=t<.25?BABYLON.Color3.Blue():.25<=t&&t<.5?BABYLON.Color3.Green():.5<=t&&t<.75?BABYLON.Color3.Yellow():BABYLON.Color3.Red();n.color=o.toHexString(),t*=n.mesh.scaling.y;var s=new BABYLON.Vector3(0,-.5,0);n.mesh.setPivotPoint(s);let a=new BABYLON.StandardMaterial(n.mesh.id,n.anchor.instance._scene);return a.diffuseColor=o,n.mesh.material=a,BABYLON.Animation.CreateAndStartAnimation(n.mesh.id,n.mesh,"scaling.y",15,30,.02,t,0,null),n.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,i&&(n.textMesh=this.createTextMesh(e,i,t,r,"#fff")),n}static createTextMesh(e,t,i,r="200px",n="white"){e.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let o=BABYLON.Mesh.CreatePlane("text_"+e.id,e.instance.scaling.x,e.app.scene,!0,BABYLON.Mesh.DOUBLESIDE);o.alwaysSelectAsActiveMesh=!0,o.position=e.instance.position.clone(),o.position.y=i+.05,o.rotation.y=Math.PI-e.instance.rotation.y,o.rotation.x=-Math.PI/2;let s=new BABYLON.StandardMaterial("text_mat_"+e.id,e.app.scene);s.diffuseColor=BABYLON.Color3.White(),s.emissiveColor=BABYLON.Color3.White();let a=new BABYLON.DynamicTexture("text_tex_"+e.id,{width:1e3*e.instance.scaling.x,height:500*e.instance.scaling.x},e.app.scene,!1);return a.hasAlpha=!0,s.diffuseTexture=a,s.opacityTexture=a,a.drawText(t,1e3*e.instance.scaling.x/2,500*e.instance.scaling.x/2,"bold "+r+" NexaBold",n,"",!0,!0),a.update(),o.material=s,e.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,o}static create2DLine(t,i,r){if(!(i.length<2)){let e=new Z;return e.id=t,e.objs=i,r&&r.width&&(e.width=r.width),r&&r.color&&(e.color=r.color),r&&r.isDotted&&(e.isDotted=r.isDotted),e.update(),e}console.error("要连线的对象不能少于2个。")}static create3DLine(t,i,r){if(!(i.length<2)){let e=new q;return e.id=t,e.objs=i,r&&r.width&&(e.width=r.width),r&&r.color&&(e.color=r.color),e.update(),e}console.error("要连线的对象不能少于2个。")}},Pe.EffectType=y,Pe.EventType=x}],u={},c.m=h,c.c=u,c.d=function(e,t,i){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(t,e){if(1&e&&(t=c(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(c.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)c.d(i,r,function(e){return t[e]}.bind(null,r));return i},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="",c(c.s=85).default;function c(e){if(u[e])return u[e].exports;var t=u[e]={i:e,l:!1,exports:{}};return h[e].call(t.exports,t,t.exports,c),t.l=!0,t.exports}var h,u});
|