mx3d 0.4.10 → 0.5.1
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/components/AlarmFlashing.d.ts +12 -11
- package/{App.d.ts → components/App.d.ts} +43 -42
- package/components/Builder.d.ts +73 -72
- package/components/Capacity.d.ts +11 -10
- package/components/Environment.d.ts +31 -30
- package/components/HeatMap.d.ts +14 -13
- package/components/Icon.d.ts +33 -32
- package/components/IconFromMesh.d.ts +22 -21
- package/components/Line.d.ts +14 -13
- package/components/LineFromMesh.d.ts +13 -12
- package/components/StatusType.d.ts +5 -5
- package/components/UI.d.ts +10 -10
- package/earths/TileLoader.d.ts +6 -0
- package/effects/Cloud.d.ts +42 -42
- package/effects/Effect.d.ts +13 -13
- package/effects/IEffect.d.ts +4 -4
- package/effects/Rain.d.ts +34 -34
- package/effects/Thunder.d.ts +31 -31
- package/events/DefaultEvent.d.ts +11 -0
- package/{components → events}/EventType.d.ts +9 -9
- package/{components/Event → events}/FPSCameraEvent.d.ts +17 -16
- package/events/IEvent.d.ts +6 -0
- package/{HubService.d.ts → hub/HubService.d.ts} +5 -5
- package/index.d.ts +23 -30
- package/lights/Directional.d.ts +8 -7
- package/lights/Hemispheric.d.ts +7 -6
- package/lights/ILightObject.d.ts +11 -10
- package/lights/LightObject.d.ts +16 -15
- package/lights/LightType.d.ts +8 -8
- package/lights/Point.d.ts +8 -7
- package/lights/Spot.d.ts +11 -10
- package/mapboxgl/BabylonLayer.d.ts +0 -24
- package/mapboxgl/Earth.d.ts +0 -9
- package/mapboxgl/Parse3dtile.d.ts +0 -0
- package/models/{baseModel.d.ts → BaseModel.d.ts} +15 -15
- package/models/BuildingObject.d.ts +7 -7
- package/models/CabinetObject.d.ts +4 -4
- package/models/CampusObject.d.ts +8 -8
- package/models/ConduitObject.d.ts +17 -16
- package/models/CornerObject.d.ts +45 -44
- package/models/DefaultObject.d.ts +61 -60
- package/models/DoorObject.d.ts +7 -7
- package/models/FloorObject.d.ts +11 -10
- package/models/IBase.d.ts +23 -22
- package/models/IObject.d.ts +15 -15
- package/models/IRegion.d.ts +49 -48
- package/models/LeakWaterObject.d.ts +12 -11
- package/models/ObjectType.d.ts +16 -16
- package/models/OptimizedWallObject.d.ts +7 -6
- package/models/Project.d.ts +30 -30
- package/models/StoreyObject.d.ts +10 -9
- package/models/UI3DTextObject.d.ts +14 -14
- package/models/VirtualBoxObject.d.ts +13 -12
- package/models/WallObject.d.ts +11 -10
- package/models/WindowObject.d.ts +7 -7
- package/mx3d.kernel.min.js +1 -0
- package/mx3d.min.js +1 -109
- package/mx3d.seat.min.js +1 -0
- package/package.json +1 -1
- package/runtime/index.d.ts +49 -0
- package/tools/ArrayEx.d.ts +3 -3
- package/tools/BaseNode.d.ts +5 -5
- package/tools/CameraController.d.ts +22 -20
- package/tools/Dictionary.d.ts +13 -13
- package/tools/GUID.d.ts +3 -3
- package/tools/RES.d.ts +3 -3
- package/tools/Resources.d.ts +26 -25
- package/tools/Sight.d.ts +15 -14
- package/tools/ToolTips.d.ts +14 -13
- package/tools/Tools.d.ts +21 -20
- package/{axios.d.ts → tools/axios.d.ts} +2 -2
- package/DCModel/DCModel.d.ts +0 -2
- package/ThunderAndRain.d.ts +0 -25
- package/components/EffectMgr.d.ts +0 -11
- package/components/EffectType.d.ts +0 -5
- package/components/Event/DefaultEvent.d.ts +0 -10
- package/components/Event/IEvent.d.ts +0 -5
- package/core/mx3d.kernel.min.js +0 -1
- package/core/mx3d.loaders.min.js +0 -6
- package/core/mx3d.seat.min.js +0 -1146
- package/models/RegionObject.d.ts +0 -14
- /package/{Earth/Tile.d.ts → earths/3dTile.d.ts} +0 -0
package/mx3d.min.js
CHANGED
|
@@ -1,109 +1 @@
|
|
|
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(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(57)}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(21))},function(e,t,i){"use strict";var r,n=i(16),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(0),i(5),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(0),i(11),i(58),i(59),i(7),i(60),i(8),i(14),i(27),i(61),i(28),i(62),i(63),i(64),i(15),i(65),i(5),i(2),i(66),i(67),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),e)},function(e,t,i){var o;e.exports=(o=i(0),i(14),i(15),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(1);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(0),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(0),function(l){var e=n,t=e.lib,i=t.WordArray,r=t.Hasher,t=e.algo,M=[];!function(){for(var e=0;e<64;e++)M[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=S(w=o[0],E=o[1],A=o[2],T=o[3],s,7,M[0]),T=S(T,w,E,A,a,12,M[1]),A=S(A,T,w,E,l,17,M[2]),E=S(E,A,T,w,c,22,M[3]);w=S(w,E,A,T,h,7,M[4]),T=S(T,w,E,A,u,12,M[5]),A=S(A,T,w,E,p,17,M[6]),E=S(E,A,T,w,d,22,M[7]),w=S(w,E,A,T,f,7,M[8]),T=S(T,w,E,A,m,12,M[9]),A=S(A,T,w,E,_,17,M[10]),E=S(E,A,T,w,g,22,M[11]),w=S(w,E,A,T,y,7,M[12]),T=S(T,w,E,A,x,12,M[13]),A=S(A,T,w,E,v,17,M[14]),w=C(w,E=S(E,A,T,w,b,22,M[15]),A,T,a,5,M[16]),T=C(T,w,E,A,p,9,M[17]),A=C(A,T,w,E,g,14,M[18]),E=C(E,A,T,w,s,20,M[19]),w=C(w,E,A,T,u,5,M[20]),T=C(T,w,E,A,_,9,M[21]),A=C(A,T,w,E,b,14,M[22]),E=C(E,A,T,w,h,20,M[23]),w=C(w,E,A,T,m,5,M[24]),T=C(T,w,E,A,v,9,M[25]),A=C(A,T,w,E,c,14,M[26]),E=C(E,A,T,w,f,20,M[27]),w=C(w,E,A,T,x,5,M[28]),T=C(T,w,E,A,l,9,M[29]),A=C(A,T,w,E,d,14,M[30]),w=I(w,E=C(E,A,T,w,y,20,M[31]),A,T,u,4,M[32]),T=I(T,w,E,A,f,11,M[33]),A=I(A,T,w,E,g,16,M[34]),E=I(E,A,T,w,v,23,M[35]),w=I(w,E,A,T,a,4,M[36]),T=I(T,w,E,A,h,11,M[37]),A=I(A,T,w,E,d,16,M[38]),E=I(E,A,T,w,_,23,M[39]),w=I(w,E,A,T,x,4,M[40]),T=I(T,w,E,A,s,11,M[41]),A=I(A,T,w,E,c,16,M[42]),E=I(E,A,T,w,p,23,M[43]),w=I(w,E,A,T,m,4,M[44]),T=I(T,w,E,A,y,11,M[45]),A=I(A,T,w,E,b,16,M[46]),w=B(w,E=I(E,A,T,w,l,23,M[47]),A,T,s,6,M[48]),T=B(T,w,E,A,d,10,M[49]),A=B(A,T,w,E,v,15,M[50]),E=B(E,A,T,w,u,21,M[51]),w=B(w,E,A,T,y,6,M[52]),T=B(T,w,E,A,c,10,M[53]),A=B(A,T,w,E,_,15,M[54]),E=B(E,A,T,w,a,21,M[55]),w=B(w,E,A,T,f,6,M[56]),T=B(T,w,E,A,b,10,M[57]),A=B(A,T,w,E,p,15,M[58]),E=B(E,A,T,w,x,21,M[59]),w=B(w,E,A,T,h,6,M[60]),T=B(T,w,E,A,g,10,M[61]),A=B(A,T,w,E,l,15,M[62]),E=B(E,A,T,w,m,21,M[63]),o[0]=o[0]+w|0,o[1]=o[1]+E|0,o[2]=o[2]+A|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 S(e,t,i,r,n,o,s){s=e+(t&i|~t&r)+n+s;return(s<<o|s>>>32-o)+t}function C(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){!function(Zf){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 k(e){return e*i}function M(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 S(e,t,i){return Math.min(i,Math.max(t,e))}function h(e,t,i){return(i=S((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 A(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 E(e){return Array.isArray(e)?e.map(E):"object"==typeof e&&e?T(e,E):e}const C={};function $(e){C[e]||("undefined"!=typeof console&&console.warn(e),C[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 z(){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 V="2.9.1";let j,G,Y,Z;const q={now:()=>void 0!==Y?Y:p.performance.now(),setNow(e){Y=e},restoreNow(){Y=void 0},frame(e){const t=p.requestAnimationFrame(e);return{cancel:()=>p.cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:r}=e;Z||(Z=p.document.createElement("canvas"));const n=Z.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return(i>Z.width||r>Z.height)&&(Z.width=i,Z.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=>(j||(j=p.document.createElement("a")),j.href=e,j.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!=Zf.env.API_URL_REGEX?new RegExp(Zf.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){$("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){$("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:V,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=ke(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=Ae(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 Ae(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}function Ee(e){const t=e.indexOf("?");if(t<0)return e;const i=Ae(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 Me=1/0;const Se={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Se);class Ce 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=z()?()=>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&&$(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 Ce(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(Ee(i.url),t)).catch(e=>$(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=Ee(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(z()&&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 Ce(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(e,t)},ze=function(e,t){return Be(b(e,{type:"arrayBuffer"}),t)},ke=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=ze(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 Ve{constructor(e,t={}){b(this,t),this.type=e}}class je extends Ve{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 Ve(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 je&&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 Ye=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 Ze(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function qe(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function $e(e){if(Array.isArray(e))return e.map($e);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=$e(e[i]);return t}return qe(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 At(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=At(r);if(e){if(e===t)continue;e=nt;break}e=t}return lt(e||nt,i)}return rt}function Et(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 Mt{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=At(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 Mt(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 St=Mt,Ct=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,At(i)))return i;if(e===this.args.length-1)throw new Ct(`Expected value to be of type ${ct(this.type)}, but found ${ct(At(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 zt=Bt;class kt{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 kt(n)}evaluate(i){return new vt(this.sections.map(e=>{const t=e.content.evaluate(i);return At(t)===at?new xt("",t,null,null,null):new xt(Et(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 Ct(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 Ct(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?vt.fromString(Et(this.args[0].evaluate(i))):"resolvedImage"===this.type.kind?bt.fromString(Et(this.args[0].evaluate(i))):Et(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 kt([{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 Vt{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 Vt(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 jt=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 Yt(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Zt(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*jt),Math.round(r*n*jt)]}function qt(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 $t(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(qt(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($t(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(!$t(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=Zt(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)*jt,o=[r.x*jt,r.y*jt],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)*jt,o=[r.x*jt,r.y*jt],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(!Yt(i,r))return!1;for(const e of s)if(!$t(e,o))return!1}if("MultiPolygon"===t.type){const a=ei(t.coordinates,r,n),l=ii(e.geometry(),i,r,n);if(!Yt(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(!Yt(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(!Yt(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 zt(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 St)&&"resolvedImage"!==e.type.kind&&di(e)){const t=new Ft;try{e=new St(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 Vt)return!1;if(e instanceof oi)return!1;const t=e instanceof Rt||e instanceof zt;let i=!0;return e.eachChild(e=>{i=t?i&&di(e):i&&e instanceof St}),!!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 Ct("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,Ai=Math.PI/180,Ei=180/Math.PI;function Mi(e){return e>.008856451679035631?Math.pow(e,1/3):e/Ti+bi}function Si(e){return e>wi?e*e*e:Ti*(e-bi)}function Ci(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=Mi((.4124564*t+.3575761*i+.1804375*r)/xi),o=Mi((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-Mi((.0193339*t+.119192*i+.9503041*r)/vi)),alpha:e.a}}function zi(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*Si(t),i=xi*Si(i),r=vi*Si(r),new gt(Ci(3.2404542*i-1.5371385*t-.4985314*r),Ci(-.969266*i+1.8760108*t+.041556*r),Ci(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function ki(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:zi,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)*Ei;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*Ai,i=e.c;return zi({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:ki(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 Vi{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 Vi(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 ji=Vi;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 Ct(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new Ct(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ct(`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 Yi=Gi;class Zi{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 Zi(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 Ct(`Expected first argument to be of type boolean, string, number or null, but found ${ct(At(t))} instead.`);if(!dt(i,["string","array"]))throw new Ct(`Expected second argument to be of type array or string, but found ${ct(At(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 qi=Zi;class $i{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 $i(i,r,n):null}return new $i(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!dt(t,["boolean","string","number","null"]))throw new Ct(`Expected first argument to be of type boolean, string, number or null, but found ${ct(At(t))} instead.`);if(!dt(i,["string","array"]))throw new Ct(`Expected second argument to be of type array or string, but found ${ct(At(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=$i;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,At(i)))return null}else n=At(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(At(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 Ct(`Expected first argument to be of type array or string, but found ${ct(At(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 zt(n.type,[r]):"value"!==r.type.kind&&"value"===n.type.kind&&(n=new zt(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=At(t),o=At(i);if(n.kind!==o.kind||"string"!==n.kind&&"number"!==n.kind)throw new Ct(`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=At(t),o=At(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 Ct(`Expected value to be of type string or array, but found ${ct(At(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:zt,at:Yi,boolean:zt,case:Ji,coalesce:Ui,collator:Vt,format:kt,image:Pt,in:qi,"index-of":Wi,interpolate:Fi,"interpolate-hcl":Fi,"interpolate-lab":Fi,length:ur,let:ji,literal:St,match:Hi,number:zt,"number-format":hr,object:zt,slice:er,step:_i,string:zt,"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 Ct(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 Ct(t.evaluate(e))}],typeof:[et,[nt],(e,[t])=>ct(At(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=>Et(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 Ar(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Er(e){return e}function Mr(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=Ze({},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=Cr,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=zr}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,Mr(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?Sr(r.default,n.default):a(r,n,i,l,c)}}}function Sr(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Cr(e,t,i,r,n){return Sr(typeof i===n?r[i]:void 0,e.default,t.default)}function Ir(e,t,i){if("number"!==Tr(i))return Sr(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 Sr(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]||Er;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 zr(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),Sr(i,e.default,t.default)}class kr{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Ft,this._defaultValue=t?function(e){return"color"===e.type&&(Ar(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 Ct(`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 kr(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,Ze(this,Mr(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 ji)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 Vr(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 jr(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 Yr(e){const o=e.valueSpec,s=qe(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=Vr({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(jr({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=qe(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(Vr({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($e(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=qe(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 Zr(t){const e=("property"===t.expressionContext?Or:Lr)($e(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 qr(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 qr(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(...qr(e,t))}),r)}function $r(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(qe(i))&&n.push(new Ur(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(qe(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=$e(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=Ye[`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($e(e.value))?Zr(Ze({},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($r({key:`${r}[0]`,value:i[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),qe(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===qe(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"===qe(i[1])?s=s.concat($r({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&&Ar($e(o))&&"identity"===qe(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=qe(r.type);const l=qe(r.ref);if(r.id){const s=qe(r.id);for(let e=0;e<t.arrayIndex;e++){const t=o.layers[e];qe(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=>{qe(e.id)===l&&(t=e)}),t?t.ref?i.push(new Ur(n,r.ref,"ref cannot reference another ref layer")):a=qe(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&&qe(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(Vr({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(Ze({layerType:a},e)),layout:e=>Vr({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>pn(Ze({layerType:a},e))}}),paint:e=>Vr({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>un(Ze({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=qe(t.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=Vr({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:mn}),s;case"geojson":if(s=Vr({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(...Zr({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),s.push(...Zr({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return Vr({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Vr({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 $r({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&&qe(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:jr,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:$r,filter:ln,function:Yr,layer:dn,object:Vr,source:_n,light:gn,terrain:yn,fog:xn,string:fn,formatted:function(e){return 0===fn(e).length?[]:Zr(e)},resolvedImage:function(e){return 0===fn(e).length?[]:Zr(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&&Ar(qe(t))?Yr(e):i.expression&&Pr($e(t))?Zr(e):i.type&&vn[i.type]?vn[i.type](e):Vr(Ze({},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=Ye){return Mn(bn({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:wn,"*":()=>[]}}))}const An=e=>Mn(un(e)),En=e=>Mn(pn(e));function Mn(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Sn(e,t){let i=!1;if(t&&t.length)for(const r of t)e.fire(new je(new Error(r.message))),i=!0;return i}var Cn=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 zn(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Bn[t]={klass:e,omit:i.omit||[]}}zn(Object,"Object"),Cn.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}},Cn.deserialize=function(e){return new Cn(e.buffer)},Object.defineProperty(Cn,"name",{value:"Grid"}),zn(Cn,"Grid"),zn(gt,"Color"),zn(Error,"Error"),zn(Ce,"AJAXError"),zn(bt,"ResolvedImage"),zn(Fr,"StylePropertyFunction"),zn(kr,"StyleExpression",{omit:["_evaluator"]}),zn(Rr,"ZoomDependentExpression"),zn(Dr,"ZoomConstantExpression"),zn(Ut,"CompoundExpression",{omit:["_evaluate"]});for(const l in gr)Bn[gr[l]._classRegistryKey]||zn(gr[l],`Expression${l}`);function kn(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(kn(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||kn(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,Vn=e=>e>=12032&&e<=12255,jn=e=>e>=12272&&e<=12287,Gn=e=>e>=12288&&e<=12351,Yn=e=>e>=12352&&e<=12447,Zn=e=>e>=12448&&e<=12543,qn=e=>e>=12544&&e<=12591,$n=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||!($n(e)||qn(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)||Yn(e)||jn(e)||(e=>e>=12688&&e<=12703)(e)||Vn(e)||Xn(e)||Zn(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)||Zn(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",Ao=null;const Eo=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(To="error"),wo&&wo(e)};function Mo(){So.fire(new Ve("pluginStateChange",{pluginStatus:To,pluginURL:Ao}))}const So=new Ge,Co=function(){return To},Io=function(){if(To!==xo||!Ao)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");To=vo,Mo(),Ao&&ze({url:Ao},e=>{e?Eo(e):(To=bo,Mo())})},Bo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>To===bo||null!=Bo.applyArabicShaping,isLoading:()=>To===vo,setState(e){To=e.pluginStatus,Ao=e.pluginURL},isParsed:()=>null!=Bo.applyArabicShaping&&null!=Bo.processBidirectionalText&&null!=Bo.processStyledBidirectionalText,getPluginURL:()=>Ao};class zo{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 ko{constructor(e,t){this.property=e,this.value=t,this.expression=function(t,i){if(Ar(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 ko(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 E(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 ko(this._values[e].property,null===t?void 0:E(t))}getTransition(e){return E(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Po(this._values[e].property)),this._values[e].transition=E(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 E(this._values[e].value)}setValue(e,t){this._values[e]=new ko(this._values[e].property,null===t?void 0:E(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 Vo{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 jo extends Vo{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 zo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new zo(Math.floor(t.zoom),t)),e.expression.evaluate(new zo(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 Yo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class Zo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new zo(0,{});for(const i in e){const r=e[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new ko(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new Po(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(t)}}}function qo(e,t){return 256*(e=S(Math.floor(e),0,255))+S(Math.floor(t),0,255)}zn(Vo,"DataDrivenProperty"),zn(Uo,"DataConstantProperty"),zn(jo,"CrossFadedDataDrivenProperty"),zn(Go,"CrossFadedProperty"),zn(Yo,"ColorRampProperty");const $o={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=$o[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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,A=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[A+48]=_,this.uint8[A+49]=g,this.uint8[A+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[A+58]=b,e}}ms.prototype.bytesPerElement=60,zn(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,A,E,M,S,C,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,A,E,M,S,C,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,A,E,M,S,C,I,B){const z=38*e,k=19*e;return this.int16[z+0]=t,this.int16[z+1]=i,this.int16[z+2]=r,this.float32[k+2]=n,this.float32[k+3]=o,this.int16[z+8]=s,this.int16[z+9]=a,this.int16[z+10]=l,this.int16[z+11]=c,this.int16[z+12]=h,this.int16[z+13]=u,this.uint16[z+14]=p,this.uint16[z+15]=d,this.uint16[z+16]=f,this.uint16[z+17]=m,this.uint16[z+18]=_,this.uint16[z+19]=g,this.uint16[z+20]=y,this.uint16[z+21]=x,this.uint16[z+22]=v,this.uint16[z+23]=b,this.uint16[z+24]=w,this.uint16[z+25]=T,this.uint16[z+26]=A,this.uint16[z+27]=E,this.uint16[z+28]=M,this.uint32[k+15]=S,this.float32[k+16]=C,this.float32[k+17]=I,this.float32[k+18]=B,e}}_s.prototype.bytesPerElement=76,zn(_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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(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,zn(Ts,"StructArrayLayout2f8");class As 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]}}As.prototype.size=12;class Es extends os{get(e){return new As(this,e)}}zn(Es,"FillExtrusionExtArray");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.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]}}Ms.prototype.size=40;class Ss extends cs{get(e){return new Ms(this,e)}}zn(Ss,"CollisionBoxArray");class Cs 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}}Cs.prototype.size=60;class Is extends ms{get(e){return new Cs(this,e)}}zn(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 zs extends _s{get(e){return new Bs(this,e)}}zn(zs,"SymbolInstanceArray");class ks extends gs{getoffsetX(e){return this.float32[1*e+0]}}zn(ks,"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]}}zn(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)}}zn(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)}}zn(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)}}zn(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"}]),Vs=Ho([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var js=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}}),Ys=js,Zs=Gs;Ys.murmur3=js,Ys.murmur2=Zs;class qs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push($s(e)),this.positions.push(t,i,r)}getPositions(e){const t=$s(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 qs;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function $s(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Ys(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}zn(qs,"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[qo(255*e.r,255*e.g),qo(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 zo(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 zo(this.zoom),t,{},n,r,o),a=this.expression.evaluate(new zo(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=S(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?Vs: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 qs,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]}zn(na,"ConstantBinder"),zn(oa,"CrossFadedConstantBinder"),zn(sa,"SourceExpressionBinder"),zn(la,"CrossFadedCompositeBinder"),zn(aa,"CompositeExpressionBinder"),zn(ca,"ProgramConfiguration",{omit:["_buffers"]}),zn(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(En,`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(An,`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),A(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)&&Sn(this,e.call(Tn,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:Ye,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&&$(`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,zn(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 Aa?new Aa(e.lng,e.lat):Aa.convert(e),this}setSouthWest(e){return this._sw=e instanceof Aa?new Aa(e.lng,e.lat):Aa.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof Aa)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(Aa.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 Aa(r.lng,r.lat),this._ne=new Aa(n.lng,n.lat)),this}getCenter(){return new Aa((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 Aa(this.getWest(),this.getNorth())}getSouthEast(){return new Aa(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}=Aa.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 Aa{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 Aa(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 Aa(this.lng-i,this.lat-t),new Aa(this.lng+i,this.lat+t))}static convert(e){if(e instanceof Aa)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Aa(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Aa(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 Ea=2*Math.PI*Ta;function Ma(e){return Ea*Math.cos(e*Math.PI/180)}function Sa(e){return(180+e)/360}function Ca(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ia(e,t){return e/Ma(t)}function Ba(e){return 360*e-180}function za(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ka(e,t){return e*Ma(za(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=Aa.convert(e);return new La(Sa(i.lng),Ca(i.lat),Ia(t,i.lat))}toLngLat(){return new Aa(Ba(this.x),za(this.y))}toAltitude(){return ka(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ea*(e=za(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 Va(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=S(i,Ua,Na),e.y=S(r,Ua,Na),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&$("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function ja(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=za((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)Va(n,s);return r}function Ga(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?ja(e):[]}}function Ya(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}function Za(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class qa{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 zo(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:ja(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;Za(l,e,t),Za(l,e,t),Za(l,e,t),Za(l,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;Ya(this.layoutVertexArray,i,r,-1,-1),Ya(this.layoutVertexArray,i,r,1,-1),Ya(this.layoutVertexArray,i,r,1,1),Ya(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 $a(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}zn(qa,"CircleBucket",{omit:["layers"]});const cl=new Zo({"circle-sort-key":new Vo(Ye.layout_circle["circle-sort-key"])});var hl={paint:new Zo({"circle-radius":new Vo(Ye.paint_circle["circle-radius"]),"circle-color":new Vo(Ye.paint_circle["circle-color"]),"circle-blur":new Vo(Ye.paint_circle["circle-blur"]),"circle-opacity":new Vo(Ye.paint_circle["circle-opacity"]),"circle-translate":new Uo(Ye.paint_circle["circle-translate"]),"circle-translate-anchor":new Uo(Ye.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Uo(Ye.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Uo(Ye.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Vo(Ye.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Vo(Ye.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Vo(Ye.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 Al(e){return Math.hypot(e[0],e[1],e[2])}function El(e,t,i){var r=new pl(3);return r[0]=e,r[1]=t,r[2]=i,r}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 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 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 zl(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function kl(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=Sl,Ul=Cl,Vl=Al;function jl(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 Yl(){var e=new pl(4);return pl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Zl(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ql(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 $l(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(),El(1,0,0),El(0,1,0),Yl(),Yl(),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=zl([],Ml([],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=za((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=El(0,0,0),tc=El(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 qa{}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}zn(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)}}zn(ac,"AlphaImage"),zn(lc,"RGBAImage");var cc={paint:new Zo({"heatmap-radius":new Vo(Ye.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Vo(Ye.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Uo(Ye.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Yo(Ye.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Uo(Ye.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 Zo({"hillshade-illumination-direction":new Uo(Ye.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Uo(Ye.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Uo(Ye.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Uo(Ye.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Uo(Ye.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Uo(Ye.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(Cc(s));for(a.sort(Ac),n=0;n<a.length;n++)i=yc(i=Ec(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===Vc(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&&kc(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||!kc(r,r.next)&&0!==zc(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=Sc(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(zc(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)&&zc(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(zc(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=Sc(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=Sc(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)&&zc(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)&&zc(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)&&zc(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)&&zc(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;!kc(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 Ac(e,t){return e.x-t.x}function Ec(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&&Mc(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 Mc(e,t){return zc(e.prev,e,t.prev)<0&&zc(t.next,e,e.next)<0}function Sc(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 Cc(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)&&(zc(e.prev,e,t.prev)||zc(e,t.prev,t))||kc(e,t)&&zc(e.prev,e,e.next)>0&&zc(t.prev,t,t.next)>0)}function zc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function kc(e,t){return e.x===t.x&&e.y===t.y}function Pc(e,t,i,r){var n=Dc(zc(e,t,i)),o=Dc(zc(e,t,r)),s=Dc(zc(i,r,e)),a=Dc(zc(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 zc(e.prev,e,e.next)<0?zc(e,t,e.next)>=0&&zc(e,e.prev,t)>=0:zc(e,t,e.prev)<0||zc(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 Vc(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 jc(e,t,i,r,n){Gc(e,t,i||0,r||e.length-1,n||Zc)}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(Yc(e,i,t),n(e[r],h)>0&&Yc(e,i,r);u<p;){for(Yc(e,u,p),u++,p--;n(e[u],h)<0;)u++;for(;n(e[p],h)>0;)p--}0===n(e[i],h)?Yc(e,i,p):Yc(e,++p,r),p<=t&&(i=p+1),t<=p&&(r=p-1)}}function Yc(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function Zc(e,t){return e<t?-1:e>t?1:0}function qc(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||(jc(n[e],i,1,n[e].length-1,$c),n[e]=n[e].slice(0,i));return n}function $c(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(Vc(e,0,n?t[0]*i:e.length,i));if(n)for(var s=0,a=t.length;s<a;s++)o-=Math.abs(Vc(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 zo(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:ja(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 qc(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)}}zn(Hc,"FillBucket",{omit:["layers","patternFeatures"]});const Kc=new Zo({"fill-sort-key":new Vo(Ye.layout_fill["fill-sort-key"])});var Jc={paint:new Zo({"fill-antialias":new Uo(Ye.paint_fill["fill-antialias"]),"fill-opacity":new Vo(Ye.paint_fill["fill-opacity"]),"fill-color":new Vo(Ye.paint_fill["fill-color"]),"fill-outline-color":new Vo(Ye.paint_fill["fill-outline-color"]),"fill-translate":new Uo(Ye.paint_fill["fill-translate"]),"fill-translate-anchor":new Uo(Ye.paint_fill["fill-translate-anchor"]),"fill-pattern":new jo(Ye.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 zo(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:ja(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 Es);const m=qc(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=za(r.y/n),a=za((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=za((r.y+t/ba)/n);return(Ca(.5*(za((r.y+i/ba)/n)+e))*n-r.y)*ba}})}zn(yh,"FillExtrusionBucket",{omit:["layers","features"]}),zn(gh,"PartMetadata");var wh={paint:new Zo({"fill-extrusion-opacity":new Uo(Ye["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Vo(Ye["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Uo(Ye["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Uo(Ye["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new jo(Ye["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Vo(Ye["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Vo(Ye["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Uo(Ye["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 Ah{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Sh(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 Eh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Sh(e,t.z,t.z,t.x,t.y)}}class Mh{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new Ah(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:Sh(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 Mh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Mh(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 Sh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Sh(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 Mh(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 Mh(t,this.wrap,t,i,r),new Mh(t,this.wrap,t,i+1,r),new Mh(t,this.wrap,t,i,r+1),new Mh(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 Mh(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Mh(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 Eh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Sh(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 Ch(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=Ch(a,a),u=Ch(a,l),p=Ch(l,l),d=Ch(c,a),f=Ch(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 zh(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}}zn(Ah,"CanonicalTileID"),zn(Mh,"OverscaledTileID",{omit:["projMatrix"]});const kh=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}=kh,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 zo(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:ja(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&&_,A=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 E=m&&_;let t=E?o:c?"butt":s;if(E&&"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*(A?-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=A?r:0,o=A?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(A?-1:1);this.addHalfVertex(f,s.x,s.y,!1,A,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()}}zn(Fh,"LineBucket",{omit:["layers","patternFeatures"]});const Nh=new Zo({"line-cap":new Vo(Ye.layout_line["line-cap"]),"line-join":new Vo(Ye.layout_line["line-join"]),"line-miter-limit":new Uo(Ye.layout_line["line-miter-limit"]),"line-round-limit":new Uo(Ye.layout_line["line-round-limit"]),"line-sort-key":new Vo(Ye.layout_line["line-sort-key"])});var Uh={paint:new Zo({"line-opacity":new Vo(Ye.paint_line["line-opacity"]),"line-color":new Vo(Ye.paint_line["line-color"]),"line-translate":new Uo(Ye.paint_line["line-translate"]),"line-translate-anchor":new Uo(Ye.paint_line["line-translate-anchor"]),"line-width":new Vo(Ye.paint_line["line-width"]),"line-gap-width":new Vo(Ye.paint_line["line-gap-width"]),"line-offset":new Vo(Ye.paint_line["line-offset"]),"line-blur":new Vo(Ye.paint_line["line-blur"]),"line-dasharray":new jo(Ye.paint_line["line-dasharray"]),"line-pattern":new jo(Ye.paint_line["line-pattern"]),"line-gradient":new Yo(Ye.paint_line["line-gradient"]),"line-trim-offset":new Uo(Ye.paint_line["line-trim-offset"])}),layout:Nh};const Vh=new class extends Vo{possiblyEvaluate(e,t){return t=new zo(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 jh(e,t){return t>0?t+2*e:e}Vh.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),Yh=Ho([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Zh=Ho([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ho([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const qh=Ho([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),$h=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 zo(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 zo(s)),maxSize:n.evaluate(new zo(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?S(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 Au(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Eu(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Mu(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Su(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Cu(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 zu(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=Eu(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Su(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Eu(this.buf,this.pos)+Eu(this.buf,this.pos+4)*hu;return this.pos+=8,e},readSFixed64:function(){var e=Eu(this.buf,this.pos)+Su(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),Mu(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Mu(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Mu(this.buf,-1&e,this.pos),Mu(this.buf,Math.floor(e*uu),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Mu(this.buf,-1&e,this.pos),Mu(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,Au,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 ku{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}=zu(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 ku(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})}}zn(ku,"ImagePosition"),zn(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 $("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)):$("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(),Zu(_,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,Zu(_,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}(_,Zu(_,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,A=0;const E="right"===g?1:"left"===g?0:.5;let M=!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&&(M=void 0!==p.ascender&&void 0!==p.descender,!M))break}if(!M)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 C=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),A=_.getSectionIndex(s),E=_.getCharCode(s);let e=g.scale,t=null,i=null,r=null,n=Hh,o=0;const I=!(y===Lu.horizontal||!v&&!fo(E)||v&&(Fu[E]||(S=E,On(S)||Fn(S)||Nn(S)||no(S)||lo(S))));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=M?-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[E]&&(i=h[E]);const d=u[g.fontStack];if(!d)continue;const m=d.glyphs[E];if(!m)continue;if(t=m.metrics,n=8203!==E?Hh:0,M){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,C.push({glyph:E,imageName:r,x:w,y:T+o,vertical:I,scale:e,localGlyph:t.localGlyph,fontStack:g.fontStack,sectionIndex:A,metrics:t,rect:i}),w+=n*e+x):(C.push({glyph:E,imageName:r,x:w,y:T+o,vertical:I,scale:e,localGlyph:t.localGlyph,fontStack:g.fontStack,sectionIndex:A,metrics:t,rect:i}),w+=t.advance*e+x)}0!==C.length&&(A=Math.max(w-x,A),M?$u(C,E,a,c,m*f/2):$u(C,E,a,0,m/2)),w=0;const r=m*f+a;t.lineOffset=Math.max(a,g),T+=r,++e}var S;const t=T,{horizontalAlign:C,verticalAlign:i}=qu(_);(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,E,C,i,A,t),h.top+=-i*t,h.bottom=h.top+t,h.left+=-C*A,h.right=h.left+A,h.hasBaseline=M}(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 Vu(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 ju(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=Vu(t,i,n,o);for(const e of r){const r=Vu(t-e.x,i,n,o)+e.badness;r<=a&&(s=e,a=r)}return{index:e,x:t,priorBreak:s,badness:a}}function Yu(e){return e?Yu(e.priorBreak).concat(e.index):[]}function Zu(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||!($n(u)||qn(u)||so(u)||ro(u)||Kn(u)||Un(u)||Wn(u)||Gn(u)||Jn(u)||Qn(u)||Hn(u)||co(u)||Yn(u)||jn(u)||Vn(u)||Xn(u)||Zn(u)||oo(u)||to(u)||eo(u)));(Nu[p]||i||o.imageName)&&a.push(Gu(e+1,h,l,a,ju(p,t.getCharCode(e+1),i&&c),!1))}}var u;return Yu(Gu(t.length(),h,l,a,0,!0))}function qu(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 $u(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}=qu(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}zn(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)||Yn(e)||Zn(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=[],A=b.image,E=A.pixelRatio,e=A.paddedRect.w-2,r=A.paddedRect.h-2,M=b.right-b.left,S=b.bottom-b.top,n=A.stretchX||[[0,e]],o=A.stretchY||[[0,r]],s=(e,t)=>e+t[1]-t[0],C=n.reduce(s,0),I=o.reduce(s,0),a=e-C,l=r-I;let B=0,z=C,k=0,P=I,L=0,D=a,R=0,O=l;if(A.content&&t){const b=A.content;B=up(n,0,b[0]),k=up(o,0,b[1]),z=up(n,b[0],b[2]),P=up(o,b[1],b[3]),L=b[0]-B,R=b[1]-k,D=b[2]-b[0]-z,O=b[3]-b[1]-P}const c=(e,t,i,r)=>{const n=dp(e.stretch-B,z,M,b.left),o=fp(e.fixed-L,D,e.stretch,C),s=dp(t.stretch-k,P,S,b.top),a=fp(t.fixed-R,O,t.stretch,I),l=dp(i.stretch-B,z,M,b.left),c=fp(i.fixed-L,D,i.stretch,C),h=dp(r.stretch-k,P,S,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/E,a/E),g=new F(c/E,u/E),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:A.paddedRect.x+1+x,y:A.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/E/M,minFontScaleY:O/E/S,isSDF:T}};if(t&&(A.stretchX||A.stretchY)){const b=pp(n,a,C),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}`),Se.Glyphs);ze(a,(e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new lu(e).readFields(Cu,{})}(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 Ap(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 zo(n),h),f["text-size"].possiblyEvaluate(new zo(o),h)]}if("composite"===r.iconSizeData.kind){const{minZoom:n,maxZoom:o}=r.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new zo(n),h),f["icon-size"].possiblyEvaluate(new zo(o),h)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new zo(u+1),h),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new zo(u+1),h),m.textMaxSize=f["text-size"].possiblyEvaluate(new zo(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"),A="point"===T,E="point"===T?d.get("text-max-width").evaluate(l,{},h)*Hh:0,M=e=>{r.allowVerticalPlacement&&ho(s)&&(x.vertical=Ou(v,n,o,a,u,E,p,g,e,m,i,Lu.vertical,!0,T,y,f))};if(!_&&w){const r="auto"===e?w.map(e=>Ep(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,E,p,"center",c,m,i,Lu.horizontal,!1,T,y,f);r&&(x.horizontal[c]=r,t=1===r.positionedLines.length)}}M("left")}else{if("auto"===e&&(e=Ep(g)),A||d.get("text-writing-mode").indexOf("horizontal")>=0||!ho(s)){const r=Ou(v,n,o,a,u,E,p,g,e,m,i,Lu.horizontal,!1,T,y,f);r&&(x.horizontal[e]=r)}M("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&&$("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)&&Mp(r,l,x,e,s,m,y,0,i,t,c,h,p)}l&&r.generateCollisionDebugBuffers(u,r.collisionBoxArray)}function Ep(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 Mp(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=(C=n.overscaling,n.zoom>18&&C>2&&(C>>=1),Math.max(ba/(512*C),1)*r.get("symbol-spacing")),b=r.get("text-padding")*n.tilePixelRatio,w=r.get("icon-padding")*n.tilePixelRatio,T=k(r.get("text-max-angle")),A="map"===r.get("text-rotation-alignment")&&"point"!==r.get("symbol-placement"),E="map"===r.get("icon-rotation-alignment")&&"point"!==r.get("symbol-placement"),M=r.get("symbol-placement"),S=v/2;var C;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 z=(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,A){const E=t.addToLineVertexArray(i,n);let M,S,C,I,B,z,k,P=0,L=0,D=0,R=0,O=-1,F=-1;const N={};let U=Ys("");const V=r?r.anchor:i;let j=0,G=0;if(void 0===c._unevaluatedLayout.getValue("text-radial-offset")?[j,G]=c.layout.get("text-offset").evaluate(v,{},A).map(e=>e*Hh):(j=c.layout.get("text-radial-offset").evaluate(v,{},A)*Hh,G=bp),t.allowVerticalPlacement&&o.vertical){const t=o.vertical;if(m)z=zp(t),l&&(k=zp(l));else{const r=c.layout.get("text-rotate").evaluate(v,{},A)+90;C=Bp(h,V,i,u,p,d,t,f,r,e),l&&(I=Bp(h,V,i,u,p,d,l,g,r))}}if(s){const n=c.layout.get("icon-rotate").evaluate(v,{},A),o="none"!==c.layout.get("icon-text-fit"),a=hp(s,n,w,o),f=l?hp(l,n,w,o):void 0;S=Bp(h,V,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,{},A)],e[0]>Sp&&$(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===m.kind&&(e=[Kh*b.compositeIconSizes[0].evaluate(v,{},A),Kh*b.compositeIconSizes[1].evaluate(v,{},A)],(e[0]>Sp||e[1]>Sp)&&$(`${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,E.lineStartIndex,E.lineLength,-1,T,A),O=t.icon.placedSymbolArray.length-1,f&&(L=4*f.length,t.addSymbols(t.icon,f,e,x,y,v,Lu.vertical,r,i,E.lineStartIndex,E.lineLength,-1,T,A),F=t.icon.placedSymbolArray.length-1)}for(const n in o.horizontal){const s=o.horizontal[n];M||(U=Ys(s.text),m?B=zp(s):M=Bp(h,V,i,u,p,d,s,f,c.layout.get("text-rotate").evaluate(v,{},A),e));const l=1===s.positionedLines.length;if(D+=Cp(t,r,i,s,a,c,m,v,e,E,o.vertical?Lu.horizontal:Lu.horizontalOnly,l?Object.keys(o.horizontal):[n],N,O,b,T,A),l)break}o.vertical&&(R+=Cp(t,r,i,o.vertical,a,c,m,v,e,E,Lu.vertical,["vertical"],N,F,b,T,A));let Y=-1;const Z=(e,t)=>e?Math.max(e,t):t;Y=Z(B,Y),Y=Z(z,Y),Y=Z(k,Y);const q=Y>-1?1:0;t.glyphOffsetArray.length>=Fd.MAX_GLYPHS&&$("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(V.x,V.y,V.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!==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,void 0!==S?S:t.collisionBoxArray.length,void 0!==S?S+1:t.collisionBoxArray.length,I||t.collisionBoxArray.length,I?I+1:t.collisionBoxArray.length,u,D,R,P,L,q,0,j,G,Y)}(n,t,r,e,s,a,l,B,n.layers[0],n.collisionBoxArray,o.index,o.sourceLayerIndex,n.index,b,A,h,0,w,E,m,o,c,u,p,d)};if("line"===M)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&&kp(n,o.text,S,s)||z(l,s,d)}}else if("line-center"===M){for(const n of o.geometry)if(n.length>1){const o=tp(n,T,s.vertical||_,a,24,x);o&&z(n,o,d)}}else if("Polygon"===o.type)for(const n of qc(o.geometry,0)){const o=yp(n,16);z(n[0],new Hu(o.x,o.y,0,0,void 0),d)}else if("LineString"===o.type)for(const n of o.geometry)z(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)z([o],new Hu(o.x,o.y,0,0,void 0),d)}const Sp=32640;function Cp(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){$("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,A=u.metrics,E=u.rect;if(null===E)continue;g&&p.verticalizable&&(r=u.imageName?T-u.metrics.width*u.scale/2:0);const M=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 S=E.w*u.scale/(i*(u.localGlyph?2:1)),C=E.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-=(A.left-e)*u.scale;const _=u.imageName?A.advance*u.scale:Hh*u.scale,g=String.fromCharCode(u.glyph);nu(g)?a.x+=(1-e)*u.scale:ou(g)?a.x+=_-A.height*u.scale+(-e-1)*u.scale:a.x+=u.imageName||A.width+2*e===E.w&&A.height+2*e===E.h?(_-C)/2:(_-(A.height+2*e)*u.scale)/2,l=new F(a.x,a.y-S),c=new F(a.x+C,a.y),h=new F(a.x+C,a.y-S)}else{const p=(A.left-e)*u.scale-T+n[0],d=(-A.top-e)*u.scale+n[1],f=p+S,m=d+C;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:M,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]>Sp&&$(`${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]>Sp||x[1]>Sp)&&$(`${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=k(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 zp(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 kp(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,Vp=Op,jp=[new Kl([Up,Up,Up],[Vp,Vp,Vp]),new Kl([Up,Up,Up],[0,0,Vp]),new Kl([0,Up,Up],[Vp,0,Vp]),new Kl([Up,0,Up],[0,Vp,Vp]),new Kl([0,0,Up],[Vp,Vp,Vp])];function Gp(e,t,i,r=!0){const n=zl([],e._camera.position,e.worldSize),o=[t,i,1,1];Gl(o,o,e.pixelMatrixInverse),jl(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=Al(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=[];zl(e,s,h/d),Pl(t,Nl(t,e,c)),Pl(s,Ml(s,c,zl(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=M(Math.asin(-v/p));let T=M(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 A=Sa(T),E=S(Ca(w),0,1);return new La(A,E)}class Yp{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 Zp(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,S(i,0,1))+e.center[t]}function qp(e){if(e.z<=1)return jp[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=[Vp,Vp,Vp],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 $p(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=qp(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=S(t.center.lat,-85.051129,Pa),m=[Sa(d),Ca(f)],_=h.getCenter().lng,g=S(h.getCenter().lat,-85.051129,Pa),y=[Sa(_),Ca(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(k(h.getSouth()))*Op:-Math.sin(k(h.getNorth()))*Op,x=kl(x,p,t,e)}const T=u[v],A=u[(v+1)%4],E=new Yp(T,A,x),M=[Zp(E,0)||T[0],Zp(E,1)||T[1],Zp(E,2)||T[2]];return s[2]=Math.min(T[2],A[2]),Il(s,s,M),Bl(o,o,M),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[[za(e.y/t),Ba(i)],[za(n),Ba(r)]]}function Xp(e,t,i,r=Op){return i=k(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function Hp(e,t,i){return Xp(Math.cos(k(e)),Math.sin(k(e)),t,i)}function Kp(e,t,i){const r=Math.pow(2,i.z),n=(e/ba+i.x)/r;return Hp(za((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,k(-n)),xl(a,a,k(-r)),a}function id(e){return h(5,6,e)}function rd(e,t){const i=Hp(t.lat,t.lng);return o=(r=Sl([],function(e){const t=Hp(e._center.lat,e._center.lng);let i=Dl([],El(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 zl(n,n,e.cameraToCenterDistance/e.pixelsPerMeter*Fp),Rl(n,n,r),Ml([],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=k(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=za(n),c=za(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),za(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 Aa(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(k(t));this.n=(r+Math.sin(k(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=k(e-this.center[0]),s=k(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=k(this.center[0])*i;s=d(s,-Math.PI-a,Math.PI-a);const l=M(s/i)+this.center[0],c=Math.asin(S((r-(e*e+o*o)*i*i)/(2*i),-1,1)),h=S(M(c),-85.051129,Pa);return new Aa(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=S(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=S(180*t/Math.PI,-180,180),l=S(180*i/Math.PI,-85.051129,Pa);return new Aa(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=S(360*(.5-t),-85.051129,Pa);return new Aa(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=k(t),n=k(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=k(t),e=k(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=S(M(a/i)+this.center[0],-180,180),c=S(M(2*Math.atan(Math.pow(r/s,1/i))-xd),-85.051129,Pa);return new Aa(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:Sa(e),y:Ca(t),z:0}}unproject(e,t){const i=Ba(e),r=za(t);return new Aa(i,r)}}const Td=k(Pa);class Ad extends hd{project(e,t){const i=(t=k(t))*t,r=i*i;return{x:.5*((e=k(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=S(i-n,-Td,Td)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=S(M(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=M(i);return new Aa(s,a)}}const Ed=k(Pa);class Md extends hd{project(e,t){t=k(t),e=k(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,M=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*M)+1/Math.PI,v=m*(p*l/4-_*o*u),b=.125*m*(l*u-_*o*c*p),w=.5*m*(M*h+_*d*n)+.5,T=v*b-w*x;s=(y*v-g*w)/T,a=(g*b-y*x)/T,i=S(i-s,-Math.PI,Math.PI),r=S(r-a,-Ed,Ed)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new Aa(M(i),M(r))}}class Sd 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(k(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:k(e)*r*i+.5,y:-Math.sin(k(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=S(M((e-.5)/i)/r,-180,180),s=Math.asin(S(n*r,-1,1)),a=S(M(s),-85.051129,Pa);return new Aa(o,a)}}class Cd 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(za((t/ba+i.y)/r),Ba(n));return Rl(o,o,Qp(qp(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;kl(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(qp(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(qp(t))),xl(r,r,k(i.lng)),yl(r,r,k(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=Ml([],zl([],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=zl([],n.up(),h),p=zl([],n.right(),h*c),d=Pl([],Ml([],Ml([],o,u),p)),f=[];let m;if(new Wl(s,d).closestPointOnSphere(l,a,f)){const t=Ml([],f,l),i=Nl([],t,s);m=Math.cos(e.fovAboveCenter)*Al(i)}else{const e=Nl([],s,l),t=Nl([],l,s);Pl(t,t);const i=Al(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(za((i/ba+e.y)/r),Ba(n),1)}upVectorScale(e){return{metersToTile:Fp*Jp(qp(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 Ad(e);case"equalEarth":return new gd(e);case"winkelTripel":return new Md(e);case"albers":return i?new Sd(e):new ud(e);case"lambertConformalConic":return i?new Sd(e):new bd(e);case"globe":return new Cd(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Bd=uh.VectorTileFeature.types,zd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function kd(e,t,i,r,n,o,s,a,l,c,h,u,p){const d=a?Math.min(Sp,Math.round(a[0])):0,f=a?Math.min(Sp,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,Zh.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,zd,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Yh.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())}}zn(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,qh.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,$h.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}zn(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 ks,this.lineVertexArray=new Ps,this.symbolInstances=new zs}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 zo(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=ja(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(za((e.y/ba+s)/r),Ba((e.x/ba+o)/r),1),Hp(za((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"===Co()||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:A,isSDF:E,sectionIndex:M}=i[e],S=g.vertexLength,C=A[1];if(kd(m,l.x,l.y,n.x,C+n.y,u.x,u.y,r,E,y.x,y.y,w,T),kd(m,l.x,l.y,s.x,C+s.y,u.x+u.w,u.y,r,E,x.x,y.y,w,T),kd(m,l.x,l.y,c.x,C+c.y,u.x,u.y+u.h,r,E,y.x,x.y,w,T),kd(m,l.x,l.y,h.x,C+h.y,u.x+u.w,u.y+u.h,r,E,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(S,S+1,S+2),f.emplaceBack(S+1,S+2,S+3),g.vertexLength+=4,g.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(A[0]),e!==i.length-1&&M===i[e+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,o,o.index,{},p,d,b&&b[M])}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)}}}zn(Fd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Fd.MAX_GLYPHS=65535,Fd.addDynamicAttributes=Ld;const Nd=new Zo({"symbol-placement":new Uo(Ye.layout_symbol["symbol-placement"]),"symbol-spacing":new Uo(Ye.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Uo(Ye.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Vo(Ye.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Uo(Ye.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Uo(Ye.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Uo(Ye.layout_symbol["icon-ignore-placement"]),"icon-optional":new Uo(Ye.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Uo(Ye.layout_symbol["icon-rotation-alignment"]),"icon-size":new Vo(Ye.layout_symbol["icon-size"]),"icon-text-fit":new Uo(Ye.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Uo(Ye.layout_symbol["icon-text-fit-padding"]),"icon-image":new Vo(Ye.layout_symbol["icon-image"]),"icon-rotate":new Vo(Ye.layout_symbol["icon-rotate"]),"icon-padding":new Uo(Ye.layout_symbol["icon-padding"]),"icon-keep-upright":new Uo(Ye.layout_symbol["icon-keep-upright"]),"icon-offset":new Vo(Ye.layout_symbol["icon-offset"]),"icon-anchor":new Vo(Ye.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Uo(Ye.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Uo(Ye.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Uo(Ye.layout_symbol["text-rotation-alignment"]),"text-field":new Vo(Ye.layout_symbol["text-field"]),"text-font":new Vo(Ye.layout_symbol["text-font"]),"text-size":new Vo(Ye.layout_symbol["text-size"]),"text-max-width":new Vo(Ye.layout_symbol["text-max-width"]),"text-line-height":new Vo(Ye.layout_symbol["text-line-height"]),"text-letter-spacing":new Vo(Ye.layout_symbol["text-letter-spacing"]),"text-justify":new Vo(Ye.layout_symbol["text-justify"]),"text-radial-offset":new Vo(Ye.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Uo(Ye.layout_symbol["text-variable-anchor"]),"text-anchor":new Vo(Ye.layout_symbol["text-anchor"]),"text-max-angle":new Uo(Ye.layout_symbol["text-max-angle"]),"text-writing-mode":new Uo(Ye.layout_symbol["text-writing-mode"]),"text-rotate":new Vo(Ye.layout_symbol["text-rotate"]),"text-padding":new Uo(Ye.layout_symbol["text-padding"]),"text-keep-upright":new Uo(Ye.layout_symbol["text-keep-upright"]),"text-transform":new Vo(Ye.layout_symbol["text-transform"]),"text-offset":new Vo(Ye.layout_symbol["text-offset"]),"text-allow-overlap":new Uo(Ye.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Uo(Ye.layout_symbol["text-ignore-placement"]),"text-optional":new Uo(Ye.layout_symbol["text-optional"])});var Ud={paint:new Zo({"icon-opacity":new Vo(Ye.paint_symbol["icon-opacity"]),"icon-color":new Vo(Ye.paint_symbol["icon-color"]),"icon-halo-color":new Vo(Ye.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vo(Ye.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vo(Ye.paint_symbol["icon-halo-blur"]),"icon-translate":new Uo(Ye.paint_symbol["icon-translate"]),"icon-translate-anchor":new Uo(Ye.paint_symbol["icon-translate-anchor"]),"text-opacity":new Vo(Ye.paint_symbol["text-opacity"]),"text-color":new Vo(Ye.paint_symbol["text-color"],{runtimeType:it,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Vo(Ye.paint_symbol["text-halo-color"]),"text-halo-width":new Vo(Ye.paint_symbol["text-halo-width"]),"text-halo-blur":new Vo(Ye.paint_symbol["text-halo-blur"]),"text-translate":new Uo(Ye.paint_symbol["text-translate"]),"text-translate-anchor":new Uo(Ye.paint_symbol["text-translate-anchor"])}),layout:Nd};class Vd{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}}zn(Vd,"FormatSectionOverride",{omit:["defaultValue"]});class jd 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(!jd.hasPaintOverride(this.layout,t))continue;const i=this.paint.get(t),r=new Vd(i),n=new kr(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())&&jd.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 St&&At(e.value)===st?o(e.value.sections):e instanceof kt?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 Zo({"background-color":new Uo(Ye.paint_background["background-color"]),"background-pattern":new Go(Ye.paint_background["background-pattern"]),"background-opacity":new Uo(Ye.paint_background["background-opacity"])})},Yd={paint:new Zo({"raster-opacity":new Uo(Ye.paint_raster["raster-opacity"]),"raster-hue-rotate":new Uo(Ye.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Uo(Ye.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Uo(Ye.paint_raster["raster-brightness-max"]),"raster-saturation":new Uo(Ye.paint_raster["raster-saturation"]),"raster-contrast":new Uo(Ye.paint_raster["raster-contrast"]),"raster-resampling":new Uo(Ye.paint_raster["raster-resampling"]),"raster-fade-duration":new Uo(Ye.paint_raster["raster-fade-duration"])})};class Zd 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 qd={paint:new Zo({"sky-type":new Uo(Ye.paint_sky["sky-type"]),"sky-atmosphere-sun":new Uo(Ye.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Uo(Ye.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Uo(Ye.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Uo(Ye.paint_sky["sky-gradient-radius"]),"sky-gradient":new Yo(Ye.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Uo(Ye.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Uo(Ye.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Uo(Ye.paint_sky["sky-opacity"])})};function $d(e,t,i){const r=[0,0,1],n=Zl([]);return $l(n,n,i?-k(e)+Math.PI:k(e)),ql(n,n,-k(t)),Ol(r,r,n),Pl(r,r)}const Wd={circle:class extends ga{constructor(e){super(e,hl)}createBucket(e){return new qa(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=zh(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=zh(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,A=_+p,E=g+d,M=Math.max(y+f,1e-5),S=new F(x/w,v/w);S.z=b/w,e.push(S);const C=new F(T/M,A/M);C.z=E/M,i.push(C)}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];$a(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"]=Vh.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=jh(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*jh(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:jd,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,Yd)}getProgramIds(){return["raster"]}},sky:class extends ga{constructor(e){super(e,qd),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")&&$("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?$d(o.azimuthal,90-o.polar,t):$d(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return $d(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 $("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&&($("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}}zn(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){z();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(){z();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,k=i+n>>1;1&e?(r=t,n=i,t=o,i=s):(t=r,i=n,r=o,n=s),o=l,s=k}const k=4*a;of[k+0]=t,of[k+1]=i,of[k+2]=r,of[k+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<q.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"!==Co()||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 Ss}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 zo(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!s.filter(new zo(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<q.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=q.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=ja(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=ja(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=za((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(qp(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,A=c[2]-i,E=(w*g+T*y+A*x)*b;if(E<0||E>1)return null;const M=T*d-A*p,S=A*u-w*d,C=w*p-T*u,I=(h[0]*M+h[1]*S+h[2]*C)*b;return I<0||E+I>1?null:(f*M+m*S+_*C)*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),A=_f(d[0],d[1],b,p[0],d[1],w,p[0],p[1],x,s,a),E=Math.min(null!==T?T:Number.MAX_VALUE,null!==A?A:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const n=kl([],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 M=mf(p,d,s,a);if(null!=M){const n=M;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=S(e*r-.5,0,r-1),o=S(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 $(`"${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=S(e,-1,this.dim),t=S(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)}}zn(Tf,"DEMData"),zn(xf,"DemMinMaxQuadTree",{omit:["dem"]});class Af{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 Ef{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Ef.ReadOnly=!1,Ef.ReadWrite=!0,Ef.disabled=new Ef(519,Ef.ReadOnly,[0,1]);const Mf=7680;class Sf{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}}Sf.disabled=new Sf({func:519,mask:0},0,0,Mf,Mf,Mf);class Cf{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}Cf.Replace=[1,0],Cf.disabled=new Cf(Cf.Replace,gt.transparent,[!1,!1,!1,!1]),Cf.unblended=new Cf(Cf.Replace,gt.transparent,[!0,!0,!0,!0]),Cf.alphaBlended=new Cf([1,771],gt.transparent,[!0,!0,!0,!0]);const If=1029,Bf=2305;class zf{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}zf.disabled=new zf(!1,If,Bf),zf.backCCW=new zf(!0,If,Bf),zf.backCW=new zf(!0,If,2304),zf.frontCW=new zf(!0,1028,2304),zf.frontCCW=new zf(!0,1028,Bf);class kf 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 Af(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 je(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=q.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 Ve("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 Mh(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<=q.now())continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-kf.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-kf.maxOverzooming,this._source.minzoom),i=Math.max(t+kf.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 Ve("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=Sa(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(S(a,...Df(t,-1))-a),Math.abs(S(a,...Df(t,1))-a)];e=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(S(a,...Df(t,-1))-a),Math.abs(S(a,...Df(t,0))-a),Math.abs(S(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>=q.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]}kf.maxOverzooming=10,kf.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 Cn(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=ja(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 zo(this.tileID.overscaledZ),r,this.tileID.canonical))return}else if(!n.filter(new zo(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}zn(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}=zu(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}}zn(Uf,"GlyphAtlas");class Vf{constructor(e){this.tileID=new Mh(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 Ss;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&&$(`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&&(jf(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?(jf(s.layers,this.zoom,n),Ap(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)&&(jf(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 jf(e,t,i){const r=new zo(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 Yf(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=ze(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=z()?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||z()){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=Ah,l.Color=gt,l.ColorMode=Cf,l.CullFaceMode=zf,l.DEMData=Tf,l.DataConstantProperty=Uo,l.DedupedRequest=Gf,l.DepthMode=Ef,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 Mh(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 Mh(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 zl(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=je,l.EvaluationParameters=zo,l.Event=Ve,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=ku,l.LineAtlas=Hd,l.LngLat=Aa,l.LngLatBounds=wa,l.LocalGlyphMode=lp,l.MAX_MERCATOR_LATITUDE=Pa,l.MercatorCoordinate=La,l.ONE_EM=Hh,l.OverscaledTileID=Mh,l.Properties=Zo,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=Se,l.SegmentVector=va,l.SourceCache=kf,l.StencilMode=Sf,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=Eh,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||Yf,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 Vf(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=Ml,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){Me++,Me>ve&&(e.getActor().send("enforceCacheSizeLimit",xe),Me=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(qp(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=Ma,l.clamp=S,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=E,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 Zd(e):new Wd[e.type](e)},l.cross=Dl,l.degToRad=k,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=Sn,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=So,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=q,l.exported$1=H,l.extend=b,l.extend$1=Ze,l.fillExtrusionHeightLift=vh,l.filterObject=A,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=qu,l.getAnchorJustification=Ep,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=S(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(k(e))),3);return Math.round(i*(Np.length-1))},l.getMapSessionAPI=_e,l.getPerformanceMeasurement=U,l.getProjection=Id,l.getRTLTextPluginStatus=Co,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 El(((t.x-i)*e.scale-e.x)*ba,(t.y*e.scale-e.y)*ba,ka(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(qp(t.canonical))),Rl(i,i,e),i},l.globeNormalizeECEF=Qp,l.globePixelsToTileUnits=function(e,t){return ba/(512*Math.pow(2,e))*Jp(qp(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,k(-i._center.lat)),xl(r,r,k(-i._center.lng+o)),Float32Array.from(r)},l.globeTileBounds=qp,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=Zl,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,A=h*m-u*f,E=h*_-p*f,M=h*g-d*f,S=u*_-p*m,C=u*g-d*m,I=p*g-d*_,B=y*I-x*C+v*S+b*M-w*E+T*A;return B?(e[0]=(a*I-l*C+c*S)*(B=1/B),e[1]=(n*C-r*I-o*S)*B,e[2]=(m*T-_*w+g*b)*B,e[3]=(p*w-u*T-d*b)*B,e[4]=(l*M-s*I-c*E)*B,e[5]=(i*I-n*M+o*E)*B,e[6]=(_*v-f*T-g*x)*B,e[7]=(h*T-p*v+d*x)*B,e[8]=(s*C-a*M+c*A)*B,e[9]=(r*M-i*C-o*A)*B,e[10]=(f*w-m*v+g*y)*B,e[11]=(u*v-h*w-d*y)*B,e[12]=(a*E-s*S-l*A)*B,e[13]=(i*S-r*E+n*A)*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=za,l.len=Vl,l.length=Al,l.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},l.loadVectorTile=Yf,l.makeRequest=Be,l.mapValue=function(e,t,i,r,n){return S((e-t)/(i-t)*(n-r)+r,r,n)},l.mercatorXfromLng=Sa,l.mercatorYfromLat=Ca,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=Cl,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=$a,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=zu,l.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},l.radToDeg=M,l.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],l.registerForPluginStateChange=function(e){return e({pluginStatus:To,pluginURL:Ao}),So.on("pluginStateChange",e),e},l.removeAuthState=function(e){ge.delete(e)},l.renderColorRamp=hc,l.resample=Ra,l.rotateX=yl,l.rotateX$1=ql,l.rotateY=xl,l.rotateY$1=$l,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=jl,l.scale$2=zl,l.scaleAndAdd=kl,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.");Ao=q.resolveURL(e),To=xo,wo=t,Mo(),i||Io()},l.smoothstep=h,l.spec=Ye,l.storeAuthState=function(e,t){t?ge.add(e):ge.delete(e)},l.sub=Nl,l.subtract=Sl,l.symbolSize=tu,l.tileAABB=function(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return $p(e,t,new Ah(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=Eo,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=>Mn(ln(e)),l.validateFog=e=>Mn(xn(e)),l.validateLayer=e=>Mn(dn(e)),l.validateLight=e=>Mn(gn(e)),l.validateSource=e=>Mn(_n(e)),l.validateStyle=Tn,l.validateTerrain=e=>Mn(yn(e)),l.values=v,l.vectorTile=uh,l.version=V,l.warnOnce=$,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,A,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 A(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 E(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;M(e,t,s,r,n,o%2),E(e,t,i,r,s-1,o+1),E(e,t,i,s+1,n,o+1)}function M(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);M(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(S(i,r,o,n),r[2*s+a]>l&&S(i,r,o,s);e<t;){for(S(i,r,e,t),e++,t--;r[2*e+a]<l;)e++;for(;r[2*t+a]>l;)t--}r[2*o+a]===l?S(i,r,o,t):(t++,S(i,r,t,s)),t<=n&&(o=t+1),n<=t&&(s=t-1)}}function S(e,t,i,r){C(e,i,r),C(t,2*i,2*r),C(t,2*i+1,2*r+1)}function C(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],z=e=>e[1];class k{constructor(t,i=B,r=z,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]);E(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=Y(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 k(s,Z,q,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 k(s,Z,q,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(V(i),j(o),V(n),j(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=V(o.geometry.coordinates[0]),i=j(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?Y({},e.properties):e.properties;const i=this.points[e.index].properties,r=this.options.map(i);return t&&r===i?Y({},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(V(i)),y:L(j(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 Y(Y({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:i})}function V(e){return e/360+.5}function j(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 Y(e,t){for(const i in t)e[i]=t[i];return e}function Z(e){return e.x}function q(e){return e.y}function $(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&&$(e,t,n,r),e[n+2]=o,i-n>3&&$(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,$(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,A=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+A,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+A,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+A,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)}),A="-transition";class E 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,A)?this._transitionable.setTransition(t.slice(0,-A.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 M(e,t,i,r){const n=te.smoothstep(45,65,i),[o,s]=S(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 S(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}const C=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(C),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),M(e,o,i.pitch,i._fov)}(this.state,e,t):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?S(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 z{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 z.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 k(e,t,i){return t*(te.EXTENT/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}z.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=k(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 V{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 j{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 j{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 Y extends j{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Z extends j{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class q extends j{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 $ extends j{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class W extends j{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class X extends j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class he extends j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 j{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 Ae extends Te{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Ee{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 Me{constructor(e){this.gl=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new G(this),this.clearDepth=new Y(this),this.clearStencil=new Z(this),this.colorMask=new q(this),this.depthMask=new $(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 V(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 Ee(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 Se 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 Ce;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 ze={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:Se,"raster-dem":class extends Se{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==Ce&&(Ce=te.window.OffscreenCanvas&&new te.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof te.window.createImageBitmap),Ce),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){Se.loadTileData(e,t,this._map.painter)}unloadTileData(e){Se.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"}))}}},ke=function(e,t,i,r){const n=new ze[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 Ve(){return Ue||(Ue=new Ne),Ue}function je(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]=je(t[e],i[t[e].ref]));return t}Ne.workerCount=2;const Ye={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 Ze(e,t,i){i.push({command:Ye.addSource,args:[e,t[e]]})}function qe(e,t,i){t.push({command:Ye.removeSource,args:[e]}),i[e]=!0}function $e(e,t,i,r){qe(e,i,r),Ze(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],A=u.projection.projectTilePoint(w.x,w.y,h.canonical),E=[A.x+T[0],A.y+T[1],A.z+T[2]],M=[...E,1];if(te.transformMat4$1(M,M,r),!at(M,m)){_t(f.numGlyphs,_);continue}const S=st(n.transform.cameraToCenterDistance,M[3]),C=te.evaluateSizeForFeature(p,d,f),I=a?C/S:C*S,B=nt(new te.pointGeometry(E[0],E[1]),o,E[2]);if(B.signedDistanceFromCamera<=0){_t(f.numGlyphs,_);continue}let e={};const z=a?null:c,k=ut(f,I,!1,l,r,o,s,i.glyphOffsetArray,y,_,g,B.point,w,e,v,z,u.projection,h,a);b=k.useVertical,z&&k.needsFlipping&&(e={}),(k.notEnoughRoom||b||k.needsFlipping&&ut(f,I,!0,l,r,o,s,i.glyphOffsetArray,y,_,g,B.point,w,e,v,z,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,A=ot(h.last.point,s).point,E=new te.pointGeometry(T[0],T[1]),M=new te.pointGeometry(A[0],A[1]);if(e&&!r){const te=ht(t,E,M,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,A=0,E=0;const M=Math.abs(y),S=[],C=[];let I=o;const B=()=>{const e=b-x;return 0===A?o:new te.pointGeometry(c.getx(e),c.gety(e))},z=()=>dt(B(),I,T,M-A+1,h,p,m,_.canonical);for(;A+E<=M;){if(b+=x,b<a||b>=l)return null;if(T=w,S.push(w),d&&C.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:z()}else I=null;A+=E,E=te.distance(T,w)}I=I||new te.pointGeometry(c.getx(b),c.gety(b));const k=B();f&&p&&(u[b]=w=void 0===u[b]?w:z(),E=te.distance(T,w));const P=(M-A)/E,L=I.sub(k).mult(P)._add(k),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 S.push(R),d&&C.push(L),{point:R,angle:U,path:S,tilePath:C,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:A}=T,E=(d?n/A:n*A)/te.ONE_EM,M=nt(new te.pointGeometry(b[0],b[1]),h,b[2]).point,S=T.signedDistanceFromCamera>0?ct(E,r,a.lineOffsetX*E,a.lineOffsetY*E,!1,M,o,a,l,h,{},t&&!d?y:null,d&&!!t,s.getProjection(),e,d):null;let C=!1,I=!1,B=!0;if(S&&!T.occluded){const s=.5*m*A+_,a=new te.pointGeometry(-100,-100),l=new te.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),r=new Je,n=S.first,c=S.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)&&(C=!0,!p))return{circles:[],offscreen:!1,collisionDetected:C,occluded:!1}}}}return{circles:!p&&C||!I?[]:g,offscreen:B,collisionDetected:C,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),M(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 At{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 Et{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r}}class Mt{constructor(){this.invProjMatrix=te.create(),this.viewportMatrix=te.create(),this.circles=[]}}class St{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class Ct{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 zt{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 Ct(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 St(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:A,layout:E,posMatrix:M,textLabelPlaneMatrix:S,labelToScreenMatrix:C,clippingData:I,textPixelRatio:B,holdingForFade:z,collisionBoxArray:i,partiallyEvaluatedTextSize:k,partiallyEvaluatedIconSize:P,collisionGroup:L}=t.parameters,D=E.get("text-optional"),R=E.get("icon-optional"),O=E.get("text-allow-overlap"),F=E.get("icon-allow-overlap"),N="map"===E.get("text-rotation-alignment"),U="map"===E.get("text-pitch-alignment"),V="none"!==E.get("icon-text-fit"),r="viewport-y"===E.get("symbol-z-order");this.transform.setProjection(A.projection);let j=O&&(F||!A.hasIconData()||R),G=F&&(O||!A.hasTextData()||D);!A.collisionArrays&&i&&A.deserializeCollisionBoxes(i),T&&e&&A.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[A.bucketInstanceId];e=I.featureIndex.loadFeature({featureIndex:h.featureIndex,bucketIndex:te.bucketIndex,sourceLayerIndex:te.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,I.dynamicFilter)(T,e,this.retainedQueryData[A.bucketInstanceId].tileID.canonical,new te.pointGeometry(h.tileAnchorX,h.tileAnchorY),this.transform.calculateDistanceTileData(I.unwrappedTileID)))return this.placements[h.crossTileID]=new Et(!1,!1,!1,!0),void(w[h.crossTileID]=!0)}if(w[h.crossTileID])return;if(z)return void(this.placements[h.crossTileID]=new Et(!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[A.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[A.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},y=i.textBox;if(y){g(y);const w=e=>{let t=te.WritingMode.horizontal;if(A.allowVerticalPlacement&&!e&&this.prevPlacement){const te=this.prevPlacement.placedOrientations[h.crossTileID];te&&(this.placedOrientations[h.crossTileID]=te,t=te,this.markUsedOrientation(A,t,h))}return t},T=(e,t)=>{if(A.allowVerticalPlacement&&h.numVerticalGlyphVertices>0&&i.verticalTextBox){for(const h of A.writingModes)if(h===te.WritingMode.vertical?(o=t(),s=o):o=e(),o&&o.box&&o.box.length)break}else o=e()};if(E.get("text-variable-anchor")){let c=E.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 C=(t,e,i)=>{const r=A.getSymbolInstanceTextSize(k,h,this.transform.zoom,u),n=(t.x2-t.x1)*r+2*t.padding,o=(t.y2-t.y1)*r+2*t.padding,s=V&&!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,M,L,e>=c.length,h,u,A,i,s,k,P);if(l&&(a=l.placedGlyphBoxes,a&&a.box&&a.box.length)){p=!0,d=l.shift;break}}return a};T(()=>C(y,i.iconBox,te.WritingMode.horizontal),()=>{const e=i.verticalTextBox;return e&&g(e),A.allowVerticalPlacement&&!(o&&o.box&&o.box.length)&&h.numVerticalGlyphVertices>0&&e?C(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(A,te.anchor,h,I))}}else{const E=(e,t)=>{const i=A.getSymbolInstanceTextSize(k,h,this.transform.zoom,u),r=this.collisionIndex.placeCollisionBox(A,i,e,new te.pointGeometry(0,0),O,B,M,L.predicate);return r&&r.box&&r.box.length&&(this.markUsedOrientation(A,t,h),this.placedOrientations[h.crossTileID]=t),r};T(()=>E(y,te.WritingMode.horizontal),()=>{const e=i.verticalTextBox;return A.allowVerticalPlacement&&h.numVerticalGlyphVertices>0&&e?(g(e),E(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=A.text.placedSymbolArray.get(h.centerJustifiedTextSymbolIndex>=0?h.centerJustifiedTextSymbolIndex:h.verticalPlacedTextSymbolIndex),u=te.evaluateSizeForFeature(A.textSizeData,k,w),I=E.get("text-padding");l=this.collisionIndex.placeCollisionCircles(A,O,w,A.lineVertexArray,A.glyphOffsetArray,u,M,S,C,T,U,L.predicate,h.collisionCircleDiameter*u/te.ONE_EM,I,this.retainedQueryData[A.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=V&&d?Bt(d.x,d.y,N,U,this.transform.angle):new te.pointGeometry(0,0),i=A.getSymbolInstanceIconSize(P,this.transform.zoom,u);return this.collisionIndex.placeCollisionBox(A,i,e,t,F,B,M,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,E.get("text-ignore-placement"),A.bucketInstanceId,s&&s.box&&m?m:f,L.ID),e&&c&&this.collisionIndex.insertCollisionBox(c.box,E.get("icon-ignore-placement"),A.bucketInstanceId,_,L.ID),l&&(p&&this.collisionIndex.insertCollisionCircles(l.circles,E.get("text-ignore-placement"),A.bucketInstanceId,f,L.ID),T)){const te=A.bucketInstanceId;let t=this.collisionCircleArrays[te];void 0===t&&(t=this.collisionCircleArrays[te]=new Mt);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"!==A.projection.name;j=j&&(b||!r),G=G&&(b||!n),this.placements[h.crossTileID]=new Et(p||j,e||G,t||A.justReloaded),w[h.crossTileID]=!0};if(r){const te=A.getSortedSymbolIndexes(this.transform.angle);for(let e=te.length-1;e>=0;--e){const w=te[e];n(A.symbolInstances.get(w),w,A.collisionArrays[w])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)n(A.symbolInstances.get(e),e,A.collisionArrays[e]);if(T&&A.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[A.bucketInstanceId];te.invert(t.invProjMatrix,M),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}A.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 At(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 At(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 At(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 At(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 At(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?Vt:te),m(r.text,c,w?Vt: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?Vt:te),r.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=i.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(r.icon,o.numVerticalIconVertices,w?Vt: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&&kt(r.textCollisionBox.collisionVertexArray,i.text.placed,!t||b,e.x,e.y),n.verticalTextBox&&kt(r.textCollisionBox.collisionVertexArray,i.text.placed,!t||w,e.x,e.y)}const a=t&&Boolean(!w&&n.verticalIconBox);n.iconBox&&kt(r.iconCollisionBox.collisionVertexArray,i.icon.placed,a,d?e.x:0,d?e.y:0),n.verticalIconBox&&kt(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 kt(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 Vt=0;class jt{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 zt(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 jt(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 Yt=512/te.EXTENT/2;class Zt{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=Yt/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 qt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class $t{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 Zt(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 qt,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 $t);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(Ye,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Kt=te.pick(Ye,["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 z(Ve(),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:Ye.setStyle,args:[i]}];let r=[];try{if(!_(t.version,i.version))return[{command:Ye.setStyle,args:[i]}];_(t.center,i.center)||r.push({command:Ye.setCenter,args:[i.center]}),_(t.zoom,i.zoom)||r.push({command:Ye.setZoom,args:[i.zoom]}),_(t.bearing,i.bearing)||r.push({command:Ye.setBearing,args:[i.bearing]}),_(t.pitch,i.pitch)||r.push({command:Ye.setPitch,args:[i.pitch]}),_(t.sprite,i.sprite)||r.push({command:Ye.setSprite,args:[i.sprite]}),_(t.glyphs,i.glyphs)||r.push({command:Ye.setGlyphs,args:[i.glyphs]}),_(t.transition,i.transition)||r.push({command:Ye.setTransition,args:[i.transition]}),_(t.light,i.light)||r.push({command:Ye.setLight,args:[i.light]}),_(t.fog,i.fog)||r.push({command:Ye.setFog,args:[i.fog]}),_(t.projection,i.projection)||r.push({command:Ye.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)||qe(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:Ye.setGeoJSONSourceData,args:[n,t[n].data]}):$e(n,t,i,r)):Ze(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:Ye.removeLayer,args:[e.id]}):s.push(e)});let e=t.terrain;e&&n[e.source]&&(r.push({command:Ye.setTerrain,args:[void 0]}),e=void 0),r=r.concat(o),_(e,i.terrain)||r.push({command:Ye.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:Ye.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:Ye.removeLayer,args:[u]}),a.splice(a.lastIndexOf(u,a.length-h),1)):h++,f=a[a.length-c],i.push({command:Ye.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,Ye.setLayoutProperty),Xe(p.paint,d.paint,i,u,null,Ye.setPaintProperty),_(p.filter,d.filter)||i.push({command:Ye.setFilter,args:[u,d.filter]}),_(p.minzoom,d.minzoom)&&_(p.maxzoom,d.maxzoom)||i.push({command:Ye.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),Ye.setPaintProperty):_(p[m],d[m])||i.push({command:Ye.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),Ye.setPaintProperty):_(p[m],d[m])||i.push({command:Ye.setLayerProperty,args:[u,m,d[m]]}))}else i.push({command:Ye.removeLayer,args:[u]}),f=a[a.lastIndexOf(u)+1],i.push({command:Ye.addLayer,args:[d,f]})}(s,i.layers,r)}catch(t){console.warn("Unable to compute style diff:",t),r=[{command:Ye.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=ke(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 E(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 ze[e]},ei.setSourceType=function(e,t){ze[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 Ai extends te.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new z(Ve(),null),r=ke("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 Ei extends te.SourceCache{constructor(e){const t=ke("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new z(Ve(),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 Mi 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 Si 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 Ei(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 Ai(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 Mi(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),A=(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},E=f.colorModeForRenderPass(),M=new te.DepthMode(v.LEQUAL,te.DepthMode.ReadWrite,f.depthRangeFor3D);xi.update(y);const S=te.calculateGlobeMercatorMatrix(T),C=[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,S,p,te.globeToMercatorTransition(T.zoom),C,T.frustumCorners.TL,T.frustumCorners.TR,T.frustumCorners.BR,T.frustumCorners.BL,T.globeCenterInViewSpace,T.globeRadius,B,u);if(A(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,M,i,E,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,A=w===(1<<r)-1,[S,e,o,s]=I.getPoleBuffers(r);if(s&&(n||A)){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,M,te.StencilMode.disabled,E,te.CullFaceMode.disabled,gi(T.projMatrix,i,i,a,0,C,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,S),A&&(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,A=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)?A/10:A);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 Ae(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 Se){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 Mi(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 Ci(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=Ci(i.staticAttributes),l=r?r.getBinderAttributes():[],c=a.concat(l),h=i.staticUniforms?Ci(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/k(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 zi=te.create(),ki=(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:zi,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=ki(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},Vi=(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]}},ji=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Gi=te.create(),Yi=(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:k(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},Zi=(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=$i(t,e.transform);h.u_texsize=t.lineAtlasTexture.size,h.u_scale=[i,r.fromScale,r.toScale],h.u_mix=r.t}return h},qi=(e,t,i,r,n,o)=>{const s=e.transform,a=$i(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 $i(e,t){return 1/k(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/k(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,Vi(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:A,height:E,anchor:M,textOffset:S,textScale:C}=b,I=lr(M,A,E,S,C,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,A=w&&"point"!==c.layout.get("symbol-placement"),E=w&&!T&&!A,M=void 0!==c.layout.get("symbol-sort-key").constantOr(1);let S=!1;const C=a.depthModeForSublayer(0,te.DepthMode.ReadOnly),I=[te.mercatorXfromLng(b.center.lng),te.mercatorYfromLat(b.center.lat)],B=c.layout.get("text-variable-anchor"),z="globe"===b.projection.name,k=[],P=[0,-1,0];let L=P;!z&&!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&&z)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,C=u?m.textSizeData:m.iconSizeData,D=T||0!==b.pitch,R=te.evaluateSizeForZoom(C,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"===C.kind||"camera"===C.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),V=b.calculatePixelsToTileUnitsMatrix(h),j=tt(U,h.tileID.canonical,T,w,b,m.getProjection(),V),G=a.terrain&&T&&A?te.invert(te.create(),j):ar,Y=rt(U,h.tileID.canonical,T,w,b,m.getProjection(),V),Z=B&&m.hasTextData(),q="none"!==c.layout.get("icon-text-fit")&&Z&&m.hasIconData();if(A){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(),V);lt(m,U,a,u,c,Y,T,_,l,f)}const $=A||u&&B||q,W=a.translatePosMatrix(U,h,p,d),X=$?ar:j,H=a.translatePosMatrix(Y,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"),$&&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(C.kind,R,E,T,a,W,X,H,e,n,f,N,I,K,F,m.getProjection()):er(C.kind,R,E,T,a,W,X,H,u,e,!0,f,N,I,K,F,m.getProjection()):Qi(C.kind,R,E,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(M&&m.canOverlap){S=!0;const a=g.segments.get();for(const l of a)k.push({segments:new te.SegmentVector([l]),sortKey:l.sortKey,state:ee})}else k.push({segments:g.segments,sortKey:0,state:ee})}S&&k.sort((e,t)=>e.sortKey-t.sortKey);for(const te of k){const l=te.state;if(a.terrain&&a.terrain.setupElevationDraw(l.tile,l.program,{useDepthForOcclusion:!z,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,C,g,y,h)),h.u_is_halo=0}pr(l.buffers,te.segments,c,a,l.program,C,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 A=e.translatePosMatrix(x.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),E=c.projection.createInversionMatrix(c,x.canonical),M=i.paint.get("fill-extrusion-vertical-gradient"),S=u?Pi(A,e,M,d,x,p,r,f,_,g,E):ki(A,e,M,d,x,f,_,g,E);e.prepareDrawProgram(a,w,x.toUnwrapped()),w.draw(a,a.gl.TRIANGLES,n,o,s,te.CullFaceMode.backCCW,S,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 Ar(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,ji(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,ji(s,te.Color.transparent,x),p,b,w,T,null,null,null,l._globeTileDebugTextBuffer)}const Er=te.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Mr}=Er;function Sr(e,t,i,r){e.emplaceBack(t,i,r)}class Cr{constructor(e){this.vertexArray=new te.StructArrayLayout3f12,this.indices=new te.StructArrayLayout3ui6,Sr(this.vertexArray,-1,-1,1),Sr(this.vertexArray,1,-1,1),Sr(this.vertexArray,-1,1,1),Sr(this.vertexArray,1,1,1),Sr(this.vertexArray,-1,-1,-1),Sr(this.vertexArray,1,-1,-1),Sr(this.vertexArray,-1,1,-1),Sr(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,Mr),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 zr{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 kr={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,Yi(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),A=i.useProgram(y,T,b),E=f.constantOr(null);if(E&&o.imageAtlas){const te=o.imageAtlas,i=te.patternPositions[E.to.toString()],r=te.patternPositions[E.from.toString()];i&&r&&T.setConstantPatternPositions(i,r)}const M=u.constantOr(null),S=d.constantOr(null);if(!m&&M&&S&&o.lineAtlas){const te=o.lineAtlas,i=te.getDash(M.to,S),r=te.getDash(M.from,S);i&&r&&T.setConstantPatternPositions(i,r)}let[e,t]=n.paint.get("line-trim-offset");if("round"===S||"square"===S){const te=1;e!==t&&(0===e&&(e-=te),1===t&&(t+=te))}const C=i.terrain?s.projMatrix:null,I=m?qi(i,o,n,g,C,h):Zi(i,o,n,g,C,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,A,s.toUnwrapped());const B=e=>{A.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 A="nearest"===n.paint.get("raster-resampling")?c.NEAREST:c.LINEAR;l.activeTexture.set(c.TEXTURE0),y.texture.bind(A,c.CLAMP_TO_EDGE),l.activeTexture.set(c.TEXTURE1),w?(w.texture.bind(A,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(A,c.CLAMP_TO_EDGE);const E=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,E,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,E,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:A}=e.getTileBoundsBuffers(v);m.draw(s,a.TRIANGLES,d,p,f,te.CullFaceMode.disabled,b,i.id,w,T,A)}},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 Cr(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 Cr(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++)Ar(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 Me(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 Si(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 zr(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&&kr.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)||kr[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]:k(t,i[0],this.transform.zoom),n?i[1]:k(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=jr(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),_=Zr(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=Zr(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=Vr(e);return te.scale(r,r,[n,n,1]),r}function Vr(e){const t=e.projection,i=jr(e.projection,e.zoom,e.width,e.height),r=Yr(t,e.center),n=Yr(t,te.LngLat.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function jr(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 Yr(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 Zr(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}class qr{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 qr(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?Vr(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 A=[];const E=l,M=a.reparseOverscaled?c:l,S=e=>e*e,C=S((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===E)return!1;if(null!=e.shouldSplit)return e.shouldSplit;const t=e.aabb.distanceX(m),i=e.aabb.distanceY(m);let r=C,n=1;if(u){r=S(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===E-1&&o>=.9)return!0}else if(s&&(r=S(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<S((1<<E-e.zoom)*_*n*((e,t)=>{if(t*S(.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,C),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!==E&&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===E?M:c.zoom+1,c.wrap,c.zoom+1,l,o),I(p)),T.push(p)}else{const s=c.zoom===E?M: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);A.push({tileID:u,distanceSq:r*r+n*n})}}if(this.fogCullDistSq){const l=this.fogCullDistSq,c=this.horizonLineFromTop();A=A.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 A.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=jr(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=jr(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 $r(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=$r(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 An(e,t){return 180*e.angleWith(t)/Math.PI}class En 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:An(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=An(e,this._startVector);return Math.abs(i)<t}}function Mn(e){return Math.abs(e.y)>Math.abs(e.x)}class Sn 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,Mn(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 Mn(e)&&Mn(t)&&o}}const Cn={panStep:100,bearingStep:15,pitchStep:10};class In{constructor(){const e=Cn;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 zn=4.000244140625;class kn{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%zn==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)>zn?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 Vn{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 jn(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 Vn,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 Sn(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 En,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 kn(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||jn(o))&&(this._changes.push([o,s,h]),this._triggerRenderFrame()),(Object.keys(a).length||jn(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()})()&&!jn(e)){const te=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",te!==n.zoom&&this._map._update(!0)}if(!jn(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 Yn="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Zn 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),A=w.add(T).mult(o.scale/o.zoomScale(b));return{center:o.unproject(a.add(l).div(2).sub(A)),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(Yn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const i=this.transform;if(!i.projection.supportsFreeCamera)return te.warnOnce(Yn),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 A(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}const M=T(0);let S=function(e){return E(M)/E(M+r*e)},C=function(e){return n*((E(M)*(A(t=M+r*e)/E(t))-A(M))/w)/b;var t},I=(T(1)-M)/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,C=function(){return 0},S=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,z=d!==c,k=!e.isPaddingEqual(f),P=n=>e=>{const t=e*I,i=1/S(t);n.zoom=1===e?u:a+n.scaleZoom(i),B&&(n.bearing=te.number(l,p,e)),z&&(n.pitch=te.number(c,d,e)),k&&(n.interpolatePadding(h,f,e),_=n.centerPoint.add(m));const r=1===e?g:n.unproject(y.add(x.mult(C(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=z,this._padding=k,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 qn{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 $n{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 Zn{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 qr(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 qn({customAttribution:e.customAttribution})),this._logoControl=new $n,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 $n&&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=$r(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:qn,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(){Ve().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(18))},function(e,t,i){"use strict";var r=i(6);function n(e){r.call(this,null==e?"canceled":e,r.ERR_CANCELED),this.name="CanceledError"}i(1).inherits(n,r,{__CANCEL__:!0}),e.exports=n},function(e,t,i){var r;e.exports=(r=i(0),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(1),a=u(40),r=u(6),t=u(19),l=u(20),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(22):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(52)},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(18))},function(e,t,i){var n;e.exports=(n=i(0),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(0),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(1);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){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,i){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,r){"use strict";!function(i){var l=r(1);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(41).Buffer)},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){"use strict";var p=i(1),d=i(45),f=i(46),m=i(17),_=i(23),g=i(49),y=i(50),x=i(19),v=i(6),b=i(10),w=i(51);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(47),n=i(48);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(1);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(0),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(0),i(11),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,A=c.low,E=h.high,i=h.low,M=u,S=p,C=d,I=f,B=m,z=_,k=g,P=y,L=x,D=v,R=b,O=w,F=T,N=A,U=E,V=i,j=0;j<80;j++){var G,Y,Z=te[j];j<16?(Y=Z.high=0|e[t+2*j],G=Z.low=0|e[t+2*j+1]):(Q=(q=te[j-15]).high,H=q.low,X=(K=te[j-2]).high,W=K.low,$=(J=te[j-7]).high,q=J.low,J=(K=te[j-16]).high,Y=(Y=((Q>>>1|H<<31)^(Q>>>8|H<<24)^Q>>>7)+$+((G=($=(H>>>1|Q<<31)^(H>>>8|Q<<24)^(H>>>7|Q<<25))+q)>>>0<$>>>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,Z.high=Y=Y+J+(G>>>0<Q>>>0?1:0),Z.low=G);var q=L&R^~L&F,$=D&O^~D&N,W=M&C^M&B^C&B,X=(S>>>28|M<<4)^(S<<30|M>>>2)^(S<<25|M>>>7),H=ee[j],K=H.high,J=H.low,Q=V+((D>>>14|L<<18)^(D>>>18|L<<14)^(D<<23|L>>>9)),Z=U+((L>>>14|D<<18)^(L>>>18|D<<14)^(L<<23|D>>>9))+(Q>>>0<V>>>0?1:0),H=X+(S&I^S&z^I&z),U=F,V=N,F=R,N=O,R=L,O=D,L=k+(Z=(Z=(Z=Z+q+((Q=Q+$)>>>0<$>>>0?1:0))+K+((Q=Q+J)>>>0<J>>>0?1:0))+Y+((Q=Q+G)>>>0<G>>>0?1:0))+((D=P+Q|0)>>>0<P>>>0?1:0)|0,k=B,P=z,B=C,z=I,C=M,I=S,M=Z+(((M>>>28|S<<4)^(M<<30|S>>>2)^(M<<25|S>>>7))+W+(H>>>0<X>>>0?1:0))+((S=Q+H|0)>>>0<Q>>>0?1:0)|0}p=r.low=p+S,r.high=u+M+(p>>>0<S>>>0?1:0),f=n.low=f+I,n.high=d+C+(f>>>0<I>>>0?1:0),_=o.low=_+z,o.high=m+B+(_>>>0<z>>>0?1:0),y=s.low=y+P,s.high=g+k+(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),A=c.low=A+N,c.high=T+F+(A>>>0<N>>>0?1:0),i=h.low=i+V,h.high=E+U+(i>>>0<V>>>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(35)},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(1),o=i(16),s=i(36),a=i(25);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(13));r.Axios=s,r.CanceledError=i(10),r.CancelToken=i(54),r.isCancel=i(24),r.VERSION=i(26).version,r.toFormData=i(20),r.AxiosError=i(6),r.Cancel=r.CanceledError,r.all=function(e){return Promise.all(e)},r.spread=i(55),r.isAxiosError=i(56),e.exports=r,e.exports.default=r},function(e,t,i){"use strict";var r=i(1),n=i(17),o=i(37),h=i(38),u=i(25),s=i(23),p=i(53),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(1);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(1),n=i(39),o=i(24),s=i(13),a=i(10);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(1),o=i(13);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(1);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,k,P){"use strict";!function(e){var a=P(42),o=P(43),s=P(44);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 z(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 z(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)}k.Buffer=u,k.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},k.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}}(),k.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=k.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,z(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,z(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 A(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 E(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 M(e,t,i,r,n){return n||E(e,0,i,4),o.write(e,t,i,r,23,4),i+4}function S(e,t,i,r,n){return n||E(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):A(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):A(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):A(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):A(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,i){return M(this,e,t,!0,i)},u.prototype.writeFloatBE=function(e,t,i){return M(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,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 C=/[^+\/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(C,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(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(21))},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(6);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(1);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(1),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(1);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(26).version,l=i(6),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(10);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(1);e.exports=function(e){return r.isObject(e)&&!0===e.isAxiosError}},function(e,t){},function(e,t,i){var r;e.exports=(r=i(0),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(0),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(0),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(0),i(27),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(0),i(11),i(28),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(0),i(11),function(h){var e=n,t=e.lib,u=t.WordArray,r=t.Hasher,p=e.x64.Word,t=e.algo,M=[],S=[],C=[];!function(){for(var e=1,t=0,i=0;i<24;i++){M[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++)S[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;C[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=M[_];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[S[_]];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[_],A=I[(l+1)%5+5*u],E=I[(l+2)%5+5*u];w.high=T.high^~A.high&E.high,w.low=T.low^~A.low&E.low}w=i[0],b=C[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(0),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]),A=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]),E=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]),M=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]),C=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=S.words,d=C.words,f=T.words,m=A.words,_=E.words,g=M.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=z(h|=0,_[i]))+c|0,o=c,c=l,l=z(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=z(h|=0,g[i]))+w|0,y=w,w=b,b=z(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 z(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(0),i(14),i(15),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(0),i(2),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(0),i(2),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(0),i(2),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(0),i(2),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(0),i(2),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(0),i(2),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(0),i(2),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(0),i(2),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(0),i(2),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(0),i(2),e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding)},function(e,t,i){var r;e.exports=(r=i(0),i(2),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(0),i(7),i(8),i(5),i(2),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(0),i(7),i(8),i(5),i(2),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(0),i(7),i(8),i(5),i(2),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(0),i(7),i(8),i(5),i(2),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(0),i(7),i(8),i(5),i(2),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 se});var n;i(30),i(31),i(32),i(33),i(34);class r{constructor(e){this.app=e}runRender(){}onPointer(e){switch(e.type){case BABYLON.PointerEventTypes.POINTERDOWN:this.isMove=0;case BABYLON.PointerEventTypes.POINTERMOVE:if(this.isMove++,!this.app.toolTips)return;e?this.app.toolTips.update(e):this.app.toolTips.close();break;case BABYLON.PointerEventTypes.POINTERWHEEL:this.app.cameraController._wheel(e.event),e.event.preventDefault();break;case BABYLON.PointerEventTypes.POINTERUP:if(2<this.isMove)return;e.pickInfo.pickedMesh||2!=e.event.button||this.app.project.goBack()}}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.instance.position.y+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/3,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)}static rand(e,t){return Math.floor(Math.random()*(t-e+1)+e)}}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()}orthographic1(e){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,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.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("camtarget","target",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);t.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:30,value:e.focus.clone()}]);var i=new BABYLON.Animation("camAlpha","alpha",30,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.alpha},{frame:30,value:e.alpha}]);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,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,r,n],0,60,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}flyTo(e,t=0){e=e||this.app.project.current.Sight,this.arcRotateCamera.mode=BABYLON.Camera.PERSPECTIVE_CAMERA;var i=new BABYLON.Animation("camTarget","target",20,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);i.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:20,value:e.focus.clone()}]);var r=new BABYLON.Animation("camRadius","radius",20,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);r.setKeys([{frame:20,value:this.arcRotateCamera.radius},{frame:40,value:e.radius}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[i,r],0,40,!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,u;class m 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 _ 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 g{constructor(e){this._text="",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: 8px 10px;border: 1px solid #353535;background: #292929;border-radius: 20%;",this.app.canvas.parentElement.appendChild(this.ele),this.close()}set text(e){this._text=e,(this.ele.innerText=e)?this.ele.style.display=null:this.close()}update(e){this._text&&(this.ele.style.top=e.event.offsetY+"px",this.ele.style.left=e.event.offsetX+20+"px")}close(){this.ele.style.display="none"}setBackground(e){this.url=e,this.ele.style.background="url("+this.url+") no-repeat",this.ele.style.backgroundSize="cover"}dispose(){this.app.canvas.parentElement.removeChild(this.ele),this.ele=null}}class y{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(se.rl+"resources/environment.env",.5),this.app.scene.fogEnabled=!0,this.app.scene.fogMode=2,this.fogDistance=800,BABYLON.Effect.IncludesShadersStore.fogVertex=`
|
|
2
|
-
#ifdef FOG
|
|
3
|
-
vFogDistance=(worldPos).xyz;
|
|
4
|
-
#endif
|
|
5
|
-
`}setTransparent(e=1){this.app.scene.clearColor=new BABYLON.Color4(this._color.r,this._color.g,this._color.b,this._color.a*e)}default(){this.color=new BABYLON.Color4(0,.0588,.1176,1)}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.r,this._color.g,this._color.b)}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 _(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 m(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,console.log(this.lights);for(const t in this.lights.map)this.lights.find(t).light.intensity=this.lights.find(t).intensity*e;this.app.scene.environmentIntensity=this.reflexIntensity*e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}showTips(){this.app.toolTips=new g(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||{}).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",t.Building="Building",t.Storey="Storey",t.Campus="Campus",(t=u=u||{}).leftClick="leftClick",t.rightClick="rightClick",t.doubleClick="doubleClick",t.eover="eover",t.longPress="longPress",t.out="out",t.click="click";class x{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 v{constructor(e){this.app=e}getInto(){}goBack(){}loadProperties(e){this.id="墙角_"+a.getGUID(12),this.name="墙角",this.parentId=e.parentId,this.customNumber=this.id,this.objectType=f.Corner,this.customType=this.objectType,this.height=e.height,this.pints=e.corners}alwaysActive(){this.instance.getChildMeshes().forEach(e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0}),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}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())}setFlash(e){}setTransparent(){}setOpaque(){}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e,t){}removeEventListener(e){}computeView(){}bind(){let i=new Array;for(let t=0;t<this.pints.length;t++)if(2<this.pints[t].pints.length){let e=BABYLON.MeshBuilder.CreatePolygon(this.id,{shape:this.pints[t].pints,sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);e.setEnabled(!1),e.position.y=this.pints[t].height,e.isPickable=!0,e.enablePointerMoveEvents=!1,i.push(e)}return!(i.length<1)&&(1<i.length?this.instance=p.MergeMeshes(i,this.app):this.instance=i[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))}toJson(){return{id:this.id,parentId:this.parentId,name:this.name,customNumber:this.customNumber,customType:this.customType,objectType:this.objectType}}completed(){this.alwaysActive(),this.optimization(!0)}}var b,t=i(3),w=i.n(t);class T{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),r=new w.a.Tween(this.colors[2]).to({r:0,g:0,b:0},500);i.chain(r),r.chain(i),i.start();let n=new w.a.Tween(this.colors[3]).to({r:1,g:.84,b:0},500),o=new w.a.Tween(this.colors[3]).to({r:0,g:0,b:0},500);n.chain(o),o.chain(n),n.start();let s=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);s.chain(a),a.chain(s),s.start();let l=new w.a.Tween(this.colors[5]).to({r:.53,g:.8,b:0},500),c=new w.a.Tween(this.colors[5]).to({r:0,g:0,b:0},500);l.chain(c),c.chain(l),l.start();let h=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);h.chain(u),u.chain(h),h.start()}}T.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=b=b||{})[t.Opaque=0]="Opaque",t[t.Flash=1]="Flash",t[t.Transparent=2]="Transparent";class A{constructor(e){this.executes=new d,this.clickEvents=new d,this.touchtime=(new Date).getTime(),this.statusType=b.Opaque,this.app=e}loadProperties(e){this.id=e.id,this.customNumber=e.customNumber,this.parentId=e.parentId,this.name=e.name,this.baseModel=e.baseModel,this.isLoop=e.isLoop,this.objectType=e.objectType,this.customType=e.customType,this.position=p.ToVector3(e.position),this.rotation=p.ToVector3(e.rotation),this.scaling=p.ToVector3(e.scaling)}setEnabled(e){if(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>e.dispose()),e){let t=new BABYLON.Mesh(this.id,this.app.scene),e=this.app.resources.resources.find(this.baseModel.modelId);e.meshes[0].getChildMeshes().forEach(e=>{e=e.createInstance(this.id);e.isPickable=!1,e.enablePointerMoveEvents=!1,e.parent=t}),t.rotation=p.ToVector3(this.rotation.clone()),t.position=p.ToVector3(this.position.clone()),t.scaling=p.ToVector3(this.scaling.clone()),this.instance.addChild(t),this.alwaysActive(),this.optimization(!0)}this.instance.setEnabled(e),this.isPickable=e,this.statusType=b.Opaque,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}set isPickable(e){e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(u.eover)||this.executes.find(u.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1)}get isPickable(){return this.instance.isPickable}bind(){var e=this.app.resources.resources.find(this.baseModel.modelId),e=p.computeBounds(e.meshes[0]);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)*this.scaling.x,(e.maximum.y-e.minimum.y)*this.scaling.y,(e.maximum.z-e.minimum.z)*this.scaling.z),0==this.instance.scaling.y&&(this.instance.scaling.y=.01),this.instance.position=p.ToVector3(this.position.clone()),this.instance.position.y=(e.maximum.y-e.minimum.y)/2+this.position.y,this.instance.rotation=p.ToVector3(this.rotation.clone()),this.instance.setEnabled(!1),this.completed()}completed(){this.alwaysActive(),this.optimization(!0),this.computeView()}computeView(){this.Sight=new x;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=5*e.boundingSphere.radius,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==u.leftClick||e==u.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(u.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(u.rightClick);i&&2==e.sourceEvent.button&&i(this,e),this.touchtime=(new Date).getTime()}),e=u.click):e==u.doubleClick?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger,e=>t(this,e)):e==u.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==u.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==u.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==u.leftClick||e==u.rightClick||e==u.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e=u.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.statusType==b.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.instancedBuffers&&(e.instancedBuffers.color=T.colors[t])}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.statusType=b.Flash)}setOpaque(){this.statusType!=b.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.statusType=b.Opaque)}setTransparent(e=.3){this.statusType==b.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.statusType=b.Transparent)}setColor(t="#ffffff"){this.statusType==b.Opaque&&(console.log(BABYLON.Color4.FromHexString(t)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.instancedBuffers&&(e.instancedBuffers.color=BABYLON.Color4.FromHexString(t))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}play(){console.log(this.instance.getBoundingInfo().boundingBox.extendSizeWorld),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}toJson(){return{id:this.id,parentId:this.parentId,name:this.name,customNumber:this.customNumber,customType:this.customType,objectType:this.objectType}}getInto(){this.app.cameraController.flyTo(this.Sight)}goBack(){}}class E extends A{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.objectType=f.Floor,this.vectors=e.vectors,this.buckles=e.buckles,this.height=e.height}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(u.eover)||this.executes.find(u.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=BABYLON.MeshBuilder.CreatePolygon("地板",{shape:p.Expand(this.vectors,-.01),holes:this.buckles,sideOrientation:BABYLON.Mesh.DOUBLESIDE},this.app.scene),this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height-.01,this.instance.id=this.id,this.instance.name="地板";var e=this.app.resources.GetMaterial(this.baseModel).clone(this.id),t=this.instance.getBoundingInfo();this.Sight=p.getVisualAngle(t,this.app),this.baseModel.isTiling&&(e.diffuseTexture.uScale=(t.maximum.x-t.minimum.x)/this.baseModel.width,e.diffuseTexture.vScale=(t.maximum.z-t.minimum.z)/this.baseModel.length),this.instance.material=e,this.completed()}computeView(){this.Sight=new x;let e=this.instance.getBoundingInfo();var t=p.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=e.boundingBox.center.clone(),this.Sight.focus.y=this.instance.position.y,this.Sight.radius=5*e.boundingSphere.radius,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 A{loadProperties(e){this.id="墙_"+a.getGUID(12),this.objectType=f.Wall,this.parentId=e.parentId,this.name="墙体",this.customNumber=this.id,this.customType=this.objectType,this.walls=e.walls,this.height=e.height,this.baseModel=e.baseModel,this.baseModel&&!this.baseModel.length&&(this.baseModel.length=3.1)}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=se.Tools.MergeMeshes(this.walls,this.app),this.instance.setEnabled(!1),this.instance.receiveShadows=!0,this.baseModel?this.nativeMaterial=this.app.resources.GetMergeMaterial(this.baseModel):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.completed()}completed(){this.alwaysActive(),this.optimization(!0)}}class S{constructor(e){this.executes=new d,this.clickEvents=new d,this.touchtime=(new Date).getTime(),this.app=e}loadProperties(e){}bind(){}completed(){this.computeView()}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var r;e==u.leftClick||e==u.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(u.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(u.rightClick);i&&2==e.sourceEvent.button&&i(this,e),this.touchtime=(new Date).getTime()}),e=u.click):e==u.doubleClick?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger,e=>t(this,e)):e==u.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==u.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==u.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==u.leftClick||e==u.rightClick||e==u.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e=u.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}load(e,n){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))})})))}if(!e){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 v(this.app);e.loadProperties({parentId:this.id,height:this.position.y,corners:t}),e.bind()?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)}),r.height=this.position.y;let t=new E(this.app);t.loadProperties(r),t.bind(),this.app.project.objectDatas.add(t.id,t)}}if(o=null,!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 r in o.map){var t=o.find(r);if(0<t.walls.length){let e=new M(this.app);e.loadProperties({baseModel:t.t,walls:t.walls,parentId:this.id,height:this.position.y}),e.bind(),this.app.project.objectDatas.add(e.id,e)}}}this.completed(),s=null}toJson(){return{id:this.id,parentId:this.parentId,name:this.name,customNumber:this.customNumber,customType:this.customType,objectType:this.objectType,index:this.index,layerHeight:this.layerHeight,layerName:this.layerName}}computeView(){var i,r;let n=this.app.project.getChildsById(this.id,!0);0<n.length&&(i=r=n[0].instance.position.clone());for(let e=0;e<n.length;e++){let t=n[e];if(t.objectType!=f.Storey&&t.objectType!=f.Campus){let e=t.instance.getBoundingInfo();i=BABYLON.Vector3.Minimize(i,e.minimum.add(t.instance.position)),r=BABYLON.Vector3.Maximize(r,e.maximum.add(t.instance.position))}}i&&r||(i=BABYLON.Vector3.Zero(),r=new BABYLON.Vector3(12,0,8)),this.Sight=new x;var e=p.getVisualAngle(new BABYLON.BoundingInfo(i,r),this.app);this.Sight.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}getInto(){for(var t in this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.app.project.objectDatas.map){let e=this.app.project.objectDatas.find(t);e.setEnabled(e.parentId==this.id)}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}goBack(){}}class C extends A{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.height=e.baseModel.height,this.objectType=f.Door,this.rotation=p.ToVector3(e.rotation),this.position=p.ToVector3(e.position)}setEnabled(e){if(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>e.dispose()),e){let t=new BABYLON.Mesh(this.id,this.app.scene),e=this.app.resources.resources.find(this.baseModel.modelId);e.meshes[0].getChildMeshes().forEach(e=>{e=e.createInstance(this.id);e.isPickable=!1,e.enablePointerMoveEvents=!1,e.parent=t}),t.rotation=p.ToVector3(this.rotation.clone()),t.position=p.ToVector3(this.position.clone()),this.instance.addChild(t),this.alwaysActive(),this.optimization(!0)}this.instance.setEnabled(e),this.isPickable=e,this.statusType=b.Opaque,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){var e=this.app.resources.resources.find(this.baseModel.modelId),e=p.computeBounds(e.meshes[0]);this.instance=this.app.resources.BOX.clone(this.id),this.instance.setBoundingInfo(e),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,e.maximum.y-e.minimum.y,e.maximum.z-e.minimum.z),this.instance.position=p.ToVector3(this.position.clone()),this.instance.position.y=(e.maximum.y-e.minimum.y)/2+this.position.y,this.instance.rotation=p.ToVector3(this.rotation.clone()),this.instance.setEnabled(!1),this.completed()}}class I extends A{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.height=e.baseModel.height,this.objectType=f.Window,this.rotation=p.ToVector3(e.rotation),this.position=p.ToVector3(e.position)}setEnabled(e){if(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>e.dispose()),e){let t=new BABYLON.Mesh(this.id,this.app.scene),e=this.app.resources.resources.find(this.baseModel.modelId);e.meshes[0].getChildMeshes().forEach(e=>{e=e.createInstance(this.id);e.isPickable=!1,e.enablePointerMoveEvents=!1,e.parent=t}),t.rotation=p.ToVector3(this.rotation.clone()),t.position=p.ToVector3(this.position.clone()),this.instance.addChild(t),this.alwaysActive(),this.optimization(!0)}this.instance.setEnabled(e),this.isPickable=e,this.statusType=b.Opaque,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){var e=this.app.resources.resources.find(this.baseModel.modelId),e=p.computeBounds(e.meshes[0]);this.instance=this.app.resources.BOX.clone(this.id),this.instance.setBoundingInfo(e),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,e.maximum.y-e.minimum.y,e.maximum.z-e.minimum.z),this.instance.position=p.ToVector3(this.position.clone()),this.instance.position.y=(e.maximum.y-e.minimum.y)/2+this.position.y,this.instance.rotation=p.ToVector3(this.rotation.clone()),this.instance.setEnabled(!1),this.completed()}}class B extends S{loadProperties(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.index=e.index,this.layerName=this.index<0?"B"+this.index:"F"+(this.index+1),this.layerHeight=e.layerHeight,this.objectType=e.objectType,this.customNumber=e.customNumber||e.id,this.customType=e.customType||this.objectType,this.position=p.ToVector3(e.position),this.rotation=p.ToVector3(e.rotation),this.scaling=p.ToVector3(e.scaling)}bind(){this.instance=BABYLON.MeshBuilder.CreateGround(this.id,{width:this.scaling.x,height:this.scaling.z},this.app.scene),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1;let e=new BABYLON.StandardMaterial("mat_"+this.id);e.diffuseColor=BABYLON.Color3.White(),e.alpha=0,e.backFaceCulling=!1,this.instance.material=e,this.instance.position=this.position,this.instance.position.y-=.01,this.instance.rotation=this.rotation.clone(),this.setEnabled(!1)}alwaysActive(){this.instance.getChildMeshes().forEach(e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0}),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}completed(){this.alwaysActive(),this.computeView()}computeView(){var i,r;let n=this.app.project.getChildsById(this.id);0<n.length&&(i=r=n[0].instance.position.clone());for(let e=0;e<n.length;e++){let t=n[e];if(t.objectType!=f.Storey&&t.objectType!=f.Campus&&t.objectType!=f.Wall&&t.objectType!=f.Corner){let e=t.instance.getBoundingInfo();i=BABYLON.Vector3.Minimize(i,e.minimum.add(t.instance.position)),r=BABYLON.Vector3.Maximize(r,e.maximum.add(t.instance.position))}}i&&r||(i=BABYLON.Vector3.Zero(),r=new BABYLON.Vector3(12,0,8)),this.Sight=p.getVisualAngle(new BABYLON.BoundingInfo(i,r),this.app)}}class z extends A{completed(){this.alwaysActive(),this.optimization(!0),this.computeView()}computeView(){var e=this.app.resources.resources.find(this.baseModel.modelId);this.instance.setBoundingInfo(p.computeBounds(e.meshes[0])),this.Sight=new x;var t=this.instance.getBoundingInfo(),e=p.getVisualAngle(t,this.app);this.Sight.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=this.position.clone(),this.Sight.radius=2*t.boundingSphere.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=3*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}getInto(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let n=new d,e=this.app.project.getChildsById(this.id);e.forEach(i=>{var r=this.app.project.getChildsById(i.id);for(let t=0;t<r.length;t++){let e=r[t];(e instanceof M||e instanceof C||e instanceof v||e instanceof I||e instanceof E)&&n.add(e.id,e.id),e instanceof M&&i instanceof B&&(e.addEventListener(u.leftClick,()=>{this.app.project.switchLevel(i.id)}),e.addEventListener(u.eover,()=>{this.app.toolTips.text=i.layerName}),e.addEventListener(u.out,()=>{this.app.toolTips.text=""}))}n.add(i.id,i.id)});for(const i in this.app.project.objectDatas.map){let e=this.app.project.objectDatas.find(i);n.find(e.id)||e.parentId==this.parentId?e.setEnabled(!0):e.setEnabled(!1)}this.setEnabled(!1);var t=this.app.project.getChildsById(this.parentId);for(let e=0;e<t.length;e++){const r=t[e];r instanceof z&&r.id!=this.id&&(r.isPickable=!1,this.app.resources.setTransparentById(r.baseModel.modelId,.3))}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}goBack(){var t=this.app.project.getChildsById(this.parentId);for(let e=0;e<t.length;e++){const i=t[e];i instanceof z&&i.id!=this.id&&(i.isPickable=!0,this.app.resources.setTransparentById(i.baseModel.modelId,1))}this.app.toolTips.text="";let e=this.app.project.getChildsById(this.id);e.forEach(e=>{var i=this.app.project.getChildsById(e.id);for(let t=0;t<i.length;t++){let e=i[t];e instanceof M&&(e.removeEventListener(u.leftClick),e.removeEventListener(u.eover),e.removeEventListener(u.out))}})}}class k{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,r)=>{for(const t in this.objectDatas.map){let i=this.objectDatas.find(t);if(i.parentId==e){let t=!1;for(let e=0;e<n.length;e++)i.customType!=n[e]||(t=!0);t||(r.push({...i.toJson(),children:[]}),o(i.id,r[r.length-1].children))}}};let t=this.objectDatas.find(e);if(t){e={...t.toJson(),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=[],n=this.current.id;this.current instanceof S||!this.current.parentId||(n=this.current.parentId);for(const o in this.objectDatas.map){let e=this.objectDatas.find(o);e.customType==t&&(i.isCurrent&&e.parentId!=n||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.Storey&&t.objectType!=f.Campus){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(e=this.root.id,t=!0){e=e||this.root.id;let i=this.objectDatas.find(e);if(i){if(this.current&&this.current.goBack(),!(i instanceof S||i instanceof z)){let e=this.objectDatas.find(i.parentId);this.current instanceof S||this.current instanceof z?i.parentId!=this.current.id&&e.getInto():i.parentId!=this.current.parentId&&e.getInto()}i.getInto(),this.current=i,this.levelEvent&&this.levelEvent(this.current),t&&(i instanceof S||i instanceof z)&&this.app.cameraController.perspective(i.Sight)}else console.error("层级不存在")}goBack(){this.app.isDefaultMutual&&(this.current?this.current.parentId?(this.current.goBack&&this.current.goBack(),this.switchLevel(this.current.parentId)):console.error("已经是最顶层级!"):console.error("层级有误、未知错误!"))}getTypes(e=null){let t=[],i=new d;for(var r in this.objectDatas.map){r=this.objectDatas.find(r);e&&r.parentId!=e||i.find(r.objectType)||i.add(r.objectType,r.objectType)}for(var n in i.map)t.push(n);return t}getCustomTypes(e=null){let t=[],i=new d;for(var r in this.objectDatas.map){r=this.objectDatas.find(r);e&&r.parentId!=e||i.find(r.customType)||i.add(r.customType,r.customType)}for(var n in i.map)t.push(n);return t}}class P{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(se.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(se.rl+"resources/fogtex.png",this.app.scene,!0,!1)}async loadModelMesh(i){let e=this.resources.find(i.modelId);if(!e)try{e=await BABYLON.SceneLoader.LoadAssetContainerAsync(se.rl+"bundle/"+i.modelId+"/",i.modelId+i.extension,this.app.scene),0<e.animationGroups.length&&e.animationGroups[0].stop(),e.addAllToScene(),e.meshes[0].setEnabled(!1),e.meshes[0].getChildMeshes().forEach(t=>{if(t.metadata&&t.metadata.gltf&&t.metadata.gltf.extras){if(t.metadata.gltf.extras.LightMapName){let e=this.LoadLightMap(i.modelId,t.metadata.gltf.extras.LightMapName);e.coordinatesIndex=1,e.level=2,t.material.lightmapTexture=e,t.material.useLightmapAsShadowmap=!0}e.isExtras=!0,t.metadata.gltf.extras.U&&BABYLON.Animation.CreateAndStartAnimation("u",t.material.albedoTexture,"uOffset",30*t.metadata.gltf.extras.Uspeed,30,0,1,1),t.metadata.gltf.extras.V&&BABYLON.Animation.CreateAndStartAnimation("v",t.material.albedoTexture,"vOffset",30*t.metadata.gltf.extras.Vspeed,30,0,1,1)}}),e.isExtras||e.meshes[0].getChildMeshes().forEach(e=>{e.registerInstancedBuffer("color",4),e.instancedBuffers.color=new BABYLON.Color4(1,1,1,1)}),this.resources.add(i.modelId,e)}catch(e){console.error("模型下载失败!模型编号:"+i.modelId+";错误信息:"+e)}return e}loadModelMeshAsync(t,i){var e=this.resources.find(t.modelId);e?i(e):BABYLON.SceneLoader.LoadAssetContainerAsync(se.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){let t=this.Materials.find(e.modelId);var i;return void 0===t&&(i=this.GetTexture(e),t=new BABYLON.StandardMaterial(e.modelId,this.app.scene),t.alphaMode=BABYLON.Engine.ALPHA_COMBINE,t.diffuseTexture=i,this.Materials.add(e.modelId,t)),t}GetTexture(e){let t=this.Textures.find(e.modelId);return void 0===t&&(t=new BABYLON.Texture(se.rl+"texture/"+e.modelId+e.extension,this.app.scene,!1),".png"==e.extension&&(t.hasAlpha=!0),this.Textures.add(e.modelId,t)),t}LoadLightMap(e,t){let i=this.Textures.find(e+t);return void 0===i&&(i=new BABYLON.Texture(se.rl+"bundle/"+e+"/"+t,this.app.scene,!1,!1),this.Textures.add(e+t,i)),i}GetMergeMaterial(t){let i=this.MergeMaterials.find(t.modelId);if(void 0===i){i=new BABYLON.CustomMaterial(t.modelId,this.app.scene),i.alphaMode=2,this.MergeMaterials.add(t.modelId,i),i.AddUniform("textureData","sampler2D",null),i.Vertex_Definitions(`
|
|
6
|
-
varying vec3 localPos ;
|
|
7
|
-
varying vec3 localNrm ;
|
|
8
|
-
`),i.Fragment_Definitions(`
|
|
9
|
-
varying vec3 localPos ;
|
|
10
|
-
varying vec3 localNrm ;`),i.Vertex_Before_PositionUpdated(`
|
|
11
|
-
localPos = position.xyz;
|
|
12
|
-
localNrm = normal;
|
|
13
|
-
`);let e=this.GetTexture(t);".png"==t.extension&&(e.hasAlpha=!0,i.alpha=.9),t.length||(t.length=3.1),t.width||(t.width=1.6),i.onBindObservable.add(()=>i.getEffect().setTexture("textureData",e)),i.Fragment_Custom_Diffuse(`
|
|
14
|
-
vec3 newUV = vec3(abs(localPos.x)/`+t.width+",abs(localPos.y)/"+t.length+",abs(localPos.z)/"+t.width+`);
|
|
15
|
-
if(abs(localNrm.z)>abs(localNrm.x)){
|
|
16
|
-
vec4 res = texture2D(textureData,newUV.xy);
|
|
17
|
-
diffuseColor = res.rgb;
|
|
18
|
-
alpha = res.a;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
vec4 res = texture2D(textureData,newUV.zy);
|
|
22
|
-
diffuseColor = res.rgb;
|
|
23
|
-
alpha = res.a;
|
|
24
|
-
}
|
|
25
|
-
`),i.freeze()}return i}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();for(const i in this.Textures.map)this.Textures.find(i).dispose(),this.Textures.remove(i);this.Textures.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])}}setTransparent(t=1){for(const i in this.resources.map){let e=this.resources.find(i);e.meshes.forEach(e=>e.visibility=t)}}setTransparentById(e,t=1){let i=this.resources.find(e);i&&i.meshes.forEach(e=>e.visibility=t)}}t=i(29);const L=i.n(t).a.create();L.defaults.headers.post["Content-Type"]="application/json",L.interceptors.request.use(e=>{var t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e},e=>Promise.reject(e)),L.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 D=L,t=i(4),R=i.n(t);class O extends A{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.objectType=f.LeakWater,this.lines=p.ToARRVector3(e.lines)}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(u.eover)||this.executes.find(u.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=p.createTube(this.id,this.lines,.02,this.app),this.instance.setEnabled(!1);var e=this.app.resources.GetMaterial(this.baseModel).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.completed()}completed(){this.alwaysActive(),this.computeView()}computeView(){this.Sight=new x;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==u.leftClick||e==u.rightClick||e==u.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(u.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(u.rightClick);i&&2==e.sourceEvent.button&&i(this,e);let r=this.clickEvents.find(u.doubleClick);r&&0==e.sourceEvent.button&&(new Date).getTime()-this.touchtime<500&&r(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==u.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==u.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==u.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==u.leftClick||e==u.rightClick||e==u.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 F extends A{loadProperties(e){this.id=e.id,this.customNumber=e.customNumber,this.parentId=e.parentId,this.name=e.name,this.radius=e.radius,this.pints=p.ToARRVector3(e.pints),this.objectType=e.objectType,this.customType=e.customType,this.position=p.ToVector3(e.position),this.rotation=p.ToVector3(e.rotation),this.color=e.color,this.alpha=e.alpha}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(u.eover)||this.executes.find(u.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=new BABYLON.Mesh(this.id);let e=p.createTube(this.id,this.pints,this.radius,this.app);this.instance.position=e.getBoundingInfo().boundingBox.center.clone(),this.instance.addChild(e),this.instance.rotation=this.rotation.clone(),this.instance.position=this.position.clone(),e.setParent(this.instance.parent),this.instance.dispose(),this.instance=e;let t=new BABYLON.StandardMaterial("mat_"+this.id,this.app.scene);t.diffuseColor=BABYLON.Color3.FromHexString(this.color),t.alpha=this.alpha,this.instance.material=t,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.setEnabled(!1),this.completed()}setColor(e="#fff"){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),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 x;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.statusType==b.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.emissiveColor=T.colors[e],this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.statusType=b.Flash)}setOpaque(){this.statusType!=b.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.statusType=b.Opaque)}setTransparent(e=.3){this.statusType==b.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.alpha=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.statusType=b.Transparent)}}class N extends A{constructor(){super(...arguments),this.tconfig={color:"",position:null,rotation:null,scaling:null,clearColor:""},this.isLookAt=!1}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(u.eover)||this.executes.find(u.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}loadProperties(e){var t,i;this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=f.UI3D,this.isLookAt=e.isLookAt,this.tconfig.color=e.color,e.size?(this.tconfig.clearColor=null,this.tconfig.position=se.Tools.ToVector3(e.position),i=se.Tools.ToVector3(e.rotation),this.tconfig.rotation=new BABYLON.Vector3(i.x+Math.PI,i.y,i.z),t=Number.parseInt(e.size.replace("px",""))/40,i=e.scaling?se.Tools.ToVector3(e.scaling):BABYLON.Vector3.One(),this.tconfig.scaling=new BABYLON.Vector3(14*t/50*i.x,1,14*t/50*i.z)):(this.tconfig.clearColor=e.clearColor,this.tconfig.position=se.Tools.ToVector3(e.position),this.tconfig.rotation=se.Tools.ToVector3(e.rotation),this.tconfig.scaling=se.Tools.ToVector3(e.scaling))}bind(){var e="bold 100px Arial";let t=new BABYLON.DynamicTexture(this.id,64,this.app.scene,!1);var i=t.getContext();i.font=e;var r=i.measureText(this.name).width+8,i=.02*r;t=new BABYLON.DynamicTexture(this.id,{width:r,height:150},this.app.scene,!1);r=new BABYLON.StandardMaterial(this.id,this.app.scene);r.backFaceCulling=!1,r.diffuseTexture=t,this.tconfig.clearColor||(t.hasAlpha=!0),t.drawText(this.name,null,null,e,this.tconfig.color,this.tconfig.clearColor,!1),this.instance=BABYLON.Mesh.CreateGround(this.id,i,3,1,this.app.scene),this.instance.setEnabled(!1),this.instance.scaling=this.tconfig.scaling,this.instance.position=this.tconfig.position,this.instance.rotation=this.tconfig.rotation,this.instance.material=r,this.isLookAt&&(this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y),this.alwaysActive(),this.computeView()}}class U extends A{loadProperties(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,this.virtualType=e.virtualType,this.color=BABYLON.Color3.FromHexString(e.color),this.alpha=e.alpha,this.isEdges=e.isEdges,this.edgesWidth=e.edgesWidth,this.edgesColor=BABYLON.Color3.FromHexString(e.edgesColor).toColor4(1),this.rotation=se.Tools.ToVector3(e.rotation),this.position=se.Tools.ToVector3(e.position),this.scaling=se.Tools.ToVector3(e.scaling)}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(u.eover)||this.executes.find(u.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){"Cylinder"==this.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 e=new BABYLON.StandardMaterial(this.id,this.app.scene);e.diffuseColor=this.color,this.alpha<.98&&(e.alpha=this.alpha,e.alphaMode=2,e.useAlphaFromDiffuseTexture=!0),this.instance.material=e,this.isEdges&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=1,this.instance.edgesColor=new BABYLON.Color4(0,1,1,1)),this.edgesWidth&&0<this.edgesWidth&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=this.edgesWidth,this.instance.edgesColor=this.edgesColor),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.rotation=this.rotation.clone(),this.instance.position=this.position.clone(),this.instance.scaling=this.scaling.clone(),this.completed()}}class V extends S{addEventListener(e,t){}removeEventListener(e){}setEnabled(e){this.instance.setEnabled(e)}loadProperties(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.index=e.index,this.layerName=this.index<0?"B"+this.index:"F"+(this.index+1),this.layerHeight=e.layerHeight,this.objectType=e.objectType,this.customNumber=e.customNumber||e.id,this.customType=e.customType||this.objectType,this.position=p.ToVector3(e.position),this.rotation=p.ToVector3(e.rotation)}bind(){this.instance=new BABYLON.Mesh(this.id,this.app.scene),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.position=this.position,this.instance.position.y-=.01,this.instance.rotation=this.rotation.clone(),this.setEnabled(!1)}}class j{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 G{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 Y{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 Z{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 q=i(12);class ${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 W{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}}var X,t=i(9),H=i.n(t);class K{constructor(e,t="540E5CBA3D09480F8CDE2F69C55934EF",i=[117.28688541016095,39.094144209740534],r=Math.PI){this.type="custom",this.renderingMode="3d",this.drones={x:39.094144209740534,y:117.28688541016095,z:0},this.rotation=Math.PI,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(),this.recalculateProjectionMatrix(this.initialCoordinates),BABYLON.SceneLoader.LoadAssetContainerAsync(se.rl+"bundle/"+this.modelsId+"/",this.modelsId+".gltf",this.scene).then(e=>{e.addAllToScene();const t=e.meshes[0];e=H.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,this.rotation,0),t.getChildMeshes().forEach(e=>{-1!=e.id.indexOf("B_")&&(console.log(e.id),e.setEnabled(!1))})})},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,this.rotation=r}recalculateProjectionMatrix(e){var t=[Math.PI/2,0,0];const i=H.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 J{static rand(e,t){return Math.floor(Math.random()*(t-e+1)+e)}static init(){J.canvasThunder=document.getElementById("canvasThunder"),J.canvasCloud=document.getElementById("canvasCloud"),J.canvasRain=document.getElementById("canvasRain"),J.canvasThunder&&J.canvasThunder.getContext||console.error("找不到下雨的画布!"),J.canvasThunderCtx=J.canvasThunder.getContext("2d"),J.canvasCloudCtx=J.canvasCloud.getContext("2d"),J.canvasRainCtx=J.canvasRain.getContext("2d"),J.X=J.canvasThunder.width=J.canvasRain.width=J.canvasCloud.width=window.innerWidth,J.Y=J.canvasThunder.height=J.canvasRain.height=J.canvasCloud.height=window.innerHeight,console.log(J.Y),window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,17)};function e(e,t,i,r){this.ctx=e,this.init(t,i,r)}e.prototype.init=function(e,t,i){this.x=e,this.y=t,this.r=i,this.l=J.rand(J.Y,3*J.Y),this.c="rgb(201, 162, 198)"},e.prototype.draw=function(){var e=this.ctx;e.beginPath(),e.lineWidth=this.r,e.strokeStyle=this.c,e.moveTo(this.x,this.y),this.x+=J.rand(-10,10),this.y+=J.rand(10,15),e.lineTo(this.x,this.y),e.stroke()},e.prototype.updateParams=function(){this.y>this.l&&this.init(J.rand(0,J.X),J.rand(0,J.Y/3),J.rand(1,5))},e.prototype.render=function(){this.updateParams(),this.draw()};for(var t=0;t<10;t++){var i=new e(J.canvasThunderCtx,J.rand(0,J.X),J.rand(0,J.Y/3),J.rand(1,5));J.thunders.push(i)}function r(e,t,i,r){this.ctx=e,this.init(t,i,r)}r.prototype.init=function(e,t,i){this.x=e,this.y=t,this.r=i,this.c="rgb(179, 203, 255)",this.v={y:10}},r.prototype.draw=function(){var e=this.ctx;e.beginPath(),e.fillStyle=this.c,e.arc(this.x,this.y,this.r,0,2*Math.PI,!1),e.fill()},r.prototype.updatePosition=function(){this.y+=this.v.y},r.prototype.wrapPosition=function(){this.y>J.Y&&(this.y=0)},r.prototype.resize=function(){this.x=J.rand(0,J.X),this.y=J.rand(0,J.Y)},r.prototype.render=function(){this.updatePosition(),this.wrapPosition(),this.draw()};for(t=0;t<100;t++){var n=new r(J.canvasRainCtx,J.rand(0,J.X),J.rand(0,J.Y),1);J.rains.push(n)}function o(e,t,i){this.ctx=e,this.init(t,i)}o.prototype.init=function(e,t){this.x=e,this.y=t,this.c="rgb(201, 162, 198)",this.r=J.rand(100,200),this.v={x:.5,y:0},this.color={r:0,g:0,b:0,a:1}},o.prototype.wrapPosition=function(){this.x-this.r>J.X&&(this.x=0-this.r)},o.prototype.updatePosition=function(){this.x+=this.v.x},o.prototype.resize=function(){this.x=J.rand(-100,J.X+100),this.y=J.rand(0,J.Y/2)},o.prototype.render=function(){this.updatePosition(),this.wrapPosition(),this.draw()},o.prototype.gradient=function(){var e=this.color.r+","+this.color.g+","+this.color.b,t=this.ctx.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r);return t.addColorStop(0,"rgba("+e+", "+ +this.color.a+")"),t.addColorStop(.5,"rgba("+e+", "+.5*this.color.a+")"),t.addColorStop(1,"rgba("+e+", "+0*this.color.a+")"),t},o.prototype.draw=function(){var e=this.ctx;e.save(),e.scale(2,1),e.beginPath(),e.globalAlpha=.2,e.fillStyle=this.gradient(),e.arc(this.x,this.y,this.r,2*Math.PI,!1),e.fill(),e.scale(.5,1),e.restore()};for(t=0;t<50;t++){var s=new o(J.canvasCloudCtx,J.rand(-100,J.X+100),J.rand(0,J.Y/2));J.clouds.push(s)}J.render(),window.addEventListener("resize",function(){J.onResize()})}static onResize(){J.X=J.canvasThunder.width=J.canvasRain.width=J.canvasCloud.width=window.innerWidth,J.Y=J.canvasThunder.height=J.canvasRain.height=J.canvasCloud.height=window.innerHeight;for(var e=0;e<J.rains.length;e++)J.rains[e].resize()}static clearCanvasThunder(){J.canvasThunderCtx.globalCompositeOperation="darken",J.canvasThunderCtx.globalAlpha=.01,J.canvasThunderCtx.fillStyle="rgb(19, 16, 65)",J.canvasThunderCtx.fillRect(0,0,J.X,J.Y),J.canvasThunderCtx.globalCompositeOperation="source-over",J.canvasThunderCtx.globalAlpha=1,Math.random()<.02&&(J.canvasThunderCtx.fillStyle="rgb(128, 128, 128)",J.canvasThunderCtx.fillRect(0,0,J.X,J.Y))}static clearCanvasRain(){J.canvasRainCtx.clearRect(0,0,J.X,J.Y)}static clearCanvasCloud(){J.canvasCloudCtx.clearRect(0,0,J.X,J.Y)}static render(){J.clearCanvasThunder(),J.clearCanvasCloud(),J.clearCanvasRain();for(var e=0;e<J.thunders.length;e++)J.thunders[e].render();for(e=0;e<J.clouds.length;e++)J.clouds[e].render();for(e=0;e<J.rains.length;e++)J.rains[e].render();requestAnimationFrame(J.render)}static stop(){J.canvasCloud.style.display="none",J.canvasRain.style.display="none",J.canvasThunder.style.display="none"}static start(){J.canvasCloud.style.display="",J.canvasRain.style.display="",J.canvasThunder.style.display=""}}J.thunders=[],J.clouds=[],J.rains=[];class Q{constructor(e){this.thunderNum=20,this.thunders=new Array,this.app=e}start(){this.canvas=document.createElement("canvas"),this.canvas.id="thunderEffect",this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;outline-width: 0;-webkit-tap-highlight-color:transparent;z-index: 0;background: #000F1E;pointer-events: none;",this.app.canvas.parentElement.appendChild(this.canvas),this.canvasThunderCtx=this.canvas.getContext("2d"),this.X=this.canvas.width=window.innerWidth,this.Y=this.canvas.height=window.innerHeight,this.app.environment.setTransparent(.5);for(var e=0;e<this.thunderNum;e++){var t=new ee(this.canvasThunderCtx,p.rand(0,this.X),p.rand(0,this.Y/3),p.rand(1,5),this.X,this.Y);this.thunders.push(t)}this.render()}close(){this.app.canvas.parentElement.removeChild(this.canvas),this.app.environment.setTransparent(1)}render(){this.clearCanvasThunder();for(var e=0;e<this.thunders.length;e++)this.thunders[e].render();window.requestAnimationFrame(()=>{this.render()})}clearCanvasThunder(){this.canvasThunderCtx.globalCompositeOperation="darken",this.canvasThunderCtx.globalAlpha=.01,this.canvasThunderCtx.fillStyle="rgb(19, 16, 65)",this.canvasThunderCtx.fillRect(0,0,this.X,this.Y),this.canvasThunderCtx.globalCompositeOperation="source-over",this.canvasThunderCtx.globalAlpha=1,Math.random()<.02&&(this.canvasThunderCtx.fillStyle="rgb(128, 128, 128)",this.canvasThunderCtx.fillRect(0,0,this.X,this.Y))}}class ee{constructor(e,t,i,r,n,o){this.ctx=e,this.X=n,this.Y=o,this.init(t,i,r)}init(e,t,i){this.x=e,this.y=t,this.r=i,this.l=p.rand(this.Y,3*this.Y),this.c="rgb(201, 162, 198)"}draw(){this.ctx.beginPath(),this.ctx.lineWidth=this.r,this.ctx.strokeStyle=this.c,this.ctx.moveTo(this.x,this.y),this.x+=p.rand(-10,10),this.y+=p.rand(10,15),this.ctx.lineTo(this.x,this.y),this.ctx.stroke()}updateParams(){this.y>this.l&&this.init(p.rand(0,this.X),p.rand(0,this.Y/3),p.rand(1,5))}render(){this.updateParams(),this.draw()}}class te{constructor(e){this.rainNum=1e3,this.rains=new Array,this.app=e}start(){this.canvas=document.createElement("canvas"),this.canvas.id="RainEffect",this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;outline-width: 0;-webkit-tap-highlight-color:transparent; z-index: 2;pointer-events: none;",this.app.canvas.parentElement.appendChild(this.canvas),this.canvasRainCtx=this.canvas.getContext("2d"),this.X=this.canvas.width=window.innerWidth,this.Y=this.canvas.height=window.innerHeight;for(var e=0;e<this.rainNum;e++){var t=new ie(this.canvasRainCtx,p.rand(0,this.X),p.rand(0,this.Y),1,this.Y);this.rains.push(t)}this.render()}close(){this.app.canvas.parentElement.removeChild(this.canvas)}render(){this.clearCanvasRain();for(var e=0;e<this.rains.length;e++)this.rains[e].render();window.requestAnimationFrame(()=>{this.render()})}clearCanvasRain(){this.canvasRainCtx.clearRect(0,0,this.X,this.Y)}}class ie{constructor(e,t,i,r,n){this.rainSpeed=10,this.ctx=e,this.Y=n,this.init(t,i,r)}init(e,t,i){this.x=e,this.y=t,this.r=i,this.c="rgb(179, 203, 255)",this.v={y:this.rainSpeed}}draw(){var e=this.ctx;e.beginPath(),e.fillStyle=this.c,e.arc(this.x,this.y,this.r,0,2*Math.PI,!1),e.fill()}updatePosition(){this.y+=this.v.y}wrapPosition(){this.y>this.Y&&(this.y=0)}render(){this.updatePosition(),this.wrapPosition(),this.draw()}}class re{constructor(e){this.cloudNum=50,this.clouds=new Array,this.app=e}start(){this.canvas=document.createElement("canvas"),this.canvas.id="CloudEffect",this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;outline-width: 0;-webkit-tap-highlight-color:transparent; z-index: 1;pointer-events: none;",this.app.canvas.parentElement.appendChild(this.canvas),this.canvasCloudCtx=this.canvas.getContext("2d"),this.X=this.canvas.width=window.innerWidth,this.Y=this.canvas.height=window.innerHeight;for(var e=0;e<this.cloudNum;e++){var t=new ne(this.canvasCloudCtx,p.rand(-100,this.X+100),p.rand(0,this.Y/2),this.X);this.clouds.push(t)}this.render()}close(){this.app.canvas.parentElement.removeChild(this.canvas)}render(){this.clearCanvasCloud();for(var e=0;e<this.clouds.length;e++)this.clouds[e].render();window.requestAnimationFrame(()=>{this.render()})}clearCanvasCloud(){this.canvasCloudCtx.clearRect(0,0,this.X,this.Y)}}class ne{constructor(e,t,i,r){this.rainSpeed=10,this.ctx=e,this.X=r,this.init(t,i)}init(e,t){this.x=e,this.y=t,this.c="rgb(201, 162, 198)",this.r=p.rand(100,200),this.v={x:.5,y:0},this.color={r:0,g:0,b:0,a:1}}draw(){this.ctx.save(),this.ctx.scale(2,1),this.ctx.beginPath(),this.ctx.globalAlpha=.2,this.ctx.fillStyle=this.gradient(),this.ctx.arc(this.x,this.y,this.r,2*Math.PI,0,!1),this.ctx.fill(),this.ctx.scale(.5,1),this.ctx.restore()}gradient(){var e=this.color.r+","+this.color.g+","+this.color.b,t=this.ctx.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r);return t.addColorStop(0,"rgba("+e+", "+ +this.color.a+")"),t.addColorStop(.5,"rgba("+e+", "+.5*this.color.a+")"),t.addColorStop(1,"rgba("+e+", "+0*this.color.a+")"),t}updatePosition(){this.x+=this.v.x}wrapPosition(){this.x-this.r>this.X&&(this.x=0-this.r)}render(){this.updatePosition(),this.wrapPosition(),this.draw()}}(t=X=X||{}).Thunder="Thunder",t.Rain="Rain",t.Cloud="Cloud";class oe{static add(e,t){switch(e){case X.Thunder:{let e=new Q(t);e.start(),this.effects.add(X.Thunder,e)}break;case X.Rain:{let e=new te(t);e.start(),this.effects.add(X.Rain,e)}break;case X.Cloud:{let e=new re(t);e.start(),this.effects.add(X.Cloud,e)}}}static remove(e){let t=this.effects.find(e);t&&t.close(),this.effects.remove(e)}}oe.effects=new d;class se{}se.sl="https://www.wodashijie.com/",se.rl="https://models.wodashijie.com/",se.App=class{constructor(e){this.isDefaultMutual=!1,e.sl&&(se.sl=e.sl),e.rl&&(se.rl=e.rl),D.defaults.baseURL=se.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;z-index: 2;",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.gl=new BABYLON.GlowLayer("glow2",this.scene),this.container=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.toolTips=new g(this),this.environment=new y(this),this.environment.defaultLights(),this.environment.openAllLight(),this.resources=new P(this),this.project=new k(this);e=new BABYLON.UtilityLayerRenderer(this.scene);this.positionGizmo=new BABYLON.PositionGizmo(e),se.AlarmFlashing.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(p){p.pk=null==p.pk?"project":p.pk,p.isDefaultLevel=null==p.isDefaultLevel||p.isDefaultLevel,p.isDefaultMutual=null==p.isDefaultMutual||p.isDefaultMutual,se.pk=p.pk;var e=await D.get(`api/service/GetToken?accessToken=${se.accessToken}`);if(200==e.status){localStorage.setItem("mx3d-token",e.data);e=await D.get("api/service");if(200==e.status){localStorage.setItem("mx3d-long",e.data);e=await D.get(`api/service/${se.pk}`);if(200==e.status){let u=JSON.parse(class{static de(e){let t=localStorage.getItem("mx3d-long");var i=R.a.enc.Utf8.parse(t.substring(0,32)),r=R.a.enc.Utf8.parse(t.substring(32,48)),e=R.a.enc.Hex.parse(e),e=R.a.enc.Base64.stringify(e);return R.a.AES.decrypt(e,i,{iv:r,mode:R.a.mode.CBC,padding:R.a.pad.Pkcs7}).toString(R.a.enc.Utf8).toString()}}.de(e.data));return new Promise(async(e,t)=>{try{console.log((new Date).toLocaleString()),this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let r=new d,n=!1;if(u.modelLists){for(let e=0;e<u.modelLists.length;e++)r.add(u.modelLists[e].modelId,u.modelLists[e]);n=!0}let o=new d;for(let i=0;i<u.objectDatas.length;i++){let e=u.objectDatas[i],t;e.baseModel&&n&&(e.baseModel=r.find(e.baseModel)),e.baseModel&&!r.find(e.baseModel.modelId)&&r.add(e.baseModel.modelId,e.baseModel),e.objectType!=f.Corner&&e.objectType!=f.Floor&&(e.objectType!=f.Wall?(e.objectType==f.Window?t=new I(this):e.objectType==f.Door?t=new C(this):e.objectType==f.Campus?(t=new V(this),o.add(e.id,new Array)):e.objectType==f.Storey?(t=new B(this),o.add(e.id,new Array)):t=new(e.objectType==f.LeakWater?O:e.objectType==f.Conduit?F:e.objectType==f.UI3D?N:e.objectType==f.VirtualBox?U:e.objectType==f.Building?z:A)(this),t.loadProperties(e),this.project.objectDatas.add(t.id,t)):(e.leftMap&&n&&(e.leftMap=r.find(e.leftMap)),e.rightMap&&n&&(e.rightMap=r.find(e.rightMap))))}for(let e=0;e<u.objectDatas.length;e++){var s=u.objectDatas[e];if(s.objectType==f.Corner||s.objectType==f.Wall||s.objectType==f.Floor){let e=o.find(s.parentId);e.push(s)}}let t=0,i=r.count();for(const l in r.map){var a=r.find(l);".gltf"!=a.extension&&".glb"!=a.extension||await this.resources.loadModelMesh(a),t++,p&&p.progress&&p.progress(t/i*.3)}t=0,r=null,i=this.project.objectDatas.count();for(const c in this.project.objectDatas.map){let e=this.project.objectDatas.find(c);await e.bind(),t++,p&&p.progress&&p.progress(.3+t/i*.5)}t=0,i=o.count();for(const h in o.map){t++,p&&p.progress&&p.progress(.8+t/i*.2);let e=this.project.objectDatas.find(h);e&&e instanceof S?e.load(!1,o.find(h)):console.error("出现错误,场景不存在或未创建成功",h,e)}this.project.root=this.project.objectDatas.find(u.id),this.project.optimization(),p.isDefaultMutual&&(this.defaultMutual=!0),p.isDefaultLevel&&this.project.switchLevel(null,!0),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,console.log((new Date).toLocaleString()),e(null),this.engine.resize(),p&&p.complete&&p.complete()}catch(e){t(e)}})}}}}set defaultMutual(e){for(var t in this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.isDefaultMutual=e,this.project.objectDatas.map){let e=this.project.objectDatas.find(t);e instanceof z&&(this.project.getChildsById(e.id).length<1||(this.isDefaultMutual?e.addEventListener(u.leftClick,()=>this.project.switchLevel(e.id)):e.removeEventListener(u.leftClick)))}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.environment.hideFps(),this.project.clear(),this.resources.delete(),this.engine.dispose()}createYUAN(e,t,i){this.claerbox(),console.log("外圈:",e),console.log("内圈:",t),console.log("长度:",i);e=p.ToARRVector3(JSON.parse(e));let r=[];t&&(t=p.ToARRVector3(JSON.parse(t)),r.push(t)),this.box11=BABYLON.MeshBuilder.ExtrudePolygon("yuan",{shape:e,holes:r,depth:i,sideOrientation:2},this.scene),this.positionGizmo&&(this.positionGizmo.attachedMesh=this.box11)}claerbox(){this.box11&&(this.box11.dispose(),this.box11=null)}perspective(){if(this.box11){var t=this.box11.getBoundingInfo(),i=p.getVisualAngle(t,this);let e=new x;e.alpha=i.alpha,e.beta=i.beta,e.focus=t.boundingSphere.center,e.radius=3*t.boundingSphere.radius,e.minimumLimit=.3,e.maximumLimit=2*e.radius,e.minBeta=.01,e.maxBeta=Math.PI/2*.98,this.cameraController.perspective(e)}}orthographic1(){if(this.box11){var t=this.box11.getBoundingInfo(),i=p.getVisualAngle(t,this);let e=new x;e.alpha=i.alpha,e.beta=i.beta,e.focus=t.boundingSphere.center,e.radius=3*t.boundingSphere.radius,e.minimumLimit=.3,e.maximumLimit=2*e.radius,e.minBeta=.01,e.maxBeta=Math.PI/2*.98,this.cameraController.orthographic1(e)}}},se.Earth=class{constructor(e,t=[117.28688541016095,39.094144209740534]){this.initialCoordinates=[117.28688541016095,39.094144209740534],this.initialCoordinates=t,H.a.accessToken="pk.eyJ1IjoibGl1ayIsImEiOiJjanczNmJoZjkwY3IxM3lxcTd1NmMwZWxjIn0.11SpcY8De0c1q6S3a-2Qcg",this.map=new H.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,i=Math.PI){i=new K("babylon-layer",e,t,i);this.map.addLayer(i)}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})}},se.Tools=p,se.AlarmFlashing=T,se.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 G(e,o,i,r,n,t.app.scene)}static createIcon(e,t,i,r){let n;t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,n=new j(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}},se.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 Z(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=q.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(se.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 Z(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=q.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 Z(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=q.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
|
-
precision highp float;
|
|
27
|
-
in vec3 position;
|
|
28
|
-
in vec4 color;
|
|
29
|
-
in float angle;
|
|
30
|
-
in vec2 size;
|
|
31
|
-
in vec2 offset;
|
|
32
|
-
uniform mat4 view;
|
|
33
|
-
uniform mat4 projection;
|
|
34
|
-
uniform vec2 translationPivot;
|
|
35
|
-
out vec2 vUV;
|
|
36
|
-
out vec4 vColor;
|
|
37
|
-
out vec3 vPositionW;
|
|
38
|
-
out vec3 vPosition;
|
|
39
|
-
uniform mat4 invView;
|
|
40
|
-
uniform vec3 eyePosition;
|
|
41
|
-
|
|
42
|
-
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
|
|
43
|
-
vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
|
|
44
|
-
vec3 zaxis=normalize(cross(yaxis,xaxis));
|
|
45
|
-
vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
|
|
46
|
-
vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
|
|
47
|
-
vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
|
|
48
|
-
mat3 rotMatrix=mat3(row0,row1,row2);
|
|
49
|
-
vec3 alignedCorner=rotMatrix*rotatedCorner;
|
|
50
|
-
return position+alignedCorner;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
void main(void) {
|
|
54
|
-
vec2 cornerPos;
|
|
55
|
-
cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;
|
|
56
|
-
vec3 rotatedCorner;
|
|
57
|
-
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
|
|
58
|
-
rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
|
|
59
|
-
rotatedCorner.z=0.;
|
|
60
|
-
vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;
|
|
61
|
-
vPositionW=(invView*vec4(viewPos,1)).xyz;
|
|
62
|
-
vPosition = position;
|
|
63
|
-
gl_Position=projection*vec4(viewPos,1.0);
|
|
64
|
-
vColor=color;
|
|
65
|
-
vUV=offset;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
`,BABYLON.Effect.ShadersStore[t.id+"myParticleFragmentShader"]=`
|
|
69
|
-
#ifdef GL_ES
|
|
70
|
-
precision highp float;
|
|
71
|
-
#endif
|
|
72
|
-
|
|
73
|
-
attribute vec3 position;
|
|
74
|
-
|
|
75
|
-
varying vec2 vUV; // Provided by babylon.js
|
|
76
|
-
varying vec4 vColor; // Provided by babylon.js
|
|
77
|
-
|
|
78
|
-
varying vec3 vPosition;
|
|
79
|
-
|
|
80
|
-
uniform sampler2D diffuseSampler; // Provided by babylon.js
|
|
81
|
-
uniform float time; // This one is custom so we need to declare it to the effect
|
|
82
|
-
|
|
83
|
-
uniform float u_emitXMin;
|
|
84
|
-
uniform float u_emitXMax;
|
|
85
|
-
uniform float u_emitYMin;
|
|
86
|
-
uniform float u_emitYMax;
|
|
87
|
-
|
|
88
|
-
uniform sampler2D boxTexSampler;
|
|
89
|
-
|
|
90
|
-
uniform mat4 emitBox_WorldM;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
void main(void) {
|
|
94
|
-
vec4 position = inverse(emitBox_WorldM) * vec4(vPosition, 1.0);
|
|
95
|
-
|
|
96
|
-
float x = position.x;
|
|
97
|
-
float z = position.y;
|
|
98
|
-
float output0 = 0.0 + (x - u_emitXMin) * (1.0 - 0.0) / (u_emitXMax - u_emitXMin);
|
|
99
|
-
float output1 = 0.0 + (z - u_emitYMin) * (1.0 - 0.0) / (u_emitYMax - u_emitYMin);
|
|
100
|
-
vec2 xy = vec2(output0, output1);
|
|
101
|
-
vec4 baseTex = texture2D(boxTexSampler, xy);
|
|
102
|
-
|
|
103
|
-
vec4 baseColor = texture2D(diffuseSampler, vUV);
|
|
104
|
-
|
|
105
|
-
vec4 resAlpha = baseColor * vColor ;
|
|
106
|
-
|
|
107
|
-
gl_FragColor = vec4(baseTex.xyz, resAlpha.a);
|
|
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",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 Y(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 W;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 $;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个。")}},se.EffectType=X,se.EventType=u,se.ThunderAndRain=J,se.Effect=oe}],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=82).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});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Runtime")):"function"==typeof define&&define.amd?define("MX3D",["Runtime"],t):"object"==typeof exports?exports.MX3D=t(require("Runtime")):e.MX3D=t(e.Runtime)}(self,(e=>(()=>{var t={452:function(e,t,n){var i;e.exports=(i=n(249),n(269),n(214),n(888),n(109),function(){var e=i,t=e.lib.BlockCipher,n=e.algo,s=[],r=[],o=[],a=[],c=[],h=[],l=[],u=[],d=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var n=0,i=0;for(t=0;t<256;t++){var p=i^i<<1^i<<2^i<<3^i<<4;p=p>>>8^255&p^99,s[n]=p,r[p]=n;var m=e[n],g=e[m],A=e[g],y=257*e[p]^16843008*p;o[n]=y<<24|y>>>8,a[n]=y<<16|y>>>16,c[n]=y<<8|y>>>24,h[n]=y,y=16843009*A^65537*g^257*m^16843008*n,l[p]=y<<24|y>>>8,u[p]=y<<16|y>>>16,d[p]=y<<8|y>>>24,f[p]=y,n?(n=m^e[e[e[A^m]]],i^=e[e[i]]):n=i=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],m=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,n=e.sigBytes/4,i=4*((this._nRounds=n+6)+1),r=this._keySchedule=[],o=0;o<i;o++)o<n?r[o]=t[o]:(h=r[o-1],o%n?n>6&&o%n==4&&(h=s[h>>>24]<<24|s[h>>>16&255]<<16|s[h>>>8&255]<<8|s[255&h]):(h=s[(h=h<<8|h>>>24)>>>24]<<24|s[h>>>16&255]<<16|s[h>>>8&255]<<8|s[255&h],h^=p[o/n|0]<<24),r[o]=r[o-n]^h);for(var a=this._invKeySchedule=[],c=0;c<i;c++){if(o=i-c,c%4)var h=r[o];else h=r[o-4];a[c]=c<4||o<=4?h:l[s[h>>>24]]^u[s[h>>>16&255]]^d[s[h>>>8&255]]^f[s[255&h]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,a,c,h,s)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,l,u,d,f,r),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,i,s,r,o,a){for(var c=this._nRounds,h=e[t]^n[0],l=e[t+1]^n[1],u=e[t+2]^n[2],d=e[t+3]^n[3],f=4,p=1;p<c;p++){var m=i[h>>>24]^s[l>>>16&255]^r[u>>>8&255]^o[255&d]^n[f++],g=i[l>>>24]^s[u>>>16&255]^r[d>>>8&255]^o[255&h]^n[f++],A=i[u>>>24]^s[d>>>16&255]^r[h>>>8&255]^o[255&l]^n[f++],y=i[d>>>24]^s[h>>>16&255]^r[l>>>8&255]^o[255&u]^n[f++];h=m,l=g,u=A,d=y}m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&d])^n[f++],g=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[d>>>8&255]<<8|a[255&h])^n[f++],A=(a[u>>>24]<<24|a[d>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^n[f++],y=(a[d>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^n[f++],e[t]=m,e[t+1]=g,e[t+2]=A,e[t+3]=y},keySize:8});e.AES=t._createHelper(m)}(),i.AES)},109:function(e,t,n){var i;e.exports=(i=n(249),n(888),void(i.lib.Cipher||function(e){var t=i,n=t.lib,s=n.Base,r=n.WordArray,o=n.BufferedBlockAlgorithm,a=t.enc,c=(a.Utf8,a.Base64),h=t.algo.EvpKDF,l=n.Cipher=o.extend({cfg:s.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,n){this.cfg=this.cfg.extend(n),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.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(){function e(e){return"string"==typeof e?B:A}return function(t){return{encrypt:function(n,i,s){return e(i).encrypt(t,n,i,s)},decrypt:function(n,i,s){return e(i).decrypt(t,n,i,s)}}}}()}),u=(n.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),t.mode={}),d=n.BlockCipherMode=s.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}}),f=u.CBC=function(){var t=d.extend();function n(t,n,i){var s,r=this._iv;r?(s=r,this._iv=e):s=this._prevBlock;for(var o=0;o<i;o++)t[n+o]^=s[o]}return t.Encryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize;n.call(this,e,t,s),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+s)}}),t.Decryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,r=e.slice(t,t+s);i.decryptBlock(e,t),n.call(this,e,t,s),this._prevBlock=r}}),t}(),p=(t.pad={}).Pkcs7={pad:function(e,t){for(var n=4*t,i=n-e.sigBytes%n,s=i<<24|i<<16|i<<8|i,o=[],a=0;a<i;a+=4)o.push(s);var c=r.create(o,i);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},m=(n.BlockCipher=l.extend({cfg:l.cfg.extend({mode:f,padding:p}),reset:function(){var e;l.reset.call(this);var t=this.cfg,n=t.iv,i=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,n&&n.words):(this._mode=e.call(i,this,n&&n.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}),n.CipherParams=s.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),g=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,n=e.salt;return(n?r.create([1398893684,1701076831]).concat(n).concat(t):t).toString(c)},parse:function(e){var t,n=c.parse(e),i=n.words;return 1398893684==i[0]&&1701076831==i[1]&&(t=r.create(i.slice(2,4)),i.splice(0,4),n.sigBytes-=16),m.create({ciphertext:n,salt:t})}},A=n.SerializableCipher=s.extend({cfg:s.extend({format:g}),encrypt:function(e,t,n,i){i=this.cfg.extend(i);var s=e.createEncryptor(n,i),r=s.finalize(t),o=s.cfg;return m.create({ciphertext:r,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,n,i){return i=this.cfg.extend(i),t=this._parse(t,i.format),e.createDecryptor(n,i).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,n,i){i||(i=r.random(8));var s=h.create({keySize:t+n}).compute(e,i),o=r.create(s.words.slice(t),4*n);return s.sigBytes=4*t,m.create({key:s,iv:o,salt:i})}},B=n.PasswordBasedCipher=A.extend({cfg:A.cfg.extend({kdf:y}),encrypt:function(e,t,n,i){var s=(i=this.cfg.extend(i)).kdf.execute(n,e.keySize,e.ivSize);i.iv=s.iv;var r=A.encrypt.call(this,e,t,s.key,i);return r.mixIn(s),r},decrypt:function(e,t,n,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var s=i.kdf.execute(n,e.keySize,e.ivSize,t.salt);return i.iv=s.iv,A.decrypt.call(this,e,t,s.key,i)}})}()))},249:function(e,t,n){var i;e.exports=(i=i||function(e,t){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(i=globalThis.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&void 0!==n.g&&n.g.crypto&&(i=n.g.crypto),!i)try{i=n(480)}catch(e){}var s=function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),o={},a=o.lib={},c=a.Base={extend:function(e){var t=r(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,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=a.WordArray=c.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,i=this.sigBytes,s=e.sigBytes;if(this.clamp(),i%4)for(var r=0;r<s;r++){var o=n[r>>>2]>>>24-r%4*8&255;t[i+r>>>2]|=o<<24-(i+r)%4*8}else for(var a=0;a<s;a+=4)t[i+a>>>2]=n[a>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=c.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(s());return new h.init(t,e)}}),l=o.enc={},u=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,i=[],s=0;s<n;s++){var r=t[s>>>2]>>>24-s%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,n=[],i=0;i<t;i+=2)n[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new h.init(n,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,i=[],s=0;s<n;s++){var r=t[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(r))}return i.join("")},parse:function(e){for(var t=e.length,n=[],i=0;i<t;i++)n[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new h.init(n,t)}},f=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,i=this._data,s=i.words,r=i.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*c,r);if(c){for(var u=0;u<c;u+=o)this._doProcessBlock(s,u);n=s.splice(0,c),i.sigBytes-=l}return new h.init(n,l)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),m=(a.Hasher=p.extend({cfg:c.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(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new m.HMAC.init(e,n).finalize(t)}}}),o.algo={});return o}(Math),i)},269:function(e,t,n){var i;e.exports=(i=n(249),function(){var e=i,t=e.lib.WordArray;function n(e,n,i){for(var s=[],r=0,o=0;o<n;o++)if(o%4){var a=i[e.charCodeAt(o-1)]<<o%4*2|i[e.charCodeAt(o)]>>>6-o%4*2;s[r>>>2]|=a<<24-r%4*8,r++}return t.create(s,r)}e.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,i=this._map;e.clamp();for(var s=[],r=0;r<n;r+=3)for(var o=(t[r>>>2]>>>24-r%4*8&255)<<16|(t[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|t[r+2>>>2]>>>24-(r+2)%4*8&255,a=0;a<4&&r+.75*a<n;a++)s.push(i.charAt(o>>>6*(3-a)&63));var c=i.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,i=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var r=0;r<i.length;r++)s[i.charCodeAt(r)]=r}var o=i.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return n(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),i.enc.Base64)},786:function(e,t,n){var i;e.exports=(i=n(249),function(){var e=i,t=e.lib.WordArray;function n(e,n,i){for(var s=[],r=0,o=0;o<n;o++)if(o%4){var a=i[e.charCodeAt(o-1)]<<o%4*2|i[e.charCodeAt(o)]>>>6-o%4*2;s[r>>>2]|=a<<24-r%4*8,r++}return t.create(s,r)}e.enc.Base64url={stringify:function(e,t=!0){var n=e.words,i=e.sigBytes,s=t?this._safe_map:this._map;e.clamp();for(var r=[],o=0;o<i;o+=3)for(var a=(n[o>>>2]>>>24-o%4*8&255)<<16|(n[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|n[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c<i;c++)r.push(s.charAt(a>>>6*(3-c)&63));var h=s.charAt(64);if(h)for(;r.length%4;)r.push(h);return r.join("")},parse:function(e,t=!0){var i=e.length,s=t?this._safe_map:this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<s.length;o++)r[s.charCodeAt(o)]=o}var a=s.charAt(64);if(a){var c=e.indexOf(a);-1!==c&&(i=c)}return n(e,i,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),i.enc.Base64url)},298:function(e,t,n){var i;e.exports=(i=n(249),function(){var e=i,t=e.lib.WordArray,n=e.enc;function s(e){return e<<8&4278255360|e>>>8&16711935}n.Utf16=n.Utf16BE={stringify:function(e){for(var t=e.words,n=e.sigBytes,i=[],s=0;s<n;s+=2){var r=t[s>>>2]>>>16-s%4*8&65535;i.push(String.fromCharCode(r))}return i.join("")},parse:function(e){for(var n=e.length,i=[],s=0;s<n;s++)i[s>>>1]|=e.charCodeAt(s)<<16-s%2*16;return t.create(i,2*n)}},n.Utf16LE={stringify:function(e){for(var t=e.words,n=e.sigBytes,i=[],r=0;r<n;r+=2){var o=s(t[r>>>2]>>>16-r%4*8&65535);i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){for(var n=e.length,i=[],r=0;r<n;r++)i[r>>>1]|=s(e.charCodeAt(r)<<16-r%2*16);return t.create(i,2*n)}}}(),i.enc.Utf16)},888:function(e,t,n){var i,s,r,o,a,c,h,l;e.exports=(l=n(249),n(783),n(824),s=(i=l).lib,r=s.Base,o=s.WordArray,a=i.algo,c=a.MD5,h=a.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n,i=this.cfg,s=i.hasher.create(),r=o.create(),a=r.words,c=i.keySize,h=i.iterations;a.length<c;){n&&s.update(n),n=s.update(e).finalize(t),s.reset();for(var l=1;l<h;l++)n=s.finalize(n),s.reset();r.concat(n)}return r.sigBytes=4*c,r}}),i.EvpKDF=function(e,t,n){return h.create(n).compute(e,t)},l.EvpKDF)},209:function(e,t,n){var i,s,r,o;e.exports=(o=n(249),n(109),s=(i=o).lib.CipherParams,r=i.enc.Hex,i.format.Hex={stringify:function(e){return e.ciphertext.toString(r)},parse:function(e){var t=r.parse(e);return s.create({ciphertext:t})}},o.format.Hex)},824:function(e,t,n){var i,s,r,o;e.exports=(i=n(249),r=(s=i).lib.Base,o=s.enc.Utf8,void(s.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var n=e.blockSize,i=4*n;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var s=this._oKey=t.clone(),r=this._iKey=t.clone(),a=s.words,c=r.words,h=0;h<n;h++)a[h]^=1549556828,c[h]^=909522486;s.sigBytes=r.sigBytes=i,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,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))},354:function(e,t,n){var i;e.exports=(i=n(249),n(938),n(433),n(298),n(269),n(786),n(214),n(783),n(153),n(792),n(34),n(460),n(327),n(706),n(824),n(112),n(888),n(109),n(568),n(242),n(968),n(660),n(148),n(615),n(807),n(77),n(475),n(991),n(209),n(452),n(253),n(857),n(454),n(974),i)},433:function(e,t,n){var i;e.exports=(i=n(249),function(){if("function"==typeof ArrayBuffer){var e=i.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=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)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var n=e.byteLength,i=[],s=0;s<n;s++)i[s>>>2]|=e[s]<<24-s%4*8;t.call(this,i,n)}else t.apply(this,arguments)};n.prototype=e}}(),i.lib.WordArray)},214:function(e,t,n){var i;e.exports=(i=n(249),function(e){var t=i,n=t.lib,s=n.WordArray,r=n.Hasher,o=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=o.MD5=r.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var i=t+n,s=e[i];e[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var r=this._hash.words,o=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],m=e[t+4],g=e[t+5],A=e[t+6],y=e[t+7],B=e[t+8],b=e[t+9],C=e[t+10],v=e[t+11],w=e[t+12],E=e[t+13],M=e[t+14],x=e[t+15],T=r[0],I=r[1],R=r[2],S=r[3];T=h(T,I,R,S,o,7,a[0]),S=h(S,T,I,R,c,12,a[1]),R=h(R,S,T,I,f,17,a[2]),I=h(I,R,S,T,p,22,a[3]),T=h(T,I,R,S,m,7,a[4]),S=h(S,T,I,R,g,12,a[5]),R=h(R,S,T,I,A,17,a[6]),I=h(I,R,S,T,y,22,a[7]),T=h(T,I,R,S,B,7,a[8]),S=h(S,T,I,R,b,12,a[9]),R=h(R,S,T,I,C,17,a[10]),I=h(I,R,S,T,v,22,a[11]),T=h(T,I,R,S,w,7,a[12]),S=h(S,T,I,R,E,12,a[13]),R=h(R,S,T,I,M,17,a[14]),T=l(T,I=h(I,R,S,T,x,22,a[15]),R,S,c,5,a[16]),S=l(S,T,I,R,A,9,a[17]),R=l(R,S,T,I,v,14,a[18]),I=l(I,R,S,T,o,20,a[19]),T=l(T,I,R,S,g,5,a[20]),S=l(S,T,I,R,C,9,a[21]),R=l(R,S,T,I,x,14,a[22]),I=l(I,R,S,T,m,20,a[23]),T=l(T,I,R,S,b,5,a[24]),S=l(S,T,I,R,M,9,a[25]),R=l(R,S,T,I,p,14,a[26]),I=l(I,R,S,T,B,20,a[27]),T=l(T,I,R,S,E,5,a[28]),S=l(S,T,I,R,f,9,a[29]),R=l(R,S,T,I,y,14,a[30]),T=u(T,I=l(I,R,S,T,w,20,a[31]),R,S,g,4,a[32]),S=u(S,T,I,R,B,11,a[33]),R=u(R,S,T,I,v,16,a[34]),I=u(I,R,S,T,M,23,a[35]),T=u(T,I,R,S,c,4,a[36]),S=u(S,T,I,R,m,11,a[37]),R=u(R,S,T,I,y,16,a[38]),I=u(I,R,S,T,C,23,a[39]),T=u(T,I,R,S,E,4,a[40]),S=u(S,T,I,R,o,11,a[41]),R=u(R,S,T,I,p,16,a[42]),I=u(I,R,S,T,A,23,a[43]),T=u(T,I,R,S,b,4,a[44]),S=u(S,T,I,R,w,11,a[45]),R=u(R,S,T,I,x,16,a[46]),T=d(T,I=u(I,R,S,T,f,23,a[47]),R,S,o,6,a[48]),S=d(S,T,I,R,y,10,a[49]),R=d(R,S,T,I,M,15,a[50]),I=d(I,R,S,T,g,21,a[51]),T=d(T,I,R,S,w,6,a[52]),S=d(S,T,I,R,p,10,a[53]),R=d(R,S,T,I,C,15,a[54]),I=d(I,R,S,T,c,21,a[55]),T=d(T,I,R,S,B,6,a[56]),S=d(S,T,I,R,x,10,a[57]),R=d(R,S,T,I,A,15,a[58]),I=d(I,R,S,T,E,21,a[59]),T=d(T,I,R,S,m,6,a[60]),S=d(S,T,I,R,v,10,a[61]),R=d(R,S,T,I,f,15,a[62]),I=d(I,R,S,T,b,21,a[63]),r[0]=r[0]+T|0,r[1]=r[1]+I|0,r[2]=r[2]+R|0,r[3]=r[3]+S|0},_doFinalize:function(){var t=this._data,n=t.words,i=8*this._nDataBytes,s=8*t.sigBytes;n[s>>>5]|=128<<24-s%32;var r=e.floor(i/4294967296),o=i;n[15+(s+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(s+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,h=0;h<4;h++){var l=c[h];c[h]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function h(e,t,n,i,s,r,o){var a=e+(t&n|~t&i)+s+o;return(a<<r|a>>>32-r)+t}function l(e,t,n,i,s,r,o){var a=e+(t&i|n&~i)+s+o;return(a<<r|a>>>32-r)+t}function u(e,t,n,i,s,r,o){var a=e+(t^n^i)+s+o;return(a<<r|a>>>32-r)+t}function d(e,t,n,i,s,r,o){var a=e+(n^(t|~i))+s+o;return(a<<r|a>>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),i.MD5)},568:function(e,t,n){var i;e.exports=(i=n(249),n(109),i.mode.CFB=function(){var e=i.lib.BlockCipherMode.extend();function t(e,t,n,i){var s,r=this._iv;r?(s=r.slice(0),this._iv=void 0):s=this._prevBlock,i.encryptBlock(s,0);for(var o=0;o<n;o++)e[t+o]^=s[o]}return e.Encryptor=e.extend({processBlock:function(e,n){var i=this._cipher,s=i.blockSize;t.call(this,e,n,s,i),this._prevBlock=e.slice(n,n+s)}}),e.Decryptor=e.extend({processBlock:function(e,n){var i=this._cipher,s=i.blockSize,r=e.slice(n,n+s);t.call(this,e,n,s,i),this._prevBlock=r}}),e}(),i.mode.CFB)},968:function(e,t,n){var i;e.exports=(i=n(249),n(109),i.mode.CTRGladman=function(){var e=i.lib.BlockCipherMode.extend();function t(e){if(255==(e>>24&255)){var t=e>>16&255,n=e>>8&255,i=255&e;255===t?(t=0,255===n?(n=0,255===i?i=0:++i):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=i}else e+=1<<24;return e}function n(e){return 0===(e[0]=t(e[0]))&&(e[1]=t(e[1])),e}var s=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,r=this._iv,o=this._counter;r&&(o=this._counter=r.slice(0),this._iv=void 0),n(o);var a=o.slice(0);i.encryptBlock(a,0);for(var c=0;c<s;c++)e[t+c]^=a[c]}});return e.Decryptor=s,e}(),i.mode.CTRGladman)},242:function(e,t,n){var i,s,r;e.exports=(r=n(249),n(109),r.mode.CTR=(i=r.lib.BlockCipherMode.extend(),s=i.Encryptor=i.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,s=this._iv,r=this._counter;s&&(r=this._counter=s.slice(0),this._iv=void 0);var o=r.slice(0);n.encryptBlock(o,0),r[i-1]=r[i-1]+1|0;for(var a=0;a<i;a++)e[t+a]^=o[a]}}),i.Decryptor=s,i),r.mode.CTR)},148:function(e,t,n){var i,s;e.exports=(s=n(249),n(109),s.mode.ECB=((i=s.lib.BlockCipherMode.extend()).Encryptor=i.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),i.Decryptor=i.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),i),s.mode.ECB)},660:function(e,t,n){var i,s,r;e.exports=(r=n(249),n(109),r.mode.OFB=(i=r.lib.BlockCipherMode.extend(),s=i.Encryptor=i.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,s=this._iv,r=this._keystream;s&&(r=this._keystream=s.slice(0),this._iv=void 0),n.encryptBlock(r,0);for(var o=0;o<i;o++)e[t+o]^=r[o]}}),i.Decryptor=s,i),r.mode.OFB)},615:function(e,t,n){var i;e.exports=(i=n(249),n(109),i.pad.AnsiX923={pad:function(e,t){var n=e.sigBytes,i=4*t,s=i-n%i,r=n+s-1;e.clamp(),e.words[r>>>2]|=s<<24-r%4*8,e.sigBytes+=s},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Ansix923)},807:function(e,t,n){var i;e.exports=(i=n(249),n(109),i.pad.Iso10126={pad:function(e,t){var n=4*t,s=n-e.sigBytes%n;e.concat(i.lib.WordArray.random(s-1)).concat(i.lib.WordArray.create([s<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Iso10126)},77:function(e,t,n){var i;e.exports=(i=n(249),n(109),i.pad.Iso97971={pad:function(e,t){e.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(e,t)},unpad:function(e){i.pad.ZeroPadding.unpad(e),e.sigBytes--}},i.pad.Iso97971)},991:function(e,t,n){var i;e.exports=(i=n(249),n(109),i.pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding)},475:function(e,t,n){var i;e.exports=(i=n(249),n(109),i.pad.ZeroPadding={pad:function(e,t){var n=4*t;e.clamp(),e.sigBytes+=n-(e.sigBytes%n||n)},unpad:function(e){var t=e.words,n=e.sigBytes-1;for(n=e.sigBytes-1;n>=0;n--)if(t[n>>>2]>>>24-n%4*8&255){e.sigBytes=n+1;break}}},i.pad.ZeroPadding)},112:function(e,t,n){var i,s,r,o,a,c,h,l,u;e.exports=(u=n(249),n(783),n(824),s=(i=u).lib,r=s.Base,o=s.WordArray,a=i.algo,c=a.SHA1,h=a.HMAC,l=a.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,i=h.create(n.hasher,e),s=o.create(),r=o.create([1]),a=s.words,c=r.words,l=n.keySize,u=n.iterations;a.length<l;){var d=i.update(t).finalize(r);i.reset();for(var f=d.words,p=f.length,m=d,g=1;g<u;g++){m=i.finalize(m),i.reset();for(var A=m.words,y=0;y<p;y++)f[y]^=A[y]}s.concat(d),c[0]++}return s.sigBytes=4*l,s}}),i.PBKDF2=function(e,t,n){return l.create(n).compute(e,t)},u.PBKDF2)},974:function(e,t,n){var i;e.exports=(i=n(249),n(269),n(214),n(888),n(109),function(){var e=i,t=e.lib.StreamCipher,n=e.algo,s=[],r=[],o=[],a=n.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,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],i=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]];this._b=0;for(var s=0;s<4;s++)c.call(this);for(s=0;s<8;s++)i[s]^=n[s+4&7];if(t){var r=t.words,o=r[0],a=r[1],h=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=h>>>16|4294901760&l,d=l<<16|65535&h;for(i[0]^=h,i[1]^=u,i[2]^=l,i[3]^=d,i[4]^=h,i[5]^=u,i[6]^=l,i[7]^=d,s=0;s<4;s++)c.call(this)}},_doProcessBlock:function(e,t){var n=this._X;c.call(this),s[0]=n[0]^n[5]>>>16^n[3]<<16,s[1]=n[2]^n[7]>>>16^n[5]<<16,s[2]=n[4]^n[1]>>>16^n[7]<<16,s[3]=n[6]^n[3]>>>16^n[1]<<16;for(var i=0;i<4;i++)s[i]=16711935&(s[i]<<8|s[i]>>>24)|4278255360&(s[i]<<24|s[i]>>>8),e[t+i]^=s[i]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,n=0;n<8;n++)r[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<r[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<r[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<r[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<r[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<r[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<r[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<r[6]>>>0?1:0)|0,this._b=t[7]>>>0<r[7]>>>0?1:0,n=0;n<8;n++){var i=e[n]+t[n],s=65535&i,a=i>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,h=((4294901760&i)*i|0)+((65535&i)*i|0);o[n]=c^h}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=t._createHelper(a)}(),i.RabbitLegacy)},454:function(e,t,n){var i;e.exports=(i=n(249),n(269),n(214),n(888),n(109),function(){var e=i,t=e.lib.StreamCipher,n=e.algo,s=[],r=[],o=[],a=n.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,n=0;n<4;n++)e[n]=16711935&(e[n]<<8|e[n]>>>24)|4278255360&(e[n]<<24|e[n]>>>8);var 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],s=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]];for(this._b=0,n=0;n<4;n++)c.call(this);for(n=0;n<8;n++)s[n]^=i[n+4&7];if(t){var r=t.words,o=r[0],a=r[1],h=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=h>>>16|4294901760&l,d=l<<16|65535&h;for(s[0]^=h,s[1]^=u,s[2]^=l,s[3]^=d,s[4]^=h,s[5]^=u,s[6]^=l,s[7]^=d,n=0;n<4;n++)c.call(this)}},_doProcessBlock:function(e,t){var n=this._X;c.call(this),s[0]=n[0]^n[5]>>>16^n[3]<<16,s[1]=n[2]^n[7]>>>16^n[5]<<16,s[2]=n[4]^n[1]>>>16^n[7]<<16,s[3]=n[6]^n[3]>>>16^n[1]<<16;for(var i=0;i<4;i++)s[i]=16711935&(s[i]<<8|s[i]>>>24)|4278255360&(s[i]<<24|s[i]>>>8),e[t+i]^=s[i]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,n=0;n<8;n++)r[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<r[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<r[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<r[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<r[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<r[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<r[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<r[6]>>>0?1:0)|0,this._b=t[7]>>>0<r[7]>>>0?1:0,n=0;n<8;n++){var i=e[n]+t[n],s=65535&i,a=i>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,h=((4294901760&i)*i|0)+((65535&i)*i|0);o[n]=c^h}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=t._createHelper(a)}(),i.Rabbit)},857:function(e,t,n){var i;e.exports=(i=n(249),n(269),n(214),n(888),n(109),function(){var e=i,t=e.lib.StreamCipher,n=e.algo,s=n.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes,i=this._S=[],s=0;s<256;s++)i[s]=s;s=0;for(var r=0;s<256;s++){var o=s%n,a=t[o>>>2]>>>24-o%4*8&255;r=(r+i[s]+a)%256;var c=i[s];i[s]=i[r],i[r]=c}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,n=this._j,i=0,s=0;s<4;s++){n=(n+e[t=(t+1)%256])%256;var r=e[t];e[t]=e[n],e[n]=r,i|=e[(e[t]+e[n])%256]<<24-8*s}return this._i=t,this._j=n,i}e.RC4=t._createHelper(s);var o=n.RC4Drop=s.extend({cfg:s.cfg.extend({drop:192}),_doReset:function(){s._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)r.call(this)}});e.RC4Drop=t._createHelper(o)}(),i.RC4)},706:function(e,t,n){var i;e.exports=(i=n(249),function(e){var t=i,n=t.lib,s=n.WordArray,r=n.Hasher,o=t.algo,a=s.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=s.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]),h=s.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]),l=s.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]),u=s.create([0,1518500249,1859775393,2400959708,2840853838]),d=s.create([1352829926,1548603684,1836072691,2053994217,0]),f=o.RIPEMD160=r.extend({_doReset:function(){this._hash=s.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var i=t+n,s=e[i];e[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var r,o,f,b,C,v,w,E,M,x,T,I=this._hash.words,R=u.words,S=d.words,O=a.words,D=c.words,F=h.words,_=l.words;for(v=r=I[0],w=o=I[1],E=f=I[2],M=b=I[3],x=C=I[4],n=0;n<80;n+=1)T=r+e[t+O[n]]|0,T+=n<16?p(o,f,b)+R[0]:n<32?m(o,f,b)+R[1]:n<48?g(o,f,b)+R[2]:n<64?A(o,f,b)+R[3]:y(o,f,b)+R[4],T=(T=B(T|=0,F[n]))+C|0,r=C,C=b,b=B(f,10),f=o,o=T,T=v+e[t+D[n]]|0,T+=n<16?y(w,E,M)+S[0]:n<32?A(w,E,M)+S[1]:n<48?g(w,E,M)+S[2]:n<64?m(w,E,M)+S[3]:p(w,E,M)+S[4],T=(T=B(T|=0,_[n]))+x|0,v=x,x=M,M=B(E,10),E=w,w=T;T=I[1]+f+M|0,I[1]=I[2]+b+x|0,I[2]=I[3]+C+v|0,I[3]=I[4]+r+w|0,I[4]=I[0]+o+E|0,I[0]=T},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,r=s.words,o=0;o<5;o++){var a=r[o];r[o]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return s},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,n){return e^t^n}function m(e,t,n){return e&t|~e&n}function g(e,t,n){return(e|~t)^n}function A(e,t,n){return e&n|t&~n}function y(e,t,n){return e^(t|~n)}function B(e,t){return e<<t|e>>>32-t}t.RIPEMD160=r._createHelper(f),t.HmacRIPEMD160=r._createHmacHelper(f)}(Math),i.RIPEMD160)},783:function(e,t,n){var i,s,r,o,a,c,h,l;e.exports=(l=n(249),s=(i=l).lib,r=s.WordArray,o=s.Hasher,a=i.algo,c=[],h=a.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,i=n[0],s=n[1],r=n[2],o=n[3],a=n[4],h=0;h<80;h++){if(h<16)c[h]=0|e[t+h];else{var l=c[h-3]^c[h-8]^c[h-14]^c[h-16];c[h]=l<<1|l>>>31}var u=(i<<5|i>>>27)+a+c[h];u+=h<20?1518500249+(s&r|~s&o):h<40?1859775393+(s^r^o):h<60?(s&r|s&o|r&o)-1894007588:(s^r^o)-899497514,a=o,o=r,r=s<<30|s>>>2,s=i,i=u}n[0]=n[0]+i|0,n[1]=n[1]+s|0,n[2]=n[2]+r|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(i+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),i.SHA1=o._createHelper(h),i.HmacSHA1=o._createHmacHelper(h),l.SHA1)},792:function(e,t,n){var i,s,r,o,a,c;e.exports=(c=n(249),n(153),s=(i=c).lib.WordArray,r=i.algo,o=r.SHA256,a=r.SHA224=o.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=o._doFinalize.call(this);return e.sigBytes-=4,e}}),i.SHA224=o._createHelper(a),i.HmacSHA224=o._createHmacHelper(a),c.SHA224)},153:function(e,t,n){var i;e.exports=(i=n(249),function(e){var t=i,n=t.lib,s=n.WordArray,r=n.Hasher,o=t.algo,a=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),i=2;i<=n;i++)if(!(t%i))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var i=2,s=0;s<64;)t(i)&&(s<8&&(a[s]=n(e.pow(i,.5))),c[s]=n(e.pow(i,1/3)),s++),i++}();var h=[],l=o.SHA256=r.extend({_doReset:function(){this._hash=new s.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,i=n[0],s=n[1],r=n[2],o=n[3],a=n[4],l=n[5],u=n[6],d=n[7],f=0;f<64;f++){if(f<16)h[f]=0|e[t+f];else{var p=h[f-15],m=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,g=h[f-2],A=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;h[f]=m+h[f-7]+A+h[f-16]}var y=i&s^i&r^s&r,B=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),b=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&u)+c[f]+h[f];d=u,u=l,l=a,a=o+b|0,o=r,r=s,s=i,i=b+(B+y)|0}n[0]=n[0]+i|0,n[1]=n[1]+s|0,n[2]=n[2]+r|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+u|0,n[7]=n[7]+d|0},_doFinalize:function(){var t=this._data,n=t.words,i=8*this._nDataBytes,s=8*t.sigBytes;return n[s>>>5]|=128<<24-s%32,n[14+(s+64>>>9<<4)]=e.floor(i/4294967296),n[15+(s+64>>>9<<4)]=i,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(l),t.HmacSHA256=r._createHmacHelper(l)}(Math),i.SHA256)},327:function(e,t,n){var i;e.exports=(i=n(249),n(938),function(e){var t=i,n=t.lib,s=n.WordArray,r=n.Hasher,o=t.x64.Word,a=t.algo,c=[],h=[],l=[];!function(){for(var e=1,t=0,n=0;n<24;n++){c[e+5*t]=(n+1)*(n+2)/2%64;var i=(2*e+3*t)%5;e=t%5,t=i}for(e=0;e<5;e++)for(t=0;t<5;t++)h[e+5*t]=t+(2*e+3*t)%5*5;for(var s=1,r=0;r<24;r++){for(var a=0,u=0,d=0;d<7;d++){if(1&s){var f=(1<<d)-1;f<32?u^=1<<f:a^=1<<f-32}128&s?s=s<<1^113:s<<=1}l[r]=o.create(a,u)}}();var u=[];!function(){for(var e=0;e<25;e++)u[e]=o.create()}();var d=a.SHA3=r.extend({cfg:r.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new o.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var n=this._state,i=this.blockSize/2,s=0;s<i;s++){var r=e[t+2*s],o=e[t+2*s+1];r=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),(I=n[s]).high^=o,I.low^=r}for(var a=0;a<24;a++){for(var d=0;d<5;d++){for(var f=0,p=0,m=0;m<5;m++)f^=(I=n[d+5*m]).high,p^=I.low;var g=u[d];g.high=f,g.low=p}for(d=0;d<5;d++){var A=u[(d+4)%5],y=u[(d+1)%5],B=y.high,b=y.low;for(f=A.high^(B<<1|b>>>31),p=A.low^(b<<1|B>>>31),m=0;m<5;m++)(I=n[d+5*m]).high^=f,I.low^=p}for(var C=1;C<25;C++){var v=(I=n[C]).high,w=I.low,E=c[C];E<32?(f=v<<E|w>>>32-E,p=w<<E|v>>>32-E):(f=w<<E-32|v>>>64-E,p=v<<E-32|w>>>64-E);var M=u[h[C]];M.high=f,M.low=p}var x=u[0],T=n[0];for(x.high=T.high,x.low=T.low,d=0;d<5;d++)for(m=0;m<5;m++){var I=n[C=d+5*m],R=u[C],S=u[(d+1)%5+5*m],O=u[(d+2)%5+5*m];I.high=R.high^~S.high&O.high,I.low=R.low^~S.low&O.low}I=n[0];var D=l[a];I.high^=D.high,I.low^=D.low}},_doFinalize:function(){var t=this._data,n=t.words,i=(this._nDataBytes,8*t.sigBytes),r=32*this.blockSize;n[i>>>5]|=1<<24-i%32,n[(e.ceil((i+1)/r)*r>>>5)-1]|=128,t.sigBytes=4*n.length,this._process();for(var o=this._state,a=this.cfg.outputLength/8,c=a/8,h=[],l=0;l<c;l++){var u=o[l],d=u.high,f=u.low;d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),h.push(f),h.push(d)}return new s.init(h,a)},clone:function(){for(var e=r.clone.call(this),t=e._state=this._state.slice(0),n=0;n<25;n++)t[n]=t[n].clone();return e}});t.SHA3=r._createHelper(d),t.HmacSHA3=r._createHmacHelper(d)}(Math),i.SHA3)},460:function(e,t,n){var i,s,r,o,a,c,h,l;e.exports=(l=n(249),n(938),n(34),s=(i=l).x64,r=s.Word,o=s.WordArray,a=i.algo,c=a.SHA512,h=a.SHA384=c.extend({_doReset:function(){this._hash=new o.init([new r.init(3418070365,3238371032),new r.init(1654270250,914150663),new r.init(2438529370,812702999),new r.init(355462360,4144912697),new r.init(1731405415,4290775857),new r.init(2394180231,1750603025),new r.init(3675008525,1694076839),new r.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),i.SHA384=c._createHelper(h),i.HmacSHA384=c._createHmacHelper(h),l.SHA384)},34:function(e,t,n){var i;e.exports=(i=n(249),n(938),function(){var e=i,t=e.lib.Hasher,n=e.x64,s=n.Word,r=n.WordArray,o=e.algo;function a(){return s.create.apply(s,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],h=[];!function(){for(var e=0;e<80;e++)h[e]=a()}();var l=o.SHA512=t.extend({_doReset:function(){this._hash=new r.init([new s.init(1779033703,4089235720),new s.init(3144134277,2227873595),new s.init(1013904242,4271175723),new s.init(2773480762,1595750129),new s.init(1359893119,2917565137),new s.init(2600822924,725511199),new s.init(528734635,4215389547),new s.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var n=this._hash.words,i=n[0],s=n[1],r=n[2],o=n[3],a=n[4],l=n[5],u=n[6],d=n[7],f=i.high,p=i.low,m=s.high,g=s.low,A=r.high,y=r.low,B=o.high,b=o.low,C=a.high,v=a.low,w=l.high,E=l.low,M=u.high,x=u.low,T=d.high,I=d.low,R=f,S=p,O=m,D=g,F=A,_=y,G=B,L=b,P=C,k=v,N=w,U=E,H=M,j=x,J=T,V=I,z=0;z<80;z++){var K,W,Q=h[z];if(z<16)W=Q.high=0|e[t+2*z],K=Q.low=0|e[t+2*z+1];else{var X=h[z-15],Y=X.high,q=X.low,Z=(Y>>>1|q<<31)^(Y>>>8|q<<24)^Y>>>7,$=(q>>>1|Y<<31)^(q>>>8|Y<<24)^(q>>>7|Y<<25),ee=h[z-2],te=ee.high,ne=ee.low,ie=(te>>>19|ne<<13)^(te<<3|ne>>>29)^te>>>6,se=(ne>>>19|te<<13)^(ne<<3|te>>>29)^(ne>>>6|te<<26),re=h[z-7],oe=re.high,ae=re.low,ce=h[z-16],he=ce.high,le=ce.low;W=(W=(W=Z+oe+((K=$+ae)>>>0<$>>>0?1:0))+ie+((K+=se)>>>0<se>>>0?1:0))+he+((K+=le)>>>0<le>>>0?1:0),Q.high=W,Q.low=K}var ue,de=P&N^~P&H,fe=k&U^~k&j,pe=R&O^R&F^O&F,me=S&D^S&_^D&_,ge=(R>>>28|S<<4)^(R<<30|S>>>2)^(R<<25|S>>>7),Ae=(S>>>28|R<<4)^(S<<30|R>>>2)^(S<<25|R>>>7),ye=(P>>>14|k<<18)^(P>>>18|k<<14)^(P<<23|k>>>9),Be=(k>>>14|P<<18)^(k>>>18|P<<14)^(k<<23|P>>>9),be=c[z],Ce=be.high,ve=be.low,we=J+ye+((ue=V+Be)>>>0<V>>>0?1:0),Ee=Ae+me;J=H,V=j,H=N,j=U,N=P,U=k,P=G+(we=(we=(we=we+de+((ue+=fe)>>>0<fe>>>0?1:0))+Ce+((ue+=ve)>>>0<ve>>>0?1:0))+W+((ue+=K)>>>0<K>>>0?1:0))+((k=L+ue|0)>>>0<L>>>0?1:0)|0,G=F,L=_,F=O,_=D,O=R,D=S,R=we+(ge+pe+(Ee>>>0<Ae>>>0?1:0))+((S=ue+Ee|0)>>>0<ue>>>0?1:0)|0}p=i.low=p+S,i.high=f+R+(p>>>0<S>>>0?1:0),g=s.low=g+D,s.high=m+O+(g>>>0<D>>>0?1:0),y=r.low=y+_,r.high=A+F+(y>>>0<_>>>0?1:0),b=o.low=b+L,o.high=B+G+(b>>>0<L>>>0?1:0),v=a.low=v+k,a.high=C+P+(v>>>0<k>>>0?1:0),E=l.low=E+U,l.high=w+N+(E>>>0<U>>>0?1:0),x=u.low=x+j,u.high=M+H+(x>>>0<j>>>0?1:0),I=d.low=I+V,d.high=T+J+(I>>>0<V>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[30+(i+128>>>10<<5)]=Math.floor(n/4294967296),t[31+(i+128>>>10<<5)]=n,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(l),e.HmacSHA512=t._createHmacHelper(l)}(),i.SHA512)},253:function(e,t,n){var i;e.exports=(i=n(249),n(269),n(214),n(888),n(109),function(){var e=i,t=e.lib,n=t.WordArray,s=t.BlockCipher,r=e.algo,o=[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],a=[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],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],h=[{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}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],u=r.DES=s.extend({_doReset:function(){for(var e=this._key.words,t=[],n=0;n<56;n++){var i=o[n]-1;t[n]=e[i>>>5]>>>31-i%32&1}for(var s=this._subKeys=[],r=0;r<16;r++){var h=s[r]=[],l=c[r];for(n=0;n<24;n++)h[n/6|0]|=t[(a[n]-1+l)%28]<<31-n%6,h[4+(n/6|0)]|=t[28+(a[n+24]-1+l)%28]<<31-n%6;for(h[0]=h[0]<<1|h[0]>>>31,n=1;n<7;n++)h[n]=h[n]>>>4*(n-1)+3;h[7]=h[7]<<5|h[7]>>>27}var u=this._invSubKeys=[];for(n=0;n<16;n++)u[n]=s[15-n]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,n){this._lBlock=e[t],this._rBlock=e[t+1],d.call(this,4,252645135),d.call(this,16,65535),f.call(this,2,858993459),f.call(this,8,16711935),d.call(this,1,1431655765);for(var i=0;i<16;i++){for(var s=n[i],r=this._lBlock,o=this._rBlock,a=0,c=0;c<8;c++)a|=h[c][((o^s[c])&l[c])>>>0];this._lBlock=o,this._rBlock=r^a}var u=this._lBlock;this._lBlock=this._rBlock,this._rBlock=u,d.call(this,1,1431655765),f.call(this,8,16711935),f.call(this,2,858993459),d.call(this,16,65535),d.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function d(e,t){var n=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=n,this._lBlock^=n<<e}function f(e,t){var n=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=n,this._rBlock^=n<<e}e.DES=s._createHelper(u);var p=r.TripleDES=s.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),s=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=u.createEncryptor(n.create(t)),this._des2=u.createEncryptor(n.create(i)),this._des3=u.createEncryptor(n.create(s))},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=s._createHelper(p)}(),i.TripleDES)},938:function(e,t,n){var i;e.exports=(i=n(249),function(e){var t=i,n=t.lib,s=n.Base,r=n.WordArray,o=t.x64={};o.Word=s.extend({init:function(e,t){this.high=e,this.low=t}}),o.WordArray=s.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=n!=e?n:8*t.length},toX32:function(){for(var e=this.words,t=e.length,n=[],i=0;i<t;i++){var s=e[i];n.push(s.high),n.push(s.low)}return r.create(n,this.sigBytes)},clone:function(){for(var e=s.clone.call(this),t=e.words=this.words.slice(0),n=t.length,i=0;i<n;i++)t[i]=t[i].clone();return e}})}(),i)},74:t=>{"use strict";t.exports=e},125:()=>{},480:()=>{}},n={};function i(e){var s=n[e];if(void 0!==s)return s.exports;var r=n[e]={exports:{}};return t[e].call(r.exports,r,r.exports,i),r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{"use strict";i.d(s,{default:()=>Xd});var e={};i.r(e),i.d(e,{decode:()=>Xa,name:()=>Qa});var t={};i.r(t),i.d(t,{name:()=>tc,preprocess:()=>nc});var n={};i.r(n),i.d(n,{name:()=>sc,preprocess:()=>rc});var r={};i.r(r),i.d(r,{decode:()=>lc,encode:()=>uc,name:()=>cc,preprocess:()=>hc});var o={};i.r(o),i.d(o,{decode:()=>Sc,name:()=>xc});var a={};i.r(a),i.d(a,{decode:()=>Lc,encode:()=>Pc,name:()=>Gc});var c={};i.r(c),i.d(c,{decode:()=>Uc,encode:()=>Hc,name:()=>Nc});var h={};i.r(h),i.d(h,{decode:()=>Vc,encode:()=>zc,name:()=>Jc});var l={};i.r(l),i.d(l,{decode:()=>Xc,name:()=>Qc});var u,d=i(74);class f{constructor(e){this.isMove=0,this.app=e}runRender(){}onPointer(e){switch(e.type){case d.PointerEventTypes.POINTERDOWN:this.isMove=0;case d.PointerEventTypes.POINTERMOVE:if(this.isMove++,!this.app.toolTips)return;e?this.app.toolTips.update(e):this.app.toolTips.close();break;case d.PointerEventTypes.POINTERWHEEL:this.app.cameraController._wheel(e.event),e.event.preventDefault();break;case d.PointerEventTypes.POINTERUP:if(this.isMove>2)return;e.pickInfo.pickedMesh||2!=e.event.button||this.app.project.goBack()}}onKeyboard(e){if(e.type===d.KeyboardEventTypes.KEYDOWN)70===e.event.keyCode&&prompt("请复制输入框内的视角参数",this.app.cameraController.getSightJson())}}class p{constructor(e){this.isFPS=!1,this.angle=Math.PI/2,this.direction=new d.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(){if(this.app.scene.activeCamera instanceof d.FreeCamera&&(this.isMoveDown||this.isMoveLeft||this.isMoveRight||this.isMoveUp)){var 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),d.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 d.PointerEventTypes.POINTERUP:if(this.isFPS)return;this.app.cameraController.freeCamera.position=d.Vector3.Zero(),this.app.cameraController.freeCamera.position.y=this.app.project.current.instance.position.y+1.5,this.app.scene.activeCamera=this.app.cameraController.freeCamera,this.app.cameraController.freeCamera.attachControl(this.app.canvas,!0),this.isFPS=!0;break;case d.PointerEventTypes.POINTERMOVE:break;case d.PointerEventTypes.POINTERWHEEL:e.event.preventDefault()}}onKeyboard(e){}}class m{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 d.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 d.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(),n=e.getBoundingInfo();if(t.length>0){for(var i=t[0].getBoundingInfo(),s=i.minimum.add(t[0].position),r=i.maximum.add(t[0].position),o=1;o<t.length;o++)i=t[o].getBoundingInfo(),s=d.Vector3.Minimize(s,i.minimum.add(t[o].position)),r=d.Vector3.Maximize(r,i.maximum.add(t[o].position));n=new d.BoundingInfo(s,r)}return n}static computeBoundsToARR(e){for(var t=e[0].getBoundingInfo(),n=t.minimum.add(e[0].position),i=t.maximum.add(e[0].position),s=1;s<e.length;s++)t=e[s].getBoundingInfo(),n=d.Vector3.Minimize(n,t.minimum.add(e[s].position)),i=d.Vector3.Maximize(i,t.maximum.add(e[s].position));return new d.BoundingInfo(n,i)}static Expand(e,t){let n=new Array,i=e.length;for(let s=0;s<i;s++){let r=e[s],o=e[0==s?i-1:s-1],a=e[s==i-1?0:s+1],c=o.x-r.x,h=o.z-r.z,l=this.norm(c,h);c/=l,h/=l;let u=a.x-r.x,f=a.z-r.z,p=this.norm(u,f);u/=p,f/=p;let m=-t/Math.sqrt((1-(c*u+h*f))/2),g=c+u,A=h+f,y=0==this.norm(g,A)?0:m/this.norm(g,A);g*=y,A*=y,n[s]=new d.Vector3(g+r.x,0,A+r.z)}return n}static norm(e,t){return Math.sqrt(e*e+t*t)}static MergeMeshes(e,t){let n=new d.Mesh((new Date).getDate().toString(),t.scene);return setTimeout((()=>{let t,i=null;for(let n=0;n<e.length;n++)if(e[n]){var s=e[n],r=s.computeWorldMatrix(!0);t=d.VertexData.ExtractFromMesh(s,!0,!0),t.transform(r),i?i.merge(t,!0):i=t,s.dispose(!1,!0)}i.applyToMesh(n)})),n}static DeconsTructMesh(e,t,n){if(e.subMeshes.length>1){for(var i=d.VertexData.ExtractFromMesh(e,!0,!0),s=i.indices,r=i.normals,o=i.positions,a=i.uvs,c=new Array,h=0;h<e.subMeshes.length;h++){for(var l=new d.VertexData,u=s.slice(e.subMeshes[h].indexStart,e.subMeshes[h].indexStart+e.subMeshes[h].indexCount),f=r.slice(3*e.subMeshes[h].verticesStart,3*e.subMeshes[h].verticesStart+3*e.subMeshes[h].verticesCount),p=o.slice(3*e.subMeshes[h].verticesStart,3*e.subMeshes[h].verticesStart+3*e.subMeshes[h].verticesCount),m=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=f,l.positions=p,l.uvs=m;var A=new d.Mesh(e.id+"-"+h,n.scene);l.applyToMesh(A),A.position.y=parseFloat(t),A.setEnabled(!1),c.push(A)}return e.dispose(!1,!0),c}return[e]}static getVisualAngle(e,t){let n={},i=e.boundingSphere.radiusWorld,s=t.engine.getAspectRatio(t.cameraController.arcRotateCamera),r=t.cameraController.arcRotateCamera.fov/1.2;return s<1&&(r=Math.atan(s*Math.tan(t.cameraController.arcRotateCamera.fov/2))),n.radius=1.1*Math.abs(i/Math.sin(r)),n.alpha=Math.PI/2,n.beta=Math.PI/3,n.focus=e.boundingSphere.center.clone(),n}static pathTransformation(e,t){let n=new d.Path3D(e).getTangents(),i=[];for(let s=0;s<e.length;s++)if(s>0&&s<e.length-1){let r=e[s-1],o=e[s+1],a=e[s],c=n[s-1],h=n[s];if(!c.equals(h)){let e=d.Vector3.Lerp(a,r,t/d.Vector3.Distance(r,a)),n=d.Vector3.Lerp(a,o,t/d.Vector3.Distance(o,a)),s=d.Curve3.CreateQuadraticBezier(e,a,n,10);i=i.concat(s.getPoints())}}else i.push(e[s]);return i}static createTube(e,t,n=.05,i){return d.MeshBuilder.CreateTube(e,{path:this.pathTransformation(t,n),radius:n/2},i.scene)}static getAngleFromVector2(e,t,n){const i=(e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y),s=(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x),r=Math.atan2(s,i);return Math.PI-r}static getAngleFromVector3(e,t,n){return this.getAngleFromVector2(new d.Vector2(e.x,e.z),new d.Vector2(t.x,t.z),new d.Vector2(n.x,n.z))}static RandomNumBoth(e,t){var n=t-e,i=Math.random();return e+Math.round(i*n)}static rand(e,t){return Math.floor(Math.random()*(t-e+1)+e)}}class g{constructor(e){this.app=e,this.arcRotateCamera=new d.ArcRotateCamera("arcRotateCamera",-Math.PI/4,Math.PI/4,50,new d.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 d.FreeCamera("FreeCamera",d.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=d.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()}orthographic1(e){this.arcRotateCamera.lowerBetaLimit=0,this.arcRotateCamera.upperBetaLimit=0,this.arcRotateCamera.lowerAlphaLimit=Math.PI/2,this.arcRotateCamera.upperAlphaLimit=Math.PI/2,this.arcRotateCamera.mode=d.Camera.ORTHOGRAPHIC_CAMERA,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?e.minimumLimit:1,this.arcRotateCamera.upperRadiusLimit=e.maximumLimit?e.maximumLimit:3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.minBeta?e.minBeta:.01,this.arcRotateCamera.upperBetaLimit=e.maxBeta?e.maxBeta:Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=d.Camera.PERSPECTIVE_CAMERA,(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 d.Animation("camtarget","target",30,d.Animation.ANIMATIONTYPE_VECTOR3,d.Animation.ANIMATIONLOOPMODE_CYCLE);t.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:30,value:e.focus.clone()}]);var n=new d.Animation("camAlpha","alpha",30,d.Animation.ANIMATIONTYPE_FLOAT,d.Animation.ANIMATIONLOOPMODE_CYCLE);n.setKeys([{frame:0,value:this.arcRotateCamera.alpha},{frame:30,value:e.alpha}]);var i=new d.Animation("camRadius","radius",30,d.Animation.ANIMATIONTYPE_FLOAT,d.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30,value:e.radius}]);var s=new d.Animation("camBeta","beta",30,d.Animation.ANIMATIONTYPE_FLOAT,d.Animation.ANIMATIONLOOPMODE_CYCLE);s.setKeys([{frame:0,value:this.arcRotateCamera.beta},{frame:30,value:e.beta}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[t,n,i,s],0,60,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}flyTo(e,t=.5){e||(e=this.app.project.current.Sight),this.arcRotateCamera.mode=d.Camera.PERSPECTIVE_CAMERA;var n=20,i=new d.Animation("camTarget","target",n,d.Animation.ANIMATIONTYPE_VECTOR3,d.Animation.ANIMATIONLOOPMODE_CONSTANT);i.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:n,value:e.focus.clone()}]);var s=new d.Animation("camRadius","radius",n,d.Animation.ANIMATIONTYPE_FLOAT,d.Animation.ANIMATIONLOOPMODE_CYCLE);s.setKeys([{frame:n,value:this.arcRotateCamera.radius},{frame:40,value:e.radius}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[i,s],0,40,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}flyToObject(e,t=.5){this.flyTo(e.Sight,t)}lookToTheFront(e,t=.5){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.arcRotateCamera.lowerRadiusLimit=e.Sight.minimumLimit?e.Sight.minimumLimit:1,this.arcRotateCamera.upperRadiusLimit=e.Sight.maximumLimit?e.Sight.maximumLimit:3e3,this.arcRotateCamera.panningSensibility=1e3,this.arcRotateCamera.lowerBetaLimit=e.Sight.minBeta?e.Sight.minBeta:.01,this.arcRotateCamera.upperBetaLimit=e.Sight.maxBeta?e.Sight.maxBeta:Math.PI/2*.98,this.arcRotateCamera.lowerAlphaLimit=null,this.arcRotateCamera.upperAlphaLimit=null,this.arcRotateCamera.mode=d.Camera.PERSPECTIVE_CAMERA;let n=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 i=new d.Animation("camtarget","target",30,d.Animation.ANIMATIONTYPE_VECTOR3,d.Animation.ANIMATIONLOOPMODE_CYCLE);i.setKeys([{frame:0,value:this.arcRotateCamera.target},{frame:30*t,value:e.Sight.focus.clone()}]);var s=new d.Animation("camAlpha","alpha",30,d.Animation.ANIMATIONTYPE_FLOAT,d.Animation.ANIMATIONLOOPMODE_CYCLE);s.setKeys([{frame:0,value:this.arcRotateCamera.alpha},{frame:30*t,value:n}]);var r=new d.Animation("camRadius","radius",30,d.Animation.ANIMATIONTYPE_FLOAT,d.Animation.ANIMATIONLOOPMODE_CYCLE);r.setKeys([{frame:0,value:this.arcRotateCamera.radius},{frame:30*t,value:e.Sight.radius/1.2}]);var o=new d.Animation("camBeta","beta",30,d.Animation.ANIMATIONTYPE_FLOAT,d.Animation.ANIMATIONLOOPMODE_CYCLE);o.setKeys([{frame:0,value:this.arcRotateCamera.beta},{frame:30*t,value:Math.PI/2}]),this.app.scene.beginDirectAnimation(this.arcRotateCamera,[i,s,r,o],0,30*t,!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}getSightJson(){return JSON.stringify({alpha:this.arcRotateCamera.alpha,focus:m.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(){const 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;let t=1e3/(this.frustrum/20);this.arcRotateCamera.panningSensibility=t>2e3?2e3:t<10?10:t}_wheel(e){if(this.arcRotateCamera.mode!=d.Camera.PERSPECTIVE_CAMERA){var t=(e.wheelDelta||24*-e.detail)<0?1.1:.9;this.frustrum*=t,this.computeCameraView()}else{let e=1e3/(this.app.cameraController.arcRotateCamera.radius/20);this.app.cameraController.arcRotateCamera.panningSensibility=e>2e3?2e3:e<10?10:e}}switchArcRotateCamera(){this.app.scene.activeCamera=this.arcRotateCamera,this.arcRotateCamera.attachControl(this.app.canvas,!0,!0),this.app.iEvent=new f(this.app)}switchFPSCamera(){this.app.iEvent=new p(this.app)}}class A{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)e+" -> "+this.map[e]+"; "}count(){var e=0;for(var t in Object.keys(this.map))++e;return e}clear(){for(var e in this.map)delete this.map[e]}}class y{static getGUID(e){var t,n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];let s=n.length;var r;if(e)for(t=0;t<e;t++)i[t]=n[0|Math.random()*s];else for(i[8]=i[13]=i[18]=i[23]="-",i[14]="4",t=0;t<36;t++)i[t]||(r=0|16*Math.random(),i[t]=n[19==t?3&r|8:r]);return i.join("")}}class B{constructor(e){this.objectType="Light",this.app=e}load(){}}class b extends B{load(){this.light=new d.DirectionalLight(this.id,this.direction,this.app.scene),this.light.position=this.position,this.light.intensity=this.intensity,this.light.diffuse=d.Color3.FromHexString(this.color),this.light.specular=d.Color3.Black()}}class C extends B{load(){this.light=new d.HemisphericLight(this.id,this.direction,this.app.scene),this.light.intensity=this.intensity,this.light.diffuse=d.Color3.FromHexString(this.color),this.light.specular=d.Color3.Black()}}!function(e){e.Point="Point",e.Spot="Spot",e.Directional="Directional",e.Hemispheric="Hemispheric"}(u||(u={}));class v extends B{load(){this.light=new d.PointLight(this.id,this.position.clone(),this.app.scene),this.light.range=this.range,this.light.intensity=this.intensity,this.light.diffuse=d.Color3.FromHexString(this.color),this.light.specular=d.Color3.Black()}}class w extends B{load(){this.light=new d.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=d.Color3.FromHexString(this.color),this.light.specular=d.Color3.Black()}}class E{set text(e){this._text=e,this.ele.innerText=e,e?this.ele.style.display=null:this.close()}constructor(e){this._text="",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: 8px 10px;border: 1px solid #353535;background: #292929;border-radius: 20%;",this.app.canvas.parentElement.appendChild(this.ele),this.close()}update(e){this._text&&(this.ele.style.top=e.event.offsetY+"px",this.ele.style.left=e.event.offsetX+20+"px")}close(){this.ele.style.display="none"}setBackground(e){this.url=e,this.ele.style.background="url("+this.url+") no-repeat",this.ele.style.backgroundSize="cover"}dispose(){this.app.canvas.parentElement.removeChild(this.ele),this.ele=null}}class M{constructor(e){this.lights=new A,this.reflexEnabled=!0,this.reflexIntensity=.5,this.app=e,this.color=new d.Color4(0,.0588,.1176,1),this.reflex(Xd.rl+"resources/environment.env",.5),this.app.scene.fogEnabled=!0,this.app.scene.fogMode=2,this.fogDistance=800,d.Effect.IncludesShadersStore.fogVertex="\n #ifdef FOG\n vFogDistance=(worldPos).xyz;\n #endif\n "}setTransparent(e=1){this.app.scene.clearColor=new d.Color4(this._color.r,this._color.g,this._color.b,this._color.a*e)}default(){this.color=new d.Color4(0,.0588,.1176,1)}set fogDistance(e){this.app.scene.fogDensity=1/e}set color(e){this._color=new d.Color4(e.r,e.g,e.b,e.a),this.app.scene.clearColor=this._color,this.app.scene.fogColor=new d.Color3(this._color.r,this._color.g,this._color.b)}reflex(e,t){const n=new d.CubeTexture(e,this.app.scene);this.app.scene.environmentTexture=n,this.app.scene.environmentIntensity=t}setBackground(e){this.background&&this.background.dispose(),this.background=new d.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 C(this.app);e.id=y.getGUID(12),e.lightType="Hemispheric",e.name="半球光_"+this.lights.count(),e.direction=new d.Vector3(1,1,0),e.color="#FFFFFF",e.intensity=1,this.lights.add(e.id,e);let t=new C(this.app);t.id=y.getGUID(12),t.lightType="Hemispheric",t.name="半球光_"+this.lights.count(),t.direction=new d.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(e){for(let t=0;t<e.length;t++){const n=e[t];let i;n.lightType==u.Hemispheric?(i=new C(this.app),i.id=n.id,i.lightType=n.lightType,i.name=n.name,i.direction=m.ToVector3(n.direction),i.color=n.color,i.intensity=n.intensity):n.lightType==u.Directional?(i=new b(this.app),i.id=n.id,i.lightType=n.lightType,i.name=n.name,i.direction=m.ToVector3(n.direction),i.position=m.ToVector3(n.position),i.color=n.color,i.intensity=n.intensity):n.lightType==u.Spot?(i=new w(this.app),i.id=n.id,i.lightType=n.lightType,i.name=n.name,i.direction=m.ToVector3(n.direction),i.position=m.ToVector3(n.position),i.angle=n.angle,i.exponent=n.exponent,i.range=n.range,i.color=n.color,i.intensity=n.intensity):n.lightType==u.Point&&(i=new v(this.app),i.id=n.id,i.lightType=n.lightType,i.name=n.name,i.position=m.ToVector3(n.position),i.range=n.range,i.color=n.color,i.intensity=n.intensity),i&&this.lights.add(i.id,i)}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.environmentIntensity=this.reflexIntensity*e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}showTips(){this.app.toolTips=new E(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()}}var x,T,I;!function(e){e.Cabinet="Cabinet",e.Corner="Corner",e.Other="Other",e.Door="Door",e.Floor="Floor",e.LeakWater="LeakWater",e.UI3D="UI3D",e.VirtualBox="VirtualBox",e.Wall="Wall",e.Window="Window",e.Conduit="Conduit",e.Building="Building",e.Storey="Storey",e.Campus="Campus"}(x||(x={})),function(e){e.leftClick="leftClick",e.rightClick="rightClick",e.doubleClick="doubleClick",e.eover="eover",e.longPress="longPress",e.out="out",e.click="click"}(T||(T={}));class R{toJosn(e){let t=JSON.parse(e);this.alpha=t.alpha,this.beta=t.beta,this.radius=t.radius,this.minimumLimit=t.minimumLimit,this.maximumLimit=t.maximumLimit,this.minBeta=t.minBeta,this.maxBeta=t.maxBeta,this.focus=m.ToVector3(t.focus)}toString(){return JSON.stringify({alpha:this.alpha,focus:m.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 S{constructor(e){this.app=e}getInto(){}goBack(){}loadProperties(e){this.id="墙角_"+y.getGUID(12),this.name="墙角",this.parentId=e.parentId,this.customNumber=this.id,this.objectType=x.Corner,this.customType=this.objectType,this.height=e.height,this.pints=e.corners}alwaysActive(){this.instance.getChildMeshes().forEach((e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0})),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}optimization(e){this.instance.getChildMeshes().forEach((t=>{e?t.freezeWorldMatrix():t.unfreezeWorldMatrix()})),e?this.instance.freezeWorldMatrix():this.instance.unfreezeWorldMatrix(),this.instance.material&&(e?this.instance.material.freeze():this.instance.material.unfreeze())}setFlash(e){}setTransparent(){}setOpaque(){}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e,t){}removeEventListener(e){}computeView(){}bind(){let e=new Array;for(let t=0;t<this.pints.length;t++)if(this.pints[t].pints.length>2){let n=d.MeshBuilder.CreatePolygon(this.id,{shape:this.pints[t].pints,sideOrientation:d.Mesh.FRONTSIDE},this.app.scene);n.setEnabled(!1),n.position.y=this.pints[t].height,n.isPickable=!0,n.enablePointerMoveEvents=!1,e.push(n)}return!(e.length<1)&&(e.length>1?this.instance=m.MergeMeshes(e,this.app):this.instance=e[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,!0)}toJson(){return{id:this.id,parentId:this.parentId,name:this.name,customNumber:this.customNumber,customType:this.customType,objectType:this.objectType}}completed(){this.alwaysActive(),this.optimization(!0)}}class O{static init(){let e=new d.TWEEN.Tween(this.colors[1]).to({r:1,g:0,b:0},500),t=new d.TWEEN.Tween(this.colors[1]).to({r:1,g:.5,b:.5},500);t.chain(e),e.chain(t),e.start();let n=new d.TWEEN.Tween(this.colors[2]).to({r:1,g:.55,b:0},500),i=new d.TWEEN.Tween(this.colors[2]).to({r:0,g:0,b:0},500);n.chain(i),i.chain(n),n.start();let s=new d.TWEEN.Tween(this.colors[3]).to({r:1,g:.84,b:0},500),r=new d.TWEEN.Tween(this.colors[3]).to({r:0,g:0,b:0},500);s.chain(r),r.chain(s),s.start();let o=new d.TWEEN.Tween(this.colors[4]).to({r:0,g:.75,b:1},500),a=new d.TWEEN.Tween(this.colors[4]).to({r:0,g:0,b:0},500);o.chain(a),a.chain(o),o.start();let c=new d.TWEEN.Tween(this.colors[5]).to({r:.53,g:.8,b:0},500),h=new d.TWEEN.Tween(this.colors[5]).to({r:0,g:0,b:0},500);c.chain(h),h.chain(c),c.start();let l=new d.TWEEN.Tween(this.colors[6]).to({r:.8,g:.8,b:.8},500),u=new d.TWEEN.Tween(this.colors[6]).to({r:0,g:0,b:0},500);l.chain(u),u.chain(l),l.start()}}O.colors={1:d.Color3.Red(),2:new d.Color3(1,.5,0),3:d.Color3.Yellow(),4:new d.Color3(0,1,1),5:d.Color3.Green(),6:d.Color3.Gray()},function(e){e[e.Opaque=0]="Opaque",e[e.Flash=1]="Flash",e[e.Transparent=2]="Transparent"}(I||(I={}));class D{constructor(e){this.executes=new A,this.clickEvents=new A,this.touchtime=(new Date).getTime(),this.statusType=I.Opaque,this.app=e}loadProperties(e){this.id=e.id,this.customNumber=e.customNumber,this.parentId=e.parentId,this.name=e.name,this.baseModel=e.baseModel,this.isLoop=e.isLoop,this.objectType=e.objectType,this.customType=e.customType,this.position=m.ToVector3(e.position),this.rotation=m.ToVector3(e.rotation),this.scaling=m.ToVector3(e.scaling)}setEnabled(e){if(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((e=>e.dispose())),e){let e=new d.Mesh(this.id,this.app.scene);this.app.resources.resources.find(this.baseModel.modelId).meshes[0].getChildMeshes().forEach((t=>{var n=t.createInstance(this.id);n.isPickable=!1,n.enablePointerMoveEvents=!1,n.parent=e})),e.rotation=m.ToVector3(this.rotation.clone()),e.position=m.ToVector3(this.position.clone()),e.scaling=m.ToVector3(this.scaling.clone()),this.instance.addChild(e),this.alwaysActive(),this.optimization(!0)}this.instance.setEnabled(e),this.isPickable=e,this.statusType=I.Opaque,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}set isPickable(e){e?(this.instance.isPickable=this.executes.count()>0,this.executes.find(T.eover)||this.executes.find(T.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1)}get isPickable(){return this.instance.isPickable}bind(){let e=this.app.resources.resources.find(this.baseModel.modelId),t=m.computeBounds(e.meshes[0]);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 d.Vector3((t.maximum.x-t.minimum.x)*this.scaling.x,(t.maximum.y-t.minimum.y)*this.scaling.y,(t.maximum.z-t.minimum.z)*this.scaling.z),0==this.instance.scaling.y&&(this.instance.scaling.y=.01),this.instance.position=m.ToVector3(this.position.clone()),this.instance.position.y=(t.maximum.y-t.minimum.y)/2+this.position.y,this.instance.rotation=m.ToVector3(this.rotation.clone()),this.instance.setEnabled(!1),this.completed()}completed(){this.alwaysActive(),this.optimization(!0),this.computeView()}computeView(){this.Sight=new R;let e=this.instance.getBoundingInfo(),t=m.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=this.instance.getAbsolutePosition(),this.Sight.radius=5*e.boundingSphere.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}optimization(e){this.instance.getChildMeshes().forEach((t=>{e?t.freezeWorldMatrix():t.unfreezeWorldMatrix()})),e?this.instance.freezeWorldMatrix():this.instance.unfreezeWorldMatrix(),this.instance.material&&(e?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 n=null;if(e==T.leftClick||e==T.rightClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,n=new d.ExecuteCodeAction(d.ActionManager.OnPickTrigger,(e=>{let t=this.clickEvents.find(T.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let n=this.clickEvents.find(T.rightClick);n&&2==e.sourceEvent.button&&n(this,e),this.touchtime=(new Date).getTime()})),e=T.click):e==T.doubleClick?n=new d.ExecuteCodeAction(d.ActionManager.OnDoublePickTrigger,(e=>t(this,e))):e==T.eover?(n=new d.ExecuteCodeAction(d.ActionManager.OnPointerOverTrigger,(e=>t(this,e))),this.instance.enablePointerMoveEvents=!0):e==T.longPress?n=new d.ExecuteCodeAction(d.ActionManager.OnLongPressTrigger,(e=>t(this,e))):e==T.out&&(n=new d.ExecuteCodeAction(d.ActionManager.OnPointerOutTrigger,(e=>t(this,e))),this.instance.enablePointerMoveEvents=!0),n){this.action||(this.action=new d.ActionManager(this.app.scene),this.instance.actionManager=this.action);let t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),this.executes.add(e,n),this.action.registerAction(n)}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==T.leftClick||e==T.rightClick||e==T.doubleClick){if(this.clickEvents.remove(e),this.clickEvents.count()>0)return;e=T.click}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let 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(e){this.statusType==I.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((t=>{t.instancedBuffers&&(t.instancedBuffers.color=O.colors[e])})),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.statusType=I.Flash)}setOpaque(){this.statusType!=I.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((e=>{e.setEnabled(!0),e.instancedBuffers&&(e.instancedBuffers.color=new d.Color4(1,1,1,1))})),this.instance.disableEdgesRendering(),this.instance.visibility=0,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.statusType=I.Opaque)}setTransparent(e=.3){this.statusType==I.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.statusType=I.Transparent)}setColor(e="#ffffff"){this.statusType==I.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((t=>{t.instancedBuffers&&(t.instancedBuffers.color=d.Color4.FromHexString(e))})),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1)}play(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((e=>{let t;e.animations.forEach((e=>{-1!=e.name.indexOf("open")&&(t=e)})),t?this.app.scene.beginDirectAnimation(e,[t],0,10*t.getKeys().length,this.isLoop):e.animations.forEach((t=>this.app.scene.beginDirectAnimation(e,[t],0,10*t.getKeys().length,this.isLoop)))})),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}stop(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((e=>{let t;e.animations.forEach((e=>{-1!=e.name.indexOf("close")&&(t=e)})),t?this.app.scene.beginDirectAnimation(e,[t],0,10*t.getKeys().length,!1):e.animations.forEach((t=>this.app.scene.beginDirectAnimation(e,[t],10*t.getKeys().length,0,!1)))})),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}toJson(){return{id:this.id,parentId:this.parentId,name:this.name,customNumber:this.customNumber,customType:this.customType,objectType:this.objectType}}getInto(){this.app.cameraController.flyTo(this.Sight)}goBack(){}}class F extends D{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.objectType=x.Floor,this.vectors=e.vectors,this.buckles=e.buckles,this.height=e.height}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=this.executes.count()>0,this.executes.find(T.eover)||this.executes.find(T.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=d.MeshBuilder.CreatePolygon("地板",{shape:m.Expand(this.vectors,-.01),holes:this.buckles,sideOrientation:d.Mesh.DOUBLESIDE},this.app.scene),this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height-.01,this.instance.id=this.id,this.instance.name="地板";var e=this.app.resources.GetMaterial(this.baseModel).clone(this.id);let t=this.instance.getBoundingInfo();this.Sight=m.getVisualAngle(t,this.app),this.baseModel.isTiling&&(e.diffuseTexture.uScale=(t.maximum.x-t.minimum.x)/this.baseModel.width,e.diffuseTexture.vScale=(t.maximum.z-t.minimum.z)/this.baseModel.length),this.instance.material=e,this.completed()}computeView(){this.Sight=new R;let e=this.instance.getBoundingInfo(),t=m.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=e.boundingBox.center.clone(),this.Sight.focus.y=this.instance.position.y,this.Sight.radius=5*e.boundingSphere.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}}class _ extends D{loadProperties(e){this.id="墙_"+y.getGUID(12),this.objectType=x.Wall,this.parentId=e.parentId,this.name="墙体",this.customNumber=this.id,this.customType=this.objectType,this.walls=e.walls,this.height=e.height,this.baseModel=e.baseModel,this.baseModel&&!this.baseModel.length&&(this.baseModel.length=3.1)}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=m.MergeMeshes(this.walls,this.app),this.instance.setEnabled(!1),this.instance.receiveShadows=!0,this.baseModel?this.nativeMaterial=this.app.resources.GetMergeMaterial(this.baseModel):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.completed()}completed(){this.alwaysActive(),this.optimization(!0)}}class G{constructor(e){this.executes=new A,this.clickEvents=new A,this.touchtime=(new Date).getTime(),this.app=e}loadProperties(e){}bind(){}completed(){this.computeView()}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let n=null;if(e==T.leftClick||e==T.rightClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,n=new d.ExecuteCodeAction(d.ActionManager.OnPickTrigger,(e=>{let t=this.clickEvents.find(T.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let n=this.clickEvents.find(T.rightClick);n&&2==e.sourceEvent.button&&n(this,e),this.touchtime=(new Date).getTime()})),e=T.click):e==T.doubleClick?n=new d.ExecuteCodeAction(d.ActionManager.OnDoublePickTrigger,(e=>t(this,e))):e==T.eover?(n=new d.ExecuteCodeAction(d.ActionManager.OnPointerOverTrigger,(e=>t(this,e))),this.instance.enablePointerMoveEvents=!0):e==T.longPress?n=new d.ExecuteCodeAction(d.ActionManager.OnLongPressTrigger,(e=>t(this,e))):e==T.out&&(n=new d.ExecuteCodeAction(d.ActionManager.OnPointerOutTrigger,(e=>t(this,e))),this.instance.enablePointerMoveEvents=!0),n){this.action||(this.action=new d.ActionManager(this.app.scene),this.instance.actionManager=this.action);let t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),this.executes.add(e,n),this.action.registerAction(n)}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==T.leftClick||e==T.rightClick||e==T.doubleClick){if(this.clickEvents.remove(e),this.clickEvents.count()>0)return;e=T.click}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let 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}load(e,t){let n=new Array;for(let e=0;e<t.length;e++){let i=t[e];i.objectType==x.Wall&&(i.height||(i.height=3.1),i.ply||(i.ply=.09),n.push(i))}let i=new A;for(let e=0;e<t.length;e++){let s=t[e];s.objectType==x.Corner&&(i.add(s.id,s.corner),s.pints.length>2&&(s.height=3.1,s.walls.forEach((e=>{n.forEach((t=>{e==t.id&&parseFloat(t.height)<s.height&&(s.height=parseFloat(t.height))}))}))))}if(!e){let e=new Array;for(let n=0;n<t.length;n++){let i=t[n];i.objectType==x.Corner&&e.push(i)}let n=new S(this.app);n.loadProperties({parentId:this.id,height:this.position.y,corners:e}),n.bind()?this.app.project.objectDatas.add(n.id,n):n=null}for(let e=0;e<t.length;e++){let n=t[e];if(n.objectType!=x.Floor)continue;n.vectors=new Array;let s=t[e];s.pints.forEach((e=>{i.find(e),n.vectors.push(i.find(e))})),n.buckles=new Array,s.holes&&s.holes.forEach((e=>{let t=new Array;e.forEach((e=>t.push(i.find(e)))),n.buckles.push(t)})),s.middles&&s.middles.forEach((e=>{let s=Array();for(let n=0;n<t.length;n++)t[n].id==e&&t[n].pints.forEach((e=>{let t=i.find(e);s.push(new d.Vector3(t.x,0,t.z))}));n.buckles.push(s)})),n.height=this.position.y;let r=new F(this.app);r.loadProperties(n),r.bind(),this.app.project.objectDatas.add(r.id,r)}if(i=null,!e){let e=new A;e.add("body",{t:"",walls:new Array});for(let t=0;t<n.length;t++){let i=d.MeshBuilder.ExtrudePolygon(n[t].id,{shape:[m.ToVector3(n[t].wtop),m.ToVector3(n[t].wleft),m.ToVector3(n[t].wbottom),m.ToVector3(n[t].wright)],depth:parseFloat(n[t].height),sideOrientation:d.Mesh.FRONTSIDE},this.app.scene);i.setEnabled(!1),i.position.y=parseFloat(n[t].height),i.subMeshes=[];var s=i.getTotalVertices();i.subMeshes.push(new d.SubMesh(0,0,s,0,6,i)),i.subMeshes.push(new d.SubMesh(0,1,s,18,6,i)),i.subMeshes.push(new d.SubMesh(0,2,s,30,6,i));for(let e=0;e<n[t].wallwindows.length;e++){const s=d.CSG.FromMesh(i);let a=this.app.project.objectDatas.find(n[t].wallwindows[e]);var r=a.instance.getBoundingInfo(),o=d.MeshBuilder.CreateBox((new Date).getTime().toString(),{height:r.maximum.y-r.minimum.y,width:r.maximum.x-r.minimum.x,depth:2*parseFloat(n[t].ply)+.1},this.app.scene);o.position=a.instance.position.clone(),o.position.y=(r.maximum.y-r.minimum.y)/2+a.height,o.rotation=a.instance.rotation.clone();const c=d.CSG.FromMesh(o);let h=s.subtract(c);o.dispose(),i.dispose(),i=h.toMesh(n[t].id,null,this.app.scene,!0),i.setEnabled(!1)}let a=e.find(n[t].leftMap.modelId);a||(a={t:n[t].leftMap,walls:new Array},e.add(n[t].leftMap.modelId,a));let c=e.find(n[t].rightMap.modelId);c||(c={t:n[t].rightMap,walls:new Array},e.add(n[t].rightMap.modelId,c));let h=m.DeconsTructMesh(i,parseFloat(n[t].height),this.app);for(let t=0;t<h.length;t++)2==t||3==t?a.walls.push(h[t]):4==t||5==t?c.walls.push(h[t]):e.find("body").walls.push(h[t])}for(const t in e.map){let n=e.find(t);if(n.walls.length>0){let e=new _(this.app);e.loadProperties({baseModel:n.t,walls:n.walls,parentId:this.id,height:this.position.y}),e.bind(),this.app.project.objectDatas.add(e.id,e)}}}this.completed(),n=null}toJson(){return{id:this.id,parentId:this.parentId,name:this.name,customNumber:this.customNumber,customType:this.customType,objectType:this.objectType,index:this.index,layerHeight:this.layerHeight,layerName:this.layerName}}computeView(){var e,t;let n=this.app.project.getChildsById(this.id,!0);n.length>0&&(e=t=n[0].instance.position.clone());for(let i=0;i<n.length;i++){let s=n[i];if(s.objectType==x.Storey||s.objectType==x.Campus)continue;let r=s.instance.getBoundingInfo();e=d.Vector3.Minimize(e,r.minimum.add(s.instance.position)),t=d.Vector3.Maximize(t,r.maximum.add(s.instance.position))}e&&t||(e=d.Vector3.Zero(),t=new d.Vector3(12,0,8)),this.Sight=new R;let i=m.getVisualAngle(new d.BoundingInfo(e,t),this.app);this.Sight.alpha=i.alpha,this.Sight.beta=i.beta,this.Sight.focus=i.focus,this.Sight.radius=i.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}getInto(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(let e in this.app.project.objectDatas.map){let t=this.app.project.objectDatas.find(e);t.setEnabled(t.parentId==this.id)}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}goBack(){}}class L extends D{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.height=e.baseModel.height,this.objectType=x.Door,this.rotation=m.ToVector3(e.rotation),this.position=m.ToVector3(e.position)}setEnabled(e){if(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((e=>e.dispose())),e){let e=new d.Mesh(this.id,this.app.scene);this.app.resources.resources.find(this.baseModel.modelId).meshes[0].getChildMeshes().forEach((t=>{var n=t.createInstance(this.id);n.isPickable=!1,n.enablePointerMoveEvents=!1,n.parent=e})),e.rotation=m.ToVector3(this.rotation.clone()),e.position=m.ToVector3(this.position.clone()),this.instance.addChild(e),this.alwaysActive(),this.optimization(!0)}this.instance.setEnabled(e),this.isPickable=e,this.statusType=I.Opaque,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){let e=this.app.resources.resources.find(this.baseModel.modelId),t=m.computeBounds(e.meshes[0]);this.instance=this.app.resources.BOX.clone(this.id),this.instance.setBoundingInfo(t),this.instance.id=this.id,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.scaling=new d.Vector3(t.maximum.x-t.minimum.x,t.maximum.y-t.minimum.y,t.maximum.z-t.minimum.z),this.instance.position=m.ToVector3(this.position.clone()),this.instance.position.y=(t.maximum.y-t.minimum.y)/2+this.position.y,this.instance.rotation=m.ToVector3(this.rotation.clone()),this.instance.setEnabled(!1),this.completed()}}class P extends D{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.height=e.baseModel.height,this.objectType=x.Window,this.rotation=m.ToVector3(e.rotation),this.position=m.ToVector3(e.position)}setEnabled(e){if(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach((e=>e.dispose())),e){let e=new d.Mesh(this.id,this.app.scene);this.app.resources.resources.find(this.baseModel.modelId).meshes[0].getChildMeshes().forEach((t=>{var n=t.createInstance(this.id);n.isPickable=!1,n.enablePointerMoveEvents=!1,n.parent=e})),e.rotation=m.ToVector3(this.rotation.clone()),e.position=m.ToVector3(this.position.clone()),this.instance.addChild(e),this.alwaysActive(),this.optimization(!0)}this.instance.setEnabled(e),this.isPickable=e,this.statusType=I.Opaque,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){let e=this.app.resources.resources.find(this.baseModel.modelId),t=m.computeBounds(e.meshes[0]);this.instance=this.app.resources.BOX.clone(this.id),this.instance.setBoundingInfo(t),this.instance.id=this.id,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.scaling=new d.Vector3(t.maximum.x-t.minimum.x,t.maximum.y-t.minimum.y,t.maximum.z-t.minimum.z),this.instance.position=m.ToVector3(this.position.clone()),this.instance.position.y=(t.maximum.y-t.minimum.y)/2+this.position.y,this.instance.rotation=m.ToVector3(this.rotation.clone()),this.instance.setEnabled(!1),this.completed()}}class k extends G{loadProperties(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.index=e.index,this.layerName=this.index<0?"B"+this.index:"F"+(this.index+1),this.layerHeight=e.layerHeight,this.objectType=e.objectType,this.customNumber=e.customNumber?e.customNumber:e.id,this.customType=e.customType?e.customType:this.objectType,this.position=m.ToVector3(e.position),this.rotation=m.ToVector3(e.rotation),this.scaling=m.ToVector3(e.scaling)}bind(){this.instance=d.MeshBuilder.CreateGround(this.id,{width:this.scaling.x,height:this.scaling.z},this.app.scene),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1;let e=new d.StandardMaterial("mat_"+this.id);e.diffuseColor=d.Color3.White(),e.alpha=0,e.backFaceCulling=!1,this.instance.material=e,this.instance.position=this.position,this.instance.position.y-=.01,this.instance.rotation=this.rotation.clone(),this.setEnabled(!1)}alwaysActive(){this.instance.getChildMeshes().forEach((e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0})),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}completed(){this.alwaysActive(),this.computeView()}computeView(){var e,t;let n=this.app.project.getChildsById(this.id);n.length>0&&(e=t=n[0].instance.position.clone());for(let i=0;i<n.length;i++){let s=n[i];if(s.objectType==x.Storey||s.objectType==x.Campus||s.objectType==x.Wall||s.objectType==x.Corner)continue;let r=s.instance.getBoundingInfo();e=d.Vector3.Minimize(e,r.minimum.add(s.instance.position)),t=d.Vector3.Maximize(t,r.maximum.add(s.instance.position))}e&&t||(e=d.Vector3.Zero(),t=new d.Vector3(12,0,8)),this.Sight=m.getVisualAngle(new d.BoundingInfo(e,t),this.app)}}class N extends D{completed(){this.alwaysActive(),this.optimization(!0),this.computeView()}computeView(){let e=this.app.resources.resources.find(this.baseModel.modelId);this.instance.setBoundingInfo(m.computeBounds(e.meshes[0])),this.Sight=new R;let t=this.instance.getBoundingInfo(),n=m.getVisualAngle(t,this.app);this.Sight.alpha=n.alpha,this.Sight.beta=n.beta,this.Sight.focus=this.position.clone(),this.Sight.radius=2*t.boundingSphere.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=3*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}getInto(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let e=new A;this.app.project.getChildsById(this.id).forEach((t=>{let n=!0,i=this.app.project.getChildsById(t.id);for(let s=0;s<i.length;s++){let r=i[s];(r instanceof _||r instanceof L||r instanceof S||r instanceof P||r instanceof F)&&(e.add(r.id,r.id),n=!1),r instanceof _&&t instanceof k&&(r.addEventListener(T.leftClick,(()=>{this.app.project.switchLevel(t.id)})),r.addEventListener(T.eover,(()=>{this.app.toolTips.text=t.layerName})),r.addEventListener(T.out,(()=>{this.app.toolTips.text=""})))}e.add(t.id,t.id)}));for(const t in this.app.project.objectDatas.map){let n=this.app.project.objectDatas.find(t);e.find(n.id)||n.parentId==this.parentId?n.setEnabled(!0):n.setEnabled(!1)}this.setEnabled(!1);let t=this.app.project.getChildsById(this.parentId);for(let e=0;e<t.length;e++){const n=t[e];n instanceof N&&n.id!=this.id&&(n.isPickable=!1,this.app.resources.setTransparentById(n.baseModel.modelId,.3))}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}goBack(){let e=this.app.project.getChildsById(this.parentId);for(let t=0;t<e.length;t++){const n=e[t];n instanceof N&&n.id!=this.id&&(n.isPickable=!0,this.app.resources.setTransparentById(n.baseModel.modelId,1))}this.app.toolTips.text="",this.app.project.getChildsById(this.id).forEach((e=>{let t=this.app.project.getChildsById(e.id);for(let e=0;e<t.length;e++){let n=t[e];n instanceof _&&(n.removeEventListener(T.leftClick),n.removeEventListener(T.eover),n.removeEventListener(T.out))}}))}}class U{constructor(e){this.objectDatas=new A,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,t=!1){e||(e=this.root.id);let n=new Array;const i=e=>{for(const s in this.objectDatas.map){let r=this.objectDatas.find(s);r.parentId==e&&(n.push(r),t&&i(r.id))}};return i(e),n}getSceneTree(e=this.root.id,t=[]){e||(e=this.root.id);const n=(e,i)=>{for(const s in this.objectDatas.map){let r=this.objectDatas.find(s);if(r.parentId!=e)continue;let o=!1;for(let e=0;e<t.length;e++)r.customType!=t[e]||(o=!0);o||(i.push(Object.assign(Object.assign({},r.toJson()),{children:[]})),n(r.id,i[i.length-1].children))}};let i=this.objectDatas.find(e);if(!i)return;let s=Object.assign(Object.assign({},i.toJson()),{children:[]});return n(this.root.id,s.children),s}findObjectById(e){return this.objectDatas.find(e)}findObjectByCustomNumber(e){let t=[];for(const n in this.objectDatas.map){let i=this.objectDatas.find(n);i.customNumber==e&&t.push(i)}return 0==t.length?null:(t.length,t[0])}findObjectsByCustomType(e,t={isCurrent:!1,isEnabled:!1}){let n=[],i=this.current.id;this.current instanceof G||!this.current.parentId||(i=this.current.parentId);for(const s in this.objectDatas.map){let r=this.objectDatas.find(s);r.customType==e&&(t.isCurrent&&r.parentId!=i||t.isEnabled&&1!=r.instance.isEnabled()||n.push(r))}return n}findObjectsByType(e){let t=new Array;for(const n in this.objectDatas.map){let i=this.objectDatas.find(n);i.objectType==e&&t.push(i)}return t}computeSight(e){var t=d.Vector3.Zero(),n=d.Vector3.Zero();for(let i=0;i<e.length;i++){let s=e[i];if(s.objectType==x.Storey||s.objectType==x.Campus)continue;let r=s.instance.getBoundingInfo();t&&n||(t=n=r.boundingBox.center.clone()),t=d.Vector3.Minimize(t,r.minimum.add(s.instance.position)),n=d.Vector3.Maximize(n,r.maximum.add(s.instance.position))}return t&&n||(t=d.Vector3.Zero(),n=new d.Vector3(12,0,8)),m.getVisualAngle(new d.BoundingInfo(t,n),this.app)}switchLevel(e=this.root.id,t=!0){e||(e=this.root.id);let n=this.objectDatas.find(e);if(n){if(this.current&&this.current.goBack(),!(n instanceof G||n instanceof N)){let e=this.objectDatas.find(n.parentId);this.current instanceof G||this.current instanceof N?n.parentId!=this.current.id&&e.getInto():n.parentId!=this.current.parentId&&e.getInto()}n.getInto(),this.current=n,this.levelEvent&&this.levelEvent(this.current),t&&(n instanceof G||n instanceof N)&&this.app.cameraController.perspective(n.Sight)}}goBack(){this.app.isDefaultMutual&&this.current&&this.current.parentId&&(this.current.goBack&&this.current.goBack(),this.switchLevel(this.current.parentId))}getTypes(e=null){let t=[],n=new A;for(let t in this.objectDatas.map){let i=this.objectDatas.find(t);e&&i.parentId!=e||(n.find(i.objectType)||n.add(i.objectType,i.objectType))}for(let e in n.map)t.push(e);return t}getCustomTypes(e=null){let t=[],n=new A;for(let t in this.objectDatas.map){let i=this.objectDatas.find(t);e&&i.parentId!=e||(n.find(i.customType)||n.add(i.customType,i.customType))}for(let e in n.map)t.push(e);return t}}var H=function(e,t,n,i){return new(n||(n=Promise))((function(s,r){function o(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};class j{constructor(e){this.walls=new A,this.resources=new A,this.ndoeMats=new A,this.Materials=new A,this.Textures=new A,this.MergeMaterials=new A,this.app=e;let t=y.getGUID(12);this.transparentBox=d.MeshBuilder.CreateBox(t,{size:1},this.app.scene),this.transparentBox.alwaysSelectAsActiveMesh=!0;let n=new d.StandardMaterial(t,this.app.scene);n.diffuseTexture=new d.Texture(Xd.rl+"resources/white.jpg",this.app.scene,!0,!1),n.alphaMode=d.Engine.ALPHA_COMBINE,n.emissiveColor=d.Color3.Green(),this.transparentBox.material=n,this.transparentBox.setEnabled(!1),this.transparentBox.visibility=.3;let i=y.getGUID(12);this.BOX=d.MeshBuilder.CreateBox(i,{size:1},this.app.scene),this.BOX.edgesColor=d.Color4.FromHexString("#4ba3fff2"),this.BOX.setEnabled(!1),this.BOX.visibility=0,this.FogTex=new d.Texture(Xd.rl+"resources/fogtex.png",this.app.scene,!0,!1)}loadModelMesh(e){return H(this,void 0,void 0,(function*(){let t=this.resources.find(e.modelId);if(!t)try{t=yield d.SceneLoader.LoadAssetContainerAsync(Xd.rl+"bundle/"+e.modelId+"/",e.modelId+e.extension,this.app.scene),t.animationGroups.length>0&&t.animationGroups[0].stop(),t.addAllToScene(),t.meshes[0].setEnabled(!1),t.meshes[0].getChildMeshes().forEach((n=>{if(n.metadata&&n.metadata.gltf&&n.metadata.gltf.extras){if(n.metadata.gltf.extras.LightMapName){let t=this.LoadLightMap(e.modelId,n.metadata.gltf.extras.LightMapName);t.coordinatesIndex=1,t.level=2,n.material.lightmapTexture=t,n.material.useLightmapAsShadowmap=!0}t.isExtras=!0,n.metadata.gltf.extras.U&&d.Animation.CreateAndStartAnimation("u",n.material.albedoTexture,"uOffset",30*n.metadata.gltf.extras.Uspeed,30,0,1,1),n.metadata.gltf.extras.V&&d.Animation.CreateAndStartAnimation("v",n.material.albedoTexture,"vOffset",30*n.metadata.gltf.extras.Vspeed,30,0,1,1)}})),t.isExtras||t.meshes[0].getChildMeshes().forEach((e=>{e.registerInstancedBuffer("color",4),e.instancedBuffers.color=new d.Color4(1,1,1,1)})),this.resources.add(e.modelId,t)}catch(e){}return t}))}loadModelMeshAsync(e,t){let n=this.resources.find(e.modelId);n?t(n):d.SceneLoader.LoadAssetContainerAsync(Xd.rl+"bundle/"+e.modelId+"/",e.modelId+e.extension,this.app.scene).then((n=>{n.animationGroups.length>0&&n.animationGroups[0].stop(),this.resources.add(e.modelId,n),t(n)})).catch((()=>{}))}GetMaterial(e){let t=this.Materials.find(e.modelId);if(void 0===t){let n=this.GetTexture(e);t=new d.StandardMaterial(e.modelId,this.app.scene),t.alphaMode=d.Engine.ALPHA_COMBINE,t.diffuseTexture=n,this.Materials.add(e.modelId,t)}return t}GetTexture(e){let t=this.Textures.find(e.modelId);return void 0===t&&(t=new d.Texture(Xd.rl+"texture/"+e.modelId+e.extension,this.app.scene,!1),".png"==e.extension&&(t.hasAlpha=!0),this.Textures.add(e.modelId,t)),t}LoadLightMap(e,t){let n=this.Textures.find(e+t);return void 0===n&&(n=new d.Texture(Xd.rl+"bundle/"+e+"/"+t,this.app.scene,!1,!1),this.Textures.add(e+t,n)),n}GetMergeMaterial(e){let t=this.MergeMaterials.find(e.modelId);if(void 0===t){t=new d.CustomMaterial(e.modelId,this.app.scene),t.alphaMode=2,this.MergeMaterials.add(e.modelId,t),t.AddUniform("textureData","sampler2D",null),t.Vertex_Definitions("\n varying vec3 localPos ; \n varying vec3 localNrm ;\n "),t.Fragment_Definitions("\n varying vec3 localPos ;\n varying vec3 localNrm ;"),t.Vertex_Before_PositionUpdated("\n localPos = position.xyz;\n localNrm = normal;\n ");let n=this.GetTexture(e);".png"==e.extension&&(n.hasAlpha=!0,t.alpha=.9),e.length||(e.length=3.1),e.width||(e.width=1.6),t.onBindObservable.add((()=>t.getEffect().setTexture("textureData",n))),t.Fragment_Custom_Diffuse("\n vec3 newUV = vec3(abs(localPos.x)/"+e.width+",abs(localPos.y)/"+e.length+",abs(localPos.z)/"+e.width+");\n if(abs(localNrm.z)>abs(localNrm.x)){\n vec4 res = texture2D(textureData,newUV.xy);\n diffuseColor = res.rgb; \n alpha = res.a;\n }\n else {\n vec4 res = texture2D(textureData,newUV.zy);\n diffuseColor = res.rgb; \n alpha = res.a;\n }\n "),t.freeze()}return t}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 e in this.resources.map)this.resources.find(e).removeAllFromScene(),this.resources.remove(e);this.resources.clear();for(const e in this.Textures.map)this.Textures.find(e).dispose(),this.Textures.remove(e);this.Textures.clear()}}GetWalls(e,t){return H(this,void 0,void 0,(function*(){let n=yield d.SceneLoader.LoadAssetContainerAsync(e,t+".gltf",this.app.scene);if(n.meshes){let e=n.meshes[0].getChildMeshes();for(let t=0;t<e.length;t++)this.walls.add(e[t].id,e[t])}}))}setTransparent(e=1){for(const t in this.resources.map){this.resources.find(t).meshes.forEach((t=>t.visibility=e))}}setTransparentById(e,t=1){let n=this.resources.find(e);n&&n.meshes.forEach((e=>e.visibility=t))}}function J(e,t){return function(){return e.apply(t,arguments)}}const{toString:V}=Object.prototype,{getPrototypeOf:z}=Object,K=(e=>t=>{const n=V.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),W=e=>(e=e.toLowerCase(),t=>K(t)===e),Q=e=>t=>typeof t===e,{isArray:X}=Array,Y=Q("undefined");const q=W("ArrayBuffer");const Z=Q("string"),$=Q("function"),ee=Q("number"),te=e=>null!==e&&"object"==typeof e,ne=e=>{if("object"!==K(e))return!1;const t=z(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},ie=W("Date"),se=W("File"),re=W("Blob"),oe=W("FileList"),ae=W("URLSearchParams");function ce(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let i,s;if("object"!=typeof e&&(e=[e]),X(e))for(i=0,s=e.length;i<s;i++)t.call(null,e[i],i,e);else{const s=n?Object.getOwnPropertyNames(e):Object.keys(e),r=s.length;let o;for(i=0;i<r;i++)o=s[i],t.call(null,e[o],o,e)}}function he(e,t){t=t.toLowerCase();const n=Object.keys(e);let i,s=n.length;for(;s-- >0;)if(i=n[s],t===i.toLowerCase())return i;return null}const le="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,ue=e=>!Y(e)&&e!==le;const de=(fe="undefined"!=typeof Uint8Array&&z(Uint8Array),e=>fe&&e instanceof fe);var fe;const pe=W("HTMLFormElement"),me=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ge=W("RegExp"),Ae=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),i={};ce(n,((n,s)=>{!1!==t(n,s,e)&&(i[s]=n)})),Object.defineProperties(e,i)},ye="abcdefghijklmnopqrstuvwxyz",Be="0123456789",be={DIGIT:Be,ALPHA:ye,ALPHA_DIGIT:ye+ye.toUpperCase()+Be};const Ce=W("AsyncFunction"),ve={isArray:X,isArrayBuffer:q,isBuffer:function(e){return null!==e&&!Y(e)&&null!==e.constructor&&!Y(e.constructor)&&$(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||$(e.append)&&("formdata"===(t=K(e))||"object"===t&&$(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&q(e.buffer),t},isString:Z,isNumber:ee,isBoolean:e=>!0===e||!1===e,isObject:te,isPlainObject:ne,isUndefined:Y,isDate:ie,isFile:se,isBlob:re,isRegExp:ge,isFunction:$,isStream:e=>te(e)&&$(e.pipe),isURLSearchParams:ae,isTypedArray:de,isFileList:oe,forEach:ce,merge:function e(){const{caseless:t}=ue(this)&&this||{},n={},i=(i,s)=>{const r=t&&he(n,s)||s;ne(n[r])&&ne(i)?n[r]=e(n[r],i):ne(i)?n[r]=e({},i):X(i)?n[r]=i.slice():n[r]=i};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&ce(arguments[e],i);return n},extend:(e,t,n,{allOwnKeys:i}={})=>(ce(t,((t,i)=>{n&&$(t)?e[i]=J(t,n):e[i]=t}),{allOwnKeys:i}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,i)=>{let s,r,o;const a={};if(t=t||{},null==e)return t;do{for(s=Object.getOwnPropertyNames(e),r=s.length;r-- >0;)o=s[r],i&&!i(o,e,t)||a[o]||(t[o]=e[o],a[o]=!0);e=!1!==n&&z(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:K,kindOfTest:W,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const i=e.indexOf(t,n);return-1!==i&&i===n},toArray:e=>{if(!e)return null;if(X(e))return e;let t=e.length;if(!ee(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let i;for(;(i=n.next())&&!i.done;){const n=i.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const i=[];for(;null!==(n=e.exec(t));)i.push(n);return i},isHTMLForm:pe,hasOwnProperty:me,hasOwnProp:me,reduceDescriptors:Ae,freezeMethods:e=>{Ae(e,((t,n)=>{if($(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const i=e[n];$(i)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},i=e=>{e.forEach((e=>{n[e]=!0}))};return X(e)?i(e):i(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:he,global:le,isContextDefined:ue,ALPHABET:be,generateString:(e=16,t=be.ALPHA_DIGIT)=>{let n="";const{length:i}=t;for(;e--;)n+=t[Math.random()*i|0];return n},isSpecCompliantForm:function(e){return!!(e&&$(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,i)=>{if(te(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[i]=e;const s=X(e)?[]:{};return ce(e,((e,t)=>{const r=n(e,i+1);!Y(r)&&(s[t]=r)})),t[i]=void 0,s}}return e};return n(e,0)},isAsyncFn:Ce,isThenable:e=>e&&(te(e)||$(e))&&$(e.then)&&$(e.catch)};function we(e,t,n,i,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),i&&(this.request=i),s&&(this.response=s)}ve.inherits(we,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:ve.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ee=we.prototype,Me={};["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","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Me[e]={value:e}})),Object.defineProperties(we,Me),Object.defineProperty(Ee,"isAxiosError",{value:!0}),we.from=(e,t,n,i,s,r)=>{const o=Object.create(Ee);return ve.toFlatObject(e,o,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),we.call(o,e.message,t,n,i,s),o.cause=e,o.name=e.name,r&&Object.assign(o,r),o};const xe=we;function Te(e){return ve.isPlainObject(e)||ve.isArray(e)}function Ie(e){return ve.endsWith(e,"[]")?e.slice(0,-2):e}function Re(e,t,n){return e?e.concat(t).map((function(e,t){return e=Ie(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const Se=ve.toFlatObject(ve,{},null,(function(e){return/^is[A-Z]/.test(e)}));const Oe=function(e,t,n){if(!ve.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const i=(n=ve.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!ve.isUndefined(t[e])}))).metaTokens,s=n.visitor||h,r=n.dots,o=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&ve.isSpecCompliantForm(t);if(!ve.isFunction(s))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(ve.isDate(e))return e.toISOString();if(!a&&ve.isBlob(e))throw new xe("Blob is not supported. Use a Buffer instead.");return ve.isArrayBuffer(e)||ve.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function h(e,n,s){let a=e;if(e&&!s&&"object"==typeof e)if(ve.endsWith(n,"{}"))n=i?n:n.slice(0,-2),e=JSON.stringify(e);else if(ve.isArray(e)&&function(e){return ve.isArray(e)&&!e.some(Te)}(e)||(ve.isFileList(e)||ve.endsWith(n,"[]"))&&(a=ve.toArray(e)))return n=Ie(n),a.forEach((function(e,i){!ve.isUndefined(e)&&null!==e&&t.append(!0===o?Re([n],i,r):null===o?n:n+"[]",c(e))})),!1;return!!Te(e)||(t.append(Re(s,n,r),c(e)),!1)}const l=[],u=Object.assign(Se,{defaultVisitor:h,convertValue:c,isVisitable:Te});if(!ve.isObject(e))throw new TypeError("data must be an object");return function e(n,i){if(!ve.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+i.join("."));l.push(n),ve.forEach(n,(function(n,r){!0===(!(ve.isUndefined(n)||null===n)&&s.call(t,n,ve.isString(r)?r.trim():r,i,u))&&e(n,i?i.concat(r):[r])})),l.pop()}}(e),t};function De(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Fe(e,t){this._pairs=[],e&&Oe(e,this,t)}const _e=Fe.prototype;_e.append=function(e,t){this._pairs.push([e,t])},_e.toString=function(e){const t=e?function(t){return e.call(this,t,De)}:De;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};const Ge=Fe;function Le(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Pe(e,t,n){if(!t)return e;const i=n&&n.encode||Le,s=n&&n.serialize;let r;if(r=s?s(t,n):ve.isURLSearchParams(t)?t.toString():new Ge(t,n).toString(i),r){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}const ke=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ve.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Ne={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ue={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ge,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};const He=function(e){function t(e,n,i,s){let r=e[s++];const o=Number.isFinite(+r),a=s>=e.length;if(r=!r&&ve.isArray(i)?i.length:r,a)return ve.hasOwnProp(i,r)?i[r]=[i[r],n]:i[r]=n,!o;i[r]&&ve.isObject(i[r])||(i[r]=[]);return t(e,n,i[r],s)&&ve.isArray(i[r])&&(i[r]=function(e){const t={},n=Object.keys(e);let i;const s=n.length;let r;for(i=0;i<s;i++)r=n[i],t[r]=e[r];return t}(i[r])),!o}if(ve.isFormData(e)&&ve.isFunction(e.entries)){const n={};return ve.forEachEntry(e,((e,i)=>{t(function(e){return ve.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),i,n,0)})),n}return null},je={"Content-Type":void 0};const Je={transitional:Ne,adapter:["xhr","http"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=ve.isObject(e);s&&ve.isHTMLForm(e)&&(e=new FormData(e));if(ve.isFormData(e))return i&&i?JSON.stringify(He(e)):e;if(ve.isArrayBuffer(e)||ve.isBuffer(e)||ve.isStream(e)||ve.isFile(e)||ve.isBlob(e))return e;if(ve.isArrayBufferView(e))return e.buffer;if(ve.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let r;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Oe(e,new Ue.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,i){return Ue.isNode&&ve.isBuffer(e)?(this.append(t,e.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((r=ve.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Oe(r?{"files[]":e}:e,t&&new t,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),function(e,t,n){if(ve.isString(e))try{return(t||JSON.parse)(e),ve.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Je.transitional,n=t&&t.forcedJSONParsing,i="json"===this.responseType;if(e&&ve.isString(e)&&(n&&!this.responseType||i)){const n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw xe.from(e,xe.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:Ue.classes.FormData,Blob:Ue.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};ve.forEach(["delete","get","head"],(function(e){Je.headers[e]={}})),ve.forEach(["post","put","patch"],(function(e){Je.headers[e]=ve.merge(je)}));const Ve=Je,ze=ve.toObjectSet(["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"]),Ke=Symbol("internals");function We(e){return e&&String(e).trim().toLowerCase()}function Qe(e){return!1===e||null==e?e:ve.isArray(e)?e.map(Qe):String(e)}function Xe(e,t,n,i,s){return ve.isFunction(i)?i.call(this,t,n):(s&&(t=n),ve.isString(t)?ve.isString(i)?-1!==t.indexOf(i):ve.isRegExp(i)?i.test(t):void 0:void 0)}class Ye{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function s(e,t,n){const s=We(t);if(!s)throw new Error("header name must be a non-empty string");const r=ve.findKey(i,s);(!r||void 0===i[r]||!0===n||void 0===n&&!1!==i[r])&&(i[r||t]=Qe(e))}const r=(e,t)=>ve.forEach(e,((e,n)=>s(e,n,t)));return ve.isPlainObject(e)||e instanceof this.constructor?r(e,t):ve.isString(e)&&(e=e.trim())&&!(e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))(e)?r((e=>{const t={};let n,i,s;return e&&e.split("\n").forEach((function(e){s=e.indexOf(":"),n=e.substring(0,s).trim().toLowerCase(),i=e.substring(s+1).trim(),!n||t[n]&&ze[n]||("set-cookie"===n?t[n]?t[n].push(i):t[n]=[i]:t[n]=t[n]?t[n]+", "+i:i)})),t})(e),t):null!=e&&s(t,e,n),this}get(e,t){if(e=We(e)){const n=ve.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=n.exec(e);)t[i[1]]=i[2];return t}(e);if(ve.isFunction(t))return t.call(this,e,n);if(ve.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=We(e)){const n=ve.findKey(this,e);return!(!n||void 0===this[n]||t&&!Xe(0,this[n],n,t))}return!1}delete(e,t){const n=this;let i=!1;function s(e){if(e=We(e)){const s=ve.findKey(n,e);!s||t&&!Xe(0,n[s],s,t)||(delete n[s],i=!0)}}return ve.isArray(e)?e.forEach(s):s(e),i}clear(e){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const s=t[n];e&&!Xe(0,this[s],s,e,!0)||(delete this[s],i=!0)}return i}normalize(e){const t=this,n={};return ve.forEach(this,((i,s)=>{const r=ve.findKey(n,s);if(r)return t[r]=Qe(i),void delete t[s];const o=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(s):String(s).trim();o!==s&&delete t[s],t[o]=Qe(i),n[o]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ve.forEach(this,((n,i)=>{null!=n&&!1!==n&&(t[i]=e&&ve.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Ke]=this[Ke]={accessors:{}}).accessors,n=this.prototype;function i(e){const i=We(e);t[i]||(!function(e,t){const n=ve.toCamelCase(" "+t);["get","set","has"].forEach((i=>{Object.defineProperty(e,i+n,{value:function(e,n,s){return this[i].call(this,t,e,n,s)},configurable:!0})}))}(n,e),t[i]=!0)}return ve.isArray(e)?e.forEach(i):i(e),this}}Ye.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ve.freezeMethods(Ye.prototype),ve.freezeMethods(Ye);const qe=Ye;function Ze(e,t){const n=this||Ve,i=t||n,s=qe.from(i.headers);let r=i.data;return ve.forEach(e,(function(e){r=e.call(n,r,s.normalize(),t?t.status:void 0)})),s.normalize(),r}function $e(e){return!(!e||!e.__CANCEL__)}function et(e,t,n){xe.call(this,null==e?"canceled":e,xe.ERR_CANCELED,t,n),this.name="CanceledError"}ve.inherits(et,xe,{__CANCEL__:!0});const tt=et;const nt=Ue.isStandardBrowserEnv?{write:function(e,t,n,i,s,r){const o=[];o.push(e+"="+encodeURIComponent(t)),ve.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),ve.isString(i)&&o.push("path="+i),ve.isString(s)&&o.push("domain="+s),!0===r&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function it(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const st=Ue.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let n;function i(n){let i=n;return e&&(t.setAttribute("href",i),i=t.href),t.setAttribute("href",i),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=i(window.location.href),function(e){const t=ve.isString(e)?i(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0};const rt=function(e,t){e=e||10;const n=new Array(e),i=new Array(e);let s,r=0,o=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),h=i[o];s||(s=c),n[r]=a,i[r]=c;let l=o,u=0;for(;l!==r;)u+=n[l++],l%=e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-s<t)return;const d=h&&c-h;return d?Math.round(1e3*u/d):void 0}};function ot(e,t){let n=0;const i=rt(50,250);return s=>{const r=s.loaded,o=s.lengthComputable?s.total:void 0,a=r-n,c=i(a);n=r;const h={loaded:r,total:o,progress:o?r/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&r<=o?(o-r)/c:void 0,event:s};h[t?"download":"upload"]=!0,e(h)}}const at="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){let i=e.data;const s=qe.from(e.headers).normalize(),r=e.responseType;let o;function a(){e.cancelToken&&e.cancelToken.unsubscribe(o),e.signal&&e.signal.removeEventListener("abort",o)}ve.isFormData(i)&&(Ue.isStandardBrowserEnv||Ue.isStandardBrowserWebWorkerEnv?s.setContentType(!1):s.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",n=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.set("Authorization","Basic "+btoa(t+":"+n))}const h=it(e.baseURL,e.url);function l(){if(!c)return;const i=qe.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,n){const i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(new xe("Request failed with status code "+n.status,[xe.ERR_BAD_REQUEST,xe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),a()}),(function(e){n(e),a()}),{data:r&&"text"!==r&&"json"!==r?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:i,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),Pe(h,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(l)},c.onabort=function(){c&&(n(new xe("Request aborted",xe.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new xe("Network Error",xe.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const i=e.transitional||Ne;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new xe(t,i.clarifyTimeoutError?xe.ETIMEDOUT:xe.ECONNABORTED,e,c)),c=null},Ue.isStandardBrowserEnv){const t=(e.withCredentials||st(h))&&e.xsrfCookieName&&nt.read(e.xsrfCookieName);t&&s.set(e.xsrfHeaderName,t)}void 0===i&&s.setContentType(null),"setRequestHeader"in c&&ve.forEach(s.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),ve.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),r&&"json"!==r&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",ot(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",ot(e.onUploadProgress)),(e.cancelToken||e.signal)&&(o=t=>{c&&(n(!t||t.type?new tt(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(o),e.signal&&(e.signal.aborted?o():e.signal.addEventListener("abort",o)));const u=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(h);u&&-1===Ue.protocols.indexOf(u)?n(new xe("Unsupported protocol "+u+":",xe.ERR_BAD_REQUEST,e)):c.send(i||null)}))},ct={http:null,xhr:at};ve.forEach(ct,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const ht=e=>{e=ve.isArray(e)?e:[e];const{length:t}=e;let n,i;for(let s=0;s<t&&(n=e[s],!(i=ve.isString(n)?ct[n.toLowerCase()]:n));s++);if(!i){if(!1===i)throw new xe(`Adapter ${n} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(ve.hasOwnProp(ct,n)?`Adapter '${n}' is not available in the build`:`Unknown adapter '${n}'`)}if(!ve.isFunction(i))throw new TypeError("adapter is not a function");return i};function lt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new tt(null,e)}function ut(e){lt(e),e.headers=qe.from(e.headers),e.data=Ze.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ht(e.adapter||Ve.adapter)(e).then((function(t){return lt(e),t.data=Ze.call(e,e.transformResponse,t),t.headers=qe.from(t.headers),t}),(function(t){return $e(t)||(lt(e),t&&t.response&&(t.response.data=Ze.call(e,e.transformResponse,t.response),t.response.headers=qe.from(t.response.headers))),Promise.reject(t)}))}const dt=e=>e instanceof qe?e.toJSON():e;function ft(e,t){t=t||{};const n={};function i(e,t,n){return ve.isPlainObject(e)&&ve.isPlainObject(t)?ve.merge.call({caseless:n},e,t):ve.isPlainObject(t)?ve.merge({},t):ve.isArray(t)?t.slice():t}function s(e,t,n){return ve.isUndefined(t)?ve.isUndefined(e)?void 0:i(void 0,e,n):i(e,t,n)}function r(e,t){if(!ve.isUndefined(t))return i(void 0,t)}function o(e,t){return ve.isUndefined(t)?ve.isUndefined(e)?void 0:i(void 0,e):i(void 0,t)}function a(n,s,r){return r in t?i(n,s):r in e?i(void 0,n):void 0}const c={url:r,method:r,data:r,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,headers:(e,t)=>s(dt(e),dt(t),!0)};return ve.forEach(Object.keys(Object.assign({},e,t)),(function(i){const r=c[i]||s,o=r(e[i],t[i],i);ve.isUndefined(o)&&r!==a||(n[i]=o)})),n}const pt="1.4.0",mt={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{mt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const gt={};mt.transitional=function(e,t,n){return(i,s,r)=>{if(!1===e)throw new xe(function(e,t){return"[Axios v1.4.0] Transitional option '"+e+"'"+t+(n?". "+n:"")}(s," has been removed"+(t?" in "+t:"")),xe.ERR_DEPRECATED);return t&&!gt[s]&&(gt[s]=!0),!e||e(i,s,r)}};const At={assertOptions:function(e,t,n){if("object"!=typeof e)throw new xe("options must be an object",xe.ERR_BAD_OPTION_VALUE);const i=Object.keys(e);let s=i.length;for(;s-- >0;){const r=i[s],o=t[r];if(o){const t=e[r],n=void 0===t||o(t,r,e);if(!0!==n)throw new xe("option "+r+" must be "+n,xe.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new xe("Unknown option "+r,xe.ERR_BAD_OPTION)}},validators:mt},yt=At.validators;class Bt{constructor(e){this.defaults=e,this.interceptors={request:new ke,response:new ke}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ft(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;let r;void 0!==n&&At.assertOptions(n,{silentJSONParsing:yt.transitional(yt.boolean),forcedJSONParsing:yt.transitional(yt.boolean),clarifyTimeoutError:yt.transitional(yt.boolean)},!1),null!=i&&(ve.isFunction(i)?t.paramsSerializer={serialize:i}:At.assertOptions(i,{encode:yt.function,serialize:yt.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase(),r=s&&ve.merge(s.common,s[t.method]),r&&ve.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete s[e]})),t.headers=qe.concat(r,s);const o=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const c=[];let h;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,u=0;if(!a){const e=[ut.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,c),l=e.length,h=Promise.resolve(t);u<l;)h=h.then(e[u++],e[u++]);return h}l=o.length;let d=t;for(u=0;u<l;){const e=o[u++],t=o[u++];try{d=e(d)}catch(e){t.call(this,e);break}}try{h=ut.call(this,d)}catch(e){return Promise.reject(e)}for(u=0,l=c.length;u<l;)h=h.then(c[u++],c[u++]);return h}getUri(e){return Pe(it((e=ft(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}ve.forEach(["delete","get","head","options"],(function(e){Bt.prototype[e]=function(t,n){return this.request(ft(n||{},{method:e,url:t,data:(n||{}).data}))}})),ve.forEach(["post","put","patch"],(function(e){function t(t){return function(n,i,s){return this.request(ft(s||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}Bt.prototype[e]=t(),Bt.prototype[e+"Form"]=t(!0)}));const bt=Bt;class Ct{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const i=new Promise((e=>{n.subscribe(e),t=e})).then(e);return i.cancel=function(){n.unsubscribe(t)},i},e((function(e,i,s){n.reason||(n.reason=new tt(e,i,s),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;const t=new Ct((function(t){e=t}));return{token:t,cancel:e}}}const vt=Ct;const wt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(wt).forEach((([e,t])=>{wt[t]=e}));const Et=wt;const Mt=function e(t){const n=new bt(t),i=J(bt.prototype.request,n);return ve.extend(i,bt.prototype,n,{allOwnKeys:!0}),ve.extend(i,n,null,{allOwnKeys:!0}),i.create=function(n){return e(ft(t,n))},i}(Ve);Mt.Axios=bt,Mt.CanceledError=tt,Mt.CancelToken=vt,Mt.isCancel=$e,Mt.VERSION=pt,Mt.toFormData=Oe,Mt.AxiosError=xe,Mt.Cancel=Mt.CanceledError,Mt.all=function(e){return Promise.all(e)},Mt.spread=function(e){return function(t){return e.apply(null,t)}},Mt.isAxiosError=function(e){return ve.isObject(e)&&!0===e.isAxiosError},Mt.mergeConfig=ft,Mt.AxiosHeaders=qe,Mt.formToJSON=e=>He(ve.isHTMLForm(e)?new FormData(e):e),Mt.HttpStatusCode=Et,Mt.default=Mt;const xt=Mt.create();xt.defaults.headers.post["Content-Type"]="application/json",xt.interceptors.request.use((e=>{let t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e}),(e=>Promise.reject(e))),xt.interceptors.response.use((e=>e),(e=>(e.response&&e.response.status,Promise.reject(e))));const Tt=xt;var It=i(354),Rt=i.n(It);class St{static de(e){let t=localStorage.getItem("mx3d-long");var n=Rt().enc.Utf8.parse(t.substring(0,32)),i=Rt().enc.Utf8.parse(t.substring(32,48)),s=Rt().enc.Hex.parse(e),r=Rt().enc.Base64.stringify(s);return Rt().AES.decrypt(r,n,{iv:i,mode:Rt().mode.CBC,padding:Rt().pad.Pkcs7}).toString(Rt().enc.Utf8).toString()}}class Ot extends D{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.baseModel=e.baseModel,this.objectType=x.LeakWater,this.lines=m.ToARRVector3(e.lines)}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=this.executes.count()>0,this.executes.find(T.eover)||this.executes.find(T.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=m.createTube(this.id,this.lines,.02,this.app),this.instance.setEnabled(!1);var e=this.app.resources.GetMaterial(this.baseModel).clone(this.id);d.Animation.CreateAndStartAnimation("u",e.diffuseTexture,"vOffset",15,30,0,1,1),e.diffuseTexture.vScale=this.instance.getTotalVertices()/50,this.instance.material=e,this.completed()}completed(){this.alwaysActive(),this.computeView()}computeView(){this.Sight=new R;let e=this.instance.getBoundingInfo(),t=m.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 n=null;if(e==T.leftClick||e==T.rightClick||e==T.doubleClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,n=new d.ExecuteCodeAction(d.ActionManager.OnPickTrigger,(e=>{let t=this.clickEvents.find(T.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let n=this.clickEvents.find(T.rightClick);n&&2==e.sourceEvent.button&&n(this,e);let i=this.clickEvents.find(T.doubleClick);i&&0==e.sourceEvent.button&&(new Date).getTime()-this.touchtime<500&&i(this,e),this.touchtime=(new Date).getTime()})),e="click"):e==T.eover?(n=new d.ExecuteCodeAction(d.ActionManager.OnPointerOverTrigger,(e=>t(this,e))),this.instance.enablePointerMoveEvents=!0):e==T.longPress?n=new d.ExecuteCodeAction(d.ActionManager.OnLongPressTrigger,(e=>t(this,e))):e==T.out&&(n=new d.ExecuteCodeAction(d.ActionManager.OnPointerOutTrigger,(e=>t(this,e))),this.instance.enablePointerMoveEvents=!0),n){this.action||(this.action=new d.ActionManager(this.app.scene),this.instance.actionManager=this.action);let t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),this.executes.add(e,n),this.action.registerAction(n)}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==T.leftClick||e==T.rightClick||e==T.doubleClick){if(this.clickEvents.remove(e),this.clickEvents.count()>0)return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let 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 Dt extends D{loadProperties(e){this.id=e.id,this.customNumber=e.customNumber,this.parentId=e.parentId,this.name=e.name,this.radius=e.radius,this.pints=m.ToARRVector3(e.pints),this.objectType=e.objectType,this.customType=e.customType,this.position=m.ToVector3(e.position),this.rotation=m.ToVector3(e.rotation),this.color=e.color,this.alpha=e.alpha}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=this.executes.count()>0,this.executes.find(T.eover)||this.executes.find(T.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){this.instance=new d.Mesh(this.id);let e=m.createTube(this.id,this.pints,this.radius,this.app);this.instance.position=e.getBoundingInfo().boundingBox.center.clone(),this.instance.addChild(e),this.instance.rotation=this.rotation.clone(),this.instance.position=this.position.clone(),e.setParent(this.instance.parent),this.instance.dispose(),this.instance=e;let t=new d.StandardMaterial("mat_"+this.id,this.app.scene);t.diffuseColor=d.Color3.FromHexString(this.color),t.alpha=this.alpha,this.instance.material=t,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.setEnabled(!1),this.completed()}setColor(e="#fff"){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=d.Color3.FromHexString(e),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}reColor(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=d.Color3.FromHexString(this.color),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}computeView(){this.Sight=new R;let e=this.instance.getBoundingInfo(),t=m.getVisualAngle(e,this.app);this.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=t.focus,this.Sight.radius=t.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.statusType==I.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.emissiveColor=O.colors[e],this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.statusType=I.Flash)}setOpaque(){this.statusType!=I.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.statusType=I.Opaque)}setTransparent(e=.3){this.statusType==I.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.alpha=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.statusType=I.Transparent)}}class Ft extends D{constructor(){super(...arguments),this.tconfig={color:"",position:null,rotation:null,scaling:null,clearColor:""},this.isLookAt=!1}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=this.executes.count()>0,this.executes.find(T.eover)||this.executes.find(T.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}loadProperties(e){if(this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=x.UI3D,this.isLookAt=e.isLookAt,this.tconfig.color=e.color,e.size){this.tconfig.clearColor=null,this.tconfig.position=m.ToVector3(e.position);let t=m.ToVector3(e.rotation);this.tconfig.rotation=new d.Vector3(t.x+Math.PI,t.y,t.z);let n=Number.parseInt(e.size.replace("px",""))/40,i=e.scaling?m.ToVector3(e.scaling):d.Vector3.One();this.tconfig.scaling=new d.Vector3(14*n/50*i.x,1,14*n/50*i.z)}else this.tconfig.clearColor=e.clearColor,this.tconfig.position=m.ToVector3(e.position),this.tconfig.rotation=m.ToVector3(e.rotation),this.tconfig.scaling=m.ToVector3(e.scaling)}bind(){var e="bold 100px Arial";let t=new d.DynamicTexture(this.id,64,this.app.scene,!1);var n=t.getContext();n.font=e;var i=n.measureText(this.name).width+8,s=.02*i;t=new d.DynamicTexture(this.id,{width:i,height:150},this.app.scene,!1);var r=new d.StandardMaterial(this.id,this.app.scene);r.backFaceCulling=!1,r.diffuseTexture=t,this.tconfig.clearColor||(t.hasAlpha=!0),t.drawText(this.name,null,null,e,this.tconfig.color,this.tconfig.clearColor,!1),this.instance=d.Mesh.CreateGround(this.id,s,3,1,this.app.scene),this.instance.setEnabled(!1),this.instance.scaling=this.tconfig.scaling,this.instance.position=this.tconfig.position,this.instance.rotation=this.tconfig.rotation,this.instance.material=r,this.isLookAt&&(this.instance.billboardMode=d.Mesh.BILLBOARDMODE_Y),this.alwaysActive(),this.computeView()}}class _t extends D{loadProperties(e){this.id=e.id,this.name=e.name,this.customNumber=e.customNumber,this.customType=e.customType,this.parentId=e.parentId,this.objectType=x.VirtualBox,this.virtualType=e.virtualType,this.color=d.Color3.FromHexString(e.color),this.alpha=e.alpha,this.isEdges=e.isEdges,this.edgesWidth=e.edgesWidth,this.edgesColor=d.Color3.FromHexString(e.edgesColor).toColor4(1),this.rotation=m.ToVector3(e.rotation),this.position=m.ToVector3(e.position),this.scaling=m.ToVector3(e.scaling)}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=this.executes.count()>0,this.executes.find(T.eover)||this.executes.find(T.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}bind(){"Cylinder"==this.virtualType?this.instance=d.MeshBuilder.CreateCylinder(this.id,{height:1,diameterTop:1,diameterBottom:1},this.app.scene):this.instance=d.MeshBuilder.CreateBox(this.id,{size:1},this.app.scene),this.instance.setEnabled(!1),this.instance.id=this.id;let e=new d.StandardMaterial(this.id,this.app.scene);e.diffuseColor=this.color,this.alpha<.98&&(e.alpha=this.alpha,e.alphaMode=2,e.useAlphaFromDiffuseTexture=!0),this.instance.material=e,this.isEdges&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=1,this.instance.edgesColor=new d.Color4(0,1,1,1)),this.edgesWidth&&this.edgesWidth>0&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=this.edgesWidth,this.instance.edgesColor=this.edgesColor),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.rotation=this.rotation.clone(),this.instance.position=this.position.clone(),this.instance.scaling=this.scaling.clone(),this.completed()}}class Gt extends G{addEventListener(e,t){}removeEventListener(e){}setEnabled(e){this.instance.setEnabled(e)}loadProperties(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.index=e.index,this.layerName=this.index<0?"B"+this.index:"F"+(this.index+1),this.layerHeight=e.layerHeight,this.objectType=e.objectType,this.customNumber=e.customNumber?e.customNumber:e.id,this.customType=e.customType?e.customType:this.objectType,this.position=m.ToVector3(e.position),this.rotation=m.ToVector3(e.rotation)}bind(){this.instance=new d.Mesh(this.id,this.app.scene),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.position=this.position,this.instance.position.y-=.01,this.instance.rotation=this.rotation.clone(),this.setEnabled(!1)}}var Lt,Pt=function(e,t,n,i){return new(n||(n=Promise))((function(s,r){function o(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};class kt{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 Nt{constructor(e){this.displayValue=!1,this.anchor=e,this.id=y.getGUID(12),this.texts=new Array}isEnabled(e){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh.setEnabled(e),this.texts.forEach((t=>t.isVisible=!!e&&this.displayValue)),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set displayValues(e){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.texts.forEach((t=>t.isVisible=e)),this.displayValue=e,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}}class Ut{constructor(){this.color="#00ff00",this.width=1}update(){this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance&&this.instance.dispose();let e=[];this.objs.forEach((t=>e.push(t.instance.getAbsolutePosition().clone()))),this.instance=m.createTube(this.id,e,this.width/100,this.objs[0].app);let t=new d.StandardMaterial("mat_"+this.id,this.objs[0].app.scene);t.diffuseColor=d.Color3.FromHexString(this.color),this.instance.material=t,this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}addEventListener(e){if(this.objs[0].app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,e){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let t=new d.ActionManager(this.objs[0].app.scene);t.registerAction(new d.ExecuteCodeAction(d.ActionManager.OnPickTrigger,(t=>e(this.id)))),this.instance.actionManager=t}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 Ht{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 d.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 jt{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 d.Image(y.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(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach((e=>e.dispose())),this.textDics.length=0;for(let t=0;t<e.length;t++){let n=new d.TextBlock;n.text=e[t].text,n.fontSize=e[t].fontSize?e[t].fontSize:"20px",n.color=e[t].color?e[t].color:"white",n.top=e[t].top?e[t].top:0,n.left=e[t].left?e[t].left:0,this.rect.addControl(n),this.textDics.push(n)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new d.Line,this._line.lineWidth=e.width?e.width:1.5,this._line.color=e.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 Jt{constructor(e,t,n,i,s,r){this.id=e,this.scene=r,this.url=n,this.scaling=i,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=d.Mesh.CreatePlane(this.id,i,this.scene,!0,d.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=t.clone(),this.instance.position.y+=s,this.instance.billboardMode=d.Mesh.BILLBOARDMODE_Y;let o=new d.StandardMaterial("Mat_"+this.id,this.scene);o.diffuseColor=d.Color3.White(),o.emissiveColor=d.Color3.White(),this.instance.material=o,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let e=new Image;e.src=this.url,e.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(e.width/e.height)/this.scaling;let t=new d.DynamicTexture(this.id,{width:e.width,height:e.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t,t.getContext().drawImage(e,0,0),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}addEventListener(e){if(this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,e){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let t=new d.ActionManager(this.scene);t.registerAction(new d.ExecuteCodeAction(d.ActionManager.OnPickTrigger,(t=>e(this.id)))),this.instance.actionManager=t}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=d.Color3.FromHexString(e),this.instance.material.emissiveColor=d.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let t=new Image;t.src=this.url,t.onload=()=>{this.instance.scaling.y=this.scaling/(t.width/t.height)/this.scaling;let n=new d.DynamicTexture(this.id,{width:t.width,height:t.height},this.scene,!1);n.hasAlpha=!0,this.instance.material.diffuseTexture=n,n.getContext().drawImage(t,0,0),e.forEach((e=>n.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color?e.color:"#fffffb","",!0,!0))),n.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 Vt{constructor(e){this.thunderNum=20,this.thunders=new Array,this.app=e}start(){this.canvas=document.createElement("canvas"),this.canvas.id="thunderEffect",this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;outline-width: 0;-webkit-tap-highlight-color:transparent;z-index: 0;background: #000F1E;pointer-events: none;",this.app.canvas.parentElement.appendChild(this.canvas),this.canvasThunderCtx=this.canvas.getContext("2d"),this.X=this.canvas.width=window.innerWidth,this.Y=this.canvas.height=window.innerHeight,this.app.environment.setTransparent(.5);for(var e=0;e<this.thunderNum;e++){var t=new zt(this.canvasThunderCtx,m.rand(0,this.X),m.rand(0,this.Y/3),m.rand(1,5),this.X,this.Y);this.thunders.push(t)}this.render()}close(){this.app.canvas.parentElement.removeChild(this.canvas),this.app.environment.setTransparent(1)}render(){this.clearCanvasThunder();for(var e=0;e<this.thunders.length;e++)this.thunders[e].render();window.requestAnimationFrame((()=>{this.render()}))}clearCanvasThunder(){this.canvasThunderCtx.globalCompositeOperation="darken",this.canvasThunderCtx.globalAlpha=.01,this.canvasThunderCtx.fillStyle="rgb(19, 16, 65)",this.canvasThunderCtx.fillRect(0,0,this.X,this.Y),this.canvasThunderCtx.globalCompositeOperation="source-over",this.canvasThunderCtx.globalAlpha=1,Math.random()<.02&&(this.canvasThunderCtx.fillStyle="rgb(128, 128, 128)",this.canvasThunderCtx.fillRect(0,0,this.X,this.Y))}}class zt{constructor(e,t,n,i,s,r){this.ctx=e,this.X=s,this.Y=r,this.init(t,n,i)}init(e,t,n){this.x=e,this.y=t,this.r=n,this.l=m.rand(this.Y,3*this.Y),this.c="rgb(201, 162, 198)"}draw(){this.ctx.beginPath(),this.ctx.lineWidth=this.r,this.ctx.strokeStyle=this.c,this.ctx.moveTo(this.x,this.y),this.x+=m.rand(-10,10),this.y+=m.rand(10,15),this.ctx.lineTo(this.x,this.y),this.ctx.stroke()}updateParams(){this.y>this.l&&this.init(m.rand(0,this.X),m.rand(0,this.Y/3),m.rand(1,5))}render(){this.updateParams(),this.draw()}}class Kt{constructor(e){this.rainNum=1e3,this.rains=new Array,this.app=e}start(){this.canvas=document.createElement("canvas"),this.canvas.id="RainEffect",this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;outline-width: 0;-webkit-tap-highlight-color:transparent; z-index: 2;pointer-events: none;",this.app.canvas.parentElement.appendChild(this.canvas),this.canvasRainCtx=this.canvas.getContext("2d"),this.X=this.canvas.width=window.innerWidth,this.Y=this.canvas.height=window.innerHeight;for(var e=0;e<this.rainNum;e++){var t=new Wt(this.canvasRainCtx,m.rand(0,this.X),m.rand(0,this.Y),1,this.Y);this.rains.push(t)}this.render()}close(){this.app.canvas.parentElement.removeChild(this.canvas)}render(){this.clearCanvasRain();for(var e=0;e<this.rains.length;e++)this.rains[e].render();window.requestAnimationFrame((()=>{this.render()}))}clearCanvasRain(){this.canvasRainCtx.clearRect(0,0,this.X,this.Y)}}class Wt{constructor(e,t,n,i,s){this.rainSpeed=10,this.ctx=e,this.Y=s,this.init(t,n,i)}init(e,t,n){this.x=e,this.y=t,this.r=n,this.c="rgb(179, 203, 255)",this.v={y:this.rainSpeed}}draw(){var e=this.ctx;e.beginPath(),e.fillStyle=this.c,e.arc(this.x,this.y,this.r,0,2*Math.PI,!1),e.fill()}updatePosition(){this.y+=this.v.y}wrapPosition(){this.y>this.Y&&(this.y=0)}render(){this.updatePosition(),this.wrapPosition(),this.draw()}}class Qt{constructor(e){this.cloudNum=50,this.clouds=new Array,this.app=e}start(){this.canvas=document.createElement("canvas"),this.canvas.id="CloudEffect",this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;outline-width: 0;-webkit-tap-highlight-color:transparent; z-index: 1;pointer-events: none;",this.app.canvas.parentElement.appendChild(this.canvas),this.canvasCloudCtx=this.canvas.getContext("2d"),this.X=this.canvas.width=window.innerWidth,this.Y=this.canvas.height=window.innerHeight;for(var e=0;e<this.cloudNum;e++){var t=new Xt(this.canvasCloudCtx,m.rand(-100,this.X+100),m.rand(0,this.Y/2),this.X);this.clouds.push(t)}this.render()}close(){this.app.canvas.parentElement.removeChild(this.canvas)}render(){this.clearCanvasCloud();for(var e=0;e<this.clouds.length;e++)this.clouds[e].render();window.requestAnimationFrame((()=>{this.render()}))}clearCanvasCloud(){this.canvasCloudCtx.clearRect(0,0,this.X,this.Y)}}class Xt{constructor(e,t,n,i){this.rainSpeed=10,this.ctx=e,this.X=i,this.init(t,n)}init(e,t){this.x=e,this.y=t,this.c="rgb(201, 162, 198)",this.r=m.rand(100,200),this.v={x:.5,y:0},this.color={r:0,g:0,b:0,a:1}}draw(){this.ctx.save(),this.ctx.scale(2,1),this.ctx.beginPath(),this.ctx.globalAlpha=.2,this.ctx.fillStyle=this.gradient(),this.ctx.arc(this.x,this.y,this.r,2*Math.PI,0,!1),this.ctx.fill(),this.ctx.scale(.5,1),this.ctx.restore()}gradient(){var e=this.color.r+","+this.color.g+","+this.color.b,t=this.ctx.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r);return t.addColorStop(0,"rgba("+e+", "+1*this.color.a+")"),t.addColorStop(.5,"rgba("+e+", "+.5*this.color.a+")"),t.addColorStop(1,"rgba("+e+", "+0*this.color.a+")"),t}updatePosition(){this.x+=this.v.x}wrapPosition(){this.x-this.r>this.X&&(this.x=0-this.r)}render(){this.updatePosition(),this.wrapPosition(),this.draw()}}!function(e){e.Thunder="Thunder",e.Rain="Rain",e.Cloud="Cloud"}(Lt||(Lt={}));class Yt{static add(e,t){switch(e){case Lt.Thunder:{let e=new Vt(t);e.start(),this.effects.add(Lt.Thunder,e)}break;case Lt.Rain:{let e=new Kt(t);e.start(),this.effects.add(Lt.Rain,e)}break;case Lt.Cloud:{let e=new Qt(t);e.start(),this.effects.add(Lt.Cloud,e)}}}static remove(e){let t=this.effects.find(e);t&&t.close(),this.effects.remove(e)}}Yt.effects=new A;const qt=e=>"boolean"==typeof e,Zt=e=>"function"==typeof e,$t=e=>null!==e&&"object"==typeof e,en=e=>$t(e)&&e.constructor==={}.constructor,tn=e=>e&&"function"==typeof e[Symbol.iterator],nn=e=>e&&"function"==typeof e[Symbol.asyncIterator],sn=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,rn=e=>"undefined"!=typeof Blob&&e instanceof Blob,on=e=>e&&"object"==typeof e&&e.isBuffer,an=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||$t(e)&&Zt(e.tee)&&Zt(e.cancel)&&Zt(e.getReader))(e)||(e=>$t(e)&&Zt(e.read)&&Zt(e.pipe)&&qt(e.readable))(e);function cn(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function hn(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function ln(e){var t,n;let i;return cn(e,"null loader"),cn(hn(e),"invalid loader"),Array.isArray(e)&&(i=e[1],e=e[0],e={...e,options:{...e.options,...i}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(n=e)&&void 0!==n&&n.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}let un="";const dn={};const fn=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,pn=/^([-\w.]+\/[-\w.+]+)/;function mn(e){const t=fn.exec(e);return t?t[1]:""}const gn=/\?.*/;function An(e){return e.replace(gn,"")}function yn(e){if(sn(e)){return e.url}if(rn(e)){return e.name||""}return"string"==typeof e?e:""}function Bn(e){if(sn(e)){const t=e,n=t.headers.get("content-type")||"",i=An(t.url);return function(e){const t=pn.exec(e);return t?t[1]:e}(n)||mn(i)}if(rn(e)){return e.type||""}return"string"==typeof e?mn(e):""}async function bn(e){if(sn(e))return e;const t={},n=function(e){if(sn(e))return e.headers["content-length"]||-1;if(rn(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);n>=0&&(t["content-length"]=String(n));const i=yn(e),s=Bn(e);s&&(t["content-type"]=s);const r=await async function(e){const t=5;if("string"==typeof e)return"data:,".concat(e.slice(0,t));if(e instanceof Blob){const t=e.slice(0,5);return await new Promise((e=>{const n=new FileReader;n.onload=t=>{var n;return e(null==t||null===(n=t.target)||void 0===n?void 0:n.result)},n.readAsDataURL(t)}))}if(e instanceof ArrayBuffer){const n=function(e){let t="";const n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)}(e.slice(0,t));return"data:base64,".concat(n)}return null}(e);r&&(t["x-first-bytes"]=r),"string"==typeof e&&(e=(new TextEncoder).encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:i}),o}async function Cn(e,t){if("string"==typeof e){e=function(e){for(const t in dn)if(e.startsWith(t)){const n=dn[t];e=e.replace(t,n)}return e.startsWith("http://")||e.startsWith("https://")||(e="".concat(un).concat(e)),e}(e);let n=t;return null!=t&&t.fetch&&"function"!=typeof(null==t?void 0:t.fetch)&&(n=t.fetch),await fetch(e,n)}return await bn(e)}function vn(e){return vn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vn(e)}function wn(e){var t=function(e,t){if("object"!==vn(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==vn(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===vn(t)?t:String(t)}function En(e,t,n){return(t=wn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mn(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||function(e){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof process&&"object"==typeof process.versions&&Boolean(process.versions.electron))return!0;const t="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,n=e||t;return!!(n&&n.indexOf("Electron")>=0)}()}const xn="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";Mn();class Tn{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";En(this,"storage",void 0),En(this,"id",void 0),En(this,"config",void 0),this.storage=function(e){try{const t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch(e){return null}}(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}let In;!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(In||(In={}));const Rn=10;function Sn(e){return"string"!=typeof e?e:(e=e.toUpperCase(),In[e]||In.WHITE)}function On(e,t){if(!e)throw new Error(t||"Assertion failed")}globalThis,globalThis.self||globalThis.window||globalThis.global;const Dn=globalThis.window||globalThis.self||globalThis.global,Fn=(globalThis.document,globalThis.process||{});globalThis.console,globalThis.navigator;function _n(){let e;var t,n;if(Mn()&&Dn.performance)e=null==Dn||null===(t=Dn.performance)||void 0===t||null===(n=t.now)||void 0===n?void 0:n.call(t);else if("hrtime"in Fn){var i;const t=null==Fn||null===(i=Fn.hrtime)||void 0===i?void 0:i.call(Fn);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const Gn={debug:Mn()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ln={enabled:!0,level:0};function Pn(){}const kn={},Nn={once:!0};class Un{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};En(this,"id",void 0),En(this,"VERSION",xn),En(this,"_startTs",_n()),En(this,"_deltaTs",_n()),En(this,"_storage",void 0),En(this,"userData",{}),En(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this.userData={},this._storage=new Tn("__probe-".concat(this.id,"__"),Ln),this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const n=Object.getPrototypeOf(e),i=Object.getOwnPropertyNames(n),s=e;for(const n of i){const i=s[n];"function"==typeof i&&(t.find((e=>n===e))||(s[n]=i.bind(e)))}}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((_n()-this._startTs).toPrecision(10))}getDelta(){return Number((_n()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table}assert(e,t){On(e,t)}warn(e){return this._getLogFunction(0,e,Gn.warn,arguments,Nn)}error(e){return this._getLogFunction(0,e,Gn.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,Gn.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Gn.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Gn.debug||Gn.info,arguments,Nn)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||Pn,n&&[n],{tag:Jn(t)}):Pn}image(e){let{logLevel:t,priority:n,image:i,message:s="",scale:r=1}=e;return this._shouldLog(t||n)?Mn()?function(e){let{image:t,message:n="",scale:i=1}=e;if("string"==typeof t){const e=new Image;return e.onload=()=>{!function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const s=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>i&&(n=Math.min(n,i/e.width));const r=e.width*n,o=e.height*n,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(r/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(s,");"),"background-size:".concat(r,"px ").concat(o,"px;"),"color:transparent;"].join("");"".concat(t," %c+")}(e,n,i)},e.src=t,Pn}const s=t.nodeName||"";if("img"===s.toLowerCase())return Pn;if("canvas"===s.toLowerCase()){const e=new Image;return e.onload=()=>{},e.src=t.toDataURL(),Pn}return Pn}({image:i,message:s,scale:r}):function(e){let{image:t,message:n="",scale:i=1}=e;return Pn}({image:i,message:s,scale:r}):Pn}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Pn)}group(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const i=jn({logLevel:e,message:t,opts:n}),{collapsed:s}=n;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Pn)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Hn(e)}_getLogFunction(e,t,n,i,s){if(this._shouldLog(e)){s=jn({logLevel:e,message:t,args:i,opts:s}),On(n=n||s.method),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=_n();const r=s.tag||s.message;if(s.once&&r){if(kn[r])return Pn;kn[r]=_n()}return t=function(e,t,n){if("string"==typeof t){const i=n.time?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const n=Math.max(t-e.length,0);return"".concat(" ".repeat(n)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(n.total)):"";t=function(e,t,n){if(!Mn&&"string"==typeof e){if(t){const n=Sn(t);e="[".concat(n,"m").concat(e,"[39m")}if(n){const t=Sn(n);e="[".concat(t+Rn,"m").concat(e,"[49m")}}return e}(t=n.time?"".concat(e,": ").concat(i," ").concat(t):"".concat(e,": ").concat(t),n.color,n.background)}return t}(this.id,s.message,s),n.bind(console,t,...s.args)}return Pn}}function Hn(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return On(Number.isFinite(t)&&t>=0),t}function jn(e){const{logLevel:t,message:n}=e;e.logLevel=Hn(t);const i=e.args?Array.from(e.args):[];for(;i.length&&i.shift()!==n;);switch(typeof t){case"string":case"function":void 0!==n&&i.unshift(n),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const s=typeof e.message;return On("string"===s||"object"===s),Object.assign(e,{args:i},e.opts)}function Jn(e){for(const t in e)for(const n in e[t])return n||"untitled";return"empty"}En(Un,"VERSION",xn);const Vn=new Un({id:"loaders.gl"});class zn{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,void 0!==i.g&&i.g,"undefined"!=typeof document&&document;const Kn=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Wn="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),Qn=(Wn&&parseFloat(Wn[1]),{fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){En(this,"console",void 0),this.console=console}log(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.console.log.bind(this.console,...t)}info(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.console.info.bind(this.console,...t)}warn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.console.warn.bind(this.console,...t)}error(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.console.error.bind(this.console,...t)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Kn,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}),Xn={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Yn(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const qn=()=>{const e=Yn();return e.globalOptions=e.globalOptions||{...Qn},e.globalOptions};function Zn(e,t,n,i){return n=n||[],function(e,t){$n(e,null,Qn,Xn,t);for(const n of t){const i=e&&e[n.id]||{},s=n.options&&n.options[n.id]||{},r=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};$n(i,n.id,s,r,t)}}(e,n=Array.isArray(n)?n:[n]),ti(t,e,i)}function $n(e,t,n,i,s){const r=t||"Top level",o=t?"".concat(t,"."):"";for(const a in e){const c=!t&&$t(e[a]);if(!(a in n)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in i)Vn.warn("".concat(r," loader option '").concat(o).concat(a,"' no longer supported, use '").concat(i[a],"'"))();else if(!c){const e=ei(a,s);Vn.warn("".concat(r," loader option '").concat(o).concat(a,"' not recognized. ").concat(e))()}}}function ei(e,t){const n=e.toLowerCase();let i="";for(const s of t)for(const t in s.options){if(e===t)return"Did you mean '".concat(s.id,".").concat(t,"'?");const r=t.toLowerCase();(n.startsWith(r)||r.startsWith(n))&&(i=i||"Did you mean '".concat(s.id,".").concat(t,"'?"))}return i}function ti(e,t,n){const i={...e.options||{}};return function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}(i,n),null===i.log&&(i.log=new zn),ni(i,qn()),ni(i,t),i}function ni(e,t){for(const n in t)if(n in t){const i=t[n];en(i)&&en(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function ii(e,t){const n=qn(),i=e||n;return"function"==typeof i.fetch?i.fetch:$t(i.fetch)?e=>Cn(e,i):null!=t&&t.fetch?null==t?void 0:t.fetch:Cn}function si(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const ri="3.4.4";const oi={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==i.g&&i.g,document:"undefined"!=typeof document&&document},ai=oi.global||oi.self||oi.window||{},ci="object"!=typeof process||"[object process]"!==String(process)||process.browser,hi="function"==typeof importScripts,li="undefined"!=typeof window&&void 0!==window.orientation,ui="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);ui&&parseFloat(ui[1]);class di{terminate(){}}const fi=new Map;function pi(e){si(e.source&&!e.url||!e.source&&e.url);let t=fi.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return mi((t=e,"try {\n importScripts('".concat(t,"');\n} catch (error) {\n console.error(error);\n throw error;\n}")));var t}(e.url),fi.set(e.url,t)),e.source&&(t=mi(e.source),fi.set(e.source,t))),si(t),t}function mi(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function gi(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0;const i=n||new Set;if(e){if(Ai(e))i.add(e);else if(Ai(e.buffer))i.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const n in e)gi(e[n],t,i)}else;return void 0===n?Array.from(i):[]}function Ai(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const yi=()=>{};class Bi{static isSupported(){return"undefined"!=typeof Worker&&ci||void 0!==di&&!ci}constructor(e){En(this,"name",void 0),En(this,"source",void 0),En(this,"url",void 0),En(this,"terminated",!1),En(this,"worker",void 0),En(this,"onMessage",void 0),En(this,"onError",void 0),En(this,"_loadableURL","");const{name:t,source:n,url:i}=e;si(n||i),this.name=t,this.source=n,this.url=i,this.onMessage=yi,this.onError=e=>{},this.worker=ci?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=yi,this.onError=yi,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||gi(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}_createBrowserWorker(){this._loadableURL=pi({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>{},e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new di(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new di(this.source,{eval:!0})}return e.on("message",(e=>{this.onMessage(e)})),e.on("error",(e=>{this.onError(e)})),e.on("exit",(e=>{})),e}}class bi{constructor(e,t){En(this,"name",void 0),En(this,"workerThread",void 0),En(this,"isRunning",!0),En(this,"result",void 0),En(this,"_resolve",(()=>{})),En(this,"_reject",(()=>{})),this.name=e,this.workerThread=t,this.result=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){si(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){si(this.isRunning),this.isRunning=!1,this._reject(e)}}class Ci{static isSupported(){return Bi.isSupported()}constructor(e){En(this,"name","unnamed"),En(this,"source",void 0),En(this,"url",void 0),En(this,"maxConcurrency",1),En(this,"maxMobileConcurrency",1),En(this,"onDebug",(()=>{})),En(this,"reuseWorkers",!0),En(this,"props",{}),En(this,"jobQueue",[]),En(this,"idleQueue",[]),En(this,"count",0),En(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach((e=>e.destroy())),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(e,t,n)=>e.done(n),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(e,t)=>e.error(t);const i=new Promise((i=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:i}),this)));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const n=new bi(t.name,e);e.onMessage=e=>t.onMessage(n,e.type,e.payload),e.onError=e=>t.onError(n,e),t.onStart(n);try{await n.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e="".concat(this.name.toLowerCase()," (#").concat(this.count," of ").concat(this.maxConcurrency,")");return new Bi({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return li?this.maxMobileConcurrency:this.maxConcurrency}}const vi={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}};class wi{static isSupported(){return Bi.isSupported()}static getWorkerFarm(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return wi._workerFarm=wi._workerFarm||new wi({}),wi._workerFarm.setProps(e),wi._workerFarm}constructor(e){En(this,"props",void 0),En(this,"workerPools",new Map),this.props={...vi},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:n,url:i}=e;let s=this.workerPools.get(t);return s||(s=new Ci({name:t,source:n,url:i}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}En(wi,"_workerFarm",void 0);const Ei="latest";async function Mi(e,t,n,i,s){const r=e.id,o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t[e.id]||{},i="".concat(e.id,"-worker.js");let s=n.workerUrl;if(s||"compression"!==e.id||(s=t.workerUrl),"test"===t._workerType&&(s="modules/".concat(e.module,"/dist/").concat(i)),!s){let t=e.version;"latest"===t&&(t=Ei);const n=t?"@".concat(t):"";s="https://unpkg.com/@loaders.gl/".concat(e.module).concat(n,"/dist/").concat(i)}return si(s),s}(e,n),a=wi.getWorkerFarm(n).getWorkerPool({name:r,url:o});n=JSON.parse(JSON.stringify(n)),i=JSON.parse(JSON.stringify(i||{}));const c=await a.startJob("process-on-worker",xi.bind(null,s));c.postMessage("process",{input:t,options:n,context:i});const h=await c.result;return await h.result}async function xi(e,t,n,i){switch(n){case"done":t.done(i);break;case"error":t.error(new Error(i.error));break;case"process":const{id:n,input:s,options:r}=i;try{const i=await e(s,r);t.postMessage("done",{id:n,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:n,error:i})}}}function Ti(e,t,n){const i=void 0!==n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(i).buffer}async function Ii(e){const t=[];for await(const n of e)t.push(n);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const i=t.map((e=>e instanceof ArrayBuffer?new Uint8Array(e):e)),s=i.reduce(((e,t)=>e+t.byteLength),0),r=new Uint8Array(s);let o=0;for(const e of i)r.set(e,o),o+=e.byteLength;return r.buffer}(...t)}const Ri=262144;const Si=262144;const Oi=1048576;function Di(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Fi(e,t){return Kn?async function*(e,t){const n=e.getReader();let i;try{for(;;){const e=i||n.read();null!=t&&t._streamReadAhead&&(i=n.read());const{done:s,value:r}=await e;if(s)return;yield Di(r)}}catch(e){n.releaseLock()}}(e,t):async function*(e,t){for await(const t of e)yield Di(t)}(e)}function _i(e,t){if("string"==typeof e)return function*(e,t){const n=(null==t?void 0:t.chunkSize)||Ri;let i=0;const s=new TextEncoder;for(;i<e.length;){const t=Math.min(e.length-i,n),r=e.slice(i,i+t);i+=t,yield s.encode(r)}}(e,t);if(e instanceof ArrayBuffer)return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){const{chunkSize:n=Si}=t;let i=0;for(;i<e.byteLength;){const t=Math.min(e.byteLength-i,n),s=new ArrayBuffer(t),r=new Uint8Array(e,i,t);new Uint8Array(s).set(r),i+=t,yield s}}()}(e,t);if(rn(e))return async function*(e,t){const n=(null==t?void 0:t.chunkSize)||Oi;let i=0;for(;i<e.size;){const t=i+n,s=await e.slice(i,t).arrayBuffer();i=t,yield s}}(e,t);if(an(e))return Fi(e,t);if(sn(e)){return Fi(e.body,t)}throw new Error("makeIterator")}const Gi="Cannot convert supplied data type";async function Li(e,t,n){const i=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||i)return function(e,t,n){if(t.text&&"string"==typeof e)return e;if(on(e)&&(e=e.buffer),e instanceof ArrayBuffer){const n=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(n):n}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let n=e.buffer;const i=e.byteLength||e.length;return 0===e.byteOffset&&i===n.byteLength||(n=n.slice(e.byteOffset,e.byteOffset+i)),n}throw new Error(Gi)}(e,t);if(rn(e)&&(e=await bn(e)),sn(e)){const n=e;return await async function(e){if(!e.ok){const t=await async function(e){let t="Failed to fetch resource ".concat(e.url," (").concat(e.status,"): ");try{const n=e.headers.get("Content-Type");let i=e.statusText;n.includes("application/json")&&(i+=" ".concat(await e.text())),t+=i,t=t.length>60?"".concat(t.slice(0,60),"..."):t}catch(e){}return t}(e);throw new Error(t)}}(n),t.binary?await n.arrayBuffer():await n.text()}if(an(e)&&(e=_i(e,n)),tn(e)||nn(e))return Ii(e);throw new Error(Gi)}function Pi(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function ki(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function Ni(e,t,n){if(n)return n;const i={fetch:ii(t,e),...e};if(i.url){const e=An(i.url);i.baseUrl=e,i.queryString=function(e){const t=e.match(gn);return t&&t[0]}(i.url),i.filename=Pi(e),i.baseUrl=ki(e)}return Array.isArray(i.loaders)||(i.loaders=null),i}const Ui=new Un({id:"loaders.gl"}),Hi=()=>{const e=Yn();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const ji=/\.([^.]+)$/;function Ji(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if(!Vi(e))return null;if(t&&!Array.isArray(t))return ln(t);let s=[];t&&(s=s.concat(t)),null!=n&&n.ignoreRegisteredLoaders||s.push(...Hi()),function(e){for(const t of e)ln(t)}(s);const r=function(e,t,n,i){const s=yn(e),r=Bn(e),o=An(s)||(null==i?void 0:i.url);let a=null,c="";null!=n&&n.mimeType&&(a=Ki(t,null==n?void 0:n.mimeType),c="match forced by supplied MIME type ".concat(null==n?void 0:n.mimeType));var h;a=a||function(e,t){const n=t&&ji.exec(t),i=n&&n[1];return i?function(e,t){t=t.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===t)return n;return null}(e,i):null}(t,o),c=c||(a?"matched url ".concat(o):""),a=a||Ki(t,r),c=c||(a?"matched MIME type ".concat(r):""),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(Wi(t,n))return n}else if(ArrayBuffer.isView(t)){if(Qi(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer){if(Qi(t,0,n))return n}return null}(t,e),c=c||(a?"matched initial data ".concat(Xi(e)):""),a=a||Ki(t,null==n?void 0:n.fallbackMimeType),c=c||(a?"matched fallback MIME type ".concat(r):""),c&&Ui.log(1,"selectLoader selected ".concat(null===(h=a)||void 0===h?void 0:h.name,": ").concat(c,"."));return a}(e,s,n,i);if(!(r||null!=n&&n.nothrow))throw new Error(zi(e));return r}function Vi(e){return!(e instanceof Response&&204===e.status)}function zi(e){const t=yn(e),n=Bn(e);let i="No valid loader found (";i+=t?"".concat(Pi(t),", "):"no url provided, ",i+="MIME type: ".concat(n?'"'.concat(n,'"'):"not provided",", ");const s=e?Xi(e):"";return i+=s?' first bytes: "'.concat(s,'"'):"first bytes: not available",i+=")",i}function Ki(e,t){for(const n of e){if(n.mimeTypes&&n.mimeTypes.includes(t))return n;if(t==="application/x.".concat(n.id))return n}return null}function Wi(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some((t=>e.startsWith(t)))}function Qi(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some((i=>function(e,t,n,i){if(i instanceof ArrayBuffer)return function(e,t,n){if(n=n||e.byteLength,e.byteLength<n||t.byteLength<n)return!1;const i=new Uint8Array(e),s=new Uint8Array(t);for(let e=0;e<i.length;++e)if(i[e]!==s[e])return!1;return!0}(i,e,i.byteLength);switch(typeof i){case"function":return i(e,n);case"string":return i===Yi(e,t,i.length);default:return!1}}(e,t,n,i)))}function Xi(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Yi(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return Yi(e,0,t)}return""}function Yi(e,t,n){if(e.byteLength<t+n)return"";const i=new DataView(e);let s="";for(let e=0;e<n;e++)s+=String.fromCharCode(i.getUint8(t+e));return s}async function qi(e,t,n,i){si(!i||"object"==typeof i),!t||Array.isArray(t)||hn(t)||(i=void 0,n=t,t=void 0),n=n||{};const s=yn(e=await e),r=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:null}(t,i),o=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if(!Vi(e))return null;let s=Ji(e,t,{...n,nothrow:!0},i);if(s)return s;if(rn(e)&&(s=Ji(e=await e.slice(0,10).arrayBuffer(),t,n,i)),!(s||null!=n&&n.nothrow))throw new Error(zi(e));return s}(e,r,n);return o?(i=Ni({url:s,parse:qi,loaders:r},n=Zn(n,o,r,s),i||null),await async function(e,t,n,i){if(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ri;si(e,"no worker provided");const n=e.version}(e),sn(t)){const e=t,{ok:n,redirected:s,status:r,statusText:o,type:a,url:c}=e,h=Object.fromEntries(e.headers.entries());i.response={headers:h,ok:n,redirected:s,status:r,statusText:o,type:a,url:c}}if(t=await Li(t,e,n),e.parseTextSync&&"string"==typeof t)return n.dataType="text",e.parseTextSync(t,n,i,e);if(function(e,t){return!!wi.isSupported()&&!!(ci||null!=t&&t._nodeWorkers)&&e.worker&&(null==t?void 0:t.worker)}(e,n))return await Mi(e,t,n,i,qi);if(e.parseText&&"string"==typeof t)return await e.parseText(t,n,i,e);if(e.parse)return await e.parse(t,n,i,e);throw si(!e.parseSync),new Error("".concat(e.id," loader - no parser found and worker is disabled"))}(o,e,n,i)):null}async function Zi(e,t,n,i){Array.isArray(t)||hn(t)||(void 0,n=t,t=void 0);const s=ii(n);let r=e;return"string"==typeof e&&(r=await s(e)),rn(e)&&(r=await s(e)),await qi(r,t,n)}const $i={ADD:1,REPLACE:2},es={EMPTY:"empty",SCENEGRAPH:"scenegraph",POINTCLOUD:"pointcloud",MESH:"mesh"},ts={I3S:"I3S",TILES3D:"TILES3D"},ns={GEOMETRIC_ERROR:"geometricError",MAX_SCREEN_THRESHOLD:"maxScreenThreshold"},is="3.4.4",ss={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"};Object.keys(ss);function rs(e,t,n){cn(e instanceof ArrayBuffer);const i=new TextDecoder("utf8"),s=new Uint8Array(e,t,n);return i.decode(s)}const os="3.4.4",as={draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},cs={name:"Draco",id:ci?"draco":"draco-nodejs",module:"draco",shapes:["mesh"],version:os,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:as};class hs{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map;En(this,"name",void 0),En(this,"type",void 0),En(this,"nullable",void 0),En(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=n,this.metadata=i}get typeId(){return this.type&&this.type.typeId}clone(){return new hs(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let ls,us,ds,fs,ps,ms,gs,As,ys=function(e){return e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e}({});class Bs{static isNull(e){return e&&e.typeId===ys.Null}static isInt(e){return e&&e.typeId===ys.Int}static isFloat(e){return e&&e.typeId===ys.Float}static isBinary(e){return e&&e.typeId===ys.Binary}static isUtf8(e){return e&&e.typeId===ys.Utf8}static isBool(e){return e&&e.typeId===ys.Bool}static isDecimal(e){return e&&e.typeId===ys.Decimal}static isDate(e){return e&&e.typeId===ys.Date}static isTime(e){return e&&e.typeId===ys.Time}static isTimestamp(e){return e&&e.typeId===ys.Timestamp}static isInterval(e){return e&&e.typeId===ys.Interval}static isList(e){return e&&e.typeId===ys.List}static isStruct(e){return e&&e.typeId===ys.Struct}static isUnion(e){return e&&e.typeId===ys.Union}static isFixedSizeBinary(e){return e&&e.typeId===ys.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===ys.FixedSizeList}static isMap(e){return e&&e.typeId===ys.Map}static isDictionary(e){return e&&e.typeId===ys.Dictionary}get typeId(){return ys.NONE}compareTo(e){return this===e}}class bs extends(null){get typeId(){return Type.Null}get[Symbol.toStringTag](){return"Null"}toString(){return"Null"}}class Cs extends(null){get typeId(){return Type.Bool}get[Symbol.toStringTag](){return"Bool"}toString(){return"Bool"}}ls=Symbol.toStringTag;class vs extends Bs{constructor(e,t){super(),En(this,"isSigned",void 0),En(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return ys.Int}get[ls](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class ws extends vs{constructor(){super(!0,8)}}class Es extends vs{constructor(){super(!0,16)}}class Ms extends vs{constructor(){super(!0,32)}}class xs extends vs{constructor(){super(!1,8)}}class Ts extends vs{constructor(){super(!1,16)}}class Is extends vs{constructor(){super(!1,32)}}const Rs=32,Ss=64;us=Symbol.toStringTag;class Os extends Bs{constructor(e){super(),En(this,"precision",void 0),this.precision=e}get typeId(){return ys.Float}get[us](){return"Float"}toString(){return"Float".concat(this.precision)}}class Ds extends Os{constructor(){super(Rs)}}class Fs extends Os{constructor(){super(Ss)}}class _s extends(null){constructor(){super()}get typeId(){return Type.Binary}toString(){return"Binary"}get[Symbol.toStringTag](){return"Binary"}}class Gs extends(null){get typeId(){return Type.Utf8}get[Symbol.toStringTag](){return"Utf8"}toString(){return"Utf8"}}ds=Symbol.toStringTag;fs=Symbol.toStringTag;ps=Symbol.toStringTag;ms=Symbol.toStringTag;gs=Symbol.toStringTag;class Ls extends Bs{constructor(e,t){super(),En(this,"listSize",void 0),En(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return ys.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[gs](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}As=Symbol.toStringTag;function Ps(e,t,n){const i=function(e){switch(e.constructor){case Int8Array:return new ws;case Uint8Array:return new xs;case Int16Array:return new Es;case Uint16Array:return new Ts;case Int32Array:return new Ms;case Uint32Array:return new Is;case Float32Array:return new Ds;case Float64Array:return new Fs;default:throw new Error("array type not supported")}}(t.value),s=n||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new hs(e,new Ls(t.size,new hs("value",i)),!1,s)}class ks{constructor(e,t){En(this,"fields",void 0),En(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(e)),function(e){const t={};for(const n of e)t[n.name],t[n.name]=!0}(e),this.fields=e,this.metadata=t||new Map}compareTo(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(let t=0;t<this.fields.length;++t)if(!this.fields[t].compareTo(e.fields[t]))return!1;return!0}select(){const e=Object.create(null);for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];for(const t of n)e[t]=!0;const s=this.fields.filter((t=>e[t.name]));return new ks(s,this.metadata)}selectAt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const i=t.map((e=>this.fields[e])).filter(Boolean);return new ks(i,this.metadata)}assign(e){let t,n=this.metadata;if(e instanceof ks){const i=e;t=i.fields,n=Ns(Ns(new Map,this.metadata),i.metadata)}else t=e;const i=Object.create(null);for(const e of this.fields)i[e.name]=e;for(const e of t)i[e.name]=e;const s=Object.values(i);return new ks(s,n)}}function Ns(e,t){return new Map([...e||new Map,...t||new Map])}function Us(e,t,n){return Ps(e,t,n?Hs(n.metadata):void 0)}function Hs(e){const t=new Map;for(const n in e)t.set("".concat(n,".string"),JSON.stringify(e[n]));return t}const js={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Js={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class Vs{constructor(e){En(this,"draco",void 0),En(this,"decoder",void 0),En(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const i=this.decoder.GetEncodedGeometryType(n),s=i===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(i){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(n,s);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(n,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!s.ptr){const t="DRACO decompression failed: ".concat(e.error_msg());throw new Error(t)}const r=this._getDracoLoaderData(s,i,t),o=this._getMeshData(s,r,t),a=function(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],c=a&&a.length;for(let e=0;e<c;e+=3){const c=a[e],h=a[e+1],l=a[e+2];t=c<t?c:t,n=h<n?h:n,i=l<i?l:i,s=c>s?c:s,r=h>r?h:r,o=l>o?l:o}return[[t,n,i],[s,r,o]]}(o.attributes),c=function(e,t,n){const i=Hs(t.metadata),s=[],r=function(e){const t={};for(const n in e){const i=e[n];t[i.name||"undefined"]=i}return t}(t.attributes);for(const t in e){const n=Us(t,e[t],r[t]);s.push(n)}if(n){const e=Us("indices",n);s.push(e)}return new ks(s,i)}(o.attributes,r,o.indices);return{loader:"draco",loaderData:r,header:{vertexCount:s.num_points(),boundingBox:a},...o,schema:c}}finally{this.draco.destroy(n),s&&this.draco.destroy(s)}}_getDracoLoaderData(e,t,n){const i=this._getTopLevelMetadata(e),s=this._getDracoAttributes(e,n);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:i,attributes:s}}_getDracoAttributes(e,t){const n={};for(let i=0;i<e.num_attributes();i++){const s=this.decoder.GetAttribute(e,i),r=this._getAttributeMetadata(e,i);n[s.unique_id()]={unique_id:s.unique_id(),attribute_type:s.attribute_type(),data_type:s.data_type(),num_components:s.num_components(),byte_offset:s.byte_offset(),byte_stride:s.byte_stride(),normalized:s.normalized(),attribute_index:i,metadata:r};const o=this._getQuantizationTransform(s,t);o&&(n[s.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(s,t);a&&(n[s.unique_id()].octahedron_transform=a)}return n}_getMeshData(e,t,n){const i=this._getMeshAttributes(t,e,n);if(!i.POSITION)throw new Error("DRACO: No position attribute found.");return e instanceof this.draco.Mesh?"triangle-strip"===n.topology?{topology:"triangle-strip",mode:4,attributes:i,indices:{value:this._getTriangleStripIndices(e),size:1}}:{topology:"triangle-list",mode:5,attributes:i,indices:{value:this._getTriangleListIndices(e),size:1}}:{topology:"point-list",mode:0,attributes:i}}_getMeshAttributes(e,t,n){const i={};for(const s of Object.values(e.attributes)){const e=this._deduceAttributeName(s,n);s.name=e;const{value:r,size:o}=this._getAttributeValues(t,s);i[e]={value:r,size:o,byteOffset:s.byte_offset,byteStride:s.byte_stride,normalized:s.normalized}}return i}_getTriangleListIndices(e){const t=3*e.num_faces(),n=4*t,i=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,i),new Uint32Array(this.draco.HEAPF32.buffer,i,t).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const n=Js[t.data_type],i=t.num_components,s=e.num_points()*i,r=s*n.BYTES_PER_ELEMENT,o=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}(this.draco,n);let a;const c=this.draco._malloc(r);try{const i=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,i,o,r,c),a=new n(this.draco.HEAPF32.buffer,c,s).slice()}finally{this.draco._free(c)}return{value:a,size:i}}_deduceAttributeName(e,t){const n=e.unique_id;for(const[e,i]of Object.entries(t.extraAttributes||{}))if(i===n)return e;const i=e.attribute_type;for(const e in js){if(this.draco[e]===i)return js[e]}const s=t.attributeNameEntry||"name";return e.metadata[s]?e.metadata[s].string:"CUSTOM_ATTRIBUTE_".concat(n)}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const n=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},n=this.metadataQuerier.NumEntries(e);for(let i=0;i<n;i++){const n=this.metadataQuerier.GetEntryName(e,i);t[n]=this._getDracoMetadataField(e,n)}return t}_getDracoMetadataField(e,t){const n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,n);const i=function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(n);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:i}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:n=[]}=e,i=[...t,...n];for(const e of i)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:n=[]}=t,i=e.attribute_type();if(n.map((e=>this.decoder[e])).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map((e=>t.min_value(e)))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:n=[]}=t,i=e.attribute_type();if(n.map((e=>this.decoder[e])).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}var zs=i(125);const Ks="3.4.4",Ws={};async function Qs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return t&&(e=function(e,t,n){if(e.startsWith("http"))return e;const i=n.modules||{};if(i[e])return i[e];if(!ci)return"modules/".concat(t,"/dist/libs/").concat(e);if(n.CDN)return si(n.CDN.startsWith("http")),"".concat(n.CDN,"/").concat(t,"@").concat(Ks,"/dist/libs/").concat(e);if(hi)return"../src/libs/".concat(e);return"modules/".concat(t,"/src/libs/").concat(e)}(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})),Ws[e]=Ws[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!ci)try{return zs&&zs.requireFromFile&&await zs.requireFromFile(e)}catch{return null}if(hi)return importScripts(e);const t=await fetch(e);return function(e,t){if(!ci)return zs.requireFromString&&zs.requireFromString(e,t);if(hi)return eval.call(ai,e),null;const n=document.createElement("script");n.id=t;try{n.appendChild(document.createTextNode(e))}catch(t){n.text=e}return document.body.appendChild(n),null}(await t.text(),e)}(e),await Ws[e]}const Xs="https://www.gstatic.com/draco/versioned/decoders/".concat("1.5.5"),Ys="".concat(Xs,"/draco_decoder.js"),qs="".concat(Xs,"/draco_wasm_wrapper.js"),Zs="".concat(Xs,"/draco_decoder.wasm");"https://raw.githubusercontent.com/google/draco/".concat("1.4.1","/javascript/draco_encoder.js");let $s;async function er(e){const t=e.modules||{};return $s=t.draco3d?$s||t.draco3d.createDecoderModule({}).then((e=>({draco:e}))):$s||async function(e){let t,n;if("js"===(e.draco&&e.draco.decoderType))t=await Qs(Ys,"draco",e);else[t,n]=await Promise.all([await Qs(qs,"draco",e),await Qs(Zs,"draco",e)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise((t=>{e({...n,onModuleLoaded:e=>t({draco:e})})}))}(t,n)}(e),await $s}const tr={...cs,parse:async function(e,t){const{draco:n}=await er(t),i=new Vs(n);try{return i.parseSync(e,null==t?void 0:t.draco)}finally{i.destroy()}}};const nr={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},ir={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...nr},sr=1/Math.PI*180,rr=1/180*Math.PI,or={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function ar(e,{precision:t=or.precision}={}){return e=function(e){return Math.round(e/or.EPSILON)*or.EPSILON}(e),"".concat(parseFloat(e.toPrecision(t)))}function cr(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function hr(e){return function(e,t){return dr(e,(e=>e*rr),t)}(e)}function lr(e){return function(e,t){return dr(e,(e=>e*sr),t)}(e)}function ur(e,t,n){const i=or.EPSILON;n&&(or.EPSILON=n);try{if(e===t)return!0;if(cr(e)&&cr(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!ur(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):"number"==typeof e&&"number"==typeof t&&Math.abs(e-t)<=or.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{or.EPSILON=i}}function dr(e,t,n){if(cr(e)){const i=e;n=n||function(e){return e.clone?e.clone():new Array(e.length)}(i);for(let s=0;s<n.length&&s<i.length;++s)n[s]=t(e[s],s,n);return n}return t(e)}class fr extends(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array)){clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:cr(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(or)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+ar(this[n],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!ur(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(void 0===n)return this.lerp(this,e,t);for(let i=0;i<this.ELEMENTS;++i){const s=e[i];this[i]=s+n*(t[i]-s)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if("number"==typeof e)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(or.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}}function pr(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function mr(e,t,n=""){if(or.debug&&!function(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}(e,t))throw new Error("math.gl: ".concat(n," some fields set to invalid numbers'"));return e}function gr(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}class Ar extends fr{get x(){return this[0]}set x(e){this[0]=pr(e)}get y(){return this[1]}set y(e){this[1]=pr(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){const i=this[n]-e[n];t+=i*i}return pr(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return pr(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return gr(e>=0&&e<this.ELEMENTS,"index is out of range"),pr(this[e])}setComponent(e,t){return gr(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}var yr=1e-6,Br="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function br(){var e=new Br(3);return Br!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Cr(e){var t=e[0],n=e[1],i=e[2];return Math.hypot(t,n,i)}function vr(e,t,n){var i=new Br(3);return i[0]=e,i[1]=t,i[2]=n,i}function wr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Er(e,t,n){var i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],c=n[2];return e[0]=s*c-r*a,e[1]=r*o-i*c,e[2]=i*a-s*o,e}function Mr(e,t,n){var i=t[0],s=t[1],r=t[2],o=n[3]*i+n[7]*s+n[11]*r+n[15];return o=o||1,e[0]=(n[0]*i+n[4]*s+n[8]*r+n[12])/o,e[1]=(n[1]*i+n[5]*s+n[9]*r+n[13])/o,e[2]=(n[2]*i+n[6]*s+n[10]*r+n[14])/o,e}function xr(e,t,n){var i=t[0],s=t[1],r=t[2];return e[0]=i*n[0]+s*n[3]+r*n[6],e[1]=i*n[1]+s*n[4]+r*n[7],e[2]=i*n[2]+s*n[5]+r*n[8],e}function Tr(e,t,n){var i=n[0],s=n[1],r=n[2],o=n[3],a=t[0],c=t[1],h=t[2],l=s*h-r*c,u=r*a-i*h,d=i*c-s*a,f=s*d-r*u,p=r*l-i*d,m=i*u-s*l,g=2*o;return l*=g,u*=g,d*=g,f*=2,p*=2,m*=2,e[0]=a+l+f,e[1]=c+u+p,e[2]=h+d+m,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Ir,Rr=Cr;Ir=br();function Sr(e,t,n){const i=t[0],s=t[1],r=n[3]*i+n[7]*s||1;return e[0]=(n[0]*i+n[4]*s)/r,e[1]=(n[1]*i+n[5]*s)/r,e}function Or(e,t,n){const i=t[0],s=t[1],r=t[2],o=n[3]*i+n[7]*s+n[11]*r||1;return e[0]=(n[0]*i+n[4]*s+n[8]*r)/o,e[1]=(n[1]*i+n[5]*s+n[9]*r)/o,e[2]=(n[2]*i+n[6]*s+n[10]*r)/o,e}function Dr(e,t,n){const i=t[0],s=t[1],r=t[2];return e[0]=n[0]*i+n[3]*s+n[6]*r,e[1]=n[1]*i+n[4]*s+n[7]*r,e[2]=n[2]*i+n[5]*s+n[8]*r,e[3]=t[3],e}const Fr=[0,0,0];let _r;class Gr extends Ar{static get ZERO(){return _r||(_r=new Gr(0,0,0),Object.freeze(_r)),_r}constructor(e=0,t=0,n=0){super(-0,-0,-0),1===arguments.length&&cr(e)?this.copy(e):(or.debug&&(pr(e),pr(t),pr(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return or.debug&&(pr(e.x),pr(e.y),pr(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=pr(e)}angle(e){return function(e,t){var n=e[0],i=e[1],s=e[2],r=t[0],o=t[1],a=t[2],c=Math.sqrt(n*n+i*i+s*s)*Math.sqrt(r*r+o*o+a*a),h=c&&wr(e,t)/c;return Math.acos(Math.min(Math.max(h,-1),1))}(this,e)}cross(e){return Er(this,this,e),this.check()}rotateX({radians:e,origin:t=Fr}){return function(e,t,n,i){var s=[],r=[];s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[0],r[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),r[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2]}(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Fr}){return function(e,t,n,i){var s=[],r=[];s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),r[1]=s[1],r[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2]}(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Fr}){return function(e,t,n,i){var s=[],r=[];s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),r[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),r[2]=s[2],e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2]}(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Mr(this,this,e),this.check()}transformAsVector(e){return Or(this,this,e),this.check()}transformByMatrix3(e){return xr(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,n){const i=t[0],s=t[1];e[0]=n[0]*i+n[2]*s,e[1]=n[1]*i+n[3]*s,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return Tr(this,this,e),this.check()}}const Lr={[nr.DOUBLE]:Float64Array,[nr.FLOAT]:Float32Array,[nr.UNSIGNED_SHORT]:Uint16Array,[nr.UNSIGNED_INT]:Uint32Array,[nr.UNSIGNED_BYTE]:Uint8Array,[nr.BYTE]:Int8Array,[nr.SHORT]:Int16Array,[nr.INT]:Int32Array},Pr={DOUBLE:nr.DOUBLE,FLOAT:nr.FLOAT,UNSIGNED_SHORT:nr.UNSIGNED_SHORT,UNSIGNED_INT:nr.UNSIGNED_INT,UNSIGNED_BYTE:nr.UNSIGNED_BYTE,BYTE:nr.BYTE,SHORT:nr.SHORT,INT:nr.INT},kr="Failed to convert GL type";class Nr{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Lr){if(Lr[t]===e)return t}throw new Error(kr)}static fromName(e){const t=Pr[e];if(!t)throw new Error(kr);return t}static getArrayType(e){switch(e){case nr.UNSIGNED_SHORT_5_6_5:case nr.UNSIGNED_SHORT_4_4_4_4:case nr.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Lr[e];if(!t)throw new Error(kr);return t}}static getByteSize(e){return Nr.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(Nr.getArrayType(e))}static createTypedArray(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;void 0===i&&(i=(t.byteLength-n)/Nr.getByteSize(e));return new(Nr.getArrayType(e))(t,n,i)}}class Ur{constructor(e,t){En(this,"json",void 0),En(this,"buffer",void 0),En(this,"featuresLength",0),En(this,"_cachedTypedArrays",{}),this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ir.UNSIGNED_INT,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const i=this.json[e];return i&&Number.isFinite(i.byteOffset)?this._getTypedArrayFromBinary(e,t,n,1,i.byteOffset):i}getPropertyArray(e,t,n){const i=this.json[e];return i&&Number.isFinite(i.byteOffset)?("componentType"in i&&(t=Nr.fromName(i.componentType)),this._getTypedArrayFromBinary(e,t,n,this.featuresLength,i.byteOffset)):this._getTypedArrayFromArray(e,t,i)}getProperty(e,t,n,i,s){const r=this.json[e];if(!r)return r;const o=this.getPropertyArray(e,t,n);if(1===n)return o[i];for(let e=0;e<n;++e)s[e]=o[n*i+e];return s}_getTypedArrayFromBinary(e,t,n,i,s){const r=this._cachedTypedArrays;let o=r[e];return o||(o=Nr.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+s,i*n),r[e]=o),o}_getTypedArrayFromArray(e,t,n){const i=this._cachedTypedArrays;let s=i[e];return s||(s=Nr.createTypedArray(t,n),i[e]=s),s}}const Hr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jr={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},Jr={SCALAR:(e,t,n)=>{t[n]=e},VEC2:(e,t,n)=>{t[2*n+0]=e[0],t[2*n+1]=e[1]},VEC3:(e,t,n)=>{t[3*n+0]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2]},VEC4:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT2:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT3:(e,t,n)=>{t[9*n+0]=e[0],t[9*n+1]=e[1],t[9*n+2]=e[2],t[9*n+3]=e[3],t[9*n+4]=e[4],t[9*n+5]=e[5],t[9*n+6]=e[6],t[9*n+7]=e[7],t[9*n+8]=e[8],t[9*n+9]=e[9]},MAT4:(e,t,n)=>{t[16*n+0]=e[0],t[16*n+1]=e[1],t[16*n+2]=e[2],t[16*n+3]=e[3],t[16*n+4]=e[4],t[16*n+5]=e[5],t[16*n+6]=e[6],t[16*n+7]=e[7],t[16*n+8]=e[8],t[16*n+9]=e[9],t[16*n+10]=e[10],t[16*n+11]=e[11],t[16*n+12]=e[12],t[16*n+13]=e[13],t[16*n+14]=e[14],t[16*n+15]=e[15]}};const Vr=e=>void 0!==e;function zr(e,t,n){if(!t)return null;let i=e.getExtension("3DTILES_batch_table_hierarchy");const s=t.HIERARCHY;return s&&(t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=s,i=s),i?function(e,t){let n,i,s;const r=e.instancesLength,o=e.classes;let a,c=e.classIds,h=e.parentCounts,l=e.parentIds,u=r;Vr(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,s=getBinaryAccessor(c),c=s.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,r));if(Vr(h))for(Vr(h.byteOffset)&&(h.componentType=defaultValue(h.componentType,GL.UNSIGNED_SHORT),h.type=AttributeType.SCALAR,s=getBinaryAccessor(h),h=s.createArrayBufferView(t.buffer,t.byteOffset+h.byteOffset,r)),a=new Uint16Array(r),u=0,n=0;n<r;++n)a[n]=u,u+=h[n];Vr(l)&&Vr(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,s=getBinaryAccessor(l),l=s.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,u));const d=o.length;for(n=0;n<d;++n){const e=o[n].length,i=o[n].instances,s=getBinaryProperties(e,i,t);o[n].instances=combine(s,i)}const f=new Array(d).fill(0),p=new Uint16Array(r);for(n=0;n<r;++n)i=c[n],p[n]=f[i],++f[i];const m={classes:o,classIds:c,classIndexes:p,parentCounts:h,parentIndexes:a,parentIds:l};return function(e){const t=e.classIds,n=t.length;for(let t=0;t<n;++t)Wr(e,t,stack)}(m),m}(i,n):null}function Kr(e,t,n){if(!e)return;const i=e.parentCounts;return e.parentIds?n(e,t):i>0?function(e,t,n){const i=e.classIds,s=e.parentCounts,r=e.parentIds,o=e.parentIndexes,a=i.length,c=scratchVisited;c.length=Math.max(c.length,a);const h=++marker,l=scratchStack;l.length=0,l.push(t);for(;l.length>0;){if(c[t=l.pop()]===h)continue;c[t]=h;const i=n(e,t);if(Vr(i))return i;const a=s[t],u=o[t];for(let e=0;e<a;++e){const n=r[u+e];n!==t&&l.push(n)}}return null}(e,t,n):function(e,t,n){let i=!0;for(;i;){const s=n(e,t);if(Vr(s))return s;const r=e.parentIds[t];i=r!==t,t=r}throw new Error("traverseHierarchySingleParent")}(e,t,n)}function Wr(e,t,n){const i=e.parentCounts,s=e.parentIds,r=e.parentIndexes,o=e.classIds.length;if(!Vr(s))return;assert(t<o,"Parent index ".concat(t," exceeds the total number of instances: ").concat(o)),assert(-1===n.indexOf(t),"Circular dependency detected in the batch table hierarchy."),n.push(t);const a=Vr(i)?i[t]:1,c=Vr(i)?r[t]:t;for(let i=0;i<a;++i){const r=s[c+i];r!==t&&Wr(e,r,n)}n.pop(t)}function Qr(e){return null!=e}const Xr=(e,t)=>e,Yr={HIERARCHY:!0,extensions:!0,extras:!0};class qr{constructor(e,t,n){var i;let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};En(this,"json",void 0),En(this,"binary",void 0),En(this,"featureCount",void 0),En(this,"_extensions",void 0),En(this,"_properties",void 0),En(this,"_binaryProperties",void 0),En(this,"_hierarchy",void 0),cn(n>=0),this.json=e||{},this.binary=t,this.featureCount=n,this._extensions=(null===(i=this.json)||void 0===i?void 0:i.extensions)||{},this._properties={};for(const e in this.json)Yr[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),s["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=zr(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),cn("string"==typeof t,t),this._hierarchy){return Qr(Kr(this._hierarchy,e,((e,n)=>{const i=e.classIds[n];return e.classes[i].name===t})))}return!1}isExactClass(e,t){return cn("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),cn("string"==typeof t,t),Qr(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=Qr(t)?t:[]).length=0;const n=Object.keys(this._properties);return t.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),cn("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(Qr(n))return this._getBinaryProperty(n,e)}const n=this._properties[t];if(Qr(n))return Xr(n[e]);if(this._hierarchy){const n=this._getHierarchyProperty(e,t);if(Qr(n))return n}}setProperty(e,t,n){const i=this.featureCount;if(this._checkBatchId(e),cn("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(i)return void this._setBinaryProperty(i,e,n)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,n))return;let s=this._properties[t];Qr(s)||(this._properties[t]=new Array(i),s=this._properties[t]),s[e]=Xr(n)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,t){return e.unpack(e.typedArray,t)}_setBinaryProperty(e,t,n){e.pack(n,e.typedArray,t)}_initializeBinaryProperties(){let e=null;for(const t in this._properties){const n=this._properties[t],i=this._initializeBinaryProperty(t,n);i&&(e=e||{},e[t]=i)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const n=t;cn(this.binary,"Property ".concat(e," requires a batch table binary.")),cn(n.type,"Property ".concat(e," requires a type."));const i=function(e,t,n,i){const{componentType:s}=e;cn(e.componentType);const r="string"==typeof s?Nr.fromName(s):s,o=Hr[e.type],a=jr[e.type],c=Jr[e.type];return n+=e.byteOffset,{values:Nr.createTypedArray(r,t,n,o*i),type:r,size:o,unpacker:a,packer:c}}(n,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:i.values,componentCount:i.size,unpack:i.unpacker,pack:i.packer}}return null}_hasPropertyInHierarchy(e,t){if(!this._hierarchy)return!1;const n=Kr(this._hierarchy,e,((e,n)=>{const i=e.classIds[n];return Qr(e.classes[i].instances[t])}));return Qr(n)}_getPropertyNamesInHierarchy(e,t){Kr(this._hierarchy,e,((e,n)=>{const i=e.classIds[n],s=e.classes[i].instances;for(const e in s)s.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)}))}_getHierarchyProperty(e,t){return Kr(this._hierarchy,e,((e,n)=>{const i=e.classIds[n],s=e.classes[i],r=e.classIndexes[n],o=s.instances[t];return Qr(o)?Qr(o.typedArray)?this._getBinaryProperty(o,r):Xr(o[r]):null}))}_setHierarchyProperty(e,t,n,i){const s=Kr(this._hierarchy,t,((e,s)=>{const r=e.classIds[s],o=e.classes[r],a=e.classIndexes[s],c=o.instances[n];return!!Qr(c)&&(cn(s===t,'Inherited property "'.concat(n,'" is read-only.')),Qr(c.typedArray)?this._setBinaryProperty(c,a,i):c[a]=Xr(i),!0)}));return Qr(s)}}const Zr=4;function $r(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const i=new DataView(t);if(e.magic=i.getUint32(n,!0),n+=Zr,e.version=i.getUint32(n,!0),n+=Zr,e.byteLength=i.getUint32(n,!0),n+=Zr,1!==e.version)throw new Error("3D Tile Version ".concat(e.version," not supported"));return n}const eo=4;function to(e,t,n){const i=new DataView(t);let s;e.header=e.header||{};let r=i.getUint32(n,!0);n+=eo;let o=i.getUint32(n,!0);n+=eo;let a=i.getUint32(n,!0);n+=eo;let c=i.getUint32(n,!0);return n+=eo,a>=570425344?(n-=2*eo,s=r,a=o,c=0,r=0,o=0):c>=570425344&&(n-=eo,s=a,a=r,c=o,r=0,o=0),e.header.featureTableJsonByteLength=r,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=c,e.header.batchLength=s,n}function no(e,t,n,i){return n=function(e,t,n,i){const{featureTableJsonByteLength:s,featureTableBinaryByteLength:r,batchLength:o}=e.header;if(e.featureTableJson={BATCH_LENGTH:o||0},s>0){const i=rs(t,n,s);e.featureTableJson=JSON.parse(i)}return n+=s,e.featureTableBinary=new Uint8Array(t,n,r),n+=r,n}(e,t,n),n=function(e,t,n,i){const{batchTableJsonByteLength:s,batchTableBinaryByteLength:r}=e.header;if(s>0){const i=rs(t,n,s);e.batchTableJson=JSON.parse(i),n+=s,r>0&&(e.batchTableBinary=new Uint8Array(t,n,r),e.batchTableBinary=new Uint8Array(e.batchTableBinary),n+=r)}return n}(e,t,n),n}function io(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];const n=e>>11&31,i=e>>5&63,s=31&e;return t[0]=n<<3,t[1]=i<<2,t[2]=s<<3,t}function so(e,t,n){if(!(t||e&&e.batchIds&&n))return null;const{batchIds:i,isRGB565:s,pointCount:r}=e;if(i&&n){const e=new Uint8ClampedArray(3*r);for(let t=0;t<r;t++){const s=i[t],r=n.getProperty(s,"dimensions").map((e=>255*e));e[3*t]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2]}return{type:ir.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(s){const e=new Uint8ClampedArray(3*r);for(let n=0;n<r;n++){const i=io(t[n]);e[3*n]=i[0],e[3*n+1]=i[1],e[3*n+2]=i[2]}return{type:ir.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*r?{type:ir.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:ir.UNSIGNED_BYTE,value:t,size:4,normalized:!0}}function ro(e,t,n){var i=t[0],s=t[1];return e[0]=n[0]*i+n[3]*s+n[6],e[1]=n[1]*i+n[4]*s+n[7],e}function oo(e,t,n){var i=t[0],s=t[1];return e[0]=n[0]*i+n[4]*s+n[12],e[1]=n[1]*i+n[5]*s+n[13],e}!function(){var e,t=(e=new Br(2),Br!=Float32Array&&(e[0]=0,e[1]=0),e)}();class ao extends Ar{constructor(e=0,t=0){super(2),cr(e)&&1===arguments.length?this.copy(e):(or.debug&&(pr(e),pr(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return or.debug&&(pr(e.x),pr(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return oo(this,this,e),this.check()}transformAsVector(e){return Sr(this,this,e),this.check()}transformByMatrix3(e){return ro(this,this,e),this.check()}transformByMatrix2x3(e){return function(e,t,n){var i=t[0],s=t[1];e[0]=n[0]*i+n[2]*s+n[4],e[1]=n[1]*i+n[3]*s+n[5]}(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,n){var i=t[0],s=t[1];e[0]=n[0]*i+n[2]*s,e[1]=n[1]*i+n[3]*s}(this,this,e),this.check()}}new ao,new Gr,new ao,new ao,new Uint8Array(1);function co(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:255;return function(e,t,n){return dr(e,(e=>Math.max(t,Math.min(n,e))))}(e,0,t)/t*2-1}function ho(e){return e<0?-1:1}function lo(e,t,n,i){if(function(e,t){if(!e)throw new Error("math.gl assertion failed. ".concat(t))}(i),e<0||e>n||t<0||t>n)throw new Error("x and y must be unsigned normalized integers between 0 and ".concat(n));if(i.x=co(e,n),i.y=co(t,n),i.z=1-(Math.abs(i.x)+Math.abs(i.y)),i.z<0){const e=i.x;i.x=(1-Math.abs(i.y))*ho(e),i.y=(1-Math.abs(e))*ho(i.y)}return i.normalize()}function uo(e,t,n){return lo(e,t,255,n)}const fo=new Gr;function po(e,t,n){return e.isQuantized?n["3d-tiles"]&&n["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const n=new Gr,i=new Float32Array(3*e.pointCount);for(let s=0;s<e.pointCount;s++)n.set(t[3*s],t[3*s+1],t[3*s+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(i,3*s);return i}(e,t)):{type:ir.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function mo(e,t,n,i,s){n=no(e,t,n=to(e,t,n=$r(e,t,n))),function(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}(e);const{featureTable:r,batchTable:o}=function(e){const t=new Ur(e.featureTableJson,e.featureTableBinary),n=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(n))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=n,e.featuresLength=n,e.pointsLength=n,e.pointCount=n,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",ir.FLOAT,3);const i=function(e,t){let n=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",ir.UNSIGNED_SHORT,1),e.batchIds)){const i=t.getGlobalProperty("BATCH_LENGTH");if(!i)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:s,batchTableBinary:r}=e;n=new qr(s,r,i)}return n}(e,t);return{featureTable:t,batchTable:i}}(e);return await async function(e,t,n,i,s){let r,o,a;const c=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);const h=t.getExtension("3DTILES_draco_point_compression");if(h){o=h.properties;const t=h.byteOffset,n=h.byteLength;if(!o||!Number.isFinite(t)||!n)throw new Error("Draco properties, byteOffset, and byteLength must be defined");r=e.featureTableBinary.slice(t,t+n),e.hasPositions=Number.isFinite(o.POSITION),e.hasColors=Number.isFinite(o.RGB)||Number.isFinite(o.RGBA),e.hasNormals=Number.isFinite(o.NORMAL),e.hasBatchIds=Number.isFinite(o.BATCH_ID),e.isTranslucent=Number.isFinite(o.RGBA)}if(!r)return!0;const l={buffer:r,properties:{...o,...a},featureTableProperties:o,batchTableProperties:a,dequantizeInShader:!1};return await async function(e,t,n,i){const{parse:s}=i,r={...n,draco:{...n.draco,extraAttributes:t.batchTableProperties||{}}};delete r["3d-tiles"];const o=await s(t.buffer,tr,r),a=o.attributes.POSITION&&o.attributes.POSITION.value,c=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,h=o.attributes.NORMAL&&o.attributes.NORMAL.value,l=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,u=a&&o.attributes.POSITION.value.quantization,d=h&&o.attributes.NORMAL.value.quantization;if(u){const t=o.POSITION.data.quantization,n=t.range;e.quantizedVolumeScale=new Gr(n,n,n),e.quantizedVolumeOffset=new Gr(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}d&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const f={};if(t.batchTableProperties)for(const e of Object.keys(t.batchTableProperties))o.attributes[e]&&o.attributes[e].value&&(f[e.toLowerCase()]=o.attributes[e].value);e.attributes={positions:a,colors:so(e,c,void 0),normals:h,batchIds:l,...f}}(e,l,i,s)}(e,r,0,i,s),function(e,t,n){if(!e.attributes.positions)if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",ir.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const i=t.getPropertyArray("POSITION_QUANTIZED",ir.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ir.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ir.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=po(e,i,n)}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(e,r,i),function(e,t,n){if(!e.attributes.colors){let i=null;t.hasProperty("RGBA")?(i=t.getPropertyArray("RGBA",ir.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?i=t.getPropertyArray("RGB",ir.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(i=t.getPropertyArray("RGB565",ir.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=so(e,i,n)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",ir.UNSIGNED_BYTE,4))}(e,r,o),function(e,t){if(!e.attributes.normals){let n=null;t.hasProperty("NORMAL")?n=t.getPropertyArray("NORMAL",ir.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(n=t.getPropertyArray("NORMAL_OCT16P",ir.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=function(e,t){if(!t)return null;if(e.isOctEncoded16P){const n=new Float32Array(3*e.pointsLength);for(let i=0;i<e.pointsLength;i++)uo(t[2*i],t[2*i+1],fo),fo.toArray(n,3*i);return{type:ir.FLOAT,size:2,value:n}}return{type:ir.FLOAT,size:2,value:t}}(e,n)}}(e,r),n}const go="3.4.4",Ao="https://unpkg.com/@loaders.gl/textures@".concat(go,"/dist/libs/basis_encoder.wasm"),yo="https://unpkg.com/@loaders.gl/textures@".concat(go,"/dist/libs/basis_encoder.js");let Bo,bo;async function Co(e){const t=e.modules||{};return t.basis?t.basis:(Bo=Bo||async function(e){let t=null,n=null;return[t,n]=await Promise.all([await Qs("basis_transcoder.js","textures",e),await Qs("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise((t=>{e(n).then((e=>{const{BasisFile:n,initializeBasis:i}=e;i(),t({BasisFile:n})}))}))}(t,n)}(e),await Bo)}async function vo(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(bo=bo||async function(e){let t=null,n=null;return[t,n]=await Promise.all([await Qs(yo,"textures",e),await Qs(Ao,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise((t=>{e(n).then((e=>{const{BasisFile:n,KTX2File:i,initializeBasis:s,BasisEncoder:r}=e;s(),t({BasisFile:n,KTX2File:i,BasisEncoder:r})}))}))}(t,n)}(e),await bo)}const wo=33776,Eo=33779,Mo=35840,xo=35842,To=36196,Io=37808,Ro=["","WEBKIT_","MOZ_"],So={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let Oo=null;function Do(e){if(!Oo){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Oo=new Set;for(const t of Ro)for(const n in So)if(e&&e.getExtension("".concat(t).concat(n))){const e=So[n];Oo.add(e)}}return Oo}new Uint8Array([0]);var Fo,_o,Go,Lo,Po,ko,No,Uo;!function(e){e[e.NONE=0]="NONE",e[e.BASISLZ=1]="BASISLZ",e[e.ZSTD=2]="ZSTD",e[e.ZLIB=3]="ZLIB"}(Fo||(Fo={})),function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(_o||(_o={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(Go||(Go={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(Lo||(Lo={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(Po||(Po={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(ko||(ko={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(No||(No={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(Uo||(Uo={}));const Ho=[171,75,84,88,32,50,48,187,13,10,26,10];const jo={etc1:{basisFormat:0,compressed:!0,format:To},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:wo},bc3:{basisFormat:3,compressed:!0,format:Eo},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:Mo},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:xo},"astc-4x4":{basisFormat:10,compressed:!0,format:Io},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function Jo(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("Failed to start basis transcoding");const e=i.getNumImages(),t=[];for(let s=0;s<e;s++){const e=i.getNumLevels(s),r=[];for(let t=0;t<e;t++)r.push(Vo(i,s,t,n));t.push(r)}return t}finally{i.close(),i.delete()}}function Vo(e,t,n,i){const s=e.getImageWidth(t,n),r=e.getImageHeight(t,n),o=e.getHasAlpha(),{compressed:a,format:c,basisFormat:h}=Wo(i,o),l=e.getImageTranscodedSizeInBytes(t,n,h),u=new Uint8Array(l);if(!e.transcodeImage(u,t,n,h,0,0))throw new Error("failed to start Basis transcoding");return{width:s,height:r,data:u,compressed:a,format:c,hasAlpha:o}}function zo(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=i.getLevels(),t=[];for(let s=0;s<e;s++){t.push(Ko(i,s,n));break}return[t]}finally{i.close(),i.delete()}}function Ko(e,t,n){const{alphaFlag:i,height:s,width:r}=e.getImageLevelInfo(t,0,0),{compressed:o,format:a,basisFormat:c}=Wo(n,i),h=e.getImageTranscodedSizeInBytes(t,0,0,c),l=new Uint8Array(h);if(!e.transcodeImage(l,t,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:r,height:s,data:l,compressed:o,levelSize:h,hasAlpha:i,format:a}}function Wo(e,t){let n=e&&e.basis&&e.basis.format;return"auto"===n&&(n=Qo()),"object"==typeof n&&(n=t?n.alpha:n.noAlpha),n=n.toLowerCase(),jo[n]}function Qo(){const e=Do();return e.has("astc")?"astc-4x4":e.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:e.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:e.has("etc1")?"etc1":e.has("etc2")?"etc2":"rgb565"}const Xo={name:"Basis",id:ci?"basis":"basis-nodejs",module:"textures",version:"3.4.4",worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",containerFormat:"auto",module:"transcoder"}}},Yo={...Xo,parse:async function(e,t){if("auto"===t.basis.containerFormat){if(function(e){const t=new Uint8Array(e);return!(t.byteLength<Ho.length||t[0]!==Ho[0]||t[1]!==Ho[1]||t[2]!==Ho[2]||t[3]!==Ho[3]||t[4]!==Ho[4]||t[5]!==Ho[5]||t[6]!==Ho[6]||t[7]!==Ho[7]||t[8]!==Ho[8]||t[9]!==Ho[9]||t[10]!==Ho[10]||t[11]!==Ho[11])}(e)){return zo((await vo(t)).KTX2File,e,t)}const{BasisFile:n}=await Co(t);return Jo(n,e,t)}if("encoder"===t.basis.module){const n=await vo(t);return"ktx2"===t.basis.containerFormat?zo(n.KTX2File,e,t):Jo(n.BasisFile,e,t)}{const{BasisFile:n}=await Co(t);return Jo(n,e,t)}}},{_parseImageNode:qo}=globalThis,Zo="undefined"!=typeof Image,$o="undefined"!=typeof ImageBitmap,ea=Boolean(qo),ta=!!Kn||ea;function na(e){const t=sa(e);if(!t)throw new Error("Not an image");return t}function ia(e){switch(na(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function sa(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"image":e&&"object"==typeof e&&e.data&&e.width&&e.height?"data":null}const ra=/^data:image\/svg\+xml/,oa=/\.svg((\?|#).*)?$/;function aa(e){return e&&(ra.test(e)||oa.test(e))}function ca(e,t){if(aa(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function ha(e,t,n){const i=function(e,t){if(aa(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return"data:image/svg+xml;base64,".concat(btoa(t))}return ca(e,t)}(e,n),s=self.URL||self.webkitURL,r="string"!=typeof i&&s.createObjectURL(i);try{return await async function(e,t){const n=new Image;if(n.src=e,t.image&&t.image.decode&&n.decode)return await n.decode(),n;return await new Promise(((t,i)=>{try{n.onload=()=>t(n),n.onerror=t=>i(new Error("Could not load image ".concat(e,": ").concat(t)))}catch(e){i(e)}}))}(r||i,t)}finally{r&&s.revokeObjectURL(r)}}const la={};let ua=!0;async function da(e,t,n){let i;if(aa(n)){i=await ha(e,t,n)}else i=ca(e,n);const s=t&&t.imagebitmap;return await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(e){for(const t in e||la)return!1;return!0}(t)&&ua||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){ua=!1}return await createImageBitmap(e)}(i,s)}function fa(e){return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const i=(s=t,[...s].map((e=>e.charCodeAt(0))));var s;for(let t=0;t<i.length;++t)if(i[t]!==e[t+n])return!1;return!0}(e,"ftyp",4)?0==(96&e[8])?null:function(e){switch((t=e,n=8,i=12,String.fromCharCode(...t.slice(n,i))).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}var t,n,i}(e):null}const pa=!1,ma=!0;function ga(e){const t=Aa(e);return function(e){const t=Aa(e),n=t.byteLength>=24&&2303741511===t.getUint32(0,pa);if(!n)return null;return{mimeType:"image/png",width:t.getUint32(16,pa),height:t.getUint32(20,pa)}}(t)||function(e){const t=Aa(e),n=t.byteLength>=3&&65496===t.getUint16(0,pa)&&255===t.getUint8(2);if(!n)return null;const{tableMarkers:i,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r+9<t.byteLength;){const e=t.getUint16(r,pa);if(s.has(e))return{mimeType:"image/jpeg",height:t.getUint16(r+5,pa),width:t.getUint16(r+7,pa)};if(!i.has(e))return null;r+=2,r+=t.getUint16(r,pa)}return null}(t)||function(e){const t=Aa(e),n=t.byteLength>=10&&1195984440===t.getUint32(0,pa);if(!n)return null;return{mimeType:"image/gif",width:t.getUint16(6,ma),height:t.getUint16(8,ma)}}(t)||function(e){const t=Aa(e),n=t.byteLength>=14&&16973===t.getUint16(0,pa)&&t.getUint32(2,ma)===t.byteLength;if(!n)return null;return{mimeType:"image/bmp",width:t.getUint32(18,ma),height:t.getUint32(22,ma)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),n=fa(t);if(!n)return null;return{mimeType:n.mimeType,width:0,height:0}}(t)}function Aa(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const ya={id:"image",module:"images",name:"Images",version:"3.4.4",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,n){const i=((t=t||{}).image||{}).type||"auto",{url:s}=n||{};let r;switch(function(e){switch(e){case"auto":case"data":return function(){if($o)return"imagebitmap";if(Zo)return"image";if(ta)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return $o||Zo||ta;case"imagebitmap":return $o;case"image":return Zo;case"data":return ta;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}(i)){case"imagebitmap":r=await da(e,t,s);break;case"image":r=await ha(e,t,s);break;case"data":r=await async function(e,t){const{mimeType:n}=ga(e)||{},i=globalThis._parseImageNode;return cn(i),await i(e,n)}(e);break;default:cn(!1)}return"data"===i&&(r=ia(r)),r},tests:[e=>Boolean(ga(new DataView(e)))],options:{image:{type:"auto",decode:!0}}};function Ba(e,t,n){if(e.byteLength<=t+n)return"";const i=new DataView(e);let s="";for(let e=0;e<n;e++)s+=String.fromCharCode(i.getUint8(t+e));return s}function ba(e){try{return JSON.parse(e)}catch(t){throw new Error('Failed to parse JSON from data starting with "'.concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Ba(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer)return Ba(e,0,t);return""}(e),'"'))}}function Ca(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function va(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const n=t.baseUri||t.uri;if(!n)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return n.substr(0,n.lastIndexOf("/")+1)+e}function wa(e,t,n){const i=e.bufferViews[n];Ca(i);const s=t[i.buffer];Ca(s);const r=(i.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,r,i.byteLength)}function Ea(e,t){return cn(e>=0),cn(t>0),e+(t-1)&~(t-1)}function Ma(e,t,n){let i;if(e instanceof ArrayBuffer)i=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;i=new Uint8Array(e.buffer||e.arrayBuffer,t,n)}return t.set(i,n),n+Ea(i.byteLength,4)}const xa=["SCALAR","VEC2","VEC3","VEC4"],Ta=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Ia=new Map(Ta),Ra={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Sa={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Oa={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Da(e){return xa[e-1]||xa[0]}function Fa(e){const t=Ia.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function _a(e,t){const n=Oa[e.componentType],i=Ra[e.type],s=Sa[e.componentType],r=e.count*i,o=e.count*i*s;return Ca(o>=0&&o<=t.byteLength),{ArrayType:n,length:r,byteLength:o}}function Ga(e){let{images:t,bufferViews:n}=e;t=t||[],n=n||[];const i=t.map((e=>e.bufferView));n=n.filter((e=>!i.includes(e)));const s=n.reduce(((e,t)=>e+t.byteLength),0),r=t.reduce(((e,t)=>{const{width:n,height:i}=t.image;return e+n*i}),0);return s+Math.ceil(4*r*1.33)}const La={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class Pa{constructor(e){En(this,"gltf",void 0),En(this,"sourceBuffers",void 0),En(this,"byteLength",void 0),this.gltf=e||{json:{...La},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find((t=>t===e)),n=this.json.extensions||{};return t?n[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find((t=>t===e))?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const n=this.json[e]&&this.json[e][t];if(!n)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return n}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,n=this.gltf.buffers[t];Ca(n);const i=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,i,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,{ArrayType:i,length:s}=_a(e,t);return new i(n,t.byteOffset+e.byteOffset,s)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,i=t.byteOffset||0;return new Uint8Array(n,i,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,n){return e.extensions=e.extensions||{},e.extensions[t]=n,this.registerUsedExtension(t),this}setObjectExtension(e,t,n){(e.extensions||{})[t]=n}removeObjectExtension(e,t){const n=e.extensions||{},i=n[t];return delete n[t],i}addExtension(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Ca(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Ca(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((t=>t===e))||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((t=>t===e))||this.json.extensionsRequired.push(e)}removeExtension(e){if(!this.getExtension(e))return;this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e],Array.isArray(this.json.extensionsRemoved)||(this.json.extensionsRemoved=[]);const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:n}=e;this.json.nodes=this.json.nodes||[];const i={mesh:t};return n&&(i.matrix=n),this.json.nodes.push(i),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:n,material:i,mode:s=4}=e,r={primitives:[{attributes:this._addAttributes(t),mode:s}]};if(n){const e=this._addIndices(n);r.primitives[0].indices=e}return Number.isFinite(i)&&(r.primitives[0].material=i),this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const n=ga(e),i=t||(null==n?void 0:n.mimeType),s={bufferView:this.addBufferView(e),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(s),this.json.images.length-1}addBufferView(e){const t=e.byteLength;Ca(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const n={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Ea(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:Da(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{size:3};const n=this.addBufferView(e);let i={min:t.min,max:t.max};i.min&&i.max||(i=this._getAccessorMinMax(e,t.size));const s={size:t.size,componentType:Fa(e),count:Math.round(e.length/t.size),min:i.min,max:i.max};return this.addAccessor(n,Object.assign(s,t))}addTexture(e){const{imageIndex:t}=e,n={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const n=this.byteLength,i=new ArrayBuffer(n),s=new Uint8Array(i);let r=0;for(const e of this.sourceBuffers||[])r=Ma(e,s,r);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=n:this.json.buffers=[{byteLength:n}],this.gltf.binary=i,this.sourceBuffers=[i]}_removeStringFromArray(e,t){let n=!0;for(;n;){const i=e.indexOf(t);i>-1?e.splice(i,1):n=!1}}_addAttributes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={};for(const n in e){const i=e[n],s=this._getGltfAttributeName(n),r=this.addBinaryBuffer(i.value,i);t[s]=r}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const n={min:null,max:null};if(e.length<t)return n;n.min=[],n.max=[];const i=e.subarray(0,t);for(const e of i)n.min.push(e),n.max.push(e);for(let i=t;i<e.length;i+=t)for(let s=0;s<t;s++)n.min[0+s]=Math.min(n.min[0+s],e[i+s]),n.max[0+s]=Math.max(n.max[0+s],e[i+s]);return n}}const ka="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",Na="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",Ua=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),Ha=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),ja={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ja={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};let Va;async function za(){return Va||(Va=async function(){let e=ka;WebAssembly.validate(Ua)&&(e=Na);const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;++n){const i=e.charCodeAt(n);t[n]=i>96?i-71:i>64?i-65:i>47?i+4:i>46?63:62}let n=0;for(let i=0;i<e.length;++i)t[n++]=t[i]<60?Ha[t[i]]:64*(t[i]-60)+t[++i];return t.buffer.slice(0,n)}(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}()),Va}function Ka(e,t,n,i,s,r,o){const a=e.exports.sbrk,c=i+3&-4,h=a(c*s),l=a(r.length),u=new Uint8Array(e.exports.memory.buffer);u.set(r,l);const d=t(h,i,s,l,r.length);if(0===d&&o&&o(h,c,s),n.set(u.subarray(h,h+i*s)),a(h-a(0)),0!==d)throw new Error("Malformed buffer data: ".concat(d))}const Wa="EXT_meshopt_compression",Qa=Wa;async function Xa(e,t){var n;const i=new Pa(e);if(null==t||null===(n=t.gltf)||void 0===n||!n.decompressMeshes)return;const s=[];for(const t of e.json.bufferViews||[])s.push(Ya(i,t));await Promise.all(s),i.removeExtension(Wa)}async function Ya(e,t){const n=e.getObjectExtension(t,Wa);if(n){const{byteOffset:i=0,byteLength:s=0,byteStride:r,count:o,mode:a,filter:c="NONE",buffer:h}=n,l=e.gltf.buffers[h],u=new Uint8Array(l.arrayBuffer,l.byteOffset+i,s),d=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);return await async function(e,t,n,i,s){let r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NONE";const o=await za();Ka(o,o.exports[Ja[s]],e,t,n,i,o.exports[ja[r||"NONE"]])}(d,o,r,u,a,c),d}return null}const qa={};function Za(e){if(void 0===qa[e]){const t=Kn?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf("data:".concat(e))}catch{return!1}}(e);default:return!0}}(e):$a(e);qa[e]=t}return qa[e]}function $a(e){const t=["image/png","image/jpeg","image/gif"],{_parseImageNode:n,_imageFormatsNode:i=t}=globalThis;return Boolean(n)&&i.includes(e)}const ec="EXT_texture_webp",tc=ec;function nc(e,t){const n=new Pa(e);if(!Za("image/webp")){if(n.getRequiredExtensions().includes(ec))throw new Error("gltf: Required extension ".concat(ec," not supported by browser"));return}const{json:i}=n;for(const e of i.textures||[]){const t=n.getObjectExtension(e,ec);t&&(e.source=t.source),n.removeObjectExtension(e,ec)}n.removeExtension(ec)}const ic="KHR_texture_basisu",sc=ic;function rc(e,t){const n=new Pa(e),{json:i}=n;for(const e of i.textures||[]){const t=n.getObjectExtension(e,ic);t&&(e.source=t.source),n.removeObjectExtension(e,ic)}n.removeExtension(ic)}function oc(e){const{buffer:t,size:n,count:i}=function(e){let t=e,n=1,i=0;e&&e.value&&(t=e.value,n=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!e)return null;if(Array.isArray(e))return new t(e);if(n&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),i=t.length/n);return{buffer:t,size:n,count:i}}(e);return{value:t,size:n,byteOffset:0,count:i,type:Da(n),componentType:Fa(t)}}const ac="KHR_draco_mesh_compression",cc=ac;function hc(e,t,n){const i=new Pa(e);for(const e of pc(i))i.getObjectExtension(e,ac)}async function lc(e,t,n){var i;if(null==t||null===(i=t.gltf)||void 0===i||!i.decompressMeshes)return;const s=new Pa(e),r=[];for(const e of pc(s))s.getObjectExtension(e,ac)&&r.push(dc(s,e,t,n));await Promise.all(r),s.removeExtension(ac)}function uc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new Pa(e);for(const e of n.json.meshes||[])fc(e,t),n.addRequiredExtension(ac)}async function dc(e,t,n,i){const s=e.getObjectExtension(t,ac);if(!s)return;const r=e.getTypedArrayForBufferView(s.bufferView),o=Ti(r.buffer,r.byteOffset),{parse:a}=i,c={...n};delete c["3d-tiles"];const h=await a(o,tr,c,i),l=function(e){const t={};for(const n in e){const i=e[n];if("indices"!==n){const e=oc(i);t[n]=e}}return t}(h.attributes);for(const[n,i]of Object.entries(l))if(n in t.attributes){const s=t.attributes[n],r=e.getAccessor(s);null!=r&&r.min&&null!=r&&r.max&&(i.min=r.min,i.max=r.max)}t.attributes=l,h.indices&&(t.indices=oc(h.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function fc(e,t){var n;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,s=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=s.DracoWriter.encodeSync({attributes:e}),a=null==r||null===(n=r.parseSync)||void 0===n?void 0:n.call(r,{attributes:e}),c=s._addFauxAttributes(a.attributes),h=s.addBufferView(o);return{primitives:[{attributes:c,mode:i,extensions:{[ac]:{bufferView:h,attributes:c}}}]}}function*pc(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}class mc extends fr{toString(){let e="[";if(or.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=" ".concat(this[n*this.RANK+t])}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=" ".concat(this[t])}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=pr(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const n=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[n+e];return t}setColumn(e,t){const n=e*this.RANK;for(let e=0;e<this.RANK;++e)this[n+e]=t[e];return this}}function gc(e,t,n){var i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=n[0],f=n[1],p=n[2],m=n[3],g=n[4],A=n[5],y=n[6],B=n[7],b=n[8];return e[0]=d*i+f*o+p*h,e[1]=d*s+f*a+p*l,e[2]=d*r+f*c+p*u,e[3]=m*i+g*o+A*h,e[4]=m*s+g*a+A*l,e[5]=m*r+g*c+A*u,e[6]=y*i+B*o+b*h,e[7]=y*s+B*a+b*l,e[8]=y*r+B*c+b*u,e}function Ac(e,t,n){var i=n[0],s=n[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}var yc;!function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"}(yc||(yc={}));const Bc=Object.freeze([1,0,0,0,1,0,0,0,1]);class bc extends mc{static get IDENTITY(){return function(){vc||(vc=new bc,Object.freeze(vc));return vc}()}static get ZERO(){return function(){Cc||(Cc=new bc([0,0,0,0,0,0,0,0,0]),Object.freeze(Cc));return Cc}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return yc}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(Bc)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var n=t[0],i=t[1],s=t[2],r=t[3],o=n+n,a=i+i,c=s+s,h=n*o,l=i*o,u=i*a,d=s*o,f=s*a,p=s*c,m=r*o,g=r*a,A=r*c;e[0]=1-u-p,e[3]=l-A,e[6]=d+g,e[1]=l+A,e[4]=1-h-p,e[7]=f-m,e[2]=d-g,e[5]=f+m,e[8]=1-h-u}(this,e),this.check()}set(e,t,n,i,s,r,o,a,c){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this[4]=s,this[5]=r,this[6]=o,this[7]=a,this[8]=c,this.check()}setRowMajor(e,t,n,i,s,r,o,a,c){return this[0]=e,this[1]=i,this[2]=o,this[3]=t,this[4]=s,this[5]=a,this[6]=n,this[7]=r,this[8]=c,this.check()}determinant(){return function(e){var t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],a=e[6],c=e[7],h=e[8];return t*(h*r-o*c)+n*(-h*s+o*a)+i*(c*s-r*a)}(this)}transpose(){return function(e,t){if(e===t){var n=t[1],i=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=i,e[7]=s}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]}(this,this),this.check()}invert(){return function(e,t){var n=t[0],i=t[1],s=t[2],r=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=l*o-a*h,d=-l*r+a*c,f=h*r-o*c,p=n*u+i*d+s*f;p&&(p=1/p,e[0]=u*p,e[1]=(-l*i+s*h)*p,e[2]=(a*i-s*o)*p,e[3]=d*p,e[4]=(l*n-s*c)*p,e[5]=(-a*n+s*r)*p,e[6]=f*p,e[7]=(-h*n+i*c)*p,e[8]=(o*n-i*r)*p)}(this,this),this.check()}multiplyLeft(e){return gc(this,e,this),this.check()}multiplyRight(e){return gc(this,this,e),this.check()}rotate(e){return function(e,t,n){var i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=Math.sin(n),f=Math.cos(n);e[0]=f*i+d*o,e[1]=f*s+d*a,e[2]=f*r+d*c,e[3]=f*o-d*i,e[4]=f*a-d*s,e[5]=f*c-d*r,e[6]=h,e[7]=l,e[8]=u}(this,this,e),this.check()}scale(e){return Array.isArray(e)?Ac(this,this,e):Ac(this,this,[e,e]),this.check()}translate(e){return function(e,t,n){var i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=n[0],f=n[1];e[0]=i,e[1]=s,e[2]=r,e[3]=o,e[4]=a,e[5]=c,e[6]=d*i+f*o+h,e[7]=d*s+f*a+l,e[8]=d*r+f*c+u}(this,this,e),this.check()}transform(e,t){let n;switch(e.length){case 2:n=ro(t||[-0,-0],e,this);break;case 3:n=xr(t||[-0,-0,-0],e,this);break;case 4:n=Dr(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return mr(n,e.length),n}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let Cc,vc;const wc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ec={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};const Mc="KHR_texture_transform",xc=Mc,Tc=new Gr,Ic=new bc,Rc=new bc;async function Sc(e,t){if(!new Pa(e).getExtension(Mc))return;const n=e.json.materials||[];for(let t=0;t<n.length;t++)Oc(t,e)}function Oc(e,t){var n,i,s;const r=[],o=null===(n=t.json.materials)||void 0===n?void 0:n[e],a=null==o||null===(i=o.pbrMetallicRoughness)||void 0===i?void 0:i.baseColorTexture;a&&Dc(t,e,a,r);const c=null==o?void 0:o.emissiveTexture;c&&Dc(t,e,c,r);const h=null==o?void 0:o.normalTexture;h&&Dc(t,e,h,r);const l=null==o?void 0:o.occlusionTexture;l&&Dc(t,e,l,r);const u=null==o||null===(s=o.pbrMetallicRoughness)||void 0===s?void 0:s.metallicRoughnessTexture;u&&Dc(t,e,u,r)}function Dc(e,t,n,i){const s=function(e,t){var n;const i=null===(n=e.extensions)||void 0===n?void 0:n[Mc],{texCoord:s=0}=e,{texCoord:r=s}=i,o=-1!==t.findIndex((e=>{let[t,n]=e;return t===s&&n===r}));if(!o){const n=function(e){const{offset:t=[0,0],rotation:n=0,scale:i=[1,1]}=e,s=(new bc).set(1,0,0,0,1,0,t[0],t[1],1),r=Ic.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),o=Rc.set(i[0],0,0,0,i[1],0,0,0,1);return s.multiplyRight(r).multiplyRight(o)}(i);return s!==r&&(e.texCoord=r),t.push([s,r]),{originalTexCoord:s,texCoord:r,matrix:n}}return null}(n,i);if(!s)return;const r=e.json.meshes||[];for(const n of r)for(const i of n.primitives){const n=i.material;Number.isFinite(n)&&t===n&&Fc(e,i,s)}}function Fc(e,t,n){const{originalTexCoord:i,texCoord:s,matrix:r}=n,o=t.attributes["TEXCOORD_".concat(i)];if(Number.isFinite(o)){var a;const n=null===(a=e.json.accessors)||void 0===a?void 0:a[o];if(n&&n.bufferView){var c;const o=null===(c=e.json.bufferViews)||void 0===c?void 0:c[n.bufferView];if(o){const{arrayBuffer:a,byteOffset:c}=e.buffers[o.buffer],h=(c||0)+(n.byteOffset||0)+(o.byteOffset||0),{ArrayType:l,length:u}=_a(n,o),d=Ec[n.componentType],f=wc[n.type],p=o.byteStride||d*f,m=new Float32Array(u);for(let e=0;e<n.count;e++){const t=new l(a,h+e*p,2);Tc.set(t[0],t[1],1),Tc.transformByMatrix3(r),m.set([Tc[0],Tc[1]],e*f)}i===s?function(e,t,n,i){e.componentType=5126,n.push({arrayBuffer:i.buffer,byteOffset:0,byteLength:i.buffer.byteLength}),t.buffer=n.length-1,t.byteLength=i.buffer.byteLength,t.byteOffset=0,delete t.byteStride}(n,o,e.buffers,m):function(e,t,n,i,s){i.buffers.push({arrayBuffer:s.buffer,byteOffset:0,byteLength:s.buffer.byteLength});const r=i.json.bufferViews;if(!r)return;r.push({buffer:i.buffers.length-1,byteLength:s.buffer.byteLength,byteOffset:0});const o=i.json.accessors;if(!o)return;o.push({bufferView:(null==r?void 0:r.length)-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),n.attributes["TEXCOORD_".concat(e)]=o.length-1}(s,n,t,e,m)}}}}const _c="KHR_lights_punctual",Gc=_c;async function Lc(e){const t=new Pa(e),{json:n}=t,i=t.getExtension(_c);i&&(t.json.lights=i.lights,t.removeExtension(_c));for(const e of n.nodes||[]){const n=t.getObjectExtension(e,_c);n&&(e.light=n.light),t.removeObjectExtension(e,_c)}}async function Pc(e){const t=new Pa(e),{json:n}=t;if(n.lights){const e=t.addExtension(_c);Ca(!e.lights),e.lights=n.lights,delete n.lights}if(t.json.lights){for(const e of t.json.lights){const n=e.node;t.addObjectExtension(n,_c,e)}delete t.json.lights}}const kc="KHR_materials_unlit",Nc=kc;async function Uc(e){const t=new Pa(e),{json:n}=t;for(const e of n.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,kc)}t.removeExtension(kc)}function Hc(e){const t=new Pa(e),{json:n}=t;if(t.materials)for(const e of n.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,kc,{}),t.addExtension(kc))}const jc="KHR_techniques_webgl",Jc=jc;async function Vc(e){const t=new Pa(e),{json:n}=t,i=t.getExtension(jc);if(i){const e=function(e,t){const{programs:n=[],shaders:i=[],techniques:s=[]}=e,r=new TextDecoder;return i.forEach((e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=r.decode(t.getTypedArrayForBufferView(e.bufferView))})),n.forEach((e=>{e.fragmentShader=i[e.fragmentShader],e.vertexShader=i[e.vertexShader]})),s.forEach((e=>{e.program=n[e.program]})),s}(i,t);for(const i of n.materials||[]){const n=t.getObjectExtension(i,jc);n&&(i.technique=Object.assign({},n,e[n.technique]),i.technique.values=Kc(i.technique,t)),t.removeObjectExtension(i,jc)}t.removeExtension(jc)}}async function zc(e,t){}function Kc(e,t){const n=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((t=>{e.uniforms[t].value&&!(t in n)&&(n[t]=e.uniforms[t].value)})),Object.keys(n).forEach((e=>{"object"==typeof n[e]&&void 0!==n[e].index&&(n[e].texture=t.getTexture(n[e].index))})),n}const Wc="EXT_feature_metadata",Qc=Wc;async function Xc(e){!function(e){var t;const n=e.getExtension(Wc),i=null==n||null===(t=n.schema)||void 0===t?void 0:t.classes,s=null==n?void 0:n.featureTables;null==n||n.featureTextures;if(i&&s)for(const t in i){const n=i[t],r=Zc(s,t);r&&Yc(e,r,n)}}(new Pa(e))}function Yc(e,t,n){for(const s in n.properties){var i;const r=n.properties[s],o=null==t||null===(i=t.properties)||void 0===i?void 0:i[s],a=t.count;if(o){const t=qc(e,r,a,o);o.data=t}}}function qc(e,t,n,i){const s=i.bufferView;let r=e.getTypedArrayForBufferView(s);switch(t.type){case"STRING":{const t=i.stringOffsetBufferView;r=function(e,t,n){const i=[],s=new TextDecoder("utf8");let r=0;const o=4;for(let a=0;a<n;a++){const n=t[(a+1)*o]-t[a*o],c=e.subarray(r,n+r),h=s.decode(c);i.push(h),r+=n}return i}(r,e.getTypedArrayForBufferView(t),n);break}}return r}function Zc(e,t){for(const n in e){const i=e[n];if(i.class===t)return i}return null}const $c=[e,t,n,r,a,c,h,o,l];function eh(e,t){var n;const i=(null==t||null===(n=t.gltf)||void 0===n?void 0:n.excludeExtensions)||{};return!(e in i&&!i[e])}const th="KHR_binary_glTF";const nh={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},ih={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class sh{constructor(){En(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),En(this,"json",void 0)}normalize(e,t){this.json=e.json;const n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return}if(!t.normalize)throw new Error("glTF v1 is not supported.");this._addAsset(n),this._convertTopLevelObjectsToArrays(n),function(e){const t=new Pa(e),{json:n}=t;for(const e of n.images||[]){const n=t.getObjectExtension(e,th);n&&Object.assign(e,n),t.removeObjectExtension(e,th)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(th)}(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in nh)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const n=e[t];if(n&&!Array.isArray(n)){e[t]=[];for(const i in n){const s=n[i];s.id=s.id||i;const r=e[t].length;e[t].push(s),this.idToIndexMap[t][i]=r}}}_convertObjectIdsToArrayIndices(e){for(const t in nh)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:n,material:i}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");n&&(t.indices=this._convertIdToIndex(n,"accessor")),i&&(t.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map((e=>this._convertIdToIndex(e,"node")))),e.meshes&&(e.meshes=e.meshes.map((e=>this._convertIdToIndex(e,"mesh"))))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map((e=>this._convertIdToIndex(e,"node"))))}_convertIdsToIndices(e,t){e[t]||(e[t]=[]);for(const n of e[t])for(const e in n){const t=n[e],i=this._convertIdToIndex(t,e);n[e]=i}}_convertIdToIndex(e,t){const n=ih[t];if(n in this.idToIndexMap){const i=this.idToIndexMap[n][e];if(!Number.isFinite(i))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return i}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const s of e.materials){var t,n,i;s.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const r=(null===(t=s.values)||void 0===t?void 0:t.tex)||(null===(n=s.values)||void 0===n?void 0:n.texture2d_0)||(null===(i=s.values)||void 0===i?void 0:i.diffuseTex),o=e.textures.findIndex((e=>e.id===r));-1!==o&&(s.pbrMetallicRoughness.baseColorTexture={index:o})}}}const rh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},oh={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ah=10240,ch=10241,hh=10242,lh=10243,uh=10497,dh={magFilter:ah,minFilter:ch,wrapS:hh,wrapT:lh},fh={[ah]:9729,[ch]:9986,[hh]:uh,[lh]:uh};class ph{constructor(){En(this,"baseUri",""),En(this,"json",{}),En(this,"buffers",[]),En(this,"images",[])}postProcess(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{json:n,buffers:i=[],images:s=[],baseUri:r=""}=e;return Ca(n),this.baseUri=r,this.json=n,this.buffers=i,this.images=s,this._resolveTree(this.json,t),this.json}_resolveTree(e){e.bufferViews&&(e.bufferViews=e.bufferViews.map(((e,t)=>this._resolveBufferView(e,t)))),e.images&&(e.images=e.images.map(((e,t)=>this._resolveImage(e,t)))),e.samplers&&(e.samplers=e.samplers.map(((e,t)=>this._resolveSampler(e,t)))),e.textures&&(e.textures=e.textures.map(((e,t)=>this._resolveTexture(e,t)))),e.accessors&&(e.accessors=e.accessors.map(((e,t)=>this._resolveAccessor(e,t)))),e.materials&&(e.materials=e.materials.map(((e,t)=>this._resolveMaterial(e,t)))),e.meshes&&(e.meshes=e.meshes.map(((e,t)=>this._resolveMesh(e,t)))),e.nodes&&(e.nodes=e.nodes.map(((e,t)=>this._resolveNode(e,t)))),e.skins&&(e.skins=e.skins.map(((e,t)=>this._resolveSkin(e,t)))),e.scenes&&(e.scenes=e.scenes.map(((e,t)=>this._resolveScene(e,t)))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const n=this.json[e]&&this.json[e][t];return n}_resolveScene(e,t){return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map((e=>this.getNode(e))),e}_resolveNode(e,t){return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map((e=>this.getNode(e)))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce(((e,t)=>{const n=this.getMesh(t);return e.id=n.id,e.primitives=e.primitives.concat(n.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map((e=>{const t=(e={...e}).attributes;e.attributes={};for(const n in t)e.attributes[n]=this.getAccessor(t[n]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e}))),e}_resolveMaterial(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var n,i;if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(n=e.componentType,oh[n]),e.components=(i=e.type,rh[i]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:n,byteLength:i}=_a(e,e.bufferView),s=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let r=t.arrayBuffer.slice(s,s+i);e.bufferView.byteStride&&(r=this._getValueFromInterleavedBuffer(t,s,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new n(r)}return e}_getValueFromInterleavedBuffer(e,t,n,i,s){const r=new Uint8Array(s*i);for(let o=0;o<s;o++){const s=t+o*n;r.set(new Uint8Array(e.arrayBuffer.slice(s,s+i)),o*i)}return r.buffer}_resolveTexture(e,t){return e.id=e.id||"texture-".concat(t),e.sampler="sampler"in e?this.getSampler(e.sampler):fh,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||"sampler-".concat(t),e.parameters={};for(const t in e){const n=this._enumSamplerParameter(t);void 0!==n&&(e.parameters[n]=e[t])}return e}_enumSamplerParameter(e){return dh[e]}_resolveImage(e,t){e.id=e.id||"image-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const n=this.images[t];return n&&(e.image=n),e}_resolveBufferView(e,t){const n=e.buffer,i={id:"bufferView-".concat(t),...e,buffer:this.buffers[n]},s=this.buffers[n].arrayBuffer;let r=this.buffers[n].byteOffset||0;return"byteOffset"in e&&(r+=e.byteOffset),i.data=new Uint8Array(s,r,e.byteLength),i}_resolveCamera(e,t){return e.id=e.id||"camera-".concat(t),e.perspective,e.orthographic,e}}const mh=1735152710,gh=12,Ah=8,yh=1313821514,Bh=5130562,bh=0,Ch=1,vh=0,wh=!0;function Eh(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=new DataView(t),r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return"".concat(String.fromCharCode(e.getUint8(t+0))).concat(String.fromCharCode(e.getUint8(t+1))).concat(String.fromCharCode(e.getUint8(t+2))).concat(String.fromCharCode(e.getUint8(t+3)))}(s,n+0),o=s.getUint32(n+4,wh),a=s.getUint32(n+8,wh);switch(Object.assign(e,{header:{byteOffset:n,byteLength:a,hasBinChunk:!1},type:r,version:o,json:{},binChunks:[]}),n+=gh,e.version){case 1:return function(e,t,n){cn(e.header.byteLength>gh+Ah);const i=t.getUint32(n+0,wh),s=t.getUint32(n+4,wh);return n+=Ah,cn(s===vh),Mh(e,t,n,i),n+=i,n+=xh(e,t,n,e.header.byteLength),n}(e,s,n);case 2:return function(e,t,n,i){return cn(e.header.byteLength>gh+Ah),function(e,t,n,i){for(;n+8<=e.header.byteLength;){const s=t.getUint32(n+0,wh),r=t.getUint32(n+4,wh);switch(n+=Ah,r){case yh:Mh(e,t,n,s);break;case Bh:xh(e,t,n,s);break;case bh:i.strict||Mh(e,t,n,s);break;case Ch:i.strict||xh(e,t,n,s)}n+=Ea(s,4)}}(e,t,n,i),n+e.header.byteLength}(e,s,n,i={});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}function Mh(e,t,n,i){const s=new Uint8Array(t.buffer,n,i),r=new TextDecoder("utf8").decode(s);return e.json=JSON.parse(r),Ea(i,4)}function xh(e,t,n,i){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:i,arrayBuffer:t.buffer}),Ea(i,4)}async function Th(e,t){var n,i,s,r;let o=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;!function(e,t,n,i){i.uri&&(e.baseUri=i.uri);if(t instanceof ArrayBuffer&&!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new DataView(e),{magic:s=mh}=n,r=i.getUint32(t,!1);return r===s||r===mh}(t,n,i)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=ba(t);else if(t instanceof ArrayBuffer){const s={};n=Eh(s,t,n,i.glb),Ca("glTF"===s.type,"Invalid GLB magic string ".concat(s.type)),e._glb=s,e.json=s.json}else Ca(!1,"GLTF: must be ArrayBuffer or string");const s=e.json.buffers||[];if(e.buffers=new Array(s.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const r=e.json.images||[];e.images=new Array(r.length).fill({})}(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(new sh).normalize(e,t)}(e,{normalize:null==o||null===(n=o.gltf)||void 0===n?void 0:n.normalize}),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const i=$c.filter((e=>eh(e.name,t)));for(const r of i){var s;null===(s=r.preprocess)||void 0===s||s.call(r,e,t,n)}}(e,o,a);const c=[];if(null!=o&&null!==(i=o.gltf)&&void 0!==i&&i.loadBuffers&&e.json.buffers&&await async function(e,t,n){const i=e.json.buffers||[];for(let o=0;o<i.length;++o){const a=i[o];if(a.uri){var s,r;const{fetch:i}=n;Ca(i);const c=va(a.uri,t),h=await(null==n||null===(s=n.fetch)||void 0===s?void 0:s.call(n,c)),l=await(null==h||null===(r=h.arrayBuffer)||void 0===r?void 0:r.call(h));e.buffers[o]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete a.uri}else null===e.buffers[o]&&(e.buffers[o]={arrayBuffer:new ArrayBuffer(a.byteLength),byteOffset:0,byteLength:a.byteLength})}}(e,o,a),null!=o&&null!==(s=o.gltf)&&void 0!==s&&s.loadImages){const t=async function(e,t,n){const i=function(e){const t=new Set,n=e.json.textures||[];for(const e of n)void 0!==e.source&&t.add(e.source);return Array.from(t).sort()}(e),s=e.json.images||[],r=[];for(const o of i)r.push(Ih(e,s[o],o,t,n));return await Promise.all(r)}(e,o,a);c.push(t)}const h=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const i=$c.filter((e=>eh(e.name,t)));for(const r of i){var s;await(null===(s=r.decode)||void 0===s?void 0:s.call(r,e,t,n))}}(e,o,a);return c.push(h),await Promise.all(c),null!=o&&null!==(r=o.gltf)&&void 0!==r&&r.postProcess?function(e,t){return(new ph).postProcess(e,t)}(e,o):e}async function Ih(e,t,n,i,s){const{fetch:r,parse:o}=s;let a;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=va(t.uri,i),n=await r(e);a=await n.arrayBuffer(),t.bufferView={data:a}}if(Number.isFinite(t.bufferView)){const n=wa(e.json,e.buffers,t.bufferView);a=Ti(n.buffer,n.byteOffset,n.byteLength)}Ca(a,"glTF image has no data");let c=await o(a,[ya,Yo],{mimeType:t.mimeType,basis:i.basis||{format:Qo()}},s);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),e.images=e.images||[],e.images[n]=c}const Rh={name:"glTF",id:"gltf",module:"gltf",version:"3.4.4",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;t={...Rh.options,...t},t.gltf={...Rh.options.gltf,...t.gltf};const{byteOffset:i=0}=t;return await Th({},e,i,t,n)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};const Sh={URI:0,EMBEDDED:1};function Oh(e,t,n,i){e.rotateYtoZ=!0;const s=e.byteOffset+e.byteLength-n;if(0===s)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=i["3d-tiles"]&&i["3d-tiles"].assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=Ti(t,n,s),e.gltfByteOffset=0,e.gltfByteLength=s,e.byteOffset+e.byteLength}async function Dh(e,t,n,i){const s=n["3d-tiles"]||{};if(function(e,t,n){switch(t){case Sh.URI:const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),n=(new TextDecoder).decode(t);e.gltfUrl=n.replace(/[\s\0]+$/,""),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Sh.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),s.loadGLTF){const{parse:t,fetch:s}=i;e.gltfUrl&&(e.gltfArrayBuffer=await s(e.gltfUrl,n),e.gltfByteOffset=0),e.gltfArrayBuffer&&(e.gltf=await t(e.gltfArrayBuffer,Rh,n,i),e.gpuMemoryUsageInBytes=Ga(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength)}}async function Fh(e,t,n,i,s){var r;n=function(e,t,n,i,s){n=$r(e,t,n),n=to(e,t,n),n=no(e,t,n),n=Oh(e,t,n,i);const r=new Ur(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=r.getGlobalProperty("RTC_CENTER",ir.FLOAT,3),n}(e,t,n,i),await Dh(e,Sh.EMBEDDED,i,s);const o=null==e||null===(r=e.gltf)||void 0===r?void 0:r.extensions;return o&&o.CESIUM_RTC&&(e.rtcCenter=o.CESIUM_RTC.center),n}let _h;class Gh extends Ar{static get ZERO(){return _h||(_h=new Gh(0,0,0,0),Object.freeze(_h)),_h}constructor(e=0,t=0,n=0,i=0){super(-0,-0,-0,-0),cr(e)&&1===arguments.length?this.copy(e):(or.debug&&(pr(e),pr(t),pr(n),pr(i)),this[0]=e,this[1]=t,this[2]=n,this[3]=i)}set(e,t,n,i){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return or.debug&&(pr(e.x),pr(e.y),pr(e.z),pr(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=pr(e)}get w(){return this[3]}set w(e){this[3]=pr(e)}transform(e){return Mr(this,this,e),this.check()}transformByMatrix3(e){return Dr(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,n){const i=t[0],s=t[1];e[0]=n[0]*i+n[2]*s,e[1]=n[1]*i+n[3]*s,e[2]=t[2],e[3]=t[3]}(this,this,e),this.check()}transformByQuaternion(e){return Tr(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}function Lh(e){var t=e[0],n=e[1],i=e[2],s=e[3];return Math.hypot(t,n,i,s)}function Ph(e){var t=e[0],n=e[1],i=e[2],s=e[3];return t*t+n*n+i*i+s*s}!function(){var e,t=(e=new Br(4),Br!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();function kh(){var e=new Br(4);return Br!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Nh(e,t,n){n*=.5;var i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function Uh(e,t,n){var i=t[0],s=t[1],r=t[2],o=t[3],a=n[0],c=n[1],h=n[2],l=n[3];return e[0]=i*l+o*a+s*h-r*c,e[1]=s*l+o*c+r*a-i*h,e[2]=r*l+o*h+i*c-s*a,e[3]=o*l-i*a-s*c-r*h,e}function Hh(e,t,n,i){var s,r,o,a,c,h=t[0],l=t[1],u=t[2],d=t[3],f=n[0],p=n[1],m=n[2],g=n[3];return(r=h*f+l*p+u*m+d*g)<0&&(r=-r,f=-f,p=-p,m=-m,g=-g),1-r>yr?(s=Math.acos(r),o=Math.sin(s),a=Math.sin((1-i)*s)/o,c=Math.sin(i*s)/o):(a=1-i,c=i),e[0]=a*h+c*f,e[1]=a*l+c*p,e[2]=a*u+c*m,e[3]=a*d+c*g,e}function jh(e,t){var n,i=t[0]+t[4]+t[8];if(i>0)n=Math.sqrt(i+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var s=0;t[4]>t[0]&&(s=1),t[8]>t[3*s+s]&&(s=2);var r=(s+1)%3,o=(s+2)%3;n=Math.sqrt(t[3*s+s]-t[3*r+r]-t[3*o+o]+1),e[s]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+s]+t[3*s+r])*n,e[o]=(t[3*o+s]+t[3*s+o])*n}return e}var Jh,Vh,zh,Kh,Wh,Qh,Xh,Yh=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},qh=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},Zh=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},$h=function(e,t,n,i){var s=t[0],r=t[1],o=t[2],a=t[3];return e[0]=s+i*(n[0]-s),e[1]=r+i*(n[1]-r),e[2]=o+i*(n[2]-o),e[3]=a+i*(n[3]-a),e},el=Lh,tl=Ph,nl=function(e,t){var n=t[0],i=t[1],s=t[2],r=t[3],o=n*n+i*i+s*s+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=i*o,e[2]=s*o,e[3]=r*o,e},il=(Jh=br(),Vh=vr(1,0,0),zh=vr(0,1,0),function(e,t,n){var i=wr(t,n);return i<-.999999?(Er(Jh,Vh,t),Rr(Jh)<1e-6&&Er(Jh,zh,t),function(e,t){var n=t[0],i=t[1],s=t[2],r=n*n+i*i+s*s;r>0&&(r=1/Math.sqrt(r)),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r}(Jh,Jh),Nh(e,Jh,Math.PI),e):i>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Er(Jh,t,n),e[0]=Jh[0],e[1]=Jh[1],e[2]=Jh[2],e[3]=1+i,nl(e,e))});Kh=kh(),Wh=kh(),Qh=new Br(9),Br!=Float32Array&&(Qh[1]=0,Qh[2]=0,Qh[3]=0,Qh[5]=0,Qh[6]=0,Qh[7]=0),Qh[0]=1,Qh[4]=1,Qh[8]=1,Xh=Qh;const sl=[0,0,0,1];class rl extends fr{constructor(e=0,t=0,n=0,i=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,n,i)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,n,i){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return jh(this,e),this.check()}fromAxisRotation(e,t){return Nh(this,e,t),this.check()}identity(){return function(e){e[0]=0,e[1]=0,e[2]=0,e[3]=1}(this),this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=pr(e)}get y(){return this[1]}set y(e){this[1]=pr(e)}get z(){return this[2]}set z(e){this[2]=pr(e)}get w(){return this[3]}set w(e){this[3]=pr(e)}len(){return el(this)}lengthSquared(){return tl(this)}dot(e){return Zh(this,e)}rotationTo(e,t){return il(this,e,t),this.check()}add(e){return Yh(this,this,e),this.check()}calculateW(){return function(e,t){var n=t[0],i=t[1],s=t[2];e[0]=n,e[1]=i,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-i*i-s*s))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){var n=t[0],i=t[1],s=t[2],r=t[3],o=n*n+i*i+s*s+r*r,a=o?1/o:0;e[0]=-n*a,e[1]=-i*a,e[2]=-s*a,e[3]=r*a}(this,this),this.check()}lerp(e,t,n){return void 0===n?this.lerp(this,e,t):($h(this,e,t,n),this.check())}multiplyRight(e){return Uh(this,this,e),this.check()}multiplyLeft(e){return Uh(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,n){n*=.5;var i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);e[0]=i*c+o*a,e[1]=s*c+r*a,e[2]=r*c-s*a,e[3]=o*c-i*a}(this,this,e),this.check()}rotateY(e){return function(e,t,n){n*=.5;var i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);e[0]=i*c-r*a,e[1]=s*c+o*a,e[2]=r*c+i*a,e[3]=o*c-s*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,n){n*=.5;var i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);e[0]=i*c+s*a,e[1]=s*c-i*a,e[2]=r*c+o*a,e[3]=o*c-r*a}(this,this,e),this.check()}scale(e){return qh(this,this,e),this.check()}slerp(e,t,n){let i,s,r;switch(arguments.length){case 1:({start:i=sl,target:s,ratio:r}=e);break;case 2:i=this,s=e,r=t;break;default:i=e,s=t,r=n}return Hh(this,i,s,r),this.check()}transformVector4(e,t=new Gh){return function(e,t,n){var i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],c=n[2],h=n[3],l=h*i+a*r-c*s,u=h*s+c*i-o*r,d=h*r+o*s-a*i,f=-o*i-a*s-c*r;e[0]=l*h+f*-o+u*-c-d*-a,e[1]=u*h+f*-a+d*-o-l*-c,e[2]=d*h+f*-c+l*-a-u*-o,e[3]=t[3]}(t,e,this),mr(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}function ol(e,t,n){var i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],g=t[13],A=t[14],y=t[15],B=n[0],b=n[1],C=n[2],v=n[3];return e[0]=B*i+b*a+C*u+v*m,e[1]=B*s+b*c+C*d+v*g,e[2]=B*r+b*h+C*f+v*A,e[3]=B*o+b*l+C*p+v*y,B=n[4],b=n[5],C=n[6],v=n[7],e[4]=B*i+b*a+C*u+v*m,e[5]=B*s+b*c+C*d+v*g,e[6]=B*r+b*h+C*f+v*A,e[7]=B*o+b*l+C*p+v*y,B=n[8],b=n[9],C=n[10],v=n[11],e[8]=B*i+b*a+C*u+v*m,e[9]=B*s+b*c+C*d+v*g,e[10]=B*r+b*h+C*f+v*A,e[11]=B*o+b*l+C*p+v*y,B=n[12],b=n[13],C=n[14],v=n[15],e[12]=B*i+b*a+C*u+v*m,e[13]=B*s+b*c+C*d+v*g,e[14]=B*r+b*h+C*f+v*A,e[15]=B*o+b*l+C*p+v*y,e}function al(e,t){var n=t[0],i=t[1],s=t[2],r=t[4],o=t[5],a=t[6],c=t[8],h=t[9],l=t[10];return e[0]=Math.hypot(n,i,s),e[1]=Math.hypot(r,o,a),e[2]=Math.hypot(c,h,l),e}var cl=function(e,t,n,i,s){var r,o=1/Math.tan(t/2);return e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0?(r=1/(i-s),e[10]=(s+i)*r,e[14]=2*s*i*r):(e[10]=-1,e[14]=-2*i),e};var hl=function(e,t,n,i,s,r,o){var a=1/(t-n),c=1/(i-s),h=1/(r-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+n)*a,e[13]=(s+i)*c,e[14]=(o+r)*h,e[15]=1,e};var ll;!function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"}(ll||(ll={}));const ul=45*Math.PI/180,dl=1,fl=.1,pl=500,ml=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class gl extends mc{static get IDENTITY(){return function(){yl||(yl=new gl,Object.freeze(yl));return yl}()}static get ZERO(){return function(){Al||(Al=new gl([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Al));return Al}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ll}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,i,s,r,o,a,c,h,l,u,d,f,p,m){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this[4]=s,this[5]=r,this[6]=o,this[7]=a,this[8]=c,this[9]=h,this[10]=l,this[11]=u,this[12]=d,this[13]=f,this[14]=p,this[15]=m,this.check()}setRowMajor(e,t,n,i,s,r,o,a,c,h,l,u,d,f,p,m){return this[0]=e,this[1]=s,this[2]=c,this[3]=d,this[4]=t,this[5]=r,this[6]=h,this[7]=f,this[8]=n,this[9]=o,this[10]=l,this[11]=p,this[12]=i,this[13]=a,this[14]=u,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(ml)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var n=t[0],i=t[1],s=t[2],r=t[3],o=n+n,a=i+i,c=s+s,h=n*o,l=i*o,u=i*a,d=s*o,f=s*a,p=s*c,m=r*o,g=r*a,A=r*c;e[0]=1-u-p,e[1]=l+A,e[2]=d-g,e[3]=0,e[4]=l-A,e[5]=1-h-p,e[6]=f+m,e[7]=0,e[8]=d+g,e[9]=f-m,e[10]=1-h-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:n,bottom:i,top:s,near:r=fl,far:o=pl}=e;return o===1/0?function(e,t,n,i,s,r){const o=2*r/(n-t),a=2*r/(s-i),c=(n+t)/(n-t),h=(s+i)/(s-i),l=-1,u=-1,d=-2*r;e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=h,e[10]=l,e[11]=u,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,n,i,s,r):function(e,t,n,i,s,r,o){var a=1/(n-t),c=1/(s-i),h=1/(r-o);e[0]=2*r*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*r*c,e[6]=0,e[7]=0,e[8]=(n+t)*a,e[9]=(s+i)*c,e[10]=(o+r)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*r*2*h,e[15]=0}(this,t,n,i,s,r,o),this.check()}lookAt(e){const{eye:t,center:n=[0,0,0],up:i=[0,1,0]}=e;return function(e,t,n,i){var s,r,o,a,c,h,l,u,d,f,p=t[0],m=t[1],g=t[2],A=i[0],y=i[1],B=i[2],b=n[0],C=n[1],v=n[2];Math.abs(p-b)<yr&&Math.abs(m-C)<yr&&Math.abs(g-v)<yr?function(e){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):(l=p-b,u=m-C,d=g-v,s=y*(d*=f=1/Math.hypot(l,u,d))-B*(u*=f),r=B*(l*=f)-A*d,o=A*u-y*l,(f=Math.hypot(s,r,o))?(s*=f=1/f,r*=f,o*=f):(s=0,r=0,o=0),a=u*o-d*r,c=d*s-l*o,h=l*r-u*s,(f=Math.hypot(a,c,h))?(a*=f=1/f,c*=f,h*=f):(a=0,c=0,h=0),e[0]=s,e[1]=a,e[2]=l,e[3]=0,e[4]=r,e[5]=c,e[6]=u,e[7]=0,e[8]=o,e[9]=h,e[10]=d,e[11]=0,e[12]=-(s*p+r*m+o*g),e[13]=-(a*p+c*m+h*g),e[14]=-(l*p+u*m+d*g),e[15]=1)}(this,t,n,i),this.check()}ortho(e){const{left:t,right:n,bottom:i,top:s,near:r=fl,far:o=pl}=e;return hl(this,t,n,i,s,r,o),this.check()}orthographic(e){const{fovy:t=ul,aspect:n=dl,focalDistance:i=1,near:s=fl,far:r=pl}=e;Bl(t);const o=t/2,a=i*Math.tan(o),c=a*n;return this.ortho({left:-c,right:c,bottom:-a,top:a,near:s,far:r})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:n=1,near:i=.1,far:s=500}=e;return Bl(t),cl(this,t,n,i,s),this.check()}determinant(){return function(e){var t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],a=e[6],c=e[7],h=e[8],l=e[9],u=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=e[15];return(t*o-n*r)*(u*g-d*m)-(t*a-i*r)*(l*g-d*p)+(t*c-s*r)*(l*m-u*p)+(n*a-i*o)*(h*g-d*f)-(n*c-s*o)*(h*m-u*f)+(i*c-s*a)*(h*p-l*f)}(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),i=1/n[0],s=1/n[1],r=1/n[2];return e[0]=this[0]*i,e[1]=this[1]*s,e[2]=this[2]*r,e[3]=0,e[4]=this[4]*i,e[5]=this[5]*s,e[6]=this[6]*r,e[7]=0,e[8]=this[8]*i,e[9]=this[9]*s,e[10]=this[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),i=1/n[0],s=1/n[1],r=1/n[2];return e[0]=this[0]*i,e[1]=this[1]*s,e[2]=this[2]*r,e[3]=this[4]*i,e[4]=this[5]*s,e[5]=this[6]*r,e[6]=this[8]*i,e[7]=this[9]*s,e[8]=this[10]*r,e}transpose(){return function(e,t){if(e===t){var n=t[1],i=t[2],s=t[3],r=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=r,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15]}(this,this),this.check()}invert(){return function(e,t){var n=t[0],i=t[1],s=t[2],r=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],A=t[15],y=n*a-i*o,B=n*c-s*o,b=n*h-r*o,C=i*c-s*a,v=i*h-r*a,w=s*h-r*c,E=l*m-u*p,M=l*g-d*p,x=l*A-f*p,T=u*g-d*m,I=u*A-f*m,R=d*A-f*g,S=y*R-B*I+b*T+C*x-v*M+w*E;S&&(S=1/S,e[0]=(a*R-c*I+h*T)*S,e[1]=(s*I-i*R-r*T)*S,e[2]=(m*w-g*v+A*C)*S,e[3]=(d*v-u*w-f*C)*S,e[4]=(c*x-o*R-h*M)*S,e[5]=(n*R-s*x+r*M)*S,e[6]=(g*b-p*w-A*B)*S,e[7]=(l*w-d*b+f*B)*S,e[8]=(o*I-a*x+h*E)*S,e[9]=(i*x-n*I-r*E)*S,e[10]=(p*v-m*b+A*y)*S,e[11]=(u*b-l*v-f*y)*S,e[12]=(a*M-o*T-c*E)*S,e[13]=(n*T-i*M+s*E)*S,e[14]=(m*B-p*C-g*y)*S,e[15]=(l*C-u*B+d*y)*S)}(this,this),this.check()}multiplyLeft(e){return ol(this,e,this),this.check()}multiplyRight(e){return ol(this,this,e),this.check()}rotateX(e){return function(e,t,n){var i=Math.sin(n),s=Math.cos(n),r=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=t[9],u=t[10],d=t[11];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]=r*s+h*i,e[5]=o*s+l*i,e[6]=a*s+u*i,e[7]=c*s+d*i,e[8]=h*s-r*i,e[9]=l*s-o*i,e[10]=u*s-a*i,e[11]=d*s-c*i}(this,this,e),this.check()}rotateY(e){return function(e,t,n){var i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],c=t[3],h=t[8],l=t[9],u=t[10],d=t[11];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]=r*s-h*i,e[1]=o*s-l*i,e[2]=a*s-u*i,e[3]=c*s-d*i,e[8]=r*i+h*s,e[9]=o*i+l*s,e[10]=a*i+u*s,e[11]=c*i+d*s}(this,this,e),this.check()}rotateZ(e){return function(e,t,n){var i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],c=t[3],h=t[4],l=t[5],u=t[6],d=t[7];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]=r*s+h*i,e[1]=o*s+l*i,e[2]=a*s+u*i,e[3]=c*s+d*i,e[4]=h*s-r*i,e[5]=l*s-o*i,e[6]=u*s-a*i,e[7]=d*s-c*i}(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,n,i){var s,r,o,a,c,h,l,u,d,f,p,m,g,A,y,B,b,C,v,w,E,M,x,T,I=i[0],R=i[1],S=i[2],O=Math.hypot(I,R,S);O<yr||(I*=O=1/O,R*=O,S*=O,s=Math.sin(n),o=1-(r=Math.cos(n)),a=t[0],c=t[1],h=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],g=t[9],A=t[10],y=t[11],B=I*I*o+r,b=R*I*o+S*s,C=S*I*o-R*s,v=I*R*o-S*s,w=R*R*o+r,E=S*R*o+I*s,M=I*S*o+R*s,x=R*S*o-I*s,T=S*S*o+r,e[0]=a*B+u*b+m*C,e[1]=c*B+d*b+g*C,e[2]=h*B+f*b+A*C,e[3]=l*B+p*b+y*C,e[4]=a*v+u*w+m*E,e[5]=c*v+d*w+g*E,e[6]=h*v+f*w+A*E,e[7]=l*v+p*w+y*E,e[8]=a*M+u*x+m*T,e[9]=c*M+d*x+g*T,e[10]=h*M+f*x+A*T,e[11]=l*M+p*x+y*T,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){return function(e,t,n){var i=n[0],s=n[1],r=n[2];e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return function(e,t,n){var i,s,r,o,a,c,h,l,u,d,f,p,m=n[0],g=n[1],A=n[2];t===e?(e[12]=t[0]*m+t[4]*g+t[8]*A+t[12],e[13]=t[1]*m+t[5]*g+t[9]*A+t[13],e[14]=t[2]*m+t[6]*g+t[10]*A+t[14],e[15]=t[3]*m+t[7]*g+t[11]*A+t[15]):(i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],e[0]=i,e[1]=s,e[2]=r,e[3]=o,e[4]=a,e[5]=c,e[6]=h,e[7]=l,e[8]=u,e[9]=d,e[10]=f,e[11]=p,e[12]=i*m+a*g+u*A+t[12],e[13]=s*m+c*g+d*A+t[13],e[14]=r*m+h*g+f*A+t[14],e[15]=o*m+l*g+p*A+t[15])}(this,this,e),this.check()}transform(e,t){return 4===e.length?(t=function(e,t,n){var i=t[0],s=t[1],r=t[2],o=t[3];return e[0]=n[0]*i+n[4]*s+n[8]*r+n[12]*o,e[1]=n[1]*i+n[5]*s+n[9]*r+n[13]*o,e[2]=n[2]*i+n[6]*s+n[10]*r+n[14]*o,e[3]=n[3]*i+n[7]*s+n[11]*r+n[15]*o,e}(t||[-0,-0,-0,-0],e,this),mr(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:n}=e;let i;switch(n){case 2:i=oo(t||[-0,-0],e,this);break;case 3:i=Mr(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return mr(i,e.length),i}transformAsVector(e,t){let n;switch(e.length){case 2:n=Sr(t||[-0,-0],e,this);break;case 3:n=Or(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return mr(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}}let Al,yl;function Bl(e){if(e>2*Math.PI)throw Error("expected radians")}const bl={EPSILON1:.1,EPSILON2:.01,EPSILON3:.001,EPSILON4:1e-4,EPSILON5:1e-5,EPSILON6:1e-6,EPSILON7:1e-7,EPSILON8:1e-8,EPSILON9:1e-9,EPSILON10:1e-10,EPSILON11:1e-11,EPSILON12:1e-12,EPSILON13:1e-13,EPSILON14:1e-14,EPSILON15:1e-15,EPSILON16:1e-16,EPSILON17:1e-17,EPSILON18:1e-18,EPSILON19:1e-19,EPSILON20:1e-20,PI_OVER_TWO:Math.PI/2,PI_OVER_FOUR:Math.PI/4,PI_OVER_SIX:Math.PI/6,TWO_PI:2*Math.PI},Cl=6378137,vl=6378137,wl=6356752.314245179;Math.max(Cl,vl,wl);function El(e){return e}new Gr;function Ml(e,t=[],n=El){return"longitude"in e?(t[0]=n(e.longitude),t[1]=n(e.latitude),t[2]=e.height):"x"in e?(t[0]=n(e.x),t[1]=n(e.y),t[2]=e.z):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}function xl(e,t,n=El){return"longitude"in t?(t.longitude=n(e[0]),t.latitude=n(e[1]),t.height=e[2]):"x"in t?(t.x=n(e[0]),t.y=n(e[1]),t.z=e[2]):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}const Tl=new Gr,Il=new Gr,Rl=new Gr;const Sl=new Gr,Ol={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Dl={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Fl={east:new Gr,north:new Gr,up:new Gr,west:new Gr,south:new Gr,down:new Gr},_l=new Gr,Gl=new Gr,Ll=new Gr;function Pl(e,t,n,i,s,r){const o=Ol[t]&&Ol[t][n];let a,c,h;gr(o&&(!i||i===o));const l=Sl.copy(s);if(ur(l.x,0,1e-14)&&ur(l.y,0,1e-14)){const e=Math.sign(l.z);a=_l.fromArray(Dl[t]),"east"!==t&&"west"!==t&&a.scale(e),c=Gl.fromArray(Dl[n]),"east"!==n&&"west"!==n&&c.scale(e),h=Ll.fromArray(Dl[i]),"east"!==i&&"west"!==i&&h.scale(e)}else{const{up:s,east:r,north:o}=Fl;r.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,s),o.copy(s).cross(r);const{down:u,west:d,south:f}=Fl;u.copy(s).scale(-1),d.copy(r).scale(-1),f.copy(o).scale(-1),a=Fl[t],c=Fl[n],h=Fl[i]}return r[0]=a.x,r[1]=a.y,r[2]=a.z,r[3]=0,r[4]=c.x,r[5]=c.y,r[6]=c.z,r[7]=0,r[8]=h.x,r[9]=h.y,r[10]=h.z,r[11]=0,r[12]=l.x,r[13]=l.y,r[14]=l.z,r[15]=1,r}const kl=new Gr,Nl=new Gr,Ul=new Gr,Hl=new Gr,jl=new Gr,Jl=new Gr;class Vl{constructor(e=0,t=0,n=0){En(this,"radii",void 0),En(this,"radiiSquared",void 0),En(this,"radiiToTheFourth",void 0),En(this,"oneOverRadii",void 0),En(this,"oneOverRadiiSquared",void 0),En(this,"minimumRadius",void 0),En(this,"maximumRadius",void 0),En(this,"centerToleranceSquared",bl.EPSILON1),En(this,"squaredXOverSquaredZ",void 0),gr(e>=0),gr(t>=0),gr(n>=0),this.radii=new Gr(e,t,n),this.radiiSquared=new Gr(e*e,t*t,n*n),this.radiiToTheFourth=new Gr(e*e*e*e,t*t*t*t,n*n*n*n),this.oneOverRadii=new Gr(0===e?0:1/e,0===t?0:1/t,0===n?0:1/n),this.oneOverRadiiSquared=new Gr(0===e?0:1/(e*e),0===t?0:1/(t*t),0===n?0:1/(n*n)),this.minimumRadius=Math.min(e,t,n),this.maximumRadius=Math.max(e,t,n),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const n=Nl,i=Ul,[,,s]=e;this.geodeticSurfaceNormalCartographic(e,n),i.copy(this.radiiSquared).scale(n);const r=Math.sqrt(n.dot(i));return i.scale(1/r),n.scale(s),i.add(n),i.to(t)}cartesianToCartographic(e,t=[0,0,0]){Jl.from(e);const n=this.scaleToGeodeticSurface(Jl,Hl);if(!n)return;const i=this.geodeticSurfaceNormal(n,Nl),s=jl;s.copy(Jl).subtract(n);const r=Math.atan2(i.y,i.x),o=Math.asin(i.z),a=Math.sign(wr(s,Jl))*Cr(s);return xl([r,o,a],t,or._cartographicRadians?El:lr)}eastNorthUpToFixedFrame(e,t=new gl){return Pl(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,n,i,s=new gl){return Pl(this,e,t,n,i,s)}geocentricSurfaceNormal(e,t=[0,0,0]){return kl.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const n=function(e,t=[]){return Ml(e,t,or._cartographicRadians?El:hr)}(e),i=n[0],s=n[1],r=Math.cos(s);return kl.set(r*Math.cos(i),r*Math.sin(i),Math.sin(s)).normalize(),kl.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return kl.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,n=[]){const{oneOverRadii:i,oneOverRadiiSquared:s,centerToleranceSquared:r}=t;Tl.from(e);const o=Tl.x,a=Tl.y,c=Tl.z,h=i.x,l=i.y,u=i.z,d=o*o*h*h,f=a*a*l*l,p=c*c*u*u,m=d+f+p,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;const A=Il;if(A.copy(e).scale(g),m<r)return A.to(n);const y=s.x,B=s.y,b=s.z,C=Rl;C.set(A.x*y*2,A.y*B*2,A.z*b*2);let v,w,E,M,x=(1-g)*Tl.len()/(.5*C.len()),T=0;do{x-=T,v=1/(1+x*y),w=1/(1+x*B),E=1/(1+x*b);const e=v*v,t=w*w,n=E*E;M=d*e+f*t+p*n-1,T=M/(-2*(d*(e*v)*y+f*(t*w)*B+p*(n*E)*b))}while(Math.abs(M)>bl.EPSILON12);return Tl.scale([v,w,E]).to(n)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){Hl.from(e);const n=Hl.x,i=Hl.y,s=Hl.z,r=this.oneOverRadiiSquared,o=1/Math.sqrt(n*n*r.x+i*i*r.y+s*s*r.z);return Hl.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return Hl.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return Hl.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,n=[0,0,0]){gr(ur(this.radii.x,this.radii.y,bl.EPSILON15)),gr(this.radii.z>0),Hl.from(e);const i=Hl.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-t))return Hl.set(0,0,i).to(n)}}async function zl(e,t,n,i,s){return n=function(e,t,n,i,s){if(n=$r(e,t,n),1!==e.version)throw new Error("Instanced 3D Model version ".concat(e.version," is not supported"));n=to(e,t,n);const r=new DataView(t);if(e.gltfFormat=r.getUint32(n,!0),n+=4,n=no(e,t,n),n=Oh(e,t,n,i),0===e.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new Ur(e.featureTableJson,e.featureTableBinary),a=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",ir.FLOAT,3);new qr(e.batchTableJson,e.batchTableBinary,a);return function(e,t,n,i){const s={instances:new Array(i),batchTable:e._batchTable,cull:!1,url:void 0,gltf:void 0,basePath:void 0,incrementallyLoadTextures:!1,forwardAxis:[1,0,0]},r=s.instances,o=new Gr,a=new Gr,c=new Gr,h=new Gr,l=new bc,u=new rl,d=new Gr,f={},p=new gl,m=[],g=[],A=new Gr,y=new Gr;for(let n=0;n<i;n++){let i;if(t.hasProperty("POSITION"))i=t.getProperty("POSITION",ir.FLOAT,3,n,o);else if(t.hasProperty("POSITION_QUANTIZED")){i=t.getProperty("POSITION_QUANTIZED",ir.UNSIGNED_SHORT,3,n,o);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ir.FLOAT,3,A);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const s=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ir.FLOAT,3,y);if(!s)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const r=65535;for(let t=0;t<3;t++)i[t]=i[t]/r*s[t]+e[t]}if(!i)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");o.copy(i),f.translation=o,e.normalUp=t.getProperty("NORMAL_UP",ir.FLOAT,3,n,m),e.normalRight=t.getProperty("NORMAL_RIGHT",ir.FLOAT,3,n,g);const s=!1;if(e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",ir.UNSIGNED_SHORT,2,m),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",ir.UNSIGNED_SHORT,2,g),e.octNormalUp){if(!e.octNormalRight)throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");throw new Error("i3dm: oct-encoded orientation not implemented")}e.eastNorthUp?(Vl.WGS84.eastNorthUpToFixedFrame(o,p),p.getRotationMatrix3(l)):l.identity()}s&&(h.copy(a).cross(c).normalize(),l.setColumn(0,a),l.setColumn(1,c),l.setColumn(2,h)),u.fromMatrix3(l),f.rotation=u,d.set(1,1,1);const B=t.getProperty("SCALE",ir.FLOAT,1,n);Number.isFinite(B)&&d.multiplyByScalar(B);const b=t.getProperty("SCALE_NON_UNIFORM",ir.FLOAT,3,n,m);b&&d.scale(b),f.scale=d;let C=t.getProperty("BATCH_ID",ir.UNSIGNED_SHORT,1,n);void 0===C&&(C=n);const v=(new gl).fromQuaternion(f.rotation);p.identity(),p.translate(f.translation),p.multiplyRight(v),p.scale(f.scale);const w=p.clone();r[n]={modelMatrix:w,batchId:C}}e.instances=r}(e,o,0,a),n}(e,t,n,i),await Dh(e,e.gltfFormat,i,s),n}async function Kl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};switch(s.byteOffset=t,s.type=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=new DataView(e);return"".concat(String.fromCharCode(n.getUint8(t+0))).concat(String.fromCharCode(n.getUint8(t+1))).concat(String.fromCharCode(n.getUint8(t+2))).concat(String.fromCharCode(n.getUint8(t+3)))}(e,t),s.type){case ss.COMPOSITE:return await async function(e,t,n,i,s,r){n=$r(e,t,n);const o=new DataView(t);for(e.tilesLength=o.getUint32(n,!0),n+=4,e.tiles=[];e.tiles.length<e.tilesLength&&e.byteLength-n>12;){const o={};e.tiles.push(o),n=await r(t,n,i,s,o)}return n}(s,e,t,n,i,Kl);case ss.BATCHED_3D_MODEL:return await Fh(s,e,t,n,i);case ss.GLTF:return await async function(e,t,n,i){e.rotateYtoZ=!0,e.gltfUpAxis=n["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y";const{parse:s}=i;e.gltf=await s(t,Rh,n,i),e.gpuMemoryUsageInBytes=Ga(e.gltf)}(s,e,n,i);case ss.INSTANCED_3D_MODEL:return await zl(s,e,t,n,i);case ss.POINT_CLOUD:return await mo(s,e,t,n,i);default:throw new Error("3DTileLoader: unknown type ".concat(s.type))}}En(Vl,"WGS84",new Vl(Cl,vl,wl));async function Wl(e,t,n,i){const s=e[t].bufferView,r=e.bufferViews[s],o=e.buffers[r.buffer];if(null==i||!i.url||!i.fetch)throw new Error("Url is not provided");if(!i.fetch)throw new Error("fetch is not provided");if(o.uri){const e=function(e,t){if(t.startsWith("http")){const n=new URL(e,t);return decodeURI(n.toString())}const n="http://".concat(t),i=new URL(e,n);return"/".concat(i.host).concat(i.pathname)}(o.uri,null==i?void 0:i.url),t=await i.fetch(e),n=await t.arrayBuffer();return new Uint8Array(n,r.byteOffset,r.byteLength)}return new Uint8Array(n,r.byteOffset,r.byteLength)}function Ql(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const Xl={id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:is,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,n){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const i=Ql(e.slice(8,16)),s=new Uint8Array(e,24,i),r=new TextDecoder("utf8").decode(s),o=JSON.parse(r),a=Ql(e.slice(16,24));let c=new ArrayBuffer(0);return a&&(c=e.slice(24+i)),"bufferView"in o.tileAvailability&&(o.tileAvailability.explicitBitstream=await Wl(o,"tileAvailability",c,n)),"bufferView"in o.contentAvailability&&(o.contentAvailability.explicitBitstream=await Wl(o,"contentAvailability",c,n)),"bufferView"in o.childSubtreeAvailability&&(o.childSubtreeAvailability.explicitBitstream=await Wl(o,"childSubtreeAvailability",c,n)),o},options:{}};var Yl=null;try{Yl=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function ql(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Zl(e){return!0===(e&&e.__isLong__)}function $l(e){var t=Math.clz32(e&-e);return e?31-t:t}ql.prototype.__isLong__,Object.defineProperty(ql.prototype,"__isLong__",{value:!0}),ql.isLong=Zl;var eu={},tu={};function nu(e,t){var n,i,s;return t?(s=0<=(e>>>=0)&&e<256)&&(i=tu[e])?i:(n=su(e,0,!0),s&&(tu[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(i=eu[e])?i:(n=su(e,e<0?-1:0,!1),s&&(eu[e]=n),n)}function iu(e,t){if(isNaN(e))return t?fu:du;if(t){if(e<0)return fu;if(e>=hu)return yu}else{if(e<=-lu)return Bu;if(e+1>=lu)return Au}return e<0?iu(-e,t).neg():su(e%cu|0,e/cu|0,t)}function su(e,t,n){return new ql(e,t,n)}ql.fromInt=nu,ql.fromNumber=iu,ql.fromBits=su;var ru=Math.pow;function ou(e,t,n){if(0===e.length)throw Error("empty string");if("number"==typeof t?(n=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?fu:du;if((n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return ou(e.substring(1),t,n).neg();for(var s=iu(ru(n,8)),r=du,o=0;o<e.length;o+=8){var a=Math.min(8,e.length-o),c=parseInt(e.substring(o,o+a),n);if(a<8){var h=iu(ru(n,a));r=r.mul(h).add(iu(c))}else r=(r=r.mul(s)).add(iu(c))}return r.unsigned=t,r}function au(e,t){return"number"==typeof e?iu(e,t):"string"==typeof e?ou(e,t):su(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}ql.fromString=ou,ql.fromValue=au;var cu=4294967296,hu=cu*cu,lu=hu/2,uu=nu(1<<24),du=nu(0);ql.ZERO=du;var fu=nu(0,!0);ql.UZERO=fu;var pu=nu(1);ql.ONE=pu;var mu=nu(1,!0);ql.UONE=mu;var gu=nu(-1);ql.NEG_ONE=gu;var Au=su(-1,2147483647,!1);ql.MAX_VALUE=Au;var yu=su(-1,-1,!0);ql.MAX_UNSIGNED_VALUE=yu;var Bu=su(0,-2147483648,!1);ql.MIN_VALUE=Bu;var bu=ql.prototype;bu.toInt=function(){return this.unsigned?this.low>>>0:this.low},bu.toNumber=function(){return this.unsigned?(this.high>>>0)*cu+(this.low>>>0):this.high*cu+(this.low>>>0)},bu.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(Bu)){var t=iu(e),n=this.div(t),i=n.mul(t).sub(this);return n.toString(e)+i.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var s=iu(ru(e,6),this.unsigned),r=this,o="";;){var a=r.div(s),c=(r.sub(a.mul(s)).toInt()>>>0).toString(e);if((r=a).isZero())return c+o;for(;c.length<6;)c="0"+c;o=""+c+o}},bu.getHighBits=function(){return this.high},bu.getHighBitsUnsigned=function(){return this.high>>>0},bu.getLowBits=function(){return this.low},bu.getLowBitsUnsigned=function(){return this.low>>>0},bu.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Bu)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},bu.isZero=function(){return 0===this.high&&0===this.low},bu.eqz=bu.isZero,bu.isNegative=function(){return!this.unsigned&&this.high<0},bu.isPositive=function(){return this.unsigned||this.high>=0},bu.isOdd=function(){return 1==(1&this.low)},bu.isEven=function(){return 0==(1&this.low)},bu.equals=function(e){return Zl(e)||(e=au(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},bu.eq=bu.equals,bu.notEquals=function(e){return!this.eq(e)},bu.neq=bu.notEquals,bu.ne=bu.notEquals,bu.lessThan=function(e){return this.comp(e)<0},bu.lt=bu.lessThan,bu.lessThanOrEqual=function(e){return this.comp(e)<=0},bu.lte=bu.lessThanOrEqual,bu.le=bu.lessThanOrEqual,bu.greaterThan=function(e){return this.comp(e)>0},bu.gt=bu.greaterThan,bu.greaterThanOrEqual=function(e){return this.comp(e)>=0},bu.gte=bu.greaterThanOrEqual,bu.ge=bu.greaterThanOrEqual,bu.compare=function(e){if(Zl(e)||(e=au(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},bu.comp=bu.compare,bu.negate=function(){return!this.unsigned&&this.eq(Bu)?Bu:this.not().add(pu)},bu.neg=bu.negate,bu.add=function(e){Zl(e)||(e=au(e));var t=this.high>>>16,n=65535&this.high,i=this.low>>>16,s=65535&this.low,r=e.high>>>16,o=65535&e.high,a=e.low>>>16,c=0,h=0,l=0,u=0;return l+=(u+=s+(65535&e.low))>>>16,h+=(l+=i+a)>>>16,c+=(h+=n+o)>>>16,c+=t+r,su((l&=65535)<<16|(u&=65535),(c&=65535)<<16|(h&=65535),this.unsigned)},bu.subtract=function(e){return Zl(e)||(e=au(e)),this.add(e.neg())},bu.sub=bu.subtract,bu.multiply=function(e){if(this.isZero())return this;if(Zl(e)||(e=au(e)),Yl)return su(Yl.mul(this.low,this.high,e.low,e.high),Yl.get_high(),this.unsigned);if(e.isZero())return this.unsigned?fu:du;if(this.eq(Bu))return e.isOdd()?Bu:du;if(e.eq(Bu))return this.isOdd()?Bu:du;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(uu)&&e.lt(uu))return iu(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,i=this.low>>>16,s=65535&this.low,r=e.high>>>16,o=65535&e.high,a=e.low>>>16,c=65535&e.low,h=0,l=0,u=0,d=0;return u+=(d+=s*c)>>>16,l+=(u+=i*c)>>>16,u&=65535,l+=(u+=s*a)>>>16,h+=(l+=n*c)>>>16,l&=65535,h+=(l+=i*a)>>>16,l&=65535,h+=(l+=s*o)>>>16,h+=t*c+n*a+i*o+s*r,su((u&=65535)<<16|(d&=65535),(h&=65535)<<16|(l&=65535),this.unsigned)},bu.mul=bu.multiply,bu.divide=function(e){if(Zl(e)||(e=au(e)),e.isZero())throw Error("division by zero");var t,n,i;if(Yl)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?su((this.unsigned?Yl.div_u:Yl.div_s)(this.low,this.high,e.low,e.high),Yl.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?fu:du;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return fu;if(e.gt(this.shru(1)))return mu;i=fu}else{if(this.eq(Bu))return e.eq(pu)||e.eq(gu)?Bu:e.eq(Bu)?pu:(t=this.shr(1).div(e).shl(1)).eq(du)?e.isNegative()?pu:gu:(n=this.sub(e.mul(t)),i=t.add(n.div(e)));if(e.eq(Bu))return this.unsigned?fu:du;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=du}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),r=s<=48?1:ru(2,s-48),o=iu(t),a=o.mul(e);a.isNegative()||a.gt(n);)a=(o=iu(t-=r,this.unsigned)).mul(e);o.isZero()&&(o=pu),i=i.add(o),n=n.sub(a)}return i},bu.div=bu.divide,bu.modulo=function(e){return Zl(e)||(e=au(e)),Yl?su((this.unsigned?Yl.rem_u:Yl.rem_s)(this.low,this.high,e.low,e.high),Yl.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},bu.mod=bu.modulo,bu.rem=bu.modulo,bu.not=function(){return su(~this.low,~this.high,this.unsigned)},bu.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},bu.clz=bu.countLeadingZeros,bu.countTrailingZeros=function(){return this.low?$l(this.low):$l(this.high)+32},bu.ctz=bu.countTrailingZeros,bu.and=function(e){return Zl(e)||(e=au(e)),su(this.low&e.low,this.high&e.high,this.unsigned)},bu.or=function(e){return Zl(e)||(e=au(e)),su(this.low|e.low,this.high|e.high,this.unsigned)},bu.xor=function(e){return Zl(e)||(e=au(e)),su(this.low^e.low,this.high^e.high,this.unsigned)},bu.shiftLeft=function(e){return Zl(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?su(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):su(0,this.low<<e-32,this.unsigned)},bu.shl=bu.shiftLeft,bu.shiftRight=function(e){return Zl(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?su(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):su(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},bu.shr=bu.shiftRight,bu.shiftRightUnsigned=function(e){return Zl(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?su(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):su(32===e?this.high:this.high>>>e-32,0,this.unsigned)},bu.shru=bu.shiftRightUnsigned,bu.shr_u=bu.shiftRightUnsigned,bu.rotateLeft=function(e){var t;return Zl(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?su(this.high,this.low,this.unsigned):e<32?(t=32-e,su(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),su(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},bu.rotl=bu.rotateLeft,bu.rotateRight=function(e){var t;return Zl(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?su(this.high,this.low,this.unsigned):e<32?(t=32-e,su(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),su(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},bu.rotr=bu.rotateRight,bu.toSigned=function(){return this.unsigned?su(this.low,this.high,!1):this},bu.toUnsigned=function(){return this.unsigned?this:su(this.low,this.high,!0)},bu.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},bu.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},bu.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},ql.fromBytes=function(e,t,n){return n?ql.fromBytesLE(e,t):ql.fromBytesBE(e,t)},ql.fromBytesLE=function(e,t){return new ql(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},ql.fromBytesBE=function(e,t){return new ql(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};const Cu=ql,vu=16;function wu(e){"X"===e&&(e="");const t=e.padEnd(vu,"0");return Cu.fromString(t,!0,16)}const Eu=-1,Mu=0,xu=1;new Gr,new Gr;const Tu=new Gr,Iu=new Gr;class Ru{constructor(e=[0,0,0],t=0){En(this,"center",void 0),En(this,"radius",void 0),this.radius=-0,this.center=new Gr,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=Tu.from(t),this.center=(new Gr).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new Ru(this.center,this.radius)}union(e){const t=this.center,n=this.radius,i=e.center,s=e.radius,r=Tu.copy(i).subtract(t),o=r.magnitude();if(n>=o+s)return this.clone();if(s>=o+n)return e.clone();const a=.5*(n+o+s);return Iu.copy(r).scale((-n+a)/o).add(t),this.center.copy(Iu),this.radius=a,this}expand(e){const t=Tu.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=al(Tu,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=Tu.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,n=this.radius,i=e.normal.dot(t)+e.distance;return i<-n?Eu:i<n?Mu:xu}}const Su=new Gr,Ou=new Gr,Du=new Gr,Fu=new Gr,_u=new Gr,Gu=new Gr,Lu=new Gr,Pu=0,ku=1,Nu=2,Uu=3,Hu=4,ju=5,Ju=6,Vu=7,zu=8;class Ku{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){En(this,"center",void 0),En(this,"halfAxes",void 0),this.center=(new Gr).from(e),this.halfAxes=new bc(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new Gr(e).len(),new Gr(t).len(),new Gr(n).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),i=new Gr(e).normalize(),s=new Gr(t).normalize(),r=new Gr(n).normalize();return(new rl).fromMatrix3(new bc([...i,...s,...r]))}fromCenterHalfSizeQuaternion(e,t,n){const i=new rl(n),s=(new bc).fromQuaternion(i);return s[0]=s[0]*t[0],s[1]=s[1]*t[0],s[2]=s[2]*t[0],s[3]=s[3]*t[1],s[4]=s[4]*t[1],s[5]=s[5]*t[1],s[6]=s[6]*t[2],s[7]=s[7]*t[2],s[8]=s[8]*t[2],this.center=(new Gr).from(e),this.halfAxes=s,this}clone(){return new Ku(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new Ru){const t=this.halfAxes,n=t.getColumn(0,Du),i=t.getColumn(1,Fu),s=t.getColumn(2,_u),r=Su.copy(n).add(i).add(s);return e.center.copy(this.center),e.radius=r.magnitude(),e}intersectPlane(e){const t=this.center,n=e.normal,i=this.halfAxes,s=n.x,r=n.y,o=n.z,a=Math.abs(s*i[Pu]+r*i[ku]+o*i[Nu])+Math.abs(s*i[Uu]+r*i[Hu]+o*i[ju])+Math.abs(s*i[Ju]+r*i[Vu]+o*i[zu]),c=n.dot(t)+e.distance;return c<=-a?Eu:c>=a?xu:Mu}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=Ou.from(e).subtract(this.center),n=this.halfAxes,i=n.getColumn(0,Du),s=n.getColumn(1,Fu),r=n.getColumn(2,_u),o=i.magnitude(),a=s.magnitude(),c=r.magnitude();i.normalize(),s.normalize(),r.normalize();let h,l=0;return h=Math.abs(t.dot(i))-o,h>0&&(l+=h*h),h=Math.abs(t.dot(s))-a,h>0&&(l+=h*h),h=Math.abs(t.dot(r))-c,h>0&&(l+=h*h),l}computePlaneDistances(e,t,n=[-0,-0]){let i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const r=this.center,o=this.halfAxes,a=o.getColumn(0,Du),c=o.getColumn(1,Fu),h=o.getColumn(2,_u),l=Gu.copy(a).add(c).add(h).add(r),u=Lu.copy(l).subtract(e);let d=t.dot(u);return i=Math.min(d,i),s=Math.max(d,s),l.copy(r).add(a).add(c).subtract(h),u.copy(l).subtract(e),d=t.dot(u),i=Math.min(d,i),s=Math.max(d,s),l.copy(r).add(a).subtract(c).add(h),u.copy(l).subtract(e),d=t.dot(u),i=Math.min(d,i),s=Math.max(d,s),l.copy(r).add(a).subtract(c).subtract(h),u.copy(l).subtract(e),d=t.dot(u),i=Math.min(d,i),s=Math.max(d,s),r.copy(l).subtract(a).add(c).add(h),u.copy(l).subtract(e),d=t.dot(u),i=Math.min(d,i),s=Math.max(d,s),r.copy(l).subtract(a).add(c).subtract(h),u.copy(l).subtract(e),d=t.dot(u),i=Math.min(d,i),s=Math.max(d,s),r.copy(l).subtract(a).subtract(c).add(h),u.copy(l).subtract(e),d=t.dot(u),i=Math.min(d,i),s=Math.max(d,s),r.copy(l).subtract(a).subtract(c).subtract(h),u.copy(l).subtract(e),d=t.dot(u),i=Math.min(d,i),s=Math.max(d,s),n[0]=i,n[1]=s,n}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,Du);t.transformAsPoint(e);const n=this.halfAxes.getColumn(1,Fu);n.transformAsPoint(e);const i=this.halfAxes.getColumn(2,_u);return i.transformAsPoint(e),this.halfAxes=new bc([...t,...n,...i]),this}getTransform(){throw new Error("not implemented")}}const Wu=new Gr,Qu=new Gr;class Xu{constructor(e=[0,0,1],t=0){En(this,"normal",void 0),En(this,"distance",void 0),this.normal=new Gr,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return gr(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Wu.from(e),this.normal.from(t).normalize();const n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,t,n,i){return this.normal.set(e,t,n),gr(ur(this.normal.len(),1)),this.distance=i,this}clone(){return new Xu(this.normal,this.distance)}equals(e){return ur(this.distance,e.distance)&&ur(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=Qu.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,t)}projectPointOntoPlane(e,t=[0,0,0]){e=Wu.from(e);const n=this.getPointDistance(e),i=Qu.copy(this.normal).scale(n);return e.subtract(i).to(t)}}const Yu=[new Gr([1,0,0]),new Gr([0,1,0]),new Gr([0,0,1])],qu=new Gr,Zu=new Gr;new Xu(new Gr(1,0,0),0);class $u{constructor(e=[]){En(this,"planes",void 0),this.planes=e}fromBoundingSphere(e){this.planes.length=2*Yu.length;const t=e.center,n=e.radius;let i=0;for(const e of Yu){let s=this.planes[i],r=this.planes[i+1];s||(s=this.planes[i]=new Xu),r||(r=this.planes[i+1]=new Xu);const o=qu.copy(e).scale(-n).add(t);e.dot(o);s.fromPointNormal(o,e);const a=qu.copy(e).scale(n).add(t),c=Zu.copy(e).negate();c.dot(a);r.fromPointNormal(a,c),i+=2}return this}computeVisibility(e){let t=xu;for(const n of this.planes){switch(e.intersectPlane(n)){case Eu:return Eu;case Mu:t=Mu}}return t}computeVisibilityWithPlaneMask(e,t){if(gr(Number.isFinite(t),"parentPlaneMask is required."),t===$u.MASK_OUTSIDE||t===$u.MASK_INSIDE)return t;let n=$u.MASK_INSIDE;const i=this.planes;for(let s=0;s<this.planes.length;++s){const r=s<31?1<<s:0;if(s<31&&0==(t&r))continue;const o=i[s],a=e.intersectPlane(o);if(a===Eu)return $u.MASK_OUTSIDE;a===Mu&&(n|=r)}return n}}En($u,"MASK_OUTSIDE",4294967295),En($u,"MASK_INSIDE",0),En($u,"MASK_INDETERMINATE",2147483647);new Gr,new Gr,new Gr,new Gr,new Gr;new Gr,new Gr,new Gr,new Gr,new Gr,new Gr,new Gr,new Gr,new Gr,new Gr,new Gr,new Gr,Math.PI;const ed=new bc,td=new bc,nd=new bc,id=new bc,sd=new bc;function rd(e,t={}){const n=bl.EPSILON20;let i=0,s=0;const r=td,o=nd;r.identity(),o.copy(e);const a=n*function(e){let t=0;for(let n=0;n<9;++n){const i=e[n];t+=i*i}return Math.sqrt(t)}(o);for(;s<10&&cd(o)>a;)hd(o,id),sd.copy(id).transpose(),o.multiplyRight(id),o.multiplyLeft(sd),r.multiplyRight(id),++i>2&&(++s,i=0);return t.unitary=r.toTarget(t.unitary),t.diagonal=o.toTarget(t.diagonal),t}const od=[1,0,0],ad=[2,2,1];function cd(e){let t=0;for(let n=0;n<3;++n){const i=e[ed.getElementIndex(ad[n],od[n])];t+=2*i*i}return Math.sqrt(t)}function hd(e,t){const n=bl.EPSILON15;let i=0,s=1;for(let t=0;t<3;++t){const n=Math.abs(e[ed.getElementIndex(ad[t],od[t])]);n>i&&(s=t,i=n)}const r=od[s],o=ad[s];let a=1,c=0;if(Math.abs(e[ed.getElementIndex(o,r)])>n){const t=(e[ed.getElementIndex(o,o)]-e[ed.getElementIndex(r,r)])/2/e[ed.getElementIndex(o,r)];let n;n=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),a=1/Math.sqrt(1+n*n),c=n*a}return bc.IDENTITY.to(t),t[ed.getElementIndex(r,r)]=t[ed.getElementIndex(o,o)]=a,t[ed.getElementIndex(o,r)]=c,t[ed.getElementIndex(r,o)]=-c,t}const ld=new Gr,ud=new Gr,dd=new Gr,fd=new Gr,pd=new Gr,md=new bc,gd={diagonal:new bc,unitary:new bc};const Ad=3,yd=61,Bd=180/Math.PI;function bd(e,t,n){const i=1<<t;return[(e[0]+n[0])/i,(e[1]+n[1])/i]}function Cd(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function vd(e){return[Cd(e[0]),Cd(e[1])]}function wd(e,t){let[n,i]=t;switch(e){case 0:return[1,n,i];case 1:return[-n,1,i];case 2:return[-n,-i,1];case 3:return[-1,-i,-n];case 4:return[i,-1,-n];case 5:return[i,n,-1];default:throw new Error("Invalid face")}}function Ed(e){let[t,n,i]=e;const s=Math.atan2(i,Math.sqrt(t*t+n*n));return[Math.atan2(n,t)*Bd,s*Bd]}function Md(e,t,n,i){if(0===i){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const i=t[0];t[0]=t[1],t[1]=i}}function xd(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=wu(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<Ad+yd;)t="0"+t;const n=t.lastIndexOf("1"),i=t.substring(0,3),s=t.substring(3,n),r=s.length/2,o=Cu.fromString(i,!0,2).toString(10);let a="";if(0!==r)for(a=Cu.fromString(s,!0,2).toString(4);a.length<r;)a="0"+a;return"".concat(o,"/").concat(a)}(t)}(e),n=function(e){if(0===e.length)throw new Error("Invalid Hilbert quad key ".concat(e));const t=e.split("/"),n=parseInt(t[0],10),i=t[1],s=i.length;let r=0;const o=[0,0];for(let e=s-1;e>=0;e--){r=s-e;const t=i[e];let n=0,a=0;"1"===t?a=1:"2"===t?(n=1,a=1):"3"===t&&(n=1);const c=Math.pow(2,r-1);Md(c,o,n,a),o[0]+=c*n,o[1]+=c*a}if(n%2==1){const e=o[0];o[0]=o[1],o[1]=e}return{face:n,ij:o,level:r}}(t);return n}const Td=100;function Id(e){const{face:t,ij:n,level:i}=e,s=[[0,0],[0,1],[1,1],[1,0],[0,0]],r=Math.max(1,Math.ceil(Td*Math.pow(2,-i))),o=new Float64Array(4*r*2+2);let a=0,c=0;for(let e=0;e<4;e++){const h=s[e].slice(0),l=s[e+1],u=(l[0]-h[0])/r,d=(l[1]-h[1])/r;for(let e=0;e<r;e++){h[0]+=u,h[1]+=d;const e=Ed(wd(t,vd(bd(n,i,h))));Math.abs(e[1])>89.999&&(e[0]=c);const s=e[0]-c;e[0]+=s>180?-360:s<-180?360:0,o[a++]=e[0],o[a++]=e[1],c=e[0]}}return o[a++]=o[0],o[a++]=o[1],o}function Rd(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],n=[];for(let i=0;i<e.length;i+=2)t.push(e[i]),n.push(e[i+1]);return t.sort(((e,t)=>e-t)),n.sort(((e,t)=>e-t)),{west:t[0],east:t[t.length-1],north:n[n.length-1],south:n[0]}}function Sd(e,t){const n=(null==t?void 0:t.minimumHeight)||0,i=(null==t?void 0:t.maximumHeight)||0,s=function(e){let t;if(2===e.face||5===e.face){let n=null,i=0;for(let t=0;t<4;t++){const s=Id(xd("".concat(e.face,"/").concat(t)));null==n&&(n=new Float64Array(4*s.length)),n.set(s,i),i+=s.length}t=Rd(n)}else t=Rd(Id(e));return t}(xd(e)),r=s.west,o=s.south,a=s.east,c=s.north,h=[];return h.push(new Gr(r,c,n)),h.push(new Gr(a,c,n)),h.push(new Gr(a,o,n)),h.push(new Gr(r,o,n)),h.push(new Gr(r,c,i)),h.push(new Gr(a,c,i)),h.push(new Gr(a,o,i)),h.push(new Gr(r,o,i)),h}function Od(e){return function(e){const t=vd(bd(e.ij,e.level,[.5,.5]));return Ed(wd(e.face,t))}(xd(e))}function Dd(e){const t=e.token,n={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},i=Sd(t,n),s=Od(t),r=s[0],o=s[1],a=Vl.WGS84.cartographicToCartesian([r,o,n.maximumHeight]),c=new Gr(a[0],a[1],a[2]);i.push(c);const h=function(e,t=new Ku){if(!e||0===e.length)return t.halfAxes=new bc([0,0,0,0,0,0,0,0,0]),t.center=new Gr,t;const n=e.length,i=new Gr(0,0,0);for(const t of e)i.add(t);const s=1/n;i.multiplyByScalar(s);let r=0,o=0,a=0,c=0,h=0,l=0;for(const t of e){const e=ld.copy(t).subtract(i);r+=e.x*e.x,o+=e.x*e.y,a+=e.x*e.z,c+=e.y*e.y,h+=e.y*e.z,l+=e.z*e.z}r*=s,o*=s,a*=s,c*=s,h*=s,l*=s;const u=md;u[0]=r,u[1]=o,u[2]=a,u[3]=o,u[4]=c,u[5]=h,u[6]=a,u[7]=h,u[8]=l;const{unitary:d}=rd(u,gd),f=t.halfAxes.copy(d);let p=f.getColumn(0,dd),m=f.getColumn(1,fd),g=f.getColumn(2,pd),A=-Number.MAX_VALUE,y=-Number.MAX_VALUE,B=-Number.MAX_VALUE,b=Number.MAX_VALUE,C=Number.MAX_VALUE,v=Number.MAX_VALUE;for(const t of e)ld.copy(t),A=Math.max(ld.dot(p),A),y=Math.max(ld.dot(m),y),B=Math.max(ld.dot(g),B),b=Math.min(ld.dot(p),b),C=Math.min(ld.dot(m),C),v=Math.min(ld.dot(g),v);p=p.multiplyByScalar(.5*(b+A)),m=m.multiplyByScalar(.5*(C+y)),g=g.multiplyByScalar(.5*(v+B)),t.center.copy(p).add(m).add(g);const w=ud.set(A-b,y-C,B-v).multiplyByScalar(.5),E=new bc([w[0],0,0,0,w[1],0,0,0,w[2]]);return t.halfAxes.multiplyRight(E),t}(i);return[...h.center,...h.halfAxes]}const Fd={QUADTREE:4,OCTREE:8};function _d(e,t,n){if(null!=e&&e.box){const i=function(e,t){const n=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(Cu.fromNumber(2*t+1-4).multiply(n))}(wu(e.s2VolumeInfo.token),t),s=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const n=t;t*=4;const i=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-i.length).join("0")+i}(i),r={...e.s2VolumeInfo};if(r.token=s,"OCTREE"===n){const t=e.s2VolumeInfo,n=t.maximumHeight-t.minimumHeight,i=n/2,s=t.minimumHeight+n/2;t.minimumHeight=s-i,t.maximumHeight=s+i}return{box:Dd(r),s2VolumeInfo:r}}}async function Gd(e){const{options:t,parentData:n={mortonIndex:0,x:0,y:0,z:0},childIndex:i=0,globalData:s={level:0,mortonIndex:0,x:0,y:0,z:0},s2VolumeBox:r}=e;let{subtree:o,level:a=0}=e;const{subdivisionScheme:c,subtreeLevels:h,maximumLevel:l,contentUrlTemplate:u,subtreesUriTemplate:d,basePath:f}=t,p={children:[],lodMetricValue:0,contentUrl:""},m=Fd[c],g=1&i,A=i>>1&1,y=i>>2&1,B=(m**a-1)/(m-1);let b=kd(n.mortonIndex,i),C=B+b,v=kd(n.x,g),w=kd(n.y,A),E=kd(n.z,y),M=!1;a+1>h&&(M=Ld(o.childSubtreeAvailability,b));const x=kd(s.x,v),T=kd(s.y,w),I=kd(s.z,E),R=a+s.level;if(M){const e=Nd("".concat(f,"/").concat(d),R,x,T,I);o=await Zi(e,Xl),s.mortonIndex=b,s.x=v,s.y=w,s.z=E,s.level=a,b=0,C=0,v=0,w=0,E=0,a=0}if(!Ld(o.tileAvailability,C)||a>l)return p;Ld(o.contentAvailability,C)&&(p.contentUrl=Nd(u,R,x,T,I));const S=a+1,O={mortonIndex:b,x:v,y:w,z:E};for(let e=0;e<m;e++){const n=_d(r,e,c),i=await Gd({subtree:o,options:t,parentData:O,childIndex:e,level:S,globalData:s,s2VolumeBox:n});if(i.contentUrl||i.children.length){const e=Pd(i,R+1,{childTileX:v,childTileY:w,childTileZ:E},t,r);p.children.push(e)}}return p}function Ld(e,t){return"constant"in e?Boolean(e.constant):!!e.explicitBitstream&&function(e,t){const n=Math.floor(e/8),i=e%8;return 1==(t[n]>>i&1)}(t,e.explicitBitstream)}function Pd(e,t,n,i,s){const{basePath:r,refine:o,getRefine:a,lodMetricType:c,getTileType:h,rootLodMetricValue:l,rootBoundingVolume:u}=i,d=e.contentUrl&&e.contentUrl.replace("".concat(r,"/"),""),f=l/2**t,p=function(e,t,n){if(t.region){const{childTileX:i,childTileY:s,childTileZ:r}=n,[o,a,c,h,l,u]=t.region,d=2**e,f=(c-o)/d,p=(h-a)/d,m=(u-l)/d,[g,A]=[o+f*i,o+f*(i+1)],[y,B]=[a+p*s,a+p*(s+1)],[b,C]=[l+m*r,l+m*(r+1)];return{region:[g,y,A,B,b,C]}}if(t.box)return t;throw new Error("Unsupported bounding volume type ".concat(t))}(t,null!=s&&s.box?{box:s.box}:u,n);return{children:e.children,contentUrl:e.contentUrl,content:{uri:d},id:e.contentUrl,refine:a(o),type:h(e),lodMetricType:c,lodMetricValue:f,geometricError:f,transform:e.transform,boundingVolume:p}}function kd(e,t){return parseInt(e.toString(2)+t.toString(2),2)}function Nd(e,t,n,i,s){const r=function(e){const t={};for(const n in e)t["{".concat(n,"}")]=e[n];return t}({level:t,x:n,y:i,z:s});return e.replace(/{level}|{x}|{y}|{z}/gi,(e=>r[e]))}function Ud(e){if(!e.contentUrl)return es.EMPTY;const t=e.contentUrl.split("?")[0].split(".").pop();switch(t){case"pnts":return es.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return es.SCENEGRAPH;default:return t}}function Hd(e){switch(e){case"REPLACE":case"replace":return $i.REPLACE;case"ADD":case"add":return $i.ADD;default:return e}}function jd(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const n=new URL(e,"".concat(t,"/"));return decodeURI(n.toString())}return e.startsWith("/")?e:"".concat(t,"/").concat(e)}function Jd(e,t){if(!e)return null;if(e.content){const n=e.content.uri||e.content.url;e.contentUrl=jd(n,t.basePath)}return e.id=e.contentUrl,e.lodMetricType=ns.GEOMETRIC_ERROR,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform,e.type=Ud(e),e.refine=Hd(e.refine),e}async function Vd(e,t,n,i){var s,r;const o=t.basePath,{subdivisionScheme:a,maximumLevel:c,subtreeLevels:h,subtrees:{uri:l}}=n,u=jd(Nd(l,0,0,0,0),o),d=await Zi(u,Xl,i),f=jd(e.content.uri,o),p=null==t||null===(s=t.root)||void 0===s?void 0:s.refine,m=e.geometricError,g=null===(r=e.boundingVolume.extensions)||void 0===r?void 0:r["3DTILES_bounding_volume_S2"];if(g){const t={box:Dd(g),s2VolumeInfo:g};e.boundingVolume=t}const A=e.boundingVolume,y={contentUrlTemplate:f,subtreesUriTemplate:l,subdivisionScheme:a,subtreeLevels:h,maximumLevel:c,refine:p,basePath:o,lodMetricType:ns.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:A,getTileType:Ud,getRefine:Hd};return await async function(e,t,n){if(!e)return null;e.lodMetricType=ns.GEOMETRIC_ERROR,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform;const{children:i,contentUrl:s}=await Gd({subtree:t,options:n,s2VolumeBox:e});s&&(e.contentUrl=s,e.content={uri:s.replace("".concat(n.basePath,"/"),"")});return e.refine=Hd(e.refine),e.type=Ud(e),e.children=i,e.id=e.contentUrl,e}(e,d,y)}function zd(e){var t;return(null==e||null===(t=e.extensions)||void 0===t?void 0:t["3DTILES_implicit_tiling"])||(null==e?void 0:e.implicitTiling)}const Kd={id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:is,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t,n){const i=t["3d-tiles"]||{};let s;s="auto"===i.isTileset?n.url&&-1!==n.url.indexOf(".json"):i.isTileset;e=s?await async function(e,t,n){var i;const s=JSON.parse((new TextDecoder).decode(e));return s.loader=t.loader||Kd,s.url=n.url,s.queryString=n.queryString,s.basePath=function(e){return ki(e.url)}(s),s.root=await async function(e,t){const n=e.basePath;let i;const s=zd(null==e?void 0:e.root);i=s&&e.root?await Vd(e.root,e,s,t):Jd(e.root,e);const r=[];for(r.push(i);r.length>0;){const i=(r.pop()||{}).children||[];for(let s of i){const i=zd(s);i?s=await Vd(s,e,i,t):Jd(s,{basePath:n}),r.push(s)}}return i}(s,t),s.type=ts.TILES3D,s.lodMetricType=ns.GEOMETRIC_ERROR,s.lodMetricValue=(null===(i=s.root)||void 0===i?void 0:i.lodMetricValue)||0,s}(e,t,n):await async function(e,t,n){const i={content:{featureIds:null}},s=0;return await Kl(e,s,t,n,i.content),i.content}(e,t,n);return e},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};var Wd=function(e,t,n,i){return new(n||(n=Promise))((function(s,r){function o(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};class Qd{}Qd.sl="https://www.wodashijie.com/",Qd.rl="https://models.wodashijie.com/",Qd.App=class{constructor(e){this.isDefaultMutual=!1,e.sl&&(Xd.sl=e.sl),e.rl&&(Xd.rl=e.rl),Tt.defaults.baseURL=Xd.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;z-index: 2;",e.container.appendChild(this.canvas),this.engine=new d.Engine(this.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0,doNotHandleContextLost:!1}),this.engine.setHardwareScalingLevel(.5),this.scene=new d.Scene(this.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),this.scene.useRightHandedSystem=!0,this.scene.getBoundingBoxRenderer().frontColor=d.Color3.Green(),this.scene.getBoundingBoxRenderer().showBackLines=!1,this.cameraController=new g(this),this.highlightLayer=new d.HighlightLayer("highlightLayer",this.scene),this.iEvent=new f(this),this.gl=new d.GlowLayer("glow2",this.scene),this.container=d.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.toolTips=new E(this),this.environment=new M(this),this.environment.defaultLights(),this.environment.openAllLight(),this.resources=new j(this),this.project=new U(this);let t=new d.UtilityLayerRenderer(this.scene);this.positionGizmo=new d.PositionGizmo(t),O.init(),this.engine.runRenderLoop((()=>{this.fps&&(this.fps.innerText=this.engine.getFps().toFixed()+" fps"),this.scene.render(),d.TWEEN.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)}))}load(e){return Pt(this,void 0,void 0,(function*(){e.pk=null==e.pk?"project":e.pk,e.isDefaultLevel=null==e.isDefaultLevel||e.isDefaultLevel,e.isDefaultMutual=null==e.isDefaultMutual||e.isDefaultMutual,Xd.pk=e.pk;let t=yield Tt.get(`api/service/GetToken?accessToken=${Xd.accessToken}`);if(200!=t.status)return;localStorage.setItem("mx3d-token",t.data);let n=yield Tt.get("api/service");if(200!=n.status)return;localStorage.setItem("mx3d-long",n.data);let i=yield Tt.get(`api/service/${Xd.pk}`);if(200!=i.status)return;let s=JSON.parse(St.de(i.data));return new Promise(((t,n)=>Pt(this,void 0,void 0,(function*(){try{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let n=new A,i=!1;if(s.modelLists){for(let e=0;e<s.modelLists.length;e++)n.add(s.modelLists[e].modelId,s.modelLists[e]);i=!0}let r=new A;for(let e=0;e<s.objectDatas.length;e++){let t,o=s.objectDatas[e];o.baseModel&&i&&(o.baseModel=n.find(o.baseModel)),o.baseModel&&!n.find(o.baseModel.modelId)&&n.add(o.baseModel.modelId,o.baseModel),o.objectType!=x.Corner&&o.objectType!=x.Floor&&(o.objectType!=x.Wall?(o.objectType==x.Window?t=new P(this):o.objectType==x.Door?t=new L(this):o.objectType==x.Campus?(t=new Gt(this),r.add(o.id,new Array)):o.objectType==x.Storey?(t=new k(this),r.add(o.id,new Array)):t=o.objectType==x.LeakWater?new Ot(this):o.objectType==x.Conduit?new Dt(this):o.objectType==x.UI3D?new Ft(this):o.objectType==x.VirtualBox?new _t(this):o.objectType==x.Building?new N(this):new D(this),t.loadProperties(o),this.project.objectDatas.add(t.id,t)):(o.leftMap&&i&&(o.leftMap=n.find(o.leftMap)),o.rightMap&&i&&(o.rightMap=n.find(o.rightMap))))}for(let e=0;e<s.objectDatas.length;e++){let t=s.objectDatas[e];if(t.objectType==x.Corner||t.objectType==x.Wall||t.objectType==x.Floor){r.find(t.parentId).push(t)}}let o=0,a=n.count();for(const t in n.map){let i=n.find(t);".gltf"!=i.extension&&".glb"!=i.extension||(yield this.resources.loadModelMesh(i)),o++,e&&e.progress&&e.progress(o/a*.3)}o=0,n=null,a=this.project.objectDatas.count();for(const t in this.project.objectDatas.map){let n=this.project.objectDatas.find(t);yield n.bind(),o++,e&&e.progress&&e.progress(.3+o/a*.5)}o=0,a=r.count();let c=!1;for(const t in r.map){o++,e&&e.progress&&e.progress(.8+o/a*.2);let n=this.project.objectDatas.find(t);n&&n instanceof G&&n.load(c,r.find(t))}this.project.root=this.project.objectDatas.find(s.id),this.project.optimization(),e.isDefaultMutual&&(this.defaultMutual=!0),e.isDefaultLevel&&this.project.switchLevel(null,!0),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,t(null),this.engine.resize(),e&&e.complete&&e.complete()}catch(e){n(e)}}))))}))}set defaultMutual(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.isDefaultMutual=e;for(let e in this.project.objectDatas.map){let t=this.project.objectDatas.find(e);t instanceof N&&(this.project.getChildsById(t.id).length<1||(this.isDefaultMutual?t.addEventListener(T.leftClick,(()=>this.project.switchLevel(t.id))):t.removeEventListener(T.leftClick)))}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.environment.hideFps(),this.project.clear(),this.resources.delete(),this.engine.dispose()}createYUAN(e,t,n){this.claerbox();var i=m.ToARRVector3(JSON.parse(e));let s=[];if(t){var r=m.ToARRVector3(JSON.parse(t));s.push(r)}this.box11=d.MeshBuilder.ExtrudePolygon("yuan",{shape:i,holes:s,depth:n,sideOrientation:2},this.scene),this.positionGizmo&&(this.positionGizmo.attachedMesh=this.box11)}claerbox(){this.box11&&(this.box11.dispose(),this.box11=null)}perspective(){if(!this.box11)return;let e=this.box11.getBoundingInfo(),t=m.getVisualAngle(e,this),n=new R;n.alpha=t.alpha,n.beta=t.beta,n.focus=e.boundingSphere.center,n.radius=3*e.boundingSphere.radius,n.minimumLimit=.3,n.maximumLimit=2*n.radius,n.minBeta=.01,n.maxBeta=Math.PI/2*.98,this.cameraController.perspective(n)}orthographic1(){if(!this.box11)return;let e=this.box11.getBoundingInfo(),t=m.getVisualAngle(e,this),n=new R;n.alpha=t.alpha,n.beta=t.beta,n.focus=e.boundingSphere.center,n.radius=3*e.boundingSphere.radius,n.minimumLimit=.3,n.maximumLimit=2*n.radius,n.minBeta=.01,n.maxBeta=Math.PI/2*.98,this.cameraController.orthographic1(n)}},Qd.AlarmFlashing=O,Qd.UI=class{static createIconFromMesh(e,t,n,i,s){let r=t.Sight.focus.clone(),o=t.instance.getBoundingInfo();return r.y+=(o.boundingBox.maximum.y-o.boundingBox.minimum.y)/2,new Jt(e,r,n,i,s,t.app.scene)}static createIcon(e,t,n,i){let s;t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,s=new jt(e,t.app.scene),s.size=n,s.height=i,s.pint=new d.Mesh(e+"_pint");let r=t.Sight.focus.clone();return s.pint.position=r,s.pint.position.y+=i,s.rect=new d.Rectangle,s.rect.isPointerBlocker=!1,s.rect.width=n.width+"px",s.rect.height=n.height+"px",s.rect.thickness=0,t.app.container.addControl(s.rect),s.rect.linkWithMesh(s.pint),t.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,s}},Qd.Builder=class{static createMatrixCloud(e){let t;if(e.displayValues=null!=e.displayValues&&e.displayValues,e.isAlpha=null==e.isAlpha||e.isAlpha,e.isParticle=null==e.isParticle||e.isParticle,e.height=e.height||.5,e.radius=e.radius||2.8,e.isLevelRender=null==e.isLevelRender||e.isLevelRender,e.range=e.range||{max:30,min:16},!(e.value||e.value.maxX||e.value.maxY||e.value.data||e.anchor))return t;e.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,t=new Nt(e.anchor);let n=e.anchor.instance.getBoundingInfo();t.mesh=e.anchor.instance.clone(t.id),t.mesh.position.y+=e.height;let i=n.maximum.x-n.minimum.x,s=i/(2*e.value.maxX),r=n.maximum.z-n.minimum.z,o=r/(2*e.value.maxY),a=new Array;for(let c=0;c<2*e.value.maxX;c++)for(let h=0;h<2*e.value.maxY;h++){let l={x:c,y:h,value:e.range.min};for(let a=0;a<e.value.data.length;a++){const u=e.value.data[a];if(2*u.x+1==c&&2*u.y+1==h){l.value=u.value;let a=new d.Vector3(n.boundingSphere.center.x-(i/2-s*c),t.mesh.position.y,n.boundingSphere.center.z-(r/2-o*h));t.texts.push(this.createTempVlaue(l.value+"℃",a,e.anchor.app.scene,e.anchor.app.container))}}a.push(l)}t.displayValues=e.displayValues;let c=d.h337.create({width:2*e.value.maxX,height:2*e.value.maxY,radius:e.radius});c.setData({min:e.range.min,max:e.range.max,data:a});let h=new d.StandardMaterial(t.id,e.anchor.app.scene);return h.diffuseTexture=new d.Texture(c.getDataURL(),e.anchor.app.scene,!1,!1),h.specularColor=new d.Color3(0,0,0),h.alpha=.5,e.isAlpha&&(h.diffuseTexture.hasAlpha=!0),e.isParticle&&d.GPUParticleSystem.IsSupported&&(this._getMatrixParticleTex(Xd.rl,e.anchor.app.resources.FogTex,h.diffuseTexture,t.mesh,e.anchor.app.scene,e.isLevelRender),t.mesh.isVisible=!1),e.isLevelRender&&(t.mesh.renderingGroupId=1),t.mesh.material=h,t.mesh.alwaysSelectAsActiveMesh=!0,t.mesh.freezeWorldMatrix(),e.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,t}static _getMatrixParticleTex(e,t,n,i,s,r){let o,a=t.clone(),c=i.getBoundingInfo().boundingBox;let h=(c.extendSizeWorld.x+c.extendSizeWorld.z)/9,l=1500*h*h;c.minimumWorld.subtract(new d.Vector3(-0,0,-0)),c.maximumWorld.subtract(new d.Vector3(0,0,0));o&&o.dispose(),d.GPUParticleSystem.IsSupported&&(o=new d.GPUParticleSystem("particles",{capacity:l},s),o.activeParticleCount=l,o.manualEmitCount=o.activeParticleCount,o.minEmitBox=c.minimumWorld,o.maxEmitBox=c.maximumWorld),o.particleTexture=a,o.emitter=i,r&&(o.renderingGroupId=1),o.isLocal=!0;let u=new d.NodeMaterial("nm_heatmapBox_"+i.id,s);return u.loadAsync(e+"resources/horizontalNodeMat.json").then((()=>{u.build(!1),u.getBlockByName("boxTex").texture=n,u.getBlockByName("emitXMin").value=o.minEmitBox.x,u.getBlockByName("emitXMax").value=o.maxEmitBox.x,u.getBlockByName("emitYMin").value=o.minEmitBox.z,u.getBlockByName("emitYMax").value=o.maxEmitBox.z,u.createEffectForParticles(o)})),i.onDispose=()=>{o&&o.dispose()},o.onDispose=()=>{u&&u.dispose(),a&&a.dispose()},o.color1=new d.Color4(.8,.8,.8,.1),o.color2=new d.Color4(.95,.95,.95,.15),o.colorDead=new d.Color4(.9,.9,.9,.1),o.minSize=1.4,o.maxSize=2,o.minLifeTime=Number.MAX_SAFE_INTEGER,o.emitRate=5e4*h,o.blendMode=d.ParticleSystem.BLENDMODE_STANDARD,o.gravity=new d.Vector3(0,0,0),o.direction1=new d.Vector3(0,0,0),o.direction2=new d.Vector3(0,0,0),o.minAngularSpeed=-2,o.maxAngularSpeed=2,o.minEmitPower=.5,o.maxEmitPower=1,o.updateSpeed=.005,o.start(),o}static createPunctateCloud(e){if(e.displayValues=null!=e.displayValues&&e.displayValues,e.isAlpha=null==e.isAlpha||e.isAlpha,e.isParticle=null==e.isParticle||e.isParticle,e.radius=e.radius||1,e.isLevelRender=null==e.isLevelRender||e.isLevelRender,e.range=e.range||{max:30,min:16},!e.value&&!e.anchor)return null;let t;e.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,t=new Nt(e.anchor),t.mesh=d.MeshBuilder.CreatePlane(t.id,{width:1,height:1,sideOrientation:2},e.anchor.app.scene),t.mesh.scaling=new d.Vector3(e.radius,e.radius,e.radius),t.mesh.alwaysSelectAsActiveMesh=!0,t.mesh.enablePointerMoveEvents=!1,t.mesh.isPickable=!1,t.mesh.position=e.anchor.instance.position.clone(),t.mesh.rotation.x=Math.PI/2;let n=[];for(let t=0;t<6;t++)for(let i=0;i<6;i++){let s={x:t,y:i,value:e.range.min};s.value=2==t&&2==i||3==t&&2==i||2==t&&3==i||3==t&&3==i?e.value:e.value-2*(Math.abs(2-t)+Math.abs(2-i)),n.push(s)}t.displayValues=e.displayValues;let i=d.h337.create({width:5,height:5,radius:2});i.setData({min:e.range.min,max:e.range.max,data:n});let s=new d.StandardMaterial(t.id,e.anchor.app.scene);return s.diffuseTexture=new d.Texture(i.getDataURL(),e.anchor.app.scene,!1,!1),s.specularColor=new d.Color3(0,0,0),s.alpha=.5,e.isAlpha&&(s.diffuseTexture.hasAlpha=!0),e.isParticle&&d.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(s.diffuseTexture,t.mesh,e.anchor.app.scene,t.anchor.app.resources.FogTex,e.isLevelRender),t.mesh.isVisible=!1),e.isLevelRender&&(t.mesh.renderingGroupId=1),t.mesh.material=s,t.mesh.alwaysSelectAsActiveMesh=!0,t.mesh.freezeWorldMatrix(),e.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,t}static createColumnCloud(e){if(e.displayValues=null!=e.displayValues&&e.displayValues,e.isAlpha=null==e.isAlpha||e.isAlpha,e.isParticle=null==e.isParticle||e.isParticle,e.radius=e.radius||4,e.isLevelRender=null==e.isLevelRender||e.isLevelRender,e.range=e.range||{max:30,min:16},!e.data&&e.data.length<1&&!e.anchor)return null;let t;e.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,t=new Nt(e.anchor);let n=.98*e.anchor.instance.scaling.y;t.mesh=d.MeshBuilder.CreatePlane(t.id,{width:.98*e.anchor.instance.scaling.x,height:n,sideOrientation:2},e.anchor.app.scene),t.mesh.alwaysSelectAsActiveMesh=!0,t.mesh.enablePointerMoveEvents=!1,t.mesh.isPickable=!1,t.mesh.position=e.anchor.instance.position.clone(),t.mesh.rotation.z=Math.PI,t.mesh.rotation.y=e.anchor.instance.rotation.y,e.isLevelRender&&(t.mesh.renderingGroupId=1);let i=[];for(let t=0;t<4;t++)for(let n=0;n<3*e.data.length;n++){let s={x:t,y:n,value:e.range.min};for(let i=0;i<e.data.length;i++){const r=e.data[i];2==t&&3*i+2==n&&(s.value=r.value)}i.push(s)}let s=n/e.data.length;for(let i=0;i<e.data.length;i++){let r=t.mesh.position.clone();r.y=r.y-n/2+(n-s*i-s/2),t.texts.push(this.createTempVlaue(e.data[i].value+"℃",r,e.anchor.app.scene,t.anchor.app.container))}t.displayValues=e.displayValues;let r=d.h337.create({width:4,height:3*e.data.length,radius:e.radius});r.setData({min:e.range.min,max:e.range.max,data:i});let o=new d.StandardMaterial(t.id,e.anchor.app.scene);return o.diffuseTexture=new d.Texture(r.getDataURL(),e.anchor.app.scene,!1,!1),o.specularColor=new d.Color3(0,0,0),o.alpha=.5,e.isAlpha&&(o.diffuseTexture.hasAlpha=!0),e.isParticle&&d.GPUParticleSystem.IsSupported&&(this._getColumnarParticleTex(o.diffuseTexture,t.mesh,e.anchor.app.scene,t.anchor.app.resources.FogTex,e.isLevelRender),t.mesh.isVisible=!1),t.mesh.material=o,t.mesh.alwaysSelectAsActiveMesh=!0,t.mesh.freezeWorldMatrix(),e.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,t}static _getColumnarParticleTex(e,t,n,i,s){let r,o=i.clone(),a=t.getBoundingInfo().boundingBox;a.extendSizeWorld.x,a.extendSizeWorld.z;d.Effect.ShadersStore.particlesVertexShader="\n precision highp float;\n in vec3 position;\n in vec4 color;\n in float angle;\n in vec2 size;\n in vec2 offset;\n uniform mat4 view;\n uniform mat4 projection;\n uniform vec2 translationPivot;\n out vec2 vUV;\n out vec4 vColor;\n out vec3 vPositionW;\n out vec3 vPosition;\n uniform mat4 invView;\n uniform vec3 eyePosition;\n\n vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\n vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\n vec3 zaxis=normalize(cross(yaxis,xaxis));\n vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\n vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\n vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\n mat3 rotMatrix=mat3(row0,row1,row2);\n vec3 alignedCorner=rotMatrix*rotatedCorner;\n return position+alignedCorner;\n }\n\n void main(void) {\n vec2 cornerPos;\n cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n vec3 rotatedCorner;\n rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\n rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\n rotatedCorner.z=0.;\n vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\n vPositionW=(invView*vec4(viewPos,1)).xyz;\n vPosition = position;\n gl_Position=projection*vec4(viewPos,1.0);\n vColor=color;\n vUV=offset;\n }\n \n ",d.Effect.ShadersStore[t.id+"myParticleFragmentShader"]="\n #ifdef GL_ES\n precision highp float;\n #endif\n\n attribute vec3 position;\n\n varying vec2 vUV; // Provided by Runtime.js\n varying vec4 vColor; // Provided by Runtime.js\n\n varying vec3 vPosition;\n\n uniform sampler2D diffuseSampler; // Provided by Runtime.js\n uniform float time; // This one is custom so we need to declare it to the effect\n\n uniform float u_emitXMin;\n uniform float u_emitXMax;\n uniform float u_emitYMin;\n uniform float u_emitYMax;\n\n uniform sampler2D boxTexSampler;\n\n uniform mat4 emitBox_WorldM;\n\n\n void main(void) {\n vec4 position = inverse(emitBox_WorldM) * vec4(vPosition, 1.0);\n\n float x = position.x;\n float z = position.y;\n float output0 = 0.0 + (x - u_emitXMin) * (1.0 - 0.0) / (u_emitXMax - u_emitXMin);\n float output1 = 0.0 + (z - u_emitYMin) * (1.0 - 0.0) / (u_emitYMax - u_emitYMin);\n vec2 xy = vec2(output0, output1);\n vec4 baseTex = texture2D(boxTexSampler, xy);\n\n vec4 baseColor = texture2D(diffuseSampler, vUV);\n\n vec4 resAlpha = baseColor * vColor ;\n\n gl_FragColor = vec4(baseTex.xyz, resAlpha.a);\n }\n ";var c=n.getEngine().createEffectForParticles(t.id+"myParticle",["time","u_emitXMin","u_emitYMin","u_emitXMax","u_emitYMax","emitBox_WorldM"],["boxTexSampler"],"");return t.onAfterWorldMatrixUpdateObservable.add((()=>{})),c.onCompileObservable.add((()=>{c.setMatrix("emitBox_WorldM",t.getWorldMatrix()),c.setFloat("u_emitXMin",r.minEmitBox.x),c.setFloat("u_emitYMin",r.minEmitBox.y),c.setFloat("u_emitXMax",r.maxEmitBox.x),c.setFloat("u_emitYMax",r.maxEmitBox.y)})),c.onBind=function(){c.setTexture("boxTexSampler",e)},r&&r.dispose(),d.GPUParticleSystem.IsSupported&&(r=new d.ParticleSystem("particles",200,n,c),r.manualEmitCount=r.getCapacity(),r.minEmitBox=a.minimum,r.maxEmitBox=a.maximum),t.onDispose=()=>{r&&r.dispose()},r.onDispose=()=>{o&&o.dispose()},r.particleTexture=o.clone(),r.emitter=t,s&&(r.renderingGroupId=1),r.isLocal=!0,r.color1=new d.Color4(.8,.8,.8,.1),r.color2=new d.Color4(.95,.95,.95,.15),r.colorDead=new d.Color4(.9,.9,.9,.1),r.minSize=.7,r.maxSize=1,r.minLifeTime=Number.MAX_SAFE_INTEGER,r.emitRate=50,r.blendMode=d.ParticleSystem.BLENDMODE_STANDARD,r.gravity=new d.Vector3(0,0,0),r.direction1=new d.Vector3(0,0,0),r.direction2=new d.Vector3(0,0,0),r.minAngularSpeed=-2,r.maxAngularSpeed=2,r.minEmitPower=.5,r.maxEmitPower=1,r.updateSpeed=.005,r.start(),r}static createTempVlaue(e,t,n,i){let s=new d.Mesh("temp_"+y.getGUID(12),n);s.position=t;let r=new d.TextBlock;return r.isPointerBlocker=!1,r.text="默认提示",r.color="white",r.resizeToFit=!0,r.fontSize="20px",r.text=e,i.addControl(r),r.linkWithMesh(s),r}static createCapacity(e,t,n,i="200px"){let s=new kt(e,t);s.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,s.mesh=d.MeshBuilder.CreateBox("RATIO_"+s.anchor.id,{size:1}),s.mesh.position=s.anchor.instance.position.clone(),s.mesh.position.y-=s.mesh.scaling.y/2,s.mesh.scaling=s.anchor.instance.scaling.clone(),s.mesh.scaling.x=.98*s.mesh.scaling.x,s.mesh.scaling.z=.98*s.mesh.scaling.z,s.mesh.rotation=s.anchor.instance.rotation.clone(),s.mesh.alwaysSelectAsActiveMesh=!0,s.mesh.visibility=1;let r=t<.25?d.Color3.Blue():t>=.25&&t<.5?d.Color3.Green():t>=.5&&t<.75?d.Color3.Yellow():d.Color3.Red();s.color=r.toHexString(),t*=s.mesh.scaling.y;var o=new d.Vector3(0,-.5,0);s.mesh.setPivotPoint(o);let a=new d.StandardMaterial(s.mesh.id,s.anchor.instance._scene);return a.diffuseColor=r,s.mesh.material=a,d.Animation.CreateAndStartAnimation(s.mesh.id,s.mesh,"scaling.y",15,30,.02,t,0,null),s.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,n&&(s.textMesh=this.createTextMesh(e,n,t,i,"#fff")),s}static createTextMesh(e,t,n,i="200px",s="white"){e.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let r=d.Mesh.CreatePlane("text_"+e.id,e.instance.scaling.x,e.app.scene,!0,d.Mesh.DOUBLESIDE);r.alwaysSelectAsActiveMesh=!0,r.position=e.instance.position.clone(),r.position.y=n+.05,r.rotation.y=Math.PI-e.instance.rotation.y,r.rotation.x=-Math.PI/2;let o=new d.StandardMaterial("text_mat_"+e.id,e.app.scene);o.diffuseColor=d.Color3.White(),o.emissiveColor=d.Color3.White();let a=new d.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,o.diffuseTexture=a,o.opacityTexture=a,a.drawText(t,1e3*e.instance.scaling.x/2,500*e.instance.scaling.x/2,"bold "+i+" NexaBold",s,"",!0,!0),a.update(),r.material=o,e.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,r}static create2DLine(e,t,n){if(t.length<2)return;let i=new Ht;return i.id=e,i.objs=t,n&&n.width&&(i.width=n.width),n&&n.color&&(i.color=n.color),n&&n.isDotted&&(i.isDotted=n.isDotted),i.update(),i}static create3DLine(e,t,n){if(t.length<2)return;let i=new Ut;return i.id=e,i.objs=t,n&&n.width&&(i.width=n.width),n&&n.color&&(i.color=n.color),i.update(),i}},Qd.EffectType=Lt,Qd.EventType=T,Qd.StatusType=I,Qd.Effect=Yt,Qd.TileLoader=class{constructor(e){this.app=e}load(e){return Wd(this,void 0,void 0,(function*(){const t=yield Zi(e,Kd),n=new d.Mesh("tileset",this.app.scene),i=t.data.attributes.POSITION.value,s=t.data.indices.value,r=new d.VertexData;r.positions=i,r.indices=s,r.applyToMesh(n);let o=new d.StandardMaterial("tilesetMaterial",this.app.scene);o.diffuseColor=new d.Color3(1,0,0),n.material=o}))}};const Xd=Qd})(),s=s.default})()));
|