29 lines
2.1 MiB
29 lines
2.1 MiB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).mapboxgl=t()}(this,(function(){"use strict";var e,t,i;function n(n,r){if(e)if(t){var o="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 = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",s={};e(s);i=r(s);"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=r;else e=r}n(0,(function(e){var t="undefined"!=typeof self?self:{},i=n;function n(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=n,this.p2x=i,this.p2y=n}n.prototype.sampleCurveX=function(e){return((this.ax*e+this.bx)*e+this.cx)*e},n.prototype.sampleCurveY=function(e){return((this.ay*e+this.by)*e+this.cy)*e},n.prototype.sampleCurveDerivativeX=function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},n.prototype.solveCurveX=function(e,t){var i,n,r,o,s;for(void 0===t&&(t=1e-6),r=e,s=0;s<8;s++){if(o=this.sampleCurveX(r)-e,Math.abs(o)<t)return r;var a=this.sampleCurveDerivativeX(r);if(Math.abs(a)<1e-6)break;r-=o/a}if((r=e)<(i=0))return i;if(r>(n=1))return n;for(;i<n;){if(o=this.sampleCurveX(r),Math.abs(o-e)<t)return r;e>o?i=r:n=r,r=.5*(n-i)+i}return r},n.prototype.solve=function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))};var r=o;function o(e,t){this.x=e,this.y=t}o.prototype={clone:function(){return new o(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),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround:function(e,t){var i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(e){return e instanceof o?e:Array.isArray(e)?new o(e[0],e[1]):e};const s=Math.PI/180,a=180/Math.PI;function l(e){return e*s}function c(e){return e*a}const u=[[0,0],[1,0],[1,1],[0,1]];function h(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 p(e,t,n,r){const o=new i(e,t,n,r);return function(e){return o.solve(e)}}const d=p(.25,.1,.25,1);function f(e,t,i){return Math.min(i,Math.max(t,e))}function m(e,t,i){return(i=f((i-e)/(t-e),0,1))*i*(3-2*i)}function g(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function _(e,t,i){if(!e.length)return i(null,[]);let n=e.length;const r=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),r[s]=t,0==--n&&i(o,r)}))}))}function y(e){const t=[];for(const i in e)t.push(e[i]);return t}function v(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let x=1;function b(){return x++}function w(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function M(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function T(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 S(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function E(e,t){return-1!==e.indexOf(t,e.length-t.length)}function A(e,t,i){const n={};for(const r in e)n[r]=t.call(i||this,e[r],r,e);return n}function C(e,t,i){const n={};for(const r in e)t.call(i||this,e[r],r,e)&&(n[r]=e[r]);return n}function L(e){return Array.isArray(e)?e.map(L):"object"==typeof e&&e?A(e,L):e}const I={};function P(e){I[e]||("undefined"!=typeof console&&console.warn(e),I[e]=!0)}function R(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function k(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r<o;s=r++)i=e[r],n=e[s],t+=(n.x-i.x)*(i.y+n.y);return t}function z(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function D(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,n,r)=>{const o=n||r;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let O=null;function F(e){if(null==O){const t=e.navigator?e.navigator.userAgent:null;O=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return O}function B(e){try{const i=t[e];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function N(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const U=t.performance;function j(e){const t=e?e.url.toString():void 0;return U.getEntriesByName(t)}var V="2.9.1";let G,H,W,q;const $={now:()=>void 0!==W?W:t.performance.now(),setNow(e){W=e},restoreNow(){W=void 0},frame(e){const i=t.requestAnimationFrame(e);return{cancel:()=>t.cancelAnimationFrame(i)}},getImageData(e,i=0){const{width:n,height:r}=e;q||(q=t.document.createElement("canvas"));const o=q.getContext("2d");if(!o)throw new Error("failed to create canvas 2d context");return(n>q.width||r>q.height)&&(q.width=n,q.height=r),o.clearRect(-i,-i,n+2*i,r+2*i),o.drawImage(e,0,0,n,r),o.getImageData(-i,-i,n+2*i,r+2*i)},resolveURL:e=>(G||(G=t.document.createElement("a")),G.href=e,G.href),get devicePixelRatio(){return t.devicePixelRatio},get prefersReducedMotion(){return!!t.matchMedia&&(null==H&&(H=t.matchMedia("(prefers-reduced-motion: reduce)")),H.matches)}};let Z;const X={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==Z){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Z=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e}catch(t){Z=e}}return Z},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},Y={supported:!1,testSupport:function(e){!K&&Q&&(ee?te(e):J=e)}};let J,Q,K=!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,Q),e.isContextLost())return;Y.supported=!0}catch(e){}e.deleteTexture(t),K=!0}t.document&&(Q=t.document.createElement("img"),Q.onload=function(){J&&te(J),J=null,ee=!0},Q.onerror=function(){K=!0,J=null},Q.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const ie="01",ne="NO_ACCESS_TOKEN";function re(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 i=e.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(t.atob(i[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class ue{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const i=ce(X.ACCESS_TOKEN);let n="";return n=i&&i.u?t.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):X.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${n}`:`mapbox.eventData:${n}`}fetchEventData(){const e=B("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{const e=t.localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const r=t.localStorage.getItem(n);r&&(this.anonId=r)}catch(e){P("Unable to read from LocalStorage")}}saveEventData(){const e=B("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{t.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&t.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(e){P("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,n){if(!X.EVENTS_URL)return;const r=ae(X.EVENTS_URL);r.params.push(`access_token=${n||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?v(o,t):o,a={url:le(r),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=Re(a,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const he=new class extends ue{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){X.EVENTS_URL&&X.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>re(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 n=i!==this.eventData.tokenU;T(this.anonId)||(this.anonId=w(),n=!0);const r=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(r),i=(r-this.eventData.lastSuccess)/864e5;n=n||i>=1||i<-1||e.getDate()!==t.getDate()}else n=!0;n?this.postEvent(r,{"enabled.telemetry":!1},(e=>{e||(this.eventData.lastSuccess=r,this.eventData.tokenU=i)}),e):this.processRequests()}},pe=he.postTurnstileEvent.bind(he),de=new class extends ue{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,n){this.skuToken=t,this.errorCb=n,X.EVENTS_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(ne)))}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(),T(this.anonId)||(this.anonId=w()),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 ue{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,n){if(!X.API_URL||!X.SESSION_PATH)return;const r=ae(X.API_URL+X.SESSION_PATH);r.params.push(`sku=${t||""}`),r.params.push(`access_token=${n||X.ACCESS_TOKEN||""}`);const o={url:le(r),headers:{"Content-Type":"text/plain"}};this.pendingRequest=ke(o,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}getSessionAPI(e,t,i,n){this.skuToken=t,this.errorCb=n,X.SESSION_PATH&&X.API_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(ne)))}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)}},ge=me.getSessionAPI.bind(me),_e=new Set;let ye,ve=500,xe=50,be={};function we(e){const t=Te(e);let i,n;t&&t.forEach((e=>{const t=e.split("=");"language"===t[0]?i=t[1]:"worldview"===t[0]&&(n=t[1])}));let r="mapbox-tiles";return i&&(r+=`-${i}`),n&&(r+=`-${n}`),r}function Me(e){t.caches&&!be[e]&&(be[e]=t.caches.open(e))}function Te(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}function Se(e){const t=e.indexOf("?");if(t<0)return e;const i=Te(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 Ee=1/0;const Ae={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Ae);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 Le=z()?()=>self.worker&&self.worker.referrer:()=>("blob:"===t.location.protocol?t.parent:t).location.href,Ie=function(e,i){if(!(/^file:/.test(n=e.url)||/^file:/.test(Le())&&!/^\w+:/.test(n))){if(t.fetch&&t.Request&&t.AbortController&&t.Request.prototype.hasOwnProperty("signal"))return function(e,i){const n=new t.AbortController,r=new t.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Le(),signal:n.signal});let o=!1,s=!1;const a=(l=r.url).indexOf("sku=")>0&&oe(l);var l;"json"===e.type&&r.headers.set("Accept","application/json");const c=(n,o,l)=>{if(s)return;if(n&&"SecurityError"!==n.message&&P(n),o&&l)return u(o);const c=Date.now();t.fetch(r).then((t=>{if(t.ok){const e=a?t.clone():null;return u(t,e,c)}return i(new Ce(t.statusText,t.status,e.url))})).catch((e=>{20!==e.code&&i(new Error(e.message))}))},u=(n,a,l)=>{("arrayBuffer"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text()).then((e=>{s||(a&&l&&function(e,i,n){const r=we(e.url);if(Me(r),!be[r])return;const o={status:i.status,statusText:i.statusText,headers:new t.Headers};i.headers.forEach(((e,t)=>o.headers.set(t,e)));const s=D(i.headers.get("Cache-Control")||"");if(s["no-store"])return;s["max-age"]&&o.headers.set("Expires",new Date(n+1e3*s["max-age"]).toUTCString());const a=o.headers.get("Expires");a&&(new Date(a).getTime()-n<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)}(i,(i=>{const n=new t.Response(i,o);Me(r),be[r]&&be[r].then((t=>t.put(Se(e.url),n))).catch((e=>P(e.message)))})))}(r,a,l),o=!0,i(null,e,n.headers.get("Cache-Control"),n.headers.get("Expires")))})).catch((e=>{s||i(new Error(e.message))}))};return a?function(e,t){const i=we(e.url);if(Me(i),!be[i])return t(null);const n=Se(e.url);be[i].then((e=>{e.match(n).then((i=>{const r=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=D(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(i);e.delete(n),r&&e.put(n,i.clone()),t(null,i,r)})).catch(t)})).catch(t)}(r,c):c(null,null),{cancel:()=>{s=!0,o||n.abort()}}}(e,i);if(z()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,i,void 0,!0)}var n;return function(e,i){const n=new t.XMLHttpRequest;n.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(n.responseType="arraybuffer");for(const t in e.headers)n.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===e.credentials,n.onerror=()=>{i(new Error(n.statusText))},n.onload=()=>{if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let t=n.response;if("json"===e.type)try{t=JSON.parse(n.response)}catch(e){return i(e)}i(null,t,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else i(new Ce(n.statusText,n.status,e.url))},n.send(e.body),{cancel:()=>n.abort()}}(e,i)},Pe=function(e,t){return Ie(v(e,{type:"arrayBuffer"}),t)},Re=function(e,t){return Ie(v(e,{method:"POST"}),t)},ke=function(e,t){return Ie(v(e,{method:"GET"}),t)};function ze(e){const i=t.document.createElement("a");return i.href=e,i.protocol===t.document.location.protocol&&i.host===t.document.location.host}const De="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Oe,Fe;Oe=[],Fe=0;const Be=function(e,i){if(Y.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Fe>=X.MAX_PARALLEL_IMAGE_REQUESTS){const t={requestParameters:e,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return Oe.push(t),t}Fe++;let n=!1;const r=()=>{if(!n)for(n=!0,Fe--;Oe.length&&Fe<X.MAX_PARALLEL_IMAGE_REQUESTS;){const e=Oe.shift(),{requestParameters:t,callback:i,cancelled:n}=e;n||(e.cancel=Be(t,i).cancel)}},o=Pe(e,((e,n,o,s)=>{r(),e?i(e):n&&(t.createImageBitmap?function(e,i){const n=new t.Blob([new Uint8Array(e)],{type:"image/png"});t.createImageBitmap(n).then((e=>{i(null,e)})).catch((e=>{i(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.`))}))}(n,((e,t)=>i(e,t,o,s))):function(e,i){const n=new t.Image,r=t.URL;n.onload=()=>{i(null,n),r.revokeObjectURL(n.src),n.onload=null,t.requestAnimationFrame((()=>{n.src=De}))},n.onerror=()=>i(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 o=new t.Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?r.createObjectURL(o):De}(n,((e,t)=>i(e,t,o,s))))}));return{cancel:()=>{o.cancel(),r()}}};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 n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class je{constructor(e,t={}){v(this,t),this.type=e}}class Ve extends je{constructor(e,t={}){super("error",v({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(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ne(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new je(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of n)Ue(i,t,this._oneTimeListeners),t.call(this,e);const r=this._eventedParent;r&&(v(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(e))}else e instanceof Ve&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var He=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 We(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 Ze extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var Xe=Ze;class Ye{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Ye(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 Je=Ye;const Qe={kind:"null"},Ke={kind:"number"},et={kind:"string"},tt={kind:"boolean"},it={kind:"color"},nt={kind:"object"},rt={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 ut=[Qe,Ke,et,tt,it,st,nt,lt(rt),at];function ht(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ht(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 ut)if(!ht(e,t))return null}return`Expected ${ct(e)} but found ${ct(t)} instead.`}function pt(e,t){return t.some((t=>t.kind===e.kind))}function dt(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}function ft(e){var t={exports:{}};return e(t,t.exports),t.exports}var mt=ft((function(e,t){var i={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 n(e){return(e=Math.round(e))<0?0:e>255?255:e}function r(e){return n("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function o(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function s(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{t.parseCSSColor=function(e){var t,a=e.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(t=parseInt(a.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===a.length&&(t=parseInt(a.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=o(h[1]),m=o(h[2]),g=m<=.5?m*(f+1):m+f-m*f,_=2*m-g;return[n(255*s(_,g,d+1/3)),n(255*s(_,g,d)),n(255*s(_,g,d-1/3)),p];default:return null}}return null}}catch(e){}}));class gt{constructor(e,t,i,n=1){this.r=e,this.g=t,this.b=i,this.a=n}static parse(e){if(!e)return;if(e instanceof gt)return e;if("string"!=typeof e)return;const t=mt.parseCSSColor(e);return t?new gt(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,n]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${n})`}toArray(){const{r:e,g:t,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*e/n,255*t/n,255*i/n,n]}toArray01(){const{r:e,g:t,b:i,a:n}=this;return 0===n?[0,0,0,0]:[e/n,t/n,i/n,n]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:n}=this;return[e,t,i,n]}}gt.black=new gt(0,0,0,1),gt.white=new gt(1,1,1,1),gt.transparent=new gt(0,0,0,0),gt.red=new gt(1,0,0,1),gt.blue=new gt(0,0,1,1);var _t=gt;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 vt{constructor(e,t,i,n,r){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r}}class xt{constructor(e){this.sections=e}static fromString(e){return new xt([new vt(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 xt?e:xt.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,n){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Mt(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 _t)return!0;if(e instanceof yt)return!0;if(e instanceof xt)return!0;if(e instanceof bt)return!0;if(Array.isArray(e)){for(const t of e)if(!Mt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Mt(e[t]))return!1;return!0}return!1}function Tt(e){if(null===e)return Qe;if("string"==typeof e)return et;if("boolean"==typeof e)return tt;if("number"==typeof e)return Ke;if(e instanceof _t)return it;if(e instanceof yt)return ot;if(e instanceof xt)return st;if(e instanceof bt)return at;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Tt(t);if(i){if(i===e)continue;i=rt;break}i=e}return lt(i||rt,t)}return nt}function St(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof _t||e instanceof xt||e instanceof bt?e.toString():JSON.stringify(e)}class Et{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(!Mt(e[1]))return t.error("invalid value");const i=e[1];let n=Tt(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Et(n,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 _t?["rgba"].concat(this.value.toArray()):this.value instanceof xt?this.value.serialize():this.value}}var At=Et,Ct=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const Lt={string:et,number:Ke,boolean:tt,object:nt};class It{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Lt)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Lt[i],n++}else r=rt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],n++}i=lt(r,o)}else i=Lt[r];const o=[];for(;n<e.length;n++){const i=t.parse(e[n],n,rt);if(!i)return null;o.push(i)}return new It(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!ht(this.type,Tt(i)))return i;if(t===this.args.length-1)throw new Ct(`Expected value to be of type ${ct(this.type)}, but found ${ct(Tt(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 n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n)}}return t.concat(this.args.map((e=>e.serialize())))}}var Pt=It;class Rt{constructor(e){this.type=st,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,lt(et)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,it),!s))return null;const a=n[n.length-1];a.scale=e,a.font=i,a.textColor=s}else{const o=t.parse(e[i],1,rt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null})}}return new Rt(n)}evaluate(e){return new xt(this.sections.map((t=>{const i=t.content.evaluate(e);return Tt(i)===at?new vt("",i,null,null,null):new vt(St(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):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 kt{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 kt(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 zt={"to-boolean":tt,"to-color":it,"to-number":Ke,"to-string":et};class Dt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=zt[i],r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],i,rt);if(!n)return null;r.push(n)}return new Dt(n,r)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const n of this.args){if(t=n.evaluate(e),i=null,t instanceof _t)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:wt(t[0],t[1],t[2],t[3]),!i))return new _t(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ct(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ct(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?xt.fromString(St(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?bt.fromString(St(this.args[0].evaluate(e))):St(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Rt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new kt(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Ot=Dt;const Ft=["Unknown","Point","LineString","Polygon"];var Bt=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?Ft[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:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=_t.parse(e)),t}};class Nt{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}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(e,t){const i=e[0],n=Nt.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let a=null;for(const[n,o]of s){a=new pi(t.registry,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t<e.length;t++){const i=e[t],r=Array.isArray(n)?n[t-1]:n.type,o=a.parse(i,1+s.length,r);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(n)&&n.length!==s.length)a.error(`Expected ${n.length} arguments, but found ${s.length} instead.`);else{for(let e=0;e<s.length;e++){const t=Array.isArray(n)?n[e]:n.type,i=s[e];a.concat(e+1).checkSubtype(t,i.type)}if(0===a.errors.length)return new Nt(i,r,o,s)}}if(1===s.length)t.errors.push(...a.errors);else{const i=(s.length?s:o).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(ct).join(", ")})`:`(${ct(t.type)}...)`;var t})).join(" | "),n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],1+n.length);if(!r)return null;n.push(ct(r.type))}t.error(`Expected arguments of type ${i}, but found (${n.join(", ")}) instead.`)}return null}static register(e,t){Nt.definitions=t;for(const i in t)e[i]=Nt}}var Ut=Nt;class jt{constructor(e,t,i){this.type=ot,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,tt);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,tt);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,et),!o)?null:new jt(n,r,o)}evaluate(e){return new yt(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Vt=8192;function Gt(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Ht(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Wt(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Vt),Math.round(n*r*Vt)]}function qt(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function $t(e,t){let i=!1;for(let s=0,a=t.length;s<a;s++){const a=t[s];for(let t=0,s=a.length;t<s-1;t++){if(qt(e,a[t],a[t+1]))return!1;(r=a[t])[1]>(n=e)[1]!=(o=a[t+1])[1]>n[1]&&n[0]<(o[0]-r[0])*(n[1]-r[1])/(o[1]-r[1])+r[0]&&(i=!i)}}var n,r,o;return i}function Zt(e,t){for(let i=0;i<t.length;i++)if($t(e,t[i]))return!0;return!1}function Xt(e,t,i,n){const r=n[0]-i[0],o=n[1]-i[1],s=(e[0]-i[0])*o-r*(e[1]-i[1]),a=(t[0]-i[0])*o-r*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Yt(e,t,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(a=[(s=c[i+1])[0]-(o=c[i])[0],s[1]-o[1]])[0]*(l=[(r=t)[0]-(n=e)[0],r[1]-n[1]])[1]-a[1]*l[0]&&Xt(n,r,o,s)&&Xt(o,s,n,r))return!0;var n,r,o,s,a,l;return!1}function Jt(e,t){for(let i=0;i<e.length;++i)if(!$t(e[i],t))return!1;for(let i=0;i<e.length-1;++i)if(Yt(e[i],e[i+1],t))return!1;return!0}function Qt(e,t){for(let i=0;i<t.length;i++)if(Jt(e,t[i]))return!0;return!1}function Kt(e,t,i){const n=[];for(let r=0;r<e.length;r++){const o=[];for(let n=0;n<e[r].length;n++){const s=Wt(e[r][n],i);Gt(t,s),o.push(s)}n.push(o)}return n}function ei(e,t,i){const n=[];for(let r=0;r<e.length;r++){const o=Kt(e[r],t,i);n.push(o)}return n}function ti(e,t,i,n){if(e[0]<i[0]||e[0]>i[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}Gt(t,e)}function ii(e,t,i,n){const r=Math.pow(2,n.z)*Vt,o=[n.x*Vt,n.y*Vt],s=[];if(!e)return s;for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];ti(n,t,i,r),s.push(n)}return s}function ni(e,t,i,n){const r=Math.pow(2,n.z)*Vt,o=[n.x*Vt,n.y*Vt],s=[];if(!e)return s;for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Gt(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)ti(n,t,i,r)}var a;return s}class ri{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(Mt(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 ri(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new ri(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new ri(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if(!r)return!1;if("Polygon"===t.type){const o=Kt(t.coordinates,n,r),s=ii(e.geometry(),i,n,r);if(!Ht(i,n))return!1;for(const e of s)if(!$t(e,o))return!1}if("MultiPolygon"===t.type){const o=ei(t.coordinates,n,r),s=ii(e.geometry(),i,n,r);if(!Ht(i,n))return!1;for(const e of s)if(!Zt(e,o))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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if(!r)return!1;if("Polygon"===t.type){const o=Kt(t.coordinates,n,r),s=ni(e.geometry(),i,n,r);if(!Ht(i,n))return!1;for(const e of s)if(!Jt(e,o))return!1}if("MultiPolygon"===t.type){const o=ei(t.coordinates,n,r),s=ni(e.geometry(),i,n,r);if(!Ht(i,n))return!1;for(const e of s)if(!Qt(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var oi=ri;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 ui=ci;class hi{constructor(e,t=[],i,n=new Je,r=[]){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Pt(t,[e]):"coerce"===i?new Ot(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof At)&&"resolvedImage"!==n.type.kind&&di(n)){const t=new Bt;try{n=new At(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new hi(this.registry,n,t||null,r,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=ht(e,t);return i&&this.error(i),i}}var pi=hi;function di(e){if(e instanceof ui)return di(e.boundExpression);if(e instanceof Ut&&"error"===e.name)return!1;if(e instanceof jt)return!1;if(e instanceof oi)return!1;const t=e instanceof Ot||e instanceof Pt;let i=!0;return e.eachChild((e=>{i=t?i&&di(e):i&&e instanceof At})),!!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 n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||t<r)return a;o=a+1}else{if(!(n>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(e,t){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.");const i=t.parse(e[1],1,Ke);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],s=e[i+1],a=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(n.length&&n[n.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new mi(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[fi(t,n)].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 e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var gi=mi;function _i(e,t,i){return e*(1-i)+t*i}var yi=Object.freeze({__proto__:null,number:_i,color:function(e,t,i){return new _t(_i(e.r,t.r,i),_i(e.g,t.g,i),_i(e.b,t.b,i),_i(e.a,t.a,i))},array:function(e,t,i){return e.map(((e,n)=>_i(e,t[n],i)))}});const vi=.95047,xi=1.08883,bi=4/29,wi=6/29,Mi=3*wi*wi,Ti=Math.PI/180,Si=180/Math.PI;function Ei(e){return e>.008856451679035631?Math.pow(e,1/3):e/Mi+bi}function Ai(e){return e>wi?e*e*e:Mi*(e-bi)}function Ci(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Li(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ii(e){const t=Li(e.r),i=Li(e.g),n=Li(e.b),r=Ei((.4124564*t+.3575761*i+.1804375*n)/vi),o=Ei((.2126729*t+.7151522*i+.072175*n)/1);return{l:116*o-16,a:500*(r-o),b:200*(o-Ei((.0193339*t+.119192*i+.9503041*n)/xi)),alpha:e.a}}function Pi(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Ai(t),i=vi*Ai(i),n=xi*Ai(n),new _t(Ci(3.2404542*i-1.5371385*t-.4985314*n),Ci(-.969266*i+1.8760108*t+.041556*n),Ci(.0556434*i-.2040259*t+1.0572252*n),e.alpha)}function Ri(e,t,i){const n=t-e;return e+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const ki={forward:Ii,reverse:Pi,interpolate:function(e,t,i){return{l:_i(e.l,t.l,i),a:_i(e.a,t.a,i),b:_i(e.b,t.b,i),alpha:_i(e.alpha,t.alpha,i)}}},zi={forward:function(e){const{l:t,a:i,b:n}=Ii(e),r=Math.atan2(n,i)*Si;return{h:r<0?r+360:r,c:Math.sqrt(i*i+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Ti,i=e.c;return Pi({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Ri(e.h,t.h,i),c:_i(e.c,t.c,i),l:_i(e.l,t.l,i),alpha:_i(e.alpha,t.alpha,i)}}};var Di=Object.freeze({__proto__:null,lab:ki,hcl:zi});class Oi{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let o=0;if("exponential"===e.name)o=Fi(t,e.base,n,r);else if("linear"===e.name)o=Fi(t,1,n,r);else if("cubic-bezier"===e.name){const s=e.controlPoints;o=new i(s[0],s[1],s[2],s[3]).solve(Fi(t,1,n,r))}return o}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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(r=t.parse(r,2,Ke),!r)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],n=o[e+1],r=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.',r);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.',r);const c=t.parse(n,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 Oi(a,i,n,r,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 n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=fi(t,n),s=Oi.interpolationFactor(this.interpolation,n,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?zi.reverse(zi.interpolate(zi.forward(a),zi.forward(l),s)):ki.reverse(ki.interpolate(ki.forward(a),ki.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 Fi(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}var Bi=Oi;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 n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}const o=n&&r.some((e=>ht(n,e.type)));return new Ni(o?rt:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(e),i&&i instanceof bt&&!i.available&&(t||(t=i),i=null,n===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 e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Ui=Ni;class ji{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let n=1;n<e.length-1;n+=2){const r=e[n];if("string"!=typeof r)return t.error(`Expected string, but found ${typeof r} instead.`,n);if(/[^a-zA-Z0-9_]/.test(r))return t.error("Variable names must contain only alphanumeric characters or '_'.",n);const o=t.parse(e[n+1],n+1);if(!o)return null;i.push([r,o])}const n=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return n?new ji(i,n):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}var Vi=ji;class Gi{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ke),n=t.parse(e[2],2,lt(t.expectedType||rt));return i&&n?new Gi(n.type.itemType,i,n):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 Hi=Gi;class Wi{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,rt),n=t.parse(e[2],2,rt);return i&&n?pt(i.type,[tt,et,Ke,Qe,rt])?new Wi(i,n):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(Tt(t))} instead.`);if(!dt(i,["string","array"]))throw new Ct(`Expected second argument to be of type array or string, but found ${ct(Tt(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=Wi;class $i{constructor(e,t,i){this.type=Ke,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,rt),n=t.parse(e[2],2,rt);if(!i||!n)return null;if(!pt(i.type,[tt,et,Ke,Qe,rt]))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 r=t.parse(e[3],3,Ke);return r?new $i(i,n,r):null}return new $i(i,n)}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(Tt(t))} instead.`);if(!dt(i,["string","array"]))throw new Ct(`Expected second argument to be of type array or string, but found ${ct(Tt(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return i.indexOf(t,n)}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 Zi=$i;class Xi{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Tt(e)))return null}else i=Tt(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,rt);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new Xi(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Tt(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=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const r=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of i)e.push(1===n.length?r(n[0]):n.map(r)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var Yi=Xi;class Ji{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n=[];for(let r=1;r<e.length-1;r+=2){const o=t.parse(e[r],r,tt);if(!o)return null;const s=t.parse(e[r+1],r+1,i);if(!s)return null;n.push([o,s]),i=i||s.type}const r=t.parse(e[e.length-1],e.length-1,i);return r?new Ji(i,n,r):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 e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Qi=Ji;class Ki{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}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,rt),n=t.parse(e[2],2,Ke);if(!i||!n)return null;if(!pt(i.type,[lt(rt),et,rt]))return t.error(`Expected first argument to be of type array or string, but found ${ct(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,Ke);return r?new Ki(i.type,i,n,r):null}return new Ki(i.type,i,n)}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(Tt(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(i,n)}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 en=Ki;function tn(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 nn(e,t,i,n){return 0===n.compare(t,i)}function rn(e,t,i){const n="=="!==e&&"!="!==e;return class r{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 o=t.parse(e[1],1,rt);if(!o)return null;if(!tn(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${ct(o.type)}'.`);let s=t.parse(e[2],2,rt);if(!s)return null;if(!tn(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${ct(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${ct(o.type)}' and '${ct(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Pt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Pt(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,ot),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Tt(o),i=Tt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ct(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Tt(o),i=Tt(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const on=rn("==",(function(e,t,i){return t===i}),nn),sn=rn("!=",(function(e,t,i){return t!==i}),(function(e,t,i,n){return!nn(0,t,i,n)})),an=rn("<",(function(e,t,i){return t<i}),(function(e,t,i,n){return n.compare(t,i)<0})),ln=rn(">",(function(e,t,i){return t>i}),(function(e,t,i,n){return n.compare(t,i)>0})),cn=rn("<=",(function(e,t,i){return t<=i}),(function(e,t,i,n){return n.compare(t,i)<=0})),un=rn(">=",(function(e,t,i){return t>=i}),(function(e,t,i,n){return n.compare(t,i)>=0}));class hn{constructor(e,t,i,n,r){this.type=et,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Ke);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,et),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,et),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,Ke),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,Ke),!a)?null:new hn(i,r,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 pn{constructor(e){this.type=Ke,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 pn(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(Tt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}const dn={"==":on,"!=":sn,">":ln,"<":an,">=":un,"<=":cn,array:Pt,at:Hi,boolean:Pt,case:Qi,coalesce:Ui,collator:jt,format:Rt,image:kt,in:qi,"index-of":Zi,interpolate:Bi,"interpolate-hcl":Bi,"interpolate-lab":Bi,length:pn,let:Vi,literal:At,match:Yi,number:Pt,"number-format":hn,object:Pt,slice:en,step:gi,string:Pt,"to-boolean":Ot,"to-color":Ot,"to-number":Ot,"to-string":Ot,var:ui,within:oi};function fn(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const o=r?r.evaluate(e):1,s=wt(t,i,n,o);if(s)throw new Ct(s);return new _t(t/255*o,i/255*o,n/255*o,o)}function mn(e,t){return e in t}function gn(e,t){const i=t[e];return void 0===i?null:i}function _n(e){return{type:e}}Ut.register(dn,{error:[{kind:"error"},[et],(e,[t])=>{throw new Ct(t.evaluate(e))}],typeof:[et,[rt],(e,[t])=>ct(Tt(t.evaluate(e)))],"to-rgba":[lt(Ke,4),[it],(e,[t])=>t.evaluate(e).toArray()],rgb:[it,[Ke,Ke,Ke],fn],rgba:[it,[Ke,Ke,Ke,Ke],fn],has:{type:tt,overloads:[[[et],(e,[t])=>mn(t.evaluate(e),e.properties())],[[et,nt],(e,[t,i])=>mn(t.evaluate(e),i.evaluate(e))]]},get:{type:rt,overloads:[[[et],(e,[t])=>gn(t.evaluate(e),e.properties())],[[et,nt],(e,[t,i])=>gn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[rt,[et],(e,[t])=>gn(t.evaluate(e),e.featureState||{})],properties:[nt,[],e=>e.properties()],"geometry-type":[et,[],e=>e.geometryType()],id:[rt,[],e=>e.id()],zoom:[Ke,[],e=>e.globals.zoom],pitch:[Ke,[],e=>e.globals.pitch||0],"distance-from-center":[Ke,[],e=>e.distanceFromCenter()],"heatmap-density":[Ke,[],e=>e.globals.heatmapDensity||0],"line-progress":[Ke,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[Ke,[],e=>e.globals.skyRadialProgress||0],accumulated:[rt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Ke,_n(Ke),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[Ke,_n(Ke),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:Ke,overloads:[[[Ke,Ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Ke],(e,[t])=>-t.evaluate(e)]]},"/":[Ke,[Ke,Ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Ke,[Ke,Ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Ke,[],()=>Math.LN2],pi:[Ke,[],()=>Math.PI],e:[Ke,[],()=>Math.E],"^":[Ke,[Ke,Ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Ke,[Ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Ke,[Ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Ke,[Ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[Ke,[Ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Ke,[Ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Ke,[Ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Ke,[Ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Ke,[Ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Ke,[Ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Ke,[Ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[Ke,_n(Ke),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Ke,_n(Ke),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Ke,[Ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[Ke,[Ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ke,[Ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Ke,[Ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[tt,[et,rt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[tt,[rt],(e,[t])=>e.id()===t.value],"filter-type-==":[tt,[et],(e,[t])=>e.geometryType()===t.value],"filter-<":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<r}],"filter-id-<":[tt,[rt],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<n}],"filter->":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[tt,[rt],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[tt,[rt],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[tt,[rt],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[tt,[rt],(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(rt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[tt,[et,lt(rt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[tt,[et,lt(rt)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+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)],[_n(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)],[_n(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,_n(rt),(e,t)=>t.map((t=>St(t.evaluate(e)))).join("")],"resolved-locale":[et,[ot],(e,[t])=>t.evaluate(e).resolvedLocale()]});var yn=dn;function vn(e){return{result:"success",value:e}}function xn(e){return{result:"error",value:e}}function bn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function wn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Mn(e){return!!e.expression&&e.expression.interpolated}function Tn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Sn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function En(e){return e}function An(e,t){const i="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],r=n||!(n||void 0!==e.property),o=e.type||(Mn(t)?"exponential":"interval");if(i&&((e=We({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],_t.parse(e[1])]))),e.default=_t.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Di[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=Pn;else if("interval"===o)s=In;else if("categorical"===o){s=Ln,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=Rn}if(n){const i={},n=[];for(let t=0;t<e.stops.length;t++){const r=e.stops[t],o=r[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},n.push(o)),i[o].stops.push([r[0].value,r[1]])}const r=[];for(const e of n)r.push([i[e].zoom,An(i[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:Bi.interpolationFactor.bind(void 0,o),zoomStops:r.map((e=>e[0])),evaluate:({zoom:i},n)=>Pn({stops:r,base:e.base},t,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Bi.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?Cn(e.default,t.default):s(e,t,r,a,l)}}}function Cn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Ln(e,t,i,n,r){return Cn(typeof i===r?n[i]:void 0,e.default,t.default)}function In(e,t,i){if("number"!==Tn(i))return Cn(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const r=fi(e.stops.map((e=>e[0])),i);return e.stops[r][1]}function Pn(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Tn(i))return Cn(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 o=fi(e.stops.map((e=>e[0])),i),s=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=yi[t.type]||En;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Di[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),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 Rn(e,t,i){return"color"===t.type?i=_t.parse(i):"formatted"===t.type?i=xt.fromString(i.toString()):"resolvedImage"===t.type?i=bt.fromString(i.toString()):Tn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Cn(i,e.default,t.default)}class kn{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Bt,this._defaultValue=t?function(e){return"color"===e.type&&(Sn(e.default)||Array.isArray(e.default))?new _t(0,0,0,0):"color"===e.type?_t.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,n,r,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||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 zn(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in yn}function Dn(e,t){const i=new pi(yn,[],t?function(e){const t={color:it,string:et,number:Ke,enum:et,boolean:tt,formatted:st,resolvedImage:at};return"array"===e.type?lt(t[e.value]||rt,e.length):t[e.type]}(t):void 0),n=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?vn(new kn(n,t)):xn(i.errors)}class On{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!ai(t.expression)}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}}class Fn{constructor(e,t,i,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!ai(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?Bi.interpolationFactor(this.interpolationType,e,t,i):0}}function Bn(e,t){if("error"===(e=Dn(e,t)).result)return e;const i=e.value.expression,n=si(i);if(!n&&!bn(t))return xn([new Xe("","data expressions not supported")]);const r=li(i,["zoom","pitch","distance-from-center"]);if(!r&&!wn(t))return xn([new Xe("","zoom expressions not supported")]);const o=Un(i);return o||r?o instanceof Xe?xn([o]):o instanceof Bi&&!Mn(t)?xn([new Xe("",'"interpolate" expressions cannot be used with this property')]):vn(o?new Fn(n?"camera":"composite",e.value,o.labels,o instanceof Bi?o.interpolation:void 0):new On(n?"constant":"source",e.value)):xn([new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Nn{constructor(e,t){this._parameters=e,this._specification=t,We(this,An(this._parameters,this._specification))}static deserialize(e){return new Nn(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Un(e){let t=null;if(e instanceof Vi)t=Un(e.result);else if(e instanceof Ui){for(const i of e.args)if(t=Un(i),t)break}else(e instanceof gi||e instanceof Bi)&&e.input instanceof Ut&&"zoom"===e.input.name&&(t=e);return t instanceof Xe||e.eachChild((e=>{const i=Un(e);i instanceof Xe?t=i:!t&&i?t=new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Xe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}class jn{constructor(e,t,i,n){this.message=(e?`${e}: `:"")+i,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__)}}function Vn(e){const t=e.key,i=e.value,n=e.valueSpec||{},r=e.objectElementValidators||{},o=e.style,s=e.styleSpec;let a=[];const l=Tn(i);if("object"!==l)return[new jn(t,i,`object expected, ${l} found`)];for(const e in i){const l=e.split(".")[0],c=n[l]||n["*"];let u;r[l]?u=r[l]:n[l]?u=br:r["*"]?u=r["*"]:n["*"]&&(u=br),u?a=a.concat(u({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:c,style:o,styleSpec:s,object:i,objectKey:e},i)):a.push(new jn(t,i[e],`unknown property "${e}"`))}for(const e in n)r[e]||n[e].required&&void 0===n[e].default&&void 0===i[e]&&a.push(new jn(t,i,`missing required property "${e}"`));return a}function Gn(e){const t=e.value,i=e.valueSpec,n=e.style,r=e.styleSpec,o=e.key,s=e.arrayElementValidator||br;if("array"!==Tn(t))return[new jn(o,t,`array expected, ${Tn(t)} found`)];if(i.length&&t.length!==i.length)return[new jn(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new jn(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};r.$version<7&&(a.function=i.function),"object"===Tn(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:n,styleSpec:r,key:`${o}[${e}]`}));return l}function Hn(e){const t=e.key,i=e.value,n=e.valueSpec;let r=Tn(i);if("number"===r&&i!=i&&(r="NaN"),"number"!==r)return[new jn(t,i,`number expected, ${r} found`)];if("minimum"in n){let r=n.minimum;if("array"===Tn(n.minimum)&&(r=n.minimum[e.arrayIndex]),i<r)return[new jn(t,i,`${i} is less than the minimum value ${r}`)]}if("maximum"in n){let r=n.maximum;if("array"===Tn(n.maximum)&&(r=n.maximum[e.arrayIndex]),i>r)return[new jn(t,i,`${i} is greater than the maximum value ${r}`)]}return[]}function Wn(e){const t=e.valueSpec,i=qe(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Tn(e.value.stops)&&"array"===Tn(e.value.stops[0])&&"object"===Tn(e.value.stops[0][0]),u=Vn({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new jn(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Gn({key:e.key,value:n,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Tn(n)&&0===n.length&&t.push(new jn(e.key,n,"array must have at least one stop")),t},default:function(e){return br({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new jn(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new jn(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Mn(e.valueSpec)&&u.push(new jn(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!bn(e.valueSpec)?u.push(new jn(e.key,e.value,"property functions not supported")):a&&!wn(e.valueSpec)&&u.push(new jn(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new jn(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Tn(n))return[new jn(a,n,`array expected, ${Tn(n)} found`)];if(2!==n.length)return[new jn(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Tn(n[0]))return[new jn(a,n,`object expected, ${Tn(n[0])} found`)];if(void 0===n[0].zoom)return[new jn(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new jn(a,n,"object stop key must have value")];const t=qe(n[0].zoom);if("number"!=typeof t)return[new jn(a,n[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new jn(a,n[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,r=void 0,s={}),i=i.concat(Vn({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Hn,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:n[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},n));return zn($e(n[1]))?i.concat([new jn(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(br({key:`${a}[1]`,value:n[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function p(e,o){const a=Tn(e.value),l=qe(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new jn(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new jn(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return bn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jn(e.key,c,n)]}return"categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof r&&void 0!==r&&l<r?[new jn(e.key,c,"stop domain values must appear in ascending order")]:(r=l,"categorical"===i&&l in s?[new jn(e.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new jn(e.key,c,`integer expected, found ${String(l)}`)]}}function qn(e){const t=("property"===e.expressionContext?Bn:Dn)($e(e.value),e.valueSpec);if("error"===t.result)return t.value.map((t=>new jn(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new jn(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!ai(i))return[new jn(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return $n(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!li(i,["zoom","feature-state"]))return[new jn(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!si(i))return[new jn(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $n(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 n=[];return e instanceof Ut&&i.has(e.name)?[new jn(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=>{n.push(...$n(e,t))})),n)}function Zn(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(qe(i))&&r.push(new jn(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(qe(i))&&r.push(new jn(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Xn(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(!Xn(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Yn(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Xn(e)||(e=nr(e));const i=e;let n=!0;try{n=function(e){if(!Kn(e))return e;let t=$e(e);return Qn(t),t=Jn(t),t}(i)}catch(e){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(i,null,2)}\n `)}const r=He[`filter_${t}`],o=Dn(n,r);let s=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(e,t,i)=>o.value.evaluate(e,t,{},i);let a=null,l=null;if(n!==i){const e=Dn(i,r);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(t,i,n,r,o)=>e.value.evaluate(t,i,{},n,void 0,void 0,r,o),l=!si(e.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:ir(n),needFeature:!!l}}function Jn(e){if(!Array.isArray(e))return e;const t=function(e){if(er.has(e[0]))for(let t=1;t<e.length;t++)if(Kn(e[t]))return!0;return e}(e);return!0===t?t:t.map((e=>Jn(e)))}function Qn(e){let t=!1;const i=[];if("case"===e[0]){for(let n=1;n<e.length-1;n+=2)t=t||Kn(e[n]),i.push(e[n+1]);i.push(e[e.length-1])}else if("match"===e[0]){t=t||Kn(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e[e.length-1])}else if("step"===e[0]){t=t||Kn(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1])}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)Qn(e[t])}function Kn(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t<e.length;t++)if(Kn(e[t]))return!0;return!1}const er=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function tr(e,t){return e<t?-1:e>t?1:0}function ir(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t<e.length;t++)if(ir(e[t]))return!0;return!1}function nr(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?rr(e[1],e[2],"=="):"!="===t?ar(rr(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?rr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(nr))):"all"===t?["all"].concat(e.slice(1).map(nr)):"none"===t?["all"].concat(e.slice(1).map(nr).map(ar)):"in"===t?or(e[1],e.slice(2)):"!in"===t?ar(or(e[1],e.slice(2))):"has"===t?sr(e[1]):"!has"===t?ar(sr(e[1])):"within"!==t||e;var i}function rr(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 or(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(tr)]]:["filter-in-small",e,["literal",t]]}}function sr(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function ar(e){return["!",e]}function lr(e){return Xn($e(e.value))?qn(We({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):cr(e)}function cr(e){const t=e.value,i=e.key;if("array"!==Tn(t))return[new jn(i,t,`array expected, ${Tn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new jn(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Zn({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),qe(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===qe(t[1])&&o.push(new jn(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new jn(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Tn(t[1]),"string"!==r&&o.push(new jn(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s<t.length;s++)r=Tn(t[s]),"$type"===qe(t[1])?o=o.concat(Zn({key:`${i}[${s}]`,value:t[s],valueSpec:n.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==r&&"number"!==r&&"boolean"!==r&&o.push(new jn(`${i}[${s}]`,t[s],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let n=1;n<t.length;n++)o=o.concat(cr({key:`${i}[${n}]`,value:t[n],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":r=Tn(t[1]),2!==t.length?o.push(new jn(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==r&&o.push(new jn(`${i}[1]`,t[1],`string expected, ${r} found`));break;case"within":r=Tn(t[1]),2!==t.length?o.push(new jn(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"object"!==r&&o.push(new jn(`${i}[1]`,t[1],`object expected, ${r} found`))}return o}function ur(e,t){const i=e.key,n=e.style,r=e.styleSpec,o=e.value,s=e.objectKey,a=r[`${t}_${e.layerType}`];if(!a)return[];const l=s.match(/^(.*)-transition$/);if("paint"===t&&l&&a[l[1]]&&a[l[1]].transition)return br({key:i,value:o,valueSpec:r.transition,style:n,styleSpec:r});const c=e.valueSpec||a[s];if(!c)return[new jn(i,o,`unknown property "${s}"`)];let u;if("string"===Tn(o)&&bn(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new jn(i,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const h=[];return"symbol"===e.layerType&&("text-field"===s&&n&&!n.glyphs&&h.push(new jn(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===s&&Sn($e(o))&&"identity"===qe(o.type)&&h.push(new jn(i,o,'"text-font" does not support identity functions'))),h.concat(br({key:e.key,value:o,valueSpec:c,style:n,styleSpec:r,expressionContext:"property",propertyType:t,propertyKey:s}))}function hr(e){return ur(e,"paint")}function pr(e){return ur(e,"layout")}function dr(e){let t=[];const i=e.value,n=e.key,r=e.style,o=e.styleSpec;i.type||i.ref||t.push(new jn(n,i,'either "type" or "ref" is required'));let s=qe(i.type);const a=qe(i.ref);if(i.id){const o=qe(i.id);for(let s=0;s<e.arrayIndex;s++){const e=r.layers[s];qe(e.id)===o&&t.push(new jn(n,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in i&&t.push(new jn(n,i[e],`"${e}" is prohibited for ref layers`))})),r.layers.forEach((t=>{qe(t.id)===a&&(e=t)})),e?e.ref?t.push(new jn(n,i.ref,"ref cannot reference another ref layer")):s=qe(e.type):"string"==typeof a&&t.push(new jn(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&qe(e.type);e?"vector"===o&&"raster"===s?t.push(new jn(n,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?t.push(new jn(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?t.push(new jn(n,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new jn(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new jn(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new jn(n,i.source,`source "${i.source}" not found`))}else t.push(new jn(n,i,'missing required property "source"'));return t=t.concat(Vn({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>br({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>lr(We({layerType:s},e)),layout:e=>Vn({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>pr(We({layerType:s},e))}}),paint:e=>Vn({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>hr(We({layerType:s},e))}})}})),t}function fr(e){const t=e.value,i=e.key,n=Tn(t);return"string"!==n?[new jn(i,t,`string expected, ${n} found`)]:[]}const mr={promoteId:function({key:e,value:t}){if("string"===Tn(t))return fr({key:e,value:t});{const i=[];for(const n in t)i.push(...fr({key:`${e}.${n}`,value:t[n]}));return i}}};function gr(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style;if(!t.type)return[new jn(i,t,'"type" is required')];const o=qe(t.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=Vn({key:i,value:t,valueSpec:n[`source_${o.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:mr}),s;case"geojson":if(s=Vn({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,objectElementValidators:mr}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;s.push(...qn({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),s.push(...qn({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return Vn({key:i,value:t,valueSpec:n.source_video,style:r,styleSpec:n});case"image":return Vn({key:i,value:t,valueSpec:n.source_image,style:r,styleSpec:n});case"canvas":return[new jn(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Zn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:r,styleSpec:n})}}function _r(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Tn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new jn("light",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?br({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):n[e]?br({key:e,value:t[e],valueSpec:n[e],style:r,styleSpec:i}):[new jn(e,t[e],`unknown property "${e}"`)])}return o}function yr(e){const t=e.value,i=e.key,n=e.style,r=e.styleSpec,o=r.terrain;let s=[];const a=Tn(t);if(void 0===t)return s;if("object"!==a)return s=s.concat([new jn("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?br({key:e,value:t[e],valueSpec:r.transition,style:n,styleSpec:r}):o[e]?br({key:e,value:t[e],valueSpec:o[e],style:n,styleSpec:r}):[new jn(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=n.sources&&n.sources[t.source],r=e&&qe(e.type);e?"raster-dem"!==r&&s.push(new jn(i,t.source,`terrain cannot be used with a source of type ${String(r)}, it only be used with a "raster-dem" source type`)):s.push(new jn(i,t.source,`source "${t.source}" not found`))}else s.push(new jn(i,t,'terrain is missing required property "source"'));return s}function vr(e){const t=e.value,i=e.style,n=e.styleSpec,r=n.fog;let o=[];const s=Tn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new jn("fog",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?br({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):r[e]?br({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}):[new jn(e,t[e],`unknown property "${e}"`)])}return o}const xr={"*":()=>[],array:Gn,boolean:function(e){const t=e.value,i=e.key,n=Tn(t);return"boolean"!==n?[new jn(i,t,`boolean expected, ${n} found`)]:[]},number:Hn,color:function(e){const t=e.key,i=e.value,n=Tn(i);return"string"!==n?[new jn(t,i,`color expected, ${n} found`)]:null===mt.parseCSSColor(i)?[new jn(t,i,`color expected, "${i}" found`)]:[]},enum:Zn,filter:lr,function:Wn,layer:dr,object:Vn,source:gr,light:_r,terrain:yr,fog:vr,string:fr,formatted:function(e){return 0===fr(e).length?[]:qn(e)},resolvedImage:function(e){return 0===fr(e).length?[]:qn(e)},projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style;let o=[];const s=Tn(t);if("object"===s)for(const e in t)o=o.concat(br({key:e,value:t[e],valueSpec:n[e],style:r,styleSpec:i}));else"string"!==s&&(o=o.concat([new jn("projection",t,`object or string expected, ${s} found`)]));return o}};function br(e){const t=e.value,i=e.valueSpec,n=e.styleSpec;return i.expression&&Sn(qe(t))?Wn(e):i.expression&&zn($e(t))?qn(e):i.type&&xr[i.type]?xr[i.type](e):Vn(We({},e,{valueSpec:i.type?n[i.type]:i}))}function wr(e){const t=e.value,i=e.key,n=fr(e);return n.length||(-1===t.indexOf("{fontstack}")&&n.push(new jn(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&n.push(new jn(i,t,'"glyphs" url must include a "{range}" token'))),n}function Mr(e,t=He){return Er(br({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:wr,"*":()=>[]}}))}const Tr=e=>Er(hr(e)),Sr=e=>Er(pr(e));function Er(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Ar(e,t){let i=!1;if(t&&t.length)for(const n of t)e.fire(new Ve(new Error(n.message))),i=!0;return i}var Cr=Lr;function Lr(e,t,i){var n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(var o=0;o<this.d*this.d;o++){var s=r[3+o],a=r[3+o+1];n.push(s===a?null:r.subarray(s,a))}var l=r[3+n.length+1];this.keys=r.subarray(r[3+n.length],l),this.bboxes=r.subarray(l),this.insert=this._insertReadonly}else{this.d=t+2*i;for(var c=0;c<this.d*this.d;c++)n.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;var u=i/t*e;this.min=-u,this.max=e+u}Lr.prototype.insert=function(e,t,i,n,r){this._forEachCell(t,i,n,r,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(r)},Lr.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Lr.prototype._insertCell=function(e,t,i,n,r,o){this.cells[r].push(o)},Lr.prototype.query=function(e,t,i,n,r){var o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=n&&!r)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(e,t,i,n,this._queryCell,a,{},r),a},Lr.prototype._queryCell=function(e,t,i,n,r,o,s,a){var l=this.cells[r];if(null!==l)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===s[p]){var d=4*p;(a?a(u[d+0],u[d+1],u[d+2],u[d+3]):e<=u[d+2]&&t<=u[d+3]&&i>=u[d+0]&&n>=u[d+1])?(s[p]=!0,o.push(c[p])):s[p]=!1}}},Lr.prototype._forEachCell=function(e,t,i,n,r,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&r.call(this,e,t,i,n,f,o,s,a))return}},Lr.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Lr.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Lr.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,i=0,n=0;n<this.cells.length;n++)i+=this.cells[n].length;var r=new Int32Array(t+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;for(var o=t,s=0;s<e.length;s++){var a=e[s];r[3+s]=o,r.set(a,o),o+=a.length}return r[3+e.length]=o,r.set(this.keys,o),r[3+e.length+1]=o+=this.keys.length,r.set(this.bboxes,o),o+=this.bboxes.length,r.buffer};const Ir={};function Pr(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Ir[t]={klass:e,omit:i.omit||[]}}Pr(Object,"Object"),Cr.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}},Cr.deserialize=function(e){return new Cr(e.buffer)},Object.defineProperty(Cr,"name",{value:"Grid"}),Pr(Cr,"Grid"),Pr(_t,"Color"),Pr(Error,"Error"),Pr(Ce,"AJAXError"),Pr(bt,"ResolvedImage"),Pr(Nn,"StylePropertyFunction"),Pr(kn,"StyleExpression",{omit:["_evaluator"]}),Pr(Fn,"ZoomDependentExpression"),Pr(On,"ZoomConstantExpression"),Pr(Ut,"CompoundExpression",{omit:["_evaluate"]});for(const e in yn)Ir[yn[e]._classRegistryKey]||Pr(yn[e],`Expression${e}`);function Rr(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function kr(e){return t.ImageBitmap&&e instanceof t.ImageBitmap}function zr(e,i){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(Rr(e)||kr(e))return i&&i.push(e),e;if(ArrayBuffer.isView(e)){const t=e;return i&&i.push(t.buffer),t}if(e instanceof t.ImageData)return i&&i.push(e.data.buffer),e;if(Array.isArray(e)){const t=[];for(const n of e)t.push(zr(n,i));return t}if("object"==typeof e){const t=e.constructor,n=t._classRegistryKey;if(!n)throw new Error(`can't serialize object of unregistered class ${n}`);const r=t.serialize?t.serialize(e,i):{};if(!t.serialize){for(const t in e)e.hasOwnProperty(t)&&(Ir[n].omit.indexOf(t)>=0||(r[t]=zr(e[t],i)));e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof e)}function Dr(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||Rr(e)||kr(e)||ArrayBuffer.isView(e)||e instanceof t.ImageData)return e;if(Array.isArray(e))return e.map(Dr);if("object"==typeof e){const t=e.$name||"Object",{klass:i}=Ir[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(n[t]=Dr(e[t]));return n}throw new Error("can't deserialize object of type "+typeof e)}class Or{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 Fr=e=>e>=1536&&e<=1791,Br=e=>e>=1872&&e<=1919,Nr=e=>e>=2208&&e<=2303,Ur=e=>e>=11904&&e<=12031,jr=e=>e>=12032&&e<=12255,Vr=e=>e>=12272&&e<=12287,Gr=e=>e>=12288&&e<=12351,Hr=e=>e>=12352&&e<=12447,Wr=e=>e>=12448&&e<=12543,qr=e=>e>=12544&&e<=12591,$r=e=>e>=12704&&e<=12735,Zr=e=>e>=12736&&e<=12783,Xr=e=>e>=12784&&e<=12799,Yr=e=>e>=12800&&e<=13055,Jr=e=>e>=13056&&e<=13311,Qr=e=>e>=13312&&e<=19903,Kr=e=>e>=19968&&e<=40959,eo=e=>e>=40960&&e<=42127,to=e=>e>=42128&&e<=42191,io=e=>e>=44032&&e<=55215,no=e=>e>=63744&&e<=64255,ro=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 uo(e){for(const t of e)if(fo(t.charCodeAt(0)))return!0;return!1}function ho(e){for(const t of e)if(!po(t.charCodeAt(0)))return!1;return!0}function po(e){return!(Fr(e)||Br(e)||Nr(e)||ro(e)||lo(e))}function fo(e){return!(746!==e&&747!==e&&(e<4352||!($r(e)||qr(e)||so(e)&&!(e>=65097&&e<=65103)||no(e)||Jr(e)||Ur(e)||Zr(e)||!(!Gr(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Qr(e)||Kr(e)||Yr(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)||Hr(e)||Vr(e)||(e=>e>=12688&&e<=12703)(e)||jr(e)||Xr(e)||Wr(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)||Gr(e)||Wr(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 go(e){return e>=1424&&e<=2303||ro(e)||lo(e)}function _o(e,t){return!(!t&&go(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function yo(e){for(const t of e)if(go(t.charCodeAt(0)))return!0;return!1}const vo="deferred",xo="loading",bo="loaded";let wo=null,Mo="unavailable",To=null;const So=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Mo="error"),wo&&wo(e)};function Eo(){Ao.fire(new je("pluginStateChange",{pluginStatus:Mo,pluginURL:To}))}const Ao=new Ge,Co=function(){return Mo},Lo=function(){if(Mo!==vo||!To)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Mo=xo,Eo(),To&&Pe({url:To},(e=>{e?So(e):(Mo=bo,Eo())}))},Io={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Mo===bo||null!=Io.applyArabicShaping,isLoading:()=>Mo===xo,setState(e){Mo=e.pluginStatus,To=e.pluginURL},isParsed:()=>null!=Io.applyArabicShaping&&null!=Io.processBidirectionalText&&null!=Io.processStyledBidirectionalText,getPluginURL:()=>To};class Po{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 Or,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!_o(i.charCodeAt(0),t))return!1;return!0}(e,Io.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 Ro{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Sn(e))return new Nn(e,t);if(zn(e)){const i=Bn(e,t);if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return i.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=_t.parse(e)),{kind:"constant",evaluate:()=>i}}}(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 ko{constructor(e){this.property=e,this.value=new Ro(e,void 0)}transitioned(e,t){return new Do(this.property,this.value,t,v({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class zo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return L(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ko(this._values[e].property)),this._values[e].value=new Ro(this._values[e].property,null===t?void 0:L(t))}getTransition(e){return L(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ko(this._values[e].property)),this._values[e].transition=L(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 n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n)}return e}transitioned(e,t){const i=new Oo(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Oo(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,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=e,this.value=t,this.begin=r+o,this.end=this.begin+s,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),r,h(s))}}return r}}class Oo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const n=new No(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].possiblyEvaluate(e,t,i);return n}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Fo{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return L(this._values[e].value)}setValue(e,t){this._values[e]=new Ro(this._values[e].property,null===t?void 0:L(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 n=new No(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].possiblyEvaluate(e,t,i);return n}}class Bo{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,n){return this.property.evaluate(this.value,this.parameters,e,t,i,n)}}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 n=yi[this.specification.type];return n?n(e,t,i):e}}class jo{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,n){return new Bo(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,n)}: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 Bo(this,{kind:"constant",value:void 0},e.parameters);const n=yi[this.specification.type];return n?new Bo(this,{kind:"constant",value:n(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,n,r,o){return"constant"===e.kind?e.value:e.evaluate(t,i,n,r,o)}}class Vo extends jo{possiblyEvaluate(e,t,i,n){if(void 0===e.value)return new Bo(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n),o="resolvedImage"===e.property.specification.type&&"string"!=typeof r?r.name:r,s=this._calculate(o,o,o,t);return new Bo(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 Bo(this,{kind:"constant",value:i},t)}return new Bo(this,e.expression,t)}evaluate(e,t,i,n,r,o){if("source"===e.kind){const s=e.evaluate(t,i,n,r,o);return this._calculate(s,s,s,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,n),e.evaluate({zoom:Math.floor(t.zoom)},i,n),e.evaluate({zoom:Math.floor(t.zoom)+1},i,n),t):e.value}_calculate(e,t,i,n){return n.zoom>n.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,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new Po(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Po(Math.floor(t.zoom),t)),e.expression.evaluate(new Po(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Ho{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class Wo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new Po(0,{});for(const i in e){const n=e[i];n.specification.overridable&&this.overridableProperties.push(i);const r=this.defaultPropertyValues[i]=new Ro(n,void 0),o=this.defaultTransitionablePropertyValues[i]=new ko(n);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=r.possiblyEvaluate(t)}}}function qo(e,t){return 256*(e=f(Math.floor(e),0,255))+f(Math.floor(t),0,255)}Pr(jo,"DataDrivenProperty"),Pr(Uo,"DataConstantProperty"),Pr(Vo,"CrossFadedDataDrivenProperty"),Pr(Go,"CrossFadedProperty"),Pr(Ho,"ColorRampProperty");const $o={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Zo{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 Yo(e,t=1){let i=0,n=0;return{members:e.map((e=>{const r=$o[e.type].BYTES_PER_ELEMENT,o=i=Jo(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}})),size:Jo(i,Math.max(n,t)),alignment:t}}function Jo(e,t){return Math.ceil(e/t)*t}class Qo 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 n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}Qo.prototype.bytesPerElement=4,Pr(Qo,"StructArrayLayout2i4");class Ko extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}Ko.prototype.bytesPerElement=6,Pr(Ko,"StructArrayLayout3i6");class es extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}es.prototype.bytesPerElement=8,Pr(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,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,e}}ts.prototype.bytesPerElement=12,Pr(ts,"StructArrayLayout2i4ub1f12");class is extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}is.prototype.bytesPerElement=16,Pr(is,"StructArrayLayout4f16");class ns extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}ns.prototype.bytesPerElement=20,Pr(ns,"StructArrayLayout10ui20");class rs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,n,r,o,s,a)}emplace(e,t,i,n,r,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=n,this.uint16[c+3]=r,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}rs.prototype.bytesPerElement=16,Pr(rs,"StructArrayLayout8ui16");class os extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,Pr(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,n,r,o,s,a,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=i,this.int16[d+2]=n,this.int16[d+3]=r,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]=u,this.int16[d+10]=h,this.int16[d+11]=p,e}}ss.prototype.bytesPerElement=24,Pr(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,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,e}}as.prototype.bytesPerElement=20,Pr(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,Pr(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,n,r,o,s,a,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h,p)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,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]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,e}}cs.prototype.bytesPerElement=40,Pr(cs,"StructArrayLayout5i4f1i1ul2ui40");class us extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}us.prototype.bytesPerElement=16,Pr(us,"StructArrayLayout3i2i2i16");class hs 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,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}hs.prototype.bytesPerElement=16,Pr(hs,"StructArrayLayout2f1f2i16");class ps extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=n,this.float32[s+2]=r,e}}ps.prototype.bytesPerElement=12,Pr(ps,"StructArrayLayout2ub2f12");class ds extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}ds.prototype.bytesPerElement=12,Pr(ds,"StructArrayLayout3f12");class fs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}fs.prototype.bytesPerElement=6,Pr(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,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b){const w=30*e,M=15*e,T=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[M+2]=r,this.float32[M+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[M+5]=l,this.uint32[M+6]=c,this.uint32[M+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[M+10]=f,this.float32[M+11]=m,this.uint8[T+48]=g,this.uint8[T+49]=_,this.uint8[T+50]=y,this.uint32[M+13]=v,this.int16[w+28]=x,this.uint8[T+58]=b,e}}ms.prototype.bytesPerElement=60,Pr(ms,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class gs 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,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T,S,E,A,C,L){const I=this.length;return this.resize(I+1),this.emplace(I,e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T,S,E,A,C,L)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T,S,E,A,C,L,I){const P=38*e,R=19*e;return this.int16[P+0]=t,this.int16[P+1]=i,this.int16[P+2]=n,this.float32[R+2]=r,this.float32[R+3]=o,this.int16[P+8]=s,this.int16[P+9]=a,this.int16[P+10]=l,this.int16[P+11]=c,this.int16[P+12]=u,this.int16[P+13]=h,this.uint16[P+14]=p,this.uint16[P+15]=d,this.uint16[P+16]=f,this.uint16[P+17]=m,this.uint16[P+18]=g,this.uint16[P+19]=_,this.uint16[P+20]=y,this.uint16[P+21]=v,this.uint16[P+22]=x,this.uint16[P+23]=b,this.uint16[P+24]=w,this.uint16[P+25]=M,this.uint16[P+26]=T,this.uint16[P+27]=S,this.uint16[P+28]=E,this.uint32[R+15]=A,this.float32[R+16]=C,this.float32[R+17]=L,this.float32[R+18]=I,e}}gs.prototype.bytesPerElement=76,Pr(gs,"StructArrayLayout3i2f6i15ui1ul3f76");class _s 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}}_s.prototype.bytesPerElement=4,Pr(_s,"StructArrayLayout1f4");class ys extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}ys.prototype.bytesPerElement=28,Pr(ys,"StructArrayLayout7f28");class vs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,e}}vs.prototype.bytesPerElement=20,Pr(vs,"StructArrayLayout5f20");class xs 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,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,e}}xs.prototype.bytesPerElement=12,Pr(xs,"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 n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}bs.prototype.bytesPerElement=4,Pr(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,Pr(ws,"StructArrayLayout1ui2");class Ms 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 n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}Ms.prototype.bytesPerElement=8,Pr(Ms,"StructArrayLayout2f8");class Ts extends Zo{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]}}Ts.prototype.size=12;class Ss extends os{get(e){return new Ts(this,e)}}Pr(Ss,"FillExtrusionExtArray");class Es extends Zo{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]}}Es.prototype.size=40;class As extends cs{get(e){return new Es(this,e)}}Pr(As,"CollisionBoxArray");class Cs extends Zo{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 Ls extends ms{get(e){return new Cs(this,e)}}Pr(Ls,"PlacedSymbolArray");class Is extends Zo{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]}}Is.prototype.size=76;class Ps extends gs{get(e){return new Is(this,e)}}Pr(Ps,"SymbolInstanceArray");class Rs extends _s{getoffsetX(e){return this.float32[1*e+0]}}Pr(Rs,"GlyphOffsetArray");class ks extends Ko{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Pr(ks,"SymbolLineVertexArray");class zs extends Zo{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]}}zs.prototype.size=12;class Ds extends xs{get(e){return new zs(this,e)}}Pr(Ds,"FeatureIndexArray");class Os extends Zo{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Os.prototype.size=4;class Fs extends bs{get(e){return new Os(this,e)}}Pr(Fs,"FillExtrusionCentroidArray");class Bs extends Zo{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]}}Bs.prototype.size=12;class Ns extends os{get(e){return new Bs(this,e)}}Pr(Ns,"CircleGlobeExtArray");const Us=Yo([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),js=Yo([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Vs=ft((function(e){e.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c<n;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,r=27492+(65535&(o=5*(65535&(r=(r^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>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:r^=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 r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}})),Gs=ft((function(e){e.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=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),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}})),Hs=Vs,Ws=Gs;Hs.murmur3=Vs,Hs.murmur2=Ws;class qs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push($s(e)),this.positions.push(t,i,n)}getPositions(e){const t=$s(e);let i=0,n=this.ids.length-1;for(;i<n;){const e=i+n>>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return Zs(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}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:Hs(String(e))}function Zs(e,t,i,n){for(;i<n;){const r=e[i+n>>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]<r);do{s--}while(e[s]>r);if(o>=s)break;Xs(e,o,s),Xs(t,3*o,3*s),Xs(t,3*o+1,3*s+1),Xs(t,3*o+2,3*s+2)}s-i<n-s?(Zs(e,t,i,s),i=s+1):(Zs(e,t,s+1,n),n=s)}}function Xs(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}Pr(qs,"FeaturePositionMap");class Ys{constructor(e,t){this.gl=e.gl,this.location=t}}class Js extends Ys{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Qs extends Ys{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 Ks extends Ys{constructor(e,t){super(e,t),this.current=_t.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 na(e){return[qo(255*e.r,255*e.g),qo(255*e.b,255*e.a)]}class ra{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 Ks(e,t):new Js(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,n){const r="u_pattern_to"===n||"u_dash_to"===n?this.patternTo:"u_pattern_from"===n||"u_dash_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;r&&e.set(r)}getBinding(e,t,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Qs(e,t):new Js(e,t)}}class sa{constructor(e,t,i,n){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 n}populatePaintArray(e,t,i,n,r,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new Po(0),t,{},r,n,o);this.paintVertexArray.resize(e),this._setPaintValue(s,e,a)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate({zoom:0},i,n,void 0,r);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const n=na(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}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,n,r,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=i,this.useIntegerZoom=n,this.zoom=r,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,n,r,o){const s=this.expression.evaluate(new Po(this.zoom),t,{},r,n,o),a=this.expression.evaluate(new Po(this.zoom+1),t,{},r,n,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,s,a)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate({zoom:this.zoom},i,n,void 0,r),s=this.expression.evaluate({zoom:this.zoom+1},i,n,void 0,r);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=na(i),o=na(n);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1],o[0],o[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i,n);this.maxValue=Math.max(this.maxValue,Math.abs(i),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,n=f(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(n)}getBinding(e,t,i){return new Js(e,t)}}class la{constructor(e,t,i,n,r,o,s){this.expression=e,this.type=i,this.useIntegerZoom=n,this.zoom=r,this.layerId=s,this.paintVertexAttributes=("array"===i?js:Us).members;for(let e=0;e<t.length;++e);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(e,t,i){const n=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(n,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,n,r,o){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(e,t,i,n){if(!n||!i)return;const{min:r,mid:o,max:s}=i,a=n[r],l=n[o],c=n[s];if(a&&l&&c)for(let i=e;i<t;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(e,t,i,n){e.emplace(t,i.tl[0],i.tl[1],i.br[0],i.br[1],n.tl[0],n.tl[1],n.br[0],n.br[1],i.pixelRatio,n.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 n=[];for(const r in e.paint._values){if(!i(r))continue;const o=e.paint.get(r);if(!(o instanceof Bo&&bn(o.property.specification)))continue;const s=pa(r,e.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,u=o.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(r)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||h){const i=ma(r,l,"source");this.binders[r]=h?new la(a,s,l,c,t,i,e.id):new sa(a,s,l,i),n.push(`/a_${r}`)}else{const e=ma(r,l,"composite");this.binders[r]=new aa(a,s,l,c,t,e),n.push(`/z_${r}`)}else this.binders[r]=h?new oa(a.value,s):new ra(a.value,s,l),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof sa||t instanceof aa?t.maxValue:0}populatePaintArrays(e,t,i,n,r,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,n,r,o)}}setConstantPatternPositions(e,t){for(const i in this.binders){const n=this.binders[i];n instanceof oa&&n.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,i,n,r,o){let s=!1;for(const a in e){const l=t.getPositions(a);for(const t of l){const l=i.feature(t.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof sa||c instanceof aa||c instanceof la)&&!0===c.expression.isStateDependent){const u=n.paint.get(i);c.expression=u.value,c.updatePaintArray(t.start,t.end,l,e[a],r,o),s=!0}}}}return s}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof ra||i instanceof oa)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof sa||i instanceof aa||i instanceof la)for(let t=0;t<i.paintVertexAttributes.length;t++)e.push(i.paintVertexAttributes[t].name)}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof ra||i instanceof oa||i instanceof aa)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){const i=[];for(const n in this.binders){const r=this.binders[n];if(r instanceof ra||r instanceof oa||r instanceof aa)for(const o of r.uniformNames)if(t[o]){const s=r.getBinding(e,t[o],o);i.push({name:o,property:n,binding:s})}}return i}setUniforms(e,t,i,n){for(const{name:e,property:r,binding:o}of t)this.binders[r].setUniform(o,n,i.get(r),e)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof la){const t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}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 ua{constructor(e,t,i=(()=>!0)){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new ca(n,t,i);this.needsUpload=!1,this._featureMap=new qs,this._bufferOffset=0}populatePaintArrays(e,t,i,n,r,o,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n,r,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,n,r){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,n,r)||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 ha={"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 ha[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const da={"line-pattern":{source:ns,composite:ns},"fill-pattern":{source:ns,composite:ns},"fill-extrusion-pattern":{source:ns,composite:ns},"line-dasharray":{source:rs,composite:rs}},fa={color:{source:Ms,composite:is},number:{source:_s,composite:Ms}};function ma(e,t,i){const n=da[e];return n&&n[i]||fa[t][i]}Pr(ra,"ConstantBinder"),Pr(oa,"CrossFadedConstantBinder"),Pr(sa,"SourceExpressionBinder"),Pr(la,"CrossFadedCompositeBinder"),Pr(aa,"CompositeExpressionBinder"),Pr(ca,"ProgramConfiguration",{omit:["_buffers"]}),Pr(ua,"ProgramConfigurationSet");const ga="-transition";class _a 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.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 Fo(t.layout)),t.paint)){this._transitionablePaint=new zo(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(Sr,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return E(e,ga)?this._transitionablePaint.getTransition(e.slice(0,-ga.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(Tr,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(E(e,ga))return this._transitionablePaint.setTransition(e.slice(0,-ga.length),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||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),C(e,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,i,n,r={}){return(!r||!1!==r.validate)&&Ar(this,e.call(Mr,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:He,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 Bo&&bn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Yn(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ya=Yo([{name:"a_pos",components:2,type:"Int16"}],4),va=Yo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class xa{constructor(e=[]){this.segments=e}prepareSegment(e,t,i,n){let r=this.segments[this.segments.length-1];return e>xa.MAX_VERTEX_ARRAY_LENGTH&&P(`Max vertices per segment is ${xa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!r||r.vertexLength+e>xa.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}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,n){return new xa([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}xa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Pr(xa,"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 Ta?new Ta(e.lng,e.lat):Ta.convert(e),this}setSouthWest(e){return this._sw=e instanceof Ta?new Ta(e.lng,e.lat):Ta.convert(e),this}extend(e){const t=this._sw,i=this._ne;let n,r;if(e instanceof Ta)n=e,r=e;else{if(!(e instanceof wa))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(wa.convert(e)):this.extend(Ta.convert(e)):this;if(n=e._sw,r=e._ne,!n||!r)return this}return t||i?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new Ta(n.lng,n.lat),this._ne=new Ta(r.lng,r.lat)),this}getCenter(){return new Ta((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 Ta(this.getWest(),this.getNorth())}getSouthEast(){return new Ta(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}=Ta.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&n}static convert(e){return!e||e instanceof wa?e:new wa(e)}}const Ma=6371008.8;class Ta{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 Ta(g(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,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return Ma*Math.acos(Math.min(r,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new wa(new Ta(this.lng-i,this.lat-t),new Ta(this.lng+i,this.lat+t))}static convert(e){if(e instanceof Ta)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Ta(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Ta(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 Sa=2*Math.PI*Ma;function Ea(e){return Sa*Math.cos(e*Math.PI/180)}function Aa(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 La(e,t){return e/Ea(t)}function Ia(e){return 360*e-180}function Pa(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Ra(e,t){return e*Ea(Pa(t))}const ka=85.051129;class za{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=Ta.convert(e);return new za(Aa(i.lng),Ca(i.lat),La(t,i.lat))}toLngLat(){return new Ta(Ia(this.x),Pa(this.y))}toAltitude(){return Ra(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Sa*(e=Pa(this.y),1/Math.cos(e*Math.PI/180));var e}}function Da(e,t,i,n,o,s,a,l,c){const u=(t+n)/2,h=(i+o)/2,p=new r(u,h);l(p),function(e,t,i,n,r,o){const s=i-r,a=n-o;return Math.abs((n-t)*s-(i-e)*a)/Math.hypot(s,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(Da(e,t,i,u,h,s,p,l,c),Da(e,u,h,n,o,p,a,l,c)):e.push(a)}function Oa(e,t,i){let n=e[0],r=n.x,o=n.y;t(n);const s=[n];for(let a=1;a<e.length;a++){const l=e[a],{x:c,y:u}=l;t(l),Da(s,r,o,c,u,n,l,t,i),r=c,o=u,n=l}return s}function Fa(e,t,i,n,r){if(r(t,i)){const o=t.add(i).mult(.5);n(o),Fa(e,t,o,n,r),Fa(e,o,i,n,r)}else e.push(i)}function Ba(e,t,i){let n=e[0];t(n);const r=[n];for(let o=1;o<e.length;o++){const s=e[o];t(s),Fa(r,n,s,t,i),n=s}return r}const Na=Math.pow(2,14)-1,Ua=-Na-1;function ja(e,t){const i=Math.round(e.x*t),n=Math.round(e.y*t);return e.x=f(i,Ua,Na),e.y=f(n,Ua,Na),(i<e.x||i>e.x+1||n<e.y||n>e.y+1)&&P("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Va(e,t,i){const n=e.loadGeometry(),r=e.extent,o=ba/r;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:s,x:a,y:l,projection:c}=i,u=e=>{const i=Ia((t.x+e.x/r)/o),n=Pa((t.y+e.y/r)/o),u=c.project(i,n);e.x=(u.x*s-a)*r,e.y=(u.y*s-l)*r};for(let t=0;t<n.length;t++)if(1!==e.type)n[t]=Oa(n[t],u,1);else{const e=[];for(const i of n[t])i.x<0||i.x>=r||i.y<0||i.y>=r||(u(i),e.push(i));n[t]=e}}for(const e of n)for(const t of e)ja(t,o);return n}function Ga(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Va(e):[]}}function Ha(e,t,i,n,r){e.emplaceBack(2*t+(n+1)/2,2*i+(r+1)/2)}function Wa(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}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 Qo,this.indexArray=new fs,this.segments=new xa,this.programConfigurations=new ua(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:t,id:r,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ga(t,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),c,i))continue;const u=s?s.evaluate(c,{},i):void 0,h={id:r,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,i,n),patterns:{},sortKey:u};o.push(h)}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ns,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=e[o].feature;this.addFeature(n,r,o,t.availableImages,i,a),t.featureIndex.insert(l,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,n)}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,va.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,n,r,o){for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=ba||n<0||n>=ba)continue;if(o){const e=o.projectTilePoint(i,n,r),t=o.upVector(r,i,n),s=this.globeExtVertexArray;Wa(s,e,t),Wa(s,e,t),Wa(s,e,t),Wa(s,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;Ha(this.layoutVertexArray,i,n,-1,-1),Ha(this.layoutVertexArray,i,n,1,-1),Ha(this.layoutVertexArray,i,n,1,1),Ha(this.layoutVertexArray,i,n,-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,{},n,r)}}function $a(e,t){for(let i=0;i<e.length;i++)if(il(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(il(e,t[i]))return!0;return!!Ja(e,t)}function Za(e,t,i){return!!il(e,t)||!!Ka(t,e,i)}function Xa(e,t){if(1===e.length)return tl(t,e[0]);for(let i=0;i<t.length;i++){const n=t[i];for(let t=0;t<n.length;t++)if(il(e,n[t]))return!0}for(let i=0;i<e.length;i++)if(tl(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Ja(e,t[i]))return!0;return!1}function Ya(e,t,i){if(e.length>1){if(Ja(e,t))return!0;for(let n=0;n<t.length;n++)if(Ka(t[n],e,i))return!0}for(let n=0;n<e.length;n++)if(Ka(e[n],t,i))return!0;return!1}function Ja(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)if(Qa(n,r,t[e],t[e+1]))return!0}return!1}function Qa(e,t,i,n){return R(e,i,n)!==R(t,i,n)&&R(e,t,i)!==R(e,t,n)}function Ka(e,t,i){const n=i*i;if(1===t.length)return e.distSqr(t[0])<n;for(let i=1;i<t.length;i++)if(el(e,t[i-1],t[i])<n)return!0;return!1}function el(e,t,i){const n=t.distSqr(i);if(0===n)return e.distSqr(t);const r=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/n;return e.distSqr(r<0?t:r>1?i:i.sub(t)._mult(r)._add(t))}function tl(e,t){let i,n,r,o=!1;for(let s=0;s<e.length;s++){i=e[s];for(let e=0,s=i.length-1;e<i.length;s=e++)n=i[e],r=i[s],n.y>t.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function il(e,t){let i=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){const o=e[n],s=e[r];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function nl(e,t,i,n,o){for(const r of e)if(t<=r.x&&i<=r.y&&n>=r.x&&o>=r.y)return!0;const s=[new r(t,i),new r(t,o),new r(n,o),new r(n,i)];if(e.length>2)for(const t of s)if(il(e,t))return!0;for(let t=0;t<e.length-1;t++)if(rl(e[t],e[t+1],s))return!0;return!1}function rl(e,t,i){const n=i[0],r=i[2];if(e.x<n.x&&t.x<n.x||e.x>r.x&&t.x>r.x||e.y<n.y&&t.y<n.y||e.y>r.y&&t.y>r.y)return!1;const o=R(e,t,i[0]);return o!==R(e,t,i[1])||o!==R(e,t,i[2])||o!==R(e,t,i[3])}function ol(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function sl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function al(e,t,i,n,o){if(!t[0]&&!t[1])return e;const s=r.convert(t)._mult(o);"viewport"===i&&s._rotate(-n);const a=[];for(let t=0;t<e.length;t++)a.push(e[t].sub(s));return a}function ll(e,t,i,n){const o=r.convert(e)._mult(n);return"viewport"===t&&o._rotate(-i),o}Pr(qa,"CircleBucket",{omit:["layers"]});const cl=new Wo({"circle-sort-key":new jo(He.layout_circle["circle-sort-key"])});var ul={paint:new Wo({"circle-radius":new jo(He.paint_circle["circle-radius"]),"circle-color":new jo(He.paint_circle["circle-color"]),"circle-blur":new jo(He.paint_circle["circle-blur"]),"circle-opacity":new jo(He.paint_circle["circle-opacity"]),"circle-translate":new Uo(He.paint_circle["circle-translate"]),"circle-translate-anchor":new Uo(He.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Uo(He.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Uo(He.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new jo(He.paint_circle["circle-stroke-width"]),"circle-stroke-color":new jo(He.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new jo(He.paint_circle["circle-stroke-opacity"])}),layout:cl},hl=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 n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],m=t[12],g=t[13],_=t[14],y=t[15],v=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*n+x*a+b*h+w*m,e[1]=v*r+x*l+b*p+w*g,e[2]=v*o+x*c+b*d+w*_,e[3]=v*s+x*u+b*f+w*y,e[4]=(v=i[4])*n+(x=i[5])*a+(b=i[6])*h+(w=i[7])*m,e[5]=v*r+x*l+b*p+w*g,e[6]=v*o+x*c+b*d+w*_,e[7]=v*s+x*u+b*f+w*y,e[8]=(v=i[8])*n+(x=i[9])*a+(b=i[10])*h+(w=i[11])*m,e[9]=v*r+x*l+b*p+w*g,e[10]=v*o+x*c+b*d+w*_,e[11]=v*s+x*u+b*f+w*y,e[12]=(v=i[12])*n+(x=i[13])*a+(b=i[14])*h+(w=i[15])*m,e[13]=v*r+x*l+b*p+w*g,e[14]=v*o+x*c+b*d+w*_,e[15]=v*s+x*u+b*f+w*y,e}function gl(e,t,i){var n,r,o,s,a,l,c,u,h,p,d,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+p*_+t[13],e[14]=o*m+c*g+d*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e}function _l(e,t,i){var n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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 n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=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*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+p*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=p*r-l*n,e}function vl(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=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*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-p*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+p*r,e}function xl(e,t,i){var n,r,o,s=i[0],a=i[1],l=i[2],c=Math.hypot(s,a,l);return c<hl?null:(s*=c=1/c,a*=c,l*=c,n=Math.sin(t),r=Math.cos(t),e[0]=s*s*(o=1-r)+r,e[1]=a*s*o+l*n,e[2]=l*s*o-a*n,e[3]=0,e[4]=s*a*o-l*n,e[5]=a*a*o+r,e[6]=l*a*o+s*n,e[7]=0,e[8]=s*l*o+a*n,e[9]=a*l*o-s*n,e[10]=l*l*o+r,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 Ml(e){var t=new pl(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Tl(e){return Math.hypot(e[0],e[1],e[2])}function Sl(e,t,i){var n=new pl(3);return n[0]=e,n[1]=t,n[2]=i,n}function El(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function Al(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 Ll(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 Il(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 Pl(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Rl(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e}function kl(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;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 zl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Dl(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=r*l-o*a,e[1]=o*s-n*l,e[2]=n*a-r*s,e}function Ol(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e}function Fl(e,t,i){var n=i[0],r=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=r*l-o*a,u=o*s-n*l,h=n*a-r*s,p=r*h-o*u,d=o*c-n*h,f=n*u-r*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,e[0]=s+(c*=m)+(p*=2),e[1]=a+u+d,e[2]=l+h+f,e}var Bl,Nl=Al,Ul=Cl,jl=Tl;function Vl(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function Gl(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,e}function Hl(){var e=new pl(4);return pl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Wl(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ql(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l+s*a,e[1]=r*l+o*a,e[2]=o*l-r*a,e[3]=s*l-n*a,e}function $l(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l-o*a,e[1]=r*l+s*a,e[2]=o*l+n*a,e[3]=s*l-r*a,e}wl(),Bl=new pl(4),pl!=Float32Array&&(Bl[0]=0,Bl[1]=0,Bl[2]=0,Bl[3]=0),wl(),Sl(1,0,0),Sl(0,1,0),Hl(),Hl(),dl();class Zl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const n=zl(t,this.dir);if(Math.abs(n)<1e-6)return!1;const r=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/n;return i[0]=this.pos[0]+this.dir[0]*r,i[1]=this.pos[1]+this.dir[1]*r,i[2]=this.pos[2]+this.dir[2]*r,!0}closestPointOnSphere(e,t,i){if(function(e,t){var i=e[0],n=e[1],r=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(i-o)<=hl*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-s)<=hl*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(r-a)<=hl*Math.max(1,Math.abs(r),Math.abs(a))}(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[n,r,o]=this.dir,s=this.pos[0]-e[0],a=this.pos[1]-e[1],l=this.pos[2]-e[2],c=n*n+r*r+o*o,u=2*(s*n+a*r+l*o),h=u*u-4*c*(s*s+a*a+l*l-t*t);if(h<0){const e=Math.max(-u/2,0),c=s+n*e,h=a+r*e,p=l+o*e,d=Math.hypot(c,h,p);return i[0]=c*t/d,i[1]=h*t/d,i[2]=p*t/d,!1}{const e=(-u-Math.sqrt(h))/(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+n*e,i[1]=a+r*e,i[2]=l+o*e,!0}}}class Xl{constructor(e,t,i,n,r){this.TL=e,this.TR=t,this.BR=i,this.BL=n,this.horizon=r}static fromInvProjectionMatrix(e,t,i){const n=[-1,1,1],r=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Ol(n,n,e),l=Ol(r,r,e),c=Ol(o,o,e),u=Ol(s,s,e);return new Xl(a,l,c,u,t/i)}}class Yl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,i,n){const r=Math.pow(2,i),o=[[-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((i=>{const o=Gl([],i,e),s=1/o[3]/t*r;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}(o,o,[s,s,n?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=kl([],Dl([],Nl([],o[e[0]],o[e[1]]),Nl([],o[e[2]],o[e[1]]))),i=-zl(t,o[e[1]]);return t.concat(i)}));return new Yl(o,s)}}class Jl{constructor(e,t){this.min=e,this.max=t,this.center=Pl([],El([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=Ml(this.min),n=Ml(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],n[e]=t[e]?this.center[e]:this.max[e];return n[2]=this.max[2],new Jl(i,n)}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(e){const t=this.getCorners();let i=!0;for(let n=0;n<e.planes.length;n++){const r=e.planes[n];let o=0;for(let e=0;e<t.length;e++)o+=zl(r,t[e])+r[3]>=0;if(0===o)return 0;o!==t.length&&(i=!1)}if(i)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let r=0;r<e.points.length;r++){const o=e.points[r][t]-this.min[t];i=Math.min(i,o),n=Math.max(n,o)}if(n<0||i>this.max[t]-this.min[t])return 0}return 1}}function Ql(e,t,i,n,r,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),p=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(h.x,h.y,!0):0,d=i.projection.projectTilePoint(h.x,h.y,c);if(p>0){const e=i.projection.upVector(c,h.x,h.y);d.x+=e[0]*u*p,d.y+=e[1]*u*p,d.z+=e[2]*u*p}const f=o?h:Kl(d.x,d.y,d.z,n),m=o?e.tilespaceRays.map((e=>ic(e,p))):e.queryGeometry.screenGeometry,g=Gl([],[d.x,d.y,d.z,1],n);if(!s&&o?l*=g[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/g[3]),o){const e=Pa((t.y/ba+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/La(1,e)}if(Za(m,f,l))return!0}return!1}function Kl(e,t,i,n){const o=Gl([],[e,t,i,1],n);return new r(o[0]/o[3],o[1]/o[3])}const ec=Sl(0,0,0),tc=Sl(0,0,1);function ic(e,t){const i=wl();return ec[2]=t,e.intersectsPlane(ec,tc,i),new r(i[0],i[1])}class nc extends qa{}function rc(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError("mismatched image size")}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function oc(e,t,i){const{width:n,height:r}=t;n===e.width&&r===e.height||(sc(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,r)},i),e.width=n,e.height=r,e.data=t.data)}function sc(e,t,i,n,r,o){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;for(let l=0;l<r.height;l++){const c=((i.y+l)*e.width+i.x)*o,u=((n.y+l)*t.width+n.x)*o;for(let e=0;e<r.width*o;e++)a[u+e]=s[c+e]}return t}Pr(nc,"HeatmapBucket",{omit:["layers"]});class ac{constructor(e,t){rc(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,n,r){sc(e,t,i,n,r,1)}}class lc{constructor(e,t){rc(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,n,r){sc(e,t,i,n,r,4)}}Pr(ac,"AlphaImage"),Pr(lc,"RGBAImage");var cc={paint:new Wo({"heatmap-radius":new jo(He.paint_heatmap["heatmap-radius"]),"heatmap-weight":new jo(He.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Uo(He.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ho(He.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Uo(He.paint_heatmap["heatmap-opacity"])})};function uc(e){const t={},i=e.resolution||256,n=e.clips?e.clips.length:1,r=e.image||new lc({width:i,height:n}),o=(i,n,o)=>{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a)};if(e.clips)for(let t=0,r=0;t<n;++t,r+=4*i)for(let n=0,s=0;n<i;n++,s+=4){const a=n/(i-1),{start:l,end:c}=e.clips[t];o(r,s,l*(1-a)+c*a)}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return r}var hc={paint:new Wo({"hillshade-illumination-direction":new Uo(He.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Uo(He.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Uo(He.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Uo(He.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Uo(He.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Uo(He.paint_hillshade["hillshade-accent-color"])})};const pc=Yo([{name:"a_pos",components:2,type:"Int16"}],4),{members:dc}=pc;var fc=gc,mc=gc;function gc(e,t,i){i=i||2;var n,r,o,s,a,l,c,u=t&&t.length,h=u?t[0]*i:e.length,p=_c(e,0,h,i,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(e,t,i,n){var r,o,s,a=[];for(r=0,o=t.length;r<o;r++)(s=_c(e,t[r]*n,r<o-1?t[r+1]*n:e.length,n,!1))===s.next&&(s.steiner=!0),a.push(Cc(s));for(a.sort(Tc),r=0;r<a.length;r++)i=yc(i=Sc(a[r],i),i.next);return i}(e,t,p,i)),e.length>80*i){n=o=e[0],r=s=e[1];for(var f=i;f<h;f+=i)(a=e[f])<n&&(n=a),(l=e[f+1])<r&&(r=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-n,s-r))?1/c:0}return vc(p,d,i,n,r,c),d}function _c(e,t,i,n,r){var o,s;if(r===jc(e,t,i,n)>0)for(o=t;o<i;o+=n)s=Bc(o,e[o],e[o+1],s);else for(o=i-n;o>=t;o-=n)s=Bc(o,e[o],e[o+1],s);return s&&Rc(s,s.next)&&(Nc(s),s=s.next),s}function yc(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!Rc(n,n.next)&&0!==Pc(n.prev,n,n.next))n=n.next;else{if(Nc(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function vc(e,t,i,n,r,o,s){if(e){!s&&o&&function(e,t,i,n){var r=e;do{null===r.z&&(r.z=Ac(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,n,r,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,n=i,a=0,t=0;t<c&&(a++,n=n.nextZ);t++);for(l=c;a>0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1)}(r)}(e,n,r,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?bc(e,n,r,o):xc(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?vc(e=wc(yc(e),t,i),t,i,n,r,o,2):2===s&&Mc(e,t,i,n,r,o):vc(yc(e),t,i,n,r,o,1);break}}}function xc(e){var t=e.prev,i=e,n=e.next;if(Pc(t,i,n)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(Lc(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Pc(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function bc(e,t,i,n){var r=e.prev,o=e,s=e.next;if(Pc(r,o,s)>=0)return!1;for(var a=r.x>o.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,l=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,c=Ac(r.x<o.x?r.x<s.x?r.x:s.x:o.x<s.x?o.x:s.x,r.y<o.y?r.y<s.y?r.y:s.y:o.y<s.y?o.y:s.y,t,i,n),u=Ac(a,l,t,i,n),h=e.prevZ,p=e.nextZ;h&&h.z>=c&&p&&p.z<=u;){if(h!==e.prev&&h!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==e.prev&&p!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=c;){if(h!==e.prev&&h!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=u;){if(p!==e.prev&&p!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function wc(e,t,i){var n=e;do{var r=n.prev,o=n.next.next;!Rc(r,o)&&kc(r,n,n.next,o)&&Oc(r,o)&&Oc(o,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(o.i/i),Nc(n),Nc(n.next),n=e=o),n=n.next}while(n!==e);return yc(n)}function Mc(e,t,i,n,r,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Ic(s,a)){var l=Fc(s,a);return s=yc(s,s.next),l=yc(l,l.next),vc(s,t,i,n,r,o),void vc(l,t,i,n,r,o)}a=a.next}s=s.next}while(s!==e)}function Tc(e,t){return e.x-t.x}function Sc(e,t){var i=function(e,t){var i,n=t,r=e.x,o=e.y,s=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var a=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>s){if(s=a,a===r){if(o===n.y)return n;if(o===n.next.y)return n.next}i=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!i)return null;if(r===s)return i;var l,c=i,u=i.x,h=i.y,p=1/0;n=i;do{r>=n.x&&n.x>=u&&r!==n.x&&Lc(o<h?r:s,o,u,h,o<h?s:r,o,n.x,n.y)&&(l=Math.abs(o-n.y)/(r-n.x),Oc(n,e)&&(l<p||l===p&&(n.x>i.x||n.x===i.x&&Ec(i,n)))&&(i=n,p=l)),n=n.next}while(n!==c);return i}(e,t);if(!i)return t;var n=Fc(i,e),r=yc(i,i.next);return yc(n,n.next),t===i?r:t}function Ec(e,t){return Pc(e.prev,e,t.prev)<0&&Pc(t.next,e,e.next)<0}function Ac(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|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 Lc(e,t,i,n,r,o,s,a){return(r-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(n-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function Ic(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&&kc(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Oc(e,t)&&Oc(t,e)&&function(e,t){var i=e,n=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Pc(e.prev,e,t.prev)||Pc(e,t.prev,t))||Rc(e,t)&&Pc(e.prev,e,e.next)>0&&Pc(t.prev,t,t.next)>0)}function Pc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Rc(e,t){return e.x===t.x&&e.y===t.y}function kc(e,t,i,n){var r=Dc(Pc(e,t,i)),o=Dc(Pc(e,t,n)),s=Dc(Pc(i,n,e)),a=Dc(Pc(i,n,t));return r!==o&&s!==a||!(0!==r||!zc(e,i,t))||!(0!==o||!zc(e,n,t))||!(0!==s||!zc(i,e,n))||!(0!==a||!zc(i,t,n))}function zc(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 Oc(e,t){return Pc(e.prev,e,e.next)<0?Pc(e,t,e.next)>=0&&Pc(e,e.prev,t)>=0:Pc(e,t,e.prev)<0||Pc(e,e.next,t)<0}function Fc(e,t){var i=new Uc(e.i,e.x,e.y),n=new Uc(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Bc(e,t,i,n){var r=new Uc(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Nc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Uc(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function jc(e,t,i,n){for(var r=0,o=t,s=i-n;o<i;o+=n)r+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return r}function Vc(e,t,i,n,r){Gc(e,t,i||0,n||e.length-1,r||Wc)}function Gc(e,t,i,n,r){for(;n>i;){if(n-i>600){var o=n-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(n,Math.floor(t+(o-s)*l/o+c)),r)}var u=e[t],h=i,p=n;for(Hc(e,i,t),r(e[n],u)>0&&Hc(e,i,n);h<p;){for(Hc(e,h,p),h++,p--;r(e[h],u)<0;)h++;for(;r(e[p],u)>0;)p--}0===r(e[i],u)?Hc(e,i,p):Hc(e,++p,n),p<=t&&(i=p+1),t<=p&&(n=p-1)}}function Hc(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function Wc(e,t){return e<t?-1:e>t?1:0}function qc(e,t){const i=e.length;if(i<=1)return[e];const n=[];let r,o;for(let t=0;t<i;t++){const i=k(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(r&&n.push(r),r=[e[t]]):r.push(e[t]))}if(r&&n.push(r),t>1)for(let e=0;e<n.length;e++)n[e].length<=t||(Vc(n[e],t,1,n[e].length-1,$c),n[e]=n[e].slice(0,t));return n}function $c(e,t){return t.area-e.area}function Zc(e,t,i){const n=i.patternDependencies;let r=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(r=!0);const o=t.constantOr(null);o&&(r=!0,n[o.to]=!0,n[o.from]=!0)}return r}function Xc(e,t,i,n,r){const o=r.patternDependencies;for(const s of t){const t=s.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:n-1},i,{},r.availableImages),a=t.evaluate({zoom:n},i,{},r.availableImages),l=t.evaluate({zoom:n+1},i,{},r.availableImages);e=e&&e.name?e.name:e,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,o[e]=!0,o[a]=!0,o[l]=!0,i.patterns[s.id]={min:e,mid:a,max:l}}}return i}gc.deviation=function(e,t,i,n){var r=t&&t.length,o=Math.abs(jc(e,0,r?t[0]*i:e.length,i));if(r)for(var s=0,a=t.length;s<a;s++)o-=Math.abs(jc(e,t[s]*i,s<a-1?t[s+1]*i:e.length,i));var l=0;for(s=0;s<n.length;s+=3){var c=n[s]*i,u=n[s+1]*i,h=n[s+2]*i;l+=Math.abs((e[c]-e[h])*(e[u+1]-e[c+1])-(e[c]-e[u])*(e[h+1]-e[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},gc.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},n=0,r=0;r<e.length;r++){for(var o=0;o<e[r].length;o++)for(var s=0;s<t;s++)i.vertices.push(e[r][o][s]);r>0&&i.holes.push(n+=e[r-1].length)}return i},fc.default=mc;class Yc{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 Qo,this.indexArray=new fs,this.indexArray2=new bs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.segments2=new xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,i,n){this.hasPattern=Zc("fill",this.layers,t);const r=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,u=Ga(s,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),u,i))continue;const h=r?r.evaluate(u,{},i,t.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Va(s,i,n),patterns:{},sortKey:h};o.push(p)}r&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=Xc("fill",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.availableImages);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,n)}addFeatures(e,t,i,n,r){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,n)}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(e,t,i,n,r,o=[]){for(const e of qc(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(n+t.length-1,n),r.push(t[0].x),r.push(t[0].y);for(let e=1;e<t.length;e++)this.layoutVertexArray.emplaceBack(t[e].x,t[e].y),this.indexArray2.emplaceBack(n+e-1,n+e),r.push(t[e].x),r.push(t[e].y);i.vertexLength+=t.length,i.primitiveLength+=t.length}const s=fc(r,o);for(let e=0;e<s.length;e+=3)this.indexArray.emplaceBack(n+s[e],n+s[e+1],n+s[e+2]);i.vertexLength+=t,i.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,o,n)}}Pr(Yc,"FillBucket",{omit:["layers","patternFeatures"]});const Jc=new Wo({"fill-sort-key":new jo(He.layout_fill["fill-sort-key"])});var Qc={paint:new Wo({"fill-antialias":new Uo(He.paint_fill["fill-antialias"]),"fill-opacity":new jo(He.paint_fill["fill-opacity"]),"fill-color":new jo(He.paint_fill["fill-color"]),"fill-outline-color":new jo(He.paint_fill["fill-outline-color"]),"fill-translate":new Uo(He.paint_fill["fill-translate"]),"fill-translate-anchor":new Uo(He.paint_fill["fill-translate-anchor"]),"fill-pattern":new Vo(He.paint_fill["fill-pattern"])}),layout:Jc};const Kc=Yo([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),eu=Yo([{name:"a_centroid_pos",components:2,type:"Uint16"}]),tu=Yo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:iu}=Kc;var nu=ru;function ru(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(ou,this,t)}function ou(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 n=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[n]=r}}(i,t):3==e?t.type=i.readVarint():4==e&&(t._geometry=i.pos)}function su(e){for(var t,i,n=0,r=0,o=e.length,s=o-1;r<o;s=r++)n+=((i=e[s]).x-(t=e[r]).x)*(t.y+i.y);return n}ru.types=["Unknown","Point","LineString","Polygon"],ru.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,i=e.readVarint()+e.pos,n=1,o=0,s=0,a=0,l=[];e.pos<i;){if(o<=0){var c=e.readVarint();n=7&c,o=c>>3}if(o--,1===n||2===n)s+=e.readSVarint(),a+=e.readSVarint(),1===n&&(t&&l.push(t),t=[]),t.push(new r(s,a));else{if(7!==n)throw new Error("unknown command "+n);t&&t.push(t[0].clone())}}return t&&l.push(t),l},ru.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos<t;){if(n<=0){var u=e.readVarint();i=7&u,n=u>>3}if(n--,1===i||2===i)(r+=e.readSVarint())<s&&(s=r),r>a&&(a=r),(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]},ru.prototype.toGeoJSON=function(e,t,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=ru.types[this.type];function u(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 h=[];for(n=0;n<l.length;n++)h[n]=l[n][0];u(l=h);break;case 2:for(n=0;n<l.length;n++)u(l[n]);break;case 3:for(l=function(e){var t=e.length;if(t<=1)return[e];for(var i,n,r=[],o=0;o<t;o++){var s=su(e[o]);0!==s&&(void 0===n&&(n=s<0),n===s<0?(i&&r.push(i),i=[e[o]]):i.push(e[o]))}return i&&r.push(i),r}(l),n=0;n<l.length;n++)for(r=0;r<l[n].length;r++)u(l[n][r])}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 au=lu;function lu(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(cu,this,t),this.length=this._features.length}function cu(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 n=e.readVarint()>>3;t=1===n?e.readString():2===n?e.readFloat():3===n?e.readDouble():4===n?e.readVarint64():5===n?e.readVarint():6===n?e.readSVarint():7===n?e.readBoolean():null}return t}(i))}function uu(e,t,i){if(3===e){var n=new au(i,i.readVarint()+i.pos);n.length&&(t[n.name]=n)}}lu.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 nu(this._pbf,t,this.extent,this._keys,this._values)};var hu={VectorTile:function(e,t){this.layers=e.readFields(uu,{},t)},VectorTileFeature:nu,VectorTileLayer:au};function pu(e,t,i,n){const o=[],s=0===n?(e,t,i,n,o,s)=>{e.push(new r(s,i+(s-t)/(n-t)*(o-i)))}:(e,t,i,n,o,s)=>{e.push(new r(t+(s-i)/(o-i)*(n-t),s))};for(const r of e){const e=[];for(const o of r){if(o.length<=2)continue;const r=[];for(let e=0;e<o.length-1;e++){const a=o[e].x,l=o[e].y,c=o[e+1].x,u=o[e+1].y,h=0===n?a:l,p=0===n?c:u;h<t?p>t&&s(r,a,l,c,u,t):h>i?p<i&&s(r,a,l,c,u,i):r.push(o[e]),p<t&&h>=t&&s(r,a,l,c,u,t),p>i&&h<=i&&s(r,a,l,c,u,i)}let a=o[o.length-1];const l=0===n?a.x:a.y;l>=t&&l<=i&&r.push(a),r.length&&(a=r[r.length-1],r[0].x===a.x&&r[0].y===a.y||r.push(r[0]),e.push(r))}e.length&&o.push(e)}return o}const du=hu.VectorTileFeature.types,fu=Math.pow(2,13);function mu(e,t,i,n,r,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(n*fu)<<1)+r,Math.round(a))}function gu(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}class _u{constructor(){this.acc=new r(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new r(e.x,e.y),this.max=new r(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const i=this.min,n=this.max;e.x<i.x?i.x=e.x:e.x>n.x&&(n.x=e.x),e.y<i.y?i.y=e.y:e.y>n.y&&(n.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,_i(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ba!=e.x>ba&&this.addBorderIntersection(1,_i(t.y,e.y,(ba-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,_i(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ba!=e.y>ba&&this.addBorderIntersection(3,_i(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 i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){const e=this.polyCount.reduce(((e,t)=>e+t.edges),0);return 0!==e?this.acc.div(e)._round():new r(0,0)}span(){return new r(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 yu{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 Fs,this.indexArray=new fs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.enableTerrain=e.enableTerrain}populate(e,t,i,n){this.features=[],this.hasPattern=Zc("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:r,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ga(r,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Va(r,i,n),properties:r.properties,type:r.type,patterns:{}},u=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,n),t.featureIndex.insert(r,c.geometry,s,a,this.index,u)}this.sortBorders()}addFeatures(e,t,i,n,r){for(const e of this.features){const{geometry:o}=e;this.addFeature(e,o,e.index,t,i,n,r)}this.sortBorders()}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,iu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,tu.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,eu.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(e,t,i,n,o,s,a){const l=[new r(0,0),new r(ba,ba)],c=a.projection,u="globe"===c.name,h=this.enableTerrain&&!u?new _u:null;u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ss);const p=qc(t,500);for(let e=p.length-1;e>=0;e--){const t=p[e];(0===t.length||(d=t[0]).every((e=>e.x<=0))||d.every((e=>e.x>=ba))||d.every((e=>e.y<=0))||d.every((e=>e.y>=ba)))&&p.splice(e,1)}var d;let f;if(u)f=bu(p,l,n);else{f=[];for(const e of p)f.push({polygon:e,bounds:l})}for(const t of f){const i=t.polygon;let r=0,o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let e=0;e<i.length;e++){const s=i[e];if(0===s.length)continue;r+=s.length;let a=0;h&&h.startRing(s[0]);for(let e=0;e<s.length;e++){const i=s[e];if(e>=1){const r=s[e-1];if(!vu(i,r,t.bounds)){h&&h.append(i,r),o.vertexLength+4>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const e=i.sub(r)._perp(),t=e.x/(Math.abs(e.x)+Math.abs(e.y)),s=e.y>0?1:0,l=r.dist(i);a+l>32768&&(a=0),mu(this.layoutVertexArray,i.x,i.y,t,s,0,0,a),mu(this.layoutVertexArray,i.x,i.y,t,s,0,1,a),a+=l,mu(this.layoutVertexArray,r.x,r.y,t,s,0,0,a),mu(this.layoutVertexArray,r.x,r.y,t,s,0,1,a);const p=o.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),o.vertexLength+=4,o.primitiveLength+=2,u){const e=this.layoutVertexExtArray,t=c.projectTilePoint(i.x,i.y,n),o=c.projectTilePoint(r.x,r.y,n),s=c.upVector(n,i.x,i.y),a=c.upVector(n,r.x,r.y);gu(e,t,s),gu(e,t,s),gu(e,o,a),gu(e,o,a)}}}}}if(o.vertexLength+r>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(r,this.layoutVertexArray,this.indexArray)),"Polygon"!==du[e.type])continue;const s=[],a=[],l=o.vertexLength;for(let e=0;e<i.length;e++){const t=i[e];if(0!==t.length){t!==i[0]&&a.push(s.length/2);for(let e=0;e<t.length;e++){const i=t[e];mu(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),s.push(i.x),s.push(i.y),h&&h.currentPolyCount.top++,u&&gu(this.layoutVertexExtArray,c.projectTilePoint(i.x,i.y,n),c.upVector(n,i.x,i.y))}}}const p=fc(s,a);for(let e=0;e<p.length;e+=3)this.indexArray.emplaceBack(l+p[e],l+p[e+2],l+p[e+1]);o.primitiveLength+=p.length/3,o.vertexLength+=r}if(h&&h.polyCount.length>0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const e=h.borders,t=this.featuresOnBorder.push(h)-1;for(let i=0;i<4;i++)e[i][0]!==Number.MAX_VALUE&&this.borders[i].push(t)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,o,s,n)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort(((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}encodeCentroid(e,t,i=!0){let n,r;if(e)if(0!==e.y){const i=t.span()._mult(this.tileToMeter);n=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(i.x/10)),r=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else n=Math.ceil(7*(e.x+450)),r=0;else n=0,r=+i;let o=i?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;t<2*e.edges;t++)this.centroidVertexArray.emplace(o++,0,r),this.centroidVertexArray.emplace(o++,n,r);for(let t=0;t<e.top;t++)this.centroidVertexArray.emplace(o++,n,r)}}}function vu(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 xu(){const e=Math.PI/32,t=Math.tan(e),i=Ma;return i*Math.sqrt(1+2*t*t)-i}function bu(e,t,i){const n=1<<i.z,o=Ia(i.x/n),s=Ia((i.x+1)/n),a=Pa(i.y/n),l=Pa((i.y+1)/n);return function(e,t,i,n,o=0,s){const a=[];if(!e.length||!i||!n)return a;const l=(e,t)=>{for(const i of e)a.push({polygon:i,bounds:t})},c=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(n)),h=c-u,p=[];for(let e=0;e<Math.abs(h);e++)p.push(h>0?0:1);for(let e=0;e<Math.min(c,u);e++)p.push(0),p.push(1);let d=e;if(d=pu(d,t[0].y-o,t[1].y+o,1),d=pu(d,t[0].x-o,t[1].x+o,0),!d.length)return a;const f=[];for(p.length?f.push({polygons:d,bounds:t,depth:0}):l(d,t);f.length;){const e=f.pop(),t=e.depth,i=p[t],n=e.bounds[0],a=e.bounds[1],c=0===i?n.x:n.y,u=0===i?a.x:a.y,h=s?s(i,c,u):.5*(c+u),d=pu(e.polygons,c-o,h+o,i),m=pu(e.polygons,h-o,u+o,i);if(d.length){const e=[n,new r(0===i?h:a.x,1===i?h:a.y)];p.length>t+1?f.push({polygons:d,bounds:e,depth:t+1}):l(d,e)}if(m.length){const e=[new r(0===i?h:n.x,1===i?h:n.y),a];p.length>t+1?f.push({polygons:m,bounds:e,depth:t+1}):l(m,e)}}return a}(e,t,Math.ceil((s-o)/11.25),Math.ceil((a-l)/11.25),1,((e,t,r)=>{if(0===e)return.5*(t+r);{const e=Pa((i.y+t/ba)/n);return(Ca(.5*(Pa((i.y+r/ba)/n)+e))*n-i.y)*ba}}))}Pr(yu,"FillExtrusionBucket",{omit:["layers","features"]}),Pr(_u,"PartMetadata");var wu={paint:new Wo({"fill-extrusion-opacity":new Uo(He["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new jo(He["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Uo(He["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Uo(He["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Vo(He["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new jo(He["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new jo(He["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Uo(He["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Mu(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class Tu{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Au(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 n=Mu(256*e,256*(t=Math.pow(2,i)-t-1),i),r=Mu(256*(e+1),256*(t+1),i);return n[0]+","+n[1]+","+r[0]+","+r[1]}(this.x,this.y,this.z),n=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<<o-1,r+=(t&n?1:0)+(i&n?2:0);return r}(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}",n).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Su{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Au(e,t.z,t.z,t.x,t.y)}}class Eu{constructor(e,t,i,n,r){this.overscaledZ=e,this.wrap=t,this.canonical=new Tu(i,+n,+r),this.key=0===t&&e===i?this.canonical.key:Au(t,e,i,n,r)}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 Eu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Eu(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 Au(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Au(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 Eu(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,n=2*this.canonical.y;return[new Eu(t,this.wrap,t,i,n),new Eu(t,this.wrap,t,i+1,n),new Eu(t,this.wrap,t,i,n+1),new Eu(t,this.wrap,t,i+1,n+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 Eu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Eu(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 Su(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Au(e,t,i,n,r){const o=1<<Math.min(i,22);let s=o*(r%o)+n%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 Cu(e,t){return e.x*t.x+e.y*t.y}function Lu(e,t){if(1===e.length){let i=0;const n=t[i++];let r;for(;!r||n.equals(r);)if(r=t[i++],!r)return 1/0;for(;i<t.length;i++){const o=t[i],s=e[0],a=r.sub(n),l=o.sub(n),c=s.sub(n),u=Cu(a,a),h=Cu(a,l),p=Cu(l,l),d=Cu(c,a),f=Cu(c,l),m=u*p-h*h,g=(p*d-h*f)/m,_=(u*f-h*d)/m,y=n.z*(1-g-_)+r.z*g+o.z*_;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function Iu(e){const t=new r(e[0],e[1]);return t.z=e[2],t}function Pu(e,t,i,n,r,o,s,a){const l=s*r.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/7-450):s*function(e,t,i){const n=Math.floor(t[0]/8),r=Math.floor(t[1]/8),o=10*(t[0]-8*n),s=10*(t[1]-8*r),a=e.getElevationAt(n,r,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=e.tileCoordToPixel(n,r),p=2*c+1,d=2*u+1,f=function(e,t,i,n,r){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+r,i,!0),e.getElevationAtPixel(t,i+r,!0),e.getElevationAtPixel(t+n,i+r,!0)]}(e,h.x-c,h.y-u,p,d),m=Math.abs(f[0]-f[1]),g=Math.abs(f[2]-f[3]),_=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+g)/p),v=Math.min(.25,.5*l*_/d);return a+Math.max(y*o,v*s)}(r,o,a):l;return{base:l+(0===i)?-1:i,top:c?Math.max(u+n,l+i+2):l+n}}Pr(Tu,"CanonicalTileID"),Pr(Eu,"OverscaledTileID",{omit:["projMatrix"]});const Ru=Yo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:ku}=Ru,zu=Yo([{name:"a_packed",components:4,type:"Float32"}]),{members:Du}=zu,Ou=hu.VectorTileFeature.types,Fu=Math.cos(Math.PI/180*37.5);class Bu{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 ua(e.layers,e.zoom),this.segments=new xa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,n){this.hasPattern=Zc("line",this.layers,t);const r=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 Po(this.zoom),c,i))continue;const u=r?r.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:c}=n;if(l&&this.addFeatureDashes(n,s),this.hasPattern){const e=Xc("line",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,s.positions,t.availableImages);a.insert(e[o].feature,r,o,c,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)t=!0;else{const t=r.value,i=n.value;if(!i)continue;e.addDash(i.from,t),e.addDash(i.to,t),i.other&&e.addDash(i.other,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a,l,c,u,h;if("constant"===r.kind){const e=r.value;if(!e)continue;s=e.other||e.to,a=e.to,l=e.from}else s=r.evaluate({zoom:i-1},e),a=r.evaluate({zoom:i},e),l=r.evaluate({zoom:i+1},e);"constant"===o.kind?c=u=h=o.value:(c=o.evaluate({zoom:i-1},e),u=o.evaluate({zoom:i},e),h=o.evaluate({zoom:i+1},e)),t.addDash(s,c),t.addDash(a,u),t.addDash(l,h);const p=t.getKey(s,c),d=t.getKey(a,u),f=t.getKey(l,h);e.patterns[n.id]={min:p,mid:d,max:f}}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,n)}addFeatures(e,t,i,n,r){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,n)}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,Du)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ku),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,n,r,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"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,o,n)}addLine(e,t,i,n,r,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const s="Polygon"===Ou[t.type];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;let l=0;for(;l<a-1&&e[l].equals(e[l+1]);)l++;if(a<(s?3:2))return;"bevel"===i&&(r=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,u=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let h,p,d,f,m;this.e1=this.e2=-1,s&&(h=e[a-2],m=e[l].sub(h)._unit()._perp());for(let t=l;t<a;t++){if(d=t===a-1?s?e[l+1]:void 0:e[t+1],d&&e[t].equals(d))continue;m&&(f=m),h&&(p=h),h=e[t],m=d?d.sub(h)._unit()._perp():f,f=f||m;let g=f.add(m);0===g.x&&0===g.y||g._unit();const _=f.x*m.x+f.y*m.y,y=g.x*m.x+g.y*m.y,v=0!==y?1/y:1/0,x=2*Math.sqrt(2-2*y),b=y<Fu&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&t>l){const e=h.dist(p);if(e>2*c){const t=h.sub(h.sub(p)._mult(c/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,f,0,0,u),p=t}}const M=p&&d;let T=M?i:s?"butt":n;if(M&&"round"===T&&(v<o?T="miter":v<=2&&(T="fakeround")),"miter"===T&&v>r&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v<r&&(T="miter")),p&&this.updateDistance(p,h),"miter"===T)g._mult(v),this.addCurrentVertex(h,g,0,0,u);else if("flipbevel"===T){if(v>100)g=m.mult(-1);else{const e=v*f.add(m).mag()/f.sub(m).mag();g._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,g,0,0,u),this.addCurrentVertex(h,g.mult(-1),0,0,u)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(v*v-1),t=w?e:0,i=w?0:e;if(p&&this.addCurrentVertex(h,f,t,i,u),"fakeround"===T){const e=Math.round(180*x/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+_*(_*(3.55645-1.43519*_)-3.2452))*e*e+(.848013+_*(.215638*_-1.06021)))}const n=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(h,n.x,n.y,!1,w,0,u)}}d&&this.addCurrentVertex(h,m,-t,-i,u)}else if("butt"===T)this.addCurrentVertex(h,g,0,0,u);else if("square"===T){const e=p?1:-1;p||this.addCurrentVertex(h,g,e,e,u),this.addCurrentVertex(h,g,0,0,u),p&&this.addCurrentVertex(h,g,e,e,u)}else"round"===T&&(p&&(this.addCurrentVertex(h,f,0,0,u),this.addCurrentVertex(h,f,1,1,u,!0)),d&&(this.addCurrentVertex(h,m,-1,-1,u,!0),this.addCurrentVertex(h,m,0,0,u)));if(b&&t<a-1){const e=h.dist(d);if(e>2*c){const t=h.add(d.sub(h)._mult(c/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,u),h=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r)}addHalfVertex({x:e,y:t},i,n,r,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+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()}}Pr(Bu,"LineBucket",{omit:["layers","patternFeatures"]});const Nu=new Wo({"line-cap":new jo(He.layout_line["line-cap"]),"line-join":new jo(He.layout_line["line-join"]),"line-miter-limit":new Uo(He.layout_line["line-miter-limit"]),"line-round-limit":new Uo(He.layout_line["line-round-limit"]),"line-sort-key":new jo(He.layout_line["line-sort-key"])});var Uu={paint:new Wo({"line-opacity":new jo(He.paint_line["line-opacity"]),"line-color":new jo(He.paint_line["line-color"]),"line-translate":new Uo(He.paint_line["line-translate"]),"line-translate-anchor":new Uo(He.paint_line["line-translate-anchor"]),"line-width":new jo(He.paint_line["line-width"]),"line-gap-width":new jo(He.paint_line["line-gap-width"]),"line-offset":new jo(He.paint_line["line-offset"]),"line-blur":new jo(He.paint_line["line-blur"]),"line-dasharray":new Vo(He.paint_line["line-dasharray"]),"line-pattern":new Vo(He.paint_line["line-pattern"]),"line-gradient":new Ho(He.paint_line["line-gradient"]),"line-trim-offset":new Uo(He.paint_line["line-trim-offset"])}),layout:Nu};const ju=new class extends jo{possiblyEvaluate(e,t){return t=new Po(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=v({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}(Uu.paint.properties["line-width"].specification);function Vu(e,t){return t>0?t+2*e:e}ju.useIntegerZoom=!0;const Gu=Yo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Hu=Yo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Wu=Yo([{name:"a_projected_pos",components:4,type:"Float32"}],4);Yo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const qu=Yo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),$u=Yo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Yo([{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 Zu=Yo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Xu=Yo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Yo([{name:"triangle",components:3,type:"Uint16"}]),Yo([{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"}]),Yo([{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"}]),Yo([{type:"Float32",name:"offsetX"}]),Yo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Yu=24;const Ju=128;function Qu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Po(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;r<t.length&&t[r]<=e;)r++;r=Math.max(0,r-1);let o=r;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const s=t[r],a=t[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:n}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new Po(s)),maxSize:i.evaluate(new Po(a)),interpolationType:n}}}function Ku(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/Ju:"composite"===e.kind?_i(n/Ju,r/Ju,i):t}function eh(e,t){let i=0,n=0;if("constant"===e.kind)n=e.layoutSize;else if("source"!==e.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=e,a=r?f(Bi.interpolationFactor(r,t,o,s),0,1):0;"camera"===e.kind?n=_i(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:n}}var th=Object.freeze({__proto__:null,getSizeData:Qu,evaluateSizeForFeature:Ku,evaluateSizeForZoom:eh,SIZE_PACK_FACTOR:Ju});function ih(e,t,i){return e.sections.forEach((e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,i)})),e}const nh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function rh(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function oh(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var sh=function(e,t,i,n,r){var o,s,a=8*r-n-1,l=(1<<a)-1,c=l>>1,u=-7,h=i?r-1:0,p=i?-1:1,d=e[t+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},ah=function(e,t,i,n,r,o){var s,a,l,c=8*o-r-1,u=(1<<c)-1,h=u>>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,f=n?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=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*l-1)*Math.pow(2,r),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,r),s=0));r>=8;e[i+d]=255&a,d+=f,a/=256,r-=8);for(s=s<<r|a,c+=r;c>0;e[i+d]=255&s,d+=f,s/=256,c-=8);e[i+d-f]|=128*m},lh=ch;function ch(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}ch.Varint=0,ch.Fixed64=1,ch.Bytes=2,ch.Fixed32=5;var uh=4294967296,hh=1/uh,ph="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function dh(e){return e.type===ch.Bytes?e.readVarint()+e.pos:e.pos+1}function fh(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function mh(e,t,i){var n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(var r=i.pos-1;r>=e;r--)i.buf[r+n]=i.buf[r]}function gh(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function _h(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function yh(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function vh(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function xh(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function bh(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function wh(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Mh(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function Th(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Sh(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Eh(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Ah(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Ch(e,t,i){t.glyphs=[],1===e&&i.readMessage(Lh,t)}function Lh(e,t,i){if(3===e){const{id:e,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Ih,{});t.glyphs.push({id:e,bitmap:new ac({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Ih(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 Ph(e){let t=0,i=0;for(const n of e)t+=n.w*n.h,i=Math.max(i,n.w);e.sort(((e,t)=>t.h-e.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();e<n.length&&(n[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):(n.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:r,h:o,fill:t/(r*o)||0}}ch.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var n=this.readVarint(),r=n>>3,o=this.pos;this.type=7&n,e(r,t,this),this.pos===o&&this.skip(n)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Sh(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Ah(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Sh(this.buf,this.pos)+Sh(this.buf,this.pos+4)*uh;return this.pos+=8,e},readSFixed64:function(){var e=Sh(this.buf,this.pos)+Ah(this.buf,this.pos+4)*uh;return this.pos+=8,e},readFloat:function(){var e=sh(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=sh(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,n=this.buf;return t=127&(i=n[this.pos++]),i<128?t:(t|=(127&(i=n[this.pos++]))<<7,i<128?t:(t|=(127&(i=n[this.pos++]))<<14,i<128?t:(t|=(127&(i=n[this.pos++]))<<21,i<128?t:function(e,t,i){var n,r,o=i.buf;if(n=(112&(r=o[i.pos++]))>>4,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<3,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<10,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<17,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<24,r<128)return fh(e,n,t);if(n|=(1&(r=o[i.pos++]))<<31,r<128)return fh(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=n[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&ph?function(e,t,i){return ph.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var n="",r=t;r<i;){var o,s,a,l=e[r],c=null,u=l>239?4:l>223?3:l>191?2:1;if(r+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(o=e[r+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(s=e[r+2],128==(192&(o=e[r+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=e[r+2],a=e[r+3],128==(192&(o=e[r+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,u=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=u}return n}(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!==ch.Bytes)return e.push(this.readVarint(t));var i=dh(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==ch.Bytes)return e.push(this.readSVarint());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==ch.Bytes)return e.push(this.readBoolean());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==ch.Bytes)return e.push(this.readFloat());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==ch.Bytes)return e.push(this.readDouble());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==ch.Bytes)return e.push(this.readFixed32());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==ch.Bytes)return e.push(this.readSFixed32());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==ch.Bytes)return e.push(this.readFixed64());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==ch.Bytes)return e.push(this.readSFixed64());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===ch.Varint)for(;this.buf[this.pos++]>127;);else if(t===ch.Bytes)this.pos=this.readVarint()+this.pos;else if(t===ch.Fixed32)this.pos+=4;else{if(t!==ch.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),Eh(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Eh(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Eh(this.buf,-1&e,this.pos),Eh(this.buf,Math.floor(e*hh),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Eh(this.buf,-1&e,this.pos),Eh(this.buf,Math.floor(e*hh),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(n=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,n=n+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)))))}(n,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var n,r,o=0;o<t.length;o++){if((n=t.charCodeAt(o))>55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&mh(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),ah(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),ah(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 n=this.pos-i;n>=128&&mh(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(e,t,i){this.writeTag(e,ch.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,gh,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,_h,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,xh,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,yh,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,vh,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,bh,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,wh,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Mh,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Th,t)},writeBytesField:function(e,t){this.writeTag(e,ch.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,ch.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,ch.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,ch.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,ch.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,ch.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,ch.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,ch.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,ch.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,ch.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class Rh{constructor(e,{pixelRatio:t,version:i,stretchX:n,stretchY:r,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=n,this.stretchY=r,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 kh{constructor(e,t){const i={},n={};this.haveRenderCallbacks=[];const r=[];this.addImages(e,i,r),this.addImages(t,n,r);const{w:o,h:s}=Ph(r),a=new lc({width:o||1,height:s||1});for(const t in e){const n=e[t],r=i[t].paddedRect;lc.copy(n.data,a,{x:0,y:0},{x:r.x+1,y:r.y+1},n.data)}for(const e in t){const i=t[e],r=n[e].paddedRect,o=r.x+1,s=r.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=n}addImages(e,t,i){for(const n in e){const r=e[n],o={x:0,y:0,w:r.data.width+2,h:r.data.height+2};i.push(o),t[n]=new Rh(o,r),r.hasRenderCallback&&this.haveRenderCallbacks.push(n)}}patchUpdatedImages(e,t){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t))),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[n,r]=e.tl;i.update(t.data,void 0,{x:n,y:r})}}Pr(Rh,"ImagePosition"),Pr(kh,"ImageAtlas");const zh={horizontal:1,vertical:2,horizontalOnly:3};class Dh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const i=new Dh;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new Dh;return t.imageName=e,t}}class Oh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const i=new Oh;for(let n=0;n<e.sections.length;n++){const r=e.sections[n];r.image?i.addImageSection(r):i.addTextSection(r,t)}return i}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(e,t){let i="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n+1)||null,o=e.charCodeAt(n-1)||null;i+=!t&&(r&&mo(r)&&!nh[e[n+1]]||o&&mo(o)&&!nh[e[n-1]])||!nh[e[n]]?e[n]:nh[e[n]]}return i}(this.text,e)}trim(){let e=0;for(let t=0;t<this.text.length&&Bh[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let i=this.text.length-1;i>=0&&i>=e&&Bh[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new Oh;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(e,t){this.text+=e.text,this.sections.push(Dh.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(i)}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void P("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(Dh.forImage(t)),this.sectionIndex.push(this.sections.length-1)):P("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Fh(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=Oh.fromFeature(e,r);let _;h===zh.vertical&&g.verticalizePunctuation(p);const{processBidirectionalText:y,processStyledBidirectionalText:v}=Io;if(y&&1===g.sections.length){_=[];const e=y(g.toString(),Wh(g,c,o,t,n,d,f));for(const t of e){const e=new Oh;e.text=t,e.sections=g.sections;for(let i=0;i<t.length;i++)e.sectionIndex.push(0);_.push(e)}}else if(v){_=[];const e=v(g.text,g.sectionIndex,Wh(g,c,o,t,n,d,f));for(const t of e){const e=new Oh;e.text=t[0],e.sectionIndex=t[1],e.sections=g.sections,_.push(e)}}else _=function(e,t){const i=[],n=e.text;let r=0;for(const n of t)i.push(e.substring(r,n)),r=n;return r<n.length&&i.push(e.substring(r,n.length)),i}(g,Wh(g,c,o,t,n,d,f));const x=[],b={positionedLines:x,text:g.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(e,t,i,n,r,o,s,a,l,c,u,h){let p=0,d=0,f=0;const m="right"===a?1:"left"===a?0:.5;let g=!1;for(const e of r){const i=e.getSections();for(const e of i){if(e.imageName)continue;const i=t[e.fontStack];if(i&&(g=void 0!==i.ascender&&void 0!==i.descender,!g))break}if(!g)break}let _=0;for(const s of r){s.trim();const r=s.getMaxScale(),a=(r-1)*Yu,v={positionedGlyphs:[],lineOffset:0};e.positionedLines[_]=v;const x=v.positionedGlyphs;let b=0;if(!s.length()){d+=o,++_;continue}let w=0,M=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCharCode(o);let _=a.scale,v=null,T=null,S=null,E=Yu,A=0;const C=!(l===zh.horizontal||!u&&!fo(m)||u&&(Bh[m]||(y=m,Fr(y)||Br(y)||Nr(y)||ro(y)||lo(y))));if(a.imageName){const t=n[a.imageName];if(!t)continue;S=a.imageName,e.iconsInText=e.iconsInText||!0,T=t.paddedRect;const i=t.displaySize;_=_*Yu/h,v={width:i[0],height:i[1],left:1,top:-3,advance:C?i[1]:i[0],localGlyph:!1},A=g?-v.height*_:r*Yu-17-i[1]*_,E=v.advance;const o=(C?i[0]:i[1])*_-Yu*r;o>0&&o>b&&(b=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(T=e[m]);const n=t[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Yu:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,i=(e+t)*_;w<i&&(w=i,M=(e-t)/2*_),A=-e*_}else A=(r-_)*Yu-17}C?(e.verticalizable=!0,x.push({glyph:m,imageName:S,x:p,y:d+A,vertical:C,scale:_,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:T}),p+=E*_+c):(x.push({glyph:m,imageName:S,x:p,y:d+A,vertical:C,scale:_,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:T}),p+=v.advance*_+c)}0!==x.length&&(f=Math.max(p-c,f),g?$h(x,m,b,M,o*r/2):$h(x,m,b,0,o/2)),p=0;const T=o*r+b;v.lineOffset=Math.max(b,a),d+=T,++_}var y;const v=d,{horizontalAlign:x,verticalAlign:b}=qh(s);(function(e,t,i,n,r,o){const s=(t-i)*r,a=-o*n;for(const t of e)for(const e of t.positionedGlyphs)e.x+=s,e.y+=a})(e.positionedLines,m,x,b,f,v),e.top+=-b*v,e.bottom=e.top+v,e.left+=-x*f,e.right=e.left+f,e.hasBaseline=g}(b,t,i,n,_,s,a,l,h,c,p,m),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(x)&&b}const Bh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Nh={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 Uh(e,t,i,n,r,o){if(t.imageName){const e=n[t.imageName];return e?e.displaySize[0]*t.scale*Yu/o+r:0}{const n=i[t.fontStack],o=n&&n.glyphs[e];return o?o.metrics.advance*t.scale+r:0}}function jh(e,t,i,n){const r=Math.pow(e-t,2);return n?e<t?r/2:2*r:r+Math.abs(i)*i}function Vh(e,t,i){let n=0;return 10===e&&(n-=1e4),i&&(n+=150),40!==e&&65288!==e||(n+=50),41!==t&&65289!==t||(n+=50),n}function Gh(e,t,i,n,r,o){let s=null,a=jh(t,i,r,o);for(const e of n){const n=jh(t-e.x,i,r,o)+e.badness;n<=a&&(s=e,a=n)}return{index:e,x:t,priorBreak:s,badness:a}}function Hh(e){return e?Hh(e.priorBreak).concat(e.index):[]}function Wh(e,t,i,n,r,o,s){if("point"!==o)return[];if(!e)return[];const a=[],l=function(e,t,i,n,r,o){let s=0;for(let i=0;i<e.length();i++){const a=e.getSection(i);s+=Uh(e.getCharCode(i),a,n,r,t,o)}return s/Math.max(1,Math.ceil(s/i))}(e,t,i,n,r,s),c=e.text.indexOf("")>=0;let u=0;for(let i=0;i<e.length();i++){const o=e.getSection(i),p=e.getCharCode(i);if(Bh[p]||(u+=Uh(p,o,n,r,t,s)),i<e.length()-1){const t=!((h=p)<11904||!($r(h)||qr(h)||so(h)||no(h)||Jr(h)||Ur(h)||Zr(h)||Gr(h)||Qr(h)||Kr(h)||Yr(h)||co(h)||Hr(h)||Vr(h)||jr(h)||Xr(h)||Wr(h)||oo(h)||to(h)||eo(h)));(Nh[p]||t||o.imageName)&&a.push(Gh(i+1,u,l,a,Vh(p,e.getCharCode(i+1),t&&c),!1))}}var h;return Hh(Gh(e.length(),u,l,a,0,!0))}function qh(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 $h(e,t,i,n,r){if(!(t||i||n||r))return;const o=e.length-1,s=e[o],a=(s.x+s.metrics.advance*s.scale)*t;for(let t=0;t<=o;t++)e[t].x-=a,e[t].y+=i+n+r}function Zh(e,t,i){const{horizontalAlign:n,verticalAlign:r}=qh(i),o=t[0]-e.displaySize[0]*n,s=t[1]-e.displaySize[1]*r;return{image:e,top:s,bottom:s+e.displaySize[1],left:o,right:o+e.displaySize[0]}}function Xh(e,t,i,n,r,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 u,h,p,d;"width"===i||"both"===i?(d=r[0]+l-n[3],h=r[0]+c+n[1]):(d=r[0]+(l+c-s.displaySize[0])/2,h=d+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=r[1]+f-n[0],p=r[1]+m+n[2]):(u=r[1]+(f+m-s.displaySize[1])/2,p=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:p,left:d,collisionPadding:a}}class Yh extends r{constructor(e,t,i,n,r){super(e,t),this.angle=n,this.z=i,void 0!==r&&(this.segment=r)}clone(){return new Yh(this.x,this.y,this.z,this.angle,this.segment)}}function Jh(e,t,i,n,r){if(void 0===t.segment)return!0;let o=t,s=t.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const t=e[s],i=e[s+1];if(!i)return!1;let o=e[s-1].angleTo(t)-t.angleTo(i);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>n;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function Qh(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function Kh(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(e,t,i,n,r,o){const s=Kh(i,r,o),a=ep(i,n)*o;let l=0;const c=Qh(e)/2;for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1],o=n.dist(r);if(l+o>c){const u=(c-l)/o,h=_i(n.x,r.x,u),p=_i(n.y,r.y,u),d=new Yh(h,p,0,r.angleTo(n),i);return!s||Jh(e,d,a,s,t)?d:void 0}l+=o}}function ip(e,t,i,n,r,o,s,a,l){const c=Kh(n,o,s),u=ep(n,r),h=u*s,p=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h<t/4&&(t=h+t/4),np(e,p?t/2*a%t:(u/2+2*o)*s*a%t,t,c,i,h,p,!1,l)}function np(e,t,i,n,r,o,s,a,l){const c=o/2,u=Qh(e);let h=0,p=t-i,d=[];for(let t=0;t<e.length-1;t++){const s=e[t],a=e[t+1],f=s.dist(a),m=a.angleTo(s);for(;p+i<h+f;){p+=i;const g=(p-h)/f,_=_i(s.x,a.x,g),y=_i(s.y,a.y,g);if(_>=0&&_<l&&y>=0&&y<l&&p-c>=0&&p+c<=u){const i=new Yh(_,y,0,m,t);i._round(),n&&!Jh(e,i,o,n,r)||d.push(i)}}h+=f}return a||d.length||s||(d=np(e,h/2,i,n,r,o,s,!0,l)),d}function rp(e,t,i,n,o){const s=[];for(let a=0;a<e.length;a++){const l=e[a];let c;for(let e=0;e<l.length-1;e++){let a=l[e],u=l[e+1];a.x<t&&u.x<t||(a.x<t?a=new r(t,a.y+(t-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x<t&&(u=new r(t,a.y+(t-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y<i&&u.y<i||(a.y<i?a=new r(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y<i&&(u=new r(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),a.x>=n&&u.x>=n||(a.x>=n?a=new r(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=n&&(u=new r(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new r(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new r(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}Pr(Yh,"Anchor");const op=1e20;function sp(e,t,i,n,r,o,s,a,l){for(let c=t;c<t+n;c++)ap(e,i*o+c,o,r,s,a,l);for(let c=i;c<i+r;c++)ap(e,c*o+t,1,n,s,a,l)}function ap(e,t,i,n,r,o,s){o[0]=0,s[0]=-op,s[1]=op,r[0]=e[t];for(let a=1,l=0,c=0;a<n;a++){r[a]=e[t+a*i];const n=a*a;do{const e=o[l];c=(r[a]-r[e]+n-e*e)/(a-e)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=op}for(let a=0,l=0;a<n;a++){for(;s[l+1]<a;)l++;const n=o[l],c=a-n;e[t+a*i]=r[n]+c*c}}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,t){const i=[];for(const t in e)for(const n of e[t])i.push({stack:t,id:n});_(i,(({stack:e,id:t},i)=>{let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[t];if(void 0!==r)return void i(null,{stack:e,id:t,glyph:r});if(r=this._tinySDF(n,e,t),r)return n.glyphs[t]=r,void i(null,{stack:e,id:t,glyph:r});const o=Math.floor(t/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[o])return void i(null,{stack:e,id:t,glyph:r});let s=n.requests[o];s||(s=n.requests[o]=[],cp.loadGlyphRange(e,o,this.url,this.requestManager,((e,t)=>{if(t){n.ascender=t.ascender,n.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=t.glyphs[+e]);n.ranges[o]=!0}for(const i of s)i(e,t);delete n.requests[o]}))),s.push(((n,r)=>{n?i(n):r&&i(null,{stack:e,id:t,glyph:r.glyphs[t]||null})}))}),((e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:n,glyph:r}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==lp.none&&(this.localGlyphMode===lp.all?!!this.localFontFamily:!!this.localFontFamily&&(Kr(e)||io(e)||Hr(e)||Wr(e)||Gr(e)))}_tinySDF(e,t,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=e.tinySDF;if(!r){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),r=e.tinySDF=new cp.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCharCode(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new ac({width:a,height:l},s),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function up(e,t,i,n){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,u=e.right-e.left,h=e.bottom-e.top,p=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],f=(e,t)=>e+t[1]-t[0],m=p.reduce(f,0),g=d.reduce(f,0),_=l-m,y=c-g;let v=0,x=m,b=0,w=g,M=0,T=_,S=0,E=y;if(s.content&&n){const e=s.content;v=hp(p,0,e[0]),b=hp(d,0,e[1]),x=hp(p,e[0],e[2]),w=hp(d,e[1],e[3]),M=e[0]-v,S=e[1]-b,T=e[2]-e[0]-x,E=e[3]-e[1]-w}const A=(n,o,l,c)=>{const p=dp(n.stretch-v,x,u,e.left),d=fp(n.fixed-M,T,n.stretch,m),f=dp(o.stretch-b,w,h,e.top),_=fp(o.fixed-S,E,o.stretch,g),y=dp(l.stretch-v,x,u,e.left),A=fp(l.fixed-M,T,l.stretch,m),C=dp(c.stretch-b,w,h,e.top),L=fp(c.fixed-S,E,c.stretch,g),I=new r(p,f),P=new r(y,f),R=new r(y,C),k=new r(p,C),z=new r(d/a,_/a),D=new r(A/a,L/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];I._matMult(i),P._matMult(i),k._matMult(i),R._matMult(i)}const F=n.stretch+n.fixed,B=o.stretch+o.fixed;return{tl:I,tr:P,bl:k,br:R,tex:{x:s.paddedRect.x+1+F,y:s.paddedRect.y+1+B,w:l.stretch+l.fixed-F,h:c.stretch+c.fixed-B},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:z,pixelOffsetBR:D,minFontScaleX:T/a/u,minFontScaleY:E/a/h,isSDF:i}};if(n&&(s.stretchX||s.stretchY)){const e=pp(p,_,m),t=pp(d,y,g);for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)o.push(A(n,t[e],r,t[e+1]))}}else o.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function hp(e,t,i){let n=0;for(const r of e)n+=Math.max(t,Math.min(i,r[1]))-Math.max(t,Math.min(i,r[0]));return n}function pp(e,t,i){const n=[{fixed:-1,stretch:0}];for(const[t,i]of e){const e=n[n.length-1];n.push({fixed:t-e.stretch,stretch:e.stretch}),n.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return n.push({fixed:t+1,stretch:i}),n}function dp(e,t,i,n){return e/t*i+n}function fp(e,t,i,n){return e-t*i/n}function mp(e,t,i,n){const r=t+e.positionedLines[n].lineOffset;return 0===n?i+r/2:i+(r+(t+e.positionedLines[n-1].lineOffset))/2}cp.loadGlyphRange=function(e,t,i,n,r){const o=256*t,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),Ae.Glyphs);Pe(a,((e,t)=>{if(e)r(e);else if(t){const e={},i=function(e){return new lh(e).readFields(Ch,{})}(t);for(const t of i.glyphs)e[t.id]=t;r(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},cp.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=n,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 ${r}`,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(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.min(this.size-this.buffer,Math.ceil(o-r)),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);_.fill(op,0,h),g.fill(0,0,h);for(let e=0;e<l;e++)for(let t=0;t<a;t++){const i=y.data[4*(e*a+t)+3]/255;if(0===i)continue;const n=(e+m)*c+t+m;if(1===i)_[n]=0,g[n]=op;else{const e=.5-i;_[n]=e>0?e*e:0,g[n]=e<0?e*e:0}}sp(_,0,0,c,u,c,this.f,this.v,this.z),sp(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e<h;e++){const t=Math.sqrt(_[e])-Math.sqrt(g[e]);p[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return d}};class gp{constructor(e=[],t=_p){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,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1),o=t[n];const s=n+1;if(s<this.length&&i(t[s],o)<0&&(n=s,o=t[s]),i(o,r)>=0)break;t[e]=o,e=n}t[e]=r}}function _p(e,t){return e<t?-1:e>t?1:0}function yp(e,t=1,i=!1){let n=1/0,o=1/0,s=-1/0,a=-1/0;const l=e[0];for(let e=0;e<l.length;e++){const t=l[e];(!e||t.x<n)&&(n=t.x),(!e||t.y<o)&&(o=t.y),(!e||t.x>s)&&(s=t.x),(!e||t.y>a)&&(a=t.y)}const c=Math.min(s-n,a-o);let u=c/2;const h=new gp([],vp);if(0===c)return new r(n,o);for(let t=n;t<s;t+=c)for(let i=o;i<a;i+=c)h.push(new xp(t+u,i+u,u,e));let p=function(e){let t=0,i=0,n=0;const r=e[0];for(let e=0,o=r.length,s=o-1;e<o;s=e++){const o=r[e],a=r[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,n+=(o.y+a.y)*l,t+=3*l}return new xp(i/t,n/t,0,e)}(e),d=h.length;for(;h.length;){const n=h.pop();(n.d>p.d||!p.d)&&(p=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-p.d<=t||(u=n.h/2,h.push(new xp(n.p.x-u,n.p.y-u,u,e)),h.push(new xp(n.p.x+u,n.p.y-u,u,e)),h.push(new xp(n.p.x-u,n.p.y+u,u,e)),h.push(new xp(n.p.x+u,n.p.y+u,u,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${p.d}`)),p.p}function vp(e,t){return t.max-e.max}function xp(e,t,i,n){this.p=new r(e,t),this.h=i,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;r<t.length;r++){const o=t[r];for(let t=0,r=o.length,s=r-1;t<r;s=t++){const r=o[t],a=o[s];r.y>e.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,el(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}const bp=Number.POSITIVE_INFINITY,wp=Math.sqrt(2);function Mp(e,t){return t[1]!==bp?function(e,t,i){let n=0,r=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,r]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/wp;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function Tp(e,t,i,n,r,o,s,a,l,c){e.createArrays(),e.tilePixelRatio=ba/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const u=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Po(t),a),h["text-size"].possiblyEvaluate(new Po(i),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Po(t),a),h["icon-size"].possiblyEvaluate(new Po(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Po(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Po(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Po(18),a);const d="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const o of e.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=f.evaluate(o,{},a),m=p.layoutTextSize.evaluate(o,{},a),g=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),_=o.text;let y,v=[0,0];if(_){const n=_.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Yu,c=u.get("text-line-height").evaluate(o,{},a)*Yu,p=ho(n)?s:0,f=u.get("text-anchor").evaluate(o,{},a),y=u.get("text-variable-anchor");if(!y){const e=u.get("text-radial-offset").evaluate(o,{},a);v=e?Mp(f,[e*Yu,bp]):u.get("text-offset").evaluate(o,{},a).map((e=>e*Yu))}let x=d?"center":u.get("text-justify").evaluate(o,{},a);const b=u.get("symbol-placement"),w="point"===b,M="point"===b?u.get("text-max-width").evaluate(o,{},a)*Yu:0,T=o=>{e.allowVerticalPlacement&&uo(n)&&(g.vertical=Fh(_,t,i,r,l,M,c,f,o,p,v,zh.vertical,!0,b,m,h))};if(!d&&y){const e="auto"===x?y.map((e=>Sp(e))):[x];let n=!1;for(let o=0;o<e.length;o++){const s=e[o];if(!g.horizontal[s])if(n)g.horizontal[s]=g.horizontal[0];else{const e=Fh(_,t,i,r,l,M,c,"center",s,p,v,zh.horizontal,!1,b,m,h);e&&(g.horizontal[s]=e,n=1===e.positionedLines.length)}}T("left")}else{if("auto"===x&&(x=Sp(f)),w||u.get("text-writing-mode").indexOf("horizontal")>=0||!uo(n)){const e=Fh(_,t,i,r,l,M,c,f,x,p,v,zh.horizontal,!1,b,m,h);e&&(g.horizontal[x]=e)}T("point"===b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const t=n[o.icon.name];t&&(y=Zh(r[o.icon.name],u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),x=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&P("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const b=Lp(g.horizontal)||g.vertical;e.iconsInText||(e.iconsInText=!!b&&b.iconsInText),(b||y)&&Ep(e,o,g,y,n,p,m,0,v,x,s,a,c)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Sp(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 Ep(e,t,i,n,r,o,s,a,c,u,h,p,d){let f=o.textMaxSize.evaluate(t,{},p);void 0===f&&(f=s);const m=e.layers[0].layout,g=m.get("icon-offset").evaluate(t,{},p),_=Lp(i.horizontal)||i.vertical,y="globe"===d.name,v=s/24,x=e.tilePixelRatio*f/24,b=(L=e.overscaling,e.zoom>18&&L>2&&(L>>=1),Math.max(ba/(512*L),1)*m.get("symbol-spacing")),w=m.get("text-padding")*e.tilePixelRatio,M=m.get("icon-padding")*e.tilePixelRatio,T=l(m.get("text-max-angle")),S="map"===m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),E="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),A=m.get("symbol-placement"),C=b/2;var L;const I=m.get("icon-text-fit");let R;n&&"none"!==I&&(e.allowVerticalPlacement&&i.vertical&&(R=Xh(n,i.vertical,I,m.get("icon-text-fit-padding"),g,v)),_&&(n=Xh(n,_,I,m.get("icon-text-fit-padding"),g,v)));const k=(s,a,l)=>{if(a.x<0||a.x>=ba||a.y<0||a.y>=ba)return;let f=null;if(y){const{x:e,y:t,z:i}=d.projectTilePoint(a.x,a.y,l);f={anchor:new Yh(e,t,i,0,void 0),up:d.upVector(l,a.x,a.y)}}!function(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T){const S=e.addToLineVertexArray(t,n);let E,A,C,L,I,R,k,z=0,D=0,O=0,F=0,B=-1,N=-1;const U={};let j=Hs("");const V=i?i.anchor:t;let G=0,H=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,H]=l.layout.get("text-offset").evaluate(x,{},T).map((e=>e*Yu)):(G=l.layout.get("text-radial-offset").evaluate(x,{},T)*Yu,H=bp),e.allowVerticalPlacement&&r.vertical){const e=r.vertical;if(f)R=Pp(e),a&&(k=Pp(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},T)+90;C=Ip(c,V,t,u,h,p,e,d,i,m),a&&(L=Ip(c,V,t,u,h,p,a,_,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},T),r="none"!==l.layout.get("icon-text-fit"),s=up(o,n,w,r),d=a?up(a,n,w,r):void 0;A=Ip(c,V,t,u,h,p,o,_,n),z=4*s.length;const f=e.iconSizeData;let m=null;"source"===f.kind?(m=[Ju*l.layout.get("icon-size").evaluate(x,{},T)],m[0]>Ap&&P(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Ju*b.compositeIconSizes[0].evaluate(x,{},T),Ju*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Ap||m[1]>Ap)&&P(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,m,v,y,x,!1,i,t,S.lineStartIndex,S.lineLength,-1,M,T),B=e.icon.placedSymbolArray.length-1,d&&(D=4*d.length,e.addSymbols(e.icon,d,m,v,y,x,zh.vertical,i,t,S.lineStartIndex,S.lineLength,-1,M,T),N=e.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];E||(j=Hs(o.text),f?I=Pp(o):E=Ip(c,V,t,u,h,p,o,d,l.layout.get("text-rotate").evaluate(x,{},T),m));const a=1===o.positionedLines.length;if(O+=Cp(e,i,t,o,s,l,f,x,m,S,r.vertical?zh.horizontal:zh.horizontalOnly,a?Object.keys(r.horizontal):[n],U,B,b,M,T),a)break}r.vertical&&(F+=Cp(e,i,t,r.vertical,s,l,f,x,m,S,zh.vertical,["vertical"],U,N,b,M,T));let W=-1;const q=(e,t)=>e?Math.max(e,t):t;W=q(I,W),W=q(R,W),W=q(k,W);const $=W>-1?1:0;e.glyphOffsetArray.length>=Bd.MAX_GLYPHS&&P("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(V.x,V.y,V.z,t.x,t.y,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,B,N,j,void 0!==E?E:e.collisionBoxArray.length,void 0!==E?E+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,L||e.collisionBoxArray.length,L?L+1:e.collisionBoxArray.length,u,O,F,z,D,$,0,G,H,W)}(e,a,f,s,i,n,r,R,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,w,S,c,0,M,E,g,t,o,u,h,p)};if("line"===A)for(const r of rp(t.geometry,0,0,ba,ba)){const t=ip(r,b,T,i.vertical||_,n,24,x,e.overscaling,ba);for(const i of t){_&&Rp(e,_.text,C,i)||k(r,i,p)}}else if("line-center"===A){for(const e of t.geometry)if(e.length>1){const t=tp(e,T,i.vertical||_,n,24,x);t&&k(e,t,p)}}else if("Polygon"===t.type)for(const e of qc(t.geometry,0)){const t=yp(e,16);k(e[0],new Yh(t.x,t.y,0,0,void 0),p)}else if("LineString"===t.type)for(const e of t.geometry)k(e,new Yh(e[0].x,e[0].y,0,0,void 0),p);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)k([t],new Yh(t.x,t.y,0,0,void 0),p)}const Ap=32640;function Cp(e,t,i,n,o,s,a,l,c,u,h,p,d,f,m,g,_){const y=function(e,t,i,n,o,s,a,l){const c=[];if(0===t.positionedLines.length)return c;const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=function(e){const t=e[0],i=e[1],n=t*i;return n>0?[t,-i]:n<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let p=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)p-=e.lineOffset;const d=t.positionedLines.length,f=p/d;let m=t.top-i[1];for(let e=0;e<d;++e){const n=t.positionedLines[e];m=mp(t,f,m,e);for(const e of n.positionedGlyphs){if(!e.rect)continue;const n=e.rect||{};let s=4,p=!0,d=1,f=0;if(e.imageName){const t=a[e.imageName];if(!t)continue;if(t.sdf){P("SDF images are not supported in formatted text and will be ignored.");continue}p=!1,d=t.pixelRatio,s=1/d}const g=(o||l)&&e.vertical,_=e.metrics.advance*e.scale/2,y=e.metrics,v=e.rect;if(null===v)continue;l&&t.verticalizable&&(f=e.imageName?_-e.metrics.width*e.scale/2:0);const x=o?[e.x+_,e.y]:[0,0];let b=[0,0],w=[0,0],M=!1;o||(g?(w=[e.x+_+h[0],e.y+h[1]-f],M=!0):b=[e.x+_+i[0],e.y+i[1]-f]);const T=v.w*e.scale/(d*(e.localGlyph?2:1)),S=v.h*e.scale/(d*(e.localGlyph?2:1));let E,A,C,L;if(g){const t=e.y-m,i=new r(-_,_-t),n=-Math.PI/2,o=new r(...w);E=new r(-_+b[0],b[1]),E._rotateAround(n,i)._add(o),E.x+=-t+_,E.y-=(y.left-s)*e.scale;const a=e.imageName?y.advance*e.scale:Yu*e.scale,l=String.fromCharCode(e.glyph);rh(l)?E.x+=(1-s)*e.scale:oh(l)?E.x+=a-y.height*e.scale+(-s-1)*e.scale:E.x+=e.imageName||y.width+2*s===v.w&&y.height+2*s===v.h?(a-S)/2:(a-(y.height+2*s)*e.scale)/2,A=new r(E.x,E.y-T),C=new r(E.x+S,E.y),L=new r(E.x+S,E.y-T)}else{const t=(y.left-s)*e.scale-_+b[0],i=(-y.top-s)*e.scale+b[1],n=t+T,o=i+S;E=new r(t,i),A=new r(n,i),C=new r(t,o),L=new r(n,o)}if(u){let e;e=o?new r(0,0):M?new r(h[0],h[1]):new r(i[0],i[1]),E._rotateAround(u,e),A._rotateAround(u,e),C._rotateAround(u,e),L._rotateAround(u,e)}const I=new r(0,0),R=new r(0,0);c.push({tl:E,tr:A,bl:C,br:L,tex:n,writingMode:t.writingMode,glyphOffset:x,sectionIndex:e.sectionIndex,isSDF:p,pixelOffsetTL:I,pixelOffsetBR:R,minFontScaleX:0,minFontScaleY:0})}}return c}(0,n,c,s,a,l,o,e.allowVerticalPlacement),v=e.textSizeData;let x=null;"source"===v.kind?(x=[Ju*s.layout.get("text-size").evaluate(l,{},_)],x[0]>Ap&&P(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Ju*m.compositeTextSizes[0].evaluate(l,{},_),Ju*m.compositeTextSizes[1].evaluate(l,{},_)],(x[0]>Ap||x[1]>Ap)&&P(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,y,x,c,a,l,h,t,i,u.lineStartIndex,u.lineLength,f,g,_);for(const t of p)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Lp(e){for(const t in e)return e[t];return null}function Ip(e,t,i,n,o,s,a,c,u,h){let p=a.top,d=a.bottom,f=a.left,m=a.right;const g=a.collisionPadding;if(g&&(f-=g[0],p-=g[1],m+=g[2],d+=g[3]),u){const e=new r(f,p),t=new r(m,p),i=new r(f,d),n=new r(m,d),o=l(u);let s=new r(0,0);h&&(s=new r(h[0],h[1])),e._rotateAround(o,s),t._rotateAround(o,s),i._rotateAround(o,s),n._rotateAround(o,s),f=Math.min(e.x,t.x,i.x,n.x),m=Math.max(e.x,t.x,i.x,n.x),p=Math.min(e.y,t.y,i.y,n.y),d=Math.max(e.y,t.y,i.y,n.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,f,p,m,d,c,n,o,s),e.length-1}function Pp(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 Rp(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])<i)return!0}else r[t]=[];return r[t].push(n),!1}const kp=Yo([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),{members:zp}=kp,Dp=Yo([{name:"a_pos_3",components:3,type:"Int16"}]);var Op=Yo([{name:"a_pos",type:"Int16",components:2}]);const Fp=ba/Math.PI/2,Bp=2*La(1,0)*Fp*Math.PI,Np=[64,32,16],Up=-Fp,jp=Fp,Vp=[new Jl([Up,Up,Up],[jp,jp,jp]),new Jl([Up,Up,Up],[0,0,jp]),new Jl([0,Up,Up],[jp,0,jp]),new Jl([Up,0,Up],[0,jp,jp]),new Jl([0,0,Up],[jp,jp,jp])];function Gp(e,t,i,n=!0){const r=Pl([],e._camera.position,e.worldSize),o=[t,i,1,1];Gl(o,o,e.pixelMatrixInverse),Vl(o,o,1/o[3]);const s=kl([],Nl([],o,r)),a=e.globeMatrix,l=[a[12],a[13],a[14]],u=Nl([],l,r),h=Tl(u),p=kl([],u),d=e.worldSize/(2*Math.PI),m=zl(p,s),g=Math.asin(d/h);if(g<Math.acos(m)){if(!n)return null;const e=[],t=[];Pl(e,s,h/m),kl(t,Nl(t,e,u)),kl(s,El(s,u,Pl(s,t,Math.tan(g)*h)))}const _=[];new Zl(r,s).closestPointOnSphere(l,d,_);const y=kl([],N(a,0)),v=kl([],N(a,1)),x=kl([],N(a,2)),b=zl(y,_),w=zl(v,_),M=zl(x,_),T=c(Math.asin(-w/d));let S=c(Math.atan2(b,M));S=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,S);const E=Aa(S),A=f(Ca(T),0,1);return new za(E,A)}class Hp{constructor(e,t,i){this.a=Nl([],e,i),this.b=Nl([],t,i),this.center=i;const n=kl([],this.a),r=kl([],this.b);this.angle=Math.acos(zl(n,r))}}function Wp(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,n){const r=Math.sin(i);return e*(Math.sin((1-n)*i)/r)+t*(Math.sin(n*i)/r)}(e.a[t],e.b[t],e.angle,f(i,0,1))+e.center[t]}function qp(e){if(e.z<=1)return Vp[e.z+2*e.y+e.x];const[t,i]=Zp(e),n=[Yp(t[0],t[1]),Yp(t[0],i[1]),Yp(i[0],t[1]),Yp(i[0],i[1])],r=[jp,jp,jp],o=[Up,Up,Up];for(const e of n)r[0]=Math.min(r[0],e[0]),r[1]=Math.min(r[1],e[1]),r[2]=Math.min(r[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 Jl(r,o)}function $p(e,t,i){const n=t/e.worldSize,r=Number.MAX_VALUE,o=[-r,-r,-r],s=[r,r,r],a=fl(new Float64Array(16));if(_l(a,a,[n,n,n]),ml(a,a,e.globeMatrix),i.z<=1){const e=qp(i).getCorners();for(let t=0;t<e.length;t++)Ol(e[t],e[t],a),Ll(s,s,e[t]),Il(o,o,e[t]);return new Jl(s,o)}const[c,u]=Zp(i),h=new wa;h.setSouthWest([c[1],u[0]]),h.setNorthEast([u[1],c[0]]);const p=[Yp(h.getSouth(),h.getWest()),Yp(h.getSouth(),h.getEast()),Yp(h.getNorth(),h.getEast()),Yp(h.getNorth(),h.getWest())];for(let e=0;e<p.length;e++)Ol(p[e],p[e],a),Ll(s,s,p[e]),Il(o,o,p[e]);if(h.contains(e.center)){o[2]=0;const t=e.point,i=[t.x*n,t.y*n,0];return Ll(s,s,i),Il(o,o,i),new Jl(s,o)}const d=[a[12],a[13],a[14]],m=e.center.lng,g=f(e.center.lat,-85.051129,ka),_=[Aa(m),Ca(g)],y=h.getCenter().lng,v=f(h.getCenter().lat,-85.051129,ka),x=[Aa(y),Ca(v)];let b=new Array(3),w=0,M=_[0]-x[0];const T=_[1]-x[1];if(M>.5?M-=1:M<-.5&&(M+=1),Math.abs(M)>Math.abs(T))w=M>=0?1:3,b=d;else{w=T>=0?0:2;const e=[a[4],a[5],a[6]];let t;t=T>=0?-Math.sin(l(h.getSouth()))*Fp:-Math.sin(l(h.getNorth()))*Fp,b=Rl(b,d,e,t)}const S=p[w],E=p[(w+1)%4],A=new Hp(S,E,b),C=[Wp(A,0)||S[0],Wp(A,1)||S[1],Wp(A,2)||S[2]];return s[2]=Math.min(S[2],E[2]),Ll(s,s,C),Il(o,o,C),new Jl(s,o)}function Zp(e){const t=1<<e.z,i=e.x/t,n=(e.x+1)/t,r=(e.y+1)/t;return[[Pa(e.y/t),Ia(i)],[Pa(r),Ia(n)]]}function Xp(e,t,i,n=Fp){return i=l(i),[e*Math.sin(i)*n,-t*n,e*Math.cos(i)*n]}function Yp(e,t,i){return Xp(Math.cos(l(e)),Math.sin(l(e)),t,i)}function Jp(e,t,i){const n=Math.pow(2,i.z),r=(e/ba+i.x)/n;return Yp(Pa((t/ba+i.y)/n),Ia(r))}function Qp(e){return 16383/Math.max(...Nl([],e.max,e.min))}function Kp(e){const t=fl(new Float64Array(16)),i=Qp(e);var n,r;return _l(t,t,[i,i,i]),gl(t,t,((n=[])[0]=-(r=e.min)[0],n[1]=-r[1],n[2]=-r[2],n)),t}function ed(e){const t=fl(new Float64Array(16)),i=1/Qp(e);return gl(t,t,e.min),_l(t,t,[i,i,i]),t}function td(e,t,i,n,r){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 gl(a,a,s),_l(a,a,[o,o,o]),yl(a,a,l(-r)),vl(a,a,l(-n)),a}function id(e){return m(5,6,e)}function nd(e,t){const i=Yp(t.lat,t.lng);return o=(n=Al([],function(e){const t=Yp(e._center.lat,e._center.lng);let i=Dl([],Sl(0,1,0),t);const n=xl([],-e.angle,t);i=Ol(i,i,n),xl(n,-e._pitch,i);const r=kl([],t);return Pl(r,r,e.cameraToCenterDistance/e.pixelsPerMeter*Bp),Ol(r,r,n),El([],t,r)}(e),i))[0],s=n[1],a=n[2],l=(r=i)[0],c=r[1],u=r[2],p=(h=Math.sqrt(o*o+s*s+a*a)*Math.sqrt(l*l+c*c+u*u))&&zl(n,r)/h,Math.acos(Math.min(Math.max(p,-1),1));var n,r,o,s,a,l,c,u,h,p}const rd=l(85),od=Math.cos(rd),sd=Math.sin(rd);function ad(e,t){const i=e.fovAboveCenter,n=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,r=(e._camera.position[2]*e.worldSize-n)/Math.cos(e._pitch),o=Math.sin(i)*r/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01)),s=Math.sin(e._pitch)*o+r;return Math.min(1.01*s,r*(1/e._horizonShift))}function ld(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),n=e.x*i,r=(e.x+1)*i,o=e.y*i,s=(e.y+1)*i,a=Ia(n),l=Ia(r),c=Pa(o),u=Pa(s),h=t.project(a,c),p=t.project(l,c),d=t.project(l,u),f=t.project(a,u);let m=Math.min(h.x,p.x,d.x,f.x),g=Math.min(h.y,p.y,d.y,f.y),_=Math.max(h.x,p.x,d.x,f.x),y=Math.max(h.y,p.y,d.y,f.y);const v=i/16;function x(e,i,n,r,o,s){const a=(n+o)/2,l=(r+s)/2,c=t.project(Ia(a),Pa(l)),u=Math.max(0,m-c.x,g-c.y,c.x-_,c.y-y);m=Math.min(m,c.x),_=Math.max(_,c.x),g=Math.min(g,c.y),y=Math.max(y,c.y),u>v&&(x(e,c,n,r,a,l),x(c,i,a,l,o,s))}x(h,p,n,o,r,o),x(p,d,r,o,r,s),x(d,f,r,s,n,s),x(f,h,n,s,n,o),m-=v,g-=v,_+=v,y+=v;const b=1/Math.max(_-m,y-g);return{scale:b,x:m*b,y:g*b,x2:_*b,y2:y*b,projection:t}}const cd=fl(new Float32Array(16));class ud{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 Ta(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 La(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return ad(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const o=e.horizonLineFromTop(!1),s=new r(t,Math.max(o,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,n))}pointCoordinate3D(e,t,i){const n=new r(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.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 n,r,o;const s=i.canonical,a=fl(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=ld(s,this);n=1,r=l.x+i.wrap*l.scale,o=l.y,_l(a,a,[n/l.scale,n/l.scale,e.pixelsPerMeter/t])}else n=t/e.zoomScale(s.z),r=(s.x+Math.pow(2,s.z)*i.wrap)*n,o=s.y*n;return gl(a,a,[r,o,0]),_l(a,a,[n/ba,n/ba,1]),a}upVector(e,t,i){return[0,0,1]}upVectorScale(e,t,i){return{metersToTile:1}}}class hd extends ud{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],n=Math.sin(l(t));this.n=(n+Math.sin(l(i)))/2,this.c=1+n*(2*this.n-n),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:i,c:n,r0:r}=this,o=l(e-this.center[0]),s=l(t),a=Math.sqrt(n-2*i*Math.sin(s))/i;return{x:a*Math.sin(o*i),y:a*Math.cos(o*i)-r,z:0}}unproject(e,t){const{n:i,c:n,r0:r}=this,o=r+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=l(this.center[0])*i;s=g(s,-Math.PI-a,Math.PI-a);const u=c(s/i)+this.center[0],h=Math.asin(f((n-(e*e+o*o)*i*i)/(2*i),-1,1)),p=f(c(h),-85.051129,ka);return new Ta(u,p)}}const pd=1.340264,dd=-.081106,fd=893e-6,md=.003796,gd=Math.sqrt(3)/2;class _d extends ud{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(gd*Math.sin(t)),n=i*i,r=n*n*n;return{x:.5*(e*Math.cos(i)/(gd*(pd+3*dd*n+r*(7*fd+9*md*n)))/Math.PI+.5),y:1-.5*(i*(pd+dd*n+r*(fd+md*n))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=i*i,r=n*n*n;for(let e,o,s,a=0;a<12&&(o=i*(pd+dd*n+r*(fd+md*n))-t,s=pd+3*dd*n+r*(7*fd+9*md*n),e=o/s,i=f(i-e,-Math.PI/3,Math.PI/3),n=i*i,r=n*n*n,!(Math.abs(e)<1e-12));++a);const o=gd*e*(pd+3*dd*n+r*(7*fd+9*md*n))/Math.cos(i),s=Math.asin(Math.sin(i)/gd),a=f(180*o/Math.PI,-180,180),l=f(180*s/Math.PI,-85.051129,ka);return new Ta(a,l)}}class yd extends ud{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),n=f(360*(.5-t),-85.051129,ka);return new Ta(i,n)}}const vd=Math.PI/2;function xd(e){return Math.tan((vd+e)/2)}class bd extends ud{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30],n=l(t),r=l(i),o=Math.cos(n);this.n=n===r?Math.sin(n):Math.log(o/Math.cos(r))/Math.log(xd(r)/xd(n)),this.f=o*Math.pow(xd(n),this.n)/this.n}project(e,t){t=l(t),e=l(e-this.center[0]);const i=1e-6,{n:n,f:r}=this;r>0?t<-vd+i&&(t=-vd+i):t>vd-i&&(t=vd-i);const o=r/Math.pow(xd(t),n),s=o*Math.sin(n*e),a=r-o*Math.cos(n*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:n}=this,r=n-t,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(e*e+r*r);let a=Math.atan2(e,Math.abs(r))*o;r*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=f(c(a/i)+this.center[0],-180,180),u=f(c(2*Math.atan(Math.pow(n/s,1/i))-vd),-85.051129,ka);return new Ta(l,u)}}class wd extends ud{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:Aa(e),y:Ca(t),z:0}}unproject(e,t){const i=Ia(e),n=Pa(t);return new Ta(i,n)}}const Md=l(ka);class Td extends ud{project(e,t){const i=(t=l(t))*t,n=i*i;return{x:.5*((e=l(e))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=25,r=0,o=i*i;do{o=i*i;const e=o*o;r=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=f(i-r,-Md,Md)}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const s=f(c(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=c(i);return new Ta(s,a)}}const Sd=l(ka);class Ed extends ud{project(e,t){t=l(t),e=l(e);const i=Math.cos(t),n=2/Math.PI,r=Math.acos(i*Math.cos(e/2)),o=Math.sin(r)/r,s=.5*(e*n+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,n=t=(2*(1-t)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,u=r*r,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,m=p*p,g=1-u*h*h,_=g?1/g:0,y=g?Math.acos(r*h)*Math.sqrt(1/g):0,v=.5*(2*y*r*p+2*i/Math.PI)-e,x=.5*(y*o+n)-t,b=.5*_*(u*m+y*r*h*c)+1/Math.PI,w=_*(d*l/4-y*o*p),M=.125*_*(l*p-y*o*u*d),T=.5*_*(c*h+y*m*r)+.5,S=w*M-T*b;s=(x*w-v*T)/S,a=(v*M-x*b)/S,i=f(i-s,-Math.PI,Math.PI),n=f(n-a,-Sd,Sd)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new Ta(c(i),c(n))}}class Ad extends ud{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(l(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:n}=this;return{x:l(e)*n*i+.5,y:-Math.sin(l(t))/n*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:n}=this,r=-(t-.5)/i,o=f(c((e-.5)/i)/n,-180,180),s=Math.asin(f(r*n,-1,1)),a=f(c(s),-85.051129,ka);return new Ta(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 n=Math.pow(2,i.z),r=(e/ba+i.x)/n,o=Yp(Pa((t/ba+i.y)/n),Ia(r));return Ol(o,o,Kp(qp(i))),{x:o[0],y:o[1],z:o[2]}}locationPoint(e,t){const i=Yp(t.lat,t.lng),n=kl([],i),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Rl(i,i,n,La(1,0)*ba*o);const s=fl(new Float64Array(16));return ml(s,e.pixelMatrix,e.globeMatrix),Ol(i,i,s),new r(i[0],i[1])}pixelsPerMeter(e,t){return La(1,0)*t}pixelSpaceConversion(e,t,i){const n=_i(La(1,45)*t,La(1,e)*t,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(e,t,i){const n=ed(qp(i.canonical));return ml(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:i}=e,n=fl(new Float64Array(16));return ml(n,n,Kp(qp(t))),vl(n,n,l(i.lng)),yl(n,n,l(i.lat)),_l(n,n,[e._projectionScaler,e._projectionScaler,1]),Float32Array.from(n)}pointCoordinate(e,t,i,n){return Gp(e,t,i,!0)||new za(0,0)}pointCoordinate3D(e,t,i){const n=this.pointCoordinate(e,t,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(e,t){return!Gp(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,n=e._centerAltitude*t,r=e._camera,o=e._camera.forward(),s=El([],Pl([],o,-i),[0,0,n]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=Pl([],r.up(),u),p=Pl([],r.right(),u*c),d=kl([],El([],El([],o,h),p)),f=[];let m;if(new Zl(s,d).closestPointOnSphere(l,a,f)){const t=El([],f,l),i=Nl([],t,s);m=Math.cos(e.fovAboveCenter)*Tl(i)}else{const e=Nl([],s,l),t=Nl([],l,s);kl(t,t);const i=Tl(e)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(zl(o,t));m*=Math.cos(n)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=id(e.zoom);if(i>0){const n=ad(e,La(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return _i(t,n+r*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){const n=1<<e.z,r=(t/ba+e.x)/n;return Yp(Pa((i/ba+e.y)/n),Ia(r),1)}upVectorScale(e){return{metersToTile:Bp*Qp(qp(e))}}}function Ld(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 Td(e);case"equalEarth":return new _d(e);case"winkelTripel":return new Ed(e);case"albers":return i?new Ad(e):new hd(e);case"lambertConformalConic":return i?new Ad(e):new bd(e);case"globe":return new Cd(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Id=hu.VectorTileFeature.types,Pd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Rd(e,t,i,n,r,o,s,a,l,c,u,h,p){const d=a?Math.min(Ap,Math.round(a[0])):0,f=a?Math.min(Ap,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*n),Math.round(32*r),o,s,(d<<1)+(l?1:0),f,16*c,16*u,256*h,256*p)}function kd(e,t,i,n,r,o,s){e.emplaceBack(t,i,n,r,o,s)}function zd(e,t,i,n,r){e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r),e.emplaceBack(t,i,n,r)}function Dd(e){for(const t of e.sections)if(yo(t.text))return!0;return!1}class Od{constructor(e){this.layoutVertexArray=new ss,this.indexArray=new fs,this.programConfigurations=e,this.segments=new xa,this.dynamicLayoutVertexArray=new is,this.opacityVertexArray=new ls,this.placedSymbolArray=new Ls,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,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gu.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Wu.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Pd,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Hu.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&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())}}Pr(Od,"SymbolBuffers");class Fd{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new xa,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,qu.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,$u.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Pr(Fd,"CollisionBuffers");class Bd{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=Qu(this.zoom,t["text-size"]),this.iconSizeData=Qu(this.zoom,t["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=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"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>zh[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 Od(new ua(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Od(new ua(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Rs,this.lineVertexArray=new ks,this.symbolInstances=new Ps}calculateGlyphDependencies(e,t,i,n,r){for(let i=0;i<e.length;i++)if(t[e.charCodeAt(i)]=!0,n&&r){const n=nh[e.charAt(i)];n&&(t[n.charCodeAt(0)]=!0)}}populate(e,t,i,n){const r=this.layers[0],o=r.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),u=("constant"!==l.value.kind||l.value.value instanceof xt&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,g=new Po(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:_}of e){const e=r._featureFilter.needGeometry,y=Ga(t,e);if(!r._featureFilter.filter(g,y,i))continue;if(e||(y.geometry=Va(t,i,n)),s&&1!==t.type&&i.z<=5){const e=y.geometry,t=1<<i.z,n=i.x,r=i.y,o=.98078528056;for(let i=0;i<e.length;i++)e[i]=Ba(e[i],(e=>e),((e,i)=>zl(Yp(Pa((e.y/ba+r)/t),Ia((e.x/ba+n)/t),1),Yp(Pa((i.y/ba+r)/t),Ia((i.x/ba+n)/t),1))<o))}let v,x;if(u){const e=r.getValueAndResolveTokens("text-field",y,i,m),t=xt.factory(e);Dd(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Co()||this.hasRTLText&&Io.isParsed())&&(v=ih(t,r,y))}if(h){const e=r.getValueAndResolveTokens("icon-image",y,i,m);x=e instanceof bt?e:bt.fromString(e)}if(!v&&!x)continue;const b=this.sortFeaturesByKey?p.evaluate(y,{},i):void 0;if(this.features.push({id:l,text:v,icon:x,index:c,sourceLayerIndex:_,geometry:y.geometry,properties:t.properties,type:Id[t.type],sortKey:b}),x&&(d[x.name]=!0),v){const e=a.evaluate(y,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(zh.vertical)>=0;for(const i of v.sections)if(i.image)d[i.image.name]=!0;else{const n=uo(v.toString()),r=i.fontStack||e,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;c<e.length;c++){const u=e[c],h=u.geometry,p=u.text?u.text.toString():null;if(!p){o(c);continue}const d=l(p,h),f=l(p,h,!0);if(d in i&&f in t&&i[d]!==t[f]){const e=a(d,f,h),r=s(d,f,n[e].geometry);delete t[d],delete i[f],i[l(p,n[r].geometry,!0)]=r,n[e].geometry=null}else d in i?s(d,f,h):f in t?a(d,f,h):(o(c),t[d]=r-1,i[f]=r-1)}return n.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,i,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i,n),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i,n))}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=Ld(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length,n=e.segment;if(void 0!==n){let i=e.dist(t[n+1]),r=e.dist(t[n]);const o={};for(let e=n+1;e<t.length;e++)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:i},e<t.length-1&&(i+=t[e+1].dist(t[e]));for(let e=n||0;e>=0;e--)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:r},e>0&&(r+=t[e-1].dist(t[e]));for(let e=0;e<t.length;e++){const t=o[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,n,r,o,s,a,l,c,u,h,p,d){const f=e.indexArray,m=e.layoutVertexArray,g=e.globeExtVertexArray,_=e.segments.prepareSegment(4*t.length,m,f,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,v=_.vertexLength,x=this.allowVerticalPlacement&&s===zh.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let n=0;n<t.length;n++){const{tl:r,tr:s,bl:c,br:u,tex:h,pixelOffsetTL:y,pixelOffsetBR:v,minFontScaleX:w,minFontScaleY:M,glyphOffset:T,isSDF:S,sectionIndex:E}=t[n],A=_.vertexLength,C=T[1];if(Rd(m,l.x,l.y,r.x,C+r.y,h.x,h.y,i,S,y.x,y.y,w,M),Rd(m,l.x,l.y,s.x,C+s.y,h.x+h.w,h.y,i,S,v.x,y.y,w,M),Rd(m,l.x,l.y,c.x,C+c.y,h.x,h.y+h.h,i,S,y.x,v.y,w,M),Rd(m,l.x,l.y,u.x,C+u.y,h.x+h.w,h.y+h.h,i,S,v.x,v.y,w,M),a){const t=a.anchor,i=a.up;kd(g,t.x,t.y,t.z,i[0],i[1],i[2]),kd(g,t.x,t.y,t.z,i[0],i[1],i[2]),kd(g,t.x,t.y,t.z,i[0],i[1],i[2]),kd(g,t.x,t.y,t.z,i[0],i[1],i[2]),zd(e.dynamicLayoutVertexArray,t.x,t.y,t.z,x)}else zd(e.dynamicLayoutVertexArray,l.x,l.y,l.z,x);f.emplaceBack(A,A+1,A+2),f.emplaceBack(A+1,A+2,A+3),_.vertexLength+=4,_.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(T[0]),n!==t.length-1&&E===t[n+1].sectionIndex||e.programConfigurations.populatePaintArrays(m.length,o,o.index,{},p,d,b&&b[E])}const w=a?a.anchor:l;e.placedSymbolArray.emplaceBack(w.x,w.y,w.z,l.x,l.y,y,this.glyphOffsetArray.length-y,v,c,u,l.segment,i?i[0]:0,i?i[1]:0,n[0],n[1],s,0,!1,0,h,0)}_commitLayoutVertex(e,t,i,n,r,o,s){e.emplaceBack(t,i,n,r,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(e,t,i,n,o,s,a){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,u=a.tileAnchorX,h=a.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,n,o,s,u,h,new r(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,o,s,u,h,new r(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,o,s,u,h,new r(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,n,o,s,u,h,new r(e.x1,e.y2)),l.vertexLength+=4;const p=i.indexArray;p.emplaceBack(c,c+1),p.emplaceBack(c+1,c+2),p.emplaceBack(c+2,c+3),p.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,i,n,r,o){for(let s=n;s<r;s++){const n=i.get(s),r=this.getSymbolInstanceTextSize(e,o,t,s);this._addCollisionDebugVertices(n,r,this.textCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,t,i,n,r,o){for(let s=n;s<r;s++){const n=i.get(s),r=this.getSymbolInstanceIconSize(e,t,s);this._addCollisionDebugVertices(n,r,this.iconCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,t){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Fd(us,Zu.members,bs),this.iconCollisionBox=new Fd(us,Zu.members,bs);const i=eh(this.iconSizeData,e),n=eh(this.textSizeData,e);for(let r=0;r<this.symbolInstances.length;r++){const o=this.symbolInstances.get(r);this._addTextDebugCollisionBoxes(n,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(n,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,i,n){const r=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),o=Ku(this.textSizeData,e,r)/Yu;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const n=this.icon.placedSymbolArray.get(i),r=Ku(this.iconSizeData,e,n);return this.tilePixelRatio*r}_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(e,t,i,n,r,o){for(let s=n;s<r;s++){const n=i.get(s),r=this.getSymbolInstanceTextSize(e,o,t,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,r,n.padding)}}_updateIconDebugCollisionBoxes(e,t,i,n,r){for(let o=n;o<r;o++){const n=i.get(o),r=this.getSymbolInstanceIconSize(e,t,o);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,r,n.padding)}}updateCollisionDebugBuffers(e,t){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=eh(this.iconSizeData,e),n=eh(this.textSizeData,e);for(let r=0;r<this.symbolInstances.length;r++){const o=this.symbolInstances.get(r);this._updateTextDebugCollisionBoxes(n,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(n,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,e,t,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(e,t,i,n,r,o,s,a,l){const c={};for(let n=t;n<i;n++){const t=e.get(n);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,padding:t.padding,projectedAnchorX:t.projectedAnchorX,projectedAnchorY:t.projectedAnchorY,projectedAnchorZ:t.projectedAnchorZ,tileAnchorX:t.tileAnchorX,tileAnchorY:t.tileAnchorY},c.textFeatureIndex=t.featureIndex;break}for(let t=n;t<r;t++){const i=e.get(t);c.verticalTextBox={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},c.verticalTextFeatureIndex=i.featureIndex;break}for(let t=o;t<s;t++){const i=e.get(t);c.iconBox={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},c.iconFeatureIndex=i.featureIndex;break}for(let t=a;t<l;t++){const i=e.get(t);c.verticalIconBox={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},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,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(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<n;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),n=[],r=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);n.push(0|Math.round(t*s.tileAnchorX+i*s.tileAnchorY)),r.push(s.featureIndex)}return o.sort(((e,t)=>n[e]-n[t]||r[t]-r[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)}}}Pr(Bd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Bd.MAX_GLYPHS=65535,Bd.addDynamicAttributes=zd;const Nd=new Wo({"symbol-placement":new Uo(He.layout_symbol["symbol-placement"]),"symbol-spacing":new Uo(He.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Uo(He.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(He.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Uo(He.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Uo(He.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Uo(He.layout_symbol["icon-ignore-placement"]),"icon-optional":new Uo(He.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Uo(He.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(He.layout_symbol["icon-size"]),"icon-text-fit":new Uo(He.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Uo(He.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(He.layout_symbol["icon-image"]),"icon-rotate":new jo(He.layout_symbol["icon-rotate"]),"icon-padding":new Uo(He.layout_symbol["icon-padding"]),"icon-keep-upright":new Uo(He.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(He.layout_symbol["icon-offset"]),"icon-anchor":new jo(He.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Uo(He.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Uo(He.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Uo(He.layout_symbol["text-rotation-alignment"]),"text-field":new jo(He.layout_symbol["text-field"]),"text-font":new jo(He.layout_symbol["text-font"]),"text-size":new jo(He.layout_symbol["text-size"]),"text-max-width":new jo(He.layout_symbol["text-max-width"]),"text-line-height":new jo(He.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(He.layout_symbol["text-letter-spacing"]),"text-justify":new jo(He.layout_symbol["text-justify"]),"text-radial-offset":new jo(He.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Uo(He.layout_symbol["text-variable-anchor"]),"text-anchor":new jo(He.layout_symbol["text-anchor"]),"text-max-angle":new Uo(He.layout_symbol["text-max-angle"]),"text-writing-mode":new Uo(He.layout_symbol["text-writing-mode"]),"text-rotate":new jo(He.layout_symbol["text-rotate"]),"text-padding":new Uo(He.layout_symbol["text-padding"]),"text-keep-upright":new Uo(He.layout_symbol["text-keep-upright"]),"text-transform":new jo(He.layout_symbol["text-transform"]),"text-offset":new jo(He.layout_symbol["text-offset"]),"text-allow-overlap":new Uo(He.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Uo(He.layout_symbol["text-ignore-placement"]),"text-optional":new Uo(He.layout_symbol["text-optional"])});var Ud={paint:new Wo({"icon-opacity":new jo(He.paint_symbol["icon-opacity"]),"icon-color":new jo(He.paint_symbol["icon-color"]),"icon-halo-color":new jo(He.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(He.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(He.paint_symbol["icon-halo-blur"]),"icon-translate":new Uo(He.paint_symbol["icon-translate"]),"icon-translate-anchor":new Uo(He.paint_symbol["icon-translate-anchor"]),"text-opacity":new jo(He.paint_symbol["text-opacity"]),"text-color":new jo(He.paint_symbol["text-color"],{runtimeType:it,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new jo(He.paint_symbol["text-halo-color"]),"text-halo-width":new jo(He.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(He.paint_symbol["text-halo-blur"]),"text-translate":new Uo(He.paint_symbol["text-translate"]),"text-translate-anchor":new Uo(He.paint_symbol["text-translate-anchor"])}),layout:Nd};class jd{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Qe,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}}Pr(jd,"FormatSectionOverride",{omit:["defaultValue"]});class Vd extends _a{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,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||zn(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}(t.properties,r)}createBucket(e){return new Bd(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Ud.paint.overridableProperties){if(!Vd.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new jd(t),n=new kn(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new On("source",n):new Fn("composite",n,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Bo(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Vd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=Ud.paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof xt)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof At&&Tt(t.value)===st?o(t.value.sections):t instanceof Rt?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}getProgramConfiguration(e){return new ca(this,e)}}var Gd={paint:new Wo({"background-color":new Uo(He.paint_background["background-color"]),"background-pattern":new Go(He.paint_background["background-pattern"]),"background-opacity":new Uo(He.paint_background["background-opacity"])})},Hd={paint:new Wo({"raster-opacity":new Uo(He.paint_raster["raster-opacity"]),"raster-hue-rotate":new Uo(He.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Uo(He.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Uo(He.paint_raster["raster-brightness-max"]),"raster-saturation":new Uo(He.paint_raster["raster-saturation"]),"raster-contrast":new Uo(He.paint_raster["raster-contrast"]),"raster-resampling":new Uo(He.paint_raster["raster-resampling"]),"raster-fade-duration":new Uo(He.paint_raster["raster-fade-duration"])})};class Wd extends _a{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 Wo({"sky-type":new Uo(He.paint_sky["sky-type"]),"sky-atmosphere-sun":new Uo(He.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Uo(He.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Uo(He.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Uo(He.paint_sky["sky-gradient-radius"]),"sky-gradient":new Ho(He.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Uo(He.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Uo(He.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Uo(He.paint_sky["sky-opacity"])})};function $d(e,t,i){const n=[0,0,1],r=Wl([]);return $l(r,r,i?-l(e)+Math.PI:l(e)),ql(r,r,-l(t)),Fl(n,n,r),kl(n,n)}const Zd={circle:class extends _a{constructor(e){super(e,ul)}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,n,r,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 Ql(e,n,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 _a{createBucket(e){return new nc(e)}constructor(e){super(e,cc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=uc({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,n,o,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(t,i);return Ql(e,n,s,a,l,!0,!0,new r(0,0),c)}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 _a{constructor(e){super(e,hc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends _a{constructor(e){super(e,Qc)}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 Yc(e)}queryRadius(){return sl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,n,r,o){return!e.queryGeometry.isAboveHorizon&&Xa(al(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends _a{constructor(e){super(e,wu)}createBucket(e){return new yu(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,n,o,s,a,l,c){const u=ll(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),p=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,g=e.tile.getBucket(this);if(f&&g instanceof yu){const e=g.centroidVertexArray,t=c+1;if(t<e.length){const i=e.get(t);d[0]=i.a_centroid_pos0,d[1]=i.a_centroid_pos1}}if(0===d[0]&&1===d[1])return!1;"globe"===s.projection.name&&(n=bu([n],[new r(0,0),new r(ba,ba)],e.tileID.canonical).map((e=>e.polygon)).flat());const _=function(e,t,i,n,o,s,a,l,c,u,h){return"globe"===e.projection.name?function(e,t,i,n,r,o,s,a,l,c,u){const h=[],p=[],d=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],g=(e,t,i,n)=>{e[0]=t,e[1]=i,e[2]=n,e[3]=1},_=xu();i>0&&(i+=_),n+=_;for(const _ of t){const t=[],y=[];for(const h of _){const p=h.x+r.x,_=h.y+r.y,v=e.projection.projectTilePoint(p,_,u),x=e.projection.upVector(u,h.x,h.y);let b=i,w=n;if(s){const e=Pu(p,_,i,n,s,a,l,c);b+=e.base,w+=e.top}0!==i?g(f,v.x+x[0]*d*b,v.y+x[1]*d*b,v.z+x[2]*d*b):g(f,v.x,v.y,v.z),g(m,v.x+x[0]*d*w,v.y+x[1]*d*w,v.z+x[2]*d*w),Ol(f,f,o),Ol(m,m,o),t.push(Iu(f)),y.push(Iu(m))}h.push(t),p.push(y)}return[h,p]}(e,t,i,n,o,s,a,l,c,u,h):a?function(e,t,i,n,r,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],d=[];for(const c of p){const u=c.x+n.x,p=c.y+n.y,f=Pu(u,p,t,i,o,s,a,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,Gl(h,h,r),h[3]=Math.max(h[3],1e-5);const m=Iu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,Gl(h,h,r),h[3]=Math.max(h[3],1e-5);const g=Iu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);e.push(m),d.push(g)}c.push(e),u.push(d)}return[c,u]}(t,i,n,o,s,a,l,c,u):function(e,t,i,n,o){const s=[],a=[],l=o[8]*t,c=o[9]*t,u=o[10]*t,h=o[11]*t,p=o[8]*i,d=o[9]*i,f=o[10]*i,m=o[11]*i;for(const t of e){const e=[],i=[];for(const s of t){const t=s.x+n.x,a=s.y+n.y,g=o[0]*t+o[4]*a+o[12],_=o[1]*t+o[5]*a+o[13],y=o[2]*t+o[6]*a+o[14],v=o[3]*t+o[7]*a+o[15],x=g+l,b=_+c,w=y+u,M=Math.max(v+h,1e-5),T=g+p,S=_+d,E=y+f,A=Math.max(v+m,1e-5),C=new r(x/M,b/M);C.z=w/M,e.push(C);const L=new r(T/A,S/A);L.z=E/A,i.push(L)}s.push(e),a.push(i)}return[s,a]}(t,i,n,o,s)}(s,n,p,h,u,a,f?l:null,d,m,s.center.lat,e.tileID.canonical),y=e.queryGeometry;return function(e,t,i){let n=1/0;Xa(i,t)&&(n=Lu(i,t[0]));for(let r=0;r<t.length;r++){const o=t[r],s=e[r];for(let e=0;e<o.length-1;e++){const t=o[e],r=[t,o[e+1],s[e+1],s[e],t];$a(i,r)&&(n=Math.min(n,Lu(i,r)))}}return n!==1/0&&n}(_[0],_[1],y.isPointQuery()?y.screenBounds:y.screenGeometry)}},line:class extends _a{constructor(e){super(e,Uu),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 gi,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"]=ju.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Bu(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=Vu(ol("line-width",this,t),ol("line-gap-width",this,t)),n=ol("line-offset",this,t);return i/2+Math.abs(n)+sl(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,o,s){if(e.queryGeometry.isAboveHorizon)return!1;const a=al(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),l=e.pixelToTileUnitsFactor/2*Vu(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),c=this.paint.get("line-offset").evaluate(t,i);return c&&(n=function(e,t){const i=[],n=new r(0,0);for(let r=0;r<e.length;r++){const o=e[r],s=[];for(let e=0;e<o.length;e++){const i=o[e-1],r=o[e],a=o[e+1],l=0===e?n:r.sub(i)._unit()._perp(),c=e===o.length-1?n:a.sub(r)._unit()._perp(),u=l._add(c)._unit();u._mult(1/(u.x*c.x+u.y*c.y)),s.push(u._mult(t)._add(r))}i.push(s)}return i}(n,c*e.pixelToTileUnitsFactor)),function(e,t,i){for(let n=0;n<t.length;n++){const r=t[n];if(e.length>=3)for(let t=0;t<r.length;t++)if(il(e,r[t]))return!0;if(Ya(e,r,i))return!0}return!1}(a,n,l)}isTileClipped(){return!0}},symbol:Vd,background:class extends _a{constructor(e){super(e,Gd)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends _a{constructor(e){super(e,Hd)}getProgramIds(){return["raster"]}},sky:class extends _a{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=uc({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"),n=!i,r=e.style.light,o=r.properties.get("position");return n&&"viewport"===r.properties.get("anchor")&&P("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?$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,n){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,n)}update(e,i,n){const{width:r,height:o}=e,{context:s}=this,{gl:a}=s,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:p}=t;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!i||!1!==i.premultiply)),n||this.size&&this.size[0]===r&&this.size[1]===o){const{x:t,y:i}=n||{x:0,y:0};e instanceof l||e instanceof c||e instanceof u||e instanceof h||p&&e instanceof p?a.texSubImage2D(a.TEXTURE_2D,0,t,i,a.RGBA,a.UNSIGNED_BYTE,e):a.texSubImage2D(a.TEXTURE_2D,0,t,i,r,o,a.RGBA,a.UNSIGNED_BYTE,e.data)}else this.size=[r,o],e instanceof l||e instanceof c||e instanceof u||e instanceof h||p&&e instanceof p?a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,a.UNSIGNED_BYTE,e):a.texImage2D(a.TEXTURE_2D,0,this.format,r,o,0,this.format,a.UNSIGNED_BYTE,e.data);this.useMipmap=Boolean(i&&i.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.filter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_NEAREST:e),this.filter=e),t!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.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 Yd{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=M(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const n=[];let r=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,s=!0;n.push({left:r,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];r=a*i,a+=l,o=a*i,n.push({left:r,right:o,isDash:s,zeroLength:0===l})}return n}addRoundDash(e,t,i){const n=t/2;for(let t=-i;t<=i;t++){const r=this.width*(this.nextRow+i+t);let o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const p=t/i*(n+1);if(s.isDash){const e=n-Math.abs(p);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+p*p);this.image.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const i=e[0],n=e[e.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i<this.width;i++){i/s.right>1&&(s=e[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const n="round"===t,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return P("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t<e.length;t++)e[t]<0&&(P("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),s+=e[t];if(0!==s){const i=this.width/s,o=this.getDashRanges(e,this.width,i);n?this.addRoundDash(o,i,r):this.addRegularDash(o,"square"===t?.5*i:0)}const a=this.nextRow+r;this.nextRow+=o;const l={tl:[a,r],br:[s,0]};return this.positions[i]=l,l}}Pr(Yd,"LineAtlas");class Jd{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 Qd{constructor(){this.tasks={},this.taskQueue=[],S(["process"],this),this.invoker=new Jd(this.process),this.nextId=0}add(e,t){const i=this.nextId++,n=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===n){z();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:n,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 e=null,t=1/0;for(let i=0;i<this.taskQueue.length;i++){const n=this.tasks[this.taskQueue[i]];n.priority<t&&(t=n.priority,e=i)}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}class Kd{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=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,n,r){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=n,this.properties=e.properties,this.id=r}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 nf=32,rf=33,of=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,n=0,r=0,o=0,s=0,a=0;for(1&t?r=o=s=nf:i=n=a=nf;(t>>=1)>1;){const e=i+r>>1,l=n+o>>1;1&t?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=e,a=l}const l=4*e;of[l+0]=i,of[l+1]=n,of[l+2]=r,of[l+3]=o}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 uf=Yo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const hf={type:2,extent:ba,loadGeometry:()=>[[new r(0,0),new r(8193,0),new r(8193,8193),new r(0,8193),new r(0,0)]]};class pf{constructor(e,t,i,n,r){this.tileID=e,this.uid=b(),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=r,this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<$.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 n of e){const e=n.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=n}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Bd){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 Bd&&t.hasRTLText){this.hasRTLText=!0,Io.isLoading()||Io.isLoaded()||"deferred"!==Co()||Lo();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 As}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,n,r,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:n,pixelPosMatrix:s,transform:o,params:r,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const n=i.loadVTLayers(),r=t?t.sourceLayer:"",o=n._geojsonTileLayer||n[r];if(!o)return;const s=Yn(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let t=0;t<o.length;t++){const n=o.feature(t);if(s.needGeometry){const e=Ga(n,!0);if(!s.filter(new Po(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new Po(this.tileID.overscaledZ),n))continue;const h=i.getId(n,r),p=new tf(n,a,l,c,h);p.tile=u,e.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=D(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{const n=this.expirationTime-t;n?this.expirationTime=e+Math.max(n,3e4):i=!0}else i=!0;i?(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(),n=t.style.listImages();for(const r in this.buckets){if(!t.style.hasLayer(r))continue;const o=this.buckets[r],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,n,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof Bu||o instanceof Yc){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(r);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<$.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=$.now()+e}setTexture(e,t){const i=t.context,n=i.gl;this.texture=t.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new Xd(i,e,n.RGBA,{useMipmap:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&n.texParameterf(n.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 i of t)if(e[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=Va(hf,this.tileID.canonical,this.tileTransform)[0],n=new Qo,r=new ws;for(let e=0;e<i.length;e++){const{x:t,y:o}=i[e];n.emplaceBack(t,o),r.emplaceBack(e)}r.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(r),this._tileDebugBuffer=e.createVertexBuffer(n,Op.members),this._tileDebugSegments=xa.simpleSegment(0,0,n.length,r.length)}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const i=Va(hf,this.tileID.canonical,this.tileTransform)[0];let n,r;if(this.isRaster){const e=function(e,t){const i=ld(e,t),n=Math.pow(2,e.z);for(let r=0;r<rf;r++)for(let o=0;o<rf;o++){const s=Ia((e.x+(o+cf(o))/nf)/n),a=Pa((e.y+(r+cf(r))/nf)/n),l=t.project(s,a),c=r*rf+o;sf[2*c+0]=Math.round((l.x*i.scale-i.x)*ba),sf[2*c+1]=Math.round((l.y*i.scale-i.y)*ba)}af.fill(0),lf.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=of[t+0],n=of[t+1],r=of[t+2],o=of[t+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,u=n*rf+i,h=o*rf+r,p=a*rf+s,d=Math.hypot((sf[2*u+0]+sf[2*h+0])/2-sf[2*p+0],(sf[2*u+1]+sf[2*h+1])/2-sf[2*p+1])>=16;if(af[p]=af[p]||(d?1:0),e<1022){const e=(n+c>>1)*rf+(i+l>>1),t=(o+c>>1)*rf+(r+l>>1);af[p]=af[p]||af[e]||af[t]}}const r=new es,o=new fs;let s=0;function a(e,t){const i=t*rf+e;return 0===lf[i]&&(r.emplaceBack(sf[2*i+0],sf[2*i+1],e*ba/nf,t*ba/nf),lf[i]=++s),lf[i]-1}function l(e,t,i,n,r,s){const c=e+i>>1,u=t+n>>1;if(Math.abs(e-r)+Math.abs(t-s)>1&&af[u*rf+c])l(r,s,e,t,c,u),l(i,n,r,s,c,u);else{const l=a(e,t),c=a(i,n),u=a(r,s);o.emplaceBack(l,c,u)}}return l(0,0,nf,nf,nf,0),l(nf,nf,0,0,0,nf),{vertices:r,indices:o}}(this.tileID.canonical,t);n=e.vertices,r=e.indices}else{n=new es,r=new fs;for(const{x:e,y:t}of i)n.emplaceBack(e,t,0,0);const e=fc(n.int16,void 0,4);for(let t=0;t<e.length;t+=3)r.emplaceBack(e[t],e[t+1],e[t+2])}this._tileBoundsBuffer=e.createVertexBuffer(n,uf.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(r),this._tileBoundsSegments=xa.simpleSegment(0,0,n.length,r.length)}_makeGlobeTileDebugBuffers(e,t){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!t||"globe"!==t.name)return;const i=this.tileID.canonical,n=Kp(qp(i));this._makeGlobeTileDebugBorderBuffer(e,i,n),this._makeGlobeTileDebugTextBuffer(e,i,n)}_makeGlobeTileDebugBorderBuffer(e,t,i){const n=new Qo,r=new ws,o=new Ko,s=(e,s,a,l,c)=>{const u=(a-e)/(c-1),h=(l-s)/(c-1),p=n.length;for(let a=0;a<c;a++){const l=e+a*u,c=s+a*h;n.emplaceBack(l,c);const d=Jp(l,c,t),f=Ol(d,d,i);o.emplaceBack(f[0],f[1],f[2]),r.emplaceBack(p+a)}},a=ba;s(0,0,a,0,16),s(a,0,a,a,16),s(a,a,0,a,16),s(0,a,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(r),this._tileDebugBuffer=e.createVertexBuffer(n,Op.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(o,Dp.members),this._tileDebugSegments=xa.simpleSegment(0,0,n.length,r.length)}_makeGlobeTileDebugTextBuffer(e,t,i){const n=new Qo,r=new fs,o=new Ko,s=25;r.reserve(32),n.reserve(s),o.reserve(s);const a=(e,t)=>s*e+t;for(let e=0;e<s;e++){const r=2048*e;for(let e=0;e<s;e++){const s=2048*e;n.emplaceBack(s,r);const a=Jp(s,r,t),l=Ol(a,a,i);o.emplaceBack(l[0],l[1],l[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=a(e,t),n=a(e,t+1),o=a(e+1,t),s=a(e+1,t+1);r.emplaceBack(i,n,o),r.emplaceBack(o,n,s)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(r),this._tileDebugTextBuffer=e.createVertexBuffer(n,Op.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(o,Dp.members),this._tileDebugTextSegments=xa.simpleSegment(0,0,s,32)}}class df{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const n=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},v(this.stateChanges[e][n],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])i[t]||(this.deletedStates[e][n][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const n=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][n]&&(this.deletedStates[e][n]=this.deletedStates[e][n]||{},this.deletedStates[e][n][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][n])for(i in this.deletedStates[e][n]={},this.stateChanges[e][n])this.deletedStates[e][n][i]=null;else this.deletedStates[e][n]=null;else this.deletedStates[e]=null}getState(e,t){const i=String(t),n=v({},(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 n[e]}return n}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]={}),v(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]||{},v(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in e)e[n].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(e,t,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(n[s])<1e-15){if(i[s]<e[s]||i[s]>t[s])return null}else{const a=1/n[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>r&&(r=l),c<o&&(o=c),r>o)return null}return r}function gf(e,t,i,n,r,o,s,a,l,c,u){const h=n-e,p=r-t,d=o-i,f=s-e,m=a-t,g=l-i,_=u[1]*g-u[2]*m,y=u[2]*f-u[0]*g,v=u[0]*m-u[1]*f,x=h*_+p*y+d*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=c[0]-e,M=c[1]-t,T=c[2]-i,S=(w*_+M*y+T*v)*b;if(S<0||S>1)return null;const E=M*d-T*p,A=T*h-w*d,C=w*p-M*h,L=(u[0]*E+u[1]*A+u[2]*C)*b;return L<0||S+L>1?null:(f*E+m*A+g*C)*b}function _f(e,t,i){return(e-t)/(i-t)}function yf(e,t,i,n,r,o,s,a,l){const c=1<<i,u=o-n,h=s-r,p=(e+1)/c*u+n,d=(t+0)/c*h+r,f=(t+1)/c*h+r;a[0]=(e+0)/c*u+n,a[1]=d,l[0]=p,l[1]=f}class vf{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(e){const t=Math.ceil(Math.log2(e.dim/8)),i=[];let n=Math.ceil(Math.pow(2,t));const r=1/n,o=(e,t,i,n,r)=>{const o=n?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;r[0]=e*i,r[1]=a,r[2]=s,r[3]=l};let s=new ff(n);const a=[];for(let t=0;t<n*n;t++){o(t%n,Math.floor(t/n),r,!1,a);const i=bf(a[0],a[1],e),l=bf(a[2],a[1],e),c=bf(a[2],a[3],e),u=bf(a[0],a[3],e);s.minimums.push(Math.min(i,l,c,u)),s.maximums.push(Math.max(i,l,c,u)),s.leaves.push(1)}for(i.push(s),n/=2;n>=1;n/=2){const e=i[i.length-1];s=new ff(n);for(let t=0;t<n*n;t++){o(t%n,Math.floor(t/n),2,!0,a);const i=e.getElevation(a[0],a[1]),r=e.getElevation(a[2],a[1]),l=e.getElevation(a[2],a[3]),c=e.getElevation(a[0],a[3]),u=e.isLeaf(a[0],a[1]),h=e.isLeaf(a[2],a[1]),p=e.isLeaf(a[2],a[3]),d=e.isLeaf(a[0],a[3]),f=Math.min(i.min,r.min,l.min,c.min),m=Math.max(i.max,r.max,l.max,c.max),g=u&&h&&p&&d;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&g?1:0)}i.push(s)}return i}(this.dem),i=t.length-1,n=t[i];this._addNode(n.minimums[0],n.maximums[0],n.leaves[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,n,r,o,s=1){return mf([e,t,-100],[i,n,this.maximums[0]*s],r,o)}raycast(e,t,i,n,r,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(e,t,i,n,r,o,s);if(null==a)return null;const l=[],c=[],u=[],h=[],p=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:a,t:d,nodex:f,nodey:m,depth:g}=p.pop();if(this.leaves[a]){yf(f,m,g,e,t,i,n,u,h);const a=1<<g,l=(f+0)/a,c=(f+1)/a,p=(m+0)/a,_=(m+1)/a,y=bf(l,p,this.dem)*s,v=bf(c,p,this.dem)*s,x=bf(c,_,this.dem)*s,b=bf(l,_,this.dem)*s,w=gf(u[0],u[1],y,h[0],u[1],v,h[0],h[1],x,r,o),M=gf(h[0],h[1],x,u[0],h[1],b,u[0],u[1],y,r,o),T=Math.min(null!==w?w:Number.MAX_VALUE,null!==M?M:Number.MAX_VALUE);if(T!==Number.MAX_VALUE)return T;{const e=Rl([],r,o,d);if(xf(y,v,b,x,_f(e[0],u[0],h[0]),_f(e[1],u[1],h[1]))>=e[2])return d}continue}let _=0;for(let p=0;p<this._siblingOffset.length;p++){yf((f<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],g+1,e,t,i,n,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[a]+p]*s;const d=mf(u,h,r,o);if(null!=d){const e=d;l[p]=e;let t=!1;for(let i=0;i<_&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,p),t=!0);t||(c[_]=p),_++}}for(let e=0;e<_;e++){const t=c[e];p.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<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(e,t,i,n,r){if(1===e[n].isLeaf(t,i))return;this.childOffsets[r]||(this.childOffsets[r]=this.nodeCount);const o=n-1,s=e[o];let a=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const n=2*t+this._siblingOffset[e][0],r=2*i+this._siblingOffset[e][1],o=s.getElevation(n,r),c=s.isLeaf(n,r),u=this._addNode(o.min,o.max,c);c&&(a|=1<<e),l||(l=u)}for(let n=0;n<this._siblingOffset.length;n++)a&1<<n||this._construct(e,2*t+this._siblingOffset[n][0],2*i+this._siblingOffset[n][1],o,l+n)}}function xf(e,t,i,n,r,o){return _i(_i(e,i,o),_i(t,n,o),r)}function bf(e,t,i){const n=i.dim,r=f(e*n-.5,0,n-1),o=f(t*n-.5,0,n-1),s=Math.floor(r),a=Math.floor(o),l=Math.min(s+1,n-1),c=Math.min(a+1,n-1);return xf(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),r-s,o-a)}const wf={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Mf{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,n=!1,r=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return P(`"${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=n,!n){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)],r&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new vf(this)}get(e,t,i=!1){i&&(e=f(e,-1,this.dim),t=f(t,-1,this.dim));const n=4*this._idx(e,t);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[n],this.pixels[n+1],this.pixels[n+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],n=Mf.getUnpackVector(t);let r=Math.floor((e+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new lc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t<s;t++)for(let i=n;i<r;i++){const n=4*this._idx(i,t),r=4*this._idx(i+a,t+l);this.pixels[n+0]=e.pixels[r+0],this.pixels[n+1]=e.pixels[r+1],this.pixels[n+2]=e.pixels[r+2],this.pixels[n+3]=e.pixels[r+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Pr(Mf,"DEMData"),Pr(vf,"DemMinMaxQuadTree",{omit:["dem"]});class Tf{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 n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(e,r)}),i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class Sf{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Sf.ReadOnly=!1,Sf.ReadWrite=!0,Sf.disabled=new Sf(519,Sf.ReadOnly,[0,1]);const Ef=7680;class Af{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Af.disabled=new Af({func:519,mask:0},0,0,Ef,Ef,Ef);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,_t.transparent,[!1,!1,!1,!1]),Cf.unblended=new Cf(Cf.Replace,_t.transparent,[!0,!0,!0,!0]),Cf.alphaBlended=new Cf([1,771],_t.transparent,[!0,!0,!0,!0]);const Lf=1029,If=2305;class Pf{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Pf.disabled=new Pf(!1,Lf,If),Pf.backCCW=new Pf(!0,Lf,If),Pf.backCW=new Pf(!0,Lf,2304),Pf.frontCW=new Pf(!0,1028,2304),Pf.frontCCW=new Pf(!0,1028,If);class Rf 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 Tf(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 t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager)}}getIds(){return y(this._tiles).map((e=>e.tileID)).sort(kf).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,n=t.tileID,o=new r(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new r(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):t.map((e=>e.tileID)).sort(kf).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,n){if(n)if(e.state="errored",404!==n.status)this._source.fire(new Ve(n,{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=$.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new je("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n<t.length;n++){const r=t[n];if(e.neighboringTiles&&e.neighboringTiles[r]){const t=this.getTileByID(r);i(e,t),i(t,e)}}function i(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 n=t.tileID.canonical.y-e.tileID.canonical.y,r=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===n||Math.abs(n)>1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){n[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),n=this._getLoadedTile(t);if(n)return n}}_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,n=Math.ceil(e.height/t)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}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(e,t,i){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let n;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new Eu(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(n=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(n=n.filter((e=>this._source.hasTile(e))))):n=[];const r=this._updateRetainedTiles(n);if(zf(this._source.type)&&0!==n.length){const e={},t={},i=Object.keys(r);for(const n of i){const i=r[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=$.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Rf.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),e[s.tileID.key]=s.tileID),t[n]=i}const o=n[n.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(r[e]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>o;){n=n.scaledTo(n.overscaledZ-1);const o=this._tiles[n.key];if(o&&o.hasData()&&t[n.key]){r[e]=i.tileID;break}}}for(const t in e)r[t]||(this._coveredTiles[t]=!0,r[t]=e[t])}for(const e in r)this._tiles[e].clearFadeHold();const o=function(e,t){const i=[];for(const n in e)n in t||i.push(n);return i}(this._tiles,r);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}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 t={};if(0===e.length)return t;const i={},n=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),r=e[0].overscaledZ,o=Math.max(r-Rf.maxOverzooming,this._source.minzoom),s=Math.max(r+Rf.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||n<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,n,s,t);for(const n of e){let e=this._tiles[n.key];if(e.hasData())continue;if(n.canonical.z>=this._source.maxzoom){const e=n.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=n.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&r&&(e=this._addTile(o)),e&&(t[o.key]=o,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(e){let t=this._tiles[e.key];if(t)return this._source.prepareTile&&this._source.prepareTile(t),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null;t=new pf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(t)||this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new je("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Aa(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(f(s,...Df(e,-1))-s),Math.abs(f(s,...Df(e,1))-s)];c=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(f(s,...Df(e,-1))-s),Math.abs(f(s,...Df(e,0))-s),Math.abs(f(s,...Df(e,1))-s)];c=[t.indexOf(Math.min(...t))-1]}}else c=[0];for(const i of c){const o=e.containsTile(l,r,t,i);o&&n.push(o)}}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(zf(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=$.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 n=this._tiles[e];n&&n.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)))}_preloadTiles(e,t){const i=new Map,n=Array.isArray(e)?e:[e],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const e of n){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)}_(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 kf(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function zf(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]}Rf.maxOverzooming=10,Rf.maxUnderzooming=3;class Of{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const n=i||e.findDEMTileFor(t);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1<<t.canonical.z-o.canonical.z;return new Of(n,n.tileSize/ba/s,[(t.canonical.x/s-o.canonical.x)*r.dim,(t.canonical.y/s-o.canonical.y)*r.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1],n=Math.floor(e*this._scale+this._offset[0]),o=Math.floor(i);return new r(n,o)}getElevationAt(e,t,i,n){const r=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],s=Math.floor(r),a=Math.floor(o),l=this._dem;return n=!!n,i?_i(_i(l.get(s,a,n),l.get(s,a+1,n),o-a),_i(l.get(s+1,a,n),l.get(s+1,a+1,n),o-a),r-s):l.get(s,a,n)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*La(1,e)*this._dem.stride}}class Ff{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Cr(ba,16,0),this.featureIndexArray=new Ds,this.promoteId=t}insert(e,t,i,n,r,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const a=this.grid;for(let e=0;e<t.length;e++){const i=t[e],n=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];n[0]=Math.min(n[0],t.x),n[1]=Math.min(n[1],t.y),n[2]=Math.max(n[2],t.x),n[3]=Math.max(n[3],t.y)}n[0]<ba&&n[1]<ba&&n[2]>=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new hu.VectorTile(new lh(this.rawTileData)).layers,this.sourceLayerCoder=new Kd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,i,n){this.loadVTLayers();const r=e.params||{},o=Yn(r.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,n)=>nl(s.bufferedTilespaceGeometry,e,t,i,n)));c.sort(Nf);let u=null;a.elevation&&c.length>0&&(u=Of.create(a.elevation,this.tileID));const h={};let p;for(let a=0;a<c.length;a++){const l=c[a];if(l===p)continue;p=l;const d=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(h,d,o,r.layers,r.availableImages,t,i,n,((t,i,n,r=0)=>(f||(f=Va(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(s,t,n,f,this.z,e.transform,e.pixelPosMatrix,u,r))))}return h}loadMatchingFeature(e,t,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=t,d=this.bucketLayerIDs[u];if(n&&!function(e,t){for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0)return!0;return!1}(n,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=Ga(m,!0);if(!i.filter(new Po(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new Po(this.tileID.overscaledZ),m))return;const g=this.getId(m,f);for(let t=0;t<d.length;t++){const i=d[t];if(n&&n.indexOf(i)<0)continue;const u=o[i];if(!u)continue;let h={};void 0!==g&&a&&(h=a.getState(u.sourceLayer||"_geojsonTileLayer",g));const f=v({},s[i]);f.paint=Bf(f.paint,u.paint,m,h,r),f.layout=Bf(f.layout,u.layout,m,h,r);const _=!l||l(m,u,h,p);if(!_)continue;const y=new tf(m,this.z,this.x,this.y,g);y.layer=f;let x=e[i];void 0===x&&(x=e[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:_})}}lookupSymbolFeatures(e,t,i,n,r,o,s,a){const l={};this.loadVTLayers();const c=Yn(r);for(const r of e)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:n,featureIndex:r,layoutVertexArrayOffset:0},c,o,s,a,t);return l}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const n=this.sourceLayerCoder.decode(i),r=this.vtFeatures[n];if(r[t])return r[t];const o=this.vtLayers[n].feature(t);return r[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 Bf(e,t,i,n,r){return A(e,((e,o)=>{const s=t instanceof No?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Nf(e,t){return t-e}Pr(Ff,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Uf{constructor(e){const t={},i=[];for(const n in e){const r=e[n],o=t[n]={};for(const e in r.glyphs){const t=r.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const n=t.metrics.localGlyph?2:1,s={x:0,y:0,w:t.bitmap.width+2*n,h:t.bitmap.height+2*n};i.push(s),o[e]=s}}const{w:n,h:r}=Ph(i),o=new ac({width:n||1,height:r||1});for(const i in e){const n=e[i];for(const e in n.glyphs){const r=n.glyphs[+e];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const s=t[i][e],a=r.metrics.localGlyph?2:1;ac.copy(r.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},r.bitmap)}}this.image=o,this.positions=t}}Pr(Uf,"GlyphAtlas");class jf{constructor(e){this.tileID=new Eu(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(e,t,i,n,r){this.status="parsing",this.data=e,this.collisionBoxArray=new As;const o=new Kd(Object.keys(e.layers).sort()),s=new Ff(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Yd(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},u=t.familiesBySource[this.source];for(const t in u){const n=e.layers[t];if(!n)continue;let r=!1,l=!1;for(const e of u[t])"symbol"===e[0].type?r=!0:l=!0;if(!0===this.isSymbolTile&&!r)continue;if(!1===this.isSymbolTile&&!l)continue;1===n.version&&P(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=o.encode(t),p=[];for(let e=0;e<n.length;e++){const i=n.feature(e),r=s.getId(i,t);p.push({feature:i,id:r,index:e,sourceLayerIndex:h})}for(const e of u[t]){const t=e[0];void 0!==this.isSymbolTile&&"symbol"===t.type!==this.isSymbolTile||t.minzoom&&this.zoom<Math.floor(t.minzoom)||t.maxzoom&&this.zoom>=t.maxzoom||"none"!==t.visibility&&(Vf(e,this.zoom,i),(a[t.id]=t.createBucket({index:s.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:i})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(e.map((e=>e.id))))}}let h,p,d,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=A(c.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(g).length?n.send("getGlyphs",{uid:this.uid,stacks:g},((e,t)=>{h||(h=e,p=t,x.call(this))}),void 0,!1,m):p={};const _=Object.keys(c.iconDependencies);_.length?n.send("getImages",{icons:_,source:this.source,tileID:this.tileID,type:"icons"},((e,t)=>{h||(h=e,d=t,x.call(this))}),void 0,!1,m):d={};const v=Object.keys(c.patternDependencies);function x(){if(h)return r(h);if(p&&d&&f){const e=new Uf(p),t=new kh(d,f);for(const n in a){const r=a[n];r instanceof Bd?(Vf(r.layers,this.zoom,i),Tp(r,p,e.positions,d,t.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection)):r.hasPattern&&(r instanceof Bu||r instanceof Yc||r instanceof yu)&&(Vf(r.layers,this.zoom,i),r.addFeatures(c,this.tileID.canonical,t.patternPositions,i,this.tileTransform))}this.status="done",r(null,{buckets:y(a).filter((e=>!e.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?e.positions:null})}}v.length?n.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},((e,t)=>{h||(h=e,f=t,x.call(this))}),void 0,!1,m):f={},x.call(this)}}function Vf(e,t,i){const n=new Po(t);for(const t of e)t.recalculate(n,i)}class Gf{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,n){const r=this.entries[e]=this.entries[e]||{callbacks:[]};if(r.result){const[e,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(e,i)}),t):n(e,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const e of r.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,n)}),t):e(i,n);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((e=>e!==n)),r.callbacks.length||(r.cancel(),delete this.entries[e]))}}}function Hf(e,t,i){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const n=Pe(e.request,((e,n,r,o)=>{e?t(e):n&&t(null,{vectorTile:i?void 0:new hu.VectorTile(new lh(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),t()}}),t)}e.ARRAY_TYPE=pl,e.AUTH_ERR_MSG=ne,e.Aabb=Jl,e.Actor=class{constructor(e,i,n){this.target=e,this.parent=i,this.mapId=n,this.callbacks={},this.cancelCallbacks={},S(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=z()?e:t,this.scheduler=new Qd}send(e,t,i,n,r=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=F(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:e,hasCallback:!!i,targetMapId:n,mustQueue:r,sourceMapId:this.mapId,data:zr(t,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:n,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(e,t){if("<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Dr(t.error)):i(null,Dr(t.data)))}else{const i=F(this.globalScope)?void 0:[],n=t.hasCallback?(t,n)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?zr(t):null,data:zr(n,i)},i)}:e=>{},r=Dr(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,r,n);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],r.source)[e[1]](r,n)}else n(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Tu,e.Color=_t,e.ColorMode=Cf,e.CullFaceMode=Pf,e.DEMData=Mf,e.DataConstantProperty=Uo,e.DedupedRequest=Gf,e.DepthMode=Sf,e.EXTENT=ba,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,n=1<<i,r=Math.floor(e.x),o=Math.floor((e.x-r)*n),s=Math.floor(e.y*n),a=this.findDEMTileFor(new Eu(i,r,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 n=this._source();if(!n)return t;if(e.y<0||e.y>1)return t;const r=n.getSource().maxzoom,o=1<<r,s=Math.floor(e.x),a=e.x-s,l=new Eu(r,s,r,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,p=(a*h-c.tileID.canonical.x)*u.dim,d=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(p),m=Math.floor(d);return(i?this.exaggeration():1)*_i(_i(u.get(f,m),u.get(f,m+1),d-m),_i(u.get(f+1,m),u.get(f+1,m+1),d-m),p-f)}getAtTileOffset(e,t,i){const n=1<<e.canonical.z;return this.getAtPointOrZero(new za(e.wrap+(e.canonical.x+t/ba)/n,(e.canonical.y+i/ba)/n))}getAtTileOffsetFunc(e,t,i,n){return r=>{const o=this.getAtTileOffset(e,r.x,r.y),s=n.upVector(e.canonical,r.x,r.y);return Pl(s,s,o*n.upVectorScale(e.canonical,t,i).metersToTile),s}}getForTilePoints(e,t,i,n){const r=Of.create(this,e,n);return!!r&&(t.forEach((e=>{e[2]=this.exaggeration()*r.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,n=t.tileID,r=1<<e.canonical.z-n.canonical.z;let o=e.canonical.x/r-n.canonical.x,s=e.canonical.y/r-n.canonical.y,a=0;for(let t=0;t<e.canonical.z-n.canonical.z&&!i.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+e,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.")}},e.ErrorEvent=Ve,e.EvaluationParameters=Po,e.Event=je,e.Evented=Ge,e.FillExtrusionBucket=yu,e.Frustum=Yl,e.FrustumCorners=Xl,e.GLOBE_METERS_TO_ECEF=Bp,e.GLOBE_RADIUS=Fp,e.GLOBE_SCALE_MATCH_LATITUDE=45,e.GLOBE_ZOOM_THRESHOLD_MAX=6,e.GLOBE_ZOOM_THRESHOLD_MIN=5,e.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 e of this._gridSegments)e.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const e of this._wireframeSegments)e.destroy()}}_createGrid(e){const t=new Qo,i=new fs,n=65;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t.emplaceBack(i,e);this._gridSegments=[];for(let e=0,t=0;e<Np.length;e++){const r=Np[e];for(let e=0;e<r;e++)for(let t=0;t<64;t++){const r=e*n+t;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+1,r+1)}const o=64*r*2;this._gridSegments.push(xa.simpleSegment(0,t,(r+1)*n,o)),t+=o}this._gridBuffer=e.createVertexBuffer(t,Op.members),this._gridIndexBuffer=e.createIndexBuffer(i,!0)}_createPoles(e){const t=new fs;for(let e=0;e<=64;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new ys,n=new ys;this._poleSegments=[];for(let e=0,t=0;e<5;e++){const r=1<<e,o=512*r/Math.PI/2,s=360/r;i.emplaceBack(0,-o,0,0,0,.5,0),n.emplaceBack(0,-o,0,0,0,.5,1);for(let e=0;e<=64;e++){const t=e/64,r=_i(0,s,t),[a,l,c]=Xp(od,sd,r,o);i.emplaceBack(a,l,c,0,0,t,0),n.emplaceBack(a,l,c,0,0,t,1)}this._poleSegments.push(xa.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,zp,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(n,zp,!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,t){if(!this._wireframeSegments){const t=new bs,i=64,n=i+1;this._wireframeSegments=[];for(let e=0,r=0;e<Np.length;e++){const o=Np[e];for(let e=0;e<o;e++)for(let r=0;r<i;r++){const i=e*n+r;t.emplaceBack(i,i+1),t.emplaceBack(i,i+n),t.emplaceBack(i,i+n+1)}const s=o*i*3;this._wireframeSegments.push(xa.simpleSegment(0,r,(o+1)*n,s)),r+=s}this._wireframeIndexBuffer=e.createIndexBuffer(t)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[t]]}},e.GlyphManager=cp,e.ImagePosition=Rh,e.LineAtlas=Yd,e.LngLat=Ta,e.LngLatBounds=wa,e.LocalGlyphMode=lp,e.MAX_MERCATOR_LATITUDE=ka,e.MercatorCoordinate=za,e.ONE_EM=Yu,e.OverscaledTileID=Eu,e.Properties=Wo,e.RGBAImage=lc,e.Ray=Zl,e.RequestManager=class{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",ie,e].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(!re(e))return e;const i=ae(e);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!re(e))return e;const i=ae(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,n){if(!re(e))return e;const r=ae(e);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,n){const r=ae(e);return re(e)?(r.path=`/styles/v1${r.path}/sprite${t}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${t}${i}`,le(r))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!re(e))return e;const n=ae(e);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==n.authority&&512===i?"@2x":""}${Y.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${X.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${X.TILE_URL_VERSION}${n.path}`);const r=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(n.params)||X.ACCESS_TOKEN;return X.REQUIRE_ACCESS_TOKEN&&r&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,r)}canonicalizeTileURL(e,t){const i=ae(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${X.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${X.TILE_URL_VERSION}/`,"")}`;let r=i.params;return t&&(r=r.filter((e=>!e.match(/^access_token=/)))),r.length&&(n+=`?${r.join("&")}`),n}canonicalizeTileset(e,t){const i=!!t&&re(t),n=[];for(const t of e.tiles||[])oe(t)?n.push(this.canonicalizeTileURL(t,i)):n.push(t);return n}_makeAPIURL(e,t){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",n=ae(X.API_URL);if(e.protocol=n.protocol,e.authority=n.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==n.path&&(e.path=`${n.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)}},e.ResourceType=Ae,e.SegmentVector=xa,e.SourceCache=Rf,e.StencilMode=Af,e.StructArrayLayout1ui2=ws,e.StructArrayLayout2f1f2i16=hs,e.StructArrayLayout2i4=Qo,e.StructArrayLayout2ui4=bs,e.StructArrayLayout3f12=ds,e.StructArrayLayout3ui6=fs,e.StructArrayLayout4i8=es,e.StructArrayLayout5f20=vs,e.Texture=Xd,e.Tile=pf,e.Transitionable=zo,e.Uniform1f=Js,e.Uniform1i=class extends Ys{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.Uniform2f=class extends Ys{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]))}},e.Uniform3f=class extends Ys{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]))}},e.Uniform4f=Qs,e.UniformColor=Ks,e.UniformMatrix2f=class extends Ys{constructor(e,t){super(e,t),this.current=ia}set(e){for(let t=0;t<4;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix2fv(this.location,!1,e);break}}},e.UniformMatrix3f=class extends Ys{constructor(e,t){super(e,t),this.current=ta}set(e){for(let t=0;t<9;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix3fv(this.location,!1,e);break}}},e.UniformMatrix4f=class extends Ys{constructor(e,t){super(e,t),this.current=ea}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.UnwrappedTileID=Su,e.ValidationError=jn,e.VectorTileWorkerSource=class extends Ge{constructor(e,t,i,n,r){super(),this.actor=e,this.layerIndex=t,this.availableImages=i,this.loadVectorData=r||Hf,this.loading={},this.loaded={},this.deduped=new Gf(e.scheduler),this.isSpriteLoaded=n,this.scheduler=e.scheduler}loadTile(e,t){const i=e.uid,n=e&&e.request,r=n&&n.collectResourceTiming,o=this.loading[i]=new jf(e);o.abort=this.loadVectorData(e,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),t(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new hu.VectorTile(new lh(c));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,i)=>{if(e||!i)return t(e);const o={};if(r){const e=j(n);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,v({rawTileData:c.slice(0)},i,u,o))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[i]=o}))}reloadTile(e,t){const i=this.loaded,n=e.uid,r=this;if(i&&i[n]){const o=i[n];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=ld(e.tileID.canonical,e.projection);const s=(e,i)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,r.layerIndex,this.availableImages,r.actor,n)),t(e,i)};"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,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}},e.WritingMode=zh,e.ZoomHistory=Or,e.add=El,e.addDynamicAttributes=zd,e.adjoint=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=s*u-a*c,e[1]=r*c-n*u,e[2]=n*a-r*s,e[3]=a*l-o*u,e[4]=i*u-r*l,e[5]=r*o-i*a,e[6]=o*c-s*l,e[7]=n*l-i*c,e[8]=i*s-n*o,e},e.asyncAll=_,e.bezier=p,e.bindAll=S,e.boundsAttributes=uf,e.bufferConvexPolygon=function(e,t){const i=[];for(let n=0;n<e.length;n++){const r=g(n-1,-1,e.length-1),o=g(n+1,-1,e.length-1),s=e[n],a=e[o],l=e[r].sub(s).unit(),c=a.sub(s).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));i.push(s.add(h))}return i},e.cacheEntryPossiblyAdded=function(e){Ee++,Ee>xe&&(e.getActor().send("enforceCacheSizeLimit",ve),Ee=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:i,y:n}=e.point,r=td(i,n,e.worldSize/e._projectionScaler,0,0);return ml(r,r,ed(qp(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:i}=e.point,{lng:n,lat:r}=e._center;return td(t,i,e.worldSize,n,r)},e.calculateGlobeMercatorMatrix=function(e){const t=e.worldSize,i=e.point,n=La(1,e.center.lat)*t,r=e.pixelsPerMeter,o=t/(n/e.pixelsPerMeter),s=fl(new Float64Array(16));return gl(s,s,[i.x,i.y,0]),_l(s,s,[o,o,r]),Float32Array.from(s)},e.circumferenceAtLatitude=Ea,e.clamp=f,e.clearTileCache=function(e){const i=[];for(const e in be)i.push(t.caches.delete(e)),delete be[e];e&&Promise.all(i).catch(e).then((()=>e()))},e.clipLine=rp,e.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},e.clone$1=L,e.collisionCircleLayout=Xu,e.config=X,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.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},e.create$1=dl,e.createExpression=Dn,e.createLayout=Yo,e.createStyleLayer=function(e){return"custom"===e.type?new Wd(e):new Zd[e.type](e)},e.cross=Dl,e.degToRad=l,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.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},e.dot=zl,e.ease=d,e.easeCubicInOut=h,e.emitValidationErrors=Ar,e.endsWith=E,e.enforceCacheSizeLimit=function(e){for(const t in be)Me(t),be[t].then((t=>{t.keys().then((i=>{for(let n=0;n<i.length-e;n++)t.delete(i[n])}))}))},e.evaluateSizeForFeature=Ku,e.evaluateSizeForZoom=eh,e.evaluateVariableOffset=Mp,e.evented=Ao,e.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},e.exactEquals$1=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},e.exported=$,e.exported$1=Y,e.extend=v,e.extend$1=We,e.fillExtrusionHeightLift=xu,e.filterObject=C,e.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},e.fromQuat=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=i+i,a=n+n,l=r+r,c=i*s,u=n*s,h=n*a,p=r*s,d=r*a,f=r*l,m=o*s,g=o*a,_=o*l;return e[0]=1-h-f,e[1]=u+_,e[2]=p-g,e[3]=0,e[4]=u-_,e[5]=1-c-f,e[6]=d+m,e[7]=0,e[8]=p+g,e[9]=d-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.fromRotation=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=i,e[2]=0,e[3]=-i,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.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},e.furthestTileCorner=function(e){const t=Math.round((e+45+360)%360/90)%4;return u[t]},e.getAABBPointSquareDist=function(e,t,i){let n=0;for(let r=0;r<2;++r){const o=i?i[r]:0;e[r]>o&&(n+=(e[r]-o)*(e[r]-o)),t[r]<o&&(n+=(o-t[r])*(o-t[r]))}return n},e.getAnchorAlignment=qh,e.getAnchorJustification=Sp,e.getBounds=function(e){let t=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of e)t=Math.min(t,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x),o=Math.max(o,r.y);return{min:new r(t,i),max:new r(n,o)}},e.getColumn=N,e.getGridMatrix=function(e,t,i){const[n,r]=t,o=.015625;return[0,(r[1]-n[1])*o,1<<e.z,(r[0]-n[0])/Np[i],0,e.y,n[0],n[1],o]},e.getImage=Be,e.getJSON=function(e,t){return Ie(v(e,{type:"json"}),t)},e.getLatitudinalLod=function(e){const t=80.051129;e=f(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(l(e))),3);return Math.round(i*(Np.length-1))},e.getMapSessionAPI=ge,e.getPerformanceMeasurement=j,e.getProjection=Ld,e.getRTLTextPluginStatus=Co,e.getReferrer=Le,e.getTilePoint=function(e,{x:t,y:i},n=0){return new r(((t-n)*e.scale-e.x)*ba,(i*e.scale-e.y)*ba)},e.getTileVec3=function(e,t,i=0){return Sl(((t.x-i)*e.scale-e.x)*ba,(t.y*e.scale-e.y)*ba,Ra(t.z,t.y))},e.getVideo=function(e,i){const n=t.document.createElement("video");n.muted=!0,n.onloadstart=function(){i(null,n)};for(let i=0;i<e.length;i++){const r=t.document.createElement("source");ze(e[i])||(n.crossOrigin="Anonymous"),r.src=e[i],n.appendChild(r)}return{cancel:()=>{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],i=fl(new Float64Array(16));return ml(i,e.pixelMatrix,e.globeMatrix),Ol(t,t,i),new r(t[0],t[1])},e.globeECEFOrigin=function(e,t){const i=[0,0,0];return Ol(i,i,Kp(qp(t.canonical))),Ol(i,i,e),i},e.globeNormalizeECEF=Kp,e.globePixelsToTileUnits=function(e,t){return ba/(512*Math.pow(2,e))*Qp(qp(t))},e.globePoleMatrixForTile=function(e,t,i){const n=fl(new Float64Array(16)),r=1<<e,o=360*(t/r-.5),s=i.point,a=i.worldSize/(i.tileSize*r);return gl(n,n,[s.x,s.y,-i.worldSize/Math.PI/2]),_l(n,n,[a,a,a]),yl(n,n,l(-i._center.lat)),vl(n,n,l(-i._center.lng+o)),Float32Array.from(n)},e.globeTileBounds=qp,e.globeTileLatLngCorners=Zp,e.globeTiltAtLngLat=nd,e.globeToMercatorTransition=id,e.globeUseCustomAntiAliasing=function(e,t,i){const n=id(i.zoom),r=e.style.map._antialias,o=!!t.extStandardDerivatives,s=t.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!r&&!s&&o},e.identity=fl,e.identity$1=Wl,e.invert=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],p=t[10],d=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=i*a-n*s,v=i*l-r*s,x=i*c-o*s,b=n*l-r*a,w=n*c-o*a,M=r*c-o*l,T=u*m-h*f,S=u*g-p*f,E=u*_-d*f,A=h*g-p*m,C=h*_-d*m,L=p*_-d*g,I=y*L-v*C+x*A+b*E-w*S+M*T;return I?(e[0]=(a*L-l*C+c*A)*(I=1/I),e[1]=(r*C-n*L-o*A)*I,e[2]=(m*M-g*w+_*b)*I,e[3]=(p*w-h*M-d*b)*I,e[4]=(l*E-s*L-c*S)*I,e[5]=(i*L-r*E+o*S)*I,e[6]=(g*x-f*M-_*v)*I,e[7]=(u*M-p*x+d*v)*I,e[8]=(s*C-a*E+c*T)*I,e[9]=(n*E-i*C-o*T)*I,e[10]=(f*w-m*x+_*y)*I,e[11]=(h*x-u*w-d*y)*I,e[12]=(a*S-s*A-l*T)*I,e[13]=(i*A-n*S+r*T)*I,e[14]=(m*v-f*b-g*y)*I,e[15]=(u*b-h*v+p*y)*I,e):null},e.isLngLatBehindGlobe=function(e,t){return nd(e,t)>Math.PI/2*1.01},e.isMapAuthenticated=function(e){return _e.has(e)},e.isMapboxURL=re,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!F(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/))},e.latFromMercatorY=Pa,e.len=jl,e.length=Tl,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.loadVectorTile=Hf,e.makeRequest=Ie,e.mapValue=function(e,t,i,n,r){return f((e-t)/(i-t)*(r-n)+n,n,r)},e.mercatorXfromLng=Aa,e.mercatorYfromLat=Ca,e.mercatorZfromAltitude=La,e.mul=bl,e.mul$1=Ul,e.multiply=ml,e.multiply$1=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=i[0],d=i[1],f=i[2],m=i[3],g=i[4],_=i[5],y=i[6],v=i[7],x=i[8];return e[0]=p*n+d*s+f*c,e[1]=p*r+d*a+f*u,e[2]=p*o+d*l+f*h,e[3]=m*n+g*s+_*c,e[4]=m*r+g*a+_*u,e[5]=m*o+g*l+_*h,e[6]=y*n+v*s+x*c,e[7]=y*r+v*a+x*u,e[8]=y*o+v*l+x*h,e},e.multiply$2=Cl,e.nextPowerOfTwo=M,e.normalize=kl,e.normalize$1=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=i*i+n*n+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=n*s,e[2]=r*s,e[3]=o*s,e},e.number=_i,e.ortho=function(e,t,i,n,r,o,s){var a=1/(t-i),l=1/(n-r),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]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e},e.pbf=lh,e.perspective=function(e,t,i,n,r){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!=r&&r!==1/0?(e[10]=(r+n)*(o=1/(n-r)),e[14]=2*r*n*o):(e[10]=-1,e[14]=-2*n),e},e.pick=function(e,t){const i={};for(let n=0;n<t.length;n++){const r=t[n];r in e&&(i[r]=e[r])}return i},e.plugin=Io,e.pointGeometry=r,e.polygonContainsPoint=il,e.polygonIntersectsBox=nl,e.polygonIntersectsPolygon=$a,e.polygonizeBounds=function(e,t,i=0,n=!0){const o=new r(i,i),s=e.sub(o),a=t.add(o),l=[s,new r(a.x,s.y),a,new r(s.x,a.y)];return n&&l.push(s.clone()),l},e.posAttributes=Op,e.postMapLoadEvent=fe,e.postTurnstileEvent=pe,e.potpack=Ph,e.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.radToDeg=c,e.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.registerForPluginStateChange=function(e){return e({pluginStatus:Mo,pluginURL:To}),Ao.on("pluginStateChange",e),e},e.removeAuthState=function(e){_e.delete(e)},e.renderColorRamp=uc,e.resample=Oa,e.rotateX=yl,e.rotateX$1=ql,e.rotateY=vl,e.rotateY$1=$l,e.rotateZ=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=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*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+p*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=p*r-l*n,e},e.rotateZ$1=function(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l+r*a,e[1]=r*l-n*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},e.scale=_l,e.scale$1=Vl,e.scale$2=Pl,e.scaleAndAdd=Rl,e.setCacheLimits=function(e,t){ve=e,xe=t},e.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]},e.setRTLTextPlugin=function(e,t,i=!1){if(Mo===vo||Mo===xo||Mo===bo)throw new Error("setRTLTextPlugin cannot be called multiple times.");To=$.resolveURL(e),Mo=vo,wo=t,Eo(),i||Lo()},e.smoothstep=m,e.spec=He,e.storeAuthState=function(e,t){t?_e.add(e):_e.delete(e)},e.sub=Nl,e.subtract=Al,e.symbolSize=th,e.tileAABB=function(e,t,i,n,r,o,s,a,l){if("globe"===l.name)return $p(e,t,new Tu(i,n,r));const c=ld({z:i,x:n,y:r},l);return new Jl([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},e.tileTransform=ld,e.transformMat3=function(e,t,i){var n=t[0],r=t[1],o=t[2];return e[0]=n*i[0]+r*i[3]+o*i[6],e[1]=n*i[1]+r*i[4]+o*i[7],e[2]=n*i[2]+r*i[5]+o*i[8],e},e.transformMat4=Ol,e.transformMat4$1=Gl,e.transformQuat=Fl,e.translate=gl,e.transpose=function(e,t){if(e===t){var i=t[1],n=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=n,e[7]=r}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},e.triggerPluginCompletionEvent=So,e.uniqueId=b,e.updateGlobeVertexNormal=function(e,t,i,n,r){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=n,e.float32[o+2]=r},e.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},e.validateFilter=e=>Er(lr(e)),e.validateFog=e=>Er(vr(e)),e.validateLayer=e=>Er(dr(e)),e.validateLight=e=>Er(_r(e)),e.validateSource=e=>Er(gr(e)),e.validateStyle=Mr,e.validateTerrain=e=>Er(yr(e)),e.values=y,e.vectorTile=hu,e.version=V,e.warnOnce=P,e.window=t,e.wrap=g}));n(0,(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let i="[";for(const n of e)i+=`${t(n)},`;return`${i}]`}let i="{";for(const n of Object.keys(e).sort())i+=`${n}:${t(e[n])},`;return`${i}}`}function i(i){let n="";for(const r of e.refProperties)n+=`/${t(i[r])}`;return n}class n{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,n){for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.createStyleLayer(i)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=function(e,t){const n={};for(let r=0;r<e.length;r++){const o=t&&t[e[r].id]||i(e[r]);t&&(t[e[r].id]=o);let s=n[o];s||(s=n[o]=[]),s.push(e[r])}const r=[];for(const e in n)r.push(n[e]);return r}(e.values(this._layerConfigs),this.keyCache);for(const e of r){const t=e.map((e=>this._layers[e.id])),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(t)}}}class r{loadTile(t,i){const{uid:n,encoding:r,rawImageData:o,padding:s,buildQuadTree:a}=t,l=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap?this.getImageData(o,s):o;i(null,new e.DEMData(n,l,r,s<1,a))}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 o=function e(t,i){var n,r=t&&t.type;if("FeatureCollection"===r)for(n=0;n<t.features.length;n++)e(t.features[n],i);else if("GeometryCollection"===r)for(n=0;n<t.geometries.length;n++)e(t.geometries[n],i);else if("Feature"===r)e(t.geometry,i);else if("Polygon"===r)s(t.coordinates,i);else if("MultiPolygon"===r)for(n=0;n<t.coordinates.length;n++)s(t.coordinates[n],i);return t};function s(e,t){if(0!==e.length){a(e[0],t);for(var i=1;i<e.length;i++)a(e[i],!t)}}function a(e,t){for(var i=0,n=0,r=0,o=e.length,s=o-1;r<o;s=r++){var a=(e[r][0]-e[s][0])*(e[s][1]+e[r][1]),l=i+a;n+=Math.abs(i)>=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!t&&e.reverse()}const l=e.vectorTile.VectorTileFeature.prototype.toGeoJSON;class c{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.pointGeometry(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const n=[];for(const t of i)n.push(new e.pointGeometry(t[0],t[1]));t.push(n)}return t}}toGeoJSON(e,t,i){return l.call(this,e,t,i)}}class u{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.EXTENT,this.length=t.length,this._features=t}feature(e){return new c(this._features[e])}}var h=e.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 t=this.rawGeometry;this.geometry=[];for(var i=0;i<t.length;i++){for(var n=t[i],r=[],o=0;o<n.length;o++)r.push(new e.pointGeometry(n[o][0],n[o][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,n=1/0,r=-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),n=Math.min(n,l.y),r=Math.max(r,l.y)}return[t,n,i,r]},f.prototype.toGeoJSON=h.prototype.toGeoJSON;var m=_,g=p;function _(t){var i=new e.pbf;return function(e,t){for(var i in e.layers)t.writeMessage(3,y,e.layers[i])}(t,i),i.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 n={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<e.length;i++)n.feature=e.feature(i),t.writeMessage(2,v,n);var r=n.keys;for(i=0;i<r.length;i++)t.writeStringField(3,r[i]);var o=n.values;for(i=0;i<o.length;i++)t.writeMessage(4,T,o[i])}function v(e,t){var i=e.feature;void 0!==i.id&&t.writeVarintField(1,i.id),t.writeMessage(2,x,e),t.writeVarintField(3,i.type),t.writeMessage(4,M,i)}function x(e,t){var i=e.feature,n=e.keys,r=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&&(n.push(a),o[a]=c=n.length-1),t.writeVarint(c);var u=typeof l;"string"!==u&&"boolean"!==u&&"number"!==u&&(l=JSON.stringify(l));var h=u+":"+l,p=s[h];void 0===p&&(r.push(l),s[h]=p=r.length-1),t.writeVarint(p)}}}function b(e,t){return(t<<3)+(7&e)}function w(e){return e<<1^e>>31}function M(e,t){for(var i=e.loadGeometry(),n=e.type,r=0,o=0,s=i.length,a=0;a<s;a++){var l=i[a],c=1;1===n&&(c=l.length),t.writeVarint(b(1,c));for(var u=3===n?l.length-1:l.length,h=0;h<u;h++){1===h&&1!==n&&t.writeVarint(b(2,u-1));var p=l[h].x-r,d=l[h].y-o;t.writeVarint(w(p)),t.writeVarint(w(d)),r+=p,o+=d}3===n&&t.writeVarint(b(7,1))}}function T(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 S(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;E(e,t,s,n,r,o%2),S(e,t,i,n,s-1,o+1),S(e,t,i,s+1,r,o+1)}function E(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);E(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(A(e,t,n,i),t[2*r+o]>s&&A(e,t,n,r);a<l;){for(A(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*n+o]===s?A(e,t,n,l):(l++,A(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function A(e,t,i,n){C(e,i,n),C(t,2*i,2*n),C(t,2*i+1,2*n+1)}function C(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function L(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}m.fromVectorTileJs=_,m.fromGeojsonVt=function(e,t){t=t||{};var i={};for(var n in e)i[n]=new p(e[n].features,t),i[n].name=n,i[n].version=t.version,i[n].extent=t.extent;return _({layers:i})},m.GeoJSONWrapper=g;const I=e=>e[0],P=e=>e[1];class R{constructor(e,t=I,i=P,n=64,r=Float64Array){this.nodeSize=n,this.points=e;const o=e.length<65536?Uint16Array:Uint32Array,s=this.ids=new o(e.length),a=this.coords=new r(2*e.length);for(let n=0;n<e.length;n++)s[n]=n,a[2*n]=t(e[n]),a[2*n+1]=i(e[n]);S(s,a,n,0,s.length-1,0)}range(e,t,i,n){return function(e,t,i,n,r,o,s){const a=[0,e.length-1,0],l=[];let c,u;for(;a.length;){const h=a.pop(),p=a.pop(),d=a.pop();if(p-d<=s){for(let s=d;s<=p;s++)c=t[2*s],u=t[2*s+1],c>=i&&c<=r&&u>=n&&u<=o&&l.push(e[s]);continue}const f=Math.floor((d+p)/2);c=t[2*f],u=t[2*f+1],c>=i&&c<=r&&u>=n&&u<=o&&l.push(e[f]);const m=(h+1)%2;(0===h?i<=c:n<=u)&&(a.push(d),a.push(f-1),a.push(m)),(0===h?r>=c:o>=u)&&(a.push(f+1),a.push(p),a.push(m))}return l}(this.ids,this.coords,e,t,i,n,this.nodeSize)}within(e,t,i){return function(e,t,i,n,r,o){const s=[0,e.length-1,0],a=[],l=r*r;for(;s.length;){const c=s.pop(),u=s.pop(),h=s.pop();if(u-h<=o){for(let r=h;r<=u;r++)L(t[2*r],t[2*r+1],i,n)<=l&&a.push(e[r]);continue}const p=Math.floor((h+u)/2),d=t[2*p],f=t[2*p+1];L(d,f,i,n)<=l&&a.push(e[p]);const m=(c+1)%2;(0===c?i-r<=d:n-r<=f)&&(s.push(h),s.push(p-1),s.push(m)),(0===c?i+r>=d:n+r>=f)&&(s.push(p+1),s.push(u),s.push(m))}return a}(this.ids,this.coords,e,t,i,this.nodeSize)}}const k={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},z=Math.fround||(D=new Float32Array(1),e=>(D[0]=+e,D[0]));var D;class O{constructor(e){this.options=H(Object.create(k),e),this.trees=new Array(this.options.maxZoom+1)}load(e){const{log:t,minZoom:i,maxZoom:n,nodeSize:r}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;let s=[];for(let t=0;t<e.length;t++)e[t].geometry&&s.push(B(e[t],t));this.trees[n+1]=new R(s,W,q,r,Float32Array),t&&console.timeEnd(o);for(let e=n;e>=i;e--){const i=+Date.now();s=this._cluster(s,e),this.trees[e]=new R(s,W,q,r,Float32Array),t&&console.log("z%d: %d clusters in %dms",e,s.length,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=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,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(j(i),V(o),j(r),V(n)),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),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.points[t];if(!o)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o.x,o.y,s),l=[];for(const t of a){const i=r.points[t];i.parentId===e&&l.push(i.numPoints?N(i):this.points[i.index])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.points,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.points,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.points,-1,i,r,u),u.features.length?u: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,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r<n?r++:e.push(t),e.length===i)break}return r}_addTileFeatures(e,t,i,n,r,o){for(const s of e){const e=t[s],a=e.numPoints;let l,c,u;if(a)l=U(e),c=e.x,u=e.y;else{const t=this.points[e.index];l=t.properties,c=j(t.geometry.coordinates[0]),u=V(t.geometry.coordinates[1])}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let p;a?p=e.id:this.options.generateId?p=e.index:this.points[e.index].id&&(p=this.points[e.index].id),void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(+e,this.options.maxZoom+1))}_cluster(e,t){const i=[],{radius:n,extent:r,reduce:o,minPoints:s}=this.options,a=n/(r*Math.pow(2,t));for(let n=0;n<e.length;n++){const r=e[n];if(r.zoom<=t)continue;r.zoom=t;const l=this.trees[t+1],c=l.within(r.x,r.y,a),u=r.numPoints||1;let h=u;for(const e of c){const i=l.points[e];i.zoom>t&&(h+=i.numPoints||1)}if(h>u&&h>=s){let e=r.x*u,s=r.y*u,a=o&&u>1?this._map(r,!0):null;const p=(n<<5)+(t+1)+this.points.length;for(const i of c){const n=l.points[i];if(n.zoom<=t)continue;n.zoom=t;const c=n.numPoints||1;e+=n.x*c,s+=n.y*c,n.parentId=p,o&&(a||(a=this._map(r,!0)),o(a,this._map(n)))}r.parentId=p,i.push(F(e/h,s/h,p,h,a))}else if(i.push(r),h>1)for(const e of c){const n=l.points[e];n.zoom<=t||(n.zoom=t,i.push(n))}}return i}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?H({},e.properties):e.properties;const i=this.points[e.index].properties,n=this.options.map(i);return t&&n===i?H({},n):n}}function F(e,t,i,n,r){return{x:z(e),y:z(t),zoom:1/0,id:i,parentId:-1,numPoints:n,properties:r}}function B(e,t){const[i,n]=e.geometry.coordinates;return{x:z(j(i)),y:z(V(n)),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 H(H({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:i})}function j(e){return e/360+.5}function V(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function G(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function H(e,t){for(const i in t)e[i]=t[i];return e}function W(e){return e.x}function q(e){return e.y}function $(e,t,i,n){for(var r,o=n,s=i-t>>1,a=i-t,l=e[t],c=e[t+1],u=e[i],h=e[i+1],p=t+3;p<i;p+=3){var d=Z(e[p],e[p+1],l,c,u,h);if(d>o)r=p,o=d;else if(d===o){var f=Math.abs(p-s);f<a&&(r=p,a=f)}}o>n&&(r-t>3&&$(e,t,r,n),e[r+2]=o,i-r>3&&$(e,r,i,n))}function Z(e,t,i,n,r,o){var s=r-i,a=o-n;if(0!==s||0!==a){var l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return(s=e-i)*s+(a=t-n)*a}function X(e,t,i,n){var r={id:void 0===e?null:e,type:t,geometry:i,tags:n,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)Y(e,t);else if("Polygon"===i||"MultiLineString"===i)for(var n=0;n<t.length;n++)Y(e,t[n]);else if("MultiPolygon"===i)for(n=0;n<t.length;n++)for(var r=0;r<t[n].length;r++)Y(e,t[n][r])}(r),r}function Y(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 J(e,t,i,n){if(t.geometry){var r=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=n||0),"Point"===o)Q(r,a);else if("MultiPoint"===o)for(var c=0;c<r.length;c++)Q(r[c],a);else if("LineString"===o)K(r,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(c=0;c<r.length;c++)K(r[c],a=[],s,!1),e.push(X(l,"LineString",a,t.properties));return}ee(r,a,s,!1)}else if("Polygon"===o)ee(r,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<t.geometry.geometries.length;c++)J(e,{id:l,geometry:t.geometry.geometries[c],properties:t.properties},i,n);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<r.length;c++){var u=[];ee(r[c],u,s,!0),a.push(u)}}e.push(X(l,o,a,t.properties))}}function Q(e,t){t.push(te(e[0])),t.push(ie(e[1])),t.push(0)}function K(e,t,i,n){for(var r,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+=n?(r*c-l*o)/2:Math.sqrt(Math.pow(l-r,2)+Math.pow(c-o,2))),r=l,o=c}var u=t.length-3;t[2]=1,$(t,0,u,i),t[u+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function ee(e,t,i,n){for(var r=0;r<e.length;r++){var o=[];K(e[r],o,i,n),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 ne(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s<n)return e;if(s<i||o>=n)return null;for(var l=[],c=0;c<e.length;c++){var u=e[c],h=u.geometry,p=u.type,d=0===r?u.minX:u.minY,f=0===r?u.maxX:u.maxY;if(d>=i&&f<n)l.push(u);else if(!(f<i||d>=n)){var m=[];if("Point"===p||"MultiPoint"===p)re(h,m,i,n,r);else if("LineString"===p)oe(h,m,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===p)ae(h,m,i,n,r,!1);else if("Polygon"===p)ae(h,m,i,n,r,!0);else if("MultiPolygon"===p)for(var g=0;g<h.length;g++){var _=[];ae(h[g],_,i,n,r,!0),_.length&&m.push(_)}if(m.length){if(a.lineMetrics&&"LineString"===p){for(g=0;g<m.length;g++)l.push(X(u.id,p,m[g],u.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(u.id,p,m,u.tags))}}}return l.length?l:null}function re(e,t,i,n,r){for(var o=0;o<e.length;o+=3){var s=e[o+r];s>=i&&s<=n&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function oe(e,t,i,n,r,o,s){for(var a,l,c=se(e),u=0===r?ce:ue,h=e.start,p=0;p<e.length-3;p+=3){var d=e[p],f=e[p+1],m=e[p+2],g=e[p+3],_=e[p+4],y=0===r?d:f,v=0===r?g:_,x=!1;s&&(a=Math.sqrt(Math.pow(d-g,2)+Math.pow(f-_,2))),y<i?v>i&&(l=u(c,d,f,g,_,i),s&&(c.start=h+a*l)):y>n?v<n&&(l=u(c,d,f,g,_,n),s&&(c.start=h+a*l)):le(c,d,f,m),v<i&&y>=i&&(l=u(c,d,f,g,_,i),x=!0),v>n&&y<=n&&(l=u(c,d,f,g,_,n),x=!0),!o&&x&&(s&&(c.end=h+a*l),t.push(c),c=se(e)),s&&(h+=a)}var b=e.length-3;d=e[b],f=e[b+1],m=e[b+2],(y=0===r?d:f)>=i&&y<=n&&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,n,r,o){for(var s=0;s<e.length;s++)oe(e[s],t,i,n,r,o,!1)}function le(e,t,i,n){e.push(t),e.push(i),e.push(n)}function ce(e,t,i,n,r,o){var s=(o-t)/(n-t);return e.push(o),e.push(i+(r-i)*s),e.push(1),s}function ue(e,t,i,n,r,o){var s=(o-i)/(r-i);return e.push(t+(n-t)*s),e.push(o),e.push(1),s}function he(e,t){for(var i=[],n=0;n<e.length;n++){var r,o=e[n],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)r=pe(o.geometry,t);else if("MultiLineString"===s||"Polygon"===s){r=[];for(var a=0;a<o.geometry.length;a++)r.push(pe(o.geometry[a],t))}else if("MultiPolygon"===s)for(r=[],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));r.push(l)}i.push(X(o.id,s,r,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 n=0;n<e.length;n+=3)i.push(e[n]+t,e[n+1],e[n+2]);return i}function de(e,t){if(e.transformed)return e;var i,n,r,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,u=l.type;if(l.geometry=[],1===u)for(n=0;n<c.length;n+=2)l.geometry.push(fe(c[n],c[n+1],t,o,s,a));else for(n=0;n<c.length;n++){var h=[];for(r=0;r<c[n].length;r+=2)h.push(fe(c[n][r],c[n][r+1],t,o,s,a));l.geometry.push(h)}}return e.transformed=!0,e}function fe(e,t,i,n,r,o){return[Math.round(i*(e*n-r)),Math.round(i*(t*n-o))]}function me(e,t,i,n,r){for(var o=t===r.maxZoom?0:r.tolerance/((1<<t)*r.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:i,y:n,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){s.numFeatures++,ge(s,e[a],o,r);var l=e[a].minX,c=e[a].minY,u=e[a].maxX,h=e[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),u>s.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function ge(e,t,i,n){var r=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<r.length;a+=3)s.push(r[a]),s.push(r[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)_e(s,r,e,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<r.length;a++)_e(s,r[a],e,i,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<r.length;l++){var c=r[l];for(a=0;a<c.length;a++)_e(s,c[a],e,i,!0,0===a)}if(s.length){var u=t.tags||null;if("LineString"===o&&n.lineMetrics){for(var h in u={},t.tags)u[h]=t.tags[h];u.mapbox_clip_start=r.start/r.size,u.mapbox_clip_end=r.end/r.size}var p={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:u};null!==t.id&&(p.id=t.id),e.features.push(p)}}function _e(e,t,i,n,r,o){var s=n*n;if(n>0&&t.size<(r?s:n))i.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===n||t[l+2]>s)&&(i.numSimplified++,a.push(t[l]),a.push(t[l+1])),i.numPoints++;r&&function(e,t){for(var i=0,n=0,r=e.length,o=r-2;n<r;o=n,n+=2)i+=(e[n]-e[o])*(e[n+1]+e[o+1]);if(i>0===t)for(n=0,r=e.length;n<r/2;n+=2){var s=e[n],a=e[n+1];e[n]=e[r-2-n],e[n+1]=e[r-1-n],e[r-2-n]=s,e[r-1-n]=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 n=function(e,t){var i=[];if("FeatureCollection"===e.type)for(var n=0;n<e.features.length;n++)J(i,e.features[n],t,n);else J(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),(n=function(e,t){var i=t.buffer/t.extent,n=e,r=ne(e,1,-1-i,i,0,-1,2,t),o=ne(e,1,1-i,2+i,0,-1,2,t);return(r||o)&&(n=ne(e,1,-i,1+i,0,-1,2,t)||[],r&&(n=he(r,1).concat(n)),o&&(n=n.concat(he(o,-1)))),n}(n,t)).length&&this.splitTile(n,0,0,0),i&&(n.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function ve(e,t,i){return 32*((1<<e)*i+t)+e}function xe(e,t){const i=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const n=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!n)return t(null,null);const r=new u(n.features);let o=m(r);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:r,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,n,r,o,s){for(var a=[e,t,i,n],l=this.options,c=l.debug;a.length;){n=a.pop(),i=a.pop(),t=a.pop(),e=a.pop();var u=1<<t,h=ve(t,i,n),p=this.tiles[h];if(!p&&(c>1&&console.time("creation"),p=this.tiles[h]=me(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,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,r){if(t===l.maxZoom||t===r)continue;var f=1<<r-t;if(i!==Math.floor(o/f)||n!==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,v,x,b=.5*l.buffer/l.extent,w=.5-b,M=.5+b,T=1+b;m=g=_=y=null,v=ne(e,u,i-b,i+M,0,p.minX,p.maxX,l),x=ne(e,u,i+w,i+T,0,p.minX,p.maxX,l),e=null,v&&(m=ne(v,u,n-b,n+M,1,p.minY,p.maxY,l),g=ne(v,u,n+w,n+T,1,p.minY,p.maxY,l),v=null),x&&(_=ne(x,u,n-b,n+M,1,p.minY,p.maxY,l),y=ne(x,u,n+w,n+T,1,p.minY,p.maxY,l),x=null),c>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*i,2*n),a.push(g||[],t+1,2*i,2*n+1),a.push(_||[],t+1,2*i+1,2*n),a.push(y||[],t+1,2*i+1,2*n+1)}}},ye.prototype.getTile=function(e,t,i){var n=this.options,r=n.extent,o=n.debug;if(e<0||e>24)return null;var s=1<<e,a=ve(e,t=(t%s+s)%s,i);if(this.tiles[a])return de(this.tiles[a],r);o>1&&console.log("drilling down to z%d-%d-%d",e,t,i);for(var l,c=e,u=t,h=i;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[ve(c,u,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,h),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?de(this.tiles[a],r):null):null};class be extends e.VectorTileWorkerSource{constructor(e,t,i,n,r){super(e,t,i,n,xe),r&&(this.loadGeoJSON=r)}loadData(t,i){const n=t&&t.request,r=n&&n.collectResourceTiming;this.loadGeoJSON(t,((s,a)=>{if(s||!a)return i(s);if("object"!=typeof a)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{o(a,!0);try{if(t.filter){const i=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const n=a.features.filter((e=>i.value.evaluate({zoom:0},e)));a={type:"FeatureCollection",features:n}}this._geoJSONIndex=t.cluster?new O(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.createExpression(s),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(t)).load(a.features):function(e,t){return new ye(e,t)}(a,t.geojsonVtOptions)}catch(s){return i(s)}this.loaded={};const l={};if(r){const i=e.getPerformanceMeasurement(n);i&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}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)e.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(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.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=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.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(t,i){this.isSpriteLoaded[t]=i;for(const n in this.workerSources[t]){const r=this.workerSources[t][n];for(const t in r)r[t]instanceof e.VectorTileWorkerSource&&(r[t].isSpriteLoaded=i,r[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,i){this.availableImages[e]=t;for(const i in this.workerSources[e]){const n=this.workerSources[e][i];for(const e in n)n[e].availableImages=t}i()}enableTerrain(e,t,i){this.terrain=t,i()}setProjection(t,i){this.projections[t]=e.getProjection(i)}setLayers(e,t,i){this.getLayerIndex(e).replace(t),i()}updateLayers(e,t,i){this.getLayerIndex(e).update(t.layers,t.removedIds),i()}loadTile(t,i,n){const r=this.enableTerrain?e.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,i.type,i.source).loadTile(r,n)}loadDEMTile(t,i,n){const r=this.enableTerrain?e.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(t,i.source).loadTile(r,n)}reloadTile(t,i,n){const r=this.enableTerrain?e.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,i.type,i.source).reloadTile(r,n)}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 n=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==n.removeSource?n.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,n){try{e.plugin.setState(i);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const i=e.plugin.isParsed();n(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),i)}}catch(e){n(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 n),t}getWorkerSource(e,t,i){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),this.workerSources[e][t][i]||(this.workerSources[e][t][i]=new this.workerSourceTypes[t]({send:(t,i,n,r,o,s)=>{this.actor.send(t,i,n,e,o,s)},scheduler:this.actor.scheduler},this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])),this.workerSources[e][t][i]}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(t,i){e.enforceCacheSizeLimit(i)}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}));n(0,(function(e){function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let n=0;n<e.length;n++)if(!t(e[n],i[n]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(e).length!==Object.keys(i).length)return!1;for(const n in e)if(!t(e[n],i[n]))return!1;return!0}return e===i}var i=n;function n(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"}),n=URL.createObjectURL(i);try{t=new Worker(n),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(n),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===r[t=e&&e.failIfMajorPerformanceCaveat]&&(r[t]=function(e){var t,i=function(e){var t=document.createElement("canvas"),i=Object.create(n.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)),r[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 r={};function o(t,i,n){const r=e.window.document.createElement(t);return void 0!==i&&(r.className=i),n&&n.appendChild(r),r}function s(t,i,n){const r=e.window.document.createElementNS("http://www.w3.org/2000/svg",t);for(const e of Object.keys(i))r.setAttributeNS(null,e,i[e]);return n&&n.appendChild(r),r}n.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const a=e.window.document&&e.window.document.documentElement.style,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;function u(){a&&l&&(c=a[l],a[l]="none")}function h(){a&&l&&(a[l]=c)}function p(t){t.preventDefault(),t.stopPropagation(),e.window.removeEventListener("click",p,!0)}function d(){e.window.addEventListener("click",p,!0),e.window.setTimeout((()=>{e.window.removeEventListener("click",p,!0)}),0)}function f(e,t){const i=e.getBoundingClientRect();return _(e,i,t)}function m(e,t){const i=e.getBoundingClientRect(),n=[];for(let r=0;r<t.length;r++)n.push(_(e,i,t[r]));return n}function g(t){return void 0!==e.window.InstallTrigger&&2===t.button&&t.ctrlKey&&e.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function _(t,i,n){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.pointGeometry((n.clientX-i.left)*r,(n.clientY-i.top)*r)}function y(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=i*o-r*n;return s?(e[0]=o*(s=1/s),e[1]=-n*s,e[2]=-r*s,e[3]=i*s,e):null}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class x extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.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(t,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]<i||n[1]<n[0]||t<n[1])return!1;i=n[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(t,i){const n={};for(const i of t){this.images[i]||this.fire(new e.Event("styleimagemissing",{id:i}));const t=this.images[i];t?n[i]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.warnOnce(`Image "${i}" 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.`)}i(null,n)}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(t){const i=this.patterns[t],n=this.getImage(t);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},r=new e.ImagePosition(i,n);this.patterns[t]={bin:i,position:r}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const i=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new e.Texture(t,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:n}=e.potpack(t),r=this.atlasImage;r.resize({width:i||1,height:n||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],n=i.x+1,o=i.y+1,s=this.images[t].data,a=s.width,l=s.height;e.RGBAImage.copy(s,r,{x:0,y:0},{x:n,y:o},{width:a,height:l}),e.RGBAImage.copy(s,r,{x:0,y:l-1},{x:n,y:o-1},{width:a,height:1}),e.RGBAImage.copy(s,r,{x:0,y:0},{x:n,y:o+l},{width:a,height:1}),e.RGBAImage.copy(s,r,{x:a-1,y:0},{x:n-1,y:o},{width:1,height:l}),e.RGBAImage.copy(s,r,{x:0,y:0},{x:n+a,y:o},{width:1,height:l})}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];v(e)&&this.updateImage(t,e)}}}const b=new e.Properties({anchor:new e.DataConstantProperty(e.spec.light.anchor),position:new class{constructor(){this.specification=e.spec.light.position}possiblyEvaluate(t,i){return function([t,i,n]){const r=e.degToRad(i+90),o=e.degToRad(n);return{x:t*Math.cos(r)*Math.sin(o),y:t*Math.sin(r)*Math.sin(o),z:t*Math.cos(o),azimuthal:i,polar:n}}(t.expression.evaluate(i))}interpolate(t,i,n){return{x:e.number(t.x,i.x,n),y:e.number(t.y,i.y,n),z:e.number(t.z,i.z,n),azimuthal:e.number(t.azimuthal,i.azimuthal,n),polar:e.number(t.polar,i.polar,n)}}},color:new e.DataConstantProperty(e.spec.light.color),intensity:new e.DataConstantProperty(e.spec.light.intensity)}),w="-transition";class M extends e.Evented{constructor(t){super(),this._transitionable=new e.Transitionable(b),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,i={}){if(!this._validate(e.validateLight,t,i))for(const i in t){const n=t[i];e.endsWith(i,w)?this._transitionable.setTransition(i.slice(0,-w.length),n):this._transitionable.setValue(i,n)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,n){return(!n||!1!==n.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}const T=new e.Properties({source:new e.DataConstantProperty(e.spec.terrain.source),exaggeration:new e.DataConstantProperty(e.spec.terrain.exaggeration)}),S="-transition";class E extends e.Evented{constructor(t,i){super(),this._transitionable=new e.Transitionable(T),this.set(t),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i}get(){return this._transitionable.serialize()}set(t){for(const i in t){const n=t[i];e.endsWith(i,S)?this._transitionable.setTransition(i.slice(0,-S.length),n):this._transitionable.setValue(i,n)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}}function A(t,i,n,r){const o=e.smoothstep(45,65,n),[s,a]=C(t,r),l=e.length(i);let c=1-Math.min(1,Math.exp((l-s)/(a-s)*-6));return c*=c*c,c=Math.min(1,1.00747*c),c*o*t.alpha}function C(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}const L=new e.Properties({range:new e.DataConstantProperty(e.spec.fog.range),color:new e.DataConstantProperty(e.spec.fog.color),"high-color":new e.DataConstantProperty(e.spec.fog["high-color"]),"space-color":new e.DataConstantProperty(e.spec.fog["space-color"]),"horizon-blend":new e.DataConstantProperty(e.spec.fog["horizon-blend"]),"star-intensity":new e.DataConstantProperty(e.spec.fog["star-intensity"])}),I="-transition";class P extends e.Evented{constructor(t,i){super(),this._transitionable=new e.Transitionable(L),this.set(t),this._transitioning=this._transitionable.untransitioned(),this._transform=i}get state(){const t=this._transform,i="globe"===t.projection.name,n=e.globeToMercatorTransition(t.zoom),r=this.properties.get("range"),o=[.5,3];return{range:i?[e.number(o[0],r[0],n),e.number(o[1],r[1],n)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i={}){if(!this._validate(e.validateFog,t,i)){for(const i of Object.keys(e.spec.fog))t&&void 0===t[i]&&(t[i]=e.spec.fog[i].default);for(const i in t){const n=t[i];e.endsWith(i,I)?this._transitionable.setTransition(i.slice(0,-I.length),n):this._transitionable.setValue(i,n)}}}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.smoothstep(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,n){const r=e.MercatorCoordinate.fromLngLat(i),o=n.elevation?n.elevation.getAtPointOrZero(r):0,s=[r.x,r.y,o];return e.transformMat4(s,s,n.mercatorFogMatrix),A(t,s,n.pitch,n._fov)}(this.state,t,i):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?C(this.state,e):[0,1]}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,n){return(!n||!1!==n.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}class R{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.uniqueId();const n=this.workerPool.acquire(this.id);for(let e=0;e<n.length;e++){const t=new R.Actor(n[e],i,this.id);t.name=`Worker ${e}`,this.actors.push(t)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(t,i,n){e.asyncAll(this.actors,((e,n)=>{e.send(t,i,n)}),n=n||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(t,i,n){return i*(e.EXTENT/(t.tileSize*Math.pow(2,n-t.tileID.overscaledZ)))}R.Actor=e.Actor;class z{constructor(e,t,i,n){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,n)}static createFromScreenPoints(t,i){let n,r;if(t instanceof e.pointGeometry||"number"==typeof t[0]){const o=e.pointGeometry.convert(t);n=[e.pointGeometry.convert(t)],r=i.isPointAboveHorizon(o)}else{const o=e.pointGeometry.convert(t[0]),s=e.pointGeometry.convert(t[1]);n=[o,s],r=e.polygonizeBounds(o,s).every((e=>i.isPointAboveHorizon(e)))}return new z(n,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<n.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.bufferConvexPolygon(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,n,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>n.y))+((o.x>i.x)+(o.x>n.x))){case 0:r[0]=o,r[4]=o.clone();break;case 1:r.splice(1,0,o);break;case 2:r[1]=o;break;case 3:r.splice(4,0,o);break;case 5:r.splice(2,0,o);break;case 6:r[3]=o;break;case 7:r.splice(3,0,o);break;case 8:r[2]=o}return r}containsTile(t,i,n,r=0){const o=t.queryPadding/i._projectionScaler+1,s=n?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map((i=>e.getTilePoint(t.tileTransform,i,a)));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>e.getTileVec3(t.tileTransform,i,a))),u=c.map((t=>new e.pointGeometry(t[0],t[1]))),h=i.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),p=e.getTileVec3(t.tileTransform,h,a),d=c.map((t=>{const i=e.sub(t,t,p);return e.normalize(i,i),new e.Ray(p,i)})),f=k(t,1,i.zoom)*i._projectionScaler;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=F(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(e,t){const i=F(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=n,n}}_projectAndResample(t,i){const n=function(t,i){const n=e.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-e.GLOBE_RADIUS,0,1],o=[0,e.GLOBE_RADIUS,0,1],s=[0,0,0,1];e.transformMat4$1(r,r,n),e.transformMat4$1(o,o,n),e.transformMat4$1(s,s,n);const a=new e.pointGeometry(r[0]/r[3],r[1]/r[3]),l=new e.pointGeometry(o[0]/o[3],o[1]/o[3]),c=e.polygonContainsPoint(t,a)&&r[3]<s[3],u=e.polygonContainsPoint(t,l)&&o[3]<s[3];if(!c&&!u)return null;const h=function(e,t,i){for(let n=1;n<e.length;n++){const r=O(t.pointCoordinate3D(e[n-1]).x),o=O(t.pointCoordinate3D(e[n]).x);if(i<0){if(r<o)return{idx:n,t:-r/(o-1-r)}}else if(o<r)return{idx:n,t:(1-r)/(o+1-r)}}return null}(t,i,c?-1:1);if(!h)return null;const{idx:p,t:d}=h;let f=p>1?D(t.slice(0,p),i):[],m=p<t.length?D(t.slice(p),i):[];f=f.map((t=>new e.pointGeometry(O(t.x),t.y))),m=m.map((t=>new e.pointGeometry(O(t.x),t.y)));const g=[...f];0===g.length&&g.push(m[m.length-1]);const _=e.number(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new e.pointGeometry(0,_),new e.pointGeometry(0,0),new e.pointGeometry(1,0),new e.pointGeometry(1,_)]:[new e.pointGeometry(1,_),new e.pointGeometry(1,1),new e.pointGeometry(0,1),new e.pointGeometry(0,_)],g.push(...y),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:!1}}(t,i);if(n)return n;const r=function(t,i){let n=!1,r=-1/0,o=0;for(let e=0;e<t.length-1;e++)t[e].x>r&&(r=t[e].x,o=e);for(let e=0;e<t.length-1;e++){const i=(o+e)%(t.length-1),r=t[i],s=t[i+1];Math.abs(r.x-s.x)>.5&&(r.x<s.x?(r.x+=1,0===i&&(t[t.length-1].x+=1)):(s.x+=1,i+1===t.length-1&&(t[0].x+=1)),n=!0)}const s=e.mercatorXfromLng(i.center.lng);return n&&s<Math.abs(s-1)&&t.forEach((e=>{e.x-=1})),{polygon:t,unwrapped:n}}(D(t,i).map((t=>new e.pointGeometry(O(t.x),t.y))),i);return{polygon:r.polygon.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:r.unwrapped}}}function D(t,i){return e.resample(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function O(e){return e<0?1+e%1:e%1}function F(e){return 100*e|0}function B(t,i,n,r,o){const s=function(n,r){if(n)return o(n);if(r){const n=e.pick(e.extend(r,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(n.vectorLayers=r.vector_layers,n.vectorLayerIds=n.vectorLayers.map((e=>e.id))),r.language_options&&(n.languageOptions=r.language_options),r.language&&r.language[r.id]&&(n.language=r.language[r.id]),r.worldview_options&&(n.worldviewOptions=r.worldview_options),r.worldview?n.worldview=r.worldview[r.id]:r.worldview_default&&(n.worldview=r.worldview_default),n.tiles=i.canonicalizeTileset(n,t.url),o(null,n)}};return t.url?e.getJSON(i.transformRequest(i.normalizeSourceURL(t.url,null,n,r),e.ResourceType.Source),s):e.exported.frame((()=>s(null,t)))}class N{constructor(t,i,n){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=n||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(t){const i=Math.pow(2,t.z),n=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*i),r=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*i);return t.x>=n&&t.x<o&&t.y>=r&&t.y<s}}class U{constructor(e,t,i){this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.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 j={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class V{constructor(e,t,i,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),e.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.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(e,t){for(let i=0;i<this.attributes.length;i++){const n=t.attributes[this.attributes[i].name];void 0!==n&&e.enableVertexAttribArray(n)}}setVertexAttribPointers(e,t,i){for(let n=0;n<this.attributes.length;n++){const r=this.attributes[n],o=t.attributes[r.name];void 0!==o&&e.vertexAttribPointer(o,r.components,e[j[r.type]],!1,this.itemSize,r.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class G{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 H extends G{getDefault(){return e.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 W extends G{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class q extends G{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class $ extends G{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 Z extends G{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class X extends G{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Y extends G{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 J extends G{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 Q extends G{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 K extends G{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 ee extends G{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 te extends G{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 G{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 ne extends G{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 re extends G{getDefault(){return e.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 G{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 G{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 G{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 G{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 G{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class ue extends G{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class he extends G{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 G{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 G{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 G{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 G{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 ge extends G{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class _e extends G{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 G{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 ve extends G{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 xe extends G{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 G{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 Me 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 Te extends Me{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Se{constructor(e,t,i,n){this.context=e,this.width=t,this.height=i;const r=this.framebuffer=e.gl.createFramebuffer();this.colorAttachment=new we(e,r),n&&(this.depthAttachment=new Me(e,r))}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 Ee{constructor(e){this.gl=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new H(this),this.clearDepth=new W(this),this.clearStencil=new q(this),this.colorMask=new $(this),this.depthMask=new Z(this),this.stencilMask=new X(this),this.stencilFunc=new Y(this),this.stencilOp=new J(this),this.stencilTest=new Q(this),this.depthRange=new K(this),this.depthTest=new ee(this),this.depthFunc=new te(this),this.blend=new ie(this),this.blendFunc=new ne(this),this.blendColor=new re(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 ue(this),this.viewport=new he(this),this.bindFramebuffer=new pe(this),this.bindRenderbuffer=new de(this),this.bindTexture=new fe(this),this.bindVertexBuffer=new me(this),this.bindElementBuffer=new ge(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new _e(this),this.pixelStoreUnpack=new ye(this),this.pixelStoreUnpackPremultiplyAlpha=new ve(this),this.pixelStoreUnpackFlipY=new xe(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 U(this,e,t)}createVertexBuffer(e,t,i){return new V(this,e,t,i)}createRenderbuffer(e,t,i){const n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i){return new Se(this,e,t,i)}clear({color:e,depth:t,stencil:i}){const n=this.gl;let r=0;e&&(r|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(r|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(r|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(r)}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(i){t(i.blendFunction,e.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor)),this.colorMask.set(i.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class Ae extends e.Evented{constructor(t,i,n,r){super(),this.id=t,this.dispatcher=n,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=e.extend({type:"raster"},i),e.extend(this,e.pick(i,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=B(this._options,this.map._requestManager,null,null,((t,i)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(e.extend(this,i),i.bounds&&(this.tileBounds=new N(i.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(i.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.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 e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const n=e.exported.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),((n,r,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):n?(t.state="errored",i(n)):r?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(r,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(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 Le(t,i,n,r,o,s,a,l){const c=[t,n,o,i,r,s,1,1,1],u=[a,l,1],h=e.adjoint([],c),[p,d,f]=e.transformMat3(u,u,e.transpose(h,h));return e.multiply$1(c,[p,0,0,0,d,0,0,0,f],c)}class Ie extends e.Evented{constructor(e,t,i,n){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(n),this.options=t}load(t,i){this._loaded=i||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),((i,n)=>{if(this._loaded=!0,i)this.fire(new e.ErrorEvent(i));else if(n){const{HTMLImageElement:i}=e.window;this.image=n instanceof i?e.exported.getImageData(n):n,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),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 e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const i=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x),o=Math.max(o,e.y);const s=Math.max(r-i,o-n),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new e.CanonicalTileID(a,Math.floor((i+r)/2*l),Math.floor((n+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const i=e.tileTransform(this.tileID,this.map.transform.projection),[n,r,o,s]=this.coordinates.map((t=>{const n=i.projection.project(t[0],t[1]);return e.getTilePoint(i,n)._round()}));this.perspectiveTransform=function(t,i,n,r,o,s,a,l,c,u){const h=Le(0,0,t,0,0,i,t,i),p=Le(n,r,o,s,a,l,c,u);return e.multiply$1(p,e.adjoint(h,h),p),[p[6]/p[8]*t/e.EXTENT,p[7]/p[8]*i/e.EXTENT]}(this.width,this.height,n.x,n.y,r.x,r.y,s.x,s.y,o.x,o.y);const a=this._boundsArray=new e.StructArrayLayout4i8;a.emplaceBack(n.x,n.y,0,0),a.emplaceBack(r.x,r.y,e.EXTENT,0),a.emplaceBack(s.x,s.y,0,e.EXTENT),a.emplaceBack(o.x,o.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(a,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._prepareData(t)}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 Pe={vector:class extends e.Evented{constructor(t,i,n,r){if(super(),this.id=t,this.dispatcher=n,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(i,["url","scheme","tileSize","promoteId"])),this._options=e.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.DedupedRequest}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"}));const i=this.language||this.map._language,n=this.worldview||this.map._worldview;this._tileJSONRequest=B(this._options,this.map._requestManager,i,n,((r,o)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${i}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.ErrorEvent(r))):o&&(e.extend(this,o),o.bounds&&(this.tileBounds=new N(o.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)}))}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 e.extend({},this._options)}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",r,o.bind(this));else if(t.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",r,o.bind(this),void 0,!0);else{const i=e.loadVectorTile.call({deduped:this._deduped},r,((e,i)=>{e||!i?o.call(this,e):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",r,o.bind(this),void 0,!0))}),!0);t.request={cancel:i}}function o(n,r){return delete t.request,t.aborted?i(null):n&&404!==n.status?i(n):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.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:Ae,"raster-dem":class extends Ae{constructor(t,i,n,r){super(t,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(e,n){e&&(t.state="errored",i(e)),n&&(t.dem=n,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null))}t.request=e.getImage(this.map._requestManager.transformRequest(n,e.ResourceType.Tile),function(n,o,s,a){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(n)t.state="errored",i(n);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const i=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap&&(null==Ce&&(Ce=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),Ce),n=1-(o.width-e.prevPowerOfTwo(o.width))/2;n<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?o:e.exported.getImageData(o,n),c={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:n};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,r.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const i=t.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+n)%n,a=i.x+1===n?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<n&&(l[new e.OverscaledTileID(t.overscaledZ,o,i.z,r,i.y+1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}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 e.Evented{constructor(t,i,n,r){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=n.getActor(),this.setEventedParent(r),this._data=i.data,this._options=e.extend({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=e.EXTENT/this.tileSize;this.workerOptions=e.extend({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:e.EXTENT,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.EXTENT,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.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,n){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:e,limit:t,offset:i},n),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.Event("dataloading",{dataType:"source"})),this._loaded=!1;const t=e.extend({},this.workerOptions),i=this._data;"string"==typeof i?(t.request=this.map._requestManager.transformRequest(e.exported.resolveURL(i),e.ResourceType.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(i),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,((t,i)=>{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,i){const n=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(n,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((e,r)=>(delete t.request,t.unloadVectorData(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===n),i(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 e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ie{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.ResourceType.Source).url);e.getVideo(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(this.video=i,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(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}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 t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ie,canvas:class extends Ie{constructor(t,i,n,r){super(t,i,n,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,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 e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.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 t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}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 e.Evented{constructor(t,i,n,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=i,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 e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new N(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:n}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const{x:n,y:r,z:o}=t.tileID.canonical,s=new e.window.AbortController,a=this._implementation.loadTile({x:n,y:r,z:o},{signal:s.signal});if(!a)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null);a.cancel=()=>s.abort(),t.request=a.then(function(n){return delete t.request,t.aborted?(t.state="unloaded",i(null)):n?function(t){return t instanceof e.window.ImageData||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLCanvasElement}(n)?(this.loadTileData(t,n),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){Ae.loadTileData(e,t,this._map.painter)}unloadTileData(e){Ae.unloadTileData(e,this._map.painter)}prepareTile(e){if(!this._implementation.prepareTile)return null;const{x:t,y:i,z:n}=e.tileID.canonical,r=this._implementation.prepareTile({x:t,y:i,z:n});return r?(this.loadTileData(e,r),e.state="loaded",r):null}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:n}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:n})}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 e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Re=function(t,i,n,r){const o=new Pe[i.type](t,i,n,r);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function ke(t,i){const n=e.identity([]);return e.scale(n,n,[.5*t.width,.5*-t.height,1]),e.translate(n,n,[1,-1,0]),e.multiply(n,n,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(n)}function ze(e,t,i,n,r,o,s,a=!1){const l=e.tilesIn(n,s,a);l.sort(Oe);const c=[];for(const n of l)c.push({wrappedTileID:n.tile.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e._state,n,r,o,ke(e.transform,n.tile.tileID),a)});const u=function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(c);for(const t in u)u[t].forEach((t=>{const i=t.feature,n=i.layer;n&&"background"!==n.type&&"sky"!==n.type&&(i.source=n.source,n["source-layer"]&&(i.sourceLayer=n["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(n["source-layer"],i.id):{})}));return u}function De(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),n=[],r={};for(let e=0;e<i.length;e++){const o=i[e],s=o.tileID.canonical.key;r[s]||(r[s]=!0,o.querySourceFeatures(n,t))}return n}function Oe(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function Fe(){return null!=uo.workerClass?new uo.workerClass:new e.window.Worker(uo.workerUrl)}const Be="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 Fe);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[Be]}numActive(){return Object.keys(this.active).length}}let Ue;function je(){return Ue||(Ue=new Ne),Ue}function Ve(t,i){const n={};for(const e in t)"ref"!==e&&(n[e]=t[e]);return e.refProperties.forEach((e=>{e in i&&(n[e]=i[e])})),n}function Ge(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=Ve(e[i],t[e[i].ref]));return e}Ne.workerCount=2;const He={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 We(e,t,i){i.push({command:He.addSource,args:[e,t[e]]})}function qe(e,t,i){t.push({command:He.removeSource,args:[e]}),i[e]=!0}function $e(e,t,i,n){qe(e,i,n),We(e,t,i)}function Ze(e,i,n){let r;for(r in e[n])if(e[n].hasOwnProperty(r)&&"data"!==r&&!t(e[n][r],i[n][r]))return!1;for(r in i[n])if(i[n].hasOwnProperty(r)&&"data"!==r&&!t(e[n][r],i[n][r]))return!1;return!0}function Xe(e,i,n,r,o,s){let a;for(a in i=i||{},e=e||{})e.hasOwnProperty(a)&&(t(e[a],i[a])||n.push({command:s,args:[r,a,i[a],o]}));for(a in i)i.hasOwnProperty(a)&&!e.hasOwnProperty(a)&&(t(e[a],i[a])||n.push({command:s,args:[r,a,i[a],o]}))}function Ye(e){return e.id}function Je(e,t){return e[t.id]=t,e}class Qe{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(t){if(1===this.points.length)return this.points[0];t=e.clamp(t,0,1);let i=1,n=this._distances[i];const r=t*this.paddedLength+this.padding;for(;n<r&&i<this._distances.length;)n=this._distances[++i];const o=i-1,s=this._distances[o],a=n-s,l=a>0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Ke{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)n.push([]),r.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,n,r){this._forEachCell(t,i,n,r,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(r)}insertCircle(e,t,i,n){this._forEachCell(t-n,i-n,t+n,i+n,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(n)}_insertBoxCell(e,t,i,n,r,o){this.boxCells[r].push(o)}_insertCircleCell(e,t,i,n,r,o){this.circleCells[r].push(o)}_query(e,t,i,n,r,o){if(i<0||e>this.width||n<0||t>this.height)return!r&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)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],n=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-n,y1:i-n,x2:t+n,y2:i+n})}return o?s.filter(o):s}return this._forEachCell(e,t,i,n,this._queryCell,s,{hitTest:r,seenUids:{box:{},circle:{}}},o),r?s.length>0:s}_queryCircle(e,t,i,n,r){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!n&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),n?c.length>0:c}query(e,t,i,n,r){return this._query(e,t,i,n,!1,r)}hitTest(e,t,i,n,r){return this._query(e,t,i,n,!0,r)}hitTestCircle(e,t,i,n){return this._queryCircle(e,t,i,!0,n)}_queryCell(e,t,i,n,r,o,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&n>=r[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]})}}}const u=this.circleCells[r];if(null!==u){const r=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(r[u],r[u+1],r[u+2],e,t,i,n)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=r[u],t=r[u+1],i=r[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,n,r,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[r];if(null!==u){const e=this.bboxes;for(const t of u)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 h=this.circleCells[r];if(null!==h){const e=this.circles;for(const t of h)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(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,this.xCellCount*l+p,o,s,a))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,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,p=u-c;return h*h+p*p<=i*i}}const et=Math.tan(85*Math.PI/180);function tt(t,i,n,r,o,s,a){const l=e.create();if(n)if("globe"===s.name){const t=e.calculateGlobeLabelMatrix(o,i);e.multiply(l,l,t)}else{const t=y([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.rotateZ(l,l,o.angle)}else e.multiply(l,o.labelPlaneMatrix,t);return l}function it(e,t,i,n,r,o,s){const a=tt(e,t,i,n,r,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function nt(t,i,n,r,o,s,a){if(n){if("globe"===s.name){const l=tt(t,i,n,r,o,s,a);return e.invert(l,l),e.multiply(l,t,l),l}{const i=e.clone(t),n=e.identity([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],e.multiply(i,i,n),r||e.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function rt(t,i,n=0){const r=[t.x,t.y,n,1];n?e.transformMat4$1(r,r,i):_t(r,r,i);const o=r[3];return{point:[r[0]/o,r[1]/o,r[2]/o],signedDistanceFromCamera:o}}function ot(t,i){const n=[t[0],t[1],t[2],1];e.transformMat4$1(n,n,i);const r=n[3];return{point:[n[0]/r,n[1]/r,n[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],n=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&n>=-t[1]&&n<=t[1]}function lt(t,i,n,r,o,s,a,l,c,u){const h=n.transform,p=r?t.textSizeData:t.iconSizeData,d=e.evaluateSizeForZoom(p,n.transform.zoom),f="globe"===h.projection.name,m=[256/n.width*2+1,256/n.height*2+1],g=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let _=null;f&&(_=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b=!1;for(let r=0;r<v.length;r++){const f=v.get(r);if(f.writingMode!==e.WritingMode.vertical||b||0!==r&&v.get(r-1).writingMode===e.WritingMode.horizontal||(b=!0),(f.hidden||f.writingMode===e.WritingMode.vertical)&&!b){gt(f.numGlyphs,g);continue}b=!1;const w=new e.pointGeometry(f.tileAnchorX,f.tileAnchorY),M=c?c(w):[0,0,0],T=h.projection.projectTilePoint(w.x,w.y,u.canonical),S=[T.x+M[0],T.y+M[1],T.z+M[2]],E=[...S,1];if(e.transformMat4$1(E,E,i),!at(E,m)){gt(f.numGlyphs,g);continue}const A=st(n.transform.cameraToCenterDistance,E[3]),C=e.evaluateSizeForFeature(p,d,f),L=a?C/A:C*A,I=rt(new e.pointGeometry(S[0],S[1]),o,S[2]);if(I.signedDistanceFromCamera<=0){gt(f.numGlyphs,g);continue}let P={};const R=a?null:c,k=ht(f,L,!1,l,i,o,s,t.glyphOffsetArray,y,g,_,I.point,w,P,x,R,h.projection,u,a);b=k.useVertical,R&&k.needsFlipping&&(P={}),(k.notEnoughRoom||b||k.needsFlipping&&ht(f,L,!0,l,i,o,s,t.glyphOffsetArray,y,g,_,I.point,w,P,x,R,h.projection,u,a).notEnoughRoom)&>(f.numGlyphs,g)}r?(t.text.dynamicLayoutVertexBuffer.updateData(g),_&&t.text.globeExtVertexBuffer.updateData(_)):(t.icon.dynamicLayoutVertexBuffer.updateData(g),_&&t.icon.globeExtVertexBuffer.updateData(_))}function ct(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=a.glyphStartIndex+a.numGlyphs,_=a.lineStartIndex,y=a.lineStartIndex+a.lineLength,v=t.getoffsetX(a.glyphStartIndex),x=t.getoffsetX(g-1),b=ft(e*v,i,n,r,o,s,a.segment,_,y,l,c,u,h,p,!0,d,f,m);if(!b)return null;const w=ft(e*x,i,n,r,o,s,a.segment,_,y,l,c,u,h,p,!0,d,f,m);return w?{first:b,last:w}:null}function ut(t,i,n,r){return t.writingMode===e.WritingMode.horizontal&&Math.abs(n.y-i.y)>Math.abs(n.x-i.x)*r?{useVertical:!0}:t.writingMode===e.WritingMode.vertical?i.y<n.y?{needsFlipping:!0}:null:0!==t.flipState&&function(e,t,i){const n=(t.x-e.x)*i;return 0===n||Math.abs((t.y-e.y)/n)>et}(i,n,r)?1===t.flipState?{needsFlipping:!0}:null:i.x>n.x?{needsFlipping:!0}:null}function ht(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v){const x=i/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x;let M;if(t.numGlyphs>1){const i=t.glyphStartIndex+t.numGlyphs,o=t.lineStartIndex,u=t.lineStartIndex+t.lineLength,h=ct(x,l,b,w,n,p,d,t,c,s,f,g,!1,_,y,v);if(!h)return{notEnoughRoom:!0};const T=ot(h.first.point,a).point,S=ot(h.last.point,a).point,E=new e.pointGeometry(T[0],T[1]),A=new e.pointGeometry(S[0],S[1]);if(r&&!n){const e=ut(t,E,A,m);if(t.flipState=e&&e.needsFlipping?1:2,e)return e}M=[h.first];for(let e=t.glyphStartIndex+1;e<i-1;e++)M.push(ft(x*l.getoffsetX(e),b,w,n,p,d,t.segment,o,u,c,s,f,g,!1,!1,_,y,v));M.push(h.last)}else{if(r&&!n){const i=rt(d,o).point,n=t.lineStartIndex+t.segment+1,r=new e.pointGeometry(c.getx(n),c.gety(n)),s=rt(r,o),a=s.signedDistanceFromCamera>0?s.point:dt(d,r,i,1,o,void 0,_,y.canonical),l=ut(t,new e.pointGeometry(i[0],i[1]),new e.pointGeometry(a[0],a[1]),m);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=ft(x*l.getoffsetX(t.glyphStartIndex),b,w,n,p,d,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,s,f,g,!1,!1,_,y,v);if(!i)return{notEnoughRoom:!0};M=[i]}if(h)for(const t of M)e.updateGlobeVertexNormal(h,u.length+0,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+1,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+2,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+3,t.up[0],t.up[1],t.up[2]),e.addDynamicAttributes(u,t.point[0],t.point[1],t.point[2],t.angle);else for(const t of M)e.addDynamicAttributes(u,t.point[0],t.point[1],t.point[2],t.angle);return{}}function pt(t,i,n,r,o){const s=r.projectTilePoint(t.x,t.y,i);if(!o)return rt(s,n,s.z);const a=o(t);return rt(new e.pointGeometry(s.x+a[0],s.y+a[1]),n,s.z+a[2])}function dt(t,i,n,r,o,s,a,l){const c=pt(t.add(t.sub(i)._unit()),l,o,a,s).point,u=e.sub([],n,c);return e.scaleAndAdd([],n,u,r/e.length(u))}function ft(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y){const v=r?t-i:t+i;let x=v>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=x>0?l+a:l+a+1,M=o,T=o,S=0,E=0;const A=Math.abs(v),C=[],L=[];let I=s;const P=()=>{const t=w-x;return 0===S?s:new e.pointGeometry(u.getx(t),u.gety(t))},R=()=>dt(P(),I,T,A-S+1,h,d,g,_.canonical);for(;S+E<=A;){if(w+=x,w<l||w>=c)return null;if(T=M,C.push(M),f&&L.push(I||P()),M=p[w],void 0===M){I=new e.pointGeometry(u.getx(w),u.gety(w));const t=pt(I,_.canonical,h,g,d);M=t.signedDistanceFromCamera>0?p[w]=t.point:R()}else I=null;S+=E,E=e.distance(T,M)}I=I||new e.pointGeometry(u.getx(w),u.gety(w));const k=P();m&&d&&(p[w]=M=void 0===p[w]?M:R(),E=e.distance(T,M));const z=(A-S)/E,D=I.sub(k).mult(z)._add(k),O=e.sub([],M,T),F=e.scaleAndAdd([],T,O,z);let B=[0,0,1],N=O[0],U=O[1];if(y&&(B=g.upVector(_.canonical,D.x,D.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[1,0,0],i=[0,1,0];t[0]=B[2],t[1]=0,t[2]=-B[0],e.cross(i,B,t),e.normalize(t,t),e.normalize(i,i),N=e.dot(O,t),U=e.dot(O,i)}if(n){const t=e.cross([],B,O);e.normalize(t,t),e.scaleAndAdd(F,F,t,n*x)}const j=b+Math.atan2(U,N);return C.push(F),f&&L.push(D),{point:F,angle:j,path:C,tilePath:L,up:B}}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 gt(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(mt,4*e)}}function _t(e,t,i){const n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e[3]=i[3]*n+i[7]*r+i[15],e}const yt=100;class vt{constructor(e,t,i=new Ke(e.width+200,e.height+200,25),n=new Ke(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=n,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,n,r,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,u=i.projectedAnchorZ;const h=i.elevation,p=i.tileID;if(h&&p){const t=e.getProjection().upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),n=e.getProjection().upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=t[0]*h*n,c+=t[1]*h*n,u+=t[2]*h*n}const d=this.projectAndGetPerspectiveRatio(s,[l,c,u],i.tileID,"globe"===e.projection.name||!!h||this.transform.pitch>0,e.getProjection()),f=o*d.perspectiveRatio,m=(i.x1*t+n.x-i.padding)*f+d.point.x,g=(i.y1*t+n.y-i.padding)*f+d.point.y,_=(i.x2*t+n.x+i.padding)*f+d.point.x,y=(i.y2*t+n.y+i.padding)*f+d.point.y,v=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,g,_,y)||!r&&this.grid.hitTest(m,g,_,y,a)||v?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,g,_,y],offscreen:this.isOffscreen(m,g,_,y),occluded:!1}}placeCollisionCircles(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=[],_=this.transform.elevation,y=_?_.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,t.getProjection()):e=>[0,0,0],v=new e.pointGeometry(n.tileAnchorX,n.tileAnchorY),x=t.getProjection().projectTilePoint(n.tileAnchorX,n.tileAnchorY,m.canonical),b=y(v),w=[x.x+b[0],x.y+b[1],x.z+b[2]],M="globe"===t.projection.name,T=this.projectAndGetPerspectiveRatio(a,[w[0],w[1],w[2]],m,M||!!_||this.transform.pitch>0,t.getProjection()),{perspectiveRatio:S}=T,E=(h?s/S:s*S)/e.ONE_EM,A=rt(new e.pointGeometry(w[0],w[1]),l,w[2]).point,C=T.signedDistanceFromCamera>0?ct(E,o,n.lineOffsetX*E,n.lineOffsetY*E,!1,A,v,n,r,l,{},_&&!h?y:null,h&&!!_,t.getProjection(),m,h):null;let L=!1,I=!1,P=!0;if(C&&!T.occluded){const t=.5*d*S+f,n=new e.pointGeometry(-100,-100),r=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new Qe,s=C.first,a=C.last;let l=[];for(let e=s.path.length-1;e>=1;e--)l.push(s.path[e]);for(let e=1;e<a.path.length;e++)l.push(a.path[e]);const h=2.5*t;if(c){const e=l.map(_&&!M?(e,t)=>{const i=y(t<s.path.length-1?s.tilePath[s.path.length-1-t]:a.tilePath[t-s.path.length+2]);return e[2]=i[2],ot(e,c)}:e=>ot(e,c));l=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let m=[];if(l.length>0){const t=l.map((t=>new e.pointGeometry(t[0],t[1])));let i=1/0,o=-1/0,s=1/0,a=-1/0;for(let e=0;e<t.length;e++)i=Math.min(i,t[e].x),s=Math.min(s,t[e].y),o=Math.max(o,t[e].x),a=Math.max(a,t[e].y);m=i>=n.x&&o<=r.x&&s>=n.y&&a<=r.y?[t]:o<n.x||i>r.x||a<n.y||s>r.y?[]:e.clipLine([t],n.x,n.y,r.x,r.y)}for(const e of m){o.reset(e,.25*t);let n=0;n=o.length<=.5*t?1:Math.ceil(o.paddedLength/h)+1;for(let e=0;e<n;e++){const r=e/Math.max(n-1,1),s=o.lerp(r),a=s.x+yt,l=s.y+yt;g.push(a,l,t,0);const c=a-t,h=l-t,d=a+t,f=l+t;if(P=P&&this.isOffscreen(c,h,d,f),I=I||this.isInsideGrid(c,h,d,f),!i&&this.grid.hitTestCircle(a,l,t,p)&&(L=!0,!u))return{circles:[],offscreen:!1,collisionDetected:L,occluded:!1}}}}return{circles:!u&&L||!I?[]:g,offscreen:P,collisionDetected:L,occluded:T.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let n=1/0,r=1/0,o=-1/0,s=-1/0;for(const a of t){const t=new e.pointGeometry(a.x+yt,a.y+yt);n=Math.min(n,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),i.push(t)}const a=this.grid.query(n,r,o,s).concat(this.ignoredGrid.query(n,r,o,s)),l={},c={};for(const t of a){const n=t.key;if(void 0===l[n.bucketInstanceId]&&(l[n.bucketInstanceId]={}),l[n.bucketInstanceId][n.featureIndex])continue;const r=[new e.pointGeometry(t.x1,t.y1),new e.pointGeometry(t.x2,t.y1),new e.pointGeometry(t.x2,t.y2),new e.pointGeometry(t.x1,t.y2)];e.polygonIntersectsPolygon(i,r)&&(l[n.bucketInstanceId][n.featureIndex]=!0,void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]=[]),c[n.bucketInstanceId].push(n.featureIndex))}return c}insertCollisionBox(e,t,i,n,r){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:n,collisionGroupID:r},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:n,collisionGroupID:r};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(t,i,n,r,o){const s=[i[0],i[1],i[2],1];let a=!1;if(i[2]||this.transform.pitch>0){e.transformMat4$1(s,s,t);const r="globe"===o.name;this.fogState&&n&&!r&&(a=function(t,i,n,r,o,s){const a=s.calculateFogTileMatrix(o),l=[i,n,r];return e.transformMat4(l,l,a),A(t,l,s.pitch,s._fov)}(this.fogState,i[0],i[1],i[2],n.toUnwrapped(),this.transform)>.9)}else _t(s,s,t);return{point:new e.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+yt,(-s[1]/s[3]+1)/2*this.transform.height+yt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(o)/s[3]*.5,1.5),signedDistanceFromCamera:s[3],occluded:r&&s[2]>s[3]||a}}isOffscreen(e,t,i,n){return i<yt||e>=this.screenRightBoundary||n<yt||t>this.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e<this.gridRightBoundary&&n>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.identity([]);return e.translate(t,t,[-100,-100,0]),t}}function xt(t,i,n){const r=i.createTileMatrix(t,t.worldSize,n.toUnwrapped());return e.multiply(new Float32Array(16),t.projMatrix,r)}function bt(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const n=i.clone();return n.setProjection(t.projection),xt(n,t.getProjection(),e)}function wt(e,t,i){return t.name===i.projection.name?e.projMatrix:xt(i,t,e)}class Mt{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Tt{constructor(e,t,i,n,r,o=!1){this.text=new Mt(e?e.text:null,t,i,r),this.icon=new Mt(e?e.icon:null,t,n,r),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class St{constructor(e,t,i,n=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=n}}class Et{constructor(){this.invProjMatrix=e.create(),this.viewportMatrix=e.create(),this.circles=[]}}class At{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}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 Lt(t,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=e.getAnchorAlignment(t),l=-(s-.5)*i,c=-(a-.5)*n,u=e.evaluateVariableOffset(t,r);return new e.pointGeometry(l+u[0]*o,c+u[1]*o)}function It(t,i,n,r,o){const s=new e.pointGeometry(t,i);return n&&s._rotate(r?o:-o),s}class Pt{constructor(e,t,i,n,r){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new vt(this.transform,r),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=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=o.layers[0].layout,l=n.collisionBoxArray,c=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),u=n.tileSize/e.EXTENT,h=n.tileID.toUnwrapped();this.transform.setProjection(o.projection);const p=(d=n.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):xt(m,f,d));var d,f,m;const g="map"===a.get("text-pitch-alignment"),_="map"===a.get("text-rotation-alignment");i.compileFilter();const y=i.dynamicFilter(),v=i.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(n),b=it(p,n.tileID.canonical,g,_,this.transform,o.getProjection(),x);let w=null;if(g){const t=nt(p,n.tileID.canonical,g,_,this.transform,o.getProjection(),x);w=e.multiply([],this.transform.labelPlaneMatrix,t)}let M=null;y&&n.latestFeatureIndex&&(M={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:n.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new At(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const T={bucket:o,layout:a,posMatrix:p,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:M,scale:c,textPixelRatio:u,holdingForFade:n.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:T})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:T})}attemptAnchorPlacement(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_){const y=[h.textOffset0,h.textOffset1],v=Lt(e,i,n,y,r),x=this.collisionIndex.placeCollisionBox(d,r,t,It(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(_,this.transform.zoom,p),m,It(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)&&x.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(t=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:i,height:n,anchor:e,textScale:r,prevAnchor:t},this.markUsedJustification(d,e,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:v,placedGlyphBoxes:x}}}placeLayerBucketPart(t,i,n,r){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:g}=t.parameters,_=s.get("text-optional"),y=s.get("icon-optional"),v=s.get("text-allow-overlap"),x=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),M="none"!==s.get("icon-text-fit"),T="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(o.projection);let S=v&&(x||!o.hasIconData()||y),E=x&&(v||!o.hasTextData()||_);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d),n&&r&&o.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(t,r,d)=>{if(u){const n={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(u.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];r=u.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(n,r,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[t.crossTileID]=new St(!1,!1,!1,!0),void(i[t.crossTileID]=!0)}if(i[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new St(!1,!1,!1));let T=!1,A=!1,C=!0,L=!1,I=!1,P=null,R={box:null,offscreen:null,occluded:null},k={box:null,offscreen:null,occluded:null},z=null,D=null,O=null,F=0,B=0,N=0;d.textFeatureIndex?F=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),d.verticalTextFeatureIndex&&(B=d.verticalTextFeatureIndex);const U=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},j=d.textBox;if(j){U(j);const i=i=>{let n=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,n=e,this.markUsedOrientation(o,n,t))}return n},n=(i,n)=>{if(o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of o.writingModes)if(t===e.WritingMode.vertical?(R=n(),k=R):R=i(),R&&R.box&&R.box.length)break}else R=i()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,i,n)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),c=(e.x2-e.x1)*s+2*e.padding,u=(e.y2-e.y1)*s+2*e.padding,p=M&&!x?i:null;p&&U(p);let d={box:[],offscreen:!1,occluded:!1};const _=v?2*l.length:l.length;for(let i=0;i<_;++i){const _=this.attemptAnchorPlacement(l[i%l.length],e,c,u,s,b,w,h,a,g,i>=l.length,t,r,o,n,p,f,m);if(_&&(d=_.placedGlyphBoxes,d&&d.box&&d.box.length)){T=!0,P=_.shift;break}}return d};n((()=>c(j,d.iconBox,e.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return i&&U(i),o.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&t.numVerticalGlyphVertices>0&&i?c(i,d.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),R&&(T=R.box,C=R.offscreen,L=R.occluded);const u=i(R&&R.box);if(!T&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(o,e.anchor,t,u))}}else{const s=(i,n)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(o,s,i,new e.pointGeometry(0,0),v,h,a,g.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,n,t),this.placedOrientations[t.crossTileID]=n),l};n((()=>s(j,e.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?(U(i),s(i,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(R&&R.box&&R.box.length)}}if(z=R,T=z&&z.box&&z.box.length>0,C=z&&z.offscreen,L=z&&z.occluded,t.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=e.evaluateSizeForFeature(o.textSizeData,f,i),u=s.get("text-padding");D=this.collisionIndex.placeCollisionCircles(o,v,i,o.lineVertexArray,o.glyphOffsetArray,r,a,l,c,n,w,g.predicate,t.collisionCircleDiameter*r/e.ONE_EM,u,this.retainedQueryData[o.bucketInstanceId].tileID),T=v||D.circles.length>0&&!D.collisionDetected,C=C&&D.offscreen,L=D.occluded}if(d.iconFeatureIndex&&(N=d.iconFeatureIndex),d.iconBox){const t=t=>{U(t);const i=M&&P?It(P.x,P.y,b,w,this.transform.angle):new e.pointGeometry(0,0),n=o.getSymbolInstanceIconSize(m,this.transform.zoom,r);return this.collisionIndex.placeCollisionBox(o,n,t,i,x,h,a,g.predicate)};k&&k.box&&k.box.length&&d.verticalIconBox?(O=t(d.verticalIconBox),A=O.box.length>0):(O=t(d.iconBox),A=O.box.length>0),C=C&&O.offscreen,I=O.occluded}const V=_||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=y||0===t.numIconVertices;if(V||G?G?V||(A=A&&T):T=A&&T:A=T=A&&T,T&&z&&z.box&&this.collisionIndex.insertCollisionBox(z.box,s.get("text-ignore-placement"),o.bucketInstanceId,k&&k.box&&B?B:F,g.ID),A&&O&&this.collisionIndex.insertCollisionBox(O.box,s.get("icon-ignore-placement"),o.bucketInstanceId,N,g.ID),D&&(T&&this.collisionIndex.insertCollisionCircles(D.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,g.ID),n)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Et);for(let e=0;e<D.circles.length;e+=4)t.circles.push(D.circles[e+0]),t.circles.push(D.circles[e+1]),t.circles.push(D.circles[e+2]),t.circles.push(D.collisionDetected?1:0)}const H="globe"!==o.projection.name;S=S&&(H||!L),E=E&&(H||!I),this.placements[t.crossTileID]=new St(T||S,A||E,C||o.justReloaded),i[t.crossTileID]=!0};if(T){const e=o.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];A(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)A(o.symbolInstances.get(e),e,o.collisionArrays[e]);if(n&&o.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[o.bucketInstanceId];e.invert(t.invProjMatrix,a),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(t,i,n,r){let o;o=r===e.WritingMode.vertical?n.verticalPlacedTextSymbolIndex:{left:n.leftJustifiedTextSymbolIndex,center:n.centerJustifiedTextSymbolIndex,right:n.rightJustifiedTextSymbolIndex}[e.getAnchorJustification(i)];const s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex,n.verticalPlacedTextSymbolIndex];for(const e of s)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:n.crossTileID)}markUsedOrientation(t,i,n){const r=i===e.WritingMode.horizontal||i===e.WritingMode.horizontalOnly?i:0,o=i===e.WritingMode.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new Tt(o,n,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Tt(null,n,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new Tt(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,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 n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i,n.collisionBoxArray)}}updateBucketOpacities(t,i,n){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),s=new Tt(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),l=r.get("icon-allow-overlap"),c=r.get("text-variable-anchor"),u="map"===r.get("text-rotation-alignment"),h="map"===r.get("text-pitch-alignment"),p="none"!==r.get("icon-text-fit"),d=new Tt(null,0,a&&(l||!t.hasIconData()||r.get("icon-optional")),l&&(a||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);const f=(e,t,i)=>{for(let n=0;n<t/4;n++)e.opacityVertexArray.emplaceBack(i)};let m=0;for(let n=0;n<t.symbolInstances.length;n++){const r=t.symbolInstances.get(n),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:g}=r;let _=this.opacities[g];i[g]?_=s:_||(_=d,this.opacities[g]=_),i[g]=!0;const y=a>0||l>0,v=r.numIconVertices>0,x=this.placedOrientations[r.crossTileID],b=x===e.WritingMode.vertical,w=x===e.WritingMode.horizontal||x===e.WritingMode.horizontalOnly;if(!y&&!v||_.isHidden()||m++,y){const e=Ut(_.text);f(t.text,a,b?jt:e),f(t.text,l,w?jt:e);const i=_.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||b?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(t,n.anchor,r,x);const o=this.placedOrientations[r.crossTileID];o&&(this.markUsedJustification(t,"left",r,o),this.markUsedOrientation(t,o,r))}if(v){const e=Ut(_.icon);r.placedIconSymbolIndex>=0&&(f(t.icon,r.numIconVertices,b?jt:e),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=_.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(f(t.icon,r.numVerticalIconVertices,w?jt:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=_.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[n];if(i){let n=new e.pointGeometry(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(c){const e=this.variableOffsets[g];e?(n=Lt(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&n._rotate(h?this.transform.angle:-this.transform.angle)):r=!1}o&&(r=!_.clipped),i.textBox&&Rt(t.textCollisionBox.collisionVertexArray,_.text.placed,!r||b,n.x,n.y),i.verticalTextBox&&Rt(t.textCollisionBox.collisionVertexArray,_.text.placed,!r||w,n.x,n.y)}const s=r&&Boolean(!w&&i.verticalIconBox);i.iconBox&&Rt(t.iconCollisionBox.collisionVertexArray,_.icon.placed,s,p?n.x:0,p?n.y:0),i.verticalIconBox&&Rt(t.iconCollisionBox.collisionVertexArray,_.icon.placed,!s,p?n.x:0,p?n.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.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 Rt(e,t,i,n,r){e.emplaceBack(t?1:0,i?1:0,n||0,r||0),e.emplaceBack(t?1:0,i?1:0,n||0,r||0),e.emplaceBack(t?1:0,i?1:0,n||0,r||0),e.emplaceBack(t?1:0,i?1:0,n||0,r||0)}const kt=Math.pow(2,25),zt=Math.pow(2,24),Dt=Math.pow(2,17),Ot=Math.pow(2,16),Ft=Math.pow(2,9),Bt=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*kt+t*zt+i*Dt+t*Ot+i*Ft+t*Bt+i*Nt+t}const jt=0;class Vt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,n,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,r())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++,r())return!0}return!1}}class Gt{constructor(e,t,i,n,r,o,s,a){this.placement=new Pt(e,r,o,s,a),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(t,i,n){const r=e.exported.now(),o=()=>{const t=e.exported.now()-r;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=i[t[this._currentPlacementIndex]],r=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=r)&&(!e.maxzoom||e.maxzoom>r)){if(this._inProgressLayer||(this._inProgressLayer=new Vt(e)),this._inProgressLayer.continuePlacement(n[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ht=512/e.EXTENT/2;class Wt{constructor(e,t,i){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<t.length;i++){const n=t.get(i),r=n.key;this.indexedSymbolInstances[r]||(this.indexedSymbolInstances[r]=[]),this.indexedSymbolInstances[r].push({crossTileID:n.crossTileID,coord:this.getScaledCoordinates(n,e)})}}getScaledCoordinates(t,i){const n=Ht/Math.pow(2,i.canonical.z-this.tileID.canonical.z);return{x:Math.floor((i.canonical.x*e.EXTENT+t.tileAnchorX)*n),y:Math.floor((i.canonical.y*e.EXTENT+t.tileAnchorY)*n)}}findMatches(e,t,i){const n=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let r=0;r<e.length;r++){const o=e.get(r);if(o.crossTileID)continue;const s=this.indexedSymbolInstances[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,t);for(const e of s)if(Math.abs(e.coord.x-a.x)<=n&&Math.abs(e.coord.y-a.y)<=n&&!i[e.crossTileID]){i[e.crossTileID]=!0,o.crossTileID=e.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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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 n=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const r=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e<t.symbolInstances.length;e++){const r=t.symbolInstances.get(e);r.crossTileID||(r.crossTileID=i.generate(),n[r.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Wt(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i in t.indexedSymbolInstances)for(const n of t.indexedSymbolInstances[i])delete this.usedCrossTileIDs[e][n.crossTileID]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const n=this.indexes[i];for(const r in n)e[n[r].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,n[r]),delete n[r],t=!0)}return t}}class Zt{constructor(){this.layerIndexes={},this.crossTileIDs=new qt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,n){let r=this.layerIndexes[e.id];void 0===r&&(r=this.layerIndexes[e.id]=new $t);let o=!1;const s={};"globe"!==n.name&&r.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return r.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=(t,i)=>e.emitValidationErrors(t,i&&i.filter((e=>"source.canvas"!==e.identifier))),Yt=e.pick(He,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Jt=e.pick(He,["setCenter","setZoom","setBearing","setPitch"]),Qt={version:8,layers:[],sources:{}},Kt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class ei extends e.Evented{constructor(t,i={}){super(),this.map=t,this.dispatcher=new R(je(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,i.localFontFamily?e.LocalGlyphMode.all:i.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.lineAtlas=new e.LineAtlas(256,512),this.crossTileSymbolIndex=new Zt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new e.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const n=this;this._rtlTextPluginCallback=ei.registerForPluginStateChange((t=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.triggerPluginCompletionEvent(t),i&&i.every((e=>e)))for(const e in n._sourceCaches){const t=n._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.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(t,i={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const n="boolean"==typeof i.validate?i.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,i.accessToken);const r=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(r,((t,i)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):i&&this._load(i,n)}))}loadJSON(t,i={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame((()=>{this._request=null,this._load(t,!1!==i.validate)}))}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Qt,!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(t,i){if(i&&Xt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const n=Ge(this.stylesheet.layers);this._order=n.map((e=>e.id)),this._layers={},this._serializedLayers={};for(let t of n)t=e.createStyleLayer(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new M(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 e.Event("data",{dataType:"style"})),this.fire(new e.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(t){this._spriteRequest=function(t,i,n){let r,o,s;const a=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.ResourceType.SpriteJSON),((e,t)=>{l=null,s||(s=e,r=t,u())})),c=e.getImage(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.ResourceType.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,u())}));function u(){if(s)n(s);else if(r&&o){const t=e.exported.getImageData(o),i={};for(const n in r){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:p,content:d}=r[n],f=new e.RGBAImage({width:o,height:s});e.RGBAImage.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),i[n]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:p,content:d}}n(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,((t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(i)for(const e in i)this.imageManager.addImage(e,i[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))}))}_validateLayer(t){const i=this.getSource(t.source);if(!i)return;const n=t.sourceLayer;n&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${t.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 e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Kt[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const i=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const n={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];n[e]=t.used,t.used=!1}for(const e of this._order){const i=this._layers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this._getLayerSourceCache(i);e&&(e.used=!0)}const n=this.map.painter;if(n){const e=i.getProgramIds();if(!e)continue;const r=i.getProgramConfiguration(t.zoom);for(const t of e)n.useProgram(t,r)}}for(const t in n){const i=this._sourceCaches[t];n[t]!==i.used&&i.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new e.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(i){if(this._checkLoaded(),Xt(this,e.validateStyle(i)))return!1;(i=e.clone$1(i)).layers=Ge(i.layers);const n=function(e,i){if(!e)return[{command:He.setStyle,args:[i]}];let n=[];try{if(!t(e.version,i.version))return[{command:He.setStyle,args:[i]}];t(e.center,i.center)||n.push({command:He.setCenter,args:[i.center]}),t(e.zoom,i.zoom)||n.push({command:He.setZoom,args:[i.zoom]}),t(e.bearing,i.bearing)||n.push({command:He.setBearing,args:[i.bearing]}),t(e.pitch,i.pitch)||n.push({command:He.setPitch,args:[i.pitch]}),t(e.sprite,i.sprite)||n.push({command:He.setSprite,args:[i.sprite]}),t(e.glyphs,i.glyphs)||n.push({command:He.setGlyphs,args:[i.glyphs]}),t(e.transition,i.transition)||n.push({command:He.setTransition,args:[i.transition]}),t(e.light,i.light)||n.push({command:He.setLight,args:[i.light]}),t(e.fog,i.fog)||n.push({command:He.setFog,args:[i.fog]}),t(e.projection,i.projection)||n.push({command:He.setProjection,args:[i.projection]});const r={},o=[];!function(e,i,n,r){let o;for(o in i=i||{},e=e||{})e.hasOwnProperty(o)&&(i.hasOwnProperty(o)||qe(o,n,r));for(o in i)i.hasOwnProperty(o)&&(e.hasOwnProperty(o)?t(e[o],i[o])||("geojson"===e[o].type&&"geojson"===i[o].type&&Ze(e,i,o)?n.push({command:He.setGeoJSONSourceData,args:[o,i[o].data]}):$e(o,i,n,r)):We(o,i,n))}(e.sources,i.sources,o,r);const s=[];e.layers&&e.layers.forEach((e=>{e.source&&r[e.source]?n.push({command:He.removeLayer,args:[e.id]}):s.push(e)}));let a=e.terrain;a&&r[a.source]&&(n.push({command:He.setTerrain,args:[void 0]}),a=void 0),n=n.concat(o),t(a,i.terrain)||n.push({command:He.setTerrain,args:[i.terrain]}),function(e,i,n){i=i||[];const r=(e=e||[]).map(Ye),o=i.map(Ye),s=e.reduce(Je,{}),a=i.reduce(Je,{}),l=r.slice(),c=Object.create(null);let u,h,p,d,f,m,g;for(u=0,h=0;u<r.length;u++)p=r[u],a.hasOwnProperty(p)?h++:(n.push({command:He.removeLayer,args:[p]}),l.splice(l.indexOf(p,h),1));for(u=0,h=0;u<o.length;u++)p=o[o.length-1-u],l[l.length-1-u]!==p&&(s.hasOwnProperty(p)?(n.push({command:He.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-h),1)):h++,m=l[l.length-u],n.push({command:He.addLayer,args:[a[p],m]}),l.splice(l.length-u,0,p),c[p]=!0);for(u=0;u<o.length;u++)if(p=o[u],d=s[p],f=a[p],!c[p]&&!t(d,f))if(t(d.source,f.source)&&t(d["source-layer"],f["source-layer"])&&t(d.type,f.type)){for(g in Xe(d.layout,f.layout,n,p,null,He.setLayoutProperty),Xe(d.paint,f.paint,n,p,null,He.setPaintProperty),t(d.filter,f.filter)||n.push({command:He.setFilter,args:[p,f.filter]}),t(d.minzoom,f.minzoom)&&t(d.maxzoom,f.maxzoom)||n.push({command:He.setLayerZoomRange,args:[p,f.minzoom,f.maxzoom]}),d)d.hasOwnProperty(g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&(0===g.indexOf("paint.")?Xe(d[g],f[g],n,p,g.slice(6),He.setPaintProperty):t(d[g],f[g])||n.push({command:He.setLayerProperty,args:[p,g,f[g]]}));for(g in f)f.hasOwnProperty(g)&&!d.hasOwnProperty(g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&(0===g.indexOf("paint.")?Xe(d[g],f[g],n,p,g.slice(6),He.setPaintProperty):t(d[g],f[g])||n.push({command:He.setLayerProperty,args:[p,g,f[g]]}))}else n.push({command:He.removeLayer,args:[p]}),m=l[l.lastIndexOf(p)+1],n.push({command:He.addLayer,args:[f,m]})}(s,i.layers,n)}catch(e){console.warn("Unable to compute style diff:",e),n=[{command:He.setStyle,args:[i]}]}return n}(this.serialize(),i).filter((e=>!(e.command in Jt)));if(0===n.length)return!1;const r=n.filter((e=>!(e.command in Yt)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((e=>e.command)).join(", ")}.`);return n.forEach((e=>{"setTransition"!==e.command&&this[e.command].apply(this,e.args)})),this.stylesheet=i,this._updateMapProjection(),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,i,n={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(e.validateSource,`sources.${t}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=Re(t,i,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:r.serialize(),sourceId:t})));const o=i=>{const n=(i?"symbol:":"other:")+t,o=this._sourceCaches[n]=new e.SourceCache(n,r,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const i=this.getSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const n=this._getSourceCaches(t);for(const t of n)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],i.setEventedParent(null),i.onRemove&&i.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(t,i,n={}){this._checkLoaded();const r=t.id;if(this.getLayer(r))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===t.type){if(Xt(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.clone$1(t),t=e.extend(t,{source:r})),this._validate(e.validateLayer,`layers.${r}`,t,{arrayIndex:-1},n))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`)));this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o;const a=this._getLayerSourceCache(o);if(this._removedLayers[r]&&o.source&&a&&"custom"!==o.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const n=this._order.indexOf(t);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const n=this._order.indexOf(t);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.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(t,i,n){this._checkLoaded();const r=this.getLayer(t);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(i,n,r={}){this._checkLoaded();const o=this.getLayer(i);if(o){if(!t(o.filter,n))return null==n?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(e.validateFilter,`layers.${o.id}.filter`,n,{layerType:o.type},r)||(o.filter=e.clone$1(n),this._updateLayer(o)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){const i=this.getLayer(t);return i&&e.clone$1(i.filter)}setLayoutProperty(i,n,r,o={}){this._checkLoaded();const s=this.getLayer(i);s?t(s.getLayoutProperty(n),r)||(s.setLayoutProperty(n,r,o),this._updateLayer(s)):this.fire(new e.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,i){const n=this.getLayer(t);if(n)return n.getLayoutProperty(i);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(i,n,r,o={}){this._checkLoaded();const s=this.getLayer(i);s?t(s.getPaintProperty(n),r)||(s.setPaintProperty(n,r,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[i]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${i}' 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(t,i){this._checkLoaded();const n=t.source,r=t.sourceLayer,o=this.getSource(n);if(!o)return void this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&r)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(n);for(const e of a)e.setFeatureState(r,t.id,i)}removeFeatureState(t,i){this._checkLoaded();const n=t.source,r=this.getSource(n);if(!r)return void this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(n);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){this._checkLoaded();const i=t.source,n=t.sourceLayer,r=this.getSource(i);if(r){if("vector"!==r.type||n)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(n,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const i=this._sourceCaches[e].getSource();t[i.id]||(t[i.id]=i.serialize())}return e.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:t,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(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]<o)break;r.push(t),n.pop()}else for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t.feature)}}return r}queryRenderedFeatures(t,i,n){i&&i.filter&&this._validate(e.validateFilter,"queryRenderedFeatures.filter",i.filter,null,i);const r={};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];r[i.source]=!0}}const o=[];i.availableImages=this._availableImages;const s=i&&i.layers?i.layers.some((e=>{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),a=z.createFromScreenPoints(t,n);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;i.layers&&!r[t]||o.push(ze(this._sourceCaches[e],this._layers,this._serializedLayers,a,i,n,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(Oe);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,e);for(const e in n){const t=a[e]=a[e]||[],r=n[e];r.sort(((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of r)t.push(e)}}for(const t in a)a[t].forEach((n=>{const r=n.feature,o=i(e[t]).getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=o}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,i){i&&i.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",i.filter,null,i);const n=this._getSourceCaches(t);let r=[];for(const e of n)r=r.concat(De(e,i));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,i={}){this._checkLoaded();const n=this.light.getLight();let r=!1;for(const i in e)if(!t(e[i],n[i])){r=!0;break}if(!r)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,i),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,n=1){if(this._checkLoaded(),!i)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===n){if("object"==typeof i.source){const t="terrain-dem-src";this.addSource(t,i.source),i=e.clone$1(i),i=e.extend(i,{source:t})}if(this._validate(e.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&n!==this.terrain.drapeRenderMode)this._createTerrain(i,n);else{const n=this.terrain,r=n.get();for(const t of Object.keys(e.spec.terrain))!i.hasOwnProperty(t)&&e.spec.terrain[t].default&&(i[t]=e.spec.terrain[t].default);for(const e in i)if(!t(i[e],r[e])){n.set(i),this.stylesheet.terrain=i;const e=this._setTransitionParameters({duration:0});n.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new P(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 i=this.fog,n=i.get();0===Object.keys(e).length&&i.set(e);for(const r in e)if(!t(e[r],n[r])){i.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});i.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,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 n=this._setTransitionParameters({duration:0});i.updateTransitions(n)}_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(t,i,n,r,o={}){return(!o||!1!==o.validate)&&Xt(this,t.call(e.validateStyle,e.extend({key:i,style:this.serialize(),value:n,styleSpec:e.spec},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].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(t,i,n,r,o=!1){let s=!1,a=!1;const l={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!l[i.source]){const e=this._getLayerSourceCache(i);if(!e)continue;l[i.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const n=this.crossTileSymbolIndex.addLayer(i,l[i.source],t.center.lng,t.projection);s=s||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new Gt(t,this._order,o,i,n,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.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 n=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};n(this._otherSourceCaches[t.source]),n(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(t,i,n){return e.makeRequest(i,n)}_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(t){const i=this._getSourceCaches(t);return 0===i.length?(this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):i.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 Pe[e]},ei.setSourceType=function(e,t){Pe[e]=t},ei.registerForPluginStateChange=e.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 ni={},ri={};ni=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),ri=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 n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,o=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=e.match(r),a=t.match(r),l=ti.match(r);let c=a?a.concat(s):s;i||(ni.staticUniforms&&(c=ni.staticUniforms.concat(c)),ri.staticUniforms&&(c=ri.staticUniforms.concat(c))),c&&(c=c.concat(l));const u={};return{fragmentSource:e=e.replace(n,((e,t,i,n,r)=>(u[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nvarying ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`))),vertexSource:t=t.replace(n,((e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return u[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nattribute ${i} ${o} a_${r};\nvarying ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nattribute ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`})),staticAttributes:o,staticUniforms:c}}class ui{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,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e<n.length;e++)this.boundPaintVertexBuffers[e]!==n[e]&&(c=!0);e.extVertexArrayObject&&this.vao&&this.boundProgram===t&&this.boundLayoutVertexBuffer===i&&!c&&this.boundIndexBuffer===r&&this.boundVertexOffset===o&&this.boundDynamicVertexBuffer===s&&this.boundDynamicVertexBuffer2===a&&this.boundDynamicVertexBuffer3===l?(e.bindVertexArrayOES.set(this.vao),s&&s.bind(),r&&r.dynamicDraw&&r.bind(),a&&a.bind(),l&&l.bind()):this.freshBind(t,i,n,r,o,s,a,l)}freshBind(e,t,i,n,r,o,s,a){let l;const c=e.numAttributes,u=this.context,h=u.gl;if(u.extVertexArrayObject)this.vao&&this.destroy(),this.vao=u.extVertexArrayObject.createVertexArrayOES(),u.bindVertexArrayOES.set(this.vao),l=0,this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=n,this.boundVertexOffset=r,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a;else{l=u.currentNumAttributes||0;for(let e=c;e<l;e++)h.disableVertexAttribArray(e)}t.enableAttributes(h,e);for(const t of i)t.enableAttributes(h,e);o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),a&&a.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,r);for(const t of i)t.bind(),t.setVertexAttribPointers(h,e,r);o&&(o.bind(),o.setVertexAttribPointers(h,e,r)),n&&n.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,e,r)),a&&(a.bind(),a.setVertexAttribPointers(h,e,r)),u.currentNumAttributes=c}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function hi(t,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new e.MercatorCoordinate(0,r/n).toLngLat().lat,new e.MercatorCoordinate(0,(r+1)/n).toLngLat().lat]}function pi(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=n.fbo;if(!u)return;t.prepareDrawTile();const h=t.useProgram("hillshade");l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get());const p=((e,t,i,n)=>{const r=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:n||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:hi(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:r,u_highlight:o,u_accent:s}})(t,n,r,t.terrain?i.projMatrix:null);t.prepareDrawProgram(l,h,i.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(n);h.draw(l,c.TRIANGLES,o,s,a,e.CullFaceMode.disabled,p,r.id,d,f,m)}function di(t,i,n){if(!i.needsDEMTextureUpload)return;const r=t.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(n.stride);const s=n.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.Texture(r,s,o.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function fi(t,i,n,r,o,s){const a=t.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),di(t,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=i.fbo;if(!h){const t=new e.Texture(a,{width:u,height:u,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=i.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(t.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,r,o,s,e.CullFaceMode.disabled,((t,i)=>{const n=i.stride,r=e.create();return e.ortho(r,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(r,r,[0,-e.EXTENT,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ,u_unpack:i.unpackVector}})(i.tileID,c),n.id,p,d,f),i.needsHillshadePrepare=!1}const mi=(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image0:new e.Uniform1i(t,i.u_image0),u_skirt_height:new e.Uniform1f(t,i.u_skirt_height)}),gi=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),_i=(e,t,i,n,r,o,s,a,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(n),u_merc_matrix:i,u_zoom_transition:r,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:u,u_globe_radius:h,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 vi=new class{constructor(){this.operations={}}newMorphing(e,t,i,n,r){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:n,phase:0,duration:r,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()}},xi={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 Mi(t,i,n,r,o){if(o>0){const s=e.exported.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=n.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),p=h&&t.refreshedUponExpiration?1:e.clamp(h?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Ti extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new R(je(),null),n=Re("mock-dem",t,i,e.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Si extends e.SourceCache{constructor(e){const t=Re("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new R(je(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,i,n){if(t.freezeTileCoverage)return;this.transform=t;const r=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,n)=>{if(i[n.key]="",!this._tiles[n.key]){const i=new e.Tile(n,this._source.tileSize*n.overscaleFactor(),t.tileZoom);i.state="loaded",this._tiles[n.key]=i}return i}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}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 Ei extends e.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 Ai extends e.Elevation{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[n,r,o]=function(t){const i=new e.StructArrayLayout4i8,n=new e.StructArrayLayout3ui6,r=131;i.reserve(17161),n.reserve(33800);const o=e.EXTENT/128,s=e.EXTENT+o/2,a=s+o;for(let t=-o;t<a;t+=o)for(let n=-o;n<a;n+=o){const r=n<0||n>s||t<0||t>s?24575:0,o=e.clamp(Math.round(n),0,e.EXTENT),a=e.clamp(Math.round(t),0,e.EXTENT);i.emplaceBack(o+r,a,o,a)}const l=(e,t)=>{const i=t*r+e;n.emplaceBack(i+1,i,i+r),n.emplaceBack(i+r,i+r+1,i+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)})),[i,n,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(n,e.boundsAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.SegmentVector.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,n.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Si(i.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,0,e.EXTENT,0,e.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new e.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Ti(i.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(t,i,n){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const r=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const o=()=>{this.sourceCache.used&&e.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 t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),i.updateElevation(!n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.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(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,i){const n=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.pointGeometry(n.x,n.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const n=new e.pointGeometry(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=new e.pointGeometry(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),s=r.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(n)-s.distSqr(o)}))}(r,this.painter),this._previousZoom=n.zoom;const o=this.proxyToSource||{};this.proxyToSource={},r.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const n=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(n)}this.proxiedCoords[i.id]=r.map((e=>new Ei(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[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 n=this.terrainTileForTile[i],r=n.dem;!r||n.demTexture&&!n.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),di(this.painter,n,r))}}_prepareDemTileUniforms(e,t,i,n){if(!t||null==t.demTexture)return!1;const r=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-r.z),s=n||"";return i[`u_dem_tl${s}`]=[r.x*o%1,r.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,i=t.gl;if(!this._emptyDepthBufferTexture){const n=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,n,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const n=i.dem.tree.minimums[0];return n>0&&e++,t+n}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const n=this._getLoadedAreaMinimum(),r=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(n,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(r,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,r,i.RGBA,{premultiply:!1}),o}setupElevationDraw(t,i,n){const r=this.painter.context,o=r.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(a),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 a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const l=this.painter.transform,c=l.projection,u=t.tileID.canonical;s.u_tile_tl_up=c.upVector(u,0,0),s.u_tile_tr_up=c.upVector(u,e.EXTENT,0),s.u_tile_br_up=c.upVector(u,e.EXTENT,e.EXTENT),s.u_tile_bl_up=c.upVector(u,0,e.EXTENT),s.u_tile_up_scale=n&&n.useDenormalizedUpVectorScale?e.GLOBE_METERS_TO_ECEF:c.upVectorScale(u,l.center.lat,l.worldSize).metersToTile;let h=null,p=null,d=1;if(n&&n.morphing&&this._useVertexMorphing){const e=n.morphing.srcDemTile,i=n.morphing.dstDemTile;d=n.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(p=e),this._prepareDemTileUniforms(t,i,s)&&(h=i))}if(p&&h?(r.activeTexture.set(o.TEXTURE2),h.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),r.activeTexture.set(o.TEXTURE4),p.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=d):(h=this.terrainTileForTile[t.tileID.key],r.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,h,s)?h.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),r.activeTexture.set(o.TEXTURE3),n&&n.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),n&&n.useMeterToDem&&h){const t=(1<<h.tileID.canonical.z)*e.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}n&&n.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=n.labelPlaneMatrixInv),i.setTerrainUniformValues(r,s)}renderToBackBuffer(t){const i=this.painter,n=this.painter.context;0!==t.length&&(n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,i,n,r,o){if("globe"===t.transform.projection.name)!function(t,i,n,r,o){const s=t.context,a=s.gl;let l,c;const u=t.options.showTerrainWireframe?2:0,h=t.transform,p=e.globeUseCustomAntiAliasing(t,s,h),d=(e,i)=>{if(c===e)return;const n=[xi[e],"PROJECTION_GLOBE_VIEW"];p&&n.push("CUSTOM_ANTIALIASING"),i&&n.push(xi[u]),l=t.useProgram("globeRaster",null,n),c=e},f=t.colorModeForRenderPass(),m=new e.DepthMode(a.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);vi.update(o);const g=e.calculateGlobeMercatorMatrix(h),_=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=t.globeSharedBuffers,v=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio];if((u?[!1,!0]:[!1]).forEach((u=>{c=-1;const p=u?a.LINES:a.TRIANGLES;for(const c of r){const r=n.getTile(c),x=e.StencilMode.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];yi(b,w)&&vi.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const M=vi.getMorphValuesForProxy(c.key),T=M?1:0,S={useDenormalizedUpVectorScale:!0};M&&e.extend$1(S,{morphing:{srcDemTile:M.from,dstDemTile:M.to,phase:e.easeCubicInOut(M.phase)}});const E=Float32Array.from(h.globeMatrix),A=e.globeTileLatLngCorners(c.canonical),C=e.getLatitudinalLod((A[0][0]+A[1][0])/2),L=e.getGridMatrix(c.canonical,A,C),I=e.globeNormalizeECEF(e.globeTileBounds(c.canonical)),P=_i(h.projMatrix,E,g,I,e.globeToMercatorTransition(h.zoom),_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,L);if(d(T,u),i.setupElevationDraw(r,l,S),t.prepareDrawProgram(s,l,c.toUnwrapped()),y){const[i,n,r]=u?y.getWirefameBuffers(t.context,C):y.getGridBuffers(C);l.draw(s,p,m,x,f,e.CullFaceMode.backCCW,P,"globe_raster",i,n,r)}}})),y){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&o.push("CUSTOM_ANTIALIASING"),l=t.useProgram("globeRaster",null,o);for(const o of r){const{x:r,y:c,z:u}=o.canonical,p=0===c,d=c===(1<<u)-1,[g,x,b,w]=y.getPoleBuffers(u);if(w&&(p||d)){const c=n.getTile(o);s.activeTexture.set(a.TEXTURE0),c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let y=e.globePoleMatrixForTile(u,r,h);const M=e.globeNormalizeECEF(e.globeTileBounds(o.canonical)),T=(t,i)=>t.draw(s,a.TRIANGLES,m,e.StencilMode.disabled,f,e.CullFaceMode.disabled,_i(h.projMatrix,y,y,M,0,_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,{}),t.prepareDrawProgram(s,l,o.toUnwrapped()),p&&T(l,g),d&&(y=e.scale(e.create(),y,[1,-1,1]),T(l,x))}}}}(t,i,n,r,o);else{const s=t.context,a=s.gl;let l,c;const u=t.options.showTerrainWireframe?2:0,h=(e,i)=>{if(c===e)return;const n=[xi[e]];i&&n.push(xi[u]),l=t.useProgram("terrainRaster",null,n),c=e},p=t.colorModeForRenderPass(),d=new e.DepthMode(a.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);vi.update(o);const f=t.transform,m=6*Math.pow(1.5,22-f.zoom)*i.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const g=u?a.LINES:a.TRIANGLES,[_,y]=u?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=n.getTile(c),v=e.StencilMode.disabled,x=i.prevTerrainTileForTile[c.key],b=i.terrainTileForTile[c.key];yi(x,b)&&vi.newMorphing(c.key,x,b,o,250),s.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=vi.getMorphValuesForProxy(c.key),M=w?1:0;let T;w&&(T={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=gi(c.projMatrix,bi(c.canonical,f.renderWorldCopies)?m/10:m);h(M,u),i.setupElevationDraw(r,l,T),t.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,g,d,v,p,e.CullFaceMode.backCCW,S,"terrain_raster",i.gridBuffer,_,y)}}))}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,n=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=[],l=i.style.order;let c=0;for(const u of o){const o=r.getTileByID(u.proxyTileKey),h=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][t]:void 0,p=void 0!==h?r.renderCache[h]:this.pool[c++],d=void 0!==h;if(o.texture=p.tex,d&&!p.dirty){a.push(o.tileID);continue}let f;n.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(n.clear({color:e.Color.transparent,stencil:0}),p.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._layers[l[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style._getLayerSourceCache(t),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(p,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}this.renderedToTile?(p.dirty=!0,a.push(o.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let i,n=0,r=0,o=!1;for(let s=0;s<t;++s){const t=e._layers[e.order[s]];this._style.isLayerDraped(t)?(o&&++n,++r):o||(o=!0,i=t.id)}return 0===r?{efficiency:100}:{efficiency:100*(1-n/r),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const n=this._visibleDemTiles.filter((e=>e.dem)).map((n=>{const r=n.tileID,o=Math.pow(2,r.overscaledZ),{x:s,y:a}=r.canonical,l=s/o,c=(s+1)/o,u=a/o,h=(a+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:n.dem.tree.raycastRoot(l,u,c,h,e,t,i),tile:n}}));n.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const r of n){if(null==r.t)return null;const n=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=n)return n}return null}_createFBO(){const t=this.painter.context,i=t.gl,n=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.Texture(t,{width:n[0],height:n[1],data:null},i.RGBA);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(n[0],n[1],!1);return o.colorAttachment.set(r.texture),o.depthAttachment=new Te(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,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),n=t.getCrossfadeParameters(),r=!!n&&1!==n.t,o=t.hasTransition();return"custom"!==t.type&&!i&&(r||o)}))}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof Ae){e=!0;break}if(e)for(let e=0;e<this._style.order.length;++e){const t=this._style._layers[this._style.order[e]],i=t.isHidden(this.painter.transform.zoom),n=this._style._getLayerSourceCache(t);if("raster"!==t.type||i||!n)continue;const r=t.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][n.id];if(t)for(const e of t){const t=Mi(n.getTile(e),n.findLoadedParent(e,0),n,this.painter.transform,r);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(n.id,e)}}}}_setupDrapedRenderBatches(){const e=this._style.order,t=e.length;if(0===t)return;const i=[];let n,r=0,o=this._style._layers[e[r]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++r<t;)o=this._style._layers[e[r]];for(;r<t;++r){const t=this._style._layers[e[r]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===n&&(n=r):void 0!==n&&(i.push({start:n,end:r-1}),n=void 0))}void 0!==n&&i.push({start:n,end:r-1}),this._drapedRenderBatches=i}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const n=Object.values(e[i]);t.renderCachePool.push(...n)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,n=this._tilesDirty;for(let r=i.length-1;r>=0;r--){const o=i[r];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],r=this.proxyToSource[o.key];let s=0;for(const e in r){const t=r[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||n[e]&&n[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const r=[...this._drapedRenderBatches];r.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of r)for(const n of i){if(t.proxyCachedFBO[n.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[n.key]={},t.proxyCachedFBO[n.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,n){if(!n||!this._sourceTilesOverlap[n.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,o=r.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&&(r.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(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,i){const n=this.painter,r=this.painter.context,o=r.gl;n._tileClippingMaskIDs={},r.setColorMode(e.ColorMode.disabled),r.setDepthMode(e.DepthMode.disabled);const s=n.useProgram("clippingMask");for(const a of t){const t=n._tileClippingMaskIDs[a.key]=--i;s.draw(r,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,wi(a.projMatrix),"$clipping",n.tileExtentBuffer,n.quadTriangleIndexBuffer,n.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const n=[t.x,t.y,1,1];e.transformMat4$1(n,n,i.pixelMatrixInverse),e.scale$1(n,n,1/n[3]),n[0]/=i.worldSize,n[1]/=i.worldSize;const r=i._camera.position,o=e.mercatorZfromAltitude(1,i.center.lat),s=[r[0],r[1],r[2]/o,0],a=e.subtract([],n.slice(0,3),s);e.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,i=t.context,n=this.proxySourceCache,r=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=i.gl,n=i.createFramebuffer(r,o,!0);i.activeTexture.set(t.TEXTURE0);const s=new e.Texture(i,{width:r,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),n.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,r,o);n.depthAttachment.set(a),this._depthFBO=n,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,r,o]),function(t,i,n,r){if("globe"===t.transform.projection.name)return;const o=t.context,s=o.gl;o.clear({depth:1});const a=t.useProgram("terrainDepth"),l=new e.DepthMode(s.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of r){const r=n.getTile(t),c=gi(t.projMatrix,0);i.setupElevationDraw(r,a),a.draw(o,s.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(t,this,n,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof Ie)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const n=this.proxiedCoords[e.id]=[],r=this.proxyCoords;for(let t=0;t<r.length;t++){const o=r[t],s=this._findTileCoveringTileID(o,e);if(s){const t=this._createProxiedId(o,s,i[o.key]&&i[o.key][e.id]);n.push(t),this.proxyToSource[o.key][e.id]=[t]}}let o=!1;for(let r=0;r<t.length;r++){const s=e.getTile(t[r]);if(!s||!s.hasData())continue;const a=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==s.tileID.canonical.z){const t=this.proxyToSource[a.tileID.key][e.id],r=this._createProxiedId(a.tileID,s,i[a.tileID.key]&&i[a.tileID.key][e.id]);t?t.splice(t.length-1,0,r):this.proxyToSource[a.tileID.key][e.id]=[r],n.push(r),o=!0}}this._sourceTilesOverlap[e.id]=o}_setupProxiedCoordsForImageSource(t,i,n){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=new e.pointGeometry(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(e.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 e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(t,i)=>{const n=t.wrap+t.canonical.x/(1<<t.canonical.z),r=t.canonical.y/(1<<t.canonical.z),o=e.EXTENT/(1<<t.canonical.z),s=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return n+o<s+l.min.x||n>s+l.max.x||r+o<a+l.min.y||r>a+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,n[s.key]&&n[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],r.push(a)}}}_createProxiedId(t,i,n){let r=this.orthoMatrix;if(n){const e=n.find((e=>e.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const n=t.canonical.z-i.tileID.canonical.z;let o,s,a;r=e.create();const l=i.tileID.wrap-t.wrap<<t.overscaledZ;n>0?(o=e.EXTENT>>n,s=o*((i.tileID.canonical.x<<n)-t.canonical.x+l),a=o*((i.tileID.canonical.y<<n)-t.canonical.y)):(o=e.EXTENT<<-n,s=e.EXTENT*(i.tileID.canonical.x-(t.canonical.x+l<<-n)),a=e.EXTENT*(i.tileID.canonical.y-(t.canonical.y<<-n))),e.ortho(r,0,o,0,o,0,1),e.translate(r,r,[s,a,0])}return new Ei(i.tileID,t.key,r)}_findTileCoveringTileID(t,i){let n=i.getTile(t);if(n&&n.hasData())return n;const r=this._findCoveringTileCache[i.id],o=r[t.key];if(n=o?i.getTileByID(o):null,n&&n.hasData()||null===o)return n;let s=n?n.tileID:t,a=s.overscaledZ;const l=i.getSource().minzoom,c=[];if(!o){const r=i.getSource().maxzoom;if(t.canonical.z>=r){const n=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.OverscaledTileID(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n)):0!==n&&(a=r,s=new e.OverscaledTileID(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n))}s.key!==t.key&&(c.push(s.key),n=i.getTile(s))}const u=e=>{c.forEach((t=>{r[t]=e})),c.length=0};for(a-=1;a>=l&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=s.calculateScaledKey(a);if(n=i.getTileByID(e),n&&n.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):n=i.getTileByID(t)}return u(n?n.tileID.key:null),n&&n.hasData()?n: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 t=function(t){let i=0;const n=new e.StructArrayLayout2ui4,r=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)i=e*r+t,n.emplaceBack(i,i+1),n.emplaceBack(i,i+r),n.emplaceBack(i+1,i+r),128===e&&n.emplaceBack(i+r,i+r+1);n.emplaceBack(i+1,i+1+r)}return n}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function Ci(e){const t=[];for(let i=0;i<e.length;i++){if(null===e[i])continue;const n=e[i].split(" ");t.push(n.pop())}return t}class Li{static cacheKey(e,t,i){let n=`${e}${i?i.cacheKey:""}`;for(const e of t)n+=`/${e}`;return n}constructor(t,i,n,r,o,s){const a=t.gl;this.program=a.createProgram();const l=Ci(n.staticAttributes),c=r?r.getBinderAttributes():[],u=l.concat(c),h=n.staticUniforms?Ci(n.staticUniforms):[],p=r?r.getBinderUniforms():[],d=h.concat(p),f=[];for(const e of d)f.indexOf(e)<0&&f.push(e);let m=r?r.defines():[];m=m.concat(s.map((e=>`#define ${e}`)));const g=m.concat(t.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(ai):ai,ai,si,oi.fragmentSource,ri.fragmentSource,n.fragmentSource).join("\n"),_=m.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,ri.vertexSource,ni.vertexSource,n.vertexSource).join("\n"),y=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(y,g),a.compileShader(y),a.attachShader(this.program,y);const v=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(v,_),a.compileShader(v),a.attachShader(this.program,v),this.attributes={};const x={};this.numAttributes=u.length;for(let e=0;e<this.numAttributes;e++)u[e]&&(a.bindAttribLocation(this.program,e,u[e]),this.attributes[u[e]]=e);a.linkProgram(this.program),a.deleteShader(v),a.deleteShader(y);for(let e=0;e<f.length;e++){const t=f[e];if(t&&!x[t]){const e=a.getUniformLocation(this.program,t);e&&(x[t]=e)}}this.fixedUniforms=o(t,x),this.binderUniforms=r?r.getUniforms(t,x):[],-1!==s.indexOf("TERRAIN")&&(this.terrainUniforms=((t,i)=>({u_dem:new e.Uniform1i(t,i.u_dem),u_dem_prev:new e.Uniform1i(t,i.u_dem_prev),u_dem_unpack:new e.Uniform4f(t,i.u_dem_unpack),u_dem_tl:new e.Uniform2f(t,i.u_dem_tl),u_dem_scale:new e.Uniform1f(t,i.u_dem_scale),u_dem_tl_prev:new e.Uniform2f(t,i.u_dem_tl_prev),u_dem_scale_prev:new e.Uniform1f(t,i.u_dem_scale_prev),u_dem_size:new e.Uniform1f(t,i.u_dem_size),u_dem_lerp:new e.Uniform1f(t,i.u_dem_lerp),u_exaggeration:new e.Uniform1f(t,i.u_exaggeration),u_depth:new e.Uniform1i(t,i.u_depth),u_depth_size_inv:new e.Uniform2f(t,i.u_depth_size_inv),u_meter_to_dem:new e.Uniform1f(t,i.u_meter_to_dem),u_label_plane_matrix_inv:new e.UniformMatrix4f(t,i.u_label_plane_matrix_inv),u_tile_tl_up:new e.Uniform3f(t,i.u_tile_tl_up),u_tile_tr_up:new e.Uniform3f(t,i.u_tile_tr_up),u_tile_br_up:new e.Uniform3f(t,i.u_tile_br_up),u_tile_bl_up:new e.Uniform3f(t,i.u_tile_bl_up),u_tile_up_scale:new e.Uniform1f(t,i.u_tile_up_scale)}))(t,x)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((t,i)=>({u_fog_matrix:new e.UniformMatrix4f(t,i.u_fog_matrix),u_fog_range:new e.Uniform2f(t,i.u_fog_range),u_fog_color:new e.Uniform4f(t,i.u_fog_color),u_fog_horizon_blend:new e.Uniform1f(t,i.u_fog_horizon_blend),u_fog_temporal_offset:new e.Uniform1f(t,i.u_fog_temporal_offset),u_frustum_tl:new e.Uniform3f(t,i.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,i.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,i.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,i.u_frustum_bl),u_globe_pos:new e.Uniform3f(t,i.u_globe_pos),u_globe_radius:new e.Uniform1f(t,i.u_globe_radius),u_globe_transition:new e.Uniform1f(t,i.u_globe_transition),u_is_globe:new e.Uniform1i(t,i.u_is_globe),u_viewport:new e.Uniform2f(t,i.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,n,r,o,s,a,l,c,u,h,p,d,f,m,g){const _=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(s[e]);d&&d.setUniforms(e,this.binderUniforms,h,{zoom:p});const y={[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];for(const i of u.get()){const n=i.vaos||(i.vaos={});(n[a]||(n[a]=new ui)).bind(e,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m,g),_.drawElements(t,i.primitiveLength*y,_.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function Ii(e,t,i){const n=1/k(i,1,t.transform.tileZoom),r=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=o*(i.tileID.canonical.x+i.tileID.wrap*r),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[n,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 Pi=e.create(),Ri=(t,i,n,r,o,s,a,l,c)=>{const u=i.style.light,h=u.properties.get("position"),p=[h.x,h.y,h.z],d=e.create$1();"viewport"===u.properties.get("anchor")&&(e.fromRotation(d,-i.transform.angle),e.transformMat3(p,p,d));const f=u.properties.get("color"),m=i.transform,g={u_matrix:t,u_lightpos:p,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[f.r,f.g,f.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Pi,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===m.projection.name&&(g.u_tile_id=[o.canonical.x,o.canonical.y,1<<o.canonical.z],g.u_zoom_transition=a,g.u_inv_rot_matrix=c,g.u_merc_center=l,g.u_up_dir=m.projection.upVector(new e.CanonicalTileID(0,0,0),l[0]*e.EXTENT,l[1]*e.EXTENT),g.u_height_lift=s),g},ki=(t,i,n,r,o,s,a,l,c,u,h)=>{const p=Ri(t,i,n,r,o,l,c,u,h),d={u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8};return e.extend(p,Ii(s,i,a),d)},zi=e=>({u_matrix:e}),Di=(t,i,n,r)=>e.extend(zi(t),Ii(n,i,r)),Oi=(e,t)=>({u_matrix:e,u_world:t}),Fi=(t,i,n,r,o)=>e.extend(Di(t,i,n,r),{u_world:o}),Bi=e.create(),Ni=(t,i,n,r,o,s)=>{const a=t.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const t=e.globePixelsToTileUnits(a.zoom,i.canonical)*a._projectionScaler;c=Float32Array.from([t,0,0,t])}else c=a.calculatePixelsToTileUnitsMatrix(n);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:t.translatePosMatrix(i.projMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Bi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=r,u.u_merc_center=o,u.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],u.u_zoom_transition=e.globeToMercatorTransition(a.zoom);const t=o[0]*e.EXTENT,n=o[1]*e.EXTENT;u.u_up_dir=a.projection.upVector(new e.CanonicalTileID(0,0,0),t,n)}return u},Ui=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},ji=(t,i,n,r)=>{const o=e.EXTENT/n.tileSize;return{u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(r),u_extrude_scale:[i.pixelsToGLUnits[0]/o,i.pixelsToGLUnits[1]/o]}},Vi=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Gi=e.create(),Hi=(t,i,n,r,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.globePixelsToTileUnits(l.zoom,i.canonical)*l._projectionScaler:k(n,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,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(c){h.u_inv_rot_matrix=r,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],h.u_zoom_transition=e.globeToMercatorTransition(l.zoom);const t=o[0]*e.EXTENT,n=o[1]*e.EXTENT;h.u_up_dir=l.projection.upVector(new e.CanonicalTileID(0,0,0),t,n)}return h},Wi=(e,t,i,n,r,o,s,a)=>{const l=e.transform,c=l.calculatePixelsToTileUnitsMatrix(t),u={u_matrix:Zi(e,t,i,r),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);u.u_texsize=t.lineAtlasTexture.size,u.u_scale=[i,n.fromScale,n.toScale],u.u_mix=n.t}return u},qi=(e,t,i,n,r,o)=>{const s=e.transform,a=$i(t,s);return{u_matrix:Zi(e,t,i,r),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:o,u_image:0,u_scale:[a,n.fromScale,n.toScale],u_fade:n.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 Zi(e,t,i,n){return e.translatePosMatrix(n||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 Yi=(e,t,i,n,r,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:i,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(a=r.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=r.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Ji(r.paint.get("raster-hue-rotate")),u_perspective_transform:o};var s,a};function Ji(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 Qi=e.create(),Ki=(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g)=>{const _=o.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_rotate_symbol:+n,u_aspect_ratio:_.width/_.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+r,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Qi,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Qi,u_up_vector:[0,-1,0]};return"globe"===g.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],y.u_zoom_transition=p,y.u_inv_rot_matrix=f,y.u_merc_center=d,y.u_camera_forward=_._camera.forward(),y.u_ecef_origin=e.globeECEFOrigin(_.globeMatrix,h.toUnwrapped()),y.u_tile_matrix=Float32Array.from(_.globeMatrix),y.u_up_vector=m),y},en=(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_)=>e.extend(Ki(t,i,n,r,o,s,a,l,c,u,p,d,f,m,g,_),{u_gamma_scale:r?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),tn=(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g)=>e.extend(en(t,i,n,r,o,s,a,l,!0,c,!0,h,p,d,f,m,g),{u_texsize_icon:u,u_texture_icon:1}),nn=(e,t,i)=>({u_matrix:e,u_opacity:t,u_color:i}),rn=(t,i,n,r,o,s)=>e.extend(function(e,t,i,n){const r=i.imageManager.getPattern(e.from.toString()),o=i.imageManager.getPattern(e.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(n.tileID.canonical.x+n.tileID.wrap*l),h=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:r.tl,u_pattern_br_a:r.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:r.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/k(n,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(r,s,n,o),{u_matrix:t,u_opacity:i}),on={fillExtrusion:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_lightpos:new e.Uniform3f(t,i.u_lightpos),u_lightintensity:new e.Uniform1f(t,i.u_lightintensity),u_lightcolor:new e.Uniform3f(t,i.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,i.u_vertical_gradient),u_opacity:new e.Uniform1f(t,i.u_opacity),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_up_dir:new e.Uniform3f(t,i.u_up_dir),u_height_lift:new e.Uniform1f(t,i.u_height_lift)}),fillExtrusionPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_lightpos:new e.Uniform3f(t,i.u_lightpos),u_lightintensity:new e.Uniform1f(t,i.u_lightintensity),u_lightcolor:new e.Uniform3f(t,i.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,i.u_vertical_gradient),u_height_factor:new e.Uniform1f(t,i.u_height_factor),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_up_dir:new e.Uniform3f(t,i.u_up_dir),u_height_lift:new e.Uniform1f(t,i.u_height_lift),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade),u_opacity:new e.Uniform1f(t,i.u_opacity)}),fill:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),fillPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade)}),fillOutline:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_world:new e.Uniform2f(t,i.u_world)}),fillOutlinePattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_world:new e.Uniform2f(t,i.u_world),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade)}),circle:(t,i)=>({u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_extrude_scale:new e.UniformMatrix2f(t,i.u_extrude_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_up_dir:new e.Uniform3f(t,i.u_up_dir)}),collisionBox:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_extrude_scale:new e.Uniform2f(t,i.u_extrude_scale)}),collisionCircle:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_inv_matrix:new e.UniformMatrix4f(t,i.u_inv_matrix),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_viewport_size:new e.Uniform2f(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.UniformColor(t,i.u_color),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_overlay:new e.Uniform1i(t,i.u_overlay),u_overlay_scale:new e.Uniform1f(t,i.u_overlay_scale)}),clippingMask:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),heatmap:(t,i)=>({u_extrude_scale:new e.Uniform1f(t,i.u_extrude_scale),u_intensity:new e.Uniform1f(t,i.u_intensity),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_up_dir:new e.Uniform3f(t,i.u_up_dir)}),heatmapTexture:(t,i)=>({u_image:new e.Uniform1i(t,i.u_image),u_color_ramp:new e.Uniform1i(t,i.u_color_ramp),u_opacity:new e.Uniform1f(t,i.u_opacity)}),hillshade:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_latrange:new e.Uniform2f(t,i.u_latrange),u_light:new e.Uniform2f(t,i.u_light),u_shadow:new e.UniformColor(t,i.u_shadow),u_highlight:new e.UniformColor(t,i.u_highlight),u_accent:new e.UniformColor(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_dimension:new e.Uniform2f(t,i.u_dimension),u_zoom:new e.Uniform1f(t,i.u_zoom),u_unpack:new e.Uniform4f(t,i.u_unpack)}),line:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_pixels_to_tile_units:new e.UniformMatrix2f(t,i.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.Uniform2f(t,i.u_units_to_pixels),u_dash_image:new e.Uniform1i(t,i.u_dash_image),u_gradient_image:new e.Uniform1i(t,i.u_gradient_image),u_image_height:new e.Uniform1f(t,i.u_image_height),u_texsize:new e.Uniform2f(t,i.u_texsize),u_scale:new e.Uniform3f(t,i.u_scale),u_mix:new e.Uniform1f(t,i.u_mix),u_alpha_discard_threshold:new e.Uniform1f(t,i.u_alpha_discard_threshold),u_trim_offset:new e.Uniform2f(t,i.u_trim_offset)}),linePattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixels_to_tile_units:new e.UniformMatrix2f(t,i.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_image:new e.Uniform1i(t,i.u_image),u_units_to_pixels:new e.Uniform2f(t,i.u_units_to_pixels),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade),u_alpha_discard_threshold:new e.Uniform1f(t,i.u_alpha_discard_threshold)}),raster:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_tl_parent:new e.Uniform2f(t,i.u_tl_parent),u_scale_parent:new e.Uniform1f(t,i.u_scale_parent),u_fade_t:new e.Uniform1f(t,i.u_fade_t),u_opacity:new e.Uniform1f(t,i.u_opacity),u_image0:new e.Uniform1i(t,i.u_image0),u_image1:new e.Uniform1i(t,i.u_image1),u_brightness_low:new e.Uniform1f(t,i.u_brightness_low),u_brightness_high:new e.Uniform1f(t,i.u_brightness_high),u_saturation_factor:new e.Uniform1f(t,i.u_saturation_factor),u_contrast_factor:new e.Uniform1f(t,i.u_contrast_factor),u_spin_weights:new e.Uniform3f(t,i.u_spin_weights),u_perspective_transform:new e.Uniform2f(t,i.u_perspective_transform)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_camera_forward:new e.Uniform3f(t,i.u_camera_forward),u_tile_matrix:new e.UniformMatrix4f(t,i.u_tile_matrix),u_up_vector:new e.Uniform3f(t,i.u_up_vector),u_ecef_origin:new e.Uniform3f(t,i.u_ecef_origin),u_texture:new e.Uniform1i(t,i.u_texture)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_texture:new e.Uniform1i(t,i.u_texture),u_gamma_scale:new e.Uniform1f(t,i.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_camera_forward:new e.Uniform3f(t,i.u_camera_forward),u_tile_matrix:new e.UniformMatrix4f(t,i.u_tile_matrix),u_up_vector:new e.Uniform3f(t,i.u_up_vector),u_ecef_origin:new e.Uniform3f(t,i.u_ecef_origin),u_is_halo:new e.Uniform1i(t,i.u_is_halo)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_texsize_icon:new e.Uniform2f(t,i.u_texsize_icon),u_texture:new e.Uniform1i(t,i.u_texture),u_texture_icon:new e.Uniform1i(t,i.u_texture_icon),u_gamma_scale:new e.Uniform1f(t,i.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_is_halo:new e.Uniform1i(t,i.u_is_halo)}),background:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_opacity:new e.Uniform1f(t,i.u_opacity),u_color:new e.UniformColor(t,i.u_color)}),backgroundPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_opacity:new e.Uniform1f(t,i.u_opacity),u_image:new e.Uniform1i(t,i.u_image),u_pattern_tl_a:new e.Uniform2f(t,i.u_pattern_tl_a),u_pattern_br_a:new e.Uniform2f(t,i.u_pattern_br_a),u_pattern_tl_b:new e.Uniform2f(t,i.u_pattern_tl_b),u_pattern_br_b:new e.Uniform2f(t,i.u_pattern_br_b),u_texsize:new e.Uniform2f(t,i.u_texsize),u_mix:new e.Uniform1f(t,i.u_mix),u_pattern_size_a:new e.Uniform2f(t,i.u_pattern_size_a),u_pattern_size_b:new e.Uniform2f(t,i.u_pattern_size_b),u_scale_a:new e.Uniform1f(t,i.u_scale_a),u_scale_b:new e.Uniform1f(t,i.u_scale_b),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.Uniform1f(t,i.u_tile_units_to_pixels)}),terrainRaster:mi,terrainDepth:mi,skybox:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_sun_direction:new e.Uniform3f(t,i.u_sun_direction),u_cubemap:new e.Uniform1i(t,i.u_cubemap),u_opacity:new e.Uniform1f(t,i.u_opacity),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset)}),skyboxGradient:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_color_ramp:new e.Uniform1i(t,i.u_color_ramp),u_center_direction:new e.Uniform3f(t,i.u_center_direction),u_radius:new e.Uniform1f(t,i.u_radius),u_opacity:new e.Uniform1f(t,i.u_opacity),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset)}),skyboxCapture:(t,i)=>({u_matrix_3f:new e.UniformMatrix3f(t,i.u_matrix_3f),u_sun_direction:new e.Uniform3f(t,i.u_sun_direction),u_sun_intensity:new e.Uniform1f(t,i.u_sun_intensity),u_color_tint_r:new e.Uniform4f(t,i.u_color_tint_r),u_color_tint_m:new e.Uniform4f(t,i.u_color_tint_m),u_luminance:new e.Uniform1f(t,i.u_luminance)}),globeRaster:(t,i)=>({u_proj_matrix:new e.UniformMatrix4f(t,i.u_proj_matrix),u_globe_matrix:new e.UniformMatrix4f(t,i.u_globe_matrix),u_normalize_matrix:new e.UniformMatrix4f(t,i.u_normalize_matrix),u_merc_matrix:new e.UniformMatrix4f(t,i.u_merc_matrix),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_image0:new e.Uniform1i(t,i.u_image0),u_grid_matrix:new e.UniformMatrix3f(t,i.u_grid_matrix),u_frustum_tl:new e.Uniform3f(t,i.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,i.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,i.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,i.u_frustum_bl),u_globe_pos:new e.Uniform3f(t,i.u_globe_pos),u_globe_radius:new e.Uniform1f(t,i.u_globe_radius),u_viewport:new e.Uniform2f(t,i.u_viewport)}),globeAtmosphere:(t,i)=>({u_frustum_tl:new e.Uniform3f(t,i.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,i.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,i.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,i.u_frustum_bl),u_horizon:new e.Uniform1f(t,i.u_horizon),u_transition:new e.Uniform1f(t,i.u_transition),u_fadeout_range:new e.Uniform1f(t,i.u_fadeout_range),u_color:new e.Uniform4f(t,i.u_color),u_high_color:new e.Uniform4f(t,i.u_high_color),u_space_color:new e.Uniform4f(t,i.u_space_color),u_star_intensity:new e.Uniform1f(t,i.u_star_intensity),u_star_density:new e.Uniform1f(t,i.u_star_density),u_star_size:new e.Uniform1f(t,i.u_star_size),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset),u_horizon_angle:new e.Uniform1f(t,i.u_horizon_angle),u_rotation_matrix:new e.UniformMatrix4f(t,i.u_rotation_matrix)})};let sn;function an(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=t.useProgram("collisionBox"),p=[];let d=0,f=0;for(let m=0;m<r.length;m++){const g=r[m],_=i.getTile(g),y=_.getBucket(n);if(!y)continue;const v=bt(g,y,u);let x=v;0===o[0]&&0===o[1]||(x=t.translatePosMatrix(v,_,o,s));const b=a?y.textCollisionBox:y.iconCollisionBox,w=y.collisionCircleArray;if(w.length>0){const t=e.create(),i=x;e.mul(t,y.placementInvProjMatrix,u.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),p.push({circleArray:w,circleOffset:f,transform:i,invTransform:t,projection:y.getProjection()}),d+=w.length/4,f=d}b&&(t.terrain&&t.terrain.setupElevationDraw(_,h),h.draw(l,c.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,ji(x,u,_,y.getProjection()),n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!a||!p.length)return;const m=t.useProgram("collisionCircle"),g=new e.StructArrayLayout2f1f2i16;g.resize(4*d),g._trim();let _=0;for(const e of p)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,n=e.circleArray[i+0],r=e.circleArray[i+1],o=e.circleArray[i+2],s=e.circleArray[i+3];g.emplace(_++,n,r,o,s,0),g.emplace(_++,n,r,o,s,1),g.emplace(_++,n,r,o,s,2),g.emplace(_++,n,r,o,s,3)}(!sn||sn.length<2*d)&&(sn=function(t){const i=2*t,n=new e.StructArrayLayout3ui6;n.resize(i),n._trim();for(let e=0;e<i;e++){const t=6*e;n.uint16[t+0]=4*e+0,n.uint16[t+1]=4*e+1,n.uint16[t+2]=4*e+2,n.uint16[t+3]=4*e+2,n.uint16[t+4]=4*e+3,n.uint16[t+5]=4*e+0}return n}(d));const y=l.createIndexBuffer(sn,!0),v=l.createVertexBuffer(g,e.collisionCircleLayout.members,!0);for(const i of p){const r={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(x=u).getCameraToCenterDistance(i.projection),u_viewport_size:[x.width,x.height]};m.draw(l,c.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,r,n.id,v,y,e.SegmentVector.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,u.zoom)}var x;v.destroy(),y.destroy()}const ln=e.create();function cn(t,i,n,r,o,s){const{horizontalAlign:a,verticalAlign:l}=e.getAnchorAlignment(t),c=-(a-.5)*i,u=-(l-.5)*n,h=e.evaluateVariableOffset(t,r);return new e.pointGeometry((c/o+h[0])*s,(u/o+h[1])*s)}function un(t,i,n,r,o,s,a,l,c,u,h){const p=t.text.placedSymbolArray,d=t.text.dynamicLayoutVertexArray,f=t.icon.dynamicLayoutVertexArray,m={},g=wt(l,t.getProjection(),s),_=s.elevation,y=t.getProjection().upVectorScale(l.canonical,s.center.lat,s.worldSize);d.clear();for(let f=0;f<p.length;f++){const v=p.get(f),x=t.allowVerticalPlacement&&!v.placedOrientation,b=v.hidden||!v.crossTileID||x?null:r[v.crossTileID];if(b){const r=new e.pointGeometry(v.tileAnchorX,v.tileAnchorY),p=t.getProjection().upVector(l.canonical,r.x,r.y),f=_?_.getAtTileOffset(l,r.x,r.y):0,x=ot([v.projectedAnchorX+f*p[0]*y.metersToTile,v.projectedAnchorY+f*p[1]*y.metersToTile,v.projectedAnchorZ+f*p[2]*y.metersToTile],n?g:a),w=st(s.getCameraToCenterDistance(t.getProjection()),x.signedDistanceFromCamera);let M=o.evaluateSizeForFeature(t.textSizeData,u,v)*w/e.ONE_EM;n&&(M*=t.tilePixelRatio/c);const{width:T,height:S,anchor:E,textOffset:A,textScale:C}=b,L=cn(E,T,S,A,C,M);let I;if(n){const e=r.add(L),{x:i,y:n,z:o}=t.getProjection().projectTilePoint(e.x,e.y,l.canonical);I=ot([i+f*p[0]*y.metersToTile,n+f*p[1]*y.metersToTile,o+f*p[2]*y.metersToTile],a).point}else{const e=i?L.rotate(-s.angle):L;I=[x.point[0]+e.x,x.point[1]+e.y,0]}const P=t.allowVerticalPlacement&&v.placedOrientation===e.WritingMode.vertical?Math.PI/2:0;for(let t=0;t<v.numGlyphs;t++)e.addDynamicAttributes(d,I[0],I[1],I[2],P);h&&v.associatedIconIndex>=0&&(m[v.associatedIconIndex]={shiftedAnchor:I,angle:P})}else gt(v.numGlyphs,d)}if(h){f.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const n=i.get(t);if(n.hidden)gt(n.numGlyphs,f);else{const i=m[t];if(i)for(let t=0;t<n.numGlyphs;t++)e.addDynamicAttributes(f,i.shiftedAnchor[0],i.shiftedAnchor[1],i.shiftedAnchor[2],i.angle);else gt(n.numGlyphs,f)}}t.icon.dynamicLayoutVertexBuffer.updateData(f)}t.text.dynamicLayoutVertexBuffer.updateData(d)}function hn(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function pn(t,i,n,r,o,s,a,l,c,u,h,p){const d=t.context,f=d.gl,m=t.transform,g="map"===l,_="map"===c,y=g&&"point"!==n.layout.get("symbol-placement"),v=g&&!_&&!y,x=void 0!==n.layout.get("symbol-sort-key").constantOr(1);let b=!1;const w=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),M=[e.mercatorXfromLng(m.center.lng),e.mercatorYfromLat(m.center.lat)],T=n.layout.get("text-variable-anchor"),S="globe"===m.projection.name,E=[],A=[0,-1,0];let C=A;!S&&!m.mercatorFromTransition||g||(C=function(t){const i=t._camera.getWorldToCamera(t.worldSize,1),n=e.multiply([],i,t.globeMatrix);e.invert(n,n);const r=[0,0,0],o=[0,1,0,0];return e.transformMat4$1(o,o,n),r[0]=o[0],r[1]=o[1],r[2]=o[2],e.normalize(r,r),r}(m));for(const l of r){const r=i.getTile(l),c=r.getBucket(n);if(!c)continue;if("mercator"===c.projection.name&&S)continue;const h=o?c.text:c.icon;if(!h||c.fullyClipped||!h.segments.get().length)continue;const p=h.programConfigurations.get(n.id),d=o||c.sdfIcons,w=o?c.textSizeData:c.iconSizeData,L=_||0!==m.pitch,I=e.evaluateSizeForZoom(w,m.zoom);let P,R,k,z,D=[0,0],O=null;if(o){if(R=r.glyphAtlasTexture,k=f.LINEAR,P=r.glyphAtlasTexture.size,c.iconsInText){D=r.imageAtlasTexture.size,O=r.imageAtlasTexture;const e="composite"===w.kind||"camera"===w.kind;z=L||t.options.rotating||t.options.zooming||e?f.LINEAR:f.NEAREST}}else{const e=1!==n.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;R=r.imageAtlasTexture,k=d||t.options.rotating||t.options.zooming||e||L?f.LINEAR:f.NEAREST,P=r.imageAtlasTexture.size}const F="globe"===c.projection.name,B=F?C:A,N=F?e.globeToMercatorTransition(m.zoom):0,U=wt(l,c.getProjection(),m),j=m.calculatePixelsToTileUnitsMatrix(r),V=tt(U,r.tileID.canonical,_,g,m,c.getProjection(),j),G=t.terrain&&_&&y?e.invert(e.create(),V):ln,H=nt(U,r.tileID.canonical,_,g,m,c.getProjection(),j),W=T&&c.hasTextData(),q="none"!==n.layout.get("icon-text-fit")&&W&&c.hasIconData();if(y){const e=m.elevation,i=e?e.getAtTileOffsetFunc(l,m.center.lat,m.worldSize,c.getProjection()):e=>[0,0,0],n=it(U,r.tileID.canonical,_,g,m,c.getProjection(),j);lt(c,U,t,o,n,H,_,u,i,l)}const $=y||o&&T||q,Z=t.translatePosMatrix(U,r,s,a),X=$?ln:V,Y=t.translatePosMatrix(H,r,s,a,!0),J=c.getProjection().createInversionMatrix(m,l.canonical),Q=[];t.terrain&&_&&Q.push("PITCH_WITH_MAP_TERRAIN"),F&&Q.push("PROJECTION_GLOBE_VIEW"),$&&Q.push("PROJECTED_POS_ON_VIEWPORT");const K=d&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let ee;ee=d?c.iconsInText?tn(w.kind,I,v,_,t,Z,X,Y,P,D,l,N,M,J,B,c.getProjection()):en(w.kind,I,v,_,t,Z,X,Y,o,P,!0,l,N,M,J,B,c.getProjection()):Ki(w.kind,I,v,_,t,Z,X,Y,o,P,l,N,M,J,B,c.getProjection());const te={program:t.useProgram(hn(d,o,c),p,Q),buffers:h,uniformValues:ee,atlasTexture:R,atlasTextureIcon:O,atlasInterpolation:k,atlasInterpolationIcon:z,isSDF:d,hasHalo:K,tile:r,labelPlaneMatrixInv:G};if(x&&c.canOverlap){b=!0;const t=h.segments.get();for(const i of t)E.push({segments:new e.SegmentVector([i]),sortKey:i.sortKey,state:te})}else E.push({segments:h.segments,sortKey:0,state:te})}b&&E.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of E){const i=e.state;if(t.terrain&&t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,dn(i.buffers,e.segments,n,t,i.program,w,h,p,r)),r.u_is_halo=0}dn(i.buffers,e.segments,n,t,i.program,w,h,p,i.uniformValues)}}function dn(t,i,n,r,o,s,a,l,c){const u=r.context;o.draw(u,u.gl.TRIANGLES,s,a,l,e.CullFaceMode.disabled,c,n.id,t.layoutVertexBuffer,t.indexBuffer,i,n.paint,r.transform.zoom,t.programConfigurations.get(n.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer)}function fn(t,i,n,r,o,s,a){const l=t.context.gl,c=n.paint.get("fill-pattern"),u=c&&c.constantOr(1),h=n.getCrossfadeParameters();let p,d,f,m,g;a?(d=u&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(d=u?"fillPattern":"fill",p=l.TRIANGLES);for(const _ of r){const r=i.getTile(_);if(u&&!r.patternsLoaded())continue;const y=r.getBucket(n);if(!y)continue;t.prepareDrawTile();const v=y.programConfigurations.get(n.id),x=t.useProgram(d,v);u&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers(h));const b=c.constantOr(null);if(b&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[b.to.toString()],i=e.patternPositions[b.from.toString()];t&&i&&v.setConstantPatternPositions(t,i)}const w=t.translatePosMatrix(_.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,g=y.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&u?Fi(w,t,h,r,e):Oi(w,e)}else m=y.indexBuffer,g=y.segments,f=u?Di(w,t,h,r):zi(w);t.prepareDrawProgram(t.context,x,_.toUnwrapped()),x.draw(t.context,p,o,t.stencilModeForClipping(_),s,e.CullFaceMode.disabled,f,n.id,y.layoutVertexBuffer,m,g,n.paint,t.transform.zoom,v)}}function mn(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=n.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=n.getCrossfadeParameters(),f=n.paint.get("fill-extrusion-opacity"),m="globe"===u.projection.name?e.fillExtrusionHeightLift():0,g="globe"===u.projection.name,_=g?e.globeToMercatorTransition(u.zoom):0,y=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)],v=[];g&&v.push("PROJECTION_GLOBE_VIEW");for(const x of r){const r=i.getTile(x),b=r.getBucket(n);if(!b||b.projection.name!==u.projection.name)continue;const w=b.programConfigurations.get(n.id),M=t.useProgram(p?"fillExtrusionPattern":"fillExtrusion",w,v);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(r,M,{useMeterToDem:!0});else{if(!b.enableTerrain)continue;if(e.setupElevationDraw(r,M,{useMeterToDem:!0}),gn(l,i,x,b,n,e),!b.centroidVertexBuffer){const e=M.attributes.a_centroid_pos;void 0!==e&&c.vertexAttrib2f(e,0,0)}}}p&&(t.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),w.updatePaintBuffers(d));const T=h.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[T.to.toString()],i=e.patternPositions[T.from.toString()];t&&i&&w.setConstantPatternPositions(t,i)}const S=t.translatePosMatrix(x.projMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),E=u.projection.createInversionMatrix(u,x.canonical),A=n.paint.get("fill-extrusion-vertical-gradient"),C=p?ki(S,t,A,f,x,d,r,m,_,y,E):Ri(S,t,A,f,x,m,_,y,E);t.prepareDrawProgram(l,M,x.toUnwrapped()),M.draw(l,l.gl.TRIANGLES,o,s,a,e.CullFaceMode.backCCW,C,n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,n.paint,t.transform.zoom,w,t.terrain?b.centroidVertexBuffer:null,g?b.layoutVertexExtBuffer:null)}}function gn(t,i,n,r,o,s){const a=[t=>{let i=t.canonical.x-1,n=t.wrap;return i<0&&(i=(1<<t.canonical.z)-1,n--),new e.OverscaledTileID(t.overscaledZ,n,t.canonical.z,i,t.canonical.y)},t=>{let i=t.canonical.x+1,n=t.wrap;return i===1<<t.canonical.z&&(i=0,n++),new e.OverscaledTileID(t.overscaledZ,n,t.canonical.z,i,t.canonical.y)},t=>new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)],l=e=>{const t=i.getSource().minzoom,n=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i<t)continue;const r=n(e.calculateScaledKey(e.overscaledZ+i));if(r)return r}},c=[0,0,0],u=(t,i)=>(c[0]=Math.min(t.min.y,i.min.y),c[1]=Math.max(t.max.y,i.max.y),c[2]=e.EXTENT-i.min.x>t.max.x?i.min.x-e.EXTENT:t.max.x,c),h=(t,i)=>(c[0]=Math.min(t.min.x,i.min.x),c[1]=Math.max(t.max.x,i.max.x),c[2]=e.EXTENT-i.min.y>t.max.y?i.min.y-e.EXTENT:t.max.y,c),p=[(e,t)=>u(e,t),(e,t)=>u(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],d=new e.pointGeometry(0,0);let f,m,g;const _=(t,i,r,o,a)=>{const l=[[o?r:t,o?t:r,0],[o?r:i,o?i:r,0]],c=a<0?e.EXTENT+a:a,u=[o?c:(t+i)/2,o?(t+i)/2:c,0];return 0===r&&a<0||0!==r&&a>0?s.getForTilePoints(g,[u],!0,m):l.push(u),s.getForTilePoints(n,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=(t<2?1:5)-t,o=r.borders[t];if(0===o.length)continue;const c=g=a[t](n),u=l(c);if(!(u&&u instanceof e.FillExtrusionBucket&&u.enableTerrain))continue;if(r.borderDoneWithNeighborZ[t]===u.canonical.z&&u.borderDoneWithNeighborZ[i]===r.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const e=s.findDEMTileFor(n);if(!e||!e.dem)return;f=e}const h=u.borders[i];let y=0;const v=u.borderDoneWithNeighborZ[i]!==r.canonical.z;if(r.canonical.z===u.canonical.z){for(let n=0;n<o.length;n++){const s=r.featuresOnBorder[o[n]],a=s.borders[t];let l;for(;y<h.length&&(l=u.featuresOnBorder[h[y]],!(l.borders[i][1]>a[0]+3));)v&&u.encodeCentroid(void 0,l,!1),y++;if(l&&y<h.length){const n=y;let o=0;for(;!(l.borders[i][0]>a[1]-3)&&(o++,++y!==h.length);)l=u.featuresOnBorder[h[y]];if(l=u.featuresOnBorder[h[n]],s.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=n),r.encodeCentroid(void 0,s,!1),v&&u.encodeCentroid(void 0,l,!1);continue}const c=p[t](s,l),f=t%2?e.EXTENT-1:0;d.x=_(c[0],Math.min(e.EXTENT-1,c[1]),f,t<2,c[2]),d.y=0,r.encodeCentroid(d,s,!1),v&&u.encodeCentroid(d,l,!1)}else r.encodeCentroid(void 0,s,!1)}r.borderDoneWithNeighborZ[t]=u.canonical.z,r.needsCentroidUpdate=!0,v&&(u.borderDoneWithNeighborZ[i]=r.canonical.z,u.needsCentroidUpdate=!0)}else{for(const e of o)r.encodeCentroid(void 0,r.featuresOnBorder[e],!1);if(v){for(const e of h)u.encodeCentroid(void 0,u.featuresOnBorder[e],!1);u.borderDoneWithNeighborZ[i]=r.canonical.z,u.needsCentroidUpdate=!0}r.borderDoneWithNeighborZ[t]=u.canonical.z,r.needsCentroidUpdate=!0}}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const _n=new e.Color(1,0,0,1),yn=new e.Color(0,1,0,1),vn=new e.Color(0,0,1,1),xn=new e.Color(1,0,1,1),bn=new e.Color(0,1,1,1);function wn(e,t,i,n){Tn(e,0,t+i/2,e.transform.width,i,n)}function Mn(e,t,i,n){Tn(e,t-i/2,0,i,e.transform.height,n)}function Tn(t,i,n,r,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.exported.devicePixelRatio,n*e.exported.devicePixelRatio,r*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function Sn(t,i,n){const r=t.context,o=r.gl,s="globe"===t.transform.projection.name,a=n.projMatrix,l=t.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),c=i.getTileByID(n.key);t.terrain&&t.terrain.setupElevationDraw(c,l);const u=e.DepthMode.disabled,h=e.StencilMode.disabled,p=t.colorModeForRenderPass(),d="$debug";r.activeTexture.set(o.TEXTURE0),t.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s?c._makeGlobeTileDebugBuffers(t.context,t.transform.projection):c._makeDebugTileBoundsBuffers(t.context,t.transform.projection);const f=c._tileDebugBuffer||t.debugBuffer,m=c._tileDebugIndexBuffer||t.debugIndexBuffer,g=c._tileDebugSegments||t.debugSegments;l.draw(r,o.LINE_STRIP,u,h,p,e.CullFaceMode.disabled,Vi(a,e.Color.red),d,f,m,g,null,null,null,c._globeTileDebugBorderBuffer);const _=c.latestRawTileData,y=Math.floor((_&&_.byteLength||0)/1024),v=i.getTile(n).tileSize,x=512/Math.min(v,512)*(n.overscaledZ/t.transform.zoom)*.5;let b=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(b+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,`${b} ${y}kb`);const w=c._tileDebugTextBuffer||t.debugBuffer,M=c._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,T=c._tileDebugTextSegments||t.debugSegments;l.draw(r,o.TRIANGLES,u,h,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Vi(a,e.Color.transparent,x),d,w,M,T,null,null,null,c._globeTileDebugTextBuffer)}const En=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:An}=En;function Cn(e,t,i,n){e.emplaceBack(t,i,n)}class Ln{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Cn(this.vertexArray,-1,-1,1),Cn(this.vertexArray,1,-1,1),Cn(this.vertexArray,-1,1,1),Cn(this.vertexArray,1,1,1),Cn(this.vertexArray,-1,-1,-1),Cn(this.vertexArray,1,-1,-1),Cn(this.vertexArray,-1,1,-1),Cn(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=t.createVertexBuffer(this.vertexArray,An),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function In(t,i,n,r,o,s){const a=t.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,n,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[n.r,n.g,n.b,n.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),r),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),n.draw(t,a.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Pn=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Rn{constructor(t){const i=new e.StructArrayLayout5f20;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const n=new e.StructArrayLayout3ui6;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Pn.members),this.indexBuffer=t.createIndexBuffer(n),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const kn={symbol:function(t,i,n,r,o){if("translucent"!==t.renderPass)return;const s=e.StencilMode.disabled,a=t.colorModeForRenderPass();n.layout.get("text-variable-anchor")&&function(t,i,n,r,o,s,a){const l=i.transform,c="map"===o,u="map"===s;for(const i of t){const t=r.getTile(i),o=t.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.evaluateSizeForZoom(o.textSizeData,l.zoom),h=wt(i,o.getProjection(),l),p=l.calculatePixelsToTileUnitsMatrix(t),d=tt(h,t.tileID.canonical,u,c,l,o.getProjection(),p),f="none"!==n.layout.get("icon-text-fit")&&o.hasIconData();if(s){const n=Math.pow(2,l.zoom-t.tileID.overscaledZ);un(o,c,u,a,e.symbolSize,l,d,i,n,s,f)}}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&pn(t,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),s,a),0!==n.paint.get("text-opacity").constantOr(1)&&pn(t,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(an(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),an(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("circle-opacity"),s=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=t.context,u=c.gl,h=t.transform,p=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),d=e.StencilMode.disabled,f=t.colorModeForRenderPass(),m="globe"===h.projection.name,g=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],_=[];for(let o=0;o<r.length;o++){const s=r[o],a=i.getTile(s),c=a.getBucket(n);if(!c||c.projection.name!==h.projection.name)continue;const u=c.programConfigurations.get(n.id),p=Ui(n);m&&p.push("PROJECTION_GLOBE_VIEW");const d=t.useProgram("circle",u,p),f=c.layoutVertexBuffer,y=c.globeExtVertexBuffer,v=c.indexBuffer,x=h.projection.createInversionMatrix(h,s.canonical),b={programConfiguration:u,program:d,layoutVertexBuffer:f,globeExtVertexBuffer:y,indexBuffer:v,uniformValues:Ni(t,s,a,x,g,n),tile:a};if(l){const t=c.segments.get();for(const i of t)_.push({segments:new e.SegmentVector([i]),sortKey:i.sortKey,state:b})}else _.push({segments:c.segments,sortKey:0,state:b})}l&&_.sort(((e,t)=>e.sortKey-t.sortKey));const y={useDepthForOcclusion:!m};for(const i of _){const{programConfiguration:r,program:o,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:g,tile:_}=i.state,v=i.segments;t.terrain&&t.terrain.setupElevationDraw(_,o,y),t.prepareDrawProgram(c,o,_.tileID.toUnwrapped()),o.draw(c,u.TRIANGLES,p,d,f,e.CullFaceMode.disabled,g,n.id,s,l,v,n.paint,h.zoom,r,m?a:null)}},heatmap:function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=e.StencilMode.disabled,l=new e.ColorMode([s.ONE,s.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,i,n){const r=e.gl,o=t.width*n,s=t.height*n;e.activeTexture.set(r.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=r.createTexture();r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!1),function(e,t,i,n,r,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,r,o,0,s.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),n.colorAttachment.set(i)}(e,0,t,a,o,s)}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,n,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.Color.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,p=u?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,d=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)];for(let f=0;f<r.length;f++){const m=r[f];if(i.hasRenderableParent(m))continue;const g=i.getTile(m),_=g.getBucket(n);if(!_||_.projection.name!==c.projection.name)continue;const y=_.programConfigurations.get(n.id),v=t.useProgram("heatmap",y,h),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(g,v),t.prepareDrawProgram(o,v,m.toUnwrapped());const b=c.projection.createInversionMatrix(c,m.canonical);v.draw(o,s.TRIANGLES,e.DepthMode.disabled,a,l,p,Hi(t,m,g,b,d,x,n.paint.get("heatmap-intensity")),n.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,n.paint,t.transform.zoom,y,u?_.globeExtVertexBuffer:null)}o.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){const n=t.context,r=n.gl,o=i.heatmapFbo;if(!o)return;n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),n.activeTexture.set(r.TEXTURE1);let s=i.colorRampTexture;s||(s=i.colorRampTexture=new e.Texture(n,i.colorRamp,r.RGBA)),s.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(n,r.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,((e,t,i,n)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,n))},line:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("line-opacity"),s=n.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),c=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,u=n.paint.get("line-dasharray"),h=u.constantOr(1),p=n.layout.get("line-cap"),d=n.paint.get("line-pattern"),f=d.constantOr(1),m=n.paint.get("line-gradient"),g=n.getCrossfadeParameters(),_=f?"linePattern":"line",y=t.context,v=y.gl,x=(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 n=e.paint.get("line-pattern").constantOr(1),r=1!==e.paint.get("line-opacity").constantOr(1);return!n&&r&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(n);let b=x.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const o of r){const r=i.getTile(o);if(f&&!r.patternsLoaded())continue;const s=r.getBucket(n);if(!s)continue;t.prepareDrawTile();const w=s.programConfigurations.get(n.id),M=t.useProgram(_,w,x),T=d.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[T.to.toString()],i=e.patternPositions[T.from.toString()];t&&i&&w.setConstantPatternPositions(t,i)}const S=u.constantOr(null),E=p.constantOr(null);if(!f&&S&&E&&r.lineAtlas){const e=r.lineAtlas,t=e.getDash(S.to,E),i=e.getDash(S.from,E);t&&i&&w.setConstantPatternPositions(t,i)}let[A,C]=n.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;A!==C&&(0===A&&(A-=e),1===C&&(C+=e))}const L=t.terrain?o.projMatrix:null,I=f?qi(t,r,n,g,L,c):Wi(t,r,n,g,L,s.lineClipsArray.length,c,[A,C]);if(m){const r=s.gradients[n.id];let a=r.texture;if(n.gradientVersion!==r.version){let l=256;if(n.stepInterpolant){const n=i.getSource().maxzoom,r=o.canonical.z===n?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;l=e.clamp(e.nextPowerOfTwo(s.maxLineLength/e.EXTENT*1024*r),256,y.maxTextureSize)}r.gradient=e.renderColorRamp({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:r.gradient||void 0,clips:s.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new e.Texture(y,r.gradient,v.RGBA),r.version=n.gradientVersion,a=r.texture}y.activeTexture.set(v.TEXTURE1),a.bind(n.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}h&&(y.activeTexture.set(v.TEXTURE0),r.lineAtlasTexture.bind(v.LINEAR,v.REPEAT),w.updatePaintBuffers(g)),f&&(y.activeTexture.set(v.TEXTURE0),r.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),w.updatePaintBuffers(g)),t.prepareDrawProgram(y,M,o.toUnwrapped());const P=i=>{M.draw(y,v.TRIANGLES,a,i,l,e.CullFaceMode.disabled,I,n.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,n.paint,t.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const i=t.stencilModeForClipping(o).ref;0===i&&t.terrain&&y.clear({stencil:0});const n={func:v.EQUAL,mask:255};I.u_alpha_discard_threshold=.8,P(new e.StencilMode(n,i,255,v.KEEP,v.KEEP,v.INVERT)),I.u_alpha_discard_threshold=0,P(new e.StencilMode(n,i,255,v.KEEP,v.KEEP,v.KEEP))}else P(t.stencilModeForClipping(o))}b&&(t.resetStencilClippingMasks(),t.terrain&&y.clear({stencil:0}))},fill:function(t,i,n,r){const o=n.paint.get("fill-color"),s=n.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=t.colorModeForRenderPass(),l=n.paint.get("fill-pattern"),c=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===c){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);fn(t,i,n,r,o,a,!1)}if("translucent"===t.renderPass&&n.paint.get("fill-antialias")){const o=t.depthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);fn(t,i,n,r,o,a,!0)}},"fill-extrusion":function(t,i,n,r){const o=n.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const s=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||n.paint.get("fill-extrusion-pattern").constantOr(1))mn(t,i,n,r,s,e.StencilMode.disabled,e.ColorMode.disabled),mn(t,i,n,r,s,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();mn(t,i,n,r,s,e.StencilMode.disabled,o)}}},hillshade:function(t,i,n,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),a=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[c,u]="translucent"!==t.renderPass||l?[{},r]:t.stencilConfigForOverlap(r);for(const r of u){const o=i.getTile(r);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)fi(t,o,n,s,e.StencilMode.disabled,a);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(r):c[r.overscaledZ];pi(t,r,o,n,s,e,a)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,i,n,r,o,s){if("translucent"!==t.renderPass)return;if(0===n.paint.get("raster-opacity"))return;if(!r.length)return;const a=t.context,l=a.gl,c=i.getSource(),u=t.useProgram("raster"),h=t.colorModeForRenderPass(),p=t.terrain&&t.terrain.renderingToTexture,[d,f]=c instanceof Ie||p?[{},r]:t.stencilConfigForOverlap(r),m=f[f.length-1].overscaledZ,g=!t.options.moving;for(const r of f){const o=p?e.DepthMode.disabled:t.depthModeForSublayer(r.overscaledZ-m,1===n.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),f=r.toUnwrapped(),_=i.getTile(r);if(p&&(!_||!_.hasData()))continue;const y=p?r.projMatrix:t.transform.calculateProjMatrix(f,g),v=t.terrain&&p?t.terrain.stencilModeForRTTOverlap(r):d[r.overscaledZ],x=s?0:n.paint.get("raster-fade-duration");_.registerFadeDuration(x);const b=i.findLoadedParent(r,0),w=Mi(_,b,i,t.transform,x);let M,T;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===n.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),_.texture.bind(S,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),M=Math.pow(2,b.tileID.overscaledZ-_.tileID.overscaledZ),T=[_.tileID.canonical.x*M%1,_.tileID.canonical.y*M%1]):_.texture.bind(S,l.CLAMP_TO_EDGE);const E=Yi(y,T||[0,0],M||1,w,n,c instanceof Ie?c.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(a,u,f),c instanceof Ie)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,o,e.StencilMode.disabled,h,e.CullFaceMode.disabled,E,n.id,c.boundsBuffer,t.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:r,tileBoundsSegments:s}=t.getTileBoundsBuffers(_);u.draw(a,l.TRIANGLES,o,v,h,e.CullFaceMode.disabled,E,n.id,i,r,s)}}t.resetStencilClippingMasks()},background:function(t,i,n,r){const o=n.paint.get("background-color"),s=n.paint.get("background-opacity");if(0===s)return;const a=t.context,l=a.gl,c=t.transform,u=c.tileSize,h=n.paint.get("background-pattern");if(t.isPatternMissing(h))return;const p=!h&&1===o.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==p)return;const d=e.StencilMode.disabled,f=t.depthModeForSublayer(0,"opaque"===p?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),g=t.useProgram(h?"backgroundPattern":"background");let _,y=r;y||(_=t.getBackgroundTiles(),y=Object.values(_).map((e=>e.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));const v=n.getCrossfadeParameters();for(const p of y){const y=p.toUnwrapped(),x=r?p.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile();const b=i?i.getTile(p):_?_[p.key]:new e.Tile(p,u,c.zoom,t),w=h?rn(x,s,t,h,{tileID:p,tileSize:u},v):nn(x,s,o);t.prepareDrawProgram(a,g,y);const{tileBoundsBuffer:M,tileBoundsIndexBuffer:T,tileBoundsSegments:S}=t.getTileBoundsBuffers(b);g.draw(a,l.TRIANGLES,f,d,m,e.CullFaceMode.disabled,w,n.id,M,T,S)}},sky:function(t,i,n){const r=t.transform,o="mercator"===r.projection.name||"globe"===r.projection.name?1:e.smoothstep(7,8,r.zoom),s=n.paint.get("sky-opacity")*o;if(0===s)return;const a=t.context,l=n.paint.get("sky-type"),c=new e.DepthMode(a.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),u=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?n.needsSkyboxCapture(t)&&(function(t,i,n,r){const o=t.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(32,32,!1),i.skyboxGeometry=new Ln(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.useProgram("skyboxCapture"),u=new Float64Array(16);e.identity(u),e.rotateY(u,u,.5*-Math.PI),In(o,i,c,u,l,0),e.identity(u),e.rotateY(u,u,.5*Math.PI),In(o,i,c,u,l,1),e.identity(u),e.rotateX(u,u,.5*-Math.PI),In(o,i,c,u,l,2),e.identity(u),e.rotateX(u,u,.5*Math.PI),In(o,i,c,u,l,3),e.identity(u),In(o,i,c,u,l,4),e.identity(u),e.rotateY(u,u,Math.PI),In(o,i,c,u,l,5),o.viewport.set([0,0,t.width,t.height])}(t,n),n.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,i,n,r,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const u=((e,t,i,n,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:n,u_temporal_offset:r}))(l.skyboxMatrix,i.getCenter(t,!1),0,r,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,n,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,u,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,c,s,u):"gradient"===l&&"sky"===t.renderPass&&function(t,i,n,r,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ln(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.Texture(s,i.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,n,r,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.degToRad(n),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,n,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,c,s,u)},debug:function(e,t,i){for(let n=0;n<i.length;n++)Sn(e,t,i[n])},custom:function(t,i,n){const r=t.context,o=n.implementation;if(t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes("custom"))e.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===t.renderPass){const e=o.prerender;e&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),e.call(o,r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(e.StencilMode.disabled);const i="3d"===o.renderingMode?new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,e.DepthMode.ReadOnly);r.setDepthMode(i),o.render(r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}}};class zn{constructor(t,i){this.context=new Ee(t),this.transform=i,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=e.SourceCache.maxUnderzooming+e.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Zt,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 Ai(this,e));const n=this._terrain;this.transform.elevation=i?n:null,n.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,n]=t.getFovAdjustedRange(this.transform._fov);if(i>n)return void(this.transform.fogCullDistSq=null);const r=i+.78*(n-i);this.transform.fogCullDistSq=r*r}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,i){if(this.width=t*e.exported.devicePixelRatio,this.height=i*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,i=new e.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(e.EXTENT,0),i.emplaceBack(0,e.EXTENT),i.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const n=new e.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(e.EXTENT,0),n.emplaceBack(0,e.EXTENT),n.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const r=new e.StructArrayLayout2i4;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const s=new e.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new Rn(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 t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,i.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,wi(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,i,n){if(!i||this.currentStencilSource===i.id||!t.isTileClipped()||!n||0===n.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of n)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=i.id;const r=this.context,o=r.gl;this.nextStencilID+n.length>256&&this.clearStencil(),r.setColorMode(e.ColorMode.disabled),r.setDepthMode(e.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of n){const n=i.getTile(t),a=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(n);s.draw(r,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},a,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,wi(t.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,i=this.context.gl;return new e.StencilMode({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const i=this.context.gl;return new e.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(t){const i=this.context.gl,n=t.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,o=n[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let n=0;n<o;n++)t[n+r]=new e.StencilMode({func:i.GEQUAL,mask:255},n+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=o,[t,n]}return[{[r]:e.StencilMode.disabled},n]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new e.ColorMode([t.CONSTANT_COLOR,t.ONE],new e.Color(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?e.ColorMode.unblended:e.ColorMode.alphaBlended}depthModeForSublayer(t,i,n){if(!this.opaquePassEnabledForLayer())return e.DepthMode.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new e.DepthMode(n||this.context.gl.LEQUAL,i,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.exported.now()),this.imageManager.beginFrame();const n=this.style.order,r=this.style._sourceCaches;for(const e in r){const t=r[e];t.used&&t.prepare(this.context)}const o={},s={},a={};for(const e in r){const t=r[e];o[e]=t.getVisibleCoordinates(),s[e]=o[e].slice().reverse(),a[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<n.length;e++)if(this.style._layers[n[e]].is3D()){this.opaquePassCutoff=e;break}if(this.terrain&&(this.terrain.updateTileBinding(a),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.GlobeSharedBuffers(this.context)),e.isMapAuthenticated(this.context.gl)){this.renderPass="offscreen";for(const e of n){const i=this.style._layers[e],n=t._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const r=n?s[n.id]:void 0;("custom"===i.type||i.isSky()||r&&r.length)&&this.renderLayer(this,n,i,r)}if(this.depthRangeFor3D=[0,1-(t.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:i.showOverdrawInspector?e.Color.black:e.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[n[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky())continue;const r=i?s[i.id]:void 0;this._renderTileClippingMasks(e,i,r),this.renderLayer(this,i,e,r)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,i){const n=t.context,r=n.gl,o=t.transform,s=new e.DepthMode(r.LEQUAL,e.DepthMode.ReadOnly,[0,1]),a=t.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=e.globeToMercatorTransition(o.zoom),c=i.properties.get("color").toArray01(),u=i.properties.get("high-color").toArray01(),h=i.properties.get("space-color").toArray01PremultipliedAlpha(),p=e.identity$1([]);e.rotateY$1(p,p,-e.degToRad(o._center.lng)),e.rotateX$1(p,p,e.degToRad(o._center.lat)),e.rotateZ$1(p,p,o.angle),e.rotateX$1(p,p,-o._pitch);const d=e.fromQuat(new Float32Array(16),p),f=e.mapValue(i.properties.get("star-intensity"),0,1,0,.25),m=5e-4,g=e.mapValue(i.properties.get("horizon-blend"),0,1,m,.25),_=e.globeUseCustomAntiAliasing(t,n,o)&&g===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(_,2)),b=Math.acos(x/v),w=((t,i,n,r,o,s,a,l,c,u,h,p,d,f)=>({u_frustum_tl:t,u_frustum_tr:i,u_frustum_br:n,u_frustum_bl:r,u_horizon:o,u_transition:s,u_fadeout_range:a,u_color:l,u_high_color:c,u_space_color:u,u_star_intensity:h,u_star_size:5*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,u_rotation_matrix:f}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,g,c,u,h,f,y,b,d);t.prepareDrawProgram(n,a);const M=t.atmosphereBuffer;M&&a.draw(n,r.TRIANGLES,s,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,w,"skybox",M.vertexBuffer,M.indexBuffer,M.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){const e=this.style._layers[n[this.currentLayer]],i=t._getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?s[i.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<n.length;){const e=this.style._layers[n[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const r=i?("symbol"===e.type?a:s)[i.id]:void 0;this._renderTileClippingMasks(e,i,i?o[i.id]:void 0),this.renderLayer(this,i,e,r),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let i=null;e.values(this.style._layers).forEach((e=>{const n=t._getLayerSourceCache(e);n&&!e.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom<n.getSource().maxzoom)&&(i=n)})),i&&this.options.showTileBoundaries&&kn.debug(this,i,i.getVisibleCoordinates())}this.options.showPadding&&function(e){const t=e.transform.padding;wn(e,e.transform.height-(t.top||0),3,_n),wn(e,t.bottom||0,3,yn),Mn(e,t.left||0,3,vn),Mn(e,e.transform.width-(t.right||0),3,xn);const i=e.transform.centerPoint;!function(e,t,i,n){Tn(e,t-1,i-10,2,20,n),Tn(e,t-10,i-1,20,2,n)}(e,i.x,e.transform.height-i.y,bn)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(e.window.performance.now()),this.saveCanvasCopy())}}renderLayer(e,t,i,n){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||n&&n.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)||kn[i.type](e,t,i,n,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 n=e[i],r=this.context.extTimerQuery,o=r.getQueryObjectEXT(n.query,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(n.query),t[i]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery;let i=0;for(const n of e)i+=t.getQueryObjectEXT(n,t.QUERY_RESULT_EXT)/1e6,t.deleteQueryEXT(n);return i}translatePosMatrix(t,i,n,r,o){if(!n[0]&&!n[1])return t;const s=o?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(s){const e=Math.sin(s),t=Math.cos(s);n=[n[0]*t-n[1]*e,n[0]*e+n[1]*t]}const a=[o?n[0]:k(i,n[0],this.transform.zoom),o?n[1]:k(i,n[1],this.transform.zoom),0],l=new Float32Array(16);return e.translate(l,t,a),l}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 n=i||[],r=this.currentGlobalDefines().concat(n),o=Li.cacheKey(e,r,t);return this.cache[o]||(this.cache[o]=new Li(this.context,e,li[e],t,on[e],r)),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=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.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(t,i,n){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const o=r.getOpacity(this.transform.pitch),s=((t,i,n,r,o,s,a,l,c,u,h)=>{const p=t.transform,d=i.properties.get("color").toArray01();d[3]=r;const f=t.frameCounter/1e3%1;return{u_fog_matrix:n?p.calculateFogTileMatrix(n):t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,r,n,o,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*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);i.setFogUniformValues(t,s)}}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 t=this._backgroundTiles,i=this._backgroundTiles={},n=this.transform.coveringTiles({tileSize:512});for(const r of n)i[r.key]=t[r.key]||new e.Tile(r,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}}class Dn{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.number(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.number(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.number(t.right,i.right,n)),this}getCenter(t,i){const n=e.clamp((this.left+t-this.right)/2,0,t),r=e.clamp((this.top+i-this.bottom)/2,0,i);return new e.pointGeometry(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Dn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function On(t,i){const n=e.getColumn(t,3);e.fromQuat(t,i),e.setColumn(t,3,n)}function Fn(t,i){const n=e.identity$1([]);return e.rotateZ$1(n,n,-i),e.rotateX$1(n,n,-t),n}function Bn(t,i){const n=[t[0],t[1],0],r=[i[0],i[1],0];if(e.length(n)>=1e-15){const t=e.normalize([],n);e.scale$2(r,t,e.dot(r,t)),i[0]=r[0],i[1]=r[1]}const o=e.cross([],i,t);if(e.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Fn(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class Nn{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.wrap(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const n=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,r=this.position,o=e.MercatorCoordinate.fromLngLat(t,n),s=[o.x-r.x,o.y-r.y,o.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Bn(s,i)}setPitchBearing(t,i){this.orientation=Fn(e.degToRad(t),e.degToRad(-i))}}class Un{constructor(t,i){this._transform=e.identity([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.setColumn(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&On(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=Fn(e,t),On(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const n=new Float64Array(16);return e.invert(n,this.getWorldToCamera(t,i)),n}getWorldToCameraPosition(t,i,n){const r=this.position;e.scale$2(r,r,-t);const o=new Float64Array(16);return e.fromScaling(o,[n,n,n]),e.translate(o,o,r),o[10]*=i,o}getWorldToCamera(t,i){const n=new Float64Array(16),r=new Float64Array(4),o=this.position;return e.conjugate(r,this._orientation),e.scale$2(o,o,-t),e.fromQuat(n,r),e.translate(n,n,o),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=i,n[9]*=i,n[10]*=i,n[11]*=i,n}getCameraToClipPerspective(t,i,n,r){const o=new Float64Array(16);return e.perspective(o,t,i,n,r),o}getDistanceToElevation(t){const i=0===t?0:e.mercatorZfromAltitude(t,this.position[1]),n=this.forward();return(i-this.position[2])/n[2]}clone(){return new Un([...this.position],[...this.orientation])}}function jn(t,i){const n=Gn(t.projection,t.zoom,t.width,t.height),r=function(t,i,n,r,o){const s=new e.LngLat(n.lng-180*Hn,n.lat),a=new e.LngLat(n.lng+180*Hn,n.lat),l=t.project(s.lng,s.lat),c=t.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=e.MercatorCoordinate.fromLngLat(n);h.y=e.clamp(h.y,-.999975,.999975);const p=h.toLngLat(),d=t.project(p.lng,p.lat),f=e.MercatorCoordinate.fromLngLat(p);f.x+=Hn;const m=f.toLngLat(),g=t.project(m.lng,m.lat),_=qn(g.x-d.x,g.y-d.y,u),y=e.MercatorCoordinate.fromLngLat(p);y.y+=Hn;const v=y.toLngLat(),x=t.project(v.lng,v.lat),b=qn(x.x-d.x,x.y-d.y,u),w=Math.abs(_.x)/Math.abs(b.y),M=e.identity([]);e.rotateZ(M,M,-u*(1-(o?0:r)));const T=e.identity([]);return e.scale(T,T,[1,1-(1-w)*r,1]),T[4]=-b.x/b.y*r,e.rotateZ(T,T,u),e.multiply(T,M,T),T}(t.projection,0,t.center,n,i),o=Vn(t);return e.scale(r,r,[o,o,1]),r}function Vn(t){const i=t.projection,n=Gn(t.projection,t.zoom,t.width,t.height),r=Wn(i,t.center),o=Wn(i,e.LngLat.convert(i.center));return Math.pow(2,r*n+(1-n)*o)}function Gn(t,i,n,r,o=1/0){const s=t.range;if(!s)return 0;const a=Math.min(o,Math.max(n,r)),l=Math.log(a/1024)/Math.LN2;return e.smoothstep(s[0]+l,s[1]+l,i)}const Hn=1/4e4;function Wn(t,i){const n=e.clamp(i.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),r=new e.LngLat(i.lng-180*Hn,n),o=new e.LngLat(i.lng+180*Hn,n),s=t.project(r.lng,n),a=t.project(o.lng,n),l=e.MercatorCoordinate.fromLngLat(r),c=e.MercatorCoordinate.fromLngLat(o),u=a.x-s.x,h=a.y-s.y,p=c.x-l.x,d=c.y-l.y,f=Math.sqrt((p*p+d*d)/(u*u+h*h));return Math.log(f)/Math.LN2}function qn(e,t,i){const n=Math.cos(i),r=Math.sin(i);return{x:e*n-t*r,y:e*r+t*n}}class $n{constructor(t,i,n,r,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==n?0:n,this._maxPitch=null==r?60:r,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.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 Dn,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Un,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 $n(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 e.pick(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const n=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const r=!t(n,this.getProjection());return r&&this._calcMatrices(),r}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 e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.pointGeometry(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;var n;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(n=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n),function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+o*a,e[1]=r*l+s*a,e[2]=n*-a+o*l,e[3]=r*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,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]],n=this.horizonLineFromTop();let r=0,o=0;for(let s=0;s<i.length;s++){const a=new e.pointGeometry(i[s][0]*this.width,n+i[s][1]*(this.height-n)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);r+=l[3]*c,o+=c}return 0===o?NaN:r/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,n=this._mercatorZfromZoom(e),r=this._mercatorZfromZoom(this._maxZoom),o=Math.max(n-i,r);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(t){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let n;n=t.z<this._camera.position[2]?[i.x,i.y,i.z]:[t.x,t.y,t.z];const r=e.length(e.sub([],this._camera.position,n));return e.clamp(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let i=!1;if(t.orientation&&!e.exactEquals(t.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(t.orientation)),t.position){const n=[t.position.x,t.position.y,t.position.z];e.exactEquals$1(n,this._camera.position)||(this._setCameraPosition(n),i=!0)}i&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,i=new Nn;return i.position=new e.MercatorCoordinate(t[0],t[1],t[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(t){if(!e.length$1(t))return!1;e.normalize$1(t,t);const i=e.transformQuat([],[0,0,-1],t),n=e.transformQuat([],[0,-1,0],t);if(n[2]<0)return!1;const r=Bn(i,n);return!!r&&(this._camera.orientation=r,!0)}_setCameraPosition(t){const i=this.zoomScale(this.minZoom)*this.tileSize,n=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;t[2]=e.clamp(t[2],r/n,r/i),this._camera.position=t}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 e.UnwrappedTileID(0,t)];if(this.renderWorldCopies){const n=this.pointCoordinate(new e.pointGeometry(0,0)),r=this.pointCoordinate(new e.pointGeometry(this.width,0)),o=this.pointCoordinate(new e.pointGeometry(this.width,this.height)),s=this.pointCoordinate(new e.pointGeometry(0,this.height)),a=Math.floor(Math.min(n.x,r.x,o.x,s.x)),l=Math.floor(Math.max(n.x,r.x,o.x,s.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new e.UnwrappedTileID(n,t))}return i}coveringTiles(t){let i=this.coveringZoomLevel(t);const n=i,r=this.elevation&&!t.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==t.minzoom&&i<t.minzoom)return[];void 0!==t.maxzoom&&i>t.maxzoom&&(i=t.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<<i,c=[l*s.x,l*s.y,0],u="globe"===this.projection.name,h=!u,p=e.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,h),d=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=l*e.mercatorZfromAltitude(1,this.center.lat),m=this._camera.position[2]/e.mercatorZfromAltitude(1,this.center.lat),g=[l*d.x,l*d.y,m*(h?1:f)],_=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?i:0,v=t.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,x=t.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?Vn(this):1,w=t=>{const i=1/4e4,n=new e.MercatorCoordinate(t.x+i,t.y,t.z),r=new e.MercatorCoordinate(t.x,t.y+i,t.z),o=t.toLngLat(),s=n.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),p=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*p)*b/i},M=t=>{const i=v,n=x;return{aabb:e.tileAABB(this,l,0,0,0,t,n,i,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:i,wrap:t,fullyVisible:!1}},T=[];let S=[];const E=i,A=t.reparseOverscaled?n:i,C=e=>e*e,L=C((m-this._centerAltitude)*f),I=e=>{if(!this._elevation||!e.tileID||!o)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=P(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},P=t=>{if(t.zoom<y)return!0;if(t.zoom===E)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const i=t.aabb.distanceX(g),o=t.aabb.distanceY(g);let s=L,l=1;if(u){s=C(t.aabb.distanceZ(g));const i=Math.pow(2,t.zoom),n=e.latFromMercatorY((t.y+1)/i),r=e.latFromMercatorY(t.y/i),o=Math.min(Math.max(a,n),r),c=e.circumferenceAtLatitude(o)/e.circumferenceAtLatitude(a);if(l=o===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,c/this._mercatorScaleRatio),this.zoom<=e.GLOBE_ZOOM_THRESHOLD_MIN&&t.zoom===E-1&&c>=.9)return!0}else if(r&&(s=C(t.aabb.distanceZ(g)*f)),this.projection.isReprojectedInTileSpace&&n<=5){const i=Math.pow(2,t.zoom),n=w(new e.MercatorCoordinate((t.x+.5)/i,(t.y+.5)/i));l=n>.85?1:n}const c=i*i+o*o+s;return c<C((1<<E-t.zoom)*_*l*((e,t)=>{if(t*C(.707)<e)return 1;const i=Math.sqrt(t/e);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,L),c))};if(this.renderWorldCopies)for(let e=1;e<=3;e++)T.push(M(-e)),T.push(M(e));for(T.push(M(0));T.length>0;){const n=T.pop(),s=n.x,a=n.y;let h=n.fullyVisible;if(!h){const e=n.aabb.intersects(p);if(0===e)continue;h=2===e}if(n.zoom!==E&&P(n))for(let t=0;t<4;t++){const i=(s<<1)+t%2,c=(a<<1)+(t>>1),p={aabb:o?n.aabb.quadrant(t):e.tileAABB(this,l,n.zoom+1,i,c,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:i,y:c,wrap:n.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};r&&!u&&(p.tileID=new e.OverscaledTileID(n.zoom+1===E?A:n.zoom+1,n.wrap,n.zoom+1,i,c),I(p)),T.push(p)}else{const r=n.zoom===E?A:n.zoom;if(t.minzoom&&t.minzoom>r)continue;const o=c[0]-(.5+s+(n.wrap<<n.zoom))*(1<<i-n.zoom),l=c[1]-.5-a,u=n.tileID?n.tileID:new e.OverscaledTileID(r,n.wrap,n.zoom,s,a);S.push({tileID:u,distanceSq:o*o+l*l})}}if(this.fogCullDistSq){const i=this.fogCullDistSq,n=this.horizonLineFromTop();S=S.filter((r=>{const o=[0,0,0,1],s=[e.EXTENT,e.EXTENT,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.transformMat4$1(o,o,a),e.transformMat4$1(s,s,a);const l=e.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>i&&0!==n){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=u.getMinMaxForTile(r.tileID)),o||(o={min:x,max:v});const s=e.furthestTileCorner(this.rotation),a=[s[0]*e.EXTENT,s[1]*e.EXTENT,o.max];e.transformMat4(a,a,i),c=(1-a[1])*this.height*.5<n}return l<i||c}))}return S.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(t){const i=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),n=this.projection.project(t.lng,i);return new e.pointGeometry(n.x*this.worldSize,n.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(t,i){let n,r;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(i.x-o.x)/e,r=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);n=e.x-t.x,r=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(s.x-n,s.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(t,i){const n=i?e.mercatorZfromAltitude(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const n=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(r,r,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const s=o[3];e.scale$1(r,r,1/r[3]),e.scale$1(o,o,1/s);const a=r[2],l=o[2];return{p0:r,p1:o,t:a===l?0:(n-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],n=[t.x,t.y,1,1];return e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(n,n,this.pixelMatrixInverse),e.scale$1(i,i,1/i[3]),e.scale$1(n,n,1/n[3]),i[2]=e.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,n[2]=e.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,e.scale$1(i,i,1/this.worldSize),e.scale$1(n,n,1/this.worldSize),new e.Ray([i[0],i[1],i[2]],e.normalize([],e.sub([],n,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:n,t:r}=t,o=e.mercatorZfromAltitude(i[2],this._center.lat),s=e.mercatorZfromAltitude(n[2],this._center.lat);return new e.MercatorCoordinate(e.number(i[0],n[0],r)/this.worldSize,e.number(i[1],n[1],r)/this.worldSize,e.number(o,s,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 e.MercatorCoordinate(i[0],i[1],i[2]);let n=0,r=this.horizonLineFromTop();if(t.y>r)return this.pointCoordinate(t);const o=.02*r,s=t.clone();for(let t=0;t<10&&r-n>o;t++){s.y=e.number(n,r,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(r=s.y,i=t):n=s.y}return i?new e.MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(t,i){const n=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,n+t.toAltitude(),1];return e.transformMat4$1(r,r,this.pixelMatrix),r[3]>0?new e.pointGeometry(r[0]/r[3],r[1]/r[3]):new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(t,i){const n=new e.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),r=new e.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new e.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new e.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(n,t),l=this.pointCoordinate(r,t);const c=this.pointCoordinate(o,i),u=this.pointCoordinate(s,i),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return a.y>1&&l.y>=0?a=new e.MercatorCoordinate((1-u.y)/h(u,a)+u.x,1):a.y<0&&l.y<=1&&(a=new e.MercatorCoordinate(-u.y/h(u,a)+u.x,0)),l.y>1&&a.y>=0?l=new e.MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new e.MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_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(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=e.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=e.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=e.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const i=t.key,n=this._distanceTileDataCache;if(n[i])return n[i];const r=t.canonical,o=1/this.height,s=this.cameraWorldSize/this.zoomScale(r.z),a=(r.x+Math.pow(2,r.z)*t.wrap)*s,l=r.y*s,c=this.point,u=this.angle,h=Math.sin(-u),p=-Math.cos(-u);return n[i]={bearing:[h,p],center:[(c.x-a)*o,(c.y-l)*o],scale:s/e.EXTENT*o},n[i]}calculateFogTileMatrix(t){const i=t.key,n=this._fogTileMatrixCache;if(n[i])return n[i];const r=this.projection.createTileMatrix(this,this.cameraWorldSize,t);return e.multiply(r,this.worldToFogMatrix,r),n[i]=new Float32Array(r),n[i]}calculateProjMatrix(t,i=!1){const n=t.key,r=i?this._alignedProjMatrixCache:this._projMatrixCache;if(r[n])return r[n];const o=this.calculatePosMatrix(t,this.worldSize);return e.multiply(o,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.alignedProjMatrix:this.projMatrix,o),r[n]=new Float32Array(o),r[n]}calculatePixelsToTileUnitsMatrix(t){const i=t.tileID.key,n=this._pixelsToTileUnitsCache;if(n[i])return n[i];const r=function(t,i){const{scale:n}=t.tileTransform,r=n*e.EXTENT/(t.tileSize*Math.pow(2,i.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return o=new Float32Array(4),l=(s=i.inverseAdjustmentMatrix)[1],c=s[2],u=s[3],p=(a=[r,r])[1],o[0]=s[0]*(h=a[0]),o[1]=l*h,o[2]=c*p,o[3]=u*p,o;var o,s,a,l,c,u,h,p}(t,this);return n[i]=r,n[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const i=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),r=this._camera.forward(),o=e.mercatorZfromAltitude(1,this._center.lat);n[2]/=o,r[2]/=o,e.normalize(r,r);const s=t.raycast(n,r,t.exaggeration());if(s){const t=e.scaleAndAdd([],n,r,s),i=new e.MercatorCoordinate(t[0],t[1],e.mercatorZfromAltitude(t[2],e.latFromMercatorY(t[1]))),a=(i.z+e.length([i.x-n[0],i.y-n[1],i.z-n[2]*o]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const i=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),r=t.getAtPointOrZero(new e.MercatorCoordinate(...n)),o=this._minimumHeightOverTerrain()*Math.cos(e.degToRad(this._maxPitch)),s=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*r;if(s<o){const t=this.locationCoordinate(this._center,this._centerAltitude),i=[t.x-n[0],t.y-n[1],t.z-n[2]],r=e.length(i);i[2]-=(o-s)/this._projectionScaler;const a=e.length(i);if(0===a)return;e.scale$2(i,i,r/a*this._projectionScaler),this._camera.position=[t.x-i[0],t.y-i[1],t.z*this._projectionScaler-i[2]],this._camera.orientation=Bn(i,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const t=this.center;return t.lat=e.clamp(t.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(t.lng=e.clamp(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:i,y:n}=this.point;let r=0,o=i,s=n;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,u=this.worldMaxY*this.scale;if(n-l<c&&(s=c+l),n+l>u&&(s=u-l),u-c<this.height&&(r=Math.max(r,this.height/(u-c)),s=(u+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,n=this.worldSize/2-(e+t)/2;o=(i+n+this.worldSize)%this.worldSize-n,o-a<e&&(o=e+a),o+a>t&&(o=t-a),t-e<this.width&&(r=Math.max(r,this.width/(t-e)),o=(t+e)/2)}o===i&&s===n||(this.center=this.unproject(new e.pointGeometry(o,s))),r&&(this.zoom+=this.scaleZoom(r)),this._constrainCameraAltitude(),this._unmodified=t,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 t=this.centerOffset,i=this.pixelsPerMeter;if("globe"===this.projection.name){const t=e.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,i=e.mercatorZfromAltitude(1,e.GLOBE_SCALE_MATCH_LATITUDE)*this.worldSize;this._mercatorScaleRatio=t/i}const n=Gn(this.projection,this.zoom,this.width,this.height,1024);this._projectionScaler=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,n),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?i:1),o=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);o[8]=2*-t.x/this.width,o[9]=2*t.y/this.height;let s=e.mul([],o,r);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.identity([]);e.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.multiply(i,i,jn(this)),e.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.multiply(s,s,i),this.inverseAdjustmentMatrix=function(e){const t=jn(e,!0);return y([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=e.scale([],s,[this.worldSize,this.worldSize,this.worldSize/i,1]),this.projMatrix=s,this.invProjMatrix=e.invert(new Float64Array(16),this.projMatrix);const a=e.invert([],o);this.frustumCorners=e.FrustumCorners.fromInvProjectionMatrix(a,this.horizonLineFromTop(),this.height);const l=new Float32Array(16);e.identity(l),e.scale(l,l,[1,-1,1]),e.rotateX(l,l,this._pitch),e.rotateZ(l,l,this.angle);const c=e.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),u=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;c[8]=2*-t.x/this.width,c[9]=2*(t.y+u)/this.height,this.skyboxMatrix=e.multiply(l,c,l);const h=this.point,p=h.x,d=h.y,f=this.width%2/2,m=this.height%2/2,g=Math.cos(this.angle),_=Math.sin(this.angle),v=p-Math.round(p)+g*f+_*m,x=d-Math.round(d)+g*m+_*f,b=new Float64Array(s);if(e.translate(b,b,[v>.5?v-1:v,x>.5?x-1:x,0]),this.alignedProjMatrix=b,s=e.create(),e.scale(s,s,[this.width/2,-this.height/2,1]),e.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=e.create(),e.scale(s,s,[1,-1,1]),e.translate(s,s,[-1,-1,0]),e.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=e.invert(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=s,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,r),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSize,i=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._projectionScaler,o=[t,t,i];e.scale$2(o,o,r),e.scale$2(n,n,-1),e.multiply$2(n,n,o);const s=e.create();e.translate(s,s,n),e.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),n=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[n.x/this.worldSize-i[0]*r,n.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=t[2];let r=1;n>0&&(r=Math.min((i-this._camera.position[2])/n,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,r),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(n),s),l=this._zoomFromMercatorZ(a);e.scaleAndAdd(t,t,i,a),this._pitch=e.clamp(n,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(r,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[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&&(e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,i){const n=Math.min(t.x,i.x),r=Math.max(t.x,i.x),o=Math.min(t.y,i.y),s=Math.max(t.y,i.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new e.pointGeometry(n,o),new e.pointGeometry(r,s),new e.pointGeometry(n,s),new e.pointGeometry(r,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.pointGeometry(0,0),new e.pointGeometry(this.width,this.height))}zoomDeltaToMovement(t,i){const n=e.length(e.sub([],this._camera.position,t)),r=this._zoomFromMercatorZ(n)+i;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function(t,i){const n=[t[0],t[1],t[2],1];e.transformMat4$1(n,n,i);const r=Math.max(n[3],1e-6);return[n[0]/r,n[1]/r,n[2]/r,r]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.pointGeometry(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.pointGeometry(0,t))}}getCameraToCenterDistance(e){const t=Gn(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 Zn(e,t){let i=!1,n=null;const r=()=>{n=null,i&&(e(),n=setTimeout(r,t),i=!1)};return()=>(i=!0,n||r(),n)}class Xn{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Zn(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(t){const i=this._map;if(!i)return"";const n=i.getCenter(),r=Math.round(100*i.getZoom())/100,o=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,o),a=Math.round(n.lng*s)/s,l=Math.round(n.lat*s)/s,c=i.getBearing(),u=i.getPitch();let h="";if(h+=t?`/${a}/${l}/${r}`:`${r}/${l}/${a}`,(c||u)&&(h+="/"+Math.round(10*c)/10),u&&(h+=`/${Math.round(u)}`),this._hashName){const t=this._hashName;let i=!1;const n=e.window.location.hash.slice(1).split("&").map((e=>{const n=e.split("=")[0];return n===t?(i=!0,`${n}=${h}`):e})).filter((e=>e));return i||n.push(`${t}=${h}`),`#${n.join("&")}`}return`#${h}`}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((e=>e.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.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 t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}const Yn={linearity:.3,easing:e.bezier(0,0,.3,1)},Jn=e.extend({deceleration:2500,maxSpeed:1400},Yn),Qn=e.extend({deceleration:20,maxSpeed:1400},Yn),Kn=e.extend({deceleration:1e3,maxSpeed:360},Yn),er=e.extend({deceleration:1e3,maxSpeed:90},Yn);class tr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.exported.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=nr(i.pan.mag(),n,e.extend({},Jn,t||{}));r.offset=i.pan.mult(o.amount/i.pan.mag()),r.center=this._map.transform.center,ir(r,o)}if(i.zoom){const e=nr(i.zoom,n,Qn);r.zoom=this._map.transform.zoom+e.amount,ir(r,e)}if(i.bearing){const t=nr(i.bearing,n,Kn);r.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),ir(r,t)}if(i.pitch){const e=nr(i.pitch,n,er);r.pitch=this._map.transform.pitch+e.amount,ir(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function ir(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function nr(t,i,n){const{maxSpeed:r,linearity:o,deceleration:s}=n,a=e.clamp(t*o/(i/1e3),-r,r),l=Math.abs(a)/(s*o);return{easing:n.easing,duration:1e3*l,amount:a*(l/2)}}class rr extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n,r={}){const o=f(i.getCanvasContainer(),n),s=i.unproject(o);super(t,e.extend({point:o,lngLat:s,originalEvent:n},r)),this._defaultPrevented=!1,this.target=i}}class or extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n){const r="touchend"===t?n.changedTouches:n.touches,o=m(i.getCanvasContainer(),r),s=o.map((e=>i.unproject(e))),a=o.reduce(((e,t,i,n)=>e.add(t.div(n.length))),new e.pointGeometry(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class sr extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class ar{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new sr(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new rr(e.type,this._map,e))}mouseup(e){this._map.fire(new rr(e.type,this._map,e))}preclick(t){const i=e.extend({},t);i.type="preclick",this._map.fire(new rr(i.type,this._map,i))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new rr(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new rr(e.type,this._map,e))}mouseover(e){this._map.fire(new rr(e.type,this._map,e))}mouseout(e){this._map.fire(new rr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new or(e.type,this._map,e))}touchmove(e){this._map.fire(new or(e.type,this._map,e))}touchend(e){this._map.fire(new or(e.type,this._map,e))}touchcancel(e){this._map.fire(new or(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new rr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new rr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new rr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cr{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&&(u(),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 n=this._startPos;this._lastPos=i,this._box||(this._box=o("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const r=Math.min(n.x,i.x),s=Math.max(n.x,i.x),a=Math.min(n.y,i.y),l=Math.max(n.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${r}px,${a}px)`,this._box.style.width=s-r+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(t,i){if(!this._active)return;if(0!==t.button)return;const n=this._startPos,r=i;if(this.reset(),d(),n.x!==r.x||n.y!==r.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}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),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.Event(t,{originalEvent:i}))}}function ur(e,t){const i={};for(let n=0;n<e.length;n++)i[e[n].identifier]=t[n];return i}class hr{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,i,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){const i=new e.pointGeometry(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=ur(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=ur(i,t);for(const e in this.touches){const t=this.touches[e],i=n[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 pr{constructor(e){this.singleTap=new hr(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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class dr{constructor(){this._zoomIn=new pr({numTouches:1,numTaps:2}),this._zoomOut=new pr({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(e,t,i){const n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const fr={0:1,2:2};class mr{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=g(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=fr[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&&g(e)===this._eventButton&&(this._moved&&d(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class gr extends mr{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 _r extends mr{_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 yr extends mr{_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 vr{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),e.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.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(t,i,n){n.length>0&&(this._active=!0);const r=ur(n,i),o=new e.pointGeometry(0,0),s=new e.pointGeometry(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}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=o("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 xr{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 n=this._firstTwoTouches;if(!n)return;e.preventDefault();const[r,o]=n,s=br(i,t,r),a=br(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[n,r]=this._firstTwoTouches,o=br(i,t,n),s=br(i,t,r);o&&s||(this._active&&d(),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 br(e,t,i){for(let n=0;n<e.length;n++)if(e[n].identifier===i)return t[n]}function wr(e,t){return Math.log(e/t)/Math.LN2}class Mr extends xr{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(wr(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:wr(this._distance,i),pinchAround:t}}}function Tr(e,t){return 180*e.angleWith(t)/Math.PI}class Sr extends xr{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:Tr(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=Tr(e,this._startVector);return Math.abs(i)<t}}function Er(e){return Math.abs(e.y)>Math.abs(e.x)}class Ar extends xr{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,Er(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){const n=this._lastPoints;if(!n)return;const r=e[0].sub(n[0]),o=e[1].sub(n[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Er(e)&&Er(t)&&o}}const Cr={panStep:100,bearingStep:15,pitchStep:10};class Lr{constructor(){const e=Cr;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=0,r=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Ir,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}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 Ir(e){return e*(2-e)}const Pr=4.000244140625;class Rr{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.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(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=e.exported.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==i&&i%Pr==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.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=f(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 e="wheel"===this._type&&Math.abs(this._delta)>Pr?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==n&&(n=1/n);const r=i(),o=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*n))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&r&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.number(r,n,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=n,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.ease;if(this._prevEase){const t=this._prevEase,n=(e.exported.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.bezier(o,s,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(e.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!!e.window.document.fullscreenElement||!!e.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 kr{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 zr{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dr{constructor(){this._tap=new pr({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 n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/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 Or{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 Fr{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 Br{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,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 Nr=e=>e.zoom||e.drag||e.pitch||e.rotate;class Ur extends e.Event{}class jr{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const n=e.sub([],i,t);this.radius=e.length(n[2]<0?e.div([],n,this.constants):[n[0],n[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const i=e.scale$2([],t,this.radius);if(i[2]>0){const t=e.scale$2([],[0,0,1],e.dot(i,[0,0,1])),n=e.scale$2([],e.normalize([],[i[0],i[1],0]),this.radius),r=e.add([],i,e.scale$2([],e.sub([],e.add([],n,t),i),2));i[0]=r[0],i[1]=r[1]}return i}}function Vr(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Gr{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new tr(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new jr,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.bindAll(["handleEvent","handleWindowEvent"],this);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[e.window.document,"mousemove",{capture:!0}],[e.window.document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[e.window,"blur",void 0]];for(const[t,i,n]of this._listeners)t.addEventListener(i,t===e.window.document?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(const[t,i,n]of this._listeners)t.removeEventListener(i,t===e.window.document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new ar(t,e));const n=t.boxZoom=new cr(t,e);this._add("boxZoom",n);const r=new dr,o=new zr;t.doubleClickZoom=new kr(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const s=new Dr;this._add("tapDragZoom",s);const a=t.touchPitch=new Ar(t);this._add("touchPitch",a);const l=new _r(e),c=new yr(e);t.dragRotate=new Fr(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new gr(e),h=new vr(t,e);t.dragPan=new Or(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new Sr,d=new Mr;t.touchZoomRotate=new Br(i,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new lr(t));const f=t.scrollZoom=new Rr(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new Lr;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!!Nr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<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(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,n=i?void 0:e,r={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?m(this._el,a):i?void 0:f(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(r,o,h,i,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=n);this._previousActiveHandlers=s,(Object.keys(c).length||Vr(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Vr(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(t,i,n,r,o){if(!n)return;e.extend(t,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.pointGeometry(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),e.extend(i,o),e.extend(n,s);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,i,n){const r=this._map,o=r.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Vr(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(!Vr(t))return void this._fireEvents(i,n,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:p,pinchAround:d}=t;void 0!==d&&(h=d),(e=>i.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a){const t=o.pointCoordinate(h);if("globe"===o.projection.name){const i=e.latFromMercatorY(t.y),n=o.center.lat,r=Math.min(e.mercatorZfromAltitude(1,i)/e.mercatorZfromAltitude(1,n),2);a=a.rotate(-o.angle),f[0]=-a.x/o.worldSize*r,f[1]=-a.y/o.worldSize*r}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=s(p||o.pointCoordinate3D(h)),i={dir:e.normalize([],e.sub([],t,o._camera.position))};if(i.dir[2]<0){const n=o.zoomDeltaToMovement(t,l);e.scale$2(g,i.dir,n)}}const _=e.add(f,f,g);o._translateCameraConstrained(_),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,n,!0)}_fireEvents(t,i,n){const r=Nr(this._eventsInProgress),o=Nr(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||n,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Nr(this._eventsInProgress);if(n&&(r||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.Event("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.Event(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new Ur("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Hr="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Wr extends e.Evented{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,n){return t=e.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},i),n)}panTo(t,i,n){return this.easeTo(e.extend({center:t},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,n){return this.easeTo(e.extend({zoom:t},i),n)}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(t,i,n){return this.easeTo(e.extend({bearing:t},i),n)}resetNorth(t,i){return this.rotateTo(0,e.extend({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),i),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(t,i){"globe"===this.transform.projection.name&&e.warnOnce('Globe projection does not support cameraForBounds API, this API may behave unexpectedly."'),t=e.LngLatBounds.convert(t);const n=i&&i.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),n,i)}_extendCameraOptions(t){const i={top:0,bottom:0,right:0,left:0};if("number"==typeof(t=e.extend({padding:i,offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding){const e=t.padding;t.padding={top:e,bottom:e,right:e,left:e}}return t.padding=e.extend(i,t.padding),t}_cameraForBoxAndBearing(t,i,n,r){const o=this._extendCameraOptions(r),s=this.transform,a=s.padding,l=s.project(e.LngLat.convert(t)),c=s.project(e.LngLat.convert(i)),u=new e.pointGeometry(l.x,c.y),h=new e.pointGeometry(c.x,l.y),p=-e.degToRad(n),d=l.rotate(p),f=c.rotate(p),m=u.rotate(p),g=h.rotate(p),_=new e.pointGeometry(Math.max(d.x,f.x,m.x,g.x),Math.max(d.y,f.y,m.y,g.y)),y=new e.pointGeometry(Math.min(d.x,f.x,m.x,g.x),Math.min(d.y,f.y,m.y,g.y)),v=_.sub(y),x=(s.width-((a.left||0)+(a.right||0)+o.padding.left+o.padding.right))/v.x,b=(s.height-((a.top||0)+(a.bottom||0)+o.padding.top+o.padding.bottom))/v.y;if(b<0||x<0)return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const w=Math.min(s.scaleZoom(s.scale*Math.min(x,b)),o.maxZoom),M="number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.pointGeometry(o.offset.x,o.offset.y):e.pointGeometry.convert(o.offset),T=new e.pointGeometry((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(n*Math.PI/180),S=M.add(T).mult(s.scale/s.zoomScale(w));return{center:s.unproject(l.add(c).div(2).sub(S)),zoom:w,bearing:n}}_cameraForBox(t,i,n,r,o){const s=this._extendCameraOptions(o);n=n||0,r=r||0,t=e.LngLat.convert(t),i=e.LngLat.convert(i);const a=this.transform.clone();a.padding=s.padding;const l=this.getFreeCameraOptions(),c=new e.LngLat(.5*(t.lng+i.lng),.5*(t.lat+i.lat)),u=.5*(n+r);if(a._camera.position[2]<e.mercatorZfromAltitude(u,c.lat))return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");l.lookAtPoint(c),a.setFreeCameraOptions(l);const h=e.MercatorCoordinate.fromLngLat(t),p=e.MercatorCoordinate.fromLngLat(i),d=a.pointRayIntersection(a.centerPoint,u),f=[(m=a.rayIntersectionCoordinate(d)).x,m.y,m.z];var m;const g=a.screenPointToMercatorRay(a.centerPoint),_="globe"!==a.projection.name;let y,v=0;do{const i=Math.floor(a.zoom),o=1<<i,s=Math.min(o*h.x,o*p.x),l=Math.min(o*h.y,o*p.y),c=Math.max(o*h.x,o*p.x),u=Math.max(o*h.y,o*p.y),d=new e.Aabb([s,l,n],[c,u,r]),m=e.Frustum.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,i,_);if(2!==d.intersects(m)){y&&(a._camera.position=e.scaleAndAdd([],a._camera.position,g.dir,-y),a._updateStateFromCamera());break}const v=e.sub([],a._camera.position,f);y=.5*e.length(v),a._camera.position=e.scaleAndAdd([],a._camera.position,g.dir,y);try{a._updateStateFromCamera()}catch(t){return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++v<10);return{center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}fitBounds(t,i,n){return"globe"===this.transform.projection.name&&e.warnOnce("Globe projection does not support fitBounds API, this API may behave unexpectedly."),this._fitInternal(this.cameraForBounds(t,i),i,n)}_raycastElevationBox(t,i){const n=this.transform.elevation;if(!n)return;const r=new e.pointGeometry(t.x,i.y),o=new e.pointGeometry(i.x,t.y),s=n.pointCoordinate(t);if(!s)return;const a=n.pointCoordinate(i);if(!a)return;const l=n.pointCoordinate(r);if(!l)return;const c=n.pointCoordinate(o);if(!c)return;const u=new e.MercatorCoordinate(s[0],s[1]).toLngLat(),h=new e.MercatorCoordinate(a[0],a[1]).toLngLat(),p=new e.MercatorCoordinate(l[0],l[1]).toLngLat(),d=new e.MercatorCoordinate(c[0],c[1]).toLngLat(),f=Math.min(u.lng,Math.min(h.lng,Math.min(p.lng,d.lng))),m=Math.min(u.lat,Math.min(h.lat,Math.min(p.lat,d.lat))),g=Math.max(u.lng,Math.max(h.lng,Math.max(p.lng,d.lng))),_=Math.max(u.lat,Math.max(h.lat,Math.max(p.lat,d.lat))),y=Math.min(s[3],Math.min(a[3],Math.min(l[3],c[3]))),v=Math.max(s[3],Math.max(a[3],Math.max(l[3],c[3])));return{minLngLat:new e.LngLat(f,m),maxLngLat:new e.LngLat(g,_),minAltitude:y,maxAltitude:v}}fitScreenCoordinates(t,i,n,r,o){let s,a,l,c;"globe"===this.transform.projection.name&&e.warnOnce("Globe projection does not support fitScreenCoordinates API, this API may behave unexpectedly.");const u=e.pointGeometry.convert(t),h=e.pointGeometry.convert(i),p=this._raycastElevationBox(u,h);if(p)s=p.minLngLat,a=p.maxLngLat,l=p.minAltitude,c=p.maxAltitude;else{if(this.transform.anyCornerOffEdge(u,h))return this;s=this.transform.pointLocation(u),a=this.transform.pointLocation(h)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(e.pointGeometry.convert(t)),this.transform.pointLocation(e.pointGeometry.convert(i)),n,r):this._cameraForBox(s,a,l,c,r),r,o)}_fitInternal(t,i,n){return t?(delete(i=e.extend(t,i)).padding,i.linear?this.easeTo(i,n):this.flyTo(i,n)):this}jumpTo(t,i){this.stop();const n=t.preloadOnly?this.transform.clone():this.transform;let r=!1,o=!1,s=!1;return"zoom"in t&&n.zoom!==+t.zoom&&(r=!0,n.zoom=+t.zoom),void 0!==t.center&&(n.center=e.LngLat.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(o=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(s=!0,n.pitch=+t.pitch),null==t.padding||n.isPaddingEqual(t.padding)||(n.padding=t.padding),t.preloadOnly?(this._preloadTiles(n),this):(this.fire(new e.Event("movestart",i)).fire(new e.Event("move",i)),r&&this.fire(new e.Event("zoomstart",i)).fire(new e.Event("zoom",i)).fire(new e.Event("zoomend",i)),o&&this.fire(new e.Event("rotatestart",i)).fire(new e.Event("rotate",i)).fire(new e.Event("rotateend",i)),s&&this.fire(new e.Event("pitchstart",i)).fire(new e.Event("pitch",i)).fire(new e.Event("pitchend",i)),this.fire(new e.Event("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(Hr),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const n=this.transform;if(!n.projection.supportsFreeCamera)return e.warnOnce(Hr),this;this.stop();const r=n.zoom,o=n.pitch,s=n.bearing;n.setFreeCameraOptions(t);const a=r!==n.zoom,l=o!==n.pitch,c=s!==n.bearing;return this.fire(new e.Event("movestart",i)).fire(new e.Event("move",i)),a&&this.fire(new e.Event("zoomstart",i)).fire(new e.Event("zoom",i)).fire(new e.Event("zoomend",i)),c&&this.fire(new e.Event("rotatestart",i)).fire(new e.Event("rotate",i)).fire(new e.Event("rotateend",i)),l&&this.fire(new e.Event("pitchstart",i)).fire(new e.Event("pitch",i)).fire(new e.Event("pitchend",i)),this.fire(new e.Event("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||!t.essential&&e.exported.prefersReducedMotion)&&(t.duration=0);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h="padding"in t?t.padding:n.padding,p=e.pointGeometry.convert(t.offset);let d,f,m;if("globe"===n.projection.name){const i=e.MercatorCoordinate.fromLngLat(n.center),r=p.rotate(-n.angle);i.x+=r.x/n.worldSize,i.y+=r.y/n.worldSize;const o=i.toLngLat(),s=e.LngLat.convert(t.center||o);this._normalizeCenter(s),d=n.centerPoint.add(r),f=new e.pointGeometry(i.x,i.y).mult(n.worldSize),m=new e.pointGeometry(e.mercatorXfromLng(s.lng),e.mercatorYfromLat(s.lat)).mult(n.worldSize).sub(f)}else{d=n.centerPoint.add(p);const i=n.pointLocation(d),r=e.LngLat.convert(t.center||i);this._normalizeCenter(r),f=n.project(i),m=n.project(r).sub(f)}const g=n.zoomScale(l-r);let _,y;t.around&&(_=e.LngLat.convert(t.around),y=n.locationPoint(_));const v=this._zooming||l!==r,x=this._rotating||o!==c,b=this._pitching||u!==s,w=!n.isPaddingEqual(h),M=n=>M=>{if(v&&(n.zoom=e.number(r,l,M)),x&&(n.bearing=e.number(o,c,M)),b&&(n.pitch=e.number(s,u,M)),w&&(n.interpolatePadding(a,h,M),d=n.centerPoint.add(p)),_)n.setLocationAtPoint(_,y);else{const e=n.zoomScale(n.zoom-r),t=l>r?Math.min(2,g):Math.max(.5,g),i=Math.pow(t,1-M),o=n.unproject(f.add(m.mult(M*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,d)}return t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(M,t.duration,n);return this._preloadTiles(e),this}const T={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,T),this._ease(M(n),(e=>{n.recenterOnTerrain(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||n.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.Event("zoomend",t)),r&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,i){if(!t.essential&&e.exported.prefersReducedMotion){const n=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,i)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,n.minZoom,n.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h="padding"in t?t.padding:n.padding,p=n.zoomScale(l-r),d=e.pointGeometry.convert(t.offset);let f=n.centerPoint.add(d);const m=n.pointLocation(f),g=e.LngLat.convert(t.center||m);this._normalizeCenter(g);const _=n.project(m),y=n.project(g).sub(_);let v=t.curve;const x=Math.max(n.width,n.height),b=x/p,w=y.mag();if("minZoom"in t){const i=e.clamp(Math.min(t.minZoom,r,l),n.minZoom,n.maxZoom),o=x/n.zoomScale(i-r);v=Math.sqrt(o/w*2)}const M=v*v;function T(e){const t=(b*b-x*x+(e?-1:1)*M*M*w*w)/(2*(e?b:x)*M*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}const A=T(0);let C=function(e){return E(A)/E(A+v*e)},L=function(e){return x*((E(A)*(S(t=A+v*e)/E(t))-S(A))/M)/w;var t},I=(T(1)-A)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,i);const e=b<x?-1:1;I=Math.abs(Math.log(b/x))/v,L=function(){return 0},C=function(t){return Math.exp(e*v*t)}}t.duration="duration"in t?+t.duration:1e3*I/("screenSpeed"in t?+t.screenSpeed/v:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const P=o!==c,R=u!==s,k=!n.isPaddingEqual(h),z=n=>p=>{const m=p*I,v=1/C(m);n.zoom=1===p?l:r+n.scaleZoom(v),P&&(n.bearing=e.number(o,c,p)),R&&(n.pitch=e.number(s,u,p)),k&&(n.interpolatePadding(a,h,p),f=n.centerPoint.add(d));const x=1===p?g:n.unproject(_.add(y.mult(L(m))).mult(v));return n.setLocationAtPoint(n.renderWorldCopies?x.wrap():x,f),n._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(z,t.duration,n);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=R,this._padding=k,this._prepareEase(i,!1),this._ease(z(n),(()=>this._afterEase(i)),t),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(t,i,n){!1===n.animate||0===n.duration?(t(1),i()):(this._easeStart=e.exported.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.wrap(t,-180,180);const n=Math.abs(t-i);return Math.abs(t-360-i)<n&&(t-=360),Math.abs(t+360-i)<n&&(t+=360),t}_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 n=Math.ceil(15*t/1e3),r=[],o=e(i.clone());for(let e=0;e<=n;e++){const t=o(e/n);r.push(t.clone())}return r}}class qr{constructor(t={}){this.options=t,e.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=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("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=o("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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const n=i.reduce(((e,t,n)=>(t.value&&(e+=`${t.key}=${t.value}${n<i.length-1?"&":""}`),e)),"?");t.href=`${e.config.FEEDBACK_URL}/${n}${this._map._hash?this._map._hash.getHashString(!0):""}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._sourceCaches;for(const i in t){const n=t[i];if(n.used){const t=n.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let n=i+1;n<e.length;n++)if(e[n].indexOf(t)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,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 $r{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("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 Zr{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 Xr(t,i,n){if(t=new e.LngLat(t.lng,t.lat),i){const r=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-n.center.lng)/360),a=n.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>n.width||i.y>n.height;n.locationPoint(r).distSqr(i)<a&&(l||Math.abs(r.lng-n.center.lng)<s)?t=r:n.locationPoint(o).distSqr(i)<a&&(l||Math.abs(o.lng-n.center.lng)<s)&&(t=o)}for(;Math.abs(t.lng-n.center.lng)>180;){const e=n.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}const Yr={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 Jr extends e.Evented{constructor(t,i){if(super(),(t instanceof e.window.HTMLElement||i)&&(t=e.extend({element:t},i)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=e.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const i=41,n=27,r=s("svg",{display:"block",height:i*this._scale+"px",width:n*this._scale+"px",viewBox:`0 0 ${n} ${i}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},r));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),s("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),s("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),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=e.pointGeometry.convert(t&&t.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 n=this._element.classList;for(const e in Yr)n.remove(`mapboxgl-marker-anchor-${e}`);n.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(t){return this._lngLat=e.LngLat.convert(t),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,n=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":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],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 n=i.position.toLngLat();return n.distanceTo(t)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const n=t.unproject(i);let r;t._usingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.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) ${Yr[this._anchor]}\n ${t}\n translate(${i.x}px,${i.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map;if("map"!==this.getPitchAlignment()||!i||!t)return"";if(!i._usingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.radToDeg(e.globeTiltAtLngLat(i.transform,this._lngLat)),r=t.sub(e.globeCenterToScreenPoint(i.transform)),o=n/(Math.abs(r.x)+Math.abs(r.y)),s=r.x*o,a=-r.y*o;return a||s?`rotateX(${a}deg) rotateY(${s}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 t=this._map;if(this._pos&&t&&t._usingGlobe()){const i=t.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),n=t.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(i);return this._rotation+e.radToDeg(Math.atan2(n.y,n.x))-90}return this._rotation-this._map.getBearing()}return 0}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=Xr(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._usingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.pointGeometry.convert(t),this._update(),this}_onMove(t){const i=this._map;if(i){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=i.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.Event("dragstart"))),this.fire(new e.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.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 Qr{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}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 Kr={"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 no{constructor(t,i,n=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new _r({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,n&&(this.mousePitch=new yr({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u()}move(e,t){const i=this.map,n=this.mouseRotate.mousemoveWindow(e,t),r=n&&n.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const n=this.mousePitch.mousemoveWindow(e,t),r=n&&n.pitchDelta;r&&i.setPitch(i.getPitch()+r)}}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(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),f(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,f(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=m(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=m(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 ro={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,n,r,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"!==r?new Intl.NumberFormat(n,{style:"unit",unitDisplay:"narrow",unit:r}).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(t=new e.pointGeometry(0,0),i="bottom"){if("number"==typeof t){const n=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case"top":return new e.pointGeometry(0,t);case"top-left":return new e.pointGeometry(n,n);case"top-right":return new e.pointGeometry(-n,n);case"bottom":return new e.pointGeometry(0,-t);case"bottom-left":return new e.pointGeometry(n,-n);case"bottom-right":return new e.pointGeometry(-n,-n);case"left":return new e.pointGeometry(t,0);case"right":return new e.pointGeometry(-t,0)}return new e.pointGeometry(0,0)}return t instanceof e.pointGeometry||Array.isArray(t)?e.pointGeometry.convert(t):e.pointGeometry.convert(t[i]||[0,0])}const uo={version:e.version,supported:i,setRTLTextPlugin:e.setRTLTextPlugin,getRTLTextPluginStatus:e.getRTLTextPluginStatus,Map:class extends Wr{constructor(t){if(null!=(t=e.extend({},eo,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new $n(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language="auto"===t.language?e.window.navigator.language:t.language,this._worldview=t.worldview,this._renderTaskQueue=new Zr,this._domRenderTaskQueue=new Zr,this._controls=[],this._markers=[],this._mapId=e.uniqueId(),this._locale=e.extend({},Kr,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Qr(0),this._explicitProjection=null,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.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!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new Gr(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Xn("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new qr({customAttribution:t.customAttribution})),this._logoControl=new $r,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.Event(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.Event(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 i=!this._moving;return i&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),i&&this.fire(new e.Event("moveend",t)),this}getBounds(){return"globe"===this.transform.projection.name&&e.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?85:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.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(t){if(this._language="auto"===t?e.window.navigator.language:t,this.style)for(const e in this.style._sourceCaches){const t=this.style._sourceCaches[e]._source;t._setLanguage&&t._setLanguage(this._language)}for(const e of this._controls)e._setLanguage&&e._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(t){const i=this.getProjection();null===t&&(this._explicitProjection=null);const n=t||this.getProjection();let r;if(n&&"globe"===n.name&&this.transform.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(r=this.transform.setProjection({name:"mercator"}),this.transform.mercatorFromTransition=!0):(r=this.transform.setProjection(n),this.transform.mercatorFromTransition=!1),t&&(this._explicitProjection="globe"===t.name?{name:"globe",center:[0,0]}:this.transform.getProjection()),this.style.applyProjectionUpdate(),r){if("globe"===i.name&&"globe"===this.getProjection().name)this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles()}this._update(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.pointGeometry.convert(t))}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(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new rr(e,this,r.originalEvent,{features:s}))):n=!1},o=()=>{n=!1};return{layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new rr(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new rr(e,this,t.originalEvent)))};return{layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter((e=>this.getLayer(e))),r=n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:new Set(t),listener:i,delegates:{[e]:n}}}}on(e,t,i){if(void 0===i)return super.on(e,t);Array.isArray(t)||(t=[t]);const n=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(n);for(const e in n.delegates)this.on(e,n.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);Array.isArray(t)||(t=[t]);const n=this._createDelegatedListener(e,t,i);for(const e in n.delegates)this.once(e,n.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const n=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},r=this._delegatedListeners?this._delegatedListeners[e]:void 0;return r&&(e=>{for(let r=0;r<e.length;r++){const o=e[r];if(o.listener===i&&n(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(r,1),this}}})(r),this}queryRenderedFeatures(t,i){return this.style?(void 0!==i||void 0===t||t instanceof e.pointGeometry||Array.isArray(t)||(i=t,t=void 0),this.style.queryRenderedFeatures(t=t||[[0,0],[this.transform.width,this.transform.height]],i=i||{},this.transform)):[]}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}queryTerrainElevation(t,i){const n=this.transform.elevation;return n?(i=e.extend({},{exaggerated:!0},i),n.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,i.exaggerated)):null}setStyle(t,i){return!1!==(i=e.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.localFontFamily===this._localFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_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(t,i){if("string"==typeof t){const n=this._requestManager.normalizeStyleURL(t),r=this._requestManager.transformRequest(n,e.ResourceType.Style);e.getJSON(r,((t,n)=>{t?this.fire(new e.ErrorEvent(t)):n&&this._updateDiff(n,i)}))}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t)&&this._update(!0)}catch(n){e.warnOnce(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.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 t=i[e];if("loaded"!==t.state&&"errored"!==t.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(t,i,{pixelRatio:n=1,sdf:r=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&i instanceof e.window.ImageBitmap){const{width:l,height:c,data:u}=e.exported.getImageData(i);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},u),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new e.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:l,height:c}=i,u=i;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}updateImage(t,i){const n=this.style.getImage(t);if(!n)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&i instanceof e.window.ImageBitmap?e.exported.getImageData(i):i,{width:o,height:s}=r;void 0!==o&&void 0!==s?o===n.data.width&&s===n.data.height?(n.data.replace(r.data,!(i instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&i instanceof e.window.ImageBitmap)),this.style.updateImage(t,n)):this.fire(new e.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${n.data.width}, ${n.data.height})`))):this.fire(new e.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(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,i){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),((t,n)=>{i(t,n instanceof e.window.HTMLImageElement?e.exported.getImageData(n):n)}))}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,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),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(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),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 t=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let n,r,o,s=this._container;for(;s&&(!r||!o);){const t=e.window.getComputedStyle(s).transform;t&&"none"!==t&&(n=t.match(/matrix.*\((.+)\)/)[1].split(", "),n[0]&&"0"!==n[0]&&"1"!==n[0]&&(r=n[0]),n[3]&&"0"!==n[3]&&"1"!==n[3]&&(o=n[3])),s=s.parentElement}this._containerWidth=r?Math.abs(t/r):t,this._containerHeight=o?Math.abs(i/o):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.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=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=o("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=o("div","mapboxgl-control-container",e),n=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{n[e]=o("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const n=e.exported.devicePixelRatio||1;this._canvas.width=n*Math.ceil(t),this._canvas.height=n*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_setupPainter(){const t=e.extend({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),n=this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);n?(e.storeAuthState(n,!0),this.painter=new zn(n,this.transform),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.exported$1.testSupport(n)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_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 n=this.painter.context.extTimerQuery,r=e.exported.now();if(this.listens("gpu-timing-frame")&&(i=n.createQueryEXT(),n.beginQueryEXT(n.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>=e.GLOBE_ZOOM_THRESHOLD_MAX?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let o=!1;const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,n=e.exported.now();this.style.zoomHistory.update(t,n);const r=new e.EvaluationParameters(t,{now:n,fadeDuration:s,pitch:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=r.crossFadingFactor();1===a&&a===this._crossFadingFactor||(o=!0,this._crossFadingFactor=a),this.style.update(r)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(r),this.style._updateSources(this.transform),this._forceMarkerUpdate()):a=this._updateAverageElevation(r),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,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:s,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 e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.exported.now()-r;n.endQueryEXT(n.TIME_ELAPSED_EXT,i),setTimeout((()=>{const o=n.getQueryObjectEXT(i,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(i),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.window.performance.mark("frame-gpu",{startTime:r,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(r,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const e of this._markers)e._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation(),r=!1;this.transform.elevation&&(r=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof $r&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.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/")))}})),e.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,n=i.createFramebuffer();function r(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,n),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let n=i[1]-i[0];const r=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);n+=(i[o+2]-i[o+1])*(1-a/r)}return n}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.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!==e.window&&(e.window.removeEventListener("resize",this._onWindowResize,!1),e.window.removeEventListener("orientationchange",this._onWindowResize,!1),e.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),to(this._canvasContainer),to(this._controlContainer),to(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),e.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new e.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.exported.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const i=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(i,((e,i)=>e._preloadTiles(t,i)),(()=>{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(t,i){e.setCacheLimits(t,i)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},io,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),o("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})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.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=o("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(),n=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.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 no(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=o("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 e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},ro,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Zn(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("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!==e.window.navigator.permissions?e.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const i=new e.LngLat(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),o=e.extend({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(n),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,i=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,n=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Jr({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Jr({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",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.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 e.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 e.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 e.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 e.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=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.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:qr,ScaleControl:class{constructor(t){this.options=e.extend({},oo,t),e.bindAll(["_update","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){!function(e,t,i,n){const r=n&&n.maxWidth||100,o=e._containerHeight/2,s=e._containerWidth/2-r/2,a=e.unproject([s,o]),l=e.unproject([s+r,o]),c=a.distanceTo(l);if(n&&"imperial"===n.unit){const n=3.2808*c;n>5280?so(t,r,n/5280,i,"mile",e):so(t,r,n,i,"foot",e)}else n&&"nautical"===n.unit?so(t,r,c/1852,i,"nautical-mile",e):c>=1e3?so(t,r,c/1e3,i,"kilometer",e):so(t,r,c,i,"meter",e)}(this._map,this._container,this._language,this.options)}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("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(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.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(){(e.window.document.fullscreenElement||e.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()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(ao),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._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(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const i=e.window.document.createDocumentFragment(),n=e.window.document.createElement("body");let r;for(n.innerHTML=t;r=n.firstChild,r;)i.appendChild(r);return this.setDOMContent(i)}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=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("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,n=this._pos;if(!t||!i||!n)return"bottom";const r=i.offsetWidth,o=i.offsetHeight,s=n.x<r/2,a=n.x>t.transform.width-r/2;if(n.y+e<o)return s?"top-left":a?"top-right":"top";if(n.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(t){const i=this._map,n=this._content;if(!i||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=o("div","mapboxgl-popup",i.getContainer()),this._tip=o("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Xr(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:i.project(this._lngLat),n=co(this.options.offset),r=this._anchor=this._getAnchor(n.y),o=co(this.options.offset,r),s=e.add(o).round();i._requestDomTask((()=>{this._container&&r&&(this._container.style.transform=`${Yr[r]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._usingGlobe()){const t=e.isLngLatBehindGlobe(i.transform,this._lngLat)?0:1;this._setOpacity(t)}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:Jr,Style:ei,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.pointGeometry,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:Nn,Evented:e.Evented,config:e.config,prewarm:function(){je().acquire(Be)},clearPrewarmedResources:function(){const e=Ue;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Be),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 e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return Ne.workerCount},set workerCount(e){Ne.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return uo}));return i}));!function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(e,t,i){"use strict";var n=e("@mapbox/mapbox-gl-sync-move"),r=e("events").EventEmitter;function o(e,t,i,o){if(this.options=o||{},this._mapA=e,this._mapB=t,this._horizontal="horizontal"===this.options.orientation,this._onDown=this._onDown.bind(this),this._onMove=this._onMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._ev=new r,this._swiper=document.createElement("div"),this._swiper.className=this._horizontal?"compare-swiper-horizontal":"compare-swiper-vertical",this._controlContainer=document.createElement("div"),this._controlContainer.className=this._horizontal?"mapboxgl-compare mapboxgl-compare-horizontal":"mapboxgl-compare",this._controlContainer.className=this._controlContainer.className,this._controlContainer.appendChild(this._swiper),"string"==typeof i&&document.body.querySelectorAll){var s=document.body.querySelectorAll(i)[0];if(!s)throw new Error("Cannot find element with specified container selector.");s.appendChild(this._controlContainer)}else{if(!(i instanceof Element&&i.appendChild))throw new Error("Invalid container specified. Must be CSS selector or HTML element.");i.appendChild(this._controlContainer)}this._bounds=t.getContainer().getBoundingClientRect();var a=(this._horizontal?this._bounds.height:this._bounds.width)/2;this._setPosition(a),this._clearSync=n(e,t),this._onResize=function(){this._bounds=t.getContainer().getBoundingClientRect(),this.currentPosition&&this._setPosition(this.currentPosition)}.bind(this),t.on("resize",this._onResize),this.options&&this.options.mousemove&&(e.getContainer().addEventListener("mousemove",this._onMove),t.getContainer().addEventListener("mousemove",this._onMove)),this._swiper.addEventListener("mousedown",this._onDown),this._swiper.addEventListener("touchstart",this._onDown)}o.prototype={_setPointerEvents:function(e){this._controlContainer.style.pointerEvents=e,this._swiper.style.pointerEvents=e},_onDown:function(e){e.touches?(document.addEventListener("touchmove",this._onMove),document.addEventListener("touchend",this._onTouchEnd)):(document.addEventListener("mousemove",this._onMove),document.addEventListener("mouseup",this._onMouseUp))},_setPosition:function(e){e=Math.min(e,this._horizontal?this._bounds.height:this._bounds.width);var t=this._horizontal?"translate(0, "+e+"px)":"translate("+e+"px, 0)";this._controlContainer.style.transform=t,this._controlContainer.style.WebkitTransform=t;var i=this._horizontal?"rect(0, 999em, "+e+"px, 0)":"rect(0, "+e+"px, "+this._bounds.height+"px, 0)",n=this._horizontal?"rect("+e+"px, 999em, "+this._bounds.height+"px,0)":"rect(0, 999em, "+this._bounds.height+"px,"+e+"px)";this._mapA.getContainer().style.clip=i,this._mapB.getContainer().style.clip=n,this.currentPosition=e},_onMove:function(e){this.options&&this.options.mousemove&&this._setPointerEvents(e.touches?"auto":"none"),this._horizontal?this._setPosition(this._getY(e)):this._setPosition(this._getX(e))},_onMouseUp:function(){document.removeEventListener("mousemove",this._onMove),document.removeEventListener("mouseup",this._onMouseUp),this.fire("slideend",{currentPosition:this.currentPosition})},_onTouchEnd:function(){document.removeEventListener("touchmove",this._onMove),document.removeEventListener("touchend",this._onTouchEnd)},_getX:function(e){var t=(e=e.touches?e.touches[0]:e).clientX-this._bounds.left;return t<0&&(t=0),t>this._bounds.width&&(t=this._bounds.width),t},_getY:function(e){var t=(e=e.touches?e.touches[0]:e).clientY-this._bounds.top;return t<0&&(t=0),t>this._bounds.height&&(t=this._bounds.height),t},setSlider:function(e){this._setPosition(e)},on:function(e,t){return this._ev.on(e,t),this},fire:function(e,t){return this._ev.emit(e,t),this},off:function(e,t){return this._ev.removeListener(e,t),this},remove:function(){this._clearSync(),this._mapB.off("resize",this._onResize);var e=this._mapA.getContainer();e&&(e.style.clip=null,e.removeEventListener("mousemove",this._onMove));var t=this._mapB.getContainer();t&&(t.style.clip=null,t.removeEventListener("mousemove",this._onMove)),this._swiper.removeEventListener("mousedown",this._onDown),this._swiper.removeEventListener("touchstart",this._onDown),this._controlContainer.remove()}},window.mapboxgl?mapboxgl.Compare=o:void 0!==t&&(t.exports=o)},{"@mapbox/mapbox-gl-sync-move":2,events:3}],2:[function(e,t,i){t.exports=function(){var e,t=arguments.length;if(1===t)e=arguments[0];else{e=[];for(var i=0;i<t;i++)e.push(arguments[i])}var n=[];function r(){e.forEach((function(e,t){e.on("move",n[t])}))}function o(){e.forEach((function(e,t){e.off("move",n[t])}))}return e.forEach((function(t,i){n[i]=function(e,t){o(),function(e,t){var i=e.getCenter(),n=e.getZoom(),r=e.getBearing(),o=e.getPitch();t.forEach((function(e){e.jumpTo({center:i,zoom:n,bearing:r,pitch:o})}))}(e,t),r()}.bind(null,t,e.filter((function(e,t){return t!==i})))})),r(),function(){o(),n=[]}}},{}],3:[function(e,t,i){var n=Object.create||function(e){function t(){}return t.prototype=e,new t},r=Object.keys||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.push(i);return i},o=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((t.exports=s).EventEmitter=s).prototype._events=void 0,s.prototype._maxListeners=void 0;var a,l=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),a=0===c.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,i,r){var o,s,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),s=e._events),a=s[t]):(s=e._events=n(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=r?[i,a]:[a,i]:r?a.unshift(i):a.push(i),!a.warned&&(o=u(e))&&0<o&&a.length>o){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=s[t]=i,++e._eventsCount;return e}function p(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function d(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=o.call(p,n);return r.listener=i,n.wrapFn=r}function f(e,t,i){var n=e._events;if(!n)return[];var r=n[t];return r?"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(r):g(r,r.length):[]}function m(e){var t=this._events;if(t){var i=t[e];if("function"==typeof i)return 1;if(i)return i.length}return 0}function g(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');l=e}}):s.defaultMaxListeners=l,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e,t,i,n){var r,o,s,a,l,c,u="error"===e;if(c=this._events)u=u&&null==c.error;else if(!u)return!1;if(u){if(1<arguments.length&&(r=t),r instanceof Error)throw r;var h=new Error('Unhandled "error" event. ('+r+")");throw h.context=r,h}if(!(o=c[e]))return!1;var p="function"==typeof o;switch(s=arguments.length){case 1:!function(e,t,i){if(t)e.call(i);else for(var n=e.length,r=g(e,n),o=0;o<n;++o)r[o].call(i)}(o,p,this);break;case 2:!function(e,t,i,n){if(t)e.call(i,n);else for(var r=e.length,o=g(e,r),s=0;s<r;++s)o[s].call(i,n)}(o,p,this,t);break;case 3:!function(e,t,i,n,r){if(t)e.call(i,n,r);else for(var o=e.length,s=g(e,o),a=0;a<o;++a)s[a].call(i,n,r)}(o,p,this,t,i);break;case 4:!function(e,t,i,n,r,o){if(t)e.call(i,n,r,o);else for(var s=e.length,a=g(e,s),l=0;l<s;++l)a[l].call(i,n,r,o)}(o,p,this,t,i,n);break;default:for(a=new Array(s-1),l=1;l<s;l++)a[l-1]=arguments[l];!function(e,t,i,n){if(t)e.apply(i,n);else for(var r=e.length,o=g(e,r),s=0;s<r;++s)o[s].apply(i,n)}(o,p,this,a)}return!0},s.prototype.on=s.prototype.addListener=function(e,t){return h(this,e,t,!1)},s.prototype.prependListener=function(e,t){return h(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,d(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,d(this,e,t)),this},s.prototype.removeListener=function(e,t){var i,r,o,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(i=r[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=n(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(o=-1,s=i.length-1;0<=s;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,o=s;break}if(o<0)return this;0===o?i.shift():function(e,t){for(var i=t,n=i+1,r=e.length;n<r;i+=1,n+=1)e[i]=e[n];e.pop()}(i,o),1===i.length&&(r[e]=i[0]),r.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,i,o;if(!(i=this._events))return this;if(!i.removeListener)return 0===arguments.length?(this._events=n(null),this._eventsCount=0):i[e]&&(0==--this._eventsCount?this._events=n(null):delete i[e]),this;if(0===arguments.length){var s,a=r(i);for(o=0;o<a.length;++o)"removeListener"!==(s=a[o])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=n(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(t)for(o=t.length-1;0<=o;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}]},{},[1]);!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MapboxDirections=e()}}((function(){return function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(e,t,i){"use strict";var n={};function r(e){return Math.floor(Math.abs(e)+.5)*(e>=0?1:-1)}function o(e,t,i){var n=(e=r(e*i))-(t=r(t*i));n<<=1;e-t<0&&(n=~n);for(var o="";n>=32;){o+=String.fromCharCode(63+(32|31&n));n>>=5}return o+=String.fromCharCode(n+63)}n.decode=function(e,t){for(var i,n=0,r=0,o=0,s=[],a=0,l=0,c=null,u=Math.pow(10,Number.isInteger(t)?t:5);n<e.length;){c=null;a=0;l=0;do{l|=(31&(c=e.charCodeAt(n++)-63))<<a;a+=5}while(c>=32);i=1&l?~(l>>1):l>>1;a=l=0;do{l|=(31&(c=e.charCodeAt(n++)-63))<<a;a+=5}while(c>=32);r+=i;o+=1&l?~(l>>1):l>>1;s.push([r/u,o/u])}return s};n.encode=function(e,t){if(!e.length)return"";for(var i=Math.pow(10,Number.isInteger(t)?t:5),n=o(e[0][0],0,i)+o(e[0][1],0,i),r=1;r<e.length;r++){var s=e[r],a=e[r-1];n+=o(s[0],a[0],i);n+=o(s[1],a[1],i)}return n};function s(e){for(var t=[],i=0;i<e.length;i++){var n=e[i].slice();t.push([n[1],n[0]])}return t}n.fromGeoJSON=function(e,t){e&&"Feature"===e.type&&(e=e.geometry);if(!e||"LineString"!==e.type)throw new Error("Input must be a GeoJSON LineString");return n.encode(s(e.coordinates),t)};n.toGeoJSON=function(e,t){return{type:"LineString",coordinates:s(n.decode(e,t))}};"object"==typeof t&&t.exports&&(t.exports=n)},{}],2:[function(e,t,i){"use strict";var n=e("is-obj"),r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function s(e,t,i){var o=t[i];if(null!=o){if(r.call(e,i)&&(void 0===e[i]||null===e[i]))throw new TypeError("Cannot convert undefined or null to object ("+i+")");r.call(e,i)&&n(o)?e[i]=a(Object(e[i]),t[i]):e[i]=o}}function a(e,t){if(e===t)return e;t=Object(t);for(var i in t)r.call(t,i)&&s(e,t,i);if(Object.getOwnPropertySymbols)for(var n=Object.getOwnPropertySymbols(t),a=0;a<n.length;a++)o.call(t,n[a])&&s(e,t,n[a]);return e}t.exports=function(e){e=function(e){if(null==e)throw new TypeError("Sources cannot be null or undefined");return Object(e)}(e);for(var t=1;t<arguments.length;t++)a(e,arguments[t]);return e}},{"is-obj":5}],3:[function(e,t,i){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||void 0}t.exports=n;n.EventEmitter=n;n.prototype._events=void 0;n.prototype._maxListeners=void 0;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!(t=e,"number"==typeof t)||e<0||isNaN(e))throw TypeError("n must be a positive number");var t;this._maxListeners=e;return this};n.prototype.emit=function(e){var t,i,n,a,l,c;this._events||(this._events={});if("error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");u.context=t;throw u}if(s(i=this._events[e]))return!1;if(r(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1);i.apply(this,a)}else if(o(i)){a=Array.prototype.slice.call(arguments,1);n=(c=i.slice()).length;for(l=0;l<n;l++)c[l].apply(this,a)}return!0};n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");this._events||(this._events={});this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t);this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t;if(o(this._events[e])&&!this._events[e].warned&&(i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i){this._events[e].warned=!0;console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length);"function"==typeof console.trace&&console.trace()}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var i=!1;function n(){this.removeListener(e,n);if(!i){i=!0;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var i,n,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;s=(i=this._events[e]).length;n=-1;if(i===t||r(i.listener)&&i.listener===t){delete this._events[e];this._events.removeListener&&this.emit("removeListener",e,t)}else if(o(i)){for(a=s;a-- >0;)if(i[a]===t||i[a].listener&&i[a].listener===t){n=a;break}if(n<0)return this;if(1===i.length){i.length=0;delete this._events[e]}else i.splice(n,1);this._events.removeListener&&this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener){0===arguments.length?this._events={}:this._events[e]&&delete this._events[e];return this}if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);this.removeAllListeners("removeListener");this._events={};return this}if(r(i=this._events[e]))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);delete this._events[e];return this};n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]};n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0};n.listenerCount=function(e,t){return e.listenerCount(t)};function r(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}},{}],4:[function(e,t,i){!function(){var e={};void 0!==i?t.exports=e:this.fuzzy=e;e.simpleFilter=function(t,i){return i.filter((function(i){return e.test(t,i)}))};e.test=function(t,i){return null!==e.match(t,i)};e.match=function(e,t,i){i=i||{};var n,r=0,o=[],s=t.length,a=0,l=0,c=i.pre||"",u=i.post||"",h=i.caseSensitive&&t||t.toLowerCase();e=i.caseSensitive&&e||e.toLowerCase();for(var p=0;p<s;p++){n=t[p];if(h[p]===e[r]){n=c+n+u;r+=1;l+=1+l}else l=0;a+=l;o[o.length]=n}if(r===e.length){a=h===e?1/0:a;return{rendered:o.join(""),score:a}}return null};e.filter=function(t,i,n){if(!i||0===i.length)return[];if("string"!=typeof t)return i;n=n||{};return i.reduce((function(i,r,o,s){var a=r;n.extract&&(a=n.extract(r));var l=e.match(t,a,n);null!=l&&(i[i.length]={string:l.rendered,score:l.score,index:o,original:r});return i}),[]).sort((function(e,t){var i=t.score-e.score;return i||e.index-t.index}))}}()},{}],5:[function(e,t,i){"use strict";t.exports=function(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}},{}],6:[function(e,t,i){t.exports=/<%=([\s\S]+?)%>/g},{}],7:[function(e,t,i){(function(e){var i=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,l=parseInt,c="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,h=c||u||Function("return this")(),p=Object.prototype.toString,d=Math.max,f=Math.min,m=function(){return h.Date.now()};function g(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function _(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==n}(e))return i;if(g(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=g(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var c=s.test(e);return c||a.test(e)?l(e.slice(2),c?2:8):o.test(e)?i:+e}t.exports=function(e,t,i){var n,r,o,s,a,l,c=0,u=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");t=_(t)||0;if(g(i)){u=!!i.leading;o=(h="maxWait"in i)?d(_(i.maxWait)||0,t):o;p="trailing"in i?!!i.trailing:p}function y(t){var i=n,o=r;n=r=void 0;c=t;return s=e.apply(o,i)}function v(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function x(){var e=m();if(v(e))return b(e);a=setTimeout(x,function(e){var i=t-(e-l);return h?f(i,o-(e-c)):i}(e))}function b(e){a=void 0;if(p&&n)return y(e);n=r=void 0;return s}function w(){var e=m(),i=v(e);n=arguments;r=this;l=e;if(i){if(void 0===a)return function(e){c=e;a=setTimeout(x,t);return u?y(e):s}(l);if(h){a=setTimeout(x,t);return y(l)}}void 0===a&&(a=setTimeout(x,t));return s}w.cancel=function(){void 0!==a&&clearTimeout(a);c=0;n=l=r=a=void 0};w.flush=function(){return void 0===a?s:b(m())};return w}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,t,i){(function(e){var n="__lodash_hash_undefined__",r=1,o=2,s=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",h="[object Date]",p="[object Error]",d="[object Function]",f="[object GeneratorFunction]",m="[object Map]",g="[object Number]",_="[object Null]",y="[object Object]",v="[object Promise]",x="[object Proxy]",b="[object RegExp]",w="[object Set]",M="[object String]",T="[object Symbol]",S="[object Undefined]",E="[object WeakMap]",A="[object ArrayBuffer]",C="[object DataView]",L=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0;P[a]=P[l]=P[A]=P[u]=P[C]=P[h]=P[p]=P[d]=P[m]=P[g]=P[y]=P[b]=P[w]=P[M]=P[E]=!1;var R="object"==typeof e&&e&&e.Object===Object&&e,k="object"==typeof self&&self&&self.Object===Object&&self,z=R||k||Function("return this")(),D="object"==typeof i&&i&&!i.nodeType&&i,O=D&&"object"==typeof t&&t&&!t.nodeType&&t,F=O&&O.exports===D,B=F&&R.process,N=function(){try{return B&&B.binding&&B.binding("util")}catch(e){}}(),U=N&&N.isTypedArray;function j(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}function V(e){var t=-1,i=Array(e.size);e.forEach((function(e,n){i[++t]=[n,e]}));return i}function G(e){var t=-1,i=Array(e.size);e.forEach((function(e){i[++t]=e}));return i}var H,W,q,$=Array.prototype,Z=Function.prototype,X=Object.prototype,Y=z["__core-js_shared__"],J=Z.toString,Q=X.hasOwnProperty,K=(H=/[^.]+$/.exec(Y&&Y.keys&&Y.keys.IE_PROTO||""))?"Symbol(src)_1."+H:"",ee=X.toString,te=RegExp("^"+J.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ie=F?z.Buffer:void 0,ne=z.Symbol,re=z.Uint8Array,oe=X.propertyIsEnumerable,se=$.splice,ae=ne?ne.toStringTag:void 0,le=Object.getOwnPropertySymbols,ce=ie?ie.isBuffer:void 0,ue=(W=Object.keys,q=Object,function(e){return W(q(e))}),he=Ne(z,"DataView"),pe=Ne(z,"Map"),de=Ne(z,"Promise"),fe=Ne(z,"Set"),me=Ne(z,"WeakMap"),ge=Ne(Object,"create"),_e=Ge(he),ye=Ge(pe),ve=Ge(de),xe=Ge(fe),be=Ge(me),we=ne?ne.prototype:void 0,Me=we?we.valueOf:void 0;function Te(e){var t=-1,i=null==e?0:e.length;this.clear();for(;++t<i;){var n=e[t];this.set(n[0],n[1])}}Te.prototype.clear=function(){this.__data__=ge?ge(null):{};this.size=0};Te.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];this.size-=t?1:0;return t};Te.prototype.get=function(e){var t=this.__data__;if(ge){var i=t[e];return i===n?void 0:i}return Q.call(t,e)?t[e]:void 0};Te.prototype.has=function(e){var t=this.__data__;return ge?void 0!==t[e]:Q.call(t,e)};Te.prototype.set=function(e,t){var i=this.__data__;this.size+=this.has(e)?0:1;i[e]=ge&&void 0===t?n:t;return this};function Se(e){var t=-1,i=null==e?0:e.length;this.clear();for(;++t<i;){var n=e[t];this.set(n[0],n[1])}}Se.prototype.clear=function(){this.__data__=[];this.size=0};Se.prototype.delete=function(e){var t=this.__data__,i=Ie(t,e);if(i<0)return!1;i==t.length-1?t.pop():se.call(t,i,1);--this.size;return!0};Se.prototype.get=function(e){var t=this.__data__,i=Ie(t,e);return i<0?void 0:t[i][1]};Se.prototype.has=function(e){return Ie(this.__data__,e)>-1};Se.prototype.set=function(e,t){var i=this.__data__,n=Ie(i,e);if(n<0){++this.size;i.push([e,t])}else i[n][1]=t;return this};function Ee(e){var t=-1,i=null==e?0:e.length;this.clear();for(;++t<i;){var n=e[t];this.set(n[0],n[1])}}Ee.prototype.clear=function(){this.size=0;this.__data__={hash:new Te,map:new(pe||Se),string:new Te}};Ee.prototype.delete=function(e){var t=Be(this,e).delete(e);this.size-=t?1:0;return t};Ee.prototype.get=function(e){return Be(this,e).get(e)};Ee.prototype.has=function(e){return Be(this,e).has(e)};Ee.prototype.set=function(e,t){var i=Be(this,e),n=i.size;i.set(e,t);this.size+=i.size==n?0:1;return this};function Ae(e){var t=-1,i=null==e?0:e.length;this.__data__=new Ee;for(;++t<i;)this.add(e[t])}Ae.prototype.add=Ae.prototype.push=function(e){this.__data__.set(e,n);return this};Ae.prototype.has=function(e){return this.__data__.has(e)};function Ce(e){var t=this.__data__=new Se(e);this.size=t.size}Ce.prototype.clear=function(){this.__data__=new Se;this.size=0};Ce.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);this.size=t.size;return i};Ce.prototype.get=function(e){return this.__data__.get(e)};Ce.prototype.has=function(e){return this.__data__.has(e)};Ce.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Se){var n=i.__data__;if(!pe||n.length<199){n.push([e,t]);this.size=++i.size;return this}i=this.__data__=new Ee(n)}i.set(e,t);this.size=i.size;return this};function Le(e,t){var i=qe(e),n=!i&&We(e),r=!i&&!n&&$e(e),o=!i&&!n&&!r&&Qe(e),s=i||n||r||o,a=s?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],l=a.length;for(var c in e)!t&&!Q.call(e,c)||s&&("length"==c||r&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Ve(c,l))||a.push(c);return a}function Ie(e,t){for(var i=e.length;i--;)if(He(e[i][0],t))return i;return-1}function Pe(e){return null==e?void 0===e?S:_:ae&&ae in Object(e)?function(e){var t=Q.call(e,ae),i=e[ae];try{e[ae]=void 0;var n=!0}catch(e){}var r=ee.call(e);n&&(t?e[ae]=i:delete e[ae]);return r}(e):function(e){return ee.call(e)}(e)}function Re(e){return Je(e)&&Pe(e)==a}function ke(e,t,i,n,s){return e===t||(null==e||null==t||!Je(e)&&!Je(t)?e!=e&&t!=t:function(e,t,i,n,s,c){var d=qe(e),f=qe(t),_=d?l:je(e),v=f?l:je(t),x=(_=_==a?y:_)==y,S=(v=v==a?y:v)==y,E=_==v;if(E&&$e(e)){if(!$e(t))return!1;d=!0;x=!1}if(E&&!x){c||(c=new Ce);return d||Qe(e)?Oe(e,t,i,n,s,c):function(e,t,i,n,s,a,l){switch(i){case C:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer;t=t.buffer;case A:return!(e.byteLength!=t.byteLength||!a(new re(e),new re(t)));case u:case h:case g:return He(+e,+t);case p:return e.name==t.name&&e.message==t.message;case b:case M:return e==t+"";case m:var c=V;case w:var d=n&r;c||(c=G);if(e.size!=t.size&&!d)return!1;var f=l.get(e);if(f)return f==t;n|=o;l.set(e,t);var _=Oe(c(e),c(t),n,s,a,l);l.delete(e);return _;case T:if(Me)return Me.call(e)==Me.call(t)}return!1}(e,t,_,i,n,s,c)}if(!(i&r)){var L=x&&Q.call(e,"__wrapped__"),I=S&&Q.call(t,"__wrapped__");if(L||I){var P=L?e.value():e,R=I?t.value():t;c||(c=new Ce);return s(P,R,i,n,c)}}if(!E)return!1;c||(c=new Ce);return function(e,t,i,n,o,s){var a=i&r,l=Fe(e),c=l.length,u=Fe(t),h=u.length;if(c!=h&&!a)return!1;var p=c;for(;p--;){var d=l[p];if(!(a?d in t:Q.call(t,d)))return!1}var f=s.get(e);if(f&&s.get(t))return f==t;var m=!0;s.set(e,t);s.set(t,e);var g=a;for(;++p<c;){var _=e[d=l[p]],y=t[d];if(n)var v=a?n(y,_,d,t,e,s):n(_,y,d,e,t,s);if(!(void 0===v?_===y||o(_,y,i,n,s):v)){m=!1;break}g||(g="constructor"==d)}if(m&&!g){var x=e.constructor,b=t.constructor;x==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(m=!1)}s.delete(e);s.delete(t);return m}(e,t,i,n,s,c)}(e,t,i,n,ke,s))}function ze(e){return!(!Ye(e)||function(e){return!!K&&K in e}(e))&&(Ze(e)?te:L).test(Ge(e))}function De(e){if(!(t=e,i=t&&t.constructor,n="function"==typeof i&&i.prototype||X,t===n))return ue(e);var t,i,n,r=[];for(var o in Object(e))Q.call(e,o)&&"constructor"!=o&&r.push(o);return r}function Oe(e,t,i,n,s,a){var l=i&r,c=e.length,u=t.length;if(c!=u&&!(l&&u>c))return!1;var h=a.get(e);if(h&&a.get(t))return h==t;var p=-1,d=!0,f=i&o?new Ae:void 0;a.set(e,t);a.set(t,e);for(;++p<c;){var m=e[p],g=t[p];if(n)var _=l?n(g,m,p,t,e,a):n(m,g,p,e,t,a);if(void 0!==_){if(_)continue;d=!1;break}if(f){if(!j(t,(function(e,t){if(!(r=f,o=t,r.has(o))&&(m===e||s(m,e,i,n,a)))return f.push(t);var r,o}))){d=!1;break}}else if(m!==g&&!s(m,g,i,n,a)){d=!1;break}}a.delete(e);a.delete(t);return d}function Fe(e){return function(e,t,i){var n=t(e);return qe(e)?n:function(e,t){for(var i=-1,n=t.length,r=e.length;++i<n;)e[r+i]=t[i];return e}(n,i(e))}(e,Ke,Ue)}function Be(e,t){var i,n,r=e.__data__;return("string"==(n=typeof(i=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?r["string"==typeof t?"string":"hash"]:r.map}function Ne(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return ze(i)?i:void 0}var Ue=le?function(e){if(null==e)return[];e=Object(e);return function(e,t){for(var i=-1,n=null==e?0:e.length,r=0,o=[];++i<n;){var s=e[i];t(s,i,e)&&(o[r++]=s)}return o}(le(e),(function(t){return oe.call(e,t)}))}:function(){return[]},je=Pe;(he&&je(new he(new ArrayBuffer(1)))!=C||pe&&je(new pe)!=m||de&&je(de.resolve())!=v||fe&&je(new fe)!=w||me&&je(new me)!=E)&&(je=function(e){var t=Pe(e),i=t==y?e.constructor:void 0,n=i?Ge(i):"";if(n)switch(n){case _e:return C;case ye:return m;case ve:return v;case xe:return w;case be:return E}return t});function Ve(e,t){return!!(t=null==t?s:t)&&("number"==typeof e||I.test(e))&&e>-1&&e%1==0&&e<t}function Ge(e){if(null!=e){try{return J.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function He(e,t){return e===t||e!=e&&t!=t}var We=Re(function(){return arguments}())?Re:function(e){return Je(e)&&Q.call(e,"callee")&&!oe.call(e,"callee")},qe=Array.isArray;var $e=ce||function(){return!1};function Ze(e){if(!Ye(e))return!1;var t=Pe(e);return t==d||t==f||t==c||t==x}function Xe(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=s}function Ye(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Je(e){return null!=e&&"object"==typeof e}var Qe=U?function(e){return function(t){return e(t)}}(U):function(e){return Je(e)&&Xe(e.length)&&!!P[Pe(e)]};function Ke(e){return null!=(t=e)&&Xe(t.length)&&!Ze(t)?Le(e):De(e);var t}t.exports=function(e,t){return ke(e,t)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,t,i){(function(n){var r=e("lodash._reinterpolate"),o=e("lodash.templatesettings"),s=1/0,a=9007199254740991,l="[object Arguments]",c="[object AsyncFunction]",u="[object DOMException]",h="[object Error]",p="[object Function]",d="[object GeneratorFunction]",f="[object Null]",m="[object Object]",g="[object Proxy]",_="[object Symbol]",y="[object Undefined]",v=/\b__p \+= '';/g,x=/\b(__p \+=) '' \+/g,b=/(__e\(.*?\)|\b__t\)) \+\n'';/g,w=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,M=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,S=/($^)/,E=/['\n\r\u2028\u2029\\]/g,A={};A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0;A[l]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object Boolean]"]=A["[object DataView]"]=A["[object Date]"]=A[h]=A[p]=A["[object Map]"]=A["[object Number]"]=A[m]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object WeakMap]"]=!1;var C={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},L="object"==typeof n&&n&&n.Object===Object&&n,I="object"==typeof self&&self&&self.Object===Object&&self,P=L||I||Function("return this")(),R="object"==typeof i&&i&&!i.nodeType&&i,k=R&&"object"==typeof t&&t&&!t.nodeType&&t,z=k&&k.exports===R,D=z&&L.process,O=function(){try{var e=k&&k.require&&k.require("util").types;return e||D&&D.binding&&D.binding("util")}catch(e){}}(),F=O&&O.isTypedArray;function B(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}function N(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i<n;)r[i]=t(e[i],i,e);return r}function U(e){return"\\"+C[e]}function j(e,t){return function(i){return e(t(i))}}var V,G=Function.prototype,H=Object.prototype,W=P["__core-js_shared__"],q=G.toString,$=H.hasOwnProperty,Z=(V=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",X=H.toString,Y=q.call(Object),J=RegExp("^"+q.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Q=z?P.Buffer:void 0,K=P.Symbol,ee=j(Object.getPrototypeOf,Object),te=H.propertyIsEnumerable,ie=K?K.toStringTag:void 0,ne=function(){try{var e=function(e){if(!De(e)||function(e){return!!Z&&Z in e}(e))return!1;var t=ke(e)?J:M;return t.test(function(e){if(null!=e){try{return q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}(t=function(e,t){return null==e?void 0:e[t]}(Object,"defineProperty"))?t:void 0;e({},"",{});return e}catch(e){}var t}(),re=Q?Q.isBuffer:void 0,oe=j(Object.keys,Object),se=Math.max,ae=Date.now,le=K?K.prototype:void 0,ce=le?le.toString:void 0;function ue(e,t){var i=Le(e),n=!i&&Ce(e),r=!i&&!n&&Pe(e),o=!i&&!n&&!r&&Fe(e),s=i||n||r||o,a=s?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],l=a.length;for(var c in e)!t&&!$.call(e,c)||s&&("length"==c||r&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||xe(c,l))||a.push(c);return a}function he(e,t,i){var n=e[t];$.call(e,t)&&Ae(n,i)&&(void 0!==i||t in e)||pe(e,t,i)}function pe(e,t,i){"__proto__"==t&&ne?ne(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function de(e){return null==e?void 0===e?y:f:ie&&ie in Object(e)?function(e){var t=$.call(e,ie),i=e[ie];try{e[ie]=void 0;var n=!0}catch(e){}var r=X.call(e);n&&(t?e[ie]=i:delete e[ie]);return r}(e):function(e){return X.call(e)}(e)}function fe(e){return Oe(e)&&de(e)==l}function me(e){if(!De(e))return function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t}(e);var t=we(e),i=[];for(var n in e)("constructor"!=n||!t&&$.call(e,n))&&i.push(n);return i}function ge(e,t){return Ee(function(e,t,i){t=se(void 0===t?e.length-1:t,0);return function(){for(var n=arguments,r=-1,o=se(n.length-t,0),s=Array(o);++r<o;)s[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];a[t]=i(s);return B(e,this,a)}}(e,t,Ve),e+"")}var _e=ne?function(e,t){return ne(e,"toString",{configurable:!0,enumerable:!1,value:(i=t,function(){return i}),writable:!0});var i}:Ve;function ye(e){if("string"==typeof e)return e;if(Le(e))return N(e,ye)+"";if(function(e){return"symbol"==typeof e||Oe(e)&&de(e)==_}(e))return ce?ce.call(e):"";var t=e+"";return"0"==t&&1/e==-s?"-0":t}function ve(e,t,i,n){return void 0===e||Ae(e,H[i])&&!$.call(n,i)?t:e}function xe(e,t){var i=typeof e;return!!(t=null==t?a:t)&&("number"==i||"symbol"!=i&&T.test(e))&&e>-1&&e%1==0&&e<t}function be(e,t,i){if(!De(i))return!1;var n=typeof t;return!!("number"==n?Ie(i)&&xe(t,i.length):"string"==n&&t in i)&&Ae(i[t],e)}function we(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||H)}var Me,Te,Se,Ee=(Me=_e,Te=0,Se=0,function(){var e=ae(),t=16-(e-Se);Se=e;if(t>0){if(++Te>=800)return arguments[0]}else Te=0;return Me.apply(void 0,arguments)});function Ae(e,t){return e===t||e!=e&&t!=t}var Ce=fe(function(){return arguments}())?fe:function(e){return Oe(e)&&$.call(e,"callee")&&!te.call(e,"callee")},Le=Array.isArray;function Ie(e){return null!=e&&ze(e.length)&&!ke(e)}var Pe=re||function(){return!1};function Re(e){if(!Oe(e))return!1;var t=de(e);return t==h||t==u||"string"==typeof e.message&&"string"==typeof e.name&&!function(e){if(!Oe(e)||de(e)!=m)return!1;var t=ee(e);if(null===t)return!0;var i=$.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&q.call(i)==Y}(e)}function ke(e){if(!De(e))return!1;var t=de(e);return t==p||t==d||t==c||t==g}function ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function De(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Oe(e){return null!=e&&"object"==typeof e}var Fe=F?function(e){return function(t){return e(t)}}(F):function(e){return Oe(e)&&ze(e.length)&&!!A[de(e)]};var Be,Ne=(Be=function(e,t,i,n){!function(e,t,i,n){var r=!i;i||(i={});for(var o=-1,s=t.length;++o<s;){var a=t[o],l=n?n(i[a],e[a],a,i,e):void 0;void 0===l&&(l=e[a]);r?pe(i,a,l):he(i,a,l)}}(t,function(e){return Ie(e)?ue(e,!0):me(e)}(t),e,n)},ge((function(e,t){var i=-1,n=t.length,r=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;r=Be.length>3&&"function"==typeof r?(n--,r):void 0;if(o&&be(t[0],t[1],o)){r=n<3?void 0:r;n=1}e=Object(e);for(;++i<n;){var s=t[i];s&&Be(e,s,i,r)}return e})));function Ue(e){return Ie(e)?ue(e):function(e){if(!we(e))return oe(e);var t=[];for(var i in Object(e))$.call(e,i)&&"constructor"!=i&&t.push(i);return t}(e)}var je=ge((function(e,t){try{return B(e,void 0,t)}catch(e){return Re(e)?e:new Error(e)}}));function Ve(e){return e}t.exports=function(e,t,i){var n,s=o.imports._.templateSettings||o;i&&be(e,t,i)&&(t=void 0);e=null==(n=e)?"":ye(n);t=Ne({},t,s,ve);var a,l,c,u=Ne({},t.imports,s.imports,ve),h=Ue(u),p=(a=u,N(h,(function(e){return a[e]}))),d=0,f=t.interpolate||S,m="__p += '",g=RegExp((t.escape||S).source+"|"+f.source+"|"+(f===r?w:S).source+"|"+(t.evaluate||S).source+"|$","g"),_=$.call(t,"sourceURL")?"//# sourceURL="+(t.sourceURL+"").replace(/[\r\n]/g," ")+"\n":"";e.replace(g,(function(t,i,n,r,o,s){n||(n=r);m+=e.slice(d,s).replace(E,U);if(i){l=!0;m+="' +\n__e("+i+") +\n'"}if(o){c=!0;m+="';\n"+o+";\n__p += '"}n&&(m+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'");d=s+t.length;return t}));m+="';\n";var y=$.call(t,"variable")&&t.variable;y||(m="with (obj) {\n"+m+"\n}\n");m=(c?m.replace(v,""):m).replace(x,"$1").replace(b,"$1;");m="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(l?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var M=je((function(){return Function(h,_+"return "+m).apply(void 0,p)}));M.source=m;if(Re(M))throw M;return M}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash._reinterpolate":6,"lodash.templatesettings":10}],10:[function(e,t,i){(function(i){var n=e("lodash._reinterpolate"),r=1/0,o="[object Null]",s="[object Symbol]",a="[object Undefined]",l=/[&<>"']/g,c=RegExp(l.source),u="object"==typeof i&&i&&i.Object===Object&&i,h="object"==typeof self&&self&&self.Object===Object&&self,p=u||h||Function("return this")();var d,f=(d={"&":"&","<":"<",">":">",'"':""","'":"'"},function(e){return null==d?void 0:d[e]}),m=Object.prototype,g=m.hasOwnProperty,_=m.toString,y=p.Symbol,v=y?y.toStringTag:void 0,x=y?y.prototype:void 0,b=x?x.toString:void 0,w={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:n,variable:"",imports:{_:{escape:function(e){return(e=(t=e,null==t?"":T(t)))&&c.test(e)?e.replace(l,f):e;var t}}}};function M(e){return null==e?void 0===e?a:o:v&&v in Object(e)?function(e){var t=g.call(e,v),i=e[v];try{e[v]=void 0;var n=!0}catch(e){}var r=_.call(e);n&&(t?e[v]=i:delete e[v]);return r}(e):function(e){return _.call(e)}(e)}function T(e){if("string"==typeof e)return e;if(S(e))return function(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i<n;)r[i]=t(e[i],i,e);return r}(e,T)+"";if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&M(e)==s}(e))return b?b.call(e):"";var t=e+"";return"0"==t&&1/e==-r?"-0":t}var S=Array.isArray;t.exports=w}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash._reinterpolate":6}],11:[function(e,t,i){var n=e("./_root").Symbol;t.exports=n},{"./_root":18}],12:[function(e,t,i){var n=e("./_Symbol"),r=e("./_getRawTag"),o=e("./_objectToString"),s=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?r(e):o(e)}},{"./_Symbol":11,"./_getRawTag":15,"./_objectToString":16}],13:[function(e,t,i){(function(e){var i="object"==typeof e&&e&&e.Object===Object&&e;t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],14:[function(e,t,i){var n=e("./_overArg")(Object.getPrototypeOf,Object);t.exports=n},{"./_overArg":17}],15:[function(e,t,i){var n=e("./_Symbol"),r=Object.prototype,o=r.hasOwnProperty,s=r.toString,a=n?n.toStringTag:void 0;t.exports=function(e){var t=o.call(e,a),i=e[a];try{e[a]=void 0;var n=!0}catch(e){}var r=s.call(e);n&&(t?e[a]=i:delete e[a]);return r}},{"./_Symbol":11}],16:[function(e,t,i){var n=Object.prototype.toString;t.exports=function(e){return n.call(e)}},{}],17:[function(e,t,i){t.exports=function(e,t){return function(i){return e(t(i))}}},{}],18:[function(e,t,i){var n=e("./_freeGlobal"),r="object"==typeof self&&self&&self.Object===Object&&self,o=n||r||Function("return this")();t.exports=o},{"./_freeGlobal":13}],19:[function(e,t,i){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],20:[function(e,t,i){var n=e("./_baseGetTag"),r=e("./_getPrototype"),o=e("./isObjectLike"),s=Function.prototype,a=Object.prototype,l=s.toString,c=a.hasOwnProperty,u=l.call(Object);t.exports=function(e){if(!o(e)||"[object Object]"!=n(e))return!1;var t=r(e);if(null===t)return!0;var i=c.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&l.call(i)==u}},{"./_baseGetTag":12,"./_getPrototype":14,"./isObjectLike":19}],21:[function(e,t,i){var n,r,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();function l(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout){n=setTimeout;return setTimeout(e,0)}try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}var c,u=[],h=!1,p=-1;function d(){if(h&&c){h=!1;c.length?u=c.concat(u):p=-1;u.length&&f()}}function f(){if(!h){var e=l(d);h=!0;for(var t=u.length;t;){c=u;u=[];for(;++p<t;)c&&c[p].run();p=-1;t=u.length}c=null;h=!1;!function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout){r=clearTimeout;return clearTimeout(e)}try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];u.push(new m(e,t));1!==u.length||h||l(f)};function m(e,t){this.fun=e;this.array=t}m.prototype.run=function(){this.fun.apply(null,this.array)};o.title="browser";o.browser=!0;o.env={};o.argv=[];o.version="";o.versions={};function g(){}o.on=g;o.addListener=g;o.once=g;o.off=g;o.removeListener=g;o.removeAllListeners=g;o.emit=g;o.prependListener=g;o.prependOnceListener=g;o.listeners=function(e){return[]};o.binding=function(e){throw new Error("process.binding is not supported")};o.cwd=function(){return"/"};o.chdir=function(e){throw new Error("process.chdir is not supported")};o.umask=function(){return 0}},{}],22:[function(e,t,i){"use strict";i.__esModule=!0;function n(e){return function(t){var i=t.dispatch,n=t.getState;return function(t){return function(r){return"function"==typeof r?r(i,n,e):t(r)}}}}var r=n();r.withExtraArgument=n;i.default=r},{}],23:[function(e,t,i){"use strict";i.__esModule=!0;var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e};i.default=function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return function(e){return function(i,r,o){var a,l=e(i,r,o),c=l.dispatch,u={getState:l.getState,dispatch:function(e){return c(e)}};a=t.map((function(e){return e(u)}));c=s.default.apply(void 0,a)(l.dispatch);return n({},l,{dispatch:c})}}};var r,o=e("./compose"),s=(r=o)&&r.__esModule?r:{default:r}},{"./compose":26}],24:[function(e,t,i){"use strict";i.__esModule=!0;i.default=function(e,t){if("function"==typeof e)return n(e,t);if("object"!=typeof e||null===e)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var i=Object.keys(e),r={},o=0;o<i.length;o++){var s=i[o],a=e[s];"function"==typeof a&&(r[s]=n(a,t))}return r};function n(e,t){return function(){return t(e.apply(void 0,arguments))}}},{}],25:[function(e,t,i){(function(t){"use strict";i.__esModule=!0;i.default=function(e){for(var i=Object.keys(e),s={},l=0;l<i.length;l++){var c=i[l];"production"!==t.env.NODE_ENV&&void 0===e[c]&&(0,o.default)('No reducer provided for key "'+c+'"');"function"==typeof e[c]&&(s[c]=e[c])}var u=Object.keys(s),h=void 0;"production"!==t.env.NODE_ENV&&(h={});var p=void 0;try{!function(e){Object.keys(e).forEach((function(t){var i=e[t];if(void 0===i(void 0,{type:n.ActionTypes.INIT}))throw new Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===i(void 0,{type:"@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".")}))throw new Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+n.ActionTypes.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(s)}catch(e){p=e}return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments[1];if(p)throw p;if("production"!==t.env.NODE_ENV){var l=function(e,t,i,o){var s=Object.keys(t),a=i&&i.type===n.ActionTypes.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===s.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!(0,r.default)(e))return"The "+a+' has unexpected type of "'+{}.toString.call(e).match(/\s([a-z|A-Z]+)/)[1]+'". Expected argument to be an object with the following keys: "'+s.join('", "')+'"';var l=Object.keys(e).filter((function(e){return!t.hasOwnProperty(e)&&!o[e]}));l.forEach((function(e){o[e]=!0}));if(l.length>0)return"Unexpected "+(l.length>1?"keys":"key")+' "'+l.join('", "')+'" found in '+a+'. Expected to find one of the known reducer keys instead: "'+s.join('", "')+'". Unexpected keys will be ignored.'}(e,s,i,h);l&&(0,o.default)(l)}for(var c=!1,d={},f=0;f<u.length;f++){var m=u[f],g=s[m],_=e[m],y=g(_,i);if(void 0===y){var v=a(m,i);throw new Error(v)}d[m]=y;c=c||y!==_}return c?d:e}};var n=e("./createStore"),r=s(e("lodash/isPlainObject")),o=s(e("./utils/warning"));function s(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var i=t&&t.type;return"Given action "+(i&&'"'+i.toString()+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}}).call(this,e("_process"))},{"./createStore":27,"./utils/warning":29,_process:21,"lodash/isPlainObject":20}],26:[function(e,t,i){"use strict";i.__esModule=!0;i.default=function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(0===t.length)return function(e){return e};if(1===t.length)return t[0];return t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}},{}],27:[function(e,t,i){"use strict";i.__esModule=!0;i.ActionTypes=void 0;i.default=function e(t,i,o){var a;if("function"==typeof i&&void 0===o){o=i;i=void 0}if(void 0!==o){if("function"!=typeof o)throw new Error("Expected the enhancer to be a function.");return o(e)(t,i)}if("function"!=typeof t)throw new Error("Expected the reducer to be a function.");var l=t,c=i,u=[],h=u,p=!1;function d(){h===u&&(h=u.slice())}function f(){return c}function m(e){if("function"!=typeof e)throw new Error("Expected listener to be a function.");var t=!0;d();h.push(e);return function(){if(t){t=!1;d();var i=h.indexOf(e);h.splice(i,1)}}}function g(e){if(!(0,n.default)(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(p)throw new Error("Reducers may not dispatch actions.");try{p=!0;c=l(c,e)}finally{p=!1}for(var t=u=h,i=0;i<t.length;i++){(0,t[i])()}return e}g({type:s.INIT});return(a={dispatch:g,subscribe:m,getState:f,replaceReducer:function(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");l=e;g({type:s.INIT})}})[r.default]=function(){var e,t=m;return(e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Expected the observer to be an object.");function i(){e.next&&e.next(f())}i();return{unsubscribe:t(i)}}})[r.default]=function(){return this},e},a};var n=o(e("lodash/isPlainObject")),r=o(e("symbol-observable"));function o(e){return e&&e.__esModule?e:{default:e}}var s=i.ActionTypes={INIT:"@@redux/INIT"}},{"lodash/isPlainObject":20,"symbol-observable":33}],28:[function(e,t,i){(function(t){"use strict";i.__esModule=!0;i.compose=i.applyMiddleware=i.bindActionCreators=i.combineReducers=i.createStore=void 0;var n=l(e("./createStore")),r=l(e("./combineReducers")),o=l(e("./bindActionCreators")),s=l(e("./applyMiddleware")),a=l(e("./compose"));l(e("./utils/warning"));function l(e){return e&&e.__esModule?e:{default:e}}function c(){}"production"!==t.env.NODE_ENV&&"string"==typeof c.name&&c.name;i.createStore=n.default;i.combineReducers=r.default;i.bindActionCreators=o.default;i.applyMiddleware=s.default;i.compose=a.default}).call(this,e("_process"))},{"./applyMiddleware":23,"./bindActionCreators":24,"./combineReducers":25,"./compose":26,"./createStore":27,"./utils/warning":29,_process:21}],29:[function(e,t,i){"use strict";i.__esModule=!0;i.default=function(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}},{}],30:[function(e,t,i){"use strict";var n=e("./src/suggestions");window.Suggestions=t.exports=n},{"./src/suggestions":32}],31:[function(e,t,i){var n=function(e){this.component=e;this.items=[];this.active=0;this.element=document.createElement("ul");this.element.className="suggestions";this.selectingListItem=!1;e.el.parentNode.insertBefore(this.element,e.el.nextSibling);return this};n.prototype.show=function(){this.element.style.display="block"};n.prototype.hide=function(){this.element.style.display="none"};n.prototype.add=function(e){this.items.push(e)};n.prototype.clear=function(){this.items=[];this.active=0};n.prototype.isEmpty=function(){return!this.items.length};n.prototype.draw=function(){this.element.innerHTML="";if(0!==this.items.length){for(var e=0;e<this.items.length;e++)this.drawItem(this.items[e],this.active===e);this.show()}else this.hide()};n.prototype.drawItem=function(e,t){var i=document.createElement("li"),n=document.createElement("a");t&&(i.className+=" active");n.innerHTML=e.string;i.appendChild(n);this.element.appendChild(i);i.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this));i.addEventListener("mouseup",function(){this.handleMouseUp.call(this,e)}.bind(this))};n.prototype.handleMouseUp=function(e){this.selectingListItem=!1;this.component.value(e.original);this.clear();this.draw()};n.prototype.move=function(e){this.active=e;this.draw()};n.prototype.previous=function(){this.move(0===this.active?this.items.length-1:this.active-1)};n.prototype.next=function(){this.move(this.active===this.items.length-1?0:this.active+1)};t.exports=n},{}],32:[function(e,t,i){"use strict";var n=e("xtend"),r=e("fuzzy"),o=e("./list"),s=function(e,t,i){i=i||{};this.options=n({minLength:2,limit:5,filter:!0},i);this.el=e;this.data=t||[];this.list=new o(this);this.query="";this.selected=null;this.list.draw();this.el.addEventListener("keyup",function(e){this.handleKeyUp(e.keyCode)}.bind(this),!1);this.el.addEventListener("keydown",function(e){this.handleKeyDown(e)}.bind(this));this.el.addEventListener("focus",function(){this.handleFocus()}.bind(this));this.el.addEventListener("blur",function(){this.handleBlur()}.bind(this));this.el.addEventListener("paste",function(e){this.handlePaste(e)}.bind(this));return this};s.prototype.handleKeyUp=function(e){40!==e&&38!==e&&27!==e&&13!==e&&9!==e&&this.handleInputChange(this.el.value)};s.prototype.handleKeyDown=function(e){switch(e.keyCode){case 13:case 9:e.preventDefault();if(!this.list.isEmpty()){this.value(this.list.items[this.list.active].original);this.list.hide()}break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next()}};s.prototype.handleBlur=function(){this.list.selectingListItem||this.list.hide()};s.prototype.handlePaste=function(e){if(e.clipboardData)this.handleInputChange(e.clipboardData.getData("Text"));else{var t=this;setTimeout((function(){t.handleInputChange(e.target.value)}),100)}};s.prototype.handleInputChange=function(e){this.query=this.normalize(e);this.list.clear();this.query.length<this.options.minLength?this.list.draw():this.getCandidates(function(e){for(var t=0;t<e.length;t++){this.list.add(e[t]);if(t===this.options.limit-1)break}this.list.draw()}.bind(this))};s.prototype.handleFocus=function(){this.list.isEmpty()||this.list.show();this.list.selectingListItem=!1};s.prototype.update=function(e){this.data=e;this.handleKeyUp()};s.prototype.clear=function(){this.data=[];this.list.clear()};s.prototype.normalize=function(e){return e=e.toLowerCase()};s.prototype.match=function(e,t){return e.indexOf(t)>-1};s.prototype.value=function(e){this.selected=e;this.el.value=this.getItemValue(e);if(document.createEvent){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1);this.el.dispatchEvent(t)}else this.el.fireEvent("onchange")};s.prototype.getCandidates=function(e){var t={pre:"<strong>",post:"</strong>",extract:function(e){return this.getItemValue(e)}.bind(this)};e(this.options.filter?r.filter(this.query,this.data,t):this.data.map(function(e){for(var t=this.getItemValue(e),i=this.normalize(t),n=i.lastIndexOf(this.query);n>-1;){var r=n+this.query.length;t=t.slice(0,n)+"<strong>"+t.slice(n,r)+"</strong>"+t.slice(r);n=i.slice(0,n).lastIndexOf(this.query)}return{original:e,string:t}}.bind(this)))};s.prototype.getItemValue=function(e){return e};t.exports=s},{"./list":31,fuzzy:4,xtend:37}],33:[function(e,t,i){(function(n){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r,o,s=e("./ponyfill.js"),a=(r=s)&&r.__esModule?r:{default:r};o="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n?n:void 0!==t?t:Function("return this")();var l=(0,a.default)(o);i.default=l}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./ponyfill.js":34}],34:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.default=function(e){var t,i=e.Symbol;if("function"==typeof i)if(i.observable)t=i.observable;else{t=i("observable");i.observable=t}else t="@@observable";return t}},{}],35:[function(e,t,i){var n=e("turf-meta").coordEach;t.exports=function(e){var t=[1/0,1/0,-1/0,-1/0];n(e,(function(e){t[0]>e[0]&&(t[0]=e[0]);t[1]>e[1]&&(t[1]=e[1]);t[2]<e[0]&&(t[2]=e[0]);t[3]<e[1]&&(t[3]=e[1])}));return t}},{"turf-meta":36}],36:[function(e,t,i){function n(e,t,i){var n,r,o,s,a,c,u,h,p,d=0,f="FeatureCollection"===e.type,m="Feature"===e.type,g=f?e.features.length:1;for(n=0;n<g;n++){c=(p="GeometryCollection"===(h=f?e.features[n].geometry:m?e.geometry:e).type)?h.geometries.length:1;for(s=0;s<c;s++){u=(a=p?h.geometries[s]:h).coordinates;d=!i||"Polygon"!==a.type&&"MultiPolygon"!==a.type?0:1;if("Point"===a.type)t(u);else if("LineString"===a.type||"MultiPoint"===a.type)for(r=0;r<u.length;r++)t(u[r]);else if("Polygon"===a.type||"MultiLineString"===a.type)for(r=0;r<u.length;r++)for(o=0;o<u[r].length-d;o++)t(u[r][o]);else{if("MultiPolygon"!==a.type)throw new Error("Unknown Geometry Type");for(r=0;r<u.length;r++)for(o=0;o<u[r].length;o++)for(l=0;l<u[r][o].length-d;l++)t(u[r][o][l])}}}}t.exports.coordEach=n;t.exports.coordReduce=function(e,t,i,r){n(e,(function(e){i=t(i,e)}),r);return i};function r(e,t){var i;switch(e.type){case"FeatureCollection":features=e.features;for(i=0;i<e.features.length;i++)t(e.features[i].properties);break;case"Feature":t(e.properties)}}t.exports.propEach=r;t.exports.propReduce=function(e,t,i){r(e,(function(e){i=t(i,e)}));return i}},{}],37:[function(e,t,i){t.exports=function(){for(var e={},t=0;t<arguments.length;t++){var i=arguments[t];for(var r in i)n.call(i,r)&&(e[r]=i[r])}return e};var n=Object.prototype.hasOwnProperty},{}],38:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.queryOrigin=function(e){return{type:r.ORIGIN_QUERY,query:e}};i.queryDestination=function(e){return{type:r.DESTINATION_QUERY,query:e}};i.queryOriginCoordinates=m;i.queryDestinationCoordinates=g;i.clearOrigin=function(){return function(e){e({type:r.ORIGIN_CLEAR});e(x("clear",{type:"origin"}));e(f(null))}};i.clearDestination=function(){return function(e){e({type:r.DESTINATION_CLEAR});e(x("clear",{type:"destination"}));e(f(null))}};i.setOptions=function(e){return{type:r.SET_OPTIONS,options:e}};i.hoverMarker=function(e){return function(t){t(function(e){return{type:r.HOVER_MARKER,hoverMarker:e}}(e?s.default.createPoint(e,{id:"hover"}):{}))}};i.setRouteIndex=_;i.createOrigin=y;i.createDestination=v;i.setProfile=function(e){return function(t,i){var n=i(),o=n.origin,s=n.destination;t({type:r.DIRECTIONS_PROFILE,profile:e});t(x("profile",{profile:e}));o.geometry&&s.geometry&&t(p())}};i.reverse=function(){return function(e,t){var i=t();i.destination.geometry&&e(l(i.destination.geometry.coordinates));i.origin.geometry&&e(c(i.origin.geometry.coordinates));i.origin.geometry&&i.destination.geometry&&e(p());for(var n=document.getElementsByClassName("suggestions"),r=0;r<n.length;r++)n[r].style.visibility="hidden"}};i.setOriginFromCoordinates=function(e){return function(t){s.default.validCoords(e)||(e=[s.default.wrap(e[0]),s.default.wrap(e[1])]);if(isNaN(e[0])&&isNaN(e[1]))return t(f(new Error("Coordinates are not valid")));t(m(e));t(y(e))}};i.setDestinationFromCoordinates=function(e){return function(t){s.default.validCoords(e)||(e=[s.default.wrap(e[0]),s.default.wrap(e[1])]);if(isNaN(e[0])&&isNaN(e[1]))return t(f(new Error("Coordinates are not valid")));t(v(e));t(g(e))}};i.addWaypoint=function(e,t){return function(i,n){var r=n(),o=r.destination,s=r.waypoints;s.splice(e,0,d(t));i(h(s));o.geometry&&i(p())}};i.setWaypoint=function(e,t){return function(i,n){var r=n(),o=r.destination,s=r.waypoints;s[e]=d(t);i(h(s));o.geometry&&i(p())}};i.removeWaypoint=function(e){return function(t,i){var n=i(),r=n.destination,o=n.waypoints;t(h(o=o.filter((function(t){return!s.default.coordinateMatch(t,e)}))));r.geometry&&t(p())}};i.eventSubscribe=function(e,t){return function(i,n){var o=n().events;o[e]=o[e]||[];o[e].push(t);return{type:r.EVENTS,events:o}}};i.eventEmit=x;var n,r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t}(e("../constants/action_types")),o=e("../utils"),s=(n=o)&&n.__esModule?n:{default:n};var a=new XMLHttpRequest;function l(e){return function(t){var i=s.default.createPoint(e,{id:"origin","marker-symbol":"A"});t({type:r.ORIGIN,origin:i});t(x("origin",{feature:i}))}}function c(e){return function(t){var i=s.default.createPoint(e,{id:"destination","marker-symbol":"B"});t({type:r.DESTINATION,destination:i});t(x("destination",{feature:i}))}}function u(e){return function(t){t({type:r.DIRECTIONS,directions:e});t(x("route",{route:e}))}}function h(e){return{type:r.WAYPOINTS,waypoints:e}}function p(){return function(e,t){var i=t(),n=i.api,r=i.accessToken,o=i.routeIndex,s=i.profile,h=i.alternatives,p=i.congestion,d=i.destination,m=i.language,g=i.exclude;if(d&&d.geometry){var y=function(e){var t=e(),i=t.origin,n=t.destination,r=t.waypoints,o=[];o.push(i.geometry.coordinates.join(","));o.push(";");r.length&&r.forEach((function(e){o.push(e.geometry.coordinates.join(","));o.push(";")}));o.push(n.geometry.coordinates.join(","));return encodeURIComponent(o.join(""))}(t),v=[];v.push("geometries=polyline");h&&v.push("alternatives=true");p&&v.push("annotations=congestion");v.push("steps=true");v.push("overview=full");m&&v.push("language="+m);g&&v.push("exclude="+g);r&&v.push("access_token="+r);a.abort();a.open("GET",""+n+s+"/"+y+".json?"+v.join("&"),!0);a.onload=function(){if(!(a.status>=200&&a.status<400)){e(u([]));return e(f(JSON.parse(a.responseText).message))}var t=JSON.parse(a.responseText);if(t.error){e(u([]));return e(f(t.error))}e(f(null));t.routes[o]||e(_(0));e(u(t.routes));e(l(t.waypoints[0].location));e(c(t.waypoints[t.waypoints.length-1].location))};a.onerror=function(){e(u([]));return e(f(JSON.parse(a.responseText).message))};a.send()}}}function d(e){var t={id:"waypoint"};return Object.assign(e,{properties:e.properties?Object.assign(e.properties,t):t})}function f(e){return function(t){t({type:"ERROR",error:e});e&&t(x("error",{error:e}))}}function m(e){return{type:r.ORIGIN_FROM_COORDINATES,coordinates:e}}function g(e){return{type:r.DESTINATION_FROM_COORDINATES,coordinates:e}}function _(e){return{type:r.ROUTE_INDEX,routeIndex:e}}function y(e){return function(t,i){var n=i().destination;t(l(e));n.geometry&&t(p())}}function v(e){return function(t,i){var n=i().origin;t(c(e));n.geometry&&t(p())}}function x(e,t){var i=this;return function(n,o){var s=o().events;if(!s[e])return{type:r.EVENTS,events:s};for(var a=s[e].slice(),l=0;l<a.length;l++)a[l].call(i,t)}}},{"../constants/action_types":39,"../utils":47}],39:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.DESTINATION="DESTINATION",i.DESTINATION_CLEAR="DESTINATION_CLEAR",i.DESTINATION_QUERY="DESTINATION_QUERY",i.DESTINATION_FROM_COORDINATES="DESTINATION_FROM_COORDINATES",i.DIRECTIONS="DIRECTIONS",i.DIRECTIONS_PROFILE="DIRECTIONS_PROFILE",i.EVENTS="EVENTS",i.ERROR="ERROR",i.HOVER_MARKER="HOVER_MARKER",i.ORIGIN="ORIGIN",i.ORIGIN_CLEAR="ORIGIN_CLEAR",i.ORIGIN_QUERY="ORIGIN_QUERY",i.ORIGIN_FROM_COORDINATES="ORIGIN_FROM_COORDINATES",i.ROUTE_INDEX="ROUTE_INDEX",i.SET_OPTIONS="SET_OPTIONS",i.WAYPOINTS="WAYPOINTS"},{}],40:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n="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},r=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1;n.configurable=!0;"value"in n&&(n.writable=!0);Object.defineProperty(e,n.key,n)}}return function(t,i,n){i&&e(t.prototype,i);n&&e(t,n);return t}}(),o=c(e("suggestions")),s=c(e("lodash.debounce")),a=e("events"),l=c(e("../utils"));function c(e){return e&&e.__esModule?e:{default:e}}var u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);this._ev=new a.EventEmitter;this.options=t;this.api=t&&t.api||"https://api.mapbox.com/geocoding/v5/mapbox.places/"}r(e,[{key:"onAdd",value:function(e){this._map=e;this.request=new XMLHttpRequest;var t=document.createElement("div");t.className="mapboxgl-ctrl-geocoder";var i=document.createElement("span");i.className="geocoder-icon geocoder-icon-search";var n=this._inputEl=document.createElement("input");n.type="text";n.placeholder=this.options.placeholder;n.addEventListener("keydown",(0,s.default)(function(e){if(!e.target.value)return this._clearEl.classList.remove("active");e.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(e.keyCode)||this._queryFromInput(e.target.value)}.bind(this)),200);n.addEventListener("change",function(t){t.target.value&&this._clearEl.classList.add("active");var i=this._typeahead.selected;if(i){if(this.options.flyTo)if(i.bbox&&i.context&&i.context.length<=3||i.bbox&&!i.context){var n=i.bbox;e.fitBounds([[n[0],n[1]],[n[2],n[3]]])}else e.flyTo({center:i.center,zoom:this.options.zoom});this._input=i;this.fire("result",{result:i})}}.bind(this));var r=document.createElement("div");r.classList.add("geocoder-pin-right");var a=this._clearEl=document.createElement("button");a.className="geocoder-icon geocoder-icon-close";a.addEventListener("click",this._clear.bind(this));var l=this._loadingEl=document.createElement("span");l.className="geocoder-icon geocoder-icon-loading";r.appendChild(a);r.appendChild(l);t.appendChild(i);t.appendChild(n);t.appendChild(r);this.options.container&&(this.options.position=!1);this._typeahead=new o.default(n,[],{filter:!1});this._typeahead.getItemValue=function(e){return e.place_name};return t}},{key:"_geocode",value:function(e,t){this._loadingEl.classList.add("active");this.fire("loading");var i=this.options,n=["placeholder","zoom","flyTo","accessToken"],r=Object.keys(this.options).filter((function(e){return-1===n.indexOf(e)})).map((function(e){return e+"="+i[e]})),o=this.options.accessToken?this.options.accessToken:mapboxgl.accessToken;r.push("access_token="+o);this.request.abort();this.request.open("GET",this.api+encodeURIComponent(e.trim())+".json?"+r.join("&"),!0);this.request.onload=function(){this._loadingEl.classList.remove("active");if(this.request.status>=200&&this.request.status<400){var e=JSON.parse(this.request.responseText);if(e.features.length)this._clearEl.classList.add("active");else{this._clearEl.classList.remove("active");this._typeahead.selected=null}this.fire("results",{results:e.features});this._typeahead.update(e.features);return t(e.features)}this.fire("error",{error:JSON.parse(this.request.responseText).message})}.bind(this);this.request.onerror=function(){this._loadingEl.classList.remove("active");this.fire("error",{error:JSON.parse(this.request.responseText).message})}.bind(this);this.request.send()}},{key:"_queryFromInput",value:function(e){(e=e.trim())||this._clear();e.length>2&&this._geocode(e,function(e){this._results=e}.bind(this))}},{key:"_change",value:function(){var e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1);this._inputEl.dispatchEvent(e)}},{key:"_query",value:function(e){if(e){"object"===(void 0===e?"undefined":n(e))&&e.length&&(e=[l.default.wrap(e[0]),l.default.wrap(e[1])].join());this._geocode(e,function(e){if(e.length){var t=e[0];this._results=e;this._typeahead.selected=t;this._inputEl.value=t.place_name;this._change()}}.bind(this))}}},{key:"_setInput",value:function(e){if(e){"object"===(void 0===e?"undefined":n(e))&&e.length&&(e=[l.default.roundWithOriginalPrecision(l.default.wrap(e[0]),e[0]),l.default.roundWithOriginalPrecision(l.default.wrap(e[1]),e[1])].join());this._inputEl.value=e;this._input=null;this._typeahead.selected=null;this._typeahead.clear();this._change()}}},{key:"_clear",value:function(){this._input=null;this._inputEl.value="";this._typeahead.selected=null;this._typeahead.clear();this._change();this._inputEl.focus();this._clearEl.classList.remove("active");this.fire("clear")}},{key:"getResult",value:function(){return this._input}},{key:"query",value:function(e){this._query(e);return this}},{key:"setInput",value:function(e){this._setInput(e);return this}},{key:"on",value:function(e,t){this._ev.on(e,t);this._ev.on("error",(function(e){console.log(e)}));return this}},{key:"fire",value:function(e,t){this._ev.emit(e,t);return this}},{key:"off",value:function(e,t){this._ev.removeListener(e,t);return this}}]);return e}();i.default=u},{"../utils":47,events:3,"lodash.debounce":7,suggestions:30}],41:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1;n.configurable=!0;"value"in n&&(n.writable=!0);Object.defineProperty(e,n.key,n)}}return function(t,i,n){i&&e(t.prototype,i);n&&e(t,n);return t}}(),r=l(e("./geocoder")),o=l(e("lodash.template")),s=l(e("lodash.isequal")),a=l(e("turf-extent"));function l(e){return e&&e.__esModule?e:{default:e}}var c=(0,o.default)("<div class='mapbox-directions-component mapbox-directions-inputs'>\n <div class='mapbox-directions-component-keyline'>\n <div class='mapbox-directions-origin'>\n <label class='mapbox-form-label'>\n <span class='directions-icon directions-icon-depart'></span>\n </label>\n <div id='mapbox-directions-origin-input'></div>\n </div>\n\n <button\n class='directions-icon directions-icon-reverse directions-reverse js-reverse-inputs'\n title='Reverse origin & destination'>\n </button>\n\n <div class='mapbox-directions-destination'>\n <label class='mapbox-form-label'>\n <span class='directions-icon directions-icon-arrive'></span>\n </label>\n <div id='mapbox-directions-destination-input'></div>\n </div>\n </div>\n\n <% if (controls.profileSwitcher) { %>\n <div class='mapbox-directions-profile mapbox-directions-component-keyline mapbox-directions-clearfix'><input\n id='mapbox-directions-profile-driving-traffic'\n type='radio'\n name='profile'\n value='mapbox/driving-traffic'\n <% if (profile === 'mapbox/driving-traffic') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-driving-traffic'>Traffic</label>\n <input\n id='mapbox-directions-profile-driving'\n type='radio'\n name='profile'\n value='mapbox/driving'\n <% if (profile === 'mapbox/driving') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-driving'>Driving</label>\n <input\n id='mapbox-directions-profile-walking'\n type='radio'\n name='profile'\n value='mapbox/walking'\n <% if (profile === 'mapbox/walking') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-walking'>Walking</label>\n <input\n id='mapbox-directions-profile-cycling'\n type='radio'\n name='profile'\n value='mapbox/cycling'\n <% if (profile === 'mapbox/cycling') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-cycling'>Cycling</label>\n </div>\n <% } %>\n</div>\n"),u=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var o=i.getState(),s=o.originQuery,a=o.destinationQuery,l=o.profile,u=o.controls;t.innerHTML=c({originQuery:s,destinationQuery:a,profile:l,controls:u});this.container=t;this.actions=n;this.store=i;this._map=r;this.onAdd();this.render()}n(e,[{key:"animateToCoordinates",value:function(e,t){var i=this.store.getState(),n=i.origin,r=i.destination,o=i.routePadding;if(n.geometry&&r.geometry&&!(0,s.default)(n.geometry,r.geometry)){var l=(0,a.default)({type:"FeatureCollection",features:[n,r]});this._map.fitBounds([[l[0],l[1]],[l[2],l[3]]],{padding:o})}else this._map.flyTo({center:t})}},{key:"onAdd",value:function(){var e=this,t=this.actions,i=t.clearOrigin,n=t.clearDestination,o=t.createOrigin,s=t.createDestination,a=t.setProfile,l=t.reverse,c=this.store.getState(),u=c.geocoder,h=c.accessToken,p=c.flyTo,d=c.placeholderOrigin,f=c.placeholderDestination,m=c.zoom;this.originInput=new r.default(Object.assign({},{accessToken:h},u,{flyTo:p,placeholder:d,zoom:m}));var g=this.originInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-origin-input").appendChild(g);this.destinationInput=new r.default(Object.assign({},{accessToken:h},u,{flyTo:p,placeholder:f,zoom:m}));var _=this.destinationInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-destination-input").appendChild(_);this.originInput.on("result",(function(t){var i=t.result.center;o(i);e.animateToCoordinates("origin",i)}));this.originInput.on("clear",i);this.destinationInput.on("result",(function(t){var i=t.result.center;s(i);e.animateToCoordinates("destination",i)}));this.destinationInput.on("clear",n);var y=this.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(y,(function(e){e.addEventListener("change",(function(){a(e.value)}))}));this.container.querySelector(".js-reverse-inputs").addEventListener("click",(function(){var t=e.store.getState(),i=t.origin,n=t.destination;i&&e.actions.queryDestination(i.geometry.coordinates);n&&e.actions.queryOrigin(n.geometry.coordinates);l()}))}},{key:"render",value:function(){var e=this;this.store.subscribe((function(){var t=e.store.getState(),i=t.originQuery,n=t.destinationQuery,r=t.originQueryCoordinates,o=t.destinationQueryCoordinates;if(i){e.originInput.query(i);e.actions.queryOrigin(null)}if(n){e.destinationInput.query(n);e.actions.queryDestination(null)}if(r){e.originInput.setInput(r);e.animateToCoordinates("origin",r);e.actions.queryOriginCoordinates(null)}if(o){e.destinationInput.setInput(o);e.animateToCoordinates("destination",o);e.actions.queryDestinationCoordinates(null)}}))}}]);return e}();i.default=u},{"./geocoder":40,"lodash.isequal":8,"lodash.template":9,"turf-extent":35}],42:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1;n.configurable=!0;"value"in n&&(n.writable=!0);Object.defineProperty(e,n.key,n)}}return function(t,i,n){i&&e(t.prototype,i);n&&e(t,n);return t}}(),r=a(e("../utils")),o=a(e("lodash.template")),s=a(e("lodash.isequal"));function a(e){return e&&e.__esModule?e:{default:e}}var l=(0,o.default)("<div class='directions-control directions-control-directions'>\n <div class='mapbox-directions-component mapbox-directions-route-summary<% if (routes > 1) { %> mapbox-directions-multiple<% } %>'>\n <% if (routes > 1) { %>\n <div class='mapbox-directions-routes mapbox-directions-clearfix'>\n <% for (var i = 0; i < routes; i++) { %>\n <input type='radio' name='routes' id='<%= i %>' <% if (i === routeIndex) { %>checked<% } %>>\n <label for='<%= i %>' class='mapbox-directions-route'><%= i + 1 %></label>\n <% } %>\n </div>\n <% } %>\n <h1><%- duration %></h1>\n <span><%- distance %></span>\n </div>\n\n <div class='mapbox-directions-instructions'>\n <div class='mapbox-directions-instructions-wrapper'>\n <ol class='mapbox-directions-steps'>\n <% steps.forEach(function(step) { %>\n <%\n var distance = step.distance ? format(step.distance) : false;\n var icon = step.maneuver.modifier ? step.maneuver.modifier.replace(/\\s+/g, '-').toLowerCase() : step.maneuver.type.replace(/\\s+/g, '-').toLowerCase();\n\n if (step.maneuver.type === 'arrive' || step.maneuver.type === 'depart') {\n icon = step.maneuver.type;\n }\n\n if (step.maneuver.type === 'roundabout' || step.maneuver.type === 'rotary') {\n icon= 'roundabout';\n }\n\n var lng = step.maneuver.location[0];\n var lat = step.maneuver.location[1];\n %>\n <li\n data-lat='<%= lat %>'\n data-lng='<%= lng %>'\n class='mapbox-directions-step'>\n <span class='directions-icon directions-icon-<%= icon %>'></span>\n <div class='mapbox-directions-step-maneuver'>\n <%= step.maneuver.instruction %>\n </div>\n <% if (distance) { %>\n <div class='mapbox-directions-step-distance'>\n <%= distance %>\n </div>\n <% } %>\n </li>\n <% }); %>\n </ol>\n </div>\n </div>\n</div>\n"),c=(0,o.default)("<div class='directions-control directions-control-directions'>\n <div class='mapbox-directions-error'>\n <%= error %>\n </div>\n</div>\n"),u=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);this.container=t;this.actions=n;this.store=i;this._map=r;this.directions={};this.render()}n(e,[{key:"render",value:function(){var e=this;this.store.subscribe((function(){var t=e.actions,i=t.hoverMarker,n=t.setRouteIndex,o=e.store.getState(),a=o.routeIndex,u=o.unit,h=o.directions,p=o.error,d=o.compile,f=!(0,s.default)(h[a],e.directions);if(p)e.container.innerHTML=c({error:p});else if(h.length&&f){var m=e.directions=h[a];d&&m.legs.forEach((function(e){e.steps.forEach((function(e){e.maneuver.instruction=d("en",e)}))}));e.container.innerHTML=l({routeIndex:a,routes:h.length,steps:m.legs[0].steps,format:r.default.format[u],duration:r.default.format[u](m.distance),distance:r.default.format.duration(m.duration)});var g=e.container.querySelectorAll(".mapbox-directions-step");Array.prototype.forEach.call(g,(function(t){var n=t.getAttribute("data-lng"),r=t.getAttribute("data-lat");t.addEventListener("mouseover",(function(){i([n,r])}));t.addEventListener("mouseout",(function(){i(null)}));t.addEventListener("click",(function(){e._map.flyTo({center:[n,r],zoom:16})}))}));var _=e.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(_,(function(e){e.addEventListener("change",(function(e){n(parseInt(e.target.id,10))}))}))}else e.container.innerHTML&&f&&(e.container.innerHTML="")}))}}]);return e}();i.default=u},{"../utils":47,"lodash.isequal":8,"lodash.template":9}],43:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1;n.configurable=!0;"value"in n&&(n.writable=!0);Object.defineProperty(e,n.key,n)}}return function(t,i,n){i&&e(t.prototype,i);n&&e(t,n);return t}}(),r=e("redux"),o=d(e("redux-thunk")),s=e("@mapbox/polyline"),a=d(e("./utils")),l=d(e("./reducers")),c=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t}(e("./actions")),u=d(e("./directions_style")),h=d(e("./controls/inputs")),p=d(e("./controls/instructions"));function d(e){return e&&e.__esModule?e:{default:e}}var f=(0,r.applyMiddleware)(o.default)(r.createStore)(l.default),m=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);this.actions=(0,r.bindActionCreators)(c,f.dispatch);this.actions.setOptions(t||{});this.options=t||{};this.onDragDown=this._onDragDown.bind(this);this.onDragMove=this._onDragMove.bind(this);this.onDragUp=this._onDragUp.bind(this);this.move=this._move.bind(this);this.onClick=this._clickHandler().bind(this)}n(e,[{key:"onAdd",value:function(e){var t=this;this._map=e;var i=f.getState().controls,n=this.container=document.createElement("div");n.className="mapboxgl-ctrl-directions mapboxgl-ctrl";var r=document.createElement("div");r.className="directions-control directions-control-inputs";new h.default(r,f,this.actions,this._map);var o=document.createElement("div");o.className="directions-control directions-control-instructions";new p.default(o,f,{hoverMarker:this.actions.hoverMarker,setRouteIndex:this.actions.setRouteIndex},this._map);i.inputs&&n.appendChild(r);i.instructions&&n.appendChild(o);this.subscribedActions();this._map.loaded()?this.mapState():this._map.on("load",(function(){return t.mapState()}));return n}},{key:"onRemove",value:function(e){this.container.parentNode.removeChild(this.container);this.removeRoutes();e.off("mousedown",this.onDragDown);e.off("mousemove",this.move);e.off("touchstart",this.onDragDown);e.off("touchstart",this.move);e.off("click",this.onClick);if(this.storeUnsubscribe){this.storeUnsubscribe();delete this.storeUnsubscribe}u.default.forEach((function(t){e.getLayer(t.id)&&e.removeLayer(t.id)}));e.getSource("directions")&&e.removeSource("directions");this._map=null;return this}},{key:"mapState",value:function(){var e=this,t=f.getState(),i=t.profile,n=(t.alternatives,t.congestion,t.styles),r=t.interactive;t.compile;this.actions.eventEmit("profile",{profile:i});this._map.addSource("directions",{type:"geojson",data:{type:"FeatureCollection",features:[]}});n&&n.length&&n.forEach((function(t){return e._map.addLayer(t)}));u.default.forEach((function(t){e._map.getLayer(t.id)||e._map.addLayer(t)}));if(r){this._map.on("mousedown",this.onDragDown);this._map.on("mousemove",this.move);this._map.on("click",this.onClick);this._map.on("touchstart",this.move);this._map.on("touchstart",this.onDragDown)}}},{key:"subscribedActions",value:function(){var e=this;this.storeUnsubscribe=f.subscribe((function(){var t=f.getState(),i=t.origin,n=t.destination,r=t.hoverMarker,o=t.directions,a=t.routeIndex,l={type:"FeatureCollection",features:[i,n,r].filter((function(e){return e.geometry}))};o.length&&o.forEach((function(e,t){var i=[];(0,s.decode)(e.geometry,5).map((function(e){return e.reverse()})).forEach((function(n,r){var o=i[i.length-1],s=e.legs[0].annotation&&e.legs[0].annotation.congestion&&e.legs[0].annotation.congestion[r-1];if(!o||s&&o.properties.congestion!==s){var l={geometry:{type:"LineString",coordinates:[]},properties:{"route-index":t,route:t===a?"selected":"alternate"}};o&&l.geometry.coordinates.push(o.geometry.coordinates[o.geometry.coordinates.length-1]);l.geometry.coordinates.push(n);s&&(l.properties.congestion=e.legs[0].annotation.congestion[r-1]);i.push(l)}else o.geometry.coordinates.push(n)}));l.features=l.features.concat(i);t===a&&e.legs[0].steps.forEach((function(e){"waypoint"===e.maneuver.type&&l.features.push({type:"Feature",geometry:e.maneuver.location,properties:{id:"waypoint"}})}))}));e._map.style&&e._map.getSource("directions")&&e._map.getSource("directions").setData(l)}))}},{key:"_clickHandler",value:function(){var e=null;return function(t){if(e){clearTimeout(e);e=null;this._map.zoomIn()}else{var i=this._onSingleClick.bind(this);e=setTimeout((function(){i(t);e=null}),250)}}}},{key:"_onSingleClick",value:function(e){var t=this,i=f.getState().origin,n=[e.lngLat.lng,e.lngLat.lat];if(i.geometry){var r=this._map.queryRenderedFeatures(e.point,{layers:["directions-origin-point","directions-destination-point","directions-waypoint-point","directions-route-line-alt"]});if(r.length){r.forEach((function(e){"directions-waypoint-point"===e.layer.id&&t.actions.removeWaypoint(e)}));if("alternate"===r[0].properties.route){var o=r[0].properties["route-index"];this.actions.setRouteIndex(o)}}else{this.actions.setDestinationFromCoordinates(n);this._map.flyTo({center:n})}}else this.actions.setOriginFromCoordinates(n)}},{key:"_move",value:function(e){var t=this,i=f.getState().hoverMarker,n=this._map.queryRenderedFeatures(e.point,{layers:["directions-route-line-alt","directions-route-line","directions-origin-point","directions-destination-point","directions-hover-point"]});this._map.getCanvas().style.cursor=n.length?"pointer":"";if(n.length){this.isCursorOverPoint=n[0];this._map.dragPan.disable();n.forEach((function(n){"directions-route-line"===n.layer.id?t.actions.hoverMarker([e.lngLat.lng,e.lngLat.lat]):i.geometry&&t.actions.hoverMarker(null)}))}else if(this.isCursorOverPoint){this.isCursorOverPoint=!1;this._map.dragPan.enable()}}},{key:"_onDragDown",value:function(){if(this.isCursorOverPoint){this.isDragging=this.isCursorOverPoint;this._map.getCanvas().style.cursor="grab";this._map.on("mousemove",this.onDragMove);this._map.on("mouseup",this.onDragUp);this._map.on("touchmove",this.onDragMove);this._map.on("touchend",this.onDragUp)}}},{key:"_onDragMove",value:function(e){if(this.isDragging){var t=[e.lngLat.lng,e.lngLat.lat];switch(this.isDragging.layer.id){case"directions-origin-point":this.actions.createOrigin(t);break;case"directions-destination-point":this.actions.createDestination(t);break;case"directions-hover-point":this.actions.hoverMarker(t)}}}},{key:"_onDragUp",value:function(){if(this.isDragging){var e=f.getState(),t=e.hoverMarker,i=e.origin,n=e.destination;switch(this.isDragging.layer.id){case"directions-origin-point":this.actions.setOriginFromCoordinates(i.geometry.coordinates);break;case"directions-destination-point":this.actions.setDestinationFromCoordinates(n.geometry.coordinates);break;case"directions-hover-point":t.geometry&&!a.default.coordinateMatch(this.isDragging,t)&&this.actions.addWaypoint(0,t)}this.isDragging=!1;this._map.getCanvas().style.cursor="";this._map.off("touchmove",this.onDragMove);this._map.off("touchend",this.onDragUp);this._map.off("mousemove",this.onDragMove);this._map.off("mouseup",this.onDragUp)}}},{key:"interactive",value:function(e){if(e){this._map.on("touchstart",this.move);this._map.on("touchstart",this.onDragDown);this._map.on("mousedown",this.onDragDown);this._map.on("mousemove",this.move);this._map.on("click",this.onClick)}else{this._map.off("touchstart",this.move);this._map.off("touchstart",this.onDragDown);this._map.off("mousedown",this.onDragDown);this._map.off("mousemove",this.move);this._map.off("click",this.onClick)}return this}},{key:"getOrigin",value:function(){return f.getState().origin}},{key:"setOrigin",value:function(e){"string"==typeof e?this.actions.queryOrigin(e):this.actions.setOriginFromCoordinates(e);return this}},{key:"getDestination",value:function(){return f.getState().destination}},{key:"setDestination",value:function(e){"string"==typeof e?this.actions.queryDestination(e):this.actions.setDestinationFromCoordinates(e);return this}},{key:"reverse",value:function(){this.actions.reverse();return this}},{key:"addWaypoint",value:function(e,t){t.type||(t=a.default.createPoint(t,{id:"waypoint"}));this.actions.addWaypoint(e,t);return this}},{key:"setWaypoint",value:function(e,t){t.type||(t=a.default.createPoint(t,{id:"waypoint"}));this.actions.setWaypoint(e,t);return this}},{key:"removeWaypoint",value:function(e){var t=f.getState().waypoints;this.actions.removeWaypoint(t[e]);return this}},{key:"getWaypoints",value:function(){return f.getState().waypoints}},{key:"removeRoutes",value:function(){this.actions.clearOrigin();this.actions.clearDestination();return this}},{key:"on",value:function(e,t){this.actions.eventSubscribe(e,t);return this}}]);return e}();i.default=m},{"./actions":38,"./controls/inputs":41,"./controls/instructions":42,"./directions_style":44,"./reducers":46,"./utils":47,"@mapbox/polyline":1,redux:28,"redux-thunk":22}],44:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.default=[{id:"directions-route-line-alt",type:"line",source:"directions",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#bbb","line-width":4},filter:["all",["in","$type","LineString"],["in","route","alternate"]]},{id:"directions-route-line-casing",type:"line",source:"directions",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2d5f99","line-width":12},filter:["all",["in","$type","LineString"],["in","route","selected"]]},{id:"directions-route-line",type:"line",source:"directions",layout:{"line-cap":"butt","line-join":"round"},paint:{"line-color":{property:"congestion",type:"categorical",default:"#4882c5",stops:[["unknown","#4882c5"],["low","#4882c5"],["moderate","#f09a46"],["heavy","#e34341"],["severe","#8b2342"]]},"line-width":7},filter:["all",["in","$type","LineString"],["in","route","selected"]]},{id:"directions-hover-point-casing",type:"circle",source:"directions",paint:{"circle-radius":8,"circle-color":"#fff"},filter:["all",["in","$type","Point"],["in","id","hover"]]},{id:"directions-hover-point",type:"circle",source:"directions",paint:{"circle-radius":6,"circle-color":"#3bb2d0"},filter:["all",["in","$type","Point"],["in","id","hover"]]},{id:"directions-waypoint-point-casing",type:"circle",source:"directions",paint:{"circle-radius":8,"circle-color":"#fff"},filter:["all",["in","$type","Point"],["in","id","waypoint"]]},{id:"directions-waypoint-point",type:"circle",source:"directions",paint:{"circle-radius":6,"circle-color":"#8a8bc9"},filter:["all",["in","$type","Point"],["in","id","waypoint"]]},{id:"directions-origin-point",type:"circle",source:"directions",paint:{"circle-radius":18,"circle-color":"#3bb2d0"},filter:["all",["in","$type","Point"],["in","marker-symbol","A"]]},{id:"directions-origin-label",type:"symbol",source:"directions",layout:{"text-field":"A","text-font":["Open Sans Bold","Arial Unicode MS Bold"],"text-size":12},paint:{"text-color":"#fff"},filter:["all",["in","$type","Point"],["in","marker-symbol","A"]]},{id:"directions-destination-point",type:"circle",source:"directions",paint:{"circle-radius":18,"circle-color":"#8a8bc9"},filter:["all",["in","$type","Point"],["in","marker-symbol","B"]]},{id:"directions-destination-label",type:"symbol",source:"directions",layout:{"text-field":"B","text-font":["Open Sans Bold","Arial Unicode MS Bold"],"text-size":12},paint:{"text-color":"#fff"},filter:["all",["in","$type","Point"],["in","marker-symbol","B"]]}]},{}],45:[function(e,t,i){"use strict";var n,r=e("./directions"),o=(n=r)&&n.__esModule?n:{default:n};t.exports=o.default},{"./directions":43}],46:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n,r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t}(e("../constants/action_types.js")),o=e("deep-assign"),s=(n=o)&&n.__esModule?n:{default:n};var a={api:"https://api.mapbox.com/directions/v5/",profile:"mapbox/driving-traffic",alternatives:!1,congestion:!1,unit:"imperial",flyTo:!0,placeholderOrigin:"Choose a starting place",placeholderDestination:"Choose destination",zoom:16,language:"en",compile:null,proximity:!1,styles:[],controls:{profileSwitcher:!0,inputs:!0,instructions:!0},geocoder:{},interactive:!0,events:{},origin:{},destination:{},hoverMarker:{},waypoints:[],originQuery:null,destinationQuery:null,originQueryCoordinates:null,destinationQueryCoordinates:null,directions:[],routeIndex:0,routePadding:80};i.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,t=arguments[1];switch(t.type){case r.SET_OPTIONS:return(0,s.default)({},e,t.options);case r.DIRECTIONS_PROFILE:return Object.assign({},e,{profile:t.profile});case r.ORIGIN:return Object.assign({},e,{origin:t.origin,hoverMarker:{}});case r.DESTINATION:return Object.assign({},e,{destination:t.destination,hoverMarker:{}});case r.HOVER_MARKER:return Object.assign({},e,{hoverMarker:t.hoverMarker});case r.WAYPOINTS:return Object.assign({},e,{waypoints:t.waypoints});case r.ORIGIN_QUERY:return Object.assign({},e,{originQuery:t.query});case r.DESTINATION_QUERY:return Object.assign({},e,{destinationQuery:t.query});case r.ORIGIN_FROM_COORDINATES:return Object.assign({},e,{originQueryCoordinates:t.coordinates});case r.DESTINATION_FROM_COORDINATES:return Object.assign({},e,{destinationQueryCoordinates:t.coordinates});case r.ORIGIN_CLEAR:return Object.assign({},e,{origin:{},originQuery:"",waypoints:[],directions:[]});case r.DESTINATION_CLEAR:return Object.assign({},e,{destination:{},destinationQuery:"",waypoints:[],directions:[]});case r.DIRECTIONS:return Object.assign({},e,{directions:t.directions});case r.ROUTE_INDEX:return Object.assign({},e,{routeIndex:t.routeIndex});case r.ERROR:return Object.assign({},e,{error:t.error});default:return e}}},{"../constants/action_types.js":39,"deep-assign":2}],47:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={duration:function(e){var t=Math.floor(e/60),i=Math.floor(t/60);e%=60;t%=60;return 0===i&&0===t?e+"s":0===i?t+"min":i+"h "+t+"min"},imperial:function(e){var t=e/1609.344;return t>=100?t.toFixed(0)+"mi":t>=10?t.toFixed(1)+"mi":t>=.1?t.toFixed(2)+"mi":(5280*t).toFixed(0)+"ft"},metric:function(e){return e>=1e5?(e/1e3).toFixed(0)+"km":e>=1e4?(e/1e3).toFixed(1)+"km":e>=100?(e/1e3).toFixed(2)+"km":e.toFixed(0)+"m"}};i.default={format:n,coordinateMatch:function(e,t){e=e.geometry.coordinates;t=t.geometry.coordinates;return e.join()===t.join()||e[0].toFixed(3)===t[0].toFixed(3)&&e[1].toFixed(3)===t[1].toFixed(3)},createPoint:function(e,t){return{type:"Feature",geometry:{type:"Point",coordinates:e},properties:t||{}}},validCoords:function(e){return e[0]>=-180&&e[0]<=180&&e[1]>=-90&&e[1]<=90},wrap:function(e){var t=((e- -180)%360+360)%360-180;return-180===t?180:t},roundWithOriginalPrecision:function(e,t){var i=0;Math.floor(t)!==t&&(i=t.toString().split(".")[1].length);return e.toFixed(Math.min(i,5))}}},{}]},{},[45])(45)}));!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MapboxGeocoder=e()}}((function(){return function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(e,t,i){"use strict";function n(e){this.origin=e.origin||"https://api.mapbox.com",this.endpoint="events/v2",this.access_token=e.accessToken,this.version="0.2.0",this.sessionID=this.generateSessionID(),this.userAgent=this.getUserAgent(),this.options=e,this.send=this.send.bind(this),this.countries=e.countries?e.countries.split(","):null,this.types=e.types?e.types.split(","):null,this.bbox=e.bbox?e.bbox:null,this.language=e.language?e.language.split(","):null,this.limit=e.limit?+e.limit:null,this.locale=navigator.language||null,this.enableEventLogging=this.shouldEnableLogging(e),this.eventQueue=new Array,this.flushInterval=e.flushInterval||1e3,this.maxQueueSize=e.maxQueueSize||100,this.timer=this.flushInterval?setTimeout(this.flush.bind(this),this.flushInterval):null,this.lastSentInput="",this.lastSentIndex=0}var r=e("nanoid");n.prototype={select:function(e,t){var i=this.getSelectedIndex(e,t),n=this.getEventPayload("search.select",t);if(n.resultIndex=i,n.resultPlaceName=e.place_name,n.resultId=e.id,(i!==this.lastSentIndex||n.queryString!==this.lastSentInput)&&-1!=i&&(this.lastSentIndex=i,this.lastSentInput=n.queryString,n.queryString))return this.push(n)},start:function(e){var t=this.getEventPayload("search.start",e);if(t.queryString)return this.push(t)},keyevent:function(e,t){if(e.key&&!e.metaKey&&-1===[9,27,37,39,13,38,40].indexOf(e.keyCode)){var i=this.getEventPayload("search.keystroke",t);if(i.lastAction=e.key,i.queryString)return this.push(i)}},send:function(e,t){if(this.enableEventLogging){var i=this.getRequestOptions(e);this.request(i,function(e){return e?this.handleError(e,t):t?t():void 0}.bind(this))}else if(t)return t()},getRequestOptions:function(e){return Array.isArray(e)||(e=[e]),{method:"POST",host:this.origin,path:this.endpoint+"?access_token="+this.access_token,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}},getEventPayload:function(e,t){var i;i=t.options.proximity?[t.options.proximity.longitude,t.options.proximity.latitude]:null;var n=t._map?t._map.getZoom():void 0,r={event:e,created:+new Date,sessionIdentifier:this.sessionID,country:this.countries,userAgent:this.userAgent,language:this.language,bbox:this.bbox,types:this.types,endpoint:"mapbox.places",proximity:i,limit:t.options.limit,mapZoom:n,keyboardLocale:this.locale};return"search.select"===e?r.queryString=t.inputString:"search.select"!=e&&t._inputEl?r.queryString=t._inputEl.value:r.queryString=t.inputString,r},request:function(e,t){var i=new XMLHttpRequest;i.onreadystatechange=function(){if(4==this.readyState)return t(204==this.status?null:this.statusText)},i.open(e.method,e.host+"/"+e.path,!0);for(var n in e.headers){var r=e.headers[n];i.setRequestHeader(n,r)}i.send(e.body)},handleError:function(e,t){if(t)return t(e)},generateSessionID:function(){return r()},getUserAgent:function(){return"mapbox-gl-geocoder."+this.version+"."+navigator.userAgent},getSelectedIndex:function(e,t){if(t._typeahead){var i=t._typeahead.data,n=e.id;return i.map((function(e){return e.id})).indexOf(n)}},shouldEnableLogging:function(e){return!(!1===e.enableEventLogging||e.origin&&-1==e.origin.indexOf("api.mapbox.com")||e.localGeocoder||e.filter)},flush:function(){this.eventQueue.length>0&&(this.send(this.eventQueue),this.eventQueue=new Array),this.timer&&clearTimeout(this.timer),this.flushInterval&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))},push:function(e,t){this.eventQueue.push(e),(this.eventQueue.length>=this.maxQueueSize||t)&&this.flush()},remove:function(){this.flush()}},t.exports=n},{nanoid:30}],2:[function(e,t,i){t.exports={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}}},{}],3:[function(e,t,i){"use strict";function n(e){this._eventEmitter=new a,this.options=s({},this.options,e),this.inputString="",this.fresh=!0,this.lastSelected=null}var r=e("suggestions"),o=e("lodash.debounce"),s=e("xtend"),a=e("events").EventEmitter,l=e("./exceptions"),c=e("@mapbox/mapbox-sdk"),u=e("@mapbox/mapbox-sdk/services/geocoding"),h=e("./events"),p=e("./localization"),d=e("subtag");const f=0,m=1,g=2;n.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,reverseGeocode:!1,limit:5,origin:"https://api.mapbox.com",enableEventLogging:!0,marker:!0,mapboxgl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,getItemValue:function(e){return e.place_name},render:function(e){var t=e.place_name.split(",");return'<div class="mapboxgl-ctrl-geocoder--suggestion"><div class="mapboxgl-ctrl-geocoder--suggestion-title">'+t[0]+'</div><div class="mapboxgl-ctrl-geocoder--suggestion-address">'+t.splice(1,t.length).join(",")+"</div></div>"}},addTo:function(e){function t(e,t){if(!document.body.contains(t))throw new Error("Element provided to #addTo() exists, but is not in the DOM");const i=e.onAdd();t.appendChild(i)}if(e._controlContainer)e.addControl(this);else if(e instanceof HTMLElement)t(this,e);else{if("string"!=typeof e)throw new Error("Error: addTo must be a mapbox-gl-js map, an html element, or a CSS selector query for a single html element");const i=document.querySelectorAll(e);if(0===i.length)throw new Error("Element ",e,"not found.");if(i.length>1)throw new Error("Geocoder can only be added to a single html element");t(this,i[0])}},onAdd:function(e){if(e&&"string"!=typeof e&&(this._map=e),this.setLanguage(),this.options.localGeocoderOnly||(this.geocoderService=u(c({accessToken:this.options.accessToken,origin:this.options.origin}))),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this.eventManager=new h(this.options),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this);var t=this.container=document.createElement("div");t.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var i=this.createIcon("search",'<path d="M7.4 2.5c-2.7 0-4.9 2.2-4.9 4.9s2.2 4.9 4.9 4.9c1 0 1.8-.2 2.5-.8l3.7 3.7c.2.2.4.3.8.3.7 0 1.1-.4 1.1-1.1 0-.3-.1-.5-.3-.8L11.4 10c.4-.8.8-1.6.8-2.5.1-2.8-2.1-5-4.8-5zm0 1.6c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2-3.3-1.3-3.3-3.1 1.4-3.3 3.3-3.3z"/>');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",o(this._onKeyDown,200)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",function(e){this.eventManager.keyevent(e,this)}.bind(this));var n=document.createElement("div");n.classList.add("mapboxgl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button";var s=this.createIcon("close",'<path d="M3.8 2.5c-.6 0-1.3.7-1.3 1.3 0 .3.2.7.5.8L7.2 9 3 13.2c-.3.3-.5.7-.5 1 0 .6.7 1.3 1.3 1.3.3 0 .7-.2 1-.5L9 10.8l4.2 4.2c.2.3.7.3 1 .3.6 0 1.3-.7 1.3-1.3 0-.3-.2-.7-.3-1l-4.4-4L15 4.6c.3-.2.5-.5.5-.8 0-.7-.7-1.3-1.3-1.3-.3 0-.7.2-1 .3L9 7.1 4.8 2.8c-.3-.1-.7-.3-1-.3z"/>');return this._clearEl.appendChild(s),this._loadingEl=this.createIcon("loading",'<path fill="#333" d="M4.4 4.4l.8.8c2.1-2.1 5.5-2.1 7.6 0l.8-.8c-2.5-2.5-6.7-2.5-9.2 0z"/><path opacity=".1" d="M12.8 12.9c-2.1 2.1-5.5 2.1-7.6 0-2.1-2.1-2.1-5.5 0-7.7l-.8-.8c-2.5 2.5-2.5 6.7 0 9.2s6.6 2.5 9.2 0 2.5-6.6 0-9.2l-.8.8c2.2 2.1 2.2 5.6 0 7.7z"/>'),n.appendChild(this._clearEl),n.appendChild(this._loadingEl),t.appendChild(i),t.appendChild(this._inputEl),t.appendChild(n),this._typeahead=new r(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit}),this.setRenderFunction(this.options.render),this._typeahead.getItemValue=this.options.getItemValue,this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._mapboxgl=this.options.mapboxgl,!this._mapboxgl&&this.options.marker&&(console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."),this.options.marker=!1)),t},createIcon:function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+e),i.setAttribute("viewBox","0 0 18 18"),i.setAttribute("xml:space","preserve"),i.setAttribute("width",18),i.setAttribute("height",18),"innerHTML"in i)i.innerHTML=t;else{var n=document.createElement("div");n.innerHTML="<svg>"+t.valueOf().toString()+"</svg>";var r=n.firstChild.firstChild;i.appendChild(r)}return i},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_onPaste:function(e){var t=(e.clipboardData||window.clipboardData).getData("text");t.length>=this.options.minLength&&this._geocode(t)},_onKeyDown:function(e){if(27===e.keyCode&&this.options.clearAndBlurOnEsc)return this._clear(e),this._inputEl.blur();var t=e.target&&e.target.shadowRoot?e.target.shadowRoot.activeElement:e.target;if(!t||!t.value)return this.fresh=!0,9!==e.keyCode&&this.clear(e),this._clearEl.style.display="none";e.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(e.keyCode)||t.value.length>=this.options.minLength&&this._geocode(t.value)},_showButton:function(){this._typeahead.selected&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(e){this.options.clearOnBlur&&this._clearOnBlur(e),this.options.collapsed&&this._collapse()},_onChange:function(){var e=this._typeahead.selected;if(e&&JSON.stringify(e)!==this.lastSelected){if(this._clearEl.style.display="none",this.options.flyTo){var t;if(e.properties&&l[e.properties.short_code])t=s({},this.options.flyTo),this._map&&this._map.fitBounds(l[e.properties.short_code].bbox,t);else if(e.bbox){var i=e.bbox;t=s({},this.options.flyTo),this._map&&this._map.fitBounds([[i[0],i[1]],[i[2],i[3]]],t)}else{var n={zoom:this.options.zoom};t=s({},n,this.options.flyTo),e.center?t.center=e.center:e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&(t.center=e.geometry.coordinates),this._map&&this._map.flyTo(t)}}this.options.marker&&this._mapboxgl&&this._handleMarker(e),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(e),this._eventEmitter.emit("result",{result:e}),this.eventManager.select(e,this)}},_requestType:function(e,t){return e.localGeocoderOnly?m:e.reverseGeocode&&/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)[ ]*$/.test(t)?g:f},_setupConfig:function(e,t){const i=/[\s,]+/;var n=this,r=["bbox","limit","proximity","countries","types","language","reverseMode","mode"].reduce((function(e,t){if(!n.options[t])return e;["countries","types","language"].indexOf(t)>-1?e[t]=n.options[t].split(i):e[t]=n.options[t];const r="number"==typeof n.options[t].longitude&&"number"==typeof n.options[t].latitude;if("proximity"===t&&r){const i=n.options[t].longitude,r=n.options[t].latitude;e[t]=[i,r]}return e}),{});switch(e){case g:var o=t.split(i).map((function(e){return parseFloat(e,10)})).reverse();r.types&&r.types[0],"proximity"in(r=s(r,{query:o,limit:1}))&&delete r.proximity;break;case f:/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)*[ ]*$/.test(t)&&(t=t.replace(/,/g," ")),r=s(r,{query:t})}return r},_geocode:function(e){this.inputString=e,this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:e});const t=this._requestType(this.options,e),i=this._setupConfig(t,e);var n;switch(t){case m:n=Promise.resolve();break;case f:n=this.geocoderService.forwardGeocode(i).send();break;case g:n=this.geocoderService.reverseGeocode(i).send()}var r=this.options.localGeocoder&&this.options.localGeocoder(e)||[],o=[],s=null;return n.catch(function(e){s=e}.bind(this)).then(function(t){this._loadingEl.style.display="none";var n={};return t?"200"==t.statusCode&&((n=t.body).request=t.request,n.headers=t.headers):n={type:"FeatureCollection",features:[]},n.config=i,this.fresh&&(this.eventManager.start(this),this.fresh=!1),n.features=n.features?r.concat(n.features):r,this.options.externalGeocoder?(o=this.options.externalGeocoder(e,n.features)||[]).then((function(e){return n.features=n.features?e.concat(n.features):e,n}),(function(){return n})):n}.bind(this)).then(function(e){if(s)throw s;this.options.filter&&e.features.length&&(e.features=e.features.filter(this.options.filter)),e.features.length?(this._clearEl.style.display="block",this._eventEmitter.emit("results",e),this._typeahead.update(e.features)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",e))}.bind(this)).catch(function(e){this._loadingEl.style.display="none",r.length&&this.options.localGeocoder||o.length&&this.options.externalGeocoder?(this._clearEl.style.display="block",this._typeahead.update(r)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:r}),this._eventEmitter.emit("error",{error:e})}.bind(this)),n},_clear:function(e){e&&e.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._clearEl.style.display="none",this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(e){this._clear(e),this._inputEl.focus()},_clearOnBlur:function(e){e.relatedTarget&&this._clear(e)},_onQueryResult:function(e){var t=e.body;if(t.features.length){var i=t.features[0];this._typeahead.selected=i,this._inputEl.value=i.place_name,this._onChange()}},_updateProximity:function(){if(this._map)if(this._map.getZoom()>9){var e=this._map.getCenter().wrap();this.setProximity({longitude:e.lng,latitude:e.lat})}else this.setProximity(null)},_collapse:function(){this._inputEl.value||this._inputEl===document.activeElement||this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed")},query:function(e){return this._geocode(e).then(this._onQueryResult),this},_renderError:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error'>There was an error reaching the server</div>")},_renderNoResults:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error mapbox-gl-geocoder--no-results'>No results found</div>")},_renderMessage:function(e){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(e)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var e=this.options.language.split(",")[0],t=d.language(e),i=p.placeholder[t];if(i)return i}return"Search"},setInput:function(e){return this._inputEl.value=e,this._typeahead.selected=null,this._typeahead.clear(),e.length>=this.options.minLength&&this._geocode(e),this},setProximity:function(e){return this.options.proximity=e,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(e){return e&&"function"==typeof e&&(this._typeahead.render=e),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(e){var t=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=e||this.options.language||t,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(e){return this.options.zoom=e,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(e){return this.options.flyTo=e,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(e){return this.placeholder=e||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this._inputEl.setAttribute("aria-label",this.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(e){return this.options.bbox=e,this},getCountries:function(){return this.options.countries},setCountries:function(e){return this.options.countries=e,this},getTypes:function(){return this.options.types},setTypes:function(e){return this.options.types=e,this},getMinLength:function(){return this.options.minLength},setMinLength:function(e){return this.options.minLength=e,this._typeahead&&(this._typeahead.options.minLength=e),this},getLimit:function(){return this.options.limit},setLimit:function(e){return this.options.limit=e,this._typeahead&&(this._typeahead.options.limit=e),this},getFilter:function(){return this.options.filter},setFilter:function(e){return this.options.filter=e,this},setOrigin:function(e){return this.options.origin=e,this.geocoderService=u(c({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},_handleMarker:function(e){if(this._map){this._removeMarker();var t=s({},{color:"#4668F2"},this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(t),e.center?this.mapMarker.setLngLat(e.center).addTo(this._map):e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&this.mapMarker.setLngLat(e.geometry.coordinates).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(e,t){return this._eventEmitter.on(e,t),this},off:function(e,t){return this._eventEmitter.removeListener(e,t),this.eventManager.remove(),this}},t.exports=n},{"./events":1,"./exceptions":2,"./localization":4,"@mapbox/mapbox-sdk":6,"@mapbox/mapbox-sdk/services/geocoding":17,events:25,"lodash.debounce":29,subtag:32,suggestions:33,xtend:36}],4:[function(e,t,i){"use strict";t.exports={placeholder:{de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"לחפש",ja:"サーチ",lv:"Meklēt",pt:"Procurar",sr:"Претрага",zh:"搜索",cs:"Vyhledávání",hu:"Keresés",ka:"ძიება",nb:"Søke",sk:"Vyhľadávanie",th:"ค้นหา",fi:"Hae",is:"Leita",ko:"수색",pl:"Szukaj",sl:"Iskanje",fa:"جستجو",ru:"Поиск"}}},{}],5:[function(e,t,i){"use strict";function n(e){var t=Array.isArray(e),i=function(i){return t?e[i]:e};return function(n){var o=r(h.plainArray,n);if(o)return o;if(t&&n.length!==e.length)return"an array with "+e.length+" items";for(var s=0;s<n.length;s++)if(o=r(i(s),n[s]))return[s].concat(o)}}function r(e,t){if(null!=t||e.hasOwnProperty("__required")){var i=e(t);return i?Array.isArray(i)?i:[i]:void 0}}function o(e,t){var i=e.length,n=e[i-1],r=e.slice(0,i-1);return 0===r.length&&(r=[u]),t=c(t,{path:r}),"function"==typeof n?n(t):s(t,function(e){return"must be "+function(e){return/^an? /.test(e)?e:/^[aeiou]/i.test(e)?"an "+e:/^[a-z]/i.test(e)?"a "+e:e}(e)+"."}(n))}function s(e,t){return(a(e.path)?"Item at position ":"")+(e.path.join(".")+" "+t)}function a(e){return"number"==typeof e[e.length-1]||"number"==typeof e[0]}var l=e("is-plain-obj"),c=e("xtend"),u="value",h={assert:function(e,t){return t=t||{},function(i){var n=r(e,i);if(n){var s=o(n,t);throw t.apiName&&(s=t.apiName+": "+s),new Error(s)}}}};h.shape=function(e){var t=function(e){return Object.keys(e||{}).map((function(t){return{key:t,value:e[t]}}))}(e);return function(e){var i=r(h.plainObject,e);if(i)return i;for(var n,s=[],a=0;a<t.length;a++)n=t[a].key,(i=r(t[a].value,e[n]))&&s.push([n].concat(i));return s.length<2?s[0]:function(e){s=s.map((function(t){return"- "+t[0]+": "+o(t,e).split("\n").join("\n ")}));var t=e.path.join(".");return"The following properties"+(t===u?"":" of "+t)+" have invalid values:\n "+s.join("\n ")}}},h.strictShape=function(e){var t=h.shape(e);return function(i){var n=t(i);if(n)return n;var r=Object.keys(i).reduce((function(t,i){return void 0===e[i]&&t.push(i),t}),[]);return 0!==r.length?function(){return"The following keys are invalid: "+r.join(", ")}:void 0}},h.arrayOf=function(e){return n(e)},h.tuple=function(){return n(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments))},h.required=function(e){function t(t){return null==t?function(e){return s(e,a(e.path)?"cannot be undefined/null.":"is required.")}:e.apply(this,arguments)}return t.__required=!0,t},h.oneOfType=function(){var e=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return function(t){var i=e.map((function(e){return r(e,t)})).filter(Boolean);if(i.length===e.length)return i.every((function(e){return 1===e.length&&"string"==typeof e[0]}))?function(e){return e.length<2?e[0]:2===e.length?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e.slice(-1)}(i.map((function(e){return e[0]}))):i.reduce((function(e,t){return t.length>e.length?t:e}))}},h.equal=function(e){return function(t){if(t!==e)return JSON.stringify(e)}},h.oneOf=function(){var e=(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments)).map((function(e){return h.equal(e)}));return h.oneOfType.apply(this,e)},h.range=function(e){var t=e[0],i=e[1];return function(e){if(r(h.number,e)||e<t||e>i)return"number between "+t+" & "+i+" (inclusive)"}},h.any=function(){},h.boolean=function(e){if("boolean"!=typeof e)return"boolean"},h.number=function(e){if("number"!=typeof e)return"number"},h.plainArray=function(e){if(!Array.isArray(e))return"array"},h.plainObject=function(e){if(!l(e))return"object"},h.string=function(e){if("string"!=typeof e)return"string"},h.func=function(e){if("function"!=typeof e)return"function"},h.validate=r,h.processMessage=o,t.exports=h},{"is-plain-obj":28,xtend:36}],6:[function(e,t,i){"use strict";var n=e("./lib/client");t.exports=n},{"./lib/client":7}],7:[function(e,t,i){"use strict";function n(e){o.call(this,e)}var r=e("./browser-layer"),o=e("../classes/mapi-client");n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.sendRequest=r.browserSend,n.prototype.abortRequest=r.browserAbort,t.exports=function(e){return new n(e)}},{"../classes/mapi-client":9,"./browser-layer":8}],8:[function(e,t,i){"use strict";function n(e){var t=e.total,i=e.loaded;return{total:t,transferred:i,percent:100*i/t}}function r(e,t){return new Promise((function(i,r){t.onprogress=function(t){e.emitter.emit(l.EVENT_PROGRESS_DOWNLOAD,n(t))};var o=e.file;o&&(t.upload.onprogress=function(t){e.emitter.emit(l.EVENT_PROGRESS_UPLOAD,n(t))}),t.onerror=function(e){r(e)},t.onabort=function(){var t=new a({request:e,type:l.ERROR_REQUEST_ABORTED});r(t)},t.onload=function(){if(delete u[e.id],t.status<200||t.status>=400){var n=new a({request:e,body:t.response,statusCode:t.status});r(n)}else i(t)};var s=e.body;"string"==typeof s?t.send(s):s?t.send(JSON.stringify(s)):o?t.send(o):t.send(),u[e.id]=t})).then((function(t){return function(e,t){return new s(e,{body:t.response,headers:c(t.getAllResponseHeaders()),statusCode:t.status})}(e,t)}))}function o(e,t){var i=e.url(t),n=new window.XMLHttpRequest;return n.open(e.method,i),Object.keys(e.headers).forEach((function(t){n.setRequestHeader(t,e.headers[t])})),n}var s=e("../classes/mapi-response"),a=e("../classes/mapi-error"),l=e("../constants"),c=e("../helpers/parse-headers"),u={};t.exports={browserAbort:function(e){var t=u[e.id];t&&(t.abort(),delete u[e.id])},sendRequestXhr:r,browserSend:function(e){return Promise.resolve().then((function(){var t=o(e,e.client.accessToken);return r(e,t)}))},createRequestXhr:o}},{"../classes/mapi-error":10,"../classes/mapi-response":12,"../constants":13,"../helpers/parse-headers":14}],9:[function(e,t,i){"use strict";function n(e){if(!e||!e.accessToken)throw new Error("Cannot create a client without an access token");r(e.accessToken),this.accessToken=e.accessToken,this.origin=e.origin||s.API_ORIGIN}var r=e("@mapbox/parse-mapbox-token"),o=e("./mapi-request"),s=e("../constants");n.prototype.createRequest=function(e){return new o(this,e)},t.exports=n},{"../constants":13,"./mapi-request":11,"@mapbox/parse-mapbox-token":23}],10:[function(e,t,i){"use strict";var n=e("../constants");t.exports=function(e){var t,i=e.type||n.ERROR_HTTP;if(e.body)try{t=JSON.parse(e.body)}catch(i){t=e.body}else t=null;var r=e.message||null;r||("string"==typeof t?r=t:t&&"string"==typeof t.message?r=t.message:i===n.ERROR_REQUEST_ABORTED&&(r="Request aborted")),this.message=r,this.type=i,this.statusCode=e.statusCode||null,this.request=e.request,this.body=t}},{"../constants":13}],11:[function(e,t,i){"use strict";function n(e,t){if(!e)throw new Error("MapiRequest requires a client");if(!t||!t.path||!t.method)throw new Error("MapiRequest requires an options object with path and method properties");var i={};t.body&&(i["content-type"]="application/json");var n=o(i,t.headers),r=Object.keys(n).reduce((function(e,t){return e[t.toLowerCase()]=n[t],e}),{});this.id=c++,this._options=t,this.emitter=new s,this.client=e,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=t.path,this.method=t.method,this.origin=t.origin||e.origin,this.query=t.query||{},this.params=t.params||{},this.body=t.body||null,this.file=t.file||null,this.encoding=t.encoding||"utf8",this.sendFileAs=t.sendFileAs||null,this.headers=r}var r=e("@mapbox/parse-mapbox-token"),o=e("xtend"),s=e("eventemitter3"),a=e("../helpers/url-utils"),l=e("../constants"),c=1;n.prototype.url=function(e){var t=a.prependOrigin(this.path,this.origin);t=a.appendQueryObject(t,this.query);var i=this.params,n=null==e?this.client.accessToken:e;if(n){t=a.appendQueryParam(t,"access_token",n);var s=r(n).user;i=o({ownerId:s},i)}return t=a.interpolateRouteParams(t,i)},n.prototype.send=function(){var e=this;if(e.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return e.sent=!0,e.client.sendRequest(e).then((function(t){return e.response=t,e.emitter.emit(l.EVENT_RESPONSE,t),t}),(function(t){throw e.error=t,e.emitter.emit(l.EVENT_ERROR,t),t}))},n.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},n.prototype.eachPage=function(e){function t(t){e(null,t,(function(){delete r._nextPageRequest;var e=t.nextPage();e&&(r._nextPageRequest=e,n(e))}))}function i(t){e(t,null,(function(){}))}function n(e){e.send().then(t,i)}var r=this;n(this)},n.prototype.clone=function(){return this._extend()},n.prototype._extend=function(e){var t=o(this._options,e);return new n(this.client,t)},t.exports=n},{"../constants":13,"../helpers/url-utils":16,"@mapbox/parse-mapbox-token":23,eventemitter3:26,xtend:36}],12:[function(e,t,i){"use strict";function n(e,t){this.request=e,this.headers=t.headers,this.rawBody=t.body,this.statusCode=t.statusCode;try{this.body=JSON.parse(t.body||"{}")}catch(e){this.body=t.body}this.links=r(this.headers.link)}var r=e("../helpers/parse-link-header");n.prototype.hasNextPage=function(){return!!this.links.next},n.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null},t.exports=n},{"../helpers/parse-link-header":15}],13:[function(e,t,i){"use strict";t.exports={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"}},{}],14:[function(e,t,i){"use strict";t.exports=function(e){var t={};return e?(e.trim().split(/[\r|\n]+/).forEach((function(e){var i=function(e){var t=e.indexOf(":");return{name:e.substring(0,t).trim().toLowerCase(),value:e.substring(t+1).trim()}}(e);t[i.name]=i.value})),t):t}},{}],15:[function(e,t,i){"use strict";t.exports=function(e){return e?e.split(/,\s*</).reduce((function(e,t){var i=function(e){var t=e.match(/<?([^>]*)>(.*)/);if(!t)return null;var i=t[1],n=t[2].split(";"),r=null,o=n.reduce((function(e,t){var i=function(e){var t=e.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return t?{key:t[1],value:t[2]}:null}(t);return i?"rel"===i.key?(r||(r=i.value),e):(e[i.key]=i.value,e):e}),{});return r?{url:i,rel:r,params:o}:null}(t);return i?(i.rel.split(/\s+/).forEach((function(t){e[t]||(e[t]={url:i.url,params:i.params})})),e):e}),{}):{}}},{}],16:[function(e,t,i){"use strict";function n(e){return Array.isArray(e)?function(e){return e.map(encodeURIComponent).join(",")}(e):encodeURIComponent(String(e))}function r(e,t,i){if(!1===i||null===i)return e;var r=/\?/.test(e)?"&":"?",o=encodeURIComponent(t);return void 0!==i&&""!==i&&!0!==i&&(o+="="+n(i)),""+e+r+o}t.exports={appendQueryObject:function(e,t){if(!t)return e;var i=e;return Object.keys(t).forEach((function(e){var n=t[e];void 0!==n&&(Array.isArray(n)&&(n=n.filter((function(e){return null!=e})).join(",")),i=r(i,e,n))})),i},appendQueryParam:r,prependOrigin:function(e,t){if(!t)return e;if("http"===e.slice(0,4))return e;var i="/"===e[0]?"":"/";return""+t.replace(/\/$/,"")+i+e},interpolateRouteParams:function(e,t){return t?e.replace(/\/:([a-zA-Z0-9]+)/g,(function(e,i){var r=t[i];if(void 0===r)throw new Error("Unspecified route parameter "+i);return"/"+n(r)})):e}}},{}],17:[function(e,t,i){"use strict";var n=e("xtend"),r=e("./service-helpers/validator"),o=e("./service-helpers/pick"),s=e("./service-helpers/stringify-booleans"),a=e("./service-helpers/create-service-factory"),l={},c=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];l.forwardGeocode=function(e){r.assertShape({query:r.required(r.string),mode:r.oneOf("mapbox.places","mapbox.places-permanent"),countries:r.arrayOf(r.string),proximity:r.coordinates,types:r.arrayOf(r.oneOf(c)),autocomplete:r.boolean,bbox:r.arrayOf(r.number),limit:r.number,language:r.arrayOf(r.string),routing:r.boolean})(e),e.mode=e.mode||"mapbox.places";var t=s(n({country:e.countries},o(e,["proximity","types","autocomplete","bbox","limit","language","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},l.reverseGeocode=function(e){r.assertShape({query:r.required(r.coordinates),mode:r.oneOf("mapbox.places","mapbox.places-permanent"),countries:r.arrayOf(r.string),types:r.arrayOf(r.oneOf(c)),bbox:r.arrayOf(r.number),limit:r.number,language:r.arrayOf(r.string),reverseMode:r.oneOf("distance","score"),routing:r.boolean})(e),e.mode=e.mode||"mapbox.places";var t=s(n({country:e.countries},o(e,["country","types","bbox","limit","language","reverseMode","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},t.exports=a(l)},{"./service-helpers/create-service-factory":18,"./service-helpers/pick":20,"./service-helpers/stringify-booleans":21,"./service-helpers/validator":22,xtend:36}],18:[function(e,t,i){"use strict";var n=e("../../lib/classes/mapi-client"),r=e("../../lib/client");t.exports=function(e){return function(t){var i;i=n.prototype.isPrototypeOf(t)?t:r(t);var o=Object.create(e);return o.client=i,o}}},{"../../lib/classes/mapi-client":9,"../../lib/client":7}],19:[function(e,t,i){"use strict";t.exports=function(e,t){return Object.keys(e).reduce((function(i,n){return i[n]=t(n,e[n]),i}),{})}},{}],20:[function(e,t,i){"use strict";t.exports=function(e,t){var i=function(e,i){return-1!==t.indexOf(e)&&void 0!==i};return"function"==typeof t&&(i=t),Object.keys(e).filter((function(t){return i(t,e[t])})).reduce((function(t,i){return t[i]=e[i],t}),{})}},{}],21:[function(e,t,i){"use strict";var n=e("./object-map");t.exports=function(e){return n(e,(function(e,t){return"boolean"==typeof t?JSON.stringify(t):t}))}},{"./object-map":19}],22:[function(e,t,i){(function(i){"use strict";var n=e("xtend"),r=e("@mapbox/fusspot");t.exports=n(r,{file:function(e){if("undefined"!=typeof window){if(e instanceof i.Blob||e instanceof i.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!=typeof e&&void 0===e.pipe)return"Filename or Readable stream"},date:function(e){if("boolean"==typeof e)return"date";try{var t=new Date(e);if(t.getTime&&isNaN(t.getTime()))return"date"}catch(e){return"date"}},coordinates:function(e){return r.tuple(r.number,r.number)(e)},assertShape:function(e,t){return r.assert(r.strictShape(e),t)}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@mapbox/fusspot":5,xtend:36}],23:[function(e,t,i){"use strict";function n(e){try{return JSON.parse(o.decode(e))}catch(e){throw new Error("Invalid token")}}function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var o=e("base-64"),s={};t.exports=function(e){if(s[e])return s[e];var t=e.split("."),i=t[0],o=t[1];if(!o)throw new Error("Invalid token");var a=n(o),l={usage:i,user:a.u};return r(a,"a")&&(l.authorization=a.a),r(a,"exp")&&(l.expires=1e3*a.exp),r(a,"iat")&&(l.created=1e3*a.iat),r(a,"scopes")&&(l.scopes=a.scopes),r(a,"client")&&(l.client=a.client),r(a,"ll")&&(l.lastLogin=a.ll),r(a,"iu")&&(l.impersonator=a.iu),s[e]=l,l}},{"base-64":24}],24:[function(e,t,i){(function(e){!function(n){var r="object"==typeof i&&i,o="object"==typeof t&&t&&t.exports==r&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s||(n=s);var a=function(e){this.message=e};(a.prototype=new Error).name="InvalidCharacterError";var l=function(e){throw new a(e)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,h={encode:function(e){e=String(e),/[^\0-\xFF]/.test(e)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var t,i,n,r,o=e.length%3,s="",a=-1,u=e.length-o;++a<u;)t=e.charCodeAt(a)<<16,i=e.charCodeAt(++a)<<8,n=e.charCodeAt(++a),s+=c.charAt((r=t+i+n)>>18&63)+c.charAt(r>>12&63)+c.charAt(r>>6&63)+c.charAt(63&r);return 2==o?(t=e.charCodeAt(a)<<8,i=e.charCodeAt(++a),s+=c.charAt((r=t+i)>>10)+c.charAt(r>>4&63)+c.charAt(r<<2&63)+"="):1==o&&(r=e.charCodeAt(a),s+=c.charAt(r>>2)+c.charAt(r<<4&63)+"=="),s},decode:function(e){var t=(e=String(e).replace(u,"")).length;t%4==0&&(t=(e=e.replace(/==?$/,"")).length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var i,n,r=0,o="",s=-1;++s<t;)n=c.indexOf(e.charAt(s)),i=r%4?64*i+n:n,r++%4&&(o+=String.fromCharCode(255&i>>(-2*r&6)));return o},version:"0.1.0"};if(r&&!r.nodeType)if(o)o.exports=h;else for(var p in h)h.hasOwnProperty(p)&&(r[p]=h[p]);else n.base64=h}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],25:[function(e,t,i){function n(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=h(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function r(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function o(e,t,i,n){var o,s,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),s=e._events),a=s[t]):(s=e._events=h(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),!a.warned&&(o=r(e))&&o>0&&a.length>o){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=s[t]=i,++e._eventsCount;return e}function s(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function a(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=d.call(s,n);return r.listener=i,n.wrapFn=r,r}function l(e,t,i){var n=e._events;if(!n)return[];var r=n[t];return r?"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(r):u(r,r.length):[]}function c(e){var t=this._events;if(t){var i=t[e];if("function"==typeof i)return 1;if(i)return i.length}return 0}function u(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}var h=Object.create||function(e){var t=function(){};return t.prototype=e,new t},p=Object.keys||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.push(i);return i},d=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0;var f,m=10;try{var g={};Object.defineProperty&&Object.defineProperty(g,"x",{value:0}),f=0===g.x}catch(e){f=!1}f?Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return m},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');m=e}}):n.defaultMaxListeners=m,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return r(this)},n.prototype.emit=function(e){var t,i,n,r,o,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var l=new Error('Unhandled "error" event. ('+t+")");throw l.context=t,l}if(!(i=s[e]))return!1;var c="function"==typeof i;switch(n=arguments.length){case 1:!function(e,t,i){if(t)e.call(i);else for(var n=e.length,r=u(e,n),o=0;o<n;++o)r[o].call(i)}(i,c,this);break;case 2:!function(e,t,i,n){if(t)e.call(i,n);else for(var r=e.length,o=u(e,r),s=0;s<r;++s)o[s].call(i,n)}(i,c,this,arguments[1]);break;case 3:!function(e,t,i,n,r){if(t)e.call(i,n,r);else for(var o=e.length,s=u(e,o),a=0;a<o;++a)s[a].call(i,n,r)}(i,c,this,arguments[1],arguments[2]);break;case 4:!function(e,t,i,n,r,o){if(t)e.call(i,n,r,o);else for(var s=e.length,a=u(e,s),l=0;l<s;++l)a[l].call(i,n,r,o)}(i,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(r=new Array(n-1),o=1;o<n;o++)r[o-1]=arguments[o];!function(e,t,i,n){if(t)e.apply(i,n);else for(var r=e.length,o=u(e,r),s=0;s<r;++s)o[s].apply(i,n)}(i,c,this,r)}return!0},n.prototype.addListener=function(e,t){return o(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return o(this,e,t,!0)},n.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,a(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,a(this,e,t)),this},n.prototype.removeListener=function(e,t){var i,n,r,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(i=n[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=h(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(r=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){s=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(e,t){for(var i=t,n=i+1,r=e.length;n<r;i+=1,n+=1)e[i]=e[n];e.pop()}(i,r),1===i.length&&(n[e]=i[0]),n.removeListener&&this.emit("removeListener",e,s||t)}return this},n.prototype.removeAllListeners=function(e){var t,i,n;if(!(i=this._events))return this;if(!i.removeListener)return 0===arguments.length?(this._events=h(null),this._eventsCount=0):i[e]&&(0==--this._eventsCount?this._events=h(null):delete i[e]),this;if(0===arguments.length){var r,o=p(i);for(n=0;n<o.length;++n)"removeListener"!==(r=o[n])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=h(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},n.prototype.listeners=function(e){return l(this,e,!0)},n.prototype.rawListeners=function(e){return l(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):c.call(e,t)},n.prototype.listenerCount=c,n.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],26:[function(e,t,i){"use strict";function n(){}function r(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function o(e,t,i,n,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new r(i,n||e,o),a=c?c+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],s]:e._events[a].push(s):(e._events[a]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}var l=Object.prototype.hasOwnProperty,c="~";Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(c=!1)),a.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)l.call(e,t)&&i.push(c?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=c?c+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,o=new Array(r);n<r;n++)o[n]=i[n].fn;return o},a.prototype.listenerCount=function(e){var t=c?c+e:e,i=this._events[t];return i?i.fn?1:i.length:0},a.prototype.emit=function(e,t,i,n,r,o){var s=c?c+e:e;if(!this._events[s])return!1;var a,l,u=this._events[s],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,i),!0;case 4:return u.fn.call(u.context,t,i,n),!0;case 5:return u.fn.call(u.context,t,i,n,r),!0;case 6:return u.fn.call(u.context,t,i,n,r,o),!0}for(l=1,a=new Array(h-1);l<h;l++)a[l-1]=arguments[l];u.fn.apply(u.context,a)}else{var p,d=u.length;for(l=0;l<d;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),h){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,i);break;case 4:u[l].fn.call(u[l].context,t,i,n);break;default:if(!a)for(p=1,a=new Array(h-1);p<h;p++)a[p-1]=arguments[p];u[l].fn.apply(u[l].context,a)}}return!0},a.prototype.on=function(e,t,i){return o(this,e,t,i,!1)},a.prototype.once=function(e,t,i){return o(this,e,t,i,!0)},a.prototype.removeListener=function(e,t,i,n){var r=c?c+e:e;if(!this._events[r])return this;if(!t)return s(this,r),this;var o=this._events[r];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,r);else{for(var a=0,l=[],u=o.length;a<u;a++)(o[a].fn!==t||n&&!o[a].once||i&&o[a].context!==i)&&l.push(o[a]);l.length?this._events[r]=1===l.length?l[0]:l:s(this,r)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=c?c+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=c,a.EventEmitter=a,void 0!==t&&(t.exports=a)},{}],27:[function(e,t,i){!function(){var e={};void 0!==i?t.exports=e:this.fuzzy=e,e.simpleFilter=function(t,i){return i.filter((function(i){return e.test(t,i)}))},e.test=function(t,i){return null!==e.match(t,i)},e.match=function(e,t,i){i=i||{};var n,r=0,o=[],s=t.length,a=0,l=0,c=i.pre||"",u=i.post||"",h=i.caseSensitive&&t||t.toLowerCase();e=i.caseSensitive&&e||e.toLowerCase();for(var p=0;p<s;p++)n=t[p],h[p]===e[r]?(n=c+n+u,r+=1,l+=1+l):l=0,a+=l,o[o.length]=n;return r===e.length?(a=h===e?1/0:a,{rendered:o.join(""),score:a}):null},e.filter=function(t,i,n){return i&&0!==i.length?"string"!=typeof t?i:(n=n||{},i.reduce((function(i,r,o,s){var a=r;n.extract&&(a=n.extract(r));var l=e.match(t,a,n);return null!=l&&(i[i.length]={string:l.rendered,score:l.score,index:o,original:r}),i}),[]).sort((function(e,t){return t.score-e.score||e.index-t.index}))):[]}}()},{}],28:[function(e,t,i){"use strict";var n=Object.prototype.toString;t.exports=function(e){var t;return"[object Object]"===n.call(e)&&(null===(t=Object.getPrototypeOf(e))||t===Object.getPrototypeOf({}))}},{}],29:[function(e,t,i){(function(e){function i(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function n(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&m.call(e)==s}(e))return o;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(a,"");var n=c.test(e);return n||u.test(e)?h(e.slice(2),n?2:8):l.test(e)?o:+e}var r="Expected a function",o=NaN,s="[object Symbol]",a=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,h=parseInt,p="object"==typeof e&&e&&e.Object===Object&&e,d="object"==typeof self&&self&&self.Object===Object&&self,f=p||d||Function("return this")(),m=Object.prototype.toString,g=Math.max,_=Math.min,y=function(){return f.Date.now()};t.exports=function(e,t,o){function s(t){var i=h,n=p;return h=p=void 0,x=t,f=e.apply(n,i)}function a(e){var i=e-v;return void 0===v||i>=t||i<0||w&&e-x>=d}function l(){var e=y();if(a(e))return c(e);m=setTimeout(l,function(e){var i=t-(e-v);return w?_(i,d-(e-x)):i}(e))}function c(e){return m=void 0,M&&h?s(e):(h=p=void 0,f)}function u(){var e=y(),i=a(e);if(h=arguments,p=this,v=e,i){if(void 0===m)return function(e){return x=e,m=setTimeout(l,t),b?s(e):f}(v);if(w)return m=setTimeout(l,t),s(v)}return void 0===m&&(m=setTimeout(l,t)),f}var h,p,d,f,m,v,x=0,b=!1,w=!1,M=!0;if("function"!=typeof e)throw new TypeError(r);return t=n(t)||0,i(o)&&(b=!!o.leading,d=(w="maxWait"in o)?g(n(o.maxWait)||0,t):d,M="trailing"in o?!!o.trailing:M),u.cancel=function(){void 0!==m&&clearTimeout(m),x=0,h=v=p=m=void 0},u.flush=function(){return void 0===m?f:c(y())},u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],30:[function(e,t,i){(function(e){if("production"!==e.env.NODE_ENV&&("undefined"==typeof self||!self.crypto&&!self.msCrypto))throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.");var i=self.crypto||self.msCrypto;t.exports=function(e){e=e||21;for(var t="",n=i.getRandomValues(new Uint8Array(e));0<e--;)t+="Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz-"[63&n[e]];return t}}).call(this,e("_process"))},{_process:31}],31:[function(e,t,i){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(u===setTimeout)return setTimeout(e,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function s(){m&&d&&(m=!1,d.length?f=d.concat(f):g=-1,f.length&&a())}function a(){if(!m){var e=o(s);m=!0;for(var t=f.length;t;){for(d=f,f=[];++g<t;)d&&d[g].run();g=-1,t=f.length}d=null,m=!1,function(e){if(h===clearTimeout)return clearTimeout(e);if((h===r||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}(e)}}function l(e,t){this.fun=e,this.array=t}function c(){}var u,h,p=t.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:n}catch(e){u=n}try{h="function"==typeof clearTimeout?clearTimeout:r}catch(e){h=r}}();var d,f=[],m=!1,g=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];f.push(new l(e,t)),1!==f.length||m||o(a)},l.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=c,p.addListener=c,p.once=c,p.off=c,p.removeListener=c,p.removeAllListeners=c,p.emit=c,p.prependListener=c,p.prependOnceListener=c,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},{}],32:[function(e,t,i){!function(e,i,n){void 0!==t&&t.exports?t.exports=n():e.subtag=n()}(this,0,(function(){function e(e){return e.match(o)||[]}function t(t){return{language:(t=e(t))[1]||r,extlang:t[2]||r,script:t[3]||r,region:t[4]||r}}function i(e,t,i){Object.defineProperty(e,t,{value:i,enumerable:!0})}function n(n,o,s){function a(t){return e(t)[n]||r}i(a,"pattern",o),i(t,s,a)}var r="",o=/^([a-zA-Z]{2,3})(?:[_-]+([a-zA-Z]{3})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{4})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{2}|[0-9]{3})(?=$|[_-]+))?/;return n(1,/^[a-zA-Z]{2,3}$/,"language"),n(2,/^[a-zA-Z]{3}$/,"extlang"),n(3,/^[a-zA-Z]{4}$/,"script"),n(4,/^[a-zA-Z]{2}$|^[0-9]{3}$/,"region"),i(t,"split",(function(t){return e(t).filter((function(e,t){return e&&t}))})),t}))},{}],33:[function(e,t,i){"use strict";var n=e("./src/suggestions");window.Suggestions=t.exports=n},{"./src/suggestions":35}],34:[function(e,t,i){var n=function(e){return this.component=e,this.items=[],this.active=0,this.wrapper=document.createElement("div"),this.wrapper.className="suggestions-wrapper",this.element=document.createElement("ul"),this.element.className="suggestions",this.wrapper.appendChild(this.element),this.selectingListItem=!1,e.el.parentNode.insertBefore(this.wrapper,e.el.nextSibling),this};n.prototype.show=function(){this.element.style.display="block"},n.prototype.hide=function(){this.element.style.display="none"},n.prototype.add=function(e){this.items.push(e)},n.prototype.clear=function(){this.items=[],this.active=0},n.prototype.isEmpty=function(){return!this.items.length},n.prototype.isVisible=function(){return"block"===this.element.style.display},n.prototype.draw=function(){if(this.element.innerHTML="",0!==this.items.length){for(var e=0;e<this.items.length;e++)this.drawItem(this.items[e],this.active===e);this.show()}else this.hide()},n.prototype.drawItem=function(e,t){var i=document.createElement("li"),n=document.createElement("a");t&&(i.className+=" active"),n.innerHTML=e.string,i.appendChild(n),this.element.appendChild(i),i.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this)),i.addEventListener("mouseup",function(){this.handleMouseUp.call(this,e)}.bind(this))},n.prototype.handleMouseUp=function(e){this.selectingListItem=!1,this.component.value(e.original),this.clear(),this.draw()},n.prototype.move=function(e){this.active=e,this.draw()},n.prototype.previous=function(){this.move(0===this.active?this.items.length-1:this.active-1)},n.prototype.next=function(){this.move(this.active===this.items.length-1?0:this.active+1)},n.prototype.drawError=function(e){var t=document.createElement("li");t.innerHTML=e,this.element.appendChild(t),this.show()},t.exports=n},{}],35:[function(e,t,i){"use strict";var n=e("xtend"),r=e("fuzzy"),o=e("./list"),s=function(e,t,i){return i=i||{},this.options=n({minLength:2,limit:5,filter:!0},i),this.el=e,this.data=t||[],this.list=new o(this),this.query="",this.selected=null,this.list.draw(),this.el.addEventListener("keyup",function(e){this.handleKeyUp(e.keyCode)}.bind(this),!1),this.el.addEventListener("keydown",function(e){this.handleKeyDown(e)}.bind(this)),this.el.addEventListener("focus",function(){this.handleFocus()}.bind(this)),this.el.addEventListener("blur",function(){this.handleBlur()}.bind(this)),this.el.addEventListener("paste",function(e){this.handlePaste(e)}.bind(this)),this.render=this.options.render?this.options.render.bind(this):this.render.bind(this),this.getItemValue=this.options.getItemValue?this.options.getItemValue.bind(this):this.getItemValue.bind(this),this};s.prototype.handleKeyUp=function(e){40!==e&&38!==e&&27!==e&&13!==e&&9!==e&&this.handleInputChange(this.el.value)},s.prototype.handleKeyDown=function(e){switch(e.keyCode){case 13:case 9:this.list.isEmpty()||(this.list.isVisible()&&e.preventDefault(),this.value(this.list.items[this.list.active].original),this.list.hide());break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next()}},s.prototype.handleBlur=function(){this.list.selectingListItem||this.list.hide()},s.prototype.handlePaste=function(e){if(e.clipboardData)this.handleInputChange(e.clipboardData.getData("Text"));else{var t=this;setTimeout((function(){t.handleInputChange(e.target.value)}),100)}},s.prototype.handleInputChange=function(e){this.query=this.normalize(e),this.list.clear(),this.query.length<this.options.minLength?this.list.draw():this.getCandidates(function(e){for(var t=0;t<e.length&&(this.list.add(e[t]),t!==this.options.limit-1);t++);this.list.draw()}.bind(this))},s.prototype.handleFocus=function(){this.list.isEmpty()||this.list.show(),this.list.selectingListItem=!1},s.prototype.update=function(e){this.data=e,this.handleKeyUp()},s.prototype.clear=function(){this.data=[],this.list.clear()},s.prototype.normalize=function(e){return e.toLowerCase()},s.prototype.match=function(e,t){return e.indexOf(t)>-1},s.prototype.value=function(e){if(this.selected=e,this.el.value=this.getItemValue(e),document.createEvent){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1),this.el.dispatchEvent(t)}else this.el.fireEvent("onchange")},s.prototype.getCandidates=function(e){var t,i={pre:"<strong>",post:"</strong>",extract:function(e){return this.getItemValue(e)}.bind(this)};this.options.filter?t=(t=r.filter(this.query,this.data,i)).map(function(e){return{original:e.original,string:this.render(e.original,e.string)}}.bind(this)):t=this.data.map(function(e){return{original:e,string:this.render(e)}}.bind(this)),e(t)},s.prototype.getItemValue=function(e){return e},s.prototype.render=function(e,t){if(t)return t;for(var i=e.original?this.getItemValue(e.original):this.getItemValue(e),n=this.normalize(i),r=n.lastIndexOf(this.query);r>-1;){var o=r+this.query.length;i=i.slice(0,r)+"<strong>"+i.slice(r,o)+"</strong>"+i.slice(o),r=n.slice(0,r).lastIndexOf(this.query)}return i},s.prototype.renderError=function(e){this.list.drawError(e)},t.exports=s},{"./list":34,fuzzy:27,xtend:36}],36:[function(e,t,i){t.exports=function(){for(var e={},t=0;t<arguments.length;t++){var i=arguments[t];for(var r in i)n.call(i,r)&&(e[r]=i[r])}return e};var n=Object.prototype.hasOwnProperty},{}]},{},[3])(3)}));!function(){var e,t,i=function(e){var t;return function(i){return t||e(t={exports:{},parent:i},t.exports),t.exports}}((function(e,t){(function(e,i){(function(){var n=z.nextTick,r=(Function.prototype.apply,Array.prototype.slice),o={},s=0;function a(e,t){this._id=e,this._clearFn=t}a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(window,this._id)},t.setImmediate="function"==typeof e?e:function(e){var i=s++,a=!(arguments.length<2)&&r.call(arguments,1);return o[i]=!0,n((function(){o[i]&&(a?e.apply(null,a):e.call(null),t.clearImmediate(i))})),i},t.clearImmediate="function"==typeof i?i:function(e){delete o[e]}}).call(this)}).call(this,i({}).setImmediate,i({}).clearImmediate)})),n={exports:{}};e=this,t=function(e){"use strict";const t="132",i=100,n=300,r=301,o=302,s=303,a=304,l=306,c=307,u=1e3,h=1001,p=1002,d=1003,f=1004,m=1005,g=1006,_=1007,y=1008,v=1009,x=1012,b=1014,w=1015,M=1016,T=1020,S=1022,E=1023,A=1026,C=1027,L=33776,I=33777,P=33778,R=33779,k=35840,z=35841,D=35842,O=35843,F=37492,B=37496,N=2300,U=2301,j=2302,V=2400,G=2401,H=2402,W=2500,q=2501,$=3e3,Z=3001,X=3007,Y=3002,J=3004,Q=3005,K=3006,ee=35044,te=35048,ie="300 es";class ne{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const i=this._listeners[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const i=t.slice(0);for(let t=0,n=i.length;t<n;t++)i[t].call(this,e);e.target=null}}}const re=[];for(let e=0;e<256;e++)re[e]=(e<16?"0":"")+e.toString(16);let oe=1234567;const se=Math.PI/180,ae=180/Math.PI;function le(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(re[255&e]+re[e>>8&255]+re[e>>16&255]+re[e>>24&255]+"-"+re[255&t]+re[t>>8&255]+"-"+re[t>>16&15|64]+re[t>>24&255]+"-"+re[63&i|128]+re[i>>8&255]+"-"+re[i>>16&255]+re[i>>24&255]+re[255&n]+re[n>>8&255]+re[n>>16&255]+re[n>>24&255]).toUpperCase()}function ce(e,t,i){return Math.max(t,Math.min(i,e))}function ue(e,t){return(e%t+t)%t}function he(e,t,i){return(1-i)*e+i*t}function pe(e){return 0==(e&e-1)&&0!==e}function de(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function fe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var me=Object.freeze({__proto__:null,DEG2RAD:se,RAD2DEG:ae,generateUUID:le,clamp:ce,euclideanModulo:ue,mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},inverseLerp:function(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:he,damp:function(e,t,i,n){return he(e,t,1-Math.exp(-i*n))},pingpong:function(e,t=1){return t-Math.abs(ue(e,2*t)-t)},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(oe=e%2147483647),((oe=16807*oe%2147483647)-1)/2147483646},degToRad:function(e){return e*se},radToDeg:function(e){return e*ae},isPowerOfTwo:pe,ceilPowerOfTwo:de,floorPowerOfTwo:fe,setQuaternionFromProperEuler:function(e,t,i,n,r){const o=Math.cos,s=Math.sin,a=o(i/2),l=s(i/2),c=o((t+n)/2),u=s((t+n)/2),h=o((t-n)/2),p=s((t-n)/2),d=o((n-t)/2),f=s((n-t)/2);switch(r){case"XYX":e.set(a*u,l*h,l*p,a*c);break;case"YZY":e.set(l*p,a*u,l*h,a*c);break;case"ZXZ":e.set(l*h,l*p,a*u,a*c);break;case"XZX":e.set(a*u,l*f,l*d,a*c);break;case"YXY":e.set(l*d,a*u,l*f,a*c);break;case"ZYZ":e.set(l*f,l*d,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}});class ge{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*n+e.x,this.y=r*n+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}ge.prototype.isVector2=!0;class _e{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,n,r,o,s,a,l){const c=this.elements;return c[0]=e,c[1]=n,c[2]=s,c[3]=t,c[4]=r,c[5]=a,c[6]=i,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],s=i[3],a=i[6],l=i[1],c=i[4],u=i[7],h=i[2],p=i[5],d=i[8],f=n[0],m=n[3],g=n[6],_=n[1],y=n[4],v=n[7],x=n[2],b=n[5],w=n[8];return r[0]=o*f+s*_+a*x,r[3]=o*m+s*y+a*b,r[6]=o*g+s*v+a*w,r[1]=l*f+c*_+u*x,r[4]=l*m+c*y+u*b,r[7]=l*g+c*v+u*w,r[2]=h*f+p*_+d*x,r[5]=h*m+p*y+d*b,r[8]=h*g+p*v+d*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8];return t*o*c-t*s*l-i*r*c+i*s*a+n*r*l-n*o*a}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=c*o-s*l,h=s*a-c*r,p=l*r-o*a,d=t*u+i*h+n*p;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const f=1/d;return e[0]=u*f,e[1]=(n*l-c*i)*f,e[2]=(s*i-n*o)*f,e[3]=h*f,e[4]=(c*t-n*a)*f,e[5]=(n*r-s*t)*f,e[6]=p*f,e[7]=(i*a-l*t)*f,e[8]=(o*t-i*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return 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}setUvTransform(e,t,i,n,r,o,s){const a=Math.cos(r),l=Math.sin(r);return this.set(i*a,i*l,-i*(a*o+l*s)+o+e,-n*l,n*a,-n*(-l*o+a*s)+s+t,0,0,1),this}scale(e,t){const i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),n=this.elements,r=n[0],o=n[3],s=n[6],a=n[1],l=n[4],c=n[7];return n[0]=t*r+i*a,n[3]=t*o+i*l,n[6]=t*s+i*c,n[1]=-i*r+t*a,n[4]=-i*o+t*l,n[7]=-i*s+t*c,this}translate(e,t){const i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}let ye;_e.prototype.isMatrix3=!0;class ve{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===ye&&(ye=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),ye.width=e.width,ye.height=e.height;const i=ye.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=ye}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let xe=0;class be extends ne{constructor(e=be.DEFAULT_IMAGE,t=be.DEFAULT_MAPPING,i=1001,n=1001,r=1006,o=1008,s=1023,a=1009,l=1,c=3e3){super(),Object.defineProperty(this,"id",{value:xe++}),this.uuid=le(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new ge(0,0),this.repeat=new ge(1,1),this.center=new ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new _e,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=le()),!t&&void 0===e.images[n.uuid]){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(we(n[e].image)):t.push(we(n[e]))}else t=we(n);e.images[n.uuid]={uuid:n.uuid,url:t}}i.image=n.uuid}return t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==n)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case u:e.x=e.x-Math.floor(e.x);break;case h:e.x=e.x<0?0:1;break;case p:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case u:e.y=e.y-Math.floor(e.y);break;case h:e.y=e.y<0?0:1;break;case p:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function we(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ve.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}be.DEFAULT_IMAGE=void 0,be.DEFAULT_MAPPING=n,be.prototype.isTexture=!0;class Me{constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*t+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*t+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*t+o[7]*i+o[11]*n+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;const o=.01,s=e.elements,a=s[0],l=s[4],c=s[8],u=s[1],h=s[5],p=s[9],d=s[2],f=s[6],m=s[10];if(Math.abs(l-u)<o&&Math.abs(c-d)<o&&Math.abs(p-f)<o){if(Math.abs(l+u)<.1&&Math.abs(c+d)<.1&&Math.abs(p+f)<.1&&Math.abs(a+h+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const e=(a+1)/2,s=(h+1)/2,g=(m+1)/2,_=(l+u)/4,y=(c+d)/4,v=(p+f)/4;return e>s&&e>g?e<o?(i=0,n=.707106781,r=.707106781):(n=_/(i=Math.sqrt(e)),r=y/i):s>g?s<o?(i=.707106781,n=0,r=.707106781):(i=_/(n=Math.sqrt(s)),r=v/n):g<o?(i=.707106781,n=.707106781,r=0):(i=y/(r=Math.sqrt(g)),n=v/r),this.set(i,n,r,t),this}let g=Math.sqrt((f-p)*(f-p)+(c-d)*(c-d)+(u-l)*(u-l));return Math.abs(g)<.001&&(g=1),this.x=(f-p)/g,this.y=(c-d)/g,this.z=(u-l)/g,this.w=Math.acos((a+h+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}Me.prototype.isVector4=!0;class Te extends ne{constructor(e,t,i={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Me(0,0,e,t),this.scissorTest=!1,this.viewport=new Me(0,0,e,t),this.texture=new be(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:g,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,i=1){this.width===e&&this.height===t&&this.depth===i||(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Te.prototype.isWebGLRenderTarget=!0;class Se extends Te{constructor(e,t,i){super(e,t);const n=this.texture;this.texture=[];for(let e=0;e<i;e++)this.texture[e]=n.clone()}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,r=this.texture.length;n<r;n++)this.texture[n].image.width=e,this.texture[n].image.height=t,this.texture[n].image.depth=i;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this.texture.length=0;for(let t=0,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone();return this}}Se.prototype.isWebGLMultipleRenderTargets=!0;class Ee extends Te{constructor(e,t,i){super(e,t,i),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Ee.prototype.isWebGLMultisampleRenderTarget=!0;class Ae{constructor(e=0,t=0,i=0,n=1){this._x=e,this._y=t,this._z=i,this._w=n}static slerp(e,t,i,n){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(e,t,n)}static slerpFlat(e,t,i,n,r,o,s){let a=i[n+0],l=i[n+1],c=i[n+2],u=i[n+3];const h=r[o+0],p=r[o+1],d=r[o+2],f=r[o+3];if(0===s)return e[t+0]=a,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===s)return e[t+0]=h,e[t+1]=p,e[t+2]=d,void(e[t+3]=f);if(u!==f||a!==h||l!==p||c!==d){let e=1-s;const t=a*h+l*p+c*d+u*f,i=t>=0?1:-1,n=1-t*t;if(n>Number.EPSILON){const r=Math.sqrt(n),o=Math.atan2(r,t*i);e=Math.sin(e*o)/r,s=Math.sin(s*o)/r}const r=s*i;if(a=a*e+h*r,l=l*e+p*r,c=c*e+d*r,u=u*e+f*r,e===1-s){const e=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=e,l*=e,c*=e,u*=e}}e[t]=a,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,r,o){const s=i[n],a=i[n+1],l=i[n+2],c=i[n+3],u=r[o],h=r[o+1],p=r[o+2],d=r[o+3];return e[t]=s*d+c*u+a*p-l*h,e[t+1]=a*d+c*h+l*u-s*p,e[t+2]=l*d+c*p+s*h-a*u,e[t+3]=c*d-s*u-a*h-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=e._x,n=e._y,r=e._z,o=e._order,s=Math.cos,a=Math.sin,l=s(i/2),c=s(n/2),u=s(r/2),h=a(i/2),p=a(n/2),d=a(r/2);switch(o){case"XYZ":this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d;break;case"YXZ":this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d;break;case"ZXY":this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d;break;case"ZYX":this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d;break;case"YZX":this._x=h*c*u+l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u-h*p*d;break;case"XZY":this._x=h*c*u-l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u+h*p*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],o=t[1],s=t[5],a=t[9],l=t[2],c=t[6],u=t[10],h=i+s+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(c-a)*e,this._y=(r-l)*e,this._z=(o-n)*e}else if(i>s&&i>u){const e=2*Math.sqrt(1+i-s-u);this._w=(c-a)/e,this._x=.25*e,this._y=(n+o)/e,this._z=(r+l)/e}else if(s>u){const e=2*Math.sqrt(1+s-i-u);this._w=(r-l)/e,this._x=(n+o)/e,this._y=.25*e,this._z=(a+c)/e}else{const e=2*Math.sqrt(1+u-i-s);this._w=(o-n)/e,this._x=(r+l)/e,this._y=(a+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ce(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(0===i)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,o=e._w,s=t._x,a=t._y,l=t._z,c=t._w;return this._x=i*c+o*s+n*l-r*a,this._y=n*c+o*a+r*s-i*l,this._z=r*c+o*l+i*a-n*s,this._w=o*c-i*s-n*a-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const i=this._x,n=this._y,r=this._z,o=this._w;let s=o*e._w+i*e._x+n*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=o,this._x=i,this._y=n,this._z=r,this;const a=1-s*s;if(a<=Number.EPSILON){const e=1-t;return this._w=e*o+t*this._w,this._x=e*i+t*this._x,this._y=e*n+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(a),c=Math.atan2(l,s),u=Math.sin((1-t)*c)/l,h=Math.sin(t*c)/l;return this._w=o*u+this._w*h,this._x=i*u+this._x*h,this._y=n*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){this.copy(e).slerp(t,i)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Ae.prototype.isQuaternion=!0;class Ce{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Ie.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ie.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,o=e.y,s=e.z,a=e.w,l=a*t+o*n-s*i,c=a*i+s*t-r*n,u=a*n+r*i-o*t,h=-r*t-o*i-s*n;return this.x=l*a+h*-r+c*-s-u*-o,this.y=c*a+h*-o+u*-r-l*-s,this.z=u*a+h*-s+l*-o-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,o=t.x,s=t.y,a=t.z;return this.x=n*a-r*s,this.y=r*o-i*a,this.z=i*s-n*o,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Le.copy(this).projectOnVector(e),this.sub(Le)}reflect(e){return this.sub(Le.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ce(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}Ce.prototype.isVector3=!0;const Le=new Ce,Ie=new Ae;class Pe{constructor(e=new Ce(1/0,1/0,1/0),t=new Ce(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,l=e.length;a<l;a+=3){const l=e[a],c=e[a+1],u=e[a+2];l<t&&(t=l),c<i&&(i=c),u<n&&(n=u),l>r&&(r=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(t,i,n),this.max.set(r,o,s),this}setFromBufferAttribute(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,l=e.count;a<l;a++){const l=e.getX(a),c=e.getY(a),u=e.getZ(a);l<t&&(t=l),c<i&&(i=c),u<n&&(n=u),l>r&&(r=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(t,i,n),this.max.set(r,o,s),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=ke.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);const t=e.geometry;void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),ze.copy(t.boundingBox),ze.applyMatrix4(e.matrixWorld),this.union(ze));const i=e.children;for(let e=0,t=i.length;e<t;e++)this.expandByObject(i[e]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ke),ke.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(je),Ve.subVectors(this.max,je),De.subVectors(e.a,je),Oe.subVectors(e.b,je),Fe.subVectors(e.c,je),Be.subVectors(Oe,De),Ne.subVectors(Fe,Oe),Ue.subVectors(De,Fe);let t=[0,-Be.z,Be.y,0,-Ne.z,Ne.y,0,-Ue.z,Ue.y,Be.z,0,-Be.x,Ne.z,0,-Ne.x,Ue.z,0,-Ue.x,-Be.y,Be.x,0,-Ne.y,Ne.x,0,-Ue.y,Ue.x,0];return!!We(t,De,Oe,Fe,Ve)&&!!We(t=[1,0,0,0,1,0,0,0,1],De,Oe,Fe,Ve)&&(Ge.crossVectors(Be,Ne),We(t=[Ge.x,Ge.y,Ge.z],De,Oe,Fe,Ve))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ke.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(ke).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Re[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Re[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Re[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Re[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Re[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Re[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Re[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Re[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Re)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}Pe.prototype.isBox3=!0;const Re=[new Ce,new Ce,new Ce,new Ce,new Ce,new Ce,new Ce,new Ce],ke=new Ce,ze=new Pe,De=new Ce,Oe=new Ce,Fe=new Ce,Be=new Ce,Ne=new Ce,Ue=new Ce,je=new Ce,Ve=new Ce,Ge=new Ce,He=new Ce;function We(e,t,i,n,r){for(let o=0,s=e.length-3;o<=s;o+=3){He.fromArray(e,o);const s=r.x*Math.abs(He.x)+r.y*Math.abs(He.y)+r.z*Math.abs(He.z),a=t.dot(He),l=i.dot(He),c=n.dot(He);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>s)return!1}return!0}const qe=new Pe,$e=new Ce,Ze=new Ce,Xe=new Ce;class Ye{constructor(e=new Ce,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;void 0!==t?i.copy(t):qe.setFromPoints(e).getCenter(i);let n=0;for(let t=0,r=e.length;t<r;t++)n=Math.max(n,i.distanceToSquared(e[t]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){Xe.subVectors(e,this.center);const t=Xe.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),i=.5*(e-this.radius);this.center.add(Xe.multiplyScalar(i/e)),this.radius+=i}return this}union(e){return Ze.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint($e.copy(e.center).add(Ze)),this.expandByPoint($e.copy(e.center).sub(Ze)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Je=new Ce,Qe=new Ce,Ke=new Ce,et=new Ce,tt=new Ce,it=new Ce,nt=new Ce;class rt{constructor(e=new Ce,t=new Ce(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Je)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Je.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Je.copy(this.direction).multiplyScalar(t).add(this.origin),Je.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Qe.copy(e).add(t).multiplyScalar(.5),Ke.copy(t).sub(e).normalize(),et.copy(this.origin).sub(Qe);const r=.5*e.distanceTo(t),o=-this.direction.dot(Ke),s=et.dot(this.direction),a=-et.dot(Ke),l=et.lengthSq(),c=Math.abs(1-o*o);let u,h,p,d;if(c>0)if(h=o*s-a,d=r*c,(u=o*a-s)>=0)if(h>=-d)if(h<=d){const e=1/c;p=(u*=e)*(u+o*(h*=e)+2*s)+h*(o*u+h+2*a)+l}else h=r,p=-(u=Math.max(0,-(o*h+s)))*u+h*(h+2*a)+l;else h=-r,p=-(u=Math.max(0,-(o*h+s)))*u+h*(h+2*a)+l;else h<=-d?p=-(u=Math.max(0,-(-o*r+s)))*u+(h=u>0?-r:Math.min(Math.max(-r,-a),r))*(h+2*a)+l:h<=d?(u=0,p=(h=Math.min(Math.max(-r,-a),r))*(h+2*a)+l):p=-(u=Math.max(0,-(o*r+s)))*u+(h=u>0?r:Math.min(Math.max(-r,-a),r))*(h+2*a)+l;else h=o>0?-r:r,p=-(u=Math.max(0,-(o*h+s)))*u+h*(h+2*a)+l;return i&&i.copy(this.direction).multiplyScalar(u).add(this.origin),n&&n.copy(Ke).multiplyScalar(h).add(Qe),p}intersectSphere(e,t){Je.subVectors(e.center,this.origin);const i=Je.dot(this.direction),n=Je.dot(Je)-i*i,r=e.radius*e.radius;if(n>r)return null;const o=Math.sqrt(r-n),s=i-o,a=i+o;return s<0&&a<0?null:s<0?this.at(a,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,o,s,a;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,n=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,n=(e.min.x-h.x)*l),c>=0?(r=(e.min.y-h.y)*c,o=(e.max.y-h.y)*c):(r=(e.max.y-h.y)*c,o=(e.min.y-h.y)*c),i>o||r>n?null:((r>i||i!=i)&&(i=r),(o<n||n!=n)&&(n=o),u>=0?(s=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u):(s=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u),i>a||s>n?null:((s>i||i!=i)&&(i=s),(a<n||n!=n)&&(n=a),n<0?null:this.at(i>=0?i:n,t)))}intersectsBox(e){return null!==this.intersectBox(e,Je)}intersectTriangle(e,t,i,n,r){tt.subVectors(t,e),it.subVectors(i,e),nt.crossVectors(tt,it);let o,s=this.direction.dot(nt);if(s>0){if(n)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}et.subVectors(this.origin,e);const a=o*this.direction.dot(it.crossVectors(et,it));if(a<0)return null;const l=o*this.direction.dot(tt.cross(et));if(l<0)return null;if(a+l>s)return null;const c=-o*et.dot(nt);return c<0?null:this.at(c/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ot{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=r,g[5]=o,g[9]=s,g[13]=a,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new ot).fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/st.setFromMatrixColumn(e,0).length(),r=1/st.setFromMatrixColumn(e,1).length(),o=1/st.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,i=e.x,n=e.y,r=e.z,o=Math.cos(i),s=Math.sin(i),a=Math.cos(n),l=Math.sin(n),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=o*c,i=o*u,n=s*c,r=s*u;t[0]=a*c,t[4]=-a*u,t[8]=l,t[1]=i+n*l,t[5]=e-r*l,t[9]=-s*a,t[2]=r-e*l,t[6]=n+i*l,t[10]=o*a}else if("YXZ"===e.order){const e=a*c,i=a*u,n=l*c,r=l*u;t[0]=e+r*s,t[4]=n*s-i,t[8]=o*l,t[1]=o*u,t[5]=o*c,t[9]=-s,t[2]=i*s-n,t[6]=r+e*s,t[10]=o*a}else if("ZXY"===e.order){const e=a*c,i=a*u,n=l*c,r=l*u;t[0]=e-r*s,t[4]=-o*u,t[8]=n+i*s,t[1]=i+n*s,t[5]=o*c,t[9]=r-e*s,t[2]=-o*l,t[6]=s,t[10]=o*a}else if("ZYX"===e.order){const e=o*c,i=o*u,n=s*c,r=s*u;t[0]=a*c,t[4]=n*l-i,t[8]=e*l+r,t[1]=a*u,t[5]=r*l+e,t[9]=i*l-n,t[2]=-l,t[6]=s*a,t[10]=o*a}else if("YZX"===e.order){const e=o*a,i=o*l,n=s*a,r=s*l;t[0]=a*c,t[4]=r-e*u,t[8]=n*u+i,t[1]=u,t[5]=o*c,t[9]=-s*c,t[2]=-l*c,t[6]=i*u+n,t[10]=e-r*u}else if("XZY"===e.order){const e=o*a,i=o*l,n=s*a,r=s*l;t[0]=a*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=o*c,t[9]=i*u-n,t[2]=n*u-i,t[6]=s*c,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(lt,e,ct)}lookAt(e,t,i){const n=this.elements;return pt.subVectors(e,t),0===pt.lengthSq()&&(pt.z=1),pt.normalize(),ut.crossVectors(i,pt),0===ut.lengthSq()&&(1===Math.abs(i.z)?pt.x+=1e-4:pt.z+=1e-4,pt.normalize(),ut.crossVectors(i,pt)),ut.normalize(),ht.crossVectors(pt,ut),n[0]=ut.x,n[4]=ht.x,n[8]=pt.x,n[1]=ut.y,n[5]=ht.y,n[9]=pt.y,n[2]=ut.z,n[6]=ht.z,n[10]=pt.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],s=i[4],a=i[8],l=i[12],c=i[1],u=i[5],h=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],_=i[3],y=i[7],v=i[11],x=i[15],b=n[0],w=n[4],M=n[8],T=n[12],S=n[1],E=n[5],A=n[9],C=n[13],L=n[2],I=n[6],P=n[10],R=n[14],k=n[3],z=n[7],D=n[11],O=n[15];return r[0]=o*b+s*S+a*L+l*k,r[4]=o*w+s*E+a*I+l*z,r[8]=o*M+s*A+a*P+l*D,r[12]=o*T+s*C+a*R+l*O,r[1]=c*b+u*S+h*L+p*k,r[5]=c*w+u*E+h*I+p*z,r[9]=c*M+u*A+h*P+p*D,r[13]=c*T+u*C+h*R+p*O,r[2]=d*b+f*S+m*L+g*k,r[6]=d*w+f*E+m*I+g*z,r[10]=d*M+f*A+m*P+g*D,r[14]=d*T+f*C+m*R+g*O,r[3]=_*b+y*S+v*L+x*k,r[7]=_*w+y*E+v*I+x*z,r[11]=_*M+y*A+v*P+x*D,r[15]=_*T+y*C+v*R+x*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],o=e[1],s=e[5],a=e[9],l=e[13],c=e[2],u=e[6],h=e[10],p=e[14];return e[3]*(+r*a*u-n*l*u-r*s*h+i*l*h+n*s*p-i*a*p)+e[7]*(+t*a*p-t*l*h+r*o*h-n*o*p+n*l*c-r*a*c)+e[11]*(+t*l*u-t*s*p-r*o*u+i*o*p+r*s*c-i*l*c)+e[15]*(-n*s*c-t*a*u+t*s*h+n*o*u-i*o*h+i*a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],p=e[11],d=e[12],f=e[13],m=e[14],g=e[15],_=u*m*l-f*h*l+f*a*p-s*m*p-u*a*g+s*h*g,y=d*h*l-c*m*l-d*a*p+o*m*p+c*a*g-o*h*g,v=c*f*l-d*u*l+d*s*p-o*f*p-c*s*g+o*u*g,x=d*u*a-c*f*a-d*s*h+o*f*h+c*s*m-o*u*m,b=t*_+i*y+n*v+r*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return e[0]=_*w,e[1]=(f*h*r-u*m*r-f*n*p+i*m*p+u*n*g-i*h*g)*w,e[2]=(s*m*r-f*a*r+f*n*l-i*m*l-s*n*g+i*a*g)*w,e[3]=(u*a*r-s*h*r-u*n*l+i*h*l+s*n*p-i*a*p)*w,e[4]=y*w,e[5]=(c*m*r-d*h*r+d*n*p-t*m*p-c*n*g+t*h*g)*w,e[6]=(d*a*r-o*m*r-d*n*l+t*m*l+o*n*g-t*a*g)*w,e[7]=(o*h*r-c*a*r+c*n*l-t*h*l-o*n*p+t*a*p)*w,e[8]=v*w,e[9]=(d*u*r-c*f*r-d*i*p+t*f*p+c*i*g-t*u*g)*w,e[10]=(o*f*r-d*s*r+d*i*l-t*f*l-o*i*g+t*s*g)*w,e[11]=(c*s*r-o*u*r-c*i*l+t*u*l+o*i*p-t*s*p)*w,e[12]=x*w,e[13]=(c*f*n-d*u*n+d*i*h-t*f*h-c*i*m+t*u*m)*w,e[14]=(d*s*n-o*f*n-d*i*a+t*f*a+o*i*m-t*s*m)*w,e[15]=(o*u*n-c*s*n+c*i*a-t*u*a-o*i*h+t*s*h)*w,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,o=e.x,s=e.y,a=e.z,l=r*o,c=r*s;return this.set(l*o+i,l*s-n*a,l*a+n*s,0,l*s+n*a,c*s+i,c*a-n*o,0,l*a-n*s,c*a+n*o,r*a*a+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,o){return this.set(1,i,r,0,e,1,o,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,o=t._y,s=t._z,a=t._w,l=r+r,c=o+o,u=s+s,h=r*l,p=r*c,d=r*u,f=o*c,m=o*u,g=s*u,_=a*l,y=a*c,v=a*u,x=i.x,b=i.y,w=i.z;return n[0]=(1-(f+g))*x,n[1]=(p+v)*x,n[2]=(d-y)*x,n[3]=0,n[4]=(p-v)*b,n[5]=(1-(h+g))*b,n[6]=(m+_)*b,n[7]=0,n[8]=(d+y)*w,n[9]=(m-_)*w,n[10]=(1-(h+f))*w,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let r=st.set(n[0],n[1],n[2]).length();const o=st.set(n[4],n[5],n[6]).length(),s=st.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],at.copy(this);const a=1/r,l=1/o,c=1/s;return at.elements[0]*=a,at.elements[1]*=a,at.elements[2]*=a,at.elements[4]*=l,at.elements[5]*=l,at.elements[6]*=l,at.elements[8]*=c,at.elements[9]*=c,at.elements[10]*=c,t.setFromRotationMatrix(at),i.x=r,i.y=o,i.z=s,this}makePerspective(e,t,i,n,r,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const s=this.elements,a=2*r/(t-e),l=2*r/(i-n),c=(t+e)/(t-e),u=(i+n)/(i-n),h=-(o+r)/(o-r),p=-2*o*r/(o-r);return s[0]=a,s[4]=0,s[8]=c,s[12]=0,s[1]=0,s[5]=l,s[9]=u,s[13]=0,s[2]=0,s[6]=0,s[10]=h,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,i,n,r,o){const s=this.elements,a=1/(t-e),l=1/(i-n),c=1/(o-r),u=(t+e)*a,h=(i+n)*l,p=(o+r)*c;return s[0]=2*a,s[4]=0,s[8]=0,s[12]=-u,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-h,s[2]=0,s[6]=0,s[10]=-2*c,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}ot.prototype.isMatrix4=!0;const st=new Ce,at=new ot,lt=new Ce(0,0,0),ct=new Ce(1,1,1),ut=new Ce,ht=new Ce,pt=new Ce,dt=new ot,ft=new Ae;class mt{constructor(e=0,t=0,i=0,n=mt.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],o=n[4],s=n[8],a=n[1],l=n[5],c=n[9],u=n[2],h=n[6],p=n[10];switch(t){case"XYZ":this._y=Math.asin(ce(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ce(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(ce(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-ce(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(ce(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(s,p));break;case"XZY":this._z=Math.asin(-ce(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return dt.makeRotationFromQuaternion(e),this.setFromRotationMatrix(dt,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ft.setFromEuler(this),this.setFromQuaternion(ft,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new Ce(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}mt.prototype.isEuler=!0,mt.DefaultOrder="XYZ",mt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class gt{constructor(){this.mask=1}set(e){this.mask=1<<e|0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}}let _t=0;const yt=new Ce,vt=new Ae,xt=new ot,bt=new Ce,wt=new Ce,Mt=new Ce,Tt=new Ae,St=new Ce(1,0,0),Et=new Ce(0,1,0),At=new Ce(0,0,1),Ct={type:"added"},Lt={type:"removed"};class It extends ne{constructor(){super(),Object.defineProperty(this,"id",{value:_t++}),this.uuid=le(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=It.DefaultUp.clone();const e=new Ce,t=new mt,i=new Ae,n=new Ce(1,1,1);t._onChange((function(){i.setFromEuler(t,!1)})),i._onChange((function(){t.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new ot},normalMatrix:{value:new _e}}),this.matrix=new ot,this.matrixWorld=new ot,this.matrixAutoUpdate=It.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new gt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return vt.setFromAxisAngle(e,t),this.quaternion.multiply(vt),this}rotateOnWorldAxis(e,t){return vt.setFromAxisAngle(e,t),this.quaternion.premultiply(vt),this}rotateX(e){return this.rotateOnAxis(St,e)}rotateY(e){return this.rotateOnAxis(Et,e)}rotateZ(e){return this.rotateOnAxis(At,e)}translateOnAxis(e,t){return yt.copy(e).applyQuaternion(this.quaternion),this.position.add(yt.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(St,e)}translateY(e){return this.translateOnAxis(Et,e)}translateZ(e){return this.translateOnAxis(At,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(xt.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?bt.copy(e):bt.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),wt.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xt.lookAt(wt,bt,this.up):xt.lookAt(bt,wt,this.up),this.quaternion.setFromRotationMatrix(xt),n&&(xt.extractRotation(n.matrixWorld),vt.setFromRotationMatrix(xt),this.quaternion.premultiply(vt.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Ct)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Lt)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(Lt)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),xt.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),xt.multiply(e.parent.matrixWorld)),e.applyMatrix4(xt),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wt,e,Mt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wt,Tt,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(!0===e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,i=e.length;t<i;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){const t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};function r(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const i=t.shapes;if(Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const n=i[t];r(e.shapes,n)}else r(e.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let i=0,n=this.material.length;i<n;i++)t.push(r(e.materials,this.material[i]));n.material=t}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let t=0;t<this.children.length;t++)n.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let t=0;t<this.animations.length;t++){const i=this.animations[t];n.animations.push(r(e.animations,i))}}if(t){const t=o(e.geometries),n=o(e.materials),r=o(e.textures),s=o(e.images),a=o(e.shapes),l=o(e.skeletons),c=o(e.animations);t.length>0&&(i.geometries=t),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),s.length>0&&(i.images=s),a.length>0&&(i.shapes=a),l.length>0&&(i.skeletons=l),c.length>0&&(i.animations=c)}return i.object=n,i;function o(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const i=e.children[t];this.add(i.clone())}return this}}It.DefaultUp=new Ce(0,1,0),It.DefaultMatrixAutoUpdate=!0,It.prototype.isObject3D=!0;const Pt=new Ce,Rt=new Ce,kt=new Ce,zt=new Ce,Dt=new Ce,Ot=new Ce,Ft=new Ce,Bt=new Ce,Nt=new Ce,Ut=new Ce;class jt{constructor(e=new Ce,t=new Ce,i=new Ce){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),Pt.subVectors(e,t),n.cross(Pt);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){Pt.subVectors(n,t),Rt.subVectors(i,t),kt.subVectors(e,t);const o=Pt.dot(Pt),s=Pt.dot(Rt),a=Pt.dot(kt),l=Rt.dot(Rt),c=Rt.dot(kt),u=o*l-s*s;if(0===u)return r.set(-2,-1,-1);const h=1/u,p=(l*a-s*c)*h,d=(o*c-s*a)*h;return r.set(1-p-d,d,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,zt),zt.x>=0&&zt.y>=0&&zt.x+zt.y<=1}static getUV(e,t,i,n,r,o,s,a){return this.getBarycoord(e,t,i,n,zt),a.set(0,0),a.addScaledVector(r,zt.x),a.addScaledVector(o,zt.y),a.addScaledVector(s,zt.z),a}static isFrontFacing(e,t,i,n){return Pt.subVectors(i,t),Rt.subVectors(e,t),Pt.cross(Rt).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Pt.subVectors(this.c,this.b),Rt.subVectors(this.a,this.b),.5*Pt.cross(Rt).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return jt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return jt.getUV(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return jt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let o,s;Dt.subVectors(n,i),Ot.subVectors(r,i),Bt.subVectors(e,i);const a=Dt.dot(Bt),l=Ot.dot(Bt);if(a<=0&&l<=0)return t.copy(i);Nt.subVectors(e,n);const c=Dt.dot(Nt),u=Ot.dot(Nt);if(c>=0&&u<=c)return t.copy(n);const h=a*u-c*l;if(h<=0&&a>=0&&c<=0)return o=a/(a-c),t.copy(i).addScaledVector(Dt,o);Ut.subVectors(e,r);const p=Dt.dot(Ut),d=Ot.dot(Ut);if(d>=0&&p<=d)return t.copy(r);const f=p*l-a*d;if(f<=0&&l>=0&&d<=0)return s=l/(l-d),t.copy(i).addScaledVector(Ot,s);const m=c*d-p*u;if(m<=0&&u-c>=0&&p-d>=0)return Ft.subVectors(r,n),s=(u-c)/(u-c+(p-d)),t.copy(n).addScaledVector(Ft,s);const g=1/(m+f+h);return o=f*g,s=h*g,t.copy(i).addScaledVector(Dt,o).addScaledVector(Ot,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Vt=0;class Gt extends ne{constructor(){super(),Object.defineProperty(this,"id",{value:Vt++}),this.uuid=le(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=E,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=i,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const i=e[t];if(void 0===i){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;continue}const n=this[t];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheenTint&&this.sheenTint.isColor&&(i.sheenTint=this.sheenTint.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularTint&&this.specularTint.isColor&&(i.specularTint=this.specularTint.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularTintMap&&this.specularTintMap.isTexture&&(i.specularTintMap=this.specularTintMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationTint&&(i.attenuationTint=this.attenuationTint.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.format!==E&&(i.format=this.format),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){const t=n(e.textures),r=n(e.images);t.length>0&&(i.textures=t),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.format=e.format,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(null!==t){const e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}Gt.prototype.isMaterial=!0;const Ht={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Wt={h:0,s:0,l:0},qt={h:0,s:0,l:0};function $t(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}function Zt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Xt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class Yt{constructor(e,t,i){return void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,i){return this.r=e,this.g=t,this.b=i,this}setHSL(e,t,i){if(e=ue(e,1),t=ce(t,0,1),i=ce(i,0,1),0===t)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=$t(r,n,e+1/3),this.g=$t(r,n,e),this.b=$t(r,n,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(e[1])/360,n=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=i[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=Ht[e.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){const i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=Zt(e.r),this.g=Zt(e.g),this.b=Zt(e.b),this}copyLinearToSRGB(e){return this.r=Xt(e.r),this.g=Xt(e.g),this.b=Xt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,i=this.g,n=this.b,r=Math.max(t,i,n),o=Math.min(t,i,n);let s,a;const l=(o+r)/2;if(o===r)s=0,a=0;else{const e=r-o;switch(a=l<=.5?e/(r+o):e/(2-r-o),r){case t:s=(i-n)/e+(i<n?6:0);break;case i:s=(n-t)/e+2;break;case n:s=(t-i)/e+4}s/=6}return e.h=s,e.s=a,e.l=l,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,i){return this.getHSL(Wt),Wt.h+=e,Wt.s+=t,Wt.l+=i,this.setHSL(Wt.h,Wt.s,Wt.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Wt),e.getHSL(qt);const i=he(Wt.h,qt.h,t),n=he(Wt.s,qt.s,t),r=he(Wt.l,qt.l,t);return this.setHSL(i,n,r),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}Yt.NAMES=Ht,Yt.prototype.isColor=!0,Yt.prototype.r=1,Yt.prototype.g=1,Yt.prototype.b=1;class Jt extends Gt{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new Yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Jt.prototype.isMeshBasicMaterial=!0;const Qt=new Ce,Kt=new ge;class ei{constructor(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===i,this.usage=ee,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),r=new Yt),t[i++]=r.r,t[i++]=r.g,t[i++]=r.b}return this}copyVector2sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),r=new ge),t[i++]=r.x,t[i++]=r.y}return this}copyVector3sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),r=new Ce),t[i++]=r.x,t[i++]=r.y,t[i++]=r.z}return this}copyVector4sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),r=new Me),t[i++]=r.x,t[i++]=r.y,t[i++]=r.z,t[i++]=r.w}return this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)Kt.fromBufferAttribute(this,t),Kt.applyMatrix3(e),this.setXY(t,Kt.x,Kt.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.applyMatrix3(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Qt.x=this.getX(t),Qt.y=this.getY(t),Qt.z=this.getZ(t),Qt.applyMatrix4(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Qt.x=this.getX(t),Qt.y=this.getY(t),Qt.z=this.getZ(t),Qt.applyNormalMatrix(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Qt.x=this.getX(t),Qt.y=this.getY(t),Qt.z=this.getZ(t),Qt.transformDirection(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==ee&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}ei.prototype.isBufferAttribute=!0;class ti extends ei{constructor(e,t,i){super(new Int8Array(e),t,i)}}class ii extends ei{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class ni extends ei{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class ri extends ei{constructor(e,t,i){super(new Int16Array(e),t,i)}}class oi extends ei{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class si extends ei{constructor(e,t,i){super(new Int32Array(e),t,i)}}class ai extends ei{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class li extends ei{constructor(e,t,i){super(new Uint16Array(e),t,i)}}li.prototype.isFloat16BufferAttribute=!0;class ci extends ei{constructor(e,t,i){super(new Float32Array(e),t,i)}}class ui extends ei{constructor(e,t,i){super(new Float64Array(e),t,i)}}function hi(e){if(0===e.length)return-1/0;let t=e[0];for(let i=1,n=e.length;i<n;++i)e[i]>t&&(t=e[i]);return t}const pi={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function di(e,t){return new pi[e](t)}let fi=0;const mi=new ot,gi=new It,_i=new Ce,yi=new Pe,vi=new Pe,xi=new Ce;class bi extends ne{constructor(){super(),Object.defineProperty(this,"id",{value:fi++}),this.uuid=le(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(hi(e)>65535?ai:oi)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const t=(new _e).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return mi.makeRotationFromQuaternion(e),this.applyMatrix4(mi),this}rotateX(e){return mi.makeRotationX(e),this.applyMatrix4(mi),this}rotateY(e){return mi.makeRotationY(e),this.applyMatrix4(mi),this}rotateZ(e){return mi.makeRotationZ(e),this.applyMatrix4(mi),this}translate(e,t,i){return mi.makeTranslation(e,t,i),this.applyMatrix4(mi),this}scale(e,t,i){return mi.makeScale(e,t,i),this.applyMatrix4(mi),this}lookAt(e){return gi.lookAt(e),gi.updateMatrix(),this.applyMatrix4(gi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_i).negate(),this.translate(_i.x,_i.y,_i.z),this}setFromPoints(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i];t.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new ci(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Pe);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Ce(-1/0,-1/0,-1/0),new Ce(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];yi.setFromBufferAttribute(i),this.morphTargetsRelative?(xi.addVectors(this.boundingBox.min,yi.min),this.boundingBox.expandByPoint(xi),xi.addVectors(this.boundingBox.max,yi.max),this.boundingBox.expandByPoint(xi)):(this.boundingBox.expandByPoint(yi.min),this.boundingBox.expandByPoint(yi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ye);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Ce,1/0);if(e){const i=this.boundingSphere.center;if(yi.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];vi.setFromBufferAttribute(i),this.morphTargetsRelative?(xi.addVectors(yi.min,vi.min),yi.expandByPoint(xi),xi.addVectors(yi.max,vi.max),yi.expandByPoint(xi)):(yi.expandByPoint(vi.min),yi.expandByPoint(vi.max))}yi.getCenter(i);let n=0;for(let t=0,r=e.count;t<r;t++)xi.fromBufferAttribute(e,t),n=Math.max(n,i.distanceToSquared(xi));if(t)for(let r=0,o=t.length;r<o;r++){const o=t[r],s=this.morphTargetsRelative;for(let t=0,r=o.count;t<r;t++)xi.fromBufferAttribute(o,t),s&&(_i.fromBufferAttribute(e,t),xi.add(_i)),n=Math.max(n,i.distanceToSquared(xi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=e.array,n=t.position.array,r=t.normal.array,o=t.uv.array,s=n.length/3;void 0===t.tangent&&this.setAttribute("tangent",new ei(new Float32Array(4*s),4));const a=t.tangent.array,l=[],c=[];for(let e=0;e<s;e++)l[e]=new Ce,c[e]=new Ce;const u=new Ce,h=new Ce,p=new Ce,d=new ge,f=new ge,m=new ge,g=new Ce,_=new Ce;function y(e,t,i){u.fromArray(n,3*e),h.fromArray(n,3*t),p.fromArray(n,3*i),d.fromArray(o,2*e),f.fromArray(o,2*t),m.fromArray(o,2*i),h.sub(u),p.sub(u),f.sub(d),m.sub(d);const r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(h).multiplyScalar(m.y).addScaledVector(p,-f.y).multiplyScalar(r),_.copy(p).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(r),l[e].add(g),l[t].add(g),l[i].add(g),c[e].add(_),c[t].add(_),c[i].add(_))}let v=this.groups;0===v.length&&(v=[{start:0,count:i.length}]);for(let e=0,t=v.length;e<t;++e){const t=v[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)y(i[e+0],i[e+1],i[e+2])}const x=new Ce,b=new Ce,w=new Ce,M=new Ce;function T(e){w.fromArray(r,3*e),M.copy(w);const t=l[e];x.copy(t),x.sub(w.multiplyScalar(w.dot(t))).normalize(),b.crossVectors(M,t);const i=b.dot(c[e])<0?-1:1;a[4*e]=x.x,a[4*e+1]=x.y,a[4*e+2]=x.z,a[4*e+3]=i}for(let e=0,t=v.length;e<t;++e){const t=v[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)T(i[e+0]),T(i[e+1]),T(i[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let i=this.getAttribute("normal");if(void 0===i)i=new ei(new Float32Array(3*t.count),3),this.setAttribute("normal",i);else for(let e=0,t=i.count;e<t;e++)i.setXYZ(e,0,0,0);const n=new Ce,r=new Ce,o=new Ce,s=new Ce,a=new Ce,l=new Ce,c=new Ce,u=new Ce;if(e)for(let h=0,p=e.count;h<p;h+=3){const p=e.getX(h+0),d=e.getX(h+1),f=e.getX(h+2);n.fromBufferAttribute(t,p),r.fromBufferAttribute(t,d),o.fromBufferAttribute(t,f),c.subVectors(o,r),u.subVectors(n,r),c.cross(u),s.fromBufferAttribute(i,p),a.fromBufferAttribute(i,d),l.fromBufferAttribute(i,f),s.add(c),a.add(c),l.add(c),i.setXYZ(p,s.x,s.y,s.z),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,s=t.count;e<s;e+=3)n.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),o.fromBufferAttribute(t,e+2),c.subVectors(o,r),u.subVectors(n,r),c.cross(u),i.setXYZ(e+0,c.x,c.y,c.z),i.setXYZ(e+1,c.x,c.y,c.z),i.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}merge(e,t){if(!e||!e.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const i=this.attributes;for(const n in i){if(void 0===e.attributes[n])continue;const r=i[n].array,o=e.attributes[n],s=o.array,a=o.itemSize*t,l=Math.min(s.length,r.length-a);for(let e=0,t=a;e<l;e++,t++)r[t]=s[e]}return this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)xi.fromBufferAttribute(e,t),xi.normalize(),e.setXYZ(t,xi.x,xi.y,xi.z)}toNonIndexed(){function e(e,t){const i=e.array,n=e.itemSize,r=e.normalized,o=new i.constructor(t.length*n);let s=0,a=0;for(let r=0,l=t.length;r<l;r++){s=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*n;for(let e=0;e<n;e++)o[a++]=i[s++]}return new ei(o,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new bi,i=this.index.array,n=this.attributes;for(const r in n){const o=e(n[r],i);t.setAttribute(r,o)}const r=this.morphAttributes;for(const n in r){const o=[],s=r[n];for(let t=0,n=s.length;t<n;t++){const n=e(s[t],i);o.push(n)}t.morphAttributes[n]=o}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let e=0,i=o.length;e<i;e++){const i=o[e];t.addGroup(i.start,i.count,i.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const t in i){const n=i[t];e.data.attributes[t]=n.toJSON(e.data)}const n={};let r=!1;for(const t in this.morphAttributes){const i=this.morphAttributes[t],o=[];for(let t=0,n=i.length;t<n;t++){const n=i[t];o.push(n.toJSON(e.data))}o.length>0&&(n[t]=o,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new bi).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;null!==i&&this.setIndex(i.clone(t));const n=e.attributes;for(const e in n){const i=n[e];this.setAttribute(e,i.clone(t))}const r=e.morphAttributes;for(const e in r){const i=[],n=r[e];for(let e=0,r=n.length;e<r;e++)i.push(n[e].clone(t));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let e=0,t=o.length;e<t;e++){const t=o[e];this.addGroup(t.start,t.count,t.materialIndex)}const s=e.boundingBox;null!==s&&(this.boundingBox=s.clone());const a=e.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}bi.prototype.isBufferGeometry=!0;const wi=new ot,Mi=new rt,Ti=new Ye,Si=new Ce,Ei=new Ce,Ai=new Ce,Ci=new Ce,Li=new Ce,Ii=new Ce,Pi=new Ce,Ri=new Ce,ki=new Ce,zi=new ge,Di=new ge,Oi=new ge,Fi=new Ce,Bi=new Ce;class Ni extends It{constructor(e=new bi,t=new Jt){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Ti.copy(i.boundingSphere),Ti.applyMatrix4(r),!1===e.ray.intersectsSphere(Ti))return;if(wi.copy(r).invert(),Mi.copy(e.ray).applyMatrix4(wi),null!==i.boundingBox&&!1===Mi.intersectsBox(i.boundingBox))return;let o;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position,a=i.morphAttributes.position,l=i.morphTargetsRelative,c=i.attributes.uv,u=i.attributes.uv2,h=i.groups,p=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,d=h.length;i<d;i++){const d=h[i],f=n[d.materialIndex];for(let i=Math.max(d.start,p.start),n=Math.min(d.start+d.count,p.start+p.count);i<n;i+=3){const n=r.getX(i),h=r.getX(i+1),p=r.getX(i+2);(o=Ui(this,f,e,Mi,s,a,l,c,u,n,h,p))&&(o.faceIndex=Math.floor(i/3),o.face.materialIndex=d.materialIndex,t.push(o))}}else for(let i=Math.max(0,p.start),h=Math.min(r.count,p.start+p.count);i<h;i+=3){const h=r.getX(i),p=r.getX(i+1),d=r.getX(i+2);(o=Ui(this,n,e,Mi,s,a,l,c,u,h,p,d))&&(o.faceIndex=Math.floor(i/3),t.push(o))}else if(void 0!==s)if(Array.isArray(n))for(let i=0,r=h.length;i<r;i++){const r=h[i],d=n[r.materialIndex];for(let i=Math.max(r.start,p.start),n=Math.min(r.start+r.count,p.start+p.count);i<n;i+=3)(o=Ui(this,d,e,Mi,s,a,l,c,u,i,i+1,i+2))&&(o.faceIndex=Math.floor(i/3),o.face.materialIndex=r.materialIndex,t.push(o))}else for(let i=Math.max(0,p.start),r=Math.min(s.count,p.start+p.count);i<r;i+=3)(o=Ui(this,n,e,Mi,s,a,l,c,u,i,i+1,i+2))&&(o.faceIndex=Math.floor(i/3),t.push(o))}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}function Ui(e,t,i,n,r,o,s,a,l,c,u,h){Si.fromBufferAttribute(r,c),Ei.fromBufferAttribute(r,u),Ai.fromBufferAttribute(r,h);const p=e.morphTargetInfluences;if(o&&p){Pi.set(0,0,0),Ri.set(0,0,0),ki.set(0,0,0);for(let e=0,t=o.length;e<t;e++){const t=p[e],i=o[e];0!==t&&(Ci.fromBufferAttribute(i,c),Li.fromBufferAttribute(i,u),Ii.fromBufferAttribute(i,h),s?(Pi.addScaledVector(Ci,t),Ri.addScaledVector(Li,t),ki.addScaledVector(Ii,t)):(Pi.addScaledVector(Ci.sub(Si),t),Ri.addScaledVector(Li.sub(Ei),t),ki.addScaledVector(Ii.sub(Ai),t)))}Si.add(Pi),Ei.add(Ri),Ai.add(ki)}e.isSkinnedMesh&&(e.boneTransform(c,Si),e.boneTransform(u,Ei),e.boneTransform(h,Ai));const d=function(e,t,i,n,r,o,s,a){let l;if(null===(l=1===t.side?n.intersectTriangle(s,o,r,!0,a):n.intersectTriangle(r,o,s,2!==t.side,a)))return null;Bi.copy(a),Bi.applyMatrix4(e.matrixWorld);const c=i.ray.origin.distanceTo(Bi);return c<i.near||c>i.far?null:{distance:c,point:Bi.clone(),object:e}}(e,t,i,n,Si,Ei,Ai,Fi);if(d){a&&(zi.fromBufferAttribute(a,c),Di.fromBufferAttribute(a,u),Oi.fromBufferAttribute(a,h),d.uv=jt.getUV(Fi,Si,Ei,Ai,zi,Di,Oi,new ge)),l&&(zi.fromBufferAttribute(l,c),Di.fromBufferAttribute(l,u),Oi.fromBufferAttribute(l,h),d.uv2=jt.getUV(Fi,Si,Ei,Ai,zi,Di,Oi,new ge));const e={a:c,b:u,c:h,normal:new Ce,materialIndex:0};jt.getNormal(Si,Ei,Ai,e.normal),d.face=e}return d}Ni.prototype.isMesh=!0;class ji extends bi{constructor(e=1,t=1,i=1,n=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:o};const s=this;n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);const a=[],l=[],c=[],u=[];let h=0,p=0;function d(e,t,i,n,r,o,d,f,m,g,_){const y=o/m,v=d/g,x=o/2,b=d/2,w=f/2,M=m+1,T=g+1;let S=0,E=0;const A=new Ce;for(let o=0;o<T;o++){const s=o*v-b;for(let a=0;a<M;a++){const h=a*y-x;A[e]=h*n,A[t]=s*r,A[i]=w,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[i]=f>0?1:-1,c.push(A.x,A.y,A.z),u.push(a/m),u.push(1-o/g),S+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const i=h+t+M*e,n=h+t+M*(e+1),r=h+(t+1)+M*(e+1),o=h+(t+1)+M*e;a.push(i,n,o),a.push(n,r,o),E+=6}s.addGroup(p,E,_),p+=E,h+=S}d("z","y","x",-1,-1,i,t,e,o,r,0),d("z","y","x",1,-1,i,t,-e,o,r,1),d("x","z","y",1,1,e,i,t,n,o,2),d("x","z","y",1,-1,e,i,-t,n,o,3),d("x","y","z",1,-1,e,t,i,n,r,4),d("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(a),this.setAttribute("position",new ci(l,3)),this.setAttribute("normal",new ci(c,3)),this.setAttribute("uv",new ci(u,2))}static fromJSON(e){return new ji(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Vi(e){const t={};for(const i in e){t[i]={};for(const n in e[i]){const r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function Gi(e){const t={};for(let i=0;i<e.length;i++){const n=Vi(e[i]);for(const e in n)t[e]=n[e]}return t}const Hi={clone:Vi,merge:Gi};class Wi extends Gt{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Vi(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?t.uniforms[i]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[i]={type:"m4",value:n.toArray()}:t.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}Wi.prototype.isShaderMaterial=!0;class qi extends It{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new ot,this.projectionMatrix=new ot,this.projectionMatrixInverse=new ot}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}qi.prototype.isCamera=!0;class $i extends qi{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*ae*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*se*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*ae*Math.atan(Math.tan(.5*se*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,r,o){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*se*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const o=this.view;if(null!==this.view&&this.view.enabled){const e=o.fullWidth,s=o.fullHeight;r+=o.offsetX*n/e,t-=o.offsetY*i/s,n*=o.width/e,i*=o.height/s}const s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}$i.prototype.isPerspectiveCamera=!0;class Zi extends It{constructor(e,t,i){if(super(),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new $i(90,1,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new Ce(1,0,0)),this.add(n);const r=new $i(90,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Ce(-1,0,0)),this.add(r);const o=new $i(90,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new Ce(0,1,0)),this.add(o);const s=new $i(90,1,e,t);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new Ce(0,-1,0)),this.add(s);const a=new $i(90,1,e,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new Ce(0,0,1)),this.add(a);const l=new $i(90,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Ce(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,r,o,s,a,l]=this.children,c=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const h=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,r),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,s),e.setRenderTarget(i,4),e.render(t,a),i.texture.generateMipmaps=h,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=c}}class Xi extends be{constructor(e,t,i,n,o,s,a,l,c,u){super(e=void 0!==e?e:[],t=void 0!==t?t:r,i,n,o,s,a=void 0!==a?a:S,l,c,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Xi.prototype.isCubeTexture=!0;class Yi extends Te{constructor(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),super(e,e,t),t=t||{},this.texture=new Xi(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=E,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i=new ji(5,5,5),n=new Wi({name:"CubemapFromEquirect",uniforms:Vi({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});n.uniforms.tEquirect.value=t;const r=new Ni(i,n),o=t.minFilter;return t.minFilter===y&&(t.minFilter=g),new Zi(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,i,n){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(r)}}Yi.prototype.isWebGLCubeRenderTarget=!0;const Ji=new Ce,Qi=new Ce,Ki=new _e;class en{constructor(e=new Ce(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=Ji.subVectors(i,t).cross(Qi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const i=e.delta(Ji),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(i).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Ki.getNormalMatrix(e),n=this.coplanarPoint(Ji).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}en.prototype.isPlane=!0;const tn=new Ye,nn=new Ce;class rn{constructor(e=new en,t=new en,i=new en,n=new en,r=new en,o=new en){this.planes=[e,t,i,n,r,o]}set(e,t,i,n,r,o){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(n),s[4].copy(r),s[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){const t=this.planes,i=e.elements,n=i[0],r=i[1],o=i[2],s=i[3],a=i[4],l=i[5],c=i[6],u=i[7],h=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],_=i[14],y=i[15];return t[0].setComponents(s-n,u-a,f-h,y-m).normalize(),t[1].setComponents(s+n,u+a,f+h,y+m).normalize(),t[2].setComponents(s+r,u+l,f+p,y+g).normalize(),t[3].setComponents(s-r,u-l,f-p,y-g).normalize(),t[4].setComponents(s-o,u-c,f-d,y-_).normalize(),t[5].setComponents(s+o,u+c,f+d,y+_).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),tn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(tn)}intersectsSprite(e){return tn.center.set(0,0,0),tn.radius=.7071067811865476,tn.applyMatrix4(e.matrixWorld),this.intersectsSphere(tn)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(nn.x=n.normal.x>0?e.max.x:e.min.x,nn.y=n.normal.y>0?e.max.y:e.min.y,nn.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(nn)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function on(){let e=null,t=!1,i=null,n=null;function r(t,o){i(t,o),n=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function sn(e,t){const i=t.isWebGL2,n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const i=n.get(t);i&&(e.deleteBuffer(i.buffer),n.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=n.get(t);return void((!e||e.version<t.version)&&n.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const o=n.get(t);void 0===o?n.set(t,function(t,n){const r=t.array,o=t.usage,s=e.createBuffer();e.bindBuffer(n,s),e.bufferData(n,r,o),t.onUploadCallback();let a=5126;return r instanceof Float32Array?a=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?t.isFloat16BufferAttribute?i?a=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):a=5123:r instanceof Int16Array?a=5122:r instanceof Uint32Array?a=5125:r instanceof Int32Array?a=5124:r instanceof Int8Array?a=5120:(r instanceof Uint8Array||r instanceof Uint8ClampedArray)&&(a=5121),{buffer:s,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(t,r)):o.version<t.version&&(function(t,n,r){const o=n.array,s=n.updateRange;e.bindBuffer(r,t),-1===s.count?e.bufferSubData(r,0,o):(i?e.bufferSubData(r,s.offset*o.BYTES_PER_ELEMENT,o,s.offset,s.count):e.bufferSubData(r,s.offset*o.BYTES_PER_ELEMENT,o.subarray(s.offset,s.offset+s.count)),s.count=-1)}(o.buffer,t,r),o.version=t.version)}}}class an extends bi{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,o=t/2,s=Math.floor(i),a=Math.floor(n),l=s+1,c=a+1,u=e/s,h=t/a,p=[],d=[],f=[],m=[];for(let e=0;e<c;e++){const t=e*h-o;for(let i=0;i<l;i++){const n=i*u-r;d.push(n,-t,0),f.push(0,0,1),m.push(i/s),m.push(1-e/a)}}for(let e=0;e<a;e++)for(let t=0;t<s;t++){const i=t+l*e,n=t+l*(e+1),r=t+1+l*(e+1),o=t+1+l*e;p.push(i,n,o),p.push(n,r,o)}this.setIndex(p),this.setAttribute("position",new ci(d,3)),this.setAttribute("normal",new ci(f,3)),this.setAttribute("uv",new ci(m,2))}static fromJSON(e){return new an(e.width,e.height,e.widthSegments,e.heightSegments)}}const ln={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotVH = saturate( dot( geometry.viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float NoH ) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float NoV, float NoL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( NoL + NoV - NoL * NoV ) ) );\n}\nvec3 BRDF_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in GeometricContext geometry ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularTintFactor = specularTint;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARTINTMAP\n\t\t\tspecularTintFactor *= specularTintMapTexelToLinear( texture2D( specularTintMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularTintFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularTintFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenTint = sheenTint;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenTint;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( material.roughness, directLight.direction, geometry, material.sheenTint );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationTint, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = transmission.a;\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationTint;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularTint;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARTINTMAP\n\t\tuniform sampler2D specularTintMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenTint;\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},cn={common:{diffuse:{value:new Yt(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new _e},uv2Transform:{value:new _e},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ge(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Yt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new _e}},sprite:{diffuse:{value:new Yt(16777215)},opacity:{value:1},center:{value:new ge(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new _e}}},un={basic:{uniforms:Gi([cn.common,cn.specularmap,cn.envmap,cn.aomap,cn.lightmap,cn.fog]),vertexShader:ln.meshbasic_vert,fragmentShader:ln.meshbasic_frag},lambert:{uniforms:Gi([cn.common,cn.specularmap,cn.envmap,cn.aomap,cn.lightmap,cn.emissivemap,cn.fog,cn.lights,{emissive:{value:new Yt(0)}}]),vertexShader:ln.meshlambert_vert,fragmentShader:ln.meshlambert_frag},phong:{uniforms:Gi([cn.common,cn.specularmap,cn.envmap,cn.aomap,cn.lightmap,cn.emissivemap,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.fog,cn.lights,{emissive:{value:new Yt(0)},specular:{value:new Yt(1118481)},shininess:{value:30}}]),vertexShader:ln.meshphong_vert,fragmentShader:ln.meshphong_frag},standard:{uniforms:Gi([cn.common,cn.envmap,cn.aomap,cn.lightmap,cn.emissivemap,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.roughnessmap,cn.metalnessmap,cn.fog,cn.lights,{emissive:{value:new Yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag},toon:{uniforms:Gi([cn.common,cn.aomap,cn.lightmap,cn.emissivemap,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.gradientmap,cn.fog,cn.lights,{emissive:{value:new Yt(0)}}]),vertexShader:ln.meshtoon_vert,fragmentShader:ln.meshtoon_frag},matcap:{uniforms:Gi([cn.common,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.fog,{matcap:{value:null}}]),vertexShader:ln.meshmatcap_vert,fragmentShader:ln.meshmatcap_frag},points:{uniforms:Gi([cn.points,cn.fog]),vertexShader:ln.points_vert,fragmentShader:ln.points_frag},dashed:{uniforms:Gi([cn.common,cn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ln.linedashed_vert,fragmentShader:ln.linedashed_frag},depth:{uniforms:Gi([cn.common,cn.displacementmap]),vertexShader:ln.depth_vert,fragmentShader:ln.depth_frag},normal:{uniforms:Gi([cn.common,cn.bumpmap,cn.normalmap,cn.displacementmap,{opacity:{value:1}}]),vertexShader:ln.meshnormal_vert,fragmentShader:ln.meshnormal_frag},sprite:{uniforms:Gi([cn.sprite,cn.fog]),vertexShader:ln.sprite_vert,fragmentShader:ln.sprite_frag},background:{uniforms:{uvTransform:{value:new _e},t2D:{value:null}},vertexShader:ln.background_vert,fragmentShader:ln.background_frag},cube:{uniforms:Gi([cn.envmap,{opacity:{value:1}}]),vertexShader:ln.cube_vert,fragmentShader:ln.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ln.equirect_vert,fragmentShader:ln.equirect_frag},distanceRGBA:{uniforms:Gi([cn.common,cn.displacementmap,{referencePosition:{value:new Ce},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ln.distanceRGBA_vert,fragmentShader:ln.distanceRGBA_frag},shadow:{uniforms:Gi([cn.lights,cn.fog,{color:{value:new Yt(0)},opacity:{value:1}}]),vertexShader:ln.shadow_vert,fragmentShader:ln.shadow_frag}};function hn(e,t,i,n,r){const o=new Yt(0);let s,a,c=0,u=null,h=0,p=null;function d(e,t){i.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),d(o,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){d(o,c=e)},render:function(i,r){let f=!1,m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=t.get(m));const g=e.xr,_=g.getSession&&g.getSession();_&&"additive"===_.environmentBlendMode&&(m=null),null===m?d(o,c):m&&m.isColor&&(d(m,1),f=!0),(e.autoClear||f)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===l)?(void 0===a&&((a=new Ni(new ji(1,1,1),new Wi({name:"BackgroundCubeMaterial",uniforms:Vi(un.cube.uniforms),vertexShader:un.cube.vertexShader,fragmentShader:un.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),a.geometry.deleteAttribute("uv"),a.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(a.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(a)),a.material.uniforms.envMap.value=m,a.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,u===m&&h===m.version&&p===e.toneMapping||(a.material.needsUpdate=!0,u=m,h=m.version,p=e.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null)):m&&m.isTexture&&(void 0===s&&((s=new Ni(new an(2,2),new Wi({name:"BackgroundMaterial",uniforms:Vi(un.background.uniforms),vertexShader:un.background.vertexShader,fragmentShader:un.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(s)),s.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),s.material.uniforms.uvTransform.value.copy(m.matrix),u===m&&h===m.version&&p===e.toneMapping||(s.material.needsUpdate=!0,u=m,h=m.version,p=e.toneMapping),i.unshift(s,s.geometry,s.material,0,0,null))}}}function pn(e,t,i,n){const r=e.getParameter(34921),o=n.isWebGL2?null:t.get("OES_vertex_array_object"),s=n.isWebGL2||null!==o,a={},l=p(null);let c=l;function u(t){return n.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function h(t){return n.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function p(e){const t=[],i=[],n=[];for(let e=0;e<r;e++)t[e]=0,i[e]=0,n[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:n,object:e,attributes:{},index:null}}function d(){const e=c.newAttributes;for(let t=0,i=e.length;t<i;t++)e[t]=0}function f(e){m(e,0)}function m(i,r){const o=c.newAttributes,s=c.enabledAttributes,a=c.attributeDivisors;o[i]=1,0===s[i]&&(e.enableVertexAttribArray(i),s[i]=1),a[i]!==r&&((n.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),a[i]=r)}function g(){const t=c.newAttributes,i=c.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==t[n]&&(e.disableVertexAttribArray(n),i[n]=0)}function _(t,i,r,o,s,a){!0!==n.isWebGL2||5124!==r&&5125!==r?e.vertexAttribPointer(t,i,r,o,s,a):e.vertexAttribIPointer(t,i,r,s,a)}function y(){v(),c!==l&&u((c=l).object)}function v(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,h,y,v){let x=!1;if(s){const t=function(t,i,r){const s=!0===r.wireframe;let l=a[t.id];void 0===l&&(l={},a[t.id]=l);let c=l[i.id];void 0===c&&(c={},l[i.id]=c);let u=c[s];return void 0===u&&(u=p(n.isWebGL2?e.createVertexArray():o.createVertexArrayOES()),c[s]=u),u}(y,h,l);c!==t&&u((c=t).object),(x=function(e,t){const i=c.attributes,n=e.attributes;let r=0;for(const e in n){const t=i[e],o=n[e];if(void 0===t)return!0;if(t.attribute!==o)return!0;if(t.data!==o.data)return!0;r++}return c.attributesNum!==r||c.index!==t}(y,v))&&function(e,t){const i={},n=y.attributes;let r=0;for(const e in n){const t=n[e],o={};o.attribute=t,t.data&&(o.data=t.data),i[e]=o,r++}c.attributes=i,c.attributesNum=r,c.index=t}(0,v)}else{const e=!0===l.wireframe;c.geometry===y.id&&c.program===h.id&&c.wireframe===e||(c.geometry=y.id,c.program=h.id,c.wireframe=e,x=!0)}!0===r.isInstancedMesh&&(x=!0),null!==v&&i.update(v,34963),x&&(function(r,o,s,a){if(!1===n.isWebGL2&&(r.isInstancedMesh||a.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;d();const l=a.attributes,c=s.getAttributes(),u=o.defaultAttributeValues;for(const t in c){const n=c[t];if(n.location>=0){let o=l[t];if(void 0===o&&("instanceMatrix"===t&&r.instanceMatrix&&(o=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(o=r.instanceColor)),void 0!==o){const t=o.normalized,s=o.itemSize,l=i.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,h=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const i=o.data,l=i.stride,p=o.offset;if(i&&i.isInstancedInterleavedBuffer){for(let e=0;e<n.locationSize;e++)m(n.location+e,i.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let e=0;e<n.locationSize;e++)f(n.location+e);e.bindBuffer(34962,c);for(let e=0;e<n.locationSize;e++)_(n.location+e,s/n.locationSize,u,t,l*h,(p+s/n.locationSize*e)*h)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<n.locationSize;e++)m(n.location+e,o.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<n.locationSize;e++)f(n.location+e);e.bindBuffer(34962,c);for(let e=0;e<n.locationSize;e++)_(n.location+e,s/n.locationSize,u,t,s*h,s/n.locationSize*e*h)}}else if(void 0!==u){const i=u[t];if(void 0!==i)switch(i.length){case 2:e.vertexAttrib2fv(n.location,i);break;case 3:e.vertexAttrib3fv(n.location,i);break;case 4:e.vertexAttrib4fv(n.location,i);break;default:e.vertexAttrib1fv(n.location,i)}}}}g()}(r,l,h,y),null!==v&&e.bindBuffer(34963,i.get(v).buffer))},reset:y,resetDefaultState:v,dispose:function(){y();for(const e in a){const t=a[e];for(const e in t){const i=t[e];for(const e in i)h(i[e].object),delete i[e];delete t[e]}delete a[e]}},releaseStatesOfGeometry:function(e){if(void 0===a[e.id])return;const t=a[e.id];for(const e in t){const i=t[e];for(const e in i)h(i[e].object),delete i[e];delete t[e]}delete a[e.id]},releaseStatesOfProgram:function(e){for(const t in a){const i=a[t];if(void 0===i[e.id])continue;const n=i[e.id];for(const e in n)h(n[e].object),delete n[e];delete i[e.id]}},initAttributes:d,enableAttribute:f,disableUnusedAttributes:g}}function dn(e,t,i,n){const r=n.isWebGL2;let o;this.setMode=function(e){o=e},this.render=function(t,n){e.drawArrays(o,t,n),i.update(n,o,1)},this.renderInstances=function(n,s,a){if(0===a)return;let l,c;if(r)l=e,c="drawArraysInstanced";else if(c="drawArraysInstancedANGLE",null===(l=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](o,n,s,a),i.update(s,o,a)}}function fn(e,t,i){let n;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let s=void 0!==i.precision?i.precision:"highp";const a=r(s);a!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",a,"instead."),s=a);const l=o||t.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,u=e.getParameter(34930),h=e.getParameter(35660),p=e.getParameter(3379),d=e.getParameter(34076),f=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),_=e.getParameter(36349),y=h>0,v=o||t.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===t.has("EXT_texture_filter_anisotropic")){const i=t.get("EXT_texture_filter_anisotropic");n=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:v,floatVertexTextures:y&&v,maxSamples:o?e.getParameter(36183):0}}function mn(e){const t=this;let i=null,n=0,r=!1,o=!1;const s=new en,a=new _e,l={value:null,needsUpdate:!1};function c(){l.value!==i&&(l.value=i,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(e,i,n,r){const o=null!==e?e.length:0;let c=null;if(0!==o){if(c=l.value,!0!==r||null===c){const t=n+4*o,r=i.matrixWorldInverse;a.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,i=n;t!==o;++t,i+=4)s.copy(e[t]).applyMatrix4(r,a),s.normal.toArray(c,i),c[i+3]=s.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=o,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,o){const s=0!==e.length||t||0!==n||r;return r=t,i=u(e,o,0),n=e.length,s},this.beginShadows=function(){o=!0,u(null)},this.endShadows=function(){o=!1,c()},this.setState=function(t,s,a){const h=t.clippingPlanes,p=t.clipIntersection,d=t.clipShadows,f=e.get(t);if(!r||null===h||0===h.length||o&&!d)o?u(null):c();else{const e=o?0:n,t=4*e;let r=f.clippingState||null;l.value=r,r=u(h,s,t,a);for(let e=0;e!==t;++e)r[e]=i[e];f.clippingState=r,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=e}}}function gn(e){let t=new WeakMap;function i(e,t){return t===s?e.mapping=r:t===a&&(e.mapping=o),e}function n(e){const i=e.target;i.removeEventListener("dispose",n);const r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const o=r.mapping;if(o===s||o===a){if(t.has(r))return i(t.get(r).texture,r.mapping);{const o=r.image;if(o&&o.height>0){const s=e.getRenderTarget(),a=new Yi(o.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),e.setRenderTarget(s),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}un.physical={uniforms:Gi([un.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ge(1,1)},clearcoatNormalMap:{value:null},sheenTint:{value:new Yt(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ge},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationTint:{value:new Yt(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularTint:{value:new Yt(1,1,1)},specularTintMap:{value:null}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag};class _n extends qi{constructor(e=-1,t=1,i=1,n=-1,r=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,o=i+e,s=n+t,a=n-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o=(r+=e*this.view.offsetX)+e*this.view.width,a=(s-=t*this.view.offsetY)-t*this.view.height}this.projectionMatrix.makeOrthographic(r,o,s,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}_n.prototype.isOrthographicCamera=!0;class yn extends Wi{constructor(e){super(e),this.type="RawShaderMaterial"}}yn.prototype.isRawShaderMaterial=!0;const vn=Math.pow(2,8),xn=[.125,.215,.35,.446,.526,.582],bn=5+xn.length,wn={[$]:0,[Z]:1,[Y]:2,[J]:3,[Q]:4,[K]:5,[X]:6},Mn=new _n,{_lodPlanes:Tn,_sizeLods:Sn,_sigmas:En}=function(){const e=[],t=[],i=[];let n=8;for(let r=0;r<bn;r++){const o=Math.pow(2,n);t.push(o);let s=1/o;r>4?s=xn[r-8+4-1]:0==r&&(s=0),i.push(s);const a=1/(o-1),l=-a/2,c=1+a/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,p=6,d=3,f=2,m=1,g=new Float32Array(d*p*h),_=new Float32Array(f*p*h),y=new Float32Array(m*p*h);for(let e=0;e<h;e++){const t=e%3*2/3-1,i=e>2?0:-1,n=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0];g.set(n,d*p*e),_.set(u,f*p*e);const r=[e,e,e,e,e,e];y.set(r,m*p*e)}const v=new bi;v.setAttribute("position",new ei(g,d)),v.setAttribute("uv",new ei(_,f)),v.setAttribute("faceIndex",new ei(y,m)),e.push(v),n>4&&n--}return{_lodPlanes:e,_sizeLods:t,_sigmas:i}}(),An=new Yt;let Cn=null;const Ln=(1+Math.sqrt(5))/2,In=1/Ln,Pn=[new Ce(1,1,1),new Ce(-1,1,1),new Ce(1,1,-1),new Ce(-1,1,-1),new Ce(0,Ln,In),new Ce(0,Ln,-In),new Ce(In,0,Ln),new Ce(-In,0,Ln),new Ce(Ln,In,0),new Ce(-Ln,In,0)];class Rn{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=function(e){const t=new Float32Array(20),i=new Ce(0,1,0);return new yn({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:wn[3e3]},outputEncoding:{value:wn[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){Cn=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,i,n,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=Fn(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=On(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e<Tn.length;e++)Tn[e].dispose()}_cleanup(e){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(Cn),e.scissorTest=!1,Dn(e,0,0,e.width,e.height)}_fromTexture(e){Cn=this._renderer.getRenderTarget();const t=this._allocateTargets(e);return this._textureToCubeUV(e,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(e){const t={magFilter:d,minFilter:d,generateMipmaps:!1,type:v,format:1023,encoding:kn(e)?e.encoding:Y,depthBuffer:!1},i=zn(t);return i.depthBuffer=!e,this._pingPongRenderTarget=zn(t),i}_compileMaterial(e){const t=new Ni(Tn[0],e);this._renderer.compile(t,Mn)}_sceneToCubeUV(e,t,i,n){const r=new $i(90,1,t,i),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],a=this._renderer,l=a.autoClear,c=a.outputEncoding,u=a.toneMapping;a.getClearColor(An),a.toneMapping=0,a.outputEncoding=$,a.autoClear=!1;const h=new Jt({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),p=new Ni(new ji,h);let d=!1;const f=e.background;f?f.isColor&&(h.color.copy(f),e.background=null,d=!0):(h.color.copy(An),d=!0);for(let t=0;t<6;t++){const i=t%3;0==i?(r.up.set(0,o[t],0),r.lookAt(s[t],0,0)):1==i?(r.up.set(0,0,o[t]),r.lookAt(0,s[t],0)):(r.up.set(0,o[t],0),r.lookAt(0,0,s[t])),Dn(n,i*vn,t>2?vn:0,vn,vn),a.setRenderTarget(n),d&&a.render(p,r),a.render(e,r)}p.geometry.dispose(),p.material.dispose(),a.toneMapping=u,a.outputEncoding=c,a.autoClear=l,e.background=f}_textureToCubeUV(e,t){const i=this._renderer;e.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=Fn()):null==this._equirectShader&&(this._equirectShader=On());const n=e.isCubeTexture?this._cubemapShader:this._equirectShader,r=new Ni(Tn[0],n),o=n.uniforms;o.envMap.value=e,e.isCubeTexture||o.texelSize.value.set(1/e.image.width,1/e.image.height),o.inputEncoding.value=wn[e.encoding],o.outputEncoding.value=wn[t.texture.encoding],Dn(t,0,0,3*vn,2*vn),i.setRenderTarget(t),i.render(r,Mn)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t<bn;t++){const i=Math.sqrt(En[t]*En[t]-En[t-1]*En[t-1]),n=Pn[(t-1)%Pn.length];this._blur(e,t-1,t,i,n)}t.autoClear=i}_blur(e,t,i,n,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,n,"latitudinal",r),this._halfBlur(o,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,o,s){const a=this._renderer,l=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new Ni(Tn[n],l),u=l.uniforms,h=Sn[i]-1,p=isFinite(r)?Math.PI/(2*h):2*Math.PI/39,d=r/p,f=isFinite(r)?1+Math.floor(3*d):20;f>20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/d,i=Math.exp(-t*t/2);m.push(i),0==e?g+=i:e<f&&(g+=2*i)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===o,s&&(u.poleAxis.value=s),u.dTheta.value=p,u.mipInt.value=8-i,u.inputEncoding.value=wn[e.texture.encoding],u.outputEncoding.value=wn[e.texture.encoding];const _=Sn[n];Dn(t,3*Math.max(0,vn-2*_),(0===n?0:2*vn)+2*_*(n>4?n-8+4:0),3*_,2*_),a.setRenderTarget(t),a.render(c,Mn)}}function kn(e){return void 0!==e&&e.type===v&&(e.encoding===$||e.encoding===Z||e.encoding===X)}function zn(e){const t=new Te(3*vn,3*vn,e);return t.texture.mapping=l,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Dn(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function On(){const e=new ge(1,1);return new yn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:wn[3e3]},outputEncoding:{value:wn[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Fn(){return new yn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:wn[3e3]},outputEncoding:{value:wn[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Bn(e){let t=new WeakMap,i=null;function n(e){const i=e.target;i.removeEventListener("dispose",n);const r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(l){if(l&&l.isTexture&&!1===l.isRenderTargetTexture){const c=l.mapping,u=c===s||c===a,h=c===r||c===o;if(u||h){if(t.has(l))return t.get(l).texture;{const r=l.image;if(u&&r&&r.height>0||h&&r&&function(e){let t=0;for(let i=0;i<6;i++)void 0!==e[i]&&t++;return 6===t}(r)){const r=e.getRenderTarget();null===i&&(i=new Rn(e));const o=u?i.fromEquirectangular(l):i.fromCubemap(l);return t.set(l,o),e.setRenderTarget(r),l.addEventListener("dispose",n),o.texture}return null}}}return l},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Nn(e){const t={};function i(i){if(void 0!==t[i])return t[i];let n;switch(i){case"WEBGL_depth_texture":n=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=e.getExtension(i)}return t[i]=n,n}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(e){const t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Un(e,t,i,n){const r={},o=new WeakMap;function s(e){const a=e.target;null!==a.index&&t.remove(a.index);for(const e in a.attributes)t.remove(a.attributes[e]);a.removeEventListener("dispose",s),delete r[a.id];const l=o.get(a);l&&(t.remove(l),o.delete(a)),n.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,i.memory.geometries--}function a(e){const i=[],n=e.index,r=e.attributes.position;let s=0;if(null!==n){const e=n.array;s=n.version;for(let t=0,n=e.length;t<n;t+=3){const n=e[t+0],r=e[t+1],o=e[t+2];i.push(n,r,r,o,o,n)}}else{const e=r.array;s=r.version;for(let t=0,n=e.length/3-1;t<n;t+=3){const e=t+0,n=t+1,r=t+2;i.push(e,n,n,r,r,e)}}const a=new(hi(i)>65535?ai:oi)(i,1);a.version=s;const l=o.get(e);l&&t.remove(l),o.set(e,a)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",s),r[t.id]=!0,i.memory.geometries++),t},update:function(e){const i=e.attributes;for(const e in i)t.update(i[e],34962);const n=e.morphAttributes;for(const e in n){const i=n[e];for(let e=0,n=i.length;e<n;e++)t.update(i[e],34962)}},getWireframeAttribute:function(e){const t=o.get(e);if(t){const i=e.index;null!==i&&t.version<i.version&&a(e)}else a(e);return o.get(e)}}}function jn(e,t,i,n){const r=n.isWebGL2;let o,s,a;this.setMode=function(e){o=e},this.setIndex=function(e){s=e.type,a=e.bytesPerElement},this.render=function(t,n){e.drawElements(o,n,s,t*a),i.update(n,o,1)},this.renderInstances=function(n,l,c){if(0===c)return;let u,h;if(r)u=e,h="drawElementsInstanced";else if(h="drawElementsInstancedANGLE",null===(u=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[h](o,l,s,n*a,c),i.update(l,o,c)}}function Vn(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(e,i,n){switch(t.calls++,i){case 4:t.triangles+=n*(e/3);break;case 1:t.lines+=n*(e/2);break;case 3:t.lines+=n*(e-1);break;case 2:t.lines+=n*e;break;case 0:t.points+=n*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Gn(e,t){return e[0]-t[0]}function Hn(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Wn(e){const t={},i=new Float32Array(8),n=[];for(let e=0;e<8;e++)n[e]=[e,0];return{update:function(r,o,s,a){const l=r.morphTargetInfluences,c=void 0===l?0:l.length;let u=t[o.id];if(void 0===u||u.length!==c){u=[];for(let e=0;e<c;e++)u[e]=[e,0];t[o.id]=u}for(let e=0;e<c;e++){const t=u[e];t[0]=e,t[1]=l[e]}u.sort(Hn);for(let e=0;e<8;e++)e<c&&u[e][1]?(n[e][0]=u[e][0],n[e][1]=u[e][1]):(n[e][0]=Number.MAX_SAFE_INTEGER,n[e][1]=0);n.sort(Gn);const h=o.morphAttributes.position,p=o.morphAttributes.normal;let d=0;for(let e=0;e<8;e++){const t=n[e],r=t[0],s=t[1];r!==Number.MAX_SAFE_INTEGER&&s?(h&&o.getAttribute("morphTarget"+e)!==h[r]&&o.setAttribute("morphTarget"+e,h[r]),p&&o.getAttribute("morphNormal"+e)!==p[r]&&o.setAttribute("morphNormal"+e,p[r]),i[e]=s,d+=s):(h&&!0===o.hasAttribute("morphTarget"+e)&&o.deleteAttribute("morphTarget"+e),p&&!0===o.hasAttribute("morphNormal"+e)&&o.deleteAttribute("morphNormal"+e),i[e]=0)}const f=o.morphTargetsRelative?1:1-d;a.getUniforms().setValue(e,"morphTargetBaseInfluence",f),a.getUniforms().setValue(e,"morphTargetInfluences",i)}}}function qn(e,t,i,n){let r=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),i.remove(t.instanceMatrix),null!==t.instanceColor&&i.remove(t.instanceColor)}return{update:function(e){const s=n.render.frame,a=e.geometry,l=t.get(e,a);return r.get(l)!==s&&(t.update(l),r.set(l,s)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",o)&&e.addEventListener("dispose",o),i.update(e.instanceMatrix,34962),null!==e.instanceColor&&i.update(e.instanceColor,34962)),l},dispose:function(){r=new WeakMap}}}class $n extends be{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=d,this.minFilter=d,this.wrapR=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}$n.prototype.isDataTexture2DArray=!0;class Zn extends be{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=d,this.minFilter=d,this.wrapR=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Zn.prototype.isDataTexture3D=!0;const Xn=new be,Yn=new $n,Jn=new Zn,Qn=new Xi,Kn=[],er=[],tr=new Float32Array(16),ir=new Float32Array(9),nr=new Float32Array(4);function rr(e,t,i){const n=e[0];if(n<=0||n>0)return e;const r=t*i;let o=Kn[r];if(void 0===o&&(o=new Float32Array(r),Kn[r]=o),0!==t){n.toArray(o,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(o,r)}return o}function or(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function sr(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function ar(e,t){let i=er[t];void 0===i&&(i=new Int32Array(t),er[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function lr(e,t){const i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function cr(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(or(i,t))return;e.uniform2fv(this.addr,t),sr(i,t)}}function ur(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(void 0!==t.r)i[0]===t.r&&i[1]===t.g&&i[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(or(i,t))return;e.uniform3fv(this.addr,t),sr(i,t)}}function hr(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(or(i,t))return;e.uniform4fv(this.addr,t),sr(i,t)}}function pr(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(or(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),sr(i,t)}else{if(or(i,n))return;nr.set(n),e.uniformMatrix2fv(this.addr,!1,nr),sr(i,n)}}function dr(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(or(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),sr(i,t)}else{if(or(i,n))return;ir.set(n),e.uniformMatrix3fv(this.addr,!1,ir),sr(i,n)}}function fr(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(or(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),sr(i,t)}else{if(or(i,n))return;tr.set(n),e.uniformMatrix4fv(this.addr,!1,tr),sr(i,n)}}function mr(e,t){const i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function gr(e,t){const i=this.cache;or(i,t)||(e.uniform2iv(this.addr,t),sr(i,t))}function _r(e,t){const i=this.cache;or(i,t)||(e.uniform3iv(this.addr,t),sr(i,t))}function yr(e,t){const i=this.cache;or(i,t)||(e.uniform4iv(this.addr,t),sr(i,t))}function vr(e,t){const i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function xr(e,t){const i=this.cache;or(i,t)||(e.uniform2uiv(this.addr,t),sr(i,t))}function br(e,t){const i=this.cache;or(i,t)||(e.uniform3uiv(this.addr,t),sr(i,t))}function wr(e,t){const i=this.cache;or(i,t)||(e.uniform4uiv(this.addr,t),sr(i,t))}function Mr(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(t||Xn,r)}function Tr(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(t||Jn,r)}function Sr(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(t||Qn,r)}function Er(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(t||Yn,r)}function Ar(e,t){e.uniform1fv(this.addr,t)}function Cr(e,t){const i=rr(t,this.size,2);e.uniform2fv(this.addr,i)}function Lr(e,t){const i=rr(t,this.size,3);e.uniform3fv(this.addr,i)}function Ir(e,t){const i=rr(t,this.size,4);e.uniform4fv(this.addr,i)}function Pr(e,t){const i=rr(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function Rr(e,t){const i=rr(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function kr(e,t){const i=rr(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function zr(e,t){e.uniform1iv(this.addr,t)}function Dr(e,t){e.uniform2iv(this.addr,t)}function Or(e,t){e.uniform3iv(this.addr,t)}function Fr(e,t){e.uniform4iv(this.addr,t)}function Br(e,t){e.uniform1uiv(this.addr,t)}function Nr(e,t){e.uniform2uiv(this.addr,t)}function Ur(e,t){e.uniform3uiv(this.addr,t)}function jr(e,t){e.uniform4uiv(this.addr,t)}function Vr(e,t,i){const n=t.length,r=ar(i,n);e.uniform1iv(this.addr,r);for(let e=0;e!==n;++e)i.safeSetTexture2D(t[e]||Xn,r[e])}function Gr(e,t,i){const n=t.length,r=ar(i,n);e.uniform1iv(this.addr,r);for(let e=0;e!==n;++e)i.safeSetTextureCube(t[e]||Qn,r[e])}function Hr(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=function(e){switch(t.type){case 5126:return lr;case 35664:return cr;case 35665:return ur;case 35666:return hr;case 35674:return pr;case 35675:return dr;case 35676:return fr;case 5124:case 35670:return mr;case 35667:case 35671:return gr;case 35668:case 35672:return _r;case 35669:case 35673:return yr;case 5125:return vr;case 36294:return xr;case 36295:return br;case 36296:return wr;case 35678:case 36198:case 36298:case 36306:case 35682:return Mr;case 35679:case 36299:case 36307:return Tr;case 35680:case 36300:case 36308:case 36293:return Sr;case 36289:case 36303:case 36311:case 36292:return Er}}()}function Wr(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=function(e){switch(t.type){case 5126:return Ar;case 35664:return Cr;case 35665:return Lr;case 35666:return Ir;case 35674:return Pr;case 35675:return Rr;case 35676:return kr;case 5124:case 35670:return zr;case 35667:case 35671:return Dr;case 35668:case 35672:return Or;case 35669:case 35673:return Fr;case 5125:return Br;case 36294:return Nr;case 36295:return Ur;case 36296:return jr;case 35678:case 36198:case 36298:case 36306:case 35682:return Vr;case 35680:case 36300:case 36308:case 36293:return Gr}}()}function qr(e){this.id=e,this.seq=[],this.map={}}Wr.prototype.updateCache=function(e){const t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),sr(t,e)},qr.prototype.setValue=function(e,t,i){const n=this.seq;for(let r=0,o=n.length;r!==o;++r){const o=n[r];o.setValue(e,t[o.id],i)}};const $r=/(\w+)(\])?(\[|\.)?/g;function Zr(e,t){e.seq.push(t),e.map[t.id]=t}function Xr(e,t,i){const n=e.name,r=n.length;for($r.lastIndex=0;;){const o=$r.exec(n),s=$r.lastIndex;let a=o[1];const l="]"===o[2],c=o[3];if(l&&(a|=0),void 0===c||"["===c&&s+2===r){Zr(i,void 0===c?new Hr(a,e,t):new Wr(a,e,t));break}{let e=i.map[a];void 0===e&&Zr(i,e=new qr(a)),i=e}}}function Yr(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,35718);for(let n=0;n<i;++n){const i=e.getActiveUniform(t,n);Xr(i,e.getUniformLocation(t,i.name),this)}}function Jr(e,t,i){const n=e.createShader(t);return e.shaderSource(n,i),e.compileShader(n),n}Yr.prototype.setValue=function(e,t,i,n){const r=this.map[t];void 0!==r&&r.setValue(e,i,n)},Yr.prototype.setOptional=function(e,t,i){const n=t[i];void 0!==n&&this.setValue(e,i,n)},Yr.upload=function(e,t,i,n){for(let r=0,o=t.length;r!==o;++r){const o=t[r],s=i[o.id];!1!==s.needsUpdate&&o.setValue(e,s.value,n)}},Yr.seqWithValue=function(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const r=e[n];r.id in t&&i.push(r)}return i};let Qr=0;function Kr(e){switch(e){case $:return["Linear","( value )"];case Z:return["sRGB","( value )"];case Y:return["RGBE","( value )"];case J:return["RGBM","( value, 7.0 )"];case Q:return["RGBM","( value, 16.0 )"];case K:return["RGBD","( value, 256.0 )"];case X:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function eo(e,t,i){const n=e.getShaderParameter(t,35713),r=e.getShaderInfoLog(t).trim();return n&&""===r?"":i.toUpperCase()+"\n\n"+r+"\n\n"+function(e){const t=e.split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}(e.getShaderSource(t))}function to(e,t){const i=Kr(t);return"vec4 "+e+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function io(e,t){const i=Kr(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function no(e,t){let i;switch(t){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function ro(e){return""!==e}function oo(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function so(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const ao=/^[ \t]*#include +<([\w\d./]+)>/gm;function lo(e){return e.replace(ao,co)}function co(e,t){const i=ln[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return lo(i)}const uo=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,ho=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function po(e){return e.replace(ho,mo).replace(uo,fo)}function fo(e,t,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),mo(e,t,i,n)}function mo(e,t,i,n){let r="";for(let e=parseInt(t);e<parseInt(i);e++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function go(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function _o(e,t,i,n){const s=e.getContext(),a=i.defines;let u=i.vertexShader,h=i.fragmentShader;const p=function(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(i),d=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case r:case o:t="ENVMAP_TYPE_CUBE";break;case l:case c:t="ENVMAP_TYPE_CUBE_UV"}return t}(i),f=function(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case o:case c:t="ENVMAP_MODE_REFRACTION"}return t}(i),m=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(i),g=e.gammaFactor>0?e.gammaFactor:1,_=i.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ro).join("\n")}(i),y=function(e){const t=[];for(const i in e){const n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}(a),v=s.createProgram();let x,b,w=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?((x=[y].filter(ro).join("\n")).length>0&&(x+="\n"),(b=[_,y].filter(ro).join("\n")).length>0&&(b+="\n")):(x=[go(i),"#define SHADER_NAME "+i.shaderName,y,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+f:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularTintMap?"#define USE_SPECULARTINTMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+p:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ro).join("\n"),b=[_,go(i),"#define SHADER_NAME "+i.shaderName,y,"#define GAMMA_FACTOR "+g,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+d:"",i.envMap?"#define "+f:"",i.envMap?"#define "+m:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularTintMap?"#define USE_SPECULARTINTMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheenTint?"#define USE_SHEEN":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+p:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?ln.tonemapping_pars_fragment:"",0!==i.toneMapping?no("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.format===S?"#define OPAQUE":"",ln.encodings_pars_fragment,i.map?to("mapTexelToLinear",i.mapEncoding):"",i.matcap?to("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?to("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?to("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.specularTintMap?to("specularTintMapTexelToLinear",i.specularTintMapEncoding):"",i.lightMap?to("lightMapTexelToLinear",i.lightMapEncoding):"",io("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ro).join("\n")),u=so(u=oo(u=lo(u),i),i),h=so(h=oo(h=lo(h),i),i),u=po(u),h=po(h),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(w="#version 300 es\n",x=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,b=["#define varying in",i.glslVersion===ie?"":"out highp vec4 pc_fragColor;",i.glslVersion===ie?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+b);const M=w+b+h,T=Jr(s,35633,w+x+u),E=Jr(s,35632,M);if(s.attachShader(v,T),s.attachShader(v,E),void 0!==i.index0AttributeName?s.bindAttribLocation(v,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v),e.debug.checkShaderErrors){const e=s.getProgramInfoLog(v).trim(),t=s.getShaderInfoLog(T).trim(),i=s.getShaderInfoLog(E).trim();let n=!0,r=!0;if(!1===s.getProgramParameter(v,35714)){n=!1;const t=eo(s,T,"vertex"),i=eo(s,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+i)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==i||(r=!1);r&&(this.diagnostics={runnable:n,programLog:e,vertexShader:{log:t,prefix:x},fragmentShader:{log:i,prefix:b}})}let A,C;return s.deleteShader(T),s.deleteShader(E),this.getUniforms=function(){return void 0===A&&(A=new Yr(s,v)),A},this.getAttributes=function(){return void 0===C&&(C=function(e,t){const i={},n=e.getProgramParameter(t,35721);for(let r=0;r<n;r++){const n=e.getActiveAttrib(t,r),o=n.name;let s=1;35674===n.type&&(s=2),35675===n.type&&(s=3),35676===n.type&&(s=4),i[o]={type:n.type,location:e.getAttribLocation(t,o),locationSize:s}}return i}(s,v)),C},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.name=i.shaderName,this.id=Qr++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=E,this}function yo(e,t,i,n,r,o,s){const a=[],u=r.isWebGL2,h=r.logarithmicDepthBuffer,p=r.floatVertexTextures,d=r.maxVertexUniforms,f=r.vertexTextures;let m=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},_=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoat","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","specularIntensityMap","specularTintMap","specularTintMapEncoding","roughnessMap","metalnessMap","gradientMap","alphaMap","alphaTest","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","format","sheenTint","transmission","transmissionMap","thicknessMap"];function y(e){let t;return e&&e.isTexture?t=e.encoding:e&&e.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),t=e.texture.encoding):t=$,t}return{getParameters:function(o,a,_,v,x){const b=v.fog,w=o.isMeshStandardMaterial?v.environment:null,M=(o.isMeshStandardMaterial?i:t).get(o.envMap||w),T=g[o.type],S=x.isSkinnedMesh?function(e){const t=x.skeleton.bones;if(p)return 1024;{const e=d,i=Math.floor((e-20)/4),n=Math.min(i,t.length);return n<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+n+"."),0):n}}():0;let E,A;if(null!==o.precision&&(m=r.getMaxPrecision(o.precision))!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",m,"instead."),T){const e=un[T];E=e.vertexShader,A=e.fragmentShader}else E=o.vertexShader,A=o.fragmentShader;const C=e.getRenderTarget(),L=o.alphaTest>0,I=o.clearcoat>0;return{isWebGL2:u,shaderID:T,shaderName:o.type,vertexShader:E,fragmentShader:A,defines:o.defines,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:m,instancing:!0===x.isInstancedMesh,instancingColor:!0===x.isInstancedMesh&&null!==x.instanceColor,supportsVertexTextures:f,outputEncoding:null!==C?y(C.texture):e.outputEncoding,map:!!o.map,mapEncoding:y(o.map),matcap:!!o.matcap,matcapEncoding:y(o.matcap),envMap:!!M,envMapMode:M&&M.mapping,envMapEncoding:y(M),envMapCubeUV:!!M&&(M.mapping===l||M.mapping===c),lightMap:!!o.lightMap,lightMapEncoding:y(o.lightMap),aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,emissiveMapEncoding:y(o.emissiveMap),bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:1===o.normalMapType,tangentSpaceNormalMap:0===o.normalMapType,clearcoat:I,clearcoatMap:I&&!!o.clearcoatMap,clearcoatRoughnessMap:I&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:I&&!!o.clearcoatNormalMap,displacementMap:!!o.displacementMap,roughnessMap:!!o.roughnessMap,metalnessMap:!!o.metalnessMap,specularMap:!!o.specularMap,specularIntensityMap:!!o.specularIntensityMap,specularTintMap:!!o.specularTintMap,specularTintMapEncoding:y(o.specularTintMap),alphaMap:!!o.alphaMap,alphaTest:L,gradientMap:!!o.gradientMap,sheenTint:!!o.sheenTint&&(o.sheenTint.r>0||o.sheenTint.g>0||o.sheenTint.b>0),transmission:o.transmission>0,transmissionMap:!!o.transmissionMap,thicknessMap:!!o.thicknessMap,combine:o.combine,vertexTangents:!!o.normalMap&&!!x.geometry&&!!x.geometry.attributes.tangent,vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!x.geometry&&!!x.geometry.attributes.color&&4===x.geometry.attributes.color.itemSize,vertexUvs:!!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatMap||o.clearcoatRoughnessMap||o.clearcoatNormalMap||o.displacementMap||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap),uvsVertexOnly:!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatNormalMap||o.transmission>0||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap||!o.displacementMap),fog:!!b,useFog:o.fog,fogExp2:b&&b.isFogExp2,flatShading:!!o.flatShading,sizeAttenuation:o.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===x.isSkinnedMesh&&S>0,maxBones:S,useVertexTexture:p,morphTargets:!!x.geometry&&!!x.geometry.morphAttributes.position,morphNormals:!!x.geometry&&!!x.geometry.morphAttributes.normal,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,format:o.format,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&_.length>0,shadowMapType:e.shadowMap.type,toneMapping:o.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:2===o.side,flipSided:1===o.side,depthPacking:void 0!==o.depthPacking&&o.depthPacking,index0AttributeName:o.index0AttributeName,extensionDerivatives:o.extensions&&o.extensions.derivatives,extensionFragDepth:o.extensions&&o.extensions.fragDepth,extensionDrawBuffers:o.extensions&&o.extensions.drawBuffers,extensionShaderTextureLOD:o.extensions&&o.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(t){const i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(const e in t.defines)i.push(e),i.push(t.defines[e]);if(!1===t.isRawShaderMaterial){for(let e=0;e<_.length;e++)i.push(t[_[e]]);i.push(e.outputEncoding),i.push(e.gammaFactor)}return i.push(t.customProgramCacheKey),i.join()},getUniforms:function(e){const t=g[e.type];let i;if(t){const e=un[t];i=Hi.clone(e.uniforms)}else i=e.uniforms;return i},acquireProgram:function(t,i){let n;for(let e=0,t=a.length;e<t;e++){const t=a[e];if(t.cacheKey===i){++(n=t).usedTimes;break}}return void 0===n&&(n=new _o(e,i,t,o),a.push(n)),n},releaseProgram:function(e){if(0==--e.usedTimes){const t=a.indexOf(e);a[t]=a[a.length-1],a.pop(),e.destroy()}},programs:a}}function vo(){let e=new WeakMap;return{get:function(t){let i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,n){e.get(t)[i]=n},dispose:function(){e=new WeakMap}}}function xo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function bo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function wo(e){const t=[];let i=0;const n=[],r=[],o=[],s={id:-1};function a(n,r,o,a,l,c){let u=t[i];const h=e.get(o);return void 0===u?(u={id:n.id,object:n,geometry:r,material:o,program:h.program||s,groupOrder:a,renderOrder:n.renderOrder,z:l,group:c},t[i]=u):(u.id=n.id,u.object=n,u.geometry=r,u.material=o,u.program=h.program||s,u.groupOrder=a,u.renderOrder=n.renderOrder,u.z=l,u.group=c),i++,u}return{opaque:n,transmissive:r,transparent:o,init:function(){i=0,n.length=0,r.length=0,o.length=0},push:function(e,t,i,s,l,c){const u=a(e,t,i,s,l,c);i.transmission>0?r.push(u):!0===i.transparent?o.push(u):n.push(u)},unshift:function(e,t,i,s,l,c){const u=a(e,t,i,s,l,c);i.transmission>0?r.unshift(u):!0===i.transparent?o.unshift(u):n.unshift(u)},finish:function(){for(let e=i,n=t.length;e<n;e++){const i=t[e];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.program=null,i.group=null}},sort:function(e,t){n.length>1&&n.sort(e||xo),r.length>1&&r.sort(t||bo),o.length>1&&o.sort(t||bo)}}}function Mo(e){let t=new WeakMap;return{get:function(i,n){let r;return!1===t.has(i)?(r=new wo(e),t.set(i,[r])):n>=t.get(i).length?(r=new wo(e),t.get(i).push(r)):r=t.get(i)[n],r},dispose:function(){t=new WeakMap}}}function To(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new Ce,color:new Yt};break;case"SpotLight":i={position:new Ce,direction:new Ce,color:new Yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ce,color:new Yt,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ce,skyColor:new Yt,groundColor:new Yt};break;case"RectAreaLight":i={color:new Yt,position:new Ce,halfWidth:new Ce,halfHeight:new Ce}}return e[t.id]=i,i}}}let So=0;function Eo(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Ao(e,t){const i=new To,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ge};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ge,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)r.probe.push(new Ce);const o=new Ce,s=new ot,a=new ot;return{setup:function(o,s){let a=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let u=0,h=0,p=0,d=0,f=0,m=0,g=0,_=0;o.sort(Eo);const y=!0!==s?Math.PI:1;for(let e=0,t=o.length;e<t;e++){const t=o[e],s=t.color,v=t.intensity,x=t.distance,b=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)a+=s.r*v*y,l+=s.g*v*y,c+=s.b*v*y;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],v);else if(t.isDirectionalLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.directionalShadow[u]=i,r.directionalShadowMap[u]=b,r.directionalShadowMatrix[u]=t.shadow.matrix,m++}r.directional[u]=e,u++}else if(t.isSpotLight){const e=i.get(t);if(e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(s).multiplyScalar(v*y),e.distance=x,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.spotShadow[p]=i,r.spotShadowMap[p]=b,r.spotShadowMatrix[p]=t.shadow.matrix,_++}r.spot[p]=e,p++}else if(t.isRectAreaLight){const e=i.get(t);e.color.copy(s).multiplyScalar(v),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[d]=e,d++}else if(t.isPointLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,i.shadowCameraNear=e.camera.near,i.shadowCameraFar=e.camera.far,r.pointShadow[h]=i,r.pointShadowMap[h]=b,r.pointShadowMatrix[h]=t.shadow.matrix,g++}r.point[h]=e,h++}else if(t.isHemisphereLight){const e=i.get(t);e.skyColor.copy(t.color).multiplyScalar(v*y),e.groundColor.copy(t.groundColor).multiplyScalar(v*y),r.hemi[f]=e,f++}}d>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=cn.LTC_FLOAT_1,r.rectAreaLTC2=cn.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=cn.LTC_HALF_1,r.rectAreaLTC2=cn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=a,r.ambient[1]=l,r.ambient[2]=c;const v=r.hash;v.directionalLength===u&&v.pointLength===h&&v.spotLength===p&&v.rectAreaLength===d&&v.hemiLength===f&&v.numDirectionalShadows===m&&v.numPointShadows===g&&v.numSpotShadows===_||(r.directional.length=u,r.spot.length=p,r.rectArea.length=d,r.point.length=h,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotShadowMatrix.length=_,v.directionalLength=u,v.pointLength=h,v.spotLength=p,v.rectAreaLength=d,v.hemiLength=f,v.numDirectionalShadows=m,v.numPointShadows=g,v.numSpotShadows=_,r.version=So++)},setupView:function(e,t){let i=0,n=0,l=0,c=0,u=0;const h=t.matrixWorldInverse;for(let t=0,p=e.length;t<p;t++){const p=e[t];if(p.isDirectionalLight){const e=r.directional[i];e.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(h),i++}else if(p.isSpotLight){const e=r.spot[l];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(h),e.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(h),l++}else if(p.isRectAreaLight){const e=r.rectArea[c];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(h),a.identity(),s.copy(p.matrixWorld),s.premultiply(h),a.extractRotation(s),e.halfWidth.set(.5*p.width,0,0),e.halfHeight.set(0,.5*p.height,0),e.halfWidth.applyMatrix4(a),e.halfHeight.applyMatrix4(a),c++}else if(p.isPointLight){const e=r.point[n];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(h),n++}else if(p.isHemisphereLight){const e=r.hemi[u];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(h),e.direction.normalize(),u++}}},state:r}}function Co(e,t){const i=new Ao(e,t),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(e){i.setup(n,e)},setupLightsView:function(e){i.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function Lo(e,t){let i=new WeakMap;return{get:function(n,r=0){let o;return!1===i.has(n)?(o=new Co(e,t),i.set(n,[o])):r>=i.get(n).length?(o=new Co(e,t),i.get(n).push(o)):o=i.get(n)[r],o},dispose:function(){i=new WeakMap}}}class Io extends Gt{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}Io.prototype.isMeshDepthMaterial=!0;class Po extends Gt{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Ce,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Ro(e,t,i){let n=new rn;const r=new ge,o=new ge,s=new Me,a=new Io({depthPacking:3201}),l=new Po,c={},u=i.maxTextureSize,h={0:1,1:0,2:2},p=new Wi({uniforms:{shadow_pass:{value:null},resolution:{value:new ge},radius:{value:4},samples:{value:8}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nuniform float samples;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),f=p.clone();f.defines.HORIZONTAL_PASS=1;const m=new bi;m.setAttribute("position",new ei(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Ni(m,p),y=this;function v(i,n){const r=t.update(_);p.uniforms.shadow_pass.value=i.map.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,p.uniforms.samples.value=i.blurSamples,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(n,null,r,p,_,null),f.uniforms.shadow_pass.value=i.mapPass.texture,f.uniforms.resolution.value=i.mapSize,f.uniforms.radius.value=i.radius,f.uniforms.samples.value=i.blurSamples,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(n,null,r,f,_,null)}function x(t,i,n,r,o,s,u){let p=null;const d=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(p=void 0!==d?d:!0===r.isPointLight?l:a,e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const e=p.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=p.clone(),i[t]=r),p=r}return p.visible=n.visible,p.wireframe=n.wireframe,p.side=3===u?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],p.alphaMap=n.alphaMap,p.alphaTest=n.alphaTest,p.clipShadows=n.clipShadows,p.clippingPlanes=n.clippingPlanes,p.clipIntersection=n.clipIntersection,p.displacementMap=n.displacementMap,p.displacementScale=n.displacementScale,p.displacementBias=n.displacementBias,p.wireframeLinewidth=n.wireframeLinewidth,p.linewidth=n.linewidth,!0===r.isPointLight&&!0===p.isMeshDistanceMaterial&&(p.referencePosition.setFromMatrixPosition(r.matrixWorld),p.nearDistance=o,p.farDistance=s),p}function b(i,r,o,s,a){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,i.matrixWorld);const n=t.update(i),r=i.material;if(Array.isArray(r)){const t=n.groups;for(let l=0,c=t.length;l<c;l++){const c=t[l],u=r[c.materialIndex];if(u&&u.visible){const t=x(i,0,u,s,o.near,o.far,a);e.renderBufferDirect(o,null,n,t,i,c)}}}else if(r.visible){const t=x(i,0,r,s,o.near,o.far,a);e.renderBufferDirect(o,null,n,t,i,null)}}const l=i.children;for(let e=0,t=l.length;e<t;e++)b(l[e],r,o,s,a)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(t,i,a){if(!1===y.enabled)return;if(!1===y.autoUpdate&&!1===y.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),p=e.state;p.setBlending(0),p.buffers.color.setClear(1,1,1,1),p.buffers.depth.setTest(!0),p.setScissorTest(!1);for(let l=0,c=t.length;l<c;l++){const c=t[l],h=c.shadow;if(void 0===h){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;r.copy(h.mapSize);const f=h.getFrameExtents();if(r.multiply(f),o.copy(h.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(o.x=Math.floor(u/f.x),r.x=o.x*f.x,h.mapSize.x=o.x),r.y>u&&(o.y=Math.floor(u/f.y),r.y=o.y*f.y,h.mapSize.y=o.y)),null===h.map&&!h.isPointLightShadow&&3===this.type){const e={minFilter:g,magFilter:g,format:E};h.map=new Te(r.x,r.y,e),h.map.texture.name=c.name+".shadowMap",h.mapPass=new Te(r.x,r.y,e),h.camera.updateProjectionMatrix()}if(null===h.map){const e={minFilter:d,magFilter:d,format:E};h.map=new Te(r.x,r.y,e),h.map.texture.name=c.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();const m=h.getViewportCount();for(let e=0;e<m;e++){const t=h.getViewport(e);s.set(o.x*t.x,o.y*t.y,o.x*t.z,o.y*t.w),p.viewport(s),h.updateMatrices(c,e),n=h.getFrustum(),b(i,a,h.camera,c,this.type)}h.isPointLightShadow||3!==this.type||v(h,a),h.needsUpdate=!1}y.needsUpdate=!1,e.setRenderTarget(l,c,h)}}function ko(e,t,n){const r=n.isWebGL2,o=new function(){let t=!1;const i=new Me;let n=null;const r=new Me(0,0,0,0);return{setMask:function(i){n===i||t||(e.colorMask(i,i,i,i),n=i)},setLocked:function(e){t=e},setClear:function(t,n,o,s,a){!0===a&&(t*=s,n*=s,o*=s),i.set(t,n,o,s),!1===r.equals(i)&&(e.clearColor(t,n,o,s),r.copy(i))},reset:function(){t=!1,n=null,r.set(-1,0,0,0)}}},s=new function(){let t=!1,i=null,n=null,r=null;return{setTest:function(e){e?B(2929):N(2929)},setMask:function(n){i===n||t||(e.depthMask(n),i=n)},setFunc:function(t){if(n!==t){if(t)switch(t){case 0:e.depthFunc(512);break;case 1:e.depthFunc(519);break;case 2:e.depthFunc(513);break;case 3:default:e.depthFunc(515);break;case 4:e.depthFunc(514);break;case 5:e.depthFunc(518);break;case 6:e.depthFunc(516);break;case 7:e.depthFunc(517)}else e.depthFunc(515);n=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,i=null,n=null,r=null}}},a=new function(){let t=!1,i=null,n=null,r=null,o=null,s=null,a=null,l=null,c=null;return{setTest:function(e){t||(e?B(2960):N(2960))},setMask:function(n){i===n||t||(e.stencilMask(n),i=n)},setFunc:function(t,i,s){n===t&&r===i&&o===s||(e.stencilFunc(t,i,s),n=t,r=i,o=s)},setOp:function(t,i,n){s===t&&a===i&&l===n||(e.stencilOp(t,i,n),s=t,a=i,l=n)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,i=null,n=null,r=null,o=null,s=null,a=null,l=null,c=null}}};let l={},c=null,u={},h=null,p=!1,d=null,f=null,m=null,g=null,_=null,y=null,v=null,x=!1,b=null,w=null,M=null,T=null,S=null;const E=e.getParameter(35661);let A=!1,C=0;const L=e.getParameter(7938);-1!==L.indexOf("WebGL")?(C=parseFloat(/^WebGL (\d)/.exec(L)[1]),A=C>=1):-1!==L.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),A=C>=2);let I=null,P={};const R=e.getParameter(3088),k=e.getParameter(2978),z=(new Me).fromArray(R),D=(new Me).fromArray(k);function O(t,i,n){const r=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<n;t++)e.texImage2D(i+t,0,6408,1,1,0,6408,5121,r);return o}const F={};function B(t){!0!==l[t]&&(e.enable(t),l[t]=!0)}function N(t){!1!==l[t]&&(e.disable(t),l[t]=!1)}F[3553]=O(3553,3553,1),F[34067]=O(34067,34069,6),o.setClear(0,0,0,1),s.setClear(1),a.setClear(0),B(2929),s.setFunc(3),G(!1),H(1),B(2884),V(0);const U={[i]:32774,101:32778,102:32779};if(r)U[103]=32775,U[104]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(U[103]=e.MIN_EXT,U[104]=e.MAX_EXT)}const j={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function V(t,n,r,o,s,a,l,c){if(0!==t){if(!1===p&&(B(3042),p=!0),5===t)s=s||n,a=a||r,l=l||o,n===f&&s===_||(e.blendEquationSeparate(U[n],U[s]),f=n,_=s),r===m&&o===g&&a===y&&l===v||(e.blendFuncSeparate(j[r],j[o],j[a],j[l]),m=r,g=o,y=a,v=l),d=t,x=null;else if(t!==d||c!==x){if(f===i&&_===i||(e.blendEquation(32774),f=i,_=i),c)switch(t){case 1:e.blendFuncSeparate(1,771,1,771);break;case 2:e.blendFunc(1,1);break;case 3:e.blendFuncSeparate(0,0,769,771);break;case 4:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(770,771,1,771);break;case 2:e.blendFunc(770,1);break;case 3:e.blendFunc(0,769);break;case 4:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}m=null,g=null,y=null,v=null,d=t,x=c}}else!0===p&&(N(3042),p=!1)}function G(t){b!==t&&(t?e.frontFace(2304):e.frontFace(2305),b=t)}function H(t){0!==t?(B(2884),t!==w&&(1===t?e.cullFace(1029):2===t?e.cullFace(1028):e.cullFace(1032))):N(2884),w=t}function W(t,i,n){t?(B(32823),T===i&&S===n||(e.polygonOffset(i,n),T=i,S=n)):N(32823)}function q(t){void 0===t&&(t=33984+E-1),I!==t&&(e.activeTexture(t),I=t)}return{buffers:{color:o,depth:s,stencil:a},enable:B,disable:N,bindFramebuffer:function(t,i){return null===i&&null!==c&&(i=c),u[t]!==i&&(e.bindFramebuffer(t,i),u[t]=i,r&&(36009===t&&(u[36160]=i),36160===t&&(u[36009]=i)),!0)},bindXRFramebuffer:function(t){t!==c&&(e.bindFramebuffer(36160,t),c=t)},useProgram:function(t){return h!==t&&(e.useProgram(t),h=t,!0)},setBlending:V,setMaterial:function(e,t){2===e.side?N(2884):B(2884);let i=1===e.side;t&&(i=!i),G(i),1===e.blending&&!1===e.transparent?V(0):V(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),s.setFunc(e.depthFunc),s.setTest(e.depthTest),s.setMask(e.depthWrite),o.setMask(e.colorWrite);const n=e.stencilWrite;a.setTest(n),n&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),W(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?B(32926):N(32926)},setFlipSided:G,setCullFace:H,setLineWidth:function(t){t!==M&&(A&&e.lineWidth(t),M=t)},setPolygonOffset:W,setScissorTest:function(e){e?B(3089):N(3089)},activeTexture:q,bindTexture:function(t,i){null===I&&q();let n=P[I];void 0===n&&(n={type:void 0,texture:void 0},P[I]=n),n.type===t&&n.texture===i||(e.bindTexture(t,i||F[t]),n.type=t,n.texture=i)},unbindTexture:function(){const t=P[I];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===z.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),z.copy(t))},viewport:function(t){!1===D.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),D.copy(t))},reset:function(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===r&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),l={},I=null,P={},c=null,u={},h=null,p=!1,d=null,f=null,m=null,g=null,_=null,y=null,v=null,x=!1,b=null,w=null,M=null,T=null,S=null,z.set(0,0,e.canvas.width,e.canvas.height),D.set(0,0,e.canvas.width,e.canvas.height),o.reset(),s.reset(),a.reset()}}}function zo(e,t,i,n,r,o,s){const a=r.isWebGL2,l=r.maxTextures,c=r.maxCubemapSize,v=r.maxTextureSize,L=r.maxSamples,I=new WeakMap;let P,R=!1;try{R="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function k(e,t){return R?new OffscreenCanvas(e,t):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function z(e,t,i,n){let r=1;if((e.width>n||e.height>n)&&(r=n/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const n=t?fe:Math.floor,o=n(r*e.width),s=n(r*e.height);void 0===P&&(P=k(o,s));const a=i?k(o,s):P;return a.width=o,a.height=s,a.getContext("2d").drawImage(e,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),a}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function D(e){return pe(e.width)&&pe(e.height)}function O(e,t){return e.generateMipmaps&&t&&e.minFilter!==d&&e.minFilter!==g}function F(t,i,r,o,s=1){e.generateMipmap(t),n.get(i).__maxMipLevel=Math.log2(Math.max(r,o,s))}function B(i,n,r){if(!1===a)return n;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;return 6403===n&&(5126===r&&(o=33326),5131===r&&(o=33325),5121===r&&(o=33321)),6407===n&&(5126===r&&(o=34837),5131===r&&(o=34843),5121===r&&(o=32849)),6408===n&&(5126===r&&(o=34836),5131===r&&(o=34842),5121===r&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||t.get("EXT_color_buffer_float"),o}function N(e){return e===d||e===f||e===m?9728:9729}function U(t){const i=t.target;i.removeEventListener("dispose",U),function(t){const i=n.get(t);void 0!==i.__webglInit&&(e.deleteTexture(i.__webglTexture),n.remove(t))}(i),i.isVideoTexture&&I.delete(i),s.memory.textures--}function j(t){const i=t.target;i.removeEventListener("dispose",j),function(t){const i=t.texture,r=n.get(t),o=n.get(i);if(t){if(void 0!==o.__webglTexture&&(e.deleteTexture(o.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);r.__webglTexture&&(e.deleteTexture(r.__webglTexture),s.memory.textures--),n.remove(i[t])}n.remove(i),n.remove(t)}}(i)}let V=0;function G(e,t){const r=n.get(e);if(e.isVideoTexture&&function(e){const t=s.render.frame;I.get(e)!==t&&(I.set(e,t),e.update())}(e),e.version>0&&r.__version!==e.version){const i=e.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void X(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+t),i.bindTexture(3553,r.__webglTexture)}function H(t,r){const s=n.get(t);t.version>0&&s.__version!==t.version?function(t,n,r){if(6!==n.image.length)return;Z(t,n),i.activeTexture(33984+r),i.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const s=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),l=n.image[0]&&n.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=s||l?l?n.image[e].image:n.image[e]:z(n.image[e],!1,!0,c);const h=u[0],p=D(h)||a,d=o.convert(n.format),f=o.convert(n.type),m=B(n.internalFormat,d,f);let g;if($(34067,n,p),s){for(let e=0;e<6;e++){g=u[e].mipmaps;for(let t=0;t<g.length;t++){const r=g[t];n.format!==E&&n.format!==S?null!==d?i.compressedTexImage2D(34069+e,t,m,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+e,t,m,r.width,r.height,0,d,f,r.data)}}t.__maxMipLevel=g.length-1}else{g=n.mipmaps;for(let e=0;e<6;e++)if(l){i.texImage2D(34069+e,0,m,u[e].width,u[e].height,0,d,f,u[e].data);for(let t=0;t<g.length;t++){const n=g[t].image[e].image;i.texImage2D(34069+e,t+1,m,n.width,n.height,0,d,f,n.data)}}else{i.texImage2D(34069+e,0,m,d,f,u[e]);for(let t=0;t<g.length;t++){const n=g[t];i.texImage2D(34069+e,t+1,m,d,f,n.image[e])}}t.__maxMipLevel=g.length}O(n,p)&&F(34067,n,h.width,h.height),t.__version=n.version,n.onUpdate&&n.onUpdate(n)}(s,t,r):(i.activeTexture(33984+r),i.bindTexture(34067,s.__webglTexture))}const W={[u]:10497,[h]:33071,[p]:33648},q={[d]:9728,[f]:9984,[m]:9986,[g]:9729,[_]:9985,[y]:9987};function $(i,o,s){if(s?(e.texParameteri(i,10242,W[o.wrapS]),e.texParameteri(i,10243,W[o.wrapT]),32879!==i&&35866!==i||e.texParameteri(i,32882,W[o.wrapR]),e.texParameteri(i,10240,q[o.magFilter]),e.texParameteri(i,10241,q[o.minFilter])):(e.texParameteri(i,10242,33071),e.texParameteri(i,10243,33071),32879!==i&&35866!==i||e.texParameteri(i,32882,33071),o.wrapS===h&&o.wrapT===h||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,10240,N(o.magFilter)),e.texParameteri(i,10241,N(o.minFilter)),o.minFilter!==d&&o.minFilter!==g&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const s=t.get("EXT_texture_filter_anisotropic");if(o.type===w&&!1===t.has("OES_texture_float_linear"))return;if(!1===a&&o.type===M&&!1===t.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||n.get(o).__currentAnisotropy)&&(e.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),n.get(o).__currentAnisotropy=o.anisotropy)}}function Z(t,i){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",U),t.__webglTexture=e.createTexture(),s.memory.textures++)}function X(t,n,r){let s=3553;n.isDataTexture2DArray&&(s=35866),n.isDataTexture3D&&(s=32879),Z(t,n),i.activeTexture(33984+r),i.bindTexture(s,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const l=function(e){return!a&&(e.wrapS!==h||e.wrapT!==h||e.minFilter!==d&&e.minFilter!==g)}(n)&&!1===D(n.image),c=z(n.image,l,!1,v),u=D(c)||a,p=o.convert(n.format);let f,m=o.convert(n.type),_=B(n.internalFormat,p,m);$(s,n,u);const y=n.mipmaps;if(n.isDepthTexture)_=6402,a?_=n.type===w?36012:n.type===b?33190:n.type===T?35056:33189:n.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===A&&6402===_&&n.type!==x&&n.type!==b&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=x,m=o.convert(n.type)),n.format===C&&6402===_&&(_=34041,n.type!==T&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=T,m=o.convert(n.type))),i.texImage2D(3553,0,_,c.width,c.height,0,p,m,null);else if(n.isDataTexture)if(y.length>0&&u){for(let e=0,t=y.length;e<t;e++)f=y[e],i.texImage2D(3553,e,_,f.width,f.height,0,p,m,f.data);n.generateMipmaps=!1,t.__maxMipLevel=y.length-1}else i.texImage2D(3553,0,_,c.width,c.height,0,p,m,c.data),t.__maxMipLevel=0;else if(n.isCompressedTexture){for(let e=0,t=y.length;e<t;e++)f=y[e],n.format!==E&&n.format!==S?null!==p?i.compressedTexImage2D(3553,e,_,f.width,f.height,0,f.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,e,_,f.width,f.height,0,p,m,f.data);t.__maxMipLevel=y.length-1}else if(n.isDataTexture2DArray)i.texImage3D(35866,0,_,c.width,c.height,c.depth,0,p,m,c.data),t.__maxMipLevel=0;else if(n.isDataTexture3D)i.texImage3D(32879,0,_,c.width,c.height,c.depth,0,p,m,c.data),t.__maxMipLevel=0;else if(y.length>0&&u){for(let e=0,t=y.length;e<t;e++)f=y[e],i.texImage2D(3553,e,_,p,m,f);n.generateMipmaps=!1,t.__maxMipLevel=y.length-1}else i.texImage2D(3553,0,_,p,m,c),t.__maxMipLevel=0;O(n,u)&&F(s,n,c.width,c.height),t.__version=n.version,n.onUpdate&&n.onUpdate(n)}function Y(t,r,s,a,l){const c=o.convert(s.format),u=o.convert(s.type),h=B(s.internalFormat,c,u);32879===l||35866===l?i.texImage3D(l,0,h,r.width,r.height,r.depth,0,c,u,null):i.texImage2D(l,0,h,r.width,r.height,0,c,u,null),i.bindFramebuffer(36160,t),e.framebufferTexture2D(36160,a,l,n.get(s).__webglTexture,0),i.bindFramebuffer(36160,null)}function J(t,i,n){if(e.bindRenderbuffer(36161,t),i.depthBuffer&&!i.stencilBuffer){let r=33189;if(n){const t=i.depthTexture;t&&t.isDepthTexture&&(t.type===w?r=36012:t.type===b&&(r=33190));const n=Q(i);e.renderbufferStorageMultisample(36161,n,r,i.width,i.height)}else e.renderbufferStorage(36161,r,i.width,i.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(i.depthBuffer&&i.stencilBuffer){if(n){const t=Q(i);e.renderbufferStorageMultisample(36161,t,35056,i.width,i.height)}else e.renderbufferStorage(36161,34041,i.width,i.height);e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===i.isWebGLMultipleRenderTargets?i.texture[0]:i.texture,r=o.convert(t.format),s=o.convert(t.type),a=B(t.internalFormat,r,s);if(n){const t=Q(i);e.renderbufferStorageMultisample(36161,t,a,i.width,i.height)}else e.renderbufferStorage(36161,a,i.width,i.height)}e.bindRenderbuffer(36161,null)}function Q(e){return a&&e.isWebGLMultisampleRenderTarget?Math.min(L,e.samples):0}let K=!1,ee=!1;this.allocateTextureUnit=function(){const e=V;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),V+=1,e},this.resetTextureUnits=function(){V=0},this.setTexture2D=G,this.setTexture2DArray=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?X(r,e,t):(i.activeTexture(33984+t),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?X(r,e,t):(i.activeTexture(33984+t),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=H,this.setupRenderTarget=function(t){const l=t.texture,c=n.get(t),u=n.get(l);t.addEventListener("dispose",j),!0!==t.isWebGLMultipleRenderTargets&&(u.__webglTexture=e.createTexture(),u.__version=l.version,s.memory.textures++);const h=!0===t.isWebGLCubeRenderTarget,p=!0===t.isWebGLMultipleRenderTargets,d=!0===t.isWebGLMultisampleRenderTarget,f=l.isDataTexture3D||l.isDataTexture2DArray,m=D(t)||a;if(!a||l.format!==S||l.type!==w&&l.type!==M||(l.format=E,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else if(c.__webglFramebuffer=e.createFramebuffer(),p)if(r.drawBuffers){const i=t.texture;for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);void 0===r.__webglTexture&&(r.__webglTexture=e.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(d)if(a){c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer);const n=o.convert(l.format),r=o.convert(l.type),s=B(l.internalFormat,n,r),a=Q(t);e.renderbufferStorageMultisample(36161,a,s,t.width,t.height),i.bindFramebuffer(36160,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,c.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),J(c.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(h){i.bindTexture(34067,u.__webglTexture),$(34067,l,m);for(let e=0;e<6;e++)Y(c.__webglFramebuffer[e],t,l,36064,34069+e);O(l,m)&&F(34067,l,t.width,t.height),i.unbindTexture()}else if(p){const e=t.texture;for(let r=0,o=e.length;r<o;r++){const o=e[r],s=n.get(o);i.bindTexture(3553,s.__webglTexture),$(3553,o,m),Y(c.__webglFramebuffer,t,o,36064+r,3553),O(o,m)&&F(3553,o,t.width,t.height)}i.unbindTexture()}else{let e=3553;f&&(a?e=l.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),i.bindTexture(e,u.__webglTexture),$(e,l,m),Y(c.__webglFramebuffer,t,l,36064,e),O(l,m)&&F(e,l,t.width,t.height,t.depth),i.unbindTexture()}t.depthBuffer&&function(t){const r=n.get(t),o=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),G(r.depthTexture,0);const o=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===A)e.framebufferTexture2D(36160,36096,3553,o,0);else{if(r.depthTexture.format!==C)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,o,0)}}(r.__webglFramebuffer,t)}else if(o){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(36160,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=e.createRenderbuffer(),J(r.__webglDepthbuffer[n],t,!1)}else i.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),J(r.__webglDepthbuffer,t,!1);i.bindFramebuffer(36160,null)}(t)},this.updateRenderTargetMipmap=function(e){const t=D(e)||a,r=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let o=0,s=r.length;o<s;o++){const s=r[o];if(O(s,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,r=n.get(s).__webglTexture;i.bindTexture(t,r),F(t,s,e.width,e.height),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(a){const r=t.width,o=t.height;let s=16384;t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024);const a=n.get(t);i.bindFramebuffer(36008,a.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,a.__webglFramebuffer),e.blitFramebuffer(0,0,r,o,0,0,r,o,s,9728),i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,a.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===K&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),K=!0),e=e.texture),G(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===ee&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ee=!0),e=e.texture),H(e,t)}}function Do(e,t,i){const n=i.isWebGL2;return{convert:function(e){let i;if(e===v)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120;if(1011===e)return 5122;if(e===x)return 5123;if(1013===e)return 5124;if(e===b)return 5125;if(e===w)return 5126;if(e===M)return n?5131:null!==(i=t.get("OES_texture_half_float"))?i.HALF_FLOAT_OES:null;if(1021===e)return 6406;if(e===S)return 6407;if(e===E)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(e===A)return 6402;if(e===C)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032===e)return 36248;if(1033===e)return 36249;if(e===L||e===I||e===P||e===R){if(null===(i=t.get("WEBGL_compressed_texture_s3tc")))return null;if(e===L)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===I)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===P)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===R)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===k||e===z||e===D||e===O){if(null===(i=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===k)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===z)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===D)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===O)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e)return null!==(i=t.get("WEBGL_compressed_texture_etc1"))?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===F||e===B)&&null!==(i=t.get("WEBGL_compressed_texture_etc"))){if(e===F)return i.COMPRESSED_RGB8_ETC2;if(e===B)return i.COMPRESSED_RGBA8_ETC2_EAC}return 37808===e||37809===e||37810===e||37811===e||37812===e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e?null!==(i=t.get("WEBGL_compressed_texture_astc"))?e:null:36492===e?null!==(i=t.get("EXT_texture_compression_bptc"))?e:null:e===T?n?34042:null!==(i=t.get("WEBGL_depth_texture"))?i.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}Po.prototype.isMeshDistanceMaterial=!0;class Oo extends $i{constructor(e=[]){super(),this.cameras=e}}Oo.prototype.isArrayCamera=!0;class Fo extends It{constructor(){super(),this.type="Group"}}Fo.prototype.isGroup=!0;const Bo={type:"move"};class No{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Fo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Fo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ce,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ce),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Fo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ce,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ce),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,o=null;const s=this._targetRay,a=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==s&&null!==(n=t.getPose(e.targetRaySpace,i))&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),n.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(n.linearVelocity)):s.hasLinearVelocity=!1,n.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(n.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(Bo)),l&&e.hand){o=!0;for(const n of e.hand.values()){const e=t.getJointPose(n,i);if(void 0===l.joints[n.jointName]){const e=new Fo;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[n.jointName]=e,l.add(e)}const r=l.joints[n.jointName];null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=e.radius),r.visible=null!==e}const n=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=n.position.distanceTo(r.position),a=.02,c=.005;l.inputState.pinching&&s>a+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=a-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==a&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,i))&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1);return null!==s&&(s.visible=null!==n),null!==a&&(a.visible=null!==r),null!==l&&(l.visible=null!==o),this}}class Uo extends ne{constructor(e,t){super();const i=this,n=e.state;let r=null,o=1,s=null,a="local-floor",l=null,c=null,u=null,h=null,p=null,d=!1,f=null,m=null,g=null,_=null,y=null,v=null;const x=[],b=new Map,w=new $i;w.layers.enable(1),w.viewport=new Me;const M=new $i;M.layers.enable(2),M.viewport=new Me;const T=[w,M],S=new Oo;S.layers.enable(1),S.layers.enable(2);let E=null,A=null;function C(e){const t=b.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function L(){b.forEach((function(e,t){e.disconnect(t)})),b.clear(),E=null,A=null,n.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),u&&t.deleteFramebuffer(u),f&&t.deleteFramebuffer(f),m&&t.deleteRenderbuffer(m),g&&t.deleteRenderbuffer(g),u=null,f=null,m=null,g=null,p=null,h=null,c=null,r=null,D.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function I(e){const t=r.inputSources;for(let e=0;e<x.length;e++)b.set(t[e],x[e]);for(let t=0;t<e.removed.length;t++){const i=e.removed[t],n=b.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),b.delete(i))}for(let t=0;t<e.added.length;t++){const i=e.added[t],n=b.get(i);n&&n.dispatchEvent({type:"connected",data:i})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=x[e];return void 0===t&&(t=new No,x[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=x[e];return void 0===t&&(t=new No,x[e]=t),t.getGripSpace()},this.getHand=function(e){let t=x[e];return void 0===t&&(t=new No,x[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){o=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s},this.getBaseLayer=function(){return null!==h?h:p},this.getBinding=function(){return c},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(e){if(null!==(r=e)){r.addEventListener("select",C),r.addEventListener("selectstart",C),r.addEventListener("selectend",C),r.addEventListener("squeeze",C),r.addEventListener("squeezestart",C),r.addEventListener("squeezeend",C),r.addEventListener("end",L),r.addEventListener("inputsourceschange",I);const e=t.getContextAttributes();if(!0!==e.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers){const i={antialias:e.antialias,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:o};p=new XRWebGLLayer(r,t,i),r.updateRenderState({baseLayer:p})}else if(t instanceof WebGLRenderingContext){const i={antialias:!0,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:o};p=new XRWebGLLayer(r,t,i),r.updateRenderState({layers:[p]})}else{d=e.antialias;let i=null;e.depth&&(v=256,e.stencil&&(v|=1024),y=e.stencil?33306:36096,i=e.stencil?35056:33190);const s={colorFormat:e.alpha?32856:32849,depthFormat:i,scaleFactor:o};c=new XRWebGLBinding(r,t),h=c.createProjectionLayer(s),u=t.createFramebuffer(),r.updateRenderState({layers:[h]}),d&&(f=t.createFramebuffer(),m=t.createRenderbuffer(),t.bindRenderbuffer(36161,m),t.renderbufferStorageMultisample(36161,4,32856,h.textureWidth,h.textureHeight),n.bindFramebuffer(36160,f),t.framebufferRenderbuffer(36160,36064,36161,m),t.bindRenderbuffer(36161,null),null!==i&&(g=t.createRenderbuffer(),t.bindRenderbuffer(36161,g),t.renderbufferStorageMultisample(36161,4,i,h.textureWidth,h.textureHeight),t.framebufferRenderbuffer(36160,y,36161,g),t.bindRenderbuffer(36161,null)),n.bindFramebuffer(36160,null))}s=await r.requestReferenceSpace(a),D.setContext(r),D.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const P=new Ce,R=new Ce;function k(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;S.near=M.near=w.near=e.near,S.far=M.far=w.far=e.far,E===S.near&&A===S.far||(r.updateRenderState({depthNear:S.near,depthFar:S.far}),E=S.near,A=S.far);const t=e.parent,i=S.cameras;k(S,t);for(let e=0;e<i.length;e++)k(i[e],t);S.matrixWorld.decompose(S.position,S.quaternion,S.scale),e.position.copy(S.position),e.quaternion.copy(S.quaternion),e.scale.copy(S.scale),e.matrix.copy(S.matrix),e.matrixWorld.copy(S.matrixWorld);const n=e.children;for(let e=0,t=n.length;e<t;e++)n[e].updateMatrixWorld(!0);2===i.length?function(e,t,i){P.setFromMatrixPosition(t.matrixWorld),R.setFromMatrixPosition(i.matrixWorld);const n=P.distanceTo(R),r=t.projectionMatrix.elements,o=i.projectionMatrix.elements,s=r[14]/(r[10]-1),a=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],u=(r[8]-1)/r[0],h=(o[8]+1)/o[0],p=s*u,d=s*h,f=n/(-u+h),m=f*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=s+f,_=a+f,y=p-m,v=d+(n-m),x=l*a/_*g,b=c*a/_*g;e.projectionMatrix.makePerspective(y,v,x,b,g,_)}(S,w,M):S.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return S},this.getFoveation=function(){return null!==h?h.fixedFoveation:null!==p?p.fixedFoveation:void 0},this.setFoveation=function(e){null!==h&&(h.fixedFoveation=e),null!==p&&void 0!==p.fixedFoveation&&(p.fixedFoveation=e)};let z=null;const D=new on;D.setAnimationLoop((function(e,i){if(l=i.getViewerPose(s),_=i,null!==l){const e=l.views;null!==p&&n.bindXRFramebuffer(p.framebuffer);let i=!1;e.length!==S.cameras.length&&(S.cameras.length=0,i=!0);for(let r=0;r<e.length;r++){const o=e[r];let s=null;if(null!==p)s=p.getViewport(o);else{const e=c.getViewSubImage(h,o);n.bindXRFramebuffer(u),void 0!==e.depthStencilTexture&&t.framebufferTexture2D(36160,y,3553,e.depthStencilTexture,0),t.framebufferTexture2D(36160,36064,3553,e.colorTexture,0),s=e.viewport}const a=T[r];a.matrix.fromArray(o.transform.matrix),a.projectionMatrix.fromArray(o.projectionMatrix),a.viewport.set(s.x,s.y,s.width,s.height),0===r&&S.matrix.copy(a.matrix),!0===i&&S.cameras.push(a)}d&&(n.bindXRFramebuffer(f),null!==v&&t.clear(v))}const o=r.inputSources;for(let e=0;e<x.length;e++){const t=x[e],n=o[e];t.update(n,i,s)}if(z&&z(e,i),d){const e=h.textureWidth,i=h.textureHeight;n.bindFramebuffer(36008,f),n.bindFramebuffer(36009,u),t.invalidateFramebuffer(36008,[y]),t.invalidateFramebuffer(36009,[y]),t.blitFramebuffer(0,0,e,i,0,0,e,i,16384,9728),t.invalidateFramebuffer(36008,[36064]),n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),n.bindFramebuffer(36160,f)}_=null})),this.setAnimationLoop=function(e){z=e},this.dispose=function(){}}}function jo(e){function t(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map),i.alphaMap&&(t.alphaMap.value=i.alphaMap),i.specularMap&&(t.specularMap.value=i.specularMap),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const n=e.get(i).envMap;if(n){t.envMap.value=n,t.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio;const r=e.get(n).__maxMipLevel;void 0!==r&&(t.maxMipLevel.value=r)}let r,o;i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap?r=i.clearcoatRoughnessMap:i.specularIntensityMap?r=i.specularIntensityMap:i.specularTintMap?r=i.specularTintMap:i.transmissionMap?r=i.transmissionMap:i.thicknessMap&&(r=i.thicknessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix)),i.aoMap?o=i.aoMap:i.lightMap&&(o=i.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),t.uv2Transform.value.copy(o.matrix))}function i(t,i){t.roughness.value=i.roughness,t.metalness.value=i.metalness,i.roughnessMap&&(t.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(t.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap),i.bumpMap&&(t.bumpMap.value=i.bumpMap,t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),e.get(i).envMap&&(t.envMapIntensity.value=i.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,n,r,o,s){n.isMeshBasicMaterial?t(e,n):n.isMeshLambertMaterial?(t(e,n),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(e,n)):n.isMeshToonMaterial?(t(e,n),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshPhongMaterial?(t(e,n),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshStandardMaterial?(t(e,n),n.isMeshPhysicalMaterial?function(e,t,n){i(e,t),e.ior.value=t.ior,t.sheenTint&&e.sheenTint.value.copy(t.sheenTint),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate())),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationTint.value.copy(t.attenuationTint)),e.specularIntensity.value=t.specularIntensity,e.specularTint.value.copy(t.specularTint),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap),t.specularTintMap&&(e.specularTintMap.value=t.specularTintMap)}(e,n,s):i(e,n)):n.isMeshMatcapMaterial?(t(e,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDepthMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDistanceMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,n)):n.isMeshNormalMaterial?(t(e,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,n),n.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,n)):n.isPointsMaterial?function(e,t,i,n){let r;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*n,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?r=t.map:t.alphaMap&&(r=t.alphaMap),void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,n,r,o):n.isSpriteMaterial?function(e,t){let i;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?i=t.map:t.alphaMap&&(i=t.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,n):n.isShadowMaterial?(e.color.value.copy(n.color),e.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Vo(e={}){const t=void 0!==e.canvas?e.canvas:function(){const e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.style.display="block",e}(),i=void 0!==e.context?e.context:null,n=void 0!==e.alpha&&e.alpha,r=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,s=void 0!==e.antialias&&e.antialias,a=void 0===e.premultipliedAlpha||e.premultipliedAlpha,l=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",u=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let p=null,f=null;const m=[],g=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=$,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const _=this;let x=!1,b=0,T=0,S=null,A=-1,C=null;const L=new Me,I=new Me;let P=null,R=t.width,k=t.height,z=1,D=null,O=null;const F=new Me(0,0,R,k),B=new Me(0,0,R,k);let N=!1;const U=[],j=new rn;let V=!1,G=!1,H=null;const W=new ot,q=new Ce,Z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function X(){return null===S?z:1}let Y,J,Q,K,ee,te,ie,ne,re,oe,se,ae,le,ce,ue,he,pe,de,fe,me,ge,_e,ye,ve=i;function xe(e,i){for(let n=0;n<e.length;n++){const r=e[n],o=t.getContext(r,i);if(null!==o)return o}return null}try{const e={alpha:n,depth:r,stencil:o,antialias:s,premultipliedAlpha:a,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if(t.addEventListener("webglcontextlost",Se,!1),t.addEventListener("webglcontextrestored",Ae,!1),null===ve){const t=["webgl2","webgl","experimental-webgl"];if(!0===_.isWebGL1Renderer&&t.shift(),null===(ve=xe(t,e)))throw xe(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===ve.getShaderPrecisionFormat&&(ve.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function be(){Y=new Nn(ve),J=new fn(ve,Y,e),Y.init(J),_e=new Do(ve,Y,J),Q=new ko(ve,Y,J),U[0]=1029,K=new Vn(ve),ee=new vo,te=new zo(ve,Y,Q,ee,J,_e,K),ie=new gn(_),ne=new Bn(_),re=new sn(ve,J),ye=new pn(ve,Y,re,J),oe=new Un(ve,re,K,ye),se=new qn(ve,oe,re,K),fe=new Wn(ve),he=new mn(ee),ae=new yo(_,ie,ne,Y,J,ye,he),le=new jo(ee),ce=new Mo(ee),ue=new Lo(Y,J),de=new hn(_,ie,Q,se,a),pe=new Ro(_,se,J),me=new dn(ve,Y,K,J),ge=new jn(ve,Y,K,J),K.programs=ae.programs,_.capabilities=J,_.extensions=Y,_.properties=ee,_.renderLists=ce,_.shadowMap=pe,_.state=Q,_.info=K}be();const we=new Uo(_,ve);function Se(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function Ae(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const e=K.autoReset,t=pe.enabled,i=pe.autoUpdate,n=pe.needsUpdate,r=pe.type;be(),K.autoReset=e,pe.enabled=t,pe.autoUpdate=i,pe.needsUpdate=n,pe.type=r}function Le(e){const t=e.target;t.removeEventListener("dispose",Le),function(e){(function(e){const t=ee.get(e).programs;void 0!==t&&t.forEach((function(e){ae.releaseProgram(e)}))})(e),ee.remove(e)}(t)}this.xr=we,this.getContext=function(){return ve},this.getContextAttributes=function(){return ve.getContextAttributes()},this.forceContextLoss=function(){const e=Y.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Y.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(e){void 0!==e&&(z=e,this.setSize(R,k,!1))},this.getSize=function(e){return e.set(R,k)},this.setSize=function(e,i,n){we.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(R=e,k=i,t.width=Math.floor(e*z),t.height=Math.floor(i*z),!1!==n&&(t.style.width=e+"px",t.style.height=i+"px"),this.setViewport(0,0,e,i))},this.getDrawingBufferSize=function(e){return e.set(R*z,k*z).floor()},this.setDrawingBufferSize=function(e,i,n){R=e,k=i,z=n,t.width=Math.floor(e*n),t.height=Math.floor(i*n),this.setViewport(0,0,e,i)},this.getCurrentViewport=function(e){return e.copy(L)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,i,n){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,i,n),Q.viewport(L.copy(F).multiplyScalar(z).floor())},this.getScissor=function(e){return e.copy(B)},this.setScissor=function(e,t,i,n){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,i,n),Q.scissor(I.copy(B).multiplyScalar(z).floor())},this.getScissorTest=function(){return N},this.setScissorTest=function(e){Q.setScissorTest(N=e)},this.setOpaqueSort=function(e){D=e},this.setTransparentSort=function(e){O=e},this.getClearColor=function(e){return e.copy(de.getClearColor())},this.setClearColor=function(){de.setClearColor.apply(de,arguments)},this.getClearAlpha=function(){return de.getClearAlpha()},this.setClearAlpha=function(){de.setClearAlpha.apply(de,arguments)},this.clear=function(e,t,i){let n=0;(void 0===e||e)&&(n|=16384),(void 0===t||t)&&(n|=256),(void 0===i||i)&&(n|=1024),ve.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Se,!1),t.removeEventListener("webglcontextrestored",Ae,!1),ce.dispose(),ue.dispose(),ee.dispose(),ie.dispose(),ne.dispose(),se.dispose(),ye.dispose(),we.dispose(),we.removeEventListener("sessionstart",Pe),we.removeEventListener("sessionend",Re),H&&(H.dispose(),H=null),ke.stop()},this.renderBufferImmediate=function(e,t){ye.initAttributes();const i=ee.get(e);e.hasPositions&&!i.position&&(i.position=ve.createBuffer()),e.hasNormals&&!i.normal&&(i.normal=ve.createBuffer()),e.hasUvs&&!i.uv&&(i.uv=ve.createBuffer()),e.hasColors&&!i.color&&(i.color=ve.createBuffer());const n=t.getAttributes();e.hasPositions&&(ve.bindBuffer(34962,i.position),ve.bufferData(34962,e.positionArray,35048),ye.enableAttribute(n.position.location),ve.vertexAttribPointer(n.position.location,3,5126,!1,0,0)),e.hasNormals&&(ve.bindBuffer(34962,i.normal),ve.bufferData(34962,e.normalArray,35048),ye.enableAttribute(n.normal.location),ve.vertexAttribPointer(n.normal.location,3,5126,!1,0,0)),e.hasUvs&&(ve.bindBuffer(34962,i.uv),ve.bufferData(34962,e.uvArray,35048),ye.enableAttribute(n.uv.location),ve.vertexAttribPointer(n.uv.location,2,5126,!1,0,0)),e.hasColors&&(ve.bindBuffer(34962,i.color),ve.bufferData(34962,e.colorArray,35048),ye.enableAttribute(n.color.location),ve.vertexAttribPointer(n.color.location,3,5126,!1,0,0)),ye.disableUnusedAttributes(),ve.drawArrays(4,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,i,n,r,o){null===t&&(t=Z);const s=r.isMesh&&r.matrixWorld.determinant()<0,a=Ne(e,t,n,r);Q.setMaterial(n,s);let l=i.index;const c=i.attributes.position;if(null===l){if(void 0===c||0===c.count)return}else if(0===l.count)return;let u,h=1;!0===n.wireframe&&(l=oe.getWireframeAttribute(i),h=2),void 0===i.morphAttributes.position&&void 0===i.morphAttributes.normal||fe.update(r,i,n,a),ye.setup(r,n,a,i,l);let p=me;null!==l&&(u=re.get(l),(p=ge).setIndex(u));const d=null!==l?l.count:c.count,f=i.drawRange.start*h,m=i.drawRange.count*h,g=null!==o?o.start*h:0,_=null!==o?o.count*h:1/0,y=Math.max(f,g),v=Math.min(d,f+m,g+_)-1,x=Math.max(0,v-y+1);if(0!==x){if(r.isMesh)!0===n.wireframe?(Q.setLineWidth(n.wireframeLinewidth*X()),p.setMode(1)):p.setMode(4);else if(r.isLine){let e=n.linewidth;void 0===e&&(e=1),Q.setLineWidth(e*X()),r.isLineSegments?p.setMode(1):r.isLineLoop?p.setMode(2):p.setMode(3)}else r.isPoints?p.setMode(0):r.isSprite&&p.setMode(4);if(r.isInstancedMesh)p.renderInstances(y,x,r.count);else if(i.isInstancedBufferGeometry){const e=Math.min(i.instanceCount,i._maxInstanceCount);p.renderInstances(y,x,e)}else p.render(y,x)}},this.compile=function(e,t){(f=ue.get(e)).init(),g.push(f),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(f.pushLight(e),e.castShadow&&f.pushShadow(e))})),f.setupLights(_.physicallyCorrectLights),e.traverse((function(t){const i=t.material;if(i)if(Array.isArray(i))for(let n=0;n<i.length;n++)Fe(i[n],e,t);else Fe(i,e,t)})),g.pop(),f=null};let Ie=null;function Pe(){ke.stop()}function Re(){ke.start()}const ke=new on;function ze(e,t,i,n){const r=e.opaque,o=e.transmissive,a=e.transparent;f.setupLightsView(i),o.length>0&&function(e,t,i){if(null===H){const e=!0===s&&!0===J.isWebGL2;H=new(e?Ee:Te)(1024,1024,{generateMipmaps:!0,type:null!==_e.convert(M)?M:v,minFilter:y,magFilter:d,wrapS:h,wrapT:h})}const n=_.getRenderTarget();_.setRenderTarget(H),_.clear();const r=_.toneMapping;_.toneMapping=0,De(e,t,i),_.toneMapping=r,te.updateMultisampleRenderTarget(H),te.updateRenderTargetMipmap(H),_.setRenderTarget(n)}(r,t,i),n&&Q.viewport(L.copy(n)),r.length>0&&De(r,t,i),o.length>0&&De(o,t,i),a.length>0&&De(a,t,i)}function De(e,t,i){const n=!0===t.isScene?t.overrideMaterial:null;for(let r=0,o=e.length;r<o;r++){const o=e[r],s=o.object,a=o.geometry,l=null===n?o.material:n,c=o.group;s.layers.test(i.layers)&&Oe(s,t,i,a,l,c)}}function Oe(e,t,i,n,r,o){if(e.onBeforeRender(_,t,i,n,r,o),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject){const n=Ne(i,t,r,e);Q.setMaterial(r),ye.reset(),function(e,t){e.render((function(e){_.renderBufferImmediate(e,t)}))}(e,n)}else!0===r.transparent&&2===r.side?(r.side=1,r.needsUpdate=!0,_.renderBufferDirect(i,t,n,r,e,o),r.side=0,r.needsUpdate=!0,_.renderBufferDirect(i,t,n,r,e,o),r.side=2):_.renderBufferDirect(i,t,n,r,e,o);e.onAfterRender(_,t,i,n,r,o)}function Fe(e,t,i){!0!==t.isScene&&(t=Z);const n=ee.get(e),r=f.state.lights,o=f.state.shadowsArray,s=r.state.version,a=ae.getParameters(e,r.state,o,t,i),l=ae.getProgramCacheKey(a);let c=n.programs;n.environment=e.isMeshStandardMaterial?t.environment:null,n.fog=t.fog,n.envMap=(e.isMeshStandardMaterial?ne:ie).get(e.envMap||n.environment),void 0===c&&(e.addEventListener("dispose",Le),c=new Map,n.programs=c);let u=c.get(l);if(void 0!==u){if(n.currentProgram===u&&n.lightsStateVersion===s)return Be(e,a),u}else a.uniforms=ae.getUniforms(e),e.onBuild(a,_),e.onBeforeCompile(a,_),u=ae.acquireProgram(a,l),c.set(l,u),n.uniforms=a.uniforms;const h=n.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(h.clippingPlanes=he.uniform),Be(e,a),n.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),n.lightsStateVersion=s,n.needsLights&&(h.ambientLightColor.value=r.state.ambient,h.lightProbe.value=r.state.probe,h.directionalLights.value=r.state.directional,h.directionalLightShadows.value=r.state.directionalShadow,h.spotLights.value=r.state.spot,h.spotLightShadows.value=r.state.spotShadow,h.rectAreaLights.value=r.state.rectArea,h.ltc_1.value=r.state.rectAreaLTC1,h.ltc_2.value=r.state.rectAreaLTC2,h.pointLights.value=r.state.point,h.pointLightShadows.value=r.state.pointShadow,h.hemisphereLights.value=r.state.hemi,h.directionalShadowMap.value=r.state.directionalShadowMap,h.directionalShadowMatrix.value=r.state.directionalShadowMatrix,h.spotShadowMap.value=r.state.spotShadowMap,h.spotShadowMatrix.value=r.state.spotShadowMatrix,h.pointShadowMap.value=r.state.pointShadowMap,h.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=u.getUniforms(),d=Yr.seqWithValue(p.seq,h);return n.currentProgram=u,n.uniformsList=d,u}function Be(e,t){const i=ee.get(e);i.outputEncoding=t.outputEncoding,i.instancing=t.instancing,i.skinning=t.skinning,i.morphTargets=t.morphTargets,i.morphNormals=t.morphNormals,i.numClippingPlanes=t.numClippingPlanes,i.numIntersection=t.numClipIntersection,i.vertexAlphas=t.vertexAlphas,i.vertexTangents=t.vertexTangents}function Ne(e,t,i,n){!0!==t.isScene&&(t=Z),te.resetTextureUnits();const r=t.fog,o=i.isMeshStandardMaterial?t.environment:null,s=null===S?_.outputEncoding:S.texture.encoding,a=(i.isMeshStandardMaterial?ne:ie).get(i.envMap||o),l=!0===i.vertexColors&&!!n.geometry&&!!n.geometry.attributes.color&&4===n.geometry.attributes.color.itemSize,c=!!n.geometry&&!!n.geometry.attributes.tangent,u=!!n.geometry&&!!n.geometry.morphAttributes.position,h=!!n.geometry&&!!n.geometry.morphAttributes.normal,p=ee.get(i),d=f.state.lights;if(!0===V&&(!0===G||e!==C)){const t=e===C&&i.id===A;he.setState(i,e,t)}let m=!1;i.version===p.__version?p.needsLights&&p.lightsStateVersion!==d.state.version||p.outputEncoding!==s||n.isInstancedMesh&&!1===p.instancing?m=!0:n.isInstancedMesh||!0!==p.instancing?n.isSkinnedMesh&&!1===p.skinning?m=!0:n.isSkinnedMesh||!0!==p.skinning?p.envMap!==a||i.fog&&p.fog!==r?m=!0:void 0===p.numClippingPlanes||p.numClippingPlanes===he.numPlanes&&p.numIntersection===he.numIntersection?(p.vertexAlphas!==l||p.vertexTangents!==c||p.morphTargets!==u||p.morphNormals!==h)&&(m=!0):m=!0:m=!0:m=!0:(m=!0,p.__version=i.version);let g=p.currentProgram;!0===m&&(g=Fe(i,t,n));let y=!1,v=!1,x=!1;const b=g.getUniforms(),w=p.uniforms;if(Q.useProgram(g.program)&&(y=!0,v=!0,x=!0),i.id!==A&&(A=i.id,v=!0),y||C!==e){if(b.setValue(ve,"projectionMatrix",e.projectionMatrix),J.logarithmicDepthBuffer&&b.setValue(ve,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),C!==e&&(C=e,v=!0,x=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=b.map.cameraPosition;void 0!==t&&t.setValue(ve,q.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&b.setValue(ve,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||n.isSkinnedMesh)&&b.setValue(ve,"viewMatrix",e.matrixWorldInverse)}if(n.isSkinnedMesh){b.setOptional(ve,n,"bindMatrix"),b.setOptional(ve,n,"bindMatrixInverse");const e=n.skeleton;e&&(J.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),b.setValue(ve,"boneTexture",e.boneTexture,te),b.setValue(ve,"boneTextureSize",e.boneTextureSize)):b.setOptional(ve,e,"boneMatrices"))}var M,T;return(v||p.receiveShadow!==n.receiveShadow)&&(p.receiveShadow=n.receiveShadow,b.setValue(ve,"receiveShadow",n.receiveShadow)),v&&(b.setValue(ve,"toneMappingExposure",_.toneMappingExposure),p.needsLights&&(T=x,(M=w).ambientLightColor.needsUpdate=T,M.lightProbe.needsUpdate=T,M.directionalLights.needsUpdate=T,M.directionalLightShadows.needsUpdate=T,M.pointLights.needsUpdate=T,M.pointLightShadows.needsUpdate=T,M.spotLights.needsUpdate=T,M.spotLightShadows.needsUpdate=T,M.rectAreaLights.needsUpdate=T,M.hemisphereLights.needsUpdate=T),r&&i.fog&&le.refreshFogUniforms(w,r),le.refreshMaterialUniforms(w,i,z,k,H),Yr.upload(ve,p.uniformsList,w,te)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Yr.upload(ve,p.uniformsList,w,te),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&b.setValue(ve,"center",n.center),b.setValue(ve,"modelViewMatrix",n.modelViewMatrix),b.setValue(ve,"normalMatrix",n.normalMatrix),b.setValue(ve,"modelMatrix",n.matrixWorld),g}ke.setAnimationLoop((function(e){Ie&&Ie(e)})),"undefined"!=typeof window&&ke.setContext(window),this.setAnimationLoop=function(e){Ie=e,we.setAnimationLoop(e),null===e?ke.stop():ke.start()},we.addEventListener("sessionstart",Pe),we.addEventListener("sessionend",Re),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===x)return;!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===we.enabled&&!0===we.isPresenting&&(!0===we.cameraAutoUpdate&&we.updateCamera(t),t=we.getCamera()),!0===e.isScene&&e.onBeforeRender(_,e,t,S),(f=ue.get(e,g.length)).init(),g.push(f),W.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),j.setFromProjectionMatrix(W),G=this.localClippingEnabled,V=he.init(this.clippingPlanes,G,t),(p=ce.get(e,m.length)).init(),m.push(p),function e(t,i,n,r){if(!1===t.visible)return;if(t.layers.test(i.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(i);else if(t.isLight)f.pushLight(t),t.castShadow&&f.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||j.intersectsSprite(t)){r&&q.setFromMatrixPosition(t.matrixWorld).applyMatrix4(W);const e=se.update(t),i=t.material;i.visible&&p.push(t,e,i,n,q.z,null)}}else if(t.isImmediateRenderObject)r&&q.setFromMatrixPosition(t.matrixWorld).applyMatrix4(W),p.push(t,null,t.material,n,q.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==K.render.frame&&(t.skeleton.update(),t.skeleton.frame=K.render.frame),!t.frustumCulled||j.intersectsObject(t))){r&&q.setFromMatrixPosition(t.matrixWorld).applyMatrix4(W);const e=se.update(t),i=t.material;if(Array.isArray(i)){const r=e.groups;for(let o=0,s=r.length;o<s;o++){const s=r[o],a=i[s.materialIndex];a&&a.visible&&p.push(t,e,a,n,q.z,s)}}else i.visible&&p.push(t,e,i,n,q.z,null)}const o=t.children;for(let t=0,s=o.length;t<s;t++)e(o[t],i,n,r)}(e,t,0,_.sortObjects),p.finish(),!0===_.sortObjects&&p.sort(D,O),!0===V&&he.beginShadows();const i=f.state.shadowsArray;if(pe.render(i,e,t),!0===V&&he.endShadows(),!0===this.info.autoReset&&this.info.reset(),de.render(p,e),f.setupLights(_.physicallyCorrectLights),t.isArrayCamera){const i=t.cameras;for(let t=0,n=i.length;t<n;t++){const n=i[t];ze(p,e,n,n.viewport)}}else ze(p,e,t);null!==S&&(te.updateMultisampleRenderTarget(S),te.updateRenderTargetMipmap(S)),!0===e.isScene&&e.onAfterRender(_,e,t),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1),ye.resetDefaultState(),A=-1,C=null,g.pop(),f=g.length>0?g[g.length-1]:null,m.pop(),p=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return S},this.setRenderTarget=function(e,t=0,i=0){S=e,b=t,T=i,e&&void 0===ee.get(e).__webglFramebuffer&&te.setupRenderTarget(e);let n=null,r=!1,o=!1;if(e){const i=e.texture;(i.isDataTexture3D||i.isDataTexture2DArray)&&(o=!0);const s=ee.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(n=s[t],r=!0):n=e.isWebGLMultisampleRenderTarget?ee.get(e).__webglMultisampledFramebuffer:s,L.copy(e.viewport),I.copy(e.scissor),P=e.scissorTest}else L.copy(F).multiplyScalar(z).floor(),I.copy(B).multiplyScalar(z).floor(),P=N;if(Q.bindFramebuffer(36160,n)&&J.drawBuffers){let t=!1;if(e)if(e.isWebGLMultipleRenderTargets){const i=e.texture;if(U.length!==i.length||36064!==U[0]){for(let e=0,t=i.length;e<t;e++)U[e]=36064+e;U.length=i.length,t=!0}}else 1===U.length&&36064===U[0]||(U[0]=36064,U.length=1,t=!0);else 1===U.length&&1029===U[0]||(U[0]=1029,U.length=1,t=!0);t&&(J.isWebGL2?ve.drawBuffers(U):Y.get("WEBGL_draw_buffers").drawBuffersWEBGL(U))}if(Q.viewport(L),Q.scissor(I),Q.setScissorTest(P),r){const n=ee.get(e.texture);ve.framebufferTexture2D(36160,36064,34069+t,n.__webglTexture,i)}else if(o){const n=ee.get(e.texture),r=t||0;ve.framebufferTextureLayer(36160,36064,n.__webglTexture,i||0,r)}A=-1},this.readRenderTargetPixels=function(e,t,i,n,r,o,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=ee.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(a=a[s]),a){Q.bindFramebuffer(36160,a);try{const s=e.texture,a=s.format,l=s.type;if(a!==E&&_e.convert(a)!==ve.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===M&&(Y.has("EXT_color_buffer_half_float")||J.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===v||_e.convert(l)===ve.getParameter(35738)||l===w&&(J.isWebGL2||Y.has("OES_texture_float")||Y.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ve.checkFramebufferStatus(36160)?t>=0&&t<=e.width-n&&i>=0&&i<=e.height-r&&ve.readPixels(t,i,n,r,_e.convert(a),_e.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==S?ee.get(S).__webglFramebuffer:null;Q.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),o=Math.floor(t.image.height*n);let s=_e.convert(t.format);J.isWebGL2&&(6407===s&&(s=32849),6408===s&&(s=32856)),te.setTexture2D(t,0),ve.copyTexImage2D(3553,i,s,e.x,e.y,r,o,0),Q.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n=0){const r=t.image.width,o=t.image.height,s=_e.convert(i.format),a=_e.convert(i.type);te.setTexture2D(i,0),ve.pixelStorei(37440,i.flipY),ve.pixelStorei(37441,i.premultiplyAlpha),ve.pixelStorei(3317,i.unpackAlignment),t.isDataTexture?ve.texSubImage2D(3553,n,e.x,e.y,r,o,s,a,t.image.data):t.isCompressedTexture?ve.compressedTexSubImage2D(3553,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):ve.texSubImage2D(3553,n,e.x,e.y,s,a,t.image),0===n&&i.generateMipmaps&&ve.generateMipmap(3553),Q.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,n,r=0){if(_.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,a=e.max.z-e.min.z+1,l=_e.convert(n.format),c=_e.convert(n.type);let u;if(n.isDataTexture3D)te.setTexture3D(n,0),u=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");te.setTexture2DArray(n,0),u=35866}ve.pixelStorei(37440,n.flipY),ve.pixelStorei(37441,n.premultiplyAlpha),ve.pixelStorei(3317,n.unpackAlignment);const h=ve.getParameter(3314),p=ve.getParameter(32878),d=ve.getParameter(3316),f=ve.getParameter(3315),m=ve.getParameter(32877),g=i.isCompressedTexture?i.mipmaps[0]:i.image;ve.pixelStorei(3314,g.width),ve.pixelStorei(32878,g.height),ve.pixelStorei(3316,e.min.x),ve.pixelStorei(3315,e.min.y),ve.pixelStorei(32877,e.min.z),i.isDataTexture||i.isDataTexture3D?ve.texSubImage3D(u,r,t.x,t.y,t.z,o,s,a,l,c,g.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ve.compressedTexSubImage3D(u,r,t.x,t.y,t.z,o,s,a,l,g.data)):ve.texSubImage3D(u,r,t.x,t.y,t.z,o,s,a,l,c,g),ve.pixelStorei(3314,h),ve.pixelStorei(32878,p),ve.pixelStorei(3316,d),ve.pixelStorei(3315,f),ve.pixelStorei(32877,m),0===r&&n.generateMipmaps&&ve.generateMipmap(u),Q.unbindTexture()},this.initTexture=function(e){te.setTexture2D(e,0),Q.unbindTexture()},this.resetState=function(){b=0,T=0,S=null,Q.reset(),ye.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Go extends Vo{}Go.prototype.isWebGL1Renderer=!0;class Ho{constructor(e,t=25e-5){this.name="",this.color=new Yt(e),this.density=t}clone(){return new Ho(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Ho.prototype.isFogExp2=!0;class Wo{constructor(e,t=1,i=1e3){this.name="",this.color=new Yt(e),this.near=t,this.far=i}clone(){return new Wo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Wo.prototype.isFog=!0;class qo extends It{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}qo.prototype.isScene=!0;class $o{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=ee,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=le()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=le()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=le()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}$o.prototype.isInterleavedBuffer=!0;const Zo=new Ce;class Xo{constructor(e,t,i,n=!1){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=!0===n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Zo.x=this.getX(t),Zo.y=this.getY(t),Zo.z=this.getZ(t),Zo.applyMatrix4(e),this.setXYZ(t,Zo.x,Zo.y,Zo.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Zo.x=this.getX(t),Zo.y=this.getY(t),Zo.z=this.getZ(t),Zo.applyNormalMatrix(e),this.setXYZ(t,Zo.x,Zo.y,Zo.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Zo.x=this.getX(t),Zo.y=this.getY(t),Zo.z=this.getZ(t),Zo.transformDirection(e),this.setXYZ(t,Zo.x,Zo.y,Zo.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return new ei(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Xo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}Xo.prototype.isInterleavedBufferAttribute=!0;class Yo extends Gt{constructor(e){super(),this.type="SpriteMaterial",this.color=new Yt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}let Jo;Yo.prototype.isSpriteMaterial=!0;const Qo=new Ce,Ko=new Ce,es=new Ce,ts=new ge,is=new ge,ns=new ot,rs=new Ce,os=new Ce,ss=new Ce,as=new ge,ls=new ge,cs=new ge;class us extends It{constructor(e){if(super(),this.type="Sprite",void 0===Jo){Jo=new bi;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new $o(e,5);Jo.setIndex([0,1,2,0,2,3]),Jo.setAttribute("position",new Xo(t,3,0,!1)),Jo.setAttribute("uv",new Xo(t,2,3,!1))}this.geometry=Jo,this.material=void 0!==e?e:new Yo,this.center=new ge(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ko.setFromMatrixScale(this.matrixWorld),ns.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),es.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Ko.multiplyScalar(-es.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;hs(rs.set(-.5,-.5,0),es,o,Ko,n,r),hs(os.set(.5,-.5,0),es,o,Ko,n,r),hs(ss.set(.5,.5,0),es,o,Ko,n,r),as.set(0,0),ls.set(1,0),cs.set(1,1);let s=e.ray.intersectTriangle(rs,os,ss,!1,Qo);if(null===s&&(hs(os.set(-.5,.5,0),es,o,Ko,n,r),ls.set(0,1),null===(s=e.ray.intersectTriangle(rs,ss,os,!1,Qo))))return;const a=e.ray.origin.distanceTo(Qo);a<e.near||a>e.far||t.push({distance:a,point:Qo.clone(),uv:jt.getUV(Qo,rs,os,ss,as,ls,cs,new ge),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function hs(e,t,i,n,r,o){ts.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(is.x=o*ts.x-r*ts.y,is.y=r*ts.x+o*ts.y):is.copy(ts),e.copy(t),e.x+=is.x,e.y+=is.y,e.applyMatrix4(ns)}us.prototype.isSprite=!0;const ps=new Ce,ds=new Ce;class fs extends It{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,i=t.length;e<i;e++){const i=t[e];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);const i=this.levels;let n;for(n=0;n<i.length&&!(t<i[n].distance);n++);return i.splice(n,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,n;for(i=1,n=t.length;i<n&&!(e<t[i].distance);i++);return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){ps.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(ps);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){ps.setFromMatrixPosition(e.matrixWorld),ds.setFromMatrixPosition(this.matrixWorld);const i=ps.distanceTo(ds)/e.zoom;let n,r;for(t[0].object.visible=!0,n=1,r=t.length;n<r&&i>=t[n].distance;n++)t[n-1].object.visible=!1,t[n].object.visible=!0;for(this._currentLevel=n-1;n<r;n++)t[n].object.visible=!1}}toJSON(e){const t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let e=0,n=i.length;e<n;e++){const n=i[e];t.object.levels.push({object:n.object.uuid,distance:n.distance})}return t}}const ms=new Ce,gs=new Me,_s=new Me,ys=new Ce,vs=new ot;class xs extends Ni{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ot,this.bindMatrixInverse=new ot}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Me,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const i=this.skeleton,n=this.geometry;gs.fromBufferAttribute(n.attributes.skinIndex,e),_s.fromBufferAttribute(n.attributes.skinWeight,e),ms.fromBufferAttribute(n.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const n=_s.getComponent(e);if(0!==n){const r=gs.getComponent(e);vs.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),t.addScaledVector(ys.copy(ms).applyMatrix4(vs),n)}}return t.applyMatrix4(this.bindMatrixInverse)}}xs.prototype.isSkinnedMesh=!0;class bs extends It{constructor(){super(),this.type="Bone"}}bs.prototype.isBone=!0;class ws extends be{constructor(e=null,t=1,i=1,n,r,o,s,a,l=1003,c=1003,u,h){super(null,o,s,a,l,c,n,r,u,h),this.image={data:e,width:t,height:i},this.magFilter=l,this.minFilter=c,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}ws.prototype.isDataTexture=!0;const Ms=new ot,Ts=new ot;class Ss{constructor(e=[],t=[]){this.uuid=le(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new ot)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new ot;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=e.length;n<r;n++){const r=e[n]?e[n].matrixWorld:Ts;Ms.multiplyMatrices(r,t[n]),Ms.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)}clone(){return new Ss(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=de(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new ws(t,e,e,E,w);return this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const n=e.bones[i];let r=t[n];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new bs),this.bones.push(r),this.boneInverses.push((new ot).fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const r=t[n];e.bones.push(r.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class Es extends ei{constructor(e,t,i,n=1){"number"==typeof i&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,i),this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}Es.prototype.isInstancedBufferAttribute=!0;const As=new ot,Cs=new ot,Ls=[],Is=new Ni;class Ps extends Ni{constructor(e,t,i){super(e,t),this.instanceMatrix=new Es(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Is.geometry=this.geometry,Is.material=this.material,void 0!==Is.material)for(let r=0;r<n;r++){this.getMatrixAt(r,As),Cs.multiplyMatrices(i,As),Is.matrixWorld=Cs,Is.raycast(e,Ls);for(let e=0,i=Ls.length;e<i;e++){const i=Ls[e];i.instanceId=r,i.object=this,t.push(i)}Ls.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new Es(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}Ps.prototype.isInstancedMesh=!0;class Rs extends Gt{constructor(e){super(),this.type="LineBasicMaterial",this.color=new Yt(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}Rs.prototype.isLineBasicMaterial=!0;const ks=new Ce,zs=new Ce,Ds=new ot,Os=new rt,Fs=new Ye;class Bs extends It{constructor(e=new bi,t=new Rs){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[0];for(let e=1,n=t.count;e<n;e++)ks.fromBufferAttribute(t,e-1),zs.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=ks.distanceTo(zs);e.setAttribute("lineDistance",new ci(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,o=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Fs.copy(i.boundingSphere),Fs.applyMatrix4(n),Fs.radius+=r,!1===e.ray.intersectsSphere(Fs))return;Ds.copy(n).invert(),Os.copy(e.ray).applyMatrix4(Ds);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,l=new Ce,c=new Ce,u=new Ce,h=new Ce,p=this.isLineSegments?2:1;if(i.isBufferGeometry){const n=i.index,r=i.attributes.position;if(null!==n)for(let i=Math.max(0,o.start),s=Math.min(n.count,o.start+o.count)-1;i<s;i+=p){const o=n.getX(i),s=n.getX(i+1);if(l.fromBufferAttribute(r,o),c.fromBufferAttribute(r,s),Os.distanceSqToSegment(l,c,h,u)>a)continue;h.applyMatrix4(this.matrixWorld);const p=e.ray.origin.distanceTo(h);p<e.near||p>e.far||t.push({distance:p,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}else for(let i=Math.max(0,o.start),n=Math.min(r.count,o.start+o.count)-1;i<n;i+=p){if(l.fromBufferAttribute(r,i),c.fromBufferAttribute(r,i+1),Os.distanceSqToSegment(l,c,h,u)>a)continue;h.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(h);n<e.near||n>e.far||t.push({distance:n,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Bs.prototype.isLine=!0;const Ns=new Ce,Us=new Ce;class js extends Bs{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[];for(let e=0,n=t.count;e<n;e+=2)Ns.fromBufferAttribute(t,e),Us.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+Ns.distanceTo(Us);e.setAttribute("lineDistance",new ci(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}js.prototype.isLineSegments=!0;class Vs extends Bs{constructor(e,t){super(e,t),this.type="LineLoop"}}Vs.prototype.isLineLoop=!0;class Gs extends Gt{constructor(e){super(),this.type="PointsMaterial",this.color=new Yt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this}}Gs.prototype.isPointsMaterial=!0;const Hs=new ot,Ws=new rt,qs=new Ye,$s=new Ce;class Zs extends It{constructor(e=new bi,t=new Gs){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,o=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),qs.copy(i.boundingSphere),qs.applyMatrix4(n),qs.radius+=r,!1===e.ray.intersectsSphere(qs))return;Hs.copy(n).invert(),Ws.copy(e.ray).applyMatrix4(Hs);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position;if(null!==r)for(let i=Math.max(0,o.start),l=Math.min(r.count,o.start+o.count);i<l;i++){const o=r.getX(i);$s.fromBufferAttribute(s,o),Xs($s,o,a,n,e,t,this)}else for(let i=Math.max(0,o.start),r=Math.min(s.count,o.start+o.count);i<r;i++)$s.fromBufferAttribute(s,i),Xs($s,i,a,n,e,t,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Xs(e,t,i,n,r,o,s){const a=Ws.distanceSqToPoint(e);if(a<i){const i=new Ce;Ws.closestPointToPoint(e,i),i.applyMatrix4(n);const l=r.ray.origin.distanceTo(i);if(l<r.near||l>r.far)return;o.push({distance:l,distanceToRay:Math.sqrt(a),point:i,index:t,face:null,object:s})}}Zs.prototype.isPoints=!0;class Ys extends be{constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s,a,l),this.format=void 0!==s?s:S,this.minFilter=void 0!==o?o:g,this.magFilter=void 0!==r?r:g,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Ys.prototype.isVideoTexture=!0;class Js extends be{constructor(e,t,i,n,r,o,s,a,l,c,u,h){super(null,o,s,a,l,c,n,r,u,h),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}Js.prototype.isCompressedTexture=!0;class Qs extends be{constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s,a,l),this.needsUpdate=!0}}Qs.prototype.isCanvasTexture=!0;class Ks extends be{constructor(e,t,i,n,r,o,s,a,l,c){if((c=void 0!==c?c:A)!==A&&c!==C)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===A&&(i=x),void 0===i&&c===C&&(i=T),super(null,n,r,o,s,a,c,i,l),this.image={width:e,height:t},this.magFilter=void 0!==s?s:d,this.minFilter=void 0!==a?a:d,this.flipY=!1,this.generateMipmaps=!1}}Ks.prototype.isDepthTexture=!0;class ea extends bi{constructor(e=1,t=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const r=[],o=[],s=[],a=[],l=new Ce,c=new ge;o.push(0,0,0),s.push(0,0,1),a.push(.5,.5);for(let r=0,u=3;r<=t;r++,u+=3){const h=i+r/t*n;l.x=e*Math.cos(h),l.y=e*Math.sin(h),o.push(l.x,l.y,l.z),s.push(0,0,1),c.x=(o[u]/e+1)/2,c.y=(o[u+1]/e+1)/2,a.push(c.x,c.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new ci(o,3)),this.setAttribute("normal",new ci(s,3)),this.setAttribute("uv",new ci(a,2))}static fromJSON(e){return new ea(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ta extends bi{constructor(e=1,t=1,i=1,n=8,r=1,o=!1,s=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:s,thetaLength:a};const l=this;n=Math.floor(n),r=Math.floor(r);const c=[],u=[],h=[],p=[];let d=0;const f=[],m=i/2;let g=0;function _(i){const r=d,o=new ge,f=new Ce;let _=0;const y=!0===i?e:t,v=!0===i?1:-1;for(let e=1;e<=n;e++)u.push(0,m*v,0),h.push(0,v,0),p.push(.5,.5),d++;const x=d;for(let e=0;e<=n;e++){const t=e/n*a+s,i=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*v,f.z=y*i,u.push(f.x,f.y,f.z),h.push(0,v,0),o.x=.5*i+.5,o.y=.5*r*v+.5,p.push(o.x,o.y),d++}for(let e=0;e<n;e++){const t=r+e,n=x+e;!0===i?c.push(n,n+1,t):c.push(n+1,n,t),_+=3}l.addGroup(g,_,!0===i?1:2),g+=_}!function(){const o=new Ce,_=new Ce;let y=0;const v=(t-e)/i;for(let l=0;l<=r;l++){const c=[],g=l/r,y=g*(t-e)+e;for(let e=0;e<=n;e++){const t=e/n,r=t*a+s,l=Math.sin(r),f=Math.cos(r);_.x=y*l,_.y=-g*i+m,_.z=y*f,u.push(_.x,_.y,_.z),o.set(l,v,f).normalize(),h.push(o.x,o.y,o.z),p.push(t,1-g),c.push(d++)}f.push(c)}for(let e=0;e<n;e++)for(let t=0;t<r;t++){const i=f[t][e],n=f[t+1][e],r=f[t+1][e+1],o=f[t][e+1];c.push(i,n,o),c.push(n,r,o),y+=6}l.addGroup(g,y,0),g+=y}(),!1===o&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new ci(u,3)),this.setAttribute("normal",new ci(h,3)),this.setAttribute("uv",new ci(p,2))}static fromJSON(e){return new ta(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ia extends ta{constructor(e=1,t=1,i=8,n=1,r=!1,o=0,s=2*Math.PI){super(0,e,t,i,n,r,o,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:s}}static fromJSON(e){return new ia(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class na extends bi{constructor(e,t,i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};const r=[],o=[];function s(e,t,i,n){const r=n+1,o=[];for(let n=0;n<=r;n++){o[n]=[];const s=e.clone().lerp(i,n/r),a=t.clone().lerp(i,n/r),l=r-n;for(let e=0;e<=l;e++)o[n][e]=0===e&&n===r?s:s.clone().lerp(a,e/l)}for(let e=0;e<r;e++)for(let t=0;t<2*(r-e)-1;t++){const i=Math.floor(t/2);t%2==0?(a(o[e][i+1]),a(o[e+1][i]),a(o[e][i])):(a(o[e][i+1]),a(o[e+1][i+1]),a(o[e+1][i]))}}function a(e){r.push(e.x,e.y,e.z)}function l(t,i){const n=3*t;i.x=e[n+0],i.y=e[n+1],i.z=e[n+2]}function c(e,t,i,n){n<0&&1===e.x&&(o[t]=e.x-1),0===i.x&&0===i.z&&(o[t]=n/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}!function(e){const i=new Ce,n=new Ce,r=new Ce;for(let o=0;o<t.length;o+=3)l(t[o+0],i),l(t[o+1],n),l(t[o+2],r),s(i,n,r,e)}(n),function(e){const t=new Ce;for(let i=0;i<r.length;i+=3)t.x=r[i+0],t.y=r[i+1],t.z=r[i+2],t.normalize().multiplyScalar(e),r[i+0]=t.x,r[i+1]=t.y,r[i+2]=t.z}(i),function(){const e=new Ce;for(let i=0;i<r.length;i+=3){e.x=r[i+0],e.y=r[i+1],e.z=r[i+2];const n=u(e)/2/Math.PI+.5,s=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);o.push(n,1-s)}var t;(function(){const e=new Ce,t=new Ce,i=new Ce,n=new Ce,s=new ge,a=new ge,l=new ge;for(let h=0,p=0;h<r.length;h+=9,p+=6){e.set(r[h+0],r[h+1],r[h+2]),t.set(r[h+3],r[h+4],r[h+5]),i.set(r[h+6],r[h+7],r[h+8]),s.set(o[p+0],o[p+1]),a.set(o[p+2],o[p+3]),l.set(o[p+4],o[p+5]),n.copy(e).add(t).add(i).divideScalar(3);const d=u(n);c(s,p+0,e,d),c(a,p+2,t,d),c(l,p+4,i,d)}})(),function(){for(let e=0;e<o.length;e+=6){const t=o[e+0],i=o[e+2],n=o[e+4],r=Math.max(t,i,n),s=Math.min(t,i,n);r>.9&&s<.1&&(t<.2&&(o[e+0]+=1),i<.2&&(o[e+2]+=1),n<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new ci(r,3)),this.setAttribute("normal",new ci(r.slice(),3)),this.setAttribute("uv",new ci(o,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new na(e.vertices,e.indices,e.radius,e.details)}}class ra extends na{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ra(e.radius,e.detail)}}const oa=new Ce,sa=new Ce,aa=new Ce,la=new jt;class ca extends bi{constructor(e,t){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1,!0===e.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const i=Math.pow(10,4),n=Math.cos(se*t),r=e.getIndex(),o=e.getAttribute("position"),s=r?r.count:o.count,a=[0,0,0],l=["a","b","c"],c=new Array(3),u={},h=[];for(let e=0;e<s;e+=3){r?(a[0]=r.getX(e),a[1]=r.getX(e+1),a[2]=r.getX(e+2)):(a[0]=e,a[1]=e+1,a[2]=e+2);const{a:t,b:s,c:p}=la;if(t.fromBufferAttribute(o,a[0]),s.fromBufferAttribute(o,a[1]),p.fromBufferAttribute(o,a[2]),la.getNormal(aa),c[0]=`${Math.round(t.x*i)},${Math.round(t.y*i)},${Math.round(t.z*i)}`,c[1]=`${Math.round(s.x*i)},${Math.round(s.y*i)},${Math.round(s.z*i)}`,c[2]=`${Math.round(p.x*i)},${Math.round(p.y*i)},${Math.round(p.z*i)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let e=0;e<3;e++){const t=(e+1)%3,i=c[e],r=c[t],o=la[l[e]],s=la[l[t]],p=`${i}_${r}`,d=`${r}_${i}`;d in u&&u[d]?(aa.dot(u[d].normal)<=n&&(h.push(o.x,o.y,o.z),h.push(s.x,s.y,s.z)),u[d]=null):p in u||(u[p]={index0:a[e],index1:a[t],normal:aa.clone()})}}for(const e in u)if(u[e]){const{index0:t,index1:i}=u[e];oa.fromBufferAttribute(o,t),sa.fromBufferAttribute(o,i),h.push(oa.x,oa.y,oa.z),h.push(sa.x,sa.y,sa.z)}this.setAttribute("position",new ci(h,3))}}class ua{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)r+=(i=this.getPoint(o/e)).distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let n=0;const r=i.length;let o;o=t||e*i[r-1];let s,a=0,l=r-1;for(;a<=l;)if((s=i[n=Math.floor(a+(l-a)/2)]-o)<0)a=n+1;else{if(!(s>0)){l=n;break}l=n-1}if(i[n=l]===o)return n/(r-1);const c=i[n];return(n+(o-c)/(i[n+1]-c))/(r-1)}getTangent(e,t){let i=e-1e-4,n=e+1e-4;i<0&&(i=0),n>1&&(n=1);const r=this.getPoint(i),o=this.getPoint(n),s=t||(r.isVector2?new ge:new Ce);return s.copy(o).sub(r).normalize(),s}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new Ce,n=[],r=[],o=[],s=new Ce,a=new ot;for(let t=0;t<=e;t++){const i=t/e;n[t]=this.getTangentAt(i,new Ce),n[t].normalize()}r[0]=new Ce,o[0]=new Ce;let l=Number.MAX_VALUE;const c=Math.abs(n[0].x),u=Math.abs(n[0].y),h=Math.abs(n[0].z);c<=l&&(l=c,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),h<=l&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],s),o[0].crossVectors(n[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),o[t]=o[t-1].clone(),s.crossVectors(n[t-1],n[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(ce(n[t-1].dot(n[t]),-1,1));r[t].applyMatrix4(a.makeRotationAxis(s,e))}o[t].crossVectors(n[t],r[t])}if(!0===t){let t=Math.acos(ce(r[0].dot(r[e]),-1,1));t/=e,n[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let i=1;i<=e;i++)r[i].applyMatrix4(a.makeRotationAxis(n[i],t*i)),o[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class ha extends ua{constructor(e=0,t=0,i=1,n=1,r=0,o=2*Math.PI,s=!1,a=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=s,this.aRotation=a}getPoint(e,t){const i=t||new ge,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=o?0:n),!0!==this.aClockwise||o||(r===n?r=-n:r-=n);const s=this.aStartAngle+e*r;let a=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),i=a-this.aX,n=l-this.aY;a=i*e-n*t+this.aX,l=i*t+n*e+this.aY}return i.set(a,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}ha.prototype.isEllipseCurve=!0;class pa extends ha{constructor(e,t,i,n,r,o){super(e,t,i,i,n,r,o),this.type="ArcCurve"}}function da(){let e=0,t=0,i=0,n=0;function r(r,o,s,a){e=r,t=s,i=-3*r+3*o-2*s-a,n=2*r-2*o+s+a}return{initCatmullRom:function(e,t,i,n,o){r(t,i,o*(i-e),o*(n-t))},initNonuniformCatmullRom:function(e,t,i,n,o,s,a){let l=(t-e)/o-(i-e)/(o+s)+(i-t)/s,c=(i-t)/s-(n-t)/(s+a)+(n-i)/a;r(t,i,l*=s,c*=s)},calc:function(r){const o=r*r;return e+t*r+i*o+n*(o*r)}}}pa.prototype.isArcCurve=!0;const fa=new Ce,ma=new da,ga=new da,_a=new da;class ya extends ua{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new Ce){const i=t,n=this.points,r=n.length,o=(r-(this.closed?0:1))*e;let s,a,l=Math.floor(o),c=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=n[(l-1)%r]:(fa.subVectors(n[0],n[1]).add(n[0]),s=fa);const u=n[l%r],h=n[(l+1)%r];if(this.closed||l+2<r?a=n[(l+2)%r]:(fa.subVectors(n[r-1],n[r-2]).add(n[r-1]),a=fa),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(s.distanceToSquared(u),e),i=Math.pow(u.distanceToSquared(h),e),n=Math.pow(h.distanceToSquared(a),e);i<1e-4&&(i=1),t<1e-4&&(t=i),n<1e-4&&(n=i),ma.initNonuniformCatmullRom(s.x,u.x,h.x,a.x,t,i,n),ga.initNonuniformCatmullRom(s.y,u.y,h.y,a.y,t,i,n),_a.initNonuniformCatmullRom(s.z,u.z,h.z,a.z,t,i,n)}else"catmullrom"===this.curveType&&(ma.initCatmullRom(s.x,u.x,h.x,a.x,this.tension),ga.initCatmullRom(s.y,u.y,h.y,a.y,this.tension),_a.initCatmullRom(s.z,u.z,h.z,a.z,this.tension));return i.set(ma.calc(c),ga.calc(c),_a.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new Ce).fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function va(e,t,i,n,r){const o=.5*(n-t),s=.5*(r-i),a=e*e;return(2*i-2*n+o+s)*(e*a)+(-3*i+3*n-2*o-s)*a+o*e+i}function xa(e,t,i,n){return function(e,t){const i=1-e;return i*i*t}(e,t)+function(e,t){return 2*(1-e)*e*i}(e)+function(e,t){return e*e*n}(e)}function ba(e,t,i,n,r){return function(e,t){const i=1-e;return i*i*i*t}(e,t)+function(e,t){const i=1-e;return 3*i*i*e*t}(e,i)+function(e,t){return 3*(1-e)*e*e*n}(e)+function(e,t){return e*e*e*r}(e)}ya.prototype.isCatmullRomCurve3=!0;class wa extends ua{constructor(e=new ge,t=new ge,i=new ge,n=new ge){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new ge){const i=t,n=this.v0,r=this.v1,o=this.v2,s=this.v3;return i.set(ba(e,n.x,r.x,o.x,s.x),ba(e,n.y,r.y,o.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}wa.prototype.isCubicBezierCurve=!0;class Ma extends ua{constructor(e=new Ce,t=new Ce,i=new Ce,n=new Ce){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new Ce){const i=t,n=this.v0,r=this.v1,o=this.v2,s=this.v3;return i.set(ba(e,n.x,r.x,o.x,s.x),ba(e,n.y,r.y,o.y,s.y),ba(e,n.z,r.z,o.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}Ma.prototype.isCubicBezierCurve3=!0;class Ta extends ua{constructor(e=new ge,t=new ge){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ge){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const i=t||new ge;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}Ta.prototype.isLineCurve=!0;class Sa extends ua{constructor(e=new Ce,t=new Ce){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new Ce){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ea extends ua{constructor(e=new ge,t=new ge,i=new ge){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ge){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(xa(e,n.x,r.x,o.x),xa(e,n.y,r.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}Ea.prototype.isQuadraticBezierCurve=!0;class Aa extends ua{constructor(e=new Ce,t=new Ce,i=new Ce){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Ce){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(xa(e,n.x,r.x,o.x),xa(e,n.y,r.y,o.y),xa(e,n.z,r.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}Aa.prototype.isQuadraticBezierCurve3=!0;class Ca extends ua{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new ge){const i=t,n=this.points,r=(n.length-1)*e,o=Math.floor(r),s=r-o,a=n[0===o?o:o-1],l=n[o],c=n[o>n.length-2?n.length-1:o+1],u=n[o>n.length-3?n.length-1:o+2];return i.set(va(s,a.x,l.x,c.x,u.x),va(s,a.y,l.y,c.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new ge).fromArray(i))}return this}}Ca.prototype.isSplineCurve=!0;var La=Object.freeze({__proto__:null,ArcCurve:pa,CatmullRomCurve3:ya,CubicBezierCurve:wa,CubicBezierCurve3:Ma,EllipseCurve:ha,LineCurve:Ta,LineCurve3:Sa,QuadraticBezierCurve:Ea,QuadraticBezierCurve3:Aa,SplineCurve:Ca});function Ia(e,t,i,n,r){let o,s;if(r===function(e,t,i,n){let r=0;for(let o=t,s=i-n;o<i;o+=n)r+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return r}(e,t,i,n)>0)for(o=t;o<i;o+=n)s=Ja(o,e[o],e[o+1],s);else for(o=i-n;o>=t;o-=n)s=Ja(o,e[o],e[o+1],s);return s&&Wa(s,s.next)&&(Qa(s),s=s.next),s}function Pa(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Wa(n,n.next)&&0!==Ha(n.prev,n,n.next))n=n.next;else{if(Qa(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function Ra(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{null===r.z&&(r.z=Ua(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i,n,r,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,n=i,a=0,t=0;t<c&&(a++,n=n.nextZ);t++);for(l=c;a>0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1)}(r)}(e,n,r,o);let a,l,c=e;for(;e.prev!==e.next;)if(a=e.prev,l=e.next,o?za(e,n,r,o):ka(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),Qa(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?Ra(e=Da(Pa(e),t,i),t,i,n,r,o,2):2===s&&Oa(e,t,i,n,r,o):Ra(Pa(e),t,i,n,r,o,1);break}}function ka(e){const t=e.prev,i=e,n=e.next;if(Ha(t,i,n)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Va(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Ha(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function za(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Ha(r,o,s)>=0)return!1;const a=r.x<o.x?r.x<s.x?r.x:s.x:o.x<s.x?o.x:s.x,l=r.y<o.y?r.y<s.y?r.y:s.y:o.y<s.y?o.y:s.y,c=r.x>o.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,u=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,h=Ua(a,l,t,i,n),p=Ua(c,u,t,i,n);let d=e.prevZ,f=e.nextZ;for(;d&&d.z>=h&&f&&f.z<=p;){if(d!==e.prev&&d!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ha(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==e.prev&&f!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ha(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=h;){if(d!==e.prev&&d!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ha(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==e.prev&&f!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ha(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Da(e,t,i){let n=e;do{const r=n.prev,o=n.next.next;!Wa(r,o)&&qa(r,n,n.next,o)&&Xa(r,o)&&Xa(o,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(o.i/i),Qa(n),Qa(n.next),n=e=o),n=n.next}while(n!==e);return Pa(n)}function Oa(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Ga(s,e)){let a=Ya(s,e);return s=Pa(s,s.next),a=Pa(a,a.next),Ra(s,t,i,n,r,o),void Ra(a,t,i,n,r,o)}e=e.next}s=s.next}while(s!==e)}function Fa(e,t){return e.x-t.x}function Ba(e,t){if(t=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s){if(s=e,e===n){if(r===i.y)return i;if(r===i.next.y)return i.next}o=i.x<i.next.x?i:i.next}}i=i.next}while(i!==t);if(!o)return null;if(n===s)return o;const a=o,l=o.x,c=o.y;let u,h=1/0;i=o;do{n>=i.x&&i.x>=l&&n!==i.x&&Va(r<c?n:s,r,l,c,r<c?s:n,r,i.x,i.y)&&(u=Math.abs(r-i.y)/(n-i.x),Xa(i,e)&&(u<h||u===h&&(i.x>o.x||i.x===o.x&&Na(o,i)))&&(o=i,h=u)),i=i.next}while(i!==a);return o}(e,t)){const i=Ya(t,e);Pa(t,t.next),Pa(i,i.next)}}function Na(e,t){return Ha(e.prev,e,t.prev)<0&&Ha(t.next,e,e.next)<0}function Ua(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ja(e){let 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 Va(e,t,i,n,r,o,s,a){return(r-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(n-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function Ga(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&qa(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Xa(e,t)&&Xa(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Ha(e.prev,e,t.prev)||Ha(e,t.prev,t))||Wa(e,t)&&Ha(e.prev,e,e.next)>0&&Ha(t.prev,t,t.next)>0)}function Ha(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Wa(e,t){return e.x===t.x&&e.y===t.y}function qa(e,t,i,n){const r=Za(Ha(e,t,i)),o=Za(Ha(e,t,n)),s=Za(Ha(i,n,e)),a=Za(Ha(i,n,t));return r!==o&&s!==a||!(0!==r||!$a(e,i,t))||!(0!==o||!$a(e,n,t))||!(0!==s||!$a(i,e,n))||!(0!==a||!$a(i,t,n))}function $a(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 Za(e){return e>0?1:e<0?-1:0}function Xa(e,t){return Ha(e.prev,e,e.next)<0?Ha(e,t,e.next)>=0&&Ha(e,e.prev,t)>=0:Ha(e,t,e.prev)<0||Ha(e,e.next,t)<0}function Ya(e,t){const i=new Ka(e.i,e.x,e.y),n=new Ka(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Ja(e,t,i,n){const r=new Ka(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Qa(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 Ka(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}class el{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return.5*i}static isClockWise(e){return el.area(e)<0}static triangulateShape(e,t){const i=[],n=[],r=[];tl(e),il(i,e);let o=e.length;t.forEach(tl);for(let e=0;e<t.length;e++)n.push(o),o+=t[e].length,il(i,t[e]);const s=function(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let o=Ia(e,0,r,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c,u,h,p,d;if(n&&(o=function(e,t,i,n){const r=[];let o,s,a,l,c;for(o=0,s=t.length;o<s;o++)(c=Ia(e,a=t[o]*n,l=o<s-1?t[o+1]*n:e.length,n,!1))===c.next&&(c.steiner=!0),r.push(ja(c));for(r.sort(Fa),o=0;o<r.length;o++)Ba(r[o],i),i=Pa(i,i.next);return i}(e,t,o,i)),e.length>80*i){a=c=e[0],l=u=e[1];for(let t=i;t<r;t+=i)(h=e[t])<a&&(a=h),(p=e[t+1])<l&&(l=p),h>c&&(c=h),p>u&&(u=p);d=0!==(d=Math.max(c-a,u-l))?1/d:0}return Ra(o,s,i,a,l,d),s}(i,n);for(let e=0;e<s.length;e+=3)r.push(s.slice(e,e+3));return r}}function tl(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function il(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}class nl extends bi{constructor(e,t){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,n=[],r=[];for(let t=0,i=e.length;t<i;t++)o(e[t]);function o(e){const o=[],s=void 0!==t.curveSegments?t.curveSegments:12,a=void 0!==t.steps?t.steps:1;let l=void 0!==t.depth?t.depth:100,c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:6,h=void 0!==t.bevelSize?t.bevelSize:u-2,p=void 0!==t.bevelOffset?t.bevelOffset:0,d=void 0!==t.bevelSegments?t.bevelSegments:3;const f=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:rl;void 0!==t.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),l=t.amount);let g,_,y,v,x,b=!1;f&&(g=f.getSpacedPoints(a),b=!0,c=!1,_=f.computeFrenetFrames(a,!1),y=new Ce,v=new Ce,x=new Ce),c||(d=0,u=0,h=0,p=0);const w=e.extractPoints(s);let M=w.shape;const T=w.holes;if(!el.isClockWise(M)){M=M.reverse();for(let e=0,t=T.length;e<t;e++){const t=T[e];el.isClockWise(t)&&(T[e]=t.reverse())}}const S=el.triangulateShape(M,T),E=M;for(let e=0,t=T.length;e<t;e++){const t=T[e];M=M.concat(t)}function A(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(i).add(e)}const C=M.length,L=S.length;function I(e,t,i){let n,r,o;const s=e.x-t.x,a=e.y-t.y,l=i.x-e.x,c=i.y-e.y,u=s*s+a*a,h=s*c-a*l;if(Math.abs(h)>Number.EPSILON){const h=Math.sqrt(u),p=Math.sqrt(l*l+c*c),d=t.x-a/h,f=t.y+s/h,m=((i.x-c/p-d)*c-(i.y+l/p-f)*l)/(s*c-a*l),g=(n=d+s*m-e.x)*n+(r=f+a*m-e.y)*r;if(g<=2)return new ge(n,r);o=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(a)===Math.sign(c)&&(e=!0),e?(n=-a,r=s,o=Math.sqrt(u)):(n=s,r=a,o=Math.sqrt(u/2))}return new ge(n/o,r/o)}const P=[];for(let e=0,t=E.length,i=t-1,n=e+1;e<t;e++,i++,n++)i===t&&(i=0),n===t&&(n=0),P[e]=I(E[e],E[i],E[n]);const R=[];let k,z=P.concat();for(let e=0,t=T.length;e<t;e++){const t=T[e];k=[];for(let e=0,i=t.length,n=i-1,r=e+1;e<i;e++,n++,r++)n===i&&(n=0),r===i&&(r=0),k[e]=I(t[e],t[n],t[r]);R.push(k),z=z.concat(k)}for(let e=0;e<d;e++){const t=e/d,i=u*Math.cos(t*Math.PI/2),n=h*Math.sin(t*Math.PI/2)+p;for(let e=0,t=E.length;e<t;e++){const t=A(E[e],P[e],n);F(t.x,t.y,-i)}for(let e=0,t=T.length;e<t;e++){const t=T[e];k=R[e];for(let e=0,r=t.length;e<r;e++){const r=A(t[e],k[e],n);F(r.x,r.y,-i)}}}const D=h+p;for(let e=0;e<C;e++){const t=c?A(M[e],z[e],D):M[e];b?(v.copy(_.normals[0]).multiplyScalar(t.x),y.copy(_.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(v).add(y),F(x.x,x.y,x.z)):F(t.x,t.y,0)}for(let e=1;e<=a;e++)for(let t=0;t<C;t++){const i=c?A(M[t],z[t],D):M[t];b?(v.copy(_.normals[e]).multiplyScalar(i.x),y.copy(_.binormals[e]).multiplyScalar(i.y),x.copy(g[e]).add(v).add(y),F(x.x,x.y,x.z)):F(i.x,i.y,l/a*e)}for(let e=d-1;e>=0;e--){const t=e/d,i=u*Math.cos(t*Math.PI/2),n=h*Math.sin(t*Math.PI/2)+p;for(let e=0,t=E.length;e<t;e++){const t=A(E[e],P[e],n);F(t.x,t.y,l+i)}for(let e=0,t=T.length;e<t;e++){const t=T[e];k=R[e];for(let e=0,r=t.length;e<r;e++){const r=A(t[e],k[e],n);b?F(r.x,r.y+g[a-1].y,g[a-1].x+i):F(r.x,r.y,l+i)}}}function O(e,t){let i=e.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=e.length-1);for(let e=0,i=a+2*d;e<i;e++){const i=C*e,o=C*(e+1);N(t+n+i,t+r+i,t+r+o,t+n+o)}}}function F(e,t,i){o.push(e),o.push(t),o.push(i)}function B(e,t,r){U(e),U(t),U(r);const o=n.length/3,s=m.generateTopUV(i,n,o-3,o-2,o-1);j(s[0]),j(s[1]),j(s[2])}function N(e,t,r,o){U(e),U(t),U(o),U(t),U(r),U(o);const s=n.length/3,a=m.generateSideWallUV(i,n,s-6,s-3,s-2,s-1);j(a[0]),j(a[1]),j(a[3]),j(a[1]),j(a[2]),j(a[3])}function U(e){n.push(o[3*e+0]),n.push(o[3*e+1]),n.push(o[3*e+2])}function j(e){r.push(e.x),r.push(e.y)}!function(){const e=n.length/3;if(c){let e=0,t=C*e;for(let e=0;e<L;e++){const i=S[e];B(i[2]+t,i[1]+t,i[0]+t)}t=C*(e=a+2*d);for(let e=0;e<L;e++){const i=S[e];B(i[0]+t,i[1]+t,i[2]+t)}}else{for(let e=0;e<L;e++){const t=S[e];B(t[2],t[1],t[0])}for(let e=0;e<L;e++){const t=S[e];B(t[0]+C*a,t[1]+C*a,t[2]+C*a)}}i.addGroup(e,n.length/3-e,0)}(),function(){const e=n.length/3;let t=0;O(E,t),t+=E.length;for(let e=0,i=T.length;e<i;e++){const i=T[e];O(i,t),t+=i.length}i.addGroup(e,n.length/3-e,1)}()}this.setAttribute("position",new ci(n,3)),this.setAttribute("uv",new ci(r,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return function(e,t,i){if(i.shapes=[],Array.isArray(e))for(let t=0,n=e.length;t<n;t++){const n=e[t];i.shapes.push(n.uuid)}else i.shapes.push(e.uuid);return void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON()),i}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const r=t[e.shapes[n]];i.push(r)}const n=e.options.extrudePath;return void 0!==n&&(e.options.extrudePath=(new La[n.type]).fromJSON(n)),new nl(i,e.options)}}const rl={generateTopUV:function(e,t,i,n,r){const o=t[3*i],s=t[3*i+1],a=t[3*n],l=t[3*n+1],c=t[3*r],u=t[3*r+1];return[new ge(o,s),new ge(a,l),new ge(c,u)]},generateSideWallUV:function(e,t,i,n,r,o){const s=t[3*i],a=t[3*i+1],l=t[3*i+2],c=t[3*n],u=t[3*n+1],h=t[3*n+2],p=t[3*r],d=t[3*r+1],f=t[3*r+2],m=t[3*o],g=t[3*o+1],_=t[3*o+2];return Math.abs(a-u)<Math.abs(s-c)?[new ge(s,1-l),new ge(c,1-h),new ge(p,1-f),new ge(m,1-_)]:[new ge(a,1-l),new ge(u,1-h),new ge(d,1-f),new ge(g,1-_)]}};class ol extends na{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ol(e.radius,e.detail)}}class sl extends bi{constructor(e,t=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=ce(n,0,2*Math.PI);const r=[],o=[],s=[],a=1/t,l=new Ce,c=new ge;for(let r=0;r<=t;r++){const u=i+r*a*n,h=Math.sin(u),p=Math.cos(u);for(let i=0;i<=e.length-1;i++)l.x=e[i].x*h,l.y=e[i].y,l.z=e[i].x*p,o.push(l.x,l.y,l.z),c.x=r/t,c.y=i/(e.length-1),s.push(c.x,c.y)}for(let i=0;i<t;i++)for(let t=0;t<e.length-1;t++){const n=t+i*e.length,o=n,s=n+e.length,a=n+e.length+1,l=n+1;r.push(o,s,l),r.push(s,a,l)}if(this.setIndex(r),this.setAttribute("position",new ci(o,3)),this.setAttribute("uv",new ci(s,2)),this.computeVertexNormals(),n===2*Math.PI){const i=this.attributes.normal.array,n=new Ce,r=new Ce,o=new Ce,s=t*e.length*3;for(let t=0,a=0;t<e.length;t++,a+=3)n.x=i[a+0],n.y=i[a+1],n.z=i[a+2],r.x=i[s+a+0],r.y=i[s+a+1],r.z=i[s+a+2],o.addVectors(n,r).normalize(),i[a+0]=i[s+a+0]=o.x,i[a+1]=i[s+a+1]=o.y,i[a+2]=i[s+a+2]=o.z}}static fromJSON(e){return new sl(e.points,e.segments,e.phiStart,e.phiLength)}}class al extends na{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new al(e.radius,e.detail)}}class ll extends bi{constructor(e,t,i){super(),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i};const n=[],r=[],o=[],s=[],a=1e-5,l=new Ce,c=new Ce,u=new Ce,h=new Ce,p=new Ce;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const d=t+1;for(let n=0;n<=i;n++){const d=n/i;for(let i=0;i<=t;i++){const n=i/t;e(n,d,c),r.push(c.x,c.y,c.z),n-a>=0?(e(n-a,d,u),h.subVectors(c,u)):(e(n+a,d,u),h.subVectors(u,c)),d-a>=0?(e(n,d-a,u),p.subVectors(c,u)):(e(n,d+a,u),p.subVectors(u,c)),l.crossVectors(h,p).normalize(),o.push(l.x,l.y,l.z),s.push(n,d)}}for(let e=0;e<i;e++)for(let i=0;i<t;i++){const t=e*d+i,r=e*d+i+1,o=(e+1)*d+i+1,s=(e+1)*d+i;n.push(t,r,s),n.push(r,o,s)}this.setIndex(n),this.setAttribute("position",new ci(r,3)),this.setAttribute("normal",new ci(o,3)),this.setAttribute("uv",new ci(s,2))}}class cl extends bi{constructor(e=.5,t=1,i=8,n=1,r=0,o=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:o},i=Math.max(3,i);const s=[],a=[],l=[],c=[];let u=e;const h=(t-e)/(n=Math.max(1,n)),p=new Ce,d=new ge;for(let e=0;e<=n;e++){for(let e=0;e<=i;e++){const n=r+e/i*o;p.x=u*Math.cos(n),p.y=u*Math.sin(n),a.push(p.x,p.y,p.z),l.push(0,0,1),d.x=(p.x/t+1)/2,d.y=(p.y/t+1)/2,c.push(d.x,d.y)}u+=h}for(let e=0;e<n;e++){const t=e*(i+1);for(let e=0;e<i;e++){const n=e+t,r=n,o=n+i+1,a=n+i+2,l=n+1;s.push(r,o,l),s.push(o,a,l)}}this.setIndex(s),this.setAttribute("position",new ci(a,3)),this.setAttribute("normal",new ci(l,3)),this.setAttribute("uv",new ci(c,2))}static fromJSON(e){return new cl(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ul extends bi{constructor(e,t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],n=[],r=[],o=[];let s=0,a=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(s,a,t),s+=a,a=0;function l(e){const s=n.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===el.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===el.isClockWise(t)&&(u[e]=t.reverse())}const h=el.triangulateShape(c,u);for(let e=0,t=u.length;e<t;e++){const t=u[e];c=c.concat(t)}for(let e=0,t=c.length;e<t;e++){const t=c[e];n.push(t.x,t.y,0),r.push(0,0,1),o.push(t.x,t.y)}for(let e=0,t=h.length;e<t;e++){const t=h[e],n=t[0]+s,r=t[1]+s,o=t[2]+s;i.push(n,r,o),a+=3}}this.setIndex(i),this.setAttribute("position",new ci(n,3)),this.setAttribute("normal",new ci(r,3)),this.setAttribute("uv",new ci(o,2))}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,n=e.length;i<n;i++){const n=e[i];t.shapes.push(n.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const r=t[e.shapes[n]];i.push(r)}return new ul(i,e.curveSegments)}}class hl extends bi{constructor(e=1,t=32,i=16,n=0,r=2*Math.PI,o=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:o,thetaLength:s},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const a=Math.min(o+s,Math.PI);let l=0;const c=[],u=new Ce,h=new Ce,p=[],d=[],f=[],m=[];for(let p=0;p<=i;p++){const g=[],_=p/i;let y=0;0==p&&0==o?y=.5/t:p==i&&a==Math.PI&&(y=-.5/t);for(let i=0;i<=t;i++){const a=i/t;u.x=-e*Math.cos(n+a*r)*Math.sin(o+_*s),u.y=e*Math.cos(o+_*s),u.z=e*Math.sin(n+a*r)*Math.sin(o+_*s),d.push(u.x,u.y,u.z),h.copy(u).normalize(),f.push(h.x,h.y,h.z),m.push(a+y,1-_),g.push(l++)}c.push(g)}for(let e=0;e<i;e++)for(let n=0;n<t;n++){const t=c[e][n+1],r=c[e][n],s=c[e+1][n],l=c[e+1][n+1];(0!==e||o>0)&&p.push(t,r,l),(e!==i-1||a<Math.PI)&&p.push(r,s,l)}this.setIndex(p),this.setAttribute("position",new ci(d,3)),this.setAttribute("normal",new ci(f,3)),this.setAttribute("uv",new ci(m,2))}static fromJSON(e){return new hl(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class pl extends na{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new pl(e.radius,e.detail)}}class dl extends nl{constructor(e,t={}){const i=t.font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new bi;const n=i.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(n,t),this.type="TextGeometry"}}class fl extends bi{constructor(e=1,t=.4,i=8,n=6,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r},i=Math.floor(i),n=Math.floor(n);const o=[],s=[],a=[],l=[],c=new Ce,u=new Ce,h=new Ce;for(let o=0;o<=i;o++)for(let p=0;p<=n;p++){const d=p/n*r,f=o/i*Math.PI*2;u.x=(e+t*Math.cos(f))*Math.cos(d),u.y=(e+t*Math.cos(f))*Math.sin(d),u.z=t*Math.sin(f),s.push(u.x,u.y,u.z),c.x=e*Math.cos(d),c.y=e*Math.sin(d),h.subVectors(u,c).normalize(),a.push(h.x,h.y,h.z),l.push(p/n),l.push(o/i)}for(let e=1;e<=i;e++)for(let t=1;t<=n;t++){const i=(n+1)*e+t-1,r=(n+1)*(e-1)+t-1,s=(n+1)*(e-1)+t,a=(n+1)*e+t;o.push(i,r,a),o.push(r,s,a)}this.setIndex(o),this.setAttribute("position",new ci(s,3)),this.setAttribute("normal",new ci(a,3)),this.setAttribute("uv",new ci(l,2))}static fromJSON(e){return new fl(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class ml extends bi{constructor(e=1,t=.4,i=64,n=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:n,p:r,q:o},i=Math.floor(i),n=Math.floor(n);const s=[],a=[],l=[],c=[],u=new Ce,h=new Ce,p=new Ce,d=new Ce,f=new Ce,m=new Ce,g=new Ce;for(let s=0;s<=i;++s){const y=s/i*r*Math.PI*2;_(y,r,o,e,p),_(y+.01,r,o,e,d),m.subVectors(d,p),g.addVectors(d,p),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let e=0;e<=n;++e){const r=e/n*Math.PI*2,o=-t*Math.cos(r),d=t*Math.sin(r);u.x=p.x+(o*g.x+d*f.x),u.y=p.y+(o*g.y+d*f.y),u.z=p.z+(o*g.z+d*f.z),a.push(u.x,u.y,u.z),h.subVectors(u,p).normalize(),l.push(h.x,h.y,h.z),c.push(s/i),c.push(e/n)}}for(let e=1;e<=i;e++)for(let t=1;t<=n;t++){const i=(n+1)*(e-1)+(t-1),r=(n+1)*e+(t-1),o=(n+1)*e+t,a=(n+1)*(e-1)+t;s.push(i,r,a),s.push(r,o,a)}function _(e,t,i,n,r){const o=Math.cos(e),s=Math.sin(e),a=i/t*e,l=Math.cos(a);r.x=n*(2+l)*.5*o,r.y=n*(2+l)*s*.5,r.z=n*Math.sin(a)*.5}this.setIndex(s),this.setAttribute("position",new ci(a,3)),this.setAttribute("normal",new ci(l,3)),this.setAttribute("uv",new ci(c,2))}static fromJSON(e){return new ml(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class gl extends bi{constructor(e,t=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:n,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const s=new Ce,a=new Ce,l=new ge;let c=new Ce;const u=[],h=[],p=[],d=[];function f(r){c=e.getPointAt(r/t,c);const l=o.normals[r],p=o.binormals[r];for(let e=0;e<=n;e++){const t=e/n*Math.PI*2,r=Math.sin(t),o=-Math.cos(t);a.x=o*l.x+r*p.x,a.y=o*l.y+r*p.y,a.z=o*l.z+r*p.z,a.normalize(),h.push(a.x,a.y,a.z),s.x=c.x+i*a.x,s.y=c.y+i*a.y,s.z=c.z+i*a.z,u.push(s.x,s.y,s.z)}}!function(){for(let e=0;e<t;e++)f(e);f(!1===r?t:0),function(){for(let e=0;e<=t;e++)for(let i=0;i<=n;i++)l.x=e/t,l.y=i/n,p.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=n;t++){const i=(n+1)*(e-1)+(t-1),r=(n+1)*e+(t-1),o=(n+1)*e+t,s=(n+1)*(e-1)+t;d.push(i,r,s),d.push(r,o,s)}}()}(),this.setIndex(d),this.setAttribute("position",new ci(u,3)),this.setAttribute("normal",new ci(h,3)),this.setAttribute("uv",new ci(p,2))}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new gl((new La[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class _l extends bi{constructor(e){if(super(),this.type="WireframeGeometry",!0===e.isGeometry)return void console.error("THREE.WireframeGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const t=[],i=new Set,n=new Ce,r=new Ce;if(null!==e.index){const o=e.attributes.position,s=e.index;let a=e.groups;0===a.length&&(a=[{start:0,count:s.count,materialIndex:0}]);for(let e=0,l=a.length;e<l;++e){const l=a[e],c=l.start;for(let e=c,a=c+l.count;e<a;e+=3)for(let a=0;a<3;a++){const l=s.getX(e+a),c=s.getX(e+(a+1)%3);n.fromBufferAttribute(o,l),r.fromBufferAttribute(o,c),!0===yl(n,r,i)&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let e=0,s=o.count/3;e<s;e++)for(let s=0;s<3;s++){const a=3*e+s,l=3*e+(s+1)%3;n.fromBufferAttribute(o,a),r.fromBufferAttribute(o,l),!0===yl(n,r,i)&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new ci(t,3))}}function yl(e,t,i){const n=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==i.has(n)&&!0!==i.has(r)&&(i.add(n,r),!0)}var vl=Object.freeze({__proto__:null,BoxGeometry:ji,BoxBufferGeometry:ji,CircleGeometry:ea,CircleBufferGeometry:ea,ConeGeometry:ia,ConeBufferGeometry:ia,CylinderGeometry:ta,CylinderBufferGeometry:ta,DodecahedronGeometry:ra,DodecahedronBufferGeometry:ra,EdgesGeometry:ca,ExtrudeGeometry:nl,ExtrudeBufferGeometry:nl,IcosahedronGeometry:ol,IcosahedronBufferGeometry:ol,LatheGeometry:sl,LatheBufferGeometry:sl,OctahedronGeometry:al,OctahedronBufferGeometry:al,ParametricGeometry:ll,ParametricBufferGeometry:ll,PlaneGeometry:an,PlaneBufferGeometry:an,PolyhedronGeometry:na,PolyhedronBufferGeometry:na,RingGeometry:cl,RingBufferGeometry:cl,ShapeGeometry:ul,ShapeBufferGeometry:ul,SphereGeometry:hl,SphereBufferGeometry:hl,TetrahedronGeometry:pl,TetrahedronBufferGeometry:pl,TextGeometry:dl,TextBufferGeometry:dl,TorusGeometry:fl,TorusBufferGeometry:fl,TorusKnotGeometry:ml,TorusKnotBufferGeometry:ml,TubeGeometry:gl,TubeBufferGeometry:gl,WireframeGeometry:_l});class xl extends Gt{constructor(e){super(),this.type="ShadowMaterial",this.color=new Yt(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}xl.prototype.isShadowMaterial=!0;class bl extends Gt{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Yt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}bl.prototype.isMeshStandardMaterial=!0;class wl extends bl{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ge(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ce(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.sheenTint=new Yt(0),this.transmission=0,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationTint=new Yt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularTint=new Yt(1,1,1),this.specularTintMap=null,this._clearcoat=0,this._transmission=0,this.setValues(e)}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheenTint.copy(e.sheenTint),this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationTint.copy(e.attenuationTint),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularTint.copy(e.specularTint),this.specularTintMap=e.specularTintMap,this}}wl.prototype.isMeshPhysicalMaterial=!0;class Ml extends Gt{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new Yt(16777215),this.specular=new Yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}Ml.prototype.isMeshPhongMaterial=!0;class Tl extends Gt{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Tl.prototype.isMeshToonMaterial=!0;class Sl extends Gt{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}Sl.prototype.isMeshNormalMaterial=!0;class El extends Gt{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new Yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}El.prototype.isMeshLambertMaterial=!0;class Al extends Gt{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}Al.prototype.isMeshMatcapMaterial=!0;class Cl extends Rs{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}Cl.prototype.isLineDashedMaterial=!0;var Ll=Object.freeze({__proto__:null,ShadowMaterial:xl,SpriteMaterial:Yo,RawShaderMaterial:yn,ShaderMaterial:Wi,PointsMaterial:Gs,MeshPhysicalMaterial:wl,MeshStandardMaterial:bl,MeshPhongMaterial:Ml,MeshToonMaterial:Tl,MeshNormalMaterial:Sl,MeshLambertMaterial:El,MeshDepthMaterial:Io,MeshDistanceMaterial:Po,MeshBasicMaterial:Jt,MeshMatcapMaterial:Al,LineDashedMaterial:Cl,LineBasicMaterial:Rs,Material:Gt});const Il={arraySlice:function(e,t,i){return Il.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort((function(t,i){return e[t]-e[i]})),i},sortedArray:function(e,t,i){const n=e.length,r=new e.constructor(n);for(let o=0,s=0;s!==n;++o){const n=i[o]*t;for(let i=0;i!==t;++i)r[s++]=e[n+i]}return r},flattenJSON:function(e,t,i,n){let r=1,o=e[0];for(;void 0!==o&&void 0===o[n];)o=e[r++];if(void 0===o)return;let s=o[n];if(void 0!==s)if(Array.isArray(s))do{void 0!==(s=o[n])&&(t.push(o.time),i.push.apply(i,s)),o=e[r++]}while(void 0!==o);else if(void 0!==s.toArray)do{void 0!==(s=o[n])&&(t.push(o.time),s.toArray(i,i.length)),o=e[r++]}while(void 0!==o);else do{void 0!==(s=o[n])&&(t.push(o.time),i.push(s)),o=e[r++]}while(void 0!==o)},subclip:function(e,t,i,n,r=30){const o=e.clone();o.name=t;const s=[];for(let e=0;e<o.tracks.length;++e){const t=o.tracks[e],a=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const o=t.times[e]*r;if(!(o<i||o>=n)){l.push(t.times[e]);for(let i=0;i<a;++i)c.push(t.values[e*a+i])}}0!==l.length&&(t.times=Il.convertArray(l,t.times.constructor),t.values=Il.convertArray(c,t.values.constructor),s.push(t))}o.tracks=s;let a=1/0;for(let e=0;e<o.tracks.length;++e)a>o.tracks[e].times[0]&&(a=o.tracks[e].times[0]);for(let e=0;e<o.tracks.length;++e)o.tracks[e].shift(-1*a);return o.resetDuration(),o},makeClipAdditive:function(e,t=0,i=e,n=30){n<=0&&(n=30);const r=i.tracks.length,o=t/n;for(let t=0;t<r;++t){const n=i.tracks[t],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const s=e.tracks.find((function(e){return e.name===n.name&&e.ValueTypeName===r}));if(void 0===s)continue;let a=0;const l=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=l/3);let c=0;const u=s.getValueSize();s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const h=n.times.length-1;let p;if(o<=n.times[0]){const e=a,t=l-a;p=Il.arraySlice(n.values,e,t)}else if(o>=n.times[h]){const e=h*l+a,t=e+l-a;p=Il.arraySlice(n.values,e,t)}else{const e=n.createInterpolant(),t=a,i=l-a;e.evaluate(o),p=Il.arraySlice(e.resultBuffer,t,i)}"quaternion"===r&&(new Ae).fromArray(p).normalize().conjugate().toArray(p);const d=s.times.length;for(let e=0;e<d;++e){const t=e*u+c;if("quaternion"===r)Ae.multiplyQuaternionsFlat(s.values,t,p,0,s.values,t);else{const e=u-2*c;for(let i=0;i<e;++i)s.values[t+i]-=p[i]}}}return e.blendMode=q,e}};class Pl{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let o;i:{n:if(!(e<n)){for(let o=i+2;;){if(void 0===n){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,r)}if(i===o)break;if(r=n,e<(n=t[++i]))break t}o=t.length;break i}if(e>=r)break e;{const s=t[1];e<s&&(i=2,r=s);for(let o=i-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(i===o)break;if(n=r,e>=(r=t[--i-1]))break t}o=i,i=0}}for(;i<o;){const n=i+o>>>1;e<t[n]?o=n:i=n+1}if(n=t[i],void 0===(r=t[i-1]))return this._cachedIndex=0,this.beforeStart_(0,e,n);if(void 0===n)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,r,e)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let e=0;e!==n;++e)t[e]=i[r+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}Pl.prototype.beforeStart_=Pl.prototype.copySampleValue_,Pl.prototype.afterEnd_=Pl.prototype.copySampleValue_;class Rl extends Pl{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:V,endingEnd:V}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,o=e+1,s=n[r],a=n[o];if(void 0===s)switch(this.getSettings_().endingStart){case G:r=e,s=2*t-i;break;case H:s=t+n[r=n.length-2]-n[r+1];break;default:r=e,s=i}if(void 0===a)switch(this.getSettings_().endingEnd){case G:o=e,a=2*i-t;break;case H:o=1,a=i+n[1]-n[0];break;default:o=e-1,a=t}const l=.5*(i-t),c=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(a-i),this._offsetPrev=r*c,this._offsetNext=o*c}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,p=this._weightNext,d=(i-t)/(n-t),f=d*d,m=f*d,g=-h*m+2*h*f-h*d,_=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*d+1,y=(-1-p)*m+(1.5+p)*f+.5*d,v=p*m-p*f;for(let e=0;e!==s;++e)r[e]=g*o[c+e]+_*o[l+e]+y*o[a+e]+v*o[u+e];return r}}class kl extends Pl{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=(i-t)/(n-t),u=1-c;for(let e=0;e!==s;++e)r[e]=o[l+e]*u+o[a+e]*c;return r}}class zl extends Pl{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Dl{constructor(e,t,i,n){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Il.convertArray(t,this.TimeBufferType),this.values=Il.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Il.convertArray(e.times,Array),values:Il.convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(i.interpolation=t)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new zl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new kl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Rl(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case N:t=this.InterpolantFactoryMethodDiscrete;break;case U:t=this.InterpolantFactoryMethodLinear;break;case j:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return N;case this.InterpolantFactoryMethodLinear:return U;case this.InterpolantFactoryMethodSmooth:return j}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,o=n-1;for(;r!==n&&i[r]<e;)++r;for(;-1!==o&&i[o]>t;)--o;if(++o,0!==r||o!==n){r>=o&&(r=(o=Math.max(o,1))-1);const e=this.getValueSize();this.times=Il.arraySlice(i,r,o),this.values=Il.arraySlice(this.values,r*e,o*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let t=0;t!==r;t++){const n=i[t];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,n),e=!1;break}if(null!==o&&o>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,n,o),e=!1;break}o=n}if(void 0!==n&&Il.isTypedArray(n))for(let t=0,i=n.length;t!==i;++t){const i=n[t];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,i),e=!1;break}}return e}optimize(){const e=Il.arraySlice(this.times),t=Il.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===j,r=e.length-1;let o=1;for(let s=1;s<r;++s){let r=!1;const a=e[s];if(a!==e[s+1]&&(1!==s||a!==e[0]))if(n)r=!0;else{const e=s*i,n=e-i,o=e+i;for(let s=0;s!==i;++s){const i=t[e+s];if(i!==t[n+s]||i!==t[o+s]){r=!0;break}}}if(r){if(s!==o){e[o]=e[s];const n=s*i,r=o*i;for(let e=0;e!==i;++e)t[r+e]=t[n+e]}++o}}if(r>0){e[o]=e[r];for(let e=r*i,n=o*i,s=0;s!==i;++s)t[n+s]=t[e+s];++o}return o!==e.length?(this.times=Il.arraySlice(e,0,o),this.values=Il.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this}clone(){const e=Il.arraySlice(this.times,0),t=Il.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Dl.prototype.TimeBufferType=Float32Array,Dl.prototype.ValueBufferType=Float32Array,Dl.prototype.DefaultInterpolation=U;class Ol extends Dl{}Ol.prototype.ValueTypeName="bool",Ol.prototype.ValueBufferType=Array,Ol.prototype.DefaultInterpolation=N,Ol.prototype.InterpolantFactoryMethodLinear=void 0,Ol.prototype.InterpolantFactoryMethodSmooth=void 0;class Fl extends Dl{}Fl.prototype.ValueTypeName="color";class Bl extends Dl{}Bl.prototype.ValueTypeName="number";class Nl extends Pl{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(i-t)/(n-t);let l=e*s;for(let e=l+s;l!==e;l+=4)Ae.slerpFlat(r,0,o,l-s,o,l,a);return r}}class Ul extends Dl{InterpolantFactoryMethodLinear(e){return new Nl(this.times,this.values,this.getValueSize(),e)}}Ul.prototype.ValueTypeName="quaternion",Ul.prototype.DefaultInterpolation=U,Ul.prototype.InterpolantFactoryMethodSmooth=void 0;class jl extends Dl{}jl.prototype.ValueTypeName="string",jl.prototype.ValueBufferType=Array,jl.prototype.DefaultInterpolation=N,jl.prototype.InterpolantFactoryMethodLinear=void 0,jl.prototype.InterpolantFactoryMethodSmooth=void 0;class Vl extends Dl{}Vl.prototype.ValueTypeName="vector";class Gl{constructor(e,t=-1,i,n=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=le(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,r=i.length;e!==r;++e)t.push(Hl(i[e]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,n=i.length;e!==n;++e)t.push(Dl.toJSON(i[e]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,o=[];for(let e=0;e<r;e++){let s=[],a=[];s.push((e+r-1)%r,e,(e+1)%r),a.push(0,1,0);const l=Il.getKeyframeOrder(s);s=Il.sortedArray(s,1,l),a=Il.sortedArray(a,1,l),n||0!==s[0]||(s.push(r),a.push(a[0])),o.push(new Bl(".morphTargetInfluences["+t[e].name+"]",s,a).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const t=e;i=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,i=e.length;t<i;t++){const i=e[t],o=i.name.match(r);if(o&&o.length>1){const e=o[1];let t=n[e];t||(n[e]=t=[]),t.push(i)}}const o=[];for(const e in n)o.push(this.CreateFromMorphTargetSequence(e,n[e],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(e,t,i,n,r){if(0!==i.length){const o=[],s=[];Il.flattenJSON(i,o,s,n),0!==o.length&&r.push(new e(t,o,s))}},n=[],r=e.name||"default",o=e.fps||30,s=e.blendMode;let a=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const r=l[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){const e={};let t;for(t=0;t<r.length;t++)if(r[t].morphTargets)for(let i=0;i<r[t].morphTargets.length;i++)e[r[t].morphTargets[i]]=-1;for(const i in e){const e=[],o=[];for(let n=0;n!==r[t].morphTargets.length;++n){const n=r[t];e.push(n.time),o.push(n.morphTarget===i?1:0)}n.push(new Bl(".morphTargetInfluence["+i+"]",e,o))}a=e.length*(o||1)}else{const o=".bones["+t[e].name+"]";i(Vl,o+".position",r,"pos",n),i(Ul,o+".quaternion",r,"rot",n),i(Vl,o+".scale",r,"scl",n)}}return 0===n.length?null:new this(r,a,n,s)}resetDuration(){let e=0;for(let t=0,i=this.tracks.length;t!==i;++t){const i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Hl(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bl;case"vector":case"vector2":case"vector3":case"vector4":return Vl;case"color":return Fl;case"quaternion":return Ul;case"bool":case"boolean":return Ol;case"string":return jl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],i=[];Il.flattenJSON(e.keys,t,i,"value"),e.times=t,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const Wl={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class ql{constructor(e,t,i){const n=this;let r,o=!1,s=0,a=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){a++,!1===o&&void 0!==n.onStart&&n.onStart(e,s,a),o=!0},this.itemEnd=function(e){s++,void 0!==n.onProgress&&n.onProgress(e,s,a),s===a&&(o=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(e){void 0!==n.onError&&n.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,i=l.length;t<i;t+=2){const i=l[t],n=l[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return n}return null}}}const $l=new ql;class Zl{constructor(e){this.manager=void 0!==e?e:$l,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise((function(n,r){i.load(e,n,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const Xl={};class Yl extends Zl{constructor(e){super(e)}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Wl.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;if(void 0!==Xl[e])return void Xl[e].push({onLoad:t,onProgress:i,onError:n});const s=e.match(/^data:(.*?)(;base64)?,(.*)$/);let a;if(s){const i=s[1],o=!!s[2];let a=s[3];a=decodeURIComponent(a),o&&(a=atob(a));try{let n;const o=(this.responseType||"").toLowerCase();switch(o){case"arraybuffer":case"blob":const e=new Uint8Array(a.length);for(let t=0;t<a.length;t++)e[t]=a.charCodeAt(t);n="blob"===o?new Blob([e.buffer],{type:i}):e.buffer;break;case"document":const t=new DOMParser;n=t.parseFromString(a,i);break;case"json":n=JSON.parse(a);break;default:n=a}setTimeout((function(){t&&t(n),r.manager.itemEnd(e)}),0)}catch(t){setTimeout((function(){n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)}),0)}}else{Xl[e]=[],Xl[e].push({onLoad:t,onProgress:i,onError:n}),(a=new XMLHttpRequest).open("GET",e,!0),a.addEventListener("load",(function(t){const i=this.response,n=Xl[e];if(delete Xl[e],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Wl.add(e,i);for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onLoad&&t.onLoad(i)}r.manager.itemEnd(e)}else{for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onError&&i.onError(t)}r.manager.itemError(e),r.manager.itemEnd(e)}}),!1),a.addEventListener("progress",(function(t){const i=Xl[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onProgress&&n.onProgress(t)}}),!1),a.addEventListener("error",(function(t){const i=Xl[e];delete Xl[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onError&&n.onError(t)}r.manager.itemError(e),r.manager.itemEnd(e)}),!1),a.addEventListener("abort",(function(t){const i=Xl[e];delete Xl[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onError&&n.onError(t)}r.manager.itemError(e),r.manager.itemEnd(e)}),!1),void 0!==this.responseType&&(a.responseType=this.responseType),void 0!==this.withCredentials&&(a.withCredentials=this.withCredentials),a.overrideMimeType&&a.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const e in this.requestHeader)a.setRequestHeader(e,this.requestHeader[e]);a.send(null)}return r.manager.itemStart(e),a}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Jl extends Zl{constructor(e){super(e)}load(e,t,i,n){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Wl.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;const s=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){s.removeEventListener("load",a,!1),s.removeEventListener("error",l,!1),Wl.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){s.removeEventListener("load",a,!1),s.removeEventListener("error",l,!1),n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)}return s.addEventListener("load",a,!1),s.addEventListener("error",l,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(e),s.src=e,s}}class Ql extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=new Xi,o=new Jl(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let s=0;function a(i){o.load(e[i],(function(e){r.images[i]=e,6==++s&&(r.needsUpdate=!0,t&&t(r))}),void 0,n)}for(let t=0;t<e.length;++t)a(t);return r}}class Kl extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new ws,s=new Yl(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,(function(e){const i=r.parse(e);i&&(void 0!==i.image?o.image=i.image:void 0!==i.data&&(o.image.width=i.width,o.image.height=i.height,o.image.data=i.data),o.wrapS=void 0!==i.wrapS?i.wrapS:h,o.wrapT=void 0!==i.wrapT?i.wrapT:h,o.magFilter=void 0!==i.magFilter?i.magFilter:g,o.minFilter=void 0!==i.minFilter?i.minFilter:g,o.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.encoding&&(o.encoding=i.encoding),void 0!==i.flipY&&(o.flipY=i.flipY),void 0!==i.format&&(o.format=i.format),void 0!==i.type&&(o.type=i.type),void 0!==i.mipmaps&&(o.mipmaps=i.mipmaps,o.minFilter=y),1===i.mipmapCount&&(o.minFilter=g),void 0!==i.generateMipmaps&&(o.generateMipmaps=i.generateMipmaps),o.needsUpdate=!0,t&&t(o,i))}),i,n),o}}class ec extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=new be,o=new Jl(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,(function(i){r.image=i;const n=e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/);r.format=n?S:E,r.needsUpdate=!0,void 0!==t&&t(r)}),i,n),r}}class tc extends ua{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Ta(t,e))}getPoint(e){const t=e*this.getLength(),i=this.getCurveLengths();let n=0;for(;n<i.length;){if(i[n]>=t){const e=i[n]-t,r=this.curves[n],o=r.getLength(),s=0===o?0:1-e/o;return r.getPointAt(s)}n++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const o=r[n],s=o&&o.isEllipseCurve?2*e:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,a=o.getPoints(s);for(let e=0;e<a.length;e++){const n=a[e];i&&i.equals(n)||(t.push(n),i=n)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const i=e.curves[t];this.curves.push((new La[i.type]).fromJSON(i))}return this}}class ic extends tc{constructor(e){super(),this.type="Path",this.currentPoint=new ge,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new Ta(this.currentPoint.clone(),new ge(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const r=new Ea(this.currentPoint.clone(),new ge(e,t),new ge(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,o){const s=new wa(this.currentPoint.clone(),new ge(e,t),new ge(i,n),new ge(r,o));return this.curves.push(s),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Ca(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,o){const s=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(e+s,t+a,i,n,r,o),this}absarc(e,t,i,n,r,o){return this.absellipse(e,t,i,i,n,r,o),this}ellipse(e,t,i,n,r,o,s,a){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,i,n,r,o,s,a),this}absellipse(e,t,i,n,r,o,s,a){const l=new ha(e,t,i,n,r,o,s,a);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class nc extends ic{constructor(e){super(e),this.uuid=le(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const i=e.holes[t];this.holes.push((new ic).fromJSON(i))}return this}}class rc extends It{constructor(e,t=1){super(),this.type="Light",this.color=new Yt(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}rc.prototype.isLight=!0;class oc extends rc{constructor(e,t,i){super(e,i),this.type="HemisphereLight",this.position.copy(It.DefaultUp),this.updateMatrix(),this.groundColor=new Yt(t)}copy(e){return rc.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}oc.prototype.isHemisphereLight=!0;const sc=new ot,ac=new Ce,lc=new Ce;class cc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ge(512,512),this.map=null,this.mapPass=null,this.matrix=new ot,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rn,this._frameExtents=new ge(1,1),this._viewportCount=1,this._viewports=[new Me(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;ac.setFromMatrixPosition(e.matrixWorld),t.position.copy(ac),lc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(lc),t.updateMatrixWorld(),sc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sc),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class uc extends cc{constructor(){super(new $i(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,i=2*ae*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;i===t.fov&&n===t.aspect&&r===t.far||(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}uc.prototype.isSpotLightShadow=!0;class hc extends rc{constructor(e,t,i=0,n=Math.PI/3,r=0,o=1){super(e,t),this.type="SpotLight",this.position.copy(It.DefaultUp),this.updateMatrix(),this.target=new It,this.distance=i,this.angle=n,this.penumbra=r,this.decay=o,this.shadow=new uc}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}hc.prototype.isSpotLight=!0;const pc=new ot,dc=new Ce,fc=new Ce;class mc extends cc{constructor(){super(new $i(90,1,.5,500)),this._frameExtents=new ge(4,2),this._viewportCount=6,this._viewports=[new Me(2,1,1,1),new Me(0,1,1,1),new Me(3,1,1,1),new Me(1,1,1,1),new Me(3,0,1,1),new Me(1,0,1,1)],this._cubeDirections=[new Ce(1,0,0),new Ce(-1,0,0),new Ce(0,0,1),new Ce(0,0,-1),new Ce(0,1,0),new Ce(0,-1,0)],this._cubeUps=[new Ce(0,1,0),new Ce(0,1,0),new Ce(0,1,0),new Ce(0,1,0),new Ce(0,0,1),new Ce(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),dc.setFromMatrixPosition(e.matrixWorld),i.position.copy(dc),fc.copy(i.position),fc.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(fc),i.updateMatrixWorld(),n.makeTranslation(-dc.x,-dc.y,-dc.z),pc.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(pc)}}mc.prototype.isPointLightShadow=!0;class gc extends rc{constructor(e,t,i=0,n=1){super(e,t),this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new mc}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}gc.prototype.isPointLight=!0;class _c extends cc{constructor(){super(new _n(-5,5,5,-5,.5,500))}}_c.prototype.isDirectionalLightShadow=!0;class yc extends rc{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(It.DefaultUp),this.updateMatrix(),this.target=new It,this.shadow=new _c}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}yc.prototype.isDirectionalLight=!0;class vc extends rc{constructor(e,t){super(e,t),this.type="AmbientLight"}}vc.prototype.isAmbientLight=!0;class xc extends rc{constructor(e,t,i=10,n=10){super(e,t),this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}xc.prototype.isRectAreaLight=!0;class bc{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Ce)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,n=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*n),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],i*n*1.092548),t.addScaledVector(o[5],n*r*1.092548),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],i*r*1.092548),t.addScaledVector(o[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],1.023328*n),t.addScaledVector(o[2],1.023328*r),t.addScaledVector(o[3],1.023328*i),t.addScaledVector(o[4],.858086*i*n),t.addScaledVector(o[5],.858086*n*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],.858086*i*r),t.addScaledVector(o[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+3*n);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+3*n);return e}static getBasisAt(e,t){const i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}bc.prototype.isSphericalHarmonics3=!0;class wc extends rc{constructor(e=new bc,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}wc.prototype.isLightProbe=!0;class Mc extends Zl{constructor(e){super(e),this.textures={}}load(e,t,i,n){const r=this,o=new Yl(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e){const t=this.textures;function i(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const n=new Ll[e.type];if(void 0!==e.uuid&&(n.uuid=e.uuid),void 0!==e.name&&(n.name=e.name),void 0!==e.color&&void 0!==n.color&&n.color.setHex(e.color),void 0!==e.roughness&&(n.roughness=e.roughness),void 0!==e.metalness&&(n.metalness=e.metalness),void 0!==e.sheenTint&&(n.sheenTint=(new Yt).setHex(e.sheenTint)),void 0!==e.emissive&&void 0!==n.emissive&&n.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==n.specular&&n.specular.setHex(e.specular),void 0!==e.specularIntensity&&(n.specularIntensity=e.specularIntensity),void 0!==e.specularTint&&void 0!==n.specularTint&&n.specularTint.setHex(e.specularTint),void 0!==e.shininess&&(n.shininess=e.shininess),void 0!==e.clearcoat&&(n.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(n.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.transmission&&(n.transmission=e.transmission),void 0!==e.thickness&&(n.thickness=e.thickness),void 0!==e.attenuationDistance&&(n.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationTint&&void 0!==n.attenuationTint&&n.attenuationTint.setHex(e.attenuationTint),void 0!==e.fog&&(n.fog=e.fog),void 0!==e.flatShading&&(n.flatShading=e.flatShading),void 0!==e.blending&&(n.blending=e.blending),void 0!==e.combine&&(n.combine=e.combine),void 0!==e.side&&(n.side=e.side),void 0!==e.shadowSide&&(n.shadowSide=e.shadowSide),void 0!==e.opacity&&(n.opacity=e.opacity),void 0!==e.format&&(n.format=e.format),void 0!==e.transparent&&(n.transparent=e.transparent),void 0!==e.alphaTest&&(n.alphaTest=e.alphaTest),void 0!==e.depthTest&&(n.depthTest=e.depthTest),void 0!==e.depthWrite&&(n.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(n.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(n.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(n.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(n.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(n.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(n.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(n.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(n.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(n.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(n.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(n.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(n.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(n.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(n.rotation=e.rotation),1!==e.linewidth&&(n.linewidth=e.linewidth),void 0!==e.dashSize&&(n.dashSize=e.dashSize),void 0!==e.gapSize&&(n.gapSize=e.gapSize),void 0!==e.scale&&(n.scale=e.scale),void 0!==e.polygonOffset&&(n.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(n.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(n.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(n.dithering=e.dithering),void 0!==e.alphaToCoverage&&(n.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(n.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.toneMapped&&(n.toneMapped=e.toneMapped),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?n.vertexColors=e.vertexColors>0:n.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(n.uniforms[t]={},r.type){case"t":n.uniforms[t].value=i(r.value);break;case"c":n.uniforms[t].value=(new Yt).setHex(r.value);break;case"v2":n.uniforms[t].value=(new ge).fromArray(r.value);break;case"v3":n.uniforms[t].value=(new Ce).fromArray(r.value);break;case"v4":n.uniforms[t].value=(new Me).fromArray(r.value);break;case"m3":n.uniforms[t].value=(new _e).fromArray(r.value);break;case"m4":n.uniforms[t].value=(new ot).fromArray(r.value);break;default:n.uniforms[t].value=r.value}}if(void 0!==e.defines&&(n.defines=e.defines),void 0!==e.vertexShader&&(n.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(n.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(const t in e.extensions)n.extensions[t]=e.extensions[t];if(void 0!==e.shading&&(n.flatShading=1===e.shading),void 0!==e.size&&(n.size=e.size),void 0!==e.sizeAttenuation&&(n.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(n.map=i(e.map)),void 0!==e.matcap&&(n.matcap=i(e.matcap)),void 0!==e.alphaMap&&(n.alphaMap=i(e.alphaMap)),void 0!==e.bumpMap&&(n.bumpMap=i(e.bumpMap)),void 0!==e.bumpScale&&(n.bumpScale=e.bumpScale),void 0!==e.normalMap&&(n.normalMap=i(e.normalMap)),void 0!==e.normalMapType&&(n.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),n.normalScale=(new ge).fromArray(t)}return void 0!==e.displacementMap&&(n.displacementMap=i(e.displacementMap)),void 0!==e.displacementScale&&(n.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(n.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(n.roughnessMap=i(e.roughnessMap)),void 0!==e.metalnessMap&&(n.metalnessMap=i(e.metalnessMap)),void 0!==e.emissiveMap&&(n.emissiveMap=i(e.emissiveMap)),void 0!==e.emissiveIntensity&&(n.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(n.specularMap=i(e.specularMap)),void 0!==e.specularIntensityMap&&(n.specularIntensityMap=i(e.specularIntensityMap)),void 0!==e.specularTintMap&&(n.specularTintMap=i(e.specularTintMap)),void 0!==e.envMap&&(n.envMap=i(e.envMap)),void 0!==e.envMapIntensity&&(n.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(n.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(n.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(n.lightMap=i(e.lightMap)),void 0!==e.lightMapIntensity&&(n.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(n.aoMap=i(e.aoMap)),void 0!==e.aoMapIntensity&&(n.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(n.gradientMap=i(e.gradientMap)),void 0!==e.clearcoatMap&&(n.clearcoatMap=i(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(n.clearcoatNormalScale=(new ge).fromArray(e.clearcoatNormalScale)),void 0!==e.transmissionMap&&(n.transmissionMap=i(e.transmissionMap)),void 0!==e.thicknessMap&&(n.thicknessMap=i(e.thicknessMap)),n}setTextures(e){return this.textures=e,this}}class Tc{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}}class Sc extends bi{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}Sc.prototype.isInstancedBufferGeometry=!0;class Ec extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Yl(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e){const t={},i={};function n(e,n){if(void 0!==t[n])return t[n];const r=e.interleavedBuffers[n],o=function(e,t){if(void 0!==i[t])return i[t];const n=e.arrayBuffers[t],r=new Uint32Array(n).buffer;return i[t]=r,r}(e,r.buffer),s=di(r.type,o),a=new $o(s,r.stride);return a.uuid=r.uuid,t[n]=a,a}const r=e.isInstancedBufferGeometry?new Sc:new bi,o=e.data.index;if(void 0!==o){const e=di(o.type,o.array);r.setIndex(new ei(e,1))}const s=e.data.attributes;for(const t in s){const i=s[t];let o;if(i.isInterleavedBufferAttribute){const t=n(e.data,i.data);o=new Xo(t,i.itemSize,i.offset,i.normalized)}else{const e=di(i.type,i.array);o=new(i.isInstancedBufferAttribute?Es:ei)(e,i.itemSize,i.normalized)}void 0!==i.name&&(o.name=i.name),void 0!==i.usage&&o.setUsage(i.usage),void 0!==i.updateRange&&(o.updateRange.offset=i.updateRange.offset,o.updateRange.count=i.updateRange.count),r.setAttribute(t,o)}const a=e.data.morphAttributes;if(a)for(const t in a){const i=a[t],o=[];for(let t=0,r=i.length;t<r;t++){const r=i[t];let s;if(r.isInterleavedBufferAttribute){const t=n(e.data,r.data);s=new Xo(t,r.itemSize,r.offset,r.normalized)}else{const e=di(r.type,r.array);s=new ei(e,r.itemSize,r.normalized)}void 0!==r.name&&(s.name=r.name),o.push(s)}r.morphAttributes[t]=o}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const t=l[e];r.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;if(void 0!==c){const e=new Ce;void 0!==c.center&&e.fromArray(c.center),r.boundingSphere=new Ye(e,c.radius)}return e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}}const Ac={UVMapping:n,CubeReflectionMapping:r,CubeRefractionMapping:o,EquirectangularReflectionMapping:s,EquirectangularRefractionMapping:a,CubeUVReflectionMapping:l,CubeUVRefractionMapping:c},Cc={RepeatWrapping:u,ClampToEdgeWrapping:h,MirroredRepeatWrapping:p},Lc={NearestFilter:d,NearestMipmapNearestFilter:f,NearestMipmapLinearFilter:m,LinearFilter:g,LinearMipmapNearestFilter:_,LinearMipmapLinearFilter:y};class Ic extends Zl{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Wl.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,fetch(e,s).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){Wl.add(e,i),t&&t(i),r.manager.itemEnd(e)})).catch((function(t){n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}Ic.prototype.isImageBitmapLoader=!0;class Pc{constructor(){this.type="ShapePath",this.color=new Yt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ic,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,r,o){return this.currentPath.bezierCurveTo(e,t,i,n,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function i(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i],r=new nc;r.curves=n.curves,t.push(r)}return t}function n(e,t){const i=t.length;let n=!1;for(let r=i-1,o=0;o<i;r=o++){let i=t[r],s=t[o],a=s.x-i.x,l=s.y-i.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(i=t[o],a=-a,s=t[r],l=-l),e.y<i.y||e.y>s.y)continue;if(e.y===i.y){if(e.x===i.x)return!0}else{const t=l*(e.x-i.x)-a*(e.y-i.y);if(0===t)return!0;if(t<0)continue;n=!n}}else{if(e.y!==i.y)continue;if(s.x<=e.x&&e.x<=i.x||i.x<=e.x&&e.x<=s.x)return!0}}return n}const r=el.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return i(o);let s,a,l;const c=[];if(1===o.length)return a=o[0],(l=new nc).curves=a.curves,c.push(l),c;let u=!r(o[0].getPoints());u=e?!u:u;const h=[],p=[];let d,f,m=[],g=0;p[g]=void 0,m[g]=[];for(let t=0,i=o.length;t<i;t++)s=r(d=(a=o[t]).getPoints()),(s=e?!s:s)?(!u&&p[g]&&g++,p[g]={s:new nc,p:d},p[g].s.curves=a.curves,u&&g++,m[g]=[]):m[g].push({h:a,p:d[0]});if(!p[0])return i(o);if(p.length>1){let e=!1;const t=[];for(let e=0,t=p.length;e<t;e++)h[e]=[];for(let i=0,r=p.length;i<r;i++){const r=m[i];for(let o=0;o<r.length;o++){const s=r[o];let a=!0;for(let r=0;r<p.length;r++)n(s.p,p[r].p)&&(i!==r&&t.push({froms:i,tos:r,hole:o}),a?(a=!1,h[r].push(s)):e=!0);a&&h[i].push(s)}}t.length>0&&(e||(m=h))}for(let e=0,t=p.length;e<t;e++){l=p[e].s,c.push(l),f=m[e];for(let e=0,t=f.length;e<t;e++)l.holes.push(f[e].h)}return c}}class Rc{constructor(e){this.type="Font",this.data=e}generateShapes(e,t=100){const i=[],n=function(e,t,i){const n=Array.from(e),r=t/i.resolution,o=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,s=[];let a=0,l=0;for(let e=0;e<n.length;e++){const t=n[e];if("\n"===t)a=0,l-=o;else{const e=kc(t,r,a,l,i);a+=e.offsetX,s.push(e.path)}}return s}(e,t,this.data);for(let e=0,t=n.length;e<t;e++)Array.prototype.push.apply(i,n[e].toShapes());return i}}function kc(e,t,i,n,r){const o=r.glyphs[e]||r.glyphs["?"];if(!o)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+r.familyName+".");const s=new Pc;let a,l,c,u,h,p,d,f;if(o.o){const e=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let r=0,o=e.length;r<o;)switch(e[r++]){case"m":a=e[r++]*t+i,l=e[r++]*t+n,s.moveTo(a,l);break;case"l":a=e[r++]*t+i,l=e[r++]*t+n,s.lineTo(a,l);break;case"q":c=e[r++]*t+i,u=e[r++]*t+n,h=e[r++]*t+i,p=e[r++]*t+n,s.quadraticCurveTo(h,p,c,u);break;case"b":c=e[r++]*t+i,u=e[r++]*t+n,h=e[r++]*t+i,p=e[r++]*t+n,d=e[r++]*t+i,f=e[r++]*t+n,s.bezierCurveTo(h,p,d,f,c,u)}}return{offsetX:o.ha*t,path:s}}let zc;Rc.prototype.isFont=!0;const Dc={getContext:function(){return void 0===zc&&(zc=new(window.AudioContext||window.webkitAudioContext)),zc},setContext:function(e){zc=e}};class Oc extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Yl(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(i){try{const e=i.slice(0);Dc.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}}class Fc extends wc{constructor(e,t,i=1){super(void 0,i);const n=(new Yt).set(e),r=(new Yt).set(t),o=new Ce(n.r,n.g,n.b),s=new Ce(r.r,r.g,r.b),a=Math.sqrt(Math.PI),l=a*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(s).multiplyScalar(a),this.sh.coefficients[1].copy(o).sub(s).multiplyScalar(l)}}Fc.prototype.isHemisphereLightProbe=!0;class Bc extends wc{constructor(e,t=1){super(void 0,t);const i=(new Yt).set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}}Bc.prototype.isAmbientLightProbe=!0;const Nc=new ot,Uc=new ot;class jc{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Vc(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Vc();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Vc(){return("undefined"==typeof performance?Date:performance).now()}const Gc=new Ce,Hc=new Ae,Wc=new Ce,qc=new Ce;class $c extends It{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Zc=new Ce,Xc=new Ae,Yc=new Ce,Jc=new Ce;class Qc{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class Kc{constructor(e,t,i){let n,r,o;switch(this.binding=e,this.valueSize=i,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let o=this.cumulativeWeight;if(0===o){for(let e=0;e!==n;++e)i[r+e]=i[e];o=t}else{const e=t/(o+=t);this._mixBufferRegion(i,r,0,e,n)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const e=t*this._origIndex;this._mixBufferRegion(i,n,e,1-r,t)}o>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(i[e]!==i[e+t]){s.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let e=i,r=n;e!==r;++e)t[e]=t[n+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)e[t+n]=e[i+n]}_slerp(e,t,i,n){Ae.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const o=this._workIndex*r;Ae.multiplyQuaternionsFlat(e,o,e,t,e,i),Ae.slerpFlat(e,t,e,t,e,o,n)}_lerp(e,t,i,n,r){const o=1-n;for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]*o+e[i+s]*n}}_lerpAdditive(e,t,i,n,r){for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]+e[i+o]*n}}}const eu=new RegExp("[\\[\\]\\.:\\/]","g"),tu="[^\\[\\]\\.:\\/]",iu="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",nu=/((?:WC+[\/:])*)/.source.replace("WC",tu),ru=/(WCOD+)?/.source.replace("WCOD",iu),ou=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",tu),su=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",tu),au=new RegExp("^"+nu+ru+ou+su+"$"),lu=["material","materials","bones"];class cu{constructor(e,t,i){this.path=t,this.parsedPath=i||cu.parseTrackName(t),this.node=cu.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new cu.Composite(e,t,i):new cu(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(eu,"")}static parseTrackName(e){const t=au.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const e=i.nodeName.substring(n+1);-1!==lu.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){const i=function(e){for(let n=0;n<e.length;n++){const r=e[n];if(r.name===t||r.uuid===t)return r;const o=i(r.children);if(o)return o}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=cu.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===n){n=t;break}break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==n){if(void 0===e[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[n]}}const o=e[n];if(void 0===o){const i=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",e)}let s=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?s=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(s=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}a=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else void 0!==o.fromArray&&void 0!==o.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(a=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}cu.Composite=class{constructor(e,t,i){const n=i||cu.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},cu.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},cu.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},cu.prototype.GetterByBindingType=[cu.prototype._getValue_direct,cu.prototype._getValue_array,cu.prototype._getValue_arrayElement,cu.prototype._getValue_toArray],cu.prototype.SetterByBindingTypeAndVersioning=[[cu.prototype._setValue_direct,cu.prototype._setValue_direct_setNeedsUpdate,cu.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[cu.prototype._setValue_array,cu.prototype._setValue_array_setNeedsUpdate,cu.prototype._setValue_array_setMatrixWorldNeedsUpdate],[cu.prototype._setValue_arrayElement,cu.prototype._setValue_arrayElement_setNeedsUpdate,cu.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[cu.prototype._setValue_fromArray,cu.prototype._setValue_fromArray_setNeedsUpdate,cu.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class uu{constructor(){this.uuid=le(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,o=r.length;let s,a=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],h=u.uuid;let p=t[h];if(void 0===p){p=a++,t[h]=p,e.push(u);for(let e=0,t=o;e!==t;++e)r[e].push(new cu(u,i[e],n[e]))}else if(p<l){s=e[p];const a=--l,c=e[a];t[c.uuid]=p,e[p]=c,t[h]=a,e[a]=u;for(let e=0,t=o;e!==t;++e){const t=r[e],o=t[a];let s=t[p];t[p]=o,void 0===s&&(s=new cu(u,i[e],n[e])),t[a]=s}}else e[p]!==s&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o],a=s.uuid,l=t[a];if(void 0!==l&&l>=r){const o=r++,c=e[o];t[c.uuid]=l,e[l]=c,t[a]=o,e[o]=s;for(let e=0,t=n;e!==t;++e){const t=i[e],n=t[o],r=t[l];t[l]=n,t[o]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=e.length;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s].uuid,l=t[a];if(void 0!==l)if(delete t[a],l<r){const s=--r,a=e[s],c=--o,u=e[c];t[a.uuid]=l,e[l]=a,t[u.uuid]=s,e[s]=u,e.pop();for(let e=0,t=n;e!==t;++e){const t=i[e],n=t[s],r=t[c];t[l]=n,t[s]=r,t.pop()}}else{const r=--o,s=e[r];r>0&&(t[s.uuid]=l),e[l]=s,e.pop();for(let e=0,t=n;e!==t;++e){const t=i[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(void 0!==n)return r[n];const o=this._paths,s=this._parsedPaths,a=this._objects,l=a.length,c=this.nCachedObjects_,u=new Array(l);n=r.length,i[e]=n,o.push(e),s.push(t),r.push(u);for(let i=c,n=a.length;i!==n;++i){const n=a[i];u[i]=new cu(n,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){const n=this._paths,r=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s];t[e[s]]=i,o[i]=a,o.pop(),r[i]=r[s],r.pop(),n[i]=n[s],n.pop()}}}uu.prototype.isAnimationObjectGroup=!0;class hu{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,o=r.length,s=new Array(o),a={endingStart:V,endingEnd:V};for(let e=0;e!==o;++e){const t=r[e].createInterpolant(null);s[e]=t,t.settings=a}this._interpolantSettings=a,this._interpolants=s,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const i=this._clip.duration,n=e._clip.duration,r=n/i,o=i/n;e.warp(1,r,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,o=this.timeScale;let s=this._timeScaleInterpolant;null===s&&(s=n._lendControlInterpolant(),this._timeScaleInterpolant=s);const a=s.parameterPositions,l=s.sampleValues;return a[0]=r,a[1]=r+i,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const n=(e-r)*i;if(n<0||0===i)return;this._startTime=null,t=i*n}t*=this._updateTimeScale(e);const o=this._updateTime(t),s=this._updateWeight(e);if(s>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===q)for(let i=0,n=e.length;i!==n;++i)e[i].evaluate(o),t[i].accumulateAdditive(s);else for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(o),t[i].accumulate(n,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;null!==i&&(t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const o=2202===i;if(0===e)return-1===r?n:o&&1==(1&r)?t-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),n>=t||n<0){const i=Math.floor(n/t);n-=t*i,r+=Math.abs(i);const s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){const t=e<0;this._setEndings(t,!t,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(o&&1==(1&r))return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=G,n.endingEnd=G):(n.endingStart=e?this.zeroSlopeAtStart?G:V:H,n.endingEnd=t?this.zeroSlopeAtEnd?G:V:H)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);const s=o.parameterPositions,a=o.sampleValues;return s[0]=r,a[0]=t,s[1]=r+e,a[1]=i,this}}class pu extends ne{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,o=e._propertyBindings,s=e._interpolants,a=i.uuid,l=this._bindingsByRootAndName;let c=l[a];void 0===c&&(c={},l[a]=c);for(let e=0;e!==r;++e){const r=n[e],l=r.name;let u=c[l];if(void 0!==u)o[e]=u;else{if(void 0!==(u=o[e])){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,a,l));continue}const n=t&&t._propertyBindings[e].binding.parsedPath;++(u=new Kc(cu.create(i,l,n),r.ValueTypeName,r.getValueSize())).referenceCount,this._addInactiveBinding(u,a,l),o[e]=u}s[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,t)}const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,r=this._actionsByClip;let o=r[t];if(void 0===o)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const t=o.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=n.length,n.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,s=o[r],a=s.knownActions,l=a[a.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,a[c]=l,a.pop(),e._byClipCacheIndex=null,delete s.actionByRoot[(e._localRoot||this._root).uuid],0===a.length&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let o=n[t];void 0===o&&(o={},n[t]=o),o[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,o=this._bindingsByRootAndName,s=o[n],a=t[t.length-1],l=e._cacheIndex;a._cacheIndex=l,t[l]=a,t.pop(),delete s[r],0===Object.keys(s).length&&delete o[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return void 0===i&&((i=new kl(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let o="string"==typeof e?Gl.findByName(n,e):e;const s=null!==o?o.uuid:e,a=this._actionsByClip[s];let l=null;if(void 0===i&&(i=null!==o?o.blendMode:W),void 0!==a){const e=a.actionByRoot[r];if(void 0!==e&&e.blendMode===i)return e;l=a.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const c=new hu(this,o,t,i);return this._bindAction(c,l),this._addInactiveAction(c,s,r),c}existingAction(e,t){const i=t||this._root,n=i.uuid,r="string"==typeof e?Gl.findByName(i,e):e,o=r?r.uuid:e,s=this._actionsByClip[o];return void 0!==s&&s.actionByRoot[n]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let s=0;s!==i;++s)t[s]._update(n,e,r,o);const s=this._bindings,a=this._nActiveBindings;for(let e=0;e!==a;++e)s[e].apply(o);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const e=r.knownActions;for(let i=0,n=e.length;i!==n;++i){const n=e[i];this._deactivateAction(n);const r=n._cacheIndex,o=t[t.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,o._cacheIndex=r,t[r]=o,t.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const e in i){const n=i[e].actionByRoot[t];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[t];if(void 0!==n)for(const e in n){const t=n[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}pu.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class du{constructor(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new du(void 0===this.value.clone?this.value:this.value.clone())}}class fu extends $o{constructor(e,t,i=1){super(e,t),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}fu.prototype.isInstancedInterleavedBuffer=!0;class mu{constructor(e,t,i,n,r){this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}function gu(e,t){return e.distance-t.distance}function _u(e,t,i,n){if(e.layers.test(t.layers)&&e.raycast(t,i),!0===n){const n=e.children;for(let e=0,r=n.length;e<r;e++)_u(n[e],t,i,!0)}}mu.prototype.isGLBufferAttribute=!0;const yu=new ge;class vu{constructor(e=new ge(1/0,1/0),t=new ge(-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=yu.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return yu.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}vu.prototype.isBox2=!0;const xu=new Ce,bu=new Ce;class wu{constructor(e=new Ce,t=new Ce){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){xu.subVectors(e,this.start),bu.subVectors(this.end,this.start);const i=bu.dot(bu);let n=bu.dot(xu)/i;return t&&(n=ce(n,0,1)),n}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}class Mu extends It{constructor(e){super(),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}}Mu.prototype.isImmediateRenderObject=!0;const Tu=new Ce,Su=new Ce,Eu=new ot,Au=new ot;class Cu extends js{constructor(e){const t=function e(t){const i=[];t&&t.isBone&&i.push(t);for(let n=0;n<t.children.length;n++)i.push.apply(i,e(t.children[n]));return i}(e),i=new bi,n=[],r=[],o=new Yt(0,0,1),s=new Yt(0,1,0);for(let e=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(o.r,o.g,o.b),r.push(s.r,s.g,s.b))}i.setAttribute("position",new ci(n,3)),i.setAttribute("color",new ci(r,3)),super(i,new Rs({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");Au.copy(this.root.matrixWorld).invert();for(let e=0,i=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(Eu.multiplyMatrices(Au,r.matrixWorld),Su.setFromMatrixPosition(Eu),n.setXYZ(i,Su.x,Su.y,Su.z),Eu.multiplyMatrices(Au,r.parent.matrixWorld),Su.setFromMatrixPosition(Eu),n.setXYZ(i+1,Su.x,Su.y,Su.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}const Lu=new Ce,Iu=new Yt,Pu=new Yt;class Ru extends js{constructor(e=10,t=10,i=4473924,n=8947848){i=new Yt(i),n=new Yt(n);const r=t/2,o=e/t,s=e/2,a=[],l=[];for(let e=0,c=0,u=-s;e<=t;e++,u+=o){a.push(-s,0,u,s,0,u),a.push(u,0,-s,u,0,s);const t=e===r?i:n;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new bi;c.setAttribute("position",new ci(a,3)),c.setAttribute("color",new ci(l,3)),super(c,new Rs({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}const ku=new Ce,zu=new Ce,Du=new Ce,Ou=new Ce,Fu=new qi;function Bu(e,t,i,n,r,o,s){Ou.set(r,o,s).unproject(n);const a=t[e];if(void 0!==a){const e=i.getAttribute("position");for(let t=0,i=a.length;t<i;t++)e.setXYZ(a[t],Ou.x,Ou.y,Ou.z)}}const Nu=new Pe;class Uu extends js{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new bi;r.setIndex(new ei(i,1)),r.setAttribute("position",new ei(n,3)),super(r,new Rs({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Nu.setFromObject(this.object),Nu.isEmpty())return;const t=Nu.min,i=Nu.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=t.x,r[4]=i.y,r[5]=i.z,r[6]=t.x,r[7]=t.y,r[8]=i.z,r[9]=i.x,r[10]=t.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=t.z,r[15]=t.x,r[16]=i.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=i.x,r[22]=t.y,r[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e){return js.prototype.copy.call(this,e),this.object=e.object,this}}const ju=new Ce;let Vu,Gu;class Hu extends js{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=new bi;i.setAttribute("position",new ci(t,3)),i.setAttribute("color",new ci([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new Rs({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,i){const n=new Yt,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}const Wu=new Float32Array(1),qu=new Int32Array(Wu.buffer);ua.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(ua.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},ic.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},Ru.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},Cu.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Zl.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Tc.extractUrlBase(e)},Zl.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},vu.prototype.center=function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},vu.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},vu.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},vu.prototype.size=function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)},Pe.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Pe.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Pe.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Pe.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},Pe.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},Ye.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},rn.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},wu.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},_e.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},_e.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},_e.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},_e.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},_e.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},_e.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},ot.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},ot.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},ot.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Ce).setFromMatrixColumn(this,3)},ot.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},ot.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},ot.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ot.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ot.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},ot.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},ot.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ot.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},ot.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},ot.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},ot.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},ot.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},ot.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ot.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},ot.prototype.makeFrustum=function(e,t,i,n,r,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,n,i,r,o)},ot.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},en.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Ae.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Ae.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},rt.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},rt.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},rt.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},jt.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},jt.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},jt.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},jt.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},jt.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},jt.barycoordFromPoint=function(e,t,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),jt.getBarycoord(e,t,i,n,r)},jt.normal=function(e,t,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),jt.getNormal(e,t,i,n)},nc.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},nc.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new nl(this,e)},nc.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new ul(this,e)},ge.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},ge.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},ge.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Ce.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},Ce.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},Ce.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},Ce.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},Ce.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},Ce.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},Ce.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},Ce.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Ce.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Me.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},Me.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},It.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},It.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},It.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},It.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},It.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(It.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Ni.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(Ni.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),xs.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},$i.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(rc.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(ei.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===te},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(te)}}}),ei.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?te:ee),this},ei.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},ei.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},bi.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},bi.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new ei(arguments[1],arguments[2])))},bi.prototype.addDrawCall=function(e,t,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},bi.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},bi.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},bi.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},bi.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(bi.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),$o.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?te:ee),this},$o.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},nl.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},nl.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},nl.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},qo.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},du.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(Gt.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Yt}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}}),Object.defineProperties(Wi.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Vo.prototype.clearTarget=function(e,t,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,i,n)},Vo.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},Vo.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},Vo.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},Vo.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},Vo.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},Vo.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},Vo.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},Vo.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},Vo.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},Vo.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},Vo.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},Vo.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},Vo.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},Vo.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},Vo.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},Vo.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},Vo.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},Vo.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},Vo.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},Vo.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},Vo.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},Vo.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},Vo.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},Vo.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(Vo.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?Z:$}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Ro.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Te.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),$c.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new Oc).load(e,(function(e){t.setBuffer(e)})),this},Qc.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Zi.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},Zi.prototype.clear=function(e,t,i,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,i,n)},ve.crossOrigin=void 0,ve.loadTexture=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new ec;r.setCrossOrigin(this.crossOrigin);const o=r.load(e,i,void 0,n);return t&&(o.mapping=t),o},ve.loadTextureCube=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new Ql;r.setCrossOrigin(this.crossOrigin);const o=r.load(e,i,void 0,n);return t&&(o.mapping=t),o},ve.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ve.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};const $u={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t),e.ACESFilmicToneMapping=4,e.AddEquation=i,e.AddOperation=2,e.AdditiveAnimationBlendMode=q,e.AdditiveBlending=2,e.AlphaFormat=1021,e.AlwaysDepth=1,e.AlwaysStencilFunc=519,e.AmbientLight=vc,e.AmbientLightProbe=Bc,e.AnimationClip=Gl,e.AnimationLoader=class extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Yl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e){const t=[];for(let i=0;i<e.length;i++){const n=Gl.parse(e[i]);t.push(n)}return t}},e.AnimationMixer=pu,e.AnimationObjectGroup=uu,e.AnimationUtils=Il,e.ArcCurve=pa,e.ArrayCamera=Oo,e.ArrowHelper=class extends It{constructor(e=new Ce(0,0,1),t=new Ce(0,0,0),i=1,n=16776960,r=.2*i,o=.2*r){super(),this.type="ArrowHelper",void 0===Vu&&((Vu=new bi).setAttribute("position",new ci([0,0,0,0,1,0],3)),(Gu=new ta(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new Bs(Vu,new Rs({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ni(Gu,new Jt({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,r,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ju.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ju,t)}}setLength(e,t=.2*e,i=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}},e.Audio=$c,e.AudioAnalyser=Qc,e.AudioContext=Dc,e.AudioListener=class extends It{constructor(){super(),this.type="AudioListener",this.context=Dc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new jc}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Gc,Hc,Wc),qc.set(0,0,-1).applyQuaternion(Hc),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Gc.x,e),t.positionY.linearRampToValueAtTime(Gc.y,e),t.positionZ.linearRampToValueAtTime(Gc.z,e),t.forwardX.linearRampToValueAtTime(qc.x,e),t.forwardY.linearRampToValueAtTime(qc.y,e),t.forwardZ.linearRampToValueAtTime(qc.z,e),t.upX.linearRampToValueAtTime(i.x,e),t.upY.linearRampToValueAtTime(i.y,e),t.upZ.linearRampToValueAtTime(i.z,e)}else t.setPosition(Gc.x,Gc.y,Gc.z),t.setOrientation(qc.x,qc.y,qc.z,i.x,i.y,i.z)}},e.AudioLoader=Oc,e.AxesHelper=Hu,e.AxisHelper=function(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Hu(e)},e.BackSide=1,e.BasicDepthPacking=3200,e.BasicShadowMap=0,e.BinaryTextureLoader=function(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Kl(e)},e.Bone=bs,e.BooleanKeyframeTrack=Ol,e.BoundingBoxHelper=function(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Uu(e,t)},e.Box2=vu,e.Box3=Pe,e.Box3Helper=class extends js{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new bi;n.setIndex(new ei(i,1)),n.setAttribute("position",new ci([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new Rs({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}},e.BoxBufferGeometry=ji,e.BoxGeometry=ji,e.BoxHelper=Uu,e.BufferAttribute=ei,e.BufferGeometry=bi,e.BufferGeometryLoader=Ec,e.ByteType=1010,e.Cache=Wl,e.Camera=qi,e.CameraHelper=class extends js{constructor(e){const t=new bi,i=new Rs({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],o={},s=new Yt(16755200),a=new Yt(16711680),l=new Yt(43775),c=new Yt(16777215),u=new Yt(3355443);function h(e,t,i){p(e,i),p(t,i)}function p(e,t){n.push(0,0,0),r.push(t.r,t.g,t.b),void 0===o[e]&&(o[e]=[]),o[e].push(n.length/3-1)}h("n1","n2",s),h("n2","n4",s),h("n4","n3",s),h("n3","n1",s),h("f1","f2",s),h("f2","f4",s),h("f4","f3",s),h("f3","f1",s),h("n1","f1",s),h("n2","f2",s),h("n3","f3",s),h("n4","f4",s),h("p","n1",a),h("p","n2",a),h("p","n3",a),h("p","n4",a),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",c),h("p","c",u),h("cn1","cn2",u),h("cn3","cn4",u),h("cf1","cf2",u),h("cf3","cf4",u),t.setAttribute("position",new ci(n,3)),t.setAttribute("color",new ci(r,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){const e=this.geometry,t=this.pointMap;Fu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Bu("c",t,e,Fu,0,0,-1),Bu("t",t,e,Fu,0,0,1),Bu("n1",t,e,Fu,-1,-1,-1),Bu("n2",t,e,Fu,1,-1,-1),Bu("n3",t,e,Fu,-1,1,-1),Bu("n4",t,e,Fu,1,1,-1),Bu("f1",t,e,Fu,-1,-1,1),Bu("f2",t,e,Fu,1,-1,1),Bu("f3",t,e,Fu,-1,1,1),Bu("f4",t,e,Fu,1,1,1),Bu("u1",t,e,Fu,.7,1.1,-1),Bu("u2",t,e,Fu,-.7,1.1,-1),Bu("u3",t,e,Fu,0,2,-1),Bu("cf1",t,e,Fu,-1,0,1),Bu("cf2",t,e,Fu,1,0,1),Bu("cf3",t,e,Fu,0,-1,1),Bu("cf4",t,e,Fu,0,1,1),Bu("cn1",t,e,Fu,-1,0,-1),Bu("cn2",t,e,Fu,1,0,-1),Bu("cn3",t,e,Fu,0,-1,-1),Bu("cn4",t,e,Fu,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},e.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},e.CanvasTexture=Qs,e.CatmullRomCurve3=ya,e.CineonToneMapping=3,e.CircleBufferGeometry=ea,e.CircleGeometry=ea,e.ClampToEdgeWrapping=h,e.Clock=jc,e.Color=Yt,e.ColorKeyframeTrack=Fl,e.CompressedTexture=Js,e.CompressedTextureLoader=class extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=[],s=new Js,a=new Yl(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let l=0;function c(c){a.load(e[c],(function(e){const i=r.parse(e,!0);o[c]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},6===(l+=1)&&(1===i.mipmapCount&&(s.minFilter=g),s.image=o,s.format=i.format,s.needsUpdate=!0,t&&t(s))}),i,n)}if(Array.isArray(e))for(let t=0,i=e.length;t<i;++t)c(t);else a.load(e,(function(e){const i=r.parse(e,!0);if(i.isCubemap){const e=i.mipmaps.length/i.mipmapCount;for(let t=0;t<e;t++){o[t]={mipmaps:[]};for(let e=0;e<i.mipmapCount;e++)o[t].mipmaps.push(i.mipmaps[t*i.mipmapCount+e]),o[t].format=i.format,o[t].width=i.width,o[t].height=i.height}s.image=o}else s.image.width=i.width,s.image.height=i.height,s.mipmaps=i.mipmaps;1===i.mipmapCount&&(s.minFilter=g),s.format=i.format,s.needsUpdate=!0,t&&t(s)}),i,n);return s}},e.ConeBufferGeometry=ia,e.ConeGeometry=ia,e.CubeCamera=Zi,e.CubeReflectionMapping=r,e.CubeRefractionMapping=o,e.CubeTexture=Xi,e.CubeTextureLoader=Ql,e.CubeUVReflectionMapping=l,e.CubeUVRefractionMapping=c,e.CubicBezierCurve=wa,e.CubicBezierCurve3=Ma,e.CubicInterpolant=Rl,e.CullFaceBack=1,e.CullFaceFront=2,e.CullFaceFrontBack=3,e.CullFaceNone=0,e.Curve=ua,e.CurvePath=tc,e.CustomBlending=5,e.CustomToneMapping=5,e.CylinderBufferGeometry=ta,e.CylinderGeometry=ta,e.Cylindrical=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return(new this.constructor).copy(this)}},e.DataTexture=ws,e.DataTexture2DArray=$n,e.DataTexture3D=Zn,e.DataTextureLoader=Kl,e.DataUtils=class{static toHalfFloat(e){Wu[0]=e;const t=qu[0];let i=t>>16&32768,n=t>>12&2047;const r=t>>23&255;return r<103?i:r>142?(i|=31744,i|=(255==r?0:1)&&8388607&t):r<113?i|=((n|=2048)>>114-r)+(n>>113-r&1):(i|=r-112<<10|n>>1,i+=1&n)}},e.DecrementStencilOp=7683,e.DecrementWrapStencilOp=34056,e.DefaultLoadingManager=$l,e.DepthFormat=A,e.DepthStencilFormat=C,e.DepthTexture=Ks,e.DirectionalLight=yc,e.DirectionalLightHelper=class extends It{constructor(e,t,i){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===t&&(t=1);let n=new bi;n.setAttribute("position",new ci([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Rs({fog:!1,toneMapped:!1});this.lightPlane=new Bs(n,r),this.add(this.lightPlane),(n=new bi).setAttribute("position",new ci([0,0,0,0,0,1],3)),this.targetLine=new Bs(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){ku.setFromMatrixPosition(this.light.matrixWorld),zu.setFromMatrixPosition(this.light.target.matrixWorld),Du.subVectors(zu,ku),this.lightPlane.lookAt(zu),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(zu),this.targetLine.scale.z=Du.length()}},e.DiscreteInterpolant=zl,e.DodecahedronBufferGeometry=ra,e.DodecahedronGeometry=ra,e.DoubleSide=2,e.DstAlphaFactor=206,e.DstColorFactor=208,e.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new ei(e,t).setUsage(te)},e.DynamicCopyUsage=35050,e.DynamicDrawUsage=te,e.DynamicReadUsage=35049,e.EdgesGeometry=ca,e.EdgesHelper=function(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new js(new ca(e.geometry),new Rs({color:void 0!==t?t:16777215}))},e.EllipseCurve=ha,e.EqualDepth=4,e.EqualStencilFunc=514,e.EquirectangularReflectionMapping=s,e.EquirectangularRefractionMapping=a,e.Euler=mt,e.EventDispatcher=ne,e.ExtrudeBufferGeometry=nl,e.ExtrudeGeometry=nl,e.FaceColors=1,e.FileLoader=Yl,e.FlatShading=1,e.Float16BufferAttribute=li,e.Float32Attribute=function(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new ci(e,t)},e.Float32BufferAttribute=ci,e.Float64Attribute=function(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new ui(e,t)},e.Float64BufferAttribute=ui,e.FloatType=w,e.Fog=Wo,e.FogExp2=Ho,e.Font=Rc,e.FontLoader=class extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Yl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(e){let i;try{i=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(e.substring(65,e.length-2))}const n=r.parse(i);t&&t(n)}),i,n)}parse(e){return new Rc(e)}},e.FrontSide=0,e.Frustum=rn,e.GLBufferAttribute=mu,e.GLSL1="100",e.GLSL3=ie,e.GammaEncoding=X,e.GreaterDepth=6,e.GreaterEqualDepth=5,e.GreaterEqualStencilFunc=518,e.GreaterStencilFunc=516,e.GridHelper=Ru,e.Group=Fo,e.HalfFloatType=M,e.HemisphereLight=oc,e.HemisphereLightHelper=class extends It{constructor(e,t,i){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;const n=new al(t);n.rotateY(.5*Math.PI),this.material=new Jt({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),o=new Float32Array(3*r.count);n.setAttribute("color",new ei(o,3)),this.add(new Ni(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Iu.copy(this.light.color),Pu.copy(this.light.groundColor);for(let e=0,i=t.count;e<i;e++){const n=e<i/2?Iu:Pu;t.setXYZ(e,n.r,n.g,n.b)}t.needsUpdate=!0}e.lookAt(Lu.setFromMatrixPosition(this.light.matrixWorld).negate())}},e.HemisphereLightProbe=Fc,e.IcosahedronBufferGeometry=ol,e.IcosahedronGeometry=ol,e.ImageBitmapLoader=Ic,e.ImageLoader=Jl,e.ImageUtils=ve,e.ImmediateRenderObject=Mu,e.IncrementStencilOp=7682,e.IncrementWrapStencilOp=34055,e.InstancedBufferAttribute=Es,e.InstancedBufferGeometry=Sc,e.InstancedInterleavedBuffer=fu,e.InstancedMesh=Ps,e.Int16Attribute=function(e,t){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new ri(e,t)},e.Int16BufferAttribute=ri,e.Int32Attribute=function(e,t){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new si(e,t)},e.Int32BufferAttribute=si,e.Int8Attribute=function(e,t){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ti(e,t)},e.Int8BufferAttribute=ti,e.IntType=1013,e.InterleavedBuffer=$o,e.InterleavedBufferAttribute=Xo,e.Interpolant=Pl,e.InterpolateDiscrete=N,e.InterpolateLinear=U,e.InterpolateSmooth=j,e.InvertStencilOp=5386,e.JSONLoader=function(){console.error("THREE.JSONLoader has been removed.")},e.KeepStencilOp=7680,e.KeyframeTrack=Dl,e.LOD=fs,e.LatheBufferGeometry=sl,e.LatheGeometry=sl,e.Layers=gt,e.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")},e.LessDepth=2,e.LessEqualDepth=3,e.LessEqualStencilFunc=515,e.LessStencilFunc=513,e.Light=rc,e.LightProbe=wc,e.Line=Bs,e.Line3=wu,e.LineBasicMaterial=Rs,e.LineCurve=Ta,e.LineCurve3=Sa,e.LineDashedMaterial=Cl,e.LineLoop=Vs,e.LinePieces=1,e.LineSegments=js,e.LineStrip=0,e.LinearEncoding=$,e.LinearFilter=g,e.LinearInterpolant=kl,e.LinearMipMapLinearFilter=1008,e.LinearMipMapNearestFilter=1007,e.LinearMipmapLinearFilter=y,e.LinearMipmapNearestFilter=_,e.LinearToneMapping=1,e.Loader=Zl,e.LoaderUtils=Tc,e.LoadingManager=ql,e.LogLuvEncoding=3003,e.LoopOnce=2200,e.LoopPingPong=2202,e.LoopRepeat=2201,e.LuminanceAlphaFormat=1025,e.LuminanceFormat=1024,e.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},e.Material=Gt,e.MaterialLoader=Mc,e.Math=me,e.MathUtils=me,e.Matrix3=_e,e.Matrix4=ot,e.MaxEquation=104,e.Mesh=Ni,e.MeshBasicMaterial=Jt,e.MeshDepthMaterial=Io,e.MeshDistanceMaterial=Po,e.MeshFaceMaterial=function(e){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),e},e.MeshLambertMaterial=El,e.MeshMatcapMaterial=Al,e.MeshNormalMaterial=Sl,e.MeshPhongMaterial=Ml,e.MeshPhysicalMaterial=wl,e.MeshStandardMaterial=bl,e.MeshToonMaterial=Tl,e.MinEquation=103,e.MirroredRepeatWrapping=p,e.MixOperation=1,e.MultiMaterial=function(e=[]){return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,e.materials=e,e.clone=function(){return e.slice()},e},e.MultiplyBlending=4,e.MultiplyOperation=0,e.NearestFilter=d,e.NearestMipMapLinearFilter=1005,e.NearestMipMapNearestFilter=1004,e.NearestMipmapLinearFilter=m,e.NearestMipmapNearestFilter=f,e.NeverDepth=0,e.NeverStencilFunc=512,e.NoBlending=0,e.NoColors=0,e.NoToneMapping=0,e.NormalAnimationBlendMode=W,e.NormalBlending=1,e.NotEqualDepth=7,e.NotEqualStencilFunc=517,e.NumberKeyframeTrack=Bl,e.Object3D=It,e.ObjectLoader=class extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=""===this.path?Tc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const s=new Yl(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(i){let o=null;try{o=JSON.parse(i)}catch(t){return void 0!==n&&n(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}const s=o.metadata;void 0!==s&&void 0!==s.type&&"geometry"!==s.type.toLowerCase()?r.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e)}),i,n)}async loadAsync(e,t){const i=""===this.path?Tc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const n=new Yl(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(e,t),o=JSON.parse(r),s=o.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),o=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),s=this.parseTextures(e.textures,o),a=this.parseMaterials(e.materials,s),l=this.parseObject(e.object,r,a,s,i),c=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,c),void 0!==t){let e=!1;for(const t in o)if(o[t]instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),s=this.parseMaterials(e.materials,o),a=this.parseObject(e.object,n,s,o,t),l=this.parseSkeletons(e.skeletons,a);return this.bindSkeletons(a,l),a}parseShapes(e){const t={};if(void 0!==e)for(let i=0,n=e.length;i<n;i++){const n=(new nc).fromJSON(e[i]);t[n.uuid]=n}return t}parseSkeletons(e,t){const i={},n={};if(t.traverse((function(e){e.isBone&&(n[e.uuid]=e)})),void 0!==e)for(let t=0,r=e.length;t<r;t++){const r=(new Ss).fromJSON(e[t],n);i[r.uuid]=r}return i}parseGeometries(e,t){const i={};if(void 0!==e){const n=new Ec;for(let r=0,o=e.length;r<o;r++){let o;const s=e[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":o=n.parse(s);break;case"Geometry":console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:s.type in vl?o=vl[s.type].fromJSON(s,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${s.type}"`)}o.uuid=s.uuid,void 0!==s.name&&(o.name=s.name),!0===o.isBufferGeometry&&void 0!==s.userData&&(o.userData=s.userData),i[s.uuid]=o}}return i}parseMaterials(e,t){const i={},n={};if(void 0!==e){const r=new Mc;r.setTextures(t);for(let t=0,o=e.length;t<o;t++){const o=e[t];if("MultiMaterial"===o.type){const e=[];for(let t=0;t<o.materials.length;t++){const n=o.materials[t];void 0===i[n.uuid]&&(i[n.uuid]=r.parse(n)),e.push(i[n.uuid])}n[o.uuid]=e}else void 0===i[o.uuid]&&(i[o.uuid]=r.parse(o)),n[o.uuid]=i[o.uuid]}}return n}parseAnimations(e){const t={};if(void 0!==e)for(let i=0;i<e.length;i++){const n=e[i],r=Gl.parse(n);t[r.uuid]=r}return t}parseImages(e,t){const i=this,n={};let r;function o(e){if("string"==typeof e){const t=e;return function(e){return i.manager.itemStart(e),r.load(e,(function(){i.manager.itemEnd(e)}),void 0,(function(){i.manager.itemError(e),i.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:i.resourcePath+t)}return e.data?{data:di(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const i=new ql(t);(r=new Jl(i)).setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){const i=e[t],r=i.url;if(Array.isArray(r)){n[i.uuid]=[];for(let e=0,t=r.length;e<t;e++){const t=o(r[e]);null!==t&&(t instanceof HTMLImageElement?n[i.uuid].push(t):n[i.uuid].push(new ws(t.data,t.width,t.height)))}}else{const e=o(i.url);null!==e&&(n[i.uuid]=e)}}}return n}async parseImagesAsync(e){const t=this,i={};let n;async function r(e){if("string"==typeof e){const i=e,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:t.resourcePath+i;return await n.loadAsync(r)}return e.data?{data:di(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){(n=new Jl(this.manager)).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){const n=e[t],o=n.url;if(Array.isArray(o)){i[n.uuid]=[];for(let e=0,t=o.length;e<t;e++){const t=o[e],s=await r(t);null!==s&&(s instanceof HTMLImageElement?i[n.uuid].push(s):i[n.uuid].push(new ws(s.data,s.width,s.height)))}}else{const e=await r(n.url);null!==e&&(i[n.uuid]=e)}}}return i}parseTextures(e,t){function i(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const n={};if(void 0!==e)for(let r=0,o=e.length;r<o;r++){const o=e[r];let s;void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===t[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const a=t[o.image];Array.isArray(a)?(s=new Xi(a),6===a.length&&(s.needsUpdate=!0)):(s=a&&a.data?new ws(a.data,a.width,a.height):new be(a),a&&(s.needsUpdate=!0)),s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),void 0!==o.mapping&&(s.mapping=i(o.mapping,Ac)),void 0!==o.offset&&s.offset.fromArray(o.offset),void 0!==o.repeat&&s.repeat.fromArray(o.repeat),void 0!==o.center&&s.center.fromArray(o.center),void 0!==o.rotation&&(s.rotation=o.rotation),void 0!==o.wrap&&(s.wrapS=i(o.wrap[0],Cc),s.wrapT=i(o.wrap[1],Cc)),void 0!==o.format&&(s.format=o.format),void 0!==o.type&&(s.type=o.type),void 0!==o.encoding&&(s.encoding=o.encoding),void 0!==o.minFilter&&(s.minFilter=i(o.minFilter,Lc)),void 0!==o.magFilter&&(s.magFilter=i(o.magFilter,Lc)),void 0!==o.anisotropy&&(s.anisotropy=o.anisotropy),void 0!==o.flipY&&(s.flipY=o.flipY),void 0!==o.premultiplyAlpha&&(s.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(s.unpackAlignment=o.unpackAlignment),n[o.uuid]=s}return n}parseObject(e,t,i,n,r){let o,s,a;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function c(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),t.push(i[r])}return t}return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),i[e]}}function u(e){return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),n[e]}switch(e.type){case"Scene":o=new qo,void 0!==e.background&&(Number.isInteger(e.background)?o.background=new Yt(e.background):o.background=u(e.background)),void 0!==e.environment&&(o.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?o.fog=new Wo(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(o.fog=new Ho(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new $i(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(o.focus=e.focus),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.filmGauge&&(o.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(o.filmOffset=e.filmOffset),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new _n(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new vc(e.color,e.intensity);break;case"DirectionalLight":o=new yc(e.color,e.intensity);break;case"PointLight":o=new gc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new xc(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new hc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new oc(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=(new wc).fromJSON(e);break;case"SkinnedMesh":s=l(e.geometry),a=c(e.material),o=new xs(s,a),void 0!==e.bindMode&&(o.bindMode=e.bindMode),void 0!==e.bindMatrix&&o.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(o.skeleton=e.skeleton);break;case"Mesh":s=l(e.geometry),a=c(e.material),o=new Ni(s,a);break;case"InstancedMesh":s=l(e.geometry),a=c(e.material);const t=e.count,i=e.instanceMatrix,n=e.instanceColor;(o=new Ps(s,a,t)).instanceMatrix=new Es(new Float32Array(i.array),16),void 0!==n&&(o.instanceColor=new Es(new Float32Array(n.array),n.itemSize));break;case"LOD":o=new fs;break;case"Line":o=new Bs(l(e.geometry),c(e.material));break;case"LineLoop":o=new Vs(l(e.geometry),c(e.material));break;case"LineSegments":o=new js(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new Zs(l(e.geometry),c(e.material));break;case"Sprite":o=new us(c(e.material));break;case"Group":o=new Fo;break;case"Bone":o=new bs;break;default:o=new It}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(o.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(o.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.frustumCulled&&(o.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(o.renderOrder=e.renderOrder),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.layers&&(o.layers.mask=e.layers),void 0!==e.children){const s=e.children;for(let e=0;e<s.length;e++)o.add(this.parseObject(s[e],t,i,n,r))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const i=t[e];o.animations.push(r[i])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(o.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const i=t[e],n=o.getObjectByProperty("uuid",i.object);void 0!==n&&o.addLevel(n,i.distance)}}return o}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){const i=t[e.skeleton];void 0===i?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(i,e.bindMatrix)}}))}setTexturePath(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}},e.ObjectSpaceNormalMap=1,e.OctahedronBufferGeometry=al,e.OctahedronGeometry=al,e.OneFactor=201,e.OneMinusDstAlphaFactor=207,e.OneMinusDstColorFactor=209,e.OneMinusSrcAlphaFactor=205,e.OneMinusSrcColorFactor=203,e.OrthographicCamera=_n,e.PCFShadowMap=1,e.PCFSoftShadowMap=2,e.PMREMGenerator=Rn,e.ParametricBufferGeometry=ll,e.ParametricGeometry=ll,e.Particle=function(e){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new us(e)},e.ParticleBasicMaterial=function(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new Gs(e)},e.ParticleSystem=function(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new Zs(e,t)},e.ParticleSystemMaterial=function(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new Gs(e)},e.Path=ic,e.PerspectiveCamera=$i,e.Plane=en,e.PlaneBufferGeometry=an,e.PlaneGeometry=an,e.PlaneHelper=class extends Bs{constructor(e,t=1,i=16776960){const n=i,r=new bi;r.setAttribute("position",new ci([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),r.computeBoundingSphere(),super(r,new Rs({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=new bi;o.setAttribute("position",new ci([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),o.computeBoundingSphere(),this.add(new Ni(o,new Jt({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?1:0,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}},e.PointCloud=function(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new Zs(e,t)},e.PointCloudMaterial=function(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new Gs(e)},e.PointLight=gc,e.PointLightHelper=class extends Ni{constructor(e,t,i){super(new hl(t,4,2),new Jt({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},e.Points=Zs,e.PointsMaterial=Gs,e.PolarGridHelper=class extends js{constructor(e=10,t=16,i=8,n=64,r=4473924,o=8947848){r=new Yt(r),o=new Yt(o);const s=[],a=[];for(let i=0;i<=t;i++){const n=i/t*(2*Math.PI),l=Math.sin(n)*e,c=Math.cos(n)*e;s.push(0,0,0),s.push(l,0,c);const u=1&i?r:o;a.push(u.r,u.g,u.b),a.push(u.r,u.g,u.b)}for(let t=0;t<=i;t++){const l=1&t?r:o,c=e-e/i*t;for(let e=0;e<n;e++){let t=e/n*(2*Math.PI),i=Math.sin(t)*c,r=Math.cos(t)*c;s.push(i,0,r),a.push(l.r,l.g,l.b),t=(e+1)/n*(2*Math.PI),i=Math.sin(t)*c,r=Math.cos(t)*c,s.push(i,0,r),a.push(l.r,l.g,l.b)}}const l=new bi;l.setAttribute("position",new ci(s,3)),l.setAttribute("color",new ci(a,3)),super(l,new Rs({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}},e.PolyhedronBufferGeometry=na,e.PolyhedronGeometry=na,e.PositionalAudio=class extends $c{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Zc,Xc,Yc),Jc.set(0,0,1).applyQuaternion(Xc);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Zc.x,e),t.positionY.linearRampToValueAtTime(Zc.y,e),t.positionZ.linearRampToValueAtTime(Zc.z,e),t.orientationX.linearRampToValueAtTime(Jc.x,e),t.orientationY.linearRampToValueAtTime(Jc.y,e),t.orientationZ.linearRampToValueAtTime(Jc.z,e)}else t.setPosition(Zc.x,Zc.y,Zc.z),t.setOrientation(Jc.x,Jc.y,Jc.z)}},e.PropertyBinding=cu,e.PropertyMixer=Kc,e.QuadraticBezierCurve=Ea,e.QuadraticBezierCurve3=Aa,e.Quaternion=Ae,e.QuaternionKeyframeTrack=Ul,e.QuaternionLinearInterpolant=Nl,e.REVISION=t,e.RGBADepthPacking=3201,e.RGBAFormat=E,e.RGBAIntegerFormat=1033,e.RGBA_ASTC_10x10_Format=37819,e.RGBA_ASTC_10x5_Format=37816,e.RGBA_ASTC_10x6_Format=37817,e.RGBA_ASTC_10x8_Format=37818,e.RGBA_ASTC_12x10_Format=37820,e.RGBA_ASTC_12x12_Format=37821,e.RGBA_ASTC_4x4_Format=37808,e.RGBA_ASTC_5x4_Format=37809,e.RGBA_ASTC_5x5_Format=37810,e.RGBA_ASTC_6x5_Format=37811,e.RGBA_ASTC_6x6_Format=37812,e.RGBA_ASTC_8x5_Format=37813,e.RGBA_ASTC_8x6_Format=37814,e.RGBA_ASTC_8x8_Format=37815,e.RGBA_BPTC_Format=36492,e.RGBA_ETC2_EAC_Format=B,e.RGBA_PVRTC_2BPPV1_Format=O,e.RGBA_PVRTC_4BPPV1_Format=D,e.RGBA_S3TC_DXT1_Format=I,e.RGBA_S3TC_DXT3_Format=P,e.RGBA_S3TC_DXT5_Format=R,e.RGBDEncoding=K,e.RGBEEncoding=Y,e.RGBEFormat=1023,e.RGBFormat=S,e.RGBIntegerFormat=1032,e.RGBM16Encoding=Q,e.RGBM7Encoding=J,e.RGB_ETC1_Format=36196,e.RGB_ETC2_Format=F,e.RGB_PVRTC_2BPPV1_Format=z,e.RGB_PVRTC_4BPPV1_Format=k,e.RGB_S3TC_DXT1_Format=L,e.RGFormat=1030,e.RGIntegerFormat=1031,e.RawShaderMaterial=yn,e.Ray=rt,e.Raycaster=class{constructor(e,t,i=0,n=1/0){this.ray=new rt(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new gt,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!1,i=[]){return _u(e,this,i,t),i.sort(gu),i}intersectObjects(e,t=!1,i=[]){for(let n=0,r=e.length;n<r;n++)_u(e[n],this,i,t);return i.sort(gu),i}},e.RectAreaLight=xc,e.RedFormat=1028,e.RedIntegerFormat=1029,e.ReinhardToneMapping=2,e.RepeatWrapping=u,e.ReplaceStencilOp=7681,e.ReverseSubtractEquation=102,e.RingBufferGeometry=cl,e.RingGeometry=cl,e.SRGB8_ALPHA8_ASTC_10x10_Format=37851,e.SRGB8_ALPHA8_ASTC_10x5_Format=37848,e.SRGB8_ALPHA8_ASTC_10x6_Format=37849,e.SRGB8_ALPHA8_ASTC_10x8_Format=37850,e.SRGB8_ALPHA8_ASTC_12x10_Format=37852,e.SRGB8_ALPHA8_ASTC_12x12_Format=37853,e.SRGB8_ALPHA8_ASTC_4x4_Format=37840,e.SRGB8_ALPHA8_ASTC_5x4_Format=37841,e.SRGB8_ALPHA8_ASTC_5x5_Format=37842,e.SRGB8_ALPHA8_ASTC_6x5_Format=37843,e.SRGB8_ALPHA8_ASTC_6x6_Format=37844,e.SRGB8_ALPHA8_ASTC_8x5_Format=37845,e.SRGB8_ALPHA8_ASTC_8x6_Format=37846,e.SRGB8_ALPHA8_ASTC_8x8_Format=37847,e.Scene=qo,e.SceneUtils=$u,e.ShaderChunk=ln,e.ShaderLib=un,e.ShaderMaterial=Wi,e.ShadowMaterial=xl,e.Shape=nc,e.ShapeBufferGeometry=ul,e.ShapeGeometry=ul,e.ShapePath=Pc,e.ShapeUtils=el,e.ShortType=1011,e.Skeleton=Ss,e.SkeletonHelper=Cu,e.SkinnedMesh=xs,e.SmoothShading=2,e.Sphere=Ye,e.SphereBufferGeometry=hl,e.SphereGeometry=hl,e.Spherical=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(ce(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},e.SphericalHarmonics3=bc,e.SplineCurve=Ca,e.SpotLight=hc,e.SpotLightHelper=class extends It{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const i=new bi,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,i=32;e<i;e++,t++){const r=e/i*Math.PI*2,o=t/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(o),Math.sin(o),1)}i.setAttribute("position",new ci(n,3));const r=new Rs({fog:!1,toneMapped:!1});this.cone=new js(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Tu.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Tu),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},e.Sprite=us,e.SpriteMaterial=Yo,e.SrcAlphaFactor=204,e.SrcAlphaSaturateFactor=210,e.SrcColorFactor=202,e.StaticCopyUsage=35046,e.StaticDrawUsage=ee,e.StaticReadUsage=35045,e.StereoCamera=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new $i,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new $i,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;const i=e.projectionMatrix.clone(),n=t.eyeSep/2,r=n*t.near/t.focus,o=t.near*Math.tan(se*t.fov*.5)/t.zoom;let s,a;Uc.elements[12]=-n,Nc.elements[12]=n,s=-o*t.aspect+r,a=o*t.aspect+r,i.elements[0]=2*t.near/(a-s),i.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(i),s=-o*t.aspect-r,a=o*t.aspect-r,i.elements[0]=2*t.near/(a-s),i.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Uc),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Nc)}},e.StreamCopyUsage=35042,e.StreamDrawUsage=35040,e.StreamReadUsage=35041,e.StringKeyframeTrack=jl,e.SubtractEquation=101,e.SubtractiveBlending=3,e.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e.TangentSpaceNormalMap=0,e.TetrahedronBufferGeometry=pl,e.TetrahedronGeometry=pl,e.TextBufferGeometry=dl,e.TextGeometry=dl,e.Texture=be,e.TextureLoader=ec,e.TorusBufferGeometry=fl,e.TorusGeometry=fl,e.TorusKnotBufferGeometry=ml,e.TorusKnotGeometry=ml,e.Triangle=jt,e.TriangleFanDrawMode=2,e.TriangleStripDrawMode=1,e.TrianglesDrawMode=0,e.TubeBufferGeometry=gl,e.TubeGeometry=gl,e.UVMapping=n,e.Uint16Attribute=function(e,t){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new oi(e,t)},e.Uint16BufferAttribute=oi,e.Uint32Attribute=function(e,t){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ai(e,t)},e.Uint32BufferAttribute=ai,e.Uint8Attribute=function(e,t){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new ii(e,t)},e.Uint8BufferAttribute=ii,e.Uint8ClampedAttribute=function(e,t){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new ni(e,t)},e.Uint8ClampedBufferAttribute=ni,e.Uniform=du,e.UniformsLib=cn,e.UniformsUtils=Hi,e.UnsignedByteType=v,e.UnsignedInt248Type=T,e.UnsignedIntType=b,e.UnsignedShort4444Type=1017,e.UnsignedShort5551Type=1018,e.UnsignedShort565Type=1019,e.UnsignedShortType=x,e.VSMShadowMap=3,e.Vector2=ge,e.Vector3=Ce,e.Vector4=Me,e.VectorKeyframeTrack=Vl,e.Vertex=function(e,t,i){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Ce(e,t,i)},e.VertexColors=2,e.VideoTexture=Ys,e.WebGL1Renderer=Go,e.WebGLCubeRenderTarget=Yi,e.WebGLMultipleRenderTargets=Se,e.WebGLMultisampleRenderTarget=Ee,e.WebGLRenderTarget=Te,e.WebGLRenderTargetCube=function(e,t,i){return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."),new Yi(e,i)},e.WebGLRenderer=Vo,e.WebGLUtils=Do,e.WireframeGeometry=_l,e.WireframeHelper=function(e,t){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new js(new _l(e.geometry),new Rs({color:void 0!==t?t:16777215}))},e.WrapAroundEnding=H,e.XHRLoader=function(e){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Yl(e)},e.ZeroCurvatureEnding=V,e.ZeroFactor=200,e.ZeroSlopeEnding=G,e.ZeroStencilOp=0,e.sRGBEncoding=Z,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof n.exports?t(n.exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).THREE={}),n=n.exports;var r={};const s=.1/180*Math.PI,a=Math.atan(.75);r=r={WORLD_SIZE:1024e3,PROJECTION_WORLD_SIZE:1024e3/(6371008.8*Math.PI*2),MERCATOR_A:6371008.8,DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,EARTH_RADIUS:6371008.8,EARTH_CIRCUMFERENCE:2*Math.PI*6371008.8,EARTH_CIRCUMFERENCE_EQUATOR:40075017,FOV_ORTHO:s,FOV:a,FOV_DEGREES:180*a/Math.PI,TILE_SIZE:512};var l={};function c(){}c.prototype={Coords:function(e){if(e.constructor===Array)if(e.length<2)console.error("Coords length must be at least 2");else{for(const t of e)if(t.constructor!==Number)return void console.error("Coords values must be numbers");if(!(Math.abs(e[1])>90))return e;console.error("Latitude must be between -90 and 90")}else console.error("Coords must be an array")},Line:function(e){if(e.constructor===Array){for(const t of e)if(!this.Coords(t))return void console.error("Each coordinate in a line must be a valid Coords type");return e}console.error("Line must be an array")},Rotation:function(e){if(e.constructor===Number)e={z:e};else{if(e.constructor!==Object)return void console.error("Rotation must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Rotation parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual rotation values must be numbers")}}return e},Scale:function(e){if(e.constructor===Number)e={x:e,y:e,z:e};else{if(e.constructor!==Object)return void console.error("Scale must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Scale parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual scale values must be numbers")}}return e}},l=l=c;var u={},h={prettyPrintMatrix:function(e){for(var t=0;t<4;t++){var i=[e[t],e[t+4],e[t+8],e[t+12]];console.log(i.map((function(e){return e.toFixed(4)})))}},makePerspectiveMatrix:function(e,t,i,r){var o=new n.Matrix4,s=1/Math.tan(e/2),a=1/(i-r),l=[s/t,0,0,0,0,s,0,0,0,0,(r+i)*a,-1,0,0,2*r*i*a,0];return o.elements=l,o},makeOrthographicMatrix:function(e,t,i,r,o,s){var a=new n.Matrix4;const l=1/(t-e),c=1/(i-r),u=1/(s-o);var h=[2*l,0,0,0,0,2*c,0,0,0,0,-1*u,0,-(t+e)*l,-(i+r)*c,-o*u,1];return a.elements=h,a},radify:function(e){function t(e){return e=e||0,2*Math.PI*e/360}return"object"==typeof e?e.length>0?e.map((function(e){return t(e)})):[t(e.x),t(e.y),t(e.z)]:t(e)},degreeify:function(e){function t(e){return 360*(e=e||0)/(2*Math.PI)}return"object"==typeof e?[t(e.x),t(e.y),t(e.z)]:t(e)},projectToWorld:function(e){var t=[-r.MERCATOR_A*r.DEG2RAD*e[0]*r.PROJECTION_WORLD_SIZE,-r.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*r.DEG2RAD*e[1]))*r.PROJECTION_WORLD_SIZE];if(e[2]){var i=this.projectedUnitsPerMeter(e[1]);t.push(e[2]*i)}else t.push(0);return new n.Vector3(t[0],t[1],t[2])},projectedUnitsPerMeter:function(e){return Math.abs(r.WORLD_SIZE/Math.cos(r.DEG2RAD*e)/r.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(e){return r.EARTH_CIRCUMFERENCE*Math.cos(e*Math.PI/180)},mercatorZfromAltitude:function(e,t){return e/this._circumferenceAtLatitude(t)},_scaleVerticesToMeters:function(e,t){for(var i=this.projectedUnitsPerMeter(e[1]),n=(this.projectToWorld(e),0);n<t.length;n++)t[n].multiplyScalar(i);return t},projectToScreen:function(e){console.log("WARNING: Projecting to screen coordinates is not yet implemented")},unprojectFromScreen:function(e){console.log("WARNING: unproject is not yet implemented")},unprojectFromWorld:function(e){var t=[-e.x/(r.MERCATOR_A*r.DEG2RAD*r.PROJECTION_WORLD_SIZE),2*(Math.atan(Math.exp(e.y/(r.PROJECTION_WORLD_SIZE*-r.MERCATOR_A)))-Math.PI/4)/r.DEG2RAD],i=this.projectedUnitsPerMeter(t[1]),n=e.z||0;return t.push(n/i),t},toScreenPosition:function(e,t){var i=new n.Vector3,r=.5*renderer.context.canvas.width,o=.5*renderer.context.canvas.height;return e.updateMatrixWorld(),i.setFromMatrixPosition(e.matrixWorld),i.project(t),i.x=i.x*r+r,i.y=-i.y*o+o,{x:i.x,y:i.y}},getFeatureCenter:function(e,t,i){let n=[],r=0,o=0,s=0,a=[...e.geometry.coordinates[0]];return"Point"===e.geometry.type?n=[...a[0]]:("MultiPolygon"===e.geometry.type&&(a=a[0]),a.splice(-1,1),a.forEach((function(e){r+=e[0],o+=e[1]})),n=[r/a.length,o/a.length]),s=this.getObjectHeightOnFloor(e,t,i),n.length<3?n.push(s):n[2]=s,n},getObjectHeightOnFloor:function(e,t,i=e.properties.level||0){let n=i*(e.properties.levelHeight||0),r=e.properties.base_height||e.properties.min_height||0;return n+((t&&t.model?0:e.properties.height-r)+r)},_flipMaterialSides:function(e){},normalizeVertices(e){let t=new n.BufferGeometry,i=[];for(var r=0;r<e.length;r++){let t=e[r];i.push(t.x,t.y,t.z),i.push(t.x,t.y,t.z)}t.setAttribute("position",new n.BufferAttribute(new Float32Array(i),3)),t.computeBoundingSphere();var o=t.boundingSphere.center;return{vertices:e.map((function(e){return e.sub(o)})),position:o}},flattenVectors(e){var t=[];for(let i of e)t.push(i.x,i.y,i.z);return t},lnglatsToWorld:function(e){return e.map((function(e){var t=h.projectToWorld(e);return new n.Vector3(t.x,t.y,t.z)}))},extend:function(e,t){for(let i in t)e[i]=t[i]},clone:function(e){var t={};for(let i in e)t[i]=e[i];return t},clamp:function(e,t,i){return Math.min(i,Math.max(t,e))},types:{rotation:function(e,t){e||(e=0),"number"==typeof e&&(e={z:e});var i=this.applyDefault([e.x,e.y,e.z],t);return h.radify(i)},scale:function(e,t){return e||(e=1),"number"==typeof e?[e,e,e]:this.applyDefault([e.x,e.y,e.z],t)},applyDefault:function(e,t){return e.map((function(e,i){return e||t[i]}))}},toDecimal:function(e,t){return Number(e.toFixed(t))},equal:function(e,t){const i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;if(0==i.length&&0==n.length&&i!==n)return!1;for(const n of i){const i=e[n],r=t[n],o=this.isObject(i)&&this.isObject(r);if(o&&!equal(i,r)||!o&&i!==r)return!1}return!0},isObject:function(e){return null!=e&&"object"==typeof e},curveToLine:(e,t)=>{let{width:i,color:r}=t,o=(new n.BufferGeometry).setFromPoints(e.getPoints(100)),s=new n.LineBasicMaterial({color:r,linewidth:i});return new n.Line(o,s)},curvesToLines:e=>{var t=[16711680,2031360,2490623];return e.map(((e,i)=>curveToLine(e,{width:3,color:t[i]||"purple"})))},_validate:function(e,t){e=e||{};var i={};h.extend(i,e);for(let n of Object.keys(t))if(void 0===e[n]){if(null===t[n])return void console.error(n+" is required");i[n]=t[n]}else i[n]=e[n];return i},Validator:new l,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};u=u=h;var p={};function d(e,t,i){this.map=e,this.camera=t,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=i||new n.Group,this.world.position.x=this.world.position.y=r.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new n.Matrix4).makeTranslation(r.WORLD_SIZE/2,-r.WORLD_SIZE/2,0),worldSizeRatio:r.TILE_SIZE/r.WORLD_SIZE,worldSize:r.TILE_SIZE*this.map.transform.scale};let o=this;this.map.on("move",(function(){o.updateCamera()})).on("resize",(function(){o.setupCamera()})),this.setupCamera()}d.prototype={setupCamera:function(){const e=this.map.transform;this.camera.aspect=e.width/e.height,this.halfFov=e._fov/2,this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*e.height;const t=e._maxPitch*Math.PI/180;this.acuteAngle=Math.PI/2-t,this.updateCamera()},updateCamera:function(e){if(!this.camera)return void console.log("nocamera");const t=this.map.transform;this.camera.aspect=t.width/t.height;const i=t.centerOffset||new n.Vector3;let r=0,o=0;this.halfFov=t._fov/2;const s=Math.PI/2+t._pitch,a=Math.cos(Math.PI/2-t._pitch);this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*t.height;let l=1;const c=this.worldSize();if(this.map.tb.mapboxVersion>=2){l=this.mercatorZfromAltitude(1,t.center.lat)*c;const e=t._fov*(.5+t.centerOffset.y/t.height),i=t.elevation?t.elevation.getMinElevationBelowMSL()*l:0,n=(t._camera.position[2]*c-i)/Math.cos(t._pitch);o=a*(Math.sin(e)*n/Math.sin(u.clamp(Math.PI-s-e,.01,Math.PI-.01)))+n;const h=n*(1/t._horizonShift);r=Math.min(1.01*o,h)}else r=1.01*(o=a*(Math.sin(this.halfFov)*this.cameraToCenterDistance/Math.sin(Math.PI-s-this.halfFov))+this.cameraToCenterDistance);this.cameraTranslateZ=(new n.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const h=t.height/50,p=Math.max(h*a,h),f=t.height,m=t.width;this.camera instanceof n.OrthographicCamera?this.camera.projectionMatrix=u.makeOrthographicMatrix(m/-2,m/2,f/2,f/-2,p,r):this.camera.projectionMatrix=u.makePerspectiveMatrix(t._fov,m/f,p,r),this.camera.projectionMatrix.elements[8]=2*-i.x/t.width,this.camera.projectionMatrix.elements[9]=2*i.y/t.height;let g=this.calcCameraMatrix(t._pitch,t.angle);t.elevation&&(g.elements[14]=t._camera.position[2]*c),this.camera.matrixWorld.copy(g);let _=t.scale*this.state.worldSizeRatio,y=new n.Matrix4,v=new n.Matrix4,x=new n.Matrix4;y.makeScale(_,_,_);let b=t.x||t.point.x,w=t.y||t.point.y;v.makeTranslation(-b,w,0),x.makeRotationZ(Math.PI),this.world.matrix=(new n.Matrix4).premultiply(x).premultiply(this.state.translateCenter).premultiply(y).premultiply(v),this.map.fire("CameraSynced",{detail:{nearZ:p,farZ:r,pitch:t._pitch,angle:t.angle,furthestDistance:o,cameraToCenterDistance:this.cameraToCenterDistance,t:this.map.transform,tbProjMatrix:this.camera.projectionMatrix.elements,tbWorldMatrix:this.world.matrix.elements,cameraSyn:d}})},worldSize(){let e=this.map.transform;return e.tileSize*e.scale},worldSizeFromZoom(){let e=this.map.transform;return Math.pow(2,e.zoom)*e.tileSize},mercatorZfromAltitude(e,t){return e/this.circumferenceAtLatitude(t)},mercatorZfromZoom(){return this.cameraToCenterDistance/this.worldSizeFromZoom()},circumferenceAtLatitude:e=>r.EARTH_CIRCUMFERENCE*Math.cos(e*Math.PI/180),calcCameraMatrix(e,t,i){const r=this.map.transform,o=void 0===e?r._pitch:e,s=void 0===t?r.angle:t,a=void 0===i?this.cameraTranslateZ:i;return(new n.Matrix4).premultiply(a).premultiply((new n.Matrix4).makeRotationX(o)).premultiply((new n.Matrix4).makeRotationZ(s))},updateCameraState(){let e=this.map.transform;if(!e.height)return;const t=e._camera.forward(),i=e.cameraToCenterDistance,n=e.point,r=(e._cameraZoom?e._cameraZoom:e._zoom,this.mercatorZfromZoom(e)-this.mercatorZfromAltitude(e._centerAltitude,e.center.lat)),o=e.cameraToCenterDistance/r;return[n.x/this.worldSize()-t[0]*i/o,n.y/this.worldSize()-t[1]*i/o,this.mercatorZfromAltitude(e._centerAltitude,e._center.lat)+-t[2]*i/o]},getWorldToCamera(e,t){let i=this.map.transform;const r=new n.Matrix4,o=new n.Matrix4,s=i._camera._orientation,a=i._camera.position,l=new n.Vector3(a[0],a[1],a[2]),c=new n.Quaternion;c.set(s[0],s[1],s[2],s[3]);const u=c.conjugate();return l.multiplyScalar(-e),o.makeTranslation(l.x,l.y,l.z),r.makeRotationFromQuaternion(u).premultiply(o),r.elements[1]*=-1,r.elements[5]*=-1,r.elements[9]*=-1,r.elements[13]*=-1,r.elements[8]*=t,r.elements[9]*=t,r.elements[10]*=t,r.elements[11]*=t,r},translate(e,t,i){let n,r,o,s,a,l,c,u,h,p,d,f,m=i[0]||i.x,g=i[1]||i.y,_=i[2]||i.z;return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=n,e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+p*_+t[13],e[14]=o*m+c*g+d*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e}},p=p=d;var f={};!function(){"use strict";var e=Math.PI,t=Math.sin,i=Math.cos,n=Math.tan,r=Math.asin,o=Math.atan2,s=Math.acos,a=e/180;function l(e){return e.valueOf()/864e5-.5+2440588}function c(e){return new Date(864e5*(e+.5-2440588))}function u(e){return l(e)-2451545}var h=23.4397*a;function p(e,r){return o(t(e)*i(h)-n(r)*t(h),i(e))}function d(e,n){return r(t(n)*i(h)+i(n)*t(h)*t(e))}function m(e,r,s){return o(t(e),i(e)*t(r)-n(s)*i(r))}function g(e,n,o){return r(t(n)*t(o)+i(n)*i(o)*i(e))}function _(e,t){return a*(280.16+360.9856235*e)-t}function y(e){return a*(357.5291+.98560028*e)}function v(i){return i+a*(1.9148*t(i)+.02*t(2*i)+3e-4*t(3*i))+102.9372*a+e}function x(e){var t=v(y(e));return{dec:d(t,0),ra:p(t,0)}}var b={getPosition:function(e,t,i){var n=a*-i,r=a*t,o=u(e),s=x(o),l=_(o,n)-s.ra;return{azimuth:m(l,r,s.dec),altitude:g(l,r,s.dec)}},toJulian:function(e){return l(e)}},w=b.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];b.addTime=function(e,t,i){w.push([e,t,i])};function M(t,i,n){return 9e-4+(t+i)/(2*e)+n}function T(e,i,n){return 2451545+e+.0053*t(i)-.0069*t(2*n)}function S(e,n,r,o,a,l,c){return T(M(function(e,n,r){return s((t(e)-t(n)*t(r))/(i(n)*i(r)))}(e,r,o),n,a),l,c)}function E(e){var n=a*(134.963+13.064993*e),r=a*(93.272+13.22935*e),o=a*(218.316+13.176396*e)+6.289*a*t(n),s=5.128*a*t(r),l=385001-20905*i(n);return{ra:p(o,s),dec:d(o,s),dist:l}}function A(e,t){return new Date(e.valueOf()+864e5*t/24)}b.getTimes=function(t,i,n,r){var o,s,l,h,p,f=a*-n,m=a*i,g=function(e){return-2.076*Math.sqrt(e)/60}(r=r||0),_=function(t,i){return Math.round(t-9e-4-i/(2*e))}(u(t),f),x=M(0,f,_),b=y(x),E=v(b),A=d(E,0),C=T(x,b,E),L={solarNoon:c(C),nadir:c(C-.5)};for(o=0,s=w.length;o<s;o+=1)p=C-((h=S(((l=w[o])[0]+g)*a,f,m,A,_,b,E))-C),L[l[1]]=c(p),L[l[2]]=c(h);return L},b.getMoonPosition=function(e,r,s){var l=a*-s,c=a*r,h=u(e),p=E(h),d=_(h,l)-p.ra,f=g(d,c,p.dec),y=o(t(d),n(c)*i(p.dec)-t(p.dec)*i(d));return f+=function(e){return e<0&&(e=0),2967e-7/Math.tan(e+.00312536/(e+.08901179))}(f),{azimuth:m(d,c,p.dec),altitude:f,distance:p.dist,parallacticAngle:y}},b.getMoonIllumination=function(e){var n=u(e||new Date),r=x(n),a=E(n),l=s(t(r.dec)*t(a.dec)+i(r.dec)*i(a.dec)*i(r.ra-a.ra)),c=o(149598e3*t(l),a.dist-149598e3*i(l)),h=o(i(r.dec)*t(r.ra-a.ra),t(r.dec)*i(a.dec)-i(r.dec)*t(a.dec)*i(r.ra-a.ra));return{fraction:(1+i(c))/2,phase:.5+.5*c*(h<0?-1:1)/Math.PI,angle:h}},b.getMoonTimes=function(e,t,i,n){var r=new Date(e);n?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);for(var o,s,l,c,u,h,p,d,f,m,g,_,y,v=.133*a,x=b.getMoonPosition(r,t,i).altitude-v,w=1;w<=24&&(o=b.getMoonPosition(A(r,w),t,i).altitude-v,d=((u=(x+(s=b.getMoonPosition(A(r,w+1),t,i).altitude-v))/2-o)*(p=-(h=(s-x)/2)/(2*u))+h)*p+o,m=0,(f=h*h-4*u*o)>=0&&(g=p-(y=Math.sqrt(f)/(2*Math.abs(u))),_=p+y,Math.abs(g)<=1&&m++,Math.abs(_)<=1&&m++,g<-1&&(g=_)),1===m?x<0?l=w+g:c=w+g:2===m&&(l=w+(d<0?_:g),c=w+(d<0?g:_)),!l||!c);w+=2)x=s;var M={};return l&&(M.rise=A(r,l)),c&&(M.set=A(r,c)),l||c||(M[d>0?"alwaysUp":"alwaysDown"]=!0),M},f=f=b}();var m={},g={material:"MeshBasicMaterial",color:"black",opacity:1};m=m=function(e){var t;function i(){return new n[g.material]({color:g.color})}return e?((t=(e=u._validate(e,g)).material&&e.material.isMaterial?e.material:e.material||e.color||e.opacity?new n[e.material]({color:e.color,transparent:e.opacity<1}):i()).opacity=e.opacity,e.side&&(t.side=e.side)):t=i(),t};var _={};function y(e){this.map=e,this.enrolledObjects=[],this.previousFrameTime}y.prototype={unenroll:function(e){this.enrolledObjects.splice(this.enrolledObjects.indexOf(e),1)},enroll:function(e){if(e.clock=new n.Clock,e.hasDefaultAnimation=!1,e.defaultAction,e.actions=[],e.mixer,e.animations&&e.animations.length>0){e.hasDefaultAnimation=!0;let i=e.userData.defaultAnimation?e.userData.defaultAnimation:0;e.mixer=new n.AnimationMixer(e),t(i)}function t(t){for(let i=0;i<e.animations.length;i++){t>e.animations.length&&console.log("The animation index "+t+" doesn't exist for this object");let n=e.animations[i],r=e.mixer.clipAction(n);e.actions.push(r),t===i?(e.defaultAction=r,r.setEffectiveWeight(1)):r.setEffectiveWeight(0),r.play()}}let i=!1;Object.defineProperty(e,"isPlaying",{get:()=>i,set(t){i!=t&&(i=t,e.dispatchEvent({type:"IsPlayingChanged",detail:e}))}}),this.enrolledObjects.push(e),e.animationQueue=[],e.set=function(t){if(t.duration>0){let i={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,i);let r=t.coords,o=t.rotation,s=t.scale||t.scaleX||t.scaleY||t.scaleZ;if(o){let i=e.rotation;t.startRotation=[i.x,i.y,i.z],t.endState.rotation=u.types.rotation(t.rotation,t.startRotation),t.rotationPerMs=t.endState.rotation.map((function(e,i){return(e-t.startRotation[i])/t.duration}))}if(s){let i=e.scale;t.startScale=[i.x,i.y,i.z],t.endState.scale=u.types.scale(t.scale,t.startScale),t.scalePerMs=t.endState.scale.map((function(e,i){return(e-t.startScale[i])/t.duration}))}r&&(t.pathCurve=new n.CatmullRomCurve3(u.lnglatsToWorld([e.coordinates,t.coords])));let a={type:"set",parameters:t};this.animationQueue.push(a),tb.map.repaint=!0}else this.stop(),t.rotation=u.radify(t.rotation),this._setObject(t);return this},e.animationMethod=null,e.stop=function(t){return e.mixer&&(e.isPlaying=!1,cancelAnimationFrame(e.animationMethod)),this.animationQueue=[],this},e.followPath=function(e,t){let i={type:"followPath",parameters:u._validate(e,v.followPath)};return u.extend(i.parameters,{pathCurve:new n.CatmullRomCurve3(u.lnglatsToWorld(e.path)),start:Date.now(),expiration:Date.now()+i.parameters.duration,cb:t}),this.animationQueue.push(i),tb.map.repaint=!0,this},e._setObject=function(t){e.setScale();let i=t.position,r=t.rotation,o=t.scale,s=t.worldCoordinates,a=t.quaternion,l=t.translate,c=t.worldTranslate;if(i){this.coordinates=i;let e=u.projectToWorld(i);this.position.copy(e)}if(l){this.coordinates=[this.coordinates[0]+l[0],this.coordinates[1]+l[1],this.coordinates[2]+l[2]];let e=u.projectToWorld(l);this.position.copy(e),t.position=this.coordinates}if(c){this.translateX(c.x),this.translateY(c.y),this.translateZ(c.z);let e=u.unprojectFromWorld(this.position);this.coordinates=t.position=e}if(r&&(this.rotation.set(r[0],r[1],r[2]),t.rotation=new n.Vector3(r[0],r[1],r[2])),o&&(this.scale.set(o[0],o[1],o[2]),t.scale=this.scale),a&&(this.quaternion.setFromAxisAngle(a[0],a[1]),t.rotation=a[0].multiplyScalar(a[1])),s){this.position.copy(s);let e=u.unprojectFromWorld(s);this.coordinates=t.position=e}this.setBoundingBoxShadowFloor(),this.setReceiveShadowFloor(),this.updateMatrixWorld(),tb.map.repaint=!0;let h={type:"ObjectChanged",detail:{object:this,action:{position:t.position,rotation:t.rotation,scale:t.scale}}};this.dispatchEvent(h)},e.playDefault=function(t){if(e.mixer&&e.hasDefaultAnimation){let i={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,i),e.mixer.timeScale=t.speed||1;let n={type:"playDefault",parameters:t};return this.animationQueue.push(n),tb.map.repaint=!0,this}},e.playAnimation=function(i){e.mixer&&(i.animation&&t(i.animation),e.playDefault(i))},e.pauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!0}))},e.unPauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!1}))},e.deactivateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.stop()}))},e.activateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.play()}))},e.idle=function(){return e.mixer&&e.mixer.update(.01),tb.map.repaint=!0,this}},update:function(e){if(void 0===this.previousFrameTime&&(this.previousFrameTime=e),!this.enrolledObjects)return!1;for(let t=this.enrolledObjects.length-1;t>=0;t--){let i=this.enrolledObjects[t];if(i.animationQueue&&0!==i.animationQueue.length)for(let t=i.animationQueue.length-1;t>=0;t--){let r=i.animationQueue[t];if(!r)continue;let o=r.parameters;if(!o.expiration)return i.animationQueue.splice(t,1),void(i.animationQueue[t]&&(i.animationQueue[t].parameters.start=e));if(e>=o.expiration)o.expiration=!1,"playDefault"===r.type?i.stop():(o.endState&&i._setObject(o.endState),void 0!==o.cb&&o.cb());else{let t=(e-o.start)/o.duration;if("set"===r.type){let e={};o.pathCurve&&(e.worldCoordinates=o.pathCurve.getPoint(t)),o.rotationPerMs&&(e.rotation=o.startRotation.map((function(e,i){return e+o.rotationPerMs[i]*t*o.duration}))),o.scalePerMs&&(e.scale=o.startScale.map((function(e,i){return e+o.scalePerMs[i]*t*o.duration}))),i._setObject(e)}if("followPath"===r.type){let e={worldCoordinates:o.pathCurve.getPointAt(t)};if(o.trackHeading){let i=o.pathCurve.getTangentAt(t).normalize(),r=new n.Vector3(0,0,0),s=new n.Vector3(0,1,0);r.crossVectors(s,i).normalize();let a=Math.acos(s.dot(i));e.quaternion=[r,a]}i._setObject(e)}"playDefault"===r.type&&(i.activateAllActions(),i.isPlaying=!0,i.animationMethod=requestAnimationFrame(this.update),i.mixer.update(i.clock.getDelta()),tb.map.repaint=!0)}}}this.previousFrameTime=e}};const v={followPath:{path:null,duration:1e3,trackHeading:!0}};_=_=y;var x={};!function(){class e extends n.Object3D{constructor(e){super(),this.element=e||document.createElement("div"),this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.alwaysVisible=!1,Object.defineProperty(this,"layer",{get(){return this.parent&&this.parent.parent?this.parent.parent.layer:null}}),this.dispose=function(){this.remove(),this.element=null},this.remove=function(){this.element instanceof Element&&null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)},this.addEventListener("removed",(function(){this.remove()}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}}e.prototype.isCSS2DObject=!0;const t=new n.Vector3,i=new n.Matrix4,r=new n.Matrix4,o=new n.Vector3,s=new n.Vector3;n.CSS2DObject=e,n.CSS2DRenderer=class{constructor(){const e=this;let n,a,l,c;const u={objects:new WeakMap,list:new Map};this.cacheList=u.list;const h=document.createElement("div");h.style.overflow="hidden",this.domElement=h,this.getSize=function(){return{width:n,height:a}},this.render=function(n,a){!0===n.autoUpdate&&n.updateMatrixWorld(),null===a.parent&&a.updateMatrixWorld(),i.copy(a.matrixWorldInverse),r.multiplyMatrices(a.projectionMatrix,i),function i(n,a,p){if(n.isCSS2DObject)if(n.visible){n.onBeforeRender(e,a,p),t.setFromMatrixPosition(n.matrixWorld),t.applyMatrix4(r);const i=n.element;var d;d=/apple/i.test(navigator.vendor)?"translate(-50%,-50%) translate("+Math.round(t.x*l+l)+"px,"+Math.round(-t.y*c+c)+"px)":"translate(-50%,-50%) translate("+(t.x*l+l)+"px,"+(-t.y*c+c)+"px)",i.style.WebkitTransform=d,i.style.MozTransform=d,i.style.oTransform=d,i.style.transform=d,i.style.display=n.visible&&t.z>=-1&&t.z<=1?"":"none";const g={distanceToCameraSquared:(f=p,m=n,o.setFromMatrixPosition(f.matrixWorld),s.setFromMatrixPosition(m.matrixWorld),o.distanceToSquared(s))};u.objects.set({key:n.uuid},g),u.list.set(n.uuid,n),i.parentNode!==h&&h.appendChild(i),n.onAfterRender(e,a,p)}else u.objects.delete({key:n.uuid}),u.list.delete(n.uuid),n.remove();var f,m;for(let e=0,t=n.children.length;e<t;e++)i(n.children[e],a,p)}(n,n,a),function(e){const t=function(e){const t=[];return e.traverse((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){let i=u.objects.get({key:e.uuid}),n=u.objects.get({key:t.uuid});if(i&&n)return i.distanceToCameraSquared-n.distanceToCameraSquared})),i=t.length;for(let e=0,n=t.length;e<n;e++)t[e].element.style.zIndex=i-e}(n)},this.setSize=function(e,t){l=(n=e)/2,c=(a=t)/2,h.style.width=e+"px",h.style.height=t+"px"}}}}(),x=x={CSS2DRenderer:n.CSS2DRenderer,CSS2DObject:n.CSS2DObject};var b={};const w=n;function M(){}M.prototype={line:function(e){e=u._validate(e,this._defaults.line);var t=u.lnglatsToWorld(e.geometry),i=u.normalizeVertices(t),n=u.flattenVectors(i.vertices),r=new Float32Array(n),o=new w.BufferGeometry;o.setAttribute("position",new w.BufferAttribute(r,3));var s=new w.LineBasicMaterial({color:16711680,linewidth:21}),a=new w.Line(o,s);return a.options=options||{},a.position.copy(i.position),a},extrusion:function(e){},unenroll:function(e,t){t||this.animationManager.unenroll(e)},_addMethods:function(e,t){var i=this;if(t);else{function n(e,t,i,n){let r=u.radify(n);e.position.sub(t),e.position.applyAxisAngle(i,r),e.position.add(t),e.rotateOnAxis(i,r),tb.map.repaint=!0}e.coordinates||(e.coordinates=[0,0,0]),Object.defineProperty(e,"model",{get:()=>e.getObjectByName("model")}),Object.defineProperty(e,"animations",{get(){const t=e.model;return t?t.animations:null}}),i.animationManager.enroll(e),e.setCoords=function(t){return e.userData.topMargin&&e.userData.feature&&(t[2]+=((e.userData.feature.properties.height||0)-(e.userData.feature.properties.base_height||e.userData.feature.properties.min_height||0))*(e.userData.topMargin||0)),e.coordinates=t,e.set({position:t}),e},e.setTranslate=function(t){return e.set({translate:t}),e},e.setRotation=function(t){"number"==typeof t&&(t={z:t});var i={x:u.radify(t.x)||e.rotation.x,y:u.radify(t.y)||e.rotation.y,z:u.radify(t.z)||e.rotation.z};e._setObject({rotation:[i.x,i.y,i.z]})},e.calculateAdjustedPosition=function(t,i,n){let r=t.slice(),o=u.unprojectFromWorld(e.modelSize);return n?(r[0]-=0!=i.x?o[0]/i.x:0,r[1]-=0!=i.y?o[1]/i.y:0,r[2]-=0!=i.z?o[2]/i.z:0):(r[0]+=0!=i.x?o[0]/i.x:0,r[1]+=0!=i.y?o[1]/i.y:0,r[2]+=0!=i.z?o[2]/i.z:0),r},e.setRotationAxis=function(t){"number"==typeof t&&(t={z:t});let i=e.modelBox(),r=new w.Vector3(i.max.x,i.max.y,i.min.z);0!=t.x&&n(e,r,new w.Vector3(0,0,1),t.x),0!=t.y&&n(e,r,new w.Vector3(0,0,1),t.y),0!=t.z&&n(e,r,new w.Vector3(0,0,1),t.z)},Object.defineProperty(e,"scaleGroup",{get:()=>e.getObjectByName("scaleGroup")}),Object.defineProperty(e,"boxGroup",{get:()=>e.getObjectByName("boxGroup")}),Object.defineProperty(e,"boundingBox",{get:()=>e.getObjectByName("boxModel")}),Object.defineProperty(e,"boundingBoxShadow",{get:()=>e.getObjectByName("boxShadow")}),e.drawBoundingBox=function(){let t=e.box3(),i=new w.Group;i.name="boxGroup",i.updateMatrixWorld(!0);let n=new w.Box3Helper(t,M.prototype._defaults.colors.yellow);n.name="boxModel",i.add(n),n.layers.disable(0);let r=t.clone();r.max.z=r.min.z;let o=new w.Box3Helper(r,M.prototype._defaults.colors.black);o.name="boxShadow",i.add(o),o.layers.disable(0),i.visible=!1,e.scaleGroup.add(i),e.setBoundingBoxShadowFloor()},e.setBoundingBoxShadowFloor=function(){if(e.boundingBoxShadow){let t=-e.modelHeight,i=e.rotation,n=e.boundingBoxShadow;n.box.max.z=n.box.min.z=t,n.rotation.y=i.y,n.rotation.x=-i.x}},e.setAnchor=function(t){const i=e.box3(),n=i.getCenter(new w.Vector3);switch(e.none={x:0,y:0,z:0},e.center={x:n.x,y:n.y,z:i.min.z},e.bottom={x:n.x,y:i.max.y,z:i.min.z},e.bottomLeft={x:i.max.x,y:i.max.y,z:i.min.z},e.bottomRight={x:i.min.x,y:i.max.y,z:i.min.z},e.top={x:n.x,y:i.min.y,z:i.min.z},e.topLeft={x:i.max.x,y:i.min.y,z:i.min.z},e.topRight={x:i.min.x,y:i.min.y,z:i.min.z},e.left={x:i.max.x,y:n.y,z:i.min.z},e.right={x:i.min.x,y:n.y,z:i.min.z},t){case"center":e.anchor=e.center;break;case"top":e.anchor=e.top;break;case"top-left":e.anchor=e.topLeft;break;case"top-right":e.anchor=e.topRight;break;case"left":e.anchor=e.left;break;case"right":e.anchor=e.right;break;case"bottom":e.anchor=e.bottom;break;case"bottom-left":default:e.anchor=e.bottomLeft;break;case"bottom-right":e.anchor=e.bottomRight;break;case"auto":case"none":e.anchor=e.none}e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)},e.setCenter=function(t){if(t&&(0!=t.x||0!=t.y||0!=t.z)){let i=e.getSize();e.anchor={x:e.anchor.x-i.x*t.x,y:e.anchor.y-i.y*t.y,z:e.anchor.z-i.z*t.z},e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)}},Object.defineProperty(e,"label",{get:()=>e.getObjectByName("label")}),Object.defineProperty(e,"tooltip",{get:()=>e.getObjectByName("tooltip")}),Object.defineProperty(e,"help",{get:()=>e.getObjectByName("help")});let o=!1;Object.defineProperty(e,"hidden",{get:()=>o,set(t){o!=t&&(o=t,e.visibility=!o)}}),Object.defineProperty(e,"visibility",{get:()=>e.visible,set(t){let i=t;if("visible"==t||1==t)i=!0,e.label&&(e.label.visible=i);else{if("none"!=t&&0!=t)return;i=!1,e.label&&e.label.alwaysVisible&&(e.label.visible=i),e.tooltip&&(e.tooltip.visible=i)}if(e.visible!=i){if(e.hidden&&i)return;e.visible=i,e.model&&e.model.traverse((function(t){"Mesh"!=t.type&&"SkinnedMesh"!=t.type||(i&&e.raycasted?t.layers.enable(0):t.layers.disable(0)),"LineSegments"==t.type&&t.layers.disableAll()}))}}}),e.addLabel=function(t,i,n,r){t&&e.drawLabelHTML(t,i,n,r)},e.removeLabel=function(){e.removeCSS2D("label")},e.drawLabelHTML=function(t,n=!1,r=e.anchor,o=.5){let s=i.drawLabelHTML(t,M.prototype._defaults.label.cssClass),a=e.addCSS2D(s,"label",r,o);return a.alwaysVisible=n,a.visible=n,a},e.addTooltip=function(t,i,n,r=!0,o=1){let s=e.addHelp(t,"tooltip",i,n,o);s.visible=!1,s.custom=r},e.removeTooltip=function(){e.removeCSS2D("tooltip")},e.addHelp=function(t,n="help",r=!1,o=e.anchor,s=0){let a=i.drawTooltip(t,r),l=e.addCSS2D(a,n,o,s);return l.visible=!0,l},e.removeHelp=function(){e.removeCSS2D("help")},e.addCSS2D=function(t,i,n=e.anchor,r=1){if(t){const o=e.box3(),s=o.getSize(new w.Vector3);let a={x:o.max.x,y:o.max.y,z:o.min.z};e.removeCSS2D(i);let l=new x.CSS2DObject(t);return l.name=i,l.position.set(.5*-s.x-e.model.position.x-n.x+a.x,.5*-s.y-e.model.position.y-n.y+a.y,s.z*r),l.visible=!1,e.scaleGroup.add(l),l}},e.removeCSS2D=function(t){let i=e.getObjectByName(t);if(i){i.dispose();let t=e.scaleGroup.children;t.splice(t.indexOf(i),1)}},Object.defineProperty(e,"shadowPlane",{get:()=>e.getObjectByName("shadowPlane")});let s=!1;Object.defineProperty(e,"castShadow",{get:()=>s,set(t){if(e.model&&s!==t){if(e.model.traverse((function(e){e.isMesh&&(e.castShadow=!0)})),t){const i=e.modelSize,n=[i.x,i.y,i.z,e.modelHeight],r=10*Math.max(...n),o=new w.PlaneBufferGeometry(r,r),s=new w.ShadowMaterial;s.opacity=.5;let a=new w.Mesh(o,s);a.name="shadowPlane",a.layers.enable(1),a.layers.disable(0),a.receiveShadow=t,e.add(a)}else e.traverse((function(t){t.isMesh&&t.material instanceof w.ShadowMaterial&&e.remove(t)}));s=t}}}),e.setReceiveShadowFloor=function(){if(e.castShadow){let t=e.shadowPlane,i=t.position,n=t.rotation;if(i.z=-e.modelHeight,n.y=e.rotation.y,n.x=-e.rotation.x,"meters"===e.userData.units){const n=e.modelSize,r=[n.x,n.y,n.z,-i.z],o=10*Math.max(...r)/t.geometry.parameters.width;t.scale.set(o,o,o)}}};let a=!1;Object.defineProperty(e,"receiveShadow",{get:()=>a,set(t){e.model&&a!==t&&(e.model.traverse((function(e){e.isMesh&&(e.receiveShadow=!0)})),a=t)}});let l=!1;Object.defineProperty(e,"wireframe",{get:()=>l,set(t){e.model&&l!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let i=[];Array.isArray(e.material)?i=e.material:i.push(e.material);let n=i[0];t?(e.userData.materials=n,e.material=n.clone(),e.material.wireframe=e.material.transparent=t,e.material.opacity=.3):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null),t?(e.layers.disable(0),e.layers.enable(1)):(e.layers.disable(1),e.layers.enable(0))}"LineSegments"==e.type&&e.layers.disableAll()})),l=t,e.dispatchEvent({type:"Wireframed",detail:e}))}});let c=null;Object.defineProperty(e,"color",{get:()=>c,set(t){e.model&&c!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let i=[];Array.isArray(e.material)?i=e.material:i.push(e.material);let n=i[0];t?(e.userData.materials=n,e.material=new w.MeshStandardMaterial,e.material.color.setHex(t)):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null)}})),c=t)}});let h=!1;Object.defineProperty(e,"selected",{get:()=>h,set(t){t?(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.boxGroup&&(e.boundingBox.material=M.prototype._defaults.materials.boxSelectedMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1)),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0)):(e.boxGroup&&e.remove(e.boxGroup),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1),e.removeHelp()),e.tooltip&&(e.tooltip.visible=t),h!=t&&(h=t,e.dispatchEvent({type:"SelectedChange",detail:e}))}});let p=!0;Object.defineProperty(e,"raycasted",{get:()=>p,set(t){e.model&&p!==t&&(e.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(t?(e.layers.disable(1),e.layers.enable(0)):(e.layers.disable(0),e.layers.enable(1)))})),p=t)}});let d=!1;Object.defineProperty(e,"over",{get:()=>d,set(t){t?(e.selected||(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.userData.tooltip&&!e.tooltip&&e.addTooltip(e.uuid,!0,e.anchor,!1),e.boxGroup&&(e.boundingBox.material=M.prototype._defaults.materials.boxOverMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1))),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0),e.dispatchEvent({type:"ObjectMouseOver",detail:e})):(e.selected||(e.boxGroup&&(e.remove(e.boxGroup),e.tooltip&&!e.tooltip.custom&&e.removeTooltip()),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1)),e.dispatchEvent({type:"ObjectMouseOut",detail:e})),e.tooltip&&(e.tooltip.visible=t||e.selected),d=t}}),e.box3=function(){let t;if(e.updateMatrix(),e.updateMatrixWorld(!0,!0),e.model){let i=e.clone(!0),n=e.model.clone();if(t=(new w.Box3).setFromObject(n),e.parent){let r=new w.Matrix4,o=new w.Matrix4;e.matrix.extractRotation(r),o.copy(r).invert(),i.setRotationFromMatrix(o),t=(new w.Box3).setFromObject(n)}}return t},e.modelBox=function(){return e.box3()},e.getSize=function(){return e.box3().getSize(new w.Vector3(0,0,0))};let f=!1;Object.defineProperty(e,"modelSize",{get:()=>f=e.getSize(),set(e){f!=e&&(f=e)}}),Object.defineProperty(e,"modelHeight",{get(){let t=e.coordinates[2]||0;return"scene"===e.userData.units&&(t*=e.unitsPerMeter/e.scale.x),t}}),Object.defineProperty(e,"unitsPerMeter",{get:()=>Number(u.projectedUnitsPerMeter(e.coordinates[1]).toFixed(7))}),Object.defineProperty(e,"fixedZoom",{get:()=>e.userData.fixedZoom,set(t){e.userData.fixedZoom!==t&&(e.userData.fixedZoom=t,e.userData.units=t?"scene":"meters")}}),e.setFixedZoom=function(t){if(null!=e.fixedZoom&&0!=e.fixedZoom){t||(t=e.userData.mapScale);let n=(i=e.fixedZoom,Math.pow(2,i));if(n>t){let i=n/t;e.scale.set(i,i,i)}else e.scale.set(1,1,1)}var i},e.setScale=function(t){if("scene"!=e.userData.units){let t=e.unitsPerMeter;e.scale.set(t,t,t)}else e.fixedZoom?(t&&(e.userData.mapScale=t),e.setFixedZoom(e.userData.mapScale)):e.scale.set(1,1,1)},e.setObjectScale=function(t){e.setScale(t),e.setBoundingBoxShadowFloor(),e.setReceiveShadowFloor()}}e.add=function(t){return e.scaleGroup.add(t),t.position.z=e.coordinates[2]?-e.coordinates[2]:0,t},e.remove=function(t){t&&(t.traverse((e=>{if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()})),e.scaleGroup.remove(t),tb.map.repaint=!0)},e.duplicate=function(t){let n=e.clone(!0);if(n.getObjectByName("model").animations=e.animations,n.userData.feature&&(t&&t.feature&&(n.userData.feature=t.feature),n.userData.feature.properties.uuid=n.uuid),i._addMethods(n),!t||u.equal(t.scale,e.userData.scale))return n.copyAnchor(e),n;{n.userData=t,n.userData.isGeoGroup=!0,n.remove(n.boxGroup);const e=u.types.rotation(t.rotation,[0,0,0]),i=u.types.scale(t.scale,[1,1,1]);return n.model.position.set(0,0,0),n.model.rotation.set(e[0],e[1],e[2]),n.model.scale.set(i[0],i[1],i[2]),n.setAnchor(t.anchor),n.setCenter(t.adjustment),n}},e.copyAnchor=function(t){e.anchor=t.anchor,e.none={x:0,y:0,z:0},e.center=t.center,e.bottom=t.bottom,e.bottomLeft=t.bottomLeft,e.bottomRight=t.bottomRight,e.top=t.top,e.topLeft=t.topLeft,e.topRight=t.topRight,e.left=t.left,e.right=t.right},e.dispose=function(){M.prototype.unenroll(e),e.traverse((e=>{if((!e.parent||"world"!=e.parent.name)&&"threeboxObject"!==e.name){if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()}})),e.children=[]};const r=e=>{e.dispose();for(const t of Object.keys(e)){const i=e[t];i&&"object"==typeof i&&"minFilter"in i&&i.dispose()}let t=e;(t.map||t.alphaMap||t.aoMap||t.bumpMap||t.displacementMap||t.emissiveMap||t.envMap||t.lightMap||t.metalnessMap||t.normalMap||t.roughnessMap)&&(t.map&&t.map.dispose(),t.alphaMap&&t.alphaMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.displacementMap&&t.displacementMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.envMap&&t.envMap.dispose(),t.lightMap&&t.lightMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose())};return e},_makeGroup:function(e,t){let i=new w.Group;i.name="scaleGroup",i.add(e);var n=new w.Group;if(n.userData=t||{},n.userData.isGeoGroup=!0,n.userData.feature&&(n.userData.feature.properties.uuid=n.uuid),i.length)for(o of i)n.add(o);else n.add(i);return n.name="threeboxObject",n},animationManager:new _,drawTooltip:function(e,t=!1){if(e){let i;if(t){let t=document.createElement("div");t.className="mapboxgl-popup-content";let n=document.createElement("strong");n.innerHTML=e,t.appendChild(n);let r=document.createElement("div");r.className="mapboxgl-popup-tip";let o=document.createElement("div");o.className="marker mapboxgl-popup-anchor-bottom",o.appendChild(r),o.appendChild(t),(i=document.createElement("div")).className+="label3D",i.appendChild(o)}else(i=document.createElement("span")).className=this._defaults.tooltip.cssClass,i.innerHTML=e;return i}},drawLabelHTML:function(e,t){let i=document.createElement("div");return i.className+=t,i.innerHTML="string"==typeof e?e:e.outerHTML,i},_defaults:{colors:{red:new w.Color(16711680),yellow:new w.Color(16776960),green:new w.Color(65280),black:new w.Color(0)},materials:{boxNormalMaterial:new w.LineBasicMaterial({color:new w.Color(16711680)}),boxOverMaterial:new w.LineBasicMaterial({color:new w.Color(16776960)}),boxSelectedMaterial:new w.LineBasicMaterial({color:new w.Color(65280)})},line:{geometry:null,color:"black",width:1,opacity:1},label:{htmlElement:null,cssClass:" label3D",alwaysVisible:!1,topMargin:-.5},tooltip:{text:"",cssClass:"toolTip text-xs",mapboxStyle:!1,topMargin:0},sphere:{position:[0,0,0],radius:1,sides:20,units:"scene",material:"MeshBasicMaterial",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},tube:{geometry:null,radius:1,sides:6,units:"scene",material:"MeshBasicMaterial",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0},loadObj:{type:null,obj:null,units:"scene",scale:1,rotation:0,defaultAnimation:0,anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0,clone:!0},Object3D:{obj:null,units:"scene",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},extrusion:{coordinates:[[[]]],geometryOptions:{},height:100,materials:new w.MeshPhongMaterial({color:6684672,side:w.DoubleSide}),scale:1,rotation:0,units:"scene",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0}},geometries:{line:["LineString"],tube:["LineString"],sphere:["Point"]}},b=b=M;var T={};T=T=function(e){let t=(e=u._validate(e,b.prototype._defaults.Object3D)).obj;const i=u.types.rotation(e.rotation,[0,0,0]),n=u.types.scale(e.scale,[1,1,1]);t.rotation.set(i[0],i[1],i[2]),t.scale.set(n[0],n[1],n[2]),t.name="model";let r=b.prototype._makeGroup(t,e);return e.obj.name="model",b.prototype._addMethods(r),r.setAnchor(e.anchor),r.setCenter(e.adjustment),r.raycasted=e.raycasted,r.visibility=!0,r};var S={};S=S=function(e){e=u._validate(e,b.prototype._defaults.sphere);let t=new n.SphereBufferGeometry(e.radius,e.sides,e.sides),i=m(e),r=new n.Mesh(t,i);return new T({obj:r,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var E={};function A(e){e=u._validate(e,b.prototype._defaults.extrusion);let t=A.prototype.buildShape(e.coordinates),i=A.prototype.buildGeometry(t,e.geometryOptions),r=new n.Mesh(i,e.materials);return e.obj=r,new T(e)}A.prototype={buildShape:function(e){if(e[0]instanceof(n.Vector2||n.Vector3))return new n.Shape(e);let t=new n.Shape;for(let i=0;i<e.length;i++)0===i?t=new n.Shape(this.buildPoints(e[0],e[0])):t.holes.push(new n.Path(this.buildPoints(e[i],e[0])));return t},buildPoints:function(e,t){const i=[];let r=u.projectToWorld([t[0][0],t[0][1],0]);for(let t=0;t<e.length;t++){let o=u.projectToWorld([e[t][0],e[t][1],0]);i.push(new n.Vector2(u.toDecimal(o.x-r.x,9),u.toDecimal(o.y-r.y,9)))}return i},buildGeometry:function(e,t){let i=new n.ExtrudeBufferGeometry(e,t);return i.computeBoundingBox(),i}},E=E=A;var C={};C=C=function(e){e=u._validate(e,b.prototype._defaults.label);let t=b.prototype.drawLabelHTML(e.htmlElement,e.cssClass),i=new x.CSS2DObject(t);i.name="label",i.visible=e.alwaysVisible,i.alwaysVisible=e.alwaysVisible;var n=b.prototype._makeGroup(i,e);return b.prototype._addMethods(n),n.visibility=e.alwaysVisible,n};var L={};L=L=function(e){if((e=u._validate(e,b.prototype._defaults.tooltip)).text){let i=b.prototype.drawTooltip(e.text,e.mapboxStyle),n=new x.CSS2DObject(i);n.visible=!1,n.name="tooltip";var t=b.prototype._makeGroup(n,e);return b.prototype._addMethods(t),t}};var I={};!function(){const e=/^[og]\s*(.+)?/,t=/^mtllib /,i=/^usemtl /,r=/^usemap /,o=new n.Vector3,s=new n.Vector3,a=new n.Vector3,l=new n.Vector3,c=new n.Vector3;function u(){const e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=e,void(this.object.fromDeclaration=!1!==t);const i=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:!1!==t,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const n={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==i?i.smooth:this.smooth,groupStart:void 0!==i?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){const t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(n),n},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){const t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},i&&i.name&&"function"==typeof i.clone){const e=i.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseNormalIndex:function(e,t){const i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseUVIndex:function(e,t){const i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)},addVertex:function(e,t,i){const n=this.vertices,r=this.object.geometry.vertices;r.push(n[e+0],n[e+1],n[e+2]),r.push(n[t+0],n[t+1],n[t+2]),r.push(n[i+0],n[i+1],n[i+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,i){const n=this.normals,r=this.object.geometry.normals;r.push(n[e+0],n[e+1],n[e+2]),r.push(n[t+0],n[t+1],n[t+2]),r.push(n[i+0],n[i+1],n[i+2])},addFaceNormal:function(e,t,i){const n=this.vertices,r=this.object.geometry.normals;o.fromArray(n,e),s.fromArray(n,t),a.fromArray(n,i),c.subVectors(a,s),l.subVectors(o,s),c.cross(l),c.normalize(),r.push(c.x,c.y,c.z),r.push(c.x,c.y,c.z),r.push(c.x,c.y,c.z)},addColor:function(e,t,i){const n=this.colors,r=this.object.geometry.colors;void 0!==n[e]&&r.push(n[e+0],n[e+1],n[e+2]),void 0!==n[t]&&r.push(n[t+0],n[t+1],n[t+2]),void 0!==n[i]&&r.push(n[i+0],n[i+1],n[i+2])},addUV:function(e,t,i){const n=this.uvs,r=this.object.geometry.uvs;r.push(n[e+0],n[e+1]),r.push(n[t+0],n[t+1]),r.push(n[i+0],n[i+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,i,n,r,o,s,a,l){const c=this.vertices.length;let u=this.parseVertexIndex(e,c),h=this.parseVertexIndex(t,c),p=this.parseVertexIndex(i,c);if(this.addVertex(u,h,p),this.addColor(u,h,p),void 0!==s&&""!==s){const e=this.normals.length;u=this.parseNormalIndex(s,e),h=this.parseNormalIndex(a,e),p=this.parseNormalIndex(l,e),this.addNormal(u,h,p)}else this.addFaceNormal(u,h,p);if(void 0!==n&&""!==n){const e=this.uvs.length;u=this.parseUVIndex(n,e),h=this.parseUVIndex(r,e),p=this.parseUVIndex(o,e),this.addUV(u,h,p),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let i=0,n=e.length;i<n;i++){const n=this.parseVertexIndex(e[i],t);this.addVertexPoint(n),this.addColor(n)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const i=this.vertices.length,n=this.uvs.length;for(let t=0,n=e.length;t<n;t++)this.addVertexLine(this.parseVertexIndex(e[t],i));for(let e=0,i=t.length;e<i;e++)this.addUVLine(this.parseUVIndex(t[e],n))}};return e.startObject("",!1),e}n.OBJLoader=class extends n.Loader{constructor(e){super(e),this.materials=null}load(e,t,i,r){const o=this,s=new n.FileLoader(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(i){try{t(o.parse(i))}catch(t){r?r(t):console.error(t),o.manager.itemError(e)}}),i,r)}setMaterials(e){return this.materials=e,this}parse(o){const s=new u;-1!==o.indexOf("\r\n")&&(o=o.replace(/\r\n/g,"\n")),-1!==o.indexOf("\\\n")&&(o=o.replace(/\\\n/g,""));const a=o.split("\n");let l="",c="",h=0,p=[];const d="function"==typeof"".trimLeft;for(let n=0,o=a.length;n<o;n++)if(l=a[n],0!==(h=(l=d?l.trimLeft():l.trim()).length)&&"#"!==(c=l.charAt(0)))if("v"===c){const e=l.split(/\s+/);switch(e[0]){case"v":s.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?s.colors.push(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])):s.colors.push(void 0,void 0,void 0);break;case"vn":s.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case"vt":s.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if("f"===c){const e=l.substr(1).trim().split(/\s+/),t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i];if(n.length>0){const e=n.split("/");t.push(e)}}const i=t[0];for(let e=1,n=t.length-1;e<n;e++){const n=t[e],r=t[e+1];s.addFace(i[0],n[0],r[0],i[1],n[1],r[1],i[2],n[2],r[2])}}else if("l"===c){const e=l.substring(1).trim().split(" ");let t=[];const i=[];if(-1===l.indexOf("/"))t=e;else for(let n=0,r=e.length;n<r;n++){const r=e[n].split("/");""!==r[0]&&t.push(r[0]),""!==r[1]&&i.push(r[1])}s.addLineGeometry(t,i)}else if("p"===c){const e=l.substr(1).trim().split(" ");s.addPointGeometry(e)}else if(null!==(p=e.exec(l))){const e=(" "+p[0].substr(1).trim()).substr(1);s.startObject(e)}else if(i.test(l))s.object.startMaterial(l.substring(7).trim(),s.materialLibraries);else if(t.test(l))s.materialLibraries.push(l.substring(7).trim());else if(r.test(l))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if("s"===c){if((p=l.split(" ")).length>1){const e=p[1].trim().toLowerCase();s.object.smooth="0"!==e&&"off"!==e}else s.object.smooth=!0;const e=s.object.currentMaterial();e&&(e.smooth=s.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}s.finalize();const f=new n.Group;if(f.materialLibraries=[].concat(s.materialLibraries),1==!(1===s.objects.length&&0===s.objects[0].geometry.vertices.length))for(let e=0,t=s.objects.length;e<t;e++){const t=s.objects[e],i=t.geometry,r=t.materials,o="Line"===i.type,a="Points"===i.type;let l=!1;if(0===i.vertices.length)continue;const c=new n.BufferGeometry;c.setAttribute("position",new n.Float32BufferAttribute(i.vertices,3)),i.normals.length>0&&c.setAttribute("normal",new n.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(l=!0,c.setAttribute("color",new n.Float32BufferAttribute(i.colors,3))),!0===i.hasUVIndices&&c.setAttribute("uv",new n.Float32BufferAttribute(i.uvs,2));const u=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],i=t.name+"_"+t.smooth+"_"+l;let c=s.materials[i];if(null!==this.materials)if(c=this.materials.create(t.name),!o||!c||c instanceof n.LineBasicMaterial){if(a&&c&&!(c instanceof n.PointsMaterial)){const e=new n.PointsMaterial({size:10,sizeAttenuation:!1});n.Material.prototype.copy.call(e,c),e.color.copy(c.color),e.map=c.map,c=e}}else{const e=new n.LineBasicMaterial;n.Material.prototype.copy.call(e,c),e.color.copy(c.color),c=e}void 0===c&&((c=o?new n.LineBasicMaterial:a?new n.PointsMaterial({size:1,sizeAttenuation:!1}):new n.MeshPhongMaterial).name=t.name,c.flatShading=!t.smooth,c.vertexColors=l,s.materials[i]=c),u.push(c)}let h;if(u.length>1){for(let e=0,t=r.length;e<t;e++){const t=r[e];c.addGroup(t.groupStart,t.groupCount,e)}h=o?new n.LineSegments(c,u):a?new n.Points(c,u):new n.Mesh(c,u)}else h=o?new n.LineSegments(c,u[0]):a?new n.Points(c,u[0]):new n.Mesh(c,u[0]);h.name=t.name,f.add(h)}else if(s.vertices.length>0){const e=new n.PointsMaterial({size:1,sizeAttenuation:!1}),t=new n.BufferGeometry;t.setAttribute("position",new n.Float32BufferAttribute(s.vertices,3)),s.colors.length>0&&void 0!==s.colors[0]&&(t.setAttribute("color",new n.Float32BufferAttribute(s.colors,3)),e.vertexColors=!0);const i=new n.Points(t,e);f.add(i)}return f}}}(),I=I=n.OBJLoader;var P={};!function(){class e{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:n.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:n.RepeatWrapping}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const i in e){const n=e[i],r={};t[i]=r;for(const e in n){let t=!0,i=n[e];const o=e.toLowerCase();switch(o){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(i=[i[0]/255,i[1]/255,i[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===i[0]&&0===i[1]&&0===i[2]&&(t=!1)}t&&(r[o]=i)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,i=this.materialsInfo[e],r={name:e,side:this.side};function o(e,i){if(r[e])return;const n=t.getTextureParams(i,r),o=t.loadTexture((s=t.baseUrl,"string"!=typeof(a=n.url)||""===a?"":/^https?:\/\//i.test(a)?a:s+a));var s,a;o.repeat.copy(n.scale),o.offset.copy(n.offset),o.wrapS=t.wrap,o.wrapT=t.wrap,r[e]=o}for(const e in i){const t=i[e];let s;if(""!==t)switch(e.toLowerCase()){case"kd":r.color=(new n.Color).fromArray(t);break;case"ks":r.specular=(new n.Color).fromArray(t);break;case"ke":r.emissive=(new n.Color).fromArray(t);break;case"map_kd":o("map",t);break;case"map_ks":o("specularMap",t);break;case"map_ke":o("emissiveMap",t);break;case"norm":o("normalMap",t);break;case"map_bump":case"bump":o("bumpMap",t);break;case"map_d":o("alphaMap",t),r.transparent=!0;break;case"ns":r.shininess=parseFloat(t);break;case"d":(s=parseFloat(t))<1&&(r.opacity=s,r.transparent=!0);break;case"tr":s=parseFloat(t),this.options&&this.options.invertTrProperty&&(s=1-s),s>0&&(r.opacity=1-s,r.transparent=!0)}}return this.materials[e]=new n.MeshPhongMaterial(r),this.materials[e]}getTextureParams(e,t){const i={scale:new n.Vector2(1,1),offset:new n.Vector2(0,0)},r=e.split(/\s+/);let o;return(o=r.indexOf("-bm"))>=0&&(t.bumpScale=parseFloat(r[o+1]),r.splice(o,2)),(o=r.indexOf("-s"))>=0&&(i.scale.set(parseFloat(r[o+1]),parseFloat(r[o+2])),r.splice(o,4)),(o=r.indexOf("-o"))>=0&&(i.offset.set(parseFloat(r[o+1]),parseFloat(r[o+2])),r.splice(o,4)),i.url=r.join(" ").trim(),i}loadTexture(e,t,i,r,o){const s=void 0!==this.manager?this.manager:n.DefaultLoadingManager;let a=s.getHandler(e);null===a&&(a=new n.TextureLoader(s)),a.setCrossOrigin&&a.setCrossOrigin(this.crossOrigin);const l=a.load(e,i,r,o);return void 0!==t&&(l.mapping=t),l}}n.MTLLoader=class extends n.Loader{constructor(e){super(e)}load(e,t,i,r){const o=this,s=""===this.path?n.LoaderUtils.extractUrlBase(e||""):this.path,a=new n.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{t(o.parse(i,s))}catch(t){r?r(t):console.error(t),o.manager.itemError(e)}}),i,r)}setMaterialOptions(e){return this.materialOptions=e,this}parse(t,i){const n=t.split("\n");let r={};const o=/\s+/,s={};for(let e=0;e<n.length;e++){let t=n[e];if(0===(t=t.trim()).length||"#"===t.charAt(0))continue;const i=t.indexOf(" ");let a=i>=0?t.substring(0,i):t;a=a.toLowerCase();let l=i>=0?t.substring(i+1):"";if(l=l.trim(),"newmtl"===a)r={name:l},s[l]=r;else if("ka"===a||"kd"===a||"ks"===a||"ke"===a){const e=l.split(o,3);r[a]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else r[a]=l}const a=new e(this.resourcePath||i,this.materialOptions);return a.setCrossOrigin(this.crossOrigin),a.setManager(this.manager),a.setMaterials(s),a}}}(),P=P=n.MTLLoader;var R,k,z={},D=z={};function O(){throw new Error("setTimeout has not been defined")}function F(){throw new Error("clearTimeout has not been defined")}function B(e){if(R===setTimeout)return setTimeout(e,0);if((R===O||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}!function(){try{R="function"==typeof setTimeout?setTimeout:O}catch(e){R=O}try{k="function"==typeof clearTimeout?clearTimeout:F}catch(e){k=F}}();var N,U=[],j=!1,V=-1;function G(){j&&N&&(j=!1,N.length?U=N.concat(U):V=-1,U.length&&H())}function H(){if(!j){var e=B(G);j=!0;for(var t=U.length;t;){for(N=U,U=[];++V<t;)N&&N[V].run();V=-1,t=U.length}N=null,j=!1,function(e){if(k===clearTimeout)return clearTimeout(e);if((k===F||!k)&&clearTimeout)return k=clearTimeout,clearTimeout(e);try{k(e)}catch(t){try{return k.call(null,e)}catch(t){return k.call(this,e)}}}(e)}}function W(e,t){this.fun=e,this.array=t}function q(){}D.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];U.push(new W(e,t)),1!==U.length||j||B(H)},W.prototype.run=function(){this.fun.apply(null,this.array)},D.title="browser",D.browser=!0,D.env={},D.argv=[],D.version="",D.versions={},D.on=q,D.addListener=q,D.once=q,D.off=q,D.removeListener=q,D.removeAllListeners=q,D.emit=q,D.prependListener=q,D.prependOnceListener=q,D.listeners=function(e){return[]},D.binding=function(e){throw new Error("process.binding is not supported")},D.cwd=function(){return"/"},D.chdir=function(e){throw new Error("process.chdir is not supported")},D.umask=function(){return 0};var $={exports:{}};(function(e){(function(){!function(e){"object"==typeof $.exports?$.exports=e():"undefined"!=typeof define&&define.amd?define(["fflate",e]):("undefined"!=typeof self?self:this).fflate=e()}((function(){var t={__esModule:!0},i=("object"==typeof $.exports?function(t){"use strict";try{(void 0)("require('worker_threads')").Worker}catch(e){}return $.exports.default=function(t,i,n,r,o){e((function(){return o(Error("async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)"),null)}));var s=function(){};return{terminate:s,postMessage:s}},t}:function(e){"use strict";var t=eval;return e.default=function(e,i,n,r,o){var s=t[i]||(t[i]=URL.createObjectURL(new Blob([e],{type:"text/javascript"}))),a=new Worker(s);return a.onerror=function(e){return o(e.error,null)},a.onmessage=function(e){return o(null,e.data)},a.postMessage(n,r),a},e})({}),n=Uint8Array,r=Uint16Array,o=Uint32Array,s=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),c=function(e,t){for(var i=new r(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var s=new o(i[30]);for(n=1;n<30;++n)for(var a=i[n];a<i[n+1];++a)s[a]=a-i[n]<<5|n;return[i,s]},u=c(s,2),h=u[0],p=u[1];h[28]=258,p[258]=28;for(var d=c(a,0),f=d[0],m=d[1],g=new r(32768),_=0;_<32768;++_){var y=(43690&_)>>>1|(21845&_)<<1;g[_]=((65280&(y=(61680&(y=(52428&y)>>>2|(13107&y)<<2))>>>4|(3855&y)<<4))>>>8|(255&y)<<8)>>>1}var v=function(e,t,i){for(var n=e.length,o=0,s=new r(t);o<n;++o)++s[e[o]-1];var a,l=new r(t);for(o=0;o<t;++o)l[o]=l[o-1]+s[o-1]<<1;if(i){a=new r(1<<t);var c=15-t;for(o=0;o<n;++o)if(e[o])for(var u=o<<4|e[o],h=t-e[o],p=l[e[o]-1]++<<h,d=p|(1<<h)-1;p<=d;++p)a[g[p]>>>c]=u}else for(a=new r(n),o=0;o<n;++o)e[o]&&(a[o]=g[l[e[o]-1]++]>>>15-e[o]);return a},x=new n(288);for(_=0;_<144;++_)x[_]=8;for(_=144;_<256;++_)x[_]=9;for(_=256;_<280;++_)x[_]=7;for(_=280;_<288;++_)x[_]=8;var b=new n(32);for(_=0;_<32;++_)b[_]=5;var w=v(x,9,0),M=v(x,9,1),T=v(b,5,0),S=v(b,5,1),E=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},A=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},C=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},L=function(e){return(e/8|0)+(7&e&&1)},I=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof r?r:e instanceof o?o:n)(i-t);return s.set(e.subarray(t,i)),s},P=function(e,t,i){var r=e.length;if(!r||i&&!i.l&&r<5)return t||new n(0);var o=!t||i,c=!i||i.i;i||(i={}),t||(t=new n(3*r));var u=function(e){var i=t.length;if(e>i){var r=new n(Math.max(2*i,e));r.set(t),t=r}},p=i.f||0,d=i.p||0,m=i.b||0,g=i.l,_=i.d,y=i.m,x=i.n,b=8*r;do{if(!g){i.f=p=A(e,d,1);var w=A(e,d+1,3);if(d+=3,!w){var T=e[(j=L(d)+4)-4]|e[j-3]<<8,P=j+T;if(P>r){if(c)throw"unexpected EOF";break}o&&u(m+T),t.set(e.subarray(j,P),m),i.b=m+=T,i.p=d=8*P;continue}if(1==w)g=M,_=S,y=9,x=5;else{if(2!=w)throw"invalid block type";var R=A(e,d,31)+257,k=A(e,d+10,15)+4,z=R+A(e,d+5,31)+1;d+=14;for(var D=new n(z),O=new n(19),F=0;F<k;++F)O[l[F]]=A(e,d+3*F,7);d+=3*k;var B=E(O),N=(1<<B)-1;if(!c&&d+z*(B+7)>b)break;var U=v(O,B,1);for(F=0;F<z;){var j,V=U[A(e,d,N)];if(d+=15&V,(j=V>>>4)<16)D[F++]=j;else{var G=0,H=0;for(16==j?(H=3+A(e,d,3),d+=2,G=D[F-1]):17==j?(H=3+A(e,d,7),d+=3):18==j&&(H=11+A(e,d,127),d+=7);H--;)D[F++]=G}}var W=D.subarray(0,R),q=D.subarray(R);y=E(W),x=E(q),g=v(W,y,1),_=v(q,x,1)}if(d>b)throw"unexpected EOF"}o&&u(m+131072);for(var $=(1<<y)-1,Z=(1<<x)-1,X=y+x+18;c||d+X<b;){var Y=(G=g[C(e,d)&$])>>>4;if((d+=15&G)>b)throw"unexpected EOF";if(!G)throw"invalid length/literal";if(Y<256)t[m++]=Y;else{if(256==Y){g=null;break}var J=Y-254;Y>264&&(J=A(e,d,(1<<(ee=s[F=Y-257]))-1)+h[F],d+=ee);var Q=_[C(e,d)&Z],K=Q>>>4;if(!Q)throw"invalid distance";if(d+=15&Q,q=f[K],K>3){var ee=a[K];q+=C(e,d)&(1<<ee)-1,d+=ee}if(d>b)throw"unexpected EOF";o&&u(m+131072);for(var te=m+J;m<te;m+=4)t[m]=t[m-q],t[m+1]=t[m+1-q],t[m+2]=t[m+2-q],t[m+3]=t[m+3-q];m=te}}i.l=g,i.p=d,i.b=m,g&&(p=1,i.m=y,i.d=_,i.n=x)}while(!p);return m==t.length?t:I(t,0,m)},R=function(e,t,i){var n=t/8|0;e[n]|=i<<=7&t,e[n+1]|=i>>>8},k=function(e,t,i){var n=t/8|0;e[n]|=i<<=7&t,e[n+1]|=i>>>8,e[n+2]|=i>>>16},z=function(e,t){for(var i=[],o=0;o<e.length;++o)e[o]&&i.push({s:o,f:e[o]});var s=i.length,a=i.slice();if(!s)return[j,0];if(1==s){var l=new n(i[0].s+1);return l[i[0].s]=1,[l,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var c=i[0],u=i[1],h=0,p=1,d=2;for(i[0]={s:-1,f:c.f+u.f,l:c,r:u};p!=s-1;)c=i[i[h].f<i[d].f?h++:d++],u=i[h!=p&&i[h].f<i[d].f?h++:d++],i[p++]={s:-1,f:c.f+u.f,l:c,r:u};var f=a[0].s;for(o=1;o<s;++o)a[o].s>f&&(f=a[o].s);var m=new r(f+1),g=D(i[p-1],m,0);if(g>t){o=0;var _=0,y=g-t,v=1<<y;for(a.sort((function(e,t){return m[t.s]-m[e.s]||e.f-t.f}));o<s;++o){var x=a[o].s;if(!(m[x]>t))break;_+=v-(1<<g-m[x]),m[x]=t}for(_>>>=y;_>0;){var b=a[o].s;m[b]<t?_-=1<<t-m[b]++-1:++o}for(;o>=0&&_;--o){var w=a[o].s;m[w]==t&&(--m[w],++_)}g=t}return[new n(m),g]},D=function(e,t,i){return-1==e.s?Math.max(D(e.l,t,i+1),D(e.r,t,i+1)):t[e.s]=i},O=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new r(++t),n=0,o=e[0],s=1,a=function(e){i[n++]=e},l=1;l<=t;++l)if(e[l]==o&&l!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(o),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(o);s=1,o=e[l]}return[i.subarray(0,n),t]},F=function(e,t){for(var i=0,n=0;n<t.length;++n)i+=e[n]*t[n];return i},B=function(e,t,i){var n=i.length,r=L(t+2);e[r]=255&n,e[r+1]=n>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var o=0;o<n;++o)e[r+o+4]=i[o];return 8*(r+4+n)},N=function(e,t,i,n,o,c,u,h,p,d,f){R(t,f++,i),++o[256];for(var m=z(o,15),g=m[0],_=m[1],y=z(c,15),M=y[0],S=y[1],E=O(g),A=E[0],C=E[1],L=O(M),I=L[0],P=L[1],D=new r(19),N=0;N<A.length;++N)D[31&A[N]]++;for(N=0;N<I.length;++N)D[31&I[N]]++;for(var U=z(D,7),j=U[0],V=U[1],G=19;G>4&&!j[l[G-1]];--G);var H,W,q,$,Z=d+5<<3,X=F(o,x)+F(c,b)+u,Y=F(o,g)+F(c,M)+u+14+3*G+F(D,j)+(2*D[16]+3*D[17]+7*D[18]);if(Z<=X&&Z<=Y)return B(t,f,e.subarray(p,p+d));if(R(t,f,1+(Y<X)),f+=2,Y<X){H=v(g,_,0),W=g,q=v(M,S,0),$=M;var J=v(j,V,0);for(R(t,f,C-257),R(t,f+5,P-1),R(t,f+10,G-4),f+=14,N=0;N<G;++N)R(t,f+3*N,j[l[N]]);f+=3*G;for(var Q=[A,I],K=0;K<2;++K){var ee=Q[K];for(N=0;N<ee.length;++N)R(t,f,J[te=31&ee[N]]),f+=j[te],te>15&&(R(t,f,ee[N]>>>5&127),f+=ee[N]>>>12)}}else H=w,W=x,q=T,$=b;for(N=0;N<h;++N)if(n[N]>255){var te;k(t,f,H[257+(te=n[N]>>>18&31)]),f+=W[te+257],te>7&&(R(t,f,n[N]>>>23&31),f+=s[te]);var ie=31&n[N];k(t,f,q[ie]),f+=$[ie],ie>3&&(k(t,f,n[N]>>>5&8191),f+=a[ie])}else k(t,f,H[n[N]]),f+=W[n[N]];return k(t,f,H[256]),f+W[256]},U=new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),j=new n(0),V=function(e,t,i,l,c,u){var h=e.length,d=new n(l+h+5*(1+Math.ceil(h/7e3))+c),f=d.subarray(l,d.length-c),g=0;if(!t||h<8)for(var _=0;_<=h;_+=65535){var y=_+65535;y<h?g=B(f,g,e.subarray(_,y)):(f[_]=u,g=B(f,g,e.subarray(_,h)))}else{for(var v=U[t-1],x=v>>>13,b=8191&v,w=(1<<i)-1,M=new r(32768),T=new r(w+1),S=Math.ceil(i/3),E=2*S,A=function(t){return(e[t]^e[t+1]<<S^e[t+2]<<E)&w},C=new o(25e3),P=new r(288),R=new r(32),k=0,z=0,D=(_=0,0),O=0,F=0;_<h;++_){var V=A(_),G=32767&_,H=T[V];if(M[G]=H,T[V]=G,O<=_){var W=h-_;if((k>7e3||D>24576)&&W>423){g=N(e,f,0,C,P,R,z,D,F,_-F,g),D=k=z=0,F=_;for(var q=0;q<286;++q)P[q]=0;for(q=0;q<30;++q)R[q]=0}var $=2,Z=0,X=b,Y=G-H&32767;if(W>2&&V==A(_-Y))for(var J=Math.min(x,W)-1,Q=Math.min(32767,_),K=Math.min(258,W);Y<=Q&&--X&&G!=H;){if(e[_+$]==e[_+$-Y]){for(var ee=0;ee<K&&e[_+ee]==e[_+ee-Y];++ee);if(ee>$){if($=ee,Z=Y,ee>J)break;var te=Math.min(Y,ee-2),ie=0;for(q=0;q<te;++q){var ne=_-Y+q+32768&32767,re=ne-M[ne]+32768&32767;re>ie&&(ie=re,H=ne)}}}Y+=(G=H)-(H=M[G])+32768&32767}if(Z){C[D++]=268435456|p[$]<<18|m[Z];var oe=31&p[$],se=31&m[Z];z+=s[oe]+a[se],++P[257+oe],++R[se],O=_+$,++k}else C[D++]=e[_],++P[e[_]]}}g=N(e,f,u,C,P,R,z,D,F,_-F,g),!u&&7&g&&(g=B(f,g+1,j))}return I(d,0,l+L(g)+c)},G=function(){for(var e=new o(256),t=0;t<256;++t){for(var i=t,n=9;--n;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),H=function(){var e=-1;return{p:function(t){for(var i=e,n=0;n<t.length;++n)i=G[255&i^t[n]]^i>>>8;e=i},d:function(){return~e}}},W=function(){var e=1,t=0;return{p:function(i){for(var n=e,r=t,o=i.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s<a;++s)r+=n+=i[s];n=(65535&n)+15*(n>>16),r=(65535&r)+15*(r>>16)}e=n,t=r},d:function(){return((e%=65521)>>>8<<16|(255&(t%=65521))<<8|t>>>8)+2*((255&e)<<23)}}},q=function(e,t,i,n,r){return V(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,n,!r)},Z=function(e,t){var i={};for(var n in e)i[n]=e[n];for(var n in t)i[n]=t[n];return i},X=function(e,t,i){for(var n=e(),r=""+e,o=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/ /g,"").split(","),s=0;s<n.length;++s){var a=n[s],l=o[s];if("function"==typeof a){t+=";"+l+"=";var c=""+a;if(a.prototype)if(-1!=c.indexOf("[native code]")){var u=c.indexOf(" ",8)+1;t+=c.slice(u,c.indexOf("(",u))}else for(var h in t+=c,a.prototype)t+=";"+l+".prototype."+h+"="+a.prototype[h];else t+=c}else i[l]=a}return[t,i]},Y=[],J=function(e){var t=[];for(var i in e)(e[i]instanceof n||e[i]instanceof r||e[i]instanceof o)&&t.push((e[i]=new e[i].constructor(e[i])).buffer);return t},Q=function(e,t,n,r){var o;if(!Y[n]){for(var s="",a={},l=e.length-1,c=0;c<l;++c)s=(o=X(e[c],s,a))[0],a=o[1];Y[n]=X(e[l],s,a)}var u=Z({},Y[n][1]);return i.default(Y[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t+"}",n,u,J(u),r)},K=function(){return[n,r,o,s,a,l,h,f,M,S,g,v,E,A,C,L,I,P,Ce,oe,se]},ee=function(){return[n,r,o,s,a,l,p,m,w,x,T,b,g,U,j,v,R,k,z,D,O,F,B,N,L,I,V,q,Te,oe]},te=function(){return[fe,_e,de,H,G]},ie=function(){return[me,ge]},ne=function(){return[ye,de,W]},re=function(){return[ve]},oe=function(e){return postMessage(e,[e.buffer])},se=function(e){return e&&e.size&&new n(e.size)},ae=function(e,t,i,n,r,o){var s=Q(i,n,r,(function(e,t){s.terminate(),o(e,t)}));return s.postMessage([e,t],t.consume?[e.buffer]:[]),function(){s.terminate()}},le=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}},ce=function(e,t,i,n,r){var o,s=Q(e,n,r,(function(e,i){e?(s.terminate(),t.ondata.call(t,e)):(i[1]&&s.terminate(),t.ondata.call(t,e,i[0],i[1]))}));s.postMessage(i),t.push=function(e,i){if(o)throw"stream finished";if(!t.ondata)throw"no stream handler";s.postMessage([e,o=i],[e.buffer])},t.terminate=function(){s.terminate()}},ue=function(e,t){return e[t]|e[t+1]<<8},he=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+2*(e[t+3]<<23)},pe=function(e,t){return he(e,t)|4294967296*he(e,t)},de=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},fe=function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&de(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var n=0;n<=i.length;++n)e[n+10]=i.charCodeAt(n)}},me=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],i=10;4&t&&(i+=e[10]|2+(e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)},ge=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16)+2*(e[t-1]<<23)},_e=function(e){return 10+(e.filename&&e.filename.length+1||0)},ye=function(e,t){var i=t.level,n=0==i?0:i<6?1:9==i?3:2;e[0]=120,e[1]=n<<6|(n?32-2*n:1)},ve=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function xe(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var be=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(q(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}();t.Deflate=be;var we=function(e,t){ce([ee,function(){return[le,be]}],this,xe.call(this,e,t),(function(e){var t=new be(e.data);onmessage=le(t)}),6)};function Me(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[ee],(function(e){return oe(Te(e.data[0],e.data[1]))}),0,i)}function Te(e,t){return q(e,t||{},0,0)}t.AsyncDeflate=we,t.deflate=Me,t.deflateSync=Te;var Se=function(){function e(e){this.s={},this.p=new n(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,i=new n(t+e.length);i.set(this.p),i.set(e,t),this.p=i},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,i=P(this.p,this.o,this.s);this.ondata(I(i,t,this.s.b),this.d),this.o=I(i,this.s.b-32768),this.s.b=this.o.length,this.p=I(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();t.Inflate=Se;var Ee=function(e){this.ondata=e,ce([K,function(){return[le,Se]}],this,0,(function(){var e=new Se;onmessage=le(e)}),7)};function Ae(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[K],(function(e){return oe(Ce(e.data[0],se(e.data[1])))}),1,i)}function Ce(e,t){return P(e,t)}t.AsyncInflate=Ee,t.inflate=Ae,t.inflateSync=Ce;var Le=function(){function e(e,t){this.c=H(),this.l=0,this.v=1,be.call(this,e,t)}return e.prototype.push=function(e,t){be.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var i=q(e,this.o,this.v&&_e(this.o),t&&8,!t);this.v&&(fe(i,this.o),this.v=0),t&&(de(i,i.length-8,this.c.d()),de(i,i.length-4,this.l)),this.ondata(i,t)},e}();t.Gzip=Le,t.Compress=Le;var Ie=function(e,t){ce([ee,te,function(){return[le,be,Le]}],this,xe.call(this,e,t),(function(e){var t=new Le(e.data);onmessage=le(t)}),8)};function Pe(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[ee,te,function(){return[Re]}],(function(e){return oe(Re(e.data[0],e.data[1]))}),2,i)}function Re(e,t){t||(t={});var i=H(),n=e.length;i.p(e);var r=q(e,t,_e(t),8),o=r.length;return fe(r,t),de(r,o-8,i.d()),de(r,o-4,n),r}t.AsyncGzip=Ie,t.AsyncCompress=Ie,t.gzip=Pe,t.compress=Pe,t.gzipSync=Re,t.compressSync=Re;var ke=function(){function e(e){this.v=1,Se.call(this,e)}return e.prototype.push=function(e,t){if(Se.prototype.e.call(this,e),this.v){var i=this.p.length>3?me(this.p):4;if(i>=this.p.length&&!t)return;this.p=this.p.subarray(i),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Se.prototype.c.call(this,t)},e}();t.Gunzip=ke;var ze=function(e){this.ondata=e,ce([K,ie,function(){return[le,Se,ke]}],this,0,(function(){var e=new ke;onmessage=le(e)}),9)};function De(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[K,ie,function(){return[Oe]}],(function(e){return oe(Oe(e.data[0]))}),3,i)}function Oe(e,t){return P(e.subarray(me(e),-8),t||new n(ge(e)))}t.AsyncGunzip=ze,t.gunzip=De,t.gunzipSync=Oe;var Fe=function(){function e(e,t){this.c=W(),this.v=1,be.call(this,e,t)}return e.prototype.push=function(e,t){be.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var i=q(e,this.o,this.v&&2,t&&4,!t);this.v&&(ye(i,this.o),this.v=0),t&&de(i,i.length-4,this.c.d()),this.ondata(i,t)},e}();t.Zlib=Fe;function Be(e,t){t||(t={});var i=W();i.p(e);var n=q(e,t,2,4);return ye(n,t),de(n,n.length-4,i.d()),n}t.AsyncZlib=function(e,t){ce([ee,ne,function(){return[le,be,Fe]}],this,xe.call(this,e,t),(function(e){var t=new Fe(e.data);onmessage=le(t)}),10)},t.zlib=function(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[ee,ne,function(){return[Be]}],(function(e){return oe(Be(e.data[0],e.data[1]))}),4,i)},t.zlibSync=Be;var Ne=function(){function e(e){this.v=1,Se.call(this,e)}return e.prototype.push=function(e,t){if(Se.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Se.prototype.c.call(this,t)},e}();t.Unzlib=Ne;var Ue=function(e){this.ondata=e,ce([K,re,function(){return[le,Se,Ne]}],this,0,(function(){var e=new Ne;onmessage=le(e)}),11)};function je(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[K,re,function(){return[Ve]}],(function(e){return oe(Ve(e.data[0],se(e.data[1])))}),5,i)}function Ve(e,t){return P((ve(e),e.subarray(2,-4)),t)}t.AsyncUnzlib=Ue,t.unzlib=je,t.unzlibSync=Ve;var Ge=function(){function e(e){this.G=ke,this.I=Se,this.Z=Ne,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var i=new n(this.p.length+e.length);i.set(this.p),i.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var r=this,o=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(o):new this.Z(o),this.s.push(this.p,t),this.p=null}}},e}();t.Decompress=Ge;var He=function(){function e(e){this.G=ze,this.I=Ee,this.Z=Ue,this.ondata=e}return e.prototype.push=function(e,t){Ge.prototype.push.call(this,e,t)},e}();t.AsyncDecompress=He,t.decompress=function(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?De(e,t,i):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Ae(e,t,i):je(e,t,i)},t.decompressSync=function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?Oe(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Ce(e,t):Ve(e,t)};var We=function(e,t,i,r){for(var o in e){var s=e[o],a=t+o;s instanceof n?i[a]=[s,r]:Array.isArray(s)?i[a]=[s[0],Z(r,s[1])]:We(s,a+"/",i,r)}},qe="undefined"!=typeof TextEncoder&&new TextEncoder,$e="undefined"!=typeof TextDecoder&&new TextDecoder,Ze=0;try{$e.decode(j,{stream:!0}),Ze=1}catch(i){}var Xe=function(e){for(var t="",i=0;;){var n=e[i++],r=(n>127)+(n>223)+(n>239);if(i+r>e.length)return[t,I(e,i-1)];r?3==r?(n=((15&n)<<18|(63&e[i++])<<12|(63&e[i++])<<6|63&e[i++])-65536,t+=String.fromCharCode(55296|n>>10,56320|1023&n)):t+=String.fromCharCode(1&r?(31&n)<<6|63&e[i++]:(15&n)<<12|(63&e[i++])<<6|63&e[i++]):t+=String.fromCharCode(n)}},Ye=function(){function e(e){this.ondata=e,Ze?this.t=new TextDecoder:this.p=j}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t||(t=!1),this.t)return this.ondata(this.t.decode(e,{stream:!t}),t);var i=new n(this.p.length+e.length);i.set(this.p),i.set(e,this.p.length);var r=Xe(i),o=r[0],s=r[1];if(t&&s.length)throw"invalid utf-8 data";this.p=s,this.ondata(o,t)},e}();t.DecodeUTF8=Ye;var Je=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";this.ondata(Qe(e),t||!1)},e}();function Qe(e,t){if(t){for(var i=new n(e.length),r=0;r<e.length;++r)i[r]=e.charCodeAt(r);return i}if(qe)return qe.encode(e);var o=e.length,s=new n(e.length+(e.length>>1)),a=0,l=function(e){s[a++]=e};for(r=0;r<o;++r){if(a+5>s.length){var c=new n(a+8+(o-r<<1));c.set(s),s=c}var u=e.charCodeAt(r);u<128||t?l(u):u<2048?(l(192|u>>>6),l(128|63&u)):u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++r))>>>18),l(128|u>>>12&63),l(128|u>>>6&63),l(128|63&u)):(l(224|u>>>12),l(128|u>>>6&63),l(128|63&u))}return I(s,0,a)}function Ke(e,t){if(t){for(var i="",n=0;n<e.length;n+=16384)i+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return i}if($e)return $e.decode(e);var r=Xe(e);if(r[1].length)throw"invalid utf-8 data";return r[0]}t.EncodeUTF8=Je,t.strToU8=Qe,t.strFromU8=Ke;var et=function(e){return 1==e?3:e<6?2:9==e?1:0},tt=function(e,t){return t+30+ue(e,t+26)+ue(e,t+28)},it=function(e,t,i){var n=ue(e,t+28),r=Ke(e.subarray(t+46,t+46+n),!(2048&ue(e,t+8))),o=t+46+n,s=he(e,t+20),a=i&&4294967295==s?nt(e,o):[s,he(e,t+24),he(e,t+42)],l=a[0],c=a[1],u=a[2];return[ue(e,t+10),l,c,r,o+ue(e,t+30)+ue(e,t+32),u]},nt=function(e,t){for(;1!=ue(e,t);t+=4+ue(e,t+2));return[pe(e,t+12),pe(e,t+4),pe(e,t+20)]},rt=function(e){var t=0;if(e)for(var i in e){var n=e[i].length;if(n>65535)throw"extra field too long";t+=n+4}return t},ot=function(e,t,i,n,r,o,s,a){var l=n.length,c=i.extra,u=a&&a.length,h=rt(c);de(e,t,null!=s?33639248:67324752),t+=4,null!=s&&(e[t++]=20,e[t++]=i.os),e[t]=20,t+=2,e[t++]=i.flag<<1|(null==o&&8),e[t++]=r&&8,e[t++]=255&i.compression,e[t++]=i.compression>>8;var p=new Date(null==i.mtime?Date.now():i.mtime),d=p.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(de(e,t,2*(d<<24)|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),t+=4,null!=o&&(de(e,t,i.crc),de(e,t+4,o),de(e,t+8,i.size)),de(e,t+12,l),de(e,t+14,h),t+=16,null!=s&&(de(e,t,u),de(e,t+6,i.attrs),de(e,t+10,s),t+=14),e.set(n,t),t+=l,h)for(var f in c){var m=c[f],g=m.length;de(e,t,+f),de(e,t+2,g),e.set(m,t+4),t+=4+g}return u&&(e.set(a,t),t+=u),t},st=function(e,t,i,n,r){de(e,t,101010256),de(e,t+8,i),de(e,t+10,i),de(e,t+12,n),de(e,t+16,r)},at=function(){function e(e){this.filename=e,this.c=H(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();t.ZipPassThrough=at;var lt=function(){function e(e,t){var i=this;t||(t={}),at.call(this,e),this.d=new be(t,(function(e,t){i.ondata(null,e,t)})),this.compression=8,this.flag=et(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){at.prototype.push.call(this,e,t)},e}();t.ZipDeflate=lt;var ct=function(){function e(e,t){var i=this;t||(t={}),at.call(this,e),this.d=new we(t,(function(e,t,n){i.ondata(e,t,n)})),this.compression=8,this.flag=et(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){at.prototype.push.call(this,e,t)},e}();t.AsyncZipDeflate=ct;var ut=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var i=Qe(e.filename),r=i.length,o=e.comment,s=o&&Qe(o),a=r!=e.filename.length||s&&o.length!=s.length,l=r+rt(e.extra)+30;if(r>65535)throw"filename too long";var c=new n(l);ot(c,0,e,i,a);var u=[c],h=function(){for(var e=0,i=u;e<i.length;e++)t.ondata(null,i[e],!1);u=[]},p=this.d;this.d=0;var d=this.u.length,f=Z(e,{f:i,u:a,o:s,t:function(){e.terminate&&e.terminate()},r:function(){if(h(),p){var e=t.u[d+1];e?e.r():t.d=1}p=1}}),m=0;e.ondata=function(i,r,o){if(i)t.ondata(i,r,o),t.terminate();else if(m+=r.length,u.push(r),o){var s=new n(16);de(s,0,134695760),de(s,4,e.crc),de(s,8,m),de(s,12,e.size),u.push(s),f.c=m,f.b=l+m+16,f.crc=e.crc,f.size=e.size,p&&f.r(),p=1}else p&&h()},this.u.push(f)},e.prototype.end=function(){var e=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,i=0,r=0,o=this.u;r<o.length;r++)i+=46+(c=o[r]).f.length+rt(c.extra)+(c.o?c.o.length:0);for(var s=new n(i+22),a=0,l=this.u;a<l.length;a++){var c;ot(s,e,c=l[a],c.f,c.u,c.c,t,c.o),e+=46+c.f.length+rt(c.extra)+(c.o?c.o.length:0),t+=c.b}st(s,e,this.u.length,i,t),this.ondata(null,s,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2},e}();t.Zip=ut,t.zip=function(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";var r={};We(e,"",r,t);var o=Object.keys(r),s=o.length,a=0,l=0,c=s,u=Array(s),h=[],p=function(){for(var e=0;e<h.length;++e)h[e]()},d=function(){var e=new n(l+22),t=a,r=l-a;l=0;for(var o=0;o<c;++o){var s=u[o];try{var h=s.c.length;ot(e,l,s,s.f,s.u,h);var p=30+s.f.length+rt(s.extra),d=l+p;e.set(s.c,d),ot(e,a,s,s.f,s.u,h,l,s.m),a+=16+p+(s.m?s.m.length:0),l=d+h}catch(e){return i(e,null)}}st(e,a,u.length,r,t),i(null,e)};s||d();for(var f=function(e){var t=o[e],n=r[t],c=n[0],f=n[1],m=H(),g=c.length;m.p(c);var _=Qe(t),y=_.length,v=f.comment,x=v&&Qe(v),b=x&&x.length,w=rt(f.extra),M=0==f.level?0:8,T=function(n,r){if(n)p(),i(n,null);else{var o=r.length;u[e]=Z(f,{size:g,crc:m.d(),c:r,f:_,m:x,u:y!=t.length||x&&v.length!=b,compression:M}),a+=30+y+w+o,l+=76+2*(y+w)+(b||0)+o,--s||d()}};if(y>65535&&T("filename too long",null),M)if(g<16e4)try{T(null,Te(c,f))}catch(e){T(e,null)}else h.push(Me(c,f,T));else T(null,c)},m=0;m<c;++m)f(m);return p},t.zipSync=function(e,t){t||(t={});var i={},r=[];We(e,"",i,t);var o=0,s=0;for(var a in i){var l=i[a],c=l[0],u=l[1],h=0==u.level?0:8,p=(T=Qe(a)).length,d=u.comment,f=d&&Qe(d),m=f&&f.length,g=rt(u.extra);if(p>65535)throw"filename too long";var _=h?Te(c,u):c,y=_.length,v=H();v.p(c),r.push(Z(u,{size:c.length,crc:v.d(),c:_,f:T,m:f,u:p!=a.length||f&&d.length!=m,o:o,compression:h})),o+=30+p+g+y,s+=76+2*(p+g)+(m||0)+y}for(var x=new n(s+22),b=o,w=s-o,M=0;M<r.length;++M){var T;ot(x,(T=r[M]).o,T,T.f,T.u,T.c.length);var S=30+T.f.length+rt(T.extra);x.set(T.c,T.o+S),ot(x,o,T,T.f,T.u,T.c.length,T.o,T.m),o+=16+S+(T.m?T.m.length:0)}return st(x,o,r.length,w,b),x};var ht=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}();t.UnzipPassThrough=ht;var pt=function(){function e(){var e=this;this.i=new Se((function(t,i){e.ondata(null,t,i)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(i){this.ondata(i,e,t)}},e.compression=8,e}();t.UnzipInflate=pt;var dt=function(){function e(e,t){var i=this;t<32e4?this.i=new Se((function(e,t){i.ondata(null,e,t)})):(this.i=new Ee((function(e,t,n){i.ondata(e,t,n)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=I(e,0)),this.i.push(e,t)},e.compression=8,e}();t.AsyncUnzipInflate=dt;var ft=function(){function e(e){this.onfile=e,this.k=[],this.o={0:ht},this.p=j}return e.prototype.push=function(e,t){var i=this;if(!this.onfile)throw"no callback";if(this.c>0){var r=Math.min(this.c,e.length),o=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(o,!this.c):this.k[0].push(o),(e=e.subarray(r)).length)return this.push(e,t)}else{var s=0,a=0,l=void 0,c=void 0;this.p.length?e.length?((c=new n(this.p.length+e.length)).set(this.p),c.set(e,this.p.length)):c=this.p:c=e;for(var u=c.length,h=this.c,p=h&&this.d,d=function(){var e,t=he(c,a);if(67324752==t){s=1,l=a,f.d=null,f.c=0;var n=ue(c,a+6),r=ue(c,a+8),o=2048&n,p=8&n,d=ue(c,a+26),m=ue(c,a+28);if(u>a+30+d+m){var g=[];f.k.unshift(g),s=2;var _=he(c,a+18),y=he(c,a+22),v=Ke(c.subarray(a+30,a+=30+d),!o);4294967295==_?(e=p?[-2]:nt(c,a),_=e[0],y=e[1]):p&&(_=-1),a+=m,f.c=_;var x={name:v,compression:r,start:function(){if(!x.ondata)throw"no callback";if(_){var e=i.o[r];if(!e)throw"unknown compression type "+r;var t=_<0?new e(v):new e(v,_,y);t.ondata=function(e,t,i){x.ondata(e,t,i)};for(var n=0,o=g;n<o.length;n++)t.push(o[n],!1);i.k[0]==g?i.d=t:t.push(j,!0)}else x.ondata(null,j,!0)},terminate:function(){i.k[0]==g&&i.d.terminate&&i.d.terminate()}};_>=0&&(x.size=_,x.originalSize=y),f.onfile(x)}return"break"}if(h){if(134695760==t)return l=a+=12+(-2==h&&8),s=2,f.c=0,"break";if(33639248==t)return l=a-=4,s=2,f.c=0,"break"}},f=this;a<u-4&&"break"!==d();++a);if(this.p=j,h<0){var m=c.subarray(0,s?l-12-(-2==h&&8)-(134695760==he(c,l-16)&&4):a);p?p.push(m,!!s):this.k[+(2==s)].push(m)}if(2&s)return this.push(c.subarray(a),t);this.p=c.subarray(a)}if(t&&this.c)throw"invalid zip file"},e.prototype.register=function(e){this.o[e.compression]=e},e}();return t.Unzip=ft,t.unzip=function(e,t){if("function"!=typeof t)throw"no callback";for(var i=[],r=function(){for(var e=0;e<i.length;++e)i[e]()},o={},s=e.length-22;101010256!=he(e,s);--s)if(!s||e.length-s>65558)return void t("invalid zip file",null);var a=ue(e,s+8);a||t(null,{});var l=a,c=he(e,s+16),u=4294967295==c;if(u){if(s=he(e,s-12),101075792!=he(e,s))return void t("invalid zip file",null);l=a=he(e,s+32),c=he(e,s+48)}for(var h=function(s){var l=it(e,c,u),h=l[0],p=l[1],d=l[2],f=l[3],m=l[4],g=tt(e,l[5]);c=m;var _=function(e,i){e?(r(),t(e,null)):(o[f]=i,--a||t(null,o))};if(h)if(8==h){var y=e.subarray(g,g+p);if(p<32e4)try{_(null,Ce(y,new n(d)))}catch(e){_(e,null)}else i.push(Ae(y,{size:d},_))}else _("unknown compression type "+h,null);else _(null,I(e,g,g+p))},p=0;p<l;++p)h();return r},t.unzipSync=function(e){for(var t={},i=e.length-22;101010256!=he(e,i);--i)if(!i||e.length-i>65558)throw"invalid zip file";var r=ue(e,i+8);if(!r)return{};var o=he(e,i+16),s=4294967295==o;if(s){if(i=he(e,i-12),101075792!=he(e,i))throw"invalid zip file";r=he(e,i+32),o=he(e,i+48)}for(var a=0;a<r;++a){var l=it(e,o,s),c=l[0],u=l[1],h=l[2],p=l[3],d=l[4],f=tt(e,l[5]);if(o=d,c){if(8!=c)throw"unknown compression type "+c;t[p]=Ce(e.subarray(f,f+u),new n(h))}else t[p]=I(e,f,f+u)}return t},t}))}).call(this)}).call(this,i({}).setImmediate),$=$.exports;var Z={};!function(){let e,t,i;class r{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){t=this.parseConnections();const e=this.parseImages(),n=this.parseTextures(e),r=this.parseMaterials(n),s=this.parseDeformers(),a=(new o).parse(s);return this.parseScene(s,a,r),i}parseConnections(){const t=new Map;return"Connections"in e&&e.Connections.connections.forEach((function(e){const i=e[0],n=e[1],r=e[2];t.has(i)||t.set(i,{parents:[],children:[]});const o={ID:n,relationship:r};t.get(i).parents.push(o),t.has(n)||t.set(n,{parents:[],children:[]});const s={ID:i,relationship:r};t.get(n).children.push(s)})),t}parseImages(){const t={},i={};if("Video"in e.Objects){const n=e.Objects.Video;for(const e in n){const r=n[e];if(t[parseInt(e)]=r.RelativeFilename||r.Filename,"Content"in r){const t=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,o="string"==typeof r.Content&&""!==r.Content;if(t||o){const t=this.parseImage(n[e]);i[r.RelativeFilename||r.Filename]=t}}}}for(const e in t){const n=t[e];void 0!==i[n]?t[e]=i[n]:t[e]=t[e].split("\\").pop()}return t}parseImage(e){const t=e.Content,i=e.RelativeFilename||e.Filename,n=i.slice(i.lastIndexOf(".")+1).toLowerCase();let r;switch(n){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),r="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+n+'" is not supported.')}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(t){const i=new Map;if("Texture"in e.Objects){const n=e.Objects.Texture;for(const e in n){const r=this.parseTexture(n[e],t);i.set(parseInt(e),r)}}return i}parseTexture(e,t){const i=this.loadTexture(e,t);i.ID=e.id,i.name=e.attrName;const r=e.WrapModeU,o=e.WrapModeV,s=void 0!==r?r.value:0,a=void 0!==o?o.value:0;if(i.wrapS=0===s?n.RepeatWrapping:n.ClampToEdgeWrapping,i.wrapT=0===a?n.RepeatWrapping:n.ClampToEdgeWrapping,"Scaling"in e){const t=e.Scaling.value;i.repeat.x=t[0],i.repeat.y=t[1]}return i}loadTexture(e,i){let r;const o=this.textureLoader.path,s=t.get(e.id).children;let a;void 0!==s&&s.length>0&&void 0!==i[s[0].ID]&&(0!==(r=i[s[0].ID]).indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));const l=e.FileName.slice(-3).toLowerCase();if("tga"===l){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new n.Texture):(t.setPath(this.textureLoader.path),a=t.load(r))}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new n.Texture):a=this.textureLoader.load(r);return this.textureLoader.setPath(o),a}parseMaterials(t){const i=new Map;if("Material"in e.Objects){const n=e.Objects.Material;for(const e in n){const r=this.parseMaterial(n[e],t);null!==r&&i.set(parseInt(e),r)}}return i}parseMaterial(e,i){const r=e.id,o=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!t.has(r))return null;const a=this.parseParameters(e,i,r);let l;switch(s.toLowerCase()){case"phong":l=new n.MeshPhongMaterial;break;case"lambert":l=new n.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',s),l=new n.MeshPhongMaterial}return l.setValues(a),l.name=o,l}parseParameters(e,i,r){const o={};e.BumpFactor&&(o.bumpScale=e.BumpFactor.value),e.Diffuse?o.color=(new n.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(o.color=(new n.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(o.displacementScale=e.DisplacementFactor.value),e.Emissive?o.emissive=(new n.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(o.emissive=(new n.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(o.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(o.opacity=parseFloat(e.Opacity.value)),o.opacity<1&&(o.transparent=!0),e.ReflectionFactor&&(o.reflectivity=e.ReflectionFactor.value),e.Shininess&&(o.shininess=e.Shininess.value),e.Specular?o.specular=(new n.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(o.specular=(new n.Color).fromArray(e.SpecularColor.value));const s=this;return t.get(r).children.forEach((function(e){const t=e.relationship;switch(t){case"Bump":o.bumpMap=s.getTexture(i,e.ID);break;case"Maya|TEX_ao_map":o.aoMap=s.getTexture(i,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=s.getTexture(i,e.ID),void 0!==o.map&&(o.map.encoding=n.sRGBEncoding);break;case"DisplacementColor":o.displacementMap=s.getTexture(i,e.ID);break;case"EmissiveColor":o.emissiveMap=s.getTexture(i,e.ID),void 0!==o.emissiveMap&&(o.emissiveMap.encoding=n.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=s.getTexture(i,e.ID);break;case"ReflectionColor":o.envMap=s.getTexture(i,e.ID),void 0!==o.envMap&&(o.envMap.mapping=n.EquirectangularReflectionMapping,o.envMap.encoding=n.sRGBEncoding);break;case"SpecularColor":o.specularMap=s.getTexture(i,e.ID),void 0!==o.specularMap&&(o.specularMap.encoding=n.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=s.getTexture(i,e.ID),o.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",t)}})),o}getTexture(i,n){return"LayeredTexture"in e.Objects&&n in e.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),n=t.get(n).children[0].ID),i.get(n)}parseDeformers(){const i={},n={};if("Deformer"in e.Objects){const r=e.Objects.Deformer;for(const e in r){const o=r[e],s=t.get(parseInt(e));if("Skin"===o.attrType){const t=this.parseSkeleton(s,r);t.ID=e,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,i[e]=t}else if("BlendShape"===o.attrType){const t={id:e};t.rawTargets=this.parseMorphTargets(s,r),t.id=e,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),n[e]=t}}}return{skeletons:i,morphTargets:n}}parseSkeleton(e,t){const i=[];return e.children.forEach((function(e){const r=t[e.ID];if("Cluster"!==r.attrType)return;const o={ID:e.ID,indices:[],weights:[],transformLink:(new n.Matrix4).fromArray(r.TransformLink.a)};"Indexes"in r&&(o.indices=r.Indexes.a,o.weights=r.Weights.a),i.push(o)})),{rawBones:i,bones:[]}}parseMorphTargets(e,i){const n=[];for(let r=0;r<e.children.length;r++){const o=e.children[r],s=i[o.ID],a={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;a.geoID=t.get(parseInt(o.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(a)}return n}parseScene(r,o,a){i=new n.Group;const l=this.parseModels(r.skeletons,o,a),c=e.Objects.Model,u=this;l.forEach((function(e){const n=c[e.ID];u.setLookAtProperties(e,n),t.get(e.ID).parents.forEach((function(t){const i=l.get(t.ID);void 0!==i&&i.add(e)})),null===e.parent&&i.add(e)})),this.bindSkeleton(r.skeletons,o,l),this.createAmbientLight(),i.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=_(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const h=(new s).parse();1===i.children.length&&i.children[0].isGroup&&(i.children[0].animations=h,i=i.children[0]),i.animations=h}parseModels(i,r,o){const s=new Map,a=e.Objects.Model;for(const e in a){const l=parseInt(e),c=a[e],u=t.get(l);let h=this.buildSkeleton(u,i,l,c.attrName);if(!h){switch(c.attrType){case"Camera":h=this.createCamera(u);break;case"Light":h=this.createLight(u);break;case"Mesh":h=this.createMesh(u,r,o);break;case"NurbsCurve":h=this.createCurve(u,r);break;case"LimbNode":case"Root":h=new n.Bone;break;default:h=new n.Group}h.name=c.attrName?n.PropertyBinding.sanitizeNodeName(c.attrName):"",h.ID=l}this.getTransformData(h,c),s.set(l,h)}return s}buildSkeleton(e,t,i,r){let o=null;return e.parents.forEach((function(e){for(const s in t){const a=t[s];a.rawBones.forEach((function(t,s){if(t.ID===e.ID){const e=o;(o=new n.Bone).matrixWorld.copy(t.transformLink),o.name=r?n.PropertyBinding.sanitizeNodeName(r):"",o.ID=i,a.bones[s]=o,null!==e&&o.add(e)}}))}})),o}createCamera(t){let i,r;if(t.children.forEach((function(t){const i=e.Objects.NodeAttribute[t.ID];void 0!==i&&(r=i)})),void 0===r)i=new n.Object3D;else{let e=0;void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(e=1);let t=1;void 0!==r.NearPlane&&(t=r.NearPlane.value/1e3);let o=1e3;void 0!==r.FarPlane&&(o=r.FarPlane.value/1e3);let s=window.innerWidth,a=window.innerHeight;void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(s=r.AspectWidth.value,a=r.AspectHeight.value);const l=s/a;let c=45;void 0!==r.FieldOfView&&(c=r.FieldOfView.value);const u=r.FocalLength?r.FocalLength.value:null;switch(e){case 0:i=new n.PerspectiveCamera(c,l,t,o),null!==u&&i.setFocalLength(u);break;case 1:i=new n.OrthographicCamera(-s/2,s/2,a/2,-a/2,t,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),i=new n.Object3D}}return i}createLight(t){let i,r;if(t.children.forEach((function(t){const i=e.Objects.NodeAttribute[t.ID];void 0!==i&&(r=i)})),void 0===r)i=new n.Object3D;else{let e;e=void 0===r.LightType?0:r.LightType.value;let t=16777215;void 0!==r.Color&&(t=(new n.Color).fromArray(r.Color.value));let o=void 0===r.Intensity?1:r.Intensity.value/100;void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(o=0);let s=0;void 0!==r.FarAttenuationEnd&&(s=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value);const a=1;switch(e){case 0:i=new n.PointLight(t,o,s,a);break;case 1:i=new n.DirectionalLight(t,o);break;case 2:let e=Math.PI/3;void 0!==r.InnerAngle&&(e=n.MathUtils.degToRad(r.InnerAngle.value));let l=0;void 0!==r.OuterAngle&&(l=n.MathUtils.degToRad(r.OuterAngle.value),l=Math.max(l,1)),i=new n.SpotLight(t,o,s,e,l,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a THREE.PointLight."),i=new n.PointLight(t,o)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(i.castShadow=!0)}return i}createMesh(e,t,i){let r,o=null,s=null;const a=[];return e.children.forEach((function(e){t.has(e.ID)&&(o=t.get(e.ID)),i.has(e.ID)&&a.push(i.get(e.ID))})),a.length>1?s=a:a.length>0?s=a[0]:(s=new n.MeshPhongMaterial({color:13421772}),a.push(s)),"color"in o.attributes&&a.forEach((function(e){e.vertexColors=!0})),o.FBX_Deformer?(r=new n.SkinnedMesh(o,s)).normalizeSkinWeights():r=new n.Mesh(o,s),r}createCurve(e,t){const i=e.children.reduce((function(e,i){return t.has(i.ID)&&(e=t.get(i.ID)),e}),null),r=new n.LineBasicMaterial({color:3342591,linewidth:1});return new n.Line(i,r)}getTransformData(e,t){const i={};"InheritType"in t&&(i.inheritType=parseInt(t.InheritType.value)),i.eulerOrder="RotationOrder"in t?y(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(i.translation=t.Lcl_Translation.value),"PreRotation"in t&&(i.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(i.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(i.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(i.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(i.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(i.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(i.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(i.rotationPivot=t.RotationPivot.value),e.userData.transformData=i}setLookAtProperties(r,o){"LookAtProperty"in o&&t.get(r.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const o=e.Objects.Model[t.ID];if("Lcl_Translation"in o){const e=o.Lcl_Translation.value;void 0!==r.target?(r.target.position.fromArray(e),i.add(r.target)):r.lookAt((new n.Vector3).fromArray(e))}}}))}bindSkeleton(e,i,r){const o=this.parsePoseNodes();for(const s in e){const a=e[s];t.get(parseInt(a.ID)).parents.forEach((function(e){if(i.has(e.ID)){const i=e.ID;t.get(i).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new n.Skeleton(a.bones),o[e.ID])}))}}))}}parsePoseNodes(){const t={};if("Pose"in e.Objects){const i=e.Objects.Pose;for(const e in i)if("BindPose"===i[e].attrType){const r=i[e].PoseNode;Array.isArray(r)?r.forEach((function(e){t[e.Node]=(new n.Matrix4).fromArray(e.Matrix.a)})):t[r.Node]=(new n.Matrix4).fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in e&&"AmbientColor"in e.GlobalSettings){const t=e.GlobalSettings.AmbientColor.value,r=t[0],o=t[1],s=t[2];if(0!==r||0!==o||0!==s){const e=new n.Color(r,o,s);i.add(new n.AmbientLight(e,1))}}}}class o{parse(i){const n=new Map;if("Geometry"in e.Objects){const r=e.Objects.Geometry;for(const e in r){const o=t.get(parseInt(e)),s=this.parseGeometry(o,r[e],i);n.set(parseInt(e),s)}}return n}parseGeometry(e,t,i){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,i);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(t,i,n){const r=n.skeletons,o=[],s=t.parents.map((function(t){return e.Objects.Model[t.ID]}));if(0===s.length)return;const a=t.children.reduce((function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e}),null);t.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&o.push(n.morphTargets[e.ID])}));const l=s[0],c={};"RotationOrder"in l&&(c.eulerOrder=y(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const u=_(c);return this.genGeometry(i,a,o,u)}genGeometry(e,t,i,r){const o=new n.BufferGeometry;e.attrName&&(o.name=e.attrName);const s=this.parseGeoNode(e,t),a=this.genBuffers(s),l=new n.Float32BufferAttribute(a.vertex,3);if(l.applyMatrix4(r),o.setAttribute("position",l),a.colors.length>0&&o.setAttribute("color",new n.Float32BufferAttribute(a.colors,3)),t&&(o.setAttribute("skinIndex",new n.Uint16BufferAttribute(a.weightsIndices,4)),o.setAttribute("skinWeight",new n.Float32BufferAttribute(a.vertexWeights,4)),o.FBX_Deformer=t),a.normal.length>0){const e=(new n.Matrix3).getNormalMatrix(r),t=new n.Float32BufferAttribute(a.normal,3);t.applyNormalMatrix(e),o.setAttribute("normal",t)}if(a.uvs.forEach((function(e,t){let i="uv"+(t+1).toString();0===t&&(i="uv"),o.setAttribute(i,new n.Float32BufferAttribute(a.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=a.materialIndex[0],t=0;if(a.materialIndex.forEach((function(i,n){i!==e&&(o.addGroup(t,n-t,e),e=i,t=n)})),o.groups.length>0){const t=o.groups[o.groups.length-1],i=t.start+t.count;i!==a.materialIndex.length&&o.addGroup(i,a.materialIndex.length-i,e)}0===o.groups.length&&o.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(o,e,i,r),o}parseGeoNode(e,t){const i={};if(i.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],i.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(i.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(i.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(i.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){i.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&i.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return i.weightTable={},null!==t&&(i.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(n,r){void 0===i.weightTable[n]&&(i.weightTable[n]=[]),i.weightTable[n].push({id:t,weight:e.weights[r]})}))}))),i}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let i=0,n=0,r=!1,o=[],s=[],a=[],l=[],c=[],u=[];const h=this;return e.vertexIndices.forEach((function(p,d){let m,g=!1;p<0&&(p^=-1,g=!0);let _=[],y=[];if(o.push(3*p,3*p+1,3*p+2),e.color){const t=f(d,i,p,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[p]&&e.weightTable[p].forEach((function(e){y.push(e.weight),_.push(e.id)})),y.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach((function(i,n){let r=i,o=_[n];t.forEach((function(t,i,n){if(r>t){n[i]=r,r=t;const s=e[i];e[i]=o,o=s}}))})),_=e,y=t}for(;y.length<4;)y.push(0),_.push(0);for(let e=0;e<4;++e)c.push(y[e]),u.push(_[e])}if(e.normal){const t=f(d,i,p,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(m=f(d,i,p,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const n=f(d,i,p,e);void 0===l[t]&&(l[t]=[]),l[t].push(n[0]),l[t].push(n[1])})),n++,g&&(h.genFace(t,e,o,m,s,a,l,c,u,n),i++,n=0,o=[],s=[],a=[],l=[],c=[],u=[])})),t}genFace(e,t,i,n,r,o,s,a,l,c){for(let u=2;u<c;u++)e.vertex.push(t.vertexPositions[i[0]]),e.vertex.push(t.vertexPositions[i[1]]),e.vertex.push(t.vertexPositions[i[2]]),e.vertex.push(t.vertexPositions[i[3*(u-1)]]),e.vertex.push(t.vertexPositions[i[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[i[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[i[3*u]]),e.vertex.push(t.vertexPositions[i[3*u+1]]),e.vertex.push(t.vertexPositions[i[3*u+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(u-1)]),e.vertexWeights.push(a[4*(u-1)+1]),e.vertexWeights.push(a[4*(u-1)+2]),e.vertexWeights.push(a[4*(u-1)+3]),e.vertexWeights.push(a[4*u]),e.vertexWeights.push(a[4*u+1]),e.vertexWeights.push(a[4*u+2]),e.vertexWeights.push(a[4*u+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[3*(u-1)]),e.colors.push(o[3*(u-1)+1]),e.colors.push(o[3*(u-1)+2]),e.colors.push(o[3*u]),e.colors.push(o[3*u+1]),e.colors.push(o[3*u+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(n),e.materialIndex.push(n),e.materialIndex.push(n)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[3*(u-1)]),e.normal.push(r[3*(u-1)+1]),e.normal.push(r[3*(u-1)+2]),e.normal.push(r[3*u]),e.normal.push(r[3*u+1]),e.normal.push(r[3*u+2])),t.uv&&t.uv.forEach((function(t,i){void 0===e.uvs[i]&&(e.uvs[i]=[]),e.uvs[i].push(s[i][0]),e.uvs[i].push(s[i][1]),e.uvs[i].push(s[i][2*(u-1)]),e.uvs[i].push(s[i][2*(u-1)+1]),e.uvs[i].push(s[i][2*u]),e.uvs[i].push(s[i][2*u+1])}))}addMorphTargets(t,i,n,r){if(0===n.length)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const o=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=e.Objects.Geometry[n.geoID];void 0!==s&&o.genMorphGeometry(t,i,s,r,n.name)}))}))}genMorphGeometry(e,t,i,r,o){const s=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],a=void 0!==i.Vertices?i.Vertices.a:[],l=void 0!==i.Indexes?i.Indexes.a:[],c=3*e.attributes.position.count,u=new Float32Array(c);for(let e=0;e<l.length;e++){const t=3*l[e];u[t]=a[3*e],u[t+1]=a[3*e+1],u[t+2]=a[3*e+2]}const h={vertexIndices:s,vertexPositions:u},p=this.genBuffers(h),d=new n.Float32BufferAttribute(p.vertex,3);d.name=o||i.attrName,d.applyMatrix4(r),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.Normals.a;let r=[];return"IndexToDirect"===i&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:n,indices:r,mappingType:t,referenceType:i}}parseUVs(e){const t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.UV.a;let r=[];return"IndexToDirect"===i&&(r=e.UVIndex.a),{dataSize:2,buffer:n,indices:r,mappingType:t,referenceType:i}}parseVertexColors(e){const t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.Colors.a;let r=[];return"IndexToDirect"===i&&(r=e.ColorIndex.a),{dataSize:4,buffer:n,indices:r,mappingType:t,referenceType:i}}parseMaterialIndices(e){const t=e.MappingInformationType,i=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:i};const n=e.Materials.a,r=[];for(let e=0;e<n.length;++e)r.push(e);return{dataSize:1,buffer:n,indices:r,mappingType:t,referenceType:i}}parseNurbsGeometry(e){if(void 0===n.NURBSCurve)return console.error("THREE.FBXLoader: The loader relies on THREE.NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new n.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new n.BufferGeometry;const i=t-1,r=e.KnotVector.a,o=[],s=e.Points.a;for(let e=0,t=s.length;e<t;e+=4)o.push((new n.Vector4).fromArray(s,e));let a,l;if("Closed"===e.Form)o.push(o[0]);else if("Periodic"===e.Form){a=i,l=r.length-1-a;for(let e=0;e<i;++e)o.push(o[e])}const c=new n.NURBSCurve(i,r,o,a,l).getPoints(12*o.length);return(new n.BufferGeometry).setFromPoints(c)}}class s{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const i in t){const n=t[i],r=this.addClip(n);e.push(r)}return e}parseClips(){if(void 0===e.Objects.AnimationCurve)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const i=this.parseAnimationLayers(t);return this.parseAnimStacks(i)}parseAnimationCurveNodes(){const t=e.Objects.AnimationCurveNode,i=new Map;for(const e in t){const n=t[e];if(null!==n.attrName.match(/S|R|T|DeformPercent/)){const e={id:n.id,attr:n.attrName,curves:{}};i.set(e.id,e)}}return i}parseAnimationCurves(i){const n=e.Objects.AnimationCurve;for(const e in n){const r={id:n[e].id,times:n[e].KeyTime.a.map(p),values:n[e].KeyValueFloat.a},o=t.get(r.id);if(void 0!==o){const e=o.parents[0].ID,t=o.parents[0].relationship;t.match(/X/)?i.get(e).curves.x=r:t.match(/Y/)?i.get(e).curves.y=r:t.match(/Z/)?i.get(e).curves.z=r:t.match(/d|DeformPercent/)&&i.has(e)&&(i.get(e).curves.morph=r)}}}parseAnimationLayers(r){const o=e.Objects.AnimationLayer,s=new Map;for(const a in o){const o=[],l=t.get(parseInt(a));void 0!==l&&(l.children.forEach((function(s,a){if(r.has(s.ID)){const l=r.get(s.ID);if(void 0!==l.curves.x||void 0!==l.curves.y||void 0!==l.curves.z){if(void 0===o[a]){const r=t.get(s.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==r){const t=e.Objects.Model[r.toString()];if(void 0===t)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",s);const l={modelName:t.attrName?n.PropertyBinding.sanitizeNodeName(t.attrName):"",ID:t.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};i.traverse((function(e){e.ID===t.id&&(l.transform=e.matrix,e.userData.transformData&&(l.eulerOrder=e.userData.transformData.eulerOrder))})),l.transform||(l.transform=new n.Matrix4),"PreRotation"in t&&(l.preRotation=t.PreRotation.value),"PostRotation"in t&&(l.postRotation=t.PostRotation.value),o[a]=l}}o[a]&&(o[a][l.attr]=l)}else if(void 0!==l.curves.morph){if(void 0===o[a]){const i=t.get(s.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=t.get(i).parents[0].ID,l=t.get(r).parents[0].ID,c=t.get(l).parents[0].ID,u=e.Objects.Model[c],h={modelName:u.attrName?n.PropertyBinding.sanitizeNodeName(u.attrName):"",morphName:e.Objects.Deformer[i].attrName};o[a]=h}o[a][l.attr]=l}}})),s.set(parseInt(a),o))}return s}parseAnimStacks(i){const n=e.Objects.AnimationStack,r={};for(const e in n){const o=t.get(parseInt(e)).children;o.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=i.get(o[0].ID);r[e]={name:n[e].attrName,layer:s}}return r}addClip(e){let t=[];const i=this;return e.layer.forEach((function(e){t=t.concat(i.generateTracks(e))})),new n.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let i=new n.Vector3,r=new n.Quaternion,o=new n.Vector3;if(e.transform&&e.transform.decompose(i,r,o),i=i.toArray(),r=(new n.Euler).setFromQuaternion(r,e.eulerOrder).toArray(),o=o.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.T.curves,i,"position");void 0!==n&&t.push(n)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);void 0!==i&&t.push(i)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,o,"scale");void 0!==i&&t.push(i)}if(void 0!==e.DeformPercent){const i=this.generateMorphTrack(e);void 0!==i&&t.push(i)}return t}generateVectorTrack(e,t,i,r){const o=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(o,t,i);return new n.VectorKeyframeTrack(e+"."+r,o,s)}generateRotationTrack(e,t,i,r,o,s){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(n.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(n.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(n.MathUtils.degToRad));const a=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(a,t,i);void 0!==r&&((r=r.map(n.MathUtils.degToRad)).push(s),r=(new n.Euler).fromArray(r),r=(new n.Quaternion).setFromEuler(r)),void 0!==o&&((o=o.map(n.MathUtils.degToRad)).push(s),o=(new n.Euler).fromArray(o),o=(new n.Quaternion).setFromEuler(o).invert());const c=new n.Quaternion,u=new n.Euler,h=[];for(let e=0;e<l.length;e+=3)u.set(l[e],l[e+1],l[e+2],s),c.setFromEuler(u),void 0!==r&&c.premultiply(r),void 0!==o&&c.multiply(o),c.toArray(h,e/3*4);return new n.QuaternionKeyframeTrack(e+".quaternion",a,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,r=t.values.map((function(e){return e/100})),o=i.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new n.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+o+"]",t.times,r)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),(t=t.sort((function(e,t){return e-t}))).length>1){let e=1,i=t[0];for(let n=1;n<t.length;n++){const r=t[n];r!==i&&(t[e]=r,i=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,i){const n=i,r=[];let o=-1,s=-1,a=-1;return e.forEach((function(e){if(t.x&&(o=t.x.times.indexOf(e)),t.y&&(s=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==o){const e=t.x.values[o];r.push(e),n[0]=e}else r.push(n[0]);if(-1!==s){const e=t.y.values[s];r.push(e),n[1]=e}else r.push(n[1]);if(-1!==a){const e=t.z.values[a];r.push(e),n[2]=e}else r.push(n[2])})),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const i=e.values[t-1],n=e.values[t]-i,r=Math.abs(n);if(r>=180){const o=r/180,s=n/o;let a=i+s;const l=e.times[t-1],c=(e.times[t]-l)/o;let u=l+c;const h=[],p=[];for(;u<e.times[t];)h.push(u),u+=c,p.push(a),a+=s;e.times=b(e.times,t,h),e.values=b(e.values,t,p)}}}}class a{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new u,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,i=e.split(/[\r\n]+/);return i.forEach((function(e,n){const r=e.match(/^[\s\t]*;/),o=e.match(/^[\s\t]*$/);if(r||o)return;const s=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");s?t.parseNodeBegin(e,s):a?t.parseNodeProperty(e,a,i[++n]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const i=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),r={name:i},o=this.parseNodeAttr(n),s=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(i,r):i in s?("PoseNode"===i?s.PoseNode.push(r):void 0!==s[i].id&&(s[i]={},s[i][s[i].id]=s[i]),""!==o.id&&(s[i][o.id]=r)):"number"==typeof o.id?(s[i]={},s[i][o.id]=r):"Properties70"!==i&&(s[i]="PoseNode"===i?[r]:r),"number"==typeof o.id&&(r.id=o.id),""!==o.name&&(r.attrName=o.name),""!==o.type&&(r.attrType=o.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let i="",n="";return e.length>1&&(i=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:i,type:n}}parseNodeProperty(e,t,i){let n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===r&&(r=i.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===n){const e=r.split(",").slice(1),t=parseInt(e[0]),i=parseInt(e[1]);let s=r.split(",").slice(3);n="connections",function(e,t){for(let i=0,n=e.length,r=t.length;i<r;i++,n++)e[n]=t[i]}(r=[t,i],s=s.map((function(e){return e.trim().replace(/^"/,"")}))),void 0===o[n]&&(o[n]=[])}"Node"===n&&(o.id=r),n in o&&Array.isArray(o[n])?o[n].push(r):"a"!==n?o[n]=r:o.a=r,this.setCurrentProp(o,n),"a"===n&&","!==r.slice(-1)&&(o.a=v(r))}else this.parseNodeSpecialProperty(e,n,r)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=v(t.a))}parseNodeSpecialProperty(e,t,i){const n=i.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=n[0],o=n[1],s=n[2],a=n[3];let l=n[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=v(l)}this.getPrevNode()[r]={type:o,type2:s,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),r)}}class l{parse(e){const t=new c(e);t.skip(23);const i=t.getUint32();if(i<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+i);const n=new u;for(;!this.endOfContent(t);){const e=this.parseNode(t,i);null!==e&&n.add(e.name,e)}return n}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const i={},n=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),s=e.getString(o);if(0===n)return null;const a=[];for(let t=0;t<r;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(i.singleProperty=1===r&&e.getOffset()===n;n>e.getOffset();){const n=this.parseNode(e,t);null!==n&&this.parseSubNode(s,i,n)}return i.propertyList=a,"number"==typeof l&&(i.id=l),""!==c&&(i.attrName=c),""!==u&&(i.attrType=u),""!==s&&(i.name=s),i}parseSubNode(e,t,i){if(!0===i.singleProperty){const e=i.propertyList[0];Array.isArray(e)?(t[i.name]=i,i.a=e):t[i.name]=e}else if("Connections"===e&&"C"===i.name){const e=[];i.propertyList.forEach((function(t,i){0!==i&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===i.name)Object.keys(i).forEach((function(e){t[e]=i[e]}));else if("Properties70"===e&&"P"===i.name){let e=i.propertyList[0],n=i.propertyList[1];const r=i.propertyList[2],o=i.propertyList[3];let s;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===n.indexOf("Lcl ")&&(n=n.replace("Lcl ","Lcl_")),s="Color"===n||"ColorRGB"===n||"Vector"===n||"Vector3D"===n||0===n.indexOf("Lcl_")?[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:i.propertyList[4],t[e]={type:n,type2:r,flag:o,value:s}}else void 0===t[i.name]?"number"==typeof i.id?(t[i.name]={},t[i.name][i.id]=i):t[i.name]=i:"PoseNode"===i.name?(Array.isArray(t[i.name])||(t[i.name]=[t[i.name]]),t[i.name].push(i)):void 0===t[i.name][i.id]&&(t[i.name][i.id]=i)}parseProperty(e){const t=e.getString(1);let i;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return i=e.getUint32(),e.getArrayBuffer(i);case"S":return i=e.getUint32(),e.getString(i);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=e.getUint32(),r=e.getUint32(),o=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}void 0===$&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const s=$.unzlibSync(new Uint8Array(e.getArrayBuffer(o))),a=new c(s.buffer);switch(t){case"b":case"c":return a.getBooleanArray(n);case"d":return a.getFloat64Array(n);case"f":return a.getFloat32Array(n);case"i":return a.getInt32Array(n);case"l":return a.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class c{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let i=0;i<e;i++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let i=0;i<e;i++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,4294967295==(e=4294967295&~e)&&(t=t+1&4294967295),-(4294967296*t+(e=e+1&4294967295))):4294967296*t+e}getInt64Array(e){const t=[];for(let i=0;i<e;i++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let i=0;i<e;i++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let i=0;i<e;i++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let i=0;i<e;i++)t[i]=this.getUint8();const i=t.indexOf(0);return i>=0&&(t=t.slice(0,i)),n.LoaderUtils.decodeText(new Uint8Array(t))}}class u{add(e,t){this[e]=t}}function h(e){const t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function p(e){return e/46186158e3}const d=[];function f(e,t,i,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=i;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}"IndexToDirect"===n.referenceType&&(r=n.indices[r]);const o=r*n.dataSize,s=o+n.dataSize;return function(e,t,i,n){for(let r=i,o=0;r<n;r++,o++)e[o]=t[r];return e}(d,n.buffer,o,s)}const m=new n.Euler,g=new n.Vector3;function _(e){const t=new n.Matrix4,i=new n.Matrix4,r=new n.Matrix4,o=new n.Matrix4,s=new n.Matrix4,a=new n.Matrix4,l=new n.Matrix4,c=new n.Matrix4,u=new n.Matrix4,h=new n.Matrix4,p=new n.Matrix4,d=new n.Matrix4,f=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(g.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(n.MathUtils.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(m.fromArray(t))}if(e.rotation){const t=e.rotation.map(n.MathUtils.degToRad);t.push(e.eulerOrder),r.makeRotationFromEuler(m.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(n.MathUtils.degToRad);t.push(e.eulerOrder),o.makeRotationFromEuler(m.fromArray(t)),o.invert()}e.scale&&s.scale(g.fromArray(e.scale)),e.scalingOffset&&l.setPosition(g.fromArray(e.scalingOffset)),e.scalingPivot&&a.setPosition(g.fromArray(e.scalingPivot)),e.rotationOffset&&c.setPosition(g.fromArray(e.rotationOffset)),e.rotationPivot&&u.setPosition(g.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(p.copy(e.parentMatrix),h.copy(e.parentMatrixWorld));const _=i.clone().multiply(r).multiply(o),y=new n.Matrix4;y.extractRotation(h);const v=new n.Matrix4;v.copyPosition(h);const x=v.clone().invert().multiply(h),b=y.clone().invert().multiply(x),w=s,M=new n.Matrix4;if(0===f)M.copy(y).multiply(_).multiply(b).multiply(w);else if(1===f)M.copy(y).multiply(b).multiply(_).multiply(w);else{const e=(new n.Matrix4).scale((new n.Vector3).setFromMatrixScale(p)).clone().invert(),t=b.clone().multiply(e);M.copy(y).multiply(_).multiply(t).multiply(w)}const T=u.clone().invert(),S=a.clone().invert();let E=t.clone().multiply(c).multiply(u).multiply(i).multiply(r).multiply(o).multiply(T).multiply(l).multiply(a).multiply(s).multiply(S);const A=(new n.Matrix4).copyPosition(E),C=h.clone().multiply(A);return d.copyPosition(C),(E=d.clone().multiply(M)).premultiply(h.invert()),E}function y(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported THREE.Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function v(e){return e.split(",").map((function(e){return parseFloat(e)}))}function x(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.byteLength),n.LoaderUtils.decodeText(new Uint8Array(e,t,i))}function b(e,t,i){return e.slice(0,t).concat(i).concat(e.slice(t))}n.FBXLoader=class extends n.Loader{constructor(e){super(e)}load(e,t,i,r){const o=this,s=""===o.path?n.LoaderUtils.extractUrlBase(e):o.path,a=new n.FileLoader(this.manager);a.setPath(o.path),a.setResponseType("arraybuffer"),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,(function(i){try{t(o.parse(i,s))}catch(t){r?r(t):console.error(t),o.manager.itemError(e)}}),i,r)}parse(t,i){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===x(e,0,t.length)}(t))e=(new l).parse(t);else{const i=x(t);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let i=0;function n(t){const n=e[t-1];return e=e.slice(i+t),i++,n}for(let e=0;e<t.length;++e)if(n(1)===t[e])return!1;return!0}(i))throw new Error("THREE.FBXLoader: Unknown format.");if(h(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+h(i));e=(new a).parse(i)}const o=new n.TextureLoader(this.manager).setPath(this.resourcePath||i).setCrossOrigin(this.crossOrigin);return new r(o,this.manager).parse(e)}}}(),Z=Z=n.FBXLoader;var X={};!function(){function e(){let e={};return{get:function(t){return e[t]},add:function(t,i){e[t]=i},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const t="KHR_binary_glTF",i="KHR_draco_mesh_compression",r="KHR_materials_pbrSpecularGlossiness",o="KHR_materials_unlit",s="KHR_texture_transform",a="KHR_mesh_quantization";class l{constructor(e){this.parser=e,this.name="KHR_lights_punctual",this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const o=t.json,s=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let a;const l=new n.Color(16777215);void 0!==s.color&&l.fromArray(s.color);const c=void 0!==s.range?s.range:0;switch(s.type){case"directional":(a=new n.DirectionalLight(l)).target.position.set(0,0,-1),a.add(a.target);break;case"point":(a=new n.PointLight(l)).distance=c;break;case"spot":(a=new n.SpotLight(l)).distance=c,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,void 0!==s.intensity&&(a.intensity=s.intensity),a.name=t.createUniqueName(s.name||"light_"+e),r=Promise.resolve(a),t.cache.add(i,r),r}createNodeAttachment(e){const t=this,i=this.parser,n=i.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return i._getNodeRef(t.cache,r,e)}))}}class c{constructor(){this.name=o}getMaterialType(){return n.MeshBasicMaterial}extendParams(e,t,i){const r=[];e.color=new n.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const t=o.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==o.baseColorTexture&&r.push(i.assignTexture(e,"map",o.baseColorTexture))}return Promise.all(r)}}class u{constructor(e){this.parser=e,this.name="KHR_materials_clearcoat"}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],s=r.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&o.push(i.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&o.push(i.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(o.push(i.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new n.Vector2(e,-e)}return Promise.all(o)}}class h{constructor(e){this.parser=e,this.name="KHR_materials_transmission"}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&r.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class p{constructor(e){this.parser=e,this.name="KHR_materials_volume"}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],s=r.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&o.push(i.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||0;const a=s.attenuationColor||[1,1,1];return t.attenuationTint=new n.Color(a[0],a[1],a[2]),Promise.all(o)}}class d{constructor(e){this.parser=e,this.name="KHR_materials_ior"}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class f{constructor(e){this.parser=e,this.name="KHR_materials_specular"}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],s=r.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&o.push(i.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularTint=new n.Color(a[0],a[1],a[2]),void 0!==s.specularColorTexture&&o.push(i.assignTexture(t,"specularTintMap",s.specularColorTexture).then((function(e){e.encoding=n.sRGBEncoding}))),Promise.all(o)}}class m{constructor(e){this.parser=e,this.name="KHR_texture_basisu"}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],o=i.images[r.source],s=t.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o,s)}}class g{constructor(e){this.parser=e,this.name="EXT_texture_webp",this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],s=n.images[o.source];let a=i.textureLoader;if(s.uri){const e=i.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,s,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class _{constructor(e){this.name="EXT_meshopt_compression",this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const e=i.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([n,r.ready]).then((function(t){const i=e.byteOffset||0,n=e.byteLength||0,o=e.count,s=e.byteStride,a=new ArrayBuffer(o*s),l=new Uint8Array(t[0],i,n);return r.decodeGltfBuffer(new Uint8Array(a),o,s,l,e.mode,e.filter),a}))}return null}}class y{constructor(e){this.name=t,this.content=null,this.body=null;const i=new DataView(e,0,12);if(this.header={magic:n.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:i.getUint32(4,!0),length:i.getUint32(8,!0)},"glTF"!==this.header.magic)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,o=new DataView(e,12);let s=0;for(;s<r;){const t=o.getUint32(s,!0);s+=4;const i=o.getUint32(s,!0);if(s+=4,1313821514===i){const i=new Uint8Array(e,12+s,t);this.content=n.LoaderUtils.decodeText(i)}else if(5130562===i){const i=12+s;this.body=e.slice(i,i+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class v{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=i,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,s={},a={},l={};for(const e in o){const t=P[e]||e.toLowerCase();s[t]=o[e]}for(const t in e.attributes){const n=P[t]||t.toLowerCase();if(void 0!==o[t]){const r=i.accessors[e.attributes[t]],o=A[r.componentType];l[n]=o,a[n]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){n.decodeDracoFile(e,(function(e){for(const t in e.attributes){const i=e.attributes[t],n=a[t];void 0!==n&&(i.normalized=n)}t(e)}),s,l)}))}))}}class x{constructor(){this.name=s}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class b extends n.MeshStandardMaterial{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),i=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),r=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),o=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new n.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",i).replace("#include <roughnessmap_fragment>",r).replace("#include <metalnessmap_fragment>",o).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class w{constructor(){this.name=r,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return b}extendParams(e,t,i){const r=t.extensions[this.name];e.color=new n.Color(1,1,1),e.opacity=1;const o=[];if(Array.isArray(r.diffuseFactor)){const t=r.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==r.diffuseTexture&&o.push(i.assignTexture(e,"map",r.diffuseTexture)),e.emissive=new n.Color(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new n.Color(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const t=r.specularGlossinessTexture;o.push(i.assignTexture(e,"glossinessMap",t)),o.push(i.assignTexture(e,"specularMap",t))}return Promise.all(o)}createMaterial(e){const t=new b(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=n.TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}class M{constructor(){this.name=a}}class T extends n.Interpolant{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=i[r+e];return t}}T.prototype.beforeStart_=T.prototype.copySampleValue_,T.prototype.afterEnd_=T.prototype.copySampleValue_,T.prototype.interpolate_=function(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=2*s,l=3*s,c=n-t,u=(i-t)/c,h=u*u,p=h*u,d=e*l,f=d-l,m=-2*p+3*h,g=p-h,_=1-m,y=g-h+u;for(let e=0;e!==s;e++){const t=o[f+e+s],i=o[f+e+a]*c,n=o[d+e+s],l=o[d+e]*c;r[e]=_*t+y*i+m*n+g*l}return r};const S=new n.Quaternion;class E extends T{interpolate_(e,t,i,n){const r=super.interpolate_(e,t,i,n);return S.fromArray(r).normalize().toArray(r),r}}const A={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},C={9728:n.NearestFilter,9729:n.LinearFilter,9984:n.NearestMipmapNearestFilter,9985:n.LinearMipmapNearestFilter,9986:n.NearestMipmapLinearFilter,9987:n.LinearMipmapLinearFilter},L={33071:n.ClampToEdgeWrapping,33648:n.MirroredRepeatWrapping,10497:n.RepeatWrapping},I={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},P={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},R={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},k={CUBICSPLINE:void 0,LINEAR:n.InterpolateLinear,STEP:n.InterpolateDiscrete};function z(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function D(e,t,i){for(const n in i.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=i.extensions[n])}function O(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function F(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let i=0,n=t.weights.length;i<n;i++)e.morphTargetInfluences[i]=t.weights[i];if(t.extras&&Array.isArray(t.extras.targetNames)){const i=t.extras.targetNames;if(e.morphTargetInfluences.length===i.length){e.morphTargetDictionary={};for(let t=0,n=i.length;t<n;t++)e.morphTargetDictionary[i[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function B(e){const t=e.extensions&&e.extensions[i];return t?"draco:"+t.bufferView+":"+t.indices+":"+N(t.attributes):e.indices+":"+N(e.attributes)+":"+e.mode}function N(e){let t="";const i=Object.keys(e).sort();for(let n=0,r=i.length;n<r;n++)t+=i[n]+":"+e[i[n]]+";";return t}function U(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class j{constructor(t={},i={}){this.json=t,this.extensions={},this.plugins={},this.options=i,this.cache=new e,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox/.test(navigator.userAgent)?this.textureLoader=new n.ImageBitmapLoader(this.options.manager):this.textureLoader=new n.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new n.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(t){const o={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:i,userData:{}};D(r,o,n),O(o,n),Promise.all(i._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){e(o)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i].joints;for(let t=0,i=n.length;t<i;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const n=i.clone();return n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this.loadNode(t);break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this.loadAnimation(t);break;case"camera":n=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map((function(t,n){return i.getDependency(e,n)}))),this.cache.add(e,t)}return t}loadBuffer(e){const i=this.json.buffers[e],n=this.fileLoader;if(i.type&&"arraybuffer"!==i.type)throw new Error("THREE.GLTFLoader: "+i.type+" buffer type is not supported.");if(void 0===i.uri&&0===e)return Promise.resolve(this.extensions[t].body);const r=this.options;return new Promise((function(e,t){n.load(z(i.uri,r.path),e,void 0,(function(){t(new Error('THREE.GLTFLoader: Failed to load buffer "'+i.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const i=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+i)}))}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse)return Promise.resolve(null);const o=[];return void 0!==r.bufferView?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),void 0!==r.sparse&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then((function(e){const o=e[0],s=I[r.type],a=A[r.componentType],l=a.BYTES_PER_ELEMENT,c=l*s,u=r.byteOffset||0,h=void 0!==r.bufferView?i.bufferViews[r.bufferView].byteStride:void 0,p=!0===r.normalized;let d,f;if(h&&h!==c){const e=Math.floor(u/h),i="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let c=t.cache.get(i);c||(d=new a(o,e*h,r.count*h/l),c=new n.InterleavedBuffer(d,h/l),t.cache.add(i,c)),f=new n.InterleavedBufferAttribute(c,s,u%h/l,p)}else d=null===o?new a(r.count*s):new a(o,u,r.count*s),f=new n.BufferAttribute(d,s,p);if(void 0!==r.sparse){const t=I.SCALAR,i=A[r.sparse.indices.componentType],l=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,u=new i(e[1],l,r.sparse.count*t),h=new a(e[2],c,r.sparse.count*s);null!==o&&(f=new n.BufferAttribute(f.array.slice(),f.itemSize,f.normalized));for(let e=0,t=u.length;e<t;e++){const t=u[e];if(f.setX(t,h[e*s]),s>=2&&f.setY(t,h[e*s+1]),s>=3&&f.setZ(t,h[e*s+2]),s>=4&&f.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.")}}return f}))}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e],r=t.images[n.source];let o=this.textureLoader;if(r.uri){const e=i.manager.getHandler(r.uri);null!==e&&(o=e)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,i){const r=this,o=this.json,s=this.options,a=o.textures[e],l=(t.uri||t.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=self.URL||self.webkitURL;let u=t.uri||"",h=!1,p=!0;const d=u.search(/\.jpe?g($|\?)/i)>0||0===u.search(/^data\:image\/jpeg/);if(("image/jpeg"===t.mimeType||d)&&(p=!1),void 0!==t.bufferView)u=r.getDependency("bufferView",t.bufferView).then((function(e){if("image/png"===t.mimeType){const t=new DataView(e,25,1).getUint8(0,!1);p=6===t||4===t||3===t}h=!0;const i=new Blob([e],{type:t.mimeType});return u=c.createObjectURL(i)}));else if(void 0===t.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(u).then((function(e){return new Promise((function(t,r){let o=t;!0===i.isImageBitmapLoader&&(o=function(e){const i=new n.Texture(e);i.needsUpdate=!0,t(i)}),i.load(z(e,s.path),o,void 0,r)}))})).then((function(t){!0===h&&c.revokeObjectURL(u),t.flipY=!1,a.name&&(t.name=a.name),p||(t.format=n.RGBFormat);const i=(o.samplers||{})[a.sampler]||{};return t.magFilter=C[i.magFilter]||n.LinearFilter,t.minFilter=C[i.minFilter]||n.LinearMipmapLinearFilter,t.wrapS=L[i.wrapS]||n.RepeatWrapping,t.wrapT=L[i.wrapT]||n.RepeatWrapping,r.associations.set(t,{type:"textures",index:e}),t})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",u),null}));return this.textureCache[l]=f,f}assignTexture(e,t,i){const n=this;return this.getDependency("texture",i.index).then((function(r){if(void 0===i.texCoord||0==i.texCoord||"aoMap"===t&&1==i.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+i.texCoord+" for texture "+t+" not yet supported."),n.extensions[s]){const e=void 0!==i.extensions?i.extensions[s]:void 0;if(e){const t=n.associations.get(r);r=n.extensions[s].extendTexture(r,e),n.associations.set(r,t)}}return e[t]=r,r}))}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=void 0!==t.attributes.tangent,o=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new n.PointsMaterial,n.Material.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,t.sizeAttenuation=!1,this.cache.add(e,t)),i=t}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new n.LineBasicMaterial,n.Material.prototype.copy.call(t,i),t.color.copy(i.color),this.cache.add(e,t)),i=t}if(r||o||s){let e="ClonedMaterial:"+i.uuid+":";i.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),r&&(e+="vertex-tangents:"),o&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),o&&(t.vertexColors=!0),s&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}i.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=i}getMaterialType(){return n.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,s=this.extensions,a=i.materials[e];let l;const c={},u=a.extensions||{},h=[];if(u[r]){const e=s[r];l=e.getMaterialType(),h.push(e.extendParams(c,a,t))}else if(u[o]){const e=s[o];l=e.getMaterialType(),h.push(e.extendParams(c,a,t))}else{const i=a.pbrMetallicRoughness||{};if(c.color=new n.Color(1,1,1),c.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;c.color.fromArray(e),c.opacity=e[3]}void 0!==i.baseColorTexture&&h.push(t.assignTexture(c,"map",i.baseColorTexture)),c.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,c.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(h.push(t.assignTexture(c,"metalnessMap",i.metallicRoughnessTexture)),h.push(t.assignTexture(c,"roughnessMap",i.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),h.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,c)}))))}!0===a.doubleSided&&(c.side=n.DoubleSide);const p=a.alphaMode||"OPAQUE";return"BLEND"===p?(c.transparent=!0,c.depthWrite=!1):(c.format=n.RGBFormat,c.transparent=!1,"MASK"===p&&(c.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&l!==n.MeshBasicMaterial&&(h.push(t.assignTexture(c,"normalMap",a.normalTexture)),c.normalScale=new n.Vector2(1,-1),void 0!==a.normalTexture.scale&&c.normalScale.set(a.normalTexture.scale,-a.normalTexture.scale)),void 0!==a.occlusionTexture&&l!==n.MeshBasicMaterial&&(h.push(t.assignTexture(c,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(c.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&l!==n.MeshBasicMaterial&&(c.emissive=(new n.Color).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&l!==n.MeshBasicMaterial&&h.push(t.assignTexture(c,"emissiveMap",a.emissiveTexture)),Promise.all(h).then((function(){let i;return i=l===b?s[r].createMaterial(c):new l(c),a.name&&(i.name=a.name),i.map&&(i.map.encoding=n.sRGBEncoding),i.emissiveMap&&(i.emissiveMap.encoding=n.sRGBEncoding),O(i,a),t.associations.set(i,{type:"materials",index:e}),a.extensions&&D(s,i,a),i}))}createUniqueName(e){const t=n.PropertyBinding.sanitizeNodeName(e||"");let i=t;for(let e=1;this.nodeNamesUsed[i];++e)i=t+"_"+e;return this.nodeNamesUsed[i]=!0,i}loadGeometries(e){const t=this,r=this.extensions,o=this.primitiveCache;function s(e){return r[i].decodePrimitive(e,t).then((function(i){return G(i,e,t)}))}const a=[];for(let r=0,l=e.length;r<l;r++){const l=e[r],c=B(l),u=o[c];if(u)a.push(u.promise);else{let e;e=l.extensions&&l.extensions[i]?s(l):G(new n.BufferGeometry,l,t),o[c]={primitive:l,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){const t=this,i=this.json,r=this.extensions,o=i.meshes[e],s=o.primitives,a=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?(void 0===(l=this.cache).DefaultMaterial&&(l.DefaultMaterial=new n.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:n.FrontSide})),l.DefaultMaterial):this.getDependency("material",s[e].material);a.push(t)}var l;return a.push(t.loadGeometries(s)),Promise.all(a).then((function(i){const a=i.slice(0,i.length-1),l=i[i.length-1],c=[];for(let i=0,u=l.length;i<u;i++){const u=l[i],h=s[i];let p;const d=a[i];if(4===h.mode||5===h.mode||6===h.mode||void 0===h.mode)!0!==(p=!0===o.isSkinnedMesh?new n.SkinnedMesh(u,d):new n.Mesh(u,d)).isSkinnedMesh||p.geometry.attributes.skinWeight.normalized||p.normalizeSkinWeights(),5===h.mode?p.geometry=H(p.geometry,n.TriangleStripDrawMode):6===h.mode&&(p.geometry=H(p.geometry,n.TriangleFanDrawMode));else if(1===h.mode)p=new n.LineSegments(u,d);else if(3===h.mode)p=new n.Line(u,d);else if(2===h.mode)p=new n.LineLoop(u,d);else{if(0!==h.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);p=new n.Points(u,d)}Object.keys(p.geometry.morphAttributes).length>0&&F(p,o),p.name=t.createUniqueName(o.name||"mesh_"+e),O(p,o),h.extensions&&D(r,p,h),t.assignFinalMaterial(p),c.push(p)}if(1===c.length)return c[0];const u=new n.Group;for(let e=0,t=c.length;e<t;e++)u.add(c[e]);return u}))}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(r)return"perspective"===i.type?t=new n.PerspectiveCamera(n.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===i.type&&(t=new n.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),O(t,i),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],i={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(i):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return i.inverseBindMatrices=e,i}))}loadAnimation(e){const t=this.json.animations[e],i=[],r=[],o=[],s=[],a=[];for(let e=0,n=t.channels.length;e<n;e++){const n=t.channels[e],l=t.samplers[n.sampler],c=n.target,u=void 0!==c.node?c.node:c.id,h=void 0!==t.parameters?t.parameters[l.input]:l.input,p=void 0!==t.parameters?t.parameters[l.output]:l.output;i.push(this.getDependency("node",u)),r.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",p)),s.push(l),a.push(c)}return Promise.all([Promise.all(i),Promise.all(r),Promise.all(o),Promise.all(s),Promise.all(a)]).then((function(i){const r=i[0],o=i[1],s=i[2],a=i[3],l=i[4],c=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],i=o[e],u=s[e],h=a[e],p=l[e];if(void 0===t)continue;let d;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,R[p.path]){case R.weights:d=n.NumberKeyframeTrack;break;case R.rotation:d=n.QuaternionKeyframeTrack;break;default:d=n.VectorKeyframeTrack}const f=t.name?t.name:t.uuid,m=void 0!==h.interpolation?k[h.interpolation]:n.InterpolateLinear,g=[];R[p.path]===R.weights?t.traverse((function(e){!0===e.isMesh&&e.morphTargetInfluences&&g.push(e.name?e.name:e.uuid)})):g.push(f);let _=u.array;if(u.normalized){const e=U(_.constructor),t=new Float32Array(_.length);for(let i=0,n=_.length;i<n;i++)t[i]=_[i]*e;_=t}for(let e=0,t=g.length;e<t;e++){const t=new d(g[e]+"."+R[p.path],i.array,_,m);"CUBICSPLINE"===h.interpolation&&(t.createInterpolant=function(e){return new(this instanceof n.QuaternionKeyframeTrack?E:T)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),c.push(t)}}const u=t.name?t.name:"animation_"+e;return new n.AnimationClip(u,void 0,c)}))}createNodeMesh(e){const t=this.json,i=this,n=t.nodes[e];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then((function(e){const t=i._getNodeRef(i.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,i=n.weights.length;t<i;t++)e.morphTargetInfluences[t]=n.weights[t]})),t}))}loadNode(e){const t=this.json,i=this.extensions,r=this,o=t.nodes[e],s=o.name?r.createUniqueName(o.name):"";return function(){const t=[],i=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return i&&t.push(i),void 0!==o.camera&&t.push(r.getDependency("camera",o.camera).then((function(e){return r._getNodeRef(r.cameraCache,o.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if((a=!0===o.isBone?new n.Bone:t.length>1?new n.Group:1===t.length?t[0]:new n.Object3D)!==t[0])for(let e=0,i=t.length;e<i;e++)a.add(t[e]);if(o.name&&(a.userData.name=o.name,a.name=s),O(a,o),o.extensions&&D(i,a,o),void 0!==o.matrix){const e=new n.Matrix4;e.fromArray(o.matrix),a.applyMatrix4(e)}else void 0!==o.translation&&a.position.fromArray(o.translation),void 0!==o.rotation&&a.quaternion.fromArray(o.rotation),void 0!==o.scale&&a.scale.fromArray(o.scale);return r.associations.set(a,{type:"nodes",index:e}),a}))}loadScene(e){const t=this.json,i=this.extensions,r=this.json.scenes[e],o=this,s=new n.Group;r.name&&(s.name=o.createUniqueName(r.name)),O(s,r),r.extensions&&D(i,s,r);const a=r.nodes||[],l=[];for(let e=0,i=a.length;e<i;e++)l.push(V(a[e],s,t,o));return Promise.all(l).then((function(){return s}))}}function V(e,t,i,r){const o=i.nodes[e];return r.getDependency("node",e).then((function(e){if(void 0===o.skin)return e;let t;return r.getDependency("skin",o.skin).then((function(e){const i=[];for(let n=0,o=(t=e).joints.length;n<o;n++)i.push(r.getDependency("node",t.joints[n]));return Promise.all(i)})).then((function(i){return e.traverse((function(e){if(!e.isMesh)return;const r=[],o=[];for(let e=0,s=i.length;e<s;e++){const s=i[e];if(s){r.push(s);const i=new n.Matrix4;void 0!==t.inverseBindMatrices&&i.fromArray(t.inverseBindMatrices.array,16*e),o.push(i)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new n.Skeleton(r,o),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const n=[];if(o.children){const t=o.children;for(let o=0,s=t.length;o<s;o++){const s=t[o];n.push(V(s,e,i,r))}}return Promise.all(n)}))}function G(e,t,i){const r=t.attributes,o=[];function s(t,n){return i.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}for(const t in r){const i=P[t]||t.toLowerCase();i in e.attributes||o.push(s(r[t],i))}if(void 0!==t.indices&&!e.index){const n=i.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));o.push(n)}return O(e,t),function(e,t,i){const r=t.attributes,o=new n.Box3;if(void 0===r.POSITION)return;{const e=i.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new n.Vector3(t[0],t[1],t[2]),new n.Vector3(s[0],s[1],s[2])),e.normalized){const t=U(A[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new n.Vector3,t=new n.Vector3;for(let n=0,r=s.length;n<r;n++){const r=s[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],o=n.min,s=n.max;if(void 0!==o&&void 0!==s){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(s[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(s[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(s[2]))),n.normalized){const e=U(A[n.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const a=new n.Sphere;o.getCenter(a.center),a.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=a}(e,t,i),Promise.all(o).then((function(){return void 0!==t.targets?function(e,t,i){let n=!1,r=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),n&&r)break}if(!n&&!r)return Promise.resolve(e);const o=[],s=[];for(let a=0,l=t.length;a<l;a++){const l=t[a];if(n){const t=void 0!==l.POSITION?i.getDependency("accessor",l.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==l.NORMAL?i.getDependency("accessor",l.NORMAL):e.attributes.normal;s.push(t)}}return Promise.all([Promise.all(o),Promise.all(s)]).then((function(t){const i=t[0],o=t[1];return n&&(e.morphAttributes.position=i),r&&(e.morphAttributes.normal=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,i):e}))}function H(e,t){let i=e.getIndex();if(null===i){const t=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const r=i.count-2,o=[];if(t===n.TriangleFanDrawMode)for(let e=1;e<=r;e++)o.push(i.getX(0)),o.push(i.getX(e)),o.push(i.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(o.push(i.getX(e)),o.push(i.getX(e+1)),o.push(i.getX(e+2))):(o.push(i.getX(e+2)),o.push(i.getX(e+1)),o.push(i.getX(e)));o.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(o),s}n.GLTFLoader=class extends n.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new u(e)})),this.register((function(e){return new m(e)})),this.register((function(e){return new g(e)})),this.register((function(e){return new h(e)})),this.register((function(e){return new p(e)})),this.register((function(e){return new d(e)})),this.register((function(e){return new f(e)})),this.register((function(e){return new l(e)})),this.register((function(e){return new _(e)}))}load(e,t,i,r){const o=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:n.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),o.manager.itemError(e),o.manager.itemEnd(e)},l=new n.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(i){try{o.parse(i,s,(function(i){t(i),o.manager.itemEnd(e)}),a)}catch(e){a(e)}}),i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,l,u,h){let p;const d={},f={};if("string"==typeof e)p=e;else if("glTF"===n.LoaderUtils.decodeText(new Uint8Array(e,0,4))){try{d[t]=new y(e)}catch(e){return void(h&&h(e))}p=d[t].content}else p=n.LoaderUtils.decodeText(new Uint8Array(e));const m=JSON.parse(p);if(void 0===m.asset||m.asset.version[0]<2)return void(h&&h(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const g=new j(m,{path:l||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});g.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](g);f[t.name]=t,d[t.name]=!0}if(m.extensionsUsed)for(let e=0;e<m.extensionsUsed.length;++e){const t=m.extensionsUsed[e],n=m.extensionsRequired||[];switch(t){case o:d[t]=new c;break;case r:d[t]=new w;break;case i:d[t]=new v(m,this.dracoLoader);break;case s:d[t]=new x;break;case a:d[t]=new M;break;default:n.indexOf(t)>=0&&void 0===f[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}g.setExtensions(d),g.setPlugins(f),g.parse(u,h)}}}(),X=X=n.GLTFLoader;var Y={};n.ColladaLoader=class extends n.Loader{constructor(e){super(e)}load(e,t,i,r){const o=this,s=""===o.path?n.LoaderUtils.extractUrlBase(e):o.path,a=new n.FileLoader(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,(function(i){try{t(o.parse(i,s))}catch(t){r?r(t):console.error(t),o.manager.itemError(e)}}),i,r)}parse(e,t){function i(e,t){const i=[],n=e.childNodes;for(let e=0,r=n.length;e<r;e++){const r=n[e];r.nodeName===t&&i.push(r)}return i}function r(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),i=new Array(t.length);for(let e=0,n=t.length;e<n;e++)i[e]=t[e];return i}function o(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),i=new Array(t.length);for(let e=0,n=t.length;e<n;e++)i[e]=parseFloat(t[e]);return i}function s(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),i=new Array(t.length);for(let e=0,n=t.length;e<n;e++)i[e]=parseInt(t[e]);return i}function a(e){return e.substring(1)}function l(e){return 0===Object.keys(e).length}function c(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function u(e){return void 0!==e?e.textContent:"Y_UP"}function h(e,t,n,r){const o=i(e,t)[0];if(void 0!==o){const e=i(o,n);for(let t=0;t<e.length;t++)r(e[t])}}function p(e,t){for(const i in e)e[i].build=t(e[i])}function d(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function f(e){const t={inputs:{}};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"input"===n.nodeName){const e=a(n.getAttribute("source")),i=n.getAttribute("semantic");t.inputs[i]=e}}return t}function m(e){const t={};let i=e.getAttribute("target").split("/");const n=i.shift();let r=i.shift();const o=-1!==r.indexOf("("),s=-1!==r.indexOf(".");if(s)i=r.split("."),r=i.shift(),t.member=i.shift();else if(o){const e=r.split("(");r=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=n,t.sid=r,t.arraySyntax=o,t.memberSyntax=s,t.sampler=a(e.getAttribute("source")),t}function g(e){const t=[],i=e.channels,n=e.samplers,r=e.sources;for(const e in i)if(i.hasOwnProperty(e)){const o=i[e],s=n[o.sampler],a=s.inputs.INPUT,l=s.inputs.OUTPUT;w(y(o,r[a],r[l]),t)}return t}function _(e){return d(Xe.animations[e],g)}function y(e,t,i){const n=Xe.nodes[e.id],r=Oe(n.id),o=n.transforms[e.sid],s=n.matrix.clone().transpose();let a,l,c,u,h,p;const d={};switch(o){case"matrix":for(c=0,u=t.array.length;c<u;c++)if(a=t.array[c],l=c*i.stride,void 0===d[a]&&(d[a]={}),!0===e.arraySyntax){const t=i.array[l],n=e.indices[0]+4*e.indices[1];d[a][n]=t}else for(h=0,p=i.stride;h<p;h++)d[a][h]=i.array[l+h];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',o)}const f=function(e,t){const i=[];for(const t in e)i.push({time:parseFloat(t),value:e[t]});i.sort((function(e,t){return e.time-t.time}));for(let e=0;e<16;e++)M(i,e,t.elements[e]);return i}(d,s);return{name:r.uuid,keyframes:f}}const v=new n.Vector3,x=new n.Vector3,b=new n.Quaternion;function w(e,t){const i=e.keyframes,r=e.name,o=[],s=[],a=[],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=t.time,r=t.value;Se.fromArray(r).transpose(),Se.decompose(v,b,x),o.push(n),s.push(v.x,v.y,v.z),a.push(b.x,b.y,b.z,b.w),l.push(x.x,x.y,x.z)}return s.length>0&&t.push(new n.VectorKeyframeTrack(r+".position",o,s)),a.length>0&&t.push(new n.QuaternionKeyframeTrack(r+".quaternion",o,a)),l.length>0&&t.push(new n.VectorKeyframeTrack(r+".scale",o,l)),t}function M(e,t,i){let n,r,o,s=!0;for(r=0,o=e.length;r<o;r++)void 0===(n=e[r]).value[t]?n.value[t]=null:s=!1;if(!0===s)for(r=0,o=e.length;r<o;r++)(n=e[r]).value[t]=i;else!function(e,t){let i,n;for(let r=0,o=e.length;r<o;r++){const o=e[r];if(null===o.value[t]){if(i=T(e,r,t),n=S(e,r,t),null===i){o.value[t]=n.value[t];continue}if(null===n){o.value[t]=i.value[t];continue}E(o,i,n,t)}}}(e,t)}function T(e,t,i){for(;t>=0;){const n=e[t];if(null!==n.value[i])return n;t--}return null}function S(e,t,i){for(;t<e.length;){const n=e[t];if(null!==n.value[i])return n;t++}return null}function E(e,t,i,n){i.time-t.time!=0?e.value[n]=(e.time-t.time)*(i.value[n]-t.value[n])/(i.time-t.time)+t.value[n]:e.value[n]=t.value[n]}function A(e){const t=[],i=e.name,r=e.end-e.start||-1,o=e.animations;for(let e=0,i=o.length;e<i;e++){const i=_(o[e]);for(let e=0,n=i.length;e<n;e++)t.push(i[e])}return new n.AnimationClip(i,r,t)}function C(e){return d(Xe.clips[e],A)}function L(e){const t={sources:{}};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=o(n.textContent);break;case"source":const e=n.getAttribute("id");t.sources[e]=oe(n);break;case"joints":t.joints=I(n);break;case"vertex_weights":t.vertexWeights=P(n)}}return t}function I(e){const t={inputs:{}};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"input"===n.nodeName){const e=n.getAttribute("semantic"),i=a(n.getAttribute("source"));t.inputs[e]=i}}return t}function P(e){const t={inputs:{}};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"input":const e=n.getAttribute("semantic"),i=a(n.getAttribute("source")),r=parseInt(n.getAttribute("offset"));t.inputs[e]={id:i,offset:r};break;case"vcount":t.vcount=s(n.textContent);break;case"v":t.v=s(n.textContent)}}return t}function R(e){const t={id:e.id},i=Xe.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){const t={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},i=e.sources,r=e.vertexWeights,o=r.vcount,s=r.v,a=r.inputs.JOINT.offset,l=r.inputs.WEIGHT.offset,c=e.sources[e.joints.inputs.JOINT],u=e.sources[e.joints.inputs.INV_BIND_MATRIX],h=i[r.inputs.WEIGHT.id].array;let p,d,f,m=0;for(p=0,f=o.length;p<f;p++){const e=o[p],i=[];for(d=0;d<e;d++){const e=s[m+a],t=h[s[m+l]];i.push({index:e,weight:t}),m+=2}for(i.sort(g),d=0;d<4;d++){const e=i[d];void 0!==e?(t.indices.array.push(e.index),t.weights.array.push(e.weight)):(t.indices.array.push(0),t.weights.array.push(0))}}for(e.bindShapeMatrix?t.bindMatrix=(new n.Matrix4).fromArray(e.bindShapeMatrix).transpose():t.bindMatrix=(new n.Matrix4).identity(),p=0,f=c.array.length;p<f;p++){const e=c.array[p],i=(new n.Matrix4).fromArray(u.array,p*u.stride).transpose();t.joints.push({name:e,boneInverse:i})}return t;function g(e,t){return t.weight-e.weight}}(e.skin),i.sources.skinIndices=t.skin.indices,i.sources.skinWeights=t.skin.weights),t}function k(e){return void 0!==e.build?e.build:e.init_from}function z(e){const t=Xe.images[e];return void 0!==t?d(t,k):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function D(e){const t={surfaces:{},samplers:{}};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"newparam":O(n,t);break;case"technique":t.technique=N(n);break;case"extra":t.extra=W(n)}}return t}function O(e,t){const i=e.getAttribute("sid");for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"surface":t.surfaces[i]=F(r);break;case"sampler2D":t.samplers[i]=B(r)}}}function F(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"init_from"===n.nodeName)t.init_from=n.textContent}return t}function B(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"source"===n.nodeName)t.source=n.textContent}return t}function N(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=n.nodeName,t.parameters=U(n)}}return t}function U(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[n.nodeName]=j(n);break;case"transparent":t[n.nodeName]={opaque:n.getAttribute("opaque"),data:j(n)}}}return t}function j(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"color":t[n.nodeName]=o(n.textContent);break;case"float":t[n.nodeName]=parseFloat(n.textContent);break;case"texture":t[n.nodeName]={id:n.getAttribute("texture"),extra:V(n)}}}return t}function V(e){const t={technique:{}};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"extra"===n.nodeName)G(n,t)}return t}function G(e,t){for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"technique"===n.nodeName)H(n,t)}}function H(e,t){for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[n.nodeName]=parseFloat(n.textContent);break;case"wrapU":case"wrapV":"TRUE"===n.textContent.toUpperCase()?t.technique[n.nodeName]=1:"FALSE"===n.textContent.toUpperCase()?t.technique[n.nodeName]=0:t.technique[n.nodeName]=parseInt(n.textContent)}}}function W(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"technique"===n.nodeName)t.technique=q(n)}return t}function q(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"double_sided"===n.nodeName)t[n.nodeName]=parseInt(n.textContent)}return t}function $(e){return e}function Z(e){const t=(i=e.url,d(Xe.effects[i],$));var i;const r=t.profile.technique,o=t.profile.extra;let s;switch(r.type){case"phong":case"blinn":s=new n.MeshPhongMaterial;break;case"lambert":s=new n.MeshLambertMaterial;break;default:s=new n.MeshBasicMaterial}function a(e){const i=t.profile.samplers[e.id];let r=null;if(void 0!==i?r=z(t.profile.surfaces[i.source].init_from):(console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),r=z(e.id)),null!==r){const t=function(e){let t,i=e.slice(2+(e.lastIndexOf(".")-1>>>0));if("tga"===(i=i.toLowerCase()))t=We;else t=He;return t}(r);if(void 0!==t){const i=t.load(r),o=e.extra;if(void 0!==o&&void 0!==o.technique&&!1===l(o.technique)){const e=o.technique;i.wrapS=e.wrapU?n.RepeatWrapping:n.ClampToEdgeWrapping,i.wrapT=e.wrapV?n.RepeatWrapping:n.ClampToEdgeWrapping,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=n.RepeatWrapping,i.wrapT=n.RepeatWrapping;return i}return console.warn("THREE.ColladaLoader: THREE.Loader for texture %s not found.",r),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}s.name=e.name||"";const c=r.parameters;for(const e in c){const t=c[e];switch(e){case"diffuse":t.color&&s.color.fromArray(t.color),t.texture&&(s.map=a(t.texture));break;case"specular":t.color&&s.specular&&s.specular.fromArray(t.color),t.texture&&(s.specularMap=a(t.texture));break;case"bump":t.texture&&(s.normalMap=a(t.texture));break;case"ambient":t.texture&&(s.lightMap=a(t.texture));break;case"shininess":t.float&&s.shininess&&(s.shininess=t.float);break;case"emission":t.color&&s.emissive&&s.emissive.fromArray(t.color),t.texture&&(s.emissiveMap=a(t.texture))}}let u=c.transparent,h=c.transparency;if(void 0===h&&u&&(h={float:1}),void 0===u&&h&&(u={opaque:"A_ONE",data:{color:[1,1,1,1]}}),u&&h)if(u.data.texture)s.transparent=!0;else{const e=u.data.color;switch(u.opaque){case"A_ONE":s.opacity=e[3]*h.float;break;case"RGB_ZERO":s.opacity=1-e[0]*h.float;break;case"A_ZERO":s.opacity=1-e[3]*h.float;break;case"RGB_ONE":s.opacity=e[0]*h.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',u.opaque)}s.opacity<1&&(s.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(s.side=n.DoubleSide),s}function X(e){return d(Xe.materials[e],Z)}function Y(e){for(let t=0;t<e.childNodes.length;t++){const i=e.childNodes[t];if("technique_common"===i.nodeName)return J(i)}return{}}function J(e){const t={};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];switch(n.nodeName){case"perspective":case"orthographic":t.technique=n.nodeName,t.parameters=Q(n)}}return t}function Q(e){const t={};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];switch(n.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[n.nodeName]=parseFloat(n.textContent)}}return t}function K(e){let t;switch(e.optics.technique){case"perspective":t=new n.PerspectiveCamera(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":let i=e.optics.parameters.ymag,r=e.optics.parameters.xmag;const o=e.optics.parameters.aspect_ratio;r=void 0===r?i*o:r,i=void 0===i?r/o:i,r*=.5,i*=.5,t=new n.OrthographicCamera(-r,r,i,-i,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new n.PerspectiveCamera}return t.name=e.name||"",t}function ee(e){const t=Xe.cameras[e];return void 0!==t?d(t,K):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function te(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=n.nodeName,t.parameters=ie(n)}}return t}function ie(e){const t={};for(let i=0,r=e.childNodes.length;i<r;i++){const r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"color":const e=o(r.textContent);t.color=(new n.Color).fromArray(e);break;case"falloff_angle":t.falloffAngle=parseFloat(r.textContent);break;case"quadratic_attenuation":const i=parseFloat(r.textContent);t.distance=i?Math.sqrt(1/i):0}}return t}function ne(e){let t;switch(e.technique){case"directional":t=new n.DirectionalLight;break;case"point":t=new n.PointLight;break;case"spot":t=new n.SpotLight;break;case"ambient":t=new n.AmbientLight}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function re(e){const t=Xe.lights[e];return void 0!==t?d(t,ne):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function oe(e){const t={array:[],stride:3};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"float_array":t.array=o(s.textContent);break;case"Name_array":t.array=r(s.textContent);break;case"technique_common":const e=i(s,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function se(e){const t={};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];1===n.nodeType&&(t[n.getAttribute("semantic")]=a(n.getAttribute("source")))}return t}function ae(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"input":const e=a(n.getAttribute("source")),i=n.getAttribute("semantic"),r=parseInt(n.getAttribute("offset")),o=parseInt(n.getAttribute("set")),l=o>0?i+o:i;t.inputs[l]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===i&&(t.hasUV=!0);break;case"vcount":t.vcount=s(n.textContent);break;case"p":t.p=s(n.textContent)}}return t}function le(e){let t=0;for(let i=0,n=e.length;i<n;i++)!0===e[i].hasUV&&t++;t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function ce(e){const t={},i=e.sources,n=e.vertices,r=e.primitives;if(0===r.length)return{};const o=function(e){const t={};for(let i=0;i<e.length;i++){const n=e[i];void 0===t[n.type]&&(t[n.type]=[]),t[n.type].push(n)}return t}(r);for(const e in o){const r=o[e];le(r),t[e]=ue(r,i,n)}return t}function ue(e,t,i){const r={},o={array:[],stride:0},s={array:[],stride:0},a={array:[],stride:0},l={array:[],stride:0},c={array:[],stride:0},u=[],h=[],p=new n.BufferGeometry,d=[];let f=0;for(let n=0;n<e.length;n++){const r=e[n],m=r.inputs;let g=0;switch(r.type){case"lines":case"linestrips":g=2*r.count;break;case"triangles":g=3*r.count;break;case"polylist":for(let e=0;e<r.count;e++){const t=r.vcount[e];switch(t){case 3:g+=3;break;case 4:g+=6;break;default:g+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",r.type)}p.addGroup(f,g,n),f+=g,r.material&&d.push(r.material);for(const n in m){const p=m[n];switch(n){case"VERTEX":for(const n in i){const d=i[n];switch(n){case"POSITION":const i=o.array.length;if(he(r,t[d],p.offset,o.array),o.stride=t[d].stride,t.skinWeights&&t.skinIndices&&(he(r,t.skinIndices,p.offset,u),he(r,t.skinWeights,p.offset,h)),!1===r.hasUV&&!0===e.uvsNeedsFix){const e=(o.array.length-i)/o.stride;for(let t=0;t<e;t++)a.array.push(0,0)}break;case"NORMAL":he(r,t[d],p.offset,s.array),s.stride=t[d].stride;break;case"COLOR":he(r,t[d],p.offset,c.array),c.stride=t[d].stride;break;case"TEXCOORD":he(r,t[d],p.offset,a.array),a.stride=t[d].stride;break;case"TEXCOORD1":he(r,t[d],p.offset,l.array),a.stride=t[d].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',n)}}break;case"NORMAL":he(r,t[p.id],p.offset,s.array),s.stride=t[p.id].stride;break;case"COLOR":he(r,t[p.id],p.offset,c.array),c.stride=t[p.id].stride;break;case"TEXCOORD":he(r,t[p.id],p.offset,a.array),a.stride=t[p.id].stride;break;case"TEXCOORD1":he(r,t[p.id],p.offset,l.array),l.stride=t[p.id].stride}}}return o.array.length>0&&p.setAttribute("position",new n.Float32BufferAttribute(o.array,o.stride)),s.array.length>0&&p.setAttribute("normal",new n.Float32BufferAttribute(s.array,s.stride)),c.array.length>0&&p.setAttribute("color",new n.Float32BufferAttribute(c.array,c.stride)),a.array.length>0&&p.setAttribute("uv",new n.Float32BufferAttribute(a.array,a.stride)),l.array.length>0&&p.setAttribute("uv2",new n.Float32BufferAttribute(l.array,l.stride)),u.length>0&&p.setAttribute("skinIndex",new n.Float32BufferAttribute(u,4)),h.length>0&&p.setAttribute("skinWeight",new n.Float32BufferAttribute(h,4)),r.data=p,r.type=e[0].type,r.materialKeys=d,r}function he(e,t,i,n){const r=e.p,o=e.stride,s=e.vcount;function a(e){let t=r[e+i]*c;const o=t+c;for(;t<o;t++)n.push(l[t])}const l=t.array,c=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(4===i){const t=e+1*o,i=e+2*o,n=e+3*o;a(e+0*o),a(t),a(n),a(t),a(i),a(n)}else if(3===i){const t=e+1*o,i=e+2*o;a(e+0*o),a(t),a(i)}else if(i>4)for(let t=1,n=i-2;t<=n;t++){const i=e+o*t,n=e+o*(t+1);a(e+0*o),a(i),a(n)}e+=o*i}}else for(let e=0,t=r.length;e<t;e+=o)a(e)}function pe(e){return d(Xe.geometries[e],ce)}function de(e){return void 0!==e.build?e.build:e}function fe(e,t){for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"joint":t.joints[n.getAttribute("sid")]=me(n);break;case"link":t.links.push(_e(n))}}}function me(e){let t;for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"prismatic":case"revolute":t=ge(n)}}return t}function ge(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new n.Vector3,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"axis":const e=o(n.textContent);t.axis.fromArray(e);break;case"limits":const i=n.getElementsByTagName("max")[0],r=n.getElementsByTagName("min")[0];t.limits.max=parseFloat(i.textContent),t.limits.min=parseFloat(r.textContent)}}return t.limits.min>=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function _e(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"attachment_full":t.attachments.push(ye(n));break;case"matrix":case"translate":case"rotate":t.transforms.push(ve(n))}}return t}function ye(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"link":t.links.push(_e(n));break;case"matrix":case"translate":case"rotate":t.transforms.push(ve(n))}}return t}function ve(e){const t={type:e.nodeName},i=o(e.textContent);switch(t.type){case"matrix":t.obj=new n.Matrix4,t.obj.fromArray(i).transpose();break;case"translate":t.obj=new n.Vector3,t.obj.fromArray(i);break;case"rotate":t.obj=new n.Vector3,t.obj.fromArray(i),t.angle=n.MathUtils.degToRad(i[3])}return t}function xe(e,t){for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType&&"technique_common"===n.nodeName)be(n,t)}}function be(e,t){for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"inertia":t.inertia=o(n.textContent);break;case"mass":t.mass=o(n.textContent)[0]}}}function we(e){const t={target:e.getAttribute("target").split("/").pop()};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType&&"axis"===n.nodeName){const e=n.getElementsByTagName("param")[0];t.axis=e.textContent;const i=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=i.substr(0,i.length-1)}}return t}function Me(e){return void 0!==e.build?e.build:e}function Te(e){const t=[],i=Ue.querySelector('[id="'+e.id+'"]');for(let e=0;e<i.childNodes.length;e++){const r=i.childNodes[e];if(1!==r.nodeType)continue;let s,a;switch(r.nodeName){case"matrix":s=o(r.textContent);const e=(new n.Matrix4).fromArray(s).transpose();t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:e});break;case"translate":case"scale":s=o(r.textContent),a=(new n.Vector3).fromArray(s),t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:a});break;case"rotate":s=o(r.textContent),a=(new n.Vector3).fromArray(s);const i=n.MathUtils.degToRad(s[3]);t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:a,angle:i})}}return t}const Se=new n.Matrix4,Ee=new n.Vector3;function Ae(e){const t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new n.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let i=0;i<e.childNodes.length;i++){const r=e.childNodes[i];if(1!==r.nodeType)continue;let s;switch(r.nodeName){case"node":t.nodes.push(r.getAttribute("id")),Ae(r);break;case"instance_camera":t.instanceCameras.push(a(r.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(Ce(r));break;case"instance_light":t.instanceLights.push(a(r.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(Ce(r));break;case"instance_node":t.instanceNodes.push(a(r.getAttribute("url")));break;case"matrix":s=o(r.textContent),t.matrix.multiply(Se.fromArray(s).transpose()),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"translate":s=o(r.textContent),Ee.fromArray(s),t.matrix.multiply(Se.makeTranslation(Ee.x,Ee.y,Ee.z)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"rotate":s=o(r.textContent);const e=n.MathUtils.degToRad(s[3]);t.matrix.multiply(Se.makeRotationAxis(Ee.fromArray(s),e)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"scale":s=o(r.textContent),t.matrix.scale(Ee.fromArray(s)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"extra":break;default:console.log(r)}}return De(t.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",t.id):Xe.nodes[t.id]=t,t}function Ce(e){const t={id:a(e.getAttribute("url")),materials:{},skeletons:[]};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];switch(n.nodeName){case"bind_material":const e=n.getElementsByTagName("instance_material");for(let i=0;i<e.length;i++){const n=e[i],r=n.getAttribute("symbol"),o=n.getAttribute("target");t.materials[r]=a(o)}break;case"skeleton":t.skeletons.push(a(n.textContent))}}return t}function Le(e,t){const i=[],r=[];let o,s,a;for(o=0;o<e.length;o++){const n=e[o];let r;if(De(n))Ie(r=Oe(n),t,i);else if(l=n,void 0!==Xe.visualScenes[l]){const e=Xe.visualScenes[n].children;for(let n=0;n<e.length;n++){const r=e[n];"JOINT"===r.type&&Ie(Oe(r.id),t,i)}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",n)}var l;for(o=0;o<t.length;o++)for(s=0;s<i.length;s++)if((a=i[s]).bone.name===t[o].name){r[o]=a,a.processed=!0;break}for(o=0;o<i.length;o++)!1===(a=i[o]).processed&&(r.push(a),a.processed=!0);const c=[],u=[];for(o=0;o<r.length;o++)a=r[o],c.push(a.bone),u.push(a.boneInverse);return new n.Skeleton(c,u)}function Ie(e,t,i){e.traverse((function(e){if(!0===e.isBone){let r;for(let i=0;i<t.length;i++){const n=t[i];if(n.name===e.name){r=n.boneInverse;break}}void 0===r&&(r=new n.Matrix4),i.push({bone:e,boneInverse:r,processed:!1})}}))}function Pe(e){const t=[],i=e.matrix,r=e.nodes,o=e.type,s=e.instanceCameras,a=e.instanceControllers,l=e.instanceLights,c=e.instanceGeometries,u=e.instanceNodes;for(let e=0,i=r.length;e<i;e++)t.push(Oe(r[e]));for(let e=0,i=s.length;e<i;e++){const i=ee(s[e]);null!==i&&t.push(i.clone())}for(let e=0,i=a.length;e<i;e++){const i=a[e],n=(h=i.id,d(Xe.controllers[h],R)),r=ze(pe(n.id),i.materials),o=Le(i.skeletons,n.skin.joints);for(let e=0,i=r.length;e<i;e++){const i=r[e];i.isSkinnedMesh&&(i.bind(o,n.skin.bindMatrix),i.normalizeSkinWeights()),t.push(i)}}var h;for(let e=0,i=l.length;e<i;e++){const i=re(l[e]);null!==i&&t.push(i.clone())}for(let e=0,i=c.length;e<i;e++){const i=c[e],n=ze(pe(i.id),i.materials);for(let e=0,i=n.length;e<i;e++)t.push(n[e])}for(let e=0,i=u.length;e<i;e++)t.push(Oe(u[e]).clone());let p;if(0===r.length&&1===t.length)p=t[0];else{p="JOINT"===o?new n.Bone:new n.Group;for(let e=0;e<t.length;e++)p.add(t[e])}return p.name="JOINT"===o?e.sid:e.name,p.matrix.copy(i),p.matrix.decompose(p.position,p.quaternion,p.scale),p}const Re=new n.MeshBasicMaterial({color:16711935});function ke(e,t){const i=[];for(let n=0,r=e.length;n<r;n++){const r=t[e[n]];void 0===r?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[n]),i.push(Re)):i.push(X(r))}return i}function ze(e,t){const i=[];for(const r in e){const o=e[r],s=ke(o.materialKeys,t);0===s.length&&("lines"===r||"linestrips"===r?s.push(new n.LineBasicMaterial):s.push(new n.MeshPhongMaterial));const a=void 0!==o.data.attributes.skinIndex,l=1===s.length?s[0]:s;let c;switch(r){case"lines":c=new n.LineSegments(o.data,l);break;case"linestrips":c=new n.Line(o.data,l);break;case"triangles":case"polylist":c=a?new n.SkinnedMesh(o.data,l):new n.Mesh(o.data,l)}i.push(c)}return i}function De(e){return void 0!==Xe.nodes[e]}function Oe(e){return d(Xe.nodes[e],Pe)}function Fe(e){const t=new n.Group;t.name=e.name;const i=e.children;for(let e=0;e<i.length;e++){const n=i[e];t.add(Oe(n.id))}return t}function Be(e){return d(Xe.visualScenes[e],Fe)}if(0===e.length)return{scene:new n.Scene};const Ne=(new DOMParser).parseFromString(e,"application/xml"),Ue=i(Ne,"COLLADA")[0],je=Ne.getElementsByTagName("parsererror")[0];if(void 0!==je){const e=i(je,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const i=[e];for(;i.length;){const e=i.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",i.push.apply(i,e.childNodes))}return t.trim()}(je),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const Ve=Ue.getAttribute("version");console.log("THREE.ColladaLoader: File version",Ve);const Ge=function(e){return{unit:c(i(e,"unit")[0]),upAxis:u(i(e,"up_axis")[0])}}(i(Ue,"asset")[0]),He=new n.TextureLoader(this.manager);let We;He.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),n.TGALoader&&(We=new n.TGALoader(this.manager)).setPath(this.resourcePath||t);const qe=[];let $e={},Ze=0;const Xe={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};h(Ue,"library_animations","animation",(function e(t){const i={sources:{},samplers:{},channels:{}};let r=!1;for(let n=0,o=t.childNodes.length;n<o;n++){const o=t.childNodes[n];if(1!==o.nodeType)continue;let s;switch(o.nodeName){case"source":s=o.getAttribute("id"),i.sources[s]=oe(o);break;case"sampler":s=o.getAttribute("id"),i.samplers[s]=f(o);break;case"channel":s=o.getAttribute("target"),i.channels[s]=m(o);break;case"animation":e(o),r=!0;break;default:console.log(o)}}!1===r&&(Xe.animations[t.getAttribute("id")||n.MathUtils.generateUUID()]=i)})),h(Ue,"library_animation_clips","animation_clip",(function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"instance_animation"===n.nodeName)t.animations.push(a(n.getAttribute("url")))}Xe.clips[e.getAttribute("id")]=t})),h(Ue,"library_controllers","controller",(function(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"skin":t.id=a(n.getAttribute("source")),t.skin=L(n);break;case"morph":t.id=a(n.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}Xe.controllers[e.getAttribute("id")]=t})),h(Ue,"library_images","image",(function(e){const t={init_from:i(e,"init_from")[0].textContent};Xe.images[e.getAttribute("id")]=t})),h(Ue,"library_effects","effect",(function(e){const t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"profile_COMMON"===n.nodeName)t.profile=D(n)}Xe.effects[e.getAttribute("id")]=t})),h(Ue,"library_materials","material",(function(e){const t={name:e.getAttribute("name")};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"instance_effect"===n.nodeName)t.url=a(n.getAttribute("url"))}Xe.materials[e.getAttribute("id")]=t})),h(Ue,"library_cameras","camera",(function(e){const t={name:e.getAttribute("name")};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"optics"===n.nodeName)t.optics=Y(n)}Xe.cameras[e.getAttribute("id")]=t})),h(Ue,"library_lights","light",(function(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){const n=e.childNodes[i];if(1===n.nodeType&&"technique_common"===n.nodeName)t=te(n)}Xe.lights[e.getAttribute("id")]=t})),h(Ue,"library_geometries","geometry",(function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},n=i(e,"mesh")[0];if(void 0!==n){for(let e=0;e<n.childNodes.length;e++){const i=n.childNodes[e];if(1!==i.nodeType)continue;const r=i.getAttribute("id");switch(i.nodeName){case"source":t.sources[r]=oe(i);break;case"vertices":t.vertices=se(i);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",i.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(ae(i));break;default:console.log(i)}}Xe.geometries[e.getAttribute("id")]=t}})),h(Ue,"library_nodes","node",Ae),h(Ue,"library_visual_scenes","visual_scene",(function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let e=0;e<t.length;e++){const i=t[e];!1===i.hasAttribute("id")&&i.setAttribute("id","three_default_"+Ze++)}}(e);const n=i(e,"node");for(let e=0;e<n.length;e++)t.children.push(Ae(n[e]));Xe.visualScenes[e.getAttribute("id")]=t})),h(Ue,"library_kinematics_models","kinematics_model",(function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType&&"technique_common"===n.nodeName)fe(n,t)}Xe.kinematicsModels[e.getAttribute("id")]=t})),h(Ue,"library_physics_models","physics_model",(function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType&&"rigid_body"===n.nodeName)t.rigidBodies[n.getAttribute("name")]={},xe(n,t.rigidBodies[n.getAttribute("name")])}Xe.physicsModels[e.getAttribute("id")]=t})),h(Ue,"scene","instance_kinematics_scene",(function(e){const t={bindJointAxis:[]};for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i];if(1===n.nodeType&&"bind_joint_axis"===n.nodeName)t.bindJointAxis.push(we(n))}Xe.kinematicsScenes[a(e.getAttribute("url"))]=t})),p(Xe.animations,g),p(Xe.clips,A),p(Xe.controllers,R),p(Xe.images,k),p(Xe.effects,$),p(Xe.materials,Z),p(Xe.cameras,K),p(Xe.lights,ne),p(Xe.geometries,ce),p(Xe.visualScenes,Fe),function(){const e=Xe.clips;if(!0===l(e)){if(!1===l(Xe.animations)){const e=[];for(const t in Xe.animations){const i=_(t);for(let t=0,n=i.length;t<n;t++)e.push(i[t])}qe.push(new n.AnimationClip("default",-1,e))}}else for(const t in e)qe.push(C(t))}(),function(){const e=Object.keys(Xe.kinematicsModels)[0],t=Object.keys(Xe.kinematicsScenes)[0],i=Object.keys(Xe.visualScenes)[0];if(void 0===e||void 0===t)return;const r=(o=e,d(Xe.kinematicsModels[o],de));var o;const s=function(e){return d(Xe.kinematicsScenes[e],Me)}(t),a=Be(i),l=s.bindJointAxis,c={};for(let e=0,t=l.length;e<t;e++){const t=l[e],i=Ue.querySelector('[sid="'+t.target+'"]');if(i){const e=i.parentElement;u(t.jointIndex,e)}}function u(e,t){const i=t.getAttribute("name"),n=r.joints[e];a.traverse((function(r){r.name===i&&(c[e]={object:r,transforms:Te(t),joint:n,position:n.zeroPosition})}))}const h=new n.Matrix4;$e={joints:r&&r.joints,getJointValue:function(e){const t=c[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(e,t){const i=c[e];if(i){const r=i.joint;if(t>r.limits.max||t<r.limits.min)console.warn("THREE.ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+r.limits.min+", max: "+r.limits.max+").");else if(r.static)console.warn("THREE.ColladaLoader: Joint "+e+" is static.");else{const o=i.object,s=r.axis,a=i.transforms;Se.identity();for(let i=0;i<a.length;i++){const o=a[i];if(o.sid&&-1!==o.sid.indexOf(e))switch(r.type){case"revolute":Se.multiply(h.makeRotationAxis(s,n.MathUtils.degToRad(t)));break;case"prismatic":Se.multiply(h.makeTranslation(s.x*t,s.y*t,s.z*t));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+r.type)}else switch(o.type){case"matrix":Se.multiply(o.obj);break;case"translate":Se.multiply(h.makeTranslation(o.obj.x,o.obj.y,o.obj.z));break;case"scale":Se.scale(o.obj);break;case"rotate":Se.multiply(h.makeRotationAxis(o.obj,o.angle))}}o.matrix.copy(Se),o.matrix.decompose(o.position,o.quaternion,o.scale),c[e].position=t}}else console.log("THREE.ColladaLoader: "+e+" does not exist.")}}}();const Ye=function(e){return Be(a(i(e,"instance_visual_scene")[0].getAttribute("url")))}(i(Ue,"scene")[0]);return Ye.animations=qe,"Z_UP"===Ge.upAxis&&Ye.quaternion.setFromEuler(new n.Euler(-Math.PI/2,0,0)),Ye.scale.multiplyScalar(Ge.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),qe},kinematics:$e,library:Xe,scene:Ye}}},Y=Y=n.ColladaLoader;var J={};const Q=new I,K=new P,ee=new X,te=new Z,ie=new Y;J=J=function(e,t,i){if(void 0===e)return console.error("Invalid options provided to loadObj()");let n;switch((e=u._validate(e,b.prototype._defaults.loadObj)).type||(e.type="mtl"),e.type){case"mtl":n=Q;break;case"gltf":case"glb":n=ee;break;case"fbx":n=te;break;case"dae":n=ie}K.load(e.mtl,(function(r){r&&"mtl"==e.type&&(r.preload(),n.setMaterials(r)),n.load(e.obj,(n=>{let r=[];switch(e.type){case"mtl":n=n.children[0];break;case"gltf":case"glb":case"dae":r=n.animations,n=n.scene;break;case"fbx":r=n.animations}n.animations=r;const o=u.types.rotation(e.rotation,[0,0,0]),s=u.types.scale(e.scale,[1,1,1]);n.rotation.set(o[0],o[1],o[2]),n.scale.set(s[0],s[1],s[2]),e.normalize&&n.traverse((function(e){if(e.isMesh){let t;"MeshStandardMaterial"==e.material.type?(e.material.metalness&&(e.material.metalness*=.1),e.material.glossiness&&(e.material.glossiness*=.25),t=new THREE.Color(12,12,12)):"MeshPhongMaterial"==e.material.type&&(e.material.shininess=.1,t=new THREE.Color(20,20,20)),e.material.specular&&e.material.specular.isColor&&(e.material.specular=t)}})),n.name="model";let a=b.prototype._makeGroup(n,e);b.prototype._addMethods(a),a.setAnchor(e.anchor),a.setCenter(e.adjustment),a.raycasted=e.raycasted,i(a),t(a),a.setFixedZoom(e.mapScale),a.idle()}),(()=>null),(t=>{console.error("Could not load model file: "+e.obj+" \n "+t.stack),i("Error loading the model")}))}),(()=>null),(e=>{console.warn("No material file found "+e.stack)}))};var ne={};function re(e){e=u._validate(e,b.prototype._defaults.line);var t=u.lnglatsToWorld(e.geometry),i=u.normalizeVertices(t),r=u.flattenVectors(i.vertices),o=new n.LineGeometry;o.setPositions(r);let s=new n.LineMaterial({color:e.color,linewidth:e.width,dashed:!1,opacity:e.opacity});return s.resolution.set(window.innerWidth,window.innerHeight),s.isMaterial=!0,s.transparent=!0,s.depthWrite=!1,(re=new n.Line2(o,s)).position.copy(i.position),re.computeLineDistances(),re}ne=ne=re,function(){const e=new n.Box3,t=new n.Vector3;class i extends n.InstancedBufferGeometry{constructor(){super(),this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new n.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new n.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),i.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new n.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new n.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceEnd",new n.InterleavedBufferAttribute(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new n.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new n.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceColorEnd",new n.InterleavedBufferAttribute(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new n.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;if(!t.isGeometry)return t.isBufferGeometry&&this.setPositions(t.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new n.Box3);const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;void 0!==t&&void 0!==i&&(this.boundingBox.setFromBufferAttribute(t),e.setFromBufferAttribute(i),this.boundingBox.union(e))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new n.Sphere),null===this.boundingBox&&this.computeBoundingBox();const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;if(void 0!==e&&void 0!==i){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let o=0,s=e.count;o<s;o++)t.fromBufferAttribute(e,o),r=Math.max(r,n.distanceToSquared(t)),t.fromBufferAttribute(i,o),r=Math.max(r,n.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}i.prototype.isLineSegmentsGeometry=!0,n.LineSegmentsGeometry=i}(),function(){class e extends n.LineSegmentsGeometry{constructor(){super(),this.type="LineGeometry"}setPositions(e){for(var t=e.length-3,i=new Float32Array(2*t),n=0;n<t;n+=3)i[2*n]=e[n],i[2*n+1]=e[n+1],i[2*n+2]=e[n+2],i[2*n+3]=e[n+3],i[2*n+4]=e[n+4],i[2*n+5]=e[n+5];return super.setPositions(i),this}setColors(e){for(var t=e.length-3,i=new Float32Array(2*t),n=0;n<t;n+=3)i[2*n]=e[n],i[2*n+1]=e[n+1],i[2*n+2]=e[n+2],i[2*n+3]=e[n+3],i[2*n+4]=e[n+4],i[2*n+5]=e[n+5];return super.setColors(i),this}fromLine(e){var t=e.geometry;if(!t.isGeometry)return t.isBufferGeometry&&this.setPositions(t.attributes.position.array),this;console.error("THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}}e.prototype.isLineGeometry=!0,n.LineGeometry=e}(),function(){class e extends n.LineSegmentsGeometry{constructor(e){super(),this.type="WireframeGeometry2",this.fromWireframeGeometry(new n.WireframeGeometry(e))}}e.prototype.isWireframeGeometry2=!0,n.WireframeGeometry2=e}(),function(){n.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new n.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},n.ShaderLib.line={uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.fog,n.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\tworldStart = start.xyz;\n\t\t\tworldEnd = end.xyz;\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segements overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class e extends n.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:n.UniformsUtils.clone(n.ShaderLib.line.uniforms),vertexShader:n.ShaderLib.line.vertexShader,fragmentShader:n.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(e){Boolean(e)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set:function(e){Boolean(e)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===e?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}e.prototype.isLineMaterial=!0,n.LineMaterial=e}(),function(){const e=new n.Vector3,t=new n.Vector3,i=new n.Vector4,r=new n.Vector4,o=new n.Vector4,s=new n.Vector3,a=new n.Matrix4,l=new n.Line3,c=new n.Vector3,u=new n.Box3,h=new n.Sphere,p=new n.Vector4;class d extends n.Mesh{constructor(e=new n.LineSegmentsGeometry,t=new n.LineMaterial({color:16777215*Math.random()})){super(e,t),this.type="LineSegments2"}computeLineDistances(){const i=this.geometry,r=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=new Float32Array(2*r.count);for(let i=0,n=0,a=r.count;i<a;i++,n+=2)e.fromBufferAttribute(r,i),t.fromBufferAttribute(o,i),s[n]=0===n?0:s[n-1],s[n+1]=s[n]+e.distanceTo(t);const a=new n.InstancedInterleavedBuffer(s,2,1);return i.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(a,1,0)),i.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){null===e.camera&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');const d=void 0!==e.params.Line2&&e.params.Line2.threshold||0,f=e.ray,m=e.camera,g=m.projectionMatrix,_=this.matrixWorld,y=this.geometry,v=this.material,x=v.resolution,b=v.linewidth+d,w=y.attributes.instanceStart,M=y.attributes.instanceEnd,T=-m.near,S=2*Math.max(b/x.width,b/x.height);null===y.boundingSphere&&y.computeBoundingSphere(),h.copy(y.boundingSphere).applyMatrix4(_);const E=Math.max(m.near,h.distanceToPoint(f.origin));p.set(0,0,-E,1).applyMatrix4(m.projectionMatrix),p.multiplyScalar(1/p.w),p.applyMatrix4(m.projectionMatrixInverse);const A=.5*Math.abs(S/p.w);if(h.radius+=A,!1===e.ray.intersectsSphere(h))return;null===y.boundingBox&&y.computeBoundingBox(),u.copy(y.boundingBox).applyMatrix4(_);const C=Math.max(m.near,u.distanceToPoint(f.origin));p.set(0,0,-C,1).applyMatrix4(m.projectionMatrix),p.multiplyScalar(1/p.w),p.applyMatrix4(m.projectionMatrixInverse);const L=.5*Math.abs(S/p.w);if(u.max.x+=L,u.max.y+=L,u.max.z+=L,u.min.x-=L,u.min.y-=L,u.min.z-=L,!1!==e.ray.intersectsBox(u)){f.at(1,o),o.w=1,o.applyMatrix4(m.matrixWorldInverse),o.applyMatrix4(g),o.multiplyScalar(1/o.w),o.x*=x.x/2,o.y*=x.y/2,o.z=0,s.copy(o),a.multiplyMatrices(m.matrixWorldInverse,_);for(let e=0,o=w.count;e<o;e++){if(i.fromBufferAttribute(w,e),r.fromBufferAttribute(M,e),i.w=1,r.w=1,i.applyMatrix4(a),r.applyMatrix4(a),i.z>T&&r.z>T)continue;if(i.z>T){const e=i.z-r.z,t=(i.z-T)/e;i.lerp(r,t)}else if(r.z>T){const e=r.z-i.z,t=(r.z-T)/e;r.lerp(i,t)}i.applyMatrix4(g),r.applyMatrix4(g),i.multiplyScalar(1/i.w),r.multiplyScalar(1/r.w),i.x*=x.x/2,i.y*=x.y/2,r.x*=x.x/2,r.y*=x.y/2,l.start.copy(i),l.start.z=0,l.end.copy(r),l.end.z=0;const o=l.closestPointToPointParameter(s,!0);l.at(o,c);const u=n.MathUtils.lerp(i.z,r.z,o),h=u>=-1&&u<=1,p=s.distanceTo(c)<.5*b;if(h&&p){l.start.fromBufferAttribute(w,e),l.end.fromBufferAttribute(M,e),l.start.applyMatrix4(_),l.end.applyMatrix4(_);const i=new n.Vector3,r=new n.Vector3;f.distanceSqToSegment(l.start,l.end,r,i),t.push({point:r,pointOnLine:i,distance:f.origin.distanceTo(r),object:this,face:null,faceIndex:e,uv:null,uv2:null})}}}}}d.prototype.LineSegments2=!0,n.LineSegments2=d}(),function(){class e extends n.LineSegments2{constructor(e=new n.LineGeometry,t=new n.LineMaterial({color:16777215*Math.random()})){super(e,t),this.type="Line2"}}e.prototype.isLine2=!0,n.Line2=e}(),function(){const e=new n.Vector3,t=new n.Vector3;class i extends n.Mesh{constructor(e=new n.LineSegmentsGeometry,t=new n.LineMaterial({color:16777215*Math.random()})){super(e,t),this.type="Wireframe"}computeLineDistances(){const i=this.geometry,r=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=new Float32Array(2*r.count);for(let i=0,n=0,a=r.count;i<a;i++,n+=2)e.fromBufferAttribute(r,i),t.fromBufferAttribute(o,i),s[n]=0===n?0:s[n-1],s[n+1]=s[n]+e.distanceTo(t);const a=new n.InstancedInterleavedBuffer(s,2,1);return i.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(a,1,0)),i.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(a,1,1)),this}}i.prototype.isWireframe=!0,n.Wireframe=i}();var oe={};oe=oe=function(e,t){e=u._validate(e,b.prototype._defaults.tube);let i=[];e.geometry.forEach((e=>{i.push(new n.Vector3(e[0],e[1],e[2]))}));const r=new n.CatmullRomCurve3(i);let o=new n.TubeGeometry(r,i.length,e.radius,e.sides,!1),s=m(e),a=new n.Mesh(o,s);return new T({obj:a,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var se={};se=se=function(e){this.map=e,this.renderer=new x.CSS2DRenderer,this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.domElement.style.position="absolute",this.renderer.domElement.id="labelCanvas",this.renderer.domElement.style.top=0,this.renderer.domElement.style.zIndex="0",this.map.getCanvasContainer().appendChild(this.renderer.domElement),this.scene,this.camera,this.dispose=function(){this.map.getCanvasContainer().removeChild(this.renderer.domElement),this.renderer.domElement.remove(),this.renderer={}},this.setSize=function(e,t){this.renderer.setSize(e,t)},this.map.on("resize",function(){this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight)}.bind(this)),this.state={reset:function(){}},this.render=async function(e,t){return this.scene=e,this.camera=t,new Promise((i=>{i(this.renderer.render(e,t))}))},this.toggleLabels=async function(e,t){return new Promise((i=>{i(this.setVisibility(e,t,this.scene,this.camera,this.renderer))}))},this.setVisibility=function(e,t,i,n,r){this.renderer.cacheList.forEach((function(o){o.visible!=t&&o.layer===e&&(t&&o.alwaysVisible||!t)&&(o.visible=t,r.renderObject(o,i,n))}))}};var ae={};ae=ae=class{constructor(e,t){this.id=e.layerId,this.type="custom",this.renderingMode="3d",this.opacity=.5,this.buildingsLayerId=e.buildingsLayerId,this.minAltitude=e.minAltitude||.1,this.tb=t}onAdd(e,t){this.map=e;const i=t.createShader(t.VERTEX_SHADER);t.shaderSource(i,"\n\t\t\tuniform mat4 u_matrix;\n\t\t\tuniform float u_height_factor;\n\t\t\tuniform float u_altitude;\n\t\t\tuniform float u_azimuth;\n\t\t\tattribute vec2 a_pos;\n\t\t\tattribute vec4 a_normal_ed;\n\t\t\tattribute lowp vec2 a_base;\n\t\t\tattribute lowp vec2 a_height;\n\t\t\tvoid main() {\n\t\t\t\tfloat base = max(0.0, a_base.x);\n\t\t\t\tfloat height = max(0.0, a_height.x);\n\t\t\t\tfloat t = mod(a_normal_ed.x, 2.0);\n\t\t\t\tvec4 pos = vec4(a_pos, t > 0.0 ? height : base, 1);\n\t\t\t\tfloat len = pos.z * u_height_factor / tan(u_altitude);\n\t\t\t\tpos.x += cos(u_azimuth) * len;\n\t\t\t\tpos.y += sin(u_azimuth) * len;\n\t\t\t\tpos.z = 0.0;\n\t\t\t\tgl_Position = u_matrix * pos;\n\t\t\t}\n\t\t\t"),t.compileShader(i);const n=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(n,"\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.7);\n\t\t\t}\n\t\t\t"),t.compileShader(n),this.program=t.createProgram(),t.attachShader(this.program,i),t.attachShader(this.program,n),t.linkProgram(this.program),t.validateProgram(this.program),this.uMatrix=t.getUniformLocation(this.program,"u_matrix"),this.uHeightFactor=t.getUniformLocation(this.program,"u_height_factor"),this.uAltitude=t.getUniformLocation(this.program,"u_altitude"),this.uAzimuth=t.getUniformLocation(this.program,"u_azimuth"),this.aPos=t.getAttribLocation(this.program,"a_pos"),this.aNormal=t.getAttribLocation(this.program,"a_normal_ed"),this.aBase=t.getAttribLocation(this.program,"a_base"),this.aHeight=t.getAttribLocation(this.program,"a_height")}render(e,t){e.useProgram(this.program);const i=this.map.style.sourceCaches.composite,n=i.getVisibleCoordinates().reverse(),r=this.map.getLayer(this.buildingsLayerId),o=this.map.painter.context,{lng:s,lat:a}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[s,a]);e.uniform1f(this.uAltitude,l.altitude>this.minAltitude?l.altitude:0),e.uniform1f(this.uAzimuth,l.azimuth+3*Math.PI/2),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.getExtension("EXT_blend_minmax"),e.disable(e.DEPTH_TEST);for(const t of n){const n=i.getTile(t),s=n.getBucket(r);if(!s)continue;const[a,l]=s.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;e.uniformMatrix4fv(this.uMatrix,!1,t.posMatrix),e.uniform1f(this.uHeightFactor,Math.pow(2,t.overscaledZ)/n.tileSize/8);for(const t of s.segments.get()){const i=o.currentNumAttributes||0,n=2;for(let t=n;t<i;t++)e.disableVertexAttribArray(t);const r=t.vertexOffset||0;e.enableVertexAttribArray(this.aPos),e.enableVertexAttribArray(this.aNormal),e.enableVertexAttribArray(this.aHeight),e.enableVertexAttribArray(this.aBase),s.layoutVertexBuffer.bind(),e.vertexAttribPointer(this.aPos,2,e.SHORT,!1,12,12*r),e.vertexAttribPointer(this.aNormal,4,e.SHORT,!1,12,4+12*r),a.bind(),e.vertexAttribPointer(this.aHeight,1,e.FLOAT,!1,4,4*r),l.bind(),e.vertexAttribPointer(this.aBase,1,e.FLOAT,!1,4,4*r),s.indexBuffer.bind(),o.currentNumAttributes=n,e.drawElements(e.TRIANGLES,3*t.primitiveLength,e.UNSIGNED_SHORT,3*t.primitiveOffset*2)}}}};var le={};function ce(e,t,i){this.init(e,t,i)}ce.prototype={repaint:function(){this.map.repaint=!0},init:function(e,t,i){this.options=u._validate(i||{},ue),this.map=e,this.map.tb=this,this.objects=new b,this.mapboxVersion=parseFloat(this.map.version),this.renderer=new n.WebGLRenderer({alpha:!0,antialias:!0,preserveDrawingBuffer:i.preserveDrawingBuffer,canvas:e.getCanvas(),context:t}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.outputEncoding=n.sRGBEncoding,this.renderer.autoClear=!1,this.labelRenderer=new se(this.map),this.scene=new n.Scene,this.world=new n.Group,this.world.name="world",this.scene.add(this.world),this.objectsCache=new Map,this.zoomLayers=[],this.fov=this.options.fov,this.orthographic=this.options.orthographic||!1,this.raycaster=new n.Raycaster,this.raycaster.layers.set(0),this.mapCenter=this.map.getCenter(),this.mapCenterUnits=u.projectToWorld([this.mapCenter.lng,this.mapCenter.lat]),this.lightDateTime=new Date,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition,this.rotationStep=5,this.gridStep=6,this.altitudeStep=.1,this.defaultCursor="default",this.lights=this.initLights,this.options.defaultLights&&this.defaultLights(),this.options.realSunlight&&this.realSunlight(this.options.realSunlightHelper),this.skyLayerName="sky-layer",this.terrainSourceName="mapbox-dem",this.terrainExaggeration=1,this.terrainLayerName="",this.enableSelectingFeatures=this.options.enableSelectingFeatures||!1,this.enableSelectingObjects=this.options.enableSelectingObjects||!1,this.enableDraggingObjects=this.options.enableDraggingObjects||!1,this.enableRotatingObjects=this.options.enableRotatingObjects||!1,this.enableTooltips=this.options.enableTooltips||!1,this.multiLayer=this.options.multiLayer||!1,this.map.on("style.load",(function(){this.tb.zoomLayers=[],this.tb.options.multiLayer&&this.addLayer({id:"threebox_layer",type:"custom",renderingMode:"3d",map:this,onAdd:function(e,t){},render:function(e,t){this.map.tb.update()}}),this.once("idle",(()=>{this.tb.setObjectsScale()})),this.tb.options.sky&&(this.tb.sky=!0),this.tb.options.terrain&&(this.tb.terrain=!0),["satellite","mapbox-mapbox-satellite","satelliteLayer"].forEach((e=>{this.getLayer(e)&&(this.tb.terrainLayerName=e)}))})),this.map.on("load",(function(){let t;this.selectedObject,this.selectedFeature,this.draggedObject,this.overedObject,this.overedFeature;let i,n=this.getCanvasContainer();this.getCanvasContainer().style.cursor=this.tb.defaultCursor;let r,o,s,a,l=[];function c(e){var t=n.getBoundingClientRect();return{x:e.originalEvent.clientX-t.left-n.clientLeft,y:e.originalEvent.clientY-t.top-n.clientTop}}this.unselectObject=function(){this.selectedObject.selected=!1,this.selectedObject=null},this.outObject=function(){this.overedObject.over=!1,this.overedObject=null},this.unselectFeature=function(e){void 0!==e.id&&(this.setFeatureState({source:e.source,sourceLayer:e.sourceLayer,id:e.id},{select:!1}),this.removeTooltip(e),(e=this.queryRenderedFeatures({layers:[e.layer.id],filter:["==",["id"],e.id]})[0])&&this.fire("SelectedFeatureChange",{detail:e}),this.selectedFeature=null)},this.selectFeature=function(e){this.selectedFeature=e,this.setFeatureState({source:this.selectedFeature.source,sourceLayer:this.selectedFeature.sourceLayer,id:this.selectedFeature.id},{select:!0}),this.selectedFeature=this.queryRenderedFeatures({layers:[this.selectedFeature.layer.id],filter:["==",["id"],this.selectedFeature.id]})[0],this.addTooltip(this.selectedFeature),this.fire("SelectedFeatureChange",{detail:this.selectedFeature})},this.outFeature=function(t){this.overedFeature&&void 0!==this.overedFeature&&this.overedFeature.id!=t&&(e.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!1}),this.removeTooltip(this.overedFeature),this.overedFeature=null)},this.addTooltip=function(e){if(!this.tb.enableTooltips)return;let t=this.tb.getFeatureCenter(e),i=this.tb.tooltip({text:e.properties.name||e.id||e.type,mapboxStyle:!0,feature:e});i.setCoords(t),this.tb.add(i,e.layer.id),e.tooltip=i,e.tooltip.tooltip.visible=!0},this.removeTooltip=function(e){e.tooltip&&(e.tooltip.visibility=!1,this.tb.remove(e.tooltip),e.tooltip=null)},e.onContextMenu=function(e){alert("contextMenu")},this.onClick=function(t){let i,n=[];if(e.tb.enableSelectingObjects&&(n=this.tb.queryRenderedFeatures(t.point)),i="object"==typeof n[0]){let e=ce.prototype.findParent3DObject(n[0]);if(e){if(this.selectedFeature&&this.unselectFeature(this.selectedFeature),this.selectedObject){if(this.selectedObject.uuid!=e.uuid)this.selectedObject.selected=!1,e.selected=!0,this.selectedObject=e;else if(this.selectedObject.uuid==e.uuid)return void this.unselectObject()}else this.selectedObject=e,this.selectedObject.selected=!0;this.selectedObject.dispatchEvent({type:"Wireframed",detail:this.selectedObject}),this.selectedObject.dispatchEvent({type:"IsPlayingChanged",detail:this.selectedObject}),this.repaint=!0,t.preventDefault()}}else{let i=[];if(e.tb.enableSelectingFeatures&&(i=this.queryRenderedFeatures(t.point)),i.length>0&&"fill-extrusion"==i[0].layer.type&&void 0!==i[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=i[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(i[0]);else if(this.selectedFeature.id==i[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(i[0])}},this.onMouseMove=function(n){let l,u=c(n);if(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,n.originalEvent.altKey&&this.draggedObject){if(!e.tb.enableRotatingObjects)return;t="rotate",this.getCanvasContainer().style.cursor="move",Math.min(i.x,u.x),Math.max(i.x,u.x),Math.min(i.y,u.y),Math.max(i.y,u.y);let n={x:0,y:0,z:Math.round(a[2]+~~((u.x-i.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(n),void this.draggedObject.addHelp("rot: "+n.z+"°")}if(n.originalEvent.shiftKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="translate",this.getCanvasContainer().style.cursor="move";let i=n.lngLat,s=[Number((i.lng+r).toFixed(this.tb.gridStep)),Number((i.lat+o).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(s),void this.draggedObject.addHelp("lng: "+s[0]+"°, lat: "+s[1]+"°")}if(n.originalEvent.ctrlKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="altitude",this.getCanvasContainer().style.cursor="move";let i=n.point.y*this.tb.altitudeStep,r=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-i-s).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(r),void this.draggedObject.addHelp("alt: "+r[2]+"m")}let h=[];if(e.tb.enableSelectingObjects&&(h=this.tb.queryRenderedFeatures(n.point)),l="object"==typeof h[0]){let e=ce.prototype.findParent3DObject(h[0]);e&&(this.outFeature(this.overedFeature),this.getCanvasContainer().style.cursor="pointer",this.selectedObject&&e.uuid==this.selectedObject.uuid?this.selectedObject&&e.uuid==this.selectedObject.uuid&&(e.over=!0,this.overedObject=e):(this.overedObject&&this.overedObject.uuid!=e.uuid&&this.outObject(),e.over=!0,this.overedObject=e),this.repaint=!0,n.preventDefault())}else{this.overedObject&&this.outObject();let t=[];e.tb.enableSelectingFeatures&&(t=this.queryRenderedFeatures(n.point)),t.length>0&&(this.outFeature(t[0]),"fill-extrusion"==t[0].layer.type&&void 0!==t[0].id&&(this.selectedFeature&&this.selectedFeature.id==t[0].id||(this.getCanvasContainer().style.cursor="pointer",this.overedFeature=t[0],this.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!0}),this.overedFeature=e.queryRenderedFeatures({layers:[this.overedFeature.layer.id],filter:["==",["id"],this.overedFeature.id]})[0],this.addTooltip(this.overedFeature))))}},this.onMouseDown=function(t){(t.originalEvent.shiftKey||t.originalEvent.altKey||t.originalEvent.ctrlKey)&&0===t.originalEvent.button&&this.selectedObject&&(e.tb.enableDraggingObjects||e.tb.enableRotatingObjects)&&(t.preventDefault(),e.getCanvasContainer().style.cursor="move",e.once("mouseup",this.onMouseUp),this.draggedObject=this.selectedObject,i=c(t),l=this.draggedObject.coordinates,a=u.degreeify(this.draggedObject.rotation),r=l[0]-t.lngLat.lng,o=l[1]-t.lngLat.lat,s=-this.draggedObject.modelHeight-t.point.y*this.tb.altitudeStep)},this.onMouseUp=function(e){this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.off("mouseup",this.onMouseUp),this.off("mouseout",this.onMouseUp),this.dragPan.enable(),this.draggedObject&&(this.draggedObject.dispatchEvent({type:"ObjectDragged",detail:{draggedObject:this.draggedObject,draggedAction:t}}),this.draggedObject.removeHelp(),this.draggedObject=null,t=null)},this.onMouseOut=function(e){if(this.overedFeature){let t=this.queryRenderedFeatures(e.point);t.length>0&&this.overedFeature.id!=t[0].id&&(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.outFeature(t[0]))}},this.onZoom=function(e){this.tb.zoomLayers.forEach((e=>{this.tb.toggleLayer(e)})),this.tb.setObjectsScale()};let h=!1,p=!1;this.on("click",this.onClick),this.on("mousemove",this.onMouseMove),this.on("mouseout",this.onMouseOut),this.on("mousedown",this.onMouseDown),this.on("zoom",this.onZoom),this.on("zoomend",this.onZoom),document.addEventListener("keydown",function(e){17!==e.which&&91!==e.which||(h=!0),16===e.which&&(p=!0);let t=this.selectedObject;if(p&&83===e.which&&t){let e=u.toDecimal;if(t.help)t.removeHelp();else{let i=t.modelSize,n=1;"meters"!==t.userData.units&&((n=u.projectedUnitsPerMeter(t.coordinates[1]))||(n=1),n=e(n,7)),t.addHelp("size(m): "+e(i.x/n,3)+" W, "+e(i.y/n,3)+" L, "+e(i.z/n,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(e){17!=e.which&&91!=e.which||(h=!1),16===e.which&&(p=!1)}.bind(this))}))},get sky(){return this.options.sky},set sky(e){e?this.createSkyLayer():this.removeLayer(this.skyLayerName),this.options.sky=e},get terrain(){return this.options.terrain},set terrain(e){if(this.terrainLayerName="",e)this.createTerrainLayer();else{if(this.mapboxVersion<2)return void console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0");this.map.getTerrain()&&(this.map.setTerrain(null),this.map.removeSource(this.terrainSourceName))}this.options.terrain=e},get fov(){return this.options.fov},set fov(e){this.camera instanceof n.PerspectiveCamera&&this.options.fov!==e&&(this.map.transform.fov=e,this.camera.fov=this.map.transform.fov,this.cameraSync.setupCamera(),this.map.repaint=!0,this.options.fov=e)},get orthographic(){return this.options.orthographic},set orthographic(e){const t=this.map.getCanvas().clientHeight,i=this.map.getCanvas().clientWidth;e?(this.map.transform.fov=0,this.camera=new n.OrthographicCamera(i/-2,i/2,t/2,t/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new n.PerspectiveCamera(this.map.transform.fov,i/t,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new p(this.map,this.camera,this.world),this.map.repaint=!0,this.options.orthographic=e},createSkyLayer:function(){if(this.mapboxVersion<2)return console.warn("Sky layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.sky=!1);this.map.getLayer(this.skyLayerName)||(this.map.addLayer({id:this.skyLayerName,type:"sky",paint:{"sky-opacity":["interpolate",["linear"],["zoom"],0,0,5,.3,8,1],"sky-type":"atmosphere","sky-atmosphere-sun":this.getSunSky(this.lightDateTime),"sky-atmosphere-sun-intensity":10}}),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()})))},createTerrainLayer:function(){if(this.mapboxVersion<2)return console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.terrain=!1);this.map.getTerrain()||(this.map.addSource(this.terrainSourceName,{type:"raster-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1",tileSize:512,maxzoom:14}),this.map.setTerrain({source:this.terrainSourceName,exaggeration:this.terrainExaggeration}),this.map.once("idle",(()=>{this.cameraSync.updateCamera(),this.repaint()})))},sphere:function(e){return this.setDefaultView(e,this.options),S(e,this.world)},line:ne,label:C,tooltip:L,tube:function(e){return this.setDefaultView(e,this.options),oe(e,this.world)},extrusion:function(e){return this.setDefaultView(e,this.options),E(e)},Object3D:function(e){return this.setDefaultView(e,this.options),T(e)},loadObj:async function(e,t){if(this.setDefaultView(e,this.options),!1===e.clone)return new Promise((async i=>{J(e,t,(async e=>{i(e)}))}));{let i=this.objectsCache.get(e.obj);i?i.promise.then((i=>{t(i.duplicate(e))})).catch((t=>{this.objectsCache.delete(e.obj),console.error("Could not load model file: "+e.obj)})):this.objectsCache.set(e.obj,{promise:new Promise((async(i,n)=>{J(e,t,(async e=>{e.duplicate?i(e.duplicate()):n(e)}))}))})}},material:function(e){return m(e)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:u,SunCalc:f,Constants:r,projectToWorld:function(e){return this.utils.projectToWorld(e)},unprojectFromWorld:function(e){return this.utils.unprojectFromWorld(e)},projectedUnitsPerMeter:function(e){return this.utils.projectedUnitsPerMeter(e)},getFeatureCenter:function(e,t,i){return u.getFeatureCenter(e,t,i)},getObjectHeightOnFloor:function(e,t,i){return u.getObjectHeightOnFloor(e,t,i)},queryRenderedFeatures:function(e){let t=new n.Vector2;return t.x=e.x/this.map.transform.width*2-1,t.y=1-e.y/this.map.transform.height*2,this.raycaster.setFromCamera(t,this.camera),this.raycaster.intersectObjects(this.world.children,!0)},findParent3DObject:function(e){var t;return e.object.traverseAncestors((function(e){e.parent&&"Group"==e.parent.type&&e.userData.obj&&(t=e)})),t},setLayoutProperty:function(e,t,i){this.map.setLayoutProperty(e,t,i),null!=i&&"visibility"===t&&this.world.children.filter((t=>t.layer===e)).forEach((e=>{e.visibility=i}))},setLayerZoomRange:function(e,t,i){this.map.getLayer(e)&&(this.map.setLayerZoomRange(e,t,i),this.zoomLayers.includes(e)||this.zoomLayers.push(e),this.toggleLayer(e))},setLayerHeigthProperty:function(e,t){let i=this.map.getLayer(e);if(i)if("fill-extrusion"==i.type){let e=this.map.getStyle().sources[i.source].data;e.features.forEach((function(e){e.properties.level=t})),this.map.getSource(i.source).setData(e)}else"custom"==i.type&&this.world.children.forEach((function(i){let n=i.userData.feature;if(n&&n.layer===e){let e=this.tb.getFeatureCenter(n,i,t);i.setCoords(e)}}))},setObjectsScale:function(){this.world.children.filter((e=>null!=e.fixedZoom)).forEach((e=>{e.setObjectScale(this.map.transform.scale)}))},setStyle:function(e,t){this.clear().then((()=>{this.map.setStyle(e,t)}))},toggleLayer:function(e,t=!0){let i=this.map.getLayer(e);if(i){if(!t)return void this.toggle(i.id,!1);let e=this.map.getZoom();if(i.minzoom&&e<i.minzoom)return void this.toggle(i.id,!1);if(i.maxzoom&&e>=i.maxzoom)return void this.toggle(i.id,!1);this.toggle(i.id,!0)}},toggle:function(e,t){this.setLayoutProperty(e,"visibility",t?"visible":"none"),this.labelRenderer.toggleLabels(e,t)},update:function(){this.map.repaint&&(this.map.repaint=!1);var e=Date.now();this.objects.animationManager.update(e),this.updateLightHelper(),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this.labelRenderer.render(this.scene,this.camera),!1===this.options.passiveRendering&&this.map.triggerRepaint()},add:function(e,t,i){if(!this.enableTooltips&&e.tooltip&&(e.tooltip.visibility=!1),this.world.add(e),t){e.layer=t,e.source=i;let n=this.map.getLayer(t);if(n){let t=n.visibility,i=void 0===t;e.visibility=!(!i&&"visible"!==t)}}},removeByName:function(e){let t=this.world.getObjectByName(e);t&&this.remove(t)},remove:function(e){this.map.selectedObject&&e.uuid==this.map.selectedObject.uuid&&this.map.unselectObject(),this.map.draggedObject&&e.uuid==this.map.draggedObject.uuid&&(this.map.draggedObject=null),e.dispose&&e.dispose(),this.world.remove(e),e=null},clear:async function(e=null,t=!1){return new Promise(((i,n)=>{let r=[];this.world.children.forEach((function(e){r.push(e)}));for(let t=0;t<r.length;t++){let i=r[t];i.layer!==e&&e||this.remove(i)}t&&this.objectsCache.forEach((e=>{e.promise.then((e=>{e.dispose(),e=null}))})),i("clear")}))},removeLayer:function(e){this.clear(e,!0).then((()=>{this.map.removeLayer(e)}))},getSunPosition:function(e,t){return f.getPosition(e||Date.now(),t[1],t[0])},getSunTimes:function(e,t){return f.getTimes(e,t[1],t[0],t[2]?t[2]:0)},setBuildingShadows:function(e){if(this.map.getLayer(e.buildingsLayerId)){let t=new ae(e,this);this.map.addLayer(t,e.buildingsLayerId)}else console.warn("The layer '"+e.buildingsLayerId+"' does not exist in the map.")},setSunlight:function(e=new Date,t){if(!this.lights.dirLight||!this.options.realSunlight)return void console.warn("To use setSunlight it's required to set realSunlight : true in Threebox initial options.");var i=new Date(e.getTime());if(t?t.lng&&t.lat?this.mapCenter=t:this.mapCenter={lng:t[0],lat:t[1]}:this.mapCenter=this.map.getCenter(),this.lightDateTime&&this.lightDateTime.getTime()===i.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=i,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(i,[this.mapCenter.lng,this.mapCenter.lat]);let n=this.sunPosition.altitude,o=Math.PI+this.sunPosition.azimuth,s=r.WORLD_SIZE/2,a=Math.sin(n),l=Math.cos(n),c=Math.cos(o)*l,u=Math.sin(o)*l;this.lights.dirLight.position.set(u,c,a),this.lights.dirLight.position.multiplyScalar(s),this.lights.dirLight.intensity=Math.max(a,0),this.lights.hemiLight.intensity=Math.max(1*a,.1),this.lights.dirLight.updateMatrixWorld(),this.updateLightHelper(),this.map.loaded()&&(this.updateSunGround(this.sunPosition),this.map.setLight({anchor:"map",position:[3,180+180*this.sunPosition.azimuth/Math.PI,90-180*this.sunPosition.altitude/Math.PI],intensity:Math.cos(this.sunPosition.altitude),color:`hsl(40, ${50*Math.cos(this.sunPosition.altitude)}%, ${Math.max(20,20+96*Math.sin(this.sunPosition.altitude))}%)`},{duration:0}),this.sky&&this.updateSunSky(this.getSunSky(i,this.sunPosition)))},getSunSky:function(e,t){if(!t){var i=this.map.getCenter();t=this.getSunPosition(e||Date.now(),[i.lng,i.lat])}return[180+180*t.azimuth/Math.PI,90-180*t.altitude/Math.PI]},updateSunSky:function(e){this.sky&&this.map.setPaintProperty(this.skyLayerName,"sky-atmosphere-sun",e)},updateSunGround:function(e){""!=this.terrainLayerName&&this.map.setPaintProperty(this.terrainLayerName,"raster-opacity",Math.max(Math.min(1,4*e.altitude),.25))},updateLightHelper:function(){this.lights.dirLightHelper&&(this.lights.dirLightHelper.position.setFromMatrixPosition(this.lights.dirLight.matrixWorld),this.lights.dirLightHelper.updateMatrix(),this.lights.dirLightHelper.update())},dispose:async function(){return console.log(this.memory()),new Promise((e=>{e(this.clear(null,!0).then((e=>(this.map.remove(),this.map={},this.scene.remove(this.world),this.world.children=[],this.world=null,this.objectsCache.clear(),this.labelRenderer.dispose(),console.log(this.memory()),this.renderer.dispose(),e))))}))},defaultLights:function(){this.lights.ambientLight=new n.AmbientLight(new n.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new n.DirectionalLight(new n.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new n.DirectionalLight(new n.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLight.position.set(-30,100,-100),this.scene.add(this.lights.dirLight)},realSunlight:function(e=!1){this.renderer.shadowMap.enabled=!0,this.lights.dirLight=new n.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),e&&(this.lights.dirLightHelper=new n.DirectionalLightHelper(this.lights.dirLight,5),this.scene.add(this.lights.dirLightHelper)),this.lights.dirLight.castShadow=!0,this.lights.dirLight.shadow.radius=2,this.lights.dirLight.shadow.mapSize.width=8192,this.lights.dirLight.shadow.mapSize.height=8192,this.lights.dirLight.shadow.camera.top=this.lights.dirLight.shadow.camera.right=1e3,this.lights.dirLight.shadow.camera.bottom=this.lights.dirLight.shadow.camera.left=-1e3,this.lights.dirLight.shadow.camera.near=1,this.lights.dirLight.shadow.camera.visible=!0,this.lights.dirLight.shadow.camera.far=4e8,this.lights.hemiLight=new n.HemisphereLight(new n.Color(16777215),new n.Color(16777215),.6),this.lights.hemiLight.color.setHSL(.661,.96,.12),this.lights.hemiLight.groundColor.setHSL(.11,.96,.14),this.lights.hemiLight.position.set(0,0,50),this.scene.add(this.lights.hemiLight),this.setSunlight(),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()}))},setDefaultView:function(e,t){e.bbox=(e.bbox||null==e.bbox)&&t.enableSelectingObjects,e.tooltip=(e.tooltip||null==e.tooltip)&&t.enableTooltips,e.mapScale=this.map.transform.scale},memory:function(){return this.renderer.info.memory},programs:function(){return this.renderer.info.programs.length},version:"2.2.6"};var ue={defaultLights:!1,realSunlight:!1,realSunlightHelper:!1,passiveRendering:!0,preserveDrawingBuffer:!1,enableSelectingFeatures:!1,enableSelectingObjects:!1,enableDraggingObjects:!1,enableRotatingObjects:!1,enableTooltips:!1,multiLayer:!1,orthographic:!1,fov:r.FOV_DEGREES,sky:!1,terrain:!1};le=le=ce,window.Threebox=le,window.THREE=n}();!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).turf=e()}}((function(){return function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(e,t,i){t.exports={along:e("@turf/along").default,bbox:e("@turf/bbox").default,center:e("@turf/center").default,distance:e("@turf/distance").default,destination:e("@turf/destination").default,length:e("@turf/length").default,nearestPointOnLine:e("@turf/nearest-point-on-line").default,booleanPointInPolygon:e("@turf/boolean-point-in-polygon").default,pointOnFeature:e("@turf/point-on-feature").default}},{"@turf/along":2,"@turf/bbox":3,"@turf/boolean-point-in-polygon":5,"@turf/center":6,"@turf/destination":8,"@turf/distance":9,"@turf/length":13,"@turf/nearest-point-on-line":17,"@turf/point-on-feature":19}],2:[function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=n(e("@turf/bearing")),o=n(e("@turf/destination")),s=n(e("@turf/distance")),a=e("@turf/helpers"),l=e("@turf/invariant");i.default=function(e,t,i){void 0===i&&(i={});for(var n=l.getGeom(e).coordinates,c=0,u=0;u<n.length&&!(t>=c&&u===n.length-1);u++){if(c>=t){var h=t-c;if(h){var p=r.default(n[u],n[u-1])-180;return o.default(n[u],h,p,i)}return a.point(n[u])}c+=s.default(n[u],n[u+1],i)}return a.point(n[n.length-1])}},{"@turf/bearing":4,"@turf/destination":8,"@turf/distance":9,"@turf/helpers":11,"@turf/invariant":12}],3:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/meta");function r(e){var t=[1/0,1/0,-1/0,-1/0];n.coordEach(e,(function(e){t[0]>e[0]&&(t[0]=e[0]);t[1]>e[1]&&(t[1]=e[1]);t[2]<e[0]&&(t[2]=e[0]);t[3]<e[1]&&(t[3]=e[1])}));return t}r.default=r;i.default=r},{"@turf/meta":16}],4:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers"),r=e("@turf/invariant");function o(e,t,i){void 0===i&&(i={});if(!0===i.final)return function(e,t){var i=o(t,e);return(i+180)%360}(e,t);var s=r.getCoord(e),a=r.getCoord(t),l=n.degreesToRadians(s[0]),c=n.degreesToRadians(a[0]),u=n.degreesToRadians(s[1]),h=n.degreesToRadians(a[1]),p=Math.sin(c-l)*Math.cos(h),d=Math.cos(u)*Math.sin(h)-Math.sin(u)*Math.cos(h)*Math.cos(c-l);return n.radiansToDegrees(Math.atan2(p,d))}i.default=o},{"@turf/helpers":11,"@turf/invariant":12}],5:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/invariant");i.default=function(e,t,i){void 0===i&&(i={});if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");var o=n.getCoord(e),s=n.getGeom(t),a=s.type,l=t.bbox,c=s.coordinates;if(l&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(o,l))return!1;"Polygon"===a&&(c=[c]);for(var u=!1,h=0;h<c.length&&!u;h++)if(r(o,c[h][0],i.ignoreBoundary)){for(var p=!1,d=1;d<c[h].length&&!p;){r(o,c[h][d],!i.ignoreBoundary)&&(p=!0);d++}p||(u=!0)}return u};function r(e,t,i){var n=!1;t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&(t=t.slice(0,t.length-1));for(var r=0,o=t.length-1;r<t.length;o=r++){var s=t[r][0],a=t[r][1],l=t[o][0],c=t[o][1];if(e[1]*(s-l)+a*(l-e[0])+c*(e[0]-s)==0&&(s-e[0])*(l-e[0])<=0&&(a-e[1])*(c-e[1])<=0)return!i;a>e[1]!=c>e[1]&&e[0]<(l-s)*(e[1]-a)/(c-a)+s&&(n=!n)}return n}},{"@turf/invariant":12}],6:[function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=n(e("@turf/bbox")),o=e("@turf/helpers");i.default=function(e,t){void 0===t&&(t={});var i=r.default(e),n=(i[0]+i[2])/2,s=(i[1]+i[3])/2;return o.point([n,s],t.properties,t)}},{"@turf/bbox":3,"@turf/helpers":11}],7:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});function n(e){var t={type:"Feature"};Object.keys(e).forEach((function(i){switch(i){case"type":case"properties":case"geometry":return;default:t[i]=e[i]}}));t.properties=r(e.properties);t.geometry=o(e.geometry);return t}function r(e){var t={};if(!e)return t;Object.keys(e).forEach((function(i){var n=e[i];"object"==typeof n?null===n?t[i]=null:Array.isArray(n)?t[i]=n.map((function(e){return e})):t[i]=r(n):t[i]=n}));return t}function o(e){var t={type:e.type};e.bbox&&(t.bbox=e.bbox);if("GeometryCollection"===e.type){t.geometries=e.geometries.map((function(e){return o(e)}));return t}t.coordinates=s(e.coordinates);return t}function s(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map((function(e){return s(e)}))}i.default=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return n(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};Object.keys(e).forEach((function(i){switch(i){case"type":case"features":return;default:t[i]=e[i]}}));t.features=e.features.map((function(e){return n(e)}));return t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return o(e);default:throw new Error("unknown GeoJSON type")}}},{}],8:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers"),r=e("@turf/invariant");i.default=function(e,t,i,o){void 0===o&&(o={});var s=r.getCoord(e),a=n.degreesToRadians(s[0]),l=n.degreesToRadians(s[1]),c=n.degreesToRadians(i),u=n.lengthToRadians(t,o.units),h=Math.asin(Math.sin(l)*Math.cos(u)+Math.cos(l)*Math.sin(u)*Math.cos(c)),p=a+Math.atan2(Math.sin(c)*Math.sin(u)*Math.cos(l),Math.cos(u)-Math.sin(l)*Math.sin(h)),d=n.radiansToDegrees(p),f=n.radiansToDegrees(h);return n.point([d,f],o.properties)}},{"@turf/helpers":11,"@turf/invariant":12}],9:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/invariant"),r=e("@turf/helpers");i.default=function(e,t,i){void 0===i&&(i={});var o=n.getCoord(e),s=n.getCoord(t),a=r.degreesToRadians(s[1]-o[1]),l=r.degreesToRadians(s[0]-o[0]),c=r.degreesToRadians(o[1]),u=r.degreesToRadians(s[1]),h=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(l/2),2)*Math.cos(c)*Math.cos(u);return r.radiansToLength(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),i.units)}},{"@turf/helpers":11,"@turf/invariant":12}],10:[function(e,t,i){"use strict";var n=e("@turf/meta"),r=e("@turf/helpers");function o(e){var t=[];"FeatureCollection"===e.type?n.featureEach(e,(function(e){n.coordEach(e,(function(i){t.push(r.point(i,e.properties))}))})):n.coordEach(e,(function(i){t.push(r.point(i,e.properties))}));return r.featureCollection(t)}t.exports=o;t.exports.default=o},{"@turf/helpers":11,"@turf/meta":16}],11:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.earthRadius=6371008.8;i.factors={centimeters:100*i.earthRadius,centimetres:100*i.earthRadius,degrees:i.earthRadius/111325,feet:3.28084*i.earthRadius,inches:39.37*i.earthRadius,kilometers:i.earthRadius/1e3,kilometres:i.earthRadius/1e3,meters:i.earthRadius,metres:i.earthRadius,miles:i.earthRadius/1609.344,millimeters:1e3*i.earthRadius,millimetres:1e3*i.earthRadius,nauticalmiles:i.earthRadius/1852,radians:1,yards:1.0936*i.earthRadius};i.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/i.earthRadius,yards:1.0936133};i.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function n(e,t,i){void 0===i&&(i={});var n={type:"Feature"};(0===i.id||i.id)&&(n.id=i.id);i.bbox&&(n.bbox=i.bbox);n.properties=t||{};n.geometry=e;return n}i.feature=n;i.geometry=function(e,t,i){void 0===i&&(i={});switch(e){case"Point":return r(t).geometry;case"LineString":return s(t).geometry;case"Polygon":return o(t).geometry;case"MultiPoint":return c(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return u(t).geometry;default:throw new Error(e+" is invalid")}};function r(e,t,i){void 0===i&&(i={});if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(e[0])||!f(e[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:e},t,i)}i.point=r;i.points=function(e,t,i){void 0===i&&(i={});return a(e.map((function(e){return r(e,t)})),i)};function o(e,t,i){void 0===i&&(i={});for(var r=0,o=e;r<o.length;r++){var s=o[r];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<s[s.length-1].length;a++)if(s[s.length-1][a]!==s[0][a])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:e},t,i)}i.polygon=o;i.polygons=function(e,t,i){void 0===i&&(i={});return a(e.map((function(e){return o(e,t)})),i)};function s(e,t,i){void 0===i&&(i={});if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return n({type:"LineString",coordinates:e},t,i)}i.lineString=s;i.lineStrings=function(e,t,i){void 0===i&&(i={});return a(e.map((function(e){return s(e,t)})),i)};function a(e,t){void 0===t&&(t={});var i={type:"FeatureCollection"};t.id&&(i.id=t.id);t.bbox&&(i.bbox=t.bbox);i.features=e;return i}i.featureCollection=a;function l(e,t,i){void 0===i&&(i={});return n({type:"MultiLineString",coordinates:e},t,i)}i.multiLineString=l;function c(e,t,i){void 0===i&&(i={});return n({type:"MultiPoint",coordinates:e},t,i)}i.multiPoint=c;function u(e,t,i){void 0===i&&(i={});return n({type:"MultiPolygon",coordinates:e},t,i)}i.multiPolygon=u;i.geometryCollection=function(e,t,i){void 0===i&&(i={});return n({type:"GeometryCollection",geometries:e},t,i)};i.round=function(e,t){void 0===t&&(t=0);if(t&&!(t>=0))throw new Error("precision must be a positive number");var i=Math.pow(10,t||0);return Math.round(e*i)/i};function h(e,t){void 0===t&&(t="kilometers");var n=i.factors[t];if(!n)throw new Error(t+" units is invalid");return e*n}i.radiansToLength=h;function p(e,t){void 0===t&&(t="kilometers");var n=i.factors[t];if(!n)throw new Error(t+" units is invalid");return e/n}i.lengthToRadians=p;i.lengthToDegrees=function(e,t){return d(p(e,t))};i.bearingToAzimuth=function(e){var t=e%360;t<0&&(t+=360);return t};function d(e){return 180*(e%(2*Math.PI))/Math.PI}i.radiansToDegrees=d;i.degreesToRadians=function(e){return e%360*Math.PI/180};i.convertLength=function(e,t,i){void 0===t&&(t="kilometers");void 0===i&&(i="kilometers");if(!(e>=0))throw new Error("length must be a positive number");return h(p(e,t),i)};i.convertArea=function(e,t,n){void 0===t&&(t="meters");void 0===n&&(n="kilometers");if(!(e>=0))throw new Error("area must be a positive number");var r=i.areaFactors[t];if(!r)throw new Error("invalid original units");var o=i.areaFactors[n];if(!o)throw new Error("invalid final units");return e/r*o};function f(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}i.isNumber=f;i.isObject=function(e){return!!e&&e.constructor===Object};i.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach((function(e){if(!f(e))throw new Error("bbox must only contain numbers")}))};i.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},{}],12:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers");i.getCoord=function(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")};i.getCoords=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")};i.containsNumber=function e(t){if(t.length>1&&n.isNumber(t[0])&&n.isNumber(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return e(t[0]);throw new Error("coordinates must only contain numbers")};i.geojsonType=function(e,t,i){if(!t||!i)throw new Error("type and name required");if(!e||e.type!==t)throw new Error("Invalid input to "+i+": must be a "+t+", given "+e.type)};i.featureOf=function(e,t,i){if(!e)throw new Error("No feature passed");if(!i)throw new Error(".featureOf() requires a name");if(!e||"Feature"!==e.type||!e.geometry)throw new Error("Invalid input to "+i+", Feature with geometry required");if(!e.geometry||e.geometry.type!==t)throw new Error("Invalid input to "+i+": must be a "+t+", given "+e.geometry.type)};i.collectionOf=function(e,t,i){if(!e)throw new Error("No featureCollection passed");if(!i)throw new Error(".collectionOf() requires a name");if(!e||"FeatureCollection"!==e.type)throw new Error("Invalid input to "+i+", FeatureCollection required");for(var n=0,r=e.features;n<r.length;n++){var o=r[n];if(!o||"Feature"!==o.type||!o.geometry)throw new Error("Invalid input to "+i+", Feature with geometry required");if(!o.geometry||o.geometry.type!==t)throw new Error("Invalid input to "+i+": must be a "+t+", given "+o.geometry.type)}};i.getGeom=function(e){return"Feature"===e.type?e.geometry:e};i.getType=function(e,t){return"FeatureCollection"===e.type?"FeatureCollection":"GeometryCollection"===e.type?"GeometryCollection":"Feature"===e.type&&null!==e.geometry?e.geometry.type:e.type}},{"@turf/helpers":11}],13:[function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=n(e("@turf/distance")),o=e("@turf/meta");i.default=function(e,t){void 0===t&&(t={});return o.segmentReduce(e,(function(e,i){var n=i.geometry.coordinates;return e+r.default(n[0],n[1],t)}),0)}},{"@turf/distance":9,"@turf/meta":16}],14:[function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=e("@turf/helpers"),o=e("@turf/invariant"),s=n(e("@turf/line-segment")),a=e("@turf/meta"),l=n(e("geojson-rbush"));function c(e,t){var i=o.getCoords(e),n=o.getCoords(t);if(2!==i.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var s=i[0][0],a=i[0][1],l=i[1][0],c=i[1][1],u=n[0][0],h=n[0][1],p=n[1][0],d=n[1][1],f=(d-h)*(l-s)-(p-u)*(c-a),m=(p-u)*(a-h)-(d-h)*(s-u),g=(l-s)*(a-h)-(c-a)*(s-u);if(0===f)return null;var _=m/f,y=g/f;if(_>=0&&_<=1&&y>=0&&y<=1){var v=s+_*(l-s),x=a+_*(c-a);return r.point([v,x])}return null}i.default=function(e,t){var i={},n=[];"LineString"===e.type&&(e=r.feature(e));"LineString"===t.type&&(t=r.feature(t));if("Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var u=c(e,t);u&&n.push(u);return r.featureCollection(n)}var h=l.default();h.load(s.default(t));a.featureEach(s.default(e),(function(e){a.featureEach(h.search(e),(function(t){var r=c(e,t);if(r){var s=o.getCoords(r).join(",");if(!i[s]){i[s]=!0;n.push(r)}}}))}));return r.featureCollection(n)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/line-segment":15,"@turf/meta":16,"geojson-rbush":20}],15:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers"),r=e("@turf/invariant"),o=e("@turf/meta");i.default=function(e){if(!e)throw new Error("geojson is required");var t=[];o.flattenEach(e,(function(e){!function(e,t){var i=[],o=e.geometry;if(null!==o){switch(o.type){case"Polygon":i=r.getCoords(o);break;case"LineString":i=[r.getCoords(o)]}i.forEach((function(i){var r=function(e,t){var i=[];e.reduce((function(e,r){var o,s,a,l,c,u,h=n.lineString([e,r],t);h.bbox=(s=r,a=(o=e)[0],l=o[1],c=s[0],u=s[1],[a<c?a:c,l<u?l:u,a>c?a:c,l>u?l:u]);i.push(h);return r}));return i}(i,e.properties);r.forEach((function(e){e.id=t.length;t.push(e)}))}))}}(e,t)}));return n.featureCollection(t)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/meta":16}],16:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers");function r(e,t,i){if(null!==e)for(var n,o,s,a,l,c,u,h,p=0,d=0,f=e.type,m="FeatureCollection"===f,g="Feature"===f,_=m?e.features.length:1,y=0;y<_;y++){l=(h=!!(u=m?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var v=0;v<l;v++){var x=0,b=0;if(null!==(a=h?u.geometries[v]:u)){c=a.coordinates;var w=a.type;p=!i||"Polygon"!==w&&"MultiPolygon"!==w?0:1;switch(w){case null:break;case"Point":if(!1===t(c,d,y,x,b))return!1;d++;x++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],d,y,x,b))return!1;d++;"MultiPoint"===w&&x++}"LineString"===w&&x++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(o=0;o<c[n].length-p;o++){if(!1===t(c[n][o],d,y,x,b))return!1;d++}"MultiLineString"===w&&x++;"Polygon"===w&&b++}"Polygon"===w&&x++;break;case"MultiPolygon":for(n=0;n<c.length;n++){b=0;for(o=0;o<c[n].length;o++){for(s=0;s<c[n][o].length-p;s++){if(!1===t(c[n][o][s],d,y,x,b))return!1;d++}b++}x++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===r(a.geometries[n],t,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function o(e,t){var i;switch(e.type){case"FeatureCollection":for(i=0;i<e.features.length&&!1!==t(e.features[i].properties,i);i++);break;case"Feature":t(e.properties,0)}}function s(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var i=0;i<e.features.length&&!1!==t(e.features[i],i);i++);}function a(e,t){var i,n,r,o,s,a,l,c,u,h,p=0,d="FeatureCollection"===e.type,f="Feature"===e.type,m=d?e.features.length:1;for(i=0;i<m;i++){a=d?e.features[i].geometry:f?e.geometry:e;c=d?e.features[i].properties:f?e.properties:{};u=d?e.features[i].bbox:f?e.bbox:void 0;h=d?e.features[i].id:f?e.id:void 0;s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1;for(r=0;r<s;r++)if(null!==(o=l?a.geometries[r]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,p,c,u,h))return!1;break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(!1===t(o.geometries[n],p,c,u,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,u,h))return!1;p++}}function l(e,t){a(e,(function(e,i,r,o,s){var a,l=null===e?null:e.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature(e,r,{bbox:o,id:s}),i,0)&&void 0}switch(l){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var c=0;c<e.coordinates.length;c++){var u={type:a,coordinates:e.coordinates[c]};if(!1===t(n.feature(u,r),i,c))return!1}}))}function c(e,t){l(e,(function(e,i,o){var s=0;if(e.geometry){var a=e.geometry.type;if("Point"!==a&&"MultiPoint"!==a){var l,c=0,u=0,h=0;return!1!==r(e,(function(r,a,p,d,f){if(void 0===l||i>c||d>u||f>h){l=r;c=i;u=d;h=f;s=0}else{var m=n.lineString([l,r],e.properties);if(!1===t(m,i,o,f,s))return!1;s++;l=r}}))&&void 0}}}))}function u(e,t){if(!e)throw new Error("geojson is required");l(e,(function(e,i,r){if(null!==e.geometry){var o=e.geometry.type,s=e.geometry.coordinates;switch(o){case"LineString":if(!1===t(e,i,r,0,0))return!1;break;case"Polygon":for(var a=0;a<s.length;a++)if(!1===t(n.lineString(s[a],e.properties),i,r,a))return!1}}}))}i.coordAll=function(e){var t=[];r(e,(function(e){t.push(e)}));return t};i.coordEach=r;i.coordReduce=function(e,t,i,n){var o=i;r(e,(function(e,n,r,s,a){o=0===n&&void 0===i?e:t(o,e,n,r,s,a)}),n);return o};i.featureEach=s;i.featureReduce=function(e,t,i){var n=i;s(e,(function(e,r){n=0===r&&void 0===i?e:t(n,e,r)}));return n};i.findPoint=function(e,t){t=t||{};if(!n.isObject(t))throw new Error("options is invalid");var i,r=t.featureIndex||0,o=t.multiFeatureIndex||0,s=t.geometryIndex||0,a=t.coordIndex||0,l=t.properties;switch(e.type){case"FeatureCollection":r<0&&(r=e.features.length+r);l=l||e.features[r].properties;i=e.features[r].geometry;break;case"Feature":l=l||e.properties;i=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":i=e;break;default:throw new Error("geojson is invalid")}if(null===i)return null;var c=i.coordinates;switch(i.type){case"Point":return n.point(c,l,t);case"MultiPoint":o<0&&(o=c.length+o);return n.point(c[o],l,t);case"LineString":a<0&&(a=c.length+a);return n.point(c[a],l,t);case"Polygon":s<0&&(s=c.length+s);a<0&&(a=c[s].length+a);return n.point(c[s][a],l,t);case"MultiLineString":o<0&&(o=c.length+o);a<0&&(a=c[o].length+a);return n.point(c[o][a],l,t);case"MultiPolygon":o<0&&(o=c.length+o);s<0&&(s=c[o].length+s);a<0&&(a=c[o][s].length-a);return n.point(c[o][s][a],l,t)}throw new Error("geojson is invalid")};i.findSegment=function(e,t){t=t||{};if(!n.isObject(t))throw new Error("options is invalid");var i,r=t.featureIndex||0,o=t.multiFeatureIndex||0,s=t.geometryIndex||0,a=t.segmentIndex||0,l=t.properties;switch(e.type){case"FeatureCollection":r<0&&(r=e.features.length+r);l=l||e.features[r].properties;i=e.features[r].geometry;break;case"Feature":l=l||e.properties;i=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":i=e;break;default:throw new Error("geojson is invalid")}if(null===i)return null;var c=i.coordinates;switch(i.type){case"Point":case"MultiPoint":return null;case"LineString":a<0&&(a=c.length+a-1);return n.lineString([c[a],c[a+1]],l,t);case"Polygon":s<0&&(s=c.length+s);a<0&&(a=c[s].length+a-1);return n.lineString([c[s][a],c[s][a+1]],l,t);case"MultiLineString":o<0&&(o=c.length+o);a<0&&(a=c[o].length+a-1);return n.lineString([c[o][a],c[o][a+1]],l,t);case"MultiPolygon":o<0&&(o=c.length+o);s<0&&(s=c[o].length+s);a<0&&(a=c[o][s].length-a-1);return n.lineString([c[o][s][a],c[o][s][a+1]],l,t)}throw new Error("geojson is invalid")};i.flattenEach=l;i.flattenReduce=function(e,t,i){var n=i;l(e,(function(e,r,o){n=0===r&&0===o&&void 0===i?e:t(n,e,r,o)}));return n};i.geomEach=a;i.geomReduce=function(e,t,i){var n=i;a(e,(function(e,r,o,s,a){n=0===r&&void 0===i?e:t(n,e,r,o,s,a)}));return n};i.lineEach=u;i.lineReduce=function(e,t,i){var n=i;u(e,(function(e,r,o,s){n=0===r&&void 0===i?e:t(n,e,r,o,s)}));return n};i.propEach=o;i.propReduce=function(e,t,i){var n=i;o(e,(function(e,r){n=0===r&&void 0===i?e:t(n,e,r)}));return n};i.segmentEach=c;i.segmentReduce=function(e,t,i){var n=i,r=!1;c(e,(function(e,o,s,a,l){n=!1===r&&void 0===i?e:t(n,e,o,s,a,l);r=!0}));return n}},{"@turf/helpers":11}],17:[function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=n(e("@turf/bearing")),o=n(e("@turf/distance")),s=n(e("@turf/destination")),a=n(e("@turf/line-intersect")),l=e("@turf/meta"),c=e("@turf/helpers"),u=e("@turf/invariant");i.default=function(e,t,i){void 0===i&&(i={});var n=c.point([1/0,1/0],{dist:1/0}),h=0;l.flattenEach(e,(function(e){for(var l=u.getCoords(e),p=0;p<l.length-1;p++){var d=c.point(l[p]);d.properties.dist=o.default(t,d,i);var f=c.point(l[p+1]);f.properties.dist=o.default(t,f,i);var m=o.default(d,f,i),g=Math.max(d.properties.dist,f.properties.dist),_=r.default(d,f),y=s.default(t,g,_+90,i),v=s.default(t,g,_-90,i),x=a.default(c.lineString([y.geometry.coordinates,v.geometry.coordinates]),c.lineString([d.geometry.coordinates,f.geometry.coordinates])),b=null;if(x.features.length>0){(b=x.features[0]).properties.dist=o.default(t,b,i);b.properties.location=h+o.default(d,b,i)}if(d.properties.dist<n.properties.dist){(n=d).properties.index=p;n.properties.location=h}if(f.properties.dist<n.properties.dist){(n=f).properties.index=p+1;n.properties.location=h+m}b&&b.properties.dist<n.properties.dist&&((n=b).properties.index=p);h+=m}}));return n}},{"@turf/bearing":4,"@turf/destination":8,"@turf/distance":9,"@turf/helpers":11,"@turf/invariant":12,"@turf/line-intersect":14,"@turf/meta":16}],18:[function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=n(e("@turf/clone")),o=n(e("@turf/distance")),s=e("@turf/meta");i.default=function(e,t){if(!e)throw new Error("targetPoint is required");if(!t)throw new Error("points is required");var i,n=1/0,a=0;s.featureEach(t,(function(t,i){var r=o.default(e,t);if(r<n){a=i;n=r}}));(i=r.default(t.features[a])).properties.featureIndex=a;i.properties.distanceToPoint=n;return i}},{"@turf/clone":7,"@turf/distance":9,"@turf/meta":16}],19:[function(e,t,i){"use strict";var n=e("@turf/explode"),r=e("@turf/center"),o=e("@turf/nearest-point"),s=e("@turf/boolean-point-in-polygon"),a=e("@turf/helpers");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=l(n),u=l(r),h=l(o),p=l(s);function d(e){for(var t=function(e){if("FeatureCollection"!==e.type)return"Feature"!==e.type?a.featureCollection([a.feature(e)]):a.featureCollection([e]);return e}(e),i=u.default(t),n=!1,r=0;!n&&r<t.features.length;){var o,s=t.features[r].geometry,l=!1;if("Point"===s.type)i.geometry.coordinates[0]===s.coordinates[0]&&i.geometry.coordinates[1]===s.coordinates[1]&&(n=!0);else if("MultiPoint"===s.type){var d=!1;o=0;for(;!d&&o<s.coordinates.length;){if(i.geometry.coordinates[0]===s.coordinates[o][0]&&i.geometry.coordinates[1]===s.coordinates[o][1]){n=!0;d=!0}o++}}else if("LineString"===s.type){o=0;for(;!l&&o<s.coordinates.length-1;){if(f(i.geometry.coordinates[0],i.geometry.coordinates[1],s.coordinates[o][0],s.coordinates[o][1],s.coordinates[o+1][0],s.coordinates[o+1][1])){l=!0;n=!0}o++}}else if("MultiLineString"===s.type)for(var m=0;m<s.coordinates.length;){l=!1;o=0;for(var g=s.coordinates[m];!l&&o<g.length-1;){if(f(i.geometry.coordinates[0],i.geometry.coordinates[1],g[o][0],g[o][1],g[o+1][0],g[o+1][1])){l=!0;n=!0}o++}m++}else"Polygon"!==s.type&&"MultiPolygon"!==s.type||p.default(i,s)&&(n=!0);r++}if(n)return i;var _=a.featureCollection([]);for(r=0;r<t.features.length;r++)_.features=_.features.concat(c.default(t.features[r]).features);return a.point(h.default(i,_).geometry.coordinates)}function f(e,t,i,n,r,o){return Math.sqrt((r-i)*(r-i)+(o-n)*(o-n))===Math.sqrt((e-i)*(e-i)+(t-n)*(t-n))+Math.sqrt((r-e)*(r-e)+(o-t)*(o-t))}t.exports=d;t.exports.default=d},{"@turf/boolean-point-in-polygon":5,"@turf/center":6,"@turf/explode":10,"@turf/helpers":11,"@turf/nearest-point":18}],20:[function(e,t,i){var n=e("rbush"),r=e("@turf/helpers"),o=e("@turf/meta"),s=e("@turf/bbox").default,a=o.featureEach,l=(o.coordEach,r.polygon,r.featureCollection);function c(e){var t=new n(e);t.insert=function(e){if("Feature"!==e.type)throw new Error("invalid feature");e.bbox=e.bbox?e.bbox:s(e);return n.prototype.insert.call(this,e)};t.load=function(e){var t=[];Array.isArray(e)?e.forEach((function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:s(e);t.push(e)})):a(e,(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:s(e);t.push(e)}));return n.prototype.load.call(this,t)};t.remove=function(e,t){if("Feature"!==e.type)throw new Error("invalid feature");e.bbox=e.bbox?e.bbox:s(e);return n.prototype.remove.call(this,e,t)};t.clear=function(){return n.prototype.clear.call(this)};t.search=function(e){var t=n.prototype.search.call(this,this.toBBox(e));return l(t)};t.collides=function(e){return n.prototype.collides.call(this,this.toBBox(e))};t.all=function(){var e=n.prototype.all.call(this);return l(e)};t.toJSON=function(){return n.prototype.toJSON.call(this)};t.fromJSON=function(e){return n.prototype.fromJSON.call(this,e)};t.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=s(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=s(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}};return t}t.exports=c;t.exports.default=c},{"@turf/bbox":3,"@turf/helpers":11,"@turf/meta":16,rbush:21}],21:[function(e,t,i){n=this,r=function(){"use strict";function e(e,n,r,o,s){!function e(i,n,r,o,s){for(;o>r;){if(o-r>600){var a=o-r+1,l=n-r+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*(l-a/2<0?-1:1);e(i,n,Math.max(r,Math.floor(n-l*u/a+h)),Math.min(o,Math.floor(n+(a-l)*u/a+h)),s)}var p=i[n],d=r,f=o;for(t(i,r,n),s(i[o],p)>0&&t(i,r,o);d<f;){for(t(i,d,f),d++,f--;s(i[d],p)<0;)d++;for(;s(i[f],p)>0;)f--}0===s(i[r],p)?t(i,r,f):t(i,++f,o),f<=n&&(r=f+1),n<=f&&(o=f-1)}}(e,n,r||0,o||e.length-1,s||i)}function t(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function i(e,t){return e<t?-1:e>t?1:0}var n=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(e,t,i){if(!i)return t.indexOf(e);for(var n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function o(e,t){s(e,0,e.children.length,t,e)}function s(e,t,i,n,r){r||(r=f(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o=t;o<i;o++){var s=e.children[o];a(r,e.leaf?n(s):s)}return r}function a(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function l(e,t){return e.minX-t.minX}function c(e,t){return e.minY-t.minY}function u(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function h(e){return e.maxX-e.minX+(e.maxY-e.minY)}function p(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function d(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function f(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,i,n,r,o){for(var s=[i,n];s.length;)if(!((n=s.pop())-(i=s.pop())<=r)){var a=i+Math.ceil((n-i)/r/2)*r;e(t,a,i,n,o),s.push(i,a,a,n)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,i=[];if(!d(e,t))return i;for(var n=this.toBBox,r=[];t;){for(var o=0;o<t.children.length;o++){var s=t.children[o],a=t.leaf?n(s):s;d(e,a)&&(t.leaf?i.push(s):p(e,a)?this._all(s,i):r.push(s))}t=r.pop()}return i},n.prototype.collides=function(e){var t=this.data;if(!d(e,t))return!1;for(var i=[];t;){for(var n=0;n<t.children.length;n++){var r=t.children[n],o=t.leaf?this.toBBox(r):r;if(d(e,o)){if(t.leaf||p(e,o))return!0;i.push(r)}}t=i.pop()}return!1},n.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var i=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var n=this.data;this.data=i,i=n}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},n.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},n.prototype.clear=function(){return this.data=f([]),this},n.prototype.remove=function(e,t){if(!e)return this;for(var i,n,o,s=this.data,a=this.toBBox(e),l=[],c=[];s||l.length;){if(s||(s=l.pop(),n=l[l.length-1],i=c.pop(),o=!0),s.leaf){var u=r(e,s.children,t);if(-1!==u)return s.children.splice(u,1),l.push(s),this._condense(l),this}o||s.leaf||!p(s,a)?n?(i++,s=n.children[i],o=!1):s=null:(l.push(s),c.push(i),i=0,n=s,s=s.children[0])}return this},n.prototype.toBBox=function(e){return e},n.prototype.compareMinX=function(e,t){return e.minX-t.minX},n.prototype.compareMinY=function(e,t){return e.minY-t.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(e){return this.data=e,this},n.prototype._all=function(e,t){for(var i=[];e;)e.leaf?t.push.apply(t,e.children):i.push.apply(i,e.children),e=i.pop();return t},n.prototype._build=function(e,t,i,n){var r,s=i-t+1,a=this._maxEntries;if(s<=a)return o(r=f(e.slice(t,i+1)),this.toBBox),r;n||(n=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,n-1))),(r=f([])).leaf=!1,r.height=n;var l=Math.ceil(s/a),c=l*Math.ceil(Math.sqrt(a));m(e,t,i,c,this.compareMinX);for(var u=t;u<=i;u+=c){var h=Math.min(u+c-1,i);m(e,u,h,l,this.compareMinY);for(var p=u;p<=h;p+=l){var d=Math.min(p+l-1,h);r.children.push(this._build(e,p,d,n-1))}}return o(r,this.toBBox),r},n.prototype._chooseSubtree=function(e,t,i,n){for(;n.push(t),!t.leaf&&n.length-1!==i;){for(var r=1/0,o=1/0,s=void 0,a=0;a<t.children.length;a++){var l=t.children[a],c=u(l),h=(p=e,d=l,(Math.max(d.maxX,p.maxX)-Math.min(d.minX,p.minX))*(Math.max(d.maxY,p.maxY)-Math.min(d.minY,p.minY))-c);h<o?(o=h,r=c<r?c:r,s=l):h===o&&c<r&&(r=c,s=l)}t=s||t.children[0]}var p,d;return t},n.prototype._insert=function(e,t,i){var n=i?e:this.toBBox(e),r=[],o=this._chooseSubtree(n,this.data,t,r);for(o.children.push(e),a(o,n);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)},n.prototype._split=function(e,t){var i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);var s=this._chooseSplitIndex(i,r,n),a=f(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)},n.prototype._splitRoot=function(e,t){this.data=f([e,t]),this.data.height=e.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(e,t,i){for(var n,r,o,a,l,c,h,p=1/0,d=1/0,f=t;f<=i-t;f++){var m=s(e,0,f,this.toBBox),g=s(e,f,i,this.toBBox),_=(r=m,o=g,a=Math.max(r.minX,o.minX),l=Math.max(r.minY,o.minY),c=Math.min(r.maxX,o.maxX),h=Math.min(r.maxY,o.maxY),Math.max(0,c-a)*Math.max(0,h-l)),y=u(m)+u(g);_<p?(p=_,n=f,d=y<d?y:d):_===p&&y<d&&(d=y,n=f)}return n||i-t},n.prototype._chooseSplitAxis=function(e,t,i){var n=e.leaf?this.compareMinX:l,r=e.leaf?this.compareMinY:c;this._allDistMargin(e,t,i,n)<this._allDistMargin(e,t,i,r)&&e.children.sort(n)},n.prototype._allDistMargin=function(e,t,i,n){e.children.sort(n);for(var r=this.toBBox,o=s(e,0,t,r),l=s(e,i-t,i,r),c=h(o)+h(l),u=t;u<i-t;u++){var p=e.children[u];a(o,e.leaf?r(p):p),c+=h(o)}for(var d=i-t-1;d>=t;d--){var f=e.children[d];a(l,e.leaf?r(f):f),c+=h(l)}return c},n.prototype._adjustParentBBoxes=function(e,t,i){for(var n=i;n>=0;n--)a(t[n],e)},n.prototype._condense=function(e){for(var t=e.length-1,i=void 0;t>=0;t--)0===e[t].children.length?t>0?(i=e[t-1].children).splice(i.indexOf(e[t]),1):this.clear():o(e[t],this.toBBox)},n},"object"==typeof i&&void 0!==t?t.exports=r():(n=n||self).RBush=r();var n,r},{}]},{},[1])(1)}));class CustomHTMLControl{constructor(e){this.custom_html=e.custom_html}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.innerHTML=this.custom_html;return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class DownloadControl{constructor(e,t,i,n){this.interact_with_filters=e.interact_with_filters;this.notify_on_download=e.notify_on_download;this.included_fields=e.included_fields;this.features=t.concat(i.concat(n))}addListeners(){jQuery(document).on("click",".mapster-data-download",(()=>{this.downloadFeatures()}))}downloadFeatures(){let e=this.processFeatures();e.length>0?this.downloadCSV(e):alert("No features selected for download.")}processFeatures(e){let t=[];this.features.forEach((e=>{if(this.interact_with_filters&&window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(e.id)>-1)return;let i=e.data.location?e.data.location:e.data.line?e.data.line:e.data.polygon?e.data.polygon:null,n={};n.title=e.title;n.permalink=e.permalink;n.categories=e.categories.map((e=>e.name)).join(",");this.getRecursivePropertyValue(n,e.data.additional_details,"");n.geography=JSON.stringify(i);if(this.included_fields&&""!==this.included_fields){let e={};this.included_fields.split(",").forEach((t=>{let i=t.trim();n[i]&&(e[i]=n[i])}));n=e}t.push(n)}));return t}getRecursivePropertyValue(e,t,i){for(let n in t)Array.isArray(t[n])?e[i+n]=t[n].join(","):"object"==typeof t[n]?this.getRecursivePropertyValue(e,t[n],i+n+"_"):e[i+n]=JSON.stringify(t[n])}downloadCSV(e){const t=(e,t)=>null===t?"":t;let i=[];e.forEach((e=>{for(let t in e)-1===i.indexOf(t)&&i.push(t)}));e.forEach((e=>{i.forEach((t=>{e[t]||(e[t]="")}))}));let n=e.map((e=>i.map((i=>JSON.stringify(e[i],t).replace(/\\"/g,'""'))).join(",")));n.unshift(i.join(","));n=n.join("\r\n");var r=document.createElement("a"),o=new Blob(["\ufeff",n]),s=URL.createObjectURL(o);r.href=s;r.download="map-data-download.csv";document.body.appendChild(r);r.click();document.body.removeChild(r);if(this.notify_on_download){let e=[];jQuery(".mapster-category-control input").each((function(){jQuery(this).is(":checked")&&e.push(jQuery(this).closest("li").text().trim())}));fetch(`${window.mapster_params.rest_url}mapster-wp-maps/send-email`,{method:"POST",body:JSON.stringify({users:this.notify_on_download,active_filters:e})})}}onAdd(e){this.map=e;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");if(window.mapster_params.public){this._container.className="mapboxgl-ctrl mapster-download-control";this._container.innerHTML='\n <div class="mapster-download-control-content">\n <button class="mapster-data-download">Download Data</button>\n </div>\n ';this.addListeners()}return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class ListControl{constructor(e,t,i,n,r,o){this.sort_by_distance=e.sort_by_distance;this.show_distance=e.show_distance;this.units=e.units;this.markers=r;this.mapLibrary=o;this.listing_type=e.listing_type;this.number_of_locations=e.number_of_locations;this.store_locator=e.store_locator_options.enable;this.sort_hours_by_day=e.store_locator_options.sort_hours_by_day;this.features=t.concat(i.concat(n));this.currentPage=1;this.storedBounds=null}storeLocatorHTML(e){return"<div>Upgrade to Mapster Pro to enable this functionality.</div>"}setHTML(e){const t=new MapsterHelpers;var i="<ul>",n=[];this.features.forEach(((e,i)=>{if(!(window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(e.id)>-1)){var r=t.makeFeatureJSON(e.data);if(this.show_distance||this.sort_by_distance){var o=turf.distance(turf.center(r).geometry.coordinates,this.getCenter());e.distance=o*("imperial"===this.units?.621371:1)}n.push(e)}}));this.sort_by_distance&&(n=n.sort(((e,t)=>e.distance>t.distance?1:-1)));var r=[];n.forEach(((e,t)=>{"paginate"===this.listing_type?this.number_of_locations*(this.currentPage-1)<=t&&this.number_of_locations*this.currentPage>t&&r.push(e):r=n}));this.store_locator?i=this.storeLocatorHTML(i,r):r.forEach((e=>{i+=`\n <li data-id="${e.id}">\n ${e.title}\n <em>${e.distance?e.distance.toFixed(2)+("imperial"===this.units?" miles":" km"):""}</em>\n </li>\n `}));i+="</ul>";if("paginate"===this.listing_type){i+='<div class="mapster-paging">';this.currentPage>1&&(i+='<span class="mapster-back dashicons dashicons-arrow-left"></span>');this.number_of_locations*this.currentPage<this.number_of_locations.length&&(i+='<span class="mapster-next dashicons dashicons-arrow-right"></span>');i+="</div>"}if(e)return i;jQuery(".mapster-list-control-content").html(i)}getStoreHTML(e){return""}getCenter(){return[this.map.getCenter().lng,this.map.getCenter().lat]}addListeners(){var e=this;const t=new MapsterHelpers;jQuery(document).on("click",".mapster-list-control li",(function(i){if(!i.isTrigger){var n=e.features.find((e=>parseInt(e.id)==jQuery(this).data("id"))),r=t.makeFeatureJSON(n.data).features[0];if("Point"===r.geometry.type){const t=e.markers.find((e=>e.mapsterProperties.id===n.id));t&&n.data.enable_popup&&e.openPopup(t,n);!t&&n.data.enable_popup&&e.openPopupNonMarker(n);e.centerMap(r.geometry.coordinates,15)}else{var o=turf.bbox(r);e.fitBounds(o,{padding:20})}if(e.store_locator){jQuery(".mapster-list-control-content").hide();jQuery(".mapster-list-control-single-content").show();jQuery(".mapster-list-control-single-content").html(e.getStoreHTML(n))}}}));jQuery(document).on("click",".mapster-next",(()=>{this.currentPage=this.currentPage+1;this.setHTML()}));jQuery(document).on("click",".mapster-back",(()=>{this.currentPage=this.currentPage-1;this.setHTML()}));jQuery(document).on("click",".mapster-store-locator-results",(()=>{jQuery(".mapster-list-control-content").show();jQuery(".mapster-list-control-single-content").hide();jQuery(".mapster-list-control-single-content").empty();this.fitBounds(this.storedBounds)}));jQuery(document).on("change",".mapster-cat-toggle",(()=>{this.setHTML()}))}openPopup(e,t){const i=new MapsterHelpers;e.setPopup(new this.mapLibrary.Popup(i.returnPopupOptions(t.data)).setHTML(i.getPopupHTML(t.id,t.data))).togglePopup()}openPopupNonMarker(e){let t=this;const i=setInterval((()=>{if(t.map.getBounds().contains(e.data.location.coordinates)){t.map.fire("click",{lngLat:e.data.location.coordinates,originalEvent:{}});clearInterval(i)}}),100)}centerMap(e,t){this.map.flyTo({center:e,zoom:t})}fitBounds(e,t){this.map.fitBounds(e,t)}onAdd(e){this.map=e;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-list-control"+(this.store_locator?" mapster-store-locator":"")+(window.innerWidth<768?" mapster-mobile":"");this._container.innerHTML=`<div class="mapster-list-control-content" style="max-height : ${jQuery(this.map._container).height()-100}px">`+this.setHTML(!0)+`</div><div class="mapster-list-control-single-content" style="max-height : ${jQuery(this.map._container).height()}px;"></div>`;if(window.innerWidth<768&&this.store_locator){jQuery(this.map._container).css("overflow","visible");this._container.style.marginTop=`${jQuery(this.map._container).height()}px`;jQuery(this.map._container).after(`<div style="height: ${jQuery(this.map._container).height()}px"></div>`);jQuery(".maplibregl-control-container > div, .mapboxgl-control-container > div").width("100%");jQuery(".mapboxgl-ctrl-geocoder").width("100%")}this.addListeners();this.map.on("moveend",(()=>{this.setHTML()}));setTimeout((()=>{this.store_locator&&!jQuery(".mapster-store-locator .mapboxgl-ctrl-geocoder").length&&jQuery(".mapboxgl-ctrl-geocoder").prependTo(".mapster-store-locator")}),100);return this._container}onAddGoogleMap(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-list-control mapster-list-control-google"+(this.store_locator?" mapster-store-locator":"")+(window.innerWidth<768?" mapster-mobile":"");this._container.innerHTML=`<div class="mapster-list-control-content" style="max-height : ${jQuery(this.map.__gm.div).height()-100}px">`+this.setHTML(!0)+`</div><div class="mapster-list-control-single-content" style="max-height : ${jQuery(this.map.__gm.div).height()}px;"></div>`;this.addListeners();this.map.addListener("dragend",(()=>{this.setHTML()}));google.maps.event.addListenerOnce(this.map,"idle",(()=>{this.store_locator&&setTimeout((()=>{jQuery(".mapster-google-geocoder-input").addClass("geocoder-google-store-locator");jQuery(".mapster-google-geocoder-input").prependTo(".mapster-store-locator")}),1e3);const e=this.map.getBounds();this.storedBounds=[e.getSouthWest().lng(),e.getSouthWest().lat(),e.getNorthEast().lng(),e.getNorthEast().lat()]}));return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}
|
||
;class PitchToggle{constructor(e=-20,t=70,i=null){this._bearing=-20;this._pitch=70;this._minpitchzoom=i}onAdd(e){this._map=e;let t=this;this._btn=document.createElement("button");this._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-3d";this._btn.type="button";this._btn["aria-label"]="Toggle Pitch";this._btn.onclick=function(){if(0===e.getPitch()){let i={pitch:t._pitch,bearing:t._bearing};t._minpitchzoom&&e.getZoom()>t._minpitchzoom&&(i.zoom=t._minpitchzoom);e.easeTo(i);t._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-2d"}else{e.easeTo({pitch:0,bearing:0});t._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-3d"}};this._container=document.createElement("div");this._container.className="mapboxgl-ctrl-group mapboxgl-ctrl";this._container.appendChild(this._btn);return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class CategoryControl{constructor(e,t,i,n,r,o,s,a,l,c,u){this.displayMode=e.category_display;this.checkboxMode=e.checkbox_display;this.initialVisibility=e.initial_visibility;this.preSelectedCategories=e.pre_selected_categories;this.independentChildren=e.independent_children;this.excludedCategories=e.excluded_categories;this.functionality=e.functionality;this.additional_filters=e.additional_filters;this.accordion_layout=e.accordion_layout;this.show_number_of_features=e.show_number_of_features;this.did_one_accordion=!1;this.markers=i;this.map_provider=a;this.circle_clustering=l;this.label_icon_clustering=c;this.marker_clustering=u;this.cluster_options=t;this.features=r.concat(o.concat(s));this.dataLayers=n;this.locations=r;this.lines=o;this.polygons=s}setMarkers(e){this.markers=e}organizeCategories(){var e=[];this.features.forEach((t=>{t.categories.forEach((t=>{-1===e.findIndex((e=>e.id===t.id))&&e.push(t)}))}));return e=this.filterCategories(e)}returnHTML(){return`\n <div>\n ${this.returnCategoryHTML(this.organizeCategories())}\n </div>\n `}returnCategoryHTML(e){var t="<ul>";e.filter((e=>0===e.parent)).forEach(((i,n)=>{var r=e.filter((e=>e.parent===i.id));t+=this.returnInputHTML(i,r);t+=this.returnChildrenHTML(i,e)}));return t+="</ul>"}returnChildrenHTML(e,t){var i="<ul>",n=t.filter((t=>t.parent===e.id));n.forEach((e=>{i+=this.returnInputHTML(e,[]);i+=this.returnChildrenHTML(e,t)}));i+="</ul>";0===n.length&&(i="");return i}returnInputHTML(e,t){var i=!0;!this.initialVisibility&&this.preSelectedCategories&&-1===this.preSelectedCategories.indexOf(e.id)&&(i=!1);return this.returnAccordionHTML(`\n <li>\n ${"checkbox"===this.checkboxMode?`\n <input class="mapster-cat-toggle" id="${e.id}" data-term="${e.id}" data-parent="${e.parent}" ${i?'checked="checked"':""} type="checkbox" />\n `:`\n <label class="mapster-switch">\n <input class="mapster-cat-toggle" id="${e.id}" data-term="${e.id}" data-parent="${e.parent}" ${i?'checked="checked"':""} type="checkbox" />\n <span class="mapster-slider mapster-round"></span>\n </label>\n `}\n ${"colors"===this.displayMode?`<div class="mapster-color-swatch" style="background-color: ${e.color};"></div>`:""}\n ${"icons"===this.displayMode?`<div class="mapster-icon-swatch" style="background-image: url(${e.icon});background-size: cover;"></div>`:""}\n <label for="${e.id}">${e.name} ${this.returnNumberOfFeatures(e)?`<span class="mapster-number-of-features">(${this.returnNumberOfFeatures(e)})</span>`:""}</label>\n </li>\n `,e,t)}setToggles(e){var t=jQuery(e).data("term"),i=jQuery(e).data("parent"),n=jQuery(e).is(":checked");if(!this.independentChildren)if(0===i)n?jQuery(`.mapster-cat-toggle[data-parent="${t}"]`).prop("checked",!0):jQuery(`.mapster-cat-toggle[data-parent="${t}"]`).prop("checked",!1);else if(n)jQuery(`.mapster-cat-toggle[data-term="${i}"]`).prop("checked",!0);else{var r=!0;jQuery(`.mapster-cat-toggle[data-parent="${i}"]`).each((function(){jQuery(this).is(":checked")&&(r=!1)}));r&&jQuery(`.mapster-cat-toggle[data-term="${i}"]`).prop("checked",!1)}}returnIDsToHideFeatures(e){let t=[];this.features.forEach((i=>{if(i.categories.length>0)if("exclusive"===this.functionality)i.categories.find((t=>e.indexOf(t.id)>-1))&&t.push(i.id);else if("inclusive"===this.functionality){var n=!0;i.categories.forEach((t=>{-1===e.indexOf(t.id)&&(n=!1)}));n&&t.push(i.id)}}));return t}returnNumberOfFeatures(){return!1}adjustMarkers(e){let t=[];this.markers.forEach((i=>{const n=this.returnMarkerProperties(i);if(n.categories.length>0)if("exclusive"===this.functionality)if(n.categories.find((t=>e.indexOf(t.id)>-1))){this.changeMarker("hide",i);t.push(i.mapsterProperties.id)}else this.changeMarker("show",i);else if("inclusive"===this.functionality){var r=!0;if(n.categories.length>0){n.categories.forEach((t=>{-1===e.indexOf(t.id)&&(r=!1)}));if(r){this.changeMarker("hide",i);t.push(i.mapsterProperties.id)}else this.changeMarker("show",i)}}}));this.adjustMarkerClusters(t)}adjustMarkerClusters(e){if(this.marker_clustering){let t=["marker"];(new MapsterHelpers).makeClusters(this.map,this.map_provider,this.cluster_options,t,this.locations,[],[],e)}}returnAccordionHTML(e,t,i){return e}filterCategories(e){return e}changeMarker(e,t){"hide"===e?t.remove():"show"===e&&t.addTo(this.map)}changeLayerVisibility(){var e=[];jQuery(".mapster-cat-toggle").each((function(){jQuery(this).is(":checked")||e.push(jQuery(this).data("term"))}));var t=this.returnIDsToHideFeatures(e);this.setHiddenFeatures(t);this.adjustMarkers(e)}setHiddenFeatures(e){if(this.map.getLayer("symbol")){this.map.getLayer("symbol-clusters")&&(new MapsterHelpers).setClustering(this.map,this.map_provider,this.cluster_options,this.circle_clustering,this.label_icon_clustering,this.marker_clustering,this.markers,this.locations,this.lines,this.polygons,e);this.map.setLayoutProperty("symbol","text-size",["case",["in",["get","post_id"],["literal",e]],0,["==",!1,["get","label_label_on"]],0,["has","label_text_properties_text-size"],["to-number",["get","label_text_properties_text-size"]],16]);this.map.setLayoutProperty("symbol","icon-size",["case",["in",["get","post_id"],["literal",e]],0,["==",!1,["get","icon_icon_on"]],0,["has","icon_icon_properties_icon-size"],["/",["to-number",["get","icon_icon_properties_icon-size"]],100],1])}if(this.map.getLayer("circle")){this.map.setPaintProperty("circle","circle-radius",["case",["in",["get","post_id"],["literal",e]],0,["has","circle_radius"],["to-number",["get","circle_radius"]],0]);this.map.setPaintProperty("circle","circle-stroke-width",["case",["in",["get","post_id"],["literal",e]],0,["has","circle_radius"],["to-number",["get","circle_radius"]],0])}this.map.getLayer("line")&&this.map.setPaintProperty("line","line-width",["case",["in",["get","post_id"],["literal",e]],0,["has","width"],["to-number",["get","width"]],2]);if(this.map.getLayer("fill")){const t=new MapsterHelpers;let i=this.polygons.filter((t=>-1===e.indexOf(t.id))),n=t.createLayerGeoJSON(this.map,"polygon","fill",[],[],i);this.map.getSource("fill").setData(n)}}returnMarkerProperties(e){return e.mapsterProperties}addListeners(){var e=this;jQuery(document).on("change",".mapster-cat-toggle",(function(){e.setToggles(this);e.changeLayerVisibility()}));jQuery(document).on("click",".mapster-accordion-indicator",(function(){let e=!1;jQuery(this).parent().hasClass("mapster-accordion-indicator-open")&&(e=!0);jQuery(".mapster-accordion-indicator").each((function(){if(jQuery(this).parent().next("ul").is(":visible")){jQuery(this).parent().next("ul").slideToggle(400,(()=>jQuery(this).parent().addClass("mapster-accordion-indicator-closed")));jQuery(this).parent().removeClass("mapster-accordion-indicator-open")}}));if(e)jQuery(this).parent().addClass("mapster-accordion-indicator-closed");else{jQuery(this).parent().addClass("mapster-accordion-indicator-open");jQuery(this).parent().next("ul").slideToggle()}}))}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-category-control";this._container.innerHTML=this.returnHTML();this.initialVisibility||setTimeout((()=>{this.changeLayerVisibility()}),10);this.addListeners();return this._container}onAddGoogleMap(e){this.map=e;this._container=document.createElement("div");this._container.className="mapster-category-control mapster-google-category-control";this._container.innerHTML=this.returnHTML();this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this.map=void 0}}
|
||
;class LayerControl{constructor(e){this.toggleable_layers=e.toggleable_layers;this.toggleable_layer_titles=e.toggleable_layer_titles;this.checkbox_type=e.checkbox_type}returnHTML(){let e='<ul class="mapster-layer-control-content">';const t=this.toggleable_layers.replace("\r","").split("\n"),i=this.toggleable_layer_titles.replace("\r","").split("\n");t.forEach(((t,n)=>{e+="<li>";const r=t.split(",");let o=!0,s=!0;r.forEach((e=>{if(""!==e){this.map.getLayer(e.trim())||(o=!1);"hidden"!==this.map.getLayoutProperty(e.trim(),"visibility")&&void 0===this.map.getLayoutProperty(e.trim(),"visibility")||(s=!1)}}));o?"checkbox"===this.checkbox_type?e+=`<input class="mapster-layer-toggle" data-layers="${t}" ${s?'checked="checked"':""} type="checkbox" /> ${i[n]}`:"radio"===this.checkbox_type?e+=`<input name="mapster-layer-control" class="mapster-layer-toggle" data-layers="${t}" ${s?'checked="checked"':""} type="radio" /> ${i[n]}`:"switch"===this.checkbox_type&&(e+=`<label class="mapster-switch">\n <input class="mapster-layer-toggle" data-layers="${t}" ${s?'checked="checked"':""} type="checkbox" />\n <span class="mapster-slider mapster-round"></span>\n </label> ${i[n]}`):alert("Please double check the layers you've set for the layer control: some don't exist in the style!");e+="</li>"}));e+="</ul>";return e}changeLayerVisibility(){let e=this;jQuery(".mapster-layer-toggle").each((function(){jQuery(this).data("layers").split(",").forEach((t=>{jQuery(this).is(":checked")?e.map.setLayoutProperty(t.trim(),"visibility","visible"):e.map.setLayoutProperty(t.trim(),"visibility","none")}))}))}addListeners(){var e=this;jQuery(document).on("change",".mapster-layer-toggle",(function(){e.changeLayerVisibility()}))}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-layer-control";const t=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(t)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class StyleControl{constructor(e){this.toggleable_styles=e.toggleable_styles;this.toggleable_styles_titles=e.toggleable_styles_titles;this.initial_style_title=e.initial_style_title;this.default_style=!1}returnHTML(){let e='<ul class="mapster-style-control-content">';this.default_style=this.map.getStyle();e+=`<li><input name="mapster-style-control" class="mapster-style-toggle" data-index="default" checked="checked" type="radio" /> ${this.initial_style_title}`;const t=this.toggleable_styles.replace("\r","").split("\n"),i=this.toggleable_styles_titles.replace("\r","").split("\n");t.forEach(((t,n)=>{if(""!==t){e+="<li>";e+=`<input name="mapster-style-control" class="mapster-style-toggle" data-index="${n}" type="radio" /> ${i[n]}`;e+="</li>"}}));e+="</ul>";return e}addListeners(){var e=this;new MapsterHelpers;jQuery(document).on("change",".mapster-style-toggle",(function(){const t=jQuery(this).data("index");if("default"!==t){const i=e.toggleable_styles.split("\n");i[t].indexOf("{")>-1?e.map.setStyle(JSON.parse(i[t])):e.map.setStyle(i[t]);e.map.fire("mapster_custom_style_load")}else{e.map.setStyle(e.default_style);e.map.fire("mapster_custom_style_load")}}))}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-style-control";const t=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(t)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class ElevationControl{constructor(e){this.lines=e.lines;this.post_id=e.post_id;this.single_line=e.single_line;this.open_on_load=e.open_on_load;this.profile_color=e.profile_color;this.units=e.units;this.show_line_length=e.show_line_length;this.profile_displayed=!1;this.last_line_displayed=!1}addListeners(){jQuery(document).on("click",".mapster-elevation-control-content",(()=>{if(this.profile_displayed){this.removeElevation();this.profile_displayed=!1;jQuery(".mapster-elevation-control-content").removeClass("mapster-elevation-control-active")}else{jQuery(".mapster-elevation-control-content");if(this.map.getSource("mapbox-dem"))this.addElevation(this.last_line_displayed);else{this.loadElevationData();this.map.once("idle",(()=>{this.addElevation(this.last_line_displayed)}))}this.profile_displayed=!0;jQuery(".mapster-elevation-control-content").addClass("mapster-elevation-control-active")}}));this.single_line&&this.open_on_load&&setTimeout((()=>{this.last_line_displayed=this.lines[0];jQuery(".mapster-elevation-control-content").click()}),1e3);this.single_line||this.map.on("click","line",(e=>{this.last_line_displayed=this.lines.find((t=>t.id===e.features[0].properties.post_id));this.profile_displayed&&jQuery(".mapster-elevation-control-content").click();jQuery(".mapster-elevation-control-content").click()}));this.map.on("mousemove",(()=>{this.map.getLayer("elevation-point-along-layer")&&this.map.setLayoutProperty("elevation-point-along-layer","visibility","none")}))}loadElevationData(){this.map.addSource("mapbox-dem",{type:"raster-dem",url:"mapbox://mapbox.terrain-rgb",tileSize:512,maxzoom:14});this.map.setTerrain({source:"mapbox-dem",exaggeration:1.5})}removeElevation(){document.getElementById("mapster-chartjs-container").remove()}addElevation(e){let t=[],i=turf.length(e.data.line);for(let n=0;n<i;n+=i/50){let i=turf.along(e.data.line,n),r=this.map.queryTerrainElevation(i.geometry.coordinates,{exaggerated:!1});"feet"===this.units&&(r*=3.28084);t.push(r)}let n=document.createElement("div");n.setAttribute("id","mapster-chartjs-container");let r=document.createElement("canvas");r.setAttribute("id","mapster-chartjs");document.getElementById(`mapster-wp-maps-${this.post_id}`).append(n);n.append(r);const o=new MapsterConstants;let s=t.map((e=>""));if(this.show_line_length){s=[];t.forEach(((e,t)=>{let n=i/50;"feet"===this.units&&(n*=.621371);let r=parseInt(t*n*10)/10;s.push(r)}))}new Chart(document.getElementById("mapster-chartjs"),{type:"line",data:{labels:s,datasets:[{label:"Elevation",data:t,fill:!1,borderColor:this.profile_color,pointRadius:0,tension:.2}]},options:o.returnElevationChartOptions(this.units,this.show_line_length),plugins:[o.returnElevationChartPlugin(this.map,e)]})}onAdd(e){this.map=e;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");if(window.mapster_params.public){this._container.className="mapboxgl-ctrl mapster-elevation-control";this._container.innerHTML='\n <div class="mapster-elevation-control-content">\n <svg class="mapster-svg-mountain" focusable="false" viewBox="0 0 24 24" aria-hidden="true">\n <path d="M14 6l-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z"></path>\n </svg>\n </div>\n ';this.addListeners()}return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class MapsterConstants{returnElevationChartPlugin(e,t){return{id:"corsair",afterInit:e=>{e.corsair={x:0,y:0}},afterEvent:(e,t)=>{const{chartArea:{top:i,bottom:n,left:r,right:o}}=e,{event:{x:s,y:a}}=t;if(s<r||s>o||a<i||a>n){e.corsair={x:s,y:a,draw:!1};e.draw()}else{e.corsair={x:s,y:a,draw:!0};e.draw()}},afterDatasetsDraw:(i,n,r)=>{const{ctx:o,chartArea:{top:s,bottom:a,left:l,right:c}}=i,{x:u,y:h,draw:p}=i.corsair;if(!p)return;o.lineWidth=r.width||0;o.setLineDash(r.dash||[]);o.strokeStyle=r.color||"black";o.save();o.beginPath();o.moveTo(u,a);o.lineTo(u,s);o.stroke();o.restore();const d=(u-l)/(c-l);let f=turf.length(t.data.line),m=turf.along(t.data.line,f*d);if(e.getSource("elevation-point-along")&&e.getLayer("elevation-point-along-layer")){e.getSource("elevation-point-along").setData(m);e.setLayoutProperty("elevation-point-along-layer","visibility","visible")}else{e.addSource("elevation-point-along",{type:"geojson",data:m});e.addLayer({id:"elevation-point-along-layer",type:"circle",source:"elevation-point-along"})}}}}returnElevationChartOptions(e,t){return{interaction:{intersect:!1,mode:"index"},scales:{x:{title:{display:!!t,text:"meters"===e?"KM":"Miles",font:{style:"italic",size:10}},grid:{display:!0},ticks:{font:{size:10}}}},maintainAspectRatio:!1,plugins:{legend:{display:!1},title:{display:!0,text:`Elevation (${"meters"===e?"m":"ft"})`},tooltip:{displayColors:!1,callbacks:{label:function(t){return parseInt(10*t.parsed.y)/10+" "+("meters"===e?"m":"ft")}}},corsair:{color:"#333",width:1}}}}returnStyleProviders(){return[{id:"streets",style:"mapbox://styles/mapbox/streets-v12"},{id:"outdoors",style:"mapbox://styles/mapbox/outdoors-v12"},{id:"light",style:"mapbox://styles/mapbox/light-v11"},{id:"dark",style:"mapbox://styles/mapbox/dark-v11"},{id:"satellite",style:"mapbox://styles/mapbox/satellite-v9"},{id:"satellite-streets",style:"mapbox://styles/mapbox/satellite-streets-v12"},{id:"custom-image",style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(255,255,255,1)"}}]}},{id:"empty",style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(255,255,255,1)"}}]}},{id:"open-street-map",style:this.returnJsonStyle("https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"open-topo-map",style:this.returnJsonStyle("https://a.tile.opentopomap.org/{z}/{x}/{y}.png",'Map data: © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)')},{id:"cyclo-osm",style:this.returnJsonStyle("https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",'<a href="https://github.com/cyclosm/cyclosm-cartocss-style/releases" title="CyclOSM - Open Bicycle render">CyclOSM</a> | Map data: © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"toner-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png",'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"watercolor-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png",'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"terrain-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png",'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"esri-satellite",style:this.returnJsonStyle("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}","Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community")},{id:"blank-map",style:this.returnJsonStyle("https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')}]}returnJsonStyle(e,t){return{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{"raster-tiles":{type:"raster",tiles:[e],tileSize:256,attribution:t}},layers:[{id:"simple-tiles",type:"raster",source:"raster-tiles",minzoom:0,maxzoom:22}]}}loaderHTML(){return'\n\t\t\t<div class="mapster-map-loader">\n\t\t\t\t<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#333">\n\t\t\t\t\t<g fill="none" fill-rule="evenodd">\n\t\t\t\t\t\t\t<g transform="translate(1 1)" stroke-width="2">\n\t\t\t\t\t\t\t\t\t<circle stroke-opacity=".5" cx="18" cy="18" r="18"/>\n\t\t\t\t\t\t\t\t\t<path d="M36 18c0-9.94-8.06-18-18-18">\n\t\t\t\t\t\t\t\t\t\t\t<animateTransform\n\t\t\t\t\t\t\t\t\t\t\t\t\tattributeName="transform"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype="rotate"\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom="0 18 18"\n\t\t\t\t\t\t\t\t\t\t\t\t\tto="360 18 18"\n\t\t\t\t\t\t\t\t\t\t\t\t\tdur="1s"\n\t\t\t\t\t\t\t\t\t\t\t\t\trepeatCount="indefinite"/>\n\t\t\t\t\t\t\t\t\t</path>\n\t\t\t\t\t\t\t</g>\n\t\t\t\t\t</g>\n\t\t\t\t</svg>\n\t\t\t</div>\n\t\t'}markerAsSVG(e){return"data:image/svg+xml;charset=UTF-8,"+encodeURIComponent(`\n <svg display="block" height="41px" width="27px" viewBox="0 0 27 41" xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink">\n <g fill-rule="nonzero">\n <g transform="translate(3.0, 29.0)" fill="#000000">\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="10.5" ry="5.25002273"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="10.5" ry="5.25002273"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="9.5" ry="4.77275007"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="8.5" ry="4.29549936"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="7.5" ry="3.81822308"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="6.5" ry="3.34094679"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="5.5" ry="2.86367051"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="4.5" ry="2.38636864"></ellipse>\n </g>\n <g fill="${e}">\n <path d="M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"></path>\n </g>\n <g opacity="0.25" fill="${e}">\n <path d="M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"></path>\n </g>\n <g transform="translate(6.0, 7.0)" fill="#FFFFFF"></g>\n <g transform="translate(8.0, 8.0)">\n <circle fill="${e}" opacity="0.25" cx="5.5" cy="5.5" r="5.4999962"></circle>\n <circle fill="#FFFFFF" cx="5.5" cy="5.5" r="5.4999962"></circle>\n </g>\n </g>\n </svg>\n `)}}class MapsterHelpers{constructor(){this.queuedImages=[]}isMobile(){let e=!1;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0);return e}changeCursor(e,t,i){t.data.enable_popup&&(e.getCanvas().style.cursor="on"===i?"pointer":"grab")}formatResponse(e){["location","line","polygon"].forEach((t=>{e[t+"s"].forEach((i=>{this.setObjectProperties(i,e[t+"_template"]);this.setPopupStyles(i,e.popup_styles)}))}));return new Promise((t=>{t(e)}))}getDefaultCenter(){let e=[0,0];"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_lat&&window.mapster_params.mapster_default_lng&&(e=[parseFloat(window.mapster_params.mapster_default_lng),parseFloat(window.mapster_params.mapster_default_lat)]);return e}getDefaultZoom(){let e=2;"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_zoom&&(e=parseFloat(window.mapster_params.mapster_default_zoom));return e}doHover(e,t){let i=t.data.line?"line":t.data.symbol?"symbol":t.data.circle?"circle":t.data.polygon?"fill":[],n="line"===i||"fill"===i?t.data:"circle"===i?t.data.circle:t.data.symbol;if(n.hover_effects&&n.hover_effects.hover_enabled){e.removeFeatureState({source:i});e.setFeatureState({source:i,id:t.id},{hover:!0})}}doHoverOut(e,t){let i=t.data.line?"line":t.data.symbol?"symbol":t.data.circle?"circle":t.data.polygon?"fill":[],n="line"===i||"fill"===i?t.data:"circle"===i?t.data.circle:t.data.symbol;n.hover_effects&&n.hover_effects.hover_enabled&&e.setFeatureState({source:i,id:t.id},{hover:!1})}doMarkerHover(e,t,i){let n=i.mapsterProperties.data;if(n.marker.hover_effects.hover_enabled){const r=new t.Marker({color:n.marker.hover_effects.hover_color,scale:parseFloat(n.marker.hover_effects.hover_scale)/100,rotation:parseFloat(n.marker.hover_effects.hover_rotation),anchor:n.marker.anchor});-1===r._element.className.indexOf("mapster-remove-hover")&&(r._element.className+=" mapster-remove-hover");-1===i._element.className.indexOf("mapster-hide-original")&&(i._element.className+=" mapster-hide-original");r.setLngLat([i._lngLat.lng,i._lngLat.lat]).addTo(e);return r}return!1}doMarkerHoverOut(e,t){t._element.className.indexOf("mapster-hide-original")>-1&&(t._element.className=t._element.className.replace(" mapster-hide-original",""));e.remove()}setMapCompare(e,t,i,n){
|
||
}applyProSearchFilter(e,t){
|
||
return t}setGeolocationOnLoad(e){
|
||
}setMapBreakpointSizes(e,t){
|
||
}async getImageData(e){return wp.media.attachment(e).fetch().then((e=>e))}async setCustomImageMap(e,t,i){
|
||
}loadModalSteps(e,t,i,n,r,o){const s=new MapsterConstants;let a=!1,l=[];if("create_point"===n){if(r)if(1===r.length){a=r[0].term_id;if(o.submission_interface.include_address_search){c(e);u()}else{u();h()}}else{c(e);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n <div class="mapster-category-container">\n ${r.map((e=>`\n <div class="mapster-category-tile mapster-cat-set" data-category="${e.term_id}">\n ${e.icon?`<div class="mapster-category-image"><img src="${e.icon}" /></div>`:""}\n ${e.name?`<div class="mapster-category-name"><p>${e.name}</p></div>`:""}\n ${e.description?`<div class="mapster-category-description"><p>${e.description}</p></div>`:""}\n </div>\n `)).join("")}\n </div>\n `)}else{c(e);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n <div class="mapster-category-container" data-category="none">\n <div class="mapster-category-tile mapster-cat-set">${o.custom_texts.add_point_text}</div>\n </div>\n `)}jQuery(document).on("click",`#mapster-submission-modal-${e} .mapster-category-tile.mapster-cat-set`,(function(){"none"!==jQuery(this).data("category")&&(a=jQuery(this).data("category"));u()}))}if("edit_point"===n){const t=window.mapster_params.user_submission_permalink;c(e);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n ${s.loaderHTML()}\n <iframe\n onload="jQuery('.mapster-map-loader').remove();"\n class="mapster-submission-embed"\n src="${t}?pagetype=search&map_id=${e}">\n </iframe>\n `)}window.onmessage=function(e){if(e.data&&e.data.indexOf){e.data.indexOf("set_point")>-1&&u(e.data.replace("set_point-",""));if(e.data.indexOf("close_modal")>-1){jQuery(".mapster-submission-modal-overlay").fadeOut(50);jQuery(".mapster-submission-modal").fadeOut(100)}}};function c(e){jQuery(`.mapster-submit-${e} #mapster-submission-modal-overlay-${e}`).fadeIn(100);jQuery(`.mapster-submit-${e} #mapster-submission-modal-${e}`).fadeIn(150)}function u(n){o.submission_interface.include_address_search?jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n <div class="mapster-description-text"><p>${o.custom_texts.choose_how}</p></div>\n <div class="mapster-category-container">\n ${o.submission_interface.include_address_search?`<div class="mapster-category-tile mapster-method-set" data-method="address" style="max-width:none;"><p>${o.custom_texts.address_search}</p></div>`:""}\n <div class="mapster-category-tile mapster-method-set" data-method="click" style="max-width:none;"><p>${o.custom_texts.map_click}</p></div>\n </div>\n `):h();jQuery(document).on("click",`#mapster-submission-modal-${e} .mapster-category-tile.mapster-method-set`,(function(){if("address"===jQuery(this).data("method")){const n=new MapboxGeocoder({accessToken:o.submission_interface.mapbox_geocoder_access_token,mapboxgl:i,marker:!1});jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`<p>${o.custom_texts.search_location}</p>`);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`)[0].appendChild(n.onAdd(t));n.on("result",(function(){h()}))}"click"===jQuery(this).data("method")&&h()}));jQuery(document).on("click",`#mapster-wp-maps-${e} .mapster-selection-instructions button`,(function(i){const n=t.getCenter();let r=!0;if(o.administration.allowed_area){const e=JSON.parse(o.administration.allowed_area);turf.booleanPointInPolygon([n.lng,n.lat],e.features[0])||(r=!1)}jQuery(".mapboxgl-ctrl").show();jQuery(".mapster-selection-overlay").remove();l=[n.lng,n.lat];jQuery(`#mapster-submission-modal-overlay-${e}`).fadeIn(100);jQuery(`#mapster-submission-modal-${e}`).fadeIn(150);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n <div class="mapster-description-text"><p>${r?o.custom_texts.selection_saved:o.custom_texts.selection_error}</p></div>\n <div class="mapster-category-container">\n <div class="mapster-category-tile mapster-method-set" data-method="click" style="max-width:none;"><p>${o.custom_texts.try_again}</p></div>\n ${r?`<div class="mapster-category-tile mapster-coords-set" style="max-width:none;"><p>${o.custom_texts.confirm}</p></div>`:""}\n </div>\n `)}));jQuery(document).on("click",`#mapster-submission-modal-${e} .mapster-category-tile.mapster-coords-set`,(function(){const t=window.mapster_params.user_submission_permalink;let i=!!o.administration.template_post&&o.administration.template_post.ID;if(o.administration.multiple_templates){let e=o.submission_interface.categories.indexOf(a);i=o.administration.template_posts[e]}let r=n?"&type=edit&post_id="+n:"";jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n ${s.loaderHTML()}\n <iframe\n onload="jQuery('.mapster-map-loader').remove();"\n class="mapster-submission-embed"\n src="${t}?category=${a}&coords=${l.join(",")}&map_id=${e}${r}">\n </iframe>\n `)}))}function h(){jQuery(".mapster-submission-modal-close").trigger("click");jQuery(".mapboxgl-ctrl").hide();jQuery(t._container).append(`\n <div class="mapster-selection-overlay">\n <div class="mapster-selection-instructions">\n <p>${o.custom_texts.drag_zoom}</p>\n <button>${o.custom_texts.capture_point}</button>\n </div>\n <svg version="1.1" id="Uploaded to svgrepo.com" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n width="32px" height="32px" viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">\n <style type="text/css">\n .dashing_een{fill:#141414;}\n .st0{fill:#141414;}\n </style>\n <path class="dashing_een" d="M15.5,21.5v-2c0-0.276,0.224-0.5,0.5-0.5s0.5,0.224,0.5,0.5v2c0,0.276-0.224,0.5-0.5,0.5\n S15.5,21.776,15.5,21.5z M16,13c0.276,0,0.5-0.224,0.5-0.5v-2c0-0.276-0.224-0.5-0.5-0.5s-0.5,0.224-0.5,0.5v2\n C15.5,12.776,15.724,13,16,13z M16,3c0.276,0,0.5-0.224,0.5-0.5v-2C16.5,0.224,16.276,0,16,0c-0.276,0-0.5,0.224-0.5,0.5v2\n C15.5,2.776,15.724,3,16,3z M16,32c0.276,0,0.5-0.224,0.5-0.5v-2c0-0.276-0.224-0.5-0.5-0.5s-0.5,0.224-0.5,0.5v2\n C15.5,31.776,15.724,32,16,32z M22,16c0-0.276-0.224-0.5-0.5-0.5h-2c-0.276,0-0.5,0.224-0.5,0.5s0.224,0.5,0.5,0.5h2\n C21.776,16.5,22,16.276,22,16z M13,16c0-0.276-0.224-0.5-0.5-0.5h-2c-0.276,0-0.5,0.224-0.5,0.5s0.224,0.5,0.5,0.5h2\n C12.776,16.5,13,16.276,13,16z M3,16c0-0.276-0.224-0.5-0.5-0.5h-2C0.224,15.5,0,15.724,0,16c0,0.276,0.224,0.5,0.5,0.5h2\n C2.776,16.5,3,16.276,3,16z M32,16c0-0.276-0.224-0.5-0.5-0.5h-2c-0.276,0-0.5,0.224-0.5,0.5s0.224,0.5,0.5,0.5h2\n C31.776,16.5,32,16.276,32,16z M27,16c0,6.065-4.935,11-11,11S5,22.065,5,16S9.935,5,16,5S27,9.935,27,16z M26,16.5h-1.5\n c-0.276,0-0.5-0.224-0.5-0.5s0.224-0.5,0.5-0.5H26c-0.255-5.115-4.387-9.245-9.5-9.5v1.5C16.5,7.776,16.276,8,16,8\n s-0.5-0.224-0.5-0.5V6c-5.113,0.255-9.245,4.385-9.5,9.5h1.5C7.776,15.5,8,15.724,8,16s-0.224,0.5-0.5,0.5H6\n c0.255,5.115,4.387,9.245,9.5,9.5v-1.5c0-0.276,0.224-0.5,0.5-0.5s0.5,0.224,0.5,0.5V26C21.613,25.745,25.745,21.615,26,16.5z"/>\n </svg>\n </div>\n `)}}setProjectionGlobe(e,t){
|
||
}create3DModels(e,t){
|
||
}setPopupStyles(e,t){if(e.data.popup_style){let i=e.data.popup_style,n=t.find((e=>e.id===i));e.data.popup_style=n}}setObjectProperties(e,t){for(var i in t)if(this.isObject(t[i])){null==e[i]&&(e[i]={});this.setObjectProperties(e[i],t[i])}else null==e[i]&&(e[i]=t[i])}isObject(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}makeFeatureJSON(e){let t=e.line?e.line:e.location?e.location:!!e.polygon&&e.polygon;return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:t.type,coordinates:t.coordinates}}]}}getStyle(e){const t=new MapsterConstants;if(""!==e.custom_mapbox_style)return e.custom_mapbox_style;if("custom-image"===e.map_provider)return t.returnStyleProviders().find((e=>"custom-image"===e.id)).style;if(""!==e.access_token){var i=e.map_tile_style_access_token;return t.returnStyleProviders().find((e=>e.id===i)).style}i=e.map_tile_style_no_access_token;return t.returnStyleProviders().find((e=>e.id===i)).style}addMapControl(e,t,i,n,r,o={}){t&&e.removeControl(t);if(i){const t=new r(o);e.addControl(t,n);return t}return!1}searchLocalFeatures(e,t,i,n,r){var o={type:"FeatureCollection",features:[]};i.concat(n.concat(r)).forEach((e=>{var t=this.makeFeatureJSON(e.data);o.features.push(this.makeGeocoderResult(e,t))}));let s=this.localFeaturesTextMatch(e,t,o.features);s.sort(((e,t)=>e.place_name>t.place_name?1:-1));return s}localFeaturesTextMatch(e,t,i){let n=[];const r=t.split(" ").filter((e=>""!==e));i.forEach((i=>{var o=!1;i.properties.searchableTexts.forEach((s=>{var a={type:"Feature",id:i.properties.id,place_name:jQuery("<div>").html(i.properties.place_name).text()};if(!(window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.length>0&&-1!==window.mapster_categories_hidden_features.indexOf(i.properties.id))){if("exact-match"===e&&s&&(s.toLowerCase().indexOf(t.toLowerCase())>-1||" "===t)&&!o){a.center=turf.center(i).geometry.coordinates;"Point"!==i.geometry.type&&(a.bbox=turf.bbox(i));n.push(a);o=!0}
|
||
}}))}));return n}initializeSlider(e,t){const i=e=>{jQuery("#mapster-slider ul").animate({left:jQuery("#mapster-slider ul li").width()*("right"===e?-1:1)},200,(()=>{jQuery("#mapster-slider ul li:first-child").appendTo("#mapster-slider ul");jQuery("#mapster-slider ul").css("left","")}))};if(!window.sliderClicksInitialized){jQuery(document).on("click","#mapster-slider .mapster-slider-control_prev",(function(){i("left")}));jQuery(document).on("click","#mapster-slider .mapster-slider-control_next",(function(){i("right")}));window.sliderClicksInitialized=!0}}makeHeatmap(e,t,i,n){
|
||
}createHeatmapProperties(e,t,i,n){
|
||
}fadeHeatmapFeatures(e,t){
|
||
}setClustering(e,t,i,n,r,o,s,a,l,c,u){if(r||n)return this.doSymbolClustering(e,t,i,n,r,a,l,c,u);o&&this.doMarkerClustering(e,t,i,o,s,a,u);return[]}doMarkerClustering(e,t,i,n,r,o,s){let a=i.cluster_by_category?i.categories_to_cluster.map((e=>"marker-"+e)):["marker"];this.makeClusters(e,t,i,a,o,[],[],s);e.on("render",(()=>{let t=[];a.forEach((i=>{if(!e.isSourceLoaded(i))return;const n=e.querySourceFeatures(i);t=t.concat(n.filter((e=>e.properties.id)).map((e=>e.properties.id)))}));r.forEach((i=>{-1===t.indexOf(i.mapsterProperties.id)?i.remove():(!i._popup||i._popup&&!i._popup.isOpen())&&i.addTo(e)}))}))}doSymbolClustering(e,t,i,n,r,o,s,a,l){var c=[];r&&(i.cluster_by_category?i.categories_to_cluster.forEach((e=>{c.push("symbol-"+e)})):c.push("symbol"));n&&(i.cluster_by_category?i.categories_to_cluster.forEach((e=>{c.push("circle-"+e)})):c.push("circle"));this.makeClusters(e,t,i,c,o,s,a,l);return c}makeClusters(e,t,i,n,r,o,s,a){n.forEach((t=>{e.getLayer(`${t}-cluster-count`)&&e.removeLayer(`${t}-cluster-count`);e.getLayer(`${t}-clusters`)&&e.removeLayer(`${t}-clusters`);e.getLayer(`${t}-clusters-border`)&&e.removeLayer(`${t}-clusters-border`);e.getLayer(t)&&e.removeLayer(t);if(e.getSource(t))try{e.removeSource(t)}catch(e){}}));n.forEach(((n,l)=>{let c,u=n.split("-")[0];if(e.getLayer(u)&&e.getSource(u)){e.removeLayer(u);e.removeSource(u)}c=n.indexOf("marker")>-1?this.createMarkerGeoJSON(r,n):this.createLayerGeoJSON(e,"location",n,r,o,s);a=a||[];var h=c.features.filter((e=>-1===a.indexOf(e.properties.post_id)));let p=!1;if(i.show_category_name){let e=r.concat(o.concat(s)),t=parseInt(n.split("-")[1]);e.forEach((e=>{p||(p=e.categories.find((e=>e.id===t)))}))}e.addSource(n,{type:"geojson",data:{type:"FeatureCollection",features:h},cluster:!0,clusterMaxZoom:14,clusterRadius:50});if(n.indexOf("marker")>-1)e.addLayer({id:n,source:n,type:"circle",filter:["!",["has","point_count"]],paint:{"circle-radius":0}});else{var d=this.getLayerExpressions("location",n.indexOf("symbol")>-1?"symbol":"circle",t);e.addLayer({id:n,source:n,type:n.split("-")[0],filter:["!",["has","point_count"]],paint:d.paint,layout:d.layout})}this.addIcons(e,n,c);let f="#51bbd6",m=100,g=20,_="#f1f075",y=750,v=30,x="#f28cb1",b=40;
|
||
e.addLayer({id:`${n}-clusters`,type:"circle",source:n,filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],f,m,_,y,x],"circle-radius":["step",["get","point_count"],g,m,v,y,b]}});e.addLayer({id:`${n}-cluster-count`,type:"symbol",source:n,filter:["has","point_count"],layout:{"text-field":p?p.name:"{point_count_abbreviated}","text-font":"mapbox"===t?["DIN Offc Pro Medium","Arial Unicode MS Bold"]:["Open Sans Regular"],"text-size":12}});setTimeout((()=>{e.on("click",`${n}-clusters`,(t=>{const i=e.queryRenderedFeatures(t.point,{layers:[`${n}-clusters`]}),r=i[0].properties.cluster_id;e.getSource(n).getClusterExpansionZoom(r,((t,n)=>{e.easeTo({center:i[0].geometry.coordinates,zoom:n+1})}))}))}),500)}))}makeGeocoderResult(e,t){var i=t.features[0];i.properties={searchableTexts:[e.data.popup?e.data.popup.header_text:"",e.data.popup?e.data.popup.body_text:"",e.title,e.content],id:e.id,place_name:e.title};return i}modifyDropdown(e){e.container.classList.add("mapster-maps-dropdown");jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--icon.mapboxgl-ctrl-geocoder--icon-search").replaceWith('<svg viewBox="0 0 32 32" class="mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-search" viewBox="0 0 32 32" aria-hidden="true">\n <path d="M24 11.305l-7.997 11.39L8 11.305z"/>\n </svg>');jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--input").wrap('<div class="input-wrapper"></div>');jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--input").attr("disabled",!0);jQuery(document).on("click",".mapster-maps-dropdown .input-wrapper",(()=>{e.setInput("");jQuery(".suggestions-wrapper .suggestions li").removeClass("active")}));jQuery(document).on("click",".mapboxgl-ctrl-geocoder--icon.mapboxgl-ctrl-geocoder--icon-close",(()=>{e.clear();jQuery(".suggestions-wrapper .suggestions").hide()}))}openExternalLink(e){e&&e.data.open_link_on_click&&e.data.click_link&&e.data.click_link.url&&(e.data.click_link.open_link_in_new_tab?window.open(e.data.click_link.url):window.open(e.data.click_link.url,"_self"))}getMapBounds(e,t,i){var n={type:"FeatureCollection",features:[]};[["location",e],["line",t],["polygon",i]].forEach((e=>{e[1].forEach((e=>{var t=this.makeFeatureJSON(e.data);n.features.push(t.features[0])}))}));return n.features.length>0?turf.bbox(n):null}openStoreLocatorClick(e,t){e.enable&&jQuery(`.mapster-store-locator-list[data-id="${t}"]`).click()}openSidebarClick(e,t,i,n,r,o){!e.enable&&t&&this.setSidebarHTML(i.data,n,r,o)}openPopup(e,t,i,n,r,o,s){if(!o.enable&&!s){i&&i.remove();if(n.data.popup_style){n.data.location&&"Point"===n.data.location.type&&(r=n.data.location.coordinates);let i=new t.Popup(this.returnPopupOptions(n.data)).setLngLat(r).setHTML(this.getPopupHTML(n.id,n.data));this.centerPopup(e,i,n);i.addTo(e);return i}}}centerPopup(e,t,i){
|
||
}mouseIsNear(e,t,i){if(e&&e.offset()){var n=e.offset().left-t,r=e.offset().top-t,o=n+e.width()+2*t,s=r+e.height()+2*t,a=i.pageX,l=i.pageY;return a>n&&a<o&&l>r&&l<s}return!1}getDirectionsLatLng(e){let t="";e.location&&(t=e.location.coordinates[1].toString()+","+e.location.coordinates[0].toString());if(e.line){let i=turf.center(e.line);t=i.geometry.coordinates[1].toString()+","+i.geometry.coordinates[0].toString()}if(e.polygon){let i=turf.center(e.polygon);t=i.geometry.coordinates[1].toString()+","+i.geometry.coordinates[0].toString()}return t}getPopupHTML(e,t){var i=this.getPopupStyle(t),n=this.returnPopupCSS(t),r=this.returnPopupLayout(t),o=this.returnPopupContent(t),s=this.returnPopupHTML(t),a="";"to-directions"===o.button_action&&(a=this.getDirectionsLatLng(t));r.enable_image&&"gallery"===o.image_type&&setTimeout((()=>{this.initializeSlider(`mapster-popup-${t.popup_style.id}`,o.images.length+1)}),400);return`\n <style>${i}</style>\n ${r.use_custom_css?`<style>${n.css_editor.replace(/#mapster-popup/g,`#mapster-popup-${t.popup_style.id}`)}</style>`:""}\n ${r.use_custom_html?this.replaceHTMLValues(s.html_editor,o):`<div id="mapster-popup-${t.popup_style.id}" class="map-popup-background ${r.popup_class} mapster-feature-popup-${e}">\n ${r.enable_header?`<div class="map-popup-header">\n <h2>${o.header_text}</h2>\n </div>`:""}\n ${r.enable_image&&"feature-image"===o.image_type?'<div class="map-popup-image"></div>':""}\n ${r.enable_image&&"gallery"===o.image_type?`<div class="map-popup-gallery">\n <div id="mapster-slider" style="height : ${n.image_height}px;">\n <div class="mapster-slider-control_next">></div>\n <div class="mapster-slider-control_prev"><</div>\n <ul>\n ${o.images.map((e=>`<li style="height : ${n.image_height}px; background-image: url(${e});"> </li>`)).join(" ")}\n </ul>\n </div>\n </div>`:""}\n ${r.enable_body?`<div class="map-popup-body">\n <p>${o.body_text}</p>\n </div>`:""}\n ${r.enable_footer?`<div class="map-popup-footer">\n ${"do-nothing"===o.button_action?`<button class="map-popup-footer-button">${o.button_text}</button>`:""}\n ${"to-post"===o.button_action?`<button class="map-popup-footer-button" onclick="${o.open_link_in_new_tab?`window.open('${t.popup.permalink}', '_blank');`:`window.open('${t.popup.permalink}', '_self');`}">\n ${o.button_text}\n </button>`:""}\n ${"to-link"===o.button_action?`<button class="map-popup-footer-button" onclick="${o.open_link_in_new_tab?`window.open('${o.button_url}', '_blank');`:`window.open('${o.button_url}', '_self');`}">\n ${o.button_text}\n </button>`:""}\n ${"to-directions"===o.button_action?`<button class="map-popup-footer-button" onclick="window.open('https://www.google.com/maps/dir/?api=1&destination=${a}', '_blank');">\n ${o.button_text}\n </button>`:""}\n ${"to-modal"===o.button_action?`<button class="map-popup-footer-button mapster-button-modal-open">\n ${o.button_text}\n </button>\n <div class="mapster-modal-content-in-popup"><embed style='width: 100%; height: ${window.innerHeight-300}px;' src='http://localhost:8888/wp-content/plugins/mapster-wordpress-maps/admin/includes/mapster-modal-shortcode.php?feature_id=${e}'></embed></div>`:""}\n </div>`:""}\n </div>`}\n `}getPopupStyle(e){var t=this.returnPopupCSS(e),i=this.returnPopupLayout(e),n=this.returnPopupContent(e),r=e.popup_style.id;return`\n .mapboxgl-popup .mapboxgl-popup-content, .maplibregl-popup .maplibregl-popup-content {\n padding: 0px;\n background: none;\n border: none;\n border-radius: none;\n box-shadow: none;\n }\n #mapster-popup-${r}.map-popup-background {\n background : ${t.background};\n text-align : ${t.align};\n border-radius: 3px;\n box-shadow: 0 1px 2px rgb(0 0 0 / 10%);\n }\n #mapster-popup-${r} .map-popup-header {\n background : ${t.header};\n padding: 10px;\n }\n #mapster-popup-${r} .map-popup-header h2 {\n all : revert;\n color : ${t.header_text};\n font-weight: bold;\n margin: 0;\n padding: 0;\n }\n #mapster-popup-${r} .map-popup-image {\n background-image : url("${n.featured_image?n.featured_image.url:""}");\n background-position : center center;\n background-size: cover;\n height : ${t.image_height}px;\n width: 100%;\n }\n #mapster-popup-${r} .map-popup-body {\n margin-top: -1px;\n background : ${t.body};\n padding: 10px;\n color : ${t.body_text};\n }\n #mapster-popup-${r} .map-popup-body p {\n padding: 0px;\n margin: 0px;\n }\n #mapster-popup-${r} .map-popup-footer {\n margin-top: -1px;\n background : ${t.footer};\n padding: 10px;\n }\n #mapster-popup-${r} .map-popup-footer .map-popup-footer-button {\n all : revert;\n background : ${t.button};\n border-color: ${t.button};\n color : ${t.button_text};\n padding: 5px;\n text-decoration: none;\n text-shadow: none;\n }\n #mapster-popup-${r} .map-popup-footer .map-popup-footer-button:hover {\n cursor: pointer;\n filter: brightness(1.15);\n }\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n }\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip {\n\t\t\t\tborder-left-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n\t\t\t}\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip {\n\t\t\t\tborder-right-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n\t\t\t}\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n }\n `}setSidebarHTML(e,t,i,n){var r="#mapster-wp-maps-"+n;jQuery(".mapster-sidebar-popup").remove();var o=jQuery(r).height(),s=(jQuery(r).width(),this.getPopupStyle(e)),a=this.returnPopupCSS(e),l=this.returnPopupLayout(e),c=this.returnPopupContent(e);l.enable_image&&"gallery"===c.image_type&&setTimeout((()=>{this.initializeSlider(`mapster-sidebar-popup-${e.popup_style.id}`,c.images.length+1)}),400);jQuery(document).on("click",".mapster-sidebar-popup-exit",(()=>{jQuery(".mapster-sidebar-popup").remove()}));const u=parseFloat(t),h=parseFloat(i),p=`\n <style>${s.replace(/-popup/g,"-sidebar-popup")}</style>\n ${l.use_custom_css?`<style>${a.css_editor.replace(/#mapster-popup/g,`#mapster-popup-${e.popup_style.id}`)}</style>`:""}\n <div id="mapster-sidebar-popup-${e.popup_style.id}" class="mapster-sidebar-popup" style="min-width: ${u}px; min-height: ${o/2}px; max-height: ${o}px; max-width: ${h}px;">\n <div class="mapster-sidebar-popup-exit">✖</div>\n ${l.enable_header?`<div class="map-sidebar-popup-header">\n <h2>${c.header_text}</h2>\n </div>`:""}\n ${l.enable_image&&"feature-image"===c.image_type?'<div class="map-sidebar-popup-image"></div>':""}\n ${l.enable_image&&"gallery"===c.image_type?`<div class="map-sidebar-popup-gallery">\n <div id="mapster-slider" style="height : ${a.image_height}px;">\n <div class="mapster-slider-control_next">></div>\n <div class="mapster-slider-control_prev"><</div>\n <ul>\n ${c.images.map((e=>`<li style="height : ${a.image_height}px; background-image: url(${e});"> </li>`)).join(" ")}\n </ul>\n </div>\n </div>`:""}\n ${l.enable_body?`<div class="map-sidebar-popup-body">\n <p>${c.body_text}</p>\n </div>`:""}\n ${l.enable_footer?`<div class="map-sidebar-popup-footer">\n ${"do-nothing"===c.button_action?`<button class="map-sidebar-popup-footer-button">${c.button_text}</button>`:""}\n ${"to-post"===c.button_action?`<button class="map-sidebar-popup-footer-button" onclick="${c.open_link_in_new_tab?`window.open('${e.popup.permalink}', '_blank');`:`window.open('${e.popup.permalink}', '_self');`}">\n ${c.button_text}\n </button>`:""}\n ${"to-link"===c.button_action?`<button class="map-sidebar-popup-footer-button" onclick="${c.open_link_in_new_tab?`window.open('${c.button_url}', '_blank');`:`window.open('${c.button_url}', '_self');`}">\n ${c.button_text}\n </button>`:""}\n ${"to-modal"===c.button_action?`<button class="map-sidebar-popup-footer-button mapster-button-modal-open">\n ${c.button_text}\n </button>\n <div class="mapster-modal-content-in-popup">${c.modal_details}</div>`:""}\n </div>`:""}\n </div>\n `;jQuery(r).append(p)}replaceHTMLValues(e,t){let i;
|
||
return i}returnPopupHTML(e){return{html_editor:e.popup_style.html_editor}}returnPopupContent(e){return{header_text:e.popup.header_text,image_type:e.popup.image_type,featured_image:e.popup.featured_image,images:e.popup.images,body_text:e.popup.body_text,button_text:e.popup.button_text,button_action:e.popup.button_action,button_url:e.popup.button_url,modal_details:e.popup.modal_details,additional_details:e.additional_details,open_link_in_new_tab:e.popup.open_link_in_new_tab}}returnPopupLayout(e){return{enable_header:e.popup_style.enable_header,enable_image:e.popup_style.enable_image,enable_body:e.popup_style.enable_body,enable_footer:e.popup_style.enable_footer,enable_pointer:e.popup_style.enable_pointer,use_custom_css:e.popup_style.use_custom_css,use_custom_html:e.popup_style.use_custom_html,popup_class:e.popup_style.popup_class}}returnPopupOptions(e){return{className:"hover"===e.interaction?"mapster-hover-popup":"",closeButton:e.popup_style.close_button,closeOnClick:e.popup_style.close_on_click,closeMapMove:e.popup_style.close_on_map_move,maxWidth:e.popup_style.max_width+"px"}}returnPopupCSS(e){return{background:e.popup_style.background,header:e.popup_style.header,image_height:e.popup_style.image_height,body:e.popup_style.body,footer:e.popup_style.footer,button:e.popup_style.button,pointer:e.popup_style.pointer,header_text:e.popup_style.header_text,body_text:e.popup_style.body_text,button_text:e.popup_style.button_text,align:e.popup_style.align,css_editor:e.popup_style.css_editor,max_width:e.popup_style.max_width}}getMarkerStyles(e){var t=e.data;return{color:t.marker.color,scale:parseFloat(t.marker.scale)/100,rotation:parseFloat(t.marker.rotation),anchor:t.marker.anchor}}getLayerExpressions(e,t,i){if("line"===e)return{layout:{},paint:{"line-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"line-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","hover_effects_hover_opacity"]],100],["has","opacity"],["/",["to-number",["get","opacity"]],100],1],"line-width":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","hover_effects_hover_width"]],["has","width"],["to-number",["get","width"]],2],"line-dasharray":"mapbox"===i?["case",["==",!0,["to-boolean",["get","dashed_line"]]],["get","dash_properties_line_dash_array"],["literal",[1,0]]]:[1,0]}};if("polygon"===e){if("fill"===t)return{layout:{},paint:{"fill-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"fill-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","hover_effects_opacity"]],100],["has","opacity"],["/",["to-number",["get","opacity"]],100],1],"fill-outline-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_outline-color"],["has","outline-color"],["get","outline-color"],"rgba(0,0,0,0)"]}};if("fill-extrusion"===t)return"1"===window.mapster_params.activated?{layout:{},paint:{"fill-extrusion-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"fill-extrusion-opacity":.75,"fill-extrusion-base":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","3d_polygon_base"]],100],["has","3d_polygon_base"],["to-number",["get","3d_polygon_base"]],0],"fill-extrusion-height":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","3d_polygon_height"]],["has","3d_polygon_height"],["to-number",["get","3d_polygon_height"]],0]}}:{layout:{},paint:{}}}if("location"===e){if("circle"===t)return{layout:{},paint:{"circle-color":["case",["boolean",["feature-state","hover"],!1],["get","circle_hover_effects_hover_color"],["has","circle_color"],["get","circle_color"],"#000"],"circle-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","circle_hover_effects_hover_opacity"]],100],["has","circle_opacity"],["/",["to-number",["get","circle_opacity"]],100],1],"circle-radius":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","circle_hover_effects_hover_radius"]],["has","circle_radius"],["to-number",["get","circle_radius"]],0],"circle-stroke-width":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","circle_hover_effects_hover_stroke-width"]],["has","circle_stroke-width"],["to-number",["get","circle_stroke-width"]],0],"circle-stroke-color":["case",["boolean",["feature-state","hover"],!1],["get","circle_hover_effects_hover_stroke-color"],["has","circle_stroke-color"],["get","circle_stroke-color"],"#000"],"circle-stroke-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","circle_hover_effects_hover_stroke-opacity"]],100],["has","circle_stroke-opacity"],["/",["to-number",["get","circle_stroke-opacity"]],100],1]}};if("symbol"===t)return{layout:{"text-field":["case",["has","label_text_properties_text-field"],["get","label_text_properties_text-field"],"New Text"],"text-font":["case",["==","Open Sans Regular",["get","label_text_properties_text-font"]],["literal",["Open Sans Regular"]],["==","Open Sans Bold",["get","label_text_properties_text-font"]],["literal",["Open Sans Bold"]],["==","Open Sans Italic",["get","label_text_properties_text-font"]],["literal",["Open Sans Italic"]],["==","Klokantech Noto Sans Regular",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Regular"]],["==","Klokantech Noto Sans Bold",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Bold"]],["==","Klokantech Noto Sans Italic",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Italic"]],["==","Metropolis",["get","label_text_properties_text-font"]],["literal",["Metropolis"]],["==","Metropolis Bold",["get","label_text_properties_text-font"]],["literal",["Metropolis Bold"]],["==","Metropolis Regular Italic",["get","label_text_properties_text-font"]],["literal",["Metropolis Regular Italic"]],["literal",["Open Sans Regular"]]],"text-rotate":["case",["has","label_text_properties_text-rotate"],["to-number",["get","label_text_properties_text-rotate"]],0],"text-size":["case",["==",!1,["get","label_label_on"]],0,["has","label_text_properties_text-size"],["to-number",["get","label_text_properties_text-size"]],16],"icon-size":["case",["==",!1,["get","icon_icon_on"]],0,["has","icon_icon_properties_icon-size"],["/",["to-number",["get","icon_icon_properties_icon-size"]],100],1],"icon-rotate":["case",["has","icon_icon_properties_icon-rotate"],["to-number",["get","icon_icon_properties_icon-rotate"]],0],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-anchor":["case",["has","icon_icon_properties_icon-anchor"],["get","icon_icon_properties_icon-anchor"],"center"],"icon-offset":["case",["has","icon_icon_properties_offset_array"],["get","icon_icon_properties_offset_array"],["literal",[0,0]]],"text-offset":["case",["has","label_text_properties_offset_array"],["get","label_text_properties_offset_array"],["literal",[0,0]]]},paint:{"text-color":["case",["has","label_text_properties_text-color"],["get","label_text_properties_text-color"],"#000000"],"text-halo-width":["case",["has","label_text_properties_text-halo-width"],["to-number",["get","label_text_properties_text-halo-width"]],1],"text-halo-color":["case",["has","label_text_properties_text-halo-color"],["get","label_text_properties_text-halo-color"],"#FFFFFF"],"text-halo-blur":["case",["has","label_text_properties_text-halo-blur"],["/",["to-number",["get","label_text_properties_text-halo-blur"]],100],1],"text-opacity":["case",["has","label_text_properties_text-opacity"],["/",["to-number",["get","label_text_properties_text-opacity"]],100],1],"icon-opacity":["case",["has","icon_icon_properties_icon-opacity"],["/",["to-number",["get","icon_icon_properties_icon-opacity"]],100],1]}}}}addIcons(e,t,i){t.indexOf("symbol")>-1&&i.features.forEach((i=>{i.properties.icon_icon_on&&i.properties["icon_icon_properties_icon-image_url"]&&this.addNewIcon(e,i.properties["icon_icon_properties_icon-image_url"],i.properties["icon_icon_properties_icon-image_id"],(()=>{e.getLayer(t)&&e.setLayoutProperty(t,"icon-image",["case",["has","icon_icon_properties_icon-image_id"],["concat","icon-image-",["get","icon_icon_properties_icon-image_id"]],"none"])}))}))}addNewIcon(e,t,i,n){if(this.queuedImages.indexOf(`icon-image-${i}`)>-1)n();else{this.queuedImages.push(`icon-image-${i}`);t||n();"https:"===window.location.protocol&&t.indexOf("http://")>-1&&(t=t.replace("http","https"));var r=new Image;r.src=t;r.crossOrigin="";r.onload=function(){if(e.loaded()){e.hasImage(`icon-image-${i}`)?e.updateImage(`icon-image-${i}`,r):e.addImage(`icon-image-${i}`,r);n()}else e.once("idle",(()=>{e.hasImage(`icon-image-${i}`)?e.updateImage(`icon-image-${i}`,r):e.addImage(`icon-image-${i}`,r);n()}))}}}createLayerGeoJSON(e,t,i,n,r,o){var s={type:"FeatureCollection",features:[]};let a="line"===t?r:"location"===t?n:"polygon"===t?o:[],l=i.indexOf("-")>-1&&i.split("-")[1],c=i.indexOf("-")>-1?i.split("-")[0]:i;if("fill-extrusion"===i){c=i;l=!1}a.forEach((n=>{if(n.data[t]&&c===this.getLayerType(t,n.data)&&(!l||n.categories.find((e=>e.id===parseFloat(l))))){var r=this.makeFeatureJSON(n.data);if(r.features[0]){var o=this.makeFeatureWithProperties(n,r.features[0]);s.features.push(o)}n.data.open_popup_on_load&&-1===i.indexOf("-")&&setTimeout((()=>{if(e){const t=turf.pointOnFeature(r);e.fire("click",{lngLat:t.geometry.coordinates})}}),500)}}));return s}createMarkerGeoJSON(e,t){let i=!!t.indexOf("-")&&t.split("-")[1];var n={type:"FeatureCollection",features:[]};n.features=e.filter((e=>!i&&"marker"===e.data.location_style||!(!i||"marker"!==e.data.location_style||!e.categories.find((e=>e.id===parseFloat(i)))))).map((e=>{e.post_id=e.id;return{type:"Feature",properties:e,geometry:e.data.location}}));return n}makeFeatureWithProperties(e,t){var i=JSON.parse(JSON.stringify(t));i.id=e.id;i.properties.post_id=e.id;for(var n in e.data)-1===["polygon","line","location","popup","popup_style"].indexOf(n)&&this.assignToProperty(i,e.data,n);i.properties.dashed_line&&i.properties.dash_properties_dash_length&&(i.properties.dash_properties_line_dash_array=[parseFloat(i.properties.dash_properties_dash_length),parseFloat(i.properties.dash_properties_gap_length)]);(i.properties["label_text_properties_text-translate-x"]||i.properties["label_text_properties_text-translate-y"])&&(i.properties.label_text_properties_offset_array=[parseFloat(i.properties["label_text_properties_text-translate-x"]),parseFloat(i.properties["label_text_properties_text-translate-y"])]);(i.properties["icon_icon_properties_icon-translate-x"]||i.properties["icon_icon_properties_icon-translate-y"])&&(i.properties.icon_icon_properties_offset_array=[parseFloat(i.properties["icon_icon_properties_icon-translate-x"]),parseFloat(i.properties["icon_icon_properties_icon-translate-y"])]);return i}assignToProperty(e,t,i,n){if("object"==typeof t[i])for(var r in t[i])this.assignToProperty(e,t[i],r,n?n+"_"+i:i);else{var o=n?n+"_"+i:i;e.properties[o]=t[i]}}getLayerType(e,t){if("line"===e)return"line";if("polygon"===e){if(!t.polygon_style||"fill"===t.polygon_style)return"fill";if("fill-extrusion"===t.polygon_style)return"fill-extrusion"}if("location"===e){if("circle"===t.location_style)return"circle";if("label"===t.location_style)return"symbol"}}}class MapsterCore{constructor(){}setDataLayers(){}getPostData({post_id:e,single_feature_id:t}){const i=new MapsterHelpers;let n=t?`&single_feature_id=${t}`:"";return fetch(`${window.mapster_params.rest_url}mapster-wp-maps/map${window.mapster_params.qd}id=${e}${n}`).then((e=>e.json())).then((e=>i.formatResponse(e)))}getFeaturesAdmin({locations_ids:e,lines_ids:t,polygons_ids:i,cats:n}){const r=e.concat(t.concat(i));return fetch(`${window.mapster_params.rest_url}mapster-wp-maps/features${window.mapster_params.qd}ids=${JSON.stringify(r)}&categories=${JSON.stringify(n)}`).then((e=>e.json()))}sortLocations({adminFeatures:e}){return e.filter((e=>e.data.location))}sortLines({adminFeatures:e}){return e.filter((e=>e.data.line))}sortPolygons({adminFeatures:e}){return e.filter((e=>e.data.polygon))}doClustering({map:e,map_provider:t,cluster_options:i,circle_clustering:n,label_icon_clustering:r,marker_clustering:o,markers:s,locations:a,lines:l,polygons:c,idsToHide:u}){return(new MapsterHelpers).setClustering(e,t,i,n,r,o,s,a,l,c,u)}loadCustomScripts({map:e,javascript:t,locations:i,lines:n,polygons:r}){t&&window[t]&&(0,window[t])(e,i.concat(n.concat(r)))}setMapStyle({map:e,map_type:t}){const i=new MapsterHelpers;"custom-image"===t.map_provider?i.setCustomImageMap(e,t,!0):t.custom_style_json&&""!==t.custom_style_json?e.setStyle(JSON.parse(t.custom_style_json)):e.setStyle(i.getStyle(t))}loadProjection({map:e,map_provider:t,projection:i}){"mapbox"===t&&e.setProjection({name:i,center:[0,30],parallels:[30,30]})}loadTerrain({map:e,map_provider:t,terrain:i}){if("mapbox"===t)if(i){if(!e.getSource("mapbox-mapster-dem")){e.addSource("mapbox-mapster-dem",{type:"raster-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1",tileSize:512,maxzoom:14});e.setTerrain({source:"mapbox-mapster-dem",exaggeration:1.5});e.addLayer({id:"sky",type:"sky",paint:{"sky-type":"atmosphere","sky-atmosphere-sun":[0,0],"sky-atmosphere-sun-intensity":15}})}}else{e.getLayer("sky")&&e.removeLayer("sky");e.setTerrain(null);e.getSource("mapbox-mapster-dem")&&e.removeSource("mapbox-mapster-dem")}}layerClick({map:e,interactivity:t,clickedEvent:i,locations:n,lines:r,polygons:o}){if(t){let t=i.point?i.point:e.project(i.lngLat);var s=e.queryRenderedFeatures(t).filter((e=>["symbol","line","fill","circle"].indexOf(e.source.split("-")[0])>-1));return!(!s[0]||"fill"===s[0].layer.id&&("fill"!==s[0].layer.id||0===s[0].layer.paint["fill-opacity"]))&&n.concat(r.concat(o)).find((e=>e.id===s[0].properties.post_id))}return!1}storeLocatorClick({clickedFeature:e,store_locator_options:t}){const i=new MapsterHelpers;e&&e.data.enable_popup&&("click"===e.data.interaction||i.isMobile()&&e.data.click_on_mobile)&&i.openStoreLocatorClick(t,e.id)}sidebarClick({post_id:e,clickedFeature:t,minimum_sidebar_width:i,maximum_sidebar_width:n,store_locator_options:r,open_popups_in_sidebar:o}){const s=new MapsterHelpers;t&&t.data.enable_popup&&("click"===t.data.interaction||s.isMobile()&&t.data.click_on_mobile)&&s.openSidebarClick(r,o,t,i,n,e)}externalClickLayer({clickedFeature:e}){(new MapsterHelpers).openExternalLink(e)}externalClickMarker({clickedMarker:e}){(new MapsterHelpers).openExternalLink(e)}popupClick({map:e,mapLibrary:t,clickedPopup:i,clickedFeature:n,clickedEvent:r,store_locator_options:o,open_popups_in_sidebar:s}){const a=new MapsterHelpers;if(n&&n.data.enable_popup&&("click"===n.data.interaction||a.isMobile()&&n.data.click_on_mobile))return a.openPopup(e,t,i,n,r.lngLat,o,s)}layerHover({map:e,interactivity:t,hoveredEvent:i,locations:n,lines:r,polygons:o}){if(t){var s=e.queryRenderedFeatures(i.point).filter((e=>["symbol","line","fill","circle"].indexOf(e.source.split("-")[0])>-1));return!(!s[0]||"fill"===s[0].layer.id&&("fill"!==s[0].layer.id||0===s[0].layer.paint["fill-opacity"]))&&n.concat(r.concat(o)).find((e=>e.id===s[0].properties.post_id))}return!1}layerHoverEffect({map:e,interactivity:t,hoveredFeature:i}){const n=new MapsterHelpers;n.changeCursor(e,i,"on");
|
||
}popupHover({map:e,mapLibrary:t,hoveredPopup:i,hoveredFeature:n,hoveredEvent:r,store_locator_options:o}){const s=new MapsterHelpers;if(n&&n.data.enable_popup&&"hover"===n.data.interaction&&(!s.isMobile()||s.isMobile()&&n.data.click_on_mobile))return s.openPopup(e,t,i,n,r.lngLat,o)}markerClick({interactivity:e,clickedMarker:t}){return!!e&&t.mapsterProperties}markerHover({interactivity:e,hoveredMarker:t}){return!!e&&t.mapsterProperties}markerHoverEffect({map:e,mapLibrary:t,interactivity:i,hoveredMarker:n}){
|
||
}openMarkerClickPopup({map:e,mapLibrary:t,clickedMarker:i,clickedFeature:n,clickedPopup:r,store_locator_options:o,open_popups_in_sidebar:s}){const a=new MapsterHelpers;if(!o.enable&&!s&&n&&n.data.enable_popup&&("click"===n.data.interaction||a.isMobile()&&n.data.click_on_mobile)&&n.data.popup_style){const r=new t.Popup(a.returnPopupOptions(n.data));r.setHTML(a.getPopupHTML(n.id,n.data));a.centerPopup(e,r,n);i.setPopup(r)}}openMarkerHoverPopup({map:e,mapLibrary:t,hoveredMarker:i,hoveredFeature:n}){const r=new MapsterHelpers;if(n&&n.data.enable_popup&&"hover"===n.data.interaction&&!r.isMobile()&&n.data.popup_style&&!i.getPopup()){const o=new t.Popup(r.returnPopupOptions(n.data));o.setHTML(r.getPopupHTML(n.id,n.data));r.centerPopup(e,o,n);i.setPopup(o).togglePopup()}}markerHoverEffectOff({tempHoverMarker:e,hoveredMarker:t}){
|
||
}removeMarkerHoverPopup({hoveredMarker:e,hoveredFeature:t}){const i=new MapsterHelpers;t&&t.data.enable_popup&&"hover"===t.data.interaction&&!i.isMobile()&&(e&&!t.data.keep_popup_open_on_hover?e.setPopup(null):e&&t.data.keep_popup_open_on_hover&&jQuery(document).on("mousemove.mapster",(function(e){let n=jQuery(`.mapster-feature-popup-${t.id}`).closest(".mapboxgl-popup");i.mouseIsNear(n,2,e)?n.one("mouseleave",(function(){jQuery(document).off("mousemove.mapster")})):jQuery(document).off("mousemove.mapster")})))}layerHoverEffectOff({map:e,interactivity:t,hoveredFeature:i}){const n=new MapsterHelpers;n.changeCursor(e,i,"off");
|
||
}removePopupHover({hoveredFeature:e,hoveredPopup:t}){t&&!e.data.keep_popup_open_on_hover?t.remove():t&&e.data.keep_popup_open_on_hover&&jQuery(document).one("mousemove",(function(i){let n=jQuery(`.mapster-feature-popup-${e.id}`).closest(".mapboxgl-popup:hover");n.length?n.one("mouseleave",(function(){t.remove()})):t.remove()}))}setInteractivity({map:e,zoom_on_scroll:t,interactivity:i,allow_rotation_and_pitch:n}){t||e.scrollZoom.disable();if(!i){e.scrollZoom.disable();e.boxZoom.disable();e.dragRotate.disable();e.dragPan.disable();e.keyboard.disable();e.doubleClickZoom.disable();e.touchZoomRotate.disable()}if(i&&!n){e.dragRotate.disable();e.touchZoomRotate.disable()}}setFeaturesToMap({map:e,map_provider:t,locations:i,lines:n,polygons:r}){const o=new MapsterHelpers;[["line","line"],["polygon","fill"],["polygon","fill-extrusion"],["location","circle"],["location","symbol"],["location","3d-model"]].forEach((s=>{var a=o.createLayerGeoJSON(e,s[0],s[1],i,n,r);if("3d-model"!==s[1])if(e.getSource(s[1])){e.getSource(s[1]).setData(a);o.addIcons(e,s[1],a)}else{e.addSource(s[1],{type:"geojson",data:a});var l=o.getLayerExpressions(s[0],s[1],t);e.addLayer({id:s[1],source:s[1],type:s[1],paint:l.paint,layout:l.layout});o.addIcons(e,s[1],a)}else o.create3DModels(e,i)}))}setMarkersToMap({map:e,markers:t,mapLibrary:i,locations:n,marker_clustering:r}){const o=new MapsterHelpers;let s=[];t.forEach((e=>{n.find((t=>t.id===e.id))?s.push(e):e.remove()}));let a=[];a=a.concat(s);const l=n.filter((e=>"marker"===e.data.location_style));let c=[];l.sort(((e,t)=>{if(e.data.location.coordinates&&t.data.location.coordinates)return e.data.location.coordinates[1]>t.data.location.coordinates[1]?-1:1;if(!e.data.location.coordinates&&-1===c.indexOf(e.title)){alert(`A point is missing coordinates. See ${e.title}.`);c.push(e.title)}if(!t.data.location.coordinates&&-1===c.indexOf(t.title)){alert(`A point is missing coordinates. See ${t.title}.`);c.push(t.title)}}));l.forEach((t=>{if(!s.find((e=>e.mapsterProperties.id===t.id))){var n=o.getMarkerStyles(t),l=o.makeFeatureJSON(t.data).features[0].geometry.coordinates,c=new i.Marker(n).setLngLat(l);c.mapsterProperties=t;r||c.addTo(e);a.push(c);t.data.open_popup_on_load&&setTimeout((()=>{jQuery(c.getElement()).click()}),100)}}));return a}setHeatmap({map:e,mapLibrary:t,markers:i,locations:n,heatmap:r}){
|
||
}setMapSize({post_id:e,layout:t}){var i="#mapster-wp-maps-"+e;const n=new MapsterHelpers;if(!t.full_page){jQuery(i).height(t.height+t.height_units);jQuery(i).width(t.width+t.width_units);n.setMapBreakpointSizes(e,t)}if(t.full_page){jQuery(i).height(window.innerHeight+t.height_units);jQuery(i).width("100%")}if(t.full_page&&t.ignore_container){jQuery(`<div id="margin-compensator" style="padding-bottom: ${window.innerHeight}px"></div>`).insertAfter(i);jQuery(i).css("marginLeft",-1*jQuery(i).offset().left+"px");jQuery(i).width(window.innerWidth+"px");jQuery(i).css("position","absolute")}}setMapMoveEndVariables({map:e}){jQuery('.acf-field[data-name="manual_pitch"]').find(".acf-label label").html(`Manual Pitch <i>(currently: ${e.getPitch()})</i>`);jQuery('.acf-field[data-name="manual_zoom"]').find(".acf-label label").html(`Manual Zoom <i>(currently: ${e.getZoom()})</i>`);jQuery('.acf-field[data-name="manual_rotation"]').find(".acf-label label").html(`Manual Rotation <i>(currently: ${e.getBearing()})</i>`);const{lng:t,lat:i}=e.getCenter();jQuery('.acf-field[data-name="manual_latitude"]').find(".acf-label label").html(`Manual Latitude <i>(currently: ${i})</i>`);jQuery('.acf-field[data-name="manual_longitude"]').find(".acf-label label").html(`Manual Longitude <i>(currently: ${t})</i>`)}setDefaultAccessToken(){""===jQuery('.acf-field[data-name="access_token"]').find(":input").val()&&jQuery('.acf-field[data-name="access_token"]').find(":input").val(window.mapster_params.mapbox_access_token)}setMapType({map_type:e}){if("mapbox"!==e.map_provider){""!==e.access_token&&(maplibregl.accessToken=e.access_token);return maplibregl}if(""!==e.access_token){mapboxgl.accessToken=e.access_token;return mapboxgl}window.alert(window.mapster_params.strings["Mapbox Token Warning"])}setSubmissionModal({post_id:e,map:t,mapLibrary:i,submission:n}){const r=new MapsterHelpers;jQuery(document).on("click",`#mapster-submit-${e}`,(function(){const o=jQuery(this).data("type"),s=jQuery(this).data("header");jQuery(`.mapster-submit-${e} .mapster-submission-modal-title`).text(s);jQuery(`.mapster-submit-${e} #mapster-submission-modal-overlay-${e}`).parent().detach().appendTo("body");jQuery(`.mapster-submit-${e} #mapster-submission-modal-${e}`).parent().detach().appendTo("body");n.submission_interface.categories.length>0?fetch(`${window.mapster_params.rest_url}mapster-wp-maps/submission-info${window.mapster_params.qd}categories=${n.submission_interface.categories.join(",")}`).then((e=>e.json())).then((s=>{r.loadModalSteps(e,t,i,o,s,n)})):r.loadModalSteps(e,t,i,o,!1,n)}));jQuery(document).on("click",".mapster-submission-modal-close",(function(){jQuery(".mapster-submission-modal-overlay").fadeOut(50);jQuery(".mapster-submission-modal").fadeOut(100)}))}setMap({post_id:e,mapLibrary:t,map:i,locations:n,lines:r,polygons:o}){var s="mapster-wp-maps-"+e;const a=new MapsterHelpers;let l=!0,c="manual"===i.view.initial_load?[parseFloat(i.view.manual_longitude),parseFloat(i.view.manual_latitude)]:a.getDefaultCenter();if(jQuery(`#${s}`).data("latitude")&&"null"!==jQuery(`#${s}`).data("latitude")&&jQuery(`#${s}`).data("longitude")&&"null"!==jQuery(`#${s}`).data("longitude")){c=[parseFloat(jQuery(`#${s}`).data("longitude")),parseFloat(jQuery(`#${s}`).data("latitude"))];l=!1}let u="manual"===i.view.initial_load?parseFloat(i.view.manual_zoom):a.getDefaultZoom();if(jQuery(`#${s}`).data("zoom")&&"null"!==jQuery(`#${s}`).data("zoom")){u=parseFloat(jQuery(`#${s}`).data("zoom"));l=!1}const h={renderWorldCopies:i.layout.duplicate_horizontally,style:a.getStyle(i.map_type),container:s,fitBoundsOptions:{padding:20,maxZoom:18},projection:{name:i.map_type.projection?i.map_type.projection:"mercator",center:[0,30],parallels:[30,30]},bounds:"fit-features"===i.view.initial_load&&l?a.getMapBounds(n,r,o):null,center:c,zoom:u,pitch:i.view.manual_pitch?parseFloat(i.view.manual_pitch):0,bearing:i.view.manual_rotation?parseFloat(i.view.manual_rotation):0,attributionControl:!1,logoPosition:i.logo_control?i.logo_control.position:"bottom-left"};if("1"===window.mapster_params.activated&&i.restricted_movement.restrict_movement){let e=i.restricted_movement.allowed_bounds.southwest_longitude,t=i.restricted_movement.allowed_bounds.southwest_latitude,n=i.restricted_movement.allowed_bounds.northeast_longitude,r=i.restricted_movement.allowed_bounds.northeast_latitude;if(""!==e&&""!==t&&""!==n&&""!==r){let i=[[parseFloat(e),parseFloat(t)],[parseFloat(n),parseFloat(r)]];h.maxBounds=i}let o=i.restricted_movement.allowed_zoom.min_zoom;""!==o&&(h.minZoom=parseFloat(o));let s=i.restricted_movement.allowed_zoom.max_zoom;""!==s&&(h.maxZoom=parseFloat(s))}const p=new t.Map(h);i.map_type.custom_style_json&&""!==i.map_type.custom_style_json&&p.setStyle(JSON.parse(i.map_type.custom_style_json));"custom-image"===i.map_type.map_provider&&a.setCustomImageMap(p,i.map_type);i.map_compare&&i.map_compare.enable_map_slider&&i.map_compare.compared_map&&a.setMapCompare(t,p,e,i.map_compare);window[`mapsterMap${e}`]=p;a.setProjectionGlobe(p,i.map_type);jQuery(".mapster-wp-maps-loader-container").hide();return p}setLoader({post_id:e}){const t=new MapsterConstants;jQuery("#mapster-wp-maps-"+e).append(t.loaderHTML())}setLoaderDone({post_id:e}){jQuery("#mapster-wp-maps-"+e+" .mapster-map-loader").fadeOut()}setMapResize({map:e}){e.resize()}setStreetViewControl(){}setMapTypeControl(){}setZoomControl({map:e,mapLibrary:t,controls:i,zoom_control:n}){return(new MapsterHelpers).addMapControl(e,i.zoomControl,n.enable,n.position,t.NavigationControl)}setAttributionControl({map:e,mapLibrary:t,controls:i,attribution_control:n,map_type:r}){}setElevationControl({map:e,mapLibrary:t,controls:i,elevation_line_chart:n,post_id:r,lines:o}){
|
||
}set3DControl(e){const{map:t,mapLibrary:i,controls:n}=e;return(new MapsterHelpers).addMapControl(t,n["3dControl"],e["3d_control"].enable,e["3d_control"].position,PitchToggle)}setScaleControl({map:e,mapLibrary:t,controls:i,scale_control:n}){return(new MapsterHelpers).addMapControl(e,i.scaleControl,n.enable,n.position,t.ScaleControl)}setGeolocationControl({map:e,mapLibrary:t,controls:i,geolocation_control:n}){const r=new MapsterHelpers,o={showAccuracyCircle:n.show_accuracy_circle,showUserHeading:n.show_user_heading,trackUserLocation:n.show_user_heading||n.track_user_location},s=r.addMapControl(e,i.geolocationControl,n.enable,n.position,t.GeolocateControl,o);r.setGeolocationOnLoad(n);return s}setFullscreenControl({map:e,mapLibrary:t,controls:i,fullscreen_control:n}){return(new MapsterHelpers).addMapControl(e,i.fullscreenControl,n.enable,n.position,t.FullscreenControl)}setGeocoderControl({map:e,mapLibrary:t,controls:i,geocoder_control:n}){const r=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var o={accessToken:t.accessToken,mapboxgl:t,placeholder:n.placeholder};return r.addMapControl(e,i.geocoderControl,n.enable,n.position,MapboxGeocoder,o)}}setDirectionsControl({map:e,mapLibrary:t,controls:i,directions_control:n}){if("undefined"!=typeof MapboxDirections){const o=new MapsterHelpers;var r={accessToken:t.accessToken,mapboxgl:t,unit:n.unit,profile:n.profile,placeholderOrigin:n.placeholderOrigin};return o.addMapControl(e,i.directionsControl,n.enable,n.position,MapboxDirections,r)}}setCustomSearchFilterControl({map:e,mapLibrary:t,controls:i,custom_search_filter:n,locations:r,lines:o,polygons:s,markers:a}){const l=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var c={mapboxgl:t,marker:!1,placeholder:n.placeholder};n.include_geocoder?c.accessToken=t.accessToken:c.localGeocoderOnly=!0;""!==n.limit_results&&(c.countries=n.limit_results);(c=l.applyProSearchFilter(n,c)).localGeocoder=e=>l.searchLocalFeatures(n.search_type,e,r,o,s);const u=l.addMapControl(e,i.customSearchControl,n.enable,n.position,MapboxGeocoder,c);if(u){u.on("result",(({result:e})=>{var i=document.createElement("div");i.innerHTML=e.place_name;jQuery(u._inputEl).val(i.innerHTML);const n=a.find((t=>t.mapsterProperties.id===e.id));n&&n.mapsterProperties.data.enable_popup&&n.setPopup(new t.Popup(l.returnPopupOptions(n.mapsterProperties.data)).setHTML(l.getPopupHTML(n.mapsterProperties.id,n.mapsterProperties.data))).togglePopup()}));return u}}}setFilterDropdownControl({map:e,mapLibrary:t,controls:i,filter_dropdown:n,locations:r,lines:o,polygons:s,markers:a}){const l=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var c={mapboxgl:t,localGeocoderOnly:!0,marker:!1,placeholder:n.placeholder,minLength:0,limit:1e3,localGeocoder:e=>l.searchLocalFeatures("exact-match",e,r,o,s)};const u=l.addMapControl(e,i.filterDropdownControl,n.enable,n.position,MapboxGeocoder,c);if(u){n.enable&&l.modifyDropdown(u);u.on("result",(e=>{const i=a.find((t=>t.mapsterProperties.id===e.result.id));i&&i.mapsterProperties.data.enable_popup&&i.setPopup(new t.Popup(l.returnPopupOptions(i.mapsterProperties.data)).setHTML(l.getPopupHTML(i.mapsterProperties.id,i.mapsterProperties.data))).togglePopup()}))}return u}}setCategoryFilterControl({map:e,mapLibrary:t,controls:i,cluster_options:n,category_filter:r,markers:o,dataLayers:s,locations:a,lines:l,polygons:c,map_provider:u,label_icon_clustering:h,circle_clustering:p,marker_clustering:d}){new MapsterHelpers;const f={functionality:r.functionality,independent_children:r.independent_children,initial_visibility:r.initial_visibility,category_display:r.category_display,checkbox_display:r.checkbox_display,pre_selected_categories:r.pre_selected_categories,additional_filters:r.additional_filters,accordion_layout:r.accordion_layout,excluded_categories:r.excluded_categories,show_number_of_features:r.show_number_of_features};i.categoryFilterControl&&e.removeControl(i.categoryFilterControl);if(r.enable){const t=new CategoryControl(f,n,o,s,a,l,c,u,p,h,d);""!==r.render_in_external_div&&document.getElementById(r.render_in_external_div)?document.getElementById(r.render_in_external_div).appendChild(t.onAdd(e)):e.addControl(t,r.position);return t}return!1}setListControl({map:e,mapLibrary:t,controls:i,list:n,locations:r,lines:o,polygons:s,markers:a}){new MapsterHelpers;i.listControl&&e.removeControl(i.listControl);if(n.enable){const i=new ListControl(n,r,o,s,a,t);e.addControl(i,n.position);return i}return!1}setDownloadControl({map:e,mapLibrary:t,controls:i,download_control:n,locations:r,lines:o,polygons:s}){
|
||
}setCustomHTMLControl({map:e,mapLibrary:t,controls:i,custom_html_control:n}){
|
||
}setLayerControl({map:e,mapLibrary:t,controls:i,layer_control:n}){
|
||
}setStyleControl({map:e,mapLibrary:t,controls:i,style_control:n}){
|
||
}setListingPosts({post_id:e,map:t,listing_page:i,locations:n,lines:r,polygons:o}){
|
||
}setJqueryEvents(){
|
||
}}class MapsterContainer{constructor(e,t,i){this.core={};this.MapsterMap=i;this.post_id=e;this.single_feature_id=t;this.postResponse;this.mapLibrary;this.markers=[];this.controls=[];this.clusterLayers=[];this.clickedEvent;this.clickedFeature;this.clickedPopup;this.clickedMarker;this.hoveredEvent;this.hoveredFeature;this.hoveredPopup;this.hoveredMarker;this.tempHoverMarker;this.map;this.postResponseAdmin;this.adminFeatures;this.dataLayers;this.defineCore()}defineCore(){const e=new MapsterCore;this.core.set_accesstokendefault={args:[],hook:"access_token_set",func:e.setDefaultAccessToken};this.core.define_postResponse={args:["post_id","single_feature_id"],hook:"data_fetched",func:e.getPostData,promise:!0};this.core.set_mapSize={args:["post_id","postResponse.map.layout"],hook:"map_size_set",func:e.setMapSize};this.core.define_mapLibrary={args:["postResponse.map.map_type"],hook:"map_library_set",func:e.setMapType};this.core.set_submissionModal={args:["post_id","map","mapLibrary","postResponse.map.submission"],hook:"submission_modal_initialized",func:e.setSubmissionModal};this.core.define_map={args:["post_id","mapLibrary","postResponse.map","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_set",func:e.setMap};this.core.set_moveendVariables={args:["map"],hook:"map_moveend",func:e.setMapMoveEndVariables};this.core.set_jquery_events={args:[],hook:"jquery_events_set",func:e.setJqueryEvents};this.core.set_loader={args:["post_id"],hook:"loading_icon_started",func:e.setLoader};this.core.set_loaderdone={args:["post_id"],hook:"loading_icon_done",func:e.setLoaderDone};this.core.set_mapresize={args:["map"],hook:"map_resize_set",func:e.setMapResize};this.core.set_listingposts={args:["post_id","map","postResponse.map.listing_page","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_set_listing_posts",func:e.setListingPosts};this.core.define_dataLayers={args:["map","postResponse.map.map_type.map_provider","dataLayers","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_datalayers_set",func:e.setDataLayers,callback:this.MapsterMap.setDataLayerEvents};this.core.set_mapfeatures={args:["map","postResponse.map.map_type.map_provider","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_features_set",func:e.setFeaturesToMap,callback:this.MapsterMap.setLayerEvents};this.core.define_markers={args:["map","markers","mapLibrary","postResponse.locations","postResponse.map.marker_clustering"],hook:"map_markers_set",func:e.setMarkersToMap,callback:this.MapsterMap.setMarkerEvents};this.core.set_heatmap={args:["map","markers","postResponse.locations","postResponse.map.heatmap"],hook:"map_heatmap_set",func:e.setHeatmap};this.core["define_controls.elevationControl"]={args:["map","mapLibrary","controls","postResponse.map.elevation_line_chart","post_id","postResponse.lines"],hook:"elevation_control_set",func:e.setElevationControl};this.core["define_controls.zoomControl"]={args:["map","mapLibrary","controls","postResponse.map.zoom_control"],hook:"zoom_control_set",func:e.setZoomControl};this.core["define_controls.attributionControl"]={args:["map","mapLibrary","controls","postResponse.map.attribution_control","postResponse.map.map_type"],hook:"attribution_control_set",func:e.setAttributionControl};this.core["define_controls.streetViewControl"]={args:["map","mapLibrary","controls","postResponse.map.street_view_control"],hook:"street_view_control_set",func:e.setStreetViewControl};this.core["define_controls.mapTypeControl"]={args:["map","mapLibrary","controls","postResponse.map.map_type_control"],hook:"map_type_control_set",func:e.setMapTypeControl};this.core["define_controls.geocoderControl"]={args:["map","mapLibrary","controls","postResponse.map.geocoder_control"],hook:"geocoder_control_set",func:e.setGeocoderControl};this.core["define_controls.directionsControl"]={args:["map","mapLibrary","controls","postResponse.map.directions_control"],hook:"directions_control_set",func:e.setDirectionsControl};this.core["define_controls.3dControl"]={args:["map","mapLibrary","controls","postResponse.map.3d_control"],hook:"3d_control_set",func:e.set3DControl};this.core["define_controls.scaleControl"]={args:["map","mapLibrary","controls","postResponse.map.scale_control"],hook:"scale_control_set",func:e.setScaleControl};this.core["define_controls.geolocationControl"]={args:["map","mapLibrary","controls","postResponse.map.geolocation_control"],hook:"geolocation_control_set",func:e.setGeolocationControl};this.core["define_controls.fullscreenControl"]={args:["map","mapLibrary","controls","postResponse.map.fullscreen_control"],hook:"fullscreen_control_set",func:e.setFullscreenControl};this.core["define_controls.downloadControl"]={args:["map","mapLibrary","controls","postResponse.map.download_control","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"download_control_set",func:e.setDownloadControl};this.core["define_controls.customHTMLControl"]={args:["map","mapLibrary","controls","postResponse.map.custom_html_control"],hook:"custom_html_control_set",func:e.setCustomHTMLControl};this.core["define_controls.layerControl"]={args:["map","mapLibrary","controls","postResponse.map.layer_control"],hook:"layer_control_set",func:e.setLayerControl};this.core["define_controls.styleControl"]={args:["map","mapLibrary","controls","postResponse.map.style_control"],hook:"style_control_set",func:e.setStyleControl};this.core["define_controls.customSearchControl"]={args:["map","mapLibrary","controls","postResponse.map.filter.custom_search_filter","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"customSearch_control_set",func:e.setCustomSearchFilterControl};this.core["define_controls.filterDropdownControl"]={args:["map","mapLibrary","controls","postResponse.map.filter.filter_dropdown","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"filterDropdown_control_set",func:e.setFilterDropdownControl};this.core["define_controls.categoryFilterControl"]={args:["map","mapLibrary","controls","postResponse.map.cluster_options","postResponse.map.filter.category_filter","markers","dataLayers","postResponse.locations","postResponse.lines","postResponse.polygons","postResponse.map.map_type.map_provider","postResponse.map.circle_clustering","postResponse.map.label_icon_clustering","postResponse.map.marker_clustering"],hook:"categoryFilter_control_set",func:e.setCategoryFilterControl};this.core["define_controls.listControl"]={args:["map","mapLibrary","controls","postResponse.map.list","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"list_control_set",func:e.setListControl};this.core.define_clusterLayers={args:["map","postResponse.map.map_type.map_provider","postResponse.map.cluster_options","postResponse.map.circle_clustering","postResponse.map.label_icon_clustering","postResponse.map.marker_clustering","markers","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_clustering_set",func:e.doClustering,callback:this.MapsterMap.setDynamicLayerEvents};this.core.set_customscripts={args:["map","postResponse.map.javascript","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"custom_scripts_set",func:e.loadCustomScripts};this.core.set_interactivity={args:["map","postResponse.map.zoom_on_scroll","postResponse.map.interactivity","postResponse.map.allow_rotation_and_pitch"],hook:"interactivity_set",func:e.setInteractivity};this.core.set_mapstyle={args:["map","postResponse.map.map_type"],hook:"map_style_set",func:e.setMapStyle,callback:this.MapsterMap.idleReload};this.core.set_terrain={args:["map","postResponse.map.map_type.map_provider","postResponse.map.map_type.terrain"],hook:"map_terrain_set",func:e.loadTerrain};this.core.set_projection={args:["map","postResponse.map.map_type.map_provider","postResponse.map.map_type.projection"],hook:"map_projection_set",func:e.loadProjection};this.core.define_clickedFeature={args:["map","postResponse.map.interactivity","clickedEvent","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"layer_feature_clicked",func:e.layerClick};this.core.set_storelocatorclick={args:["clickedFeature","postResponse.map.list.store_locator_options"],hook:"",func:e.storeLocatorClick};this.core.set_sidebarclick={args:["post_id","clickedFeature","postResponse.map.minimum_sidebar_width","postResponse.map.maximum_sidebar_width","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"",func:e.sidebarClick};this.core.define_clickedPopup={args:["map","mapLibrary","clickedPopup","clickedFeature","clickedEvent","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_layer_click",func:e.popupClick};this.core.define_hoveredFeature={args:["map","postResponse.map.interactivity","hoveredEvent","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"layer_feature_hovered",func:e.layerHover};this.core.set_hoverEffects={args:["map","postResponse.map.interactivity","hoveredFeature","dataLayers"],hook:"",func:e.layerHoverEffect};this.core.define_hoveredPopup={args:["map","mapLibrary","hoveredPopup","hoveredFeature","hoveredEvent","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_layer_hover",func:e.popupHover};this.core.set_hoverEffectsOff={args:["map","postResponse.map.interactivity","hoveredFeature","dataLayers"],hook:"",func:e.layerHoverEffectOff};this.core.set_hoveredPopupOff={args:["hoveredFeature","hoveredPopup"],hook:"popup_closed_from_layer_hover",func:e.removePopupHover};this.core.set_externallink={args:["clickedFeature"],hook:"external_link_opened",func:e.externalClickLayer};this.core.define_clickedFeature_fromMarker={args:["clickedMarker","postResponse.map.interactivity"],hook:"marker_feature_clicked",func:e.markerClick};this.core.define_hoveredFeature_fromMarker={args:["hoveredMarker","postResponse.map.interactivity"],hook:"marker_feature_hovered",func:e.markerHover};this.core.define_tempHoverMarker={args:["map","mapLibrary","postResponse.map.interactivity","hoveredMarker"],hook:"",func:e.markerHoverEffect};this.core.define_clickedPopup_fromMarker={args:["map","mapLibrary","clickedMarker","clickedFeature","clickedPopup","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_marker_click",func:e.openMarkerClickPopup};this.core.define_hoveredPopup_fromMarker={args:["map","mapLibrary","hoveredMarker","hoveredFeature","hoveredPopup"],hook:"popup_opened_from_marker_hover",func:e.openMarkerHoverPopup};this.core.set_hoverEffectsOff_fromMarker={args:["tempHoverMarker","hoveredMarker"],hook:"",func:e.markerHoverEffectOff};this.core.set_hoveredPopupOff_fromMarker={args:["hoveredMarker","hoveredFeature","hoveredPopup"],hook:"popup_closed_from_marker_hover",func:e.removeMarkerHoverPopup};this.core.define_adminFeatures={args:["postResponseAdmin.locations_ids","postResponseAdmin.lines_ids","postResponseAdmin.polygons_ids","postResponse.cats"],hook:"",func:e.getFeaturesAdmin,promise:!0};this.core["define_postResponse.locations"]={args:["adminFeatures"],hook:"locations_fetched",func:e.sortLocations};this.core["define_postResponse.lines"]={args:["adminFeatures"],hook:"lines_fetched",func:e.sortLines};this.core["define_postResponse.polygons"]={args:["adminFeatures"],hook:"polygons_fetched",func:e.sortPolygons}}doCore(e){let t=this.core[e].args,i=this.core[e].func,n={};for(var r=0;r<t.length;r++){let e=t[r].split(".");n[e[e.length-1]]=this.getObjectProperty(this,t[r])}if(this.core[e].promise)return Promise.resolve(i(n)).then((t=>{this.defineThisObject(e,t);this.core[e].callback&&this.core[e].callback(this,this.MapsterMap);this.core[e].hook&&this.MapsterMap.runHookActions(e,t)}));{const t=i(n);this.defineThisObject(e,t);this.core[e].callback&&this.core[e].callback(this,this.MapsterMap);this.core[e].hook&&this.MapsterMap.runHookActions(e,t);return t}}registerListener(e,t,i,n){this.setStarterValue(e,t,i);jQuery(document).on("change","select"!==t?e:e.replace("select",":input"),(()=>{"check"===t&&this.setObjectProperty(this,i,jQuery(e).is(":checked"));"val"===t&&this.setObjectProperty(this,i,jQuery(e).val());"select"===t&&this.setObjectProperty(this,i,jQuery(e).select2("data").map((e=>e.id)));if(n&&n.length>0)for(var r=0;r<n.length;r++){if(this.core[n[r]].promise){this.MapsterMap.doCoreAndRunActions(n[r]).then((()=>{for(var e=r+1;e<n.length;e++)this.MapsterMap.doCoreAndRunActions(n[e])}));break}this.MapsterMap.doCoreAndRunActions(n[r])}}))}setStarterValue(e,t,i){"check"===t&&this.setObjectProperty(this,i,jQuery(e).is(":checked"));"val"===t&&this.setObjectProperty(this,i,jQuery(e).val());"select"===t&&this.setObjectProperty(this,i,jQuery(e).select2("data").map((e=>e.id)))}defineThisObject(e,t){e.indexOf("define_")>-1&&this.setObjectProperty(this,e.split("_")[1],t)}getObjectProperty(e,t){return t.split(".").reduce(((e,t)=>e?.[t]),e)}setObjectProperty(e,t,i){t.split(".").reduce(((e,n)=>{n===t.split(".")[t.split(".").length-1]&&(e[n]=i);void 0===e[n]&&(n===t.split(".")[t.split(".").length-1]?e[n]="":e[n]={});return e?.[n]}),e)}}class MapsterMap{constructor(e,t,i){this.MapsterContainer=new MapsterContainer(e,i,this);this.post_id=e;this.isPublic=t;this.dynamicLayerListenersSet=!1;this.isPublic||this.registerAdminEventListeners()}preInitMap(){return this.isPublic?this.doCoreAndRunActions("define_postResponse"):this.doCoreAndRunActions("define_adminFeatures")}init(){this.preInitMap().then((()=>{if(!this.isPublic){this.doCoreAndRunActions("set_accesstokendefault");this.doCoreAndRunActions("define_postResponse.locations");this.doCoreAndRunActions("define_postResponse.lines");this.doCoreAndRunActions("define_postResponse.polygons")}this.initMap();this.MapsterContainer.map.on("load",(()=>{this.postLoad();this.setMoveEvents(this.MapsterContainer.map)}));this.MapsterContainer.map.on("mapster_custom_style_load",(()=>{this.postStyleSwitch(this.MapsterContainer,this)}))}))}initMap(){this.isPublic&&this.doCoreAndRunActions("set_mapSize");this.doCoreAndRunActions("define_mapLibrary");this.doCoreAndRunActions("define_map");this.doCoreAndRunActions("set_jquery_events");this.doCoreAndRunActions("set_loader");if(this.isPublic){this.doCoreAndRunActions("set_submissionModal");this.doCoreAndRunActions("set_interactivity");this.doCoreAndRunActions("set_listingposts")}}postLoad(){this.doCoreAndRunActions("set_mapresize");this.doCoreAndRunActions("set_terrain");this.doCoreAndRunActions("set_mapfeatures");this.doCoreAndRunActions("define_dataLayers");this.doCoreAndRunActions("define_markers");this.doCoreAndRunActions("set_heatmap");this.setControls();this.isPublic&&this.doCoreAndRunActions("define_clusterLayers");this.doCoreAndRunActions("set_loaderdone");this.doCoreAndRunActions("set_customscripts")}setControls(){this.doCoreAndRunActions("define_controls.zoomControl");this.doCoreAndRunActions("define_controls.mapTypeControl");this.doCoreAndRunActions("define_controls.streetViewControl");this.doCoreAndRunActions("define_controls.attributionControl");this.doCoreAndRunActions("define_controls.geocoderControl");this.doCoreAndRunActions("define_controls.directionsControl");this.doCoreAndRunActions("define_controls.3dControl");this.doCoreAndRunActions("define_controls.scaleControl");this.doCoreAndRunActions("define_controls.geolocationControl");this.doCoreAndRunActions("define_controls.fullscreenControl");this.doCoreAndRunActions("define_controls.downloadControl");this.doCoreAndRunActions("define_controls.customHTMLControl");this.doCoreAndRunActions("define_controls.layerControl");this.doCoreAndRunActions("define_controls.styleControl");this.doCoreAndRunActions("define_controls.customSearchControl");this.doCoreAndRunActions("define_controls.filterDropdownControl");this.doCoreAndRunActions("define_controls.categoryFilterControl");this.doCoreAndRunActions("define_controls.elevationControl");this.doCoreAndRunActions("define_controls.listControl")}idleReload(e,t){e.map.once("idle",(()=>{t.doCoreAndRunActions("set_loader");t.doCoreAndRunActions("set_terrain");t.doCoreAndRunActions("set_mapfeatures");t.doCoreAndRunActions("define_dataLayers");t.doCoreAndRunActions("define_markers");t.doCoreAndRunActions("define_clusterLayers");t.doCoreAndRunActions("set_loaderdone")}))}postStyleSwitch(e,t){e.map.once("idle",(()=>{t.doCoreAndRunActions("set_terrain");t.doCoreAndRunActions("set_mapfeatures");t.doCoreAndRunActions("define_dataLayers");t.doCoreAndRunActions("define_markers");t.doCoreAndRunActions("define_clusterLayers")}))}setLayerEvents(e,t){["symbol","circle","line","fill"].forEach((i=>{e.map.on("click",i,(i=>{e.clickedEvent=i;t.doCoreAndRunActions("define_clickedFeature");t.doCoreAndRunActions("set_storelocatorclick");t.doCoreAndRunActions("set_sidebarclick");t.doCoreAndRunActions("set_externallink");t.doCoreAndRunActions("define_clickedPopup")}));e.map.on("mousemove",i,(i=>{e.hoveredEvent=i;t.doCoreAndRunActions("define_hoveredFeature");t.doCoreAndRunActions("set_hoverEffects");t.doCoreAndRunActions("define_hoveredPopup")}));e.map.on("mouseout",i,(e=>{t.doCoreAndRunActions("set_hoverEffectsOff");t.doCoreAndRunActions("set_hoveredPopupOff")}))}))}setDynamicLayerEvents(e,t){if(e.clusterLayers.length>0&&!this.dynamicLayerListenersSet){e.clusterLayers.forEach((i=>{if(i.indexOf("-")>-1){e.map.on("click",i,(i=>{e.clickedEvent=i;t.doCoreAndRunActions("define_clickedFeature");t.doCoreAndRunActions("set_storelocatorclick");t.doCoreAndRunActions("set_sidebarclick");t.doCoreAndRunActions("set_externallink");t.doCoreAndRunActions("define_clickedPopup")}));e.map.on("mousemove",i,(i=>{e.hoveredEvent=i;t.doCoreAndRunActions("define_hoveredFeature");t.doCoreAndRunActions("set_hoverEffects");t.doCoreAndRunActions("define_hoveredPopup")}));e.map.on("mouseout",i,(e=>{t.doCoreAndRunActions("set_hoverEffectsOff");t.doCoreAndRunActions("set_hoveredPopupOff")}))}}));this.dynamicLayerListenersSet=!0}}setDataLayerEvents(e,t){}setMarkerEvents(e,t){e.markers.forEach((i=>{i.getElement().addEventListener("click",(()=>{e.clickedMarker=i;t.doCoreAndRunActions("define_clickedFeature_fromMarker");t.doCoreAndRunActions("set_storelocatorclick");t.doCoreAndRunActions("set_sidebarclick");t.doCoreAndRunActions("set_externallink");t.doCoreAndRunActions("define_clickedPopup_fromMarker")}));i.getElement().addEventListener("mouseenter",(n=>{e.hoveredMarker=i;t.doCoreAndRunActions("define_hoveredFeature_fromMarker");t.doCoreAndRunActions("define_tempHoverMarker");t.doCoreAndRunActions("define_hoveredPopup_fromMarker")}));i.getElement().addEventListener("mouseleave",(e=>{t.doCoreAndRunActions("set_hoverEffectsOff_fromMarker");t.doCoreAndRunActions("set_hoveredPopupOff_fromMarker")}))}))}setMoveEvents(e){if(!this.isPublic){e.once("idle",(e=>{this.doCoreAndRunActions("set_moveendVariables")}));e.on("moveend",(e=>{this.doCoreAndRunActions("set_moveendVariables")}))}}doCoreAndRunActions(e){return this.MapsterContainer.doCore(e)}runHookActions(e,t){if(window.mwm){let n=this.MapsterContainer.core[e].hook;const r=`${n}/mapster-${this.isPublic?this.post_id:"admin"}`;if(window.mwm.actions[r]){window.mwm.actions[r].funcs;if(window.mwm.actions[r].funcs.length>0)for(var i=0;i<window.mwm.actions[r].funcs.length;i++)window.mwm.actions[r].funcs[i].func(t)}if(window.mwm.actions[n]){window.mwm.actions[n].funcs;if(window.mwm.actions[n].funcs.length>0)for(i=0;i<window.mwm.actions[n].funcs.length;i++)window.mwm.actions[n].funcs[i].func(t)}}}registerAdminEventListeners(){this.MapsterContainer.registerListener('.acf-field[data-name="zoom_on_scroll"] :input',"check","postResponse.map.zoom_on_scroll");this.MapsterContainer.registerListener('.acf-field[data-name="interactivity"] :input',"check","postResponse.map.interactivity");this.MapsterContainer.registerListener('.acf-field[data-name="open_popups_in_sidebar"] :input',"check","postResponse.map.open_popups_in_sidebar");this.MapsterContainer.registerListener('.acf-field[data-name="restrict_movement"] :input',"check","postResponse.map.restricted_movement.restrict_movement");this.MapsterContainer.registerListener('.acf-field[data-name="southwest_longitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.southwest_longitude");this.MapsterContainer.registerListener('.acf-field[data-name="southwest_latitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.southwest_latitude");this.MapsterContainer.registerListener('.acf-field[data-name="northeast_longitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.northeast_longitude");this.MapsterContainer.registerListener('.acf-field[data-name="northeast_latitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.northeast_latitude");this.MapsterContainer.registerListener('.acf-field[data-name="min_zoom"] :input',"val","postResponse.map.restricted_movement.allowed_zoom.min_zoom");this.MapsterContainer.registerListener('.acf-field[data-name="max_zoom"] :input',"val","postResponse.map.restricted_movement.allowed_zoom.max_zoom");this.MapsterContainer.registerListener('.acf-field[data-name="zoom_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.zoom_control.enable",["define_controls.zoomControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="zoom_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.zoom_control.position",["define_controls.zoomControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="3d_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.3d_control.enable",["define_controls.3dControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="3d_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.3d_control.position",["define_controls.3dControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="scale_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.scale_control.enable",["define_controls.scaleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="scale_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.scale_control.position",["define_controls.scaleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="attribution_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.attribution_control.position",["define_controls.attributionControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geolocation_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.geolocation_control.enable",["define_controls.geolocationControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geolocation_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.geolocation_control.position",["define_controls.geolocationControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geolocation_control"] .acf-field[data-name="set_on_load"] :input',"check","postResponse.map.geolocation_control.set_on_load",["define_controls.geolocationControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="fullscreen_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.fullscreen_control.enable",["define_controls.fullscreenControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="fullscreen_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.fullscreen_control.position",["define_controls.fullscreenControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="street_view_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.street_view_control.enable",["define_controls.streetViewControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="street_view_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.street_view_control.position",["define_controls.streetViewControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_type_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.map_type_control.enable",["define_controls.mapTypeControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_type_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.map_type_control.position",["define_controls.mapTypeControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.download_control.enable",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.download_control.position",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="interact_with_filters"] :input',"check","postResponse.map.download_control.interact_with_filters",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="notify_on_download"] :input',"val","postResponse.map.download_control.notify_on_download",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_html_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.custom_html_control.enable",["define_controls.customHTMLControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_html_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.custom_html_control.position",["define_controls.customHTMLControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_html_control"] .acf-field[data-name="custom_html"] :input',"val","postResponse.map.custom_html_control.custom_html",["define_controls.customHTMLControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.layer_control.enable",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.layer_control.position",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="toggleable_layers"] :input',"val","postResponse.map.layer_control.toggleable_layers",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="toggleable_layer_titles"] :input',"val","postResponse.map.layer_control.toggleable_layer_titles",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="checkbox_type"] :input',"val","postResponse.map.layer_control.checkbox_type",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.style_control.enable",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.style_control.position",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="toggleable_styles"] :input',"val","postResponse.map.style_control.toggleable_styles",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="toggleable_styles_titles"] :input',"val","postResponse.map.style_control.toggleable_styles_titles",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="initial_style_title"] :input',"val","postResponse.map.style_control.initial_style_title",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.geocoder_control.enable",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.geocoder_control.position",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="limit_results"] :input',"val","postResponse.map.geocoder_control.limit_results",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="placeholder"] :input',"val","postResponse.map.geocoder_control.placeholder",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.directions_control.enable",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.directions_control.position",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="unit"] :input',"val","postResponse.map.directions_control.unit",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="profile"] :input',"val","postResponse.map.directions_control.profile",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="placeholderOrigin"] :input',"val","postResponse.map.directions_control.placeholderOrigin",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="enable"] :input',"check","postResponse.map.filter.custom_search_filter.enable",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="position"] :input',"val","postResponse.map.filter.custom_search_filter.position",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="include_geocoder"] :input',"check","postResponse.map.filter.custom_search_filter.include_geocoder",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="limit_results"] :input',"val","postResponse.map.filter.custom_search_filter.limit_results",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="number_of_results"] :input',"val","postResponse.map.filter.custom_search_filter.number_of_results",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="placeholder"] :input',"val","postResponse.map.filter.custom_search_filter.placeholder",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="filter_dropdown"] .acf-field[data-name="enable"] :input',"check","postResponse.map.filter.filter_dropdown.enable",["define_controls.filterDropdownControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="filter_dropdown"] .acf-field[data-name="position"] :input',"val","postResponse.map.filter.filter_dropdown.position",["define_controls.filterDropdownControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="filter_dropdown"] .acf-field[data-name="placeholder"] :input',"val","postResponse.map.filter.filter_dropdown.placeholder",["define_controls.filterDropdownControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="enable"] :input',"check","postResponse.map.filter.category_filter.enable",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="position"] :input',"val","postResponse.map.filter.category_filter.position",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="initial_visibility"] :input',"check","postResponse.map.filter.category_filter.initial_visibility",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="functionality"] :input',"val","postResponse.map.filter.category_filter.functionality",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="independent_children"] :input',"check","postResponse.map.filter.category_filter.independent_children",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="category_display"] :input',"val","postResponse.map.filter.category_filter.category_display",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="checkbox_display"] :input',"val","postResponse.map.filter.category_filter.checkbox_display",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="pre_selected_categories"] :input',"val","postResponse.map.filter.category_filter.pre_selected_categories",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="enable"] :input',"check","postResponse.map.list.enable",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="position"] :input',"val","postResponse.map.list.position",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="units"] :input',"val","postResponse.map.list.units",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="show_distance"] :input',"check","postResponse.map.list.show_distance",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="sort_by_distance"] :input',"check","postResponse.map.list.sort_by_distance",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="listing_type"] :input',"val","postResponse.map.list.listing_type",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="number_of_locations"] :input',"val","postResponse.map.list.number_of_locations",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="store_locator_options"] .acf-field[data-name="enable"] :input',"check","postResponse.map.list.store_locator_options.enable",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="store_locator_options"] .acf-field[data-name="sort_hours_by_day"] :input',"check","postResponse.map.list.store_locator_options.sort_hours_by_day",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="locations"] select',"select","postResponseAdmin.locations_ids",["define_adminFeatures","define_postResponse.locations","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="lines"] select',"select","postResponseAdmin.lines_ids",["define_adminFeatures","define_postResponse.lines","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="polygons"] select',"select","postResponseAdmin.polygons_ids",["define_adminFeatures","define_postResponse.polygons","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="add_by_category"] select',"select","postResponse.cats",["define_adminFeatures","define_postResponse.locations","define_postResponse.lines","define_postResponse.polygons","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="manual_latitude"] :input',"val","postResponse.map.view.manual_latitude");this.MapsterContainer.registerListener('.acf-field[data-name="manual_longitude"] :input',"val","postResponse.map.view.manual_longitude");this.MapsterContainer.registerListener('.acf-field[data-name="manual_zoom"] :input',"val","postResponse.map.view.manual_zoom");this.MapsterContainer.registerListener('.acf-field[data-name="manual_pitch"] :input',"val","postResponse.map.view.manual_pitch");this.MapsterContainer.registerListener('.acf-field[data-name="manual_rotation"] :input',"val","postResponse.map.view.manual_rotation");this.MapsterContainer.registerListener('.acf-field[data-name="initial_load"] :input',"val","postResponse.map.view.initial_load");this.MapsterContainer.registerListener('.acf-field[data-name="circle_clustering"] :input',"check","postResponse.map.circle_clustering");this.MapsterContainer.registerListener('.acf-field[data-name="label_icon_clustering"] :input',"check","postResponse.map.label_icon_clustering");this.MapsterContainer.registerListener('.acf-field[data-name="enable_heatmap"] :input',"check","postResponse.map.heatmap.enable_heatmap",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_layer"] :input',"val","postResponse.map.heatmap.heatmap_layer",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_layer_visibility"] :input',"val","postResponse.map.heatmap.heatmap_layer_visibility",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_weighted_property"] :input',"val","postResponse.map.heatmap.heatmap_weighted_property",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_intensity"] :input',"val","postResponse.map.heatmap.heatmap_intensity",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_color_range"] :input',"val","postResponse.map.heatmap.heatmap_color_range",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_point_radius"] :input',"val","postResponse.map.heatmap.heatmap_point_radius",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_opacity"] :input',"val","postResponse.map.heatmap.heatmap_opacity",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="enable_elevation_chart"] :input',"check","postResponse.map.elevation_line_chart.enable_elevation_chart");this.MapsterContainer.registerListener('.acf-field[data-name="map_provider"] :input',"val","postResponse.map.map_type.map_provider",["define_mapLibrary"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_tile_style_access_token"] :input',"val","postResponse.map.map_type.map_tile_style_access_token",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_tile_style_no_access_token"] :input',"val","postResponse.map.map_type.map_tile_style_no_access_token",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="access_token"] :input',"val","postResponse.map.map_type.access_token");this.MapsterContainer.registerListener('.acf-field[data-name="custom_mapbox_style"] :input',"val","postResponse.map.map_type.custom_mapbox_style",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_style_json"] :input',"val","postResponse.map.map_type.custom_style_json",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="snazzy_map_style"] :input',"val","postResponse.map.map_type.snazzy_map_style",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_image"] :input',"val","postResponse.map.map_type.custom_image",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="duplicate_horizontally"] :input',"check","postResponse.map.layout.duplicate_horizontally");this.MapsterContainer.registerListener('.acf-field[data-name="terrain"] :input',"check","postResponse.map.map_type.terrain",["set_terrain"]);this.MapsterContainer.registerListener('.acf-field[data-name="projection"] :input',"val","postResponse.map.map_type.projection",["set_projection"]);this.MapsterContainer.registerListener('.acf-field[data-name="globe"] :input',"check","postResponse.map.map_type.globe",[]);this.MapsterContainer.registerListener('.acf-field[data-name="globe_background"] :input',"val","postResponse.map.map_type.globe_background",[])}}class MapsterPublic{constructor(){this.actions={}}add_action(e,t){this.actions[e]||(this.actions[e]={funcs:[]});this.actions[e].funcs.push({func:t})}}window.mwm=new MapsterPublic;!function(e){if(window.mapster_params.public)(o=".mapster-wp-maps",new Promise((e=>{if(document.querySelector(o))return e(document.querySelector(o));const t=new MutationObserver((i=>{if(document.querySelector(o)){e(document.querySelector(o));t.disconnect()}}));t.observe(document.body,{childList:!0,subtree:!0})}))).then((t=>{e(".mapster-wp-maps").each((function(){const t=e(this).attr("id").replace("mapster-wp-maps-",""),i=""!==e(this).data("single_feature_id")&&e(this).data("single_feature_id");new MapsterMap(t,window.mapster_params.public,i).init()}))}));else{let s="Publish this post to generate an embed code.";const a=new URLSearchParams(window.location.search);if(a.has("post")){let c=window.mapster_params.directory.replace("/admin/","/admin/includes/mapster-embed-map.php");c=c+window.mapster_params.qd+"map_id="+a.get("post");s=`<embed src="${c}" />`}let l="Publish this post to generate an listing code.";a.has("post")&&(l=`[mapster_listing_posts id="${a.get("post")}"]`);if(document.body.classList.contains("block-editor-page")){e("#mapster-wp-maps-preview").prependTo("#normal-sortables");e(".acf-field-625df5ebf4ecc .acf-input").text(s);e(".acf-field-6507ba6e3053a .acf-input").text(l)}else{e("#mapster-wp-maps-preview").prependTo("#acf_after_title-sortables");e(".acf-field-625df5ebf4ecc .acf-input").text(s);e(".acf-field-6507ba6e3053a .acf-input").text(l)}if(a.has("post")){let u=`\n [mapster_wp_map_submit map_id="${a.get("post")}" type="create_point"]<br />\n [mapster_wp_map_submit map_id="${a.get("post")}" type="edit_point" button_text="Edit Point" header_text="Edit Point"]\n `;e(".acf-field-62bf86b094491 .acf-input").append(u)}var t=acf.getFields().length,i=0,n=0;function r(e){"select"!==e&&(i+=1);i===t&&4===n&&new MapsterMap("map",window.mapster_params.public,!1).init()}acf.add_action("ready_field",r);acf.addAction("select2_init",(function(e,t,i,o){n+=1;r("select")}))}var o}(jQuery); |