7138 lines
3.0 MiB
Plaintext
7138 lines
3.0 MiB
Plaintext
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.maplibregl=r())})(e,(function(){var e={},t={};function n(n,r,i){if(t[n]=i,n===`index`){var a=`var sharedModule = {}; (`+t.shared+`)(sharedModule); (`+t.worker+`)(sharedModule);`,o={};return t.shared(o),t.index(e,o),typeof window<`u`&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([a],{type:`text/javascript`}))),e}}return n(`shared`,[`exports`],(function(e){function t(e,t,n,r){return new(n||=Promise)((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){this.x=e,this.y=t}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var i,a;n.prototype={clone(){return new n(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let 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(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround(e,t){let n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:n},n.convert=function(e){if(e instanceof n)return e;if(Array.isArray(e))return new n(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new n(+e.x,+e.y);throw Error(`Expected [x, y] or {x, y} point format`)};var o=r(function(){if(a)return i;function e(e,t,n,r){this.cx=3*e,this.bx=3*(n-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=n,this.p2y=r}return a=1,i=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(t===void 0&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=i/a}var o=0,s=1;for(n=e,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-e)<t));r++)e>i?o=n:s=n,n=.5*(s-o)+o;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},i}());let s,c;function l(){return s??=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)&&typeof createImageBitmap==`function`,s}function u(){if(c==null&&(c=!1,l())){let e=new OffscreenCanvas(5,5).getContext(`2d`,{willReadFrequently:!0});if(e){for(let t=0;t<25;t++){let n=4*t;e.fillStyle=`rgb(${n},${n+1},${n+2})`,e.fillRect(t%5,Math.floor(t/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let e=0;e<100;e++)if(e%4!=3&&t[e]!==e){c=!0;break}}}return c||!1}var d=1e-6,f=typeof Float32Array<`u`?Float32Array:Array;function p(){var e=new f(9);return f!=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 m(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 h(){var e=new f(3);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function g(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function _(e,t,n){var r=new f(3);return r[0]=e,r[1]=t,r[2]=n,r}function v(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function y(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function b(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-a*s,e[1]=a*o-r*c,e[2]=r*s-i*o,e}var x,S=g;function C(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}function w(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function T(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`zyx`,a=Math.PI/360;t*=a,r*=a,n*=a;var o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=Math.sin(r),d=Math.cos(r);switch(i){case`xyz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`xzy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d+o*c*u;break;case`yxz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;case`yzx`:e[0]=o*l*d+s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d-o*c*u;break;case`zxy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`zyx`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;default:throw Error(`Unknown angle order `+i)}return e}function E(){var e=new f(2);return f!=Float32Array&&(e[0]=0,e[1]=0),e}function D(e,t){var n=new f(2);return n[0]=e,n[1]=t,n}h(),x=new f(4),f!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),h(),_(1,0,0),_(0,1,0),w(),w(),p(),E();let O=8192;function k(e,t,n){return t*(O/(e.tileSize*2**(n-e.tileID.overscaledZ)))}function A(e){return e instanceof Error?e:Error(typeof e==`string`?e:String(e))}function j(e,t){return(e%t+t)%t}function M(e,t,n){return e*(1-n)+t*n}function N(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function P(e,t,n,r){let i=new o(e,t,n,r);return e=>i.solve(e)}let F=P(.25,.1,.25,1);function ee(e,t,n){return Math.min(n,Math.max(t,e))}function I(e,t,n){let r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function L(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}let te=1;function ne(e,t,n){let r={};for(let n in e)r[n]=t.call(this,e[n],n,e);return r}function R(e,t,n){let r={};for(let n in e)t.call(this,e[n],n,e)&&(r[n]=e[n]);return r}function re(e){return Array.isArray(e)?e.map(re):typeof e==`object`&&e?ne(e,re):e}let ie={};function ae(e){ie[e]||(typeof console<`u`&&console.warn(e),ie[e]=!0)}function oe(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function se(e){return typeof WorkerGlobalScope<`u`&&e!==void 0&&e instanceof WorkerGlobalScope}let ce=null;function le(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap}let ue=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=`;function de(e,n,r,i,a){return t(this,void 0,void 0,(function*(){if(typeof VideoFrame>`u`)throw Error(`VideoFrame not supported`);let t=new VideoFrame(e,{timestamp:0});try{let o=t?.format;if(!o||!o.startsWith(`BGR`)&&!o.startsWith(`RGB`))throw Error(`Unrecognized format ${o}`);let s=o.startsWith(`BGR`),c=new Uint8ClampedArray(i*a*4);if(yield t.copyTo(c,function(e,t,n,r,i){let a=4*Math.max(-t,0),o=(Math.max(0,n)-n)*r*4+a,s=4*r,c=Math.max(0,t),l=Math.max(0,n);return{rect:{x:c,y:l,width:Math.min(e.width,t+r)-c,height:Math.min(e.height,n+i)-l},layout:[{offset:o,stride:s}]}}(e,n,r,i,a)),s)for(let e=0;e<c.length;e+=4){let t=c[e];c[e]=c[e+2],c[e+2]=t}return c}finally{t.close()}}))}let fe,pe;function me(e,t,n,r){return e.addEventListener(t,n,r),{unsubscribe:()=>{e.removeEventListener(t,n,r)}}}function he(e){return e*Math.PI/180}function ge(e){return e/Math.PI*180}let _e={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ve={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ye=`AbortError`;class be extends Error{constructor(e=ye){super(e instanceof Error?e.message:e),this.name=ye,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function xe(e){return e instanceof Error&&e.name===ye}function Se(e){if(e.aborted)throw new be(e.reason)}let Ce={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:``};function we(e){return Ce.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf(`://`))]}let Te=`global-dispatcher`;class Ee extends Error{constructor(e,t,n,r){super(`AJAXError: ${t} (${e}): ${n}`),this.status=e,this.statusText=t,this.url=n,this.body=r}}let De=()=>se(self)?self.worker?.referrer:(window.location.protocol===`blob:`?window.parent:window).location.href,Oe=function(e,n){return t(this,void 0,void 0,(function*(){if(e.url.includes(`://`)&&!/^https?:|^file:/.test(e.url)){let t=we(e.url);if(t){let r=yield t(e,n);return r.data||e.type!==`arrayBuffer`?r:L(r,{data:new ArrayBuffer(0)})}if(se(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,targetMapId:Te},n)}if(!(e=>e.startsWith(`file:`)||De()?.startsWith(`file:`)&&!/^\w+:/.test(e))(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,`signal`))return function(e,n){return t(this,void 0,void 0,(function*(){let t=new Request(e.url,{method:e.method||`GET`,body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:De(),referrerPolicy:e.referrerPolicy,signal:n.signal}),r,i;e.type!==`json`||t.headers.has(`Accept`)||t.headers.set(`Accept`,`application/json`);try{r=yield fetch(t)}catch(t){throw xe(t)?t:new Ee(0,A(t).message,e.url,new Blob)}if(!r.ok){let t=yield r.blob();throw new Ee(r.status,r.statusText,e.url,t)}i=e.type===`arrayBuffer`||e.type===`image`?r.arrayBuffer():e.type===`json`?r.json():r.text();let a=yield i;return Se(n.signal),{data:a,cacheControl:r.headers.get(`Cache-Control`),expires:r.headers.get(`Expires`),etag:r.headers.get(`ETag`)}}))}(e,n);if(se(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,mustQueue:!0,targetMapId:Te},n)}return function(e,t){return new Promise(((n,r)=>{var i;let a=new XMLHttpRequest;a.open(e.method||`GET`,e.url,!0),e.type!==`arrayBuffer`&&e.type!==`image`||(a.responseType=`arraybuffer`);for(let t in e.headers)a.setRequestHeader(t,e.headers[t]);e.type===`json`&&(a.responseType=`text`,(i=e.headers)!=null&&i.Accept||a.setRequestHeader(`Accept`,`application/json`)),a.withCredentials=e.credentials===`include`,a.onerror=()=>{r(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||a.status===0)&&a.response!==null){let t=a.response;if(e.type===`json`)try{t=JSON.parse(a.response)}catch(e){r(e);return}n({data:t,cacheControl:a.getResponseHeader(`Cache-Control`),expires:a.getResponseHeader(`Expires`),etag:a.getResponseHeader(`ETag`)})}else{let t=new Blob([a.response],{type:a.getResponseHeader(`Content-Type`)});r(new Ee(a.status,a.statusText,e.url,t))}},t.signal.addEventListener(`abort`,(()=>{a.abort(),r(new be(t.signal.reason))})),a.send(e.body)}))}(e,n)}))};function ke(e){if(!e||e.indexOf(`://`)<=0||e.startsWith(`data:image/`)||e.startsWith(`blob:`))return!0;let t=new URL(e),n=window.location;return t.protocol===n.protocol&&t.host===n.host}function Ae(e,t,n){var r;(r=n[e])!=null&&r.includes(t)||(n[e]||(n[e]=[]),n[e].push(t))}function je(e,t,n){if(n?.[e]){let r=n[e].indexOf(t);r!==-1&&n[e].splice(r,1)}}class Me{constructor(e,t={}){L(this,t),this.type=e}}class Ne extends Me{constructor(e,t={}){super(`error`,L({error:e},t))}}class Pe{on(e,t){return this._listeners||={},Ae(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return je(e,t,this._listeners),je(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||={},Ae(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){typeof e==`string`&&(e=new Me(e,t||{}));let n=e.type;if(this.listens(n)){e.target=this;let t=this._listeners?.[n]?this._listeners[n].slice():[];for(let n of t)n.call(this,e);let r=this._oneTimeListeners?.[n]?this._oneTimeListeners[n].slice():[];for(let t of r)je(n,t,this._oneTimeListeners),t.call(this,e);let i=this._eventedParent;i&&(L(e,typeof this._eventedParentData==`function`?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Ne&&console.error(e.error);return this}listens(e){return this._listeners?.[e]?.length>0||this._oneTimeListeners?.[e]?.length>0||this._eventedParent?.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var z={$version:8,$root:{version:{required:!0,type:`enum`,values:[8]},name:{type:`string`},metadata:{type:`*`},center:{type:`array`,value:`number`,length:2},centerAltitude:{type:`number`},zoom:{type:`number`},bearing:{type:`number`,default:0,period:360,units:`degrees`},pitch:{type:`number`,default:0,units:`degrees`},roll:{type:`number`,default:0,units:`degrees`},state:{type:`state`,default:{}},light:{type:`light`},sky:{type:`sky`},projection:{type:`projection`},terrain:{type:`terrain`},sources:{required:!0,type:`sources`},sprite:{type:`sprite`},glyphs:{type:`string`},"font-faces":{type:`fontFaces`},transition:{type:`transition`},layers:{required:!0,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:!0,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:!1},encoding:{type:`enum`,values:{mvt:{},mlt:{}},default:`mvt`},"*":{type:`*`}},source_raster:{type:{required:!0,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:!1},"*":{type:`*`}},source_raster_dem:{type:{required:!0,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:{},custom:{}},default:`mapbox`},redFactor:{type:`number`,default:1},blueFactor:{type:`number`,default:1},greenFactor:{type:`number`,default:1},baseShift:{type:`number`,default:0},volatile:{type:`boolean`,default:!1},"*":{type:`*`}},source_geojson:{type:{required:!0,type:`enum`,values:{geojson:{}}},data:{required:!0,type:`*`},maxzoom:{type:`number`,default:18},attribution:{type:`string`},buffer:{type:`number`,default:128,maximum:512,minimum:0},filter:{type:`filter`},tolerance:{type:`number`,default:.375},cluster:{type:`boolean`,default:!1},clusterRadius:{type:`number`,default:50,minimum:0},clusterMaxZoom:{type:`number`},clusterMinPoints:{type:`number`},clusterProperties:{type:`*`},lineMetrics:{type:`boolean`,default:!1},generateId:{type:`boolean`,default:!1},promoteId:{type:`promoteId`}},source_video:{type:{required:!0,type:`enum`,values:{video:{}}},urls:{required:!0,type:`array`,value:`string`},coordinates:{required:!0,type:`array`,length:4,value:{type:`array`,length:2,value:`number`}}},source_image:{type:{required:!0,type:`enum`,values:{image:{}}},url:{required:!0,type:`string`},coordinates:{required:!0,type:`array`,length:4,value:{type:`array`,length:2,value:`number`}}},layer:{id:{type:`string`,required:!0},type:{type:`enum`,values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},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_color-relief`,`layout_background`],layout_background:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_fill:{"fill-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_circle:{"circle-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_heatmap:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},"layout_fill-extrusion":{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_line:{"line-cap":{type:`enum`,values:{butt:{},round:{},square:{}},default:`butt`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"line-join":{type:`enum`,values:{bevel:{},round:{},miter:{}},default:`miter`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"line-miter-limit":{type:`number`,default:2,requires:[{"line-join":`miter`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"line-round-limit":{type:`number`,default:1.05,requires:[{"line-join":`round`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"line-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_symbol:{"symbol-placement":{type:`enum`,values:{point:{},line:{},"line-center":{}},default:`point`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-spacing":{type:`number`,default:250,minimum:1,units:`pixels`,requires:[{"symbol-placement":`line`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-avoid-edges":{type:`boolean`,default:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"symbol-z-order":{type:`enum`,values:{auto:{},"viewport-y":{},source:{}},default:`auto`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-allow-overlap":{type:`boolean`,default:!1,requires:[`icon-image`,{"!":`icon-overlap`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-overlap":{type:`enum`,values:{never:{},always:{},cooperative:{}},requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-ignore-placement":{type:`boolean`,default:!1,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-optional":{type:`boolean`,default:!1,requires:[`icon-image`,`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-rotation-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`icon-image`],expression:{interpolated:!1,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:!0,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:!1,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:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-image":{type:`resolvedImage`,tokens:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-padding":{type:`padding`,default:[2],units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-keep-upright":{type:`boolean`,default:!1,requires:[`icon-image`,{"icon-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-offset":{type:`array`,value:`number`,length:2,default:[0,0],requires:[`icon-image`],expression:{interpolated:!0,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:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotation-alignment":{type:`enum`,values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-field":{type:`formatted`,default:``,tokens:!0,expression:{interpolated:!1,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:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-size":{type:`number`,default:16,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-max-width":{type:`number`,default:10,minimum:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-line-height":{type:`number`,default:1.2,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-letter-spacing":{type:`number`,default:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-justify":{type:`enum`,values:{auto:{},left:{},center:{},right:{}},default:`center`,requires:[`text-field`],expression:{interpolated:!1,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:!0,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:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-variable-anchor-offset":{type:`variableAnchorOffsetCollection`,requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"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:!1,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:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-writing-mode":{type:`array`,value:`enum`,values:{horizontal:{},vertical:{}},requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-padding":{type:`number`,default:2,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-keep-upright":{type:`boolean`,default:!0,requires:[`text-field`,{"text-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-transform":{type:`enum`,values:{none:{},uppercase:{},lowercase:{}},default:`none`,requires:[`text-field`],expression:{interpolated:!1,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:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-allow-overlap":{type:`boolean`,default:!1,requires:[`text-field`,{"!":`text-overlap`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-overlap":{type:`enum`,values:{never:{},always:{},cooperative:{}},requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-ignore-placement":{type:`boolean`,default:!1,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-optional":{type:`boolean`,default:!1,requires:[`text-field`,`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_raster:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_hillshade:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},"layout_color-relief":{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},filter:{type:`boolean`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},filter_operator:{type:`enum`,values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},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:!1}},function_stop:{type:`array`,minimum:0,maximum:24,value:[`number`,`color`],length:2},expression:{type:`array`,value:`expression_name`,minimum:1},light:{anchor:{type:`enum`,default:`viewport`,values:{map:{},viewport:{}},"property-type":`data-constant`,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]}},position:{type:`array`,default:[1.15,210,30],length:3,value:`number`,"property-type":`data-constant`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]}},color:{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},intensity:{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},sky:{"sky-color":{type:`color`,"property-type":`data-constant`,default:`#88C6FC`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-ground-blend":{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-fog-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"sky-horizon-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"atmosphere-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},terrain:{source:{type:`string`,required:!0},exaggeration:{type:`number`,minimum:0,default:1}},projection:{type:{type:`projectionDefinition`,default:`mercator`,"property-type":`data-constant`,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]}}},paint:[`paint_fill`,`paint_line`,`paint_circle`,`paint_heatmap`,`paint_fill-extrusion`,`paint_symbol`,`paint_raster`,`paint_hillshade`,`paint_color-relief`,`paint_background`],paint_fill:{"fill-antialias":{type:`boolean`,default:!0,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-outline-color":{type:`color`,transition:!0,requires:[{"!":`fill-pattern`},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-extrusion-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-extrusion-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"fill-extrusion-height":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-base":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,requires:[`fill-extrusion-height`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-vertical-gradient":{type:`boolean`,default:!0,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_line:{"line-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`line-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"line-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`line-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"line-width":{type:`number`,default:1,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-gap-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-offset":{type:`number`,default:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-dasharray":{type:`array`,value:`number`,minimum:0,transition:!0,units:`line widths`,requires:[{"!":`line-pattern`}],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-gradient":{type:`color`,transition:!1,requires:[{"!":`line-dasharray`},{"!":`line-pattern`},{source:`geojson`,has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:[`line-progress`]},"property-type":`color-ramp`}},paint_circle:{"circle-radius":{type:`number`,default:5,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-blur":{type:`number`,default:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"circle-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`circle-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-scale":{type:`enum`,values:{map:{},viewport:{}},default:`map`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-alignment":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-stroke-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`}},paint_heatmap:{"heatmap-radius":{type:`number`,default:30,minimum:1,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-weight":{type:`number`,default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-intensity":{type:`number`,default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"heatmap-color":{type:`color`,default:[`interpolate`,[`linear`],[`heatmap-density`],0,`rgba(0, 0, 255, 0)`,.1,`royalblue`,.3,`cyan`,.5,`lime`,.7,`yellow`,1,`red`],transition:!1,expression:{interpolated:!0,parameters:[`heatmap-density`]},"property-type":`color-ramp`},"heatmap-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_symbol:{"icon-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-color":{type:`color`,default:`#000000`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`icon-image`,`icon-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-color":{type:`color`,default:`#000000`,transition:!0,overridable:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`text-field`,`text-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_raster:{"raster-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-hue-rotate":{type:`number`,default:0,period:360,transition:!0,units:`degrees`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-min":{type:`number`,default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-max":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-saturation":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-contrast":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"raster-resampling":{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"raster-fade-duration":{type:`number`,default:300,minimum:0,transition:!1,units:`milliseconds`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_hillshade:{"hillshade-illumination-direction":{type:`numberArray`,default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-altitude":{type:`numberArray`,default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-exaggeration":{type:`number`,default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-shadow-color":{type:`colorArray`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-highlight-color":{type:`colorArray`,default:`#FFFFFF`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-accent-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-method":{type:`enum`,values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:`standard`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},"paint_color-relief":{"color-relief-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"color-relief-color":{type:`color`,transition:!1,expression:{interpolated:!0,parameters:[`elevation`]},"property-type":`color-ramp`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_background:{"background-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`background-pattern`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"background-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`cross-faded`},"background-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,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`}},interpolation:{type:`array`,value:`interpolation_name`,minimum:1},interpolation_name:{type:`enum`,values:{linear:{syntax:{overloads:[{parameters:[],"output-type":`interpolation`}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:[`base`],"output-type":`interpolation`}],parameters:[{name:`base`,type:`number literal`}]}},"cubic-bezier":{syntax:{overloads:[{parameters:[`x1`,`y1`,`x2`,`y2`],"output-type":`interpolation`}],parameters:[{name:`x1`,type:`number literal`},{name:`y1`,type:`number literal`},{name:`x2`,type:`number literal`},{name:`y2`,type:`number literal`}]}}}}};let Fe=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function Ie(e,t){let n={};for(let t in e)t!==`ref`&&(n[t]=e[t]);return Fe.forEach((e=>{e in t&&(n[e]=t[e])})),n}function Le(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Le(e[n],t[n]))return!1;return!0}if(typeof e==`object`&&e&&t!==null){if(typeof t!=`object`||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(!Le(e[n],t[n]))return!1;return!0}return e===t}function Re(e,t){e.push(t)}function ze(e,t,n){Re(n,{command:`addSource`,args:[e,t[e]]})}function Be(e,t,n){Re(t,{command:`removeSource`,args:[e]}),n[e]=!0}function Ve(e,t,n,r){Be(e,n,r),ze(e,t,n)}function He(e,t,n){let r;for(r in e[n])if(Object.prototype.hasOwnProperty.call(e[n],r)&&r!==`data`&&!Le(e[n][r],t[n][r]))return!1;for(r in t[n])if(Object.prototype.hasOwnProperty.call(t[n],r)&&r!==`data`&&!Le(e[n][r],t[n][r]))return!1;return!0}function Ue(e,t,n,r,i,a){e||={},t||={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(Le(e[o],t[o])||n.push({command:a,args:[r,o,t[o],i]}));for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&!Object.prototype.hasOwnProperty.call(e,o)&&(Le(e[o],t[o])||n.push({command:a,args:[r,o,t[o],i]}))}function We(e){return e.id}function Ge(e,t){return e[t.id]=t,e}class B{constructor(e,t,n,r){this.message=(e?`${e}: `:``)+n,r&&(this.identifier=r),t!=null&&t.__line__&&(this.line=t.__line__)}}function Ke(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}class qe extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Je{constructor(e,t=[]){this.parent=e,this.bindings={};for(let[e,n]of t)this.bindings[e]=n}concat(e){return new Je(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}let Ye={kind:`null`},V={kind:`number`},Xe={kind:`string`},Ze={kind:`boolean`},H={kind:`color`},Qe={kind:`projectionDefinition`},$e={kind:`object`},et={kind:`value`},tt={kind:`collator`},nt={kind:`formatted`},U={kind:`padding`},rt={kind:`colorArray`},it={kind:`numberArray`},at={kind:`resolvedImage`},ot={kind:`variableAnchorOffsetCollection`};function st(e,t){return{kind:`array`,itemType:e,N:t}}function ct(e){if(e.kind===`array`){let t=ct(e.itemType);return typeof e.N==`number`?`array<${t}, ${e.N}>`:e.itemType.kind===`value`?`array`:`array<${t}>`}return e.kind}let lt=[Ye,V,Xe,Ze,H,Qe,nt,$e,st(et),U,it,rt,at,ot];function ut(e,t){if(t.kind===`error`)return null;if(e.kind===`array`){if(t.kind===`array`&&(t.N===0&&t.itemType.kind===`value`||!ut(e.itemType,t.itemType))&&(typeof e.N!=`number`||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if(e.kind===`value`){for(let e of lt)if(!ut(e,t))return null}}return`Expected ${ct(e)} but found ${ct(t)} instead.`}function dt(e,t){return t.some((t=>t.kind===e.kind))}function ft(e,t){return t.some((t=>t===`null`?e===null:t===`array`?Array.isArray(e):t===`object`?e&&!Array.isArray(e)&&typeof e==`object`:t===typeof e))}function pt(e,t){return e.kind===`array`&&t.kind===`array`?e.itemType.kind===t.itemType.kind&&typeof e.N==`number`:e.kind===t.kind}let mt=.96422,ht=.82521,gt=4/29,_t=6/29,vt=3*_t*_t,yt=Math.PI/180,bt=180/Math.PI;function xt(e){return(e%=360)<0&&(e+=360),e}function St([e,t,n,r]){let i,a,o=wt((.2225045*(e=Ct(e))+.7168786*(t=Ct(t))+.0606169*(n=Ct(n)))/1);e===t&&t===n?i=a=o:(i=wt((.4360747*e+.3850649*t+.1430804*n)/mt),a=wt((.0139322*e+.0971045*t+.7141733*n)/ht));let s=116*o-16;return[s<0?0:s,500*(i-o),200*(o-a),r]}function Ct(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function wt(e){return e>.008856451679035631?e**(1/3):e/vt+gt}function Tt([e,t,n,r]){let i=(e+16)/116,a=isNaN(t)?i:i+t/500,o=isNaN(n)?i:i-n/200;return i=1*Dt(i),a=mt*Dt(a),o=ht*Dt(o),[Et(3.1338561*a-1.6168667*i-.4906146*o),Et(-.9787684*a+1.9161415*i+.033454*o),Et(.0719453*a-.2289914*i+1.4052427*o),r]}function Et(e){return(e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055)<0?0:e>1?1:e}function Dt(e){return e>_t?e*e*e:vt*(e-gt)}let Ot=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function kt(e,t){return Ot(e,t)?e[t]:void 0}function At(e){return parseInt(e.padEnd(2,e),16)/255}function jt(e,t){return Mt(t?e/100:e,0,1)}function Mt(e,t,n){return Math.min(Math.max(t,e),n)}function Nt(e){return!e.some(Number.isNaN)}let Pt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ft(e,t,n){return e+n*(t-e)}function It(e,t,n){return e.map(((e,r)=>Ft(e,t[r],n)))}class Lt{constructor(e,t,n,r=1,i=!0){this.r=e,this.g=t,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter(`rgb`,[e,t,n,r]))}static parse(e){if(e instanceof Lt)return e;if(typeof e!=`string`)return;let t=function(e){if((e=e.toLowerCase().trim())===`transparent`)return[0,0,0,0];let t=kt(Pt,e);if(t){let[e,n,r]=t;return[e/255,n/255,r/255,1]}if(e.startsWith(`#`)&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let t=e.length<6?1:2,n=1;return[At(e.slice(n,n+=t)),At(e.slice(n,n+=t)),At(e.slice(n,n+=t)),At(e.slice(n,n+t)||`ff`)]}if(e.startsWith(`rgb`)){let t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){let[e,n,r,i,a,o,s,c,l,u,d,f]=t,p=[i||` `,s||` `,u].join(``);if(p===` `||p===` /`||p===`,,`||p===`,,,`){let e=[r,o,l].join(``),t=e===`%%%`?100:e===``?255:0;if(t){let e=[Mt(+n/t,0,1),Mt(+a/t,0,1),Mt(+c/t,0,1),d?jt(+d,f):1];if(Nt(e))return e}}return}}let n=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){let[e,t,r,i,a,o,s,c,l]=n,u=[r||` `,a||` `,s].join(``);if(u===` `||u===` /`||u===`,,`||u===`,,,`){let e=[+t,Mt(+i,0,100),Mt(+o,0,100),c?jt(+c,l):1];if(Nt(e))return function([e,t,n,r]){function i(r){let i=(r+e/30)%12,a=t*Math.min(n,1-n);return n-a*Math.max(-1,Math.min(i-3,9-i,1))}return e=xt(e),t/=100,n/=100,[i(0),i(8),i(4),r]}(e)}}}(e);return t?new Lt(...t,!1):void 0}get rgb(){let{r:e,g:t,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter(`rgb`,[e/i,t/i,n/i,r])}get hcl(){return this.overwriteGetter(`hcl`,function(e){let[t,n,r,i]=St(e),a=Math.sqrt(n*n+r*r);return[Math.round(1e4*a)?xt(Math.atan2(r,n)*bt):NaN,a,t,i]}(this.rgb))}get lab(){return this.overwriteGetter(`lab`,St(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){let[e,t,n,r]=this.rgb;return`rgba(${[e,t,n].map((e=>Math.round(255*e))).join(`,`)},${r})`}static interpolate(e,t,n,r=`rgb`){switch(r){case`rgb`:{let[r,i,a,o]=It(e.rgb,t.rgb,n);return new Lt(r,i,a,o,!1)}case`hcl`:{let[r,i,a,o]=e.hcl,[s,c,l,u]=t.hcl,d,f;if(isNaN(r)||isNaN(s))isNaN(r)?isNaN(s)?d=NaN:(d=s,a!==1&&a!==0||(f=c)):(d=r,l!==1&&l!==0||(f=i));else{let e=s-r;s>r&&e>180?e-=360:s<r&&r-s>180&&(e+=360),d=r+n*e}let[p,m,h,g]=function([e,t,n,r]){return e=isNaN(e)?0:e*yt,Tt([n,Math.cos(e)*t,Math.sin(e)*t,r])}([d,f??Ft(i,c,n),Ft(a,l,n),Ft(o,u,n)]);return new Lt(p,m,h,g,!1)}case`lab`:{let[r,i,a,o]=Tt(It(e.lab,t.lab,n));return new Lt(r,i,a,o,!1)}}}}Lt.black=new Lt(0,0,0,1),Lt.white=new Lt(1,1,1,1),Lt.transparent=new Lt(0,0,0,0),Lt.red=new Lt(1,0,0,1);class Rt{constructor(e,t,n){this.sensitivity=e?t?`variant`:`case`:t?`accent`:`base`,this.locale=n,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}}let zt=[`bottom`,`center`,`top`];class Bt{constructor(e,t,n,r,i,a){this.text=e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=a}}class Vt{constructor(e){this.sections=e}static fromString(e){return new Vt([new Bt(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof Vt?e:Vt.fromString(e)}toString(){return this.sections.length===0?``:this.sections.map((e=>e.text)).join(``)}}class Ht{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ht)return e;if(typeof e==`number`)return new Ht([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let t of e)if(typeof t!=`number`)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Ht(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){return new Ht(It(e.values,t.values,n))}}class Ut{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ut)return e;if(typeof e==`number`)return new Ut([e]);if(Array.isArray(e)){for(let t of e)if(typeof t!=`number`)return;return new Ut(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){return new Ut(It(e.values,t.values,n))}}class Wt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Wt)return e;if(typeof e==`string`){let t=Lt.parse(e);return t?new Wt([t]):void 0}if(!Array.isArray(e))return;let t=[];for(let n of e){if(typeof n!=`string`)return;let e=Lt.parse(n);if(!e)return;t.push(e)}return new Wt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n,r=`rgb`){let i=[];if(e.values.length!=t.values.length)throw Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let a=0;a<e.values.length;a++)i.push(Lt.interpolate(e.values[a],t.values[a],n,r));return new Wt(i)}}class Gt extends Error{constructor(e){super(e),this.name=`RuntimeError`}toJSON(){return this.message}}let Kt=new Set([`center`,`left`,`right`,`top`,`bottom`,`top-left`,`top-right`,`bottom-left`,`bottom-right`]);class qt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof qt)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];if(typeof n!=`string`||!Kt.has(n)||!Array.isArray(r)||r.length!==2||typeof r[0]!=`number`||typeof r[1]!=`number`)return}return new qt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){let r=e.values,i=t.values;if(r.length!==i.length)throw new Gt(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${t.toString()}`);let a=[];for(let e=0;e<r.length;e+=2){if(r[e]!==i[e])throw new Gt(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${r[e]}, to[${e}]: ${i[e]}`);a.push(r[e]);let[t,o]=r[e+1],[s,c]=i[e+1];a.push([Ft(t,s,n),Ft(o,c,n)])}return new qt(a)}}class Jt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Jt({name:e,available:!1}):null}}class Yt{constructor(e,t,n){this.from=e,this.to=t,this.transition=n}static interpolate(e,t,n){return new Yt(e,t,n)}static parse(e){return e instanceof Yt?e:Array.isArray(e)&&e.length===3&&typeof e[0]==`string`&&typeof e[1]==`string`&&typeof e[2]==`number`?new Yt(e[0],e[1],e[2]):typeof e==`object`&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.transition==`number`?new Yt(e.from,e.to,e.transition):typeof e==`string`?new Yt(e,e,1):void 0}}function Xt(e,t,n,r){return typeof e==`number`&&e>=0&&e<=255&&typeof t==`number`&&t>=0&&t<=255&&typeof n==`number`&&n>=0&&n<=255?r===void 0||typeof r==`number`&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(`, `)}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r==`number`?[e,t,n,r]:[e,t,n]).join(`, `)}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Zt(e){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||e instanceof Yt||e instanceof Lt||e instanceof Rt||e instanceof Vt||e instanceof Ht||e instanceof Ut||e instanceof Wt||e instanceof qt||e instanceof Jt)return!0;if(Array.isArray(e)){for(let t of e)if(!Zt(t))return!1;return!0}if(typeof e==`object`){for(let t in e)if(!Zt(e[t]))return!1;return!0}return!1}function Qt(e){if(e===null)return Ye;if(typeof e==`string`)return Xe;if(typeof e==`boolean`)return Ze;if(typeof e==`number`)return V;if(e instanceof Lt)return H;if(e instanceof Yt)return Qe;if(e instanceof Rt)return tt;if(e instanceof Vt)return nt;if(e instanceof Ht)return U;if(e instanceof Ut)return it;if(e instanceof Wt)return rt;if(e instanceof qt)return ot;if(e instanceof Jt)return at;if(Array.isArray(e)){let t=e.length,n;for(let t of e){let e=Qt(t);if(n){if(n===e)continue;n=et;break}n=e}return st(n||et,t)}return $e}function $t(e){let t=typeof e;return e===null?``:t===`string`||t===`number`||t===`boolean`?String(e):e instanceof Lt||e instanceof Yt||e instanceof Vt||e instanceof Ht||e instanceof Ut||e instanceof Wt||e instanceof qt||e instanceof Jt?e.toString():JSON.stringify(e)}class en{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(e.length!==2)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Zt(e[1]))return t.error(`invalid value`);let n=e[1],r=Qt(n),i=t.expectedType;return r.kind!==`array`||r.N!==0||!i||i.kind!==`array`||typeof i.N==`number`&&i.N!==0||(r=i),new en(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}let tn={string:Xe,number:V,boolean:Ze,object:$e};class nn{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 n,r=1,i=e[0];if(i===`array`){let i,a;if(e.length>2){let n=e[1];if(typeof n!=`string`||!(n in tn)||n===`object`)return t.error(`The item type argument of "array" must be one of string, number, boolean`,1);i=tn[n],r++}else i=et;if(e.length>3){if(e[2]!==null&&(typeof e[2]!=`number`||e[2]<0||e[2]!==Math.floor(e[2])))return t.error(`The length argument to "array" must be a positive integer literal`,2);a=e[2],r++}n=st(i,a)}else{if(!tn[i])throw Error(`Types doesn't contain name = ${i}`);n=tn[i]}let a=[];for(;r<e.length;r++){let n=t.parse(e[r],r,et);if(!n)return null;a.push(n)}return new nn(n,a)}evaluate(e){for(let t=0;t<this.args.length;t++){let n=this.args[t].evaluate(e);if(!ut(this.type,Qt(n)))return n;if(t===this.args.length-1)throw new Gt(`Expected value to be of type ${ct(this.type)}, but found ${ct(Qt(n))} instead.`)}throw Error()}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}let rn={"to-boolean":Ze,"to-color":H,"to-number":V,"to-string":Xe};class an{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 n=e[0];if(!rn[n])throw Error(`Can't parse ${n} as it is not part of the known types`);if((n===`to-boolean`||n===`to-string`)&&e.length!==2)return t.error(`Expected one argument.`);let r=rn[n],i=[];for(let n=1;n<e.length;n++){let r=t.parse(e[n],n,et);if(!r)return null;i.push(r)}return new an(r,i)}evaluate(e){switch(this.type.kind){case`boolean`:return!!this.args[0].evaluate(e);case`color`:{let t,n;for(let r of this.args){if(t=r.evaluate(e),n=null,t instanceof Lt)return t;if(typeof t==`string`){let n=e.parseColor(t);if(n)return n}else if(Array.isArray(t)&&(n=t.length<3||t.length>4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Xt(t[0],t[1],t[2],t[3]),!n))return new Lt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Gt(n||`Could not parse color from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`padding`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Ht.parse(t);if(r)return r}throw new Gt(`Could not parse padding from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`numberArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Ut.parse(t);if(r)return r}throw new Gt(`Could not parse numberArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`colorArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Wt.parse(t);if(r)return r}throw new Gt(`Could not parse colorArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`variableAnchorOffsetCollection`:{let t;for(let n of this.args){t=n.evaluate(e);let r=qt.parse(t);if(r)return r}throw new Gt(`Could not parse variableAnchorOffsetCollection from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`number`:{let t=null;for(let n of this.args){if(t=n.evaluate(e),t===null)return 0;let r=Number(t);if(!isNaN(r))return r}throw new Gt(`Could not convert ${JSON.stringify(t)} to number.`)}case`formatted`:return Vt.fromString($t(this.args[0].evaluate(e)));case`resolvedImage`:return Jt.fromString($t(this.args[0].evaluate(e)));case`projectionDefinition`:return this.args[0].evaluate(e);default:return $t(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}let on=[`Unknown`,`Point`,`LineString`,`Polygon`];class sn{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&`id`in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type==`number`?on[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Lt.parse(e),this._parseColorCache.set(e,t)),t}}class cn{constructor(e,t,n=[],r,i=new Je,a=[]){this.registry=e,this.path=n,this.key=n.map((e=>`[${e}]`)).join(``),this.scope=i,this.errors=a,this.expectedType=r,this._isConstant=t}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return n===`assert`?new nn(t,[e]):n===`coerce`?new an(t,[e]):e}if(e!==null&&typeof e!=`string`&&typeof e!=`boolean`&&typeof e!=`number`||(e=[`literal`,e]),Array.isArray(e)){if(e.length===0)return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);let r=e[0];if(typeof r!=`string`)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let i=this.registry[r];if(i){let r=i.parse(e,this);if(!r)return null;if(this.expectedType){let e=this.expectedType,i=r.type;if(e.kind!==`string`&&e.kind!==`number`&&e.kind!==`boolean`&&e.kind!==`object`&&e.kind!==`array`||i.kind!==`value`){if(e.kind===`projectionDefinition`&&[`string`,`array`].includes(i.kind)||[`color`,`formatted`,`resolvedImage`].includes(e.kind)&&[`value`,`string`].includes(i.kind)||[`padding`,`numberArray`].includes(e.kind)&&[`value`,`number`,`array`].includes(i.kind)||e.kind===`colorArray`&&[`value`,`string`,`array`].includes(i.kind)||e.kind===`variableAnchorOffsetCollection`&&[`value`,`array`].includes(i.kind))r=n(r,e,t.typeAnnotation||`coerce`);else if(this.checkSubtype(e,i))return null}else r=n(r,e,t.typeAnnotation||`assert`)}if(!(r instanceof en)&&r.type.kind!==`resolvedImage`&&this._isConstant(r)){let e=new sn;try{r=new en(r.type,r.evaluate(e))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?`'undefined' value invalid. Use null instead.`:typeof e==`object`?`Bare objects invalid. Use ["literal", {...}] instead.`:`Expected an array, but found ${typeof e} instead.`)}concat(e,t,n){let r=typeof e==`number`?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new cn(this.registry,this._isConstant,r,t||null,i,this.errors)}error(e,...t){let n=`${this.key}${t.map((e=>`[${e}]`)).join(``)}`;this.errors.push(new qe(n,e))}checkSubtype(e,t){let n=ut(e,t);return n&&this.error(n),n}}class ln{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let 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.`);let n=[];for(let r=1;r<e.length-1;r+=2){let i=e[r];if(typeof i!=`string`)return t.error(`Expected string, but found ${typeof i} instead.`,r);if(/[^a-zA-Z0-9_]/.test(i))return t.error(`Variable names must contain only alphanumeric characters or '_'.`,r);let a=t.parse(e[r+1],r+1);if(!a)return null;n.push([i,a])}let r=t.parse(e[e.length-1],e.length-1,t.expectedType,n);return r?new ln(n,r):null}outputDefined(){return this.result.outputDefined()}}class un{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(e.length!==2||typeof e[1]!=`string`)return t.error(`'var' expression requires exactly one string literal argument.`);let n=e[1];return t.scope.has(n)?new un(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class dn{constructor(e,t,n){this.type=e,this.index=t,this.input=n}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,V),r=t.parse(e[2],2,st(t.expectedType||et));return n&&r?new dn(r.type.itemType,n,r):null}evaluate(e){let t=this.index.evaluate(e),n=this.input.evaluate(e);if(t<0)throw new Gt(`Array index out of bounds: ${t} < 0.`);if(t>=n.length)throw new Gt(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new Gt(`Array index must be an integer, but found ${t} instead.`);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class fn{constructor(e,t){this.type=Ze,this.needle=e,this.haystack=t}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,et),r=t.parse(e[2],2,et);return n&&r?dt(n.type,[Ze,Xe,V,Ye,et])?new fn(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(n.type)} instead`):null}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!n)return!1;if(!ft(t,[`boolean`,`string`,`number`,`null`]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Qt(t))} instead.`);if(!ft(n,[`string`,`array`]))throw new Gt(`Expected second argument to be of type array or string, but found ${ct(Qt(n))} instead.`);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class pn{constructor(e,t,n){this.type=V,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,et),r=t.parse(e[2],2,et);if(!n||!r)return null;if(!dt(n.type,[Ze,Xe,V,Ye,et]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(n.type)} instead`);if(e.length===4){let i=t.parse(e[3],3,V);return i?new pn(n,r,i):null}return new pn(n,r)}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!ft(t,[`boolean`,`string`,`number`,`null`]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Qt(t))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),ft(n,[`string`])){let e=n.indexOf(t,r);return e===-1?-1:[...n.slice(0,e)].length}if(ft(n,[`array`]))return n.indexOf(t,r);throw new Gt(`Expected second argument to be of type array or string, but found ${ct(Qt(n))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class mn{constructor(e,t,n,r,i,a){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=a}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 n,r;t.expectedType&&t.expectedType.kind!==`value`&&(r=t.expectedType);let i={},a=[];for(let o=2;o<e.length-1;o+=2){let s=e[o],c=e[o+1];Array.isArray(s)||(s=[s]);let l=t.concat(o);if(s.length===0)return l.error(`Expected at least one branch label.`);for(let e of s){if(typeof e!=`number`&&typeof e!=`string`)return l.error(`Branch labels must be numbers or strings.`);if(typeof e==`number`&&Math.abs(e)>2**53-1)return l.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof e==`number`&&Math.floor(e)!==e)return l.error(`Numeric branch labels must be integer values.`);if(n){if(l.checkSubtype(n,Qt(e)))return null}else n=Qt(e);if(i[String(e)]!==void 0)return l.error(`Branch labels must be unique.`);i[String(e)]=a.length}let u=t.parse(c,o,r);if(!u)return null;r||=u.type,a.push(u)}let o=t.parse(e[1],1,et);if(!o)return null;let s=t.parse(e[e.length-1],e.length-1,r);return s?o.type.kind!==`value`&&t.concat(1).checkSubtype(n,o.type)?null:new mn(n,r,o,i,a,s):null}evaluate(e){let t=this.input.evaluate(e);return(Qt(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()}}class hn{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}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 n;t.expectedType&&t.expectedType.kind!==`value`&&(n=t.expectedType);let r=[];for(let i=1;i<e.length-1;i+=2){let a=t.parse(e[i],i,Ze);if(!a)return null;let o=t.parse(e[i+1],i+1,n);if(!o)return null;r.push([a,o]),n||=o.type}let i=t.parse(e[e.length-1],e.length-1,n);if(!i)return null;if(!n)throw Error(`Can't infer output type`);return new hn(n,r,i)}evaluate(e){for(let[t,n]of this.branches)if(t.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[t,n]of this.branches)e(t),e(n);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}}class gn{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,et),r=t.parse(e[2],2,V);if(!n||!r)return null;if(!dt(n.type,[st(et),Xe,et]))return t.error(`Expected first argument to be of type array or string, but found ${ct(n.type)} instead`);if(e.length===4){let i=t.parse(e[3],3,V);return i?new gn(n.type,n,r,i):null}return new gn(n.type,n,r)}evaluate(e){let t=this.input.evaluate(e),n=this.beginIndex.evaluate(e),r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),ft(t,[`string`]))return[...t].slice(n,r).join(``);if(ft(t,[`array`]))return t.slice(n,r);throw new Gt(`Expected first argument to be of type array or string, but found ${ct(Qt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function _n(e,t){let n=e.length-1,r,i,a=0,o=n,s=0;for(;a<=o;)if(s=Math.floor((a+o)/2),r=e[s],i=e[s+1],r<=t){if(s===n||t<i)return s;a=s+1}else{if(!(r>t))throw new Gt(`Input is not a number.`);o=s-1}return 0}class vn{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(let[e,t]of n)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.`);let n=t.parse(e[1],1,V);if(!n)return null;let r=[],i=null;t.expectedType&&t.expectedType.kind!==`value`&&(i=t.expectedType);for(let n=1;n<e.length;n+=2){let a=n===1?-1/0:e[n],o=e[n+1],s=n,c=n+1;if(typeof a!=`number`)return t.error(`Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.`,s);if(r.length&&r[r.length-1][0]>=a)return t.error(`Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.`,s);let l=t.parse(o,c,i);if(!l)return null;i||=l.type,r.push([a,l])}return new vn(i,n,r)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[_n(t,r)].evaluate(e)}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function yn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var bn,xn,Sn=yn(function(){if(xn)return bn;function e(e,t,n,r){this.cx=3*e,this.bx=3*(n-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=n,this.p2y=r}return xn=1,bn=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(t===void 0&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=i/a}var o=0,s=1;for(n=e,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-e)<t));r++)e>i?o=n:s=n,n=.5*(s-o)+o;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},bn}());class Cn{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(let[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if(e.name===`exponential`)i=wn(t,e.base,n,r);else if(e.name===`linear`)i=wn(t,1,n,r);else if(e.name===`cubic-bezier`){let a=e.controlPoints;i=new Sn(a[0],a[1],a[2],a[3]).solve(wn(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...a]=e;if(!Array.isArray(r)||r.length===0)return t.error(`Expected an interpolation type expression.`,1);if(r[0]===`linear`)r={name:`linear`};else if(r[0]===`exponential`){let e=r[1];if(typeof e!=`number`)return t.error(`Exponential interpolation requires a numeric base.`,1,1);r={name:`exponential`,base:e}}else{if(r[0]!==`cubic-bezier`)return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{let e=r.slice(1);if(e.length!==4||e.some((e=>typeof e!=`number`||e<0||e>1)))return t.error(`Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.`,1);r={name:`cubic-bezier`,controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error(`Expected an even number of arguments.`);if(i=t.parse(i,2,V),!i)return null;let o=[],s=null;n!==`interpolate-hcl`&&n!==`interpolate-lab`||t.expectedType==rt?t.expectedType&&t.expectedType.kind!==`value`&&(s=t.expectedType):s=H;for(let e=0;e<a.length;e+=2){let n=a[e],r=a[e+1],i=e+3,c=e+4;if(typeof n!=`number`)return t.error(`Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.`,i);if(o.length&&o[o.length-1][0]>=n)return t.error(`Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.`,i);let l=t.parse(r,c,s);if(!l)return null;s||=l.type,o.push([n,l])}return pt(s,V)||pt(s,Qe)||pt(s,H)||pt(s,U)||pt(s,it)||pt(s,rt)||pt(s,ot)||pt(s,st(V))?new Cn(s,n,r,i,o):t.error(`Type ${ct(s)} is not interpolatable.`)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);let a=_n(t,r),o=Cn.interpolationFactor(this.interpolation,r,t[a],t[a+1]),s=n[a].evaluate(e),c=n[a+1].evaluate(e);switch(this.operator){case`interpolate`:switch(this.type.kind){case`number`:return Ft(s,c,o);case`color`:return Lt.interpolate(s,c,o);case`padding`:return Ht.interpolate(s,c,o);case`colorArray`:return Wt.interpolate(s,c,o);case`numberArray`:return Ut.interpolate(s,c,o);case`variableAnchorOffsetCollection`:return qt.interpolate(s,c,o);case`array`:return It(s,c,o);case`projectionDefinition`:return Yt.interpolate(s,c,o)}case`interpolate-hcl`:switch(this.type.kind){case`color`:return Lt.interpolate(s,c,o,`hcl`);case`colorArray`:return Wt.interpolate(s,c,o,`hcl`)}case`interpolate-lab`:switch(this.type.kind){case`color`:return Lt.interpolate(s,c,o,`lab`);case`colorArray`:return Wt.interpolate(s,c,o,`lab`)}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function wn(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}let Tn={color:Lt.interpolate,number:Ft,padding:Ht.interpolate,numberArray:Ut.interpolate,colorArray:Wt.interpolate,variableAnchorOffsetCollection:qt.interpolate,array:It};class En{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 n=null,r=t.expectedType;r&&r.kind!==`value`&&(n=r);let i=[];for(let r of e.slice(1)){let e=t.parse(r,1+i.length,n,void 0,{typeAnnotation:`omit`});if(!e)return null;n||=e.type,i.push(e)}if(!n)throw Error(`No output type`);return new En(r&&i.some((e=>ut(r,e.type)))?et:n,i)}evaluate(e){let t,n=null,r=0;for(let i of this.args)if(r++,n=i.evaluate(e),n&&n instanceof Jt&&!n.available&&(t||=n.name,n=null,r===this.args.length&&(n=t)),n!==null)break;return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Dn(e,t){return e===`==`||e===`!=`?t.kind===`boolean`||t.kind===`string`||t.kind===`number`||t.kind===`null`||t.kind===`value`:t.kind===`string`||t.kind===`number`||t.kind===`value`}function On(e,t,n,r){return r.compare(t,n)===0}function kn(e,t,n){let r=e!==`==`&&e!==`!=`;return class i{constructor(e,t,n){this.type=Ze,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument=e.type.kind===`value`||t.type.kind===`value`}static parse(e,t){if(e.length!==3&&e.length!==4)return t.error(`Expected two or three arguments.`);let n=e[0],a=t.parse(e[1],1,et);if(!a)return null;if(!Dn(n,a.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${ct(a.type)}'.`);let o=t.parse(e[2],2,et);if(!o)return null;if(!Dn(n,o.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${ct(o.type)}'.`);if(a.type.kind!==o.type.kind&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot compare types '${ct(a.type)}' and '${ct(o.type)}'.`);r&&(a.type.kind===`value`&&o.type.kind!==`value`?a=new nn(o.type,[a]):a.type.kind!==`value`&&o.type.kind===`value`&&(o=new nn(a.type,[o])));let s=null;if(e.length===4){if(a.type.kind!==`string`&&o.type.kind!==`string`&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot use collator to compare non-string types.`);if(s=t.parse(e[3],3,tt),!s)return null}return new i(a,o,s)}evaluate(i){let a=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){let t=Qt(a),n=Qt(o);if(t.kind!==n.kind||t.kind!==`string`&&t.kind!==`number`)throw new Gt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){let e=Qt(a),n=Qt(o);if(e.kind!==`string`||n.kind!==`string`)return t(i,a,o)}return this.collator?n(i,a,o,this.collator.evaluate(i)):t(i,a,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}let An=kn(`==`,(function(e,t,n){return t===n}),On),jn=kn(`!=`,(function(e,t,n){return t!==n}),(function(e,t,n,r){return!On(0,t,n,r)})),Mn=kn(`<`,(function(e,t,n){return t<n}),(function(e,t,n,r){return r.compare(t,n)<0})),Nn=kn(`>`,(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),Pn=kn(`<=`,(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),Fn=kn(`>=`,(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class In{constructor(e,t,n){this.type=tt,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(e.length!==2)return t.error(`Expected one argument.`);let n=e[1];if(typeof n!=`object`||Array.isArray(n))return t.error(`Collator options argument must be an object.`);let r=t.parse(n[`case-sensitive`]!==void 0&&n[`case-sensitive`],1,Ze);if(!r)return null;let i=t.parse(n[`diacritic-sensitive`]!==void 0&&n[`diacritic-sensitive`],1,Ze);if(!i)return null;let a=null;return n.locale&&(a=t.parse(n.locale,1,Xe),!a)?null:new In(r,i,a)}evaluate(e){return new Rt(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}}class Ln{constructor(e,t,n,r,i,a){this.type=Xe,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=a}static parse(e,t){if(e.length!==3)return t.error(`Expected two arguments.`);let n=t.parse(e[1],1,V);if(!n)return null;let r=e[2];if(typeof r!=`object`||Array.isArray(r))return t.error(`NumberFormat options argument must be an object.`);let i=null;if(r.locale&&(i=t.parse(r.locale,1,Xe),!i))return null;let a=null;if(r.currency&&(a=t.parse(r.currency,1,Xe),!a))return null;let o=null;if(r.unit&&(o=t.parse(r.unit,1,Xe),!o))return null;if(a&&o)return t.error("NumberFormat options `currency` and `unit` are mutually exclusive");let s=null;if(r[`min-fraction-digits`]&&(s=t.parse(r[`min-fraction-digits`],1,V),!s))return null;let c=null;return r[`max-fraction-digits`]&&(c=t.parse(r[`max-fraction-digits`],1,V),!c)?null:new Ln(n,i,a,o,s,c)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?`currency`:this.unit?`unit`:`decimal`,currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.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.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Rn{constructor(e){this.type=nt,this.sections=e}static parse(e,t){if(e.length<2)return t.error(`Expected at least one argument.`);let n=e[1];if(!Array.isArray(n)&&typeof n==`object`)return t.error(`First argument must be an image or text section.`);let r=[],i=!1;for(let n=1;n<=e.length-1;++n){let a=e[n];if(i&&typeof a==`object`&&!Array.isArray(a)){i=!1;let e=null;if(a[`font-scale`]&&(e=t.parse(a[`font-scale`],1,V),!e))return null;let n=null;if(a[`text-font`]&&(n=t.parse(a[`text-font`],1,st(Xe)),!n))return null;let o=null;if(a[`text-color`]&&(o=t.parse(a[`text-color`],1,H),!o))return null;let s=null;if(a[`vertical-align`]){if(typeof a[`vertical-align`]==`string`&&!zt.includes(a[`vertical-align`]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${a[`vertical-align`]}' instead.`);if(s=t.parse(a[`vertical-align`],1,Xe),!s)return null}let c=r[r.length-1];c.scale=e,c.font=n,c.textColor=o,c.verticalAlign=s}else{let a=t.parse(e[n],1,et);if(!a)return null;let o=a.type.kind;if(o!==`string`&&o!==`value`&&o!==`null`&&o!==`resolvedImage`)return t.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);i=!0,r.push({content:a,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Rn(r)}evaluate(e){return new Vt(this.sections.map((t=>{let n=t.content.evaluate(e);return Qt(n)===at?new Bt(``,n,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new Bt($t(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(`,`):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)})))}eachChild(e){for(let t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class zn{constructor(e){this.type=at,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected two arguments.`);let n=t.parse(e[1],1,Xe);return n?new zn(n):t.error(`No image name provided.`)}evaluate(e){let t=this.input.evaluate(e),n=Jt.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}}class Bn{constructor(e){this.type=V,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=t.parse(e[1],1);return n?n.type.kind!==`array`&&n.type.kind!==`string`&&n.type.kind!==`value`?t.error(`Expected argument of type string or array, but found ${ct(n.type)} instead.`):new Bn(n):null}evaluate(e){let t=this.input.evaluate(e);if(typeof t==`string`)return[...t].length;if(Array.isArray(t))return t.length;throw new Gt(`Expected value to be of type string or array, but found ${ct(Qt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}let Vn=8192;function Hn(e,t){let n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=2**t.z;return[Math.round(n*i*Vn),Math.round(r*i*Vn)]}function Un(e,t){let n=2**t.z;return[(i=(e[0]/Vn+t.x)/n,360*i-180),(r=(e[1]/Vn+t.y)/n,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,i}function Wn(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 Gn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Kn(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[0]-n[0],o=e[1]-n[1];return r*o-a*i==0&&r*a<=0&&i*o<=0}function qn(e,t,n,r){return(i=[r[0]-n[0],r[1]-n[1]])[0]*(a=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*a[0]!=0&&!(!$n(e,t,n,r)||!$n(n,r,e,t));var i,a}function Jn(e,t,n){for(let r of n)for(let n=0;n<r.length-1;++n)if(qn(e,t,r[n],r[n+1]))return!0;return!1}function Yn(e,t,n=!1){let r=!1;for(let s of t)for(let t=0;t<s.length-1;t++){if(Kn(e,s[t],s[t+1]))return n;(a=s[t])[1]>(i=e)[1]!=(o=s[t+1])[1]>i[1]&&i[0]<(o[0]-a[0])*(i[1]-a[1])/(o[1]-a[1])+a[0]&&(r=!r)}var i,a,o;return r}function Xn(e,t){for(let n of t)if(Yn(e,n))return!0;return!1}function Zn(e,t){for(let n of e)if(!Yn(n,t))return!1;for(let n=0;n<e.length-1;++n)if(Jn(e[n],e[n+1],t))return!1;return!0}function Qn(e,t){for(let n of t)if(Zn(e,n))return!0;return!1}function $n(e,t,n,r){let i=r[0]-n[0],a=r[1]-n[1],o=(e[0]-n[0])*a-i*(e[1]-n[1]),s=(t[0]-n[0])*a-i*(t[1]-n[1]);return o>0&&s<0||o<0&&s>0}function er(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=[];for(let r=0;r<e[i].length;r++){let o=Hn(e[i][r],n);Wn(t,o),a.push(o)}r.push(a)}return r}function tr(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=er(e[i],t,n);r.push(a)}return r}function nr(e,t,n,r){if(e[0]<n[0]||e[0]>n[2]){let t=.5*r,i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;i===0&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}Wn(t,e)}function rr(e,t,n,r){let i=2**r.z*Vn,a=[r.x*Vn,r.y*Vn],o=[];for(let r of e)for(let e of r){let r=[e.x+a[0],e.y+a[1]];nr(r,t,n,i),o.push(r)}return o}function ir(e,t,n,r){let i=2**r.z*Vn,a=[r.x*Vn,r.y*Vn],o=[];for(let n of e){let e=[];for(let r of n){let n=[r.x+a[0],r.y+a[1]];Wn(t,n),e.push(n)}o.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(let e of o)for(let r of e)nr(r,t,n,i)}var s;return o}class ar{constructor(e,t){this.type=Ze,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Zt(e[1])){let t=e[1];if(t.type===`FeatureCollection`){let e=[];for(let n of t.features){let{type:t,coordinates:r}=n.geometry;t===`Polygon`&&e.push(r),t===`MultiPolygon`&&e.push(...r)}if(e.length)return new ar(t,{type:`MultiPolygon`,coordinates:e})}else if(t.type===`Feature`){let e=t.geometry.type;if(e===`Polygon`||e===`MultiPolygon`)return new ar(t,t.geometry)}else if(t.type===`Polygon`||t.type===`MultiPolygon`)return new ar(t,t)}return t.error(`'within' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=er(t.coordinates,r,i),o=rr(e.geometry(),n,r,i);if(!Gn(n,r))return!1;for(let e of o)if(!Yn(e,a))return!1}if(t.type===`MultiPolygon`){let a=tr(t.coordinates,r,i),o=rr(e.geometry(),n,r,i);if(!Gn(n,r))return!1;for(let e of o)if(!Xn(e,a))return!1}return!0}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=er(t.coordinates,r,i),o=ir(e.geometry(),n,r,i);if(!Gn(n,r))return!1;for(let e of o)if(!Zn(e,a))return!1}if(t.type===`MultiPolygon`){let a=tr(t.coordinates,r,i),o=ir(e.geometry(),n,r,i);if(!Gn(n,r))return!1;for(let e of o)if(!Qn(e,a))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let or=class{constructor(e=[],t=(e,t)=>e<t?-1:+(e>t)){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._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=1+(e<<1),a=r+1;if(a<this.length&&n(t[a],t[r])<0&&(r=a),n(t[r],i)>=0)break;t[e]=t[r],e=r}t[e]=i}};function sr(e,t,n=0,r=e.length-1,i=lr){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);sr(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(cr(e,n,t),i(e[r],a)>0&&cr(e,n,r);o<s;){for(cr(e,o,s),o++,s--;i(e[o],a)<0;)o++;for(;i(e[s],a)>0;)s--}i(e[n],a)===0?cr(e,n,s):(s++,cr(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function cr(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function lr(e,t){return e<t?-1:+(e>t)}function ur(e,t){if(e.length<=1)return[e];let n=[],r,i;for(let t of e){let e=fr(t);e!==0&&(t.area=Math.abs(e),i===void 0&&(i=e<0),i===e<0?(r&&n.push(r),r=[t]):r.push(t))}if(r&&n.push(r),t>1)for(let e=0;e<n.length;e++)n[e].length<=t||(sr(n[e],t,1,n[e].length-1,dr),n[e]=n[e].slice(0,t));return n}function dr(e,t){return t.area-e.area}function fr(e){let t=0;for(let n,r,i=0,a=e.length,o=a-1;i<a;o=i++)n=e[i],r=e[o],t+=(r.x-n.x)*(n.y+r.y);return t}let pr=1/298.257223563,mr=pr*(2-pr),hr=Math.PI/180;class gr{constructor(e){let t=6378.137*hr*1e3,n=Math.cos(e*hr),r=1/(1-mr*(1-n*n)),i=Math.sqrt(r);this.kx=t*i*n,this.ky=t*i*r*(1-mr)}distance(e,t){let n=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(n*n+r*r)}pointOnLine(e,t){let n,r,i,a,o=1/0;for(let s=0;s<e.length-1;s++){let c=e[s][0],l=e[s][1],u=this.wrap(e[s+1][0]-c)*this.kx,d=(e[s+1][1]-l)*this.ky,f=0;u===0&&d===0||(f=(this.wrap(t[0]-c)*this.kx*u+(t[1]-l)*this.ky*d)/(u*u+d*d),f>1?(c=e[s+1][0],l=e[s+1][1]):f>0&&(c+=u/this.kx*f,l+=d/this.ky*f)),u=this.wrap(t[0]-c)*this.kx,d=(t[1]-l)*this.ky;let p=u*u+d*d;p<o&&(o=p,n=c,r=l,i=s,a=f)}return{point:[n,r],index:i,t:Math.max(0,Math.min(1,a))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function _r(e,t){return t[0]-e[0]}function vr(e){return e[1]-e[0]+1}function yr(e,t){return e[1]>=e[0]&&e[1]<t}function br(e,t){if(e[0]>e[1])return[null,null];let n=vr(e);if(t){if(n===2)return[e,null];let t=Math.floor(n/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(n===1)return[e,null];let r=Math.floor(n/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function xr(e,t){if(!yr(t,e.length))return[1/0,1/0,-1/0,-1/0];let n=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)Wn(n,e[r]);return n}function Sr(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)for(let e of n)Wn(t,e);return t}function Cr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function wr(e,t,n){if(!Cr(e)||!Cr(t))return NaN;let r=0,i=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]<t[1]&&(i=t[1]-e[3]),n.distance([0,0],[r,i])}function Tr(e,t,n){let r=n.pointOnLine(t,e);return n.distance(e,r.point)}function Er(e,t,n,r,i){let a=Math.min(Tr(e,[n,r],i),Tr(t,[n,r],i)),o=Math.min(Tr(n,[e,t],i),Tr(r,[e,t],i));return Math.min(a,o)}function Dr(e,t,n,r,i){if(!yr(t,e.length)||!yr(r,n.length))return 1/0;let a=1/0;for(let o=t[0];o<t[1];++o){let t=e[o],s=e[o+1];for(let e=r[0];e<r[1];++e){let r=n[e],o=n[e+1];if(qn(t,s,r,o))return 0;a=Math.min(a,Er(t,s,r,o,i))}}return a}function Or(e,t,n,r,i){if(!yr(t,e.length)||!yr(r,n.length))return NaN;let a=1/0;for(let o=t[0];o<=t[1];++o)for(let t=r[0];t<=r[1];++t)if(a=Math.min(a,i.distance(e[o],n[t])),a===0)return a;return a}function kr(e,t,n){if(Yn(e,t,!0))return 0;let r=1/0;for(let i of t){let t=i[0],a=i[i.length-1];if(t!==a&&(r=Math.min(r,Tr(e,[a,t],n)),r===0))return r;let o=n.pointOnLine(i,e);if(r=Math.min(r,n.distance(e,o.point)),r===0)return r}return r}function Ar(e,t,n,r){if(!yr(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(Yn(e[r],n,!0))return 0;let i=1/0;for(let a=t[0];a<t[1];++a){let t=e[a],o=e[a+1];for(let e of n)for(let n=0,a=e.length,s=a-1;n<a;s=n++){let a=e[s],c=e[n];if(qn(t,o,a,c))return 0;i=Math.min(i,Er(t,o,a,c,r))}}return i}function jr(e,t){for(let n of e)for(let e of n)if(Yn(e,t,!0))return!0;return!1}function Mr(e,t,n,r=1/0){let i=Sr(e),a=Sr(t);if(r!==1/0&&wr(i,a,n)>=r)return r;if(Gn(i,a)){if(jr(e,t))return 0}else if(jr(t,e))return 0;let o=1/0;for(let r of e)for(let e=0,i=r.length,a=i-1;e<i;a=e++){let i=r[a],s=r[e];for(let e of t)for(let t=0,r=e.length,a=r-1;t<r;a=t++){let r=e[a],c=e[t];if(qn(i,s,r,c))return 0;o=Math.min(o,Er(i,s,r,c,n))}}return o}function Nr(e,t,n,r,i,a){if(!a)return;let o=wr(xr(r,a),i,n);o<t&&e.push([o,a,[0,0]])}function Pr(e,t,n,r,i,a,o){if(!a||!o)return;let s=wr(xr(r,a),xr(i,o),n);s<t&&e.push([s,a,o])}function Fr(e,t,n,r,i=1/0){let a=Math.min(r.distance(e[0],n[0][0]),i);if(a===0)return a;let o=new or([[0,[0,e.length-1],[0,0]]],_r),s=Sr(n);for(;o.length>0;){let i=o.pop();if(i[0]>=a)continue;let c=i[1],l=t?50:100;if(vr(c)<=l){if(!yr(c,e.length))return NaN;if(t){let t=Ar(e,c,n,r);if(isNaN(t)||t===0)return t;a=Math.min(a,t)}else for(let t=c[0];t<=c[1];++t){let i=kr(e[t],n,r);if(a=Math.min(a,i),a===0)return 0}}else{let n=br(c,t);Nr(o,a,r,e,s,n[0]),Nr(o,a,r,e,s,n[1])}}return a}function Ir(e,t,n,r,i,a=1/0){let o=Math.min(a,i.distance(e[0],n[0]));if(o===0)return o;let s=new or([[0,[0,e.length-1],[0,n.length-1]]],_r);for(;s.length>0;){let a=s.pop();if(a[0]>=o)continue;let c=a[1],l=a[2],u=t?50:100,d=r?50:100;if(vr(c)<=u&&vr(l)<=d){if(!yr(c,e.length)&&yr(l,n.length))return NaN;let a;if(t&&r)a=Dr(e,c,n,l,i),o=Math.min(o,a);else if(t&&!r){let t=e.slice(c[0],c[1]+1);for(let e=l[0];e<=l[1];++e)if(a=Tr(n[e],t,i),o=Math.min(o,a),o===0)return o}else if(!t&&r){let t=n.slice(l[0],l[1]+1);for(let n=c[0];n<=c[1];++n)if(a=Tr(e[n],t,i),o=Math.min(o,a),o===0)return o}else a=Or(e,c,n,l,i),o=Math.min(o,a)}else{let a=br(c,t),u=br(l,r);Pr(s,o,i,e,n,a[0],u[0]),Pr(s,o,i,e,n,a[0],u[1]),Pr(s,o,i,e,n,a[1],u[0]),Pr(s,o,i,e,n,a[1],u[1])}}return o}function Lr(e){return e.type===`MultiPolygon`?e.coordinates.map((e=>({type:`Polygon`,coordinates:e}))):e.type===`MultiLineString`?e.coordinates.map((e=>({type:`LineString`,coordinates:e}))):e.type===`MultiPoint`?e.coordinates.map((e=>({type:`Point`,coordinates:e}))):[e]}class Rr{constructor(e,t){this.type=V,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Zt(e[1])){let t=e[1];if(t.type===`FeatureCollection`)return new Rr(t,t.features.map((e=>Lr(e.geometry))).flat());if(t.type===`Feature`)return new Rr(t,Lr(t.geometry));if(`type`in t&&`coordinates`in t)return new Rr(t,Lr(t))}return t.error(`'distance' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,t){let n=e.geometry(),r=n.flat().map((t=>Un([t.x,t.y],e.canonical)));if(n.length===0)return NaN;let i=new gr(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,Ir(r,!1,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,Ir(r,!1,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,Fr(r,!1,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,t){let n=e.geometry(),r=n.flat().map((t=>Un([t.x,t.y],e.canonical)));if(n.length===0)return NaN;let i=new gr(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,Ir(r,!0,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,Ir(r,!0,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,Fr(r,!0,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries);if(e.geometryType()===`Polygon`)return function(e,t){let n=e.geometry();if(n.length===0||n[0].length===0)return NaN;let r=ur(n,0).map((t=>t.map((t=>t.map((t=>Un([t.x,t.y],e.canonical))))))),i=new gr(r[0][0][0][1]),a=1/0;for(let e of t)for(let t of r){switch(e.type){case`Point`:a=Math.min(a,Fr([e.coordinates],!1,t,i,a));break;case`LineString`:a=Math.min(a,Fr(e.coordinates,!0,t,i,a));break;case`Polygon`:a=Math.min(a,Mr(t,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class zr{constructor(e){this.type=et,this.key=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=e[1];return n==null?t.error(`Global state property must be defined.`):typeof n==`string`?new zr(n):t.error(`Global state property must be string, but found ${typeof e[1]} instead.`)}evaluate(e){let t=e.globals?.globalState;return t&&Object.keys(t).length!==0?kt(t,this.key):null}eachChild(){}outputDefined(){return!1}}let Br={"==":An,"!=":jn,">":Nn,"<":Mn,">=":Fn,"<=":Pn,array:nn,at:dn,boolean:nn,case:hn,coalesce:En,collator:In,format:Rn,image:zn,in:fn,"index-of":pn,interpolate:Cn,"interpolate-hcl":Cn,"interpolate-lab":Cn,length:Bn,let:ln,literal:en,match:mn,number:nn,"number-format":Ln,object:nn,slice:gn,step:vn,string:nn,"to-boolean":an,"to-color":an,"to-number":an,"to-string":an,var:un,within:ar,distance:Rr,"global-state":zr};class Vr{constructor(e,t,n,r){this.name=e,this.type=t,this._evaluate=n,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){let n=e[0],r=Vr.definitions[n];if(!r)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);let i=Array.isArray(r)?r[0]:r.type,a=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=a.filter((([t])=>!Array.isArray(t)||t.length===e.length-1)),s=null;for(let[r,a]of o){s=new cn(t.registry,Kr,t.path,null,t.scope);let o=[],c=!1;for(let t=1;t<e.length;t++){let n=e[t],i=Array.isArray(r)?r[t-1]:r.type,a=s.parse(n,1+o.length,i);if(!a){c=!0;break}o.push(a)}if(!c)if(Array.isArray(r)&&r.length!==o.length)s.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let e=0;e<o.length;e++){let t=Array.isArray(r)?r[e]:r.type,n=o[e];s.concat(e+1).checkSubtype(t,n.type)}if(s.errors.length===0)return new Vr(n,i,a,o)}}if(o.length===1)t.errors.push(...s.errors);else{let n=(o.length?o:a).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(ct).join(`, `)})`:`(${ct(t.type)}...)`;var t})).join(` | `),r=[];for(let n=1;n<e.length;n++){let i=t.parse(e[n],1+r.length);if(!i)return null;r.push(ct(i.type))}t.error(`Expected arguments of type ${n}, but found (${r.join(`, `)}) instead.`)}return null}static register(e,t){Vr.definitions=t;for(let n in t)e[n]=Vr}}function Hr(e,[t,n,r,i]){t=t.evaluate(e),n=n.evaluate(e),r=r.evaluate(e);let a=i?i.evaluate(e):1,o=Xt(t,n,r,a);if(o)throw new Gt(o);return new Lt(t/255,n/255,r/255,a,!1)}function Ur(e,t){return e in t}function Wr(e,t){let n=t[e];return n===void 0?null:n}function Gr(e){return{type:e}}function Kr(e){if(e instanceof un)return Kr(e.boundExpression);if(e instanceof Vr&&e.name===`error`||e instanceof In||e instanceof ar||e instanceof Rr||e instanceof zr)return!1;let t=e instanceof an||e instanceof nn,n=!0;return e.eachChild((e=>{n=t?n&&Kr(e):n&&e instanceof en})),!!n&&qr(e)&&Yr(e,[`zoom`,`heatmap-density`,`elevation`,`line-progress`,`accumulated`,`is-supported-script`])}function qr(e){if(e instanceof Vr&&(e.name===`get`&&e.args.length===1||e.name===`feature-state`||e.name===`has`&&e.args.length===1||e.name===`properties`||e.name===`geometry-type`||e.name===`id`||/^filter-/.test(e.name))||e instanceof ar||e instanceof Rr)return!1;let t=!0;return e.eachChild((e=>{t&&!qr(e)&&(t=!1)})),t}function Jr(e){if(e instanceof Vr&&e.name===`feature-state`)return!1;let t=!0;return e.eachChild((e=>{t&&!Jr(e)&&(t=!1)})),t}function Yr(e,t){if(e instanceof Vr&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild((e=>{n&&!Yr(e,t)&&(n=!1)})),n}function Xr(e){return{result:`success`,value:e}}function Zr(e){return{result:`error`,value:e}}function Qr(e){return e[`property-type`]===`data-driven`||e[`property-type`]===`cross-faded-data-driven`}function $r(e){return!!e.expression&&e.expression.parameters.indexOf(`zoom`)>-1}function ei(e){return!!e.expression&&e.expression.interpolated}function ti(e){return e instanceof Number?`number`:e instanceof String?`string`:e instanceof Boolean?`boolean`:Array.isArray(e)?`array`:e===null?`null`:typeof e}function ni(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Qt(e)===$e}function ri(e){return e}function ii(e,t){let n=e.stops&&typeof e.stops[0][0]==`object`,r=n||!(n||e.property!==void 0),i=e.type||(ei(t)?`exponential`:`interval`),a=function(e){switch(e.type){case`color`:return Lt.parse;case`padding`:return Ht.parse;case`numberArray`:return Ut.parse;case`colorArray`:return Wt.parse;default:return null}}(t);if(a&&((e=Ke({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],a(e[1])]))),e.default=a(e.default?e.default:t.default)),e.colorSpace&&(o=e.colorSpace)!==`rgb`&&o!==`hcl`&&o!==`lab`)throw Error(`Unknown color space: "${e.colorSpace}"`);var o;let s=function(e){switch(e){case`exponential`:return ci;case`interval`:return si;case`categorical`:return oi;case`identity`:return li;default:throw Error(`Unknown function type "${e}"`)}}(i),c,l;if(i===`categorical`){c=Object.create(null);for(let t of e.stops)c[t[0]]=t[1];l=typeof e.stops[0][0]}if(n){let n={},r=[];for(let t=0;t<e.stops.length;t++){let i=e.stops[t],a=i[0].zoom;n[a]===void 0&&(n[a]={zoom:a,type:e.type,property:e.property,default:e.default,stops:[]},r.push(a)),n[a].stops.push([i[0].value,i[1]])}let i=[];for(let e of r)i.push([n[e].zoom,ii(n[e],t)]);let a={name:`linear`};return{kind:`composite`,interpolationType:a,interpolationFactor:Cn.interpolationFactor.bind(void 0,a),zoomStops:i.map((e=>e[0])),evaluate:({zoom:n},r)=>ci({stops:i,base:e.base},t,n).evaluate(n,r)}}if(r){let n=i===`exponential`?{name:`exponential`,base:e.base===void 0?1:e.base}:null;return{kind:`camera`,interpolationType:n,interpolationFactor:Cn.interpolationFactor.bind(void 0,n),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:n})=>s(e,t,n,c,l)}}return{kind:`source`,evaluate(n,r){let i=r&&r.properties?r.properties[e.property]:void 0;return i===void 0?ai(e.default,t.default):s(e,t,i,c,l)}}}function ai(e,t,n){return e===void 0?t===void 0?n===void 0?void 0:n:t:e}function oi(e,t,n,r,i){return ai(typeof n===i?r[n]:void 0,e.default,t.default)}function si(e,t,n){if(ti(n)!==`number`)return ai(e.default,t.default);let r=e.stops.length;if(r===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];let i=_n(e.stops.map((e=>e[0])),n);return e.stops[i][1]}function ci(e,t,n){let r=e.base===void 0?1:e.base;if(ti(n)!==`number`)return ai(e.default,t.default);let i=e.stops.length;if(i===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];let a=_n(e.stops.map((e=>e[0])),n),o=function(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}(n,r,e.stops[a][0],e.stops[a+1][0]),s=e.stops[a][1],c=e.stops[a+1][1],l=Tn[t.type]||ri;return typeof s.evaluate==`function`?{evaluate(...t){let n=s.evaluate.apply(void 0,t),r=c.evaluate.apply(void 0,t);if(n!==void 0&&r!==void 0)return l(n,r,o,e.colorSpace)}}:l(s,c,o,e.colorSpace)}function li(e,t,n){switch(t.type){case`color`:n=Lt.parse(n);break;case`formatted`:n=Vt.fromString(n.toString());break;case`resolvedImage`:n=Jt.fromString(n.toString());break;case`padding`:n=Ht.parse(n);break;case`colorArray`:n=Wt.parse(n);break;case`numberArray`:n=Ut.parse(n);break;default:ti(n)===t.type||t.type===`enum`&&t.values[n]||(n=void 0)}return ai(n,e.default,t.default)}Vr.register(Br,{error:[{kind:`error`},[Xe],(e,[t])=>{throw new Gt(t.evaluate(e))}],typeof:[Xe,[et],(e,[t])=>ct(Qt(t.evaluate(e)))],"to-rgba":[st(V,4),[H],(e,[t])=>{let[n,r,i,a]=t.evaluate(e).rgb;return[255*n,255*r,255*i,a]}],rgb:[H,[V,V,V],Hr],rgba:[H,[V,V,V,V],Hr],has:{type:Ze,overloads:[[[Xe],(e,[t])=>Ur(t.evaluate(e),e.properties())],[[Xe,$e],(e,[t,n])=>Ur(t.evaluate(e),n.evaluate(e))]]},get:{type:et,overloads:[[[Xe],(e,[t])=>Wr(t.evaluate(e),e.properties())],[[Xe,$e],(e,[t,n])=>Wr(t.evaluate(e),n.evaluate(e))]]},"feature-state":[et,[Xe],(e,[t])=>Wr(t.evaluate(e),e.featureState||{})],properties:[$e,[],e=>e.properties()],"geometry-type":[Xe,[],e=>e.geometryType()],id:[et,[],e=>e.id()],zoom:[V,[],e=>e.globals.zoom],"heatmap-density":[V,[],e=>e.globals.heatmapDensity||0],elevation:[V,[],e=>e.globals.elevation||0],"line-progress":[V,[],e=>e.globals.lineProgress||0],accumulated:[et,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[V,Gr(V),(e,t)=>{let n=0;for(let r of t)n+=r.evaluate(e);return n}],"*":[V,Gr(V),(e,t)=>{let n=1;for(let r of t)n*=r.evaluate(e);return n}],"-":{type:V,overloads:[[[V,V],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[V],(e,[t])=>-t.evaluate(e)]]},"/":[V,[V,V],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[V,[V,V],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[V,[],()=>Math.LN2],pi:[V,[],()=>Math.PI],e:[V,[],()=>Math.E],"^":[V,[V,V],(e,[t,n])=>t.evaluate(e)**+n.evaluate(e)],sqrt:[V,[V],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[V,[V],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[V,[V],(e,[t])=>Math.log(t.evaluate(e))],log2:[V,[V],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[V,[V],(e,[t])=>Math.sin(t.evaluate(e))],cos:[V,[V],(e,[t])=>Math.cos(t.evaluate(e))],tan:[V,[V],(e,[t])=>Math.tan(t.evaluate(e))],asin:[V,[V],(e,[t])=>Math.asin(t.evaluate(e))],acos:[V,[V],(e,[t])=>Math.acos(t.evaluate(e))],atan:[V,[V],(e,[t])=>Math.atan(t.evaluate(e))],min:[V,Gr(V),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[V,Gr(V),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[V,[V],(e,[t])=>Math.abs(t.evaluate(e))],round:[V,[V],(e,[t])=>{let n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[V,[V],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[V,[V],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Ze,[Xe,et],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[Ze,[et],(e,[t])=>e.id()===t.value],"filter-type-==":[Ze,[Xe],(e,[t])=>e.geometryType()===t.value],"filter-<":[Ze,[Xe,et],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<i}],"filter-id-<":[Ze,[et],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<r}],"filter->":[Ze,[Xe,et],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[Ze,[et],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[Ze,[Xe,et],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[Ze,[et],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[Ze,[Xe,et],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[Ze,[et],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[Ze,[et],(e,[t])=>t.value in e.properties()],"filter-has-id":[Ze,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[Ze,[st(Xe)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Ze,[st(et)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Ze,[Xe,st(et)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Ze,[Xe,st(et)],(e,[t,n])=>function(e,t,n,r){for(;n<=r;){let i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:Ze,overloads:[[[Ze,Ze],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[Gr(Ze),(e,t)=>{for(let n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:Ze,overloads:[[[Ze,Ze],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[Gr(Ze),(e,t)=>{for(let n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[Ze,[Ze],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Ze,[Xe],(e,[t])=>{let n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[Xe,[Xe],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Xe,[Xe],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Xe,Gr(et),(e,t)=>t.map((t=>$t(t.evaluate(e)))).join(``)],split:[st(Xe),[Xe,Xe],(e,[t,n])=>t.evaluate(e).split(n.evaluate(e))],join:[Xe,[st(Xe),Xe],(e,[t,n])=>t.evaluate(e).join(n.evaluate(e))],"resolved-locale":[Xe,[tt],(e,[t])=>t.evaluate(e).resolvedLocale()]});class ui{constructor(e,t,n){this.expression=e,this._warningHistory={},this._evaluator=new sn,this._defaultValue=t?function(e){if(e.type===`color`&&ni(e.default))return new Lt(0,0,0,0);switch(e.type){case`color`:return Lt.parse(e.default)||null;case`padding`:return Ht.parse(e.default)||null;case`numberArray`:return Ut.parse(e.default)||null;case`colorArray`:return Wt.parse(e.default)||null;case`variableAnchorOffsetCollection`:return qt.parse(e.default)||null;case`projectionDefinition`:return Yt.parse(e.default)||null;default:return e.default===void 0?null:e.default}}(t):null,this._enumValues=t&&t.type===`enum`?t.values:null,this._globalState=n}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=yi(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,a){this._globalState&&(e=yi(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null;try{let e=this.expression.evaluate(this._evaluator);if(e==null||typeof e==`number`&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Gt(`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,typeof console<`u`&&console.warn(e.message)),this._defaultValue}}}function di(e){return Array.isArray(e)&&e.length>0&&typeof e[0]==`string`&&e[0]in Br}function fi(e,t,n){let r=new cn(Br,Kr,[],t?function(e){let t={color:H,string:Xe,number:V,enum:Xe,boolean:Ze,formatted:nt,padding:U,numberArray:it,colorArray:rt,projectionDefinition:Qe,resolvedImage:at,variableAnchorOffsetCollection:ot};return e.type===`array`?st(t[e.value]||et,e.length):t[e.type]}(t):void 0),i=r.parse(e,void 0,void 0,void 0,t&&t.type===`string`?{typeAnnotation:`coerce`}:void 0);return i?Xr(new ui(i,t,n)):Zr(r.errors)}class pi{constructor(e,t,n){this.kind=e,this._styleExpression=t,this.isStateDependent=e!==`constant`&&!Jr(t.expression),this.globalStateRefs=vi(t.expression),this._globalState=n}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=yi(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=yi(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}}class mi{constructor(e,t,n,r,i){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent=e!==`camera`&&!Jr(t.expression),this.globalStateRefs=vi(t.expression),this.interpolationType=r,this._globalState=i}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=yi(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=yi(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}interpolationFactor(e,t,n){return this.interpolationType?Cn.interpolationFactor(this.interpolationType,e,t,n):0}}function hi(e,t,n){let r=fi(e,t,n);if(r.result===`error`)return r;let i=r.value.expression,a=qr(i);if(!a&&!Qr(t))return Zr([new qe(``,`data expressions not supported`)]);let o=Yr(i,[`zoom`]);if(!o&&!$r(t))return Zr([new qe(``,`zoom expressions not supported`)]);let s=_i(i);return s||o?s instanceof qe?Zr([s]):s instanceof Cn&&!ei(t)?Zr([new qe(``,`"interpolate" expressions cannot be used with this property`)]):Xr(s?new mi(a?`camera`:`composite`,r.value,s.labels,s instanceof Cn?s.interpolation:void 0,n):new pi(a?`constant`:`source`,r.value,n)):Zr([new qe(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`)])}class gi{constructor(e,t){this._parameters=e,this._specification=t,Ke(this,ii(this._parameters,this._specification))}static deserialize(e){return new gi(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function _i(e){let t=null;if(e instanceof ln)t=_i(e.result);else if(e instanceof En){for(let n of e.args)if(t=_i(n),t)break}else (e instanceof vn||e instanceof Cn)&&e.input instanceof Vr&&e.input.name===`zoom`&&(t=e);return t instanceof qe||e.eachChild((e=>{let n=_i(e);n instanceof qe?t=n:!t&&n?t=new qe(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`):t&&n&&t!==n&&(t=new qe(``,`Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.`))})),t}function vi(e,t=new Set){return e instanceof zr&&t.add(e.key),e.eachChild((e=>{vi(e,t)})),t}function yi(e,t){let{zoom:n,heatmapDensity:r,elevation:i,lineProgress:a,isSupportedScript:o,accumulated:s}=e??{};return{zoom:n,heatmapDensity:r,elevation:i,lineProgress:a,isSupportedScript:o,accumulated:s,globalState:t}}function bi(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||e.length===0)return!1;switch(e[0]){case`has`:return e.length>=2&&e[1]!==`$id`&&e[1]!==`$type`;case`in`:return e.length>=3&&(typeof e[1]!=`string`||Array.isArray(e[2]));case`!in`:case`!has`:case`none`:return!1;case`==`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2]);case`any`:case`all`:for(let t of e.slice(1))if(!bi(t)&&typeof t!=`boolean`)return!1;return!0;default:return!0}}let xi={type:`boolean`,default:!1,transition:!1,"property-type":`data-driven`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]}};function Si(e,t){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};bi(e)||(e=Ti(e));let n=fi(e,xi,t);if(n.result===`error`)throw Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return{filter:(e,t,r)=>n.value.evaluate(e,t,{},r),needGeometry:wi(e),getGlobalStateRefs:()=>vi(n.value.expression)}}function Ci(e,t){return e<t?-1:+(e>t)}function wi(e){if(!Array.isArray(e))return!1;if(e[0]===`within`||e[0]===`distance`)return!0;for(let t=1;t<e.length;t++)if(wi(e[t]))return!0;return!1}function Ti(e){if(!e)return!0;let t=e[0];return e.length<=1?t!==`any`:t===`==`?Ei(e[1],e[2],`==`):t===`!=`?ki(Ei(e[1],e[2],`==`)):t===`<`||t===`>`||t===`<=`||t===`>=`?Ei(e[1],e[2],t):t===`any`?(n=e.slice(1),[`any`].concat(n.map(Ti))):t===`all`?[`all`].concat(e.slice(1).map(Ti)):t===`none`?[`all`].concat(e.slice(1).map(Ti).map(ki)):t===`in`?Di(e[1],e.slice(2)):t===`!in`?ki(Di(e[1],e.slice(2))):t===`has`?Oi(e[1]):t!==`!has`||ki(Oi(e[1]));var n}function Ei(e,t,n){switch(e){case`$type`:return[`filter-type-${n}`,t];case`$id`:return[`filter-id-${n}`,t];default:return[`filter-${n}`,e,t]}}function Di(e,t){if(t.length===0)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(Ci)]]:[`filter-in-small`,e,[`literal`,t]]}}function Oi(e){switch(e){case`$type`:return!0;case`$id`:return[`filter-has-id`];default:return[`filter-has`,e]}}function ki(e){return[`!`,e]}function Ai(e){let t=typeof e;if(t===`number`||t===`boolean`||t===`string`||e==null)return JSON.stringify(e);if(Array.isArray(e)){let t=`[`;for(let n of e)t+=`${Ai(n)},`;return`${t}]`}let n=Object.keys(e).sort(),r=`{`;for(let t=0;t<n.length;t++)r+=`${JSON.stringify(n[t])}:${Ai(e[n[t]])},`;return`${r}}`}function ji(e){let t=``;for(let n of Fe)t+=`/${Ai(e[n])}`;return t}function Mi(e){let t=e.value;return t?[new B(e.key,t,`constants have been deprecated as of v8`)]:[]}function Ni(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Pi(e){if(Array.isArray(e))return e.map(Pi);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let n in e)t[n]=Pi(e[n]);return t}return Ni(e)}function Fi(e){let t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},a=e.style,o=e.styleSpec,s=e.validateSpec,c=[],l=ti(n);if(l!==`object`)return[new B(t,n,`object expected, ${l} found`)];for(let e in n){let l=e.split(`.`)[0],u=kt(r,l)||r[`*`],d;if(kt(i,l))d=i[l];else if(kt(r,l)){if(n[e]===void 0)continue;d=s}else if(i[`*`])d=i[`*`];else{if(!r[`*`]){c.push(new B(t,n[e],`unknown property "${e}"`));continue}d=s}c=c.concat(d({key:(t&&`${t}.`)+e,value:n[e],valueSpec:u,style:a,styleSpec:o,object:n,objectKey:e,validateSpec:s},n))}for(let e in r)i[e]||r[e].required&&r[e].default===void 0&&n[e]===void 0&&c.push(new B(t,n,`missing required property "${e}"`));return c}function Ii(e){let t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,a=e.key,o=e.arrayElementValidator||e.validateSpec;if(ti(t)!==`array`)return[new B(a,t,`array expected, ${ti(t)} found`)];if(n.length&&t.length!==n.length)return[new B(a,t,`array length ${n.length} expected, length ${t.length} found`)];let s={type:n.value,values:n.values};i.$version<7&&(s.function=n.function),ti(n.value)===`object`&&(s=n.value);let c=[];for(let n=0;n<t.length;n++)c=c.concat(o({array:t,arrayIndex:n,value:t[n],valueSpec:s,validateSpec:e.validateSpec,style:r,styleSpec:i,key:`${a}[${n}]`}));return c}function Li(e){let t=e.key,n=e.value,r=e.valueSpec,i=ti(n);return i===`number`&&n!=n&&(i=`NaN`),i===`number`?`minimum`in r&&n<r.minimum?[new B(t,n,`${n} is less than the minimum value ${r.minimum}`)]:`maximum`in r&&n>r.maximum?[new B(t,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]:[new B(t,n,`number expected, ${i} found`)]}function Ri(e){let t=e.valueSpec,n=Ni(e.value.type),r,i,a,o={},s=n!==`categorical`&&e.value.property===void 0,c=!s,l=ti(e.value.stops)===`array`&&ti(e.value.stops[0])===`array`&&ti(e.value.stops[0][0])===`object`,u=Fi({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if(n===`identity`)return[new B(e.key,e.value,`identity function may not have a "stops" property`)];let t=[],r=e.value;return t=t.concat(Ii({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:d})),ti(r)===`array`&&r.length===0&&t.push(new B(e.key,r,`array must have at least one stop`)),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return n===`identity`&&s&&u.push(new B(e.key,e.value,`missing required property "property"`)),n===`identity`||e.value.stops||u.push(new B(e.key,e.value,`missing required property "stops"`)),n===`exponential`&&e.valueSpec.expression&&!ei(e.valueSpec)&&u.push(new B(e.key,e.value,`exponential functions not supported`)),e.styleSpec.$version>=8&&(c&&!Qr(e.valueSpec)?u.push(new B(e.key,e.value,`property functions not supported`)):s&&!$r(e.valueSpec)&&u.push(new B(e.key,e.value,`zoom functions not supported`))),n!==`categorical`&&!l||e.value.property!==void 0||u.push(new B(e.key,e.value,`"property" property is required`)),u;function d(e){let n=[],r=e.value,s=e.key;if(ti(r)!==`array`)return[new B(s,r,`array expected, ${ti(r)} found`)];if(r.length!==2)return[new B(s,r,`array length 2 expected, length ${r.length} found`)];if(l){if(ti(r[0])!==`object`)return[new B(s,r,`object expected, ${ti(r[0])} found`)];if(r[0].zoom===void 0)return[new B(s,r,`object stop key must have zoom`)];if(r[0].value===void 0)return[new B(s,r,`object stop key must have value`)];if(a&&a>Ni(r[0].zoom))return[new B(s,r[0].zoom,`stop zoom values must appear in ascending order`)];Ni(r[0].zoom)!==a&&(a=Ni(r[0].zoom),i=void 0,o={}),n=n.concat(Fi({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Li,value:f}}))}else n=n.concat(f({key:`${s}[0]`,value:r[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return di(Pi(r[1]))?n.concat([new B(`${s}[1]`,r[1],`expressions are not allowed in function stops.`)]):n.concat(e.validateSpec({key:`${s}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function f(e,a){let s=ti(e.value),c=Ni(e.value),l=e.value===null?a:e.value;if(r){if(s!==r)return[new B(e.key,l,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if(s!==`number`&&s!==`string`&&s!==`boolean`)return[new B(e.key,l,`stop domain value must be a number, string, or boolean`)];if(s!==`number`&&n!==`categorical`){let r=`number expected, ${s} found`;return Qr(t)&&n===void 0&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new B(e.key,l,r)]}return n!==`categorical`||s!==`number`||isFinite(c)&&Math.floor(c)===c?n!==`categorical`&&s===`number`&&i!==void 0&&c<i?[new B(e.key,l,`stop domain values must appear in ascending order`)]:(i=c,n===`categorical`&&c in o?[new B(e.key,l,`stop domain values must be unique`)]:(o[c]=!0,[])):[new B(e.key,l,`integer expected, found ${c}`)]}}function zi(e){let t=(e.expressionContext===`property`?hi:fi)(Pi(e.value),e.valueSpec);if(t.result===`error`)return t.value.map((t=>new B(`${e.key}${t.key}`,e.value,t.message)));let n=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext===`property`&&e.propertyKey===`text-font`&&!n.outputDefined())return[new B(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext===`property`&&e.propertyType===`layout`&&!Jr(n))return[new B(e.key,e.value,`"feature-state" data expressions are not supported with layout properties.`)];if(e.expressionContext===`filter`&&!Jr(n))return[new B(e.key,e.value,`"feature-state" data expressions are not supported with filters.`)];if(e.expressionContext&&e.expressionContext.indexOf(`cluster`)===0){if(!Yr(n,[`zoom`,`feature-state`]))return[new B(e.key,e.value,`"zoom" and "feature-state" expressions are not supported with cluster properties.`)];if(e.expressionContext===`cluster-initial`&&!qr(n))return[new B(e.key,e.value,`Feature data expressions are not supported with initial expression part of cluster properties.`)]}return[]}function Bi(e){let t=e.key,n=e.value,r=ti(n);return r===`string`?Lt.parse(String(n))?[]:[new B(t,n,`color expected, "${n}" found`)]:[new B(t,n,`color expected, ${r} found`)]}function Vi(e){let t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?r.values.indexOf(Ni(n))===-1&&i.push(new B(t,n,`expected one of [${r.values.join(`, `)}], ${JSON.stringify(n)} found`)):Object.keys(r.values).indexOf(Ni(n))===-1&&i.push(new B(t,n,`expected one of [${Object.keys(r.values).join(`, `)}], ${JSON.stringify(n)} found`)),i}function Hi(e){return bi(Pi(e.value))?zi(Ke({},e,{expressionContext:`filter`,valueSpec:{value:`boolean`}})):Ui(e)}function Ui(e){let t=e.value,n=e.key;if(ti(t)!==`array`)return[new B(n,t,`array expected, ${ti(t)} found`)];let r=e.styleSpec,i,a=[];if(t.length<1)return[new B(n,t,`filter array must have at least 1 element`)];switch(a=a.concat(Vi({key:`${n}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),Ni(t[0])){case`<`:case`<=`:case`>`:case`>=`:t.length>=2&&Ni(t[1])===`$type`&&a.push(new B(n,t,`"$type" cannot be use with operator "${t[0]}"`));case`==`:case`!=`:t.length!==3&&a.push(new B(n,t,`filter array for operator "${t[0]}" must have 3 elements`));case`in`:case`!in`:t.length>=2&&(i=ti(t[1]),i!==`string`&&a.push(new B(`${n}[1]`,t[1],`string expected, ${i} found`)));for(let o=2;o<t.length;o++)i=ti(t[o]),Ni(t[1])===`$type`?a=a.concat(Vi({key:`${n}[${o}]`,value:t[o],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):i!==`string`&&i!==`number`&&i!==`boolean`&&a.push(new B(`${n}[${o}]`,t[o],`string, number, or boolean expected, ${i} found`));break;case`any`:case`all`:case`none`:for(let r=1;r<t.length;r++)a=a.concat(Ui({key:`${n}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case`has`:case`!has`:i=ti(t[1]),t.length===2?i!==`string`&&a.push(new B(`${n}[1]`,t[1],`string expected, ${i} found`)):a.push(new B(n,t,`filter array for "${t[0]}" operator must have 2 elements`))}return a}function Wi(e,t){let n=e.key,r=e.validateSpec,i=e.style,a=e.styleSpec,o=e.value,s=e.objectKey,c=a[`${t}_${e.layerType}`];if(!c)return[];let l=s.match(/^(.*)-transition$/);if(t===`paint`&&l&&c[l[1]]&&c[l[1]].transition)return r({key:n,value:o,valueSpec:a.transition,style:i,styleSpec:a});let u=e.valueSpec||c[s];if(!u)return[new B(n,o,`unknown property "${s}"`)];let d;if(ti(o)===`string`&&Qr(u)&&!u.tokens&&(d=/^{([^}]+)}$/.exec(o)))return[new B(n,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(d[1])} }\`.`)];let f=[];return e.layerType===`symbol`&&s===`text-font`&&ni(Pi(o))&&Ni(o.type)===`identity`&&f.push(new B(n,o,`"text-font" does not support identity functions`)),f.concat(r({key:e.key,value:o,valueSpec:u,style:i,styleSpec:a,expressionContext:`property`,propertyType:t,propertyKey:s}))}function Gi(e){return Wi(e,`paint`)}function Ki(e){return Wi(e,`layout`)}function qi(e){var t,n;let r=[],i=e.value,a=e.key,o=e.style,s=e.styleSpec;if(ti(i)!==`object`)return[new B(a,i,`object expected, ${ti(i)} found`)];i.type||i.ref||r.push(new B(a,i,`either "type" or "ref" is required`));let c=Ni(i.type),l=Ni(i.ref);if(i.id){let t=Ni(i.id);for(let n=0;n<e.arrayIndex;n++){let e=o.layers[n];Ni(e.id)===t&&r.push(new B(a,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&&r.push(new B(a,i[e],`"${e}" is prohibited for ref layers`))})),o.layers.forEach((t=>{Ni(t.id)===l&&(e=t)})),e?e.ref?r.push(new B(a,i.ref,`ref cannot reference another ref layer`)):c=Ni(e.type):r.push(new B(a,i.ref,`ref layer "${l}" not found`))}else if(c!==`background`)if(i.source){let e=o.sources&&o.sources[i.source],t=e&&Ni(e.type);e?t===`vector`&&c===`raster`?r.push(new B(a,i.source,`layer "${i.id}" requires a raster source`)):t!==`raster-dem`&&c===`hillshade`||t!==`raster-dem`&&c===`color-relief`?r.push(new B(a,i.source,`layer "${i.id}" requires a raster-dem source`)):t===`raster`&&c!==`raster`?r.push(new B(a,i.source,`layer "${i.id}" requires a vector source`)):t!==`vector`||i[`source-layer`]?t===`raster-dem`&&c!==`hillshade`&&c!==`color-relief`?r.push(new B(a,i.source,`raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.`)):c!==`line`||!i.paint||!i.paint[`line-gradient`]||t===`geojson`&&e.lineMetrics||r.push(new B(a,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new B(a,i,`layer "${i.id}" must specify a "source-layer"`)):r.push(new B(a,i.source,`source "${i.source}" not found`))}else r.push(new B(a,i,`missing required property "source"`));return c===`raster`&&(t=i.paint)!=null&&t.resampling&&(n=i.paint)!=null&&n[`raster-resampling`]&&r.push(new B(a,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),r=r.concat(Fi({key:a,value:i,valueSpec:s.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${a}.type`,value:i.type,valueSpec:s.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:`type`}),filter:Hi,layout:e=>Fi({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Ki(Ke({layerType:c},e))}}),paint:e=>Fi({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Gi(Ke({layerType:c},e))}})}})),r}function Ji(e){let t=e.value,n=e.key,r=ti(t);return r===`string`?[]:[new B(n,t,`string expected, ${r} found`)]}let Yi={promoteId:function({key:e,value:t}){if(ti(t)===`string`)return Ji({key:e,value:t});{let n=[];for(let r in t)n.push(...Ji({key:`${e}.${r}`,value:t[r]}));return n}}};function Xi(e){let t=e.value,n=e.key,r=e.styleSpec,i=e.style,a=e.validateSpec;if(!t.type)return[new B(n,t,`"type" is required`)];let o=Ni(t.type),s;switch(o){case`vector`:case`raster`:return s=Fi({key:n,value:t,valueSpec:r[`source_${o.replace(`-`,`_`)}`],style:e.style,styleSpec:r,objectElementValidators:Yi,validateSpec:a}),s;case`raster-dem`:return s=function(e){let t=e.sourceName??``,n=e.value,r=e.styleSpec,i=r.source_raster_dem,a=e.style,o=[],s=ti(n);if(n===void 0)return o;if(s!==`object`)return o.push(new B(`source_raster_dem`,n,`object expected, ${s} found`)),o;let c=Ni(n.encoding)===`custom`,l=[`redFactor`,`greenFactor`,`blueFactor`,`baseShift`],u=e.value.encoding?`"${e.value.encoding}"`:`Default`;for(let s in n)!c&&l.includes(s)?o.push(new B(s,n[s],`In "${t}": "${s}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):i[s]?o=o.concat(e.validateSpec({key:s,value:n[s],valueSpec:i[s],validateSpec:e.validateSpec,style:a,styleSpec:r})):o.push(new B(s,n[s],`unknown property "${s}"`));return o}({sourceName:n,value:t,style:e.style,styleSpec:r,validateSpec:a}),s;case`geojson`:if(s=Fi({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:a,objectElementValidators:Yi}),t.cluster)for(let e in t.clusterProperties){let[r,i]=t.clusterProperties[e],a=typeof r==`string`?[r,[`accumulated`],[`get`,e]]:r;s.push(...zi({key:`${n}.${e}.map`,value:i,expressionContext:`cluster-map`})),s.push(...zi({key:`${n}.${e}.reduce`,value:a,expressionContext:`cluster-reduce`}))}return s;case`video`:return Fi({key:n,value:t,valueSpec:r.source_video,style:i,validateSpec:a,styleSpec:r});case`image`:return Fi({key:n,value:t,valueSpec:r.source_image,style:i,validateSpec:a,styleSpec:r});case`canvas`:return[new B(n,null,`Please use runtime APIs to add canvas sources, rather than including them in stylesheets.`,`source.canvas`)];default:return Vi({key:`${n}.type`,value:t.type,valueSpec:{values:[`vector`,`raster`,`raster-dem`,`geojson`,`video`,`image`]}})}}function Zi(e){let t=e.value,n=e.styleSpec,r=n.light,i=e.style,a=[],o=ti(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new B(`light`,t,`object expected, ${o} found`)]),a;for(let o in t){let s=o.match(/^(.*)-transition$/);a=a.concat(s&&r[s[1]]&&r[s[1]].transition?e.validateSpec({key:o,value:t[o],valueSpec:n.transition,validateSpec:e.validateSpec,style:i,styleSpec:n}):r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n}):[new B(o,t[o],`unknown property "${o}"`)])}return a}function Qi(e){let t=e.value,n=e.styleSpec,r=n.sky,i=e.style,a=ti(t);if(t===void 0)return[];if(a!==`object`)return[new B(`sky`,t,`object expected, ${a} found`)];let o=[];for(let a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n}):[new B(a,t[a],`unknown property "${a}"`)]);return o}function $i(e){let t=e.value,n=e.styleSpec,r=n.terrain,i=e.style,a=[],o=ti(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new B(`terrain`,t,`object expected, ${o} found`)]),a;for(let o in t)a=a.concat(r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n}):[new B(o,t[o],`unknown property "${o}"`)]);return a}function ea(e){let t=[],n=e.value,r=e.key;if(Array.isArray(n)){let i=[],a=[];for(let o in n)n[o].id&&i.includes(n[o].id)&&t.push(new B(r,n,`all the sprites' ids must be unique, but ${n[o].id} is duplicated`)),i.push(n[o].id),n[o].url&&a.includes(n[o].url)&&t.push(new B(r,n,`all the sprites' URLs must be unique, but ${n[o].url} is duplicated`)),a.push(n[o].url),t=t.concat(Fi({key:`${r}[${o}]`,value:n[o],valueSpec:{id:{type:`string`,required:!0},url:{type:`string`,required:!0}},validateSpec:e.validateSpec}));return t}return Ji({key:r,value:n})}function ta(e){return!!e&&e.constructor===Object}function na(e){return ta(e.value)?[]:[new B(e.key,e.value,`object expected, ${ti(e.value)} found`)]}let ra={"*":()=>[],array:Ii,boolean:function(e){let t=e.value,n=e.key,r=ti(t);return r===`boolean`?[]:[new B(n,t,`boolean expected, ${r} found`)]},number:Li,color:Bi,constants:Mi,enum:Vi,filter:Hi,function:Ri,layer:qi,object:Fi,source:Xi,light:Zi,sky:Qi,terrain:$i,projection:function(e){let t=e.value,n=e.styleSpec,r=n.projection,i=e.style,a=ti(t);if(t===void 0)return[];if(a!==`object`)return[new B(`projection`,t,`object expected, ${a} found`)];let o=[];for(let a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n}):[new B(a,t[a],`unknown property "${a}"`)]);return o},projectionDefinition:function(e){let t=e.key,n=e.value;n=n instanceof String?n.valueOf():n;let r=ti(n);return r!==`array`||function(e){return Array.isArray(e)&&e.length===3&&typeof e[0]==`string`&&typeof e[1]==`string`&&typeof e[2]==`number`}(n)||function(e){return!![`interpolate`,`step`,`literal`].includes(e[0])}(n)?[`array`,`string`].includes(r)?[]:[new B(t,n,`projection expected, invalid type "${r}" found`)]:[new B(t,n,`projection expected, invalid array ${JSON.stringify(n)} found`)]},string:Ji,formatted:function(e){return Ji(e).length===0?[]:zi(e)},resolvedImage:function(e){return Ji(e).length===0?[]:zi(e)},padding:function(e){let t=e.key,n=e.value;if(ti(n)===`array`){if(n.length<1||n.length>4)return[new B(t,n,`padding requires 1 to 4 values; ${n.length} values found`)];let r={type:`number`},i=[];for(let a=0;a<n.length;a++)i=i.concat(e.validateSpec({key:`${t}[${a}]`,value:n[a],validateSpec:e.validateSpec,valueSpec:r}));return i}return Li({key:t,value:n,valueSpec:{}})},numberArray:function(e){let t=e.key,n=e.value;if(ti(n)===`array`){let r={type:`number`};if(n.length<1)return[new B(t,n,`array length at least 1 expected, length 0 found`)];let i=[];for(let a=0;a<n.length;a++)i=i.concat(e.validateSpec({key:`${t}[${a}]`,value:n[a],validateSpec:e.validateSpec,valueSpec:r}));return i}return Li({key:t,value:n,valueSpec:{}})},colorArray:function(e){let t=e.key,n=e.value;if(ti(n)===`array`){if(n.length<1)return[new B(t,n,`array length at least 1 expected, length 0 found`)];let e=[];for(let r=0;r<n.length;r++)e=e.concat(Bi({key:`${t}[${r}]`,value:n[r]}));return e}return Bi({key:t,value:n})},variableAnchorOffsetCollection:function(e){let t=e.key,n=e.value,r=ti(n),i=e.styleSpec;if(r!==`array`||n.length<1||n.length%2!=0)return[new B(t,n,`variableAnchorOffsetCollection requires a non-empty array of even length`)];let a=[];for(let r=0;r<n.length;r+=2)a=a.concat(Vi({key:`${t}[${r}]`,value:n[r],valueSpec:i.layout_symbol[`text-anchor`]})),a=a.concat(Ii({key:`${t}[${r+1}]`,value:n[r+1],valueSpec:{length:2,value:`number`},validateSpec:e.validateSpec,style:e.style,styleSpec:i}));return a},sprite:ea,state:na,fontFaces:function(e){let t=e.key,n=e.value,r=e.validateSpec,i=e.styleSpec,a=e.style;if(!ta(n))return[new B(t,n,`object expected, ${ti(n)} found`)];let o=[];for(let e in n){let s=n[e],c=ti(s);if(c===`string`)o.push(...Ji({key:`${t}.${e}`,value:s}));else if(c===`array`){let n={url:{type:`string`,required:!0},"unicode-range":{type:`array`,value:`string`}};for(let[c,l]of s.entries())o.push(...Fi({key:`${t}.${e}[${c}]`,value:l,valueSpec:n,styleSpec:i,style:a,validateSpec:r}))}else o.push(new B(`${t}.${e}`,s,`string or array expected, ${c} found`))}return o}};function ia(e){let t=e.value,n=e.valueSpec,r=e.styleSpec;return e.validateSpec=ia,n.expression&&ni(Ni(t))?Ri(e):n.expression&&di(Pi(t))?zi(e):n.type&&ra[n.type]?ra[n.type](e):Fi(Ke({},e,{valueSpec:n.type?r[n.type]:n}))}function aa(e){let t=e.value,n=e.key,r=Ji(e);return r.length||(t.indexOf(`{fontstack}`)===-1&&r.push(new B(n,t,`"glyphs" url must include a "{fontstack}" token`)),t.indexOf(`{range}`)===-1&&r.push(new B(n,t,`"glyphs" url must include a "{range}" token`))),r}function oa(e,t=z){let n=[];return n=n.concat(ia({key:``,value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:ia,objectElementValidators:{glyphs:aa,"*":()=>[]}})),e.constants&&(n=n.concat(Mi({key:`constants`,value:e.constants}))),ca(n)}function sa(e){return function(t){return e(Object.assign({},t,{validateSpec:ia}))}}function ca(e){return[].concat(e).sort(((e,t)=>e.line-t.line))}function la(e){return function(...t){return ca(e.apply(this,t))}}oa.source=la(sa(Xi)),oa.sprite=la(sa(ea)),oa.glyphs=la(sa(aa)),oa.light=la(sa(Zi)),oa.sky=la(sa(Qi)),oa.terrain=la(sa($i)),oa.state=la(sa(na)),oa.layer=la(sa(qi)),oa.filter=la(sa(Hi)),oa.paintProperty=la(sa(Gi)),oa.layoutProperty=la(sa(Ki));let ua={type:`enum`,"property-type":`data-constant`,expression:{interpolated:!1,parameters:[`global-state`]},values:{visible:{},none:{}},transition:!1,default:`visible`};class da{constructor(e,t){this._globalState=t,this.setValue(e)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(e){if(e==null||e===`visible`||e===`none`)return this._literalValue=e===`none`?`none`:`visible`,this._compiledValue=void 0,void(this._globalStateRefs=new Set);let t=fi(e,ua,this._globalState);if(t.result===`error`)throw this._literalValue=`visible`,this._compiledValue=void 0,Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=vi(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}let fa=z,pa=oa,ma=pa.light,ha=pa.sky,ga=pa.paintProperty,_a=pa.layoutProperty;function va(e,t){let n=!1;if(t?.length)for(let r of t)e.fire(new Ne(Error(r.message))),n=!0;return n}class ya{constructor(e,t,n){let r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(let e=0;e<this.d*this.d;e++){let t=i[3+e],n=i[3+e+1];r.push(t===n?null:i.subarray(t,n))}let a=i[3+r.length+1];this.keys=i.subarray(i[3+r.length],a),this.bboxes=i.subarray(a),this.insert=this._insertReadonly}else{this.d=t+2*n;for(let e=0;e<this.d*this.d;e++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=n,this.scale=t/e,this.uid=0;let i=n/t*e;this.min=-i,this.max=e+i}insert(e,t,n,r,i){this._forEachCell(t,n,r,i,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)}_insertReadonly(){throw Error(`Cannot insert into a GridIndex created from an ArrayBuffer.`)}_insertCell(e,t,n,r,i,a){this.cells[i].push(a)}query(e,t,n,r,i){let a=this.min,o=this.max;if(e<=a&&t<=a&&o<=n&&o<=r&&!i)return[...this.keys];{let a=[];return this._forEachCell(e,t,n,r,this._queryCell,a,{},i),a}}_queryCell(e,t,n,r,i,a,o,s){let c=this.cells[i];if(c!==null){let i=this.keys,l=this.bboxes;for(let u of c)if(o[u]===void 0){let c=4*u;(s?s(l[c+0],l[c+1],l[c+2],l[c+3]):e<=l[c+2]&&t<=l[c+3]&&n>=l[c+0]&&r>=l[c+1])?(o[u]=!0,a.push(i[u])):o[u]=!1}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToCellCoord(e),l=this._convertToCellCoord(t),u=this._convertToCellCoord(n),d=this._convertToCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++){let l=this.d*c+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(c),this._convertFromCellCoord(f+1),this._convertFromCellCoord(c+1)))&&i.call(this,e,t,n,r,l,a,o,s))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,t=3+this.cells.length+1+1,n=0;for(let e of this.cells)n+=e.length;let r=new Int32Array(t+n+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let i=t;for(let t=0;t<e.length;t++){let n=e[t];r[3+t]=i,r.set(n,i),i+=n.length}return r[3+e.length]=i,r.set(this.keys,i),i+=this.keys.length,r[3+e.length+1]=i,r.set(this.bboxes,i),i+=this.bboxes.length,r.buffer}static serialize(e,t){let n=e.toArrayBuffer();return t&&t.push(n),{buffer:n}}static deserialize(e){return new ya(e.buffer)}}let ba={};function W(e,t,n={}){if(ba[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ba[e]={klass:t,omit:n.omit||[],shallow:n.shallow||[]}}W(`Object`,Object),W(`Set`,Set),W(`TransferableGridIndex`,ya),W(`Color`,Lt),W(`Error`,Error),W(`AJAXError`,Ee),W(`ResolvedImage`,Jt),W(`StylePropertyFunction`,gi),W(`StyleExpression`,ui,{omit:[`_evaluator`]}),W(`ZoomDependentExpression`,mi),W(`ZoomConstantExpression`,pi),W(`CompoundExpression`,Vr,{omit:[`_evaluate`]});for(let e in Br)Br[e]._classRegistryKey||W(`Expression_${e}`,Br[e]);function xa(e){return e&&typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||e.constructor?.name===`ArrayBuffer`)}function Sa(e){return e.$name||e.constructor._classRegistryKey}function Ca(e){return!function(e){if(typeof e!=`object`||!e)return!1;let t=Sa(e);return t&&t!==`Object`}(e)&&(e==null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||xa(e)||le(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function wa(e,t){if(Ca(e))return(xa(e)||le(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let n=[];for(let r of e)n.push(wa(r,t));return n}if(typeof e!=`object`)throw Error(`can't serialize object of type `+typeof e);let n=Sa(e);if(!n)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!ba[n])throw Error(`${n} is not registered.`);let{klass:r}=ba[n],i=r.serialize?r.serialize(e,t):{};if(r.serialize){if(i===t?.[t.length-1])throw Error(`statically serialized object won't survive transfer of $name property`)}else{for(let r in e){if(!e.hasOwnProperty(r)||ba[n].omit.includes(r))continue;let a=e[r];i[r]=ba[n].shallow.includes(r)?a:wa(a,t)}e instanceof Error&&(i.message=e.message)}if(i.$name)throw Error(`$name property is reserved for worker serialization logic.`);return n!==`Object`&&(i.$name=n),i}function Ta(e){if(Ca(e))return e;if(Array.isArray(e))return e.map(Ta);if(typeof e!=`object`)throw Error(`can't deserialize object of type `+typeof e);let t=Sa(e)||`Object`;if(!ba[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:n}=ba[t];if(!n)throw Error(`can't deserialize unregistered class ${t}`);if(n.deserialize)return n.deserialize(e);let r=Object.create(n.prototype);for(let n of Object.keys(e)){if(n===`$name`)continue;let i=e[n];r[n]=ba[t].shallow.includes(n)?i:Ta(i)}return r}class Ea{constructor(){this.first=!0}update(e,t){let n=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<n&&(this.lastIntegerZoom=n,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=n,!0))}}function Da(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function Oa(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function ka(e){return/\s/u.test(String.fromCodePoint(e))}function Aa(e){for(let t of e)if(Oa(t.codePointAt(0)))return!0;return!1}function ja(e){for(let t of e)if(!Pa(t.codePointAt(0)))return!1;return!0}function Ma(e){let t=e.map((e=>{try{return RegExp(`\\p{sc=${e}}`,`u`).source}catch{return null}})).filter((e=>e));return new RegExp(t.join(`|`),`u`)}let Na=Ma([`Arab`,`Dupl`,`Mong`,`Ougr`,`Syrc`]);function Pa(e){return!Na.test(String.fromCodePoint(e))}function Fa(e){return!(Oa(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}let Ia=Ma(`Adlm.Arab.Armi.Avst.Chrs.Cprt.Egyp.Elym.Gara.Hatr.Hebr.Hung.Khar.Lydi.Mand.Mani.Mend.Merc.Mero.Narb.Nbat.Nkoo.Orkh.Palm.Phli.Phlp.Phnx.Prti.Rohg.Samr.Sarb.Sogo.Syrc.Thaa.Todr.Yezi`.split(`.`));function La(e){return Ia.test(String.fromCodePoint(e))}function Ra(e,t){return!(!t&&La(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function za(e){for(let t of e)if(La(t.codePointAt(0)))return!0;return!1}let Ba=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus=`unavailable`,this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Ba.isParsed())throw Error(`RTL text plugin already registered.`);this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,n){return t(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if(e.pluginStatus!==`loading`)return this.setState(e),e;let t=e.pluginURL,r=new Promise((e=>{this.loadScriptResolve=e}));n(t);let i=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([r,i]),this.isParsed()){let e={pluginStatus:`loaded`,pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:`error`,pluginURL:``}),Error(`RTL Text Plugin failed to import scripts from ${t}`)}))}};class Va{constructor(e,t){this.isSupportedScript=Ha,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new Ea,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ea,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,t=e-Math.floor(e),n=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*t}}}function Ha(e){return function(e,t){for(let n of e)if(!Ra(n.codePointAt(0),t))return!1;return!0}(e,Ba.getRTLTextPluginStatus()===`loaded`)}let Ua=`-transition`;class Wa{constructor(e,t,n){this.property=e,this.value=t,this.expression=function(e,t,n){if(ni(e))return new gi(e,t);if(di(e)){let r=hi(e,t,n);if(r.result===`error`)throw Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return r.value}{let n=e;return t.type===`color`&&typeof e==`string`?n=Lt.parse(e):t.type!==`padding`||typeof e!=`number`&&!Array.isArray(e)?t.type!==`numberArray`||typeof e!=`number`&&!Array.isArray(e)?t.type!==`colorArray`||typeof e!=`string`&&!Array.isArray(e)?t.type===`variableAnchorOffsetCollection`&&Array.isArray(e)?n=qt.parse(e):t.type===`projectionDefinition`&&typeof e==`string`&&(n=Yt.parse(e)):n=Wt.parse(e):n=Ut.parse(e):n=Ht.parse(e),{globalStateRefs:new Set,_globalState:null,kind:`constant`,evaluate:()=>n}}}(t===void 0?e.specification.default:t,e.specification,n)}isDataDriven(){return this.expression.kind===`source`||this.expression.kind===`composite`}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class Ga{constructor(e,t){this.property=e,this.value=new Wa(e,void 0,t)}transitioned(e,t){return new qa(this.property,this.value,t,L({},e.transition,this.transition),e.now)}untransitioned(){return new qa(this.property,this.value,null,{},0)}}class Ka{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return re(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Ga(this._values[e].property,this._globalState)),this._values[e].value=new Wa(this._values[e].property,t===null?void 0:re(t),this._globalState)}getTransition(e){return re(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Ga(this._values[e].property,this._globalState)),this._values[e].transition=re(t)||void 0}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n);let r=this.getTransition(t);r!==void 0&&(e[`${t}${Ua}`]=r)}return e}transitioned(e,t){let n=new Ja(this._properties);for(let r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){let e=new Ja(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class qa{constructor(e,t,n,r,i){this.property=e,this.value=t,this.begin=i+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){let r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),a=this.prior;if(a){if(r>this.end||this.value.isDataDriven())return this.prior=null,i;if(r<this.begin)return a.possiblyEvaluate(e,t,n);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(a.possiblyEvaluate(e,t,n),i,N(o))}}return i}}class Ja{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,n){let r=new Za(this._properties);for(let i of Object.keys(this._values))r._values[i]=this._values[i].possiblyEvaluate(e,t,n);return r}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Ya{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=t}hasValue(e){return this._values[e].value!==void 0}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return re(this._values[e].value)}setValue(e,t){this._values[e]=new Wa(this._values[e].property,t===null?void 0:re(t),this._globalState)}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n)}return e}possiblyEvaluate(e,t,n){let r=new Za(this._properties);for(let i of Object.keys(this._values))r._values[i]=this._values[i].possiblyEvaluate(e,t,n);return r}}class Xa{constructor(e,t,n){this.property=e,this.value=t,this.parameters=n}isConstant(){return this.value.kind===`constant`}constantOr(e){return this.value.kind===`constant`?this.value.value:e}evaluate(e,t,n,r){return this.property.evaluate(this.value,this.parameters,e,t,n,r)}}class Za{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Qa{constructor(e){this.specification=e}possiblyEvaluate(e,t){if(e.isDataDriven())throw Error(`Value should not be data driven`);return e.expression.evaluate(t)}interpolate(e,t,n){let r=Tn[this.specification.type];return r?r(e,t,n):e}}class $a{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,n,r){return new Xa(this,e.expression.kind===`constant`||e.expression.kind===`camera`?{kind:`constant`,value:e.expression.evaluate(t,null,{},n,r)}:e.expression,t)}interpolate(e,t,n){if(e.value.kind!==`constant`||t.value.kind!==`constant`)return e;if(e.value.value===void 0||t.value.value===void 0)return new Xa(this,{kind:`constant`,value:void 0},e.parameters);let r=Tn[this.specification.type];if(r){let i=r(e.value.value,t.value.value,n);return new Xa(this,{kind:`constant`,value:i},e.parameters)}return e}evaluate(e,t,n,r,i,a){return e.kind===`constant`?e.value:e.evaluate(t,n,r,i,a)}}class eo extends $a{possiblyEvaluate(e,t,n,r){if(e.value===void 0)return new Xa(this,{kind:`constant`,value:void 0},t);if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r),a=e.property.specification.type===`resolvedImage`&&typeof i!=`string`?i.name:i,o=this._calculate(a,a,a,t);return new Xa(this,{kind:`constant`,value:o},t)}if(e.expression.kind===`camera`){let n=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 Xa(this,{kind:`constant`,value:n},t)}return new Xa(this,e.expression,t)}evaluate(e,t,n,r,i,a){if(e.kind===`source`){let o=e.evaluate(t,n,r,i,a);return this._calculate(o,o,o,t)}return e.kind===`composite`?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},n,r),e.evaluate({zoom:Math.floor(t.zoom)},n,r),e.evaluate({zoom:Math.floor(t.zoom)+1},n,r),t):e.value}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}}class to{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){if(e.value!==void 0){if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r);return this._calculate(i,i,i,t)}return this._calculate(e.expression.evaluate(new Va(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Va(Math.floor(t.zoom),t)),e.expression.evaluate(new Va(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}}class no{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){return!!e.expression.evaluate(t,null,{},n,r)}interpolate(){return!1}}class ro{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let n=e[t];n.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new Wa(n,void 0,void 0),i=this.defaultTransitionablePropertyValues[t]=new Ga(n,void 0);this.defaultTransitioningPropertyValues[t]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}}W(`DataDrivenProperty`,$a),W(`DataConstantProperty`,Qa),W(`CrossFadedDataDrivenProperty`,eo),W(`CrossFadedProperty`,to),W(`ColorRampProperty`,no);let io=` is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?`,ao=` is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?`;class oo extends Pe{constructor(e,t,n){if(super(),this.id=e.id,this.type=e.type,this._globalState=n,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,t){return new da(e,t)}(this.visibility,n),e.type!==`custom`&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!==`background`&&(this.source=e.source,this.sourceLayer=e[`source-layer`],this.filter=e.filter,this._featureFilter=Si(e.filter,n)),t.layout&&(this._unevaluatedLayout=new Ya(t.layout,n)),t.paint)){this._transitionablePaint=new Ka(t.paint,n);for(let t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(let t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Za(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=Si(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){if(e===`visibility`)return this.visibility;if(this._transitionablePaint?.hasProperty(e))throw Error(e+io);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=new Set;for(let t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let n=this._unevaluatedLayout._values[t];for(let t of n.getGlobalStateRefs())e.add(t)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){let e=new globalThis.Map;if(this._transitionablePaint)for(let t in this._transitionablePaint._values){let n=this._transitionablePaint._values[t].value;for(let r of n.getGlobalStateRefs()){let i=e.get(r)??[];i.push({name:t,value:n.value}),e.set(r,i)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,n={}){if(e===`visibility`)return this.visibility=t,this._visibilityExpression.setValue(t),void this.recalculateVisibility();this._transitionablePaint?.hasProperty(e)?this.fire(new Ne(Error(e+io))):t!=null&&this._validate(_a,`layers.${this.id}.layout.${e}`,e,t,n)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){if(e.endsWith(Ua)){let t=e.slice(0,-11);if(t===`visibility`||this._unevaluatedLayout?.hasProperty(t))throw Error(e+ao);return this._transitionablePaint.getTransition(t)}if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))throw Error(e+ao);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))return this.fire(new Ne(Error(e+ao))),!1;if(t!=null&&this._validate(ga,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(e.endsWith(Ua))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let n=this._transitionablePaint._values[e],r=n.property.specification[`property-type`]===`cross-faded-data-driven`,i=n.value.isDataDriven(),a=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let o=this._transitionablePaint._values[e].value;return o.isDataDriven()||i||r||this._handleOverridablePaintPropertyUpdate(e,a,o)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e=this.minzoom,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||this._evaluatedVisibility===`none`}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}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(){let 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?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(e.layout||={},e.layout.visibility=this.visibility),R(e,((e,t)=>!(e===void 0||t===`layout`&&!Object.keys(e).length||t===`paint`&&!Object.keys(e).length)))}_validate(e,t,n,r,i={}){return!1!==i?.validate&&va(this,e.call(pa,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:z,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof Xa&&Qr(t.property.specification)&&(t.value.kind===`source`||t.value.kind===`composite`)&&t.value.isStateDependent)return!0}return!1}}let so;var co={get paint(){return so||=new ro({"raster-opacity":new Qa(z.paint_raster[`raster-opacity`]),"raster-hue-rotate":new Qa(z.paint_raster[`raster-hue-rotate`]),"raster-brightness-min":new Qa(z.paint_raster[`raster-brightness-min`]),"raster-brightness-max":new Qa(z.paint_raster[`raster-brightness-max`]),"raster-saturation":new Qa(z.paint_raster[`raster-saturation`]),"raster-contrast":new Qa(z.paint_raster[`raster-contrast`]),resampling:new Qa(z.paint_raster.resampling),"raster-resampling":new Qa(z.paint_raster[`raster-resampling`]),"raster-fade-duration":new Qa(z.paint_raster[`raster-fade-duration`])})}};class lo extends oo{constructor(e,t){super(e,co,t)}}let uo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class fo{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 po{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){let 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);let t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw Error(`_refreshViews() must be implemented by each concrete StructArray layout`)}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}}function mo(e,t=1){let n=0,r=0;return{members:e.map((e=>{let i=uo[e.type].BYTES_PER_ELEMENT,a=n=ho(n,Math.max(t,i)),o=e.components||1;return r=Math.max(r,i),n+=i*o,{name:e.name,type:e.type,components:o,offset:a}})),size:ho(n,Math.max(r,t)),alignment:t}}function ho(e,t){return Math.ceil(e/t)*t}class go extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}go.prototype.bytesPerElement=4,W(`StructArrayLayout2i4`,go);class _o extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}_o.prototype.bytesPerElement=6,W(`StructArrayLayout3i6`,_o);class vo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=4*e;return this.int16[a+0]=t,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,e}}vo.prototype.bytesPerElement=8,W(`StructArrayLayout4i8`,vo);class yo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}}yo.prototype.bytesPerElement=12,W(`StructArrayLayout2i4i12`,yo);class bo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=4*e,c=8*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.uint8[c+4]=r,this.uint8[c+5]=i,this.uint8[c+6]=a,this.uint8[c+7]=o,e}}bo.prototype.bytesPerElement=8,W(`StructArrayLayout2i4ub8`,bo);class xo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}xo.prototype.bytesPerElement=8,W(`StructArrayLayout2f8`,xo);class So extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,n,r,i,a,o,s,c,l)}emplace(e,t,n,r,i,a,o,s,c,l,u){let d=10*e;return this.uint16[d+0]=t,this.uint16[d+1]=n,this.uint16[d+2]=r,this.uint16[d+3]=i,this.uint16[d+4]=a,this.uint16[d+5]=o,this.uint16[d+6]=s,this.uint16[d+7]=c,this.uint16[d+8]=l,this.uint16[d+9]=u,e}}So.prototype.bytesPerElement=20,W(`StructArrayLayout10ui20`,So);class Co extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,r,i,a,o,s)}emplace(e,t,n,r,i,a,o,s,c){let l=8*e;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=r,this.uint16[l+3]=i,this.uint16[l+4]=a,this.uint16[l+5]=o,this.uint16[l+6]=s,this.uint16[l+7]=c,e}}Co.prototype.bytesPerElement=16,W(`StructArrayLayout8ui16`,Co);class wo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,a,o,s,c,l,u,d)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=12*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.uint16[p+4]=a,this.uint16[p+5]=o,this.uint16[p+6]=s,this.uint16[p+7]=c,this.int16[p+8]=l,this.int16[p+9]=u,this.int16[p+10]=d,this.int16[p+11]=f,e}}wo.prototype.bytesPerElement=24,W(`StructArrayLayout4i4ui4i24`,wo);class To extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}To.prototype.bytesPerElement=12,W(`StructArrayLayout3f12`,To);class Eo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}Eo.prototype.bytesPerElement=4,W(`StructArrayLayout1ul4`,Eo);class Do extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,r,i,a,o,s,c)}emplace(e,t,n,r,i,a,o,s,c,l){let u=10*e,d=5*e;return this.int16[u+0]=t,this.int16[u+1]=n,this.int16[u+2]=r,this.int16[u+3]=i,this.int16[u+4]=a,this.int16[u+5]=o,this.uint32[d+3]=s,this.uint16[u+8]=c,this.uint16[u+9]=l,e}}Do.prototype.bytesPerElement=20,W(`StructArrayLayout6i1ul2ui20`,Do);class Oo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}}Oo.prototype.bytesPerElement=12,W(`StructArrayLayout2i2i2i12`,Oo);class ko extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i)}emplace(e,t,n,r,i,a){let o=4*e,s=8*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.int16[s+6]=i,this.int16[s+7]=a,e}}ko.prototype.bytesPerElement=16,W(`StructArrayLayout2f1f2i16`,ko);class Ao extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=16*e,c=4*e,l=8*e;return this.uint8[s+0]=t,this.uint8[s+1]=n,this.float32[c+1]=r,this.float32[c+2]=i,this.int16[l+6]=a,this.int16[l+7]=o,e}}Ao.prototype.bytesPerElement=16,W(`StructArrayLayout2ub2f2i16`,Ao);class jo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}jo.prototype.bytesPerElement=6,W(`StructArrayLayout3ui6`,jo);class Mo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=this.length;return this.resize(_+1),this.emplace(_,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=24*e,y=12*e,b=48*e;return this.int16[v+0]=t,this.int16[v+1]=n,this.uint16[v+2]=r,this.uint16[v+3]=i,this.uint32[y+2]=a,this.uint32[y+3]=o,this.uint32[y+4]=s,this.uint16[v+10]=c,this.uint16[v+11]=l,this.uint16[v+12]=u,this.float32[y+7]=d,this.float32[y+8]=f,this.uint8[b+36]=p,this.uint8[b+37]=m,this.uint8[b+38]=h,this.uint32[y+10]=g,this.int16[v+22]=_,e}}Mo.prototype.bytesPerElement=48,W(`StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48`,Mo);class No extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D){let O=this.length;return this.resize(O+1),this.emplace(O,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O){let k=32*e,A=16*e;return this.int16[k+0]=t,this.int16[k+1]=n,this.int16[k+2]=r,this.int16[k+3]=i,this.int16[k+4]=a,this.int16[k+5]=o,this.int16[k+6]=s,this.int16[k+7]=c,this.uint16[k+8]=l,this.uint16[k+9]=u,this.uint16[k+10]=d,this.uint16[k+11]=f,this.uint16[k+12]=p,this.uint16[k+13]=m,this.uint16[k+14]=h,this.uint16[k+15]=g,this.uint16[k+16]=_,this.uint16[k+17]=v,this.uint16[k+18]=y,this.uint16[k+19]=b,this.uint16[k+20]=x,this.uint16[k+21]=S,this.uint16[k+22]=C,this.uint32[A+12]=w,this.float32[A+13]=T,this.float32[A+14]=E,this.uint16[k+30]=D,this.uint16[k+31]=O,e}}No.prototype.bytesPerElement=64,W(`StructArrayLayout8i15ui1ul2f2ui64`,No);class Po extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Po.prototype.bytesPerElement=4,W(`StructArrayLayout1f4`,Po);class Fo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.uint16[6*e+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}Fo.prototype.bytesPerElement=12,W(`StructArrayLayout1ui2f12`,Fo);class Io extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=4*e;return this.uint32[2*e+0]=t,this.uint16[i+2]=n,this.uint16[i+3]=r,e}}Io.prototype.bytesPerElement=8,W(`StructArrayLayout1ul2ui8`,Io);class Lo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}Lo.prototype.bytesPerElement=4,W(`StructArrayLayout2ui4`,Lo);class Ro extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Ro.prototype.bytesPerElement=2,W(`StructArrayLayout1ui2`,Ro);class zo extends po{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=4*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,e}}zo.prototype.bytesPerElement=16,W(`StructArrayLayout4f16`,zo);class Bo extends fo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}Bo.prototype.size=20;class Vo extends Do{get(e){return new Bo(this,e)}}W(`CollisionBoxArray`,Vo);class Ho extends fo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Ho.prototype.size=48;class Uo extends Mo{get(e){return new Ho(this,e)}}W(`PlacedSymbolArray`,Uo);class Wo extends fo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Wo.prototype.size=64;class Go extends No{get(e){return new Wo(this,e)}}W(`SymbolInstanceArray`,Go);class Ko extends Po{getoffsetX(e){return this.float32[1*e+0]}}W(`GlyphOffsetArray`,Ko);class qo extends _o{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}W(`SymbolLineVertexArray`,qo);class Jo extends fo{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Jo.prototype.size=12;class Yo extends Fo{get(e){return new Jo(this,e)}}W(`TextAnchorOffsetArray`,Yo);class Xo extends fo{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]}}Xo.prototype.size=8;class Zo extends Io{get(e){return new Xo(this,e)}}W(`FeatureIndexArray`,Zo);class Qo extends go{}class $o extends go{}class es extends go{}class ts extends yo{}class ns extends bo{}class rs extends xo{}class is extends So{}class as extends Co{}class os extends wo{}class ss extends To{}class cs extends Eo{}class ls extends Oo{}class us extends Ao{}class ds extends jo{}class fs extends Lo{}let{members:ps}=mo([{name:`a_pos`,components:2,type:`Int16`}],4);class ms{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>ms.MAX_VERTEX_ARRAY_LENGTH&&ae(`Max vertices per segment is ${ms.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ms.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+e>ms.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r?this.createNewSegment(t,n,r):i}createNewSegment(e,t,n){let r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return n!==void 0&&(r.sortKey=n),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,n){return this.prepareSegment(0,e,t,n)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,r){return new ms([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}function hs(e,t){return 256*(e=ee(Math.floor(e),0,255))+ee(Math.floor(t),0,255)}ms.MAX_VERTEX_ARRAY_LENGTH=2**16-1,W(`SegmentVector`,ms);let gs=mo([{name:`a_pattern_from`,components:4,type:`Uint16`},{name:`a_pattern_to`,components:4,type:`Uint16`},{name:`a_pixel_ratio_from`,components:1,type:`Uint16`},{name:`a_pixel_ratio_to`,components:1,type:`Uint16`}]),_s=mo([{name:`a_dasharray_from`,components:4,type:`Uint16`},{name:`a_dasharray_to`,components:4,type:`Uint16`}]);var vs,ys,bs,xs={exports:{}},Ss={exports:{}},Cs={exports:{}},ws=r(function(){if(bs)return xs.exports;bs=1;var e=(vs||(vs=1,Ss.exports=function(e,t){var n,r,i,a,o,s,c,l;for(r=e.length-(n=3&e.length),i=t,o=3432918353,s=461845907,l=0;l<r;)c=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24,++l,i=27492+(65535&(a=5*(65535&(i=(i^=c=(65535&(c=(c=(65535&c)*o+(((c>>>16)*o&65535)<<16)&4294967295)<<15|c>>>17))*s+(((c>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(c=0,n){case 3:c^=(255&e.charCodeAt(l+2))<<16;case 2:c^=(255&e.charCodeAt(l+1))<<8;case 1:i^=c=(65535&(c=(c=(65535&(c^=255&e.charCodeAt(l)))*o+(((c>>>16)*o&65535)<<16)&4294967295)<<15|c>>>17))*s+(((c>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Ss.exports),t=(ys||(ys=1,Cs.exports=function(e,t){for(var n,r=e.length,i=t^r,a=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++a;switch(r){case 3:i^=(255&e.charCodeAt(a+2))<<16;case 2:i^=(255&e.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Cs.exports);return xs.exports=e,xs.exports.murmur3=e,xs.exports.murmur2=t,xs.exports}());class Ts{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(Es(e)),this.positions.push(t,n,r)}getPositions(e){if(!this.indexed)throw Error(`Trying to get index, but feature positions are not indexed`);let t=Es(e),n=0,r=this.ids.length-1;for(;n<r;){let e=n+r>>1;this.ids[e]>=t?r=e:n=e+1}let i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){let n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Ds(n,r,0,n.length-1),t&&t.push(n.buffer,r.buffer),{ids:n,positions:r}}static deserialize(e){let t=new Ts;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function Es(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:ws(String(e))}function Ds(e,t,n,r){for(;n<r;){let i=e[n+r>>1],a=n-1,o=r+1;for(;;){do a++;while(e[a]<i);do o--;while(e[o]>i);if(a>=o)break;Os(e,a,o),Os(t,3*a,3*o),Os(t,3*a+1,3*o+1),Os(t,3*a+2,3*o+2)}o-n<r-o?(Ds(e,t,n,o),n=o+1):(Ds(e,t,o+1,r),r=o)}}function Os(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}W(`FeaturePositionMap`,Ts);class ks{constructor(e,t){this.gl=e.gl,this.location=t}}class As extends ks{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class js extends ks{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 Ms extends ks{constructor(e,t){super(e,t),this.current=Lt.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))}}let Ns=new Float32Array(16);function Ps(e){return[hs(255*e.r,255*e.g),hs(255*e.b,255*e.a)]}class Fs{constructor(e,t,n){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=n}setUniform(e,t,n){e.set(n.constantOr(this.value))}getBinding(e,t,n){return this.type===`color`?new Ms(e,t):new As(e,t)}}class Is{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,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,n,r){let i=null;r===`u_pattern_to`?i=this.patternTo:r===`u_pattern_from`?i=this.patternFrom:r===`u_dasharray_to`?i=this.dashTo:r===`u_dasharray_from`?i=this.dashFrom:r===`u_pixel_ratio_to`?i=this.pixelRatioTo:r===`u_pixel_ratio_from`&&(i=this.pixelRatioFrom),i!==null&&e.set(i)}getBinding(e,t,n){return n.startsWith(`u_pattern`)||n.startsWith(`u_dasharray_`)?new js(e,t):new As(e,t)}}class Ls{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,n){let r=this.paintVertexArray.length,i=this.expression.evaluate(new Va(0,n),t,{},n.canonical,[],n.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new Va(0,i),n,r);this._setPaintValue(e,t,a)}_setPaintValue(e,t,n){if(this.type===`color`){let r=Ps(n);for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}upload(e){var t;(t=this.paintVertexArray)!=null&&t.arrayBuffer.byteLength&&(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 Rs{constructor(e,t,n,r,i,a){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?4:2,offset:0}))),this.paintVertexArray=new a}populatePaintArray(e,t,n){let r=this.expression.evaluate(new Va(this.zoom,n),t,{},n.canonical,[],n.formattedSection),i=this.expression.evaluate(new Va(this.zoom+1,n),t,{},n.canonical,[],n.formattedSection),a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(a,e,r,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new Va(this.zoom,i),n,r),o=this.expression.evaluate(new Va(this.zoom+1,i),n,r);this._setPaintValue(e,t,a,o)}_setPaintValue(e,t,n,r){if(this.type===`color`){let i=Ps(n),a=Ps(r);for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i[0],i[1],a[0],a[1])}else{for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n,r);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(r))}}upload(e){var t;(t=this.paintVertexArray)!=null&&t.arrayBuffer.byteLength&&(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){let n=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=ee(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,n){return new As(e,t)}}class zs{constructor(e,t,n,r,i,a){this.expression=e,this.type=t,this.useIntegerZoom=n,this.zoom=r,this.layerId=a,this.zoomInPaintVertexArray=new i,this.zoomOutPaintVertexArray=new i}populatePaintArray(e,t,n){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,this.getPositionIds(t),n)}updatePaintArray(e,t,n,r,i){this._setPaintValues(e,t,this.getPositionIds(n),i)}_setPaintValues(e,t,n,r){let i=this.getPositions(r);if(!i||!n)return;let a=i[n.min],o=i[n.mid],s=i[n.max];if(a&&o&&s)for(let n=e;n<t;n++)this.emplace(this.zoomInPaintVertexArray,n,o,a),this.emplace(this.zoomOutPaintVertexArray,n,o,s)}upload(e){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let t=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,t,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,t,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Bs extends zs{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns?.[this.layerId]}getVertexAttributes(){return gs.members}emplace(e,t,n,r){e.emplace(t,n.tlbr[0],n.tlbr[1],n.tlbr[2],n.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],n.pixelRatio,r.pixelRatio)}}class Vs extends zs{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes?.[this.layerId]}getVertexAttributes(){return _s.members}emplace(e,t,n,r){e.emplace(t,0,n.y,n.height,n.width,0,r.y,r.height,r.width)}}class Hs{constructor(e,t,n){this.binders={},this._buffers=[];let r=[];for(let i in e.paint._values){if(!n(i))continue;let a=e.paint.get(i);if(!(a instanceof Xa&&Qr(a.property.specification)))continue;let o=Ws(i,e.type),s=a.value,c=a.property.specification.type,l=a.property.useIntegerZoom,u=a.property.specification[`property-type`],d=u===`cross-faded`||u===`cross-faded-data-driven`;if(s.kind===`constant`)this.binders[i]=d?new Is(s.value,o):new Fs(s.value,o,c),r.push(`/u_${i}`);else if(s.kind===`source`||d){let n=Gs(i,c,`source`);this.binders[i]=d?i===`line-dasharray`?new Vs(s,c,l,t,n,e.id):new Bs(s,c,l,t,n,e.id):new Ls(s,o,c,n),r.push(`/a_${i}`)}else{let e=Gs(i,c,`composite`);this.binders[i]=new Rs(s,o,c,l,t,e),r.push(`/z_${i}`)}}this.cacheKey=r.sort().join(``)}getMaxValue(e){let t=this.binders[e];return t instanceof Ls||t instanceof Rs?t.maxValue:0}populatePaintArrays(e,t,n){for(let r in this.binders){let i=this.binders[r];(i instanceof Ls||i instanceof Rs||i instanceof zs)&&i.populatePaintArray(e,t,n)}}setConstantPatternPositions(e,t){for(let n in this.binders){let r=this.binders[n];r instanceof Is&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(let n in this.binders){let r=this.binders[n];r instanceof Is&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,n,r,i){let a=!1;for(let o in e){let s=t.getPositions(o);for(let t of s){let s=n.feature(t.index);for(let n in this.binders){let c=this.binders[n];(c instanceof Ls||c instanceof Rs||c instanceof zs)&&!0===c.expression.isStateDependent&&(c.expression=r.paint.get(n).value,c.updatePaintArray(t.start,t.end,s,e[o],i),a=!0)}}}return a}defines(){let e=[];for(let t in this.binders){let n=this.binders[t];(n instanceof Fs||n instanceof Is)&&e.push(...n.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof Ls||n instanceof Rs)for(let t of n.paintVertexAttributes)e.push(t.name);else if(n instanceof zs){let t=n.getVertexAttributes();for(let n of t)e.push(n.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof Fs||n instanceof Is||n instanceof Rs)for(let t of n.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let n=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof Fs||i instanceof Is||i instanceof Rs){for(let a of i.uniformNames)if(t[a]){let o=i.getBinding(e,t[a],a);n.push({name:a,property:r,binding:o})}}}return n}setUniforms(e,t,n,r){for(let{name:e,property:i,binding:a}of t)this.binders[i].setUniform(a,r,n.get(i),e)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let n=this.binders[t];if(e&&n instanceof zs){let t=e.fromScale===2?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else (n instanceof Ls||n instanceof Rs)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}}upload(e){for(let t in this.binders){let n=this.binders[t];(n instanceof Ls||n instanceof Rs||n instanceof zs)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof Ls||t instanceof Rs||t instanceof zs)&&t.destroy()}}}class Us{constructor(e,t,n=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new Hs(r,t,n);this.needsUpload=!1,this._featureMap=new Ts,this._bufferOffset=0}populatePaintArrays(e,t,n,r){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r);t.id!==void 0&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r){for(let i of n)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(e,this._featureMap,t,i,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Ws(e,t){return{"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-dasharray":[`dasharray_to`,`dasharray_from`],"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`]}[e]||[e.replace(`${t}-`,``).replace(/-/g,`_`)]}function Gs(e,t,n){let r={color:{source:xo,composite:zo},number:{source:Po,composite:xo}};return function(e){return{"line-pattern":{source:is,composite:is},"fill-pattern":{source:is,composite:is},"fill-extrusion-pattern":{source:is,composite:is},"line-dasharray":{source:as,composite:as}}[e]}(e)?.[n]||r[t][n]}W(`ConstantBinder`,Fs),W(`CrossFadedConstantBinder`,Is),W(`SourceExpressionBinder`,Ls),W(`CrossFadedPatternBinder`,Bs),W(`CrossFadedDasharrayBinder`,Vs),W(`CompositeExpressionBinder`,Rs),W(`ProgramConfiguration`,Hs,{omit:[`_buffers`]}),W(`ProgramConfigurationSet`,Us);let Ks=2**14-1,qs=-Ks-1;function Js(e){let t=O/e.extent,n=e.loadGeometry();for(let e of n)for(let n of e){let e=Math.round(n.x*t),r=Math.round(n.y*t);n.x=ee(e,qs,Ks),n.y=ee(r,qs,Ks),(e<n.x||e>n.x+1||r<n.y||r>n.y+1)&&ae(`Geometry exceeds allowed extent, reduce your vector tile buffer size`)}return n}function Ys(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Js(e):[]}}let Xs=-32768;function Zs(e,t,n,r,i){e.emplaceBack(Xs+8*t+r,Xs+8*n+i)}class Qs{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.hasDependencies=!1,this.layoutVertexArray=new $o,this.indexArray=new ds,this.segments=new ms,this.programConfigurations=new Us(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){let r=this.layers[0],i=[],a=null,o=!1,s=r.type===`heatmap`;if(r.type===`circle`){let e=r;a=e.layout.get(`circle-sort-key`),o=!a.isConstant(),s||=e.paint.get(`circle-pitch-alignment`)===`map`}let c=s?t.subdivisionGranularity.circle:1;for(let{feature:t,id:r,index:s,sourceLayerIndex:c}of e){let e=this.layers[0]._featureFilter.needGeometry,l=Ys(t,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),l,n))continue;let u=o?a.evaluate(l,{},n):void 0,d={id:r,properties:t.properties,type:t.type,sourceLayerIndex:c,index:s,geometry:e?l.geometry:Js(t),patterns:{},sortKey:u};i.push(d)}o&&i.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of i){let{geometry:i,index:a,sourceLayerIndex:o}=r,s=e[a].feature;this.addFeature(r,i,a,n,c),t.featureIndex.insert(s,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ps),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())}addFeature(e,t,n,r,i=1){let a;switch(i){case 1:a=[0,7];break;case 3:a=[0,2,5,7];break;case 5:a=[0,1,3,4,6,7];break;case 7:a=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}let o=a.length;for(let n of t)for(let t of n){let n=t.x,r=t.y;if(n<0||n>=O||r<0||r>=O)continue;let i=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),s=i.vertexLength;for(let e=0;e<o;e++)for(let t=0;t<o;t++)Zs(this.layoutVertexArray,n,r,a[t],a[e]);for(let e=0;e<o-1;e++)for(let t=0;t<o-1;t++){let n=s+e*o+t,r=s+(e+1)*o+t;this.indexArray.emplaceBack(n,r+1,n+1),this.indexArray.emplaceBack(n,r,r+1)}i.vertexLength+=o*o,i.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:{},canonical:r})}}function $s(e,t){for(let n of e)if(cc(t,n))return!0;for(let n of t)if(cc(e,n))return!0;return rc(e,t)}function ec(e,t,n){return!!cc(e,t)||ac(t,e,n)}function tc(e,t){if(e.length===1)return sc(t,e[0]);for(let n of t)for(let t of n)if(cc(e,t))return!0;for(let n of e)if(sc(t,n))return!0;for(let n of t)if(rc(e,n))return!0;return!1}function nc(e,t,n){if(e.length>1){if(rc(e,t))return!0;for(let r of t)if(ac(r,e,n))return!0}for(let r of e)if(ac(r,t,n))return!0;return!1}function rc(e,t){if(e.length===0||t.length===0)return!1;for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];for(let e=0;e<t.length-1;e++)if(ic(r,i,t[e],t[e+1]))return!0}return!1}function ic(e,t,n,r){return oe(e,n,r)!==oe(t,n,r)&&oe(e,t,n)!==oe(e,t,r)}function ac(e,t,n){let r=n*n;if(t.length===1)return e.distSqr(t[0])<r;for(let n=1;n<t.length;n++)if(oc(e,t[n-1],t[n])<r)return!0;return!1}function oc(e,t,n){let r=t.distSqr(n);if(r===0)return e.distSqr(t);let i=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/r;return e.distSqr(i<0?t:i>1?n:n.sub(t)._mult(i)._add(t))}function sc(e,t){let n,r,i,a=!1;for(let o of e){n=o;for(let e=0,o=n.length-1;e<n.length;o=e++)r=n[e],i=n[o],r.y>t.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(a=!a)}return a}function cc(e,t){let n=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let a=e[r],o=e[i];a.y>t.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function lc(e,t,n){let r=n[0],i=n[2];if(e.x<r.x&&t.x<r.x||e.x>i.x&&t.x>i.x||e.y<r.y&&t.y<r.y||e.y>i.y&&t.y>i.y)return!1;let a=oe(e,t,n[0]);return a!==oe(e,t,n[1])||a!==oe(e,t,n[2])||a!==oe(e,t,n[3])}function uc(e,t,n){let r=t.paint.get(e).value;return r.kind===`constant`?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function dc(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function fc(e,t,r,i,a){if(!t[0]&&!t[1])return e;let o=n.convert(t)._mult(a);r===`viewport`&&o._rotate(-i);let s=[];for(let t of e)s.push(t.sub(o));return s}function pc(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=t.at(-1);(n===0||i&&!r.equals(i))&&t.push(r)}return t}function mc({queryGeometry:e,size:t},n){return ec(e,n,t)}function hc({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i},a){return ec(e,a,t*(n.projectTileCoordinates(a.x,a.y,r,i).signedDistanceFromCamera/n.cameraToCenterDistance))}function gc({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i},a){let o=n.projectTileCoordinates(a.x,a.y,r,i).signedDistanceFromCamera,s=t*(n.cameraToCenterDistance/o);return ec(e,yc(a,n,r,i),s)}function _c({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i},a){return ec(e,yc(a,n,r,i),t)}function vc({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i,pitchAlignment:a=`map`,pitchScale:o=`map`},s){let c=a===`map`?o===`map`?mc:hc:o===`map`?gc:_c,l={queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i};for(let e of s)for(let t of e)if(c(l,t))return!0;return!1}function yc(e,t,r,i){let a=t.projectTileCoordinates(e.x,e.y,r,i).point;return new n((.5*a.x+.5)*t.width,(.5*-a.y+.5)*t.height)}let bc,xc;W(`CircleBucket`,Qs,{omit:[`layers`]});var Sc={get paint(){return xc||=new ro({"circle-radius":new $a(z.paint_circle[`circle-radius`]),"circle-color":new $a(z.paint_circle[`circle-color`]),"circle-blur":new $a(z.paint_circle[`circle-blur`]),"circle-opacity":new $a(z.paint_circle[`circle-opacity`]),"circle-translate":new Qa(z.paint_circle[`circle-translate`]),"circle-translate-anchor":new Qa(z.paint_circle[`circle-translate-anchor`]),"circle-pitch-scale":new Qa(z.paint_circle[`circle-pitch-scale`]),"circle-pitch-alignment":new Qa(z.paint_circle[`circle-pitch-alignment`]),"circle-stroke-width":new $a(z.paint_circle[`circle-stroke-width`]),"circle-stroke-color":new $a(z.paint_circle[`circle-stroke-color`]),"circle-stroke-opacity":new $a(z.paint_circle[`circle-stroke-opacity`])})},get layout(){return bc||=new ro({"circle-sort-key":new $a(z.layout_circle[`circle-sort-key`])})}};class Cc extends oo{constructor(e,t){super(e,Sc,t)}createBucket(e){return new Qs(e)}queryRadius(e){let t=e;return uc(`circle-radius`,this,t)+uc(`circle-stroke-width`,this,t)+dc(this.paint.get(`circle-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){let c=fc(e,this.paint.get(`circle-translate`),this.paint.get(`circle-translate-anchor`),-i.bearingInRadians,a),l=this.paint.get(`circle-radius`).evaluate(t,n)+this.paint.get(`circle-stroke-width`).evaluate(t,n),u=this.paint.get(`circle-pitch-scale`),d=this.paint.get(`circle-pitch-alignment`),f,p;return d===`map`?(f=c,p=l*a):(f=function(e,t,n,r){return e.map((e=>yc(e,t,n,r)))}(c,i,o,s),p=l),vc({queryGeometry:f,size:p,transform:i,unwrappedTileID:o,getElevation:s,pitchAlignment:d,pitchScale:u},r)}}class wc extends Qs{}let Tc;W(`HeatmapBucket`,wc,{omit:[`layers`]});var Ec={get paint(){return Tc||=new ro({"heatmap-radius":new $a(z.paint_heatmap[`heatmap-radius`]),"heatmap-weight":new $a(z.paint_heatmap[`heatmap-weight`]),"heatmap-intensity":new Qa(z.paint_heatmap[`heatmap-intensity`]),"heatmap-color":new no(z.paint_heatmap[`heatmap-color`]),"heatmap-opacity":new Qa(z.paint_heatmap[`heatmap-opacity`])})}};function Dc(e,{width:t,height:n},r,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*n*r)throw RangeError(`mismatched image size. expected: ${i.length} but got: ${t*n*r}`)}else i=new Uint8Array(t*n*r);return e.width=t,e.height=n,e.data=i,e}function Oc(e,{width:t,height:n},r){if(t===e.width&&n===e.height)return;let i=Dc({},{width:t,height:n},r);kc(e,i,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,n)},r),e.width=t,e.height=n,e.data=i.data}function kc(e,t,n,r,i,a){if(i.width===0||i.height===0)return t;if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw RangeError(`out of range source coordinates for image copy`);if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw RangeError(`out of range destination coordinates for image copy`);let o=e.data,s=t.data;if(o===s)throw Error(`srcData equals dstData, so image is already copied`);for(let c=0;c<i.height;c++){let l=((n.y+c)*e.width+n.x)*a,u=((r.y+c)*t.width+r.x)*a;for(let e=0;e<i.width*a;e++)s[u+e]=o[l+e]}return t}class Ac{constructor(e,t){Dc(this,e,1,t)}resize(e){Oc(this,e,1)}clone(){return new Ac({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,r,i){kc(e,t,n,r,i,1)}}class jc{constructor(e,t){Dc(this,e,4,t)}resize(e){Oc(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new jc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,r,i){kc(e,t,n,r,i,4)}setPixel(e,t,n){let r=4*(e*this.width+t);this.data[r+0]=Math.round(255*n.r/n.a),this.data[r+1]=Math.round(255*n.g/n.a),this.data[r+2]=Math.round(255*n.b/n.a),this.data[r+3]=Math.round(255*n.a)}}function Mc(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=4){let r=e[n+3];t[n+0]=Math.round(e[n+0]*r/255),t[n+1]=Math.round(e[n+1]*r/255),t[n+2]=Math.round(e[n+2]*r/255),t[n+3]=r}return t}function Nc(e){let t={},n=e.resolution||256,r=e.clips?e.clips.length:1,i=e.image||new jc({width:n,height:r});if(Math.log(n)/Math.LN2%1!=0)throw Error(`width is not a power of 2 - ${n}`);let a=(r,a,o)=>{t[e.evaluationKey]=o;let s=e.expression.evaluate(t);i.setPixel(r/4/n,a/4,s)};if(e.clips)for(let t=0,i=0;t<r;++t,i+=4*n)for(let r=0,o=0;r<n;r++,o+=4){let s=r/(n-1),{start:c,end:l}=e.clips[t];a(i,o,c*(1-s)+l*s)}else for(let e=0,t=0;e<n;e++,t+=4)a(0,t,e/(n-1));return i}W(`AlphaImage`,Ac),W(`RGBAImage`,jc);let Pc=`big-fb`;class Fc extends oo{createBucket(e){return new wc(e)}constructor(e,t){super(e,Ec,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e===`heatmap-color`&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Nc({expression:this._transitionablePaint._values[`heatmap-color`].value.expression,evaluationKey:`heatmapDensity`,image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Pc)&&this.heatmapFbos.delete(Pc)}queryRadius(e){return uc(`heatmap-radius`,this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){return vc({queryGeometry:e,size:this.paint.get(`heatmap-radius`).evaluate(t,n)*a,transform:i,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return this.paint.get(`heatmap-opacity`)!==0&&!this.isHidden()}}let Ic;var Lc={get paint(){return Ic||=new ro({"hillshade-illumination-direction":new Qa(z.paint_hillshade[`hillshade-illumination-direction`]),"hillshade-illumination-altitude":new Qa(z.paint_hillshade[`hillshade-illumination-altitude`]),"hillshade-illumination-anchor":new Qa(z.paint_hillshade[`hillshade-illumination-anchor`]),"hillshade-exaggeration":new Qa(z.paint_hillshade[`hillshade-exaggeration`]),"hillshade-shadow-color":new Qa(z.paint_hillshade[`hillshade-shadow-color`]),"hillshade-highlight-color":new Qa(z.paint_hillshade[`hillshade-highlight-color`]),"hillshade-accent-color":new Qa(z.paint_hillshade[`hillshade-accent-color`]),"hillshade-method":new Qa(z.paint_hillshade[`hillshade-method`]),resampling:new Qa(z.paint_hillshade.resampling)})}};class Rc extends oo{constructor(e,t){super(e,Lc,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get(`hillshade-illumination-direction`).values,t=this.paint.get(`hillshade-illumination-altitude`).values,n=this.paint.get(`hillshade-highlight-color`).values,r=this.paint.get(`hillshade-shadow-color`).values,i=Math.max(e.length,t.length,n.length,r.length);e=e.concat(Array(i-e.length).fill(e.at(-1))),t=t.concat(Array(i-t.length).fill(t.at(-1))),n=n.concat(Array(i-n.length).fill(n.at(-1))),r=r.concat(Array(i-r.length).fill(r.at(-1)));let a=t.map(he);return{directionRadians:e.map(he),altitudeRadians:a,shadowColor:r,highlightColor:n}}hasOffscreenPass(){return this.paint.get(`hillshade-exaggeration`)!==0&&!this.isHidden()}}let zc;var Bc={get paint(){return zc||=new ro({"color-relief-opacity":new Qa(z[`paint_color-relief`][`color-relief-opacity`]),"color-relief-color":new no(z[`paint_color-relief`][`color-relief-color`]),resampling:new Qa(z[`paint_color-relief`].resampling)})}};function Vc(e){return`data`in e}class Hc{constructor(e,t,n,r){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,n){let{width:r,height:i}=e,a=(this.size?.[0]!==r||this.size[1]!==i)&&!n,{context:o}=this,{gl:s}=o;this.useMipmap=!!t?.useMipmap,s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let c=this.format===s.RGBA&&!1!==t?.premultiply;if(a)this.size=[r,i],Vc(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,c,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._uploadDomImage(e,s));else{let{x:t,y:a}=n||{x:0,y:0};Vc(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,c,t,a,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._updateDomImage(e,t,a,s))}this.useMipmap&&this.isSizePowerOfTwo()&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,n,r,i){let{data:a}=e;t&&a&&(a=Mc(a)),i.texImage2D(i.TEXTURE_2D,0,this.format,n,r,0,this.format,i.UNSIGNED_BYTE,a)}_updateDomImage(e,t,n,r){r.texSubImage2D(r.TEXTURE_2D,0,t,n,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,n,r,i,a,o){let{data:s}=e;t&&s&&(s=Mc(s)),o.texSubImage2D(o.TEXTURE_2D,0,n,r,i,a,o.RGBA,o.UNSIGNED_BYTE,s)}bind(e,t,n){let{context:r}=this,{gl:i}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),i.bindTexture(i.TEXTURE_2D,this.texture),n!==i.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(n=i.LINEAR),e!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,n||e),this.filter=e),t!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.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(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}}class Uc{constructor(e,t,n,r=1,i=1,a=1,o=0){if(this.uid=e,t.height!==t.width)throw RangeError(`DEM tiles must be square`);if(n&&![`mapbox`,`terrarium`,`custom`].includes(n))return void ae(`"${n}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=t.height;let s=this.dim=t.height-2;switch(this.data=new Uint32Array(t.data.buffer),n){case`terrarium`:this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case`custom`:this.redFactor=r,this.greenFactor=i,this.blueFactor=a,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=0;e<s;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(s,e)]=this.data[this._idx(s-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,s)]=this.data[this._idx(e,s-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(s,-1)]=this.data[this._idx(s-1,0)],this.data[this._idx(-1,s)]=this.data[this._idx(0,s-1)],this.data[this._idx(s,s)]=this.data[this._idx(s-1,s-1)],this.min=2**53-1,this.max=-(2**53-1);for(let e=0;e<s;e++)for(let t=0;t<s;t++){let n=this.get(e,t);n>this.max&&(this.max=n),n<this.min&&(this.min=n)}}get(e,t){let n=new Uint8Array(this.data.buffer),r=4*this._idx(e,t);return this.unpack(n[r],n[r+1],n[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+1)*this.stride+(e+1)}unpack(e,t,n){return e*this.redFactor+t*this.greenFactor+n*this.blueFactor-this.baseShift}pack(e){return Wc(e,this.getUnpackVector())}getPixels(){return new jc({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,n){if(this.dim!==e.dim)throw Error(`dem dimension mismatch`);let r=t*this.dim,i=t*this.dim+this.dim,a=n*this.dim,o=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:a=o-1;break;case 1:o=a+1}let s=-t*this.dim,c=-n*this.dim;for(let t=a;t<o;t++)for(let n=r;n<i;n++)this.data[this._idx(n,t)]=e.data[this._idx(n+s,t+c)]}}function Wc(e,t){let n=t[0],r=t[1],i=t[2],a=t[3],o=Math.min(n,r,i),s=Math.round((e+a)/o);return{r:Math.floor(s*o/n)%256,g:Math.floor(s*o/r)%256,b:Math.floor(s*o/i)%256}}W(`DEMData`,Uc);class Gc extends oo{constructor(e,t){super(e,Bc,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},n=this._transitionablePaint._values[`color-relief-color`].value.expression;if(n instanceof pi&&n._styleExpression.expression instanceof Cn){this.colorRampExpression=n;let e=n._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(let n of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:n}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[Lt.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},i=(t.elevationStops.length-1)/(e-1);for(let e=0;e<t.elevationStops.length-.5;e+=i)r.elevationStops.push(t.elevationStops[Math.round(e)]),r.colorStops.push(t.colorStops[Math.round(e)]);return ae(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${t.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values[`color-relief-color`].value.expression}getColorRampTextures(e,t,n){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(t),i=new jc({width:r.colorStops.length,height:1}),a=new jc({width:r.colorStops.length,height:1});for(let e=0;e<r.elevationStops.length;e++){let t=Wc(r.elevationStops[e],n);a.setPixel(0,e,new Lt(t.r/255,t.g/255,t.b/255,1)),i.setPixel(0,e,r.colorStops[e])}return this.colorRampTextures={elevationTexture:new Hc(e,a,e.gl.RGBA),colorTexture:new Hc(e,i,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}let{members:Kc}=mo([{name:`a_pos`,components:2,type:`Int16`}],4);function qc(e,t,n){let r=n.patternDependencies,i=!1;for(let n of t){let t=n.paint.get(`${e}-pattern`);t.isConstant()||(i=!0);let a=t.constantOr(null);a&&(i=!0,r[a.to]=!0,r[a.from]=!0)}return i}function Jc(e,t,n,r,i){let{zoom:a}=r,o=i.patternDependencies;for(let r of t){let t=r.paint.get(`${e}-pattern`).value;if(t.kind!==`constant`){let e=t.evaluate({zoom:a-1},n,{},i.availableImages),s=t.evaluate({zoom:a},n,{},i.availableImages),c=t.evaluate({zoom:a+1},n,{},i.availableImages);e=e?.name?e.name:e,s=s?.name?s.name:s,c=c?.name?c.name:c,o[e]=!0,o[s]=!0,o[c]=!0,n.patterns[r.id]={min:e,mid:s,max:c}}}return n}function Yc(e,t,n,r,i){let a;if(i===function(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=_l(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=_l(i/r|0,e[i],e[i+1],a);return a&&dl(a,a.next)&&(vl(a),a=a.next),a}function Xc(e,t){if(!e)return e;t||=e;let n,r=e;do if(n=!1,r.steiner||!dl(r,r.next)&&ul(r.prev,r,r.next)!==0)r=r.next;else{if(vl(r),r=t=r.prev,r===r.next)break;n=!0}while(n||r!==t);return t}function Zc(e,t,n,r,i,a,o){if(!e)return;!o&&a&&function(e,t,n,r){let i=e;do i.z===0&&(i.z=al(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n=1;do{let r,i=e;e=null;let a=null;for(t=0;i;){t++;let o=i,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,s--):(r=o,o=o.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;i=o}a.nextZ=null,n*=2}while(t>1)}(i)}(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?$c(e,r,i,a):Qc(e))t.push(c.i,e.i,l.i),vl(e),e=l.next,s=l.next;else if((e=l)===s){o?o===1?Zc(e=el(Xc(e),t),t,n,r,i,a,2):o===2&&tl(e,t,n,r,i,a):Zc(Xc(e),t,n,r,i,a,1);break}}}function Qc(e){let t=e.prev,n=e,r=e.next;if(ul(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&cl(i,s,a,c,o,l,m.x,m.y)&&ul(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function $c(e,t,n,r){let i=e.prev,a=e,o=e.next;if(ul(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=al(p,m,t,n,r),v=al(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&cl(s,u,c,d,l,f,y.x,y.y)&&ul(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&cl(s,u,c,d,l,f,b.x,b.y)&&ul(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&cl(s,u,c,d,l,f,y.x,y.y)&&ul(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&cl(s,u,c,d,l,f,b.x,b.y)&&ul(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function el(e,t){let n=e;do{let r=n.prev,i=n.next.next;!dl(r,i)&&fl(r,n,n.next,i)&&hl(r,i)&&hl(i,r)&&(t.push(r.i,n.i,i.i),vl(n),vl(n.next),n=e=i),n=n.next}while(n!==e);return Xc(n)}function tl(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&ll(o,e)){let s=gl(o,e);o=Xc(o,o.next),s=Xc(s,s.next),Zc(o,t,n,r,i,a,0),Zc(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function nl(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0)&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),n}function rl(e,t){let n=function(e,t){let n=t,r=e.x,i=e.y,a,o=-1/0;if(dl(e,n))return n;do{if(dl(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>o&&(o=e,a=n.x<n.next.x?n:n.next,e===r))return a}n=n.next}while(n!==t);if(!a)return null;let s=a,c=a.x,l=a.y,u=1/0;n=a;do{if(r>=n.x&&n.x>=c&&r!==n.x&&sl(i<l?r:o,i,c,l,i<l?o:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);hl(n,e)&&(t<u||t===u&&(n.x>a.x||n.x===a.x&&il(a,n)))&&(a=n,u=t)}n=n.next}while(n!==s);return a}(e,t);if(!n)return t;let r=gl(n,e);return Xc(r,r.next),Xc(n,n.next)}function il(e,t){return ul(e.prev,e,t.prev)<0&&ul(t.next,e,e.next)<0}function al(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ol(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function sl(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function cl(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&sl(e,t,n,r,i,a,o,s)}function ll(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&fl(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(hl(e,t)&&hl(t,e)&&function(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}(e,t)&&(ul(e.prev,e,t.prev)||ul(e,t.prev,t))||dl(e,t)&&ul(e.prev,e,e.next)>0&&ul(t.prev,t,t.next)>0)}function ul(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function dl(e,t){return e.x===t.x&&e.y===t.y}function fl(e,t,n,r){let i=ml(ul(e,t,n)),a=ml(ul(e,t,r)),o=ml(ul(n,r,e)),s=ml(ul(n,r,t));return i!==a&&o!==s||!(i!==0||!pl(e,n,t))||!(a!==0||!pl(e,r,t))||!(o!==0||!pl(n,e,r))||!(s!==0||!pl(n,t,r))}function pl(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ml(e){return e>0?1:e<0?-1:0}function hl(e,t){return ul(e.prev,e,e.next)<0?ul(e,t,e.next)>=0&&ul(e,e.prev,t)>=0:ul(e,t,e.prev)<0||ul(e,e.next,t)<0}function gl(e,t){let n=yl(e.i,e.x,e.y),r=yl(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function _l(e,t,n,r){let i=yl(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function vl(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 yl(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class bl{constructor(e,t){if(t>e)throw Error(`Min granularity must not be greater than base granularity.`);this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class xl{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}xl.noSubdivision=new xl({fill:new bl(0,0),line:new bl(0,0),tile:new bl(0,0),stencil:new bl(0,0),circle:1}),W(`SubdivisionGranularityExpression`,bl),W(`SubdivisionGranularitySetting`,xl);let Sl=-32768,Cl=32767;class wl{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=O/e,this._canonical=t}_getKey(e,t){return(e+=32768)<<16|t+32768}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw Error(`Vertex coordinates are out of signed 16 bit integer range.`);let n=0|Math.round(e),r=0|Math.round(t),i=this._getKey(n,r);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);let a=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,a),this._vertexBuffer.push(n,r),a}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){let n=[];for(let r=0;r<t.length;r+=3){let i=t[r],a=t[r+1],o=t[r+2],s=e[2*i],c=e[2*i+1];(e[2*a]-s)*(e[2*o+1]-c)-(e[2*a+1]-c)*(e[2*o]-s)>0?(n.push(i),n.push(o),n.push(a)):(n.push(i),n.push(a),n.push(o))}return n}(this._vertexBuffer,e);let t=[],n=e.length;for(let r=0;r<n;r+=3){let n=[e[r+0],e[r+1],e[r+2]],i=[this._vertexBuffer[2*e[r+0]+0],this._vertexBuffer[2*e[r+0]+1],this._vertexBuffer[2*e[r+1]+0],this._vertexBuffer[2*e[r+1]+1],this._vertexBuffer[2*e[r+2]+0],this._vertexBuffer[2*e[r+2]+1]],a=1/0,o=1/0,s=-1/0,c=-1/0;for(let e=0;e<3;e++){let t=i[2*e],n=i[2*e+1];a=Math.min(a,t),s=Math.max(s,t),o=Math.min(o,n),c=Math.max(c,n)}if(a===s||o===c)continue;let l=Math.floor(a/this._granularityCellSize),u=Math.ceil(s/this._granularityCellSize),d=Math.floor(o/this._granularityCellSize),f=Math.ceil(c/this._granularityCellSize);if(l!==u||d!==f)for(let e=d;e<f;e++){let r=this._scanlineGenerateVertexRingForCellRow(e,i,n);Dl(this._vertexBuffer,r,t)}else t.push(...n)}return t}_scanlineGenerateVertexRingForCellRow(e,t,n){let r=e*this._granularityCellSize,i=r+this._granularityCellSize,a=[];for(let e=0;e<3;e++){let o=t[2*e],s=t[2*e+1],c=t[2*(e+1)%6],l=t[(2*(e+1)+1)%6],u=t[2*(e+2)%6],d=t[(2*(e+2)+1)%6],f=c-o,p=l-s,m=f===0,h=p===0,g=(r-s)/p,_=(i-s)/p,v=Math.min(g,_),y=Math.max(g,_);if(!h&&(v>=1||y<=0)||h&&(s<r||s>i)){l>=r&&l<=i&&a.push(n[(e+1)%3]);continue}!h&&v>0&&a.push(this._vertexToIndex(o+f*v,s+p*v));let b=o+f*Math.max(v,0),x=o+f*Math.min(y,1);m||this._generateIntraEdgeVertices(a,o,s,c,l,b,x),!h&&y<1&&a.push(this._vertexToIndex(o+f*y,s+p*y)),(h||l>=r&&l<=i)&&a.push(n[(e+1)%3]),!h&&(l<=r||l>=i)&&this._generateInterEdgeVertices(a,o,s,c,l,u,d,x,r,i)}return a}_generateIntraEdgeVertices(e,t,n,r,i,a,o){let s=r-t,c=i-n,l=c===0,u=l?Math.min(t,r):Math.min(a,o),d=l?Math.max(t,r):Math.max(a,o),f=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(d/this._granularityCellSize)-1;if(l?t<r:a<o)for(let r=f;r<=p;r++){let i=r*this._granularityCellSize;e.push(this._vertexToIndex(i,n+c*(i-t)/s))}else for(let r=p;r>=f;r--){let i=r*this._granularityCellSize;e.push(this._vertexToIndex(i,n+c*(i-t)/s))}}_generateInterEdgeVertices(e,t,n,r,i,a,o,s,c,l){let u=i-n,d=a-r,f=o-i,p=(c-i)/f,m=(l-i)/f,h=Math.min(p,m),g=Math.max(p,m),_=r+d*h,v=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,b=s<_,x=f===0;if(x&&(o===c||o===l))return;if(x||h>=1||g<=0){let e=n-o,r=a+(t-a)*Math.min((c-o)/e,(l-o)/e);v=Math.floor(Math.min(r,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(r,s)/this._granularityCellSize)-1,b=s<r}let S=u>0?l:c;if(b)for(let t=v;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,S));else for(let t=y;t>=v;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,S))}_generateOutline(e){let t=[];for(let n of e){let e=El(n,this._granularity,!0),r=this._pointArrayToIndices(e),i=[];for(let e=1;e<r.length;e++)i.push(r[e-1]),i.push(r[e]);t.push(i)}return t}_handlePoles(e){let t=!1,n=!1;this._canonical&&(this._canonical.y===0&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(n=!0)),(t||n)&&this._fillPoles(e,t,n)}_ensureNoPoleVertices(){let e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){let n=e[t+1];n===Sl&&(e[t+1]=-32767),n===Cl&&(e[t+1]=32766)}}_generatePoleQuad(e,t,n,r,i,a){r>i==(a===Sl)?(e.push(n),e.push(t),e.push(this._vertexToIndex(r,a)),e.push(this._vertexToIndex(i,a)),e.push(n),e.push(this._vertexToIndex(r,a))):(e.push(t),e.push(n),e.push(this._vertexToIndex(r,a)),e.push(n),e.push(this._vertexToIndex(i,a)),e.push(this._vertexToIndex(r,a)))}_fillPoles(e,t,n){let r=this._vertexBuffer,i=O,a=e.length;for(let o=2;o<a;o+=3){let a=e[o-2],s=e[o-1],c=e[o],l=r[2*a],u=r[2*a+1],d=r[2*s],f=r[2*s+1],p=r[2*c],m=r[2*c+1];t&&(u===0&&f===0&&this._generatePoleQuad(e,a,s,l,d,Sl),f===0&&m===0&&this._generatePoleQuad(e,s,c,d,p,Sl),m===0&&u===0&&this._generatePoleQuad(e,c,a,p,l,Sl)),n&&(u===i&&f===i&&this._generatePoleQuad(e,a,s,l,d,Cl),f===i&&m===i&&this._generatePoleQuad(e,s,c,d,p,Cl),m===i&&u===i&&this._generatePoleQuad(e,c,a,p,l,Cl))}}_initializeVertices(e){for(let t=0;t<e.length;t+=2)this._vertexToIndex(e[t],e[t+1])}subdividePolygonInternal(e,t){if(this._used)throw Error(`Subdivision: multiple use not allowed.`);this._used=!0;let{flattened:n,holeIndices:r}=function(e){let t=[],n=[];for(let r of e)if(r.length!==0){r!==e[0]&&t.push(n.length/2);for(let e of r)n.push(e.x),n.push(e.y)}return{flattened:n,holeIndices:t}}(e),i;this._initializeVertices(n);try{let e=function(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=Yc(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=function(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=Yc(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(ol(o))}i.sort(nl);for(let e=0;e<i.length;e++)n=rl(i[e],n);return n}(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Zc(a,o,n,s,c,l,0),o}(n,r),t=this._convertIndices(n,e);i=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let a=[];return t&&(a=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:a}}_convertIndices(e,t){let n=[];for(let r of t)n.push(this._vertexToIndex(e[2*r],e[2*r+1]));return n}_pointArrayToIndices(e){let t=[];for(let n of e)t.push(this._vertexToIndex(n.x,n.y));return t}}function Tl(e,t,n,r=!0){return new wl(n,t).subdividePolygonInternal(e,r)}function El(e,t,r=!1){if(!e||e.length<1||e.length<2)return[];let i=e[0],a=e[e.length-1],o=r&&(i.x!==a.x||i.y!==a.y);if(t<2)return o?[...e,e[0]]:[...e];let s=Math.floor(O/t),c=[];c.push(new n(e[0].x,e[0].y));let l=e.length,u=o?l:l-1;for(let t=0;t<u;t++){let r=e[t],i=t<l-1?e[t+1]:e[0],a=r.x,o=r.y,u=i.x,d=i.y,f=a!==u,p=o!==d;if(!f&&!p)continue;let m=u-a,h=d-o,g=Math.abs(m),_=Math.abs(h),v=a,y=o;for(;;){let e=m>0?(Math.floor(v/s)+1)*s:(Math.ceil(v/s)-1)*s,t=h>0?(Math.floor(y/s)+1)*s:(Math.ceil(y/s)-1)*s,r=Math.abs(v-e),i=Math.abs(y-t),a=Math.abs(v-u),o=Math.abs(y-d),l=f?r/g:1/0,b=p?i/_:1/0;if((a<=r||!f)&&(o<=i||!p))break;if(l<b&&f||!p){v=e,y+=h*l;let t=new n(v,Math.round(y));c[c.length-1].x===t.x&&c[c.length-1].y===t.y||c.push(t)}else{v+=m*b,y=t;let e=new n(Math.round(v),y);c[c.length-1].x===e.x&&c[c.length-1].y===e.y||c.push(e)}}let b=new n(u,d);c[c.length-1].x===b.x&&c[c.length-1].y===b.y||c.push(b)}return c}function Dl(e,t,n){if(t.length===0)throw Error(`Subdivision vertex ring is empty.`);let r=0,i=e[2*t[0]];for(let n=1;n<t.length;n++){let a=e[2*t[n]];a<i&&(i=a,r=n)}let a=t.length,o=r,s=(o+1)%a;for(;;){let r=o-1>=0?o-1:a-1,i=(s+1)%a,c=e[2*t[r]],l=e[2*t[i]],u=e[2*t[o]],d=e[2*t[o]+1],f=e[2*t[s]+1],p=!1;if(c<l)p=!0;else if(c>l)p=!1;else{let n=f-d,a=-(e[2*t[s]]-u),o=d<f?1:-1;((c-u)*n+(e[2*t[r]+1]-d)*a)*o>((l-u)*n+(e[2*t[i]+1]-d)*a)*o&&(p=!0)}if(p){let e=t[r],i=t[o],c=t[s];e!==i&&e!==c&&i!==c&&n.push(c,i,e),o--,o<0&&(o=a-1)}else{let e=t[i],r=t[o],c=t[s];e!==r&&e!==c&&r!==c&&n.push(c,r,e),s++,s>=a&&(s=0)}if(r===i)break}}function Ol(e,t,n,r,i,a,o,s,c){let l=i.length/2,u=o&&s&&c;if(l<ms.MAX_VERTEX_ARRAY_LENGTH){let d=t.prepareSegment(l,n,r),f=d.vertexLength;for(let e=0;e<a.length;e+=3)r.emplaceBack(f+a[e],f+a[e+1],f+a[e+2]);let p,m;d.vertexLength+=l,d.primitiveLength+=a.length/3,u&&(m=o.prepareSegment(l,n,s),p=m.vertexLength,m.vertexLength+=l);for(let t=0;t<i.length;t+=2)e(i[t],i[t+1]);if(u)for(let e of c){for(let t=1;t<e.length;t+=2)s.emplaceBack(p+e[t-1],p+e[t]);m.primitiveLength+=e.length/2}}else (function(e,t,n,r,i,a){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},c=0,l=e.getOrCreateLatestSegment(t,n),u=l.vertexLength;for(let d=2;d<i.length;d+=3){let f=i[d-2],p=i[d-1],m=i[d],h=o[f]<c,g=o[p]<c,_=o[m]<c;l.vertexLength+(+!!h+ +!!g+ +!!_)>ms.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,h=!0,g=!0,_=!0,u=0);let v=kl(o,r,a,s,f,h,l),y=kl(o,r,a,s,p,g,l),b=kl(o,r,a,s,m,_,l);n.emplaceBack(u+v-c,u+y-c,u+b-c),l.primitiveLength++}})(t,n,r,i,a,e),u&&function(e,t,n,r,i,a){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},c=0,l=e.getOrCreateLatestSegment(t,n),u=l.vertexLength;for(let d of i)for(let i=1;i<d.length;i+=2){let f=d[i-1],p=d[i],m=o[f]<c,h=o[p]<c;l.vertexLength+(+!!m+ +!!h)>ms.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,m=!0,h=!0,u=0);let g=kl(o,r,a,s,f,m,l),_=kl(o,r,a,s,p,h,l);n.emplaceBack(u+g-c,u+_-c),l.primitiveLength++}}(o,n,s,i,c,e),t.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function kl(e,t,n,r,i,a,o){if(a){let a=r.count;return n(t[2*i],t[2*i+1]),e[i]=r.count,r.count++,o.vertexLength++,a}return e[i]}class Al{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.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new es,this.indexArray=new ds,this.indexArray2=new fs,this.programConfigurations=new Us(e.layers,e.zoom),this.segments=new ms,this.segments2=new ms,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.hasDependencies=qc(`fill`,this.layers,t);let r=this.layers[0].layout.get(`fill-sort-key`),i=!r.isConstant(),a=[];for(let{feature:o,id:s,index:c,sourceLayerIndex:l}of e){let e=this.layers[0]._featureFilter.needGeometry,u=Ys(o,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),u,n))continue;let d=i?r.evaluate(u,{},n,t.availableImages):void 0,f={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:c,geometry:e?u.geometry:Js(o),patterns:{},sortKey:d};a.push(f)}i&&a.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;if(this.hasDependencies){let e=Jc(`fill`,this.layers,r,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(r,i,a,n,{},t.subdivisionGranularity);t.featureIndex.insert(e[a].feature,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}addFeatures(e,t,n){for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,n,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Kc),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,n,r,i,a){for(let e of ur(t,500)){let t=Tl(e,r,a.fill.getGranularityForZoomLevel(r.z)),n=this.layoutVertexArray;Ol(((e,t)=>{n.emplaceBack(e,t)}),this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r})}}let jl,Ml;W(`FillBucket`,Al,{omit:[`layers`,`patternFeatures`]});var Nl={get paint(){return Ml||=new ro({"fill-antialias":new Qa(z.paint_fill[`fill-antialias`]),"fill-opacity":new $a(z.paint_fill[`fill-opacity`]),"fill-color":new $a(z.paint_fill[`fill-color`]),"fill-outline-color":new $a(z.paint_fill[`fill-outline-color`]),"fill-translate":new Qa(z.paint_fill[`fill-translate`]),"fill-translate-anchor":new Qa(z.paint_fill[`fill-translate-anchor`]),"fill-pattern":new eo(z.paint_fill[`fill-pattern`])})},get layout(){return jl||=new ro({"fill-sort-key":new $a(z.layout_fill[`fill-sort-key`])})}};class Pl extends oo{constructor(e,t){super(e,Nl,t)}recalculate(e,t){super.recalculate(e,t);let n=this.paint._values[`fill-outline-color`];n.value.kind===`constant`&&n.value.value===void 0&&(this.paint._values[`fill-outline-color`]=this.paint._values[`fill-color`])}createBucket(e){return new Al(e)}queryRadius(){return dc(this.paint.get(`fill-translate`))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:n,pixelsToTileUnits:r}){return tc(fc(e,this.paint.get(`fill-translate`),this.paint.get(`fill-translate-anchor`),-n.bearingInRadians,r),t)}isTileClipped(){return!0}}let Fl=mo([{name:`a_pos`,components:2,type:`Int16`},{name:`a_normal_ed`,components:4,type:`Int16`}],4),Il=mo([{name:`a_centroid`,components:2,type:`Int16`}],4),{members:Ll}=Fl;class Rl{constructor(e,t,n,r,i){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=i,e.readFields(zl,this,t)}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,r=[],i,a=1,o=0,s=0,c=0;for(;e.pos<t;){if(o<=0){let t=e.readVarint();a=7&t,o=t>>3}if(o--,a===1||a===2)s+=e.readSVarint(),c+=e.readSVarint(),a===1&&(i&&r.push(i),i=[]),i&&i.push(new n(s,c));else{if(a!==7)throw Error(`unknown command ${a}`);i&&i.push(i[0].clone())}}return i&&r.push(i),r}bbox(){let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,n=1,r=0,i=0,a=0,o=1/0,s=-1/0,c=1/0,l=-1/0;for(;e.pos<t;){if(r<=0){let t=e.readVarint();n=7&t,r=t>>3}if(r--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),i<o&&(o=i),i>s&&(s=i),a<c&&(c=a),a>l&&(l=a);else if(n!==7)throw Error(`unknown command ${n}`)}return[o,c,s,l]}toGeoJSON(e,t,n){let r=this.extent*2**n,i=this.extent*e,a=this.extent*t,o=this.loadGeometry();function s(e){return[360*(e.x+i)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+a)/r)*Math.PI))-90]}function c(e){return e.map(s)}let l;if(this.type===1){let e=[];for(let t of o)e.push(t[0]);let t=c(e);l=e.length===1?{type:`Point`,coordinates:t[0]}:{type:`MultiPoint`,coordinates:t}}else if(this.type===2){let e=o.map(c);l=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e}}else{if(this.type!==3)throw Error(`unknown feature type`);{let e=Bl(o),t=[];for(let n of e)t.push(n.map(c));l=t.length===1?{type:`Polygon`,coordinates:t[0]}:{type:`MultiPolygon`,coordinates:t}}}let u={type:`Feature`,geometry:l,properties:this.properties};return this.id!=null&&(u.id=this.id),u}}function zl(e,t,n){e===1?t.id=n.readVarint():e===2?function(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let n=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[n]=r}}(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos)}function Bl(e){let t=e.length;if(t<=1)return[e];let n=[],r,i;for(let a=0;a<t;a++){let t=Vl(e[a]);t!==0&&(i===void 0&&(i=t<0),i===t<0?(r&&n.push(r),r=[e[a]]):r&&r.push(e[a]))}return r&&n.push(r),n}function Vl(e){let t=0;for(let n,r,i=0,a=e.length,o=a-1;i<a;o=i++)n=e[i],r=e[o],t+=(r.x-n.x)*(n.y+r.y);return t}Rl.types=[`Unknown`,`Point`,`LineString`,`Polygon`];class Hl{constructor(e,t){this.version=1,this.name=``,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Ul,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error(`feature index out of bounds`);this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new Rl(this._pbf,t,this.extent,this._keys,this._values)}}function Ul(e,t,n){e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(function(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let n=e.readVarint()>>3;t=n===1?e.readString():n===2?e.readFloat():n===3?e.readDouble():n===4?e.readVarint64():n===5?e.readVarint():n===6?e.readSVarint():n===7?e.readBoolean():null}if(t==null)throw Error(`unknown feature value`);return t}(n))}class Wl{constructor(e,t){this.layers=e.readFields(Gl,{},t)}}function Gl(e,t,n){if(e===3){let e=new Hl(n,n.readVarint()+n.pos);e.length&&(t[e.name]=e)}}let Kl=2**13;function ql(e,t,n,r,i,a,o,s){e.emplaceBack(t,n,2*Math.floor(r*Kl)+o,i*Kl*2,a*Kl*2,Math.round(s))}class Jl{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.hasDependencies=!1,this.layoutVertexArray=new ts,this.centroidVertexArray=new Qo,this.indexArray=new ds,this.programConfigurations=new Us(e.layers,e.zoom),this.segments=new ms,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.features=[],this.hasDependencies=qc(`fill-extrusion`,this.layers,t);for(let{feature:r,id:i,index:a,sourceLayerIndex:o}of e){let e=this.layers[0]._featureFilter.needGeometry,s=Ys(r,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),s,n))continue;let c={id:i,sourceLayerIndex:o,index:a,geometry:e?s.geometry:Js(r),properties:r.properties,type:r.type,patterns:{}};this.hasDependencies?this.features.push(Jc(`fill-extrusion`,this.layers,c,{zoom:this.zoom},t)):this.addFeature(c,c.geometry,a,n,{},t.subdivisionGranularity),t.featureIndex.insert(r,c.geometry,a,o,this.index,!0)}}addFeatures(e,t,n){for(let r of this.features){let{geometry:i}=r;this.addFeature(r,i,r.index,t,n,e.subdivisionGranularity)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ll),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Il.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(e,t,n,r,i,a){for(let n of ur(t,500)){let t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,n,a);let o=this.layoutVertexArray.length-i,s=Math.floor(t.x/t.sampleCount),c=Math.floor(t.y/t.sampleCount);for(let e=0;e<o;e++)this.centroidVertexArray.emplaceBack(s,c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r})}processPolygon(e,t,n,r,i){if(r.length<1||Zl(r[0]))return;for(let t of r)t.length!==0&&Yl(e,t);let a={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=i.fill.getGranularityForZoomLevel(t.z),s=Rl.types[n.type]===`Polygon`;for(let e of r){if(e.length===0||Zl(e))continue;let t=El(e,o,s);this._generateSideFaces(t,a)}if(!s)return;let c=Tl(r,t,o,!1),l=this.layoutVertexArray;Ol(((e,t)=>{ql(l,e,t,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,c.verticesFlattened,c.indicesTriangles)}_generateSideFaces(e,t){let n=0;for(let r=1;r<e.length;r++){let i=e[r],a=e[r-1];if(Xl(i,a))continue;t.segment.vertexLength+4>ms.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=i.sub(a)._perp()._unit(),s=a.dist(i);n+s>32768&&(n=0),ql(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,0,n),ql(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,1,n),n+=s,ql(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,0,n),ql(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,1,n);let c=t.segment.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Yl(e,t){for(let n=0;n<t.length;n++){let r=t[n];n===t.length-1&&t[0].x===r.x&&t[0].y===r.y||(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}function Xl(e,t){return e.x===t.x&&(e.x<0||e.x>O)||e.y===t.y&&(e.y<0||e.y>O)}function Zl(e){return e.every((e=>e.x<0))||e.every((e=>e.x>O))||e.every((e=>e.y<0))||e.every((e=>e.y>O))}let Ql;W(`FillExtrusionBucket`,Jl,{omit:[`layers`,`features`]});var $l={get paint(){return Ql||=new ro({"fill-extrusion-opacity":new Qa(z[`paint_fill-extrusion`][`fill-extrusion-opacity`]),"fill-extrusion-color":new $a(z[`paint_fill-extrusion`][`fill-extrusion-color`]),"fill-extrusion-translate":new Qa(z[`paint_fill-extrusion`][`fill-extrusion-translate`]),"fill-extrusion-translate-anchor":new Qa(z[`paint_fill-extrusion`][`fill-extrusion-translate-anchor`]),"fill-extrusion-pattern":new eo(z[`paint_fill-extrusion`][`fill-extrusion-pattern`]),"fill-extrusion-height":new $a(z[`paint_fill-extrusion`][`fill-extrusion-height`]),"fill-extrusion-base":new $a(z[`paint_fill-extrusion`][`fill-extrusion-base`]),"fill-extrusion-vertical-gradient":new Qa(z[`paint_fill-extrusion`][`fill-extrusion-vertical-gradient`])})}};class eu extends oo{constructor(e,t){super(e,$l,t)}createBucket(e){return new Jl(e)}queryRadius(){return dc(this.paint.get(`fill-extrusion-translate`))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:o,pixelPosMatrix:s}){let c=fc(e,this.paint.get(`fill-extrusion-translate`),this.paint.get(`fill-extrusion-translate-anchor`),-a.bearingInRadians,o),l=this.paint.get(`fill-extrusion-height`).evaluate(t,r),u=this.paint.get(`fill-extrusion-base`).evaluate(t,r),d=function(e,t){let r=[];for(let i of e){let e=[i.x,i.y,0,1];C(e,e,t),r.push(new n(e[0]/e[3],e[1]/e[3]))}return r}(c,s),f=function(e,t,r,i){let a=[],o=[],s=i[8]*t,c=i[9]*t,l=i[10]*t,u=i[11]*t,d=i[8]*r,f=i[9]*r,p=i[10]*r,m=i[11]*r;for(let t of e){let e=[],r=[];for(let a of t){let t=a.x,o=a.y,h=i[0]*t+i[4]*o+i[12],g=i[1]*t+i[5]*o+i[13],_=i[2]*t+i[6]*o+i[14],v=i[3]*t+i[7]*o+i[15],y=_+l,b=v+u,x=h+d,S=g+f,C=_+p,w=v+m,T=new n((h+s)/b,(g+c)/b);T.z=y/b,e.push(T);let E=new n(x/w,S/w);E.z=C/w,r.push(E)}a.push(e),o.push(r)}return[a,o]}(i,u,l,s);return function(e,t,n){let r=1/0;tc(n,t)&&(r=nu(n,t[0]));for(let i=0;i<t.length;i++){let a=t[i],o=e[i];for(let e=0;e<a.length-1;e++){let t=a[e],i=[t,a[e+1],o[e+1],o[e],t];$s(n,i)&&(r=Math.min(r,nu(n,i)))}}return r!==1/0&&r}(f[0],f[1],d)}}function tu(e,t){return e.x*t.x+e.y*t.y}function nu(e,t){if(e.length===1){let n=0,r=t[n++],i;for(;!i||r.equals(i);)if(i=t[n++],!i)return 1/0;for(;n<t.length;n++){let a=t[n],o=e[0],s=i.sub(r),c=a.sub(r),l=o.sub(r),u=tu(s,s),d=tu(s,c),f=tu(c,c),p=tu(l,s),m=tu(l,c),h=u*f-d*d,g=(f*p-d*m)/h,_=(u*m-d*p)/h,v=r.z*(1-g-_)+i.z*g+a.z*_;if(isFinite(v))return v}return 1/0}{let e=1/0;for(let n of t)e=Math.min(e,n.z);return e}}let ru=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class iu{static from(e){if(!(e instanceof ArrayBuffer))throw Error(`Data must be an instance of ArrayBuffer.`);let[t,n]=new Uint8Array(e,0,2);if(t!==219)throw Error(`Data does not appear to be in a KDBush format.`);let r=n>>4;if(r!==1)throw Error(`Got v${r} data when expected v1.`);let i=ru[15&n];if(!i)throw Error(`Unrecognized array type.`);let[a]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new iu(o,a,i,e)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let i=ru.indexOf(this.ArrayType),a=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-o%8)%8;if(i<0)throw Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+a+o+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return au(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this,s=[0,i.length-1,0],c=[];for(;s.length;){let l=s.pop()||0,u=s.pop()||0,d=s.pop()||0;if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(s.push(d),s.push(f-1),s.push(1-l)),(l===0?n>=p:r>=m)&&(s.push(f+1),s.push(u),s.push(1-l))}return c}within(e,t,n){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:r,coords:i,nodeSize:a}=this,o=[0,r.length-1,0],s=[],c=n*n;for(;o.length;){let l=o.pop()||0,u=o.pop()||0,d=o.pop()||0;if(u-d<=a){for(let n=d;n<=u;n++)lu(i[2*n],i[2*n+1],e,t)<=c&&s.push(r[n]);continue}let f=d+u>>1,p=i[2*f],m=i[2*f+1];lu(p,m,e,t)<=c&&s.push(r[f]),(l===0?e-n<=p:t-n<=m)&&(o.push(d),o.push(f-1),o.push(1-l)),(l===0?e+n>=p:t+n>=m)&&(o.push(f+1),o.push(u),o.push(1-l))}return s}}function au(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;ou(e,t,o,r,i,a),au(e,t,n,r,o-1,1-a),au(e,t,n,o+1,i,1-a)}function ou(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);ou(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(su(e,t,r,n),t[2*i+a]>o&&su(e,t,r,i);s<c;){for(su(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?su(e,t,r,c):(c++,su(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function su(e,t,n,r){cu(e,n,r),cu(t,2*n,2*r),cu(t,2*n+1,2*r+1)}function cu(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function lu(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function uu(e,t,n,r){let i=r,a=t+(n-t>>1),o,s=n-t,c=e[t],l=e[t+1],u=e[n],d=e[n+1];for(let r=t+3;r<n;r+=3){let t=du(e[r],e[r+1],c,l,u,d);if(t>i)o=r,i=t;else if(t===i){let e=Math.abs(r-a);e<s&&(o=r,s=e)}}i>r&&(o-t>3&&uu(e,t,o,r),e[o+2]=i,n-o>3&&uu(e,o,n,r))}function du(e,t,n,r,i,a){let o=i-n,s=a-r;if(o!==0||s!==0){let c=((e-n)*o+(t-r)*s)/(o*o+s*s);c>1?(n=i,r=a):c>0&&(n+=o*c,r+=s*c)}return o=e-n,s=t-r,o*o+s*s}function fu(e,t,n,r){let i={type:t,geom:n},a={id:e??null,type:i.type,geometry:i.geom,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(i.type){case`Point`:case`MultiPoint`:mu(a,i.geom);break;case`LineString`:mu(a,i.geom.points);break;case`Polygon`:mu(a,i.geom[0].points);break;case`MultiLineString`:for(let e of i.geom)mu(a,e.points);break;case`MultiPolygon`:for(let e of i.geom)mu(a,e[0].points)}return a}function pu(e){e.points.length>64&&(e.points=new Float64Array(e.points))}function mu(e,t){for(let n=0;n<t.length;n+=3)e.minX=Math.min(e.minX,t[n]),e.minY=Math.min(e.minY,t[n+1]),e.maxX=Math.max(e.maxX,t[n]),e.maxY=Math.max(e.maxY,t[n+1])}function hu(e,t){let n=[];switch(e.type){case`FeatureCollection`:for(let r=0;r<e.features.length;r++)gu(n,e.features[r],t,r);break;case`Feature`:gu(n,e,t);break;default:gu(n,{geometry:e,properties:void 0},t)}return n}function gu(e,t,n,r){if(!t.geometry)return;if(t.geometry.type===`GeometryCollection`)return void function(e,t,n,r,i){for(let a of n.geometries)gu(e,{id:t.id,geometry:a,properties:t.properties},r,i)}(e,t,t.geometry,n,r);if(!t.geometry.coordinates?.length)return;let i=function(e,t,n){return t.promoteId?e.properties?.[t.promoteId]:t.generateId?n||0:e.id}(t,n,r),a=(n.tolerance/((1<<n.maxZoom)*n.extent))**2;switch(t.geometry.type){case`Point`:(function(e,t,n,r){let i=[];i.push(yu(n.coordinates[0]),bu(n.coordinates[1]),0),e.push(fu(t,`Point`,i,r))})(e,i,t.geometry,t.properties);return;case`MultiPoint`:(function(e,t,n,r){let i=[];for(let e of n.coordinates)i.push(yu(e[0]),bu(e[1]),0);e.push(fu(t,`MultiPoint`,i,r))})(e,i,t.geometry,t.properties);return;case`LineString`:(function(e,t,n,r,i){let a={points:[]};_u(n.coordinates,a,r,!1),e.push(fu(t,`LineString`,a,i))})(e,i,t.geometry,a,t.properties);return;case`MultiLineString`:(function(e,t,n,r,i,a){if(i.lineMetrics)for(let i of n.coordinates){let n={points:[]};_u(i,n,r,!1),e.push(fu(t,`LineString`,n,a))}else{let i=[];vu(n.coordinates,i,r,!1),e.push(fu(t,`MultiLineString`,i,a))}})(e,i,t.geometry,a,n,t.properties);return;case`Polygon`:(function(e,t,n,r,i){let a=[];vu(n.coordinates,a,r,!0),e.push(fu(t,`Polygon`,a,i))})(e,i,t.geometry,a,t.properties);return;case`MultiPolygon`:(function(e,t,n,r,i){let a=[];for(let e of n.coordinates){let t=[];vu(e,t,r,!0),a.push(t)}e.push(fu(t,`MultiPolygon`,a,i))})(e,i,t.geometry,a,t.properties);return;default:throw Error(`Input data is not a valid GeoJSON object.`)}}function _u(e,t,n,r){let i,a,o=0;for(let n=0;n<e.length;n++){let s=yu(e[n][0]),c=bu(e[n][1]);t.points.push(s,c,0),n>0&&(o+=r?(i*c-s*a)/2:Math.sqrt((s-i)**2+(c-a)**2)),i=s,a=c}let s=t.points.length-3;t.points[2]=1,n>0&&uu(t.points,0,s,n),t.points[s+2]=1,pu(t),t.size=Math.abs(o),t.start=0,t.end=t.size}function vu(e,t,n,r){for(let i=0;i<e.length;i++){let a={points:[]};_u(e[i],a,n,r),t.push(a)}}function yu(e){return e/360+.5}function bu(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function xu(e){let t={type:`Feature`,geometry:Su(e),properties:e.tags};return e.id!=null&&(t.id=e.id),t}function Su(e){let{type:t,geometry:n}=e;switch(t){case`Point`:return{type:t,coordinates:wu(n[0],n[1])};case`MultiPoint`:return{type:t,coordinates:Cu(n)};case`LineString`:return{type:t,coordinates:Cu(n.points)};case`MultiLineString`:case`Polygon`:return{type:t,coordinates:n.map((e=>Cu(e.points)))};case`MultiPolygon`:return{type:t,coordinates:n.map((e=>e.map((e=>Cu(e.points)))))}}}function Cu(e){let t=[];for(let n=0;n<e.length;n+=3)t.push(wu(e[n],e[n+1]));return t}function wu(e,t){return[Tu(e),Eu(t)]}function Tu(e){return 360*(e-.5)}function Eu(e){let t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var Du;function Ou(e,t,n,r,i,a,o,s){if(r/=t,a>=(n/=t)&&o<r)return e;if(o<n||a>=r)return null;let c=[];for(let t of e){let e=i===Du.X?t.minX:t.minY,a=i===Du.X?t.maxX:t.maxY;if(e>=n&&a<r)c.push(t);else if(!(a<n||e>=r))switch(t.type){case`Point`:case`MultiPoint`:ku(t,c,n,r,i);continue;case`LineString`:Au(t,c,n,r,i,s);continue;case`MultiLineString`:ju(t,c,n,r,i);continue;case`Polygon`:Mu(t,c,n,r,i);continue;case`MultiPolygon`:Nu(t,c,n,r,i);continue}}return c.length?c:null}function ku(e,t,n,r,i){let a=[];(function(e,t,n,r,i){for(let a=0;a<e.length;a+=3){let o=e[a+i];o>=n&&o<=r&&Lu(t,e[a],e[a+1],e[a+2])}})(e.geometry,a,n,r,i),a.length&&t.push(fu(e.id,a.length===3?`Point`:`MultiPoint`,a,e.tags))}function Au(e,t,n,r,i,a){let o=[];if(Pu(e.geometry,o,n,r,i,!1,a.lineMetrics),o.length)if(a.lineMetrics)for(let n of o)t.push(fu(e.id,`LineString`,n,e.tags));else t.push(o.length>1?fu(e.id,`MultiLineString`,o,e.tags):fu(e.id,`LineString`,o[0],e.tags))}function ju(e,t,n,r,i){let a=[];Iu(e.geometry,a,n,r,i,!1),a.length&&t.push(a.length===1?fu(e.id,`LineString`,a[0],e.tags):fu(e.id,`MultiLineString`,a,e.tags))}function Mu(e,t,n,r,i){let a=[];Iu(e.geometry,a,n,r,i,!0),a.length&&t.push(fu(e.id,`Polygon`,a,e.tags))}function Nu(e,t,n,r,i){let a=[];for(let t of e.geometry){let e=[];Iu(t,e,n,r,i,!0),e.length&&a.push(e)}a.length&&t.push(fu(e.id,`MultiPolygon`,a,e.tags))}function Pu(e,t,n,r,i,a,o){let s=Fu(e),c=i===Du.X?Ru:zu,l,u,d=e.start;for(let f=0;f<e.points.length-3;f+=3){let p=e.points[f],m=e.points[f+1],h=e.points[f+2],g=e.points[f+3],_=e.points[f+4],v=i===Du.X?p:m,y=i===Du.X?g:_,b=!1;o&&(l=Math.sqrt((p-g)**2+(m-_)**2)),v<n?y>n&&(u=c(s,p,m,g,_,n),o&&(s.start=d+l*u)):v>r?y<r&&(u=c(s,p,m,g,_,r),o&&(s.start=d+l*u)):Lu(s.points,p,m,h),y<n&&v>=n&&(u=c(s,p,m,g,_,n),b=!0),y>r&&v<=r&&(u=c(s,p,m,g,_,r),b=!0),!a&&b&&(o&&(s.end=d+l*u),t.push(s),s=Fu(e)),o&&(d+=l)}let f=e.points.length-3,p=e.points[f],m=e.points[f+1],h=i===Du.X?p:m;h>=n&&h<=r&&Lu(s.points,p,m,e.points[f+2]),f=s.points.length-3,a&&f>=3&&(s.points[f]!==s.points[0]||s.points[f+1]!==s.points[1])&&Lu(s.points,s.points[0],s.points[1],s.points[2]),s.points.length&&(pu(s),t.push(s))}function Fu(e){return{points:[],size:e.size,start:e.start,end:e.end}}function Iu(e,t,n,r,i,a){for(let o of e)Pu(o,t,n,r,i,a,!1)}function Lu(e,t,n,r){e.push(t,n,r)}function Ru(e,t,n,r,i,a){let o=(a-t)/(r-t);return Lu(e.points,a,n+(i-n)*o,1),o}function zu(e,t,n,r,i,a){let o=(a-n)/(i-n);return Lu(e.points,t+(r-t)*o,a,1),o}function Bu(e,t){let n=t.buffer/t.extent,r=e,i=Ou(e,1,-1-n,n,Du.X,-1,2,t),a=Ou(e,1,1-n,2+n,Du.X,-1,2,t);return i||a?(r=Ou(e,1,-n,1+n,Du.X,-1,2,t)||[],i&&(r=Vu(i,1).concat(r)),a&&(r=r.concat(Vu(a,-1))),r):r}function Vu(e,t){let n=[];for(let r of e)switch(r.type){case`Point`:case`MultiPoint`:{let e=Hu(r.geometry,t);n.push(fu(r.id,r.type,e,r.tags));continue}case`LineString`:{let e=Uu(r.geometry,t);n.push(fu(r.id,r.type,e,r.tags));continue}case`MultiLineString`:case`Polygon`:{let e=[];for(let n of r.geometry)e.push(Uu(n,t));n.push(fu(r.id,r.type,e,r.tags));continue}case`MultiPolygon`:{let e=[];for(let n of r.geometry){let r=[];for(let e of n)r.push(Uu(e,t));e.push(r)}n.push(fu(r.id,r.type,e,r.tags));continue}}return n}function Hu(e,t){let n=[];for(let r=0;r<e.length;r+=3)n.push(e[r]+t,e[r+1],e[r+2]);return n}function Uu(e,t){let n={points:[],size:e.size};e.start!==void 0&&(n.start=e.start,n.end=e.end);for(let r=0;r<e.points.length;r+=3)n.points.push(e.points[r]+t,e.points[r+1],e.points[r+2]);return pu(n),n}function Wu(e,t,n){let r=!!t.newGeometry,i=t.removeAllProperties||t.removeProperties?.length>0||t.addOrUpdateProperties?.length>0;if(r){let r=e[0],a=hu({type:`FeatureCollection`,features:[{type:`Feature`,id:r.id,geometry:t.newGeometry,properties:i?Gu(r.tags,t):r.tags}]},n);return a=Bu(a,n),a}if(i){let n=[];for(let r of e){let e={...r};e.tags=Gu(e.tags,t),n.push(e)}return n}return e}function Gu(e,t){if(t.removeAllProperties)return{};let n={...e||{}};if(t.removeProperties)for(let e of t.removeProperties)delete n[e];if(t.addOrUpdateProperties)for(let{key:e,value:r}of t.addOrUpdateProperties)n[e]=r;return n}(function(e){e[e.X=0]=`X`,e[e.Y=1]=`Y`})(Du||={});let Ku={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e};class qu{constructor(e){this.options=Object.assign(Object.create(Ku),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(e){let t=[];for(let n of e){if(!n.geometry)continue;let[e,r]=n.geometry.coordinates,[i,a]=[yu(e),bu(r)];t.push({id:n.id,type:`Point`,geometry:[i,a],tags:n.properties})}this.createIndex(t)}initialize(e){let t=[];for(let n of e)n.type===`Point`&&t.push(n);this.createIndex(t)}updateIndex(e,t,n){this.options=Object.assign(Object.create(Ku),n.clusterOptions),this.initialize(e)}createIndex(e){let{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time(`total time`);let i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let a=[];for(let t=0;t<e.length;t++){let n=e[t];if(!n?.geometry)continue;let[r,i]=n.geometry;r=Math.fround(r),i=Math.fround(i),a.push(r,i,1/0,t,-1,1),this.options.reduce&&a.push(0)}let o=this.trees[r+1]=this.createTree(a);t&&console.timeEnd(i);for(let e=r;e>=n;e--){let n=Date.now();o=this.trees[e]=this.createTree(this.cluster(o,e)),t&&console.log(`z%d: %d clusters in %dms`,e,o.numItems,Date.now()-n)}t&&console.timeEnd(`total time`)}getClusters(e,t){return this.getClustersInternal(e,t).map((e=>xu(e)))}getClustersInternal(e,t){let n=((e[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,e[1])),i=e[2]===180?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){let e=this.getClustersInternal([n,r,180,a],t),o=this.getClustersInternal([-180,r,i,a],t);return e.concat(o)}let o=this.trees[this.limitZoom(t)],s=o.range(yu(n),bu(a),yu(i),bu(r)),c=o.flatData,l=[];for(let e of s){let t=this.stride*e;l.push(c[t+5]>1?Ju(c,t,this.clusterProps):this.points[c[t+3]])}return l}getChildren(e){let t=this.getOriginId(e),n=this.getOriginZoom(e),r=Error(`No cluster with the specified id: `+e),i=this.trees[n];if(!i)throw r;let a=i.flatData;if(t*this.stride>=a.length)throw r;let o=this.options.radius/(this.options.extent*2**(n-1)),s=i.within(a[t*this.stride],a[t*this.stride+1],o),c=[];for(let t of s){let n=t*this.stride;a[n+4]===e&&c.push(a[n+5]>1?Yu(a,n,this.clusterProps):xu(this.points[a[n+3]]))}if(c.length===0)throw r;return c}getLeaves(e,t,n){let r=[];return this.appendLeaves(r,e,t||=10,n||=0,0),r}getTile(e,t,n){let r=this.trees[this.limitZoom(e)];if(!r)return null;let i=2**e,{extent:a,radius:o}=this.options,s=o/a,c=(n-s)/i,l=(n+1+s)/i,u={transformed:!0,features:[],source:null,x:t,y:n,z:e};return this.addTileFeatures(r.range((t-s)/i,c,(t+1+s)/i,l),r.flatData,t,n,i,u),t===0&&this.addTileFeatures(r.range(1-s/i,c,1,l),r.flatData,i,n,i,u),t===i-1&&this.addTileFeatures(r.range(0,c,s/i,l),r.flatData,-1,n,i,u),u}getClusterExpansionZoom(e){return this.getOriginZoom(e)}appendLeaves(e,t,n,r,i){let a=this.getChildren(t);for(let t of a){let a=t.properties;if(a?.cluster?i+a.point_count<=r?i+=a.point_count:i=this.appendLeaves(e,a.cluster_id,n,r,i):i<r?i++:e.push(t),e.length===n)break}return i}createTree(e){let t=new iu(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let n=0;n<e.length;n+=this.stride)t.add(e[n],e[n+1]);return t.finish(),t.flatData=e,t.data=null,t}addTileFeatures(e,t,n,r,i,a){for(let o of e){let e=o*this.stride,s=t[e+5]>1,c,l,u;if(s)c=Xu(t,e,this.clusterProps),l=t[e],u=t[e+1];else{let n=this.points[t[e+3]];c=n.tags,[l,u]=n.geometry}let d={type:1,geometry:[[Math.round(this.options.extent*(l*i-n)),Math.round(this.options.extent*(u*i-r))]],tags:c},f;f=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,f!==void 0&&(d.id=f),a.features.push(d)}}limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}cluster(e,t){let{radius:n,extent:r,reduce:i,minPoints:a}=this.options,o=n/(r*2**t),s=e.flatData,c=[],l=this.stride;for(let n=0;n<s.length;n+=l){if(s[n+2]<=t)continue;s[n+2]=t;let r=s[n],u=s[n+1],d=e.within(s[n],s[n+1],o),f=s[n+5],p=f;for(let e of d){let n=e*l;s[n+2]>t&&(p+=s[n+5])}if(p>f&&p>=a){let e,a=r*f,o=u*f,m=-1,h=(n/l<<5)+(t+1)+this.points.length;for(let r of d){let c=r*l;if(s[c+2]<=t)continue;s[c+2]=t;let u=s[c+5];a+=s[c]*u,o+=s[c+1]*u,s[c+4]=h,i&&(e||(e=this.map(s,n,!0),m=this.clusterProps.length,this.clusterProps.push(e)),i(e,this.map(s,c)))}s[n+4]=h,c.push(a/p,o/p,1/0,h,-1,p),i&&c.push(m)}else{for(let e=0;e<l;e++)c.push(s[n+e]);if(p>1)for(let e of d){let n=e*l;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e<l;e++)c.push(s[n+e])}}}}return c}getOriginId(e){return e-this.points.length>>5}getOriginZoom(e){return(e-this.points.length)%32}map(e,t,n){if(e[t+5]>1){let r=this.clusterProps[e[t+6]];return n?Object.assign({},r):r}let r=this.points[e[t+3]].tags,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}}function Ju(e,t,n){return{id:e[t+3],type:`Point`,tags:Xu(e,t,n),geometry:[e[t],e[t+1]]}}function Yu(e,t,n){return{type:`Feature`,id:e[t+3],properties:Xu(e,t,n),geometry:{type:`Point`,coordinates:[Tu(e[t]),Eu(e[t+1])]}}}function Xu(e,t,n){let r=e[t+5],i=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+`k`:r,a=e[t+6],o=a===-1?{}:Object.assign({},n[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:i})}let Zu=`geojsonvt_clip_start`,Qu=`geojsonvt_clip_end`;function $u(e,t,n,r,i){let a=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),o={transformed:!1,features:[],source:null,x:n,y:r,z:t,minX:2,minY:1,maxX:-1,maxY:0,numPoints:0,numSimplified:0,numFeatures:e.length};for(let t of e)ed(o,t,a,i);return o}function ed(e,t,n,r){switch(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),t.type){case`Point`:case`MultiPoint`:(function(e,t){let n=[];for(let r=0;r<t.geometry.length;r+=3)n.push(t.geometry[r],t.geometry[r+1]),e.numPoints++,e.numSimplified++;if(!n.length)return;let r={type:1,tags:t.tags||null,geometry:n};t.id!==null&&(r.id=t.id),e.features.push(r)})(e,t);return;case`LineString`:(function(e,t,n,r){let i=[];if(td(i,t.geometry,e,n,!1,!1),!i.length)return;let a=t.tags||null;if(r.lineMetrics){a={};for(let e in t.tags)a[e]=t.tags[e];a[Zu]=t.geometry.start/t.geometry.size,a[Qu]=t.geometry.end/t.geometry.size}let o={type:2,tags:a,geometry:i};t.id!==null&&(o.id=t.id),e.features.push(o)})(e,t,n,r);return;case`MultiLineString`:case`Polygon`:(function(e,t,n){let r=[];for(let i=0;i<t.geometry.length;i++)td(r,t.geometry[i],e,n,t.type===`Polygon`,i===0);if(!r.length)return;let i={type:t.type===`Polygon`?3:2,tags:t.tags||null,geometry:r};t.id!==null&&(i.id=t.id),e.features.push(i)})(e,t,n);return;case`MultiPolygon`:(function(e,t,n){let r=[];for(let i=0;i<t.geometry.length;i++){let a=t.geometry[i];for(let t=0;t<a.length;t++)td(r,a[t],e,n,!0,t===0)}if(!r.length)return;let i={type:3,tags:t.tags||null,geometry:r};t.id!==null&&(i.id=t.id),e.features.push(i)})(e,t,n);return}}function td(e,t,n,r,i,a){let o=r*r;if(r>0&&t.size<(i?o:r))return void(n.numPoints+=t.points.length/3);let s=[];for(let e=0;e<t.points.length;e+=3)(r===0||t.points[e+2]>o)&&(n.numSimplified++,s.push(t.points[e],t.points[e+1])),n.numPoints++;i&&function(e,t){let n=0;for(let t=0,r=e.length,i=r-2;t<r;i=t,t+=2)n+=(e[t]-e[i])*(e[t+1]+e[i+1]);if(n>0===t)for(let t=0,n=e.length;t<n/2;t+=2){let r=e[t],i=e[t+1];e[t]=e[n-2-t],e[t+1]=e[n-1-t],e[n-2-t]=r,e[n-1-t]=i}}(s,a),e.push(s)}function nd(e,t){if(e.transformed)return e;let n=1<<e.z,r=e.x,i=e.y;for(let a of e.features)a.type===1?rd(a,t,n,r,i):id(a,t,n,r,i);return e.transformed=!0,e}function rd(e,t,n,r,i){let a=e,o=e.geometry,s=[];for(let e=0;e<o.length;e+=2)s.push(ad(o[e],o[e+1],t,n,r,i));return a.geometry=s,a}function id(e,t,n,r,i){let a=e,o=e.geometry,s=[];for(let e of o){let a=[];for(let o=0;o<e.length;o+=2)a.push(ad(e[o],e[o+1],t,n,r,i));s.push(a)}return a.geometry=s,a}function ad(e,t,n,r,i,a){return[Math.round(n*(e*r-i)),Math.round(n*(t*r-a))]}class od{constructor(e){this.options=e,this.total=0,this.stats={},this.tiles={},this.tileCoords=[],this.stats={},this.total=0}initialize(e){this.splitTile(e,0,0,0),this.options.debug&&(e.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)))}updateIndex(e,t,n){n.debug>1&&(console.log(`invalidating tiles`),console.time(`invalidating`)),this.invalidateTiles(t),n.debug>1&&console.timeEnd(`invalidating`);let[r,i,a]=[0,0,0],o=$u(e,r,i,a,n);o.source=e;let s=sd(r,i,a);if(this.tiles[s]=o,this.tileCoords.push({z:r,x:i,y:a,id:s}),n.debug){let e=`z${r}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}getClusterExpansionZoom(e){return null}getChildren(e){return null}getLeaves(e,t,n){return null}getTile(e,t,n){let{extent:r,debug:i}=this.options,a=1<<e,o=sd(e,t=t+a&a-1,n);if(this.tiles[o])return nd(this.tiles[o],r);i>1&&console.log(`drilling down to z%d-%d-%d`,e,t,n);let s,c=e,l=t,u=n;for(;!s&&c>0;)c--,l>>=1,u>>=1,s=this.tiles[sd(c,l,u)];return s?.source?(i>1&&(console.log(`found parent tile z%d-%d-%d`,c,l,u),console.time(`drilling down`)),this.splitTile(s.source,c,l,u,e,t,n),i>1&&console.timeEnd(`drilling down`),this.tiles[o]?nd(this.tiles[o],r):null):null}splitTile(e,t,n,r,i,a,o){let s=[e,t,n,r],c=this.options,l=c.debug;for(;s.length;){r=s.pop(),n=s.pop(),t=s.pop(),e=s.pop();let u=1<<t,d=sd(t,n,r),f=this.tiles[d];if(!f&&(l>1&&console.time(`creation`),f=this.tiles[d]=$u(e,t,n,r,c),this.tileCoords.push({z:t,x:n,y:r,id:d}),l)){l>1&&(console.log(`tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,t,n,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd(`creation`));let e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(f.source=e,i==null){if(t===c.indexMaxZoom||f.numPoints<=c.indexMaxPoints)continue}else{if(t===c.maxZoom||t===i)continue;if(i!=null){let e=i-t;if(n!==a>>e||r!==o>>e)continue}}if(f.source=null,!e.length)continue;l>1&&console.time(`clipping`);let p=.5*c.buffer/c.extent,m=.5-p,h=.5+p,g=1+p,_=null,v=null,y=null,b=null,x=Ou(e,u,n-p,n+h,Du.X,f.minX,f.maxX,c),S=Ou(e,u,n+m,n+g,Du.X,f.minX,f.maxX,c);x&&(_=Ou(x,u,r-p,r+h,Du.Y,f.minY,f.maxY,c),v=Ou(x,u,r+m,r+g,Du.Y,f.minY,f.maxY,c)),S&&(y=Ou(S,u,r-p,r+h,Du.Y,f.minY,f.maxY,c),b=Ou(S,u,r+m,r+g,Du.Y,f.minY,f.maxY,c)),l>1&&console.timeEnd(`clipping`),s.push(_||[],t+1,2*n,2*r),s.push(v||[],t+1,2*n,2*r+1),s.push(y||[],t+1,2*n+1,2*r),s.push(b||[],t+1,2*n+1,2*r+1)}}invalidateTiles(e){if(!e.length)return;let t=this.options,{debug:n}=t,r=1/0,i=-1/0,a=1/0,o=-1/0;for(let t of e)r=Math.min(r,t.minX),i=Math.max(i,t.maxX),a=Math.min(a,t.minY),o=Math.max(o,t.maxY);let s=t.buffer/t.extent,c=new Set;for(let t in this.tiles){let l=this.tiles[t],u=1<<l.z,d=(l.x-s)/u,f=(l.x+1+s)/u,p=(l.y-s)/u,m=(l.y+1+s)/u;if(i<d||r>=f||o<p||a>=m)continue;let h=!1;for(let t of e)if(t.maxX>=d&&t.minX<f&&t.maxY>=p&&t.minY<m){h=!0;break}if(h){if(n){n>1&&console.log(`invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,l.z,l.x,l.y,l.numFeatures,l.numPoints,l.numSimplified);let e=`z${l.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[t],c.add(t)}}c.size&&(this.tileCoords=this.tileCoords.filter((e=>!c.has(e.id))))}}function sd(e,t,n){return 32*((1<<e)*n+t)+e}let cd={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,cluster:!1,clusterOptions:Ku,debug:0},{members:ld}=mo([{name:`a_pos_normal`,components:2,type:`Int16`},{name:`a_data`,components:4,type:`Uint8`}],4),{members:ud}=mo([{name:`a_uv_x`,components:1,type:`Float32`},{name:`a_split_index`,components:1,type:`Float32`}]),dd=Math.cos(Math.PI/180*37.5),fd=2**14/.5;class pd{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.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let e of this.layers)this.gradients[e.id]={};this.layoutVertexArray=new ns,this.layoutVertexArray2=new rs,this.indexArray=new ds,this.programConfigurations=new Us(e.layers,e.zoom),this.segments=new ms,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.hasDependencies=qc(`line`,this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get(`line-sort-key`),i=!r.isConstant(),a=[];for(let{feature:t,id:o,index:s,sourceLayerIndex:c}of e){let e=this.layers[0]._featureFilter.needGeometry,l=Ys(t,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),l,n))continue;let u=i?r.evaluate(l,{},n):void 0,d={id:o,properties:t.properties,type:t.type,sourceLayerIndex:c,index:s,geometry:e?l.geometry:Js(t),patterns:{},dashes:{},sortKey:u};a.push(d)}i&&a.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;this.hasDependencies?(qc(`line`,this.layers,t)?Jc(`line`,this.layers,r,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,t),this.patternFeatures.push(r)):this.addFeature(r,i,a,n,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[a].feature,i,a,o,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,dashPositions:r})}addFeatures(e,t,n,r){for(let i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,n,r,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,ud)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ld),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&&Object.hasOwn(e.properties,Zu)&&Object.hasOwn(e.properties,Qu))return{start:+e.properties[Zu],end:+e.properties[Qu]}}addFeature(e,t,n,r,i,a,o){let s=this.layers[0].layout,c=s.get(`line-join`).evaluate(e,{}),l=s.get(`line-cap`).evaluate(e,{}),u=s.get(`line-miter-limit`).evaluate(e,{}),d=s.get(`line-round-limit`).evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let n of t)this.addLine(n,e,c,l,u,d,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,dashPositions:a,canonical:r})}addLine(e,t,n,r,i,a,o,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=El(e,o?s.line.getGranularityForZoomLevel(o.z):1),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)}let c=Rl.types[t.type]===`Polygon`,l=e.length;for(;l>=2&&e[l-1].equals(e[l-2]);)l--;let u=0;for(;u<l-1&&e[u].equals(e[u+1]);)u++;if(l<(c?3:2))return;n===`bevel`&&(i=1.05);let d=this.overscaling<=16?122880/(512*this.overscaling):0,f=this.segments.prepareSegment(10*l,this.layoutVertexArray,this.indexArray),p,m,h,g,_;this.e1=this.e2=-1,c&&(p=e[l-2],_=e[u].sub(p)._unit()._perp());for(let t=u;t<l;t++){if(h=t===l-1?c?e[u+1]:void 0:e[t+1],h&&e[t].equals(h))continue;_&&(g=_),p&&(m=p),p=e[t],_=h?h.sub(p)._unit()._perp():g,g||=_;let o=g.add(_);o.x===0&&o.y===0||o._unit();let s=g.x*_.x+g.y*_.y,v=o.x*_.x+o.y*_.y,y=v===0?1/0:1/v,b=2*Math.sqrt(2-2*v),x=v<dd&&m&&h,S=g.x*_.y-g.y*_.x>0;if(x&&t>u){let e=p.dist(m);if(e>2*d){let t=p.sub(p.sub(m)._mult(d/e)._round());this.updateDistance(m,t),this.addCurrentVertex(t,g,0,0,f),m=t}}let C=m&&h,w=C?n:c?`butt`:r;if(C&&w===`round`&&(y<a?w=`miter`:y<=2&&(w=`fakeround`)),w===`miter`&&y>i&&(w=`bevel`),w===`bevel`&&(y>2&&(w=`flipbevel`),y<i&&(w=`miter`)),m&&this.updateDistance(m,p),w===`miter`)o._mult(y),this.addCurrentVertex(p,o,0,0,f);else if(w===`flipbevel`){if(y>100)o=_.mult(-1);else{let e=y*g.add(_).mag()/g.sub(_).mag();o._perp()._mult(e*(S?-1:1))}this.addCurrentVertex(p,o,0,0,f),this.addCurrentVertex(p,o.mult(-1),0,0,f)}else if(w===`bevel`||w===`fakeround`){let e=-Math.sqrt(y*y-1),t=S?e:0,n=S?0:e;if(m&&this.addCurrentVertex(p,g,t,n,f),w===`fakeround`){let e=Math.round(180*b/Math.PI/20);for(let t=1;t<e;t++){let n=t/e;if(n!==.5){let e=n-.5;n+=n*e*(n-1)*((1.0904+s*(s*(3.55645-1.43519*s)-3.2452))*e*e+(.848013+s*(.215638*s-1.06021)))}let r=_.sub(g)._mult(n)._add(g)._unit()._mult(S?-1:1);this.addHalfVertex(p,r.x,r.y,!1,S,0,f)}}h&&this.addCurrentVertex(p,_,-t,-n,f)}else if(w===`butt`)this.addCurrentVertex(p,o,0,0,f);else if(w===`square`){let e=m?1:-1;this.addCurrentVertex(p,o,e,e,f)}else w===`round`&&(m&&(this.addCurrentVertex(p,g,0,0,f),this.addCurrentVertex(p,g,1,1,f,!0)),h&&(this.addCurrentVertex(p,_,-1,-1,f,!0),this.addCurrentVertex(p,_,0,0,f)));if(x&&t<l-1){let e=p.dist(h);if(e>2*d){let t=p.add(h.sub(p)._mult(d/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,f),p=t}}}}addCurrentVertex(e,t,n,r,i,a=!1){let o=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,a,!1,n,i),this.addHalfVertex(e,o,s,a,!0,-r,i),this.distance>fd/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,n,r,i,a))}addHalfVertex({x:e,y:t},n,r,i,a,o,s){let c=.5*(this.lineClips?this.scaledDistance*(fd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+ +!!i,(t<<1)+ +!!a,Math.round(63*n)+128,Math.round(63*r)+128,1+(o===0?0:o<0?-1:1)|(63&c)<<2,c>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,l,this.e2),s.primitiveLength++),a?this.e2=l:this.e1=l}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(let t of e){let e=t.paint.get(`line-dasharray`);if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,n,r){for(let i of e){let e=i.paint.get(`line-dasharray`);if(!e||e.value.kind===`constant`)continue;let a=i.layout.get(`line-cap`).evaluate(t,{})===`round`,o={dasharray:e.value.evaluate({zoom:n-1},t,{}),round:a},s={dasharray:e.value.evaluate({zoom:n},t,{}),round:a},c={dasharray:e.value.evaluate({zoom:n+1},t,{}),round:a},l=`${o.dasharray.join(`,`)},${o.round}`,u=`${s.dasharray.join(`,`)},${s.round}`,d=`${c.dasharray.join(`,`)},${c.round}`;r.dashDependencies[l]=o,r.dashDependencies[u]=s,r.dashDependencies[d]=c,t.dashes[i.id]={min:l,mid:u,max:d}}}}let md,hd;W(`LineBucket`,pd,{omit:[`layers`,`patternFeatures`]});var gd={get paint(){return hd||=new ro({"line-opacity":new $a(z.paint_line[`line-opacity`]),"line-color":new $a(z.paint_line[`line-color`]),"line-translate":new Qa(z.paint_line[`line-translate`]),"line-translate-anchor":new Qa(z.paint_line[`line-translate-anchor`]),"line-width":new $a(z.paint_line[`line-width`]),"line-gap-width":new $a(z.paint_line[`line-gap-width`]),"line-offset":new $a(z.paint_line[`line-offset`]),"line-blur":new $a(z.paint_line[`line-blur`]),"line-dasharray":new eo(z.paint_line[`line-dasharray`]),"line-pattern":new eo(z.paint_line[`line-pattern`]),"line-gradient":new no(z.paint_line[`line-gradient`])})},get layout(){return md||=new ro({"line-cap":new $a(z.layout_line[`line-cap`]),"line-join":new $a(z.layout_line[`line-join`]),"line-miter-limit":new $a(z.layout_line[`line-miter-limit`]),"line-round-limit":new $a(z.layout_line[`line-round-limit`]),"line-sort-key":new $a(z.layout_line[`line-sort-key`])})}};class _d extends $a{possiblyEvaluate(e,t){return t=new Va(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=L({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}let vd;class yd extends oo{constructor(e,t){super(e,gd,t),this.gradientVersion=0,vd||(vd=new _d(gd.paint.properties[`line-width`].specification),vd.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e===`line-gradient`){let e=this.gradientExpression();this.stepInterpolant=!!function(e){return e._styleExpression!==void 0}(e)&&e._styleExpression.expression instanceof vn,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values[`line-gradient`].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values[`line-floorwidth`]=vd.possiblyEvaluate(this._transitioningPaint._values[`line-width`].value,e)}createBucket(e){return new pd(e)}queryRadius(e){let t=e,n=bd(uc(`line-width`,this,t),uc(`line-gap-width`,this,t)),r=uc(`line-offset`,this,t);return n/2+Math.abs(r)+dc(this.paint.get(`line-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:o}){let s=fc(e,this.paint.get(`line-translate`),this.paint.get(`line-translate-anchor`),-a.bearingInRadians,o),c=o/2*bd(this.paint.get(`line-width`).evaluate(t,r),this.paint.get(`line-gap-width`).evaluate(t,r)),l=this.paint.get(`line-offset`).evaluate(t,r);return l&&(i=function(e,t){let r=[];for(let i of e){let e=pc(i),a=[];for(let r=0;r<e.length;r++){let i=e[r],o=e[r-1],s=e[r+1],c=r===0?new n(0,0):i.sub(o)._unit()._perp(),l=r===e.length-1?new n(0,0):s.sub(i)._unit()._perp(),u=c._add(l)._unit(),d=u.x*l.x+u.y*l.y;d!==0&&u._mult(1/d),a.push(u._mult(t)._add(i))}r.push(a)}return r}(i,l*o)),function(e,t,n){for(let r of t){if(e.length>=3){for(let t of r)if(cc(e,t))return!0}if(nc(e,r,n))return!0}return!1}(s,i,c)}isTileClipped(){return!0}}function bd(e,t){return t>0?t+2*e:e}let xd=mo([{name:`a_pos_offset`,components:4,type:`Int16`},{name:`a_data`,components:4,type:`Uint16`},{name:`a_pixeloffset`,components:4,type:`Int16`}],4),Sd=mo([{name:`a_projected_pos`,components:3,type:`Float32`}],4);mo([{name:`a_fade_opacity`,components:1,type:`Uint32`}],4);let Cd=mo([{name:`a_placed`,components:2,type:`Uint8`},{name:`a_shift`,components:2,type:`Float32`},{name:`a_box_real`,components:2,type:`Int16`}]);mo([{type:`Int16`,name:`anchorPointX`},{type:`Int16`,name:`anchorPointY`},{type:`Int16`,name:`x1`},{type:`Int16`,name:`y1`},{type:`Int16`,name:`x2`},{type:`Int16`,name:`y2`},{type:`Uint32`,name:`featureIndex`},{type:`Uint16`,name:`sourceLayerIndex`},{type:`Uint16`,name:`bucketIndex`}]);let wd=mo([{name:`a_pos`,components:2,type:`Int16`},{name:`a_anchor_pos`,components:2,type:`Int16`},{name:`a_extrude`,components:2,type:`Int16`}],4),Td=mo([{name:`a_pos`,components:2,type:`Float32`},{name:`a_radius`,components:1,type:`Float32`},{name:`a_flags`,components:2,type:`Int16`}],4);function Ed(e,t,n){let r=t.layout.get(`text-transform`).evaluate(n,{});return r===`uppercase`?e=e.toLocaleUpperCase():r===`lowercase`&&(e=e.toLocaleLowerCase()),Ba.applyArabicShaping&&(e=Ba.applyArabicShaping(e)),e}function Dd(e,t,n){for(let r of e.sections)r.text=Ed(r.text,t,n);return e}mo([{name:`triangle`,components:3,type:`Uint16`}]),mo([{type:`Int16`,name:`anchorX`},{type:`Int16`,name:`anchorY`},{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`}]),mo([{type:`Int16`,name:`anchorX`},{type:`Int16`,name:`anchorY`},{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`,name:`textBoxScale`},{type:`Float32`,name:`collisionCircleDiameter`},{type:`Uint16`,name:`textAnchorOffsetStartIndex`},{type:`Uint16`,name:`textAnchorOffsetEndIndex`}]),mo([{type:`Float32`,name:`offsetX`}]),mo([{type:`Int16`,name:`x`},{type:`Int16`,name:`y`},{type:`Int16`,name:`tileUnitDistanceFromAnchor`}]),mo([{type:`Uint16`,name:`textAnchor`},{type:`Float32`,components:2,name:`textOffset`}]);var Od=24;let kd={"!":`︕`,"#":`#`,$:`$`,"%":`%`,"&":`&`,"(":`︵`,")":`︶`,"*":`*`,"+":`+`,",":`︐`,"-":`︲`,".":`・`,"/":`/`,":":`︓`,";":`︔`,"<":`︿`,"=":`=`,">":`﹀`,"?":`︖`,"@":`@`,"[":`﹇`,"\\":`\`,"]":`﹈`,"^":`^`,_:`︳`,"`":```,"{":`︷`,"|":`―`,"}":`︸`,"~":`~`,"¢":`¢`,"£":`£`,"¥":`¥`,"¦":`¦`,"¬":`¬`,"¯":` ̄`,"–":`︲`,"—":`︱`,"‘":`﹃`,"’":`﹄`,"“":`﹁`,"”":`﹂`,"…":`︙`,"⋯":`︙`,"‧":`・`,"₩":`₩`,"、":`︑`,"。":`︒`,"〈":`︿`,"〉":`﹀`,"《":`︽`,"》":`︾`,"「":`﹁`,"」":`﹂`,"『":`﹃`,"』":`﹄`,"【":`︻`,"】":`︼`,"〔":`︹`,"〕":`︺`,"〖":`︗`,"〗":`︘`,"!":`︕`,"(":`︵`,")":`︶`,",":`︐`,"-":`︲`,".":`・`,":":`︓`,";":`︔`,"<":`︿`,">":`﹀`,"?":`︖`,"[":`﹇`,"]":`﹈`,"_":`︳`,"{":`︷`,"|":`―`,"}":`︸`,"⦅":`︵`,"⦆":`︶`,"。":`︒`,"「":`﹁`,"」":`﹂`},Ad={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},jd={40:!0};function Md(e,t,n,r,i,a){if(`fontStack`in t){let r=n[t.fontStack]?.[e];return r?r.metrics.advance*t.scale+i:0}{let e=r[t.imageName];return e?e.displaySize[0]*t.scale*Od/a+i:0}}function Nd(e,t,n,r){let i=(e-t)**2;return r?e<t?i/2:2*i:i+Math.abs(n)*n}function Pd(e,t,n){let r=0;return e===10&&(r-=1e4),n&&(r+=150),e!==40&&e!==65288||(r+=50),t!==41&&t!==65289||(r+=50),r}function Fd(e,t,n,r,i,a){let o=null,s=Nd(t,n,i,a);for(let e of r){let r=Nd(t-e.x,n,i,a)+e.badness;r<=s&&(o=e,s=r)}return{index:e,x:t,priorBreak:o,badness:s}}function Id(e){return e?Id(e.priorBreak).concat(e.index):[]}class Ld{constructor(e=``,t=[],n=[]){this.text=e,this.sections=t,this.sectionIndex=n,this.imageSectionID=null}static fromFeature(e,t){let n=new Ld;for(let r of e.sections)r.image?n.addImageSection(r):n.addTextSection(r,t);return n}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=function(e){let t=``,n={premature:!0,value:void 0},r=e[Symbol.iterator](),i=r.next(),a=e[Symbol.iterator]();a.next();let o=a.next();for(;!i.done;)t+=!o.done&&Fa(o.value.codePointAt(0))&&!kd[o.value]||!n.premature&&Fa(n.value.codePointAt(0))&&!kd[n.value]||!kd[i.value]?i.value:kd[i.value],n={value:i.value,premature:!1},i=r.next(),o=a.next();return t}(this.text)}hasZeroWidthSpaces(){return this.text.includes(``)}trim(){let e=this.text.match(/^\s*/),t=e?e[0].length:0,n=this.text.match(/\S\s*$/),r=n?n[0].length-1:0;this.text=this.text.substring(t,this.text.length-r),this.sectionIndex=this.sectionIndex.slice(t,this.sectionIndex.length-r)}substring(e,t){let n=[...this.text].slice(e,t).join(``),r=this.sectionIndex.slice(e,t);return new Ld(n,this.sections,r)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join(``).length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}getMaxImageSize(e){let t=0,n=0;for(let r=0;r<this.length();r++){let i=this.getSection(r);if(`imageName`in i){let r=e[i.imageName];if(!r)continue;let a=r.displaySize;t=Math.max(t,a[0]),n=Math.max(n,a[1])}}return{maxImageWidth:t,maxImageHeight:n}}addTextSection(e,t){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||`bottom`,fontStack:e.fontStack||t});let n=this.sections.length-1;this.sectionIndex.push(...[...e.text].map((()=>n)))}addImageSection(e){let t=e.image?e.image.name:``;if(t.length===0)return void ae(`Can't add FormattedSection with an empty image.`);let n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push({scale:1,verticalAlign:e.verticalAlign||`bottom`,imageName:t}),this.sectionIndex.push(this.sections.length-1)):ae(`Reached maximum number of images 6401`)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,n,r,i){let a=[],o=this.determineAverageLineWidth(e,t,n,r,i),s=this.hasZeroWidthSpaces(),c=0,l=0,u=this.text[Symbol.iterator](),d=u.next(),f=this.text[Symbol.iterator]();f.next();let p=f.next(),m=this.text[Symbol.iterator]();m.next(),m.next();let h=m.next();for(;!d.done;){let t=this.getSection(l),g=d.value.codePointAt(0);if(ka(g)||(c+=Md(g,t,n,r,e,i)),!p.done){let e=Da(g),n=p.value.codePointAt(0);(Ad[g]||e||`imageName`in t||!h.done&&jd[n])&&a.push(Fd(l+1,c,o,a,Pd(g,n,e&&s),!1))}l++,d=u.next(),p=f.next(),h=m.next()}return Id(Fd(this.length(),c,o,a,0,!0))}determineAverageLineWidth(e,t,n,r,i){let a=0,o=0;for(let t of this.text){let s=this.getSection(o);a+=Md(t.codePointAt(0),s,n,r,e,i),o++}return a/Math.max(1,Math.ceil(a/t))}}let Rd=4294967296,zd=1/Rd,Bd=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`);class Vd{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,n=this.length){for(;this.pos<n;){let n=this.readVarint(),r=n>>3,i=this.pos;this.type=7&n,e(r,t,this),this.pos===i&&this.skip(n)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Rd;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Rd;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,n,r;return r=t[this.pos++],n=127&r,r<128?n:(r=t[this.pos++],n|=(127&r)<<7,r<128?n:(r=t[this.pos++],n|=(127&r)<<14,r<128?n:(r=t[this.pos++],n|=(127&r)<<21,r<128?n:(r=t[this.pos],n|=(15&r)<<28,function(e,t,n){let r=n.buf,i,a;if(a=r[n.pos++],i=(112&a)>>4,a<128||(a=r[n.pos++],i|=(127&a)<<3,a<128)||(a=r[n.pos++],i|=(127&a)<<10,a<128)||(a=r[n.pos++],i|=(127&a)<<17,a<128)||(a=r[n.pos++],i|=(127&a)<<24,a<128)||(a=r[n.pos++],i|=(1&a)<<31,a<128))return Hd(e,i,t);throw Error(`Expected varint not more than 10 bytes`)}(n,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Bd?Bd.decode(this.buf.subarray(t,e)):function(e,t,n){let r=``,i=t;for(;i<n;){let t=e[i],a,o,s,c=null,l=t>239?4:t>223?3:t>191?2:1;if(i+l>n)break;l===1?t<128&&(c=t):l===2?(a=e[i+1],(192&a)==128&&(c=(31&t)<<6|63&a,c<=127&&(c=null))):l===3?(a=e[i+1],o=e[i+2],(192&a)==128&&(192&o)==128&&(c=(15&t)<<12|(63&a)<<6|63&o,(c<=2047||c>=55296&&c<=57343)&&(c=null))):l===4&&(a=e[i+1],o=e[i+2],s=e[i+3],(192&a)==128&&(192&o)==128&&(192&s)==128&&(c=(15&t)<<18|(63&a)<<12|(63&o)<<6|63&s,(c<=65535||c>=1114112)&&(c=null))),c===null?(c=65533,l=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),i+=l}return r}(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let n=this.readPackedEnd();for(;this.pos<n;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(e){let t=7&e;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else{if(t!==1)throw Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){let e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*zd),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*zd),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),4294967295^n?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw Error(`Given varint doesn't fit into 10 bytes`);t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){let n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;let t=this.pos;this.pos=function(e,t,n){for(let r,i,a=0;a<t.length;a++){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){r>56319||a+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&=(e[n++]=239,e[n++]=191,e[n++]=189,null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);let n=this.pos-t;n>=128&&Ud(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let t=e.length;this.writeVarint(t),this.realloc(t);for(let n=0;n<t;n++)this.buf[this.pos++]=e[n]}writeRawMessage(e,t){this.pos++;let n=this.pos;e(t,this);let r=this.pos-n;r>=128&&Ud(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,n){this.writeTag(e,2),this.writeRawMessage(t,n)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Wd,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Gd,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Jd,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Kd,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,qd,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Yd,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Xd,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Zd,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Qd,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Hd(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Ud(e,t,n){let r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(let t=n.pos-1;t>=e;t--)n.buf[t+r]=n.buf[t]}function Wd(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function Gd(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function Kd(e,t){for(let n=0;n<e.length;n++)t.writeFloat(e[n])}function qd(e,t){for(let n=0;n<e.length;n++)t.writeDouble(e[n])}function Jd(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function Yd(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function Xd(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function Zd(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function Qd(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function $d(e,t,n){e===1&&n.readMessage(ef,t)}function ef(e,t,n){if(e===3){let{id:e,bitmap:r,width:i,height:a,left:o,top:s,advance:c}=n.readMessage(tf,{});t.push({id:e,bitmap:new Ac({width:i+6,height:a+6},r),metrics:{width:i,height:a,left:o,top:s,advance:c}})}}function tf(e,t,n){e===1?t.id=n.readVarint():e===2?t.bitmap=n.readBytes():e===3?t.width=n.readVarint():e===4?t.height=n.readVarint():e===5?t.left=n.readSVarint():e===6?t.top=n.readSVarint():e===7&&(t.advance=n.readVarint())}function nf(e){let t=0,n=0;for(let r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort(((e,t)=>t.h-e.h));let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}],i=0,a=0;for(let t of e)for(let e=r.length-1;e>=0;e--){let n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,a=Math.max(a,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){let t=r.pop();t&&e<r.length&&(r[e]=t)}else t.h===n.h?(n.x+=t.w,n.w-=t.w):t.w===n.w?(n.y+=t.h,n.h-=t.h):(r.push({x:n.x+t.w,y:n.y,w:n.w-t.w,h:t.h}),n.y+=t.h,n.h-=t.h);break}}return{w:i,h:a,fill:t/(i*a)||0}}class rf{constructor(e,{pixelRatio:t,version:n,stretchX:r,stretchY:i,content:a,textFitWidth:o,textFitHeight:s}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=i,this.content=a,this.version=n,this.textFitWidth=o,this.textFitHeight=s}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 tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class af{constructor(e,t){let n={},r={};this.haveRenderCallbacks=[];let i=[];this.addImages(e,n,i),this.addImages(t,r,i);let{w:a,h:o}=nf(i),s=new jc({width:a||1,height:o||1});for(let t in e){let r=e[t],i=n[t].paddedRect;jc.copy(r.data,s,{x:0,y:0},{x:i.x+1,y:i.y+1},r.data)}for(let e in t){let n=t[e],i=r[e].paddedRect,a=i.x+1,o=i.y+1,c=n.data.width,l=n.data.height;jc.copy(n.data,s,{x:0,y:0},{x:a,y:o},n.data),jc.copy(n.data,s,{x:0,y:l-1},{x:a,y:o-1},{width:c,height:1}),jc.copy(n.data,s,{x:0,y:0},{x:a,y:o+l},{width:c,height:1}),jc.copy(n.data,s,{x:c-1,y:0},{x:a-1,y:o},{width:1,height:l}),jc.copy(n.data,s,{x:0,y:0},{x:a+c,y:o},{width:1,height:l})}this.image=s,this.iconPositions=n,this.patternPositions=r}addImages(e,t,n){for(let r in e){let i=e[r],a={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(a),t[r]=new rf(a,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t||e.version===t.version)return;e.version=t.version;let[r,i]=e.tl;n.update(t.data,void 0,{x:r,y:i})}}var of;function sf(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=Ld.fromFeature(t,a),_;f===e.ax.vertical&&g.verticalizePunctuation();let v=g.determineLineBreaks(u,o,n,i,m),{processBidirectionalText:y,processStyledBidirectionalText:b}=Ba;if(y&&g.sections.length===1){_=[],v=v.map((e=>g.toCodeUnitIndex(e)));let e=y(g.toString(),v);for(let t of e){let e=[...t].map((()=>0));_.push(new Ld(t,g.sections,e))}}else if(b){_=[],v=v.map((e=>g.toCodeUnitIndex(e)));let e=0,t=[];for(let n of g.text)t.push(...Array(n.length).fill(g.sectionIndex[e])),e++;let n=b(g.text,t,v);for(let e of n){let t=[],n=``;for(let r of e[0])t.push(e[1][n.length]),n+=r;_.push(new Ld(e[0],g.sections,t))}}else _=function(e,t){let n=[],r=0;for(let i of t)n.push(e.substring(r,i)),r=i;return r<e.length()&&n.push(e.substring(r,e.length())),n}(g,v);let x=[],S={positionedLines:x,text:g.toString(),top:d[1],bottom:d[1],left:d[0],right:d[0],writingMode:f,iconsInText:!1,verticalizable:!1};return function(e,t,n,r,i,a,o,s,c,l,u,d){let f=0,p=0,m=0,h=0,g=s===`right`?1:s===`left`?0:.5,_=Od/d,v=0;for(let o of i){o.trim();let i=o.getMaxScale(),s={positionedGlyphs:[],lineOffset:0};e.positionedLines[v]=s;let d=s.positionedGlyphs,y=0;if(!o.length()){p+=a,++v;continue}let b=lf(r,o,_),x=0;for(let a of o.text){let s=o.getSection(x),m=a.codePointAt(0),h=df(c,u,m),g={glyph:m,imageName:null,x:f,y:p+-17,vertical:h,scale:1,fontStack:``,sectionIndex:o.getSectionIndex(x),metrics:null,rect:null},v;if(`fontStack`in s){if(v=ff(s,m,h,b,t,n),!v)continue;g.fontStack=s.fontStack}else{if(e.iconsInText=!0,s.scale*=_,v=pf(s,h,i,b,r),!v)continue;y=Math.max(y,v.imageOffset),g.imageName=s.imageName}let{rect:S,metrics:C,baselineOffset:w}=v;g.y+=w,g.scale=s.scale,g.metrics=C,g.rect=S,d.push(g),h?(e.verticalizable=!0,f+=(`imageName`in s?C.advance:Od)*s.scale+l):f+=C.advance*s.scale+l,x++}d.length!==0&&(m=Math.max(f-l,m),mf(d,0,d.length-1,g)),f=0,s.lineOffset=Math.max(y,(i-1)*Od);let S=a*i+y;p+=S,h=Math.max(S,h),++v}let{horizontalAlign:y,verticalAlign:b}=cf(o);(function(e,t,n,r,i,a,o,s,c){let l=(t-n)*i,u=0;u=a===o?-r*c*o+.5*o:-s*r- -17;for(let t of e)for(let e of t.positionedGlyphs)e.x+=l,e.y+=u})(e.positionedLines,g,y,b,m,h,a,p,i.length),e.top+=-b*p,e.bottom=e.top+p,e.left+=-y*m,e.right=e.left+m}(S,n,r,i,_,s,c,l,f,u,p,h),!function(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}(x)&&S}function cf(e){let t=.5,n=.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`:n=1;break;case`top`:case`top-right`:case`top-left`:n=0}return{horizontalAlign:t,verticalAlign:n}}function lf(e,t,n){let r=t.getMaxScale()*Od,{maxImageWidth:i,maxImageHeight:a}=t.getMaxImageSize(e),o=Math.max(r,a*n);return{verticalLineContentWidth:Math.max(r,i*n),horizontalLineContentHeight:o}}function uf(e){switch(e){case`top`:return 0;case`center`:return .5;default:return 1}}function df(t,n,r){return!(t===e.ax.horizontal||!n&&!Oa(r)||n&&(ka(r)||(i=r,/\p{sc=Arab}/u.test(String.fromCodePoint(i)))));var i}function ff(e,t,n,r,i,a){let o=function(e,t,n,r){if(e?.rect)return e;let i=t[n.fontStack]?.[r];return i?{rect:null,metrics:i.metrics}:null}(a[e.fontStack]?.[t],i,e,t);if(o===null)return null;let s;if(n)s=r.verticalLineContentWidth-e.scale*Od;else{let t=uf(e.verticalAlign);s=(r.horizontalLineContentHeight-e.scale*Od)*t}return{rect:o.rect,metrics:o.metrics,baselineOffset:s}}function pf(e,t,n,r,i){let a=i[e.imageName];if(!a)return null;let o=a.paddedRect,s=a.displaySize,c={width:s[0],height:s[1],left:1,top:-3,advance:t?s[1]:s[0]},l;if(t)l=r.verticalLineContentWidth-s[1]*e.scale;else{let t=uf(e.verticalAlign);l=(r.horizontalLineContentHeight-s[1]*e.scale)*t}return{rect:o,metrics:c,baselineOffset:l,imageOffset:(t?s[0]:s[1])*e.scale-Od*n}}function mf(e,t,n,r){if(r===0)return;let i=e[n],a=(e[n].x+i.metrics.advance*i.scale)*r;for(let r=t;r<=n;r++)e[r].x-=a}function hf(e,t,n){let{horizontalAlign:r,verticalAlign:i}=cf(n),a=t[0]-e.displaySize[0]*r,o=t[1]-e.displaySize[1]*i;return{image:e,top:o,bottom:o+e.displaySize[1],left:a,right:a+e.displaySize[0]}}function gf(e){let t=e.left,n=e.top,r=e.right-t,i=e.bottom-n,a=e.image.textFitWidth??`stretchOrShrink`,o=e.image.textFitHeight??`stretchOrShrink`,s=(e.image.content[2]-e.image.content[0])/(e.image.content[3]-e.image.content[1]);if(o===`proportional`){if(a===`stretchOnly`&&r/i<s||a===`proportional`){let e=Math.ceil(i*s);t*=e/r,r=e}}else if(a===`proportional`&&o===`stretchOnly`&&s!==0&&r/i>s){let e=Math.ceil(r/s);n*=e/i,i=e}return{x1:t,y1:n,x2:t+r,y2:n+i}}function _f(e,t,n,r,i,a){let o=e.image,s;if(o.content){let e=o.content,t=o.pixelRatio||1;s=[e[0]/t,e[1]/t,o.displaySize[0]-e[2]/t,o.displaySize[1]-e[3]/t]}let c=t.left*a,l=t.right*a,u,d,f,p;n===`width`||n===`both`?(p=i[0]+c-r[3],d=i[0]+l+r[1]):(p=i[0]+(c+l-o.displaySize[0])/2,d=p+o.displaySize[0]);let m=t.top*a,h=t.bottom*a;return n===`height`||n===`both`?(u=i[1]+m-r[0],f=i[1]+h+r[2]):(u=i[1]+(m+h-o.displaySize[1])/2,f=u+o.displaySize[1]),{image:o,top:u,right:d,bottom:f,left:p,collisionPadding:s}}W(`ImagePosition`,rf),W(`ImageAtlas`,af),e.ax=void 0,(of=e.ax||={})[of.none=0]=`none`,of[of.horizontal=1]=`horizontal`,of[of.vertical=2]=`vertical`,of[of.horizontalOnly=3]=`horizontalOnly`;let vf=32640;function yf(e,t){let{expression:n}=t;if(n.kind===`constant`)return{kind:`constant`,layoutSize:n.evaluate(new Va(e+1))};if(n.kind===`source`)return{kind:`source`};{let{zoomStops:t,interpolationType:r}=n,i=0;for(;i<t.length&&t[i]<=e;)i++;i=Math.max(0,i-1);let a=i;for(;a<t.length&&t[a]<e+1;)a++;a=Math.min(t.length-1,a);let o=t[i],s=t[a];return n.kind===`composite`?{kind:`composite`,minZoom:o,maxZoom:s,interpolationType:r}:{kind:`camera`,minZoom:o,maxZoom:s,minSize:n.evaluate(new Va(o)),maxSize:n.evaluate(new Va(s)),interpolationType:r}}}function bf(e,t,n){let r=`never`,i=e.get(t);return i?r=i:e.get(n)&&(r=`always`),r}let xf=[{name:`a_fade_opacity`,components:1,type:`Uint8`,offset:0}];function Sf(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=s?Math.min(vf,Math.round(s[0])):0,m=s?Math.min(vf,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),a,o,(p<<1)+ +!!c,m,16*l,16*u,256*d,256*f)}function Cf(e,t,n){e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n)}function wf(e){for(let t of e.sections)if(za(t.text))return!0;return!1}class Tf{constructor(e){this.layoutVertexArray=new os,this.indexArray=new ds,this.programConfigurations=e,this.segments=new ms,this.dynamicLayoutVertexArray=new ss,this.opacityVertexArray=new cs,this.hasVisibleVertices=!1,this.placedSymbolArray=new Uo}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Sd.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,xf,!0),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}W(`SymbolBuffers`,Tf);class Ef{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new ms,this.collisionVertexArray=new us}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Cd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}W(`CollisionBuffers`,Ef);class Df{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let n=this.layers[0]._unevaluatedLayout._values;this.textSizeData=yf(this.zoom,n[`text-size`]),this.iconSizeData=yf(this.zoom,n[`icon-size`]);let r=this.layers[0].layout,i=r.get(`symbol-sort-key`),a=r.get(`symbol-z-order`);this.canOverlap=bf(r,`text-overlap`,`text-allow-overlap`)!==`never`||bf(r,`icon-overlap`,`icon-allow-overlap`)!==`never`||r.get(`text-ignore-placement`)||r.get(`icon-ignore-placement`),this.sortFeaturesByKey=a!==`viewport-y`&&!i.isConstant(),this.sortFeaturesByY=(a===`viewport-y`||a===`auto`&&!this.sortFeaturesByKey)&&this.canOverlap,r.get(`symbol-placement`)===`point`&&(this.writingModes=r.get(`text-writing-mode`).map((t=>e.ax[t]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Tf(new Us(this.layers,this.zoom,(e=>e.startsWith(`text`)))),this.icon=new Tf(new Us(this.layers,this.zoom,(e=>e.startsWith(`icon`)))),this.glyphOffsetArray=new Ko,this.lineVertexArray=new qo,this.symbolInstances=new Go,this.textAnchorOffsets=new Yo}calculateGlyphDependencies(e,t,n,r,i){for(let a of e)if(t[a.codePointAt(0)]=!0,(n||r)&&i){let e=kd[a];e&&(t[e.codePointAt(0)]=!0)}}populate(t,n,r){let i=this.layers[0],a=i.layout,o=a.get(`text-font`),s=a.get(`text-field`),c=a.get(`icon-image`),l=(s.value.kind!==`constant`||s.value.value instanceof Vt&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&(o.value.kind!==`constant`||o.value.value.length>0),u=c.value.kind!==`constant`||!!c.value.value||Object.keys(c.parameters).length>0,d=a.get(`symbol-sort-key`);if(this.features=[],!l&&!u)return;let f=n.iconDependencies,p=n.glyphDependencies,m=n.availableImages,h=new Va(this.zoom);for(let{feature:n,id:s,index:c,sourceLayerIndex:g}of t){let t=i._featureFilter.needGeometry,_=Ys(n,t);if(!i._featureFilter.filter(h,_,r))continue;let v,y;if(t||(_.geometry=Js(n)),l){let e=i.getValueAndResolveTokens(`text-field`,_,r,m),t=Vt.factory(e);this.hasRTLText||=wf(t),(!this.hasRTLText||Ba.getRTLTextPluginStatus()===`unavailable`||this.hasRTLText&&Ba.isParsed())&&(v=Dd(t,i,_))}if(u){let e=i.getValueAndResolveTokens(`icon-image`,_,r,m);y=e instanceof Jt?e:Jt.fromString(e)}if(!v&&!y)continue;let b=this.sortFeaturesByKey?d.evaluate(_,{},r):void 0;if(this.features.push({id:s,text:v,icon:y,index:c,sourceLayerIndex:g,geometry:_.geometry,properties:n.properties,type:Rl.types[n.type],sortKey:b}),y&&(f[y.name]=!0),v){let t=o.evaluate(_,{},r).join(`,`),n=a.get(`text-rotation-alignment`)!==`viewport`&&a.get(`symbol-placement`)!==`point`;this.allowVerticalPlacement=this.writingModes?.includes(e.ax.vertical);for(let e of v.sections)if(e.image)f[e.image.name]=!0;else{let r=Aa(v.toString()),i=e.fontStack||t;p[i]||(p[i]={}),this.calculateGlyphDependencies(e.text,p[i],n,this.allowVerticalPlacement,r)}}}a.get(`symbol-placement`)===`line`&&(this.features=function(e){let t={},n={},r=[],i=0;function a(t){r.push(e[t]),i++}function o(e,t,i){let a=n[e];return delete n[e],n[t]=a,r[a].geometry[0].pop(),r[a].geometry[0]=r[a].geometry[0].concat(i[0]),a}function s(e,n,i){let a=t[n];return delete t[n],t[e]=a,r[a].geometry[0].shift(),r[a].geometry[0]=i[0].concat(r[a].geometry[0]),a}function c(e,t,n){let r=n?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let l=0;l<e.length;l++){let u=e[l],d=u.geometry,f=u.text?u.text.toString():null;if(!f){a(l);continue}let p=c(f,d),m=c(f,d,!0);if(p in n&&m in t&&n[p]!==t[m]){let e=s(p,m,d),i=o(p,m,r[e].geometry);delete t[p],delete n[m],n[c(f,r[i].geometry,!0)]=i,r[e].geometry=null}else p in n?o(p,m,d):m in t?s(p,m,d):(a(l),t[p]=i-1,n[m]=i-1)}return r.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}))}isEmpty(){return this.symbolInstances.length===0&&!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()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let n=this.lineVertexArray.length;if(e.segment!==void 0){let n=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]),i={};for(let r=e.segment+1;r<t.length;r++)i[r]={x:t[r].x,y:t[r].y,tileUnitDistanceFromAnchor:n},r<t.length-1&&(n+=t[r+1].dist(t[r]));for(let n=e.segment||0;n>=0;n--)i[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:r},n>0&&(r+=t[n-1].dist(t[n]));for(let e=0;e<t.length;e++){let t=i[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(t,n,r,i,a,o,s,c,l,u,d,f){let p=t.indexArray,m=t.layoutVertexArray,h=t.segments.prepareSegment(4*n.length,m,p,this.canOverlap?o.sortKey:void 0),g=this.glyphOffsetArray.length,_=h.vertexLength,v=this.allowVerticalPlacement&&s===e.ax.vertical?Math.PI/2:0,y=o.text&&o.text.sections;for(let e=0;e<n.length;e++){let{tl:i,tr:a,bl:s,br:l,tex:u,pixelOffsetTL:d,pixelOffsetBR:g,minFontScaleX:_,minFontScaleY:b,glyphOffset:x,isSDF:S,sectionIndex:C}=n[e],w=h.vertexLength,T=x[1];Sf(m,c.x,c.y,i.x,T+i.y,u.x,u.y,r,S,d.x,d.y,_,b),Sf(m,c.x,c.y,a.x,T+a.y,u.x+u.w,u.y,r,S,g.x,d.y,_,b),Sf(m,c.x,c.y,s.x,T+s.y,u.x,u.y+u.h,r,S,d.x,g.y,_,b),Sf(m,c.x,c.y,l.x,T+l.y,u.x+u.w,u.y+u.h,r,S,g.x,g.y,_,b),Cf(t.dynamicLayoutVertexArray,c,v),p.emplaceBack(w,w+2,w+1),p.emplaceBack(w+1,w+2,w+3),h.vertexLength+=4,h.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(x[0]),e!==n.length-1&&C===n[e+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,o,o.index,{imagePositions:{},canonical:f,formattedSection:y?.[C]})}t.placedSymbolArray.emplaceBack(c.x,c.y,g,this.glyphOffsetArray.length-g,_,l,u,c.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],s,0,!1,0,d)}_addCollisionDebugVertex(e,t,n,r,i,a){return t.emplaceBack(0,0),e.emplaceBack(n.x,n.y,r,i,Math.round(a.x),Math.round(a.y))}addCollisionDebugVertices(e,t,r,i,a,o,s){let c=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=c.vertexLength,u=a.layoutVertexArray,d=a.collisionVertexArray,f=s.anchorX,p=s.anchorY;this._addCollisionDebugVertex(u,d,o,f,p,new n(e,t)),this._addCollisionDebugVertex(u,d,o,f,p,new n(r,t)),this._addCollisionDebugVertex(u,d,o,f,p,new n(r,i)),this._addCollisionDebugVertex(u,d,o,f,p,new n(e,i)),c.vertexLength+=4;let m=a.indexArray;m.emplaceBack(l,l+1),m.emplaceBack(l+1,l+2),m.emplaceBack(l+2,l+3),m.emplaceBack(l+3,l),c.primitiveLength+=4}addDebugCollisionBoxes(e,t,n,r){for(let i=e;i<t;i++){let e=this.collisionBoxArray.get(i);this.addCollisionDebugVertices(e.x1,e.y1,e.x2,e.y2,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,n)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Ef(ls,wd.members,fs),this.iconCollisionBox=new Ef(ls,wd.members,fs);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,n,r,i,a,o,s,c){let l={};for(let r=t;r<n;r++){let t=e.get(r);l.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},l.textFeatureIndex=t.featureIndex;break}for(let t=r;t<i;t++){let n=e.get(t);l.verticalTextBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.verticalTextFeatureIndex=n.featureIndex;break}for(let t=a;t<o;t++){let n=e.get(t);l.iconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.iconFeatureIndex=n.featureIndex;break}for(let t=s;t<c;t++){let n=e.get(t);l.verticalIconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.verticalIconFeatureIndex=n.featureIndex;break}return l}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let n=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.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){let n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let t=n.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+2,t+1),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let t=Math.sin(e),n=Math.cos(e),r=[],i=[],a=[];for(let e=0;e<this.symbolInstances.length;++e){a.push(e);let o=this.symbolInstances.get(e);r.push(0|Math.round(t*o.anchorX+n*o.anchorY)),i.push(o.featureIndex)}return a.sort(((e,t)=>r[e]-r[t]||i[t]-i[e])),a}addToSortKeyRanges(e,t){let n=this.sortKeyRanges[this.sortKeyRanges.length-1];n?.sortKey===t?n.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(let e of this.symbolInstanceIndexes){let t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);let n=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e<n.length;e++){let t=n[e];t>=0&&n.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)}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)}}}let Of,kf;W(`SymbolBucket`,Df,{omit:[`layers`,`collisionBoxArray`,`features`,`compareText`]}),Df.MAX_GLYPHS=65535,Df.addDynamicAttributes=Cf;var Af={get paint(){return kf||=new ro({"icon-opacity":new $a(z.paint_symbol[`icon-opacity`]),"icon-color":new $a(z.paint_symbol[`icon-color`]),"icon-halo-color":new $a(z.paint_symbol[`icon-halo-color`]),"icon-halo-width":new $a(z.paint_symbol[`icon-halo-width`]),"icon-halo-blur":new $a(z.paint_symbol[`icon-halo-blur`]),"icon-translate":new Qa(z.paint_symbol[`icon-translate`]),"icon-translate-anchor":new Qa(z.paint_symbol[`icon-translate-anchor`]),"text-opacity":new $a(z.paint_symbol[`text-opacity`]),"text-color":new $a(z.paint_symbol[`text-color`],{runtimeType:H,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new $a(z.paint_symbol[`text-halo-color`]),"text-halo-width":new $a(z.paint_symbol[`text-halo-width`]),"text-halo-blur":new $a(z.paint_symbol[`text-halo-blur`]),"text-translate":new Qa(z.paint_symbol[`text-translate`]),"text-translate-anchor":new Qa(z.paint_symbol[`text-translate-anchor`])})},get layout(){return Of||=new ro({"symbol-placement":new Qa(z.layout_symbol[`symbol-placement`]),"symbol-spacing":new Qa(z.layout_symbol[`symbol-spacing`]),"symbol-avoid-edges":new Qa(z.layout_symbol[`symbol-avoid-edges`]),"symbol-sort-key":new $a(z.layout_symbol[`symbol-sort-key`]),"symbol-z-order":new Qa(z.layout_symbol[`symbol-z-order`]),"icon-allow-overlap":new Qa(z.layout_symbol[`icon-allow-overlap`]),"icon-overlap":new Qa(z.layout_symbol[`icon-overlap`]),"icon-ignore-placement":new Qa(z.layout_symbol[`icon-ignore-placement`]),"icon-optional":new Qa(z.layout_symbol[`icon-optional`]),"icon-rotation-alignment":new Qa(z.layout_symbol[`icon-rotation-alignment`]),"icon-size":new $a(z.layout_symbol[`icon-size`]),"icon-text-fit":new Qa(z.layout_symbol[`icon-text-fit`]),"icon-text-fit-padding":new Qa(z.layout_symbol[`icon-text-fit-padding`]),"icon-image":new $a(z.layout_symbol[`icon-image`]),"icon-rotate":new $a(z.layout_symbol[`icon-rotate`]),"icon-padding":new $a(z.layout_symbol[`icon-padding`]),"icon-keep-upright":new Qa(z.layout_symbol[`icon-keep-upright`]),"icon-offset":new $a(z.layout_symbol[`icon-offset`]),"icon-anchor":new $a(z.layout_symbol[`icon-anchor`]),"icon-pitch-alignment":new Qa(z.layout_symbol[`icon-pitch-alignment`]),"text-pitch-alignment":new Qa(z.layout_symbol[`text-pitch-alignment`]),"text-rotation-alignment":new Qa(z.layout_symbol[`text-rotation-alignment`]),"text-field":new $a(z.layout_symbol[`text-field`]),"text-font":new $a(z.layout_symbol[`text-font`]),"text-size":new $a(z.layout_symbol[`text-size`]),"text-max-width":new $a(z.layout_symbol[`text-max-width`]),"text-line-height":new Qa(z.layout_symbol[`text-line-height`]),"text-letter-spacing":new $a(z.layout_symbol[`text-letter-spacing`]),"text-justify":new $a(z.layout_symbol[`text-justify`]),"text-radial-offset":new $a(z.layout_symbol[`text-radial-offset`]),"text-variable-anchor":new Qa(z.layout_symbol[`text-variable-anchor`]),"text-variable-anchor-offset":new $a(z.layout_symbol[`text-variable-anchor-offset`]),"text-anchor":new $a(z.layout_symbol[`text-anchor`]),"text-max-angle":new Qa(z.layout_symbol[`text-max-angle`]),"text-writing-mode":new Qa(z.layout_symbol[`text-writing-mode`]),"text-rotate":new $a(z.layout_symbol[`text-rotate`]),"text-padding":new Qa(z.layout_symbol[`text-padding`]),"text-keep-upright":new Qa(z.layout_symbol[`text-keep-upright`]),"text-transform":new $a(z.layout_symbol[`text-transform`]),"text-offset":new $a(z.layout_symbol[`text-offset`]),"text-allow-overlap":new Qa(z.layout_symbol[`text-allow-overlap`]),"text-overlap":new Qa(z.layout_symbol[`text-overlap`]),"text-ignore-placement":new Qa(z.layout_symbol[`text-ignore-placement`]),"text-optional":new Qa(z.layout_symbol[`text-optional`])})}};class jf{constructor(e){if(e.property.overrides===void 0)throw Error(`overrides must be provided to instantiate FormatSectionOverride class`);this.type=e.property.overrides?e.property.overrides.runtimeType:Ye,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(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}}W(`FormatSectionOverride`,jf,{omit:[`defaultValue`]});class Mf extends oo{constructor(e,t){super(e,Af,t)}recalculate(e,t){if(super.recalculate(e,t),this.layout.get(`icon-rotation-alignment`)===`auto`&&(this.layout._values[`icon-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),this.layout.get(`text-rotation-alignment`)===`auto`&&(this.layout._values[`text-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),this.layout.get(`text-pitch-alignment`)===`auto`&&(this.layout._values[`text-pitch-alignment`]=this.layout.get(`text-rotation-alignment`)===`map`?`map`:`viewport`),this.layout.get(`icon-pitch-alignment`)===`auto`&&(this.layout._values[`icon-pitch-alignment`]=this.layout.get(`icon-rotation-alignment`)),this.layout.get(`symbol-placement`)===`point`){let e=this.layout.get(`text-writing-mode`);if(e){let t=[];for(let n of e)t.includes(n)||t.push(n);this.layout._values[`text-writing-mode`]=t}else this.layout._values[`text-writing-mode`]=[`horizontal`]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){let i=this.layout.get(e).evaluate(t,{},n,r),a=this._unevaluatedLayout._values[e];return a.isDataDriven()||di(a.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,((t,n)=>e&&n in e?String(e[n]):``))}(t.properties,i)}createBucket(e){return new Df(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error(`Should take a different path in FeatureIndex`)}_setPaintOverrides(){for(let e of Af.paint.overridableProperties){if(!Mf.hasPaintOverride(this.layout,e))continue;let t=this.paint.get(e),n=new ui(new jf(t),t.property.specification),r=null;r=t.value.kind===`constant`||t.value.kind===`source`?new pi(`source`,n):new mi(`composite`,n,t.value.zoomStops),this.paint._values[e]=new Xa(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&Mf.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){let n=e.get(`text-field`),r=Af.paint.properties[t],i=!1,a=e=>{for(let t of e)if(r.overrides?.hasOverride(t))return void(i=!0)};if(n.value.kind===`constant`&&n.value.value instanceof Vt)a(n.value.value.sections);else if(n.value.kind===`source`||n.value.kind===`composite`){let e=t=>{i||(t instanceof en&&Qt(t.value)===nt?a(t.value.sections):t instanceof Rn?a(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}}let Nf;var Pf={get paint(){return Nf||=new ro({"background-color":new Qa(z.paint_background[`background-color`]),"background-pattern":new to(z.paint_background[`background-pattern`]),"background-opacity":new Qa(z.paint_background[`background-opacity`])})}};class Ff extends oo{constructor(e,t){super(e,Pf,t)}}class If extends oo{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode===`3d`}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error(`Custom layers cannot be serialized`)}}class Lf{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,(e=this._channel)==null||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let Rf={once:!0},zf=6371008.8;class Bf{constructor(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw Error(`Invalid LngLat latitude value: must be between -90 and 90`)}wrap(){return new Bf(I(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return zf*Math.acos(Math.min(i,1))}static convert(e){if(e instanceof Bf)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Bf(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e==`object`&&e)return new Bf(Number(`lng`in e?e.lng:e.lon),Number(e.lat));throw 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>]")}}let Vf=2*Math.PI*zf;function Hf(e){return Vf*Math.cos(e*Math.PI/180)}function Uf(e){return(180+e)/360}function Wf(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Gf(e,t){return e/Hf(t)}function Kf(e){return 360*e-180}function qf(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Jf(e,t){return e*Hf(qf(t))}class Yf{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){let n=Bf.convert(e);return new Yf(Uf(n.lng),Wf(n.lat),Gf(t,n.lat))}toLngLat(){return new Bf(Kf(this.x),qf(this.y))}toAltitude(){return Jf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Vf*(e=qf(this.y),1/Math.cos(e*Math.PI/180));var e}}function Xf(e,t,n){var r=2*Math.PI*6378137/256/2**n;return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Zf{constructor(e,t,n){if(!function(e,t,n){return!(e<0||e>25||n<0||n>=2**e||t<0||t>=2**e)}(e,t,n))throw Error(`x=${t}, y=${n}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=n,this.key=ep(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,n){let r=(a=this.y,o=this.z,s=Xf(256*(i=this.x),256*(a=2**o-a-1),o),c=Xf(256*(i+1),256*(a+1),o),s[0]+`,`+s[1]+`,`+c[0]+`,`+c[1]);var i,a,o,s,c;let l=function(e,t,n){let r=``;for(let i=e;i>0;i--){let e=1<<i-1;r+=(t&e?1:0)+(n&e?2:0)}return r}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(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(n===`tms`?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?`@2x`:``).replace(/{quadkey}/g,l).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new n((e.x*t-this.x)*O,(e.y*t-this.y)*O)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Qf{constructor(e,t){this.wrap=e,this.canonical=t,this.key=ep(e,t.z,t.z,t.x,t.y)}}class $f{constructor(e,t,n,r,i){if(this.terrainRttPosMatrix32f=null,e<n)throw Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${n}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Zf(n,+r,+i),this.key=ep(t,e,n,r,i)}clone(){return new $f(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let t=this.canonical.z-e;return e>this.canonical.z?new $f(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new $f(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let n=this.canonical.z-e;return e>this.canonical.z?ep(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):ep(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;let t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new $f(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new $f(t,this.wrap,t,n,r),new $f(t,this.wrap,t,n+1,r),new $f(t,this.wrap,t,n,r+1),new $f(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new $f(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new $f(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Qf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Yf(e.x-this.wrap,e.y))}normalizeCoordinates(e,t,n=8192){if(e>=0&&e<n&&t>=0&&t<n)return{tileID:this,x:e,y:t};let r=Math.floor(e/n),i=Math.floor(t/n),a=e-r*n,o=t-i*n,s=this.canonical.z,c=1<<s,l=this.canonical.y+i;if(l<0||l>=c)return null;let u=this.canonical.x+r,d=this.wrap;return u<0?(d-=Math.ceil(-u/c),u=(u%c+c)%c):u>=c&&(d+=Math.floor(u/c),u%=c),{tileID:new $f(this.overscaledZ,d,s,u,l),x:a,y:o}}}function ep(e,t,n,r,i){(e*=2)<0&&(e=-1*e-1);let a=1<<n;return(a*a*e+a*i+r).toString(36)+n.toString(36)+t.toString(36)}W(`CanonicalTileID`,Zf),W(`OverscaledTileID`,$f,{omit:[`terrainRttPosMatrix32f`]});class tp{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){let t=new tp;return t.extend(e(new n(this.minX,this.minY))),t.extend(e(new n(this.maxX,this.minY))),t.extend(e(new n(this.minX,this.maxY))),t.extend(e(new n(this.maxX,this.maxY))),t}static fromPoints(e){let t=new tp;for(let n of e)t.extend(n);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class np{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let n=e[t];this._stringToNumber[n]=t,this._numberToString[t]=n}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class rp{constructor(e,t,n,r,i){this.type=`Feature`,this._vectorTileFeature=e,this._x=n,this._y=r,this._z=t,this.properties=e.properties,this.id=i}projectPoint(e,t,n,r){return[360*(e.x+t)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+n)/r)*Math.PI))-90]}projectLine(e,t,n,r){return e.map((e=>this.projectPoint(e,t,n,r)))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,n=e.extent*this._x,r=e.extent*this._y,i=e.loadGeometry();switch(e.type){case 1:{let e=[];for(let t of i)e.push(t[0]);let a=this.projectLine(e,n,r,t);this._geometry=e.length===1?{type:`Point`,coordinates:a[0]}:{type:`MultiPoint`,coordinates:a};break}case 2:{let e=i.map((e=>this.projectLine(e,n,r,t)));this._geometry=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e};break}case 3:{let e=Bl(i),a=[];for(let i of e)a.push(i.map((e=>this.projectLine(e,n,r,t))));this._geometry=a.length===1?{type:`Polygon`,coordinates:a[0]}:{type:`MultiPolygon`,coordinates:a};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)t!==`_geometry`&&t!==`_vectorTileFeature`&&t!==`_x`&&t!==`_y`&&t!==`_z`&&(e[t]=this[t]);return e}}class ip{constructor(e,t,n){this._name=e,this.dataBuffer=t,typeof n==`number`?this._size=n:(this.nullabilityBuffer=n,this._size=n.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class ap extends ip{}class op extends ap{getValueFromBuffer(e){return this.dataBuffer[e]}}class sp extends ap{getValueFromBuffer(e){return this.dataBuffer[e]}}class cp extends ip{constructor(e,t,n,r){super(e,t,r),this.delta=n}}class lp extends cp{constructor(e,t,n,r){super(e,Int32Array.of(t),n,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class up extends ip{constructor(e,t,n,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),n)}getValueFromBuffer(e){return this.dataBuffer[0]}}class dp{constructor(e,t,n,r,i=4096){this._name=e,this._geometryVector=t,this._idVector=n,this._propertyVectors=r,this._extent=i}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||=new Map(this._propertyVectors.map((e=>[e.name,e]))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let n=0;n<this.numFeatures;n++){let r;if(this.idVector){let e=this.idVector.getValue(n);r=this.containsMaxSafeIntegerValues(this.idVector)&&e!==null?Number(e):e}let i={coordinates:t[n],type:this.geometryVector.geometryType(n)},a={};for(let e of this.propertyVectors){if(!e)continue;let t=e.name,r=e.getValue(n);r!==null&&(a[t]=r)}e.push({id:r,geometry:i,properties:a})}return e}containsMaxSafeIntegerValues(e){return e instanceof op||e instanceof up||e instanceof lp||e instanceof sp}}class fp{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var pp,mp;(function(e){e.NONE=`NONE`,e.DELTA=`DELTA`,e.COMPONENTWISE_DELTA=`COMPONENTWISE_DELTA`,e.RLE=`RLE`,e.MORTON=`MORTON`,e.PDE=`PDE`})(pp||={}),function(e){e.NONE=`NONE`,e.FAST_PFOR=`FAST_PFOR`,e.VARINT=`VARINT`,e.ALP=`ALP`}(mp||={});let hp=new Uint32Array(33);hp[0]=0;for(let e=1;e<=32;e++)hp[e]=e===32?4294967295:4294967295>>>32-e;let gp=hp;function _p(e,t){return e-e%t}function vp(e){let t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}let yp=function(){let e=_p(65536,256);return e===0?256:e}(),bp=3*yp/256+yp|0;function xp(){let e=new Uint8Array(bp);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function Sp(e,t,n,r,i){switch(i){case 1:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0;n[i++]=t>>>0&1,n[i++]=t>>>1&1,n[i++]=t>>>2&1,n[i++]=t>>>3&1,n[i++]=t>>>4&1,n[i++]=t>>>5&1,n[i++]=t>>>6&1,n[i++]=t>>>7&1,n[i++]=t>>>8&1,n[i++]=t>>>9&1,n[i++]=t>>>10&1,n[i++]=t>>>11&1,n[i++]=t>>>12&1,n[i++]=t>>>13&1,n[i++]=t>>>14&1,n[i++]=t>>>15&1,n[i++]=t>>>16&1,n[i++]=t>>>17&1,n[i++]=t>>>18&1,n[i++]=t>>>19&1,n[i++]=t>>>20&1,n[i++]=t>>>21&1,n[i++]=t>>>22&1,n[i++]=t>>>23&1,n[i++]=t>>>24&1,n[i++]=t>>>25&1,n[i++]=t>>>26&1,n[i++]=t>>>27&1,n[i++]=t>>>28&1,n[i++]=t>>>29&1,n[i++]=t>>>30&1,n[i++]=t>>>31&1}})(e,t,n,r);break;case 2:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0;n[i++]=t>>>0&3,n[i++]=t>>>2&3,n[i++]=t>>>4&3,n[i++]=t>>>6&3,n[i++]=t>>>8&3,n[i++]=t>>>10&3,n[i++]=t>>>12&3,n[i++]=t>>>14&3,n[i++]=t>>>16&3,n[i++]=t>>>18&3,n[i++]=t>>>20&3,n[i++]=t>>>22&3,n[i++]=t>>>24&3,n[i++]=t>>>26&3,n[i++]=t>>>28&3,n[i++]=t>>>30&3,n[i++]=r>>>0&3,n[i++]=r>>>2&3,n[i++]=r>>>4&3,n[i++]=r>>>6&3,n[i++]=r>>>8&3,n[i++]=r>>>10&3,n[i++]=r>>>12&3,n[i++]=r>>>14&3,n[i++]=r>>>16&3,n[i++]=r>>>18&3,n[i++]=r>>>20&3,n[i++]=r>>>22&3,n[i++]=r>>>24&3,n[i++]=r>>>26&3,n[i++]=r>>>28&3,n[i++]=r>>>30&3}})(e,t,n,r);break;case 3:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0;n[i++]=t>>>0&7,n[i++]=t>>>3&7,n[i++]=t>>>6&7,n[i++]=t>>>9&7,n[i++]=t>>>12&7,n[i++]=t>>>15&7,n[i++]=t>>>18&7,n[i++]=t>>>21&7,n[i++]=t>>>24&7,n[i++]=t>>>27&7,n[i++]=7&(t>>>30|(1&r)<<2),n[i++]=r>>>1&7,n[i++]=r>>>4&7,n[i++]=r>>>7&7,n[i++]=r>>>10&7,n[i++]=r>>>13&7,n[i++]=r>>>16&7,n[i++]=r>>>19&7,n[i++]=r>>>22&7,n[i++]=r>>>25&7,n[i++]=r>>>28&7,n[i++]=7&(r>>>31|(3&o)<<1),n[i++]=o>>>2&7,n[i++]=o>>>5&7,n[i++]=o>>>8&7,n[i++]=o>>>11&7,n[i++]=o>>>14&7,n[i++]=o>>>17&7,n[i++]=o>>>20&7,n[i++]=o>>>23&7,n[i++]=o>>>26&7,n[i++]=o>>>29&7}})(e,t,n,r);break;case 4:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0;n[i++]=t>>>0&15,n[i++]=t>>>4&15,n[i++]=t>>>8&15,n[i++]=t>>>12&15,n[i++]=t>>>16&15,n[i++]=t>>>20&15,n[i++]=t>>>24&15,n[i++]=t>>>28&15,n[i++]=r>>>0&15,n[i++]=r>>>4&15,n[i++]=r>>>8&15,n[i++]=r>>>12&15,n[i++]=r>>>16&15,n[i++]=r>>>20&15,n[i++]=r>>>24&15,n[i++]=r>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15}})(e,t,n,r);break;case 5:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0;n[i++]=t>>>0&31,n[i++]=t>>>5&31,n[i++]=t>>>10&31,n[i++]=t>>>15&31,n[i++]=t>>>20&31,n[i++]=t>>>25&31,n[i++]=31&(t>>>30|(7&r)<<2),n[i++]=r>>>3&31,n[i++]=r>>>8&31,n[i++]=r>>>13&31,n[i++]=r>>>18&31,n[i++]=r>>>23&31,n[i++]=31&(r>>>28|(1&o)<<4),n[i++]=o>>>1&31,n[i++]=o>>>6&31,n[i++]=o>>>11&31,n[i++]=o>>>16&31,n[i++]=o>>>21&31,n[i++]=o>>>26&31,n[i++]=31&(o>>>31|(15&s)<<1),n[i++]=s>>>4&31,n[i++]=s>>>9&31,n[i++]=s>>>14&31,n[i++]=s>>>19&31,n[i++]=s>>>24&31,n[i++]=31&(s>>>29|(3&c)<<3),n[i++]=c>>>2&31,n[i++]=c>>>7&31,n[i++]=c>>>12&31,n[i++]=c>>>17&31,n[i++]=c>>>22&31,n[i++]=c>>>27&31}})(e,t,n,r);break;case 6:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0;n[i++]=t>>>0&63,n[i++]=t>>>6&63,n[i++]=t>>>12&63,n[i++]=t>>>18&63,n[i++]=t>>>24&63,n[i++]=63&(t>>>30|(15&r)<<2),n[i++]=r>>>4&63,n[i++]=r>>>10&63,n[i++]=r>>>16&63,n[i++]=r>>>22&63,n[i++]=63&(r>>>28|(3&o)<<4),n[i++]=o>>>2&63,n[i++]=o>>>8&63,n[i++]=o>>>14&63,n[i++]=o>>>20&63,n[i++]=o>>>26&63,n[i++]=s>>>0&63,n[i++]=s>>>6&63,n[i++]=s>>>12&63,n[i++]=s>>>18&63,n[i++]=s>>>24&63,n[i++]=63&(s>>>30|(15&c)<<2),n[i++]=c>>>4&63,n[i++]=c>>>10&63,n[i++]=c>>>16&63,n[i++]=c>>>22&63,n[i++]=63&(c>>>28|(3&l)<<4),n[i++]=l>>>2&63,n[i++]=l>>>8&63,n[i++]=l>>>14&63,n[i++]=l>>>20&63,n[i++]=l>>>26&63}})(e,t,n,r);break;case 7:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0;n[i++]=t>>>0&127,n[i++]=t>>>7&127,n[i++]=t>>>14&127,n[i++]=t>>>21&127,n[i++]=127&(t>>>28|(7&r)<<4),n[i++]=r>>>3&127,n[i++]=r>>>10&127,n[i++]=r>>>17&127,n[i++]=r>>>24&127,n[i++]=127&(r>>>31|(63&o)<<1),n[i++]=o>>>6&127,n[i++]=o>>>13&127,n[i++]=o>>>20&127,n[i++]=127&(o>>>27|(3&s)<<5),n[i++]=s>>>2&127,n[i++]=s>>>9&127,n[i++]=s>>>16&127,n[i++]=s>>>23&127,n[i++]=127&(s>>>30|(31&c)<<2),n[i++]=c>>>5&127,n[i++]=c>>>12&127,n[i++]=c>>>19&127,n[i++]=127&(c>>>26|(1&l)<<6),n[i++]=l>>>1&127,n[i++]=l>>>8&127,n[i++]=l>>>15&127,n[i++]=l>>>22&127,n[i++]=127&(l>>>29|(15&u)<<3),n[i++]=u>>>4&127,n[i++]=u>>>11&127,n[i++]=u>>>18&127,n[i++]=u>>>25&127}})(e,t,n,r);break;case 8:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0,d=e[a++]>>>0;n[i++]=t>>>0&255,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=r>>>0&255,n[i++]=r>>>8&255,n[i++]=r>>>16&255,n[i++]=r>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255}})(e,t,n,r);break;case 16:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<128;t++){let t=e[a++]>>>0;n[i++]=65535&t,n[i++]=t>>>16&65535}})(e,t,n,r);break;default:(function(e,t,n,r,i){let a=gp[i]>>>0,o=t,s=0,c=e[o]>>>0,l=r;for(let t=0;t<8;t++){for(let t=0;t<32;t++)if(s+i<=32)n[l+t]=c>>>s&a,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0));else{let r=32-s,u=c>>>s;o++,c=e[o]>>>0;let d=i-r;n[l+t]=(u|(c&-1>>>32-d>>>0)<<r)&a,s=d}l+=32,s=0,t<7&&(c=e[o]>>>0)}})(e,t,n,r,i)}return t+(i<<3)|0}function Cp(e,t,n,r){if(n+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${n}, byteSize=${t})`);let i=e[n++],a=e[n++];if(i>32)throw Error(`FastPFOR decode: invalid bitWidth=${i} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:i,exceptionCount:a,bytePosIn:n}}function wp(e,t,n,r,i,a,o,s,c){let{maxBits:l,exceptionBitWidth:u,bytePosIn:d}=function(e,t,n,r,i,a){if(n+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${a} (need 1 byte for maxBits, bytePos=${n}, byteSize=${t})`);let o=e[n++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${a} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${a} (bitWidth=${r}, maxBits=${o})`);if(n+i>t)throw Error(`FastPFOR decode: exception positions underflow at block=${a} (need=${i}, have=${t-n})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:n}}(i,a,o,n,r,c);if(o=d,u===1){let a=1<<n;for(let n=0;n<r;n=n+1|0)e[i[o++]+t|0]|=a;return o}let f=s.dataToBePacked[u];if(!f)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${u} (bitWidth=${n}, maxBits=${l}) at block ${c}`);let p=s.dataPointers,m=0|p[u],h=0|s.exceptionSizes[u];if(m+r>h)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${m}, need ${r}, size=${h}) at block ${c}`);for(let a=0;a<r;a=a+1|0){let r=i[o++],a=0|f[m++];e[r+t|0]|=a<<n}return p[u]=m,o}function Tp(e,t,n,r,i,a){let o=0|n,s=0|e[o];if(s<=0||o+s>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${s} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let c=o+1|0,l=o+s|0,u=e[l]>>>0,d=u+3>>>2,f=l+1,p=f+d;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${d}, pageStart=${o}, packedEnd=${l}, byteContainerStart=${f}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let m=function(e,t,n,r){r.byteContainer.length<n&&(r.byteContainer=new Uint8Array(2*n),r.byteContainerI32=void 0);let i=r.byteContainer,a=n>>>2;if(3&i.byteOffset)for(let n=0;n<a;n=n+1|0){let r=0|e[t+n|0],a=n<<2;i[a]=255&r,i[a+1|0]=r>>>8&255,i[a+2|0]=r>>>16&255,i[a+3|0]=r>>>24&255}else{let n=r.byteContainerI32;(!n||n.buffer!==i.buffer||n.byteOffset!==i.byteOffset||n.length<a)&&(n=r.byteContainerI32=new Int32Array(i.buffer,i.byteOffset,i.byteLength>>>2)),n.set(e.subarray(t,t+a))}let o=3&n;if(o>0){let n=0|e[t+a|0],r=a<<2;for(let e=0;e<o;e=e+1|0)i[r+e|0]=n>>>(e<<3)&255}return i}(e,f,u,a),h=u,g=function(e,t,n){let r=0|e[t++],i=n.dataToBePacked;for(let a=2;a<=32;a=a+1|0){if(!(r>>>a-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${a}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let o=e[t++]>>>0,s=_p(o+31,32),c=o*a+31>>>5;if(t+c>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${a}, size=${o}, streamWordIndex=${t}, needWords=${c}, availableWords=${e.length-t}, encodedWords=${e.length})`);let l=i[a];(!l||l.length<s)&&(l=i[a]=new Uint32Array(s));let u=0;for(;u<o;u=u+32|0)Ep(e,t,l,u,a),t=t+a|0;t=t-((u-o|0)*a>>>5)|0,n.exceptionSizes[a]=o}return t}(e,p,a);return a.dataPointers.fill(0),function(e,t,n,r,i,a,o,s,c,l){let u=0|n,d=0;for(let t=0;t<o;t=t+1|0){let n=Cp(s,c,d,t);d=n.bytePosIn;let r=n.bitWidth,o=n.exceptionCount,f=a+t*256|0;switch(r){case 0:i.fill(0,f,f+256);break;case 32:for(let t=0;t<256;t=t+1|0)i[f+t|0]=0|e[u+t|0];u=u+256|0;break;default:u=Sp(e,u,i,f,r)}o>0&&(d=wp(i,f,r,o,s,c,d,l,t))}if(u!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${n}, consumedPackedEnd=${u}, expectedPackedEnd=${r}, packedWords=${r-n}, encoded.length=${e.length})`)}(e,o,c,l,t,0|r,i/256|0,m,h,a),g}function Ep(e,t,n,r,i){switch(i){case 2:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0;n[i++]=a>>>0&3,n[i++]=a>>>2&3,n[i++]=a>>>4&3,n[i++]=a>>>6&3,n[i++]=a>>>8&3,n[i++]=a>>>10&3,n[i++]=a>>>12&3,n[i++]=a>>>14&3,n[i++]=a>>>16&3,n[i++]=a>>>18&3,n[i++]=a>>>20&3,n[i++]=a>>>22&3,n[i++]=a>>>24&3,n[i++]=a>>>26&3,n[i++]=a>>>28&3,n[i++]=a>>>30&3,n[i++]=o>>>0&3,n[i++]=o>>>2&3,n[i++]=o>>>4&3,n[i++]=o>>>6&3,n[i++]=o>>>8&3,n[i++]=o>>>10&3,n[i++]=o>>>12&3,n[i++]=o>>>14&3,n[i++]=o>>>16&3,n[i++]=o>>>18&3,n[i++]=o>>>20&3,n[i++]=o>>>22&3,n[i++]=o>>>24&3,n[i++]=o>>>26&3,n[i++]=o>>>28&3,n[i]=o>>>30&3})(e,t,n,r);return;case 3:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0;n[i++]=a>>>0&7,n[i++]=a>>>3&7,n[i++]=a>>>6&7,n[i++]=a>>>9&7,n[i++]=a>>>12&7,n[i++]=a>>>15&7,n[i++]=a>>>18&7,n[i++]=a>>>21&7,n[i++]=a>>>24&7,n[i++]=a>>>27&7,n[i++]=7&(a>>>30|(1&o)<<2),n[i++]=o>>>1&7,n[i++]=o>>>4&7,n[i++]=o>>>7&7,n[i++]=o>>>10&7,n[i++]=o>>>13&7,n[i++]=o>>>16&7,n[i++]=o>>>19&7,n[i++]=o>>>22&7,n[i++]=o>>>25&7,n[i++]=o>>>28&7,n[i++]=7&(o>>>31|(3&s)<<1),n[i++]=s>>>2&7,n[i++]=s>>>5&7,n[i++]=s>>>8&7,n[i++]=s>>>11&7,n[i++]=s>>>14&7,n[i++]=s>>>17&7,n[i++]=s>>>20&7,n[i++]=s>>>23&7,n[i++]=s>>>26&7,n[i]=s>>>29&7})(e,t,n,r);return;case 4:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0;n[i++]=a>>>0&15,n[i++]=a>>>4&15,n[i++]=a>>>8&15,n[i++]=a>>>12&15,n[i++]=a>>>16&15,n[i++]=a>>>20&15,n[i++]=a>>>24&15,n[i++]=a>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15,n[i++]=c>>>0&15,n[i++]=c>>>4&15,n[i++]=c>>>8&15,n[i++]=c>>>12&15,n[i++]=c>>>16&15,n[i++]=c>>>20&15,n[i++]=c>>>24&15,n[i]=c>>>28&15})(e,t,n,r);return;case 5:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0;n[i++]=a>>>0&31,n[i++]=a>>>5&31,n[i++]=a>>>10&31,n[i++]=a>>>15&31,n[i++]=a>>>20&31,n[i++]=a>>>25&31,n[i++]=31&(a>>>30|(7&o)<<2),n[i++]=o>>>3&31,n[i++]=o>>>8&31,n[i++]=o>>>13&31,n[i++]=o>>>18&31,n[i++]=o>>>23&31,n[i++]=31&(o>>>28|(1&s)<<4),n[i++]=s>>>1&31,n[i++]=s>>>6&31,n[i++]=s>>>11&31,n[i++]=s>>>16&31,n[i++]=s>>>21&31,n[i++]=s>>>26&31,n[i++]=31&(s>>>31|(15&c)<<1),n[i++]=c>>>4&31,n[i++]=c>>>9&31,n[i++]=c>>>14&31,n[i++]=c>>>19&31,n[i++]=c>>>24&31,n[i++]=31&(c>>>29|(3&l)<<3),n[i++]=l>>>2&31,n[i++]=l>>>7&31,n[i++]=l>>>12&31,n[i++]=l>>>17&31,n[i++]=l>>>22&31,n[i]=l>>>27&31})(e,t,n,r);return;case 6:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0;n[i++]=a>>>0&63,n[i++]=a>>>6&63,n[i++]=a>>>12&63,n[i++]=a>>>18&63,n[i++]=a>>>24&63,n[i++]=63&(a>>>30|(15&o)<<2),n[i++]=o>>>4&63,n[i++]=o>>>10&63,n[i++]=o>>>16&63,n[i++]=o>>>22&63,n[i++]=63&(o>>>28|(3&s)<<4),n[i++]=s>>>2&63,n[i++]=s>>>8&63,n[i++]=s>>>14&63,n[i++]=s>>>20&63,n[i++]=s>>>26&63,n[i++]=c>>>0&63,n[i++]=c>>>6&63,n[i++]=c>>>12&63,n[i++]=c>>>18&63,n[i++]=c>>>24&63,n[i++]=63&(c>>>30|(15&l)<<2),n[i++]=l>>>4&63,n[i++]=l>>>10&63,n[i++]=l>>>16&63,n[i++]=l>>>22&63,n[i++]=63&(l>>>28|(3&u)<<4),n[i++]=u>>>2&63,n[i++]=u>>>8&63,n[i++]=u>>>14&63,n[i++]=u>>>20&63,n[i]=u>>>26&63})(e,t,n,r);return;case 7:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0;n[i++]=a>>>0&127,n[i++]=a>>>7&127,n[i++]=a>>>14&127,n[i++]=a>>>21&127,n[i++]=127&(a>>>28|(7&o)<<4),n[i++]=o>>>3&127,n[i++]=o>>>10&127,n[i++]=o>>>17&127,n[i++]=o>>>24&127,n[i++]=127&(o>>>31|(63&s)<<1),n[i++]=s>>>6&127,n[i++]=s>>>13&127,n[i++]=s>>>20&127,n[i++]=127&(s>>>27|(3&c)<<5),n[i++]=c>>>2&127,n[i++]=c>>>9&127,n[i++]=c>>>16&127,n[i++]=c>>>23&127,n[i++]=127&(c>>>30|(31&l)<<2),n[i++]=l>>>5&127,n[i++]=l>>>12&127,n[i++]=l>>>19&127,n[i++]=127&(l>>>26|(1&u)<<6),n[i++]=u>>>1&127,n[i++]=u>>>8&127,n[i++]=u>>>15&127,n[i++]=u>>>22&127,n[i++]=127&(u>>>29|(15&d)<<3),n[i++]=d>>>4&127,n[i++]=d>>>11&127,n[i++]=d>>>18&127,n[i]=d>>>25&127})(e,t,n,r);return;case 8:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0;n[i++]=a>>>0&255,n[i++]=a>>>8&255,n[i++]=a>>>16&255,n[i++]=a>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255,n[i++]=f>>>0&255,n[i++]=f>>>8&255,n[i++]=f>>>16&255,n[i]=f>>>24&255})(e,t,n,r);return;case 9:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0;n[i++]=a>>>0&511,n[i++]=a>>>9&511,n[i++]=a>>>18&511,n[i++]=511&(a>>>27|(15&o)<<5),n[i++]=o>>>4&511,n[i++]=o>>>13&511,n[i++]=o>>>22&511,n[i++]=511&(o>>>31|(255&s)<<1),n[i++]=s>>>8&511,n[i++]=s>>>17&511,n[i++]=511&(s>>>26|(7&c)<<6),n[i++]=c>>>3&511,n[i++]=c>>>12&511,n[i++]=c>>>21&511,n[i++]=511&(c>>>30|(127&l)<<2),n[i++]=l>>>7&511,n[i++]=l>>>16&511,n[i++]=511&(l>>>25|(3&u)<<7),n[i++]=u>>>2&511,n[i++]=u>>>11&511,n[i++]=u>>>20&511,n[i++]=511&(u>>>29|(63&d)<<3),n[i++]=d>>>6&511,n[i++]=d>>>15&511,n[i++]=511&(d>>>24|(1&f)<<8),n[i++]=f>>>1&511,n[i++]=f>>>10&511,n[i++]=f>>>19&511,n[i++]=511&(f>>>28|(31&p)<<4),n[i++]=p>>>5&511,n[i++]=p>>>14&511,n[i]=p>>>23&511})(e,t,n,r);return;case 10:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0;n[i++]=a>>>0&1023,n[i++]=a>>>10&1023,n[i++]=a>>>20&1023,n[i++]=1023&(a>>>30|(255&o)<<2),n[i++]=o>>>8&1023,n[i++]=o>>>18&1023,n[i++]=1023&(o>>>28|(63&s)<<4),n[i++]=s>>>6&1023,n[i++]=s>>>16&1023,n[i++]=1023&(s>>>26|(15&c)<<6),n[i++]=c>>>4&1023,n[i++]=c>>>14&1023,n[i++]=1023&(c>>>24|(3&l)<<8),n[i++]=l>>>2&1023,n[i++]=l>>>12&1023,n[i++]=l>>>22&1023,n[i++]=u>>>0&1023,n[i++]=u>>>10&1023,n[i++]=u>>>20&1023,n[i++]=1023&(u>>>30|(255&d)<<2),n[i++]=d>>>8&1023,n[i++]=d>>>18&1023,n[i++]=1023&(d>>>28|(63&f)<<4),n[i++]=f>>>6&1023,n[i++]=f>>>16&1023,n[i++]=1023&(f>>>26|(15&p)<<6),n[i++]=p>>>4&1023,n[i++]=p>>>14&1023,n[i++]=1023&(p>>>24|(3&m)<<8),n[i++]=m>>>2&1023,n[i++]=m>>>12&1023,n[i]=m>>>22&1023})(e,t,n,r);return;case 11:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0;n[i++]=a>>>0&2047,n[i++]=a>>>11&2047,n[i++]=2047&(a>>>22|(1&o)<<10),n[i++]=o>>>1&2047,n[i++]=o>>>12&2047,n[i++]=2047&(o>>>23|(3&s)<<9),n[i++]=s>>>2&2047,n[i++]=s>>>13&2047,n[i++]=2047&(s>>>24|(7&c)<<8),n[i++]=c>>>3&2047,n[i++]=c>>>14&2047,n[i++]=2047&(c>>>25|(15&l)<<7),n[i++]=l>>>4&2047,n[i++]=l>>>15&2047,n[i++]=2047&(l>>>26|(31&u)<<6),n[i++]=u>>>5&2047,n[i++]=u>>>16&2047,n[i++]=2047&(u>>>27|(63&d)<<5),n[i++]=d>>>6&2047,n[i++]=d>>>17&2047,n[i++]=2047&(d>>>28|(127&f)<<4),n[i++]=f>>>7&2047,n[i++]=f>>>18&2047,n[i++]=2047&(f>>>29|(255&p)<<3),n[i++]=p>>>8&2047,n[i++]=p>>>19&2047,n[i++]=2047&(p>>>30|(511&m)<<2),n[i++]=m>>>9&2047,n[i++]=m>>>20&2047,n[i++]=2047&(m>>>31|(1023&h)<<1),n[i++]=h>>>10&2047,n[i]=h>>>21&2047})(e,t,n,r);return;case 12:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0;n[i++]=a>>>0&4095,n[i++]=a>>>12&4095,n[i++]=4095&(a>>>24|(15&o)<<8),n[i++]=o>>>4&4095,n[i++]=o>>>16&4095,n[i++]=4095&(o>>>28|(255&s)<<4),n[i++]=s>>>8&4095,n[i++]=s>>>20&4095,n[i++]=c>>>0&4095,n[i++]=c>>>12&4095,n[i++]=4095&(c>>>24|(15&l)<<8),n[i++]=l>>>4&4095,n[i++]=l>>>16&4095,n[i++]=4095&(l>>>28|(255&u)<<4),n[i++]=u>>>8&4095,n[i++]=u>>>20&4095,n[i++]=d>>>0&4095,n[i++]=d>>>12&4095,n[i++]=4095&(d>>>24|(15&f)<<8),n[i++]=f>>>4&4095,n[i++]=f>>>16&4095,n[i++]=4095&(f>>>28|(255&p)<<4),n[i++]=p>>>8&4095,n[i++]=p>>>20&4095,n[i++]=m>>>0&4095,n[i++]=m>>>12&4095,n[i++]=4095&(m>>>24|(15&h)<<8),n[i++]=h>>>4&4095,n[i++]=h>>>16&4095,n[i++]=4095&(h>>>28|(255&g)<<4),n[i++]=g>>>8&4095,n[i]=g>>>20&4095})(e,t,n,r);return;case 16:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,v=e[t+13]>>>0,y=e[t+14]>>>0,b=e[t+15]>>>0;n[i++]=a>>>0&65535,n[i++]=a>>>16&65535,n[i++]=o>>>0&65535,n[i++]=o>>>16&65535,n[i++]=s>>>0&65535,n[i++]=s>>>16&65535,n[i++]=c>>>0&65535,n[i++]=c>>>16&65535,n[i++]=l>>>0&65535,n[i++]=l>>>16&65535,n[i++]=u>>>0&65535,n[i++]=u>>>16&65535,n[i++]=d>>>0&65535,n[i++]=d>>>16&65535,n[i++]=f>>>0&65535,n[i++]=f>>>16&65535,n[i++]=p>>>0&65535,n[i++]=p>>>16&65535,n[i++]=m>>>0&65535,n[i++]=m>>>16&65535,n[i++]=h>>>0&65535,n[i++]=h>>>16&65535,n[i++]=g>>>0&65535,n[i++]=g>>>16&65535,n[i++]=_>>>0&65535,n[i++]=_>>>16&65535,n[i++]=v>>>0&65535,n[i++]=v>>>16&65535,n[i++]=y>>>0&65535,n[i++]=y>>>16&65535,n[i++]=b>>>0&65535,n[i]=b>>>16&65535})(e,t,n,r);return;case 32:for(let i=0;i<32;i=i+1|0)n[r+i|0]=0|e[t+i|0];return}let a=gp[i]>>>0,o=t,s=0,c=e[o]>>>0;for(let t=0;t<32;t++)if(s+i<=32)n[r+t]=c>>>s&a,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0));else{let l=32-s,u=c>>>s;o++,c=e[o]>>>0,n[r+t]=(u|(c&gp[i-l]>>>0)<<l)&a,s=i-l}}function Dp(e,t,n){let r=new Uint32Array(n),i=0,a=t.get();for(let t=0;t<r.length;t++){let t=e[a++],n=127&t;t<128||(t=e[a++],n|=(127&t)<<7,t<128||(t=e[a++],n|=(127&t)<<14,t<128||(t=e[a++],n|=(127&t)<<21,t<128||(t=e[a++],n|=(15&t)<<28)))),r[i++]=n}return t.set(a),r}function Op(e,t,n){let r=new BigUint64Array(n);for(let n=0;n<r.length;n++)r[n]=kp(e,t);return r}function kp(e,t){let n=0n,r=0,i=t.get();for(;i<e.length;){let t=e[i++];if(n|=BigInt(127&t)<<BigInt(r),!(128&t))break;if(r+=7,r>=64)throw Error(`Varint too long`)}return t.set(i),n}function Ap(e,t){let n,r;return r=e[t.get()],t.increment(),n=127&r,r<128?n:(r=e[t.get()],t.increment(),n|=(127&r)<<7,r<128?n:(r=e[t.get()],t.increment(),n|=(127&r)<<14,r<128?n:(r=e[t.get()],t.increment(),n|=(127&r)<<21,r<128?n:(r=e[t.get()],n|=(15&r)<<28,function(e,t,n){let r,i;if(i=t[n.get()],n.increment(),r=(112&i)>>4,i<128||(i=t[n.get()],n.increment(),r|=(127&i)<<3,i<128)||(i=t[n.get()],n.increment(),r|=(127&i)<<10,i<128)||(i=t[n.get()],n.increment(),r|=(127&i)<<17,i<128)||(i=t[n.get()],n.increment(),r|=(127&i)<<24,i<128)||(i=t[n.get()],n.increment(),r|=(1&i)<<31,i<128))return 4294967296*r+(e>>>0);throw Error(`Expected varint not more than 10 bytes`)}(n,e,t)))))}function jp(e){return e>>>1^-(1&e)}function Mp(e){return e>>1n^-(1n&e)}function Np(e){return e%2==1?(e+1)/-2:e/2}function Pp(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=e[r]}let r=new Uint32Array(n),i=0;for(let n=0;n<t;n++){let a=e[n];r.fill(e[n+t],i,i+a),i+=a}return r}function Fp(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=Number(e[r])}let r=new BigUint64Array(n),i=0;for(let n=0;n<t;n++){let a=Number(e[n]);r.fill(e[n+t],i,i+a),i+=a}return r}function Ip(e,t,n){let r=new Float64Array(n),i=0;for(let n=0;n<t;n++){let a=e[n];r.fill(e[n+t],i,i+a),i+=a}return r}function Lp(e){let t=new Int32Array(e.length);t[0]=jp(e[0]);let n=e.length/4*4,r=1;if(n>=4)for(;r<n-4;r+=4){let n=e[r+1],i=e[r+2],a=e[r+3];t[r]=jp(e[r])+t[r-1],t[r+1]=jp(n)+t[r],t[r+2]=jp(i)+t[r+1],t[r+3]=jp(a)+t[r+2]}for(;r!==e.length;++r)t[r]=jp(e[r])+t[r-1];return t}function Rp(e){let t=new BigInt64Array(e.length);t[0]=Mp(e[0]);let n=e.length/4*4,r=1;if(n>=4)for(;r<n-4;r+=4){let n=e[r+1],i=e[r+2],a=e[r+3];t[r]=Mp(e[r])+t[r-1],t[r+1]=Mp(n)+t[r],t[r+2]=Mp(i)+t[r+1],t[r+3]=Mp(a)+t[r+2]}for(;r!==t.length;++r)t[r]=Mp(e[r])+t[r-1];return t}function zp(e){let t=e.length/4*4,n=1;if(t>=4)for(let r=e[0];n<t-4;n+=4)r=e[n]+=r,r=e[n+1]+=r,r=e[n+2]+=r,r=e[n+3]+=r;for(;n!==e.length;)e[n]+=e[n-1],++n}var Bp,Vp,Hp,Up,Wp,Gp,Kp,qp;function Jp(e,t){let n=function(e,t){let n=e[t.get()],r=Object.values(Bp)[n>>4],i=null;switch(r){case Bp.DATA:i={dictionaryType:Object.values(Vp)[15&n]};break;case Bp.OFFSET:i={offsetType:Object.values(Hp)[15&n]};break;case Bp.LENGTH:i={lengthType:Object.values(Up)[15&n]}}t.increment();let a=e[t.get()],o=Object.values(pp)[a>>5],s=Object.values(pp)[a>>2&7],c=Object.values(mp)[3&a];t.increment();let l=Dp(e,t,2),u=l[0];return{physicalStreamType:r,logicalStreamType:i,logicalLevelTechnique1:o,logicalLevelTechnique2:s,physicalLevelTechnique:c,numValues:u,byteLength:l[1],decompressedCount:u}}(e,t);return n.logicalLevelTechnique1===pp.MORTON?function(e,t,n){let r=Dp(t,n,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(n,e,t):pp.RLE!==n.logicalLevelTechnique1&&pp.RLE!==n.logicalLevelTechnique2||mp.NONE===n.physicalLevelTechnique?n:function(e,t,n){let r=Dp(t,n,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(n,e,t)}(function(e){e.PRESENT=`PRESENT`,e.DATA=`DATA`,e.OFFSET=`OFFSET`,e.LENGTH=`LENGTH`})(Bp||={}),function(e){e.NONE=`NONE`,e.SINGLE=`SINGLE`,e.SHARED=`SHARED`,e.VERTEX=`VERTEX`,e.MORTON=`MORTON`,e.FSST=`FSST`}(Vp||={}),function(e){e.VERTEX=`VERTEX`,e.INDEX=`INDEX`,e.STRING=`STRING`,e.KEY=`KEY`}(Hp||={}),function(e){e.VAR_BINARY=`VAR_BINARY`,e.GEOMETRIES=`GEOMETRIES`,e.PARTS=`PARTS`,e.RINGS=`RINGS`,e.TRIANGLES=`TRIANGLES`,e.SYMBOL=`SYMBOL`,e.DICTIONARY=`DICTIONARY`}(Up||={}),function(e){e[e.FLAT=0]=`FLAT`,e[e.CONST=1]=`CONST`,e[e.SEQUENCE=2]=`SEQUENCE`,e[e.DICTIONARY=3]=`DICTIONARY`,e[e.FSST_DICTIONARY=4]=`FSST_DICTIONARY`}(Wp||={});class Yp{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8);return(this.values[t]>>e%8&1)==1}set(e,t){let n=Math.floor(e/8);this.values[n]=this.values[n]|!!t<<e%8}getInt(e){let t=Math.floor(e/8);return this.values[t]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Xp(e,t,n){if(!t)return e;let r=t.size(),i=new e.constructor(r),a=0;for(let o=0;o<r;o++)i[o]=t.get(o)?e[a++]:n;return i}function Zp(e,t,n,r,i){return function(e,t,n,r){let i;switch(t.logicalLevelTechnique1){case pp.DELTA:if(t.logicalLevelTechnique2===pp.RLE){let n=t;if(!r)return function(e,t,n){let r=new Int32Array(n),i=0,a=0;for(let n=0;n<t;n++){let o=e[n],s=jp(e[n+t]);for(let e=0;e<o;e++)a+=s,r[i++]=a}return r}(e,n.runs,n.numRleValues);i=Lp(e=Pp(e,n.runs,n.numRleValues))}else i=Lp(e);break;case pp.RLE:i=function(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=e[r]}let r=new Int32Array(n),i=0;for(let n=0;n<t;n++){let a=e[n],o=e[n+t];o=jp(o),r.fill(o,i,i+a),i+=a}return r}(e,t.runs,t.numRleValues);break;case pp.MORTON:zp(e),i=new Int32Array(e);break;case pp.COMPONENTWISE_DELTA:i=function(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=jp(e[0]),t[1]=jp(e[1]);let n=e.length/4*4,r=2;if(n>=4)for(;r<n-4;r+=4){let n=e[r+1],i=e[r+2],a=e[r+3];t[r]=jp(e[r])+t[r-2],t[r+1]=jp(n)+t[r-1],t[r+2]=jp(i)+t[r],t[r+3]=jp(a)+t[r+1]}for(;r!==e.length;r+=2)t[r]=jp(e[r])+t[r-2],t[r+1]=jp(e[r+1])+t[r-1];return t}(e);break;case pp.NONE:i=function(e){let t=new Int32Array(e.length);for(let n=0;n<e.length;n++)t[n]=jp(e[n]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Xp(i,r,0):i}(em(e,t,n),n,0,i)}function Qp(e,t,n,r,i){return function(e,t,n,r){let i;switch(t.logicalLevelTechnique1){case pp.DELTA:i=function(e){let t=new Uint32Array(e.length);t[0]=jp(e[0])>>>0;for(let n=1;n<e.length;n++)t[n]=t[n-1]+jp(e[n])>>>0;return t}(t.logicalLevelTechnique2===pp.RLE?Pp(e,t.runs,t.numRleValues):e);break;case pp.RLE:i=Pp(e,t.runs,t.numRleValues);break;case pp.MORTON:zp(e),i=e;break;case pp.COMPONENTWISE_DELTA:i=function(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=jp(e[0])>>>0,t[1]=jp(e[1])>>>0;for(let n=2;n<e.length;n+=2)t[n]=t[n-2]+jp(e[n])>>>0,t[n+1]=t[n-1]+jp(e[n+1])>>>0;return t}(e);break;case pp.NONE:i=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Xp(i,r,0):i}(em(e,t,n),n,0,i)}function $p(e,t,n){return function(e,t){if(t.logicalLevelTechnique1===pp.DELTA&&t.logicalLevelTechnique2===pp.NONE)return function(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=jp(e[0]);let n=t[1];for(let r=2;r!==t.length;++r)n+=jp(e[r-1]),t[r]=t[r-1]+n;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===pp.RLE&&t.logicalLevelTechnique2===pp.NONE)return function(e,t,n){let r=new Uint32Array(n+1);r[0]=0;let i=1,a=r[0];for(let n=0;n<t;n++){let o=e[n],s=e[n+t];for(let e=i;e<i+o;e++)r[e]=s+a,a=r[e];i+=o}return r}(e,t.runs,t.numRleValues);if(t.logicalLevelTechnique1===pp.NONE&&t.logicalLevelTechnique2===pp.NONE){(function(e){let t=0;for(let n=0;n<e.length;n++)e[n]+=t,t=e[n]})(e);let n=new Uint32Array(t.numValues+1);return n[0]=0,n.set(e,1),n}if(t.logicalLevelTechnique1===pp.DELTA&&t.logicalLevelTechnique2===pp.RLE){let n=function(e,t,n){let r=new Int32Array(n+1);r[0]=0;let i=1,a=r[0];for(let n=0;n<t;n++){let o=e[n],s=e[n+t];s=jp(s);for(let e=i;e<i+o;e++)r[e]=s+a,a=r[e];i+=o}return r}(e,t.runs,t.numRleValues);return zp(n),new Uint32Array(n)}throw Error(`Only delta encoding is supported for transforming length to offset streams yet.`)}(em(e,t,n),n)}function em(e,t,n){let r=n.physicalLevelTechnique;switch(r){case mp.FAST_PFOR:return function(e,t,n,r){return function(e,t,n,r,i){let a=r.get();if(3&n)throw Error(`FastPFOR: invalid encodedByteLength=${n} at offset=${a} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=n>>>2,s=function(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let n=new Uint32Array(Math.max(16,2*t));return e.encodedWords=n,n}(i,o);(function(e,t,n,r){if(t<0||n<0||t+n>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${n}, bytes.length=${e.length})`);let i=Math.floor(n/4),a=n%4!=0,o=a?i+1:i;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(i>0){let n=e.byteOffset+t;if(3&n)for(let n=0;n<i;n++){let i=t+4*n;r[n]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]}else{let t=new Uint32Array(e.buffer,n,i);for(let e=0;e<i;e++)r[e]=0|vp(t[e])}}if(a){let a=t+4*i,o=n-4*i,s=0;for(let t=0;t<o;t++)s|=e[a+t]<<24-8*t;r[i]=0|s}})(e,a,n,s);let c=function(e,t,n){let r=0,i=0,a=new Uint32Array(t),o=n??xp();if(e.length>0){let t=0|e[r];if(r=r+1|0,255&t)throw Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(i+t>a.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${i}, alignedLength=${t}, out.length=${a.length})`);r=function(e,t,n,r,i,a){let o=r+_p(i,256),s=r,c=n;for(;s!==o;){let n=Math.min(yp,o-s);c=Tp(e,t,c,s,n,a),s=s+n|0}return c}(e,a,r,i,t,o),i=i+t|0}return function(e,t,n,r,i,a){if(a===0)return t;let o=0,s=t,c=t+n,l=i,u=i,d=i+a,f=0,p=0;for(;s<c&&u<d;){let t=e[s]>>>o&255;if(o+=8,s+=o>>>5,o&=31,f|=(127&t)<<p,128&t)r[u++]=0|f,f=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${f}, decoded=${u-l}/${a}, inPos=${s}, inEnd=${c})`)}if(u!==d)throw Error(`FastPFOR VByte: truncated stream (decoded=${u-l}, expected=${a}, consumedWords=${s-t}/${n}, vbyteStart=${t}, vbyteEnd=${c})`)}(e,r,e.length-r|0,a,i,t-i|0),a}(s.subarray(0,o),t,i.decoderWorkspace);return r.add(n),c}(e,t,n,r,function(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,0|e);return{encodedWords:new Uint32Array(t),decoderWorkspace:xp()}}(n>>>2))}(e,n.numValues,n.byteLength,t);case mp.VARINT:return Dp(e,t,n.numValues);case mp.NONE:{let r=t.get();t.add(n.byteLength);let i=e.subarray(r,t.get());return new Uint32Array(i)}default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function tm(e,t,n){let r=em(e,t,n);return r.length===1?r[0]:function(e){return e[1]}(r)}function nm(e,t,n){return function(e){if(e.length===2){let t=jp(e[1]);return[t,t]}return[jp(e[2]),jp(e[3])]}(em(e,t,n))}function rm(e,t,n){return function(e){if(e.length===2){let t=Mp(e[1]);return[t,t]}return[Mp(e[2]),Mp(e[3])]}(Op(e,t,n.numValues))}function im(e,t,n,r){return function(e,t,n){let r;switch(t.logicalLevelTechnique1){case pp.DELTA:r=function(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,Mp(e[0]));for(let n=1;n<e.length;n++)t[n]=BigInt.asUintN(64,t[n-1]+Mp(e[n]));return t}(t.logicalLevelTechnique2===pp.RLE?Fp(e,t.runs,t.numRleValues):e);break;case pp.RLE:r=Fp(e,t.runs,t.numRleValues);break;case pp.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?Xp(r,n,0n):r}(Op(e,t,n.numValues),n,r)}function am(e,t,n){let r=Op(e,t,n.numValues);return r.length===1?r[0]:function(e){return e[1]}(r)}function om(e,t,n,r,i=`int32`){let a=e.logicalLevelTechnique1;if(a===pp.RLE)return e.runs===1?Wp.CONST:Wp.FLAT;if(a!==pp.DELTA||e.logicalLevelTechnique2!==pp.RLE)return e.numValues===1?Wp.CONST:Wp.FLAT;let o=t instanceof Yp?t.size():t;if(e.numRleValues!==o)return Wp.FLAT;if(e.runs===1)return Wp.SEQUENCE;if(e.runs!==2)return e.numValues===1?Wp.CONST:Wp.FLAT;let s=r.get();if(e.physicalLevelTechnique===mp.VARINT)return function(e,t,n){let r=new fp(t.get());if(n===`int64`){let t=Op(e,r,4);return t[2]===2n&&t[3]===2n}let i=Dp(e,r,4);return i[2]===2&&i[3]===2}(n,r,i)?Wp.SEQUENCE:e.numValues===1?Wp.CONST:Wp.FLAT;let c=r.get(),l=new Int32Array(n.buffer,n.byteOffset+c,4);return r.set(s),l[2]===2&&l[3]===2?Wp.SEQUENCE:e.numValues===1?Wp.CONST:Wp.FLAT}class sm extends ap{getValueFromBuffer(e){return this.dataBuffer[e]}}class cm extends cp{constructor(e,t,n,r){super(e,BigInt64Array.of(t),n,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}function lm(e,t,n){return{x:um(e,t)-n,y:um(e>>1,t)-n}}function um(e,t){let n=0;for(let r=0;r<t;r++)n|=(e&1<<2*r)>>r;return n}function dm(e,t,r,i,a,o,s){return e===qp.MORTON?function(e,t,r,i,a,o){let s=Array(a?i+1:i);for(let a=0;a<i;a++){let i=lm(e[t[r+a]],o.numBits,o.coordinateShift);s[a]=new n(i.x,i.y)}return a&&(s[s.length-1]=s[0]),s}(t,r,i,a,o,s):function(e,t,r,i,a){let o=Array(a?i+1:i);for(let a=0;a<2*i;a+=2){let i=2*t[r+a/2];o[a/2]=new n(e[i],e[i+1])}return a&&(o[o.length-1]=o[0]),o}(t,r,i,a,o)}function fm(e,t,r,i){let a=Array(i?r+1:r);for(let i=0;i<2*r;i+=2)a[i/2]=new n(e[t+i],e[t+i+1]);return i&&(a[a.length-1]=a[0]),a}(function(e){e[e.POINT=0]=`POINT`,e[e.LINESTRING=1]=`LINESTRING`,e[e.POLYGON=2]=`POLYGON`,e[e.MULTIPOINT=3]=`MULTIPOINT`,e[e.MULTILINESTRING=4]=`MULTILINESTRING`,e[e.MULTIPOLYGON=5]=`MULTIPOLYGON`})(Gp||={}),function(e){e[e.POINT=0]=`POINT`,e[e.LINESTRING=1]=`LINESTRING`,e[e.POLYGON=2]=`POLYGON`}(Kp||={}),function(e){e[e.MORTON=0]=`MORTON`,e[e.VEC_2=1]=`VEC_2`,e[e.VEC_3=2]=`VEC_3`}(qp||={});class pm{constructor(e,t,n,r,i){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=n,this._vertexBuffer=r,this._mortonSettings=i}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let t=lm(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[t.x,t.y]}let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return function(e){let t=Array(e.numGeometries),r=1,i=1,a=1,o=0,s=0,c=0,l=e.mortonSettings,u=e.topologyVector,d=u.geometryOffsets,f=u.partOffsets,p=u.ringOffsets,m=e.vertexOffsets,h=!m||m.length===0,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let u=0;u<e.numGeometries;u++)switch(e.geometryType(u)){case Gp.POINT:{let u,g;if(h)u=_[s++],g=_[s++];else if(e.vertexBufferType===qp.MORTON){let e=lm(_[m[c++]],l.numBits,l.coordinateShift);u=e.x,g=e.y}else{let e=2*m[c++];u=_[e],g=_[e+1]}t[o++]=[[new n(u,g)]],d&&a++,f&&r++,p&&i++}break;case Gp.MULTIPOINT:{let e=d[a]-d[a-1];a++;let l=Array(e);if(h)for(let t=0;t<e;t++){let e=_[s++],r=_[s++];l[t]=new n(e,r)}else for(let t=0;t<e;t++){let e=2*m[c++];l[t]=new n(_[e],_[e+1])}t[o++]=l.map((e=>[e])),r+=e,i+=e}break;case Gp.LINESTRING:{let n,u;g?(n=p[i]-p[i-1],i++):n=f[r]-f[r-1],r++,h?(u=fm(_,s,n,!1),s+=2*n):(u=dm(e.vertexBufferType,_,m,c,n,!1,l),c+=n),t[o++]=[u],d&&a++}break;case Gp.POLYGON:{let n=f[r]-f[r-1];r++;let u=Array(n-1),g,v=p[i]-p[i-1];if(i++,h){g=fm(_,s,v,!0),s+=2*v;for(let e=0;e<u.length;e++)v=p[i]-p[i-1],i++,u[e]=fm(_,s,v,!0),s+=2*v}else{g=dm(e.vertexBufferType,_,m,c,v,!0,l),c+=v;for(let t=0;t<u.length;t++)v=p[i]-p[i-1],i++,u[t]=dm(e.vertexBufferType,_,m,c,v,!0,l),c+=v}t[o++]=[g].concat(u),d&&a++}break;case Gp.MULTILINESTRING:{let n=d[a]-d[a-1];a++;let u=Array(n);for(let t=0;t<n;t++){let n;g?(n=p[i]-p[i-1],i++):n=f[r]-f[r-1],r++,h?(u[t]=fm(_,s,n,!1),s+=2*n):(u[t]=dm(e.vertexBufferType,_,m,c,n,!1,l),c+=n)}t[o++]=u}break;case Gp.MULTIPOLYGON:{let n=d[a]-d[a-1];a++;let u=Array(n);for(let t=0;t<n;t++){let n=f[r]-f[r-1],a;r++;let o=Array(n-1),d=p[i]-p[i-1];i++,h?(a=fm(_,s,d,!0),s+=2*d):(a=dm(e.vertexBufferType,_,m,c,d,!0,l),c+=d);for(let t=0;t<o.length;t++){let n=p[i]-p[i-1];i++,h?(o[t]=fm(_,s,n,!0),s+=2*n):(o[t]=dm(e.vertexBufferType,_,m,c,n,!0,l),c+=n)}u[t]=[a].concat(o)}t[o++]=u.flat()}break;default:throw Error(`The specified geometry type is currently not supported.`)}return t}(this)}get mortonSettings(){return this._mortonSettings}}class mm extends pm{constructor(e,t,n,r,i,a,o){super(n,r,i,a,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Gp.POLYGON||this._geometryType===Gp.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class hm extends pm{constructor(e,t,n,r,i,a){super(e,n,r,i,a),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===Gp.POLYGON||this.geometryType(e)===Gp.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class gm{constructor(e,t,n,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=n,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error(`Cannot convert GpuVector to coordinates without topology information`);let e=Array(this.numGeometries),t=this._topologyVector,r=t.partOffsets,i=t.ringOffsets,a=t.geometryOffsets,o=0,s=1,c=1,l=1;for(let t=0;t<this.numGeometries;t++)switch(this.geometryType(t)){case Gp.POLYGON:{let u=r[s]-r[s-1];s++;let d=[];for(let e=0;e<u;e++){let e=i[c]-i[c-1];c++;let t=[];for(let r=0;r<e;r++){let e=this._vertexBuffer[o++],r=this._vertexBuffer[o++];t.push(new n(e,r))}t.length>0&&t.push(t[0]),d.push(t)}e[t]=d,a&&l++}break;case Gp.MULTIPOLYGON:{let u=a[l]-a[l-1];l++;let d=[];for(let e=0;e<u;e++){let e=r[s]-r[s-1];s++;for(let t=0;t<e;t++){let e=i[c]-i[c-1];c++;let t=[];for(let r=0;r<e;r++){let e=this._vertexBuffer[o++],r=this._vertexBuffer[o++];t.push(new n(e,r))}t.length>0&&t.push(t[0]),d.push(t)}}e[t]=d}}return e}[Symbol.iterator](){return null}}function _m(e,t,n,r,i,a){return new vm(e,t,n,r,i,a)}class vm extends gm{constructor(e,t,n,r,i,a){super(n,r,i,a),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function ym(e,t,n,r,i){return new bm(e,t,n,r,i)}class bm extends gm{constructor(e,t,n,r,i){super(t,n,r,i),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function xm(e,t,n,r,i){let a=Jp(e,n),o,s,c,l;if(om(a,r,e,n)===Wp.CONST){let i=tm(e,n,a),u,d,f,p;for(let r=0;r<t-1;r++){let t=Jp(e,n);switch(t.physicalStreamType){case Bp.LENGTH:switch(t.logicalStreamType.lengthType){case Up.GEOMETRIES:u=$p(e,n,t);break;case Up.PARTS:d=$p(e,n,t);break;case Up.RINGS:f=$p(e,n,t);break;case Up.TRIANGLES:p=$p(e,n,t)}break;case Bp.OFFSET:switch(t.logicalStreamType.offsetType){case Hp.VERTEX:o=Qp(e,n,t);break;case Hp.INDEX:l=Qp(e,n,t)}break;case Bp.DATA:Vp.VERTEX===t.logicalStreamType.dictionaryType?s=Zp(e,n,t):(c={numBits:t.numBits,coordinateShift:t.coordinateShift},s=Qp(e,n,t))}}return l?u!==void 0||d!==void 0?_m(r,i,p,l,s,{geometryOffsets:u,partOffsets:d,ringOffsets:f}):_m(r,i,p,l,s):c===void 0?function(e,t,n,r,i){return new mm(e,t,qp.VEC_2,n,r,i)}(r,i,{geometryOffsets:u,partOffsets:d,ringOffsets:f},o,s):function(e,t,n,r,i,a){return new mm(e,t,qp.MORTON,n,r,i,a)}(r,i,{geometryOffsets:u,partOffsets:d,ringOffsets:f},o,s,c)}let u=Qp(e,n,a),d,f,p,m,h,g,_;for(let r=0;r<t-1;r++){let t=Jp(e,n);switch(t.physicalStreamType){case Bp.LENGTH:switch(t.logicalStreamType.lengthType){case Up.GEOMETRIES:d=Qp(e,n,t);break;case Up.PARTS:f=Qp(e,n,t);break;case Up.RINGS:p=Qp(e,n,t);break;case Up.TRIANGLES:m=$p(e,n,t)}break;case Bp.OFFSET:switch(t.logicalStreamType.offsetType){case Hp.VERTEX:o=Qp(e,n,t);break;case Hp.INDEX:l=Qp(e,n,t)}break;case Bp.DATA:Vp.VERTEX===t.logicalStreamType.dictionaryType?s=Zp(e,n,t):(c={numBits:t.numBits,coordinateShift:t.coordinateShift},s=Qp(e,n,t))}}return d?(h=Sm(u,d,2),f&&p?(g=Cm(u,h,f,!1),_=function(e,t,n,r){let i=new Uint32Array(n[n.length-1]+1),a=0;i[0]=a;let o=1,s=1,c=0;for(let l=0;l<e.length;l++){let u=e[l],d=t[l+1]-t[l];if(u!==0&&u!==3)for(let e=0;e<d;e++){let e=n[o]-n[o-1];o++;for(let t=0;t<e;t++)a=i[s++]=a+r[c++]}else for(let e=0;e<d;e++)i[s++]=++a,o++}return i}(u,h,g,p)):f&&(g=function(e,t,n){let r=new Uint32Array(t[t.length-1]+1),i=0;r[0]=i;let a=1,o=0;for(let s=0;s<e.length;s++){let c=e[s],l=t[s+1]-t[s];if(c===4||c===1)for(let e=0;e<l;e++)i=r[a++]=i+n[o++];else for(let e=0;e<l;e++)r[a++]=++i}return r}(u,h,f))):f&&p?(g=Sm(u,f,1),_=Cm(u,g,p,!0)):f&&(g=Sm(u,f,0)),l&&!g?ym(u,m,l,s):l?ym(u,m,l,s,{geometryOffsets:h,partOffsets:g,ringOffsets:_}):c===void 0?function(e,t,n,r){return new hm(qp.VEC_2,e,t,n,r)}(u,{geometryOffsets:h,partOffsets:g,ringOffsets:_},o,s):function(e,t,n,r,i){return new hm(qp.MORTON,e,t,n,r,i)}(u,{geometryOffsets:h,partOffsets:g,ringOffsets:_},o,s,c)}function Sm(e,t,n){let r=new Uint32Array(e.length+1),i=0;r[0]=i;let a=0;for(let o=0;o<e.length;o++)i=r[o+1]=i+(e[o]>n?t[a++]:1);return r}function Cm(e,t,n,r){let i=new Uint32Array(t[t.length-1]+1),a=0;i[0]=a;let o=1,s=0;for(let c=0;c<e.length;c++){let l=e[c],u=t[c+1]-t[c];if(l===5||l===2||r&&(l===4||l===1))for(let e=0;e<u;e++)a=i[o++]=a+n[s++];else for(let e=0;e<u;e++)i[o++]=++a}return i}class wm extends ip{constructor(e,t,n){super(e,t.getBuffer(),n),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}}class Tm extends ap{getValueFromBuffer(e){return this.dataBuffer[e]}}class Em extends ip{constructor(e,t,n,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),n)}getValueFromBuffer(e){return this.dataBuffer[0]}}function Dm(e,t,n,r,i){let a=function(e,t,n,r){let i=new Uint8Array(t),a=0,o=r.get()+n;for(;a<t&&!(r.get()>=o);){let n=e[r.increment()];if(n<=127){let o=n+3,s=e[r.increment()],c=Math.min(a+o,t);i.fill(s,a,c),a=c}else{let o=256-n;for(let n=0;n<o&&a<t;n++)i[a++]=e[r.increment()]}}return r.set(o),i}(e,Math.ceil(t/8),n,r);return i?function(e,t,n){if(!n)return e;let r=n.size(),i=new Yp(e,t),a=new Yp(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let e=0;e<r;e++){let t=!!n.get(e)&&i.get(o++);a.set(e,t)}return a.getBuffer()}(a,t,i):a}let Om=new TextDecoder;function km(e,t,n){return n-t>=12?Om.decode(e.subarray(t,n)):function(e,t,n){let r=``,i=t;for(;i<n;){let t=e[i],a,o,s,c=null,l=t>239?4:t>223?3:t>191?2:1;if(i+l>n)break;l===1?t<128&&(c=t):l===2?(a=e[i+1],(192&a)==128&&(c=(31&t)<<6|63&a,c<=127&&(c=null))):l===3?(a=e[i+1],o=e[i+2],(192&a)==128&&(192&o)==128&&(c=(15&t)<<12|(63&a)<<6|63&o,(c<=2047||c>=55296&&c<=57343)&&(c=null))):l===4&&(a=e[i+1],o=e[i+2],s=e[i+3],(192&a)==128&&(192&o)==128&&(192&s)==128&&(c=(15&t)<<18|(63&a)<<12|(63&o)<<6|63&s,(c<=65535||c>=1114112)&&(c=null))),c===null?(c=65533,l=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),i+=l}return r}(e,t,n)}class Am extends ip{constructor(e,t,n,r){super(e,n,r),this.offsetBuffer=t}}class jm extends Am{constructor(e,t,n,r){super(e,t,n,r??t.length-1)}getValueFromBuffer(e){return km(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class Mm extends Am{constructor(e,t,n,r,i){super(e,n,r,i??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e];return km(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class Nm extends Am{constructor(e,t,n,r,i,a,o){super(e,n,r,o),this.indexBuffer=t,this.symbolOffsetBuffer=i,this.symbolTableBuffer=a}getValueFromBuffer(e){this.decodedDictionary??=(this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(e,t,n){let r=[],i=Array(t.length).fill(0);for(let e=1;e<t.length;e++)i[e]=i[e-1]+t[e-1];for(let a=0;a<n.length;a++)if(n[a]===255)r.push(n[++a]);else{let o=t[n[a]],s=i[n[a]];for(let t=0;t<o;t++)r.push(e[s+t])}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));let t=this.indexBuffer[e];return km(this.decodedDictionary,this.offsetBuffer[t],this.offsetBuffer[t+1])}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),n=e[0];for(let r=1;r<e.length;r++){let i=e[r];t[r-1]=i-n,n=i}return t}}function Pm(e,t,n,r,i,a){return n.type===`scalarType`?function(e,t,n,r,i,a){let o=null;if(e===0)return null;if(a.nullable){let e=Jp(t,n),r=e.numValues,i=n.get(),a=Dm(t,r,e.byteLength,n);n.set(i+e.byteLength),o=new Yp(a,e.numValues)}let s=o??r;switch(i.physicalType){case 4:case 3:return function(e,t,n,r,i){let a=Jp(e,t),o=om(a,i,e,t),s=r.physicalType===3;if(o===Wp.FLAT){let r=Fm(i)?i:void 0,o=s?Zp(e,t,a,0,r):Qp(e,t,a,0,r);return new op(n.name,o,i)}if(o===Wp.SEQUENCE){let r=nm(e,t,a);return new lp(n.name,r[0],r[1],a.numRleValues)}let c=s?function(e,t,n){let r=em(e,t,n);return r.length===1?jp(r[0]):function(e){return jp(e[1])}(r)}(e,t,a):tm(e,t,a);return new up(n.name,c,i,s)}(t,n,a,i,s);case 9:return function(e,t,n,r,i){let a=null,o=null,s=null,c=null,l=null,u=i??null,d=null,f=null;for(let e=0;e<r;e++){let e=Jp(t,n);switch(e.physicalStreamType){case Bp.PRESENT:{let r=new Yp(Dm(t,e.numValues,e.byteLength,n),e.numValues);u=i??r;break}case Bp.OFFSET:o=Qp(t,n,e,0,u);break;case Bp.LENGTH:{let r=$p(t,n,e);Up.DICTIONARY===e.logicalStreamType.lengthType?a=r:Up.SYMBOL===e.logicalStreamType.lengthType?c=r:d=r;break}case Bp.DATA:{let r=t.subarray(n.get(),n.get()+e.byteLength);n.add(e.byteLength);let i=e.logicalStreamType.dictionaryType;Vp.FSST===i?l=r:Vp.SINGLE===i||Vp.SHARED===i?s=r:Vp.NONE===i&&(f=r);break}}}return function(e,t,n,r,i,a,o){return t?new Nm(e,n,r,i,a,t,o):null}(e,l,o,a,s,c,u)??function(e,t,n,r,i){return t?i?new Mm(e,n,r,t,i):new Mm(e,n,r,t):null}(e,s,o,a,u)??function(e,t,n,r,i){if(!t||!n)return null;if(r)return i?new Mm(e,r,t,n,i):new Mm(e,r,t,n);if(i&&i.size()!==t.length-1){let r=new Uint32Array(i.size()),a=0;for(let e=0;e<i.size();e++)r[e]=i.get(e)?a++:0;return new Mm(e,r,t,n,i)}return i?new jm(e,t,n,i):new jm(e,t,n)}(e,d,f,o,u)}(a.name,t,n,a.nullable?e-1:e,o);case 0:return function(e,t,n,r,i){let a=Jp(e,t),o=a.numValues,s=t.get(),c=Fm(i)?i:void 0,l=Dm(e,o,a.byteLength,t,c);t.set(s+a.byteLength);let u=new Yp(l,o);return new wm(n.name,u,i)}(t,n,a,0,s);case 6:case 5:return function(e,t,n,r,i){let a=Jp(e,t),o=om(a,r,e,t,`int64`),s=i.physicalType===5;if(o===Wp.FLAT){let i=Fm(r)?r:void 0,o=s?function(e,t,n,r){return function(e,t,n){let r;switch(t.logicalLevelTechnique1){case pp.DELTA:if(t.logicalLevelTechnique2===pp.RLE){let i=t;if(!n)return function(e,t,n){let r=new BigInt64Array(n),i=0,a=0n;for(let n=0;n<t;n++){let o=Number(e[n]),s=Mp(e[n+t]);for(let e=0;e<o;e++)a+=s,r[i++]=a}return r}(e,i.runs,i.numRleValues);r=Rp(e=Fp(e,i.runs,i.numRleValues))}else r=Rp(e);break;case pp.RLE:r=function(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=Number(e[r])}let r=new BigInt64Array(n),i=0;for(let n=0;n<t;n++){let a=Number(e[n]),o=e[n+t];o=Mp(o),r.fill(o,i,i+a),i+=a}return r}(e,t.runs,t.numRleValues);break;case pp.NONE:r=function(e){let t=new BigInt64Array(e.length);for(let n=0;n<e.length;n++)t[n]=Mp(e[n]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?Xp(r,n,0n):r}(Op(e,t,n.numValues),n,r)}(e,t,a,i):im(e,t,a,i);return new sm(n.name,o,r)}if(o===Wp.SEQUENCE){let r=rm(e,t,a);return new cm(n.name,r[0],r[1],a.numRleValues)}let c=s?function(e,t,n){let r=Op(e,t,n.numValues);return r.length===1?Mp(r[0]):function(e){return Mp(e[1])}(r)}(e,t,a):am(e,t,a);return new Em(n.name,c,r,s)}(t,n,a,s,i);case 7:return function(e,t,n,r){let i=Jp(e,t),a=Fm(r)?r:void 0,o=function(e,t,n,r){let i=t.get(),a=i+n*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(i,a)).buffer,s=new Float32Array(o);return t.set(a),r?Xp(s,r,0):s}(e,t,i.numValues,a);return new Tm(n.name,o,r)}(t,n,a,s);case 8:return function(e,t,n,r){let i=Jp(e,t),a=Fm(r)?r:void 0,o=function(e,t,n,r){let i=t.get(),a=i+n*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(i,a)).buffer,s=new Float64Array(o);return t.set(a),r?Xp(s,r,0):s}(e,t,i.numValues,a);return new sp(n.name,o,r)}(t,n,a,s);default:throw Error(`The specified data type for the field is currently not supported: ${i}`)}}(r,e,t,i,n.scalarType,n):r===0?null:function(e,t,n,r){let i=null,a=null,o=null,s=null,c=!1;for(;!c;){let n=Jp(e,t);switch(n.physicalStreamType){case Bp.LENGTH:Up.DICTIONARY===n.logicalStreamType.lengthType?i=$p(e,t,n):o=$p(e,t,n);break;case Bp.DATA:Vp.SINGLE===n.logicalStreamType.dictionaryType||Vp.SHARED===n.logicalStreamType.dictionaryType?(a=e.subarray(t.get(),t.get()+n.byteLength),c=!0):s=e.subarray(t.get(),t.get()+n.byteLength),t.add(n.byteLength)}}let l=n.complexType.children,u=[],d=0;for(let c of l){let l=Dp(e,t,1)[0];if(l===0)continue;let f=c.name?`${n.name}${c.name}`:n.name;if(l!==2||c.type!==`scalarField`||c.scalarField.physicalType!==9)throw Error(`Currently only optional string fields are implemented for a struct.`);let p=Jp(e,t),m=Dm(e,p.numValues,p.byteLength,t),h=Jp(e,t),g=Qp(e,t,h,0,h.decompressedCount===r?void 0:new Yp(m,p.numValues));u[d++]=s?new Nm(f,g,i,a,o,s,new Yp(m,p.numValues)):new Mm(f,g,i,a,new Yp(m,p.numValues))}return u}(e,t,n,i)}function Fm(e){return e instanceof Yp}function Im(e){switch(e){case 0:case 1:case 2:case 3:{let t={};t.nullable=!!(1&e),t.columnScope=0;let n={type:`logicalType`,logicalType:0};return n.longID=!!(2&e),t.scalarType=n,t.type=`scalarType`,t}case 4:{let e={nullable:!1,columnScope:0};return e.type=`complexType`,e.complexType={type:`physicalType`,physicalType:0},e}case 30:{let e={nullable:!1,columnScope:0};return e.type=`complexType`,e.complexType={type:`physicalType`,physicalType:1},e}default:return function(e){let t;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}let n={};n.nullable=!!(1&e),n.columnScope=0;let r={type:`physicalType`};return r.physicalType=t,n.type=`scalarType`,n.scalarType=r,n}(e)}}function Lm(e){return e>=10}function Rm(e){return e===30}function zm(e){if(e.type===`scalarType`){let t=e.scalarType;if(t.type===`physicalType`)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if(t.type===`logicalType`)return!1}else if(e.type===`complexType`){let t=e.complexType;if(t.type===`physicalType`)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn(`Unexpected column type in hasStreamCount`,e),!1}function Bm(e){return e.type===`complexType`&&e.complexType?.type===`physicalType`&&e.complexType.physicalType===0}let Vm=new TextDecoder;function G(e,t){let n=Dp(e,t,1)[0];if(n===0)return``;let r=t.get(),i=e.subarray(r,r+n);return t.add(n),Vm.decode(i)}function Hm(e,t){let n=Dp(e,t,1)[0]>>>0;if(n<10||n>30)throw Error(`Unsupported field type code ${n}. Supported: 10-29(scalars), 30(STRUCT)`);let r=Im(n);if(Lm(n)&&(r.name=G(e,t)),Rm(n)){let n=Dp(e,t,1)[0]>>>0;r.complexType.children=Array(n);for(let i=0;i<n;i++)r.complexType.children[i]=Hm(e,t)}return function(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:e.type===`scalarType`?`scalarField`:`complexField`}}(r)}function Um(e,t){let n=Dp(e,t,1)[0]>>>0,r=Im(n);if(!r)throw Error(`Unsupported column type code ${n}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Lm(n)?r.name=G(e,t):n>=0&&n<=3?r.name=`id`:n===4&&(r.name=`geometry`),Rm(n)){let n=Dp(e,t,1)[0]>>>0,i=r.complexType;i.children=Array(n);for(let r=0;r<n;r++)i.children[r]=Hm(e,t)}return r}function Wm(e,t){let n={featureTables:[]},r={};r.name=G(e,t);let i=Dp(e,t,1)[0]>>>0,a=Dp(e,t,1)[0]>>>0;r.columns=Array(a);for(let n=0;n<a;n++)r.columns[n]=Um(e,t);return n.featureTables.push(r),[n,i]}function Gm(e,t,n,r,i,a,o=!1){let s=t.scalarType;if(!s||s.type!==`logicalType`||s.logicalType!==0)throw Error(`ID column must be a logical ID scalar type: ${r}`);let c=s.longID?6:4,l=typeof a==`number`?void 0:a,u=om(i,a,e,n,c===6?`int64`:`int32`);if(c===4)switch(u){case Wp.FLAT:return new op(r,Qp(e,n,i,0,l),a);case Wp.SEQUENCE:{let t=nm(e,n,i);return new lp(r,t[0],t[1],i.numRleValues)}case Wp.CONST:return new up(r,tm(e,n,i),a,!1)}switch(u){case Wp.FLAT:return o?new sp(r,function(e,t,n){return function(e,t){switch(t.logicalLevelTechnique1){case pp.DELTA:return t.logicalLevelTechnique2===pp.RLE&&(e=Ip(e,t.runs,t.numRleValues)),function(e){e[0]=Np(e[0]);let t=e.length/4*4,n=1;if(t>=4)for(;n<t-4;n+=4){let t=e[n+1],r=e[n+2],i=e[n+3];e[n]=Np(e[n])+e[n-1],e[n+1]=Np(t)+e[n],e[n+2]=Np(r)+e[n+1],e[n+3]=Np(i)+e[n+2]}for(;n!==e.length;++n)e[n]=Np(e[n])+e[n-1]}(e),e;case pp.RLE:return function(e,t){return Ip(e,t.runs,t.numRleValues)}(e,t);case pp.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}(function(e,t,n){let r=new Float64Array(n);for(let i=0;i<n;i++)r[i]=Ap(e,t);return r}(e,t,n.numValues),n)}(e,n,i),a):new sm(r,im(e,n,i,l),a);case Wp.SEQUENCE:{let t=rm(e,n,i);return new cm(r,t[0],t[1],i.numRleValues)}case Wp.CONST:return new Em(r,am(e,n,i),a,!1)}throw Error(`Vector type not supported for id column.`)}class Km{constructor(e,t){switch(this._featureData=e,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Gp.POINT:case Gp.MULTIPOINT:this.type=1;break;case Gp.LINESTRING:case Gp.MULTILINESTRING:this.type=2;break;case Gp.POLYGON:case Gp.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let r=[];for(let e of t)r.push(new n(e.x,e.y));e.push(r)}return e}}class qm{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new Km(this.features[e],this.extent)}}class Jm{constructor(e){this.layers={};let t=function(e,t,n=!0){let r=new fp(0),i=[];for(;r.get()<e.length;){let t=Dp(e,r,1)[0]>>>0,o=r.get()+t;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);if(Dp(e,r,1)[0]>>>0!=1){r.set(o);continue}let[s,c]=Wm(e,r),l=s.featureTables[0],u=null,d=null,f=[],p=0;for(let t of l.columns){let i=t.name;if((a=t).type===`scalarType`&&a.scalarType?.type===`logicalType`&&a.scalarType.logicalType===0){let a=null;if(t.nullable){let t=Jp(e,r),n=r.get(),i=Dm(e,t.numValues,t.byteLength,r);r.set(n+t.byteLength),a=new Yp(i,t.numValues)}let o=Jp(e,r);p=a?a.size():o.decompressedCount,u=Gm(e,t,r,i,o,a??p,n)}else if(Bm(t)){let t=Dp(e,r,1)[0];if(p===0){let t=r.get();p=Jp(e,r).decompressedCount,r.set(t)}d=xm(e,t,r,p)}else{let n=zm(t)?Dp(e,r,1)[0]:1;if(n===0)continue;let i=Pm(e,r,t,n,p);if(i)if(Array.isArray(i))for(let e of i)f.push(e);else f.push(i)}}let m=new dp(l.name,d,u,f,c);i.push(m),r.set(o)}var a;return i}(new Uint8Array(e));this.layers=t.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new qm(t)})),{})}}class Ym{constructor(e,t){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=t,`id`in e&&(typeof e.id==`string`?this.id=parseInt(e.id,10):typeof e.id!=`number`||isNaN(e.id)||(this.id=e.id))}loadGeometry(){let e=[],t=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(let r of t){let t=[];for(let e of r)t.push(new n(e[0],e[1]));e.push(t)}return e}}let Xm=`_geojsonTileLayer`;function Zm(e,t,n=``){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||``),t.writeVarintField(5,e.extent||4096);let r={jsonPrefix:n,keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n<e.length;n++)r.feature=e.feature(n),t.writeMessage(2,Qm,r);let i=r.keys;for(let e of i)t.writeStringField(3,e);let a=r.values;for(let e of a)t.writeMessage(4,rh,e)}function Qm(e,t){if(!e.feature)return;let n=e.feature;n.id!==void 0&&t.writeVarintField(1,n.id),t.writeMessage(2,$m,e),t.writeVarintField(3,n.type),t.writeMessage(4,nh,n)}function $m(e,t){for(let n in e.feature?.properties){let r=e.feature.properties[n],i=e.keycache[n];if(r==null)continue;i===void 0&&(e.keys.push(n),i=e.keys.length-1,e.keycache[n]=i),t.writeVarint(i),typeof r!=`string`&&typeof r!=`boolean`&&typeof r!=`number`&&(r=e.jsonPrefix+JSON.stringify(r));let a=typeof r+`:`+r,o=e.valuecache[a];o===void 0&&(e.values.push(r),o=e.values.length-1,e.valuecache[a]=o),t.writeVarint(o)}}function eh(e,t){return(t<<3)+(7&e)}function th(e){return e<<1^e>>31}function nh(e,t){let n=e.loadGeometry(),r=e.type,i=0,a=0;for(let o of n){let n=1;r===1&&(n=o.length),t.writeVarint(eh(1,n));let s=r===3?o.length-1:o.length;for(let e=0;e<s;e++){e===1&&r!==1&&t.writeVarint(eh(2,s-1));let n=o[e].x-i,c=o[e].y-a;t.writeVarint(th(n)),t.writeVarint(th(c)),i+=n,a+=c}e.type===3&&t.writeVarint(eh(7,1))}}function rh(e,t){let n=typeof e;n===`string`?t.writeStringField(1,e):n===`boolean`?t.writeBooleanField(7,e):n===`number`&&(e%1==0?e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e):t.writeDoubleField(3,e))}class ih{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ya(O,16,0),this.grid3D=new ya(O,16,0),this.featureIndexArray=new Zo,this.promoteId=t}insert(e,t,n,r,i,a){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i);let s=a?this.grid3D:this.grid;for(let e of t){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)t[0]=Math.min(t[0],n.x),t[1]=Math.min(t[1],n.y),t[2]=Math.max(t[2],n.x),t[3]=Math.max(t[3],n.y);t[0]<O&&t[1]<O&&t[2]>=0&&t[3]>=0&&s.insert(o,t[0],t[1],t[2],t[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding===`mlt`?new Jm(this.rawTileData).layers:new Wl(new Vd(this.rawTileData)).layers,this.sourceLayerCoder=new np(this.vtLayers?Object.keys(this.vtLayers).sort():[Xm])),this.vtLayers}query(e,t,r,i){this.loadVTLayers();let a=e.params,o=O/e.tileSize/e.scale,s=Si(a.filter,a.globalState),c=e.queryGeometry,l=e.queryPadding*o,u=tp.fromPoints(c),d=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),f=tp.fromPoints(e.cameraQueryGeometry).expandBy(l),p=this.grid3D.query(f.minX,f.minY,f.maxX,f.maxY,((t,r,i,a)=>function(e,t,r,i,a){for(let n of e)if(t<=n.x&&r<=n.y&&i>=n.x&&a>=n.y)return!0;let o=[new n(t,r),new n(t,a),new n(i,a),new n(i,r)];if(e.length>2){for(let t of o)if(cc(e,t))return!0}for(let t=0;t<e.length-1;t++)if(lc(e[t],e[t+1],o))return!0;return!1}(e.cameraQueryGeometry,t-l,r-l,i+l,a+l)));for(let e of p)d.push(e);d.sort(oh);let m={},h;for(let n of d){if(n===h)continue;h=n;let l=this.featureIndexArray.get(n),u=null;this.loadMatchingFeature(m,l.bucketIndex,l.sourceLayerIndex,l.featureIndex,s,a.layers,a.availableImages,t,r,i,((t,n,r)=>(u||=Js(t),n.queryIntersectsFeature({queryGeometry:c,feature:t,featureState:r,geometry:u,zoom:this.z,transform:e.transform,pixelsToTileUnits:o,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return m}loadMatchingFeature(e,t,n,r,i,a,o,s,c,l,u){let d=this.bucketLayerIDs[t];if(a&&!d.some((e=>a.has(e))))return;let f=this.sourceLayerCoder.decode(n),p=this.vtLayers[f].feature(r);if(i.needGeometry){let e=Ys(p,!0);if(!i.filter(new Va(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new Va(this.tileID.overscaledZ),p))return;let m=this.getId(p,f);for(let t of d){if(a&&!a.has(t))continue;let n=s[t];if(!n)continue;let i={};m&&l&&(i=l.getState(n.sourceLayer||Xm,m));let d=L({},c[t]);d.paint=ah(d.paint,n.paint,p,i,o),d.layout=ah(d.layout,n.layout,p,i,o);let f=!u||u(p,n,i);if(!f)continue;let h=new rp(p,this.z,this.x,this.y,m);h.layer=d;let g=e[t];g===void 0&&(g=e[t]=[]),g.push({featureIndex:r,feature:h,intersectionZ:f})}}lookupSymbolFeatures(e,t,n,r,i,a,o,s){let c={};this.loadVTLayers();let l=Si(i.filterSpec,i.globalState);for(let i of e)this.loadMatchingFeature(c,n,r,i,l,a,o,s,t);return c}hasLayer(e){for(let t of this.bucketLayerIDs)for(let n of t)if(e===n)return!0;return!1}getId(e,t){var n;let r=e.id;return this.promoteId&&(r=e.properties[typeof this.promoteId==`string`?this.promoteId:this.promoteId[t]],typeof r==`boolean`&&(r=Number(r)),r===void 0&&(n=e.properties)!=null&&n.cluster&&this.promoteId&&(r=Number(e.properties.cluster_id))),r}}function ah(e,t,n,r,i){return ne(e,((e,a)=>{let o=t instanceof Za?t.get(a):null;return o?.evaluate?o.evaluate(n,r,i):o}))}function oh(e,t){return t-e}function sh(e,t,r,i,a){let o=[];for(let s of e){let e;for(let c=0;c<s.length-1;c++){let l=s[c],u=s[c+1];l.x<t&&u.x<t||(l.x<t?l=new n(t,l.y+(t-l.x)/(u.x-l.x)*(u.y-l.y))._round():u.x<t&&(u=new n(t,l.y+(t-l.x)/(u.x-l.x)*(u.y-l.y))._round()),l.y<r&&u.y<r||(l.y<r?l=new n(l.x+(r-l.y)/(u.y-l.y)*(u.x-l.x),r)._round():u.y<r&&(u=new n(l.x+(r-l.y)/(u.y-l.y)*(u.x-l.x),r)._round()),l.x>=i&&u.x>=i||(l.x>=i?l=new n(i,l.y+(i-l.x)/(u.x-l.x)*(u.y-l.y))._round():u.x>=i&&(u=new n(i,l.y+(i-l.x)/(u.x-l.x)*(u.y-l.y))._round()),l.y>=a&&u.y>=a||(l.y>=a?l=new n(l.x+(a-l.y)/(u.y-l.y)*(u.x-l.x),a)._round():u.y>=a&&(u=new n(l.x+(a-l.y)/(u.y-l.y)*(u.x-l.x),a)._round()),e&&l.equals(e[e.length-1])||(e=[l],o.push(e)),e.push(u)))))}}return o}function ch(e,t,n,r,i){switch(t){case 1:return function(e,t,n,r){let i=[];for(let a of e)for(let e of a){let a=r===0?e.x:e.y;a>=t&&a<=n&&i.push([e])}return i}(e,n,r,i);case 2:return uh(e,n,r,i,!1);case 3:return uh(e,n,r,i,!0)}return[]}function lh(e,t,r,i,a){let o=i===0?dh:fh,s=[],c=[];for(let n=0;n<e.length-1;n++){let l=e[n],u=e[n+1],d=i===0?l.x:l.y,f=i===0?u.x:u.y,p=!1;d<t?f>t&&s.push(o(l,u,t)):d>r?f<r&&s.push(o(l,u,r)):s.push(l),f<t&&d>=t&&(s.push(o(l,u,t)),p=!0),f>r&&d<=r&&(s.push(o(l,u,r)),p=!0),!a&&p&&(c.push(s),s=[])}let l=e.length-1,u=i===0?e[l].x:e[l].y;return u>=t&&u<=r&&s.push(e[l]),a&&s.length>0&&!s[0].equals(s[s.length-1])&&s.push(new n(s[0].x,s[0].y)),s.length>0&&c.push(s),c}function uh(e,t,n,r,i){let a=[];for(let o of e){let e=lh(o,t,n,r,i);e.length>0&&a.push(...e)}return a}function dh(e,t,r){return new n(r,e.y+(r-e.x)/(t.x-e.x)*(t.y-e.y))}function fh(e,t,r){return new n(e.x+(r-e.y)/(t.y-e.y)*(t.x-e.x),r)}W(`FeatureIndex`,ih,{omit:[`rawTileData`,`sourceLayerCoder`]});class ph extends n{constructor(e,t,n,r){super(e,t),this.angle=n,r!==void 0&&(this.segment=r)}clone(){return new ph(this.x,this.y,this.angle,this.segment)}}function mh(e,t,n,r,i){if(t.segment===void 0||n===0)return!0;let a=t,o=t.segment+1,s=0;for(;s>-n/2;){if(o--,o<0)return!1;s-=e[o].dist(a),a=e[o]}s+=e[o].dist(e[o+1]),o++;let c=[],l=0;for(;s<n/2;){let t=e[o],n=e[o+1];if(!n)return!1;let a=e[o-1].angleTo(t)-t.angleTo(n);for(a=Math.abs((a+3*Math.PI)%(2*Math.PI)-Math.PI),c.push({distance:s,angleDelta:a}),l+=a;s-c[0].distance>r;)l-=c.shift().angleDelta;if(l>i)return!1;o++,s+=t.dist(n)}return!0}function hh(e){let t=0;for(let n=0;n<e.length-1;n++)t+=e[n].dist(e[n+1]);return t}function gh(e,t,n){return e?.6*t*n:0}function _h(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function vh(e,t,n,r,i,a){let o=gh(n,i,a),s=_h(n,r)*a,c=0,l=hh(e)/2;for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1],a=r.dist(i);if(c+a>l){let u=(l-c)/a,d=new ph(Tn.number(r.x,i.x,u),Tn.number(r.y,i.y,u),i.angleTo(r),n);return d._round(),!o||mh(e,d,s,o,t)?d:void 0}c+=a}}function yh(e,t,n,r,i,a,o,s,c){let l=gh(r,a,o),u=_h(r,i),d=u*o,f=e[0].x===0||e[0].x===c||e[0].y===0||e[0].y===c;return t-d<t/4&&(t=d+t/4),K(e,f?t/2*s%t:(u/2+2*a)*o*s%t,t,l,n,d,f,!1,c)}function K(e,t,n,r,i,a,o,s,c){let l=a/2,u=hh(e),d=0,f=t-n,p=[];for(let t=0;t<e.length-1;t++){let o=e[t],s=e[t+1],m=o.dist(s),h=s.angleTo(o);for(;f+n<d+m;){f+=n;let g=(f-d)/m,_=Tn.number(o.x,s.x,g),v=Tn.number(o.y,s.y,g);if(_>=0&&_<c&&v>=0&&v<c&&f-l>=0&&f+l<=u){let n=new ph(_,v,h,t);n._round(),r&&!mh(e,n,a,r,i)||p.push(n)}}d+=m}return s||p.length||o||(p=K(e,d/2,n,r,i,a,o,!0,c)),p}function bh(e,t,r,i){let a=[],o=e.image,s=o.pixelRatio,c=o.paddedRect.w-2,l=o.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},d=o.stretchX||[[0,c]],f=o.stretchY||[[0,l]],p=(e,t)=>e+t[1]-t[0],m=d.reduce(p,0),h=f.reduce(p,0),g=c-m,_=l-h,v=0,y=m,b=0,x=h,S=0,C=g,w=0,T=_;if(o.content&&i){let t=o.content,n=t[2]-t[0],r=t[3]-t[1];(o.textFitWidth||o.textFitHeight)&&(u=gf(e)),v=xh(d,0,t[0]),b=xh(f,0,t[1]),y=xh(d,t[0],t[2]),x=xh(f,t[1],t[3]),S=t[0]-v,w=t[1]-b,C=n-y,T=r-x}let E=u.x1,D=u.y1,O=u.x2-E,k=u.y2-D,A=(e,i,a,c)=>{let l=Ch(e.stretch-v,y,O,E),u=wh(e.fixed-S,C,e.stretch,m),d=Ch(i.stretch-b,x,k,D),f=wh(i.fixed-w,T,i.stretch,h),p=Ch(a.stretch-v,y,O,E),g=wh(a.fixed-S,C,a.stretch,m),_=Ch(c.stretch-b,x,k,D),A=wh(c.fixed-w,T,c.stretch,h),j=new n(l,d),M=new n(p,d),N=new n(p,_),P=new n(l,_),F=new n(u/s,f/s),ee=new n(g/s,A/s),I=t*Math.PI/180;if(I){let e=Math.sin(I),t=Math.cos(I),n=[t,-e,e,t];j._matMult(n),M._matMult(n),P._matMult(n),N._matMult(n)}let L=e.stretch+e.fixed,te=i.stretch+i.fixed;return{tl:j,tr:M,bl:P,br:N,tex:{x:o.paddedRect.x+1+L,y:o.paddedRect.y+1+te,w:a.stretch+a.fixed-L,h:c.stretch+c.fixed-te},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:ee,minFontScaleX:C/s/O,minFontScaleY:T/s/k,isSDF:r}};if(i&&(o.stretchX||o.stretchY)){let e=Sh(d,g,m),t=Sh(f,_,h);for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];for(let e=0;e<t.length-1;e++)a.push(A(r,t[e],i,t[e+1]))}}else a.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:c+1},{fixed:0,stretch:l+1}));return a}function xh(e,t,n){let r=0;for(let i of e)r+=Math.max(t,Math.min(n,i[1]))-Math.max(t,Math.min(n,i[0]));return r}function Sh(e,t,n){let r=[{fixed:-1,stretch:0}];for(let[t,n]of e){let e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(n-t)})}return r.push({fixed:t+1,stretch:n}),r}function Ch(e,t,n,r){return e/t*n+r}function wh(e,t,n,r){return e-t*n/r}W(`Anchor`,ph);class Th{constructor(e,t,r,i,a,o,s,c,l,u){if(this.boxStartIndex=e.length,l){let e=o.top,t=o.bottom,n=o.collisionPadding;n&&(e-=n[1],t+=n[3]);let r=t-e;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let l=o.image?.content&&(o.image.textFitWidth||o.image.textFitHeight)?gf(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};l.y1=l.y1*s-c[0],l.y2=l.y2*s+c[2],l.x1=l.x1*s-c[3],l.x2=l.x2*s+c[1];let d=o.collisionPadding;if(d&&(l.x1-=d[0]*s,l.y1-=d[1]*s,l.x2+=d[2]*s,l.y2+=d[3]*s),u){let e=new n(l.x1,l.y1),t=new n(l.x2,l.y1),r=new n(l.x1,l.y2),i=new n(l.x2,l.y2),a=u*Math.PI/180;e._rotate(a),t._rotate(a),r._rotate(a),i._rotate(a),l.x1=Math.min(e.x,t.x,r.x,i.x),l.x2=Math.max(e.x,t.x,r.x,i.x),l.y1=Math.min(e.y,t.y,r.y,i.y),l.y2=Math.max(e.y,t.y,r.y,i.y)}e.emplaceBack(t.x,t.y,l.x1,l.y1,l.x2,l.y2,r,i,a)}this.boxEndIndex=e.length}}class q{constructor(e=[],t=(e,t)=>e<t?-1:+(e>t)){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._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=1+(e<<1),a=r+1;if(a<this.length&&n(t[a],t[r])<0&&(r=a),n(t[r],i)>=0)break;t[e]=t[r],e=r}t[e]=i}}function Eh(e,t=1){let r=tp.fromPoints(e[0]),i=Math.min(r.width(),r.height()),a=i/2,o=new q([],Dh),{minX:s,minY:c,maxX:l,maxY:u}=r;if(i===0)return new n(s,c);for(let t=s;t<l;t+=i)for(let n=c;n<u;n+=i)o.push(new Oh(t+a,n+a,a,e));let d=function(e){let t=0,n=0,r=0,i=e[0];for(let e=0,a=i.length,o=a-1;e<a;o=e++){let a=i[e],s=i[o],c=a.x*s.y-s.x*a.y;n+=(a.x+s.x)*c,r+=(a.y+s.y)*c,t+=3*c}return new Oh(n/t,r/t,0,e)}(e),f=d;for(;o.length;){let n=o.pop();(n.d>f.d||!f.d)&&(f=n),n.max-f.d<=t||(a=n.h/2,o.push(new Oh(n.p.x-a,n.p.y-a,a,e)),o.push(new Oh(n.p.x+a,n.p.y-a,a,e)),o.push(new Oh(n.p.x-a,n.p.y+a,a,e)),o.push(new Oh(n.p.x+a,n.p.y+a,a,e)))}return d.d>0&&f.d-d.d<=t?d.p:f.p}function Dh(e,t){return t.max-e.max}class Oh{constructor(e,t,r,i){this.p=new n(e,t),this.h=r,this.d=function(e,t){let n=!1,r=1/0;for(let i of t)for(let t=0,a=i.length,o=a-1;t<a;o=t++){let a=i[t],s=i[o];a.y>e.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(n=!n),r=Math.min(r,oc(e,a,s))}return(n?1:-1)*Math.sqrt(r)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}}var kh;e.aM=void 0,(kh=e.aM||={})[kh.center=1]=`center`,kh[kh.left=2]=`left`,kh[kh.right=3]=`right`,kh[kh.top=4]=`top`,kh[kh.bottom=5]=`bottom`,kh[kh[`top-left`]=6]=`top-left`,kh[kh[`top-right`]=7]=`top-right`,kh[kh[`bottom-left`]=8]=`bottom-left`,kh[kh[`bottom-right`]=9]=`bottom-right`;let J=1/0;function Ah(e,t){return t[1]===J?function(e,t){let n=0,r=0;t<0&&(t=0);let i=t/Math.SQRT2;switch(e){case`top-right`:case`top-left`:r=i-7;break;case`bottom-right`:case`bottom-left`:r=7-i;break;case`bottom`:r=7-t;break;case`top`:r=t-7}switch(e){case`top-right`:case`bottom-right`:n=-i;break;case`top-left`:case`bottom-left`:n=i;break;case`left`:n=t;break;case`right`:n=-t}return[n,r]}(e,t[0]):function(e,t,n){let r=0,i=0;switch(t=Math.abs(t),n=Math.abs(n),e){case`top-right`:case`top-left`:case`top`:i=n-7;break;case`bottom-right`:case`bottom-left`:case`bottom`:i=7-n}switch(e){case`top-right`:case`bottom-right`:case`right`:r=-t;break;case`top-left`:case`bottom-left`:case`left`:r=t}return[r,i]}(e,t[0],t[1])}function jh(e,t,n){let r=e.layout,i=r.get(`text-variable-anchor-offset`)?.evaluate(t,{},n);if(i){let e=i.values,t=[];for(let n=0;n<e.length;n+=2){let r=t[n]=e[n],i=e[n+1].map((e=>e*Od));r.startsWith(`top`)?i[1]-=7:r.startsWith(`bottom`)&&(i[1]+=7),t[n+1]=i}return new qt(t)}let a=r.get(`text-variable-anchor`);if(a){let i;i=e._unevaluatedLayout.getValue(`text-radial-offset`)===void 0?r.get(`text-offset`).evaluate(t,{},n).map((e=>e*Od)):[r.get(`text-radial-offset`).evaluate(t,{},n)*Od,J];let o=[];for(let e of a)o.push(e,Ah(e,i));return new qt(o)}return null}function Mh(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 Nh(t,n,r,i,a,o,s,c,l,u,d,f){let p=o.textMaxSize.evaluate(n,{});p===void 0&&(p=s);let m=t.layers[0].layout,h=m.get(`icon-offset`).evaluate(n,{},d),g=Fh(r.horizontal),_=s/24,v=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,b=t.tilePixelRatio*c,x=t.tilePixelRatio*m.get(`symbol-spacing`),S=m.get(`text-padding`)*t.tilePixelRatio,C=function(e,t,n,r=1){let i=e.get(`icon-padding`).evaluate(t,{},n)?.values;return[i[0]*r,i[1]*r,i[2]*r,i[3]*r]}(m,n,d,t.tilePixelRatio),w=m.get(`text-max-angle`)/180*Math.PI,T=m.get(`text-rotation-alignment`)!==`viewport`&&m.get(`symbol-placement`)!==`point`,E=m.get(`icon-rotation-alignment`)===`map`&&m.get(`symbol-placement`)!==`point`,D=m.get(`symbol-placement`),k=x/2,A=m.get(`icon-text-fit`),j;i&&A!==`none`&&(t.allowVerticalPlacement&&r.vertical&&(j=_f(i,r.vertical,A,m.get(`icon-text-fit-padding`),h,_)),g&&(i=_f(i,g,A,m.get(`icon-text-fit-padding`),h,_)));let M=d?f.line.getGranularityForZoomLevel(d.z):1,N=(c,f)=>{f.x<0||f.x>=O||f.y<0||f.y>=O||function(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T){let E=t.addToLineVertexArray(n,r),D,O,k,A,j=0,M=0,N=0,P=0,F=-1,ee=-1,I={},L=ws(``);if(t.allowVerticalPlacement&&i.vertical){let e=c.layout.get(`text-rotate`).evaluate(x,{},w)+90;k=new Th(l,n,u,d,f,i.vertical,p,m,h,e),s&&(A=new Th(l,n,u,d,f,s,_,v,h,e))}if(a){let r=c.layout.get(`icon-rotate`).evaluate(x,{}),i=c.layout.get(`icon-text-fit`)!==`none`,o=bh(a,r,C,i),p=s?bh(s,r,C,i):void 0;O=new Th(l,n,u,d,f,a,_,v,!1,r),j=4*o.length;let m=t.iconSizeData,h=null;m.kind===`source`?(h=[128*c.layout.get(`icon-size`).evaluate(x,{})],h[0]>vf&&ae(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):m.kind===`composite`&&(h=[128*S.compositeIconSizes[0].evaluate(x,{},w),128*S.compositeIconSizes[1].evaluate(x,{},w)],(h[0]>vf||h[1]>vf)&&ae(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,o,h,b,y,x,e.ax.none,n,E.lineStartIndex,E.lineLength,-1,w),F=t.icon.placedSymbolArray.length-1,p&&(M=4*p.length,t.addSymbols(t.icon,p,h,b,y,x,e.ax.vertical,n,E.lineStartIndex,E.lineLength,-1,w),ee=t.icon.placedSymbolArray.length-1)}let te=Object.keys(i.horizontal);for(let r of te){let a=i.horizontal[r];D||=(L=ws(a.text),new Th(l,n,u,d,f,a,p,m,h,c.layout.get(`text-rotate`).evaluate(x,{},w)));let s=a.positionedLines.length===1;if(N+=Ph(t,n,a,o,c,h,x,g,E,i.vertical?e.ax.horizontal:e.ax.horizontalOnly,s?te:[r],I,F,S,w),s)break}i.vertical&&(P+=Ph(t,n,i.vertical,o,c,h,x,g,E,e.ax.vertical,[`vertical`],I,ee,S,w));let ne=D?D.boxStartIndex:t.collisionBoxArray.length,R=D?D.boxEndIndex:t.collisionBoxArray.length,re=k?k.boxStartIndex:t.collisionBoxArray.length,ie=k?k.boxEndIndex:t.collisionBoxArray.length,oe=O?O.boxStartIndex:t.collisionBoxArray.length,se=O?O.boxEndIndex:t.collisionBoxArray.length,ce=A?A.boxStartIndex:t.collisionBoxArray.length,le=A?A.boxEndIndex:t.collisionBoxArray.length,ue=-1,de=(e,t)=>e?.circleDiameter?Math.max(e.circleDiameter,t):t;ue=de(D,ue),ue=de(k,ue),ue=de(O,ue),ue=de(A,ue);let fe=+(ue>-1);fe&&(ue*=T/Od),t.glyphOffsetArray.length>=Df.MAX_GLYPHS&&ae(`Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907`),x.sortKey!==void 0&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);let pe=jh(c,x,w),[me,he]=function(t,n){let r=t.length,i=n?.values;if(i?.length>0)for(let n=0;n<i.length;n+=2){let r=i[n+1];t.emplaceBack(e.aM[i[n]],r[0],r[1])}return[r,t.length]}(t.textAnchorOffsets,pe);t.symbolInstances.emplaceBack(n.x,n.y,I.right>=0?I.right:-1,I.center>=0?I.center:-1,I.left>=0?I.left:-1,I.vertical||-1,F,ee,L,ne,R,re,ie,oe,se,ce,le,u,N,P,j,M,fe,0,p,ue,me,he)}(t,f,c,r,i,a,j,t.layers[0],t.collisionBoxArray,n.index,n.sourceLayerIndex,t.index,v,[S,S,S,S],T,l,b,C,E,h,n,o,u,d,s)};if(D===`line`)for(let e of sh(n.geometry,0,0,O,O)){let n=El(e,M),a=yh(n,x,w,r.vertical||g,i,24,y,t.overscaling,O);for(let e of a)g&&Ih(t,g.text,k,e)||N(n,e)}else if(D===`line-center`){for(let e of n.geometry)if(e.length>1){let t=El(e,M),n=vh(t,w,r.vertical||g,i,24,y);n&&N(t,n)}}else if(n.type===`Polygon`)for(let e of ur(n.geometry,0)){let t=Eh(e,16);N(El(e[0],M,!0),new ph(t.x,t.y,0))}else if(n.type===`LineString`)for(let e of n.geometry){let t=El(e,M);N(t,new ph(t[0].x,t[0].y,0))}else if(n.type===`Point`)for(let e of n.geometry)for(let t of e)N([t],new ph(t.x,t.y,0))}function Ph(e,t,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=function(e,t,r,i,a,o,s,c){let l=i.layout.get(`text-rotate`).evaluate(o,{})*Math.PI/180,u=[];for(let e of t.positionedLines)for(let i of e.positionedGlyphs){if(!i.rect)continue;let o=i.rect||{},d=4,f=!0,p=1,m=0,h=(a||c)&&i.vertical,g=i.metrics.advance*i.scale/2;if(c&&t.verticalizable&&(m=e.lineOffset/2-(i.imageName?-(Od-i.metrics.width*i.scale)/2:(i.scale-1)*Od)),i.imageName){let e=s[i.imageName];f=e.sdf,p=e.pixelRatio,d=1/p}let _=a?[i.x+g,i.y]:[0,0],v=a?[0,0]:[i.x+g+r[0],i.y+r[1]-m],y=[0,0];h&&(y=v,v=[0,0]);let b=i.metrics.isDoubleResolution?2:1,x=(i.metrics.left-d)*i.scale-g+v[0],S=(-i.metrics.top-d)*i.scale+v[1],C=x+o.w/b*i.scale/p,w=S+o.h/b*i.scale/p,T=new n(x,S),E=new n(C,S),D=new n(x,w),O=new n(C,w);if(h){let e=new n(-g,g- -17),t=-Math.PI/2,r=12-g,a=new n(22-r,-(i.imageName?r:0)),o=new n(...y);T._rotateAround(t,e)._add(a)._add(o),E._rotateAround(t,e)._add(a)._add(o),D._rotateAround(t,e)._add(a)._add(o),O._rotateAround(t,e)._add(a)._add(o)}if(l){let e=Math.sin(l),t=Math.cos(l),n=[t,-e,e,t];T._matMult(n),E._matMult(n),D._matMult(n),O._matMult(n)}let k=new n(0,0),A=new n(0,0);u.push({tl:T,tr:E,bl:D,br:O,tex:o,writingMode:t.writingMode,glyphOffset:_,sectionIndex:i.sectionIndex,isSDF:f,pixelOffsetTL:k,pixelOffsetBR:A,minFontScaleX:0,minFontScaleY:0})}return u}(0,r,c,a,o,s,i,e.allowVerticalPlacement),_=e.textSizeData,v=null;_.kind===`source`?(v=[128*a.layout.get(`text-size`).evaluate(s,{})],v[0]>vf&&ae(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):_.kind===`composite`&&(v=[128*m.compositeTextSizes[0].evaluate(s,{},h),128*m.compositeTextSizes[1].evaluate(s,{},h)],(v[0]>vf||v[1]>vf)&&ae(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,v,c,o,s,u,t,l.lineStartIndex,l.lineLength,p,h);for(let t of d)f[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function Fh(e){for(let t in e)return e[t];return null}function Ih(e,t,n,r){let i=e.compareText;if(t in i){let e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<n)return!0}else i[t]=[];return i[t].push(r),!1}e.$=xe,e.A=f,e.B=Ua,e.C=va,e.D=Qa,e.E=Pe,e.F=pa,e.G=function([e,t,n]){return t+=90,t*=Math.PI/180,n*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(n),y:e*Math.sin(t)*Math.sin(n),z:e*Math.cos(n)}},e.H=Tn,e.I=rf,e.J=Va,e.K=ha,e.L=function(e){if(ce==null){let t=e.navigator?e.navigator.userAgent:null;ce=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match(`Safari`)&&!t.match(`Chrome`)))}return ce},e.M=Te,e.N=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Lf((()=>this.process())),this.subscription=me(this.target,`message`,(e=>this.receive(e)),!1),this.globalScope=se(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise(((n,r)=>{let i=Math.round(0xde0b6b3a7640000*Math.random()).toString(36).substring(0,10),a=t?me(t.signal,`abort`,(()=>{a?.unsubscribe(),delete this.resolveRejects[i];let t={id:i,type:`<cancel>`,origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)}),Rf):null;this.resolveRejects[i]={resolve:e=>{a?.unsubscribe(),n(e)},reject:e=>{a?.unsubscribe(),r(e)}};let o=[],s=Object.assign(Object.assign({},e),{id:i,sourceMapId:this.mapId,origin:location.origin,data:wa(e.data,o)});this.target.postMessage(s,{transfer:o})}))}receive(e){let t=e.data,n=t.id,r=[`file://`,`resource://android`,`null`],i=[t.origin,location.origin],a=t.origin===location.origin,o=i.some((e=>r.includes(e)));if((a||o)&&(!t.targetMapId||this.mapId===t.targetMapId)){if(t.type===`<cancel>`){delete this.tasks[n];let e=this.abortControllers[n];delete this.abortControllers[n],e&&e.abort();return}if(se(self)||t.mustQueue)return this.tasks[n]=t,this.taskQueue.push(n),void this.invoker.trigger();this.processTask(n,t)}}process(){if(this.taskQueue.length===0)return;let e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,n){return t(this,void 0,void 0,(function*(){if(n.type===`<response>`){let t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;n.error?t.reject(A(Ta(n.error))):t.resolve(Ta(n.data));return}if(!this.messageHandlers[n.type])return void this.completeTask(e,Error(`Could not find a registered handler for ${n.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(`, `)}`));let t=Ta(n.data),r=new AbortController;this.abortControllers[e]=r;try{let i=yield this.messageHandlers[n.type](n.sourceMapId,t,r);this.completeTask(e,null,i)}catch(t){this.completeTask(e,A(t))}}))}completeTask(e,t,n){let r=[];delete this.abortControllers[e];let i={id:e,type:`<response>`,sourceMapId:this.mapId,origin:location.origin,error:t?wa(t):null,data:wa(n,r)};this.target.postMessage(i,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.O=function(){var e=new f(16);return f!=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.P=n,e.Q=function(e,t,n){var r,i,a,o,s,c,l,u,d,f,p,m,h=n[0],g=n[1],_=n[2];return t===e?(e[12]=t[0]*h+t[4]*g+t[8]*_+t[12],e[13]=t[1]*h+t[5]*g+t[9]*_+t[13],e[14]=t[2]*h+t[6]*g+t[10]*_+t[14],e[15]=t[3]*h+t[7]*g+t[11]*_+t[15]):(i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],e[0]=r=t[0],e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=c,e[6]=l,e[7]=u,e[8]=d,e[9]=f,e[10]=p,e[11]=m,e[12]=r*h+s*g+d*_+t[12],e[13]=i*h+c*g+f*_+t[13],e[14]=a*h+l*g+p*_+t[14],e[15]=o*h+u*g+m*_+t[15]),e},e.R=jc,e.S=function(e,t,n){var r=n[0],i=n[1],a=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.T=Hc,e.U=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=n[0],b=n[1],x=n[2],S=n[3];return e[0]=y*r+b*s+x*d+S*h,e[1]=y*i+b*c+x*f+S*g,e[2]=y*a+b*l+x*p+S*_,e[3]=y*o+b*u+x*m+S*v,e[4]=(y=n[4])*r+(b=n[5])*s+(x=n[6])*d+(S=n[7])*h,e[5]=y*i+b*c+x*f+S*g,e[6]=y*a+b*l+x*p+S*_,e[7]=y*o+b*u+x*m+S*v,e[8]=(y=n[8])*r+(b=n[9])*s+(x=n[10])*d+(S=n[11])*h,e[9]=y*i+b*c+x*f+S*g,e[10]=y*a+b*l+x*p+S*_,e[11]=y*o+b*u+x*m+S*v,e[12]=(y=n[12])*r+(b=n[13])*s+(x=n[14])*d+(S=n[15])*h,e[13]=y*i+b*c+x*f+S*g,e[14]=y*a+b*l+x*p+S*_,e[15]=y*o+b*u+x*m+S*v,e},e.V=function(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n},e.W=Bf,e.X=I,e.Y=Wf,e.Z=Uf,e._=t,e.a=be,e.a$=function(e){var t=new f(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.a0=l,e.a1=u,e.a2=de,e.a3=$f,e.a4=Kf,e.a5=qf,e.a6=O,e.a7=Yf,e.a8=tp,e.a9=25,e.aA=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},e.aB=function(e){return e[0]=0,e[1]=0,e},e.aC=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},e.aD=Cf,e.aE=C,e.aF=function(e,t,r,i){let a=t.y-e.y,o=t.x-e.x,s=i.y-r.y,c=i.x-r.x,l=s*o-c*a;if(l===0)return null;let u=(c*(e.y-r.y)-s*(e.x-r.x))/l;return new n(e.x+u*o,e.y+u*a)},e.aG=sh,e.aH=$s,e.aI=function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);return[t,n,r,i]},e.aJ=Od,e.aK=k,e.aL=function(e,t,n,r,i=!1){if(!n[0]&&!n[1])return[0,0];let a=i?r===`map`?-e.bearingInRadians:0:r===`viewport`?e.bearingInRadians:0;if(a){let e=Math.sin(a),t=Math.cos(a);n=[n[0]*t-n[1]*e,n[0]*e+n[1]*t]}return[i?n[0]:k(t,n[0],e.zoom),i?n[1]:k(t,n[1],e.zoom)]},e.aN=bf,e.aO=Mh,e.aP=cf,e.aQ=e=>e.type===`symbol`,e.aR=iu,e.aS=mo,e.aT=xl,e.aU=Qo,e.aV=ms,e.aW=ds,e.aX=ge,e.aY=Jf,e.aZ=y,e.a_=v,e.aa=Zf,e.ab=e=>{let t=window.document.createElement(`video`);return t.muted=!0,new Promise((n=>{t.onloadstart=()=>{n(t)};for(let n of e){let e=window.document.createElement(`source`);ke(n)||(t.crossOrigin=`Anonymous`),e.src=n,t.appendChild(e)}}))},e.ac=B,e.ad=function(){return te++},e.ae=Vo,e.af=Df,e.ag=Xm,e.ah=Si,e.ai=Ys,e.aj=rp,e.ak=function(e){let t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,n,r,i)=>{let a=r||i;return t[n]=!a||a.toLowerCase(),``})),t[`max-age`]){let e=parseInt(t[`max-age`],10);isNaN(e)?delete t[`max-age`]:t[`max-age`]=e}return t},e.al=ee,e.am=85.051129,e.an=he,e.ao=function(e){return 2**e},e.ap=m,e.aq=Gf,e.ar=function(e){return Math.log(e)/Math.LN2},e.as=function(e){var t=e[0],n=e[1];return t*t+n*n},e.at=function(e){if(!e.length)return new Set;let t=Math.max(...e.map((e=>e.canonical.z))),n=1/0,r=-1/0,i=1/0,a=-1/0,o=[];for(let s of e){let{x:e,y:c,z:l}=s.canonical,u=2**(t-l),d=e*u,f=c*u;o.push({id:s,x:d,y:f}),d<n&&(n=d),d>r&&(r=d),f<i&&(i=f),f>a&&(a=f)}let s=new Set;for(let e of o)e.x!==n&&e.x!==r&&e.y!==i&&e.y!==a||s.add(e.id);return s},e.au=function(e,t){let n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x},e.av=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,n){let r=e.wrapped().key;this.data[r]===void 0&&(this.data[r]=[]);let i={value:t,timeout:void 0};if(n!==void 0&&(i.timeout=setTimeout((()=>{this.remove(e,i)}),n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){let 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){let t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let 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;let n=e.wrapped().key,r=t===void 0?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let t=[];for(let n in this.data)for(let r of this.data[n])e(r.value)||t.push(r);for(let e of t)this.remove(e.value.tileID,e)}},e.aw=function(e,t){let n=0,r=0;if(e.kind===`constant`)r=e.layoutSize;else if(e.kind!==`source`){let{interpolationType:i,minZoom:a,maxZoom:o}=e,s=i?ee(Cn.interpolationFactor(i,t,a,o),0,1):0;e.kind===`camera`?r=Tn.number(e.minSize,e.maxSize,s):n=s}return{uSizeT:n,uSize:r}},e.ay=function(e,{uSize:t,uSizeT:n},{lowerSize:r,upperSize:i}){return e.kind===`source`?r/128:e.kind===`composite`?Tn.number(r/128,i/128,n):t},e.az=E,e.b=le,e.b$=Ms,e.b0=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e},e.b1=function(e,t){var n=t[0],r=t[1],i=t[2],a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e},e.b2=b,e.b3=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b4=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},e.b5=g,e.b6=function(e,t,n){let r=t[0]*n[0]+t[1]*n[1]+t[2]*n[2];return r===0?null:(-(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])-n[3])/r},e.b7=S,e.b8=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},e.b9=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},e.bA=T,e.bB=function(e,t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],c=t[1],l=t[2],u=i*l-a*c,d=a*s-r*l,f=r*c-i*s;return e[0]=s+o*(u+=u)+i*(f+=f)-a*(d+=d),e[1]=c+o*d+a*u-r*f,e[2]=l+o*f+r*d-i*u,e},e.bC=function(e,t,n){let r=(i=[e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2]])[0]*((u=i[8])*(o=i[4])-(s=i[5])*(l=i[7]))+i[1]*(-u*(a=i[3])+s*(c=i[6]))+i[2]*(l*a-o*c);var i,a,o,s,c,l,u;if(r===0)return null;let d=b([],[t[0],t[1],t[2]],[n[0],n[1],n[2]]),f=b([],[n[0],n[1],n[2]],[e[0],e[1],e[2]]),p=b([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),m=y([],d,-e[3]);return v(m,m,y([],f,-t[3])),v(m,m,y([],p,-n[3])),y(m,m,1/r),m},e.bD=zf,e.bE=function(){return new Float64Array(4)},e.bF=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bG=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bH=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bI=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[8],u=t[9],d=t[10],f=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]=a*i-l*r,e[1]=o*i-u*r,e[2]=s*i-d*r,e[3]=c*i-f*r,e[8]=a*r+l*i,e[9]=o*r+u*i,e[10]=s*r+d*i,e[11]=c*r+f*i,e},e.bJ=function(e,t){let n=j(e,360),r=j(t,360),i=r-n,a=r>n?i-360:i+360;return Math.abs(i)<Math.abs(a)?i:a},e.bK=function(e){return e[0]=0,e[1]=0,e[2]=0,e},e.bL=function(e,t,n,r){let i=Math.sqrt(e*e+t*t),a=Math.sqrt(n*n+r*r);e/=i,t/=i,n/=a,r/=a;let o=Math.acos(e*n+t*r);return-t*n+e*r>0?o:-o},e.bM=function(e,t){let n=j(e,2*Math.PI),r=j(t,2*Math.PI);return Math.min(Math.abs(n-r),Math.abs(n-r+2*Math.PI),Math.abs(n-r-2*Math.PI))},e.bN=function(){let e={},t=z.$version;for(let n in z.$root){let r=z.$root[n];if(r.required){let i=null;i=n===`version`?t:r.type===`array`?[]:{},i!=null&&(e[n]=i)}}return e},e.bO=De,e.bP=Ea,e.bQ=function e(t,n){if(Array.isArray(t)){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0}if(typeof t==`object`&&t&&n!==null){if(typeof n!=`object`||Object.keys(t).length!==Object.keys(n).length)return!1;for(let r in t)if(!e(t[r],n[r]))return!1;return!0}return t===n},e.bR=Se,e.bS=function(e){e=e.slice();let t=Object.create(null);for(let n=0;n<e.length;n++)t[e[n].id]=e[n];for(let n=0;n<e.length;n++)`ref`in e[n]&&(e[n]=Ie(e[n],t[e[n].ref]));return e},e.bT=function(e,t){if(e.type===`custom`)return new If(e,t);switch(e.type){case`background`:return new Ff(e,t);case`circle`:return new Cc(e,t);case`color-relief`:return new Gc(e,t);case`fill`:return new Pl(e,t);case`fill-extrusion`:return new eu(e,t);case`heatmap`:return new Fc(e,t);case`hillshade`:return new Rc(e,t);case`line`:return new yd(e,t);case`raster`:return new lo(e,t);case`symbol`:return new Mf(e,t)}},e.bU=e=>e.type===`raster`,e.bV=re,e.bW=function(e,t){if(!e)return[{command:`setStyle`,args:[t]}];let n=[];try{if(!Le(e.version,t.version))return[{command:`setStyle`,args:[t]}];Le(e.center,t.center)||n.push({command:`setCenter`,args:[t.center]}),Le(e.state,t.state)||n.push({command:`setGlobalState`,args:[t.state]}),Le(e.centerAltitude,t.centerAltitude)||n.push({command:`setCenterAltitude`,args:[t.centerAltitude]}),Le(e.zoom,t.zoom)||n.push({command:`setZoom`,args:[t.zoom]}),Le(e.bearing,t.bearing)||n.push({command:`setBearing`,args:[t.bearing]}),Le(e.pitch,t.pitch)||n.push({command:`setPitch`,args:[t.pitch]}),Le(e.roll,t.roll)||n.push({command:`setRoll`,args:[t.roll]}),Le(e.sprite,t.sprite)||n.push({command:`setSprite`,args:[t.sprite]}),Le(e.glyphs,t.glyphs)||n.push({command:`setGlyphs`,args:[t.glyphs]}),Le(e.transition,t.transition)||n.push({command:`setTransition`,args:[t.transition]}),Le(e.light,t.light)||n.push({command:`setLight`,args:[t.light]}),Le(e.terrain,t.terrain)||n.push({command:`setTerrain`,args:[t.terrain]}),Le(e.sky,t.sky)||n.push({command:`setSky`,args:[t.sky]}),Le(e.projection,t.projection)||n.push({command:`setProjection`,args:[t.projection]});let r={},i=[];(function(e,t,n,r){let i;for(i in t||={},e||={})Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)||Be(i,n,r));for(i in t)Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)?Le(e[i],t[i])||(e[i].type===`geojson`&&t[i].type===`geojson`&&He(e,t,i)?Re(n,{command:`setGeoJSONSourceData`,args:[i,t[i].data]}):Ve(i,t,n,r)):ze(i,t,n))})(e.sources,t.sources,i,r);let a=[];e.layers&&e.layers.forEach((e=>{`source`in e&&r[e.source]?n.push({command:`removeLayer`,args:[e.id]}):a.push(e)})),n=n.concat(i),function(e,t,n){t||=[];let r=(e||=[]).map(We),i=t.map(We),a=e.reduce(Ge,{}),o=t.reduce(Ge,{}),s=r.slice(),c=Object.create(null),l,u,d,f,p;for(let e=0,t=0;e<r.length;e++)l=r[e],Object.prototype.hasOwnProperty.call(o,l)?t++:(Re(n,{command:`removeLayer`,args:[l]}),s.splice(s.indexOf(l,t),1));for(let e=0,t=0;e<i.length;e++)l=i[i.length-1-e],s[s.length-1-e]!==l&&(Object.prototype.hasOwnProperty.call(a,l)?(Re(n,{command:`removeLayer`,args:[l]}),s.splice(s.lastIndexOf(l,s.length-t),1)):t++,f=s[s.length-e],Re(n,{command:`addLayer`,args:[o[l],f]}),s.splice(s.length-e,0,l),c[l]=!0);for(let e=0;e<i.length;e++)if(l=i[e],u=a[l],d=o[l],!c[l]&&!Le(u,d))if(Le(u.source,d.source)&&Le(u[`source-layer`],d[`source-layer`])&&Le(u.type,d.type)){for(p in Ue(u.layout,d.layout,n,l,null,`setLayoutProperty`),Ue(u.paint,d.paint,n,l,null,`setPaintProperty`),Le(u.filter,d.filter)||Re(n,{command:`setFilter`,args:[l,d.filter]}),Le(u.minzoom,d.minzoom)&&Le(u.maxzoom,d.maxzoom)||Re(n,{command:`setLayerZoomRange`,args:[l,d.minzoom,d.maxzoom]}),u)Object.prototype.hasOwnProperty.call(u,p)&&p!==`layout`&&p!==`paint`&&p!==`filter`&&p!==`metadata`&&p!==`minzoom`&&p!==`maxzoom`&&(p.indexOf(`paint.`)===0?Ue(u[p],d[p],n,l,p.slice(6),`setPaintProperty`):Le(u[p],d[p])||Re(n,{command:`setLayerProperty`,args:[l,p,d[p]]}));for(p in d)Object.prototype.hasOwnProperty.call(d,p)&&!Object.prototype.hasOwnProperty.call(u,p)&&p!==`layout`&&p!==`paint`&&p!==`filter`&&p!==`metadata`&&p!==`minzoom`&&p!==`maxzoom`&&(p.indexOf(`paint.`)===0?Ue(u[p],d[p],n,l,p.slice(6),`setPaintProperty`):Le(u[p],d[p])||Re(n,{command:`setLayerProperty`,args:[l,p,d[p]]}))}else Re(n,{command:`removeLayer`,args:[l]}),f=s[s.lastIndexOf(l)+1],Re(n,{command:`addLayer`,args:[d,f]})}(a,t.layers,n)}catch(e){console.warn(`Unable to compute style diff:`,e),n=[{command:`setStyle`,args:[t]}]}return n},e.bX=function(e){let t=[],n=e.id;return n===void 0&&t.push({message:`layers.${n}: missing required property "id"`}),e.render===void 0&&t.push({message:`layers.${n}: missing required method "render"`}),e.renderingMode&&e.renderingMode!==`2d`&&e.renderingMode!==`3d`&&t.push({message:`layers.${n}: property "renderingMode" must be either "2d" or "3d"`}),t},e.bY=ne,e.bZ=R,e.b_=class extends ks{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.ba=Qf,e.bb=ep,e.bc=function(e,t,n,r,i){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var o=1/(r-i);e[10]=(i+r)*o,e[14]=2*i*r*o}else e[10]=-1,e[14]=-2*r;return e},e.bd=function(e){var t=new f(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.be=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=t[5],d=t[6],f=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]=a*i+l*r,e[1]=o*i+u*r,e[2]=s*i+d*r,e[3]=c*i+f*r,e[4]=l*i-a*r,e[5]=u*i-o*r,e[6]=d*i-s*r,e[7]=f*i-c*r,e},e.bf=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=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]=a*i+l*r,e[5]=o*i+u*r,e[6]=s*i+d*r,e[7]=c*i+f*r,e[8]=l*i-a*r,e[9]=u*i-o*r,e[10]=d*i-s*r,e[11]=f*i-c*r,e},e.bg=function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=n*s-r*o,y=n*c-i*o,b=n*l-a*o,x=r*c-i*s,S=r*l-a*s,C=i*l-a*c,w=u*h-d*m,T=u*g-f*m,E=u*_-p*m,D=d*g-f*h,O=d*_-p*h,k=f*_-p*g,A=v*k-y*O+b*D+x*E-S*T+C*w;return A?(e[0]=(s*k-c*O+l*D)*(A=1/A),e[1]=(i*O-r*k-a*D)*A,e[2]=(h*C-g*S+_*x)*A,e[3]=(f*S-d*C-p*x)*A,e[4]=(c*E-o*k-l*T)*A,e[5]=(n*k-i*E+a*T)*A,e[6]=(g*b-m*C-_*y)*A,e[7]=(u*C-f*b+p*y)*A,e[8]=(o*O-s*E+l*w)*A,e[9]=(r*E-n*O-a*w)*A,e[10]=(m*S-h*b+_*v)*A,e[11]=(d*b-u*S-p*v)*A,e[12]=(s*T-o*D-c*w)*A,e[13]=(n*D-r*T+i*w)*A,e[14]=(h*y-m*x-g*v)*A,e[15]=(u*x-d*y+f*v)*A,e):null},e.bh=function(){let e=new Float32Array(16);return m(e),e},e.bi=function(){let e=new Float64Array(16);return m(e),e},e.bj=function(){return new Float64Array(16)},e.bk=function(e,t,n){let r=new Float64Array(4);return T(r,e,t-90,n),r},e.bl=function(e,t,n,r){var i,a,o,s,c,l=t[0],u=t[1],f=t[2],p=t[3],m=n[0],h=n[1],g=n[2],_=n[3];return(a=l*m+u*h+f*g+p*_)<0&&(a=-a,m=-m,h=-h,g=-g,_=-_),1-a>d?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(s=1-r,c=r),e[0]=s*l+c*m,e[1]=s*u+c*h,e[2]=s*f+c*g,e[3]=s*p+c*_,e},e.bm=function(e){let t=new Float64Array(9);var n,r,i,a,o,s,c,l,u,d=(i=(r=e)[0])*(c=i+i),f=(a=r[1])*c,p,m=(o=r[2])*c,h=o*(l=a+a),g,_=(s=r[3])*c,v=s*l,y=s*(u=o+o);(n=t)[0]=1-(p=a*l)-(g=o*u),n[3]=f-y,n[6]=m+v,n[1]=f+y,n[4]=1-d-g,n[7]=h-_,n[2]=m-v,n[5]=h+_,n[8]=1-d-p;let b=ge(-Math.asin(ee(t[2],-1,1))),x,S;return Math.hypot(t[5],t[8])<.001?(x=0,S=-ge(Math.atan2(t[3],t[4]))):(x=ge(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),S=ge(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:b+90,bearing:S}},e.bn=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bo=Lt,e.bp=As,e.bq=Sl,e.br=Cl,e.bs=bl,e.bt=M,e.bu=N,e.bv=Yt,e.bw=function(e,t,n,r,i){return M(r,i,ee((e-t)/(n-t),0,1))},e.bx=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},e.by=j,e.bz=function(){return new Float64Array(3)},e.c=Ce,e.c$=fi,e.c0=class extends ks{constructor(e,t){super(e,t),this.current=Ns}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.c1=js,e.c2=class extends ks{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.c3=class extends ks{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.c4=p,e.c5=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.c6=function(e,t,n){var r=t[0],i=t[1],a=t[2];return e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8],e},e.c7=function(e,t,n,r,i,a,o){var s=1/(t-n),c=1/(r-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*c,e[14]=(o+a)*l,e[15]=1,e},e.c8=class extends ks{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(4*e.length);for(let n=0;n<e.length;n++)t[4*n]=e[n].r,t[4*n+1]=e[n].g,t[4*n+2]=e[n].b,t[4*n+3]=e[n].a;this.gl.uniform4fv(this.location,t)}}},e.c9=class extends ks{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}},e.cA=function(e,t){return _e[t]&&`touches`in e},e.cB=function(e){return _e[e]||ve[e]},e.cC=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},e.cD=function(e,t){let{x:n,y:r}=Yf.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||n<0||n>=1)},e.cE=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.cF=class extends _o{},e.cG=Ee,e.cH=function(e,t){Ce.REGISTERED_PROTOCOLS[e]=t},e.cI=function(e){delete Ce.REGISTERED_PROTOCOLS[e]},e.cJ=function(e,t){let n={};for(let r=0;r<e.length;r++){let i=t&&t[e[r].id]||ji(e[r]);t&&(t[e[r].id]=i);let a=n[i];a||=n[i]=[],a.push(e[r])}let r=[];for(let e in n)r.push(n[e]);return r},e.cK=W,e.cL=np,e.cM=ih,e.cN=af,e.cO=function(t){var n;t.bucket.createArrays(),t.bucket.tilePixelRatio=O/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;let r=t.bucket.layers[0],i=r.layout,a=r._unevaluatedLayout._values,o={layoutIconSize:a[`icon-size`].possiblyEvaluate(new Va(t.bucket.zoom+1),t.canonical),layoutTextSize:a[`text-size`].possiblyEvaluate(new Va(t.bucket.zoom+1),t.canonical),textMaxSize:a[`text-size`].possiblyEvaluate(new Va(18))};if(t.bucket.textSizeData.kind===`composite`){let{minZoom:e,maxZoom:n}=t.bucket.textSizeData;o.compositeTextSizes=[a[`text-size`].possiblyEvaluate(new Va(e),t.canonical),a[`text-size`].possiblyEvaluate(new Va(n),t.canonical)]}if(t.bucket.iconSizeData.kind===`composite`){let{minZoom:e,maxZoom:n}=t.bucket.iconSizeData;o.compositeIconSizes=[a[`icon-size`].possiblyEvaluate(new Va(e),t.canonical),a[`icon-size`].possiblyEvaluate(new Va(n),t.canonical)]}let s=i.get(`text-line-height`)*Od,c=i.get(`text-rotation-alignment`)!==`viewport`&&i.get(`symbol-placement`)!==`point`,l=i.get(`text-keep-upright`),u=i.get(`text-size`);for(let a of t.bucket.features){let d=i.get(`text-font`).evaluate(a,{},t.canonical).join(`,`),f=u.evaluate(a,{},t.canonical),p=o.layoutTextSize.evaluate(a,{},t.canonical),m=o.layoutIconSize.evaluate(a,{},t.canonical),h={horizontal:{},vertical:void 0},g=a.text,_,v=[0,0];if(g){let n=g.toString(),o=i.get(`text-letter-spacing`).evaluate(a,{},t.canonical)*Od,u=ja(n)?o:0,m=i.get(`text-anchor`).evaluate(a,{},t.canonical),_=jh(r,a,t.canonical);if(!_){let e=i.get(`text-radial-offset`).evaluate(a,{},t.canonical);v=e?Ah(m,[e*Od,J]):i.get(`text-offset`).evaluate(a,{},t.canonical).map((e=>e*Od))}let y=c?`center`:i.get(`text-justify`).evaluate(a,{},t.canonical),b=i.get(`symbol-placement`)===`point`?i.get(`text-max-width`).evaluate(a,{},t.canonical)*Od:1/0,x=()=>{t.bucket.allowVerticalPlacement&&Aa(n)&&(h.vertical=sf(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,m,`left`,u,v,e.ax.vertical,!0,p,f))};if(!c&&_){let n=new Set;if(y===`auto`)for(let e=0;e<_.values.length;e+=2)n.add(Mh(_.values[e]));else n.add(y);let r=!1;for(let i of n)if(!h.horizontal[i])if(r)h.horizontal[i]=h.horizontal[0];else{let n=sf(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,`center`,i,u,v,e.ax.horizontal,!1,p,f);n&&(h.horizontal[i]=n,r=n.positionedLines.length===1)}x()}else{y===`auto`&&(y=Mh(m));let r=sf(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,m,y,u,v,e.ax.horizontal,!1,p,f);r&&(h.horizontal[y]=r),x(),Aa(n)&&c&&l&&(h.vertical=sf(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,m,y,u,v,e.ax.vertical,!1,p,f))}}let y=!1;if(a.icon?.name){let e=t.imageMap[a.icon.name];e&&(_=hf(t.imagePositions[a.icon.name],i.get(`icon-offset`).evaluate(a,{},t.canonical),i.get(`icon-anchor`).evaluate(a,{},t.canonical)),y=!!e.sdf,t.bucket.sdfIcons===void 0?t.bucket.sdfIcons=y:t.bucket.sdfIcons!==y&&ae(`Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer`),(e.pixelRatio!==t.bucket.pixelRatio||i.get(`icon-rotate`).constantOr(1)!==0)&&(t.bucket.iconsNeedLinear=!0))}let b=Fh(h.horizontal)||h.vertical;(n=t.bucket).iconsInText||(n.iconsInText=!!b&&b.iconsInText),(b||_)&&Nh(t.bucket,a,h,_,t.imageMap,o,p,m,v,y,t.canonical,t.subdivisionGranularity)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()},e.cP=Al,e.cQ=Jl,e.cR=pd,e.cS=function(e,t=``){let n=new Vd;return function(e,t,n=``){for(let r in e.layers)t.writeMessage(3,((e,t)=>Zm(e,t,n)),e.layers[r])}(e,n,t),n.finish()},e.cT=function(e,t,n,r,i,a){let o=ch(e,t,n,i,0);return o=ch(o,t,r,a,1),o},e.cU=class{constructor(e){this.maxEntries=e,this.map=new Map}get(e){let t=this.map.get(e);return t!==void 0&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){let e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cV=Wl,e.cW=Vd,e.cX=Jm,e.cY=function(e,n,r,i,a){return t(this,void 0,void 0,(function*(){if(u())try{return yield de(e,n,r,i,a)}catch{}return function(e,t,n,r,i){let a=e.width,o=e.height;fe&&pe||(fe=new OffscreenCanvas(a,o),pe=fe.getContext(`2d`,{willReadFrequently:!0})),fe.width=a,fe.height=o,pe.drawImage(e,0,0,a,o);let s=pe.getImageData(t,n,r,i);return pe.clearRect(0,0,a,o),s.data}(e,n,r,i,a)}))},e.cZ=Uc,e.c_=class{constructor(e,t){this.layers={[Xm]:this},this.name=Xm,this.version=t?t.version:1,this.extent=t?t.extent:4096,this.length=e.length,this.features=e}feature(e){return new Ym(this.features[e],this.extent)}},e.ca=class extends ko{},e.cb=Td,e.cc=class extends jo{},e.cd=Pc,e.ce=function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)},e.cf=Nc,e.cg=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/(o||=1),e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e},e.ch=class extends vo{},e.ci=class extends Ro{},e.cj=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},e.ck=function(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],f=e[9],p=e[10],m=e[11],h=e[12],g=e[13],_=e[14],v=e[15],y=t[0],b=t[1],x=t[2],S=t[3],C=t[4],w=t[5],T=t[6],E=t[7],D=t[8],O=t[9],k=t[10],A=t[11],j=t[12],M=t[13],N=t[14],P=t[15];return Math.abs(n-y)<=d*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-b)<=d*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-x)<=d*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(a-S)<=d*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-C)<=d*Math.max(1,Math.abs(o),Math.abs(C))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(c-T)<=d*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(u-D)<=d*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(f-O)<=d*Math.max(1,Math.abs(f),Math.abs(O))&&Math.abs(p-k)<=d*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(m-A)<=d*Math.max(1,Math.abs(m),Math.abs(A))&&Math.abs(h-j)<=d*Math.max(1,Math.abs(h),Math.abs(j))&&Math.abs(g-M)<=d*Math.max(1,Math.abs(g),Math.abs(M))&&Math.abs(_-N)<=d*Math.max(1,Math.abs(_),Math.abs(N))&&Math.abs(v-P)<=d*Math.max(1,Math.abs(v),Math.abs(P))},e.cl=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.cm=e=>e.type===`circle`,e.cn=e=>e.type===`heatmap`,e.co=e=>e.type===`line`,e.cp=e=>e.type===`fill`,e.cq=e=>e.type===`fill-extrusion`,e.cr=e=>e.type===`hillshade`,e.cs=e=>e.type===`color-relief`,e.ct=e=>e.type===`background`,e.cu=e=>e.type===`custom`,e.cv=P,e.cw=function(e,t,n){if(t<=0)return e;let r=1/t;return n===void 0||Math.abs(n)<1e-10?Math.round(e*r)/r:(n>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r},e.cx=function(e,t,n){let r=D(t.x-n.x,t.y-n.y),i=D(e.x-n.x,e.y-n.y);var a,o;return ge(Math.atan2(r[0]*i[1]-r[1]*i[0],(a=r)[0]*(o=i)[0]+a[1]*o[1]))},e.cy=F,e.cz=function(e,t){if(!ve[t])return!1;let n=(e?.target)?.ownerDocument?.defaultView||window;return e instanceof n.MouseEvent||e instanceof n.WheelEvent},e.d=A,e.d0=class{constructor(e,t){let n=(t=this.options=Object.assign({},cd,t)).debug;if(n&&console.time(`preprocess data`),t.maxZoom<0||t.maxZoom>24)throw Error(`maxZoom should be in the 0-24 range`);if(t.promoteId&&t.generateId)throw Error(`promoteId and generateId cannot be used together.`);let r=hu(e,t);n&&(console.timeEnd(`preprocess data`),console.log(`index: maxZoom: %d, maxPoints: %d`,t.indexMaxZoom,t.indexMaxPoints),console.time(`generate tiles`)),r=Bu(r,t),t.updateable&&(this.source=r),this.initializeIndex(r,t)}initializeIndex(e,t){this.tileIndex=t.cluster?new qu(t.clusterOptions):new od(t),e.length&&this.tileIndex.initialize(e)}getTile(e,t,n){return t=+t,n=+n,(e=+e)<0||e>24?null:this.tileIndex.getTile(e,t,n)}updateData(e,t){let n=this.options;if(!n.updateable)throw Error("to update tile geojson `updateable` option must be set to true");let{affected:r,source:i}=function(e,t,n){let r=function(e,t){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map((e=>[t.promoteId?e.properties[t.promoteId]:e.id,e]))),update:new Map(e.update?.map((e=>[e.id,e])))}:{remove:new Set,add:new Map,update:new Map}}(t,n),i=[];if(r.removeAll&&(i=e,e=[]),r.remove.size||r.add.size){let t=[];for(let n of e)(r.remove.has(n.id)||r.add.has(n.id))&&t.push(n);if(t.length){i.push(...t);let n=new Set(t.map((e=>e.id)));e=e.filter((e=>!n.has(e.id)))}if(r.add.size){let t=hu({type:`FeatureCollection`,features:Array.from(r.add.values())},n);t=Bu(t,n),i.push(...t),e.push(...t)}}if(r.update.size){let t=new Map,a=[];for(let n of e)r.update.has(n.id)?t.set(n.id,[...t.get(n.id)||[],n]):a.push(n);for(let[e,o]of r.update){let r=t.get(e);if(!r||r.length===0)continue;let s=Wu(r,o,n);i.push(...r,...s),a.push(...s)}e=a}return{affected:i,source:e}}(this.source,e,n);t&&({affected:r,source:i}=this.filterUpdate(i,r,t)),r.length&&(this.source=i,this.tileIndex.updateIndex(i,r,n))}filterUpdate(e,t,n){let r=new Set;for(let i of e)i.id!=null&&(n(xu(i))||(t.push(i),r.add(i.id)));return{affected:t,source:e=e.filter((e=>!r.has(e.id)))}}getData(){if(!this.options.updateable)throw Error("to retrieve data the `updateable` option must be set to true");return{type:`FeatureCollection`,features:this.source.map((e=>xu(e)))}}updateClusterOptions(e,t){let n=this.options.cluster;this.options.cluster=e,this.options.clusterOptions=t,n==e?this.tileIndex.updateIndex(this.source,[],this.options):this.initializeIndex(this.source,this.options)}getClusterExpansionZoom(e){return this.tileIndex.getClusterExpansionZoom(e)}getClusterChildren(e){return this.tileIndex.getChildren(e)}getClusterLeaves(e,t,n){return this.tileIndex.getLeaves(e,t,n)}},e.d1=Ba,e.e=L,e.f=ke,e.g=we,e.h=e=>t(void 0,void 0,void 0,(function*(){if(e.byteLength===0)return createImageBitmap(new ImageData(1,1));let t=new Blob([new Uint8Array(e)],{type:`image/png`});try{return createImageBitmap(t)}catch(e){throw Error(`Could not load image because of ${A(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),e.i=se,e.j=e=>new Promise(((t,n)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>r.src=ue))},r.onerror=()=>n(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.`));let i=new Blob([new Uint8Array(e)],{type:`image/png`});r.src=e.byteLength?URL.createObjectURL(i):ue})),e.k=(e,t)=>Oe(L(e,{type:`json`}),t),e.l=Ne,e.m=Oe,e.n=Me,e.o=(e,t)=>Oe(L(e,{type:`arrayBuffer`}),t),e.p=nf,e.q=function(e){return new Vd(e).readFields($d,[])},e.r=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},e.s=me,e.t=Ac,e.u=ro,e.v=fa,e.w=ae,e.x=z,e.y=Ka,e.z=ma})),n(`worker`,[`./shared`],(function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,n,r){for(let n of t){this._layerConfigs[n.id]=n;let t=this._layers[n.id]=e.bT(n,r);t._featureFilter=e.ah(t.filter,r),this.keyCache[n.id]&&delete this.keyCache[n.id]}for(let e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let i=e.cJ(Object.values(this._layerConfigs),this.keyCache);for(let t of i){let n=t.map((e=>this._layers[e.id])),r=n[0];if(r.isHidden())continue;let i=r.source||``,a=this.familiesBySource[i];a||=this.familiesBySource[i]={};let o=r.sourceLayer||e.ag,s=a[o];s||=a[o]=[],s.push(n)}}}class n{constructor(t){let n={},r=[];for(let e in t){let i=t[e],a=n[e]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let n={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};r.push(n),a[e]={rect:n,metrics:t.metrics}}}let{w:i,h:a}=e.p(r),o=new e.t({width:i||1,height:a||1});for(let r in t){let i=t[r];for(let t in i){let a=i[+t];if(!a||a.bitmap.width===0||a.bitmap.height===0)continue;let s=n[r][t].rect;e.t.copy(a.bitmap,o,{x:0,y:0},{x:s.x+1,y:s.y+1},a.bitmap)}}this.image=o,this.positions=n}}e.cK(`GlyphAtlas`,n);class r{constructor(t){this.tileID=new e.a3(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,r,a,o,s){return e._(this,void 0,void 0,(function*(){this.status=`parsing`,this.data=t,this.collisionBoxArray=new e.ae;let c=new e.cL(Object.keys(t.layers).sort()),l=new e.cM(this.tileID,this.promoteId);l.bucketLayerIDs=[];let u={},d={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:a,subdivisionGranularity:s},f=r.familiesBySource[this.source];for(let n in f){let r=t.layers[n];if(!r)continue;r.version===1&&e.w(`Vector tile source "${this.source}" layer "${n}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let o=c.encode(n),s=[];for(let e=0;e<r.length;e++){let t=r.feature(e),i=l.getId(t,n);s.push({feature:t,id:i,index:e,sourceLayerIndex:o})}for(let t of f[n]){let n=t[0];n.source!==this.source&&e.w(`layer.source = ${n.source} does not equal this.source = ${this.source}`),n.isHidden(this.zoom,!0)||(i(t,this.zoom,a),(u[n.id]=n.createBucket({index:l.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(s,d,this.tileID.canonical),l.bucketLayerIDs.push(t.map((e=>e.id))))}}let p=e.bY(d.glyphDependencies,(e=>Object.keys(e).map(Number)));for(let e of this.inFlightDependencies)e?.abort();this.inFlightDependencies=[];let m=Promise.resolve({});if(Object.keys(p).length){let e=new AbortController;this.inFlightDependencies.push(e),m=o.sendAsync({type:`GG`,data:{stacks:p,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let h=Object.keys(d.iconDependencies),g=Promise.resolve({});if(h.length){let e=new AbortController;this.inFlightDependencies.push(e),g=o.sendAsync({type:`GI`,data:{icons:h,source:this.source,tileID:this.tileID,type:`icons`}},e)}let _=Object.keys(d.patternDependencies),v=Promise.resolve({});if(_.length){let e=new AbortController;this.inFlightDependencies.push(e),v=o.sendAsync({type:`GI`,data:{icons:_,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let y=d.dashDependencies,b=Promise.resolve({});if(Object.keys(y).length){let e=new AbortController;this.inFlightDependencies.push(e),b=o.sendAsync({type:`GDA`,data:{dashes:y}},e)}let[x,S,C,w]=yield Promise.all([m,g,v,b]),T=new n(x),E=new e.cN(S,C);for(let t in u){let n=u[t];n instanceof e.af?(i(n.layers,this.zoom,a),e.cO({bucket:n,glyphMap:x,glyphPositions:T.positions,imageMap:S,imagePositions:E.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:d.subdivisionGranularity})):n.hasDependencies&&(n instanceof e.cP||n instanceof e.cQ||n instanceof e.cR)&&(i(n.layers,this.zoom,a),n.addFeatures(d,this.tileID.canonical,E.patternPositions,w))}return this.status=`done`,{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:T.image,imageAtlas:E,dashPositions:w,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?S:null,glyphPositions:this.returnDependencies?T.positions:null}}))}}function i(t,n,r){let i=new e.J(n);for(let e of t)e.recalculate(i,r)}class a{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){let t=this.loading[e];t!=null&&t.abort&&(t.abort.abort(),delete this.loading[e])}setParsing(e,t){this.parsing[e]=t}consumeParsing(e){let t=this.parsing[e];if(t)return delete this.parsing[e],t}clearParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){let t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}}class o{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return e.length===0&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}}class s{constructor(e,t,n,r,i){this.type=e,this.properties=n||{},this.extent=i,this.pointsArray=t,this.id=r}loadGeometry(){return this.pointsArray.map((t=>t.map((t=>new e.P(t.x,t.y)))))}}class c{constructor(e,t,n){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=n}feature(e){return this._myFeatures[e]}}class l{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function u(t){let n=e.cS(t);return n.byteOffset===0&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),{vectorTile:t,rawData:n.buffer}}function d(t,n,r){let{extent:i}=t,a=2**(r.z-n.z),o=(r.x-n.x*a)*i,l=(r.y-n.y*a)*i,u=[];for(let n=0;n<t.length;n++){let r=t.feature(n),c=r.loadGeometry();for(let e of c)for(let t of e)t.x=t.x*a-o,t.y=t.y*a-l;c=e.cT(c,r.type,-128,-128,i+128,i+128),c.length!==0&&u.push(new s(r.type,c,r.properties,r.id,i))}return new c(u,t.name,i)}class f{constructor(t,n,r){this.actor=t,this.layerIndex=n,this.availableImages=r,this.tileState=new a,this.overzoomedTileResultCache=new e.cU(1e3)}loadVectorTile(t,n){try{return{vectorTile:t.encoding===`mlt`?new e.cX(n):new e.cV(new e.cW(n)),rawData:n}}catch(r){let i=new Uint8Array(n),a=`Unable to parse the tile at ${t.request.url}, `;throw a+=i[0]===31&&i[1]===139?`please make sure the data is not gzipped and that you have configured the relevant header in the server`:`got error: ${e.d(r).message}`,Error(a)}}loadTile(t){return e._(this,void 0,void 0,(function*(){let{uid:n,overzoomParameters:i}=t;i&&(t.request=i.overzoomRequest);let a=this._startRequestTiming(t),o=new r(t);this.tileState.startLoading(n,o);let s=new AbortController;o.abort=s;try{let r=yield e.o(t.request,s);if(t.etag&&t.etag===r.etag)return this.tileState.finishLoading(n),this._getEtagUnmodifiedResult(r,a);let c=this.loadVectorTile(t,r.data);if(this.tileState.finishLoading(n),!c)return null;let{vectorTile:l,rawData:u}=c;i&&({vectorTile:l,rawData:u}=this._getOverzoomTile(t,l));let d=this._getExpiryData(r),f=this._finishRequestTiming(a);o.vectorTile=l,this.tileState.markLoaded(n,o);let p={rawData:u,cacheControl:d,resourceTiming:f};this.tileState.setParsing(n,p);try{return yield this._parseWorkerTile(o,t,p)}finally{this.tileState.clearParsing(n)}}catch(e){throw this.tileState.finishLoading(n),o.status=`done`,this.tileState.markLoaded(n,o),e}}))}_getEtagUnmodifiedResult(t,n){let r=this._getExpiryData(t),i=this._finishRequestTiming(n);return e.e({etagUnmodified:!0},r,i)}_parseWorkerTile(t,n,r){return e._(this,void 0,void 0,(function*(){let i=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,n.subdivisionGranularity);if(r){let{rawData:t,cacheControl:a,resourceTiming:o}=r;i=e.e({rawTileData:t.slice(0),encoding:n.encoding},i,a,o)}return i}))}_getExpiryData({expires:e,cacheControl:t,etag:n}){let r={};return e&&(r.expires=e),t&&(r.cacheControl=t),n&&(r.etag=n),r}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new o(e.request.url)}_finishRequestTiming(e){let t=e?.finish();return t?{resourceTiming:JSON.parse(JSON.stringify(t))}:{}}_getOverzoomTile(e,t){let{tileID:n,source:r,overzoomParameters:i}=e,{maxZoomTileID:a}=i,o=`${a.key}_${n.key}_${e.request?.url}`,s=this.overzoomedTileResultCache.get(o);if(s)return s;let c=new l,f=this.layerIndex.familiesBySource[r];for(let e in f){let r=t.layers[e];if(!r)continue;let i=d(r,a,n.canonical);i.length>0&&c.addLayer(i)}let p=u(c);return this.overzoomedTileResultCache.set(o,p),p}reloadTile(t){return e._(this,void 0,void 0,(function*(){let e=t.uid,n=this.tileState.getLoaded(e);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=t.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(n,t,r)}if(n.status===`done`&&n.vectorTile)return yield this._parseWorkerTile(n,t)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.abort(t.uid)}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(t.uid)}))}}class p{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,(function*(){let{uid:n,encoding:r,rawImageData:i,redFactor:a,greenFactor:o,blueFactor:s,baseShift:c}=t,l=i.width+2,u=i.height+2,d=e.b(i)?new e.R({width:l,height:u},yield e.cY(i,-1,-1,l,u)):i,f=new e.cZ(n,d,r,a,o,s,c);return this.loaded||={},this.loaded[n]=f,f}))}removeTile(e){let t=this.loaded,n=e.uid;t!=null&&t[n]&&delete t[n]}}class m{constructor(e,t,n,r=h){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new a,this._createGeoJSONIndex=r}loadVectorTile(t){if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let{z:n,x:r,y:i}=t.tileID.canonical,a=this._geoJSONIndex.getTile(n,r,i);return a?u(new e.c_(a.features,{version:2,extent:e.a6})):null}loadTile(t){return e._(this,void 0,void 0,(function*(){let{uid:e}=t,n=new r(t);n.abort=new AbortController;try{let r=this.loadVectorTile(t);if(!r)return null;let{vectorTile:i,rawData:a}=r;n.vectorTile=i,this.tileState.markLoaded(e,n);let o={rawData:a};this.tileState.setParsing(e,o);try{return yield this._parseWorkerTile(n,t,o)}finally{this.tileState.clearParsing(e)}}catch(t){throw n.status=`done`,this.tileState.markLoaded(e,n),t}}))}_reloadLoadedTile(t){return e._(this,void 0,void 0,(function*(){let e=t.uid,n=this.tileState.getLoaded(e);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=t.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(n,t,r)}if(n.status===`done`&&n.vectorTile)return yield this._parseWorkerTile(n,t)}))}_parseWorkerTile(t,n,r){return e._(this,void 0,void 0,(function*(){let i=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,n.subdivisionGranularity);if(r){let{rawData:t}=r;i=e.e({rawTileData:t.slice(0),encoding:`mvt`},i)}return i}))}abortTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.abort(t.uid)}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(t.uid)}))}loadData(t){return e._(this,void 0,void 0,(function*(){var n;(n=this._pendingRequest)==null||n.abort();let r=this._startRequestTiming(t);this._pendingRequest=new AbortController;try{yield this.loadAndProcessGeoJSON(t,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let e={};return t.request&&(e.data=t.data),this._finishRequestTiming(r,t,e),e}catch(t){if(delete this._pendingRequest,!e.$(t))throw t;return{abandoned:!0}}}))}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new o(e.request.url)}_finishRequestTiming(e,t,n){let r=e?.finish();r&&(n.resourceTiming={[t.source]:JSON.parse(JSON.stringify(r))})}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,n){return e._(this,void 0,void 0,(function*(){if(t.request&&(t.data=(yield e.k(t.request,n)).data),t.data)return t.data=this._filterGeoJSON(t.data,t.filter),void(this._geoJSONIndex=this._createGeoJSONIndex(t.data,t));if(t.dataDiff)return this._geoJSONIndex??=this._createGeoJSONIndex({type:`FeatureCollection`,features:[]},t),void this._geoJSONIndex.updateData(t.dataDiff,this._getFilterPredicate(t.filter));if(t.updateCluster&&this._geoJSONIndex.updateClusterOptions(t.geojsonVtOptions.cluster,g(t)),this._geoJSONIndex==null)throw Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}))}_filterGeoJSON(e,t){if(e.type!==`FeatureCollection`)return e;let n=this._getFilterPredicate(t);return n?{type:`FeatureCollection`,features:e.features.filter((e=>n(e)))}:e}_getFilterPredicate(t){if(typeof t!=`boolean`&&!t?.length)return;let n=e.c$(t,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(n.result===`error`)throw Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return e=>n.value.evaluate({zoom:0},e)}removeSource(t){return e._(this,void 0,void 0,(function*(){var e;(e=this._pendingRequest)==null||e.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}}function h(t,n){let r=e.e(n.geojsonVtOptions||{},{updateable:!0,clusterOptions:g(n)});return new e.d0(t,r)}function g({geojsonVtOptions:t,clusterProperties:n}){if(!n||!t.clusterOptions)return t.clusterOptions;let r={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(n);for(let t of s){let[a,o]=n[t],s=e.c$(o),c=e.c$(typeof a==`string`?[a,[`accumulated`],[`get`,t]]:a);r[t]=s.value,i[t]=c.value}return t.clusterOptions.map=e=>{o.properties=e;let t={};for(let e of s)t[e]=r[e].evaluate(a,o);return t},t.clusterOptions.reduce=(e,t)=>{o.properties=t;for(let t of s)a.accumulated=e[t],e[t]=i[t].evaluate(a,o)},t.clusterOptions}class _{constructor(t){this.self=t,this.actor=new e.N(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cH,this.self.removeProtocol=e.cI,this.self.registerRTLTextPlugin=t=>{e.d1.setMethods(t)},this.self.makeRequest=e.m,this.actor.registerMessageHandler(`LDT`,((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler(`RDT`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,n.source).removeTile(n)})))),this.actor.registerMessageHandler(`GCEZ`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterExpansionZoom(n)})))),this.actor.registerMessageHandler(`GCC`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterChildren(n)})))),this.actor.registerMessageHandler(`GCL`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterLeaves(n)})))),this.actor.registerMessageHandler(`LD`,((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler(`LT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler(`RT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler(`AT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler(`RMT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler(`RS`,((t,n)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]?.[n.type]?.[n.source])return;let e=this.workerSources[t][n.type][n.source];delete this.workerSources[t][n.type][n.source],e.removeSource!==void 0&&e.removeSource(n)})))),this.actor.registerMessageHandler(`RM`,(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})))),this.actor.registerMessageHandler(`SR`,((t,n)=>e._(this,void 0,void 0,(function*(){this.referrer=n})))),this.actor.registerMessageHandler(`SRPS`,((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler(`IS`,((t,n)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(n)})))),this.actor.registerMessageHandler(`SI`,((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler(`UL`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(n.layers,n.removedIds,this._getGlobalState(t))})))),this.actor.registerMessageHandler(`UGS`,((t,n)=>e._(this,void 0,void 0,(function*(){let e=this._getGlobalState(t);for(let t in n)e[t]=n[t]})))),this.actor.registerMessageHandler(`SL`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(n,this._getGlobalState(t))}))))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,n){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=n;for(let e in this.workerSources[t]){let r=this.workerSources[t][e];for(let e in r)r[e].availableImages=n}}))}_syncRTLPluginState(t,n){return e._(this,void 0,void 0,(function*(){return yield e.d1.syncState(n,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||=[],t}_getLayerIndex(e){let n=this.layerIndexes[e];return n||=this.layerIndexes[e]=new t,n}_getWorkerSource(e,t,n){var r,i;if((r=this.workerSources)[e]||(r[e]={}),(i=this.workerSources[e])[t]||(i[t]={}),!this.workerSources[e][t][n]){let r={sendAsync:(t,n)=>(t.targetMapId=e,this.actor.sendAsync(t,n))};switch(t){case`vector`:this.workerSources[e][t][n]=new f(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][t][n]=new m(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][n]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][n]}_getDEMWorkerSource(e,t){var n,r;return(n=this.demWorkerSources)[e]||(n[e]={}),(r=this.demWorkerSources[e])[t]||(r[t]=new p),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new _(self)),_})),n(`index`,[`exports`,`./shared`],(function(e,t){var n=`5.24.0`;function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let i,a,o,s={frame(e,n,r,i){let a=i||window,o=a.requestAnimationFrame((e=>{s(),n(e)})),{unsubscribe:s}=t.s(e.signal,`abort`,(()=>{s(),a.cancelAnimationFrame(o),r(new t.a(e.signal.reason))}),!1)},frameAsync(e,t){return new Promise(((n,r)=>{this.frame(e,n,r,t)}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t=window.document.createElement(`canvas`),n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)throw Error(`failed to create canvas 2d context`);return t.width=e.width,t.height=e.height,n.drawImage(e,0,0,e.width,e.height),n},resolveURL:e=>(i||=document.createElement(`a`),i.href=e,i.href),hardwareConcurrency:typeof navigator<`u`&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return o===void 0?!!matchMedia&&(a??=matchMedia(`(prefers-reduced-motion: reduce)`),a.matches):o},set prefersReducedMotion(e){o=e}},c=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function l(){return c.getCurrentTime()}var u;class d{static create(e,t,n){let r=window.document.createElement(e);return t!==void 0&&(r.className=t),n&&n.appendChild(r),r}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){d.docStyle&&d.selectProp&&(d.userSelect=d.docStyle[d.selectProp],d.docStyle[d.selectProp]=`none`)}static enableDrag(){d.docStyle&&d.selectProp&&(d.docStyle[d.selectProp]=d.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener(`click`,d.suppressClickInternal,!0)}static suppressClick(){window.addEventListener(`click`,d.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener(`click`,d.suppressClickInternal,!0)}),0)}static getScale(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,n,r){let i=n.boundingClientRect;return new t.P((r.clientX-i.left)/n.x-e.clientLeft,(r.clientY-i.top)/n.y-e.clientTop)}static mousePos(e,t){let n=d.getScale(e);return d.getPoint(e,n,t)}static touchPos(e,t){let n=[],r=d.getScale(e);for(let i of t)n.push(d.getPoint(e,r,i));return n}static sanitize(e){let t=new DOMParser().parseFromString(e,`text/html`).body||document.createElement(`body`),n=t.querySelectorAll(`script`);for(let e of n)e.remove();return d.clean(t),t.innerHTML}static isPossiblyDangerous(e,t){let n=t.replace(/\s+/g,``).toLowerCase();return!(![`src`,`href`,`xlink:href`].includes(e)||!n.includes(`javascript:`)&&!n.includes(`data:`))||!!e.startsWith(`on`)||void 0}static clean(e){let t=e.children;for(let e of t)d.removeAttributes(e),d.clean(e)}static removeAttributes(e){for(let{name:t,value:n}of e.attributes)d.isPossiblyDangerous(t,n)&&e.removeAttribute(t)}}d.docStyle=typeof window<`u`&&window.document?.documentElement.style,d.selectProp=!d.docStyle||`userSelect`in d.docStyle?`userSelect`:`webkitUserSelect`,function(e){let n,r,i,a;e.resetRequestQueue=()=>{n=[],r=0,i=0,a={}},e.addThrottleControl=e=>{let t=i++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],s()},e.getImage=(e,r,i=!0)=>new Promise(((a,o)=>{e.headers||={},e.headers.accept=`image/webp,*/*`,t.e(e,{type:`image`}),n.push({abortController:r,requestParameters:e,supportImageRefresh:i,state:`queued`,onError:e=>{o(e)},onSuccess:e=>{a(e)}}),s()}));let o=e=>t._(this,void 0,void 0,(function*(){e.state=`running`;let{requestParameters:n,supportImageRefresh:i,onError:a,onSuccess:o,abortController:l}=e,u=!1===i&&!t.i(self)&&!t.g(n.url)&&(!n.headers||Object.keys(n.headers).reduce(((e,t)=>e&&t===`accept`),!0));r++;let d=u?c(n,l):t.m(n,l);try{let n=yield d;delete e.abortController,e.state=`completed`,n.data instanceof HTMLImageElement||t.b(n.data)?o(n):n.data&&o({data:yield(f=n.data,typeof createImageBitmap==`function`?t.h(f):t.j(f)),cacheControl:n.cacheControl,expires:n.expires})}catch(n){delete e.abortController,a(t.d(n))}finally{r--,s()}var f})),s=()=>{let e=(()=>{for(let e of Object.keys(a))if(a[e]())return!0;return!1})()?t.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t<e&&n.length>0;t++){let e=n.shift();e.abortController.signal.aborted?t--:o(e)}},c=(e,n)=>new Promise(((r,i)=>{let a=new Image,o=e.url,s=e.credentials;s&&s===`include`?a.crossOrigin=`use-credentials`:(s&&s===`same-origin`||!t.f(o))&&(a.crossOrigin=`anonymous`),n.signal.addEventListener(`abort`,(()=>{a.src=``,i(new t.a(n.signal.reason))})),a.fetchPriority=`high`,a.onload=()=>{a.onerror=a.onload=null,r({data:a})},a.onerror=()=>{a.onerror=a.onload=null,n.signal.aborted||i(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.`))},a.src=o}))}(u||={}),u.resetRequestQueue();class f{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function p(e){let t=[];if(typeof e==`string`)t.push({id:`default`,url:e});else if(e&&e.length>0){let n=[];for(let{id:r,url:i}of e){let e=`${r}${i}`;n.includes(e)||(n.push(e),t.push({id:r,url:i}))}}return t}function m(e,t,n){try{let r=new URL(e);return r.pathname+=`${t}${n}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function h(e){let{userImage:t}=e;return!(!t?.render||!t.render()||(e.data.replace(new Uint8Array(t.data.buffer)),0))}class g extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&=(this.atlasTexture.destroy(),null);for(let e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){let n=this.images[e];if(n&&!n.data&&n.spriteData){let e=n.spriteData;n.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),n.spriteData=null}return n}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,n){let r=!0,i=n.data||n.spriteData;return this._validateStretch(n.stretchX,i?.width)||(this.fire(new t.l(Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,i?.height)||(this.fire(new t.l(Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new t.l(Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(let r of e){if(r[0]<n||r[1]<r[0]||t<r[1])return!1;n=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let n=t.spriteData,r=n?.width||t.data.width,i=n?.height||t.data.height;return!(e[0]<0||r<e[0]||e[1]<0||i<e[1]||e[2]<0||r<e[2]||e[3]<0||i<e[3]||e[2]<e[0]||!(e[3]>=e[1]))}updateImage(e,t,n=!0){let r=this.getImage(e);if(n&&(r.data.width!==t.data.width||r.data.height!==t.data.height))throw Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${t.data.width}x${t.data.height}).`);t.version=r.version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){var t;let n=this.images[e];delete this.images[e],delete this.patterns[e],(t=n.userImage)!=null&&t.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((t,n)=>{let r=!0;if(!this.isLoaded())for(let t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})}))}_getImagesForIds(e){let n={};for(let r of e){let e=this.getImage(r);e||=(this.fire(new t.n(`styleimagemissing`,{id:r})),this.getImage(r)),e?n[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!e.userImage?.render}:t.w(`Image "${r}" 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.`)}return n}getPixelSize(){let{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){let n=this.patterns[e],r=this.getImage(e);if(!r)return null;if(n&&n.position.version===r.version)return n.position;if(n)n.position.version=r.version;else{let n={w:r.data.width+2,h:r.data.height+2,x:0,y:0},i=new t.I(n,r);this.patterns[e]={bin:n,position:i}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){let n=e.gl;this.atlasTexture?this.dirty&&=(this.atlasTexture.update(this.atlasImage),!1):this.atlasTexture=new t.T(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let e=[];for(let t in this.patterns)e.push(this.patterns[t].bin);let{w:n,h:r}=t.p(e),i=this.atlasImage;i.resize({width:n||1,height:r||1});for(let e in this.patterns){let{bin:n}=this.patterns[e],r=n.x+1,a=n.y+1,o=this.getImage(e).data,s=o.width,c=o.height;t.R.copy(o,i,{x:0,y:0},{x:r,y:a},{width:s,height:c}),t.R.copy(o,i,{x:0,y:c-1},{x:r,y:a-1},{width:s,height:1}),t.R.copy(o,i,{x:0,y:0},{x:r,y:a+c},{width:s,height:1}),t.R.copy(o,i,{x:s-1,y:0},{x:r-1,y:a},{width:1,height:c}),t.R.copy(o,i,{x:0,y:0},{x:r+s,y:a},{width:1,height:c})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let e=this.getImage(n);e||t.w(`Image with ID: "${n}" was not found`),h(e)&&this.updateImage(n,e)}}cloneImages(){let e={};for(let t in this.images){let n=this.images[t];e[t]=Object.assign(Object.assign({},n),{data:n.data?n.data.clone():null})}return e}}let _=0x56bc75e2d63100000,v=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**(1/2.2);v[e]=t*Math.abs(t)}function y(e,t,n,r,i,a,o,s,c){for(let l=t;l<t+r;l++)b(e,n*a+l,a,i,o,s,c);for(let l=n;l<n+i;l++)b(e,l*a+t,1,r,o,s,c)}function b(e,t,n,r,i,a,o){a[0]=0,o[0]=-0x56bc75e2d63100000,o[1]=_,i[0]=e[t];for(let s=1,c=0,l=0;s<r;s++){i[s]=e[t+s*n];let r=s*s;do{let e=a[c];l=(i[s]-i[e]+r-e*e)/(s-e)/2}while(l<=o[c]&&--c>-1);c++,a[c]=s,o[c]=l,o[c+1]=_}for(let s=0,c=0;s<r;s++){for(;o[c+1]<s;)c++;let r=a[c],l=s-r;e[t+s*n]=i[r]+l*l}}v[255]=-0x56bc75e2d63100000;let x=t.v.layout_symbol[`text-font`].default.join(`,`);class S{constructor(e,t,n){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=n}setURL(e){this.url=e}getGlyphs(e){return t._(this,void 0,void 0,(function*(){let t=[];for(let n in e)for(let r of e[n])t.push(this._getAndCacheGlyphsPromise(n,r));let n=yield Promise.all(t),r={};for(let{stack:e,id:t,glyph:i}of n)r[e]||(r[e]={}),r[e][t]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics};return r}))}_getAndCacheGlyphsPromise(e,n){return t._(this,void 0,void 0,(function*(){var t;(t=this.entries)[e]??(t[e]={glyphs:{},requests:{},ranges:{}});let r=this.entries[e],i=r.glyphs[n];return i===void 0?!this.url||this._charUsesLocalIdeographFontFamily(n)?(i=r.glyphs[n]=this._drawGlyph(r,e,n),{stack:e,id:n,glyph:i}):yield this._downloadAndCacheRangePromise(e,n):{stack:e,id:n,glyph:i}}))}_downloadAndCacheRangePromise(e,n){return t._(this,void 0,void 0,(function*(){var r;let i=this.entries[e],a=Math.floor(n/256);if(i.ranges[a])return{stack:e,id:n,glyph:null};(r=i.requests)[a]||(r[a]=S.loadGlyphRange(e,a,this.url,this.requestManager));try{let t=yield i.requests[a];for(let e in t)i.glyphs[+e]=t[+e];return i.ranges[a]=!0,{stack:e,id:n,glyph:t[n]||null}}catch(r){let o=i.glyphs[n]=this._drawGlyph(i,e,n);return this._warnOnMissingGlyphRange(o,a,n,t.d(r)),{stack:e,id:n,glyph:o}}}))}_warnOnMissingGlyphRange(e,n,r,i){let a=256*n,o=a+255,s=r.toString(16).padStart(4,`0`).toUpperCase();t.w(`Unable to load glyph range ${n}, ${a}-${o}. Rendering codepoint U+${s} locally instead. ${i}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&t.r(e)}_drawGlyph(e,n,r){let i=n===x&&this.localIdeographFontFamily!==``&&this._charUsesLocalIdeographFontFamily(r),a=i?`ideographTinySDF`:`tinySDF`;e[a]||(e[a]=this._createTinySDF(i?this.localIdeographFontFamily:n));let o=e[a].draw(String.fromCodePoint(r)),s=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(r));return{id:r,bitmap:new t.t({width:o.width||60,height:o.height||60},o.data),metrics:{width:s?0:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:s?0:o.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){let t=e?e.split(`,`):[];t.push(`sans-serif`);let n=t.map((e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(`,`);return new S.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:n,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?`italic`:/oblique/i.test(e)?`oblique`:`normal`}_fontWeight(e){let t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},n;for(let[r,i]of Object.entries(t))RegExp(`\\b${r}\\b`,`i`).test(e)&&(n=`${i}`);return n}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}S.loadGlyphRange=function(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=256*n,o=a+255,s=yield i.transformRequest(r.replace(`{fontstack}`,e).replace(`{range}`,`${a}-${o}`),`Glyphs`),c=yield t.o(s,new AbortController);if(!c?.data)throw Error(`Could not load glyph range. range: ${n}, ${a}-${o}`);let l={};for(let e of t.q(c.data))l[e.id]=e;return l}))},S.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i=`sans-serif`,fontWeight:a=`normal`,fontStyle:o=`normal`,lang:s=null}={}){this.buffer=t,this.radius=n,this.cutoff=r,this.lang=s;let c=this.size=e+4*t,l=this._createCanvas(c),u=this.ctx=l.getContext(`2d`,{willReadFrequently:!0});u.font=`${o} ${a} ${e}px ${i}`,u.textBaseline=`alphabetic`,u.textAlign=`left`,u.fillStyle=`black`,this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,e);let t=document.createElement(`canvas`);return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(e),o=Math.ceil(n),s=Math.floor(i),c=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a)-s)),l=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(r))),u=c+2*this.buffer,d=l+2*this.buffer,f=Math.max(u*d,0),p=new Uint8ClampedArray(f),m={data:p,width:u,height:d,glyphWidth:c,glyphHeight:l,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(c===0||l===0)return m;let{ctx:h,buffer:g,gridInner:b,gridOuter:x}=this;this.lang&&(h.lang=this.lang),h.clearRect(g,g,c,l),h.fillText(e,g-s,g+o);let S=h.getImageData(g,g,c,l);x.fill(_,0,f),b.fill(0,0,f);let C=3;for(let e=0;e<l;e++){let t=(e+g)*u+g;for(let e=0;e<c;e++,C+=4,t++){let e=S.data[C];if(e===0)continue;let n=v[e];x[t]=Math.max(0,n),b[t]=Math.max(0,-n)}}y(x,0,0,u,d,u,this.f,this.v,this.z),y(b,g,g,c,l,u,this.f,this.v,this.z);let w=255/this.radius,T=255*(1-this.cutoff);for(let e=0;e<f;e++){let t=Math.sqrt(x[e])-Math.sqrt(b[e]);p[e]=Math.round(T-w*t)}return m}};class C{constructor(){this.specification=t.x.light.position}possiblyEvaluate(e,n){return t.G(e.expression.evaluate(n))}interpolate(e,n,r){return{x:t.H.number(e.x,n.x,r),y:t.H.number(e.y,n.y,r),z:t.H.number(e.z,n.z,r)}}}let w;class T extends t.E{constructor(e){super(),w||=new t.u({anchor:new t.D(t.x.light.anchor),position:new C,color:new t.D(t.x.light.color),intensity:new t.D(t.x.light.intensity)}),this._transitionable=new t.y(w,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(t.z,e,n))for(let n in e){let r=e[n];n.endsWith(t.B)?this._transitionable.setTransition(n.slice(0,-t.B.length),r):this._transitionable.setValue(n,r)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,r){return!1!==r?.validate&&t.C(this,e.call(t.F,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.x}))}}let E=new t.u({"sky-color":new t.D(t.x.sky[`sky-color`]),"horizon-color":new t.D(t.x.sky[`horizon-color`]),"fog-color":new t.D(t.x.sky[`fog-color`]),"fog-ground-blend":new t.D(t.x.sky[`fog-ground-blend`]),"horizon-fog-blend":new t.D(t.x.sky[`horizon-fog-blend`]),"sky-horizon-blend":new t.D(t.x.sky[`sky-horizon-blend`]),"atmosphere-blend":new t.D(t.x.sky[`atmosphere-blend`])});class D extends t.E{constructor(e){super(),this._transitionable=new t.y(E,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0))}setSky(e,n={}){if(!this._validate(t.K,e,n)){e||={"sky-color":`transparent`,"horizon-color":`transparent`,"fog-color":`transparent`,"fog-ground-blend":1,"atmosphere-blend":0};for(let n in e){let r=e[n];n.endsWith(t.B)?this._transitionable.setTransition(n.slice(0,-t.B.length),r):this._transitionable.setValue(n,r)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,r={}){return!1!==r?.validate&&t.C(this,e.call(t.F,t.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.x})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class O{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){var n;let r=e.join(`,`)+String(t);return(n=this.dashEntry)[r]||(n[r]=this.addDash(e,t)),this.dashEntry[r]}getDashRanges(e,t,n){let r=[],i=e.length%2==1?-e[e.length-1]*n:0,a=e[0]*n,o=!0;r.push({left:i,right:a,isDash:o,zeroLength:e[0]===0});let s=e[0];for(let t=1;t<e.length;t++){o=!o;let c=e[t];i=s*n,s+=c,a=s*n,r.push({left:i,right:a,isDash:o,zeroLength:c===0})}return r}addRoundDash(e,t,n){let r=t/2;for(let t=-n;t<=n;t++){let i=this.width*(this.nextRow+n+t),a=0,o=e[a];for(let s=0;s<this.width;s++){s/o.right>1&&(o=e[++a]);let c=Math.abs(s-o.left),l=Math.abs(s-o.right),u=Math.min(c,l),d,f=t/n*(r+1);if(o.isDash){let e=r-Math.abs(f);d=Math.sqrt(u*u+e*e)}else d=r-Math.sqrt(u*u+f*f);this.data[i+s]=Math.max(0,Math.min(255,d+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){let n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r&&r.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}let t=e[0],n=e[e.length-1];t.isDash===n.isDash&&(t.left=n.left-this.width,n.right=t.right+this.width);let r=this.width*this.nextRow,i=0,a=e[i];for(let t=0;t<this.width;t++){t/a.right>1&&(a=e[++i]);let n=Math.abs(t-a.left),o=Math.abs(t-a.right),s=Math.min(n,o);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?s:-s)+128))}}addDash(e,n){let r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return t.w(`LineAtlas out of space`),null;let a=0;for(let t of e)a+=t;if(a!==0){let t=this.width/a,i=this.getDashRanges(e,this.width,t);n?this.addRoundDash(i,t,r):this.addRegularDash(i)}let o={y:this.nextRow+r,height:2*r,width:a};return this.nextRow+=i,this.dirty=!0,o}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}}let k=`maplibre_preloaded_worker_pool`;class A{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<A.workerCount;)this.workers.push(new Worker(t.c.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){if(delete this.active[e],this.numActive()===0){for(let e of this.workers)e.terminate();this.workers=null}}isPreloaded(){return!!this.active[k]}numActive(){return Object.keys(this.active).length}}let j=Math.floor(s.hardwareConcurrency/2),M,N;function P(){return M||=new A,M}A.workerCount=t.L(globalThis)?Math.max(Math.min(j,3),1):1;class F{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;let r=this.workerPool.acquire(n);for(let e=0;e<r.length;e++){let i=new t.N(r[e],n);i.name=`Worker ${e}`,this.actors.push(i)}if(!this.actors.length)throw Error(`No actors found`)}broadcast(e,t){let n=[];for(let r of this.actors)n.push(r.sendAsync({type:e,data:t}));return Promise.all(n)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){for(let e of this.actors)e.remove();this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(let n of this.actors)n.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(let t of this.actors)t.unregisterMessageHandler(e)}}function ee(){return N||(N=new F(P(),t.M),N.registerMessageHandler(`GR`,((e,n,r)=>t.m(n,r)))),N}function I(e,n){let r=t.O();return t.Q(r,r,[1,1,0]),t.S(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.U(r,r,e.calculatePosMatrix(n.toUnwrapped())):r}function L(e,t,n,r,i,a,o){let s=function(e,t,n){if(e)for(let r of e){let e=t[r];if(e?.source===n&&e.type===`fill-extrusion`)return!0}else for(let e in t){let r=t[e];if(r.source===n&&r.type===`fill-extrusion`)return!0}return!1}(i?.layers??null,t,e.id),c=a.maxPitchScaleFactor(),l=e.tilesIn(r,c,s);l.sort(te);let u=[];for(let r of l)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,i,a,c,I(a,r.tileID),o?(e,t)=>o(r.tileID,e,t):void 0)});return function(e,t){for(let n in e)for(let r of e[n])ne(r,t);return e}(function(e){let t={},n={};for(let{queryResults:r,wrappedTileID:i}of e){n[i]||(n[i]={});let e=n[i];for(let n in r){let i=r[n];e[n]||(e[n]={});let a=e[n];t[n]||(t[n]=[]);for(let e of i)a[e.featureIndex]||(a[e.featureIndex]=!0,t[n].push(e))}}return t}(u),e)}function te(e,t){let n=e.tileID,r=t.tileID;return n.overscaledZ-r.overscaledZ||n.canonical.y-r.canonical.y||n.wrap-r.wrap||n.canonical.x-r.canonical.x}function ne(e,t){let n=e.feature,r=t.getFeatureState(n.layer[`source-layer`],n.id);n.source=n.layer.source,n.layer[`source-layer`]&&(n.sourceLayer=n.layer[`source-layer`]),n.state=r}function R(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=e;if(e.url?a=(yield t.k(yield n.transformRequest(e.url,`Source`),r)).data:yield s.frameAsync(r,i),!a)return null;let o=t.V(t.e(a,e),[`tiles`,`minzoom`,`maxzoom`,`attribution`,`bounds`,`scheme`,`tileSize`,`encoding`]);return`vector_layers`in a&&a.vector_layers&&(o.vectorLayerIds=a.vector_layers.map((e=>e.id))),o}))}class re{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(e.length===4?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 t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}extend(e){let n=this._sw,r=this._ne,i,a;if(e instanceof t.W)i=e,a=e;else{if(!(e instanceof re))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(re.convert(e)):this.extend(t.W.convert(e)):e&&(`lng`in e||`lon`in e)&&`lat`in e?this.extend(t.W.convert(e)):this;if(i=e._sw,a=e._ne,!i||!a)return this}return n||r?(n.lng=Math.min(i.lng,n.lng),n.lat=Math.min(i.lat,n.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.W(i.lng,i.lat),this._ne=new t.W(a.lng,a.lat)),this}getCenter(){return new t.W((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 t.W(this.getWest(),this.getNorth())}getSouthEast(){return new t.W(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){let{lng:n,lat:r}=t.W.convert(e),i=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&i}intersects(e){if(!((e=re.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;let n=Math.abs(this.getEast()-this.getWest()),r=Math.abs(e.getEast()-e.getWest());if(n>=360||r>=360)return!0;let i=t.X(this.getWest(),-180,180),a=t.X(this.getEast(),-180,180),o=t.X(e.getWest(),-180,180),s=t.X(e.getEast(),-180,180),c=i>a,l=o>s;return!(!c||!l)||(c?s>=i||o<=a:l?a>=o||i<=s:o<=a&&s>=i)}static convert(e){return e instanceof re?e:e&&new re(e)}static fromLngLat(e,n=0){let r=360*n/40075017,i=r/Math.cos(Math.PI/180*e.lat);return new re(new t.W(e.lng-i,e.lat-r),new t.W(e.lng+i,e.lat+r))}adjustAntiMeridian(){let e=new t.W(this._sw.lng,this._sw.lat),n=new t.W(this._ne.lng,this._ne.lat);return new re(e,e.lng>n.lng?new t.W(n.lng+360,n.lat):n)}}class ie{constructor(e,t,n){this.bounds=re.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=n||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let n=2**e.z,r=Math.floor(t.Z(this.bounds.getWest())*n),i=Math.floor(t.Y(this.bounds.getNorth())*n),a=Math.ceil(t.Z(this.bounds.getEast())*n),o=Math.ceil(t.Y(this.bounds.getSouth())*n);return e.x>=r&&e.x<a&&e.y>=i&&e.y<o}}class ae extends t.E{constructor(e,n,r,i){if(super(),this.id=e,this.dispatcher=r,this.type=`vector`,this.minzoom=0,this.maxzoom=22,this.scheme=`xyz`,this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.e(this,t.V(n,[`url`,`scheme`,`tileSize`,`promoteId`,`encoding`])),this._options=t.e({type:`vector`},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw Error(`vector tile sources must have a tileSize of 512`);this.setEventedParent(i)}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.n(`dataloading`,{dataType:`source`})),this._tileJSONRequest=new AbortController;try{let n=yield R(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(t.e(this,n),n.bounds&&(this.tileBounds=new ie(n.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`metadata`})),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`content`,sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n={request:yield this.map._requestManager.transformRequest(t,`Tile`),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:yield this._getOverzoomParameters(e),etag:e.etag};n.request.collectResourceTiming=this._collectResourceTiming;let r=`RT`;if(e.actor&&e.state!==`expired`){if(e.state===`loading`)return new Promise(((t,n)=>{e.reloadPromise={resolve:t,reject:n}}))}else e.actor=this.dispatcher.getActor(),r=`LT`;e.abortController=new AbortController;try{let t=yield e.actor.sendAsync({type:r,data:n},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);let i={};return t!=null&&t.etagUnmodified&&(i.unmodified=!0),i}catch(t){if(delete e.abortController,e.aborted)return;if(t&&t.status!==404)throw t;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){return t._(this,void 0,void 0,(function*(){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,n=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:yield this.map._requestManager.transformRequest(n,`Tile`)}}))}_afterTileLoadWorkerResponse(e,t){if(t!=null&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t?.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){let t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:`AT`,data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:`RMT`,data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class oe extends t.E{constructor(e,n,r,i){super(),this.id=e,this.dispatcher=r,this.setEventedParent(i),this.type=`raster`,this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme=`xyz`,this.tileSize=512,this._loaded=!1,this._options=t.e({type:`raster`},n),t.e(this,t.V(n,[`url`,`scheme`,`tileSize`]))}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.n(`dataloading`,{dataType:`source`})),this._tileJSONRequest=new AbortController;try{let n=yield R(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(t.e(this,n),n.bounds&&(this.tileBounds=new ie(n.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`metadata`})),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`content`,sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(e){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{let r=yield u.getImage(yield this.map._requestManager.transformRequest(n,`Tile`),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(r?.data){this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});let n=this.map.painter.context,i=n.gl,a=r.data;e.texture=this.map.painter.getTileTexture(a.width),e.texture?e.texture.update(a,{useMipmap:!0}):(e.texture=new t.T(n,a,i.RGBA,{useMipmap:!0}),e.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_NEAREST)),e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class se extends oe{constructor(e,n,r,i){super(e,n,r,i),this.type=`raster-dem`,this.maxzoom=22,this._options=t.e({type:`raster-dem`},n),this.encoding=n.encoding||`mapbox`,this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return t._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=yield this.map._requestManager.transformRequest(n,`Tile`);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let n=yield u.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(n?.data){let r=n.data;this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let i=t.b(r)&&t.a0()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&e.state!==`expired`&&e.state!==`reloading`)return;e.actor&&e.state!==`expired`||(e.actor=this.dispatcher.getActor()),e.dem=yield e.actor.sendAsync({type:`LDT`,data:a}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if(typeof VideoFrame<`u`&&t.a1()){let n=e.width+2,r=e.height+2;try{return new t.R({width:n,height:r},yield t.a2(e,-1,-1,n,r))}catch{}}return s.getImageData(e,1)}))}_getNeighboringTiles(e){let n=e.canonical,r=2**n.z,i=(n.x-1+r)%r,a=n.x===0?e.wrap-1:e.wrap,o=(n.x+1+r)%r,s=n.x+1===r?e.wrap+1:e.wrap,c={};return c[new t.a3(e.overscaledZ,a,n.z,i,n.y).key]={backfilled:!1},c[new t.a3(e.overscaledZ,s,n.z,o,n.y).key]={backfilled:!1},n.y>0&&(c[new t.a3(e.overscaledZ,a,n.z,i,n.y-1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,s,n.z,o,n.y-1).key]={backfilled:!1}),n.y+1<r&&(c[new t.a3(e.overscaledZ,a,n.z,i,n.y+1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,s,n.z,o,n.y+1).key]={backfilled:!1}),c}unloadTile(e){return t._(this,void 0,void 0,(function*(){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`,e.actor&&(yield e.actor.sendAsync({type:`RDT`,data:{type:this.type,uid:e.uid,source:this.id}}))}))}}function ce(e,t){return t?e.properties[t]:e.id}function le(e,t){let n={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(let n of t.removeProperties){let t=e.addOrUpdateProperties.findIndex((e=>e.key===n));t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(n.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(n.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(n.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(n.newGeometry=t.newGeometry||e.newGeometry),n}function ue(e){if(!e)return{};let t={};return t.removeAll=e.removeAll,t.remove=new Set(e.remove||[]),t.add=new Map(e.add?.map((e=>[e.id,e]))),t.update=new Map(e.update?.map((e=>[e.id,e]))),t}function de(e){return e&&e.length!==0?typeof e[0]==`number`?[e]:e.flatMap((e=>de(e))):[]}function fe(e){return e.type===`GeometryCollection`?e.geometries.flatMap((e=>fe(e))):de(e.coordinates)}function pe(e){let t=new re,n;switch(e.type){case`FeatureCollection`:n=e.features.flatMap((e=>fe(e.geometry)));break;case`Feature`:n=fe(e.geometry);break;default:n=fe(e)}if(n.length===0)return t;for(let e of n){let[n,r]=e;t.extend([n,r])}return t}class me extends t.E{constructor(e,n,r,i){super(),this.id=e,this.type=`geojson`,this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actor=r.getActor(),this.setEventedParent(i),this._data=typeof n.data==`string`?{url:n.data}:{geojson:n.data},this._options=t.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&t.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=t.e({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer===void 0?128:n.buffer),tolerance:this._pixelsToTileUnits(n.tolerance===void 0?.375:n.tolerance),extent:t.a6,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1,promoteId:typeof n.promoteId==`string`?n.promoteId:void 0,cluster:n.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:t.a6,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1}},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(t.a6/this.tileSize)}_getClusterMaxZoom(e){let n=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||t.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${n}"`),n}load(){return t._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(e){this.map=e,this.load()}setData(e,t){this._data=typeof e==`string`?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};let n=this._updateWorkerData();return t?n:this}updateData(e,t){this._pendingWorkerUpdate.diff=function(e,t){if(!e)return t||{};if(!t)return e||{};let n=ue(e),r=ue(t);(function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let n of t.remove)e.add.delete(n),e.update.delete(n);for(let[n,r]of t.update){let i=e.update.get(n);i&&(t.update.set(n,le(i,r)),e.update.delete(n))}})(n,r);let i={};if((n.removeAll||r.removeAll)&&(i.removeAll=!0),i.remove=new Set([...n.remove,...r.remove]),i.add=new Map([...n.add,...r.add]),i.update=new Map([...n.update,...r.update]),i.remove.size&&i.add.size)for(let e of i.add.keys())i.remove.delete(e);return function(e){let t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}(i)}(this._pendingWorkerUpdate.diff,e);let n=this._updateWorkerData();return t?n:this}getData(){return t._(this,void 0,void 0,(function*(){return this._data.url&&(yield this.once(`data`)),this._data.geojson?this._data.geojson:{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}}))}getBounds(){return t._(this,void 0,void 0,(function*(){return pe(yield this.getData())}))}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:`GCEZ`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:`GCC`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,t,n){return this.actor.sendAsync({type:`GCL`,data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:n}})}_updateWorkerData(){return t._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void t.w(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:e,diff:n,updateCluster:r}=this._pendingWorkerUpdate,i=this._getLoadGeoJSONParameters(e,n,r);e===void 0?n?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,yield this._dispatchWorkerUpdate(i)}))}_getLoadGeoJSONParameters(e,n,r){return t._(this,void 0,void 0,(function*(){let i=t.e({type:this.type},this.workerOptions);return typeof e==`string`?(i.request=yield this.map._requestManager.transformRequest(s.resolveURL(e),`Source`),i.request.collectResourceTiming=this._collectResourceTiming,i):e===void 0?n?(i.dataDiff=n,i):r?(i.updateCluster=!0,i):void 0:(i.data=e,i)}))}_dispatchWorkerUpdate(e){return t._(this,void 0,void 0,(function*(){this._isUpdatingWorker=!0,this.fire(new t.n(`dataloading`,{dataType:`source`}));try{let n=yield e,r=yield this.actor.sendAsync({type:`LD`,data:n});if(this._isUpdatingWorker=!1,this._removed||r.abandoned)return void this.fire(new t.n(`dataabort`,{dataType:`source`}));r.data&&(this._data={geojson:r.data});let i=this._applyDiffToSource(n.dataDiff),a=this._getShouldReloadTileOptions(i),o={dataType:`source`};this._applyResourceTiming(o,r),this.fire(new t.n(`data`,Object.assign(Object.assign({},o),{sourceDataType:`metadata`}))),this.fire(new t.n(`data`,Object.assign(Object.assign({},o),{sourceDataType:`content`,shouldReloadTileOptions:a})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.n(`dataabort`,{dataType:`source`}));this.fire(new t.l(t.d(e)))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyResourceTiming(e,n){if(!this._collectResourceTiming)return;let r=n.resourceTiming?.[this.id];if(!r)return;let i=r.slice(0);i!=null&&i.length&&t.e(e,{resourceTiming:i})}_applyDiffToSource(e){if(!e)return;let t=typeof this.promoteId==`string`?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let e=function(e,t){let n=new Map;if(e==null||e.type==null)return n;if(e.type===`Feature`){let r=ce(e,t);return r==null?void 0:(n.set(r,e),n)}if(e.type===`FeatureCollection`){let r=new Set;for(let i of e.features){let e=ce(i,t);if(e==null||r.has(e))return;r.add(e),n.set(e,i)}return n}}(this._data.geojson,t);if(!e)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;let n=function(e,t,n){let r=[];if(t.removeAll)e.clear();else if(t.remove)for(let n of t.remove){let t=e.get(n);t&&(r.push(t.geometry),e.delete(n))}if(t.add)for(let i of t.add){let t=ce(i,n);if(t==null)continue;let a=e.get(t);a&&r.push(a.geometry),r.push(i.geometry),e.set(t,i)}if(t.update)for(let n of t.update){let t=e.get(n.id);if(!t)continue;let i=!!n.newGeometry,a=n.removeAllProperties||n.removeProperties?.length>0||n.addOrUpdateProperties?.length>0;if(!i&&!a)continue;r.push(t.geometry);let o=Object.assign({},t);if(e.set(n.id,o),i&&(r.push(n.newGeometry),o.geometry=n.newGeometry),a){if(o.properties=n.removeAllProperties?{}:Object.assign({},o.properties||{}),n.removeProperties)for(let e of n.removeProperties)delete o.properties[e];if(n.addOrUpdateProperties)for(let{key:e,value:t}of n.addOrUpdateProperties)o.properties[e]=t}}return r}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:n}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map((e=>pe(e)))}}shouldReloadTile(e,{affectedBounds:n}){if(e.state===`loading`)return!0;if(e.state===`unloaded`)return!1;let{buffer:r,extent:i}=this.workerOptions.geojsonVtOptions,a=function({x:e,y:n,z:r},i=0){let a=t.a4((e-i)/2**r),o=t.a5((n+1+i)/2**r),s=t.a4((e+1+i)/2**r),c=t.a5((n-i)/2**r);return new re([a,o],[s,c])}(e.tileID.canonical,r/i);for(let e of n)if(a.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return t._(this,void 0,void 0,(function*(){let t=e.actor?`RT`:`LT`;e.actor=this.actor;let n={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;let r=yield this.actor.sendAsync({type:t,data:n},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,t===`RT`)}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:`RMT`,data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:`RS`,data:{type:this.type,source:this.id}})}serialize(){return t.e({},this._options,{type:this.type,data:this._data.updateable?{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class he extends t.E{constructor(e,t,n,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type=`image`,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.n(`dataloading`,{dataType:`source`})),this.url=this.options.url,this._request=new AbortController;try{let t=yield u.getImage(yield this.map._requestManager.transformRequest(this.url,`Image`),this._request);this._request=null,this._loaded=!0,t!=null&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&=(this._request.abort(),null),this.options.url=e.url,this.load(e.coordinates).finally((()=>this.texture=null)),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`metadata`})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&=(this._request.abort(),null)}setCoordinates(e){this.coordinates=e;let n=e.map(t.a7.fromLngLat);var r;return this.tileID=function(e){let n=t.a8.fromPoints(e),r=n.width(),i=n.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),o=2**a;return new t.aa(a,Math.floor((n.minX+n.maxX)/2*o),Math.floor((n.minY+n.maxY)/2*o))}(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`content`})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,n=e.gl;this.texture||(this.texture=new t.T(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,r=!0)}r&&this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID?.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state=`errored`}))}serialize(){return{type:`image`,url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:n,minY:r,maxX:i,maxY:a}=t.a8.fromPoints(e),o={};for(let e=0;e<=t.a9;e++){let t=2**e,s=Math.floor(n*t),c=Math.floor(r*t),l=Math.floor(i*t),u=Math.floor(a*t),d=(s%t+t)%t,f=l%t;o[e]={minWrap:Math.floor(s/t),maxWrap:Math.floor(l/t),minTileXWrapped:d,maxTileXWrapped:f,minTileY:c,maxTileY:u}}return o}}class ge extends he{constructor(e,t,n,r){super(e,t,n,r),this._onPlayingHandler=()=>{var e;(e=this.map)==null||e.triggerRepaint()},this.roundZoom=!0,this.type=`video`,this.options=t}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((yield this.map._requestManager.transformRequest(t,`Source`)).url);try{let e=yield t.ab(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener(`playing`,this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.l(t.d(e)))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new t.l(new t.ac(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener(`playing`,this._onPlayingHandler),this.video.pause())}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,n=e.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,r=!0)}r&&this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`video`,urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class _e extends he{constructor(e,n,r,i){super(e,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((e=>!Array.isArray(e)||e.length!==2||e.some((e=>typeof e!=`number`))))||this.fire(new t.l(new t.ac(`sources.${e}`,null,`"coordinates" property must be an array of 4 longitude/latitude array pairs`))):this.fire(new t.l(new t.ac(`sources.${e}`,null,`missing required property "coordinates"`))),n.animate&&typeof n.animate!=`boolean`&&this.fire(new t.l(new t.ac(`sources.${e}`,null,`optional "animate" property must be a boolean value`))),n.canvas?typeof n.canvas==`string`||n.canvas instanceof HTMLCanvasElement||this.fire(new t.l(new t.ac(`sources.${e}`,null,`"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance`))):this.fire(new t.l(new t.ac(`sources.${e}`,null,`missing required property "canvas"`))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.l(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(),!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,r=n.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new t.T(n,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let i=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,i=!0)}i&&this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`canvas`,animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}let ve={},ye=e=>{switch(e){case`geojson`:return me;case`image`:return he;case`raster`:return oe;case`raster-dem`:return se;case`vector`:return ae;case`video`:return ge;case`canvas`:return _e}return ve[e]},be=`RTLPluginLoaded`;class xe extends t.E{constructor(){super(...arguments),this.status=`unavailable`,this.url=null,this.dispatcher=ee()}_syncState(e){return this.status=e,this.dispatcher.broadcast(`SRPS`,{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status=`error`,e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status=`unavailable`,this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw Error(`setRTLTextPlugin cannot be called multiple times.`);if(this.url=s.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status===`unavailable`){if(!t)return this._requestImport();this.status=`deferred`,this._syncState(this.status)}else if(this.status===`requested`)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState(`loading`),this.status=`loaded`,this.fire(new t.n(be))}))}lazyLoad(){this.status===`unavailable`?this.status=`requested`:this.status===`deferred`&&this._requestImport()}}let Se=null;function Ce(){return Se||=new xe,Se}var we,Te;(function(e){e[e.Base=0]=`Base`,e[e.Parent=1]=`Parent`})(we||={}),function(e){e[e.Departing=0]=`Departing`,e[e.Incoming=1]=`Incoming`}(Te||={});class Ee{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ad(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state=`loading`}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:n,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=n,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=l(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state===`errored`||this.state===`loaded`||this.state===`reloading`}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,n,r){if(!0!==e?.etagUnmodified)if(this.hasData()&&this.unloadVectorData(),this.state=`loaded`,e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){let n={};if(!t)return n;for(let r of e){let e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(e.length!==0){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(let t of e)n[t.id]=r}}return n}(e.buckets,n?.style),this.hasSymbolBuckets=!1;for(let e in this.buckets){let n=this.buckets[e];if(n instanceof t.af){if(this.hasSymbolBuckets=!0,!r)break;n.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let n=this.buckets[e];if(n instanceof t.af&&n.hasRTLText){this.hasRTLText=!0,Ce().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ae;else this.state=`loaded`}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state=`unloaded`}getBucket(e){return this.buckets[e.id]}upload(e){for(let t in this.buckets){let n=this.buckets[t];n.uploadPending()&&n.upload(e)}let n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,n.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,a,o,s,c,l,u){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:i,scale:a,tileSize:this.tileSize,pixelPosMatrix:l,transform:s,params:o,queryPadding:this.queryPadding*c,getElevation:u},e,t,n):{}}querySourceFeatures(e,n){let r=this.latestFeatureIndex;if(!r?.rawTileData)return;let i=r.loadVTLayers(),a=n?.sourceLayer?n.sourceLayer:``,o=i[t.ag]||i[a];if(!o)return;let s=t.ah(n?.filter,n?.globalState),{z:c,x:l,y:u}=this.tileID.canonical,d={z:c,x:l,y:u};for(let n=0;n<o.length;n++){let i=o.feature(n);if(s.needGeometry){let e=t.ai(i,!0);if(!s.filter(new t.J(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new t.J(this.tileID.overscaledZ),i))continue;let f=r.getId(i,a),p=new t.aj(i,c,l,u,f);p.tile=d,e.push(p)}}hasData(){return this.state===`loaded`||this.state===`reloading`||this.state===`expired`}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let n=this.expirationTime;if(e.cacheControl){let n=t.ak(e.cacheControl);n[`max-age`]&&(this.expirationTime=Date.now()+1e3*n[`max-age`])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let e=Date.now(),t=!1;if(this.expirationTime>e)t=!1;else if(n)if(this.expirationTime<n)t=!0;else{let r=this.expirationTime-n;r?this.expirationTime=e+Math.max(r,3e4):t=!0}else t=!0;t?(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(),2**31-1)}setFeatureState(e,n){if(!this.latestFeatureIndex?.rawTileData||Object.keys(e).length===0)return;let r=this.latestFeatureIndex.loadVTLayers();for(let i in this.buckets){if(!n.style.hasLayer(i))continue;let a=this.buckets[i],o=a.layers[0].sourceLayer||t.ag,s=r[o],c=e[o];if(!s||!c||Object.keys(c).length===0)continue;a.update(c,s,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=(n?.style)?.getLayer(i);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(a)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<l()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=l()+e}setDependencies(e,t){let n={};for(let e of t)n[e]=!0;this.dependencies[e]=n}hasDependency(e,t){for(let n of e){let e=this.dependencies[n];if(e){for(let n of t)if(e[n])return!0}}return!1}}class De{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,n,r){var i,a;let o=String(n);if((i=this.stateChanges)[e]||(i[e]={}),(a=this.stateChanges[e])[o]||(a[o]={}),t.e(this.stateChanges[e][o],r),this.deletedStates[e]===null){this.deletedStates[e]={};for(let t in this.state[e])t!==o&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]?.[o]===null){this.deletedStates[e][o]={};for(let t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null)}else for(let t in r)this.deletedStates[e]?.[o]?.[t]===null&&delete this.deletedStates[e][o][t]}removeFeatureState(e,t,n){var r,i;if(this.deletedStates[e]===null)return;let a=String(t);if((r=this.deletedStates)[e]||(r[e]={}),n&&t!==void 0)this.deletedStates[e][a]!==null&&((i=this.deletedStates[e])[a]||(i[a]={}),this.deletedStates[e][a][n]=null);else if(t!==void 0)if(this.stateChanges[e]?.[a])for(n in this.deletedStates[e][a]={},this.stateChanges[e][a])this.deletedStates[e][a][n]=null;else this.deletedStates[e][a]=null;else this.deletedStates[e]=null}getState(e,n){let r=String(n),i=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let t=this.deletedStates[e][n];if(t===null)return{};for(let e in t)delete i[e]}return i}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,n){var r,i,a;let o={};for(let e in this.stateChanges){(r=this.state)[e]||(r[e]={});let n={};for(let r in this.stateChanges[e])(i=this.state[e])[r]||(i[r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),n[r]=this.state[e][r];o[e]=n}for(let e in this.deletedStates){(a=this.state)[e]||(a[e]={});let n={};if(this.deletedStates[e]===null)for(let t in this.state[e])n[t]={},this.state[e][t]={};else for(let t in this.deletedStates[e]){if(this.deletedStates[e][t]===null)this.state[e][t]={};else for(let n of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][n];n[t]=this.state[e][t]}o[e]||(o[e]={}),t.e(o[e],n)}this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0&&(this.revision++,e.setFeatureState(o,n))}}let Oe=89.25;function ke(e,n){let r=t.al(n.lat,-t.am,t.am);return new t.P(t.Z(n.lng)*e,t.Y(r)*e)}function Ae(e,n){return new t.a7(n.x/e,n.y/e).toLngLat()}function je(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.an(90-e.pitch)),Math.tan(t.an(Oe-e.pitch)))}function Me(e,n){let r=e.canonical,i=n/t.ao(r.z),a=r.x+2**r.z*e.wrap,o=t.ap(new Float64Array(16));return t.Q(o,o,[a*i,r.y*i,0]),t.S(o,o,[i/t.a6,i/t.a6,1]),o}function Ne(e,n,r,i,a){let o=t.a7.fromLngLat(e,n),s=a*t.aq(1,e.lat),{x:c,y:l,z:u}=Pe(r,i);return new t.a7(o.x+s*-c,o.y+s*-l,o.z+s*-u)}function Pe(e,n){let r=t.an(e),i=t.an(n),a=Math.cos(-r),o=Math.sin(r);return{x:o*Math.sin(i),y:-o*Math.cos(i),z:a}}function z(e,t,n){let r=t.intersectsFrustum(e);if(!n||r===0)return r;let i=t.intersectsPlane(n);return i===0?0:r===2&&i===2?2:1}function Fe(e,t,n){let r=0,i=(n-t)/10;for(let a=0;a<10;a++)r+=i*Math.cos(t+(a+.5)/10*(n-t))**+e;return r}function Ie(e,n){return function(r,i,a,o,s){let c=2*((e-1)/t.ar(Math.cos(t.an(Oe-s))/Math.cos(t.an(Oe)))-1),l=Math.acos(a/o),u=2*Fe(c-1,0,t.an(s/2)),d=Math.min(t.an(Oe),l+t.an(s/2)),f=Fe(c-1,Math.min(d,l-t.an(s/2)),d),p=Math.atan(i/a),m=Math.hypot(i,a),h=r;return h+=t.ar(o/m/Math.max(.5,Math.cos(t.an(s/2)))),h+=c*t.ar(Math.cos(p))/2,h-=t.ar(Math.max(1,f/u/n))/2,h}}let Le=Ie(9.314,3);function Re(e,n){let r=(n.roundZoom?Math.round:Math.floor)(e.zoom+t.ar(e.tileSize/n.tileSize));return Math.max(0,r)}function ze(e,n){let r=e.getCameraFrustum(),i=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),o=t.a7.fromLngLat(e.center,e.elevation);a.z=o.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;let s=e.getCoveringTilesDetailsProvider(),c=s.allowVariableZoom(e,n),l=Re(e,n),u=n.minzoom||0,d=n.maxzoom===void 0?e.maxZoom:n.maxzoom,f=Math.min(Math.max(0,l),d),p=2**f,m=[p*a.x,p*a.y,0],h=[p*o.x,p*o.y,0],g=Math.hypot(o.x-a.x,o.y-a.y),_=Math.abs(o.z-a.z),v=Math.hypot(g,_),y=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],x=[];if(e.renderWorldCopies&&s.allowWorldCopies())for(let e=1;e<=3;e++)b.push(y(-e)),b.push(y(e));for(b.push(y(0));b.length>0;){let p=b.pop(),g=p.x,y=p.y,S=p.fullyVisible,C={x:g,y,z:p.zoom},w=s.getTileBoundingVolume(C,p.wrap,e.elevation,n);if(!S){let e=z(r,w,i);if(e===0)continue;S=e===2}let T=s.distanceToTile2d(a.x,a.y,C,w),E=l;c&&(E=(n.calculateTileZoom||Le)(e.zoom+t.ar(e.tileSize/n.tileSize),T,_,v,e.fov)),E=(n.roundZoom?Math.round:Math.floor)(E),E=Math.max(0,E);let D=Math.min(E,d);if(p.wrap=s.getWrap(o,C,p.wrap),p.zoom>=D){if(p.zoom<u)continue;let e=f-p.zoom,r=m[0]-.5-(g<<e),i=m[1]-.5-(y<<e),a=n.reparseOverscaled?Math.max(p.zoom,E):p.zoom;x.push({tileID:new t.a3(p.zoom===d?a:p.zoom,p.wrap,p.zoom,g,y),distanceSq:t.as([h[0]-.5-g,h[1]-.5-y]),tileDistanceToCamera:Math.sqrt(r*r+i*i)})}else for(let e=0;e<4;e++)b.push({zoom:p.zoom+1,x:(g<<1)+e%2,y:(y<<1)+(e>>1),wrap:p.wrap,fullyVisible:S})}return x.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}let Be=t.a8.fromPoints([new t.P(0,0),new t.P(t.a6,t.a6)]);function Ve(e){return e===`raster`||e===`image`||e===`video`}function He(e,t,n,r,i,a,o){if(!t.hasData())return!1;let{tileID:s,fadingRole:c,fadingDirection:l,fadingParentID:u}=t;if(c===we.Base&&l===Te.Incoming&&u)return n[u.key]=u,!0;let d=Math.max(s.overscaledZ-i,a);for(let i=s.overscaledZ-1;i>=d;i--){let a=s.scaledTo(i),c=e.getLoadedTile(a);if(c)return t.setCrossFadeLogic({fadingRole:we.Base,fadingDirection:Te.Incoming,fadingParentID:c.tileID,fadeEndTime:r+o}),c.setCrossFadeLogic({fadingRole:we.Parent,fadingDirection:Te.Departing,fadeEndTime:r+o}),n[a.key]=a,!0}return!1}function Ue(e,t,n,r,i,a){if(!t.hasData())return!1;let o=t.tileID.children(i),s=We(e,t,o,n,r,i,a);if(s)return!0;for(let c of o)We(e,t,c.children(i),n,r,i,a)&&(s=!0);return s}function We(e,t,n,r,i,a,o){if(n[0].overscaledZ>=a)return!1;let s=!1;for(let a of n){let n=e.getLoadedTile(a);if(!n)continue;let{fadingRole:c,fadingDirection:l,fadingParentID:u}=n;c===we.Base&&l===Te.Departing&&u||(n.setCrossFadeLogic({fadingRole:we.Base,fadingDirection:Te.Departing,fadingParentID:t.tileID,fadeEndTime:i+o}),t.setCrossFadeLogic({fadingRole:we.Parent,fadingDirection:Te.Incoming,fadeEndTime:i+o})),r[a.key]=a,s=!0}return s}function Ge(e,t,n,r){let i=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(i)&&(e.setSelfFadeLogic(n+r),!0)}function B(e,t){var n;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x,i=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,o=t.tileID.key;r===0&&i===0||Math.abs(i)>1||(Math.abs(r)>1&&(Math.abs(r+a)===1?r+=a:Math.abs(r-a)===1&&(r-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),(n=e.neighboringTiles)!=null&&n[o]&&(e.neighboringTiles[o].backfilled=!0)))}class Ke{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let n in this._tiles){let r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t){for(let n in this._tiles)this._tiles[n].setFeatureState(e,t)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(t.au).map((e=>e.key)):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let t=this.getTileById(e.key);return t?.hasData()?t:null}isIdRenderable(e,t=!1){return this.getTileById(e)?.isRenderable(t)}getRenderableIds(e=0,n){let r=[];for(let e of this.getAllIds())this.isIdRenderable(e,n)&&r.push(this.getTileById(e));return n?r.sort(((n,r)=>{let i=n.tileID,a=r.tileID,o=new t.P(i.canonical.x,i.canonical.y)._rotate(-e),s=new t.P(a.canonical.x,a.canonical.y)._rotate(-e);return i.overscaledZ-a.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):r.map((e=>e.tileID)).sort(t.au).map((e=>e.key))}}class qe extends t.E{constructor(e,n,r){super(),this.id=e,this.dispatcher=r,this.on(`data`,(e=>{this._dataHandler(e)})),this.on(`dataloading`,(()=>{this._sourceErrored=!1})),this.on(`error`,(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,t,n,r)=>{let i=new(ye(t.type))(e,t,n,r);if(i.id!==e)throw Error(`Expected Source id to be ${e} instead of ${i.id}`);return i})(e,n,r,this),this._inViewTiles=new Ke,this._outOfViewCache=new t.av(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new De,this._didEmitContent=!1,this._updated=!1}onAdd(e){var t;this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,(t=this._source)!=null&&t.onAdd&&this._source.onAdd(e)}onRemove(e){var t;for(let e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),(t=this._source)!=null&&t.onRemove&&this._source.onRemove(e),this._inViewTiles=new Ke}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,r){return t._(this,void 0,void 0,(function*(){try{let t=yield this._source.loadTile(e);this._tileLoaded(e,n,r,t)}catch(n){e.state=`errored`,n.status===404?this.update(this.transform,this.terrain):this._source.fire(new t.l(t.d(n),{tile:e}))}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.n(`dataabort`,{tile:e,coord:e.tileID,dataType:`source`}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,e)}hasRenderableParent(e){let t=e.overscaledZ-1;if(t>=this._source.minzoom){let n=this.getLoadedTile(e.scaledTo(t));if(n)return this._inViewTiles.isIdRenderable(n.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let n of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(n);t&&!this._source.shouldReloadTile(r,t)||(e?this._reloadTile(n,`expired`):r.state!==`errored`&&this._reloadTile(n,`reloading`))}}}_reloadTile(e,n){return t._(this,void 0,void 0,(function*(){let t=this._inViewTiles.getTileById(e);t&&(t.state!==`loading`&&(t.state=n),yield this._loadTile(t,e,n))}))}_tileLoaded(e,n,r,i){e.timeAdded=l(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),r===`expired`&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),i!=null&&i.unmodified||(this.getSource().type===`raster-dem`&&e.dem&&function(e,t){var n;let r=t.getRenderableIds();for(let i of r){if(!e.neighboringTiles?.[i])continue;let r=t.getTileById(i);e.neighboringTiles[i].backfilled||B(e,r),(n=r.neighboringTiles?.[e.tileID.key])!=null&&n.backfilled||B(r,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.n(`data`,{dataType:`source`,tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,t){let n=this._getLoadedDescendents(t),r=new Set;for(let i of t){let t=n[i.key];if(!t?.length){r.add(i);continue}let a=i.overscaledZ+qe.maxOverzooming,o=t.filter((e=>e.tileID.overscaledZ<=a));if(!o.length){r.add(i);continue}let s=Math.min(...o.map((e=>e.tileID.overscaledZ))),c=o.filter((e=>e.tileID.overscaledZ===s)).map((e=>e.tileID));for(let t of c)e[t.key]=t;this._areDescendentsComplete(c,s,i.overscaledZ)||r.add(i)}return r}_getLoadedDescendents(e){var t;let n={};for(let r of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(let i of e)r.tileID.isChildOf(i)&&(n[t=i.key]||(n[t]=[]),n[i.key].push(r));return n}_areDescendentsComplete(e,t,n){return e.length===1&&e[0].isOverscaled()?e[0].overscaledZ===t:4**(t-n)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){let n=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,i=Math.floor(n*r*(this._maxTileCacheZoomLevels===null?t.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a=typeof this._maxTileCacheSize==`number`?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(a)}handleWrapJump(e){let t=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);this._prevLng=e,t&&(this._inViewTiles.handleWrapJump(t),this._resetTileReloadTimers())}update(e,n){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.a3(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=ze(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type===`vector`&&this.map._zoomLevelsToOverscale!==void 0?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[],this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let i=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,i&&this.fire(new t.n(`data`,{sourceDataType:`idle`,dataType:`source`,sourceId:this.id}));let a=Re(e,this._source),o=this._updateRetainedTiles(r,a),s=Ve(this._source.type);s&&this._rasterFadeDuration>0&&!n&&function(e,n,r,i,a,o,s){let c=l(),u=t.at(n);for(let t of n){let n=e.getTileById(t.key);n.fadingDirection!==Te.Departing&&n.fadeOpacity!==0||n.resetFadeLogic(),He(e,n,r,c,i,a,s)||Ue(e,n,r,c,o,s)||Ge(n,u,c,s)||n.resetFadeLogic()}}(this._inViewTiles,r,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(e){for(let t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(let t of this._inViewTiles.getAllIds()){let n=this._inViewTiles.getTileById(t);e[t]?n.clearSymbolFadeHold():n.hasSymbolBuckets?n.holdingForSymbolFade()?n.symbolFadeFinished()&&this._removeTile(t):n.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){let t=[];for(let n of e)if(n.canonical.z>this._source.minzoom){let e=n.scaledTo(n.canonical.z-1);t.push(e);let r=n.scaledTo(Math.max(this._source.minzoom,Math.min(n.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(let e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){let n=new Set;for(let t of e)this._addTile(t).hasData()||n.add(t);let r=e.reduce(((e,t)=>(e[t.key]=t,e)),{}),i=this._retainLoadedChildren(r,n),a={},o=Math.max(t-qe.maxUnderzooming,this._source.minzoom);for(let e of i){let t=this._inViewTiles.getTileById(e.key),n=t?.wasRequested();for(let i=e.overscaledZ-1;i>=o;--i){let o=e.scaledTo(i);if(a[o.key])break;if(a[o.key]=!0,t=this.getTile(o),!t&&n&&(t=this._addTile(o)),t){let e=t.hasData();if((e||!this.map?.cancelPendingTileRequestsWhileZooming||n)&&(r[o.key]=o),n=t.wasRequested(),e)break}}}return r}_addTile(e){let n=this._inViewTiles.getTileById(e.key);if(n)return n;n=this._outOfViewCache.getAndRemove(e),n&&(n.resetFadeLogic(),this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null));let r=n;return n||(n=new Ee(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._inViewTiles.setTile(e.key,n),r||this._source.fire(new t.n(`dataloading`,{tile:n,coord:n.tileID,dataType:`source`})),n}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);let n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,`expired`),delete this._timers[e]}),n))}_clearTileReloadTimer(e){let t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(let e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(let e of this._inViewTiles.getAllIds()){let t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(let t of this._inViewTiles.getAllIds()){let n=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||n.state==`errored`)&&e.some((e=>e.equals(n.tileID.canonical)))&&this._reloadTile(t,`expired`)}}_removeTile(e){let t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),t.uses>0||(t.hasData()&&t.state!==`reloading`?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){e.dataType===`source`&&(e.sourceDataType===`metadata`?this._sourceLoaded=!0:e.sourceDataType===`content`&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,n,r){let i=[],a=this.transform;if(!a)return i;let o=a.getCoveringTilesDetailsProvider().allowWorldCopies(),s=r?a.getCameraQueryGeometry(e):e,c=e=>a.screenPointToMercatorCoordinate(e,this.terrain),l=this.transformBbox(e,c,!o),u=this.transformBbox(s,c,!o),d=this.getIds(),f=t.a8.fromPoints(u);for(let e of d){let r=this._inViewTiles.getTileById(e);if(r.holdingForSymbolFade())continue;let s=o?[r.tileID]:[r.tileID.unwrapTo(-1),r.tileID.unwrapTo(0)],c=2**(a.zoom-r.tileID.overscaledZ),d=n*r.queryPadding*t.a6/r.tileSize/c;for(let e of s){let n=f.map((n=>e.getTilePoint(new t.a7(n.x,n.y))));if(n.expandBy(d),n.intersects(Be)){let t=l.map((t=>e.getTilePoint(t))),n=u.map((t=>e.getTilePoint(t)));i.push({tile:r,tileID:o?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:n,scale:c})}}}return i}transformBbox(e,n,r){let i=e.map(n);if(r){let r=t.a8.fromPoints(e);r.shrinkBy(.001*Math.min(r.width(),r.height()));let a=r.map(n);t.a8.fromPoints(i).covers(a)||(i=i.map((e=>e.x>.5?new t.a7(e.x-1,e.y,e.z):e)))}return i}getVisibleCoordinates(e){let t=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){return!!this._source.hasTransition()||Ve(this._source.type)&&function(e,t){if(t<=0)return!1;let n=l();for(let t of e.getAllTiles())if(t.fadeEndTime>=n)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,n,r){e||=t.ag,this._state.updateState(e,n,r)}removeFeatureState(e,n,r){e||=t.ag,this._state.removeFeatureState(e,n,r)}getFeatureState(e,n){return e||=t.ag,this._state.getState(e,n)}setDependencies(e,t,n){let r=this._inViewTiles.getTileById(e);r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(let n of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(n).hasDependency(e,t)&&this._reloadTile(n,`reloading`);this._outOfViewCache.filter((n=>!n.hasDependency(e,t)))}areTilesLoaded(){for(let e of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)return!1;return!0}}qe.maxUnderzooming=10,qe.maxOverzooming=3;class Je{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=t.al(e,0,1);let n=1,r=this._distances[n],i=e*this.paddedLength+this.padding;for(;r<i&&n<this._distances.length;)r=this._distances[++n];let a=n-1,o=this._distances[a],s=r-o,c=s>0?(i-o)/s:0;return this.points[a].mult(1-c).add(this.points[n].mult(c))}}function Ye(e,t){let n=!0;return e===`always`||e!==`never`&&t!==`never`||(n=!1),n}class V{constructor(e,t,n){let r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),i.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,n,r,i){this._forEachCell(t,n,r,i,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)}insertCircle(e,t,n,r){this._forEachCell(t-r,n-r,t+r,n+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(n),this.circles.push(r)}_insertBoxCell(e,t,n,r,i,a){this.boxCells[i].push(a)}_insertCircleCell(e,t,n,r,i,a){this.circleCells[i].push(a)}_query(e,t,n,r,i,a,o){if(n<0||e>this.width||r<0||t>this.height)return[];let s=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return[{key:null,x1:e,y1:t,x2:n,y2:r}];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++){let t=this.circles[3*e],n=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:n-r,x2:t+r,y2:n+r})}}else this._forEachCell(e,t,n,r,this._queryCell,s,{hitTest:i,overlapMode:a,seenUids:{box:{},circle:{}}},o);return s}query(e,t,n,r){return this._query(e,t,n,r,!1,null)}hitTest(e,t,n,r,i,a){return this._query(e,t,n,r,!0,i,a).length>0}hitTestCircle(e,t,n,r,i){let a=e-n,o=e+n,s=t-n,c=t+n;if(o<0||a>this.width||c<0||s>this.height)return!1;let l=[];return this._forEachCell(a,s,o,c,this._queryCellCircle,l,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),l.length>0}_queryCell(e,t,n,r,i,a,o,s){let{seenUids:c,hitTest:l,overlapMode:u}=o,d=this.boxCells[i],f=1e-6;if(d!==null){let i=this.bboxes;for(let o of d)if(!c.box[o]){c.box[o]=!0;let d=4*o,p=this.boxKeys[o];if(e<=i[d+2]+f&&t<=i[d+3]+f&&n>=i[d+0]-f&&r>=i[d+1]-f&&(!s||s(p))&&(!l||!Ye(u,p.overlapMode))&&(a.push({key:p,x1:i[d],y1:i[d+1],x2:i[d+2],y2:i[d+3]}),l))return!0}}let p=this.circleCells[i];if(p!==null){let i=this.circles;for(let o of p)if(!c.circle[o]){c.circle[o]=!0;let d=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(i[d],i[d+1],i[d+2],e,t,n,r)&&(!s||s(f))&&(!l||!Ye(u,f.overlapMode))){let e=i[d],t=i[d+1],n=i[d+2];if(a.push({key:f,x1:e-n,y1:t-n,x2:e+n,y2:t+n}),l)return!0}}}return!1}_queryCellCircle(e,t,n,r,i,a,o,s){let{circle:c,seenUids:l,overlapMode:u}=o,d=this.boxCells[i];if(d!==null){let e=this.bboxes;for(let t of d)if(!l.box[t]){l.box[t]=!0;let n=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(c.x,c.y,c.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(r))&&!Ye(u,r.overlapMode))return a.push(!0),!0}}let f=this.circleCells[i];if(f!==null){let e=this.circles;for(let t of f)if(!l.circle[t]){l.circle[t]=!0;let n=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[n],e[n+1],e[n+2],c.x,c.y,c.radius)&&(!s||s(r))&&!Ye(u,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToXCellCoord(e),l=this._convertToYCellCoord(t),u=this._convertToXCellCoord(n),d=this._convertToYCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++)if(i.call(this,e,t,n,r,this.xCellCount*c+f,a,o,s))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,n,r,i,a){let o=r-e,s=i-t,c=n+a;return c*c>o*o+s*s}_circleAndRectCollide(e,t,n,r,i,a,o){let s=(a-r)/2,c=Math.abs(e-(r+s));if(c>s+n)return!1;let l=(o-i)/2,u=Math.abs(t-(i+l));if(u>l+n)return!1;if(c<=s||u<=l)return!0;let d=c-s,f=u-l;return d*d+f*f<=n*n}}function Xe(e,t){let n=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),i=t[0]*n,a=t[4]*n,o=t[8]*r,s=t[1]*n,c=t[5]*n,l=t[9]*r,u=t[2]*n,d=t[6]*n,f=t[10]*r;e[0]=i,e[1]=a,e[2]=o,e[4]=s,e[5]=c,e[6]=l,e[8]=u,e[9]=d,e[10]=f;let p=t[12],m=t[13],h=t[14];return e[12]=-i*p-s*m-u*h,e[13]=-a*p-c*m-d*h,e[14]=-o*p-l*m-f*h,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}let Ze=t.O();function H(e,n,i){let a=t.O();if(!e){let{vecSouth:e,vecEast:t}=$e(n),i=r();i[0]=t[0],i[1]=t[1],i[2]=e[0],i[3]=e[1],o=i,(f=(c=(s=i)[0])*(d=s[3])-(u=s[2])*(l=s[1]))&&(o[0]=d*(f=1/f),o[1]=-l*f,o[2]=-u*f,o[3]=c*f),a[0]=i[0],a[1]=i[1],a[4]=i[2],a[5]=i[3]}var o,s,c,l,u,d,f;return t.S(a,a,[1/i,1/i,1]),a}function Qe(e,n,r,i){if(e){let e=t.O();if(!n){let{vecSouth:t,vecEast:n}=$e(r);e[0]=n[0],e[1]=n[1],e[4]=t[0],e[5]=t[1]}return t.S(e,e,[i,i,1]),e}return r.pixelsToClipSpaceMatrix}function $e(e){let n=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),i=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),o=Math.sin(e.bearingInRadians),s=t.az();s[0]=-a*i*r-o*n,s[1]=-o*i*r+a*n;let c=t.aA(s);c<1e-9?t.aB(s):t.aC(s,s,1/c);let l=t.az();l[0]=a*i*n-o*r,l[1]=o*i*n+a*r;let u=t.aA(l);return u<1e-9?t.aB(l):t.aC(l,l,1/u),{vecEast:l,vecSouth:s}}function et(e,n,r,i){let a;i?(a=[e,n,i(e,n),1],t.aE(a,a,r)):(a=[e,n,0,1],gt(a,a,r));let o=a[3];return{point:new t.P(a[0]/o,a[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}function tt(e,t){return .5+e/t*.5}function nt(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function U(e,n,r,i,a,o,s,c,l,u,d,f,p){let m=r?e.textSizeData:e.iconSizeData,h=t.aw(m,n.transform.zoom),g=[256/n.width*2+1,256/n.height*2+1],_=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let v=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=n.transform.width/n.transform.height,x=!1;for(let r=0;r<y.length;r++){let S=y.get(r);if(S.hidden||S.writingMode===t.ax.vertical&&!x){ht(S.numGlyphs,_);continue}x=!1;let C=new t.P(S.anchorX,S.anchorY),w={getElevation:p,pitchedLabelPlaneMatrix:i,lineVertexArray:v,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:n.transform,tileAnchorPoint:C,unwrappedTileID:l,width:u,height:d,translation:f},T=ut(S.anchorX,S.anchorY,w);if(!nt(T.point,g)){ht(S.numGlyphs,_);continue}let E=tt(n.transform.cameraToCenterDistance,T.signedDistanceFromCamera),D=t.ay(m,h,S),O=o?D*n.transform.getPitchedTextCorrection(S.anchorX,S.anchorY,l)/E:D*E,k=at({projectionContext:w,pitchedLabelPlaneMatrixInverse:a,symbol:S,fontSize:O,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:b,rotateToLine:c});x=k.useVertical,(k.notEnoughRoom||x||k.needsFlipping&&at({projectionContext:w,pitchedLabelPlaneMatrixInverse:a,symbol:S,fontSize:O,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:b,rotateToLine:c}).notEnoughRoom)&&ht(S.numGlyphs,_)}r?e.text.dynamicLayoutVertexBuffer.updateData(_):e.icon.dynamicLayoutVertexBuffer.updateData(_)}function rt(e,t,n,r,i,a,o,s){let c=a.glyphStartIndex+a.numGlyphs,l=a.lineStartIndex,u=a.lineStartIndex+a.lineLength,d=t.getoffsetX(a.glyphStartIndex),f=t.getoffsetX(c-1),p=pt(e*d,n,r,i,a.segment,l,u,s,o);if(!p)return null;let m=pt(e*f,n,r,i,a.segment,l,u,s,o);return m?s.projectionCache.anyProjectionOccluded?null:{first:p,last:m}:null}function it(e,n,r,i){return e===t.ax.horizontal&&Math.abs(r.y-n.y)>Math.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.ax.vertical?n.y<r.y:n.x>r.x)?{needsFlipping:!0}:null}function at(e){let{projectionContext:n,pitchedLabelPlaneMatrixInverse:r,symbol:i,fontSize:a,flip:o,keepUpright:s,glyphOffsetArray:c,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:d}=e,f=a/24,p=i.lineOffsetX*f,m=i.lineOffsetY*f,h;if(i.numGlyphs>1){let e=i.glyphStartIndex+i.numGlyphs,t=i.lineStartIndex,a=i.lineStartIndex+i.lineLength,l=rt(f,c,p,m,o,i,d,n);if(!l)return{notEnoughRoom:!0};let g=lt(l.first.point.x,l.first.point.y,n,r),_=lt(l.last.point.x,l.last.point.y,n,r);if(s&&!o){let e=it(i.writingMode,g,_,u);if(e)return e}h=[l.first];for(let r=i.glyphStartIndex+1;r<e-1;r++){let e=pt(f*c.getoffsetX(r),p,m,o,i.segment,t,a,n,d);if(!e)return{notEnoughRoom:!0};h.push(e)}h.push(l.last)}else{if(s&&!o){let e=ct(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,a=i.lineStartIndex+i.segment+1,o=new t.P(n.lineVertexArray.getx(a),n.lineVertexArray.gety(a)),s=ct(o.x,o.y,n),c=s.signedDistanceFromCamera>0?s.point:ot(n.tileAnchorPoint,o,e,1,n),l=lt(e.x,e.y,n,r),d=lt(c.x,c.y,n,r),f=it(i.writingMode,l,d,u);if(f)return f}let e=pt(f*c.getoffsetX(i.glyphStartIndex),p,m,o,i.segment,i.lineStartIndex,i.lineStartIndex+i.lineLength,n,d);if(!e||n.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};h=[e]}for(let e of h)t.aD(l,e.point,e.angle);return{}}function ot(e,t,n,r,i){let a=e.add(e.sub(t)._unit()),o=ct(a.x,a.y,i).point,s=n.sub(o);return n.add(s._mult(r/s.mag()))}function st(e,n,r){let i=n.projectionCache;if(i.projections[e])return i.projections[e];let a=new t.P(n.lineVertexArray.getx(e),n.lineVertexArray.gety(e)),o=ct(a.x,a.y,n);if(o.signedDistanceFromCamera>0)return i.projections[e]=o.point,i.anyProjectionOccluded||=o.isOccluded,o.point;let s=e-r.direction;return ot(r.distanceFromAnchor===0?n.tileAnchorPoint:new t.P(n.lineVertexArray.getx(s),n.lineVertexArray.gety(s)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,n)}function ct(e,t,n){let r=e+n.translation[0],i=t+n.translation[1],a;return n.pitchWithMap?(a=et(r,i,n.pitchedLabelPlaneMatrix,n.getElevation),a.isOccluded=!1):(a=n.transform.projectTileCoordinates(r,i,n.unwrappedTileID,n.getElevation),a.point.x=(.5*a.point.x+.5)*n.width,a.point.y=(.5*-a.point.y+.5)*n.height),a}function lt(e,n,r,i){if(r.pitchWithMap){let a=[e,n,0,1];return t.aE(a,a,i),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return{x:e/r.width*2-1,y:1-n/r.height*2}}function ut(e,t,n){return n.transform.projectTileCoordinates(e,t,n.unwrappedTileID,n.getElevation)}function dt(e,t,n){return e._unit()._perp()._mult(t*n)}function ft(e,n,r,i,a,o,s,c,l){if(c.projectionCache.offsets[e])return c.projectionCache.offsets[e];let u=r.add(n);if(e+l.direction<i||e+l.direction>=a)return c.projectionCache.offsets[e]=u,u;let d=st(e+l.direction,c,l),f=dt(d.sub(r),s,l.direction),p=r.add(f),m=d.add(f);return c.projectionCache.offsets[e]=t.aF(o,u,p,m)||u,c.projectionCache.offsets[e]}function pt(e,t,n,r,i,a,o,s,c){let l=r?e-t:e+t,u=l>0?1:-1,d=0;r&&(u*=-1,d=Math.PI),u<0&&(d+=Math.PI);let f,p=u>0?a+i:a+i+1;s.projectionCache.cachedAnchorPoint?f=s.projectionCache.cachedAnchorPoint:(f=ct(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=f);let m,h,g=f,_=f,v=0,y=0,b=Math.abs(l),x=[],S;for(;v+y<=b;){if(p+=u,p<a||p>=o)return null;v+=y,_=g,h=m;let e={absOffsetX:b,direction:u,distanceFromAnchor:v,previousVertex:_};if(g=st(p,s,e),n===0)x.push(_),S=g.sub(_);else{let t,r=g.sub(_);t=r.mag()===0?dt(st(p+u,s,e).sub(g),n,u):dt(r,n,u),h||=_.add(t),m=ft(p,t,g,a,o,h,n,s,e),x.push(h),S=m.sub(h)}y=S.mag()}let C=S._mult((b-v)/y)._add(h||_),w=d+Math.atan2(g.y-_.y,g.x-_.x);return x.push(C),{point:C,angle:c?w:0,path:x}}let mt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ht(e,t){for(let n=0;n<e;n++){let e=t.length;t.resize(e+4),t.float32.set(mt,3*e)}}function gt(e,t,n){let r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e[3]=n[3]*r+n[7]*i+n[15],e}class _t{constructor(e,t=new V(e.width+200,e.height+200,25),n=new V(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=n,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,n,r,i,a,o,s,c,l,u,d){let f=this.projectAndGetPerspectiveRatio(e.anchorPointX+s[0],e.anchorPointY+s[1],i,l,d),p=n*f.perspectiveRatio,m;if(a||o)m=this._projectCollisionBox(e,p,r,i,a,o,s,f,l,u,d);else{let t=f.x+(u?u.x*p:0),n=f.y+(u?u.y*p:0);m={allPointsOccluded:!1,box:[t+e.x1*p,n+e.y1*p,t+e.x2*p,n+e.y2*p]}}let[h,g,_,v]=m.box,y=a?m.allPointsOccluded:f.isOccluded,b=y;return b||=f.perspectiveRatio<this.perspectiveRatioCutoff,b||=!this.isInsideGrid(h,g,_,v),b||t!==`always`&&this.grid.hitTest(h,g,_,v,t,c)?{box:[h,g,_,v],placeable:!1,offscreen:!1,occluded:y}:{box:[h,g,_,v],placeable:!0,offscreen:this.isOffscreen(h,g,_,v),occluded:y}}placeCollisionCircles(e,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=[],g=new t.P(n.anchorX,n.anchorY),_=this.getPerspectiveRatio(g.x,g.y,o,m),v=(l?a*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,o)/_:a*_)/t.aJ,y={getElevation:m,pitchedLabelPlaneMatrix:s,lineVertexArray:r,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:o,width:this.transform.width,height:this.transform.height,translation:p},b=rt(v,i,n.lineOffsetX*v,n.lineOffsetY*v,!1,n,!1,y),x=!1,S=!1,C=!0;if(b){let n=.5*d*_+f,r=new t.P(-100,-100),i=new t.P(this.screenRightBoundary,this.screenBottomBoundary),a=new Je,o=b.first,s=b.last,p=[];for(let e=o.path.length-1;e>=1;e--)p.push(o.path[e]);for(let e=1;e<s.path.length;e++)p.push(s.path[e]);let m=2.5*n;if(l){let e=this.projectPathToScreenSpace(p,y);p=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let g=[];if(p.length>0){let e=p[0].clone(),n=p[0].clone();for(let t=1;t<p.length;t++)e.x=Math.min(e.x,p[t].x),e.y=Math.min(e.y,p[t].y),n.x=Math.max(n.x,p[t].x),n.y=Math.max(n.y,p[t].y);g=e.x>=r.x&&n.x<=i.x&&e.y>=r.y&&n.y<=i.y?[p]:n.x<r.x||e.x>i.x||n.y<r.y||e.y>i.y?[]:t.aG([p],r.x,r.y,i.x,i.y)}for(let t of g){a.reset(t,.25*n);let r=0;r=a.length<=.5*n?1:Math.ceil(a.paddedLength/m)+1;for(let t=0;t<r;t++){let i=t/Math.max(r-1,1),o=a.lerp(i),s=o.x+100,l=o.y+100;h.push(s,l,n,0);let d=s-n,f=l-n,p=s+n,m=l+n;if(C&&=this.isOffscreen(d,f,p,m),S||=this.isInsideGrid(d,f,p,m),e!==`always`&&this.grid.hitTestCircle(s,l,n,e,u)&&(x=!0,!c))return{circles:[],offscreen:!1,collisionDetected:x}}}}return{circles:!c&&x||!S||_<this.perspectiveRatioCutoff?[]:h,offscreen:C,collisionDetected:x}}projectPathToScreenSpace(e,t){return function(e){let t=0,n=0,r=0,i=0;for(let a=0;a<e.length;a++)e[a].isOccluded?(r=a+1,i=0):(i++,i>n&&(n=i,t=r));return e.slice(t,t+n)}(function(e,t){let n=Ze;return function(e,t){let n=1/(t[0]*t[5]-t[1]*t[4]);e[0]=t[5]*n,e[1]=-t[1]*n,e[2]=0,e[3]=0,e[4]=-t[4]*n,e[5]=t[0]*n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15]}(n,t.pitchedLabelPlaneMatrix),e.map((e=>{let r=et(e.x,e.y,n,t.getElevation),i=t.transform.projectTileCoordinates(r.point.x,r.point.y,t.unwrappedTileID,t.getElevation);return i.point.x=(.5*i.point.x+.5)*t.width,i.point.y=(.5*-i.point.y+.5)*t.height,i}))}(e,t))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let n=[],r=new t.a8;for(let i of e){let e=new t.P(i.x+100,i.y+100);r.extend(e),n.push(e)}let{minX:i,minY:a,maxX:o,maxY:s}=r,c=this.grid.query(i,a,o,s).concat(this.ignoredGrid.query(i,a,o,s)),l={},u={};for(let e of c){let r=e.key;if(l[r.bucketInstanceId]===void 0&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;let i=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aH(n,i)&&(l[r.bucketInstanceId][r.featureIndex]=!0,u[r.bucketInstanceId]===void 0&&(u[r.bucketInstanceId]=[]),u[r.bucketInstanceId].push(r.featureIndex))}return u}insertCollisionBox(e,t,n,r,i,a){(n?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:i,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,n,r,i,a){let o=n?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:i,collisionGroupID:a,overlapMode:t};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,n,r,i,a){if(a){let r;i?(r=[e,n,i(e,n),1],t.aE(r,r,a)):(r=[e,n,0,1],gt(r,r,a));let o=r[3];return{x:(r[0]/o+1)/2*this.transform.width+100,y:(-r[1]/o+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/o*.5,isOccluded:!1,signedDistanceFromCamera:o}}{let t=this.transform.projectTileCoordinates(e,n,r,i);return{x:(t.point.x+1)/2*this.transform.width+100,y:(1-t.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/t.signedDistanceFromCamera*.5,isOccluded:t.isOccluded,signedDistanceFromCamera:t.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,n,r){let i=this.transform.projectTileCoordinates(e,t,n,r);return .5+this.transform.cameraToCenterDistance/i.signedDistanceFromCamera*.5}isOffscreen(e,t,n,r){return n<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=t.ap([]);return t.Q(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,r,i,a,o,s,c,l,u,d){let f=1,p=0,m=0,h=1,g=e.anchorPointX+s[0],_=e.anchorPointY+s[1];if(o&&!a){let e=this.projectAndGetPerspectiveRatio(g+1,_,i,l,d),t=e.x-c.x,n=Math.atan((e.y-c.y)/t)+(t<0?Math.PI:0),r=Math.sin(n),a=Math.cos(n);f=a,p=r,m=-r,h=a}else if(!o&&a){let e=$e(this.transform);f=e.vecEast[0],p=e.vecEast[1],m=e.vecSouth[0],h=e.vecSouth[1]}let v=c.x,y=c.y,b=n;a&&(v=g,y=_,b=2**-(this.transform.zoom-r.overscaledZ),b*=this.transform.getPitchedTextCorrection(g,_,i),u||(b*=t.al(.5+c.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),u&&(v+=f*u.x*b+m*u.y*b,y+=p*u.x*b+h*u.y*b);let x=e.x1*b,S=e.x2*b,C=(x+S)/2,w=e.y1*b,T=e.y2*b,E=(w+T)/2,D=[{offsetX:x,offsetY:w},{offsetX:C,offsetY:w},{offsetX:S,offsetY:w},{offsetX:S,offsetY:E},{offsetX:S,offsetY:T},{offsetX:C,offsetY:T},{offsetX:x,offsetY:T},{offsetX:x,offsetY:E}],O=[];for(let{offsetX:e,offsetY:n}of D)O.push(new t.P(v+f*e+m*n,y+p*e+h*n));let k=!1;if(a){let e=O.map((e=>this.projectAndGetPerspectiveRatio(e.x,e.y,i,l,d)));k=e.some((e=>!e.isOccluded)),O=e.map((e=>new t.P(e.x,e.y)))}else k=!0;return{box:t.aI(O),allPointsOccluded:!k}}}class vt{constructor(e,t,n,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&n?1:0,this.placed=n}isHidden(){return this.opacity===0&&!this.placed}}class yt{constructor(e,t,n,r,i){this.text=new vt(e?e.text:null,t,n,i),this.icon=new vt(e?e.icon:null,t,r,i)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class bt{constructor(e,t,n){this.text=e,this.icon=t,this.skipFade=n}}class xt{constructor(e,t,n,r,i){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i}}class St{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function Ct(e,n,r,i,a){let{horizontalAlign:o,verticalAlign:s}=t.aP(e);return new t.P(-(o-.5)*n+i[0]*a,-(s-.5)*r+i[1]*a)}class wt{constructor(e,t,n,r,i){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new _t(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=n,this.retainedQueryData={},this.collisionGroups=new St(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;return t?(n,r)=>t.getElevation(e,n,r):null}getBucketParts(e,n,r,i){let a=r.getBucket(n),o=r.latestFeatureIndex;if(!a||!o||n.id!==a.layerIds[0])return;let s=r.collisionBoxArray,c=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),d=r.tileSize/t.a6,f=r.tileID.toUnwrapped(),p=c.get(`text-rotation-alignment`)===`map`,m=t.aK(r,1,this.transform.zoom),h=t.aL(this.collisionIndex.transform,r,l.get(`text-translate`),l.get(`text-translate-anchor`)),g=t.aL(this.collisionIndex.transform,r,l.get(`icon-translate`),l.get(`icon-translate-anchor`)),_=H(p,this.transform,m);this.retainedQueryData[a.bucketInstanceId]=new xt(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID);let v={bucket:a,layout:c,translationText:h,translationIcon:g,unwrappedTileID:f,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:d,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:t.aw(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(let t of a.sortKeyRanges){let{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=t;e.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:v})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v})}attemptAnchorPlacement(e,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b){var x,S;let C=t.aM[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=Ct(C,r,i,w,a),E=this.collisionIndex.placeCollisionBox(n,f,c,l,u,s,o,g,d.predicate,y,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,f,c,l,u,s,o,_,d.predicate,y,T,b).placeable)&&E.placeable){let e;if((x=this.prevPlacement)!=null&&x.variableOffsets[p.crossTileID]&&(S=this.prevPlacement?.placements[p.crossTileID])!=null&&S.text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),p.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);return this.variableOffsets[p.crossTileID]={textOffset:w,width:r,height:i,anchor:C,textBoxScale:a,prevAnchor:e},this.markUsedJustification(m,C,p,h),m.allowVerticalPlacement&&(this.markUsedOrientation(m,h,p),this.placedOrientations[p.crossTileID]=h),{shift:T,placedGlyphBoxes:E}}}placeLayerBucketPart(e,n,r){let{bucket:i,layout:a,translationText:o,translationIcon:s,unwrappedTileID:c,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,collisionGroup:m}=e.parameters,h=a.get(`text-optional`),g=a.get(`icon-optional`),_=t.aN(a,`text-overlap`,`text-allow-overlap`),v=_===`always`,y=t.aN(a,`icon-overlap`,`icon-allow-overlap`),b=y===`always`,x=a.get(`text-rotation-alignment`)===`map`,S=a.get(`text-pitch-alignment`)===`map`,C=a.get(`icon-text-fit`)!==`none`,w=a.get(`symbol-z-order`)===`viewport-y`,T=v&&(b||!i.hasIconData()||g),E=b&&(v||!i.hasTextData()||h);!i.collisionArrays&&f&&i.deserializeCollisionBoxes(f);let D=this.retainedQueryData[i.bucketInstanceId].tileID,O=this._getTerrainElevationFunc(D),k=this.transform.getFastPathSimpleProjectionMatrix(D),A=(e,f,b)=>{if(n[e.crossTileID])return;if(d)return void(this.placements[e.crossTileID]=new bt(!1,!1,!1));let w=!1,A=!1,j=!0,M=null,N={box:null,placeable:!1,offscreen:null,occluded:!1},P={placeable:!1},F=null,ee=null,I=null,L=0,te=0,ne=0;f.textFeatureIndex?L=f.textFeatureIndex:e.useRuntimeCollisionCircles&&(L=e.featureIndex),f.verticalTextFeatureIndex&&(te=f.verticalTextFeatureIndex);let R=f.textBox;if(R){let n=n=>{let r=t.ax.horizontal;if(i.allowVerticalPlacement&&!n&&this.prevPlacement){let t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(i,r,e))}return r},a=(n,r)=>{if(i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&f.verticalTextBox){for(let e of i.writingModes)if(e===t.ax.vertical?(N=r(),P=N):N=n(),N?.placeable)break}else N=n()},l=e.textAnchorOffsetStartIndex,d=e.textAnchorOffsetEndIndex;if(d===l){let r=(t,n)=>{let r=this.collisionIndex.placeCollisionBox(t,_,u,D,c,S,x,o,m.predicate,O,void 0,k);return r!=null&&r.placeable&&(this.markUsedOrientation(i,n,e),this.placedOrientations[e.crossTileID]=n),r};a((()=>r(R,t.ax.horizontal)),(()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&n?r(n,t.ax.vertical):{box:null,offscreen:null}})),n(N?.placeable)}else{let p=t.aM[this.prevPlacement?.variableOffsets[e.crossTileID]?.anchor],h=(t,n,a)=>{let f=t.x2-t.x1,h=t.y2-t.y1,g=e.textBoxScale,v=C&&y===`never`?n:null,b=null,T=_===`never`?1:2,E=`never`;p&&T++;for(let n=0;n<T;n++){for(let n=l;n<d;n++){let r=i.textAnchorOffsets.get(n);if(p&&r.textAnchor!==p)continue;let l=this.attemptAnchorPlacement(r,t,f,h,g,x,S,u,D,c,m,E,e,i,a,o,s,v,O);if(l&&(b=l.placedGlyphBoxes,b?.placeable))return w=!0,M=l.shift,b}p?p=null:E=_}return r&&!b&&(b={box:this.collisionIndex.placeCollisionBox(R,`always`,u,D,c,S,x,o,m.predicate,O,void 0,k).box,offscreen:!1,placeable:!1,occluded:!1}),b};a((()=>h(R,f.iconBox,t.ax.horizontal)),(()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&!N?.placeable&&e.numVerticalGlyphVertices>0&&n?h(n,f.verticalIconBox,t.ax.vertical):{box:null,occluded:!0,offscreen:null}})),N&&(w=N.placeable,j=N.offscreen);let g=n(N?.placeable);if(!w&&this.prevPlacement){let t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(i,t.anchor,e,g))}}}if(F=N,w=F?.placeable,j=F?.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){let n=i.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),s=t.ay(i.textSizeData,p,n),u=a.get(`text-padding`);ee=this.collisionIndex.placeCollisionCircles(_,n,i.lineVertexArray,i.glyphOffsetArray,s,c,l,r,S,m.predicate,e.collisionCircleDiameter,u,o,O),ee.circles.length&&ee.collisionDetected&&!r&&t.w(`Collisions detected, but collision boxes are not shown`),w=v||ee.circles.length>0&&!ee.collisionDetected,j&&=ee.offscreen}if(f.iconFeatureIndex&&(ne=f.iconFeatureIndex),f.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,y,u,D,c,S,x,s,m.predicate,O,C&&M?M:void 0,k);P&&P.placeable&&f.verticalIconBox?(I=e(f.verticalIconBox),A=I.placeable):(I=e(f.iconBox),A=I.placeable),j&&=I.offscreen}let re=h||e.numHorizontalGlyphVertices===0&&e.numVerticalGlyphVertices===0,ie=g||e.numIconVertices===0;re||ie?ie?re||(A&&=w):w=A&&w:A=w=A&&w;let ae=A&&I.placeable;if(w&&F.placeable&&this.collisionIndex.insertCollisionBox(F.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,P&&P.placeable&&te?te:L,m.ID),ae&&this.collisionIndex.insertCollisionBox(I.box,y,a.get(`icon-ignore-placement`),i.bucketInstanceId,ne,m.ID),ee&&w&&this.collisionIndex.insertCollisionCircles(ee.circles,_,a.get(`text-ignore-placement`),i.bucketInstanceId,L,m.ID),r&&this.storeCollisionData(i.bucketInstanceId,b,f,F,I,ee),e.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);if(i.bucketInstanceId===0)throw Error(`bucket.bucketInstanceId can't be 0`);this.placements[e.crossTileID]=new bt((w||T)&&!F?.occluded,(A||E)&&!I?.occluded,j||i.justReloaded),n[e.crossTileID]=!0};if(w){if(e.symbolInstanceStart!==0)throw Error(`bucket.bucketInstanceId should be 0`);let t=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){let n=t[e];A(i.symbolInstances.get(n),i.collisionArrays[n],n)}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)A(i.symbolInstances.get(t),i.collisionArrays[t],t);i.justReloaded=!1}storeCollisionData(e,t,n,r,i,a){if(n.textBox||n.iconBox){let a,o;this.collisionBoxArrays.has(e)?a=this.collisionBoxArrays.get(e):(a=new Map,this.collisionBoxArrays.set(e,a)),a.has(t)?o=a.get(t):(o={text:null,icon:null},a.set(t,o)),n.textBox&&(o.text=r.box),n.iconBox&&(o.icon=i.box)}if(a){let t=this.collisionCircleArrays[e];t===void 0&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<a.circles.length;e+=4)t.push(a.circles[e+0]-100),t.push(a.circles[e+1]-100),t.push(a.circles[e+2]),t.push(+!!a.collisionDetected)}}markUsedJustification(e,n,r,i){let a;a=i===t.ax.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.aO(n)];let o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(let t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID)}markUsedOrientation(e,n,r){let i=n===t.ax.horizontal||n===t.ax.horizontalOnly?n:0,a=n===t.ax.vertical?n:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let t of o)e.text.placedSymbolArray.get(t).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},a=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(let e in this.placements){let t=this.placements[e],a=i[e];a?(this.opacities[e]=new yt(a,r,t.text,t.icon),n||=t.text!==a.text.placed,n||=t.icon!==a.icon.placed):(this.opacities[e]=new yt(null,r,t.text,t.icon,t.skipFade),n||=t.text||t.icon)}for(let e in i){let t=i[e];if(!this.opacities[e]){let i=new yt(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n||=t.text.placed,n||=t.icon.placed)}}for(let e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(let e in o)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=o[e]);if(t&&t.lastPlacementChangeTime===void 0)throw Error(`Last placement time for previous placement is not defined`);n?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!=`number`&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let n={};for(let r of t){let t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,n,r.collisionBoxArray)}}updateBucketOpacities(e,n,r,i){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],o=a.layout,s=new yt(null,0,!1,!1,!0),c=o.get(`text-allow-overlap`),l=o.get(`icon-allow-overlap`),u=a._unevaluatedLayout.hasValue(`text-variable-anchor`)||a._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),d=o.get(`text-rotation-alignment`)===`map`,f=o.get(`text-pitch-alignment`)===`map`,p=o.get(`icon-text-fit`)!==`none`,m=new yt(null,0,c&&(l||!e.hasIconData()||o.get(`icon-optional`)),l&&(c||!e.hasTextData()||o.get(`text-optional`)),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);let h=(e,t,n)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(n);e.hasVisibleVertices||=n!==jt},g=this.collisionBoxArrays.get(e.bucketInstanceId);for(let n=0;n<e.symbolInstances.length;n++){let i=e.symbolInstances.get(n),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:o,crossTileID:c}=i,l=this.opacities[c];r[c]?l=s:l||(l=m,this.opacities[c]=l),r[c]=!0;let _=i.numIconVertices>0,v=this.placedOrientations[i.crossTileID],y=v===t.ax.vertical,b=v===t.ax.horizontal||v===t.ax.horizontalOnly;if(a>0||o>0){let t=At(l.text);h(e.text,a,y?jt:t),h(e.text,o,b?jt:t);let n=l.text.isHidden(),r=[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex];for(let t of r)t>=0&&(e.text.placedSymbolArray.get(t).hidden=n||y?1:0);i.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).hidden=n||b?1:0);let s=this.variableOffsets[i.crossTileID];s&&this.markUsedJustification(e,s.anchor,i,v);let c=this.placedOrientations[i.crossTileID];c&&(this.markUsedJustification(e,`left`,i,c),this.markUsedOrientation(e,c,i))}if(_){let t=At(l.icon),n=!(p&&i.verticalPlacedIconSymbolIndex&&y);i.placedIconSymbolIndex>=0&&(h(e.icon,i.numIconVertices,n?t:jt),e.icon.placedSymbolArray.get(i.placedIconSymbolIndex).hidden=l.icon.isHidden()),i.verticalPlacedIconSymbolIndex>=0&&(h(e.icon,i.numVerticalIconVertices,n?jt:t),e.icon.placedSymbolArray.get(i.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden())}let x=g?.has(n)?g.get(n):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let r=e.collisionArrays[n];if(r){let n=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(u){let e=this.variableOffsets[c];e?(n=Ct(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),d&&n._rotate(f?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(r.textBox||r.verticalTextBox){let i;r.textBox&&(i=y),r.verticalTextBox&&(i=b),Tt(e.textCollisionBox.collisionVertexArray,l.text.placed,!t||i,x.text,n.x,n.y)}}if(r.iconBox||r.verticalIconBox){let t=!!(!b&&r.verticalIconBox),i;r.iconBox&&(i=t),r.verticalIconBox&&(i=!t),Tt(e.iconCollisionBox.collisionVertexArray,l.icon.placed,i,x.icon,p?n.x:0,p?n.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?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){let n=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*n>e}setStale(){this.stale=!0}}function Tt(e,t,n,r,i,a){r&&r.length!==0||(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,c=r[2]-100,l=r[3]-100;e.emplaceBack(+!!t,+!!n,i||0,a||0,o,s),e.emplaceBack(+!!t,+!!n,i||0,a||0,c,s),e.emplaceBack(+!!t,+!!n,i||0,a||0,c,l),e.emplaceBack(+!!t,+!!n,i||0,a||0,o,l)}let Et=2**25,Dt=2**24,Ot=2**17,kt=2**16;function At(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return 4294967295;let t=+!!e.placed,n=Math.floor(127*e.opacity);return n*Et+t*Dt+n*Ot+t*kt+n*512+t*256+n*2+t}let jt=0;class Mt{constructor(e){this._sortAcrossTiles=e.layout.get(`symbol-z-order`)!==`viewport-y`&&!e.layout.get(`symbol-sort-key`).isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,n,r,i){let a=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(a,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,i())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,a.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<a.length;)if(t.placeLayerBucketPart(a[this._currentPartIndex],this._seenCrossTileIDs,n),this._currentPartIndex++,i())return!0;return!1}}class Nt{constructor(e,t,n,r,i,a,o,s){this.placement=new wt(e,t,a,o,s),this._currentPlacementIndex=n.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=i,this._done=!1}isDone(){return this._done}continuePlacement(e,n,r){let i=l(),a=()=>!this._forceFullPlacement&&l()-i>2;for(;this._currentPlacementIndex>=0;){let i=n[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(t.aQ(i)&&i.layout&&(!i.minzoom||i.minzoom<=o)&&(!i.maxzoom||i.maxzoom>o)){if(this._inProgressLayer||=new Mt(i),this._inProgressLayer.continuePlacement(r[i.source],this.placement,this._showCollisionBoxes,i,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let Pt=512/t.a6/2;class Ft{constructor(e,n,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};let i=new Map;for(let e=0;e<n.length;e++){let t=n.get(e),r=t.key,a=i.get(r);a?a.push(t):i.set(r,[t])}for(let[e,n]of i){let r={positions:n.map((e=>({x:Math.floor(e.anchorX*Pt),y:Math.floor(e.anchorY*Pt)}))),crossTileIDs:n.map((e=>e.crossTileID))};if(r.positions.length>128){let e=new t.aR(r.positions.length,16,Uint16Array);for(let{x:t,y:n}of r.positions)e.add(t,n);e.finish(),delete r.positions,r.index=e}this._symbolsByKey[e]=r}}getScaledCoordinates(e,n){let{x:r,y:i,z:a}=this.tileID.canonical,{x:o,y:s,z:c}=n.canonical,l=Pt/2**(c-a),u=(s*t.a6+e.anchorY)*l,d=i*t.a6*Pt;return{x:Math.floor((o*t.a6+e.anchorX)*l-r*t.a6*Pt),y:Math.floor(u-d)}}findMatches(e,t,n){let r=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let i=0;i<e.length;i++){let a=e.get(i);if(a.crossTileID)continue;let o=this._symbolsByKey[a.key];if(!o)continue;let s=this.getScaledCoordinates(a,t);if(o.index){let e=o.index.range(s.x-r,s.y-r,s.x+r,s.y+r).sort();for(let t of e){let e=o.crossTileIDs[t];if(!n[e]){n[e]=!0,a.crossTileID=e;break}}}else if(o.positions)for(let e=0;e<o.positions.length;e++){let t=o.positions[e],i=o.crossTileIDs[e];if(Math.abs(t.x-s.x)<=r&&Math.abs(t.y-s.y)<=r&&!n[i]){n[i]=!0,a.crossTileID=i;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class It{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Lt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let e in this.indexes){let n=this.indexes[e],r={};for(let e in n){let i=n[e];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),r[i.tileID.key]=i}this.indexes[e]=r}this.lng=e}addBucket(e,t,n){var r,i;if(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;(r=this.usedCrossTileIDs)[i=e.overscaledZ]||(r[i]={});let a=this.usedCrossTileIDs[e.overscaledZ];for(let n in this.indexes){let r=this.indexes[n];if(Number(n)>e.overscaledZ)for(let n in r){let i=r[n];i.tileID.isChildOf(e)&&i.findMatches(t.symbolInstances,e,a)}else{let i=r[e.scaledTo(Number(n)).key];i&&i.findMatches(t.symbolInstances,e,a)}}for(let e=0;e<t.symbolInstances.length;e++){let r=t.symbolInstances.get(e);r.crossTileID||(r.crossTileID=n.generate(),a[r.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Ft(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let n of t.getCrossTileIDsLists())for(let t of n)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(let n in this.indexes){let r=this.indexes[n];for(let i in r)e[r[i].bucketInstanceId]||(this.removeBucketCrossTileIDs(n,r[i]),delete r[i],t=!0)}return t}}class Rt{constructor(){this.layerIndexes={},this.crossTileIDs=new It,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,n){let r=this.layerIndexes[e.id];r===void 0&&(r=this.layerIndexes[e.id]=new Lt);let i=!1,a={};r.handleWrapJump(n);for(let n of t){let t=n.getBucket(e);e.id===t?.layerIds[0]&&(t.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),r.addBucket(n.tileID,t,this.crossTileIDs)&&(i=!0),a[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(a)&&(i=!0),i}pruneUnusedLayers(e){let t={};for(let n of e)t[n]=!0;for(let e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var zt=`void main() {fragColor=vec4(1.0);}`;let Bt={prelude:Vt(`#ifdef GL_ES
|
||
precision mediump float;
|
||
#else
|
||
#if !defined(lowp)
|
||
#define lowp
|
||
#endif
|
||
#if !defined(mediump)
|
||
#define mediump
|
||
#endif
|
||
#if !defined(highp)
|
||
#define highp
|
||
#endif
|
||
#endif
|
||
out highp vec4 fragColor;`,`#ifdef GL_ES
|
||
precision highp float;
|
||
#else
|
||
#if !defined(lowp)
|
||
#define lowp
|
||
#endif
|
||
#if !defined(mediump)
|
||
#define mediump
|
||
#endif
|
||
#if !defined(highp)
|
||
#define highp
|
||
#endif
|
||
#endif
|
||
vec2 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(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
|
||
);}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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c
|
||
);}
|
||
#ifdef TERRAIN3D
|
||
uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
|
||
#endif
|
||
const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
|
||
#ifdef TERRAIN3D
|
||
highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
|
||
#else
|
||
return 1.0;
|
||
#endif
|
||
}float calculate_visibility(vec4 pos) {
|
||
#ifdef TERRAIN3D
|
||
vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
|
||
#else
|
||
return 1.0;
|
||
#endif
|
||
}float ele(vec2 pos) {
|
||
#ifdef TERRAIN3D
|
||
vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
|
||
#else
|
||
return 0.0;
|
||
#endif
|
||
}float get_elevation(vec2 pos) {
|
||
#ifdef TERRAIN3D
|
||
#ifdef GLOBE
|
||
if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
|
||
#endif
|
||
vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
|
||
#else
|
||
return 0.0;
|
||
#endif
|
||
}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:Vt(``,`float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}`),projectionGlobe:Vt(``,`#define GLOBE_RADIUS 6371008.8
|
||
uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
|
||
);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);
|
||
if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len
|
||
);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:Vt(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),backgroundPattern:Vt(`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;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);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);}`),circle:Vt(`in vec3 v_data;in float v_visibility;
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define mediump float radius
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define highp vec4 stroke_color
|
||
#pragma mapbox: define mediump float stroke_width
|
||
#pragma mapbox: define lowp float stroke_opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize mediump float radius
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize highp vec4 stroke_color
|
||
#pragma mapbox: initialize mediump float stroke_width
|
||
#pragma mapbox: initialize lowp float stroke_opacity
|
||
vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define mediump float radius
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define highp vec4 stroke_color
|
||
#pragma mapbox: define mediump float stroke_width
|
||
#pragma mapbox: define lowp float stroke_opacity
|
||
void main(void) {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize mediump float radius
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize highp vec4 stroke_color
|
||
#pragma mapbox: initialize mediump float stroke_width
|
||
#pragma mapbox: initialize lowp float stroke_opacity
|
||
vec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
|
||
#ifdef GLOBE
|
||
vec3 center_vector=projectToSphere(circle_center);
|
||
#endif
|
||
float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
|
||
#ifdef GLOBE
|
||
vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
|
||
#else
|
||
vec4 projected_center=projectTileWithElevation(circle_center,ele);
|
||
#endif
|
||
corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
|
||
#ifdef GLOBE
|
||
vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
|
||
#else
|
||
gl_Position=projectTileWithElevation(corner_position,ele);
|
||
#endif
|
||
} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:Vt(zt,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),heatmap:Vt(`uniform highp float u_intensity;in vec2 v_extrude;
|
||
#pragma mapbox: define highp float weight
|
||
#define GAUSS_COEF 0.3989422804014327
|
||
void main() {
|
||
#pragma mapbox: initialize highp float weight
|
||
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;
|
||
#pragma mapbox: define highp float weight
|
||
#pragma mapbox: define mediump float radius
|
||
const highp float ZERO=1.0/255.0/16.0;
|
||
#define GAUSS_COEF 0.3989422804014327
|
||
void main(void) {
|
||
#pragma mapbox: initialize highp float weight
|
||
#pragma mapbox: initialize mediump float radius
|
||
vec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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 circle_center=floor(pos_raw/8.0);
|
||
#ifdef GLOBE
|
||
vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
|
||
#else
|
||
gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
|
||
#endif
|
||
}`),heatmapTexture:Vt(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(0.0);
|
||
#endif
|
||
}`,`uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}`),collisionBox:Vt(`in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}`,`in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Vt(`in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}`,`in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),colorRelief:Vt(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
|
||
{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),debug:Vt(`uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}`,`in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}`),depth:Vt(zt,`in vec2 a_pos;void main() {
|
||
#ifdef GLOBE
|
||
gl_Position=projectTileFor3D(a_pos,0.0);
|
||
#else
|
||
gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
|
||
#endif
|
||
}`),fill:Vt(`#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
fragColor=color*opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_fill_translate;in vec2 a_pos;
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:Vt(`in vec2 v_pos;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 outline_color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 outline_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 outline_color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 outline_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
}`),fillOutlinePattern:Vt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
vec2 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=texture(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=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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=projectTile(a_pos+u_fill_translate,a_pos);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;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
}`),fillPattern:Vt(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
vec2 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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=projectTile(a_pos+u_fill_translate,a_pos);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);}`),fillExtrusion:Vt(`in vec4 v_color;void main() {fragColor=v_color;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;
|
||
#ifdef TERRAIN3D
|
||
in vec2 a_centroid;
|
||
#endif
|
||
out vec4 v_color;
|
||
#pragma mapbox: define highp float base
|
||
#pragma mapbox: define highp float height
|
||
#pragma mapbox: define highp vec4 color
|
||
void main() {
|
||
#pragma mapbox: initialize highp float base
|
||
#pragma mapbox: initialize highp float height
|
||
#pragma mapbox: initialize highp vec4 color
|
||
vec3 normal=a_normal_ed.xyz;
|
||
#ifdef TERRAIN3D
|
||
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
||
#else
|
||
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
||
#endif
|
||
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
|
||
#ifdef GLOBE
|
||
vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
||
#else
|
||
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
||
#endif
|
||
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;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
|
||
#ifdef GLOBE
|
||
mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
|
||
#endif
|
||
directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((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.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:Vt(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;
|
||
#pragma mapbox: define lowp float base
|
||
#pragma mapbox: define lowp float height
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float base
|
||
#pragma mapbox: initialize lowp float height
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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=texture(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=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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 vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;
|
||
#ifdef TERRAIN3D
|
||
in vec2 a_centroid;
|
||
#endif
|
||
#ifdef GLOBE
|
||
out vec3 v_sphere_pos;
|
||
#endif
|
||
out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
|
||
#pragma mapbox: define lowp float base
|
||
#pragma mapbox: define lowp float height
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float base
|
||
#pragma mapbox: initialize lowp float height
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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 normal=a_normal_ed.xyz;float edgedistance=a_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;
|
||
#ifdef TERRAIN3D
|
||
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
||
#else
|
||
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
||
#endif
|
||
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
|
||
#ifdef GLOBE
|
||
vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
||
#else
|
||
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
||
#endif
|
||
vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
|
||
? a_pos
|
||
: vec2(edgedistance,elevation*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/16383.0,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*=((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;}`),hillshadePrepare:Vt(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out 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:Vt(`uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
|
||
#define PI 3.141592653589793
|
||
#define STANDARD 0
|
||
#define COMBINED 1
|
||
#define IGOR 2
|
||
#define MULTIDIRECTIONAL 3
|
||
#define BASIC 4
|
||
float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
|
||
{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else
|
||
{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),line:Vt(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
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);fragColor=color*(alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
float 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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
||
#endif
|
||
v_width2=vec2(outset,inset);}`),lineGradient:Vt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
float 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;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
||
#endif
|
||
v_width2=vec2(outset,inset);}`),linePattern:Vt(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
vec2 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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
#define LINE_DISTANCE_SCALE 2.0
|
||
in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
float 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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
||
#endif
|
||
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:Vt(`uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
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 sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
#define LINE_DISTANCE_SCALE 2.0
|
||
in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
float 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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
||
#endif
|
||
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),lineGradientSDF:Vt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
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);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
#define LINE_DISTANCE_SCALE 2.0
|
||
in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
float 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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
||
#endif
|
||
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),raster:Vt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in 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=texture(u_image0,v_pos0);vec4 color1=texture(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(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;
|
||
#ifdef GLOBE
|
||
if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
|
||
#endif
|
||
v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:Vt(`uniform sampler2D u_texture;in vec2 v_tex;in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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 bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_total_opacity;
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
||
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
||
#ifdef GLOBE
|
||
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
||
#endif
|
||
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}`),symbolSDF:Vt(`#define SDF_PX 8.0
|
||
uniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
float 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 total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;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 vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
||
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
||
#ifdef GLOBE
|
||
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
||
#endif
|
||
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}`),symbolTextAndIcon:Vt(`#define SDF_PX 8.0
|
||
#define SDF 1.0
|
||
#define ICON 0.0
|
||
uniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
float total_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
return;}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;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;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 vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
||
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
||
#ifdef GLOBE
|
||
if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
||
#endif
|
||
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,total_opacity,is_sdf);}`),terrain:Vt(`uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}`,`in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}`),terrainDepth:Vt(`in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}`),terrainCoords:Vt(`precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}`),projectionErrorMeasurement:Vt(`in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}`,`in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}`),atmosphere:Vt(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
|
||
);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,`in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}`),sky:Vt(`uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}`,`in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}`)};function Vt(e,t){let n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),i=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(i):i,s={};return{fragmentSource:e=e.replace(n,((e,t,n,r,i)=>(s[i]=!0,t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nin ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = u_${i};\n#endif\n`))),vertexSource:t=t.replace(n,((e,t,n,r,i)=>{let a=r===`float`?`vec2`:`vec4`,o=i.match(/color/)?`color`:a;return s[i]?t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\nout ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`})),staticAttributes:r,staticUniforms:o}}class Ht{constructor(e,t,n){this.vertexBuffer=e,this.indexBuffer=t,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Ut=t.aS([{name:`a_pos`,type:`Int16`,components:2}]);let Wt=`#define PROJECTION_MERCATOR`,Gt=`mercator`;class Kt{constructor(){this._cachedMesh=null}get name(){return`mercator`}get useSubdivision(){return!1}get shaderVariantName(){return Gt}get shaderDefine(){return Wt}get shaderPreludeCode(){return Bt.projectionMercator}get vertexShaderPreludeCode(){return Bt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aT.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,r,i,a){if(this._cachedMesh)return this._cachedMesh;let o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(t.a6,0),o.emplaceBack(0,t.a6),o.emplaceBack(t.a6,t.a6);let s=e.createVertexBuffer(o,Ut.members),c=t.aV.simpleSegment(0,0,4,2),l=new t.aW;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new Ht(s,u,c),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class qt{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(e,n,r){return n.top!=null&&e.top!=null&&(this.top=t.H.number(e.top,n.top,r)),n.bottom!=null&&e.bottom!=null&&(this.bottom=t.H.number(e.bottom,n.bottom,r)),n.left!=null&&e.left!=null&&(this.left=t.H.number(e.left,n.left,r)),n.right!=null&&e.right!=null&&(this.right=t.H.number(e.right,n.right,r)),this}getCenter(e,n){let r=t.al((this.left+e-this.right)/2,0,e),i=t.al((this.top+n-this.bottom)/2,0,n);return new t.P(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new qt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Jt(e,t){if(!e.renderWorldCopies||e.lngRange)return;let n=t.lng-e.center.lng;t.lng+=n>180?-360:n<-180?360:0}function Yt(e){return Math.max(0,Math.floor(e))}class Xt{constructor(e,n){this.applyConstrain=(e,t)=>this._constrainOverride===null?this._callbacks.defaultConstrain(e,t):this._constrainOverride(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=n?.renderWorldCopies===void 0||!!n?.renderWorldCopies,this._minZoom=n?.minZoom||0,this._maxZoom=n?.maxZoom||22,this._minPitch=n?.minPitch==null?0:n?.minPitch,this._maxPitch=n?.maxPitch==null?60:n?.maxPitch,this._constrainOverride=n?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Yt(this._zoom),this._scale=t.ao(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new qt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,n,r){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Yt(this._zoom),this._scale=t.ao(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new qt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){e===void 0&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let n=t.X(e,-180,180)*Math.PI/180;var i,a,o,s,c,l,u,d,f;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=r(),i=this._rotationMatrix,o=-this._bearingInRadians,s=(a=this._rotationMatrix)[0],c=a[1],l=a[2],u=a[3],d=Math.sin(o),f=Math.cos(o),i[0]=s*f+l*d,i[1]=c*f+u*d,i[2]=s*-d+l*f,i[3]=c*-d+u*f)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let n=t.al(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aX(this._fovInRadians)}setFov(e){e=t.al(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.an(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let n=this.applyConstrain(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=t.ao(n),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,n){this._unmodified=!1,this._edgeInsets.interpolate(e,t,n),this.constrainInternal(),this._calcMatrices()}resize(e,t,n=!0){this._width=e,this._height=t,n&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange?.length!==2||this._lngRange?.length!==2?null:new re([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.am,t.am])}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{let{minX:r,minY:i,maxX:a,maxY:o}=t.a8.fromPoints(n).extend(e);return[new t.P(r,i),new t.P(a,i),new t.P(a,o),new t.P(r,o),new t.P(r,i)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:n}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(n),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ap(new Float64Array(16));t.S(e,e,[this._width/2,-this._height/2,1]),t.Q(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ap(new Float64Array(16)),t.S(e,e,[1,-1,1]),t.Q(e,e,[-1,-1,0]),t.S(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,r,i){let a=r===void 0?this.bearing:r,o=i=i===void 0?this.pitch:i,{distanceToCenter:s,clampedElevation:c}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,o),{x:l,y:u}=Pe(o,a),d=t.a7.fromLngLat(e,n),f,p,m=t.aY(1,d.y),h=0;do{if(h+=1,h>10)break;p=s/m,f=new t.a7(d.x+l*p,d.y+u*p),m=1/f.meterInMercatorCoordinateUnits()}while(Math.abs(s-p*m)>1e-12);return{center:f.toLngLat(),elevation:c,zoom:t.ar(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;let n=1/this.worldSize,r=t.aq(1,this.center.lat)*this.worldSize,i=t.a7.fromLngLat(this.center,this.elevation),a=i.x/n,o=i.y/n,s=i.z/n,c=this.pitch,l=this.bearing,{x:u,y:d,z:f}=Pe(c,l),p=this.cameraToCenterDistance,m=a+p*-u,h=o+p*-d,g=s+p*f,{distanceToCenter:_,clampedElevation:v}=this._distanceToCenterFromAltElevationPitch(g/r,e,c),y=_*r,b=new t.a7((m+u*y)*n,(h+d*y)*n,0).toLngLat(),x=t.aq(1,b.lat),S=t.ar(this.height/2/Math.tan(this.fovInRadians/2)/_/x/this.tileSize);this._elevation=v,this._center=b,this.setZoom(S)}_distanceToCenterFromAltElevationPitch(e,n,r){let i=-Math.cos(t.an(r)),a=e-n,o,s=n;return i*a>=0||Math.abs(i)<.1?(o=1e4,s=e+o*i):o=-a/i,{distanceToCenter:o,clampedElevation:s}}getCameraPoint(){let e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let e=t.aq(1,this.center.lat)*this.worldSize;return Ne(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let n=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/n,e.canonical.y/n,1/n/t.a6,1/n/t.a6]}}class Zt{constructor(e,n){this.min=e,this.max=n,this.center=t.aZ([],t.a_([],this.min,this.max),.5)}quadrant(e){let n=[e%2==0,e<2],r=t.a$(this.min),i=t.a$(this.max);for(let e=0;e<n.length;e++)r[e]=n[e]?this.min[e]:this.center[e],i[e]=n[e]?this.center[e]:this.max[e];return i[2]=this.max[2],new Zt(r,i)}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]}intersectsFrustum(e){let t=!0;for(let n of e.planes){let e=this.intersectsPlane(n);if(e===0)return 0;e===1&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],n=e[3];for(let r=0;r<3;r++)e[r]>0?(t+=e[r]*this.min[r],n+=e[r]*this.max[r]):(n+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:n<0?0:1}}class Qt{distanceToTile2d(e,t,n,r){let i=r,a=i.distanceX([e,t]),o=i.distanceY([e,t]);return Math.hypot(a,o)}getWrap(e,t,n){return n}getTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.a3(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}let s=1<<e.z;return new Zt([n+e.x/s,e.y/s,a],[n+(e.x+1)/s,(e.y+1)/s,o])}allowVariableZoom(e,n){let r=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,i=t.al(78.5-r/2,0,60);return!!n.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}}class $t{constructor(e,t,n){this.points=e,this.planes=t,this.aabb=n}static fromInvProjectionMatrix(e,n=1,r=0,i,a){let o=a?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],s=2**r,c=[[-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((r=>function(e,n,r,i){let a=t.aE([],e,n),o=1/a[3]/r*i;return t.b4(a,a,[o,o,1/a[3],o])}(r,e,n,s)));i&&function(e,n,r,i){let a=i?4:0,o=i?0:4,s=0,c=[],l=[];for(let n=0;n<4;n++){let r=t.b0([],e[n+o],e[n+a]),i=t.b5(r);t.aZ(r,r,1/i),c.push(i),l.push(r)}for(let n=0;n<4;n++){let i=t.b6(e[n+a],l[n],r);s=i!==null&&i>=0?Math.max(s,i):Math.max(s,c[n])}let u=function(e,n){let r=t.b0([],e[n[0]],e[n[1]]),i=t.b0([],e[n[2]],e[n[1]]),a=[0,0,0,0];return t.b1(a,t.b2([],r,i)),a[3]=-t.b3(a,e[n[0]]),a}(e,n),d=function(e,n){let r=t.b7(e),i=t.b8([],e,1/r),a=t.b0([],n,t.aZ([],i,t.b3(n,i))),o=t.b7(a);if(o>0){let e=Math.sqrt(1-i[3]*i[3]),r=t.aZ([],i,-i[3]),s=t.a_([],r,t.aZ([],a,e/o));return t.b9(n,s)}return null}(r,u);if(d!==null){let e=d/t.b3(l[0],u);s=Math.min(s,e)}for(let t=0;t<4;t++){let n=Math.min(s,c[t]);e[t+o]=[e[t+a][0]+l[t][0]*n,e[t+a][1]+l[t][1]*n,e[t+a][2]+l[t][2]*n,1]}}(c,o[0],i,a);let l=o.map((e=>{let n=t.b0([],c[e[0]],c[e[1]]),r=t.b0([],c[e[2]],c[e[1]]),i=t.b1([],t.b2([],n,r)),a=-t.b3(i,c[e[1]]);return i.concat(a)})),u=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let e of c)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),d[t]=Math.max(d[t],e[t]);return new $t(c,l,new Zt(u,d))}}class en{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,n)=>{n=t.al(+n,this.minZoom,this.maxZoom);let r={center:new t.W(e.lng,e.lat),zoom:n},i=this._helper._lngRange;!this._helper._renderWorldCopies&&i===null&&(i=[-179.9999999999,179.9999999999]);let a=this.tileSize*t.ao(r.zoom),o=0,s=a,c=0,l=a,u=0,d=0,{x:f,y:p}=this.size;if(this._helper._latRange){let e=this._helper._latRange;o=t.Y(e[1])*a,s=t.Y(e[0])*a,s-o<p&&(u=p/(s-o))}i&&(c=t.X(t.Z(i[0])*a,0,a),l=t.X(t.Z(i[1])*a,0,a),l<c&&(l+=a),l-c<f&&(d=f/(l-c)));let{x:m,y:h}=ke(a,e),g,_,v=Math.max(d||0,u||0);if(v)return r.center=Ae(a,new t.P(d?(l+c)/2:m,u?(s+o)/2:h)).wrap(),r.zoom+=t.ar(v),r;if(this._helper._latRange){let e=p/2;h-e<o&&(_=o+e),h+e>s&&(_=s-e)}if(i){let e=(c+l)/2,n=m;this._helper._renderWorldCopies&&(n=t.X(m,e-a/2,e+a/2));let r=f/2;n-r<c&&(g=c+r),n+r>l&&(g=l-r)}return(g!==void 0||_!==void 0)&&(r.center=Ae(a,new t.P(g??m,_??h)).wrap()),r},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Xt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Qt}clone(){let e=new en;return e.apply(this,!1),e}apply(e,t,n){this._helper.apply(e,t,n)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){let n=[new t.ba(0,e)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),s=Math.floor(Math.min(r.x,i.x,a.x,o.x)),c=Math.floor(Math.max(r.x,i.x,a.x,o.x));for(let r=s-1;r<=c+1;r++)r!==0&&n.push(new t.ba(r,e))}return n}getCameraFrustum(){return $t.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let t=this.screenPointToLocation(this.centerPoint,e),n=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(n)}setLocationAtPoint(e,n){let r=t.aq(this.elevation,this.center.lat),i=this.screenPointToMercatorCoordinateAtZ(n,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=t.a7.fromLngLat(e),s=new t.a7(o.x-(i.x-a.x),o.y-(i.y-a.y));this.setCenter(s?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(t.a7.fromLngLat(e),n.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(t.a7.fromLngLat(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){let n=t.pointCoordinate(e);if(n!=null)return n}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){let r=n||0,i=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.aE(i,i,this._pixelMatrixInverse),t.aE(a,a,this._pixelMatrixInverse);let o=i[3],s=a[3],c=i[1]/o,l=a[1]/s,u=i[2]/o,d=a[2]/s,f=u===d?0:(r-u)/(d-u);return new t.a7(t.H.number(i[0]/o,a[0]/s,f)/this.worldSize,t.H.number(c,l,f)/this.worldSize,r)}coordinatePoint(e,n=0,r=this._pixelMatrix){let i=[e.x*this.worldSize,e.y*this.worldSize,n,1];return t.aE(i,i,r),new t.P(i[0]/i[3],i[1]/i[3])}getBounds(){let e=Math.max(0,this._helper._height/2-je(this));return new re().extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?t.pointCoordinate(e)!=null:e.y>this.height/2-je(this)}calculatePosMatrix(e,n=!1,r){let i=e.key??t.bb(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(i)){let e=a.get(i);return r?e.f32:e.f64}let o=Me(e,this.worldSize);t.U(o,n?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return a.set(i,s),r?s.f32:s.f64}calculateFogMatrix(e){let n=e.key,r=this._fogMatrixCacheF32;if(r.has(n))return r.get(n);let i=Me(e,this.worldSize);return t.U(i,this._fogMatrix,i),r.set(n,new Float32Array(i)),r.get(n)}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}_calculateNearFarZIfNeeded(e,n,r){if(!this._helper.autoCalculateNearFarZ)return;let i=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-i*this._helper._pixelPerMeter/Math.cos(n),o=i<0?a:e,s=Math.PI/2+this.pitchInRadians,c=t.an(this.fov)*(Math.abs(Math.cos(t.an(this.roll)))*this.height+Math.abs(Math.sin(t.an(this.roll)))*this.width)/this.height*(.5+r.y/this.height),l=Math.sin(c)*o/Math.sin(t.al(Math.PI-s-c,.01,Math.PI-.01)),u=je(this),d=Math.atan(u/this._helper.cameraToCenterDistance),f=t.an(.75),p=d>f?2*d*(.5+r.y/(2*u)):f,m=Math.sin(p)*o/Math.sin(t.al(Math.PI-s-p,.01,Math.PI-.01)),h=Math.min(l,m);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*h+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let e=this.centerOffset,n=ke(this.worldSize,this.center),r=n.x,i=n.y;this._helper._pixelPerMeter=t.aq(1,this.center.lat)*this.worldSize;let a=t.an(Math.min(this.pitch,Oe)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a)),s;var c,l;this._calculateNearFarZIfNeeded(o,a,e),s=new Float64Array(16),t.bc(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),(c=this._invProjMatrix)[0]=1/(l=s)[0],c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=1/l[5],c[6]=0,c[7]=0,c[8]=0,c[9]=0,c[10]=0,c[11]=1/l[14],c[12]=0,c[13]=0,c[14]=-1,c[15]=l[10]/l[14],s[8]=2*-e.x/this._helper._width,s[9]=2*e.y/this._helper._height,this._projectionMatrix=t.bd(s),t.S(s,s,[1,-1,1]),t.Q(s,s,[0,0,-this._helper.cameraToCenterDistance]),t.be(s,s,-this.rollInRadians),t.bf(s,s,this.pitchInRadians),t.be(s,s,-this.bearingInRadians),t.Q(s,s,[-r,-i,0]),this._mercatorMatrix=t.S([],s,[this.worldSize,this.worldSize,this.worldSize]),t.S(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),t.Q(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=t.bg([],s);let u=[0,0,-1,1];t.aE(u,u,this._invViewProjMatrix),this._cameraPosition=[u[0]/u[3],u[1]/u[3],u[2]/u[3]],this._fogMatrix=new Float64Array(16),t.bc(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.S(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.be(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bf(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.be(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.Q(this._fogMatrix,this._fogMatrix,[-r,-i,0]),t.S(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,s);let d=this._helper._width%2/2,f=this._helper._height%2/2,p=Math.cos(this.bearingInRadians),m=Math.sin(-this.bearingInRadians),h=r-Math.round(r)+p*d+m*f,g=i-Math.round(i)+p*f+m*d,_=new Float64Array(s);if(t.Q(_,_,[h>.5?h-1:h,g>.5?g-1:g,0]),this._alignedProjMatrix=_,s=t.bg(new Float64Array(16),this._pixelMatrix),!s)throw Error(`failed to invert matrix`);this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new t.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aE(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let e=t.aq(1,this.center.lat)*this.worldSize;return Ne(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){let r=t.a7.fromLngLat(e),i=[r.x*this.worldSize,r.y*this.worldSize,n,1];return t.aE(i,i,this._viewProjMatrix),i[2]/i[3]}getProjectionData(e){let{overscaledTileID:n,aligned:r,applyTerrainMatrix:i}=e,a=this._helper.getMercatorTileCoordinates(n),o=n?this.calculatePosMatrix(n,r,!0):null,s;return s=n?.terrainRttPosMatrix32f&&i?n.terrainRttPosMatrix32f:o||t.bh(),{mainMatrix:s,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,n){return 1}transformLightDirection(e){return t.a$(e)}getRayDirectionFromPixel(e){throw Error(`Not implemented.`)}projectTileCoordinates(e,n,r,i){let a=this.calculatePosMatrix(r),o;i?(o=[e,n,i(e,n),1],t.aE(o,o,a)):(o=[e,n,0,1],gt(o,o,a));let s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,n){let r=t.a7.fromLngLat(e,n),i=r.meterInMercatorCoordinateUnits(),a=t.bi();return t.Q(a,a,[r.x,r.y,r.z]),t.be(a,a,Math.PI),t.bf(a,a,Math.PI/2),t.S(a,a,[-i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=new t.a3(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),i=Me(n,this.worldSize);t.U(i,this._viewProjMatrix,i),r.tileMercatorCoords=[0,0,1,1];let a=[t.a6,t.a6,this.worldSize/this._helper.pixelsPerMeter],o=t.bj();return t.S(o,i,a),r.fallbackMatrix=o,r.mainMatrix=o,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function tn(){t.w(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function nn(e){if(e.useSlerp)if(e.k<1){let n=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),i=new Float64Array(4);t.bl(i,n,r,e.k);let a=t.bm(i);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.H.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.H.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.H.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function rn(e,n,r,i,a){let o=a.padding,s=ke(a.worldSize,r.getNorthWest()),c=ke(a.worldSize,r.getNorthEast()),l=ke(a.worldSize,r.getSouthEast()),u=ke(a.worldSize,r.getSouthWest()),d=t.an(-i),f=s.rotate(d),p=c.rotate(d),m=l.rotate(d),h=u.rotate(d),g=new t.P(Math.max(f.x,p.x,h.x,m.x),Math.max(f.y,p.y,h.y,m.y)),_=new t.P(Math.min(f.x,p.x,h.x,m.x),Math.min(f.y,p.y,h.y,m.y)),v=g.sub(_),y=(a.width-(o.left+o.right+n.left+n.right))/v.x,b=(a.height-(o.top+o.bottom+n.top+n.bottom))/v.y;if(b<0||y<0)return void tn();let x=Math.min(t.ar(a.scale*Math.min(y,b)),e.maxZoom),S=t.P.convert(e.offset),C=new t.P((n.left-n.right)/2,(n.top-n.bottom)/2).rotate(t.an(i)),w=S.add(C).mult(a.scale/t.ao(x));return{center:Ae(a.worldSize,s.add(l).div(2).sub(w)),zoom:x,bearing:i}}class an{get useGlobeControls(){return!1}handlePanInertia(e,t){let n=e.mag(),r=Math.abs(je(t));return{easingOffset:e.mult(Math.min(.75*r/n,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,n){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(n,e.around)}cameraForBoxAndBearing(e,t,n,r,i){return rn(e,t,n,r,i)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom===void 0?e.zoom:+n.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(t.W.convert(n.center))}handleEaseTo(e,n){let r=e.zoom,i=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},o={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},s=n.zoom!==void 0,c=!e.isPaddingEqual(n.padding),l=!1,u=s?+n.zoom:e.zoom,d=e.centerPoint.add(n.offsetAsPoint),f=e.screenPointToLocation(d),{center:p,zoom:m}=e.applyConstrain(t.W.convert(n.center||f),u??r);Jt(e,p);let h=ke(e.worldSize,f),g=ke(e.worldSize,p).sub(h),_=t.ao(m-r);return l=m!==r,{easeFunc:s=>{if(l&&e.setZoom(t.H.number(r,m,s)),t.bn(a,o)||nn({startEulerAngles:a,endEulerAngles:o,tr:e,k:s,useSlerp:a.roll!=o.roll}),c&&(e.interpolatePadding(i,n.padding,s),d=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{let n=t.ao(e.zoom-r),i=(m>r?Math.min(2,_):Math.max(.5,_))**(1-s),a=Ae(e.worldSize,h.add(g.mult(s*i)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,d)}},isZooming:l,elevationCenter:p}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.zoom,a=e.applyConstrain(t.W.convert(n.center||n.locationAtOffset),r?+n.zoom:i),o=a.center,s=a.zoom;Jt(e,o);let c=ke(e.worldSize,n.locationAtOffset),l=ke(e.worldSize,o).sub(c),u=l.mag(),d=t.ao(s-i),f;if(n.minZoom!==void 0){let r=Math.min(+n.minZoom,i,s),a=e.applyConstrain(o,r).zoom;f=t.ao(a-i)}return{easeFunc:(n,r,a,u)=>{e.setZoom(n===1?s:i+t.ar(r));let d=n===1?o:Ae(e.worldSize,c.add(l.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?d.wrap():d,u)},scaleOfZoom:d,targetCenter:o,scaleOfMinZoom:f,pixelPathLength:u}}}class on{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}on.Replace=[1,0],on.disabled=new on(on.Replace,t.bo.transparent,[!1,!1,!1,!1]),on.unblended=new on(on.Replace,t.bo.transparent,[!0,!0,!0,!0]),on.alphaBlended=new on([1,771],t.bo.transparent,[!0,!0,!0,!0]);let sn=2305;class cn{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}cn.disabled=new cn(!1,1029,sn),cn.backCCW=new cn(!0,1029,sn),cn.frontCCW=new cn(!0,1028,sn);class ln{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}ln.ReadOnly=!1,ln.ReadWrite=!0,ln.disabled=new ln(519,ln.ReadOnly,[0,1]);let un=7680;class dn{constructor(e,t,n,r,i,a){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=a}}function fn(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext}dn.disabled=new dn({func:519,mask:0},0,0,un,un,un);class pn{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;let n=e.context,r=n.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;let i=new t.aU;i.emplaceBack(-1,-1),i.emplaceBack(2,-1),i.emplaceBack(-1,2);let a=new t.aW;a.emplaceBack(0,1,2),this._fullscreenTriangle=new Ht(n.createVertexBuffer(i,Ut.members),n.createIndexBuffer(a),t.aV.simpleSegment(0,0,i.length,a.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(r.TEXTURE1);let o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),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.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),fn(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){let e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){let n=this._updateCount;return this._readbackQueue?n>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():n>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){let e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){let r=this._cachedRenderContext.context,i=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram(`projectionErrorMeasurement`).draw(r,i.TRIANGLES,ln.disabled,dn.disabled,on.unblended,cn.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,n),null,null,`$clipping`,this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&fn(i)){i.bindBuffer(i.PIXEL_PACK_BUFFER,this._pbo),i.readBuffer(i.COLOR_ATTACHMENT0),i.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),i.bindBuffer(i.PIXEL_PACK_BUFFER,null);let e=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);i.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){let e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&fn(e)){let n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return t.w(`WebGL2 clientWaitSync failed.`),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=pn._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}let mn=t.a6/128;function hn(e,n){let r=e.granularity===void 0?1:Math.max(e.granularity,1),i=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),o=i+1,s=a+1,c=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=r+ +!!e.generateBorders,d=r+(e.generateBorders||e.extendToSouthPole?1:0),f=o*s,p=i*a*6,m=o*s>65536;if(m&&n===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let h=m||n===`32bit`,g=new Int16Array(2*f),_=0;for(let n=l;n<=d;n++)for(let i=c;i<=u;i++){let a=i/r*t.a6;i===-1&&(a=-mn),i===r+1&&(a=t.a6+mn);let o=n/r*t.a6;n===-1&&(o=e.extendToNorthPole?t.bq:-mn),n===r+1&&(o=e.extendToSouthPole?t.br:t.a6+mn),g[_++]=a,g[_++]=o}let v=h?new Uint32Array(p):new Uint16Array(p),y=0;for(let e=0;e<a;e++)for(let t=0;t<i;t++){let n=t+1+e*o,r=t+(e+1)*o,i=t+1+(e+1)*o;v[y++]=t+e*o,v[y++]=r,v[y++]=n,v[y++]=n,v[y++]=r,v[y++]=i}return{vertices:g.buffer.slice(0),indices:v.buffer.slice(0),uses32bitIndices:h}}let gn=new t.aT({fill:new t.bs(128,2),line:new t.bs(512,0),tile:new t.bs(128,32),stencil:new t.bs(128,1),circle:3});class _n{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return`vertical-perspective`}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return`globe`}get shaderDefine(){return`#define GLOBE`}get shaderPreludeCode(){return Bt.projectionGlobe}get vertexShaderPreludeCode(){return Bt.projectionMercator.vertexSource}get subdivisionGranularity(){return gn}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||=new pn(e);let n=t.Y(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,i=this._errorMeasurement.updateErrorLoop(n,r),a=l();i!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=i,this._errorMeasurementLastChangeTime=a);let o=Math.min(Math.max((a-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=t.bt(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,t.bu(o))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?`b`:``}${e.extendToNorthPole?`n`:``}${e.extendToSouthPole?`s`:``}`}getMeshFromTileID(e,t,n,r,i){let a=(i===`stencil`?gn.stencil:gn.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:a,generateBorders:n,extendToNorthPole:t.y===0&&r,extendToSouthPole:t.y===(1<<t.z)-1&&r})}_getMesh(e,n){let r=this._getMeshKey(n);if(r in this._tileMeshCache)return this._tileMeshCache[r];let i=function(e,n){let r=hn(n,`16bit`),i=t.aU.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=t.aW.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new Ht(e.createVertexBuffer(i,Ut.members),e.createIndexBuffer(a),t.aV.simpleSegment(0,0,i.length,a.length))}(e,n);return this._tileMeshCache[r]=i,i}recalculate(e){}hasTransition(){let e=l(),t=!1;return t||=(e-this._errorMeasurementLastChangeTime)/1e3<.7,t||=this._errorMeasurement?.awaitingQuery,t}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}let vn=new t.u({type:new t.D(t.x.projection.type)});class yn extends t.E{constructor(e){super(),this._transitionable=new t.y(vn,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0)),this._mercatorProjection=new Kt,this._verticalPerspectiveProjection=new _n}get transitionState(){let e=this.properties.get(`type`);if(typeof e==`string`&&e===`mercator`)return 0;if(typeof e==`string`&&e===`vertical-perspective`)return 1;if(e instanceof t.bv){if(e.from===`vertical-perspective`&&e.to===`mercator`)return 1-e.transition;if(e.from===`mercator`&&e.to===`vertical-perspective`)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,n,r,i){return this.currentProjection.getMeshFromTileID(e,t,n,r,i)}setProjection(e){this._transitionable.setValue(`type`,e?.type||`mercator`)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function bn(e){let t=Cn(e.worldSize,e.center.lat);return 2*Math.PI*t}function xn(e,n,r,i,a){let o=1/(1<<a),s=n/t.a6*o+i*o,c=t.by((e/t.a6*o+r*o)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI,u=Math.cos(l),d=new Float64Array(3);return d[0]=Math.sin(c)*u,d[1]=Math.sin(l),d[2]=Math.cos(c)*u,d}function Sn(e){return function(e,t){let n=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*n,r[1]=Math.sin(t),r[2]=Math.cos(e)*n,r}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Cn(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function wn(e){let n=Math.asin(e[1])/Math.PI*180,r=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(r>1e-6){let i=e[0]/r,a=Math.acos(e[2]/r),o=(i>0?a:-a)/Math.PI*180;return new t.W(t.X(o,-180,180),n)}return new t.W(0,n)}function Tn(e){return Math.cos(e*Math.PI/180)}function En(e,n){let r=Tn(e),i=Tn(n);return t.ar(i/r)}function Dn(e,n){let r=e.rotate(n.bearingInRadians),i=n.zoom+En(n.center.lat,0),a=t.bt(1/Tn(n.center.lat),1/Tn(Math.min(Math.abs(n.center.lat),60)),t.bw(i,7,3,0,1)),o=360/bn({worldSize:n.worldSize,center:{lat:n.center.lat}});return new t.W(n.center.lng-r.x*o*a,t.al(n.center.lat+r.y*o,-t.am,t.am))}function On(e){let t=.5*e,n=Math.sin(t),r=Math.cos(t);return Math.log(n+r)-Math.log(r-n)}function kn(e,n,r,i){let a=e.lat+r*i;if(Math.abs(r)>1){let o=(Math.sign(e.lat+r)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,s=Math.abs(e.lat+r)*Math.PI/180,c=On(o+i*(s-o)),l=On(o),u=On(s);return new t.W(e.lng+n*((c-l)/(u-l)),a)}return new t.W(e.lng+n*i,a)}class An{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,n,r){let i=`${e.z}_${e.x}_${e.y}_${r?.terrain?`t`:``}`,a=this._cache.get(i);if(a)return a;let o=this._cachePrevious.get(i);if(o)return this._cache.set(i,o),o;let s=this._boundingVolumeFactory(e,t,n,r);return this._cache.set(i,s),this._hadAnyChanges=!0,s}}class jn{constructor(e,t,n,r){this.min=n,this.max=r,this.points=e,this.planes=t}static fromAabb(e,t){let n=[];for(let r=0;r<8;r++)n.push([1&~r?e[0]:t[0],(r>>1&1)==1?t[1]:e[1],(r>>2&1)==1?t[2]:e[2]]);return new jn(n,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,n,r){let i=t.bA([],r[0],r[1],r[2]),a=t.bB([],[n[0],0,0],i),o=t.bB([],[0,n[1],0],i),s=t.bB([],[0,0,n[2]],i),c=[...e],l=[...e];for(let t=0;t<8;t++)for(let n=0;n<3;n++){let r=e[n]+a[n]*(1&~t?-1:1)+o[n]*((t>>1&1)==1?1:-1)+s[n]*((t>>2&1)==1?1:-1);c[n]=Math.min(c[n],r),l[n]=Math.max(l[n],r)}let u=[];for(let n=0;n<8;n++){let r=[...e];t.a_(r,r,t.aZ([],a,1&~n?-1:1)),t.a_(r,r,t.aZ([],o,(n>>1&1)==1?1:-1)),t.a_(r,r,t.aZ([],s,(n>>2&1)==1?1:-1)),u.push(r)}return new jn(u,[[...a,-t.b3(a,u[0])],[...o,-t.b3(o,u[0])],[...s,-t.b3(s,u[0])],[-a[0],-a[1],-a[2],-t.b3(a,u[7])],[-o[0],-o[1],-o[2],-t.b3(o,u[7])],[-s[0],-s[1],-s[2],-t.b3(s,u[7])]],c,l)}intersectsFrustum(e){let t=!0,n=this.points.length,r=this.planes.length,i=e.planes.length,a=e.points.length;for(let r=0;r<i;r++){let i=e.planes[r],a=0;for(let e=0;e<n;e++){let t=this.points[e];i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0&&a++}if(a===0)return 0;a<n&&(t=!1)}if(t)return 2;for(let t=0;t<r;t++){let n=this.planes[t],r=0;for(let t=0;t<a;t++){let i=e.points[t];n[0]*i[0]+n[1]*i[1]+n[2]*i[2]+n[3]>=0&&r++}if(r===0)return 0}return 1}intersectsPlane(e){let t=this.points.length,n=0;for(let r=0;r<t;r++){let t=this.points[r];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&n++}return n===t?2:n===0?0:1}}function Mn(e,t,n){let r=e-t;return r<0?-r:Math.max(0,r-n)}function Nn(e,t,n,r,i){let a=e-n,o;return o=a<0?Math.min(-a,1+a-i):a>i?Math.min(Math.max(a-i,0),1-a):0,Math.max(o,Mn(t,r,i))}class Pn{constructor(){this._boundingVolumeCache=new An(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,n,r){let i=1<<n.z,a=1/i,o=n.x/i,s=n.y/i,c=2;return c=Math.min(c,Nn(e,t,o,s,a)),c=Math.min(c,Nn(e,t,o+.5,-s-a,a)),c=Math.min(c,Nn(e,t,o+.5,2-s-a,a)),c}getWrap(e,t,n){let r=1<<t.z,i=1/r,a=t.x/r,o=Mn(e.x,a,i),s=Mn(e.x,a-1,i),c=Mn(e.x,a+1,i),l=Math.min(o,s,c);return l===c?1:l===s?-1:0}allowVariableZoom(e,t){return Re(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,n,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,n,r)}_computeTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.a3(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}if(a/=t.bD,o/=t.bD,a+=1,o+=1,e.z<=0)return jn.fromAabb([-o,-o,-o],[o,o,o]);if(e.z===1)return jn.fromAabb([e.x===0?-o:0,e.y===0?0:-o,-o],[e.x===0?0:o,e.y===0?o:0,o]);{let n=[xn(0,0,e.x,e.y,e.z),xn(t.a6,0,e.x,e.y,e.z),xn(t.a6,t.a6,e.x,e.y,e.z),xn(0,t.a6,e.x,e.y,e.z)],r=[];for(let e of n)r.push(t.aZ([],e,o));if(o!==a)for(let e of n)r.push(t.aZ([],e,a));e.y===0&&r.push([0,1,0]),e.y===(1<<e.z)-1&&r.push([0,-1,0]);let i=[1,1,1],s=[-1,-1,-1];for(let e of r)for(let t=0;t<3;t++)i[t]=Math.min(i[t],e[t]),s[t]=Math.max(s[t],e[t]);let c=xn(t.a6/2,t.a6/2,e.x,e.y,e.z),l=t.b2([],[0,1,0],c);t.b1(l,l);let u=t.b2([],c,l);t.b1(u,u);let d=t.b2([],n[2],n[1]);t.b1(d,d);let f=t.b2([],n[0],n[3]);t.b1(f,f),r.push(t.aZ([],c,o)),e.y>=(1<<e.z)/2&&r.push(t.aZ([],xn(t.a6/2,0,e.x,e.y,e.z),o)),e.y<(1<<e.z)/2&&r.push(t.aZ([],xn(t.a6/2,t.a6,e.x,e.y,e.z),o));let p=Fn(c,r),m=Fn(u,r),h=[-c[0],-c[1],-c[2],p.max],g=[c[0],c[1],c[2],-p.min],_=[-u[0],-u[1],-u[2],m.max],v=[u[0],u[1],u[2],-m.min],y=[...d,0],b=[...f,0],x=[];return e.y===0?x.push(t.bC(b,y,h),t.bC(b,y,g)):x.push(t.bC(_,y,h),t.bC(_,y,g),t.bC(_,b,h),t.bC(_,b,g)),e.y===(1<<e.z)-1?x.push(t.bC(b,y,h),t.bC(b,y,g)):x.push(t.bC(v,y,h),t.bC(v,y,g),t.bC(v,b,h),t.bC(v,b,g)),new jn(x,[h,g,_,v,y,b],i,s)}}}function Fn(e,n){let r=1/0,i=-1/0;for(let a of n){let n=t.b3(e,a);r=Math.min(r,n),i=Math.max(i,n)}return{min:r,max:i}}class In{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._cachedClippingPlane=t.bE(),this._projectionMatrix=t.bi(),this._globeViewProjMatrix32f=t.bh(),this._globeViewProjMatrixNoCorrection=t.bi(),this._globeViewProjMatrixNoCorrectionInverted=t.bi(),this._globeProjMatrixInverted=t.bi(),this._cameraPosition=t.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(e,n)=>{let r=t.al(e.lat,-t.am,t.am),i=t.al(+n,this.minZoom+En(0,r),this.maxZoom);return{center:new t.W(e.lng,r),zoom:i}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Xt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Pn}clone(){let e=new In;return e.apply(this,!1),e}apply(e,t,n){this._globeLatitudeErrorCorrectionRadians=n||0,this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=t.bz();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){let{overscaledTileID:t,applyGlobeMatrix:n}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!n,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){let n=this.pitchInRadians,r=this.cameraToCenterDistance/e,i=Math.sin(n)*r,a=Math.cos(n)*r+1,o=1/Math.sqrt(i*i+a*a)*1,s=-i,c=a,l=Math.sqrt(s*s+c*c);s/=l,c/=l;let u=[0,s,c];t.bF(u,u,[0,0,0],-this.bearingInRadians),t.bG(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(u,u,[0,0,0],this.center.lng*Math.PI/180);let d=1/t.b5(u);return t.aZ(u,u,d),[...u,-o*d]}isLocationOccluded(e){return!this.isSurfacePointVisible(Sn(e))}transformLightDirection(e){let n=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,i=Math.cos(r),a=[Math.sin(n)*i,Math.sin(r),Math.cos(n)*i],o=[a[2],0,-a[0]],s=[0,0,0];t.b2(s,o,a),t.b1(o,o),t.b1(s,s);let c=[0,0,0];return t.b1(c,[o[0]*e[0]+s[0]*e[1]+a[0]*e[2],o[1]*e[0]+s[1]*e[1]+a[1]*e[2],o[2]*e[0]+s[2]*e[1]+a[2]*e[2]]),c}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,r){let i=function(e,n,r){let i=1/(1<<r.z);return new t.a7(e/t.a6*i+r.x*i,n/t.a6*i+r.y*i)}(e,n,r.canonical),a=(o=i.y,[t.by(i.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(e,n,r,i){let a=r.canonical,o=xn(e,n,a.x,a.y,a.z),s=1+(i?i(e,n):0)/t.bD,c=[o[0]*s,o[1]*s,o[2]*s,1];t.aE(c,c,this._globeViewProjMatrixNoCorrection);let l=this._cachedClippingPlane,u=l[0]*o[0]+l[1]*o[1]+l[2]*o[2]+l[3]<0;return{point:new t.P(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:u}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let e=Cn(this.worldSize,this.center.lat),n=t.bj(),r=t.bj();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),t.bc(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;n[8]=2*-i.x/this._helper._width,n[9]=2*i.y/this._helper._height,this._projectionMatrix=t.bd(n),this._globeProjMatrixInverted=t.bj(),t.bg(this._globeProjMatrixInverted,n),t.Q(n,n,[0,0,-this.cameraToCenterDistance]),t.be(n,n,this.rollInRadians),t.bf(n,n,-this.pitchInRadians),t.be(n,n,this.bearingInRadians),t.Q(n,n,[0,0,-e]);let a=t.bz();a[0]=e,a[1]=e,a[2]=e,t.bf(r,n,this.center.lat*Math.PI/180),t.bI(r,r,-this.center.lng*Math.PI/180),t.S(r,r,a),this._globeViewProjMatrixNoCorrection=r,t.bf(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),t.bI(n,n,-this.center.lng*Math.PI/180),t.S(n,n,a),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=t.bj(),t.bg(this._globeViewProjMatrixNoCorrectionInverted,r);let o=t.bz();this._cameraPosition=t.bz(),this._cameraPosition[2]=this.cameraToCenterDistance/e,t.bF(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),t.bG(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),t.bF(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),t.a_(this._cameraPosition,this._cameraPosition,[0,0,1]),t.bG(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),t.bH(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let s=t.bd(this._globeViewProjMatrixNoCorrectionInverted);t.S(s,s,[1,1,-1]),this._cachedFrustum=$t.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){t.w(`calculateFogMatrix is not supported on globe projection.`);let n=t.bj();return t.ap(n),n}getVisibleUnwrappedCoordinates(e){return[new t.ba(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&t.w(`terrain is not fully supported on vertical perspective projection.`),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;let r=Sn(e);t.aZ(r,r,1+n/t.bD);let i=t.bE();return t.aE(i,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),i[2]/i[3]}populateCache(e){}getBounds(){let e=.5*this.width,n=.5*this.height,r=[new t.P(0,0),new t.P(e,0),new t.P(this.width,0),new t.P(this.width,n),new t.P(this.width,this.height),new t.P(e,this.height),new t.P(0,this.height),new t.P(0,n)],i=[];for(let e of r)i.push(this.unprojectScreenPoint(e));let a=0,o=0,s=0,c=0,l=this.center;for(let e of i){let n=t.bJ(l.lng,e.lng),r=t.bJ(l.lat,e.lat);n<o&&(o=n),n>a&&(a=n),r<c&&(c=r),r>s&&(s=r)}let u=[l.lng+o,l.lat+c,l.lng+a,l.lat+s];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new re(u)}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,n){let r=Sn(this.unprojectScreenPoint(n)),i=Sn(e),a=t.bz();t.bK(a);let o=t.bz();t.bH(o,r,a,-this.center.lng*Math.PI/180),t.bG(o,o,a,this.center.lat*Math.PI/180);let s=i[0]*i[0]+i[2]*i[2],c=o[0]*o[0];if(s<c)return;let l=Math.sqrt(s-c),u=-l,d=t.bL(i[0],i[2],o[0],l),f=t.bL(i[0],i[2],o[0],u),p=t.bz();t.bH(p,i,a,-d);let m=t.bL(p[1],p[2],o[1],o[2]),h=t.bz();t.bH(h,i,a,-f);let g=t.bL(h[1],h[2],o[1],o[2]),_=.5*Math.PI,v=m>=-_&&m<=_,y=g>=-_&&g<=_,b,x;if(v&&y){let e=this.center.lng*Math.PI/180,n=this.center.lat*Math.PI/180;t.bM(d,e)+t.bM(m,n)<t.bM(f,e)+t.bM(g,n)?(b=d,x=m):(b=f,x=g)}else if(v)b=d,x=m;else{if(!y)return;b=f,x=g}let S=b/Math.PI*180,C=x/Math.PI*180,w=this.center.lat;this.setCenter(new t.W(S,t.al(C,-90,90))),this.setZoom(this.zoom+En(w,this.center.lat))}locationToScreenPoint(e,n){let r=Sn(e);if(n){let i=n.getElevationForLngLatZoom(e,this._helper._tileZoom);t.aZ(r,r,1+i/t.bD)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(e){let n=t.bE();return t.aE(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new t.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){let t=n.pointCoordinate(e);if(t)return t}return t.a7.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}isPointOnMapSurface(e,t){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(n,r)}getRayDirectionFromPixel(e){let n=t.bE();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,t.aE(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];let r=t.bz();r[0]=n[0]-this._cameraPosition[0],r[1]=n[1]-this._cameraPosition[1],r[2]=n[2]-this._cameraPosition[2];let i=t.bz();return t.b1(i,r),i}isSurfacePointVisible(e){let t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;let n=t.bE();return t.aE(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){let r=t.b3(e,n),i=t.bz(),a=t.bz();t.aZ(a,n,r),t.b0(i,e,a);let o=1-t.b3(i,i);if(o<0)return null;let s=t.b3(e,e)-1,c=-r+(r<0?1:-1)*Math.sqrt(o),l=s/c,u=c;return{tMin:Math.min(l,u),tMax:Math.max(l,u)}}unprojectScreenPoint(e){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e),i=this.rayPlanetIntersection(n,r);if(i){let e=t.bz();t.a_(e,n,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let a=t.bz();return t.b1(a,e),wn(a)}let a=this._cachedClippingPlane,o=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],s=-t.b9(a,n)/o,c=t.bz();if(s>0)t.a_(c,n,[r[0]*s,r[1]*s,r[2]*s]);else{let e=t.bz();t.a_(e,n,[2*r[0],2*r[1],2*r[2]]);let i=t.b9(this._cachedClippingPlane,e);t.b0(c,e,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let l=function(e){let n=t.bz();return n[0]=e[0]*-e[3],n[1]=e[1]*-e[3],n[2]=e[2]*-e[3],{center:n,radius:Math.sqrt(1-e[3]*e[3])}}(a);return wn(function(e,n,r){let i=t.bz();t.b0(i,r,e);let a=t.bz();return t.bx(a,e,i,n/t.b7(i)),a}(l.center,l.radius,c))}getMatrixForModel(e,n){let r=t.W.convert(e),i=1/t.bD,a=t.bi();return t.bI(a,a,r.lng/180*Math.PI),t.bf(a,a,-r.lat/180*Math.PI),t.Q(a,a,[0,0,1+n/t.bD]),t.bf(a,a,.5*Math.PI),t.S(a,a,[i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=this.getProjectionData({overscaledTileID:new t.a3(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class Ln{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Xt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new en,this._verticalPerspectiveTransform=new In}clone(){let e=new Ln;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){let t=this._mercatorTransform.getProjectionData(e),n=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?n.mainMatrix:t.mainMatrix,clippingPlane:n.clippingPlane,tileMercatorCoords:n.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,r){let i=this._mercatorTransform.getPitchedTextCorrection(e,n,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,r);return t.bt(i,a,this._globeness)}projectTileCoordinates(e,t,n,r){return this.currentTransform.projectTileCoordinates(e,t,n,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){let t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;let n=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return n.fallbackMatrix=t.mainMatrix,n}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Rn{get useGlobeControls(){return!0}handlePanInertia(e,n){let r=Dn(e,n);return Math.abs(r.lng-n.center.lng)>180&&(r.lng=n.center.lng+179.5*Math.sign(r.lng-n.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){let r=e.around,i=n.screenPointToLocation(r);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);let a=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);let o=n.zoom-a;if(o===0)return;let s=t.bJ(n.center.lng,i.lng),c=s/(Math.abs(s/180)+1),l=t.bJ(n.center.lat,i.lat),u=n.getRayDirectionFromPixel(r),d=n.cameraPosition,f=-1*t.b3(d,u),p=t.bz();t.a_(p,d,[u[0]*f,u[1]*f,u[2]*f]);let m=t.b5(p)-1,h=Math.exp(.5*-Math.max(m-.3,0)),g=Cn(n.worldSize,n.center.lat)/Math.min(n.width,n.height),_=t.bw(g,.9,.5,1,.25),v=(1-t.ao(-o))*Math.min(h,_),y=n.center.lat,b=n.zoom,x=new t.W(n.center.lng+c*v,t.al(n.center.lat+l*v,-t.am,t.am));n.setLocationAtPoint(i,r);let S=n.center,C=t.bw(Math.abs(s),45,85,0,1),w=t.bw(g,.75,.35,0,1),T=Math.max(C,w)**.25,E=t.bJ(S.lng,x.lng),D=t.bJ(S.lat,x.lat);n.setCenter(new t.W(S.lng+E*T,S.lat+D*T).wrap()),n.setZoom(b+En(y,n.center.lat))}handleMapControlsPan(e,t,n){if(!e.panDelta)return;let r=t.center.lat,i=t.zoom;t.setCenter(Dn(e.panDelta,t).wrap()),t.setZoom(i+En(r,t.center.lat))}cameraForBoxAndBearing(e,n,r,i,a){let o=rn(e,n,r,i,a),s=n.left/a.width*2-1,c=(a.width-n.right)/a.width*2-1,l=n.top/a.height*-2+1,u=(a.height-n.bottom)/a.height*-2+1,d=t.bJ(r.getWest(),r.getEast())<0,f=d?r.getEast():r.getWest(),p=d?r.getWest():r.getEast(),m=Math.max(r.getNorth(),r.getSouth()),h=Math.min(r.getNorth(),r.getSouth()),g=f+.5*t.bJ(f,p),_=m+.5*t.bJ(m,h),v=a.clone();v.setCenter(o.center),v.setBearing(o.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(o.zoom);let y=v.modelViewProjectionMatrix,b=[Sn(r.getNorthWest()),Sn(r.getNorthEast()),Sn(r.getSouthWest()),Sn(r.getSouthEast()),Sn(new t.W(p,_)),Sn(new t.W(f,_)),Sn(new t.W(g,m)),Sn(new t.W(g,h))],x=Sn(o.center),S=1/0;for(let e of b)s<0&&(S=Rn.getLesserNonNegativeNonNull(S,Rn.solveVectorScale(e,x,y,`x`,s))),c>0&&(S=Rn.getLesserNonNegativeNonNull(S,Rn.solveVectorScale(e,x,y,`x`,c))),l>0&&(S=Rn.getLesserNonNegativeNonNull(S,Rn.solveVectorScale(e,x,y,`y`,l))),u<0&&(S=Rn.getLesserNonNegativeNonNull(S,Rn.solveVectorScale(e,x,y,`y`,u)));if(Number.isFinite(S)&&S!==0)return o.zoom=Math.min(v.zoom+t.ar(S),e.maxZoom),o;tn()}handleJumpToCenterZoom(e,n){let r=e.center.lat,i=e.applyConstrain(n.center?t.W.convert(n.center):e.center,e.zoom).center;e.setCenter(i.wrap());let a=n.zoom===void 0?e.zoom+En(r,i.lat):+n.zoom;e.zoom!==a&&e.setZoom(a)}handleEaseTo(e,n){let r=e.zoom,i=e.center,a=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},c=n.zoom!==void 0,l=!e.isPaddingEqual(n.padding),u=!1,d=n.center?t.W.convert(n.center):i,f=e.applyConstrain(d,r).center;Jt(e,f);let p=e.clone();p.setCenter(f),p.setZoom(c?+n.zoom:r+En(i.lat,d.lat)),p.setBearing(n.bearing);let m=new t.P(t.al(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(f,m);let h=(n.offset&&n.offsetAsPoint.mag())>0?p.center:f,g=c?+n.zoom:r+En(i.lat,h.lat),_=r+En(i.lat,0),v=g+En(h.lat,0),y=t.bJ(i.lng,h.lng),b=t.bJ(i.lat,h.lat),x=t.ao(v-_);return u=g!==r,{easeFunc:r=>{if(t.bn(o,s)||nn({startEulerAngles:o,endEulerAngles:s,tr:e,k:r,useSlerp:o.roll!=s.roll}),l&&e.interpolatePadding(a,n.padding,r),n.around)t.w(`Easing around a point is not supported under globe projection.`),e.setLocationAtPoint(n.around,n.aroundPoint);else{let t=kn(i,y,b,r*(v>_?Math.min(2,x):Math.max(.5,x))**(1-r));e.setCenter(t.wrap())}if(u){let n=t.H.number(_,v,r)+En(0,e.center.lat);e.setZoom(n)}},isZooming:u,elevationCenter:h}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.center,a=e.zoom,o=e.padding,s=!e.isPaddingEqual(n.padding),c=e.applyConstrain(t.W.convert(n.center||n.locationAtOffset),a).center,l=r?+n.zoom:e.zoom+En(e.center.lat,c.lat),u=e.clone();u.setCenter(c),u.setZoom(l),u.setBearing(n.bearing);let d=new t.P(t.al(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(c,d);let f=u.center;Jt(e,f);let p=function(e,n,r){let i=Sn(n),a=Sn(r),o=t.b3(i,a),s=Math.acos(o),c=bn(e);return s/(2*Math.PI)*c}(e,i,f),m=a+En(i.lat,0),h=l+En(f.lat,0),g=t.ao(h-m),_;if(typeof n.minZoom==`number`){let r=+n.minZoom+En(f.lat,0),i=Math.min(r,m,h)+En(0,f.lat),a=e.applyConstrain(f,i).zoom+En(f.lat,0);_=t.ao(a-m)}let v=t.bJ(i.lng,f.lng),y=t.bJ(i.lat,f.lat);return{easeFunc:(r,a,c,u)=>{let d=kn(i,v,y,c);s&&e.interpolatePadding(o,n.padding,r);let p=r===1?f:d;e.setCenter(p.wrap());let h=m+t.ar(a);e.setZoom(r===1?l:h+En(0,p.lat))},scaleOfZoom:g,targetCenter:f,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,n,r,i){let a=r===`x`?[n[0],n[4],n[8],n[12]]:[n[1],n[5],n[9],n[13]],o=[n[3],n[7],n[11],n[15]],s=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],u=t[0]*o[0]+t[1]*o[1]+t[2]*o[2];return l+i*c===s+i*u||o[3]*(s-l)+a[3]*(u-c)+s*u==l*c?null:(l+a[3]-i*u-i*o[3])/(l-s-i*u+i*c)}static getLesserNonNegativeNonNull(e,t){return t!==null&&t>=0&&t<e?t:e}}class zn{constructor(e){this._globe=e,this._mercatorCameraHelper=new an,this._verticalPerspectiveCameraHelper=new Rn}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,n){this.currentHelper.handleMapControlsPan(e,t,n)}cameraForBoxAndBearing(e,t,n,r,i){return this.currentHelper.cameraForBoxAndBearing(e,t,n,r,i)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}let Bn=(e,n)=>t.C(e,n?.filter((e=>e.identifier!==`source.canvas`))),Vn=t.bN();class Hn extends t.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.tileManagers){let t=this.tileManagers[e].getSource().type;t!==`vector`&&t!==`geojson`||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new F(P(),e._getMapId()),this.dispatcher.registerMessageHandler(`GG`,((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler(`GI`,((e,t)=>this.getImages(e,t))),this.dispatcher.registerMessageHandler(`GDA`,((e,t)=>this.getDashes(e,t))),this.imageManager=new g,this.imageManager.setEventedParent(this);let r=e._container?.lang||typeof document<`u`&&document.documentElement?.lang||void 0;this.glyphManager=new S(e._requestManager,n.localIdeographFontFamily,r),this.lineAtlas=new O(256,512),this.crossTileSymbolIndex=new Rt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast(`SR`,t.bO()),Ce().on(be,this._rtlPluginLoaded),this.on(`data`,(e=>{if(e.dataType!==`source`||e.sourceDataType!==`metadata`)return;let t=this.tileManagers[e.sourceId];if(!t)return;let n=t.getSource();if(n?.vectorLayerIds)for(let e in this._layers){let t=this._layers[e];t.source===n.id&&this._validateLayer(t)}}))}_setInitialValues(){this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,n){this._checkLoaded();let r=n===null?this.stylesheet.state?.[e]?.default??null:n;if(t.bQ(r,this._globalState[e]))return this;this._globalState[e]=r,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let n=[];for(let r in e)!t.bQ(this._globalState[r],e[r].default)&&(n.push(r),this._globalState[r]=e[r].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;let t=new Set,n={};for(let r of e){n[r]=this._globalState[r];for(let e in this._layers){let n=this._layers[e],i=n.getLayoutAffectingGlobalStateRefs(),a=n.getPaintAffectingGlobalStateRefs(),o=n.getVisibilityAffectingGlobalStateRefs();if(i.has(r)&&t.add(n.source),a.has(r))for(let{name:e,value:t}of a.get(r))this._updatePaintProperty(n,e,t);o!=null&&o.has(r)&&(n.recalculateVisibility(),this._updateLayer(n))}}this.dispatcher.broadcast(`UGS`,n);for(let e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e){return t._(this,arguments,void 0,(function*(e,n={},r){this.fire(new t.n(`dataloading`,{dataType:`style`})),n.validate=typeof n.validate!=`boolean`||n.validate,this._loadStyleRequest=new AbortController;let i=this._loadStyleRequest;try{let a=yield this.map._requestManager.transformRequest(e,`Style`);t.bR(i.signal);let o=yield t.k(a,i);this._loadStyleRequest===i&&(this._loadStyleRequest=null),this._load(o.data,n,r)}catch(e){this._loadStyleRequest===i&&(this._loadStyleRequest=null),e&&!i.signal.aborted&&this.fire(new t.l(t.d(e)))}}))}loadJSON(e,n={},r){this.fire(new t.n(`dataloading`,{dataType:`style`})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,n.validate=!1!==n.validate,this._load(e,n,r)})).catch((()=>{}))}loadEmpty(){this.fire(new t.n(`dataloading`,{dataType:`style`})),this._load(Vn,{validate:!1})}_load(e,n,r){let i=n.transformStyle?n.transformStyle(r,e):e;if(!n.validate||!Bn(this,t.F(i))){i=Object.assign({},i),this._loaded=!0,this.stylesheet=i;for(let e in i.sources)this.addSource(e,i.sources[e],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this._createLayers(),this.light=new T(this.stylesheet.light),this._setProjectionInternal(this.stylesheet.projection?.type||`mercator`),this.sky=new D(this.stylesheet.sky),this.map.setTerrain(this.stylesheet.terrain??null),this.fire(new t.n(`data`,{dataType:`style`})),this.fire(new t.n(`style.load`))}}_createLayers(){let e=t.bS(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast(`SL`,e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(let n of e){let e=t.bT(n,this._globalState);if(e.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=e,t.bU(e)&&this.tileManagers[e.source]){let t=n.paint?.[`raster-fade-duration`]??e.paint.get(`raster-fade-duration`);this.tileManagers[e.source].setRasterFadeDuration(t)}}}_loadSprite(e,n=!1,r=void 0){this.imageManager.setLoaded(!1);let i=new AbortController,a;this._spriteRequest=i,function(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=p(e),o=r>1?`@2x`:``,c={},l={};for(let{id:e,url:r}of a){let a=yield n.transformRequest(m(r,o,`.json`),`SpriteJSON`);c[e]=t.k(a,i);let s=yield n.transformRequest(m(r,o,`.png`),`SpriteImage`);l[e]=u.getImage(s,i)}return yield Promise.all([...Object.values(c),...Object.values(l)]),function(e,n){return t._(this,void 0,void 0,(function*(){let t={};for(let r in e){t[r]={};let i=s.getImageCanvasContext((yield n[r]).data),a=(yield e[r]).data;for(let e in a){let{width:n,height:o,x:s,y:c,sdf:l,pixelRatio:u,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h}=a[e];t[r][e]={data:null,pixelRatio:u,sdf:l,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h,spriteData:{width:n,height:o,x:s,y:c,context:i}}}}return t}))}(c,l)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(let t in e){this._spritesImagesIds[t]=[];let r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(let e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(let r in e[t]){let i=t==="default"?r:`${t}:${r}`;this._spritesImagesIds[t].push(i),i in this.imageManager.images?this.imageManager.updateImage(i,e[t][r],!1):this.imageManager.addImage(i,e[t][r]),n&&(this._changedImages[i]=!0)}}})).catch((e=>{this._spriteRequest=null,a=e,i.signal.aborted||this.fire(new t.l(a))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`})),r&&r(a)}))}_unloadSprite(){for(let e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`}))}_validateLayer(e){let n=this.tileManagers[e.source];if(!n)return;let r=e.sourceLayer;if(!r)return;let i=n.getSource();(i.type===`geojson`||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new t.l(Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,n=!1){let r=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?t.bV(r):r);let i=[];for(let a of e)if(r[a]){let e=n?t.bV(r[a]):r[a];i.push(e)}return i}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let n of t){let t=this._layers[n];t.type!==`custom`&&(e[n]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error(`Style is not done loading.`)}update(e){if(!this._loaded)return;let n=this._changed;if(n){let t=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(t.length||n.length)&&this._updateWorkerLayers(t,n);for(let e in this._updatedSources){let t=this._updatedSources[e];if(t===`reload`)this._reloadSource(e);else{if(t!==`clear`)throw Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let r={};for(let e in this.tileManagers){let t=this.tileManagers[e];r[e]=t.used,t.used=!1}for(let t of this._order){let n=this._layers[t];n.recalculate(e,this._availableImages),!n.isHidden(e.zoom)&&n.source&&(this.tileManagers[n.source].used=!0)}for(let e in r){let n=this.tileManagers[e];!!r[e]!=!!n.used&&n.fire(new t.n(`data`,{sourceDataType:`visibility`,dataType:`source`,sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new t.n(`data`,{dataType:`style`}))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies([`icons`,`patterns`],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies([`glyphs`],[``]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast(`UL`,{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var r;this._checkLoaded();let i=this.serialize();if(e=n.transformStyle?n.transformStyle(i,e):e,((r=n.validate)==null||r)&&Bn(this,t.F(e)))return!1;(e=t.bV(e)).layers=t.bS(e.layers);let a=t.bW(i,e),o=this._getOperationsToPerform(a);if(o.unimplemented.length>0)throw Error(`Unimplemented: ${o.unimplemented.join(`, `)}.`);if(o.operations.length===0)return!1;for(let e of o.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new t.n(`style.load`,{style:this})),!0}_getOperationsToPerform(e){let t=[],n=[];for(let r of e)switch(r.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:t.push((()=>this.addLayer.apply(this,r.args)));break;case`removeLayer`:t.push((()=>this.removeLayer.apply(this,r.args)));break;case`setPaintProperty`:t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case`setLayoutProperty`:t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case`setFilter`:t.push((()=>this.setFilter.apply(this,r.args)));break;case`addSource`:t.push((()=>this.addSource.apply(this,r.args)));break;case`removeSource`:t.push((()=>this.removeSource.apply(this,r.args)));break;case`setLayerZoomRange`:t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case`setLight`:t.push((()=>this.setLight.apply(this,r.args)));break;case`setGeoJSONSourceData`:t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case`setGlyphs`:t.push((()=>this.setGlyphs.apply(this,r.args)));break;case`setSprite`:t.push((()=>this.setSprite.apply(this,r.args)));break;case`setTerrain`:t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case`setSky`:t.push((()=>this.setSky.apply(this,r.args)));break;case`setProjection`:this.setProjection.apply(this,r.args);break;case`setGlobalState`:t.push((()=>this.setGlobalState.apply(this,r.args)));break;case`setTransition`:t.push((()=>{}));break;default:n.push(r.command)}return{operations:t,unimplemented:n}}addImage(e,n){if(this.getImage(e))return this.fire(new t.l(Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.l(Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,r={}){var i;if(this._checkLoaded(),this.tileManagers[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(`, `)}.`);if([`vector`,`raster`,`geojson`,`video`,`image`].includes(n.type)&&this._validate(t.F.source,`sources.${e}`,n,null,r))return;(i=this.map)!=null&&i._collectResourceTiming&&(n.collectResourceTiming=!0);let a=this.tileManagers[e]=new qe(e,n,this.dispatcher);a.style=this,a.setEventedParent(this,(()=>({isSourceLoaded:a.loaded(),source:a.serialize(),sourceId:e}))),a.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let n in this._layers)if(this._layers[n].source===e)return this.fire(new t.l(Error(`Source "${e}" cannot be removed while layer "${n}" is using it.`)));let n=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],n.fire(new t.n(`data`,{sourceDataType:`metadata`,dataType:`source`,sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);let n=this.tileManagers[e].getSource();if(n.type!==`geojson`)throw Error(`geojsonSource.type is ${n.type}, which is !== 'geojson`);n.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]?.getSource()}addLayer(e,n,r={}){this._checkLoaded();let i=e.id;if(this.getLayer(i))return void this.fire(new t.l(Error(`Layer "${i}" already exists on this map.`)));let a;if(e.type===`custom`){if(Bn(this,t.bX(e)))return;a=t.bT(e,this._globalState)}else{if(`source`in e&&typeof e.source==`object`&&(this.addSource(i,e.source),e=t.bV(e),e=t.e(e,{source:i})),this._validate(t.F.layer,`layers.${i}`,e,{arrayIndex:-1},r))return;a=t.bT(e,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}let o=n?this._order.indexOf(n):this._order.length;if(n&&o===-1)this.fire(new t.l(Error(`Cannot add layer "${i}" before non-existing layer "${n}".`)));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&a.type!==`custom`){let e=this._removedLayers[i];delete this._removedLayers[i],e.type===a.type?(this._updatedSources[a.source]=`reload`,this.tileManagers[a.source].pause()):this._updatedSources[a.source]=`clear`}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.l(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;let r=this._order.indexOf(e);this._order.splice(r,1);let i=n?this._order.indexOf(n):this._order.length;n&&i===-1?this.fire(new t.l(Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let n=this._layers[e];if(!n)return void this.fire(new t.l(Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,r){this._checkLoaded();let i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(n!=null&&(i.minzoom=n),r!=null&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.l(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,r={}){this._checkLoaded();let i=this.getLayer(e);if(i){if(!t.bQ(i.filter,n))return n==null?(i.setFilter(void 0),void this._updateLayer(i)):void(this._validate(t.F.filter,`layers.${i.id}.filter`,n,null,r)||(i.setFilter(t.bV(n)),this._updateLayer(i)))}else this.fire(new t.l(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bV(this.getLayer(e).filter)}setLayoutProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bQ(a.getLayoutProperty(n),r)||(a.setLayoutProperty(n,r,i),this._updateLayer(a)):this.fire(new t.l(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){let r=this.getLayer(e);if(r)return r.getLayoutProperty(n);this.fire(new t.l(Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bQ(a.getPaintProperty(n),r)||this._updatePaintProperty(a,n,r,i):this.fire(new t.l(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,n,r,i={}){e.setPaintProperty(n,r,i)&&this._updateLayer(e),t.bU(e)&&n===`raster-fade-duration`&&this.tileManagers[e.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,n){this._checkLoaded();let r=e.source,i=e.sourceLayer,a=this.tileManagers[r];if(a===void 0)return void this.fire(new t.l(Error(`The source '${r}' does not exist in the map's style.`)));let o=a.getSource().type;o===`geojson`&&i?this.fire(new t.l(Error(`GeoJSON sources cannot have a sourceLayer parameter.`))):o!==`vector`||i?(e.id===void 0&&this.fire(new t.l(Error(`The feature id parameter must be provided.`))),a.setFeatureState(i,e.id,n)):this.fire(new t.l(Error(`The sourceLayer parameter must be provided for vector source types.`)))}removeFeatureState(e,n){this._checkLoaded();let r=e.source,i=this.tileManagers[r];if(i===void 0)return void this.fire(new t.l(Error(`The source '${r}' does not exist in the map's style.`)));let a=i.getSource().type,o=a===`vector`?e.sourceLayer:void 0;a!==`vector`||o?n&&typeof e.id!=`string`&&typeof e.id!=`number`?this.fire(new t.l(Error(`A feature id is required to remove its specific state property.`))):i.removeFeatureState(o,e.id,n):this.fire(new t.l(Error(`The sourceLayer parameter must be provided for vector source types.`)))}getFeatureState(e){this._checkLoaded();let n=e.source,r=e.sourceLayer,i=this.tileManagers[n];if(i!==void 0)return i.getSource().type!==`vector`||r?(e.id===void 0&&this.fire(new t.l(Error(`The feature id parameter must be provided.`))),i.getFeatureState(r,e.id)):void this.fire(new t.l(Error(`The sourceLayer parameter must be provided for vector source types.`)));this.fire(new t.l(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let e=t.bY(this.tileManagers,(e=>e.serialize())),n=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return t.bZ({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,projection:i.projection,sources:e,layers:n,terrain:r},(e=>e!==void 0))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!==`raster`&&(this._updatedSources[e.source]=`reload`,this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>this._layers[e].type===`fill-extrusion`,n={},r=[];for(let i=this._order.length-1;i>=0;i--){let a=this._order[i];if(t(a)){n[a]=i;for(let t of e){let e=t[a];if(e)for(let t of e)r.push(t)}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));let i=[];for(let a=this._order.length-1;a>=0;a--){let o=this._order[a];if(t(o))for(let e=r.length-1;e>=0;e--){let t=r[e].feature;if(n[t.layer.id]<a)break;i.push(t),r.pop()}else for(let t of e){let e=t[o];if(e)for(let t of e)i.push(t.feature)}}return i}queryRenderedFeatures(e,n,r){n!=null&&n.filter&&this._validate(t.F.filter,`queryRenderedFeatures.filter`,n.filter,null,n);let i={};if(n?.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new t.l(Error(`parameters.layers must be an Array or a Set of strings`))),[];for(let e of n.layers){let n=this._layers[e];if(!n)return this.fire(new t.l(Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];i[n.source]=!0}}let a=[];n.availableImages=this._availableImages;let o=this._serializedAllLayers(),s=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,c=Object.assign(Object.assign({},n),{layers:s,globalState:this._globalState});for(let t in this.tileManagers)n.layers&&!i[t]||a.push(L(this.tileManagers[t],this._layers,o,e,c,r,this.map.terrain?(e,t,n)=>this.map.terrain.getElevation(e,t,n):void 0));return this.placement&&a.push(function(e,t,n,r,i,a,o){let s={},c=a.queryRenderedSymbols(r),l=[];for(let e of Object.keys(c).map(Number))l.push(o[e]);l.sort(te);for(let n of l){let r=n.featureIndex.lookupSymbolFeatures(c[n.bucketInstanceId],t,n.bucketIndex,n.sourceLayerIndex,{filterSpec:i.filter,globalState:i.globalState},i.layers,i.availableImages,e);for(let e in r){s[e]||(s[e]=[]);let t=r[e];t.sort(((e,t)=>{let r=n.featureSortOrder;if(r){let n=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-n}return t.featureIndex-e.featureIndex}));for(let n of t)s[e].push(n)}}return function(e,t,n){for(let r in e)for(let i of e[r])ne(i,n[t[r].source]);return e}(s,e,n)}(this._layers,o,this.tileManagers,e,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,n){n!=null&&n.filter&&this._validate(t.F.filter,`querySourceFeatures.filter`,n.filter,null,n);let r=this.tileManagers[e];return r?function(e,t){let n=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],i={};for(let e of n){let n=e.tileID.canonical.key;i[n]||(i[n]=!0,e.querySourceFeatures(r,t))}return r}(r,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in e)if(!t.bQ(e[n],r[n])){i=!0;break}if(!i)return;let a={now:l(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(a)}getProjection(){return this.stylesheet?.projection}setProjection(e){this._checkLoaded();let t=e??{type:`mercator`};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){return this.stylesheet?.sky}setSky(e,n={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!e&&!r)return;if(e&&!r)i=!0;else if(!e&&r)i=!0;else for(let n in e)if(!t.bQ(e[n],r[n])){i=!0;break}if(!i)return;let a={now:l(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(a)}_setProjectionInternal(e){let n=function(e,n){let r={constrainOverride:n};if(Array.isArray(e)){let t=new yn({type:e});return{projection:t,transform:new Ln(r),cameraHelper:new zn(t)}}switch(e){case`mercator`:return{projection:new Kt,transform:new en(r),cameraHelper:new an};case`globe`:{let e=new yn({type:[`interpolate`,[`linear`],[`zoom`],11,`vertical-perspective`,12,`mercator`]});return{projection:e,transform:new Ln(r),cameraHelper:new zn(e)}}case`vertical-perspective`:return{projection:new _n,transform:new In(r),cameraHelper:new Rn};default:return t.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Kt,transform:new en(r),cameraHelper:new an}}}(e,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(let e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,n,r,i,a={}){return!1!==a?.validate&&Bn(this,e.call(t.F,t.e({key:n,style:this.serialize(),value:r,styleSpec:t.x},i)))}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),Ce().off(be,this._rtlPluginLoaded);for(let e in this._layers)this._layers[e].setEventedParent(null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,t,n,r,i=!1){let a=!1,o=!1,s={};for(let t of this._order){let n=this._layers[t];if(n.type!==`symbol`)continue;if(!s[n.source]){let e=this.tileManagers[n.source];s[n.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)))}let r=this.crossTileSymbolIndex.addLayer(n,s[n.source],e.center.lng);a||=r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),i||=this._layerOrderChanged||n===0,(i||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(l(),e.zoom))&&(this.pauseablePlacement=new Nt(e,this.map.terrain,this._order,i,t,n,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(l()),o=!0),a&&this.pauseablePlacement.placement.setStale()),o||a)for(let e of this._order){let t=this._layers[e];t.type===`symbol`&&this.placement.updateLayerOpacities(t,s[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(l())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let t=this.tileManagers[n.source];return t&&t.setDependencies(n.tileID.key,n.type,n.icons),e}))}getGlyphs(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.glyphManager.getGlyphs(n.stacks),t=this.tileManagers[n.source];return t&&t.setDependencies(n.tileID.key,n.type,[``]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(t.F.glyphs,`glyphs`,e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,n){return t._(this,void 0,void 0,(function*(){let e={};for(let[t,r]of Object.entries(n.dashes))e[t]=this.lineAtlas.getDash(r.dasharray,r.round);return e}))}addSprite(e,n,r={},i){this._checkLoaded();let a=[{id:e,url:n}],o=[...p(this.stylesheet.sprite),...a];this._validate(t.F.sprite,`sprite`,o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(e){this._checkLoaded();let n=p(this.stylesheet.sprite);if(n.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(let t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;n.splice(n.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`}))}else this.fire(new t.l(Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return p(this.stylesheet.sprite)}setSprite(e,n={},r){this._checkLoaded(),e&&this._validate(t.F.sprite,`sprite`,e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler(`GG`),this.dispatcher.unregisterMessageHandler(`GI`),this.dispatcher.unregisterMessageHandler(`GDA`),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Un=t.aS([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]);class Wn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,n,r,i,a,o,s,c){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(l=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==n||l||this.boundIndexBuffer!==i||this.boundVertexOffset!==a||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==c?this.freshBind(t,n,r,i,a,o,s,c):(e.bindVertexArray.set(this.vao),o&&o.bind(),i!=null&&i.dynamicDraw&&i.bind(),s&&s.bind(),c&&c.bind())}freshBind(e,t,n,r,i,a,o,s){let c=e.numAttributes,l=this.context,u=l.gl;this.vao&&this.destroy(),this.vao=l.createVertexArray(),l.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=r,this.boundVertexOffset=i,this.boundDynamicVertexBuffer=a,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(u,e);for(let t of n)t.enableAttributes(u,e);a&&a.enableAttributes(u,e),o&&o.enableAttributes(u,e),s&&s.enableAttributes(u,e),t.bind(),t.setVertexAttribPointers(u,e,i);for(let t of n)t.bind(),t.setVertexAttribPointers(u,e,i);a&&(a.bind(),a.setVertexAttribPointers(u,e,i)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(u,e,i)),s&&(s.bind(),s.setVertexAttribPointers(u,e,i)),l.currentNumAttributes=c}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}}let Gn=(e,n,r,i,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:r?r.properties.get(`fog-color`):t.bo.white,u_fog_ground_blend:r?r.properties.get(`fog-ground-blend`):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get(`horizon-color`):t.bo.white,u_horizon_fog_blend:r?r.properties.get(`horizon-fog-blend`):1,u_is_globe_mode:+!!a}),Kn={mainMatrix:`u_projection_matrix`,tileMercatorCoords:`u_projection_tile_mercator_coords`,clippingPlane:`u_projection_clipping_plane`,projectionTransition:`u_projection_transition`,fallbackMatrix:`u_projection_fallback_matrix`};function qn(e){let t=[];for(let n of e){if(n===null)continue;let e=n.split(` `);t.push(e.pop())}return t}class Jn{constructor(e,n,r,i,a,o,s,c,l=[]){let u=e.gl;this.program=u.createProgram();let d=qn(n.staticAttributes),f=r?r.getBinderAttributes():[],p=d.concat(f),m=Bt.prelude.staticUniforms?qn(Bt.prelude.staticUniforms):[],h=s.staticUniforms?qn(s.staticUniforms):[],g=n.staticUniforms?qn(n.staticUniforms):[],_=r?r.getBinderUniforms():[],v=m.concat(h).concat(g).concat(_),y=[];for(let e of v)y.includes(e)||y.push(e);let b=r?r.defines():[];fn(u)&&b.unshift(`#version 300 es`),a&&b.push(`#define OVERDRAW_INSPECTOR;`),o&&b.push(`#define TERRAIN3D;`),c&&b.push(c),l&&b.push(...l);let x=b.concat(Bt.prelude.fragmentSource,s.fragmentSource,n.fragmentSource).join(`
|
||
`),S=b.concat(Bt.prelude.vertexSource,s.vertexSource,n.vertexSource).join(`
|
||
`);fn(u)||(x=function(e){return e.replace(/\bin\s/g,`varying `).replace(`out highp vec4 fragColor;`,``).replace(/fragColor/g,`gl_FragColor`).replace(/texture\(/g,`texture2D(`)}(x),S=function(e){return e.replace(/\bin\s/g,`attribute `).replace(/\bout\s/g,`varying `).replace(/texture\(/g,`texture2D(`)}(S));let C=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(C,x),u.compileShader(C),!u.getShaderParameter(C,u.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${u.getShaderInfoLog(C)}`);u.attachShader(this.program,C);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(w,S),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`);u.attachShader(this.program,w),this.attributes={};let T={};this.numAttributes=p.length;for(let e=0;e<this.numAttributes;e++)p[e]&&(u.bindAttribLocation(this.program,e,p[e]),this.attributes[p[e]]=e);if(u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS))throw Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`);u.deleteShader(w),u.deleteShader(C);for(let e of y)if(e&&!T[e]){let t=u.getUniformLocation(this.program,e);t&&(T[e]=t)}this.fixedUniforms=i(e,T),this.terrainUniforms=((e,n)=>({u_depth:new t.b_(e,n.u_depth),u_terrain:new t.b_(e,n.u_terrain),u_terrain_dim:new t.bp(e,n.u_terrain_dim),u_terrain_matrix:new t.c0(e,n.u_terrain_matrix),u_terrain_unpack:new t.c1(e,n.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,n.u_terrain_exaggeration)}))(e,T),this.projectionUniforms=((e,n)=>({u_projection_matrix:new t.c0(e,n.u_projection_matrix),u_projection_tile_mercator_coords:new t.c1(e,n.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c1(e,n.u_projection_clipping_plane),u_projection_transition:new t.bp(e,n.u_projection_transition),u_projection_fallback_matrix:new t.c0(e,n.u_projection_fallback_matrix)}))(e,T),this.binderUniforms=r?r.getUniforms(e,T):[]}draw(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){var y;let b=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(a),s){e.activeTexture.set(b.TEXTURE2),b.bindTexture(b.TEXTURE_2D,s.depthTexture),e.activeTexture.set(b.TEXTURE3),b.bindTexture(b.TEXTURE_2D,s.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(s[e])}if(c)for(let e in c)this.projectionUniforms[Kn[e]].set(c[e]);if(o)for(let e in this.fixedUniforms)this.fixedUniforms[e].set(o[e]);h&&h.setUniforms(e,this.binderUniforms,p,{zoom:m});let x=0;switch(t){case b.LINES:x=2;break;case b.TRIANGLES:x=3;break;case b.LINE_STRIP:x=1}for(let n of f.get())n.vaos||={},(y=n.vaos)[l]||(y[l]=new Wn),n.vaos[l].bind(e,this,u,h?h.getPaintVertexBuffers():[],d,n.vertexOffset,g,_,v),b.drawElements(t,n.primitiveLength*x,b.UNSIGNED_SHORT,n.primitiveOffset*x*2)}}function Yn(e,n,r){let i=1/t.aK(r,1,n.transform.tileZoom),a=2**r.tileID.overscaledZ,o=r.tileSize*2**n.transform.tileZoom/a,s=o*(r.tileID.canonical.x+r.tileID.wrap*a),c=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,c>>16],u_pixel_coord_lower:[65535&s,65535&c]}}let Xn=(e,n,r,i)=>{let a=e.style.light,o=a.properties.get(`position`),s=[o.x,o.y,o.z],c=t.c4();a.properties.get(`anchor`)===`viewport`&&t.c5(c,e.transform.bearingInRadians),t.c6(s,s,c);let l=e.transform.transformLightDirection(s),u=a.properties.get(`color`);return{u_lightpos:s,u_lightpos_globe:l,u_lightintensity:a.properties.get(`intensity`),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+n,u_opacity:r,u_fill_translate:i}},Zn=(e,n,r,i,a,o,s)=>t.e(Xn(e,n,r,i),Yn(o,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),Qn=(e,n,r,i)=>t.e(Yn(n,e,r),{u_fill_translate:i}),$n=(e,t)=>({u_world:e,u_fill_translate:t}),er=(e,n,r,i,a)=>t.e(Qn(e,n,r,a),{u_world:i}),tr=(e,n,r,i,a)=>{let o=e.transform,s,c,l=0;if(r.paint.get(`circle-pitch-alignment`)===`map`){let e=t.aK(n,1,o.zoom);s=!0,c=[e,e],l=e/(t.a6*2**n.tileID.overscaledZ)*2*Math.PI*a}else s=!1,c=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(r.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+s,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:c,u_globe_extrude_scale:l,u_translate:i}},nr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),rr=e=>({u_viewport_size:[e.width,e.height]}),ir=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),ar=(e,n,r,i)=>{let a=t.aK(e,1,n)/(t.a6*2**e.tileID.overscaledZ)*2*Math.PI*i;return{u_extrude_scale:t.aK(e,1,n),u_intensity:r,u_globe_extrude_scale:a}},or=(e,n,r,i)=>{let a=t.O();t.c7(a,0,e.width,e.height,0,0,1);let o=e.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:i,u_opacity:n.paint.get(`heatmap-opacity`)}},sr=(e,t,n)=>{let r=n.paint.get(`hillshade-accent-color`),i;switch(n.paint.get(`hillshade-method`)){case`basic`:i=4;break;case`combined`:i=1;break;case`igor`:i=2;break;case`multidirectional`:i=3;break;default:i=0}let a=n.getIlluminationProperties();for(let t=0;t<a.directionRadians.length;t++)n.paint.get(`hillshade-illumination-anchor`)===`viewport`&&(a.directionRadians[t]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:lr(0,t.tileID),u_exaggeration:n.paint.get(`hillshade-exaggeration`),u_altitudes:a.altitudeRadians,u_azimuths:a.directionRadians,u_accent:r,u_method:i,u_highlights:a.highlightColor,u_shadows:a.shadowColor}},cr=(e,n)=>{let r=n.stride,i=t.O();return t.c7(i,0,t.a6,-t.a6,0,0,1),t.Q(i,i,[0,-t.a6,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:n.getUnpackVector()}};function lr(e,n){let r=2**n.canonical.z,i=n.canonical.y;return[new t.a7(0,i/r).toLngLat().lat,new t.a7(0,(i+1)/r).toLngLat().lat]}let ur=(e,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:e.paint.get(`color-relief-opacity`)}),dr=(e,n,r,i)=>{let a=e.transform;return{u_translation:_r(e,n,r),u_ratio:i/t.aK(n,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},fr=(e,n,r,i,a)=>t.e(dr(e,n,r,i),{u_image:0,u_image_height:a}),pr=(e,n,r,i,a)=>{let o=e.transform,s=gr(n,o);return{u_translation:_r(e,n,r),u_texsize:n.imageAtlasTexture.size,u_ratio:i/t.aK(n,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},mr=(e,n,r,i,a)=>{let o=gr(n,e.transform);return t.e(dr(e,n,r,i),{u_tileratio:o,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},hr=(e,n,r,i,a,o)=>{let s=gr(n,e.transform);return t.e(dr(e,n,r,i),{u_image:0,u_image_height:o,u_tileratio:s,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function gr(e,n){return 1/t.aK(e,1,n.tileZoom)}function _r(e,n,r){return t.aL(e.transform,n,r.paint.get(`line-translate`),r.paint.get(`line-translate-anchor`))}let vr=(e,t,n,r,i)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,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:(o=r.paint.get(`raster-saturation`),o>0?1-1/(1.001-o):-o),u_contrast_factor:(a=r.paint.get(`raster-contrast`),a>0?1/(1-a):1+a),u_spin_weights:yr(r.paint.get(`raster-hue-rotate`)),u_coords_top:[i[0].x,i[0].y,i[1].x,i[1].y],u_coords_bottom:[i[3].x,i[3].y,i[2].x,i[2].y]};var a,o};function yr(e){e*=Math.PI/180;let t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}let br=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=o.transform;return{u_is_size_zoom_constant:+(e===`constant`||e===`source`),u_is_size_feature_constant:+(e===`constant`||e===`camera`),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:p.width/p.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:s,u_coord_matrix:c,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:i,u_is_variable_anchor:a,u_texsize:d,u_texture:0,u_translation:l,u_pitched_scale:f}},xr=(e,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let h=s.transform;return t.e(br(e,n,r,i,a,o,s,c,l,u,d,f,m),{u_gamma_scale:i?Math.cos(h.pitch*Math.PI/180)*h.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+!!p,u_is_plain:1})},Sr=(e,n,r,i,a,o,s,c,l,u,d,f,p)=>t.e(xr(e,n,r,i,a,o,s,c,l,u,!0,d,!0,p),{u_texsize_icon:f,u_texture_icon:1}),Cr=(e,t)=>({u_opacity:e,u_color:t}),wr=(e,n,r,i,a)=>t.e(function(e,n,r,i){let a=r.imageManager.getPattern(e.from.toString()),o=r.imageManager.getPattern(e.to.toString()),{width:s,height:c}=r.imageManager.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,d=u*(i.tileID.canonical.x+i.tileID.wrap*l),f=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,c],u_mix:n.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:n.fromScale,u_scale_b:n.toScale,u_tile_units_to_pixels:1/t.aK(i,1,r.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}(r,a,n,i),{u_opacity:e}),Tr=(e,t)=>{},Er={fillExtrusion:(e,n)=>({u_lightpos:new t.c2(e,n.u_lightpos),u_lightpos_globe:new t.c2(e,n.u_lightpos_globe),u_lightintensity:new t.bp(e,n.u_lightintensity),u_lightcolor:new t.c2(e,n.u_lightcolor),u_vertical_gradient:new t.bp(e,n.u_vertical_gradient),u_opacity:new t.bp(e,n.u_opacity),u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillExtrusionPattern:(e,n)=>({u_lightpos:new t.c2(e,n.u_lightpos),u_lightpos_globe:new t.c2(e,n.u_lightpos_globe),u_lightintensity:new t.bp(e,n.u_lightintensity),u_lightcolor:new t.c2(e,n.u_lightcolor),u_vertical_gradient:new t.bp(e,n.u_vertical_gradient),u_height_factor:new t.bp(e,n.u_height_factor),u_opacity:new t.bp(e,n.u_opacity),u_fill_translate:new t.c3(e,n.u_fill_translate),u_image:new t.b_(e,n.u_image),u_texsize:new t.c3(e,n.u_texsize),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade)}),fill:(e,n)=>({u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillPattern:(e,n)=>({u_image:new t.b_(e,n.u_image),u_texsize:new t.c3(e,n.u_texsize),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade),u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillOutline:(e,n)=>({u_world:new t.c3(e,n.u_world),u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillOutlinePattern:(e,n)=>({u_world:new t.c3(e,n.u_world),u_image:new t.b_(e,n.u_image),u_texsize:new t.c3(e,n.u_texsize),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade),u_fill_translate:new t.c3(e,n.u_fill_translate)}),circle:(e,n)=>({u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_scale_with_map:new t.b_(e,n.u_scale_with_map),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_extrude_scale:new t.c3(e,n.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,n.u_globe_extrude_scale),u_translate:new t.c3(e,n.u_translate)}),collisionBox:(e,n)=>({u_pixel_extrude_scale:new t.c3(e,n.u_pixel_extrude_scale)}),collisionCircle:(e,n)=>({u_viewport_size:new t.c3(e,n.u_viewport_size)}),debug:(e,n)=>({u_color:new t.b$(e,n.u_color),u_overlay:new t.b_(e,n.u_overlay),u_overlay_scale:new t.bp(e,n.u_overlay_scale)}),depth:Tr,clippingMask:Tr,heatmap:(e,n)=>({u_extrude_scale:new t.bp(e,n.u_extrude_scale),u_intensity:new t.bp(e,n.u_intensity),u_globe_extrude_scale:new t.bp(e,n.u_globe_extrude_scale)}),heatmapTexture:(e,n)=>({u_matrix:new t.c0(e,n.u_matrix),u_world:new t.c3(e,n.u_world),u_image:new t.b_(e,n.u_image),u_color_ramp:new t.b_(e,n.u_color_ramp),u_opacity:new t.bp(e,n.u_opacity)}),hillshade:(e,n)=>({u_image:new t.b_(e,n.u_image),u_latrange:new t.c3(e,n.u_latrange),u_exaggeration:new t.bp(e,n.u_exaggeration),u_altitudes:new t.c9(e,n.u_altitudes),u_azimuths:new t.c9(e,n.u_azimuths),u_accent:new t.b$(e,n.u_accent),u_method:new t.b_(e,n.u_method),u_shadows:new t.c8(e,n.u_shadows),u_highlights:new t.c8(e,n.u_highlights)}),hillshadePrepare:(e,n)=>({u_matrix:new t.c0(e,n.u_matrix),u_image:new t.b_(e,n.u_image),u_dimension:new t.c3(e,n.u_dimension),u_zoom:new t.bp(e,n.u_zoom),u_unpack:new t.c1(e,n.u_unpack)}),colorRelief:(e,n)=>({u_image:new t.b_(e,n.u_image),u_unpack:new t.c1(e,n.u_unpack),u_dimension:new t.c3(e,n.u_dimension),u_elevation_stops:new t.b_(e,n.u_elevation_stops),u_color_stops:new t.b_(e,n.u_color_stops),u_color_ramp_size:new t.b_(e,n.u_color_ramp_size),u_opacity:new t.bp(e,n.u_opacity)}),line:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels)}),lineGradient:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_image:new t.b_(e,n.u_image),u_image_height:new t.bp(e,n.u_image_height)}),linePattern:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_texsize:new t.c3(e,n.u_texsize),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_image:new t.b_(e,n.u_image),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade)}),lineSDF:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_image:new t.b_(e,n.u_image),u_mix:new t.bp(e,n.u_mix),u_tileratio:new t.bp(e,n.u_tileratio),u_crossfade_from:new t.bp(e,n.u_crossfade_from),u_crossfade_to:new t.bp(e,n.u_crossfade_to),u_lineatlas_width:new t.bp(e,n.u_lineatlas_width),u_lineatlas_height:new t.bp(e,n.u_lineatlas_height)}),lineGradientSDF:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_image:new t.b_(e,n.u_image),u_image_height:new t.bp(e,n.u_image_height),u_tileratio:new t.bp(e,n.u_tileratio),u_crossfade_from:new t.bp(e,n.u_crossfade_from),u_crossfade_to:new t.bp(e,n.u_crossfade_to),u_image_dash:new t.b_(e,n.u_image_dash),u_mix:new t.bp(e,n.u_mix),u_lineatlas_width:new t.bp(e,n.u_lineatlas_width),u_lineatlas_height:new t.bp(e,n.u_lineatlas_height)}),raster:(e,n)=>({u_tl_parent:new t.c3(e,n.u_tl_parent),u_scale_parent:new t.bp(e,n.u_scale_parent),u_buffer_scale:new t.bp(e,n.u_buffer_scale),u_fade_t:new t.bp(e,n.u_fade_t),u_opacity:new t.bp(e,n.u_opacity),u_image0:new t.b_(e,n.u_image0),u_image1:new t.b_(e,n.u_image1),u_brightness_low:new t.bp(e,n.u_brightness_low),u_brightness_high:new t.bp(e,n.u_brightness_high),u_saturation_factor:new t.bp(e,n.u_saturation_factor),u_contrast_factor:new t.bp(e,n.u_contrast_factor),u_spin_weights:new t.c2(e,n.u_spin_weights),u_coords_top:new t.c1(e,n.u_coords_top),u_coords_bottom:new t.c1(e,n.u_coords_bottom)}),symbolIcon:(e,n)=>({u_is_size_zoom_constant:new t.b_(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,n.u_is_size_feature_constant),u_size_t:new t.bp(e,n.u_size_t),u_size:new t.bp(e,n.u_size),u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_pitch:new t.bp(e,n.u_pitch),u_rotate_symbol:new t.b_(e,n.u_rotate_symbol),u_aspect_ratio:new t.bp(e,n.u_aspect_ratio),u_fade_change:new t.bp(e,n.u_fade_change),u_label_plane_matrix:new t.c0(e,n.u_label_plane_matrix),u_coord_matrix:new t.c0(e,n.u_coord_matrix),u_is_text:new t.b_(e,n.u_is_text),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_is_along_line:new t.b_(e,n.u_is_along_line),u_is_variable_anchor:new t.b_(e,n.u_is_variable_anchor),u_texsize:new t.c3(e,n.u_texsize),u_texture:new t.b_(e,n.u_texture),u_translation:new t.c3(e,n.u_translation),u_pitched_scale:new t.bp(e,n.u_pitched_scale)}),symbolSDF:(e,n)=>({u_is_size_zoom_constant:new t.b_(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,n.u_is_size_feature_constant),u_size_t:new t.bp(e,n.u_size_t),u_size:new t.bp(e,n.u_size),u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_pitch:new t.bp(e,n.u_pitch),u_rotate_symbol:new t.b_(e,n.u_rotate_symbol),u_aspect_ratio:new t.bp(e,n.u_aspect_ratio),u_fade_change:new t.bp(e,n.u_fade_change),u_label_plane_matrix:new t.c0(e,n.u_label_plane_matrix),u_coord_matrix:new t.c0(e,n.u_coord_matrix),u_is_text:new t.b_(e,n.u_is_text),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_is_along_line:new t.b_(e,n.u_is_along_line),u_is_variable_anchor:new t.b_(e,n.u_is_variable_anchor),u_texsize:new t.c3(e,n.u_texsize),u_texture:new t.b_(e,n.u_texture),u_gamma_scale:new t.bp(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_is_halo:new t.b_(e,n.u_is_halo),u_is_plain:new t.b_(e,n.u_is_plain),u_translation:new t.c3(e,n.u_translation),u_pitched_scale:new t.bp(e,n.u_pitched_scale)}),symbolTextAndIcon:(e,n)=>({u_is_size_zoom_constant:new t.b_(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,n.u_is_size_feature_constant),u_size_t:new t.bp(e,n.u_size_t),u_size:new t.bp(e,n.u_size),u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_pitch:new t.bp(e,n.u_pitch),u_rotate_symbol:new t.b_(e,n.u_rotate_symbol),u_aspect_ratio:new t.bp(e,n.u_aspect_ratio),u_fade_change:new t.bp(e,n.u_fade_change),u_label_plane_matrix:new t.c0(e,n.u_label_plane_matrix),u_coord_matrix:new t.c0(e,n.u_coord_matrix),u_is_text:new t.b_(e,n.u_is_text),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_is_along_line:new t.b_(e,n.u_is_along_line),u_is_variable_anchor:new t.b_(e,n.u_is_variable_anchor),u_texsize:new t.c3(e,n.u_texsize),u_texsize_icon:new t.c3(e,n.u_texsize_icon),u_texture:new t.b_(e,n.u_texture),u_texture_icon:new t.b_(e,n.u_texture_icon),u_gamma_scale:new t.bp(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_is_halo:new t.b_(e,n.u_is_halo),u_translation:new t.c3(e,n.u_translation),u_pitched_scale:new t.bp(e,n.u_pitched_scale)}),background:(e,n)=>({u_opacity:new t.bp(e,n.u_opacity),u_color:new t.b$(e,n.u_color)}),backgroundPattern:(e,n)=>({u_opacity:new t.bp(e,n.u_opacity),u_image:new t.b_(e,n.u_image),u_pattern_tl_a:new t.c3(e,n.u_pattern_tl_a),u_pattern_br_a:new t.c3(e,n.u_pattern_br_a),u_pattern_tl_b:new t.c3(e,n.u_pattern_tl_b),u_pattern_br_b:new t.c3(e,n.u_pattern_br_b),u_texsize:new t.c3(e,n.u_texsize),u_mix:new t.bp(e,n.u_mix),u_pattern_size_a:new t.c3(e,n.u_pattern_size_a),u_pattern_size_b:new t.c3(e,n.u_pattern_size_b),u_scale_a:new t.bp(e,n.u_scale_a),u_scale_b:new t.bp(e,n.u_scale_b),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,n.u_tile_units_to_pixels)}),terrain:(e,n)=>({u_texture:new t.b_(e,n.u_texture),u_ele_delta:new t.bp(e,n.u_ele_delta),u_fog_matrix:new t.c0(e,n.u_fog_matrix),u_fog_color:new t.b$(e,n.u_fog_color),u_fog_ground_blend:new t.bp(e,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,n.u_fog_ground_blend_opacity),u_horizon_color:new t.b$(e,n.u_horizon_color),u_horizon_fog_blend:new t.bp(e,n.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,n.u_is_globe_mode)}),terrainDepth:(e,n)=>({u_ele_delta:new t.bp(e,n.u_ele_delta)}),terrainCoords:(e,n)=>({u_texture:new t.b_(e,n.u_texture),u_terrain_coords_id:new t.bp(e,n.u_terrain_coords_id),u_ele_delta:new t.bp(e,n.u_ele_delta)}),projectionErrorMeasurement:(e,n)=>({u_input:new t.bp(e,n.u_input),u_output_expected:new t.bp(e,n.u_output_expected)}),atmosphere:(e,n)=>({u_sun_pos:new t.c2(e,n.u_sun_pos),u_atmosphere_blend:new t.bp(e,n.u_atmosphere_blend),u_globe_position:new t.c2(e,n.u_globe_position),u_globe_radius:new t.bp(e,n.u_globe_radius),u_inv_proj_matrix:new t.c0(e,n.u_inv_proj_matrix)}),sky:(e,n)=>({u_sky_color:new t.b$(e,n.u_sky_color),u_horizon_color:new t.b$(e,n.u_horizon_color),u_horizon:new t.c3(e,n.u_horizon),u_horizon_normal:new t.c3(e,n.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,n.u_sky_horizon_blend),u_sky_blend:new t.bp(e,n.u_sky_blend)})};class Dr{constructor(e,t,n){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error(`Attempted to update data while not in dynamic mode.`);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)}}let Or={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`};class kr{constructor(e,t,n,r){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let i=e.gl;this.buffer=i.createBuffer(),e.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let n of this.attributes){let r=t.attributes[n.name];r!==void 0&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,n){for(let r of this.attributes){let i=t.attributes[r.name];i!==void 0&&e.vertexAttribPointer(i,r.components,e[Or[r.type]],!1,this.itemSize,r.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ar{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 jr extends Ar{getDefault(){return t.bo.transparent}set(e){let 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 Mr extends Ar{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Nr extends Ar{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class Pr extends Ar{getDefault(){return[!0,!0,!0,!0]}set(e){let 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 Fr extends Ar{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Ir extends Ar{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Lr extends Ar{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let 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 Rr extends Ar{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let 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 zr extends Ar{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class Br extends Ar{getDefault(){return[0,1]}set(e){let 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 Vr extends Ar{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class Hr extends Ar{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Ur extends Ar{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class Wr extends Ar{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let 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 Gr extends Ar{getDefault(){return t.bo.transparent}set(e){let 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 Kr extends Ar{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class qr extends Ar{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Jr extends Ar{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Yr extends Ar{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Xr extends Ar{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Zr extends Ar{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Qr extends Ar{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let 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 $r extends Ar{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class ei extends Ar{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class ti extends Ar{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class ni extends Ar{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ri extends Ar{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ii extends Ar{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;let n=this.gl;fn(n)?n.bindVertexArray(e):(t=n.getExtension(`OES_vertex_array_object`))==null||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class ai extends Ar{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class oi extends Ar{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class si extends Ar{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class ci extends Ar{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class li extends ci{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class ui extends ci{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class di extends ci{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}let fi=`Framebuffer is not complete`;class pi{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;let a=e.gl,o=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new li(e,o),r)this.depthAttachment=i?new di(e,o):new ui(e,o);else if(i)throw Error(`Stencil cannot be set without depth`);if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error(fi)}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class mi{constructor(e){if(this.gl=e,this.clearColor=new jr(this),this.clearDepth=new Mr(this),this.clearStencil=new Nr(this),this.colorMask=new Pr(this),this.depthMask=new Fr(this),this.stencilMask=new Ir(this),this.stencilFunc=new Lr(this),this.stencilOp=new Rr(this),this.stencilTest=new zr(this),this.depthRange=new Br(this),this.depthTest=new Vr(this),this.depthFunc=new Hr(this),this.blend=new Ur(this),this.blendFunc=new Wr(this),this.blendColor=new Gr(this),this.blendEquation=new Kr(this),this.cullFace=new qr(this),this.cullFaceSide=new Jr(this),this.frontFace=new Yr(this),this.program=new Xr(this),this.activeTexture=new Zr(this),this.viewport=new Qr(this),this.bindFramebuffer=new $r(this),this.bindRenderbuffer=new ei(this),this.bindTexture=new ti(this),this.bindVertexBuffer=new ni(this),this.bindElementBuffer=new ri(this),this.bindVertexArray=new ii(this),this.pixelStoreUnpack=new ai(this),this.pixelStoreUnpackPremultiplyAlpha=new oi(this),this.pixelStoreUnpackFlipY=new si(this),this.extTextureFilterAnisotropic=e.getExtension(`EXT_texture_filter_anisotropic`),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),fn(e)){this.HALF_FLOAT=e.HALF_FLOAT;let t=e.getExtension(`EXT_color_buffer_half_float`);this.RGBA16F=e.RGBA16F??t?.RGBA16F_EXT,this.RGB16F=e.RGB16F??t?.RGB16F_EXT,e.getExtension(`EXT_color_buffer_float`)}else{e.getExtension(`EXT_color_buffer_half_float`),e.getExtension(`OES_texture_half_float_linear`);let t=e.getExtension(`OES_texture_half_float`);this.HALF_FLOAT=t?.HALF_FLOAT_OES}}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.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new Dr(this,e,t)}createVertexBuffer(e,t,n){return new kr(this,e,t,n)}createRenderbuffer(e,t,n){let r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n,r){return new pi(this,e,t,n,r)}clear({color:e,depth:t,stencil:n}){let r=this.gl,i=0;e&&(i|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(i|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),n!==void 0&&(i|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),r.clear(i)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t.bQ(e.blendFunction,on.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){return fn(this.gl)?this.gl.createVertexArray():this.gl.getExtension(`OES_vertex_array_object`)?.createVertexArrayOES()}deleteVertexArray(e){var t;fn(this.gl)?this.gl.deleteVertexArray(e):(t=this.gl.getExtension(`OES_vertex_array_object`))==null||t.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let hi;function gi(e,n,r,i,a){let o=e.context,s=e.transform,c=o.gl,l=e.useProgram(`collisionBox`),u=[],d=0,f=0;for(let t of i){let i=n.getTile(t).getBucket(r);if(!i)continue;let p=a?i.textCollisionBox:i.iconCollisionBox,m=i.collisionCircleArray;m.length>0&&(u.push({circleArray:m,circleOffset:f,coord:t}),d+=m.length/4,f=d),p&&l.draw(o,c.LINES,ln.disabled,dn.disabled,e.colorModeForRenderPass(),cn.disabled,nr(e.transform),e.style.map.terrain?.getTerrainData(t),s.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,null,e.transform.zoom,null,null,p.collisionVertexBuffer)}if(!a||!u.length)return;let p=e.useProgram(`collisionCircle`),m=new t.ca;m.resize(4*d),m._trim();let h=0;for(let e of u)for(let t=0;t<e.circleArray.length/4;t++){let n=4*t,r=e.circleArray[n+0],i=e.circleArray[n+1],a=e.circleArray[n+2],o=e.circleArray[n+3];m.emplace(h++,r,i,a,o,0),m.emplace(h++,r,i,a,o,1),m.emplace(h++,r,i,a,o,2),m.emplace(h++,r,i,a,o,3)}(!hi||hi.length<2*d)&&(hi=function(e){let n=2*e,r=new t.cc;r.resize(n),r._trim();for(let e=0;e<n;e++){let t=6*e;r.uint16[t+0]=4*e+0,r.uint16[t+1]=4*e+1,r.uint16[t+2]=4*e+2,r.uint16[t+3]=4*e+2,r.uint16[t+4]=4*e+3,r.uint16[t+5]=4*e+0}return r}(d));let g=o.createIndexBuffer(hi,!0),_=o.createVertexBuffer(m,t.cb.members,!0);for(let n of u){let i=rr(e.transform);p.draw(o,c.TRIANGLES,ln.disabled,dn.disabled,e.colorModeForRenderPass(),cn.disabled,i,e.style.map.terrain?.getTerrainData(n.coord),null,r.id,_,g,t.aV.simpleSegment(0,2*n.circleOffset,n.circleArray.length,n.circleArray.length/2),null,e.transform.zoom,null,null,null)}_.destroy(),g.destroy()}let _i=t.ap(new Float32Array(16));function vi(e,n,r,i,a,o){let{horizontalAlign:s,verticalAlign:c}=t.aP(e);return new t.P((-(s-.5)*n/a+i[0])*o,(-(c-.5)*r/a+i[1])*o)}function yi(e,n,r,i,a,o){let s=n.tileAnchorPoint.add(new t.P(n.translation[0],n.translation[1]));if(n.pitchWithMap){let e=i.mult(o);r||(e=e.rotate(-a));let t=s.add(e);return et(t.x,t.y,n.pitchedLabelPlaneMatrix,n.getElevation).point}if(r){let t=ct(n.tileAnchorPoint.x+1,n.tileAnchorPoint.y,n).point.sub(e),r=Math.atan(t.y/t.x)+(t.x<0?Math.PI:0);return e.add(i.rotate(r))}return e.add(i)}function bi(e,n,r,i,a,o,s,c,l,u,d,f){let p=e.text.placedSymbolArray,m=e.text.dynamicLayoutVertexArray,h=e.icon.dynamicLayoutVertexArray,g={};m.clear();for(let h=0;h<p.length;h++){let _=p.get(h),v=_.hidden||!_.crossTileID||e.allowVerticalPlacement&&!_.placedOrientation?null:i[_.crossTileID];if(v){let i=new t.P(_.anchorX,_.anchorY),p={getElevation:f,width:a.width,height:a.height,pitchedLabelPlaneMatrix:o,pitchWithMap:r,transform:a,tileAnchorPoint:i,translation:u,unwrappedTileID:d},h=r?ut(i.x,i.y,p):ct(i.x,i.y,p),y=tt(a.cameraToCenterDistance,h.signedDistanceFromCamera),b=t.ay(e.textSizeData,c,_)*y/t.aJ;r&&(b*=e.tilePixelRatio/s);let{width:x,height:S,anchor:C,textOffset:w,textBoxScale:T}=v,E=vi(C,x,S,w,T,b),D=a.getPitchedTextCorrection(i.x+u[0],i.y+u[1],d),O=yi(h.point,p,n,E,-a.bearingInRadians,D),k=e.allowVerticalPlacement&&_.placedOrientation===t.ax.vertical?Math.PI/2:0;for(let e=0;e<_.numGlyphs;e++)t.aD(m,O,k);l&&_.associatedIconIndex>=0&&(g[_.associatedIconIndex]={shiftedAnchor:O,angle:k})}else ht(_.numGlyphs,m)}if(l){h.clear();let n=e.icon.placedSymbolArray;for(let e=0;e<n.length;e++){let r=n.get(e);if(r.hidden)ht(r.numGlyphs,h);else{let n=g[e];if(n)for(let e=0;e<r.numGlyphs;e++)t.aD(h,n.shiftedAnchor,n.angle);else ht(r.numGlyphs,h)}}e.icon.dynamicLayoutVertexBuffer.updateData(h)}e.text.dynamicLayoutVertexBuffer.updateData(m)}function xi(e,t,n){return n.iconsInText&&t?`symbolTextAndIcon`:e?`symbolSDF`:`symbolIcon`}function Si(e,n,r,i,a,o,s,c,l,u,d,f,p){let m=e.context,h=m.gl,g=e.transform,_=c===`map`,v=l===`map`,y=c!==`viewport`&&r.layout.get(`symbol-placement`)!==`point`,b=_&&!v&&!y,x=!r.layout.get(`symbol-sort-key`).isConstant(),S=!1,C=e.getDepthModeForSublayer(0,ln.ReadOnly),w=r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),T=[],E=g.getCircleRadiusCorrection();for(let c of i){let i=n.getTile(c),l=i.getBucket(r);if(!l)continue;let d=a?l.text:l.icon;if(!d?.segments.get().length||!d.hasVisibleVertices)continue;let f=d.programConfigurations.get(r.id),m=a||l.sdfIcons,C=a?l.textSizeData:l.iconSizeData,D=v||g.pitch!==0,O=e.useProgram(xi(m,a,l),f),k=t.aw(C,g.zoom),A=e.style.map.terrain?.getTerrainData(c),j,M,N,P,F=[0,0],ee=null;if(a)M=i.glyphAtlasTexture,N=h.LINEAR,j=i.glyphAtlasTexture.size,l.iconsInText&&(F=i.imageAtlasTexture.size,ee=i.imageAtlasTexture,P=D||e.options.rotating||e.options.zooming||C.kind===`composite`||C.kind===`camera`?h.LINEAR:h.NEAREST);else{let t=r.layout.get(`icon-size`).constantOr(0)!==1||l.iconsNeedLinear;M=i.imageAtlasTexture,N=m||e.options.rotating||e.options.zooming||t||D?h.LINEAR:h.NEAREST,j=i.imageAtlasTexture.size}let I=t.aK(i,1,e.transform.zoom),L=H(_,e.transform,I),te=Qe(v,_,e.transform,I),ne=t.aL(g,i,o,s),R=g.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),re=w&&l.hasTextData(),ie=r.layout.get(`icon-text-fit`)!==`none`&&re&&l.hasIconData();if(y){let n=t.O();Xe(n,L);let i=e.style.map.terrain?(t,n)=>e.style.map.terrain.getElevation(c,t,n):null;U(l,e,a,L,n,v,u,r.layout.get(`text-rotation-alignment`)===`map`,c.toUnwrapped(),g.width,g.height,ne,i)}let ae=a&&w||ie,oe=y||ae?_i:v?L:e.transform.clipSpaceToPixelsMatrix,se=m&&r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,ce;ce=m?l.iconsInText?Sr(C.kind,k,b,v,y,ae,e,oe,te,ne,j,F,E):xr(C.kind,k,b,v,y,ae,e,oe,te,ne,a,j,se,E):br(C.kind,k,b,v,y,ae,e,oe,te,ne,a,j,E);let le={program:O,buffers:d,uniformValues:ce,projectionData:R,atlasTexture:M,atlasTextureIcon:ee,atlasInterpolation:N,atlasInterpolationIcon:P,isSDF:m,hasHalo:se};if(x&&l.canOverlap){S=!0;let e=d.segments.get();for(let n of e)T.push({segments:new t.aV([n]),sortKey:n.sortKey,state:le,terrainData:A})}else T.push({segments:d.segments,sortKey:0,state:le,terrainData:A})}S&&T.sort(((e,t)=>e.sortKey-t.sortKey));let D=r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(null)??1/0,O=r.layout.get(`text-letter-spacing`).constantOr(0)*t.aJ<0||D>1;for(let t of T){let n=t.state;m.activeTexture.set(h.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,h.CLAMP_TO_EDGE),n.atlasTextureIcon&&(m.activeTexture.set(h.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,h.CLAMP_TO_EDGE));let i=n.isSDF&&n.hasHalo;if(i){let i=n.uniformValues;i.u_is_halo=1,O&&(i.u_is_plain=0,Ci(n.buffers,t.segments,r,e,n.program,C,d,f,i,n.projectionData,t.terrainData),i.u_is_halo=0,i.u_is_plain=1)}Ci(n.buffers,t.segments,r,e,n.program,C,d,f,n.uniformValues,n.projectionData,t.terrainData),i&&!O&&(n.uniformValues.u_is_halo=0)}}function Ci(e,t,n,r,i,a,o,s,c,l,u){let d=r.context;i.draw(d,d.gl.TRIANGLES,a,o,s,cn.backCCW,c,u,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function wi(e,n,r,i,a){let o=e.context,s=o.gl,c=dn.disabled,l=new on([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]),u=n.getBucket(r);if(!u)return;let d=i.key,f=r.heatmapFbos.get(d);f||(f=Ei(o,n.tileSize,n.tileSize),r.heatmapFbos.set(d,f)),o.bindFramebuffer.set(f.framebuffer),o.viewport.set([0,0,n.tileSize,n.tileSize]),o.clear({color:t.bo.transparent});let p=u.programConfigurations.get(r.id),m=e.useProgram(`heatmap`,p,!a),h=e.transform.getProjectionData({overscaledTileID:n.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(i);m.draw(o,s.TRIANGLES,ln.disabled,c,l,cn.disabled,ar(n,e.transform.zoom,r.paint.get(`heatmap-intensity`),1),g,h,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,p)}function Ti(e,t,n,r,i){let a=e.context,o=a.gl,s=e.transform;a.setColorMode(e.colorModeForRenderPass());let c=Di(a,t),l=n.key,u=t.heatmapFbos.get(l);if(!u)return;a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE);let d=s.getProjectionData({overscaledTileID:n,applyTerrainMatrix:i,applyGlobeMatrix:!r});e.useProgram(`heatmapTexture`).draw(a,o.TRIANGLES,ln.disabled,dn.disabled,e.colorModeForRenderPass(),cn.disabled,or(e,t,0,1),null,d,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,s.zoom),u.destroy(),t.heatmapFbos.delete(l)}function Ei(e,t,n){let r=e.gl,i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),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);let a=e.HALF_FLOAT??r.UNSIGNED_BYTE,o=e.RGBA16F??r.RGBA;r.texImage2D(r.TEXTURE_2D,0,o,t,n,0,r.RGBA,a,null);let s=e.createFramebuffer(t,n,!1,!1);return s.colorAttachment.set(i),s}function Di(e,n){return n.colorRampTexture||=new t.T(e,n.colorRamp,e.gl.RGBA),n.colorRampTexture}function Oi(e,n,r,i,a,o,s,c){let l=256;if(a.stepInterpolant){let i=n.getSource().maxzoom,a=s.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-s.canonical.z):1;l=t.al(t.ce(o.maxLineLength/t.a6*1024*a),256,r.maxTextureSize)}return c.gradient=t.cf({expression:a.gradientExpression(),evaluationKey:`lineProgress`,resolution:l,image:c.gradient||void 0,clips:o.lineClipsArray}),c.texture?c.texture.update(c.gradient):c.texture=new t.T(r,c.gradient,i.RGBA),c.version=a.gradientVersion,c.texture}function ki(e,t,n,r,i){e.activeTexture.set(t.TEXTURE0),n.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(i)}function Ai(e,t,n,r,i,a){(i||e.lineAtlas.dirty)&&(t.activeTexture.set(n.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(a)}function ji(e,t,n,r,i,a,o){let s=a.gradients[i.id],c=s.texture;i.gradientVersion!==s.version&&(c=Oi(e,t,n,r,i,a,o,s)),n.activeTexture.set(r.TEXTURE0),c.bind(i.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function Mi(e,t,n,r,i,a,o,s,c){let l=a.gradients[i.id],u=l.texture;i.gradientVersion!==l.version&&(u=Oi(e,t,n,r,i,a,o,l)),n.activeTexture.set(r.TEXTURE0),u.bind(i.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),n.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(n),s.updatePaintBuffers(c)}function Ni(e,t,n,r,i){if(!n||!r?.imageAtlas)return;let a=r.imageAtlas.patternPositions,o=a[n.to.toString()],s=a[n.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let e=i.getPaintProperty(t);o=a[e],s=a[e]}o&&s&&e.setConstantPatternPositions(o,s)}function Pi(e,n,r,i,a,o,s,c){let l=e.context.gl,u=`fill-pattern`,d=r.paint.get(u),f=d?.constantOr(1),p=r.getCrossfadeParameters(),m,h,g,_,v,y=e.transform,b=r.paint.get(`fill-translate`),x=r.paint.get(`fill-translate-anchor`);s?(h=f&&!r.getPaintProperty(`fill-outline-color`)?`fillOutlinePattern`:`fillOutline`,m=l.LINES):(h=f?`fillPattern`:`fill`,m=l.TRIANGLES);let S=d.constantOr(null);for(let d of i){let i=n.getTile(d);if(f&&!i.patternsLoaded())continue;let C=i.getBucket(r);if(!C)continue;let w=C.programConfigurations.get(r.id),T=e.useProgram(h,w),E=e.style.map.terrain?.getTerrainData(d);f&&(e.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),w.updatePaintBuffers(p)),Ni(w,u,S,i,r);let D=y.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),O=t.aL(y,i,b,x);if(s){_=C.indexBuffer2,v=C.segments2;let t=[l.drawingBufferWidth,l.drawingBufferHeight];g=h===`fillOutlinePattern`&&f?er(e,p,i,t,O):$n(t,O)}else _=C.indexBuffer,v=C.segments,g=f?Qn(e,p,i,O):{u_fill_translate:O};let k=e.stencilModeForClipping(d);T.draw(e.context,m,a,k,o,cn.backCCW,g,E,D,r.id,C.layoutVertexBuffer,_,v,r.paint,e.transform.zoom,w)}}function Fi(e,n,r,i,a,o,s,c){let l=e.context,u=l.gl,d=`fill-extrusion-pattern`,f=r.paint.get(d),p=f.constantOr(1),m=r.getCrossfadeParameters(),h=r.paint.get(`fill-extrusion-opacity`),g=f.constantOr(null),_=e.transform;for(let f of i){let i=n.getTile(f),v=i.getBucket(r);if(!v)continue;let y=e.style.map.terrain?.getTerrainData(f),b=v.programConfigurations.get(r.id),x=e.useProgram(p?`fillExtrusionPattern`:`fillExtrusion`,b);p&&(e.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(m));let S=_.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!c,applyTerrainMatrix:!0});Ni(b,d,g,i,r);let C=t.aL(_,i,r.paint.get(`fill-extrusion-translate`),r.paint.get(`fill-extrusion-translate-anchor`)),w=r.paint.get(`fill-extrusion-vertical-gradient`),T=p?Zn(e,w,h,C,f,m,i):Xn(e,w,h,C);x.draw(l,l.gl.TRIANGLES,a,o,s,cn.backCCW,T,y,S,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer)}}function Ii(e,t,n,r,i,a,o,s,c){let l=e.style.projection,u=e.context,d=e.transform,f=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get(`hillshade-highlight-color`).values.length}`],m=e.useProgram(`hillshade`,null,!1,p),h=!e.options.moving;for(let p of r){let r=t.getTile(p),g=r.fbo;if(!g)continue;let _=l.getMeshFromTileID(u,p.canonical,s,!0,`raster`),v=e.style.map.terrain?.getTerrainData(p);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,g.colorAttachment.get());let y=d.getProjectionData({overscaledTileID:p,aligned:h,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(u,f.TRIANGLES,a,i[p.overscaledZ],o,cn.backCCW,sr(e,r,n),v,y,n.id,_.vertexBuffer,_.indexBuffer,_.segments)}}let Li=0;function Ri(e,n,r,i,a,o,s,c,l){let u=e.style.projection,d=e.context,f=e.transform,p=d.gl,m=e.useProgram(`colorRelief`),h=!e.options.moving,g=r.paint.get(`resampling`)===`nearest`?p.NEAREST:p.LINEAR,_=!0,v=0;for(let y of i){let i=n.getTile(y),b=i.dem;if(_){Li||=p.getParameter(p.MAX_TEXTURE_SIZE);let e=Li,{elevationTexture:t,colorTexture:n}=r.getColorRampTextures(d,e,b.getUnpackVector());d.activeTexture.set(p.TEXTURE1),t.bind(p.NEAREST,p.CLAMP_TO_EDGE),d.activeTexture.set(p.TEXTURE4),n.bind(p.LINEAR,p.CLAMP_TO_EDGE),_=!1,v=t.size[0]}if(!b?.data)continue;let x=b.stride,S=b.getPixels();if(d.activeTexture.set(p.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=e.getTileTexture(x),i.demTexture){let e=i.demTexture;e.update(S,{premultiply:!1}),e.bind(g,p.CLAMP_TO_EDGE)}else i.demTexture=new t.T(d,S,p.RGBA,{premultiply:!1}),i.demTexture.bind(g,p.CLAMP_TO_EDGE);let C=u.getMeshFromTileID(d,y.canonical,c,!0,`raster`),w=e.style.map.terrain?.getTerrainData(y),T=f.getProjectionData({overscaledTileID:y,aligned:h,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(d,p.TRIANGLES,o,a[y.overscaledZ],s,cn.backCCW,ur(r,i.dem,v),w,T,r.id,C.vertexBuffer,C.indexBuffer,C.segments)}}let zi=[new t.P(0,0),new t.P(t.a6,0),new t.P(t.a6,t.a6),new t.P(0,t.a6)];function Bi(e,t,n,r,i,a,o,s,c=!1,l=!1){let u=r[r.length-1].overscaledZ,d=e.context,f=d.gl,p=e.useProgram(`raster`),m=e.transform,h=e.style.projection,g=e.colorModeForRenderPass(),_=!e.options.moving,v=n.paint.get(`raster-opacity`),y=n.paint.get(`resampling`)===`nearest`||n.paint.get(`raster-resampling`)===`nearest`?f.NEAREST:f.LINEAR,b=n.paint.get(`raster-fade-duration`),x=!!e.style.map.terrain;for(let S of r){let r=e.getDepthModeForSublayer(S.overscaledZ-u,v===1?ln.ReadWrite:ln.ReadOnly,f.LESS),C=t.getTile(S);d.activeTexture.set(f.TEXTURE0),C.texture.bind(y,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(f.TEXTURE1);let{parentTile:w,parentScaleBy:T,parentTopLeft:E,fadeValues:D}=Vi(C,t,b,x);C.fadeOpacity=D.tileOpacity,w?(w.fadeOpacity=D.parentTileOpacity,w.texture.bind(y,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):C.texture.bind(y,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),C.texture.useMipmap&&d.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);let O=e.style.map.terrain?.getTerrainData(S),k=m.getProjectionData({overscaledTileID:S,aligned:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),A=vr(E,T,D.fadeMix,n,s),j=h.getMeshFromTileID(d,S.canonical,a,o,`raster`);p.draw(d,f.TRIANGLES,r,i?i[S.overscaledZ]:dn.disabled,g,c?cn.frontCCW:cn.backCCW,A,O,k,n.id,j.vertexBuffer,j.indexBuffer,j.segments)}}function Vi(e,n,r,i){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(r===0||i)return a;if(e.fadingParentID){let i=n.getLoadedTile(e.fadingParentID);if(!i)return a;let o=2**(i.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:i,parentScaleBy:o,parentTopLeft:[e.tileID.canonical.x*o%1,e.tileID.canonical.y*o%1],fadeValues:function(e,n,r){let i=l(),a=(i-n.timeAdded)/r,o=e.fadingDirection===Te.Incoming,s=t.al((i-e.timeAdded)/r,0,1),c=t.al(1-a,0,1),u=o?s:c;return{tileOpacity:u,parentTileOpacity:o?c:s,fadeMix:{opacity:1,mix:1-u}}}(e,i,r)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:function(e,n){let r=(l()-e.timeAdded)/n,i=t.al(r,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}(e,r)}:a}let Hi=new t.bo(1,0,0,1),Ui=new t.bo(0,1,0,1),Wi=new t.bo(0,0,1,1),Gi=new t.bo(1,0,1,1),Ki=new t.bo(0,1,1,1);function qi(e,t,n,r){Yi(e,0,t+n/2,e.transform.width,n,r)}function Ji(e,t,n,r){Yi(e,t-n/2,0,n,e.transform.height,r)}function Yi(e,t,n,r,i,a){let o=e.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio,i*e.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function Xi(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`debug`),s=ln.disabled,c=dn.disabled,l=e.colorModeForRenderPass(),u=`$debug`,d=e.style.map.terrain?.getTerrainData(r);i.activeTexture.set(a.TEXTURE0);let f=n.getTileByID(r.key).latestRawTileData,p=Math.floor((f?.byteLength||0)/1024),m=n.getTile(r).tileSize,h=512/Math.min(m,512)*(r.overscaledZ/e.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();let n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext(`2d`);i.clearRect(0,0,n.width,n.height),i.shadowColor=`white`,i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle=`white`,i.textBaseline=`top`,i.font=`bold 36px Open Sans, sans-serif`,i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);let _=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(i,a.TRIANGLES,s,c,on.alphaBlended,cn.disabled,ir(t.bo.transparent,h),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(i,a.LINE_STRIP,s,c,l,cn.disabled,ir(t.bo.red),d,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Zi(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=a.gl,s=e.transform,c=e.colorModeForRenderPass(),l=e.getDepthModeFor3D(),u=e.useProgram(`terrain`);a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(let r of n){let n=t.getTerrainMesh(r.tileID),d=e.renderToTexture.getTexture(r),f=t.getTerrainData(r.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,d.texture);let p=Gn(t.getMeshFrameDelta(s.zoom),s.calculateFogMatrix(r.tileID.toUnwrapped()),e.style.sky,s.pitch,i),m=s.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(a,o.TRIANGLES,l,dn.disabled,c,cn.backCCW,p,f,m,`terrain`,n.vertexBuffer,n.indexBuffer,n.segments)}}function Qi(e,n){if(!n.mesh){let r=new t.aU;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new t.aW;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),n.mesh=new Ht(e.createVertexBuffer(r,Ut.members),e.createIndexBuffer(i),t.aV.simpleSegment(0,0,r.length,i.length))}return n.mesh}let $i={symbol:function(e,n,r,i,a,o){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:s}=o,c=dn.disabled,l=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`))&&function(e,n,r,i,a,o,s,c,l){let u=n.transform,d=n.style.map.terrain,f=a===`map`,p=o===`map`;for(let a of e){let e=i.getTile(a),o=e.getBucket(r);if(!(o?.text)?.segments.get().length)continue;let m=t.aw(o.textSizeData,u.zoom),h=t.aK(e,1,n.transform.zoom),g=H(f,n.transform,h),_=r.layout.get(`icon-text-fit`)!==`none`&&o.hasIconData();if(m){let n=2**(u.zoom-e.tileID.overscaledZ),r=d?(e,t)=>d.getElevation(a,e,t):null;bi(o,f,p,l,u,g,n,m,_,t.aL(u,e,s,c),a.toUnwrapped(),r)}}}(i,e,r,n,r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),a),r.paint.get(`icon-opacity`).constantOr(1)!==0&&Si(e,n,r,i,!1,r.paint.get(`icon-translate`),r.paint.get(`icon-translate-anchor`),r.layout.get(`icon-rotation-alignment`),r.layout.get(`icon-pitch-alignment`),r.layout.get(`icon-keep-upright`),c,l,s),r.paint.get(`text-opacity`).constantOr(1)!==0&&Si(e,n,r,i,!0,r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.layout.get(`text-keep-upright`),c,l,s),n.map.showCollisionBoxes&&(gi(e,n,r,i,!0),gi(e,n,r,i,!1))},circle:function(e,n,r,i,a){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`circle-opacity`),c=r.paint.get(`circle-stroke-width`),l=r.paint.get(`circle-stroke-opacity`),u=!r.layout.get(`circle-sort-key`).isConstant();if(s.constantOr(1)===0&&(c.constantOr(1)===0||l.constantOr(1)===0))return;let d=e.context,f=d.gl,p=e.transform,m=e.getDepthModeForSublayer(0,ln.ReadOnly),h=dn.disabled,g=e.colorModeForRenderPass(),_=[],v=p.getCircleRadiusCorrection();for(let a of i){let i=n.getTile(a),s=i.getBucket(r);if(!s)continue;let c=r.paint.get(`circle-translate`),l=r.paint.get(`circle-translate-anchor`),d=t.aL(p,i,c,l),f=s.programConfigurations.get(r.id),m=e.useProgram(`circle`,f),h=s.layoutVertexBuffer,g=s.indexBuffer,y=e.style.map.terrain?.getTerrainData(a),b={programConfiguration:f,program:m,layoutVertexBuffer:h,indexBuffer:g,uniformValues:tr(e,i,r,d,v),terrainData:y,projectionData:p.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(u){let e=s.segments.get();for(let n of e)_.push({segments:new t.aV([n]),sortKey:n.sortKey,state:b})}else _.push({segments:s.segments,sortKey:0,state:b})}u&&_.sort(((e,t)=>e.sortKey-t.sortKey));for(let t of _){let{programConfiguration:n,program:i,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:c,projectionData:l}=t.state;i.draw(d,f.TRIANGLES,m,h,g,cn.backCCW,s,c,l,r.id,a,o,t.segments,r.paint,e.transform.zoom,n)}},heatmap:function(e,n,r,i,a){if(r.paint.get(`heatmap-opacity`)===0)return;let o=e.context,{isRenderingToTexture:s,isRenderingGlobe:c}=a;if(e.style.map.terrain){for(let t of i){let i=n.getTile(t);n.hasRenderableParent(t)||(e.renderPass===`offscreen`?wi(e,i,r,t,c):e.renderPass===`translucent`&&Ti(e,r,t,s,c))}o.viewport.set([0,0,e.width,e.height])}else e.renderPass===`offscreen`?function(e,n,r,i){let a=e.context,o=a.gl,s=e.transform,c=dn.disabled,l=new on([o.ONE,o.ONE],t.bo.transparent,[!0,!0,!0,!0]);(function(e,n,r){let i=e.gl;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,n.width/4,n.height/4]);let a=r.heatmapFbos.get(t.cd);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=Ei(e,n.width/4,n.height/4),r.heatmapFbos.set(t.cd,a))})(a,e,r),a.clear({color:t.bo.transparent});for(let t of i){if(n.hasRenderableParent(t))continue;let i=n.getTile(t),u=i.getBucket(r);if(!u)continue;let d=u.programConfigurations.get(r.id),f=e.useProgram(`heatmap`,d),p=s.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),m=s.getCircleRadiusCorrection();f.draw(a,o.TRIANGLES,ln.disabled,c,l,cn.backCCW,ar(i,s.zoom,r.paint.get(`heatmap-intensity`),m),null,p,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,s.zoom,d)}a.viewport.set([0,0,e.width,e.height])}(e,n,r,i):e.renderPass===`translucent`&&function(e,n){let r=e.context,i=r.gl;r.setColorMode(e.colorModeForRenderPass());let a=n.heatmapFbos.get(t.cd);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),Di(r,n).bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram(`heatmapTexture`).draw(r,i.TRIANGLES,ln.disabled,dn.disabled,e.colorModeForRenderPass(),cn.disabled,or(e,n,0,1),null,null,n.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,n.paint,e.transform.zoom))}(e,r)},line:function(e,t,n,r,i){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:a}=i,o=n.paint.get(`line-opacity`),s=n.paint.get(`line-width`);if(o.constantOr(1)===0||s.constantOr(1)===0)return;let c=e.getDepthModeForSublayer(0,ln.ReadOnly),l=e.colorModeForRenderPass(),u=n.paint.get(`line-dasharray`),d=u.constantOr(1),f=n.paint.get(`line-pattern`),p=f.constantOr(1),m=n.paint.get(`line-gradient`),h=n.getCrossfadeParameters(),g;g=p?`linePattern`:d&&m?`lineGradientSDF`:d?`lineSDF`:m?`lineGradient`:`line`;let _=e.context,v=_.gl,y=e.transform,b=!0;for(let i of r){let r=t.getTile(i);if(p&&!r.patternsLoaded())continue;let o=r.getBucket(n);if(!o)continue;let s=o.programConfigurations.get(n.id),x=e.context.program.get(),S=e.useProgram(g,s),C=b||S.program!==x,w=e.style.map.terrain?.getTerrainData(i),T=f.constantOr(null),E=u?.constantOr(null);if(T&&r.imageAtlas){let e=r.imageAtlas,t=e.patternPositions[T.to.toString()],n=e.patternPositions[T.from.toString()];t&&n&&s.setConstantPatternPositions(t,n)}else if(E){let t=n.layout.get(`line-cap`).constantOr(null)===`round`,r=e.lineAtlas.getDash(E.to,t),i=e.lineAtlas.getDash(E.from,t);s.setConstantDashPositions(r,i)}let D=y.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),O=y.getPixelScale(),k;p?(k=pr(e,r,n,O,h),ki(_,v,r,s,h)):d&&m?(k=hr(e,r,n,O,h,o.lineClipsArray.length),Mi(e,t,_,v,n,o,i,s,h)):d?(k=mr(e,r,n,O,h),Ai(e,_,v,s,C,h)):m?(k=fr(e,r,n,O,o.lineClipsArray.length),ji(e,t,_,v,n,o,i)):k=dr(e,r,n,O);let A=e.stencilModeForClipping(i);S.draw(_,v.TRIANGLES,c,A,l,cn.disabled,k,w,D,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,n.paint,e.transform.zoom,s,o.layoutVertexBuffer2),b=!1}},fill:function(e,n,r,i,a){let o=r.paint.get(`fill-color`),s=r.paint.get(`fill-opacity`);if(s.constantOr(1)===0)return;let{isRenderingToTexture:c}=a,l=e.colorModeForRenderPass(),u=r.paint.get(`fill-pattern`),d=e.opaquePassEnabledForLayer()&&!u.constantOr(1)&&o.constantOr(t.bo.transparent).a===1&&s.constantOr(0)===1?`opaque`:`translucent`;e.renderPass===d&&Pi(e,n,r,i,e.getDepthModeForSublayer(1,e.renderPass===`opaque`?ln.ReadWrite:ln.ReadOnly),l,!1,c),e.renderPass===`translucent`&&r.paint.get(`fill-antialias`)&&Pi(e,n,r,i,e.getDepthModeForSublayer(r.getPaintProperty(`fill-outline-color`)?2:0,ln.ReadOnly),l,!0,c)},fillExtrusion:function(e,t,n,r,i){let a=n.paint.get(`fill-extrusion-opacity`);if(a===0)return;let{isRenderingToTexture:o}=i;if(e.renderPass===`translucent`){let i=new ln(e.context.gl.LEQUAL,ln.ReadWrite,e.depthRangeFor3D);if(a!==1||n.paint.get(`fill-extrusion-pattern`).constantOr(1))Fi(e,t,n,r,i,dn.disabled,on.disabled,o),Fi(e,t,n,r,i,e.stencilModeFor3D(),e.colorModeForRenderPass(),o);else{let a=e.colorModeForRenderPass();Fi(e,t,n,r,i,dn.disabled,a,o)}}},hillshade:function(e,n,r,i,a){if(e.renderPass!==`offscreen`&&e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=e.context,c=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,ln.ReadOnly),u=e.colorModeForRenderPass();if(e.renderPass===`offscreen`)(function(e,n,r,i,a,o,s){let c=e.context,l=c.gl,u=i.paint.get(`resampling`)===`nearest`?l.NEAREST:l.LINEAR;for(let d of r){let r=n.getTile(d),f=r.dem;if(!f?.data||!r.needsHillshadePrepare)continue;let p=f.dim,m=f.stride,h=f.getPixels();if(c.activeTexture.set(l.TEXTURE1),c.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=e.getTileTexture(m),r.demTexture){let e=r.demTexture;e.update(h,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else r.demTexture=new t.T(c,h,l.RGBA,{premultiply:!1}),r.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);c.activeTexture.set(l.TEXTURE0);let g=r.fbo;if(!g){let e=new t.T(c,{width:p,height:p,data:null},l.RGBA);e.bind(u,l.CLAMP_TO_EDGE),g=r.fbo=c.createFramebuffer(p,p,!0,!1),g.colorAttachment.set(e.texture)}c.bindFramebuffer.set(g.framebuffer),c.viewport.set([0,0,p,p]),e.useProgram(`hillshadePrepare`).draw(c,l.TRIANGLES,a,o,s,cn.disabled,cr(r.tileID,f),null,null,i.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),r.needsHillshadePrepare=!1}})(e,n,i,r,l,dn.disabled,u),s.viewport.set([0,0,e.width,e.height]);else if(e.renderPass===`translucent`)if(c){let[t,a,s]=e.stencilConfigForOverlapTwoPass(i);Ii(e,n,r,s,t,l,u,!1,o),Ii(e,n,r,s,a,l,u,!0,o)}else{let[t,a]=e.getStencilConfigForOverlapAndUpdateStencilID(i);Ii(e,n,r,a,t,l,u,!1,o)}},colorRelief:function(e,t,n,r,i){if(e.renderPass!==`translucent`||!r.length)return;let{isRenderingToTexture:a}=i,o=e.style.projection.useSubdivision,s=e.getDepthModeForSublayer(0,ln.ReadOnly),c=e.colorModeForRenderPass();if(o){let[i,o,l]=e.stencilConfigForOverlapTwoPass(r);Ri(e,t,n,l,i,s,c,!1,a),Ri(e,t,n,l,o,s,c,!0,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Ri(e,t,n,o,i,s,c,!1,a)}},raster:function(e,t,n,r,i){if(e.renderPass!==`translucent`||n.paint.get(`raster-opacity`)===0||!r.length)return;let{isRenderingToTexture:a}=i,o=t.getSource(),s=e.style.projection.useSubdivision;if(o instanceof he)Bi(e,t,n,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,a);else if(s){let[i,o,s]=e.stencilConfigForOverlapTwoPass(r);Bi(e,t,n,s,i,!1,!0,zi,!1,a),Bi(e,t,n,s,o,!0,!0,zi,!1,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Bi(e,t,n,o,i,!1,!0,zi,!1,a)}},background:function(e,t,n,r,i){let a=n.paint.get(`background-color`),o=n.paint.get(`background-opacity`);if(o===0)return;let{isRenderingToTexture:s}=i,c=e.context,l=c.gl,u=e.style.projection,d=e.transform,f=d.tileSize,p=n.paint.get(`background-pattern`);if(e.isPatternMissing(p))return;let m=!p&&a.a===1&&o===1&&e.opaquePassEnabledForLayer()?`opaque`:`translucent`;if(e.renderPass!==m)return;let h=dn.disabled,g=e.getDepthModeForSublayer(0,m===`opaque`?ln.ReadWrite:ln.ReadOnly),_=e.colorModeForRenderPass(),v=e.useProgram(p?`backgroundPattern`:`background`),y=r||ze(d,{tileSize:f,terrain:e.style.map.terrain});p&&(c.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));let b=n.getCrossfadeParameters();for(let t of y){let r=d.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),i=p?wr(o,e,p,{tileID:t,tileSize:f},b):Cr(o,a),m=e.style.map.terrain?.getTerrainData(t),y=u.getMeshFromTileID(c,t.canonical,!1,!0,`raster`);v.draw(c,l.TRIANGLES,g,h,_,cn.backCCW,i,m,r,n.id,y.vertexBuffer,y.indexBuffer,y.segments)}},sky:function(e,t){let n=e.context,r=n.gl,i=((e,t,n)=>{let r=Math.cos(t.rollInRadians),i=Math.sin(t.rollInRadians),a=je(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get(`sky-color`),u_horizon_color:e.properties.get(`horizon-color`),u_horizon:[(t.width/2-a*i)*n,(t.height/2+a*r)*n],u_horizon_normal:[-i,r],u_sky_horizon_blend:e.properties.get(`sky-horizon-blend`)*t.height/2*n,u_sky_blend:o}})(t,e.style.map.transform,e.pixelRatio),a=new ln(r.LEQUAL,ln.ReadWrite,[0,1]),o=dn.disabled,s=e.colorModeForRenderPass(),c=e.useProgram(`sky`),l=Qi(n,t);c.draw(n,r.TRIANGLES,a,o,s,cn.disabled,i,null,void 0,`sky`,l.vertexBuffer,l.indexBuffer,l.segments)},atmosphere:function(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`atmosphere`),s=new ln(a.LEQUAL,ln.ReadOnly,[0,1]),c=e.transform,l=function(e,n){let r=e.properties.get(`position`),i=[-r.x,-r.y,-r.z],a=t.ap(new Float64Array(16));return e.properties.get(`anchor`)===`map`&&(t.be(a,a,n.rollInRadians),t.bf(a,a,-n.pitchInRadians),t.be(a,a,n.bearingInRadians),t.bf(a,a,n.center.lat*Math.PI/180),t.bI(a,a,-n.center.lng*Math.PI/180)),t.cg(i,i,a),i}(r,e.transform),u=c.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d=n.properties.get(`atmosphere-blend`)*u.projectionTransition;if(d===0)return;let f=Cn(c.worldSize,c.center.lat),p=c.inverseProjectionMatrix,m=new Float64Array(4);m[3]=1,t.aE(m,m,c.modelViewProjectionMatrix),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1,t.aE(m,m,p),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1;let h=((e,t,n,r,i)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:n,u_globe_radius:r,u_inv_proj_matrix:i}))(l,d,[m[0],m[1],m[2]],f,p),g=Qi(i,n);o.draw(i,a.TRIANGLES,s,dn.disabled,on.alphaBlended,cn.disabled,h,null,null,`atmosphere`,g.vertexBuffer,g.indexBuffer,g.segments)},custom:function(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=n.implementation,s=e.style.projection,c=e.transform,l=c.getProjectionDataForCustomLayer(i),u={farZ:c.farZ,nearZ:c.nearZ,fov:c.fov*Math.PI/180,modelViewProjectionMatrix:c.modelViewProjectionMatrix,projectionMatrix:c.projectionMatrix,shaderData:{variantName:s.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${s.shaderPreludeCode.vertexSource}`,define:s.shaderDefine},defaultProjectionData:l},d=o.renderingMode?o.renderingMode:`2d`;if(e.renderPass===`offscreen`){let t=o.prerender;t&&(e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),t.call(o,a.gl,u),a.setDirty(),e.setBaseState())}else if(e.renderPass===`translucent`){e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),a.setStencilMode(dn.disabled);let t=d===`3d`?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,ln.ReadOnly);a.setDepthMode(t),o.render(a.gl,u),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(null)}},debug:function(e,t,n){for(let r of n)Xi(e,t,r)},debugPadding:function(e){let t=e.transform.padding;qi(e,e.transform.height-(t.top||0),3,Hi),qi(e,t.bottom||0,3,Ui),Ji(e,t.left||0,3,Wi),Ji(e,e.transform.width-(t.right||0),3,Gi);let n=e.transform.centerPoint;(function(e,t,n,r){Yi(e,t-1,n-10,2,20,r),Yi(e,t-10,n-1,20,2,r)})(e,n.x,e.transform.height-n.y,Ki)},terrainDepth:function(e,n){let r=e.context,i=r.gl,a=e.transform,o=on.unblended,s=new ln(i.LEQUAL,ln.ReadWrite,[0,1]),c=n.tileManager.getRenderableTiles(),l=e.useProgram(`terrainDepth`);r.bindFramebuffer.set(n.getFramebuffer(`depth`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bo.transparent,depth:1});for(let e of c){let t=n.getTerrainMesh(e.tileID),c=n.getTerrainData(e.tileID),u=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),d={u_ele_delta:n.getMeshFrameDelta(a.zoom)};l.draw(r,i.TRIANGLES,s,dn.disabled,o,cn.backCCW,d,c,u,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])},terrainCoords:function(e,n){let r=e.context,i=r.gl,a=e.transform,o=on.unblended,s=new ln(i.LEQUAL,ln.ReadWrite,[0,1]),c=n.getCoordsTexture(),l=n.tileManager.getRenderableTiles(),u=e.useProgram(`terrainCoords`);r.bindFramebuffer.set(n.getFramebuffer(`coords`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bo.transparent,depth:1}),n.coordsIndex=[];for(let e of l){let t=n.getTerrainMesh(e.tileID),l=n.getTerrainData(e.tileID);r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,c.texture);let d={u_terrain_coords_id:(255-n.coordsIndex.length)/255,u_texture:0,u_ele_delta:n.getMeshFrameDelta(a.zoom)},f=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(r,i.TRIANGLES,s,dn.disabled,o,cn.backCCW,d,l,f,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments),n.coordsIndex.push(e.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}};class ea{constructor(e,n){this.drawFunctions=$i,this.context=new mi(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:t.ap(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=qe.maxOverzooming+qe.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new Rt}resize(e,t,n){if(this.width=Math.floor(e*n),this.height=Math.floor(t*n),this.pixelRatio=n,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let e of this.style._order)this.style._layers[e].resize()}setup(){let e=this.context,n=new t.aU;n.emplaceBack(0,0),n.emplaceBack(t.a6,0),n.emplaceBack(0,t.a6),n.emplaceBack(t.a6,t.a6),this.tileExtentBuffer=e.createVertexBuffer(n,Ut.members),this.tileExtentSegments=t.aV.simpleSegment(0,0,4,2);let r=new t.aU;r.emplaceBack(0,0),r.emplaceBack(t.a6,0),r.emplaceBack(0,t.a6),r.emplaceBack(t.a6,t.a6),this.debugBuffer=e.createVertexBuffer(r,Ut.members),this.debugSegments=t.aV.simpleSegment(0,0,4,5);let i=new t.ch;i.emplaceBack(0,0,0,0),i.emplaceBack(t.a6,0,t.a6,0),i.emplaceBack(0,t.a6,0,t.a6),i.emplaceBack(t.a6,t.a6,t.a6,t.a6),this.rasterBoundsBuffer=e.createVertexBuffer(i,Un.members),this.rasterBoundsSegments=t.aV.simpleSegment(0,0,4,2);let a=new t.aU;a.emplaceBack(0,0),a.emplaceBack(t.a6,0),a.emplaceBack(0,t.a6),a.emplaceBack(t.a6,t.a6),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Ut.members),this.rasterBoundsSegmentsPosOnly=t.aV.simpleSegment(0,0,4,5);let o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,Ut.members),this.viewportSegments=t.aV.simpleSegment(0,0,4,2);let s=new t.ci;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);let c=new t.aW;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(c);let l=this.context.gl;this.stencilClearMode=new dn({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new Ht(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=t.O();t.c7(r,0,this.width,this.height,0,0,1),t.S(r,r,[n.drawingBufferWidth,n.drawingBufferHeight,0]);let i={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram(`clippingMask`,null,!0).draw(e,n.TRIANGLES,ln.disabled,this.stencilClearMode,on.disabled,cn.disabled,null,null,i,`$clipping`,this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t?.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let r=this.context;r.setColorMode(on.disabled),r.setDepthMode(ln.disabled);let i={};for(let e of t)i[e.key]=this.nextStencilID++;this._renderTileMasks(i,t,n,!0),this._renderTileMasks(i,t,n,!1),this._tileClippingMaskIDs=i}_renderTileMasks(e,t,n,r){let i=this.context,a=i.gl,o=this.style.projection,s=this.transform,c=this.useProgram(`clippingMask`);for(let l of t){let t=e[l.key],u=this.style.map.terrain?.getTerrainData(l),d=o.getMeshFromTileID(this.context,l.canonical,r,!0,`stencil`),f=s.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!n,applyTerrainMatrix:!0});c.draw(i,a.TRIANGLES,ln.disabled,new dn({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),on.disabled,n?cn.disabled:cn.backCCW,null,u,f,`$clipping`,d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){let e=this.context,t=e.gl,n=this.style.projection,r=this.transform,i=this.useProgram(`depth`),a=this.getDepthModeFor3D(),o=ze(r,{tileSize:r.tileSize});for(let s of o){let o=this.style.map.terrain?.getTerrainData(s),c=n.getMeshFromTileID(this.context,s.canonical,!0,!0,`raster`),l=r.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!0,applyTerrainMatrix:!0});i.draw(e,t.TRIANGLES,a,dn.disabled,on.disabled,cn.backCCW,null,o,l,`$clipping`,c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new dn({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new dn({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();let e={};for(let n=0;n<i;n++)e[n+r]=new dn({func:t.GEQUAL,mask:255},n+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=i,[e,n]}return[{[r]:dn.disabled},n]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(this.clearStencil(),i>1){let e={},a={};for(let n=0;n<i;n++)e[n+r]=new dn({func:t.GREATER,mask:255},i+1+n,255,t.KEEP,t.KEEP,t.REPLACE),a[n+r]=new dn({func:t.GREATER,mask:255},1+n,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*i+1,[e,a,n]}return this.nextStencilID=3,[{[r]:new dn({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new dn({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},n]}colorModeForRenderPass(){let e=this.context.gl;if(this._showOverdrawInspector){let n=1/8;return new on([e.CONSTANT_COLOR,e.ONE],new t.bo(n,n,n,0),[!0,!0,!0,!0])}return this.renderPass===`opaque`?on.unblended:on.alphaBlended}getDepthModeForSublayer(e,t,n){if(!this.opaquePassEnabledForLayer())return ln.disabled;let r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new ln(n||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new ln(this.context.gl.LEQUAL,ln.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var r;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(l()),this.imageManager.beginFrame();let i=this.style._order,a=this.style.tileManagers,o={},s={},c={},u={isRenderingToTexture:!1,isRenderingGlobe:e.projection?.transitionState>0};for(let e in a){let t=a[e];t.used&&t.prepare(this.context),o[e]=t.getVisibleCoordinates(!1),s[e]=o[e].slice().reverse(),c[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<i.length;e++)if(this.style._layers[i[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass=`offscreen`;for(let e of i){let t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;let n=s[t.source];(t.type===`custom`||n.length)&&this.renderLayer(this,a[t.source],t,n,u)}if((r=this.style.projection)==null||r.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass=`opaque`,this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){let e=this.style._layers[i[this.currentLayer]],t=a[e.source],n=o[e.source];this._renderTileClippingMasks(e,n,!1),this.renderLayer(this,t,e,n,u)}this.renderPass=`translucent`;let d=!1;for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){let e=this.style._layers[i[this.currentLayer]],t=a[e.source];if(this.renderToTexture?.renderLayer(e,u))continue;this.opaquePassEnabledForLayer()||d||(d=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let n=(e.type===`symbol`?c:s)[e.source];this._renderTileClippingMasks(e,o[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,n,u)}if(u.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,t){let n=null,r=Object.values(e._layers).flatMap((n=>n.source&&!n.isHidden(t)?[e.tileManagers[n.source]]:[])),i=r.filter((e=>e.getSource().type===`vector`)),a=r.filter((e=>e.getSource().type!==`vector`)),o=e=>{(!n||n.getSource().maxzoom<e.getSource().maxzoom)&&(n=e)};for(let e of i)o(e);if(!n)for(let e of a)o(e);return n}(this.style,this.transform.zoom);e&&this.drawFunctions.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(e){if(!this.style?.map?.terrain)return;let n=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.depthDirty;i||=e?!t.cj(n,r):!t.ck(n,r),i||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),i&&(t.cl(n,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}maybeDrawCoords(){var e;(e=this.style?.map)!=null&&e.terrain&&this.terrainFacilitator.coordsDirty&&(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain))}renderLayer(e,n,r,i,a){if(r.isHidden(this.transform.zoom)||r.type!==`background`&&r.type!==`custom`&&!(i||[]).length)return;this.id=r.id;let o=this.drawFunctions;t.aQ(r)?o.symbol(e,n,r,i,this.style.placement.variableOffsets,a):t.cm(r)?o.circle(e,n,r,i,a):t.cn(r)?o.heatmap(e,n,r,i,a):t.co(r)?o.line(e,n,r,i,a):t.cp(r)?o.fill(e,n,r,i,a):t.cq(r)?o.fillExtrusion(e,n,r,i,a):t.cr(r)?o.hillshade(e,n,r,i,a):t.cs(r)?o.colorRelief(e,n,r,i,a):t.bU(r)?o.raster(e,n,r,i,a):t.ct(r)?o.background(e,n,r,i,a):t.cu(r)&&o.custom(e,n,r,a)}saveTileTexture(e){let t=this._tileTextures[e.size[0]];t?t.length<ea.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?t.push(e):e.destroy():this._tileTextures[e.size[0]]=[e]}getTileTexture(e){let 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;let t=this.imageManager.getPattern(e.from.toString()),n=this.imageManager.getPattern(e.to.toString());return!t||!n}useProgram(e,t,n=!1,r=[]){var i;this.cache||={};let a=!!this.style.map.terrain,o=this.style.projection,s=n?Bt.projectionMercator:o.shaderPreludeCode,c=n?Wt:o.shaderDefine,l=e+(t?t.cacheKey:``)+`/${n?Gt:o.shaderVariantName}`+(this._showOverdrawInspector?`/overdraw`:``)+(a?`/terrain`:``)+(r?`/${r.join(`/`)}`:``);return(i=this.cache)[l]||(i[l]=new Jn(this.context,Bt[e],t,Er[e],this._showOverdrawInspector,a,s,c,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let 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(){this.debugOverlayCanvas??(this.debugOverlayCanvas=document.createElement(`canvas`),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(let e in this._tileTextures){let t=this._tileTextures[e];if(t)for(let e of t)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((e=this.tileExtentMesh.vertexBuffer)==null||e.destroy()),this.tileExtentMesh&&((t=this.tileExtentMesh.indexBuffer)==null||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(let e in this.cache){let t=this.cache[e];t!=null&&t.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function ta(e,t){let n,r=!1,i=null,a=()=>{i=null,r&&=(e(...n),i=setTimeout(a,t),!1)};return(...e)=>(r=!0,n=e,i||a(),i)}ea.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class na{constructor(e){this._getCurrentHash=()=>{let e=window.location.hash.replace(`#`,``);if(this._hashName){let t,n=e.split(`&`).map((e=>e.split(`=`)));for(let e of n)e[0]===this._hashName&&(t=e);return(t&&t[1]||``).split(`/`)}return e.split(`/`)},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getCurrentHash();if(e.length===0)return;let t=e.join(`/`),n=t;n.split(`&`).length>0&&(n=n.split(`&`)[0]),this._hashName&&(n=`${this._hashName}=${t}`);let r=window.location.hash.replace(n,``);r.startsWith(`#&`)?r=r.slice(0,1)+r.slice(2):r===`#`&&(r=``);let i=window.location.href.replace(/(#.+)?$/,r);i=i.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,i)},this._updateHash=ta(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener(`hashchange`,this._onHashChange,!1),this._map.on(`moveend`,this._updateHash),this}remove(){return removeEventListener(`hashchange`,this._onHashChange,!1),this._map.off(`moveend`,this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.round(t.lng*r)/r,a=Math.round(t.lat*r)/r,o=this._map.getBearing(),s=this._map.getPitch(),c=``;if(c+=e?`/${i}/${a}/${n}`:`${n}/${a}/${i}`,(o||s)&&(c+=`/`+Math.round(10*o)/10),s&&(c+=`/${Math.round(s)}`),this._hashName){let e=this._hashName,t=!1,n=window.location.hash.slice(1).split(`&`).map((n=>{let r=n.split(`=`)[0];return r===e?(t=!0,`${r}=${c}`):n})).filter((e=>e));return t||n.push(`${e}=${c}`),`#${n.join(`&`)}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.W(+e[2],+e[1])}catch{return!1}let n=+e[0],r=+(e[3]||0),i=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}}let ra={linearity:.3,easing:t.cv(0,0,.3,1)},ia=t.e({deceleration:2500,maxSpeed:1400},ra),aa=t.e({deceleration:20,maxSpeed:1400},ra),oa=t.e({deceleration:1e3,maxSpeed:360},ra),sa=t.e({deceleration:1e3,maxSpeed:90},ra),ca=t.e({deceleration:1e3,maxSpeed:360},ra);class la{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:l(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=l();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,n.roll+=e.rollDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);let r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){let a=da(n.pan.mag(),r,t.e({},ia,e||{})),o=n.pan.mult(a.amount/n.pan.mag()),s=this._map.cameraHelper.handlePanInertia(o,this._map.transform);i.center=s.easingCenter,i.offset=s.easingOffset,ua(i,a)}if(n.zoom){let e=da(n.zoom,r,aa);i.zoom=t.cw(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount),ua(i,e)}if(n.bearing){let e=da(n.bearing,r,oa);i.bearing=this._map.transform.bearing+t.al(e.amount,-179,179),ua(i,e)}if(n.pitch){let e=da(n.pitch,r,sa);i.pitch=this._map.transform.pitch+e.amount,ua(i,e)}if(n.roll){let e=da(n.roll,r,ca);i.roll=this._map.transform.roll+t.al(e.amount,-179,179),ua(i,e)}if(i.zoom||i.bearing){let e=n.pinchAround===void 0?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(i,{noMoveStart:!0})}}function ua(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function da(e,n,r){let{maxSpeed:i,linearity:a,deceleration:o}=r,s=t.al(e*a/(n/1e3),-i,i),c=Math.abs(s)/(o*a);return{easing:r.easing,duration:1e3*c,amount:c/2*s}}class fa extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);let a=d.mousePos(n.getCanvas(),r),o=n.unproject(a);super(e,t.e({point:a,lngLat:o,originalEvent:r},i)),this._defaultPrevented=!1,this.target=n}}class pa extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r){let i=e===`touchend`?r.changedTouches:r.touches,a=d.touchPos(n.getCanvasContainer(),i),o=a.map((e=>n.unproject(e))),s=a.reduce(((e,t,n,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:s,lngLats:o,lngLat:n.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class ma extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class ha{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new ma(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new fa(e.type,this._map,e))}mouseup(e){this._map.fire(new fa(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new fa(e.type,this._map,e))}dblclick(e){return this._firePreventable(new fa(e.type,this._map,e))}mouseover(e){this._map.fire(new fa(e.type,this._map,e))}mouseout(e){this._map.fire(new fa(e.type,this._map,e))}touchstart(e){return this._firePreventable(new pa(e.type,this._map,e))}touchmove(e){this._map.fire(new pa(e.type,this._map,e))}touchend(e){this._map.fire(new pa(e.type,this._map,e))}touchcancel(e){this._map.fire(new pa(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ga{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new fa(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new fa(`contextmenu`,this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new fa(e.type,this._map,e)),this._map.listens(`contextmenu`)&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class _a{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class va{constructor(e,t){this._map=e,this._tr=new _a(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&typeof t.boxZoom==`object`&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}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&&e.button===0&&(d.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let n=t;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=n,this._box||(this._box=d.create(`div`,`maplibregl-boxzoom`,this._container),this._container.classList.add(`maplibregl-crosshair`),this._fireEvent(`boxzoomstart`,e));let i=Math.min(r.x,n.x),a=Math.max(r.x,n.x),o=Math.min(r.y,n.y),s=Math.max(r.y,n.y);this._box.style.transform=`translate(${i}px,${o}px)`,this._box.style.width=a-i+`px`,this._box.style.height=s-o+`px`}mouseupWindow(e,n){if(!this._active||e.button!==0)return;let r=this._startPos,i=n;if(this.reset(),d.suppressClick(),r.x!==i.x||r.y!==i.y)return this._map.fire(new t.n(`boxzoomend`,{originalEvent:e})),this._boxZoomEnd?void this._boxZoomEnd(this._map,r,i,e):{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})};this._fireEvent(`boxzoomcancel`,e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent(`boxzoomcancel`,e))}reset(){this._active=!1,this._container.classList.remove(`maplibregl-crosshair`),this._box&&=(this._box.remove(),null),d.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new t.n(e,{originalEvent:n}))}}function ya(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let n={};for(let r=0;r<e.length;r++)n[e[r].identifier]=t[r];return n}class ba{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){let n=new t.P(0,0);for(let t of e)n._add(t);return n.div(e.length)}(n),this.touches=ya(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;let r=ya(n,t);for(let e in this.touches){let t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class W{constructor(e){this.singleTap=new ba(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){let r=this.singleTap.touchend(e,t,n);if(r){let t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class xa{constructor(e){this._tr=new _a(e),this._zoomIn=new W({numTouches:1,numTaps:2}),this._zoomOut=new W({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,n,r){let i=this._zoomIn.touchend(e,n,r),a=this._zoomOut.touchend(e,n,r),o=this._tr;return i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:t.cw(o.zoom+1,n.getZoomSnap()),around:o.unproject(i)},{originalEvent:e})}):a?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:t.cw(o.zoom-1,n.getZoomSnap()),around:o.unproject(a)},{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}}class Sa{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let n=this._lastPoint;if(!n)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(n)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(n,r))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&d.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let Ca={0:1,2:2};class wa{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){let n=Ca[t];return e.buttons===void 0||(e.buttons&n)!==n}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}}class Ta{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class Ea{constructor(e=new wa({checkCorrectEvent:()=>!0}),t=new Ta){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,n){return e instanceof MouseEvent?t(e):typeof TouchEvent<`u`&&e instanceof TouchEvent?n(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.startMove(e)}),(e=>{this.oneFingerTouchMoveStateManager.startMove(e)}))}endMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.endMove(e)}),(e=>{this.oneFingerTouchMoveStateManager.endMove(e)}))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}let Da=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Oa{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,n){return this._calculateTransform(e,t,n)}touchmove(e,t,n){if(this._active){if(!this._shouldBePrevented(n.length))return e.preventDefault(),this._calculateTransform(e,t,n);this._map.cooperativeGestures.notifyGestureBlocked(`touch_pan`,e)}}touchend(e,t,n){this._calculateTransform(e,t,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,r){r.length>0&&(this._active=!0);let i=ya(r,n),a=new t.P(0,0),o=new t.P(0,0),s=0;for(let e in i){let t=i[e],n=this._touches[e];n&&(a._add(t),o._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,this._shouldBePrevented(s)||!o.mag())return;let c=o.div(s);return this._sum._add(c),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(s),panDelta:c}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ka{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){if(!this._firstTwoTouches)return;e.preventDefault();let[r,i]=this._firstTwoTouches,a=Aa(n,t,r),o=Aa(n,t,i);if(!a||!o)return;let s=this._aroundCenter?null:a.add(o).div(2);return this._move([a,o],s,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;let[r,i]=this._firstTwoTouches,a=Aa(n,t,r),o=Aa(n,t,i);a&&o||(this._active&&d.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Aa(e,t,n){for(let r=0;r<e.length;r++)if(e[r].identifier===n)return t[r]}function ja(e,t){return Math.log(e/t)/Math.LN2}class Ma extends ka{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let n=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(ja(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:ja(this._distance,n)*this._zoomRate,pinchAround:t}}}function Na(e,t){return 180*e.angleWith(t)/Math.PI}class Pa extends ka{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,n){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Na(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,n=Na(e,this._startVector);return Math.abs(n)<t}}function Fa(e){return Math.abs(e.y)>Math.abs(e.x)}class Ia extends ka{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,n){super.touchstart(e,t,n),this._currentTouchCount=n.length}_start(e){this._lastPoints=e,Fa(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,n){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),i=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,n){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;let a=e.y>0==t.y>0;return Fa(e)&&Fa(t)&&a}}let La={panStep:100,bearingStep:15,pitchStep:10};class Ra{constructor(e){this._tr=new _a(e);let t=La;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,r=0,i=0,a=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{let c=this._tr;s.easeTo({duration:300,easeId:`keyboardHandler`,easing:za,zoom:n?t.cw(c.zoom+n*(e.shiftKey?2:1),s.getZoomSnap()):c.zoom,bearing:c.bearing+r*this._bearingStep,pitch:c.pitch+i*this._pitchStep,offset:[-a*this._panStep,-o*this._panStep],center:c.center},{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 za(e){return e*(2-e)}let Ba=4.000244140625;class Va{constructor(e,t){this._onTimeout=e=>{this._type=`wheel`,this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new _a(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked(`wheel_zoom`,e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,n=l(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,t!==0&&t%Ba==0?this._type=`wheel`:t!==0&&Math.abs(t)<4?this._type=`trackpad`:r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?`trackpad`:`wheel`,this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=d.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.W.convert(r.center)):n,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if(typeof this._lastExpectedZoom==`number`){let t=e.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=t),typeof this._targetZoom==`number`&&(this._targetZoom+=t)}if(this._delta!==0){let n=this._type===`wheel`&&Math.abs(this._delta)>Ba?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&r!==0&&(r=1/r);let i=typeof this._targetZoom==`number`?t.ao(this._targetZoom):e.scale,a=e.applyConstrain(e.getCameraLngLat(),t.ar(i*r)).zoom,o=this._map.getZoomSnap();if(this._type===`wheel`&&o>0){let n=t.cw(e.zoom,o);this._targetZoom=t.cw(a,o,a-n)}else this._targetZoom=a;this._type===`wheel`&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom==`number`?this._targetZoom:e.zoom,r=this._startZoom,i=this._easing,a,o=!1;if(this._type===`wheel`&&r&&i){let e=l()-this._lastWheelEventTime,s=Math.min((e+5)/200,1),c=i(s);a=t.H.number(r,n,c),s<1?this._needsRerender=!0:o=!0}else a=n,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!o,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=t.cy;if(this._prevEase){let e=this._prevEase,r=(l()-e.start)/e.duration,i=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(i*i+1e-4)*.01,o=Math.sqrt(.0729-a*a);n=t.cv(a,o,.25,1)}return this._prevEase={start:l(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Ha{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 Ua{constructor(e){this._tr=new _a(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:t.cw(this._tr.zoom+(e.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wa{constructor(){this._tap=new W({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,n){if(!this._swipePoint)if(this._tapTime){let r=t[0],i=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;i&&a?n.length>0&&(this._swipePoint=r,this._swipeTouch=n[0].identifier):this.reset()}else this._tap.touchstart(e,t,n)}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;let r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128*this._zoomRate}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{let r=this._tap.touchend(e,t,n);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ga{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add(`maplibregl-touch-drag-pan`)}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove(`maplibregl-touch-drag-pan`)}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ka{constructor(e,t,n,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=n,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class qa{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add(`maplibregl-touch-zoom-rotate`)}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove(`maplibregl-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()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Ja{constructor(e,t){this._bypassKey=navigator.userAgent.includes(`Mac`)?`metaKey`:`ctrlKey`,this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add(`maplibregl-cooperative-gestures`),this._container=d.create(`div`,`maplibregl-cooperative-gesture-screen`,e);let t=this._map._getUIString(`CooperativeGesturesHandler.WindowsHelpText`);this._bypassKey===`metaKey`&&(t=this._map._getUIString(`CooperativeGesturesHandler.MacHelpText`));let n=this._map._getUIString(`CooperativeGesturesHandler.MobileHelpText`),r=document.createElement(`div`);r.className=`maplibregl-desktop-message`,r.textContent=t,this._container.appendChild(r);let i=document.createElement(`div`);i.className=`maplibregl-mobile-message`,i.textContent=n,this._container.appendChild(i),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove(`maplibregl-cooperative-gestures`)),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new t.n(`cooperativegestureprevented`,{gestureType:e,originalEvent:n})),this._container.classList.add(`maplibregl-show`),setTimeout((()=>{this._container.classList.remove(`maplibregl-show`)}),100))}}let Ya=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Xa extends t.n{}function Za(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Qa{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e,n){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,n)=>{if(e.type===`blur`)return void this.stop(!0);this._updatingCamera=!0;let r=e.type===`renderFrame`?void 0:e,i={needsRenderFrame:!1},a={},o={};for(let{handlerName:s,handler:c,allowed:l}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(o,l,s))c.reset();else if(c[n||e.type]){if(t.cz(e,n||e.type)){let t=d.mousePos(this._map.getCanvas(),e);u=c[n||e.type](e,t)}else if(t.cA(e,n||e.type)){let t=this._getMapTouches(e.touches),r=d.touchPos(this._map.getCanvas(),t);u=c[n||e.type](e,r,t)}else t.cB(n||e.type)||(u=c[n||e.type](e));this.mergeHandlerResult(i,a,u,s,r),u!=null&&u.needsRenderFrame&&this._triggerRenderFrame()}(u||c.isActive())&&(o[s]=c)}let s={};for(let e in this._previousActiveHandlers)o[e]||(s[e]=r);this._previousActiveHandlers=o,(Object.keys(s).length||Za(i))&&(this._changes.push([i,a,s]),this._triggerRenderFrame()),(Object.keys(o).length||Za(i))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new la(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);let r=this._el;this._listeners=[[r,`touchstart`,{passive:!0}],[r,`touchmove`,{passive:!1}],[r,`touchend`,void 0],[r,`touchcancel`,void 0],[r,`mousedown`,void 0],[r,`mousemove`,void 0],[r,`mouseup`,void 0],[this._ownerDocument,`mousemove`,{capture:!0}],[this._ownerDocument,`mouseup`,void 0],[r,`mouseover`,void 0],[r,`mouseout`,void 0],[r,`dblclick`,void 0],[r,`click`,void 0],[r,`keydown`,{capture:!1}],[r,`keyup`,void 0],[r,`wheel`,{passive:!1}],[r,`contextmenu`,void 0],[this._ownerWindow,`blur`,void 0]];for(let[e,t,n]of this._listeners)e.addEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(let[e,t,n]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(e){let n=this._map,r=n.getCanvasContainer();this._add(`mapEvent`,new ha(n,e));let i=n.boxZoom=new va(n,e);this._add(`boxZoom`,i),e.interactive&&e.boxZoom&&i.enable();let a=n.cooperativeGestures=new Ja(n,e.cooperativeGestures);this._add(`cooperativeGestures`,a),e.cooperativeGestures&&a.enable();let o=new xa(n),s=new Ua(n);n.doubleClickZoom=new Ha(s,o),this._add(`tapZoom`,o),this._add(`clickZoom`,s),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();let c=new Wa;this._add(`tapDragZoom`,c);let l=n.touchPitch=new Ia(n);this._add(`touchPitch`,l),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);let u=()=>n.project(n.getCenter()),d=function({enable:e,clickTolerance:n,aroundCenter:r=!0,minPixelCenterThreshold:i=100,rotateDegreesPerPixelMoved:a=.8},o){return new Sa({clickTolerance:n,move:(e,n)=>{let s=o();if(r&&Math.abs(s.y-e.y)>i)return{bearingDelta:t.cx(new t.P(e.x,n.y),n,s)};let c=(n.x-e.x)*a;return r&&n.y<s.y&&(c=-c),{bearingDelta:c}},moveStateManager:new wa({checkCorrectEvent:e=>e.button===0&&e.ctrlKey||e.button===2&&!e.ctrlKey}),enable:e,assignEvents:Da})}(e,u),f=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5}){return new Sa({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*n}),moveStateManager:new wa({checkCorrectEvent:e=>e.button===0&&e.ctrlKey||e.button===2}),enable:e,assignEvents:Da})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:n=.3},r){return new Sa({clickTolerance:t,move:(e,t)=>{let i=r(),a=(t.x-e.x)*n;return t.y<i.y&&(a=-a),{rollDelta:a}},moveStateManager:new wa({checkCorrectEvent:e=>e.button===2&&e.ctrlKey}),enable:e,assignEvents:Da})}(e,u);n.dragRotate=new Ka(e,d,f,p),this._add(`mouseRotate`,d,[`mousePitch`]),this._add(`mousePitch`,f,[`mouseRotate`,`mouseRoll`]),this._add(`mouseRoll`,p,[`mousePitch`]),e.interactive&&e.dragRotate&&n.dragRotate.enable();let m=function({enable:e,clickTolerance:t}){return new Sa({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new wa({checkCorrectEvent:e=>e.button===0&&!e.ctrlKey}),enable:e,assignEvents:Da})}(e),h=new Oa(e,n);n.dragPan=new Ga(r,m,h),this._add(`mousePan`,m),this._add(`touchPan`,h,[`touchZoom`,`touchRotate`]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);let g=new Pa,_=new Ma;n.touchZoomRotate=new qa(r,_,g,c),this._add(`touchRotate`,g,[`touchPan`,`touchZoom`]),this._add(`touchZoom`,_,[`touchPan`,`touchRotate`]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate),this._add(`blockableMapEvent`,new ga(n));let v=n.scrollZoom=new Va(n,(()=>this._triggerRenderFrame()));this._add(`scrollZoom`,v,[`mousePan`]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);let y=n.keyboard=new Ra(n);this._add(`keyboard`,y),e.interactive&&e.keyboard&&n.keyboard.enable()}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{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!!Ya(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,n){for(let r in e)if(r!==n&&!t?.includes(r))return!0;return!1}_getMapTouches(e){let t=[];for(let n of e)this._el.contains(n.target)&&t.push(n);return t}mergeHandlerResult(e,n,r,i,a){if(!r)return;t.e(e,r);let o={handlerName:i,originalEvent:r.originalEvent||a};r.zoomDelta!==void 0&&(n.zoom=o),r.panDelta!==void 0&&(n.drag=o),r.rollDelta!==void 0&&(n.roll=o),r.pitchDelta!==void 0&&(n.pitch=o),r.bearingDelta!==void 0&&(n.rotate=o)}_applyChanges(){let e={},n={},r={};for(let[i,a,o]of this._changes)i.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(i.panDelta)),i.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+i.pitchDelta),i.rollDelta&&(e.rollDelta=(e.rollDelta||0)+i.rollDelta),i.around!==void 0&&(e.around=i.around),i.pinchAround!==void 0&&(e.pinchAround=i.pinchAround),i.noInertia&&(e.noInertia=i.noInertia),t.e(n,a),t.e(r,o);this._updateMapTransform(e,n,r),this._changes=[]}_updateMapTransform(e,t,n){let r=this._map,i=r._getTransformForUpdate(),a=r.terrain;if(!(Za(e)||a&&this._terrainMovement))return void this._fireEvents(t,n,!0);r._stop(!0);let{panDelta:o,zoomDelta:s,bearingDelta:c,pitchDelta:l,rollDelta:u,around:d,pinchAround:f}=e;f!==void 0&&(d=f),d||=r.transform.centerPoint,a&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let p={panDelta:o,zoomDelta:s,rollDelta:u,pitchDelta:l,bearingDelta:c,around:d};this._map.cameraHelper.useGlobeControls&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let m=d.distSqr(i.centerPoint)<.01?i.center:i.screenPointToLocation(o?d.sub(o):d);this._handleMapControls({terrain:a,tr:i,deltasForHelper:p,preZoomAroundLoc:m,combinedEventsInProgress:t,panDelta:o}),r._applyUpdatedTransform(i),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,n,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:n,preZoomAroundLoc:r,combinedEventsInProgress:i,panDelta:a}){let o=this._map.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(n,t),e)return o.useGlobeControls?(this._terrainMovement||!i.drag&&!i.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void o.handleMapControlsPan(n,t,r)):this._terrainMovement||!i.drag&&!i.zoom?void(i.drag&&this._terrainMovement&&a?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(a))):o.handleMapControlsPan(n,t,r)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void o.handleMapControlsPan(n,t,r));o.handleMapControlsPan(n,t,r)}_fireEvents(e,n,r){let i=Ya(this._eventsInProgress),a=Ya(e),o={};for(let t in e){let{originalEvent:n}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=n),this._eventsInProgress[t]=e[t]}!i&&a&&this._fireEvent(`movestart`,a.originalEvent);for(let e in o)this._fireEvent(e,o[e]);a&&this._fireEvent(`move`,a.originalEvent);for(let t in e){let{originalEvent:n}=e[t];this._fireEvent(t,n)}let c={},l;for(let e in this._eventsInProgress){let{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,c[`${e}end`]=l)}for(let e in c)this._fireEvent(e,c[e]);let u=Ya(this._eventsInProgress),d=(i||a)&&!u;if(d&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(r&&d){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>e!==0&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&s.prefersReducedMotion?(this._map.fire(new t.n(`moveend`,{originalEvent:l})),n(this._map.getBearing())&&this._map.resetNorth()):(n(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:l})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new t.n(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new Xa(`renderFrame`,{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class $a extends t.E{constructor(e,t,n){super(),this._renderFrameCallback=()=>{let e=Math.min((l()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this._zoomSnap=n.zoomSnap,this.cameraHelper=t,this.on(`moveend`,(()=>{delete this._requestedCameraState}))}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t}getCenter(){return new t.W(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},n),r)}panTo(e,n,r){return this.easeTo(t.e({center:e},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,n,r){return this.easeTo(t.e({zoom:e},n),r)}zoomIn(e,n){return this.zoomTo(t.cw(this.getZoom()+1,this._zoomSnap),e,n),this}zoomOut(e,n){return this.zoomTo(t.cw(this.getZoom()-1,this._zoomSnap),e,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.n(`movestart`,n)).fire(new t.n(`move`,n)).fire(new t.n(`moveend`,n))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,n,r){return this.easeTo(t.e({bearing:e},n),r)}resetNorth(e,n){return this.rotateTo(0,t.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),n),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}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=re.convert(e).adjustAntiMeridian();let n=t?.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),n,t)}_cameraForBoxAndBearing(e,n,r,i){let a={top:0,bottom:0,right:0,left:0};if(typeof(i=t.e({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding==`number`){let e=i.padding;i.padding={top:e,bottom:e,right:e,left:e}}let o=t.e(a,i.padding);i.padding=o;let s=this.transform,c=new re(e,n),l=this.cameraHelper.cameraForBoxAndBearing(i,o,c,r,s);return l&&this._zoomSnap&&(l.zoom=t.cw(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,n){return this._fitInternal(this.cameraForBounds(e,t),t,n)}fitScreenCoordinates(e,n,r,i,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(t.P.convert(e)),this.transform.screenPointToLocation(t.P.convert(n)),r,i),i,a)}_fitInternal(e,n,r){return e?(delete(n=t.e(e,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(e,n){this.stop(),`zoom`in e&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));let r=this._getTransformForUpdate(),i=!1,a=!1,o=!1,s=r.zoom;this.terrain&&r.setElevation(this.terrain.getElevationForLngLatZoom(e.center?t.W.convert(e.center):r.center,e.zoom||r.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(r,e);let c=r.zoom!==s;return`elevation`in e&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),`bearing`in e&&r.bearing!==+e.bearing&&(i=!0,r.setBearing(+e.bearing)),`pitch`in e&&r.pitch!==+e.pitch&&(a=!0,r.setPitch(+e.pitch)),`roll`in e&&r.roll!==+e.roll&&(o=!0,r.setRoll(+e.roll)),e.padding==null||r.isPaddingEqual(e.padding)||r.setPadding(e.padding),this._applyUpdatedTransform(r),this.fire(new t.n(`movestart`,n)).fire(new t.n(`move`,n)),c&&this.fire(new t.n(`zoomstart`,n)).fire(new t.n(`zoom`,n)).fire(new t.n(`zoomend`,n)),i&&this.fire(new t.n(`rotatestart`,n)).fire(new t.n(`rotate`,n)).fire(new t.n(`rotateend`,n)),a&&this.fire(new t.n(`pitchstart`,n)).fire(new t.n(`pitch`,n)).fire(new t.n(`pitchend`,n)),o&&this.fire(new t.n(`rollstart`,n)).fire(new t.n(`roll`,n)).fire(new t.n(`rollend`,n)),this.fire(new t.n(`moveend`,n))}calculateCameraOptionsFromTo(e,n,r,i=0){let a=t.a7.fromLngLat(e,n),o=t.a7.fromLngLat(r,i),s=o.x-a.x,c=o.y-a.y,l=o.z-a.z,u=Math.hypot(s,c,l);if(u===0)throw Error(`Can't calculate camera options with same From and To`);let d=Math.hypot(s,c),f=t.ar(this.transform.cameraToCenterDistance/u/this.transform.tileSize),p=180*Math.atan2(s,-c)/Math.PI,m=180*Math.acos(d/u)/Math.PI;return m=l<0?90-m:90+m,{center:o.toLngLat(),elevation:i,zoom:f,pitch:m,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,n,r,i){let a=this.transform.calculateCenterFromCameraLngLatAlt(e,t,n,r);return{center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:n,pitch:r,roll:i}}easeTo(e,n){this._stop(!1,e.easeId),`zoom`in(e=t.e({offset:[0,0],duration:500,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&s.prefersReducedMotion)&&(e.duration=0);let r=this._getTransformForUpdate(),i=this.getBearing(),a=r.pitch,o=r.roll,c=`bearing`in e?this._normalizeBearing(e.bearing,i):i,l=`pitch`in e?+e.pitch:a,u=`roll`in e?this._normalizeBearing(e.roll,o):o,d=`padding`in e?e.padding:r.padding,f=t.P.convert(e.offset),p,m;e.around&&(p=t.W.convert(e.around),m=r.locationToScreenPoint(p));let h={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(r,{bearing:c,pitch:l,roll:u,padding:d,around:p,aroundPoint:m,offsetAsPoint:f,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||=i!==c,this._pitching||=l!==a,this._rolling||=u!==o,this._padding=!r.isPaddingEqual(d),this._zooming||=g.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,h),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease((t=>{g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,t)}),e),this}_prepareEase(e,n,r={}){this._moving=!0,n||r.moving||this.fire(new t.n(`movestart`,e)),this._zooming&&!r.zooming&&this.fire(new t.n(`zoomstart`,e)),this._rotating&&!r.rotating&&this.fire(new t.n(`rotatestart`,e)),this._pitching&&!r.pitching&&this.fire(new t.n(`pitchstart`,e)),this._rolling&&!r.rolling&&this.fire(new t.n(`rollstart`,e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){let t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(n-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(t.H.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),n=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(n<r){let n=this.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:n.pitch,zoom:n.zoom}}return{}}_applyUpdatedTransform(e){let t=[];if(t.push((e=>this._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;let n=e.clone();for(let e of t){let t=n.clone(),{center:r,zoom:i,roll:a,pitch:o,bearing:s,elevation:c}=e(t);r&&t.setCenter(r),c!==void 0&&t.setElevation(c),i!==void 0&&t.setZoom(i),a!==void 0&&t.setRoll(a),o!==void 0&&t.setPitch(o),s!==void 0&&t.setBearing(s),n.apply(t,!1)}this.transform.apply(n,!1)}_fireMoveEvents(e){this.fire(new t.n(`move`,e)),this._zooming&&this.fire(new t.n(`zoom`,e)),this._rotating&&this.fire(new t.n(`rotate`,e)),this._pitching&&this.fire(new t.n(`pitch`,e)),this._rolling&&this.fire(new t.n(`roll`,e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.n(`zoomend`,e)),i&&this.fire(new t.n(`rotateend`,e)),a&&this.fire(new t.n(`pitchend`,e)),o&&this.fire(new t.n(`rollend`,e)),this.fire(new t.n(`moveend`,e))}flyTo(e,n){if(!e.essential&&s.prefersReducedMotion){let r=t.V(e,[`center`,`zoom`,`bearing`,`pitch`,`roll`,`elevation`,`padding`]);return this.jumpTo(r,n)}this.stop(),`zoom`in(e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));let r=this._getTransformForUpdate(),i=r.bearing,a=r.pitch,o=r.roll,c=r.padding,l=`bearing`in e?this._normalizeBearing(e.bearing,i):i,u=`pitch`in e?+e.pitch:a,d=`roll`in e?this._normalizeBearing(e.roll,o):o,f=`padding`in e?e.padding:r.padding,p=t.P.convert(e.offset),m=r.centerPoint.add(p),h=r.screenPointToLocation(m),g=this.cameraHelper.handleFlyTo(r,{bearing:l,pitch:u,roll:d,padding:f,locationAtOffset:h,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),_=e.curve,v=Math.max(r.width,r.height),y=v/g.scaleOfZoom,b=g.pixelPathLength;typeof g.scaleOfMinZoom==`number`&&(_=Math.sqrt(v/g.scaleOfMinZoom/b*2));let x=_*_;function S(e){let t=(y*y-v*v+(e?-1:1)*x*x*b*b)/(2*(e?y:v)*x*b);return Math.log(Math.sqrt(t*t+1)-t)}function C(e){return(Math.exp(e)-Math.exp(-e))/2}function w(e){return(Math.exp(e)+Math.exp(-e))/2}let T=S(!1),E=function(e){return w(T)/w(T+_*e)},D=function(e){return v*((w(T)*(C(t=T+_*e)/w(t))-C(T))/x)/b;var t},O=(S(!0)-T)/_;if(Math.abs(b)<2e-6||!isFinite(O)){if(Math.abs(v-y)<1e-6)return this.easeTo(e,n);let t=y<v?-1:1;O=Math.abs(Math.log(y/v))/_,D=()=>0,E=e=>Math.exp(t*_*e)}return e.duration=`duration`in e?+e.duration:1e3*O/(`screenSpeed`in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=i!==l,this._pitching=u!==a,this._rolling=d!==o,this._padding=!r.isPaddingEqual(f),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease((s=>{let h=s*O,_=1/E(h),v=D(h);this._rotating&&r.setBearing(t.H.number(i,l,s)),this._pitching&&r.setPitch(t.H.number(a,u,s)),this._rolling&&r.setRoll(t.H.number(o,d,s)),this._padding&&(r.interpolatePadding(c,f,s),m=r.centerPoint.add(p)),g.easeFunc(s,_,v,m),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var n;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||(n=this.handlers)==null||n.stop(!1),this}_ease(e,t,n){!1===n.animate||n.duration===0?(e(1),t()):(this._easeStart=l(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=t.X(e,-180,180);let r=Math.abs(e-n);return Math.abs(e-360-n)<r&&(e-=360),Math.abs(e+360-n)<r&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(t.W.convert(e),this.transform):null}}let eo={compact:!0,customAttribution:`<a href="https://maplibre.org/" target="_blank">MapLibre</a>`};class to{constructor(e=eo){this._toggleAttribution=()=>{this._container.classList.contains(`maplibregl-compact`)&&(this._container.classList.contains(`maplibregl-compact-show`)?(this._container.setAttribute(`open`,``),this._container.classList.remove(`maplibregl-compact-show`)):(this._container.classList.add(`maplibregl-compact-show`),this._container.removeAttribute(`open`)))},this._updateData=e=>{!e||e.sourceDataType!==`metadata`&&e.sourceDataType!==`visibility`&&e.dataType!==`style`&&e.type!==`terrain`||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute(`open`,``):this._container.classList.contains(`maplibregl-compact`)||this._container.classList.contains(`maplibregl-attrib-empty`)||(this._container.setAttribute(`open`,``),this._container.classList.add(`maplibregl-compact`,`maplibregl-compact-show`)):(this._container.setAttribute(`open`,``),this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.remove(`maplibregl-compact`,`maplibregl-compact-show`))},this._updateCompactMinimize=()=>{this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.contains(`maplibregl-compact-show`)&&this._container.classList.remove(`maplibregl-compact-show`)},this.options=e}getDefaultPosition(){return`bottom-right`}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=d.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=d.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=d.create(`div`,`maplibregl-ctrl-attrib-inner`,this._container),this._updateAttributions(),this._updateCompact(),this._map.on(`styledata`,this._updateData),this._map.on(`sourcedata`,this._updateData),this._map.on(`terrain`,this._updateData),this._map.on(`resize`,this._updateCompact),this._map.on(`drag`,this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off(`styledata`,this._updateData),this._map.off(`sourcedata`,this._updateData),this._map.off(`terrain`,this._updateData),this._map.off(`resize`,this._updateCompact),this._map.off(`drag`,this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let n=this._map._getUIString(`AttributionControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>typeof e==`string`?e:``))):typeof this.options.customAttribution==`string`&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.tileManagers;for(let n in t){let r=t[n];if(r.used||r.usedForTerrain){let t=r.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,n)=>{for(let r=n+1;r<e.length;r++)if(e[r].includes(t))return!1;return!0}));let n=e.join(` | `);n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=d.sanitize(n),this._container.classList.remove(`maplibregl-attrib-empty`)):this._container.classList.add(`maplibregl-attrib-empty`),this._updateCompact(),this._editLink=null)}}class no{constructor(e={}){this._updateCompact=()=>{let e=this._container.children;if(e.length){let t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add(`maplibregl-compact`):t.classList.remove(`maplibregl-compact`)}},this.options=e}getDefaultPosition(){return`bottom-left`}onAdd(e){this._map=e,this._compact=this.options?.compact,this._container=d.create(`div`,`maplibregl-ctrl`);let t=d.create(`a`,`maplibregl-ctrl-logo`);return t.target=`_blank`,t.rel=`noopener nofollow`,t.href=`https://maplibre.org/`,t.setAttribute(`aria-label`,this._map._getUIString(`LogoControl.Title`)),t.setAttribute(`rel`,`noopener nofollow`),this._container.appendChild(t),this._container.style.display=`block`,this._map.on(`resize`,this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off(`resize`,this._updateCompact),this._map=void 0,this._compact=void 0}}class ro{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(let t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let t=this._currentlyRunning=this._queue;this._queue=[];for(let n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var io=t.aS([{name:`a_pos3d`,type:`Int16`,components:3}]);class ao extends t.E{constructor(e){super(),this._lastTilesetChange=l(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,n){this.tileManager.update(e,n),this._renderableTilesKeys=[];let r={};for(let i of ze(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.terrainRttPosMatrix32f=new Float64Array(16),t.c7(i.terrainRttPosMatrix32f,0,t.a6,t.a6,0,0,1),this._tiles[i.key]=new Ee(i,this.tileSize),this._lastTilesetChange=l());for(let e in this._tiles)r[e]||delete this._tiles[e]}freeRtt(e){for(let t in this._tiles){let n=this._tiles[t];(!e||n.tileID.equals(e)||n.tileID.isChildOf(e)||e.isChildOf(n.tileID))&&(n.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let n={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=e.clone(),o=t.bj();if(i.canonical.equals(e.canonical))t.c7(o,0,t.a6,t.a6,0,0,1);else if(i.canonical.isChildOf(e.canonical)){let n=i.canonical.z-e.canonical.z,r=i.canonical.x-(i.canonical.x>>n<<n),a=i.canonical.y-(i.canonical.y>>n<<n),s=t.a6>>n;t.c7(o,0,s,s,0,0,1),t.Q(o,o,[-r*s,-a*s,0])}else{if(!e.canonical.isChildOf(i.canonical))continue;{let n=e.canonical.z-i.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n),a=e.canonical.y-(e.canonical.y>>n<<n),s=t.a6>>n;t.c7(o,0,t.a6,t.a6,0,0,1),t.Q(o,o,[r*s,a*s,0]),t.S(o,o,[1/2**n,1/2**n,0])}}a.terrainRttPosMatrix32f=new Float32Array(o),n[r]=a}return n}_getTerrainCoordsForTileRanges(e,n){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,n))continue;let o=e.clone(),s=t.bj();if(a.canonical.z===e.canonical.z){let n=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),r=e.canonical.y-a.canonical.y;t.c7(s,0,t.a6,t.a6,0,0,1),t.Q(s,s,[n*t.a6,r*t.a6,0])}else if(a.canonical.z>e.canonical.z){let n=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>n<<n)+e.wrap*(1<<a.canonical.z),i=a.canonical.y-(a.canonical.y>>n<<n),o=e.canonical.x-(a.canonical.x>>n),c=e.canonical.y-(a.canonical.y>>n),l=t.a6>>n;t.c7(s,0,l,l,0,0,1),t.Q(s,s,[-r*l+o*t.a6,-i*l+c*t.a6,0])}else{let n=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n)+e.wrap*(1<<e.canonical.z),i=e.canonical.y-(e.canonical.y>>n<<n),o=(e.canonical.x>>n)-a.canonical.x,c=(e.canonical.y>>n)-a.canonical.y,l=t.a6<<n;t.c7(s,0,l,l,0,0,1),t.Q(s,s,[r*t.a6+o*l,i*t.a6+c*l,0])}o.terrainRttPosMatrix32f=new Float32Array(s),r[i]=o}return r}getSourceTile(e,t){var n,r;let i=this.tileManager._source,a=e.overscaledZ-this.deltaZoom;if(a>i.maxzoom&&(a=i.maxzoom),a<i.minzoom)return;(n=this._sourceTileCache)[r=e.key]||(n[r]=e.scaledTo(a).key);let o=this.findTileInCaches(this._sourceTileCache[e.key]);if(!o?.dem&&t)for(;a>=i.minzoom&&!o?.dem;)o=this.findTileInCaches(e.scaledTo(a--).key);return o}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let n=t[e.canonical.z];return!!n&&(e.wrap>n.minWrap||e.wrap<n.maxWrap||e.canonical.x>=n.minTileXWrapped&&e.canonical.x<=n.maxTileXWrapped&&e.canonical.y>=n.minTileY&&e.canonical.y<=n.maxTileY)}}class oo{constructor(e,t,n){this._meshCache={},this.painter=e,this.tileManager=new ao(t),this.options=n,this.exaggeration=typeof n.exaggeration==`number`?n.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboCoordsTexture&&=(this._fboCoordsTexture.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._coordsTexture&&=(this._coordsTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,n,r,i=t.a6){let a=e.normalizeCoordinates(n,r,i);if(!a)return 0;let o=this.getTerrainData(a.tileID),s=o.tile?.dem;if(!s)return 0;let c=t.cC([],[a.x/i*t.a6,a.y/i*t.a6],o.u_terrain_matrix),l=[c[0]*s.dim,c[1]*s.dim],u=Math.floor(l[0]),d=Math.floor(l[1]),f=l[0]-u,p=l[1]-d;return s.get(u,d)*(1-f)*(1-p)+s.get(u+1,d)*f*(1-p)+s.get(u,d+1)*(1-f)*p+s.get(u+1,d+1)*f*p}getElevationForLngLatZoom(e,n){if(!t.cD(n,e.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(r,i%t.a6,a%t.a6,t.a6)}getElevationForLngLat(e,t){let n=ze(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),r=0;for(let e of n)e.canonical.z>r&&(r=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,r)}getElevation(e,n,r,i=t.a6){return this.getDEMElevation(e,n,r,i)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,n=new t.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new t.T(e,n,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new t.T(e,new t.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.ap([])}let n=this.tileManager.getSourceTile(e,!0);if(n?.dem&&(!n.demTexture||n.needsTerrainPrepare)){let e=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new t.T(e,n.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),n.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let r=n&&n.toString()+n.tileID.key+e.key;if(r&&!this._demMatrixCache[r]){let i=this.tileManager.getSource().maxzoom,a=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=i?a=e.canonical.z-i:t.w(`cannot calculate elevation if elevation maxzoom > source.maxzoom`));let o=e.canonical.x-(e.canonical.x>>a<<a),s=e.canonical.y-(e.canonical.y>>a<<a),c=t.cE(new Float64Array(16),[1/(t.a6<<a),1/(t.a6<<a),0]);t.Q(c,c,[o*t.a6,s*t.a6,0]),this._demMatrixCache[r]={matrix:c,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n?.dem?.dim||1,u_terrain_matrix:r?this._demMatrixCache[r].matrix:this._emptyDemMatrix,u_terrain_unpack:(n?.dem)?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){let n=this.painter,r=n.width/devicePixelRatio,i=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===r&&this._fbo.height===i||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(r,i,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,r,i))),this._fbo.colorAttachment.set(e===`coords`?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,t=0;e<this._coordsTextureSize;e++)for(let r=0;r<this._coordsTextureSize;r++,t+=4)n[t+0]=255&r,n[t+1]=255&e,n[t+2]=r>>8<<4|e>>8,n[t+3]=0;let r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),i=new t.T(e,r,e.gl.RGBA,{premultiply:!1});return i.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=i,i}pointCoordinate(e){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();let n=new Uint8Array(4),r=this.painter.context,i=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer(`coords`).framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,n),r.bindFramebuffer.set(null);let c=n[0]+(n[2]>>4<<8),l=n[1]+((15&n[2])<<8),u=this.coordsIndex[255-n[3]],d=u&&this.tileManager.getTileByID(u);if(!d)return null;let f=this._coordsTextureSize,p=(1<<d.tileID.canonical.z)*f;return new t.a7((d.tileID.canonical.x*f+c)/p+d.tileID.wrap,(d.tileID.canonical.y*f+l)/p,this.getElevation(d.tileID,c,l,f))}depthAtPoint(e){let t=new Uint8Array(4),n=this.painter.context,r=n.gl;return n.bindFramebuffer.set(this.getFramebuffer(`depth`).framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),n.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){let n=this.painter.style.projection?.transitionState>0,r=n&&e.canonical.y===0,i=n&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${r?`n`:``}_${i?`s`:``}`;if(this._meshCache[a])return this._meshCache[a];let o=this.painter.context,s=new t.cF,c=new t.aW,l=this.meshSize,u=t.a6/l,d=l*l;for(let e=0;e<=l;e++)for(let t=0;t<=l;t++)s.emplaceBack(t*u,e*u,0);for(let e=0;e<d;e+=l+1)for(let t=0;t<l;t++)c.emplaceBack(t+e,l+t+e+1,l+t+e+2),c.emplaceBack(t+e,l+t+e+2,t+e+1);let f=s.length,p=f+(l+1),m=(l+1)*l,h=r?t.bq:0,g=+!r,_=i?t.br:t.a6,v=+!i;for(let e=0;e<=l;e++)s.emplaceBack(e*u,h,g);for(let e=0;e<=l;e++)s.emplaceBack(e*u,_,v);for(let e=0;e<l;e++)c.emplaceBack(m+e,p+e,p+e+1),c.emplaceBack(m+e,p+e+1,m+e+1),c.emplaceBack(0+e,f+e+1,f+e),c.emplaceBack(0+e,0+e+1,f+e+1);let y=s.length,b=y+2*(l+1);for(let e of[0,1])for(let n=0;n<=l;n++)for(let r of[0,1])s.emplaceBack(e*t.a6,n*u,r);for(let e=0;e<2*l;e+=2)c.emplaceBack(y+e,y+e+1,y+e+3),c.emplaceBack(y+e,y+e+3,y+e+2),c.emplaceBack(b+e,b+e+3,b+e+1),c.emplaceBack(b+e,b+e+2,b+e+3);let x=new Ht(o.createVertexBuffer(s,io.members),o.createIndexBuffer(c),t.aV.simpleSegment(0,0,s.length,c.length));return this._meshCache[a]=x,x}getMeshFrameDelta(e){return 2*Math.PI*t.bD/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,n){if(!t.cD(n,e.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(e){let t=this.getTerrainData(e).tile,n={minElevation:null,maxElevation:null};return t!=null&&t.dem&&(n.minElevation=t.dem.min*this.exaggeration,n.maxElevation=t.dem.max*this.exaggeration),n}_getOverscaledTileIDFromLngLatZoom(e,n){let r=t.a7.fromLngLat(e.wrap()),i=(1<<n)*t.a6,a=r.x*i,o=r.y*i,s=Math.floor(a/t.a6),c=Math.floor(o/t.a6);return{tileID:new t.a3(n,0,n,s,c),mercatorX:a,mercatorY:o}}}class so{constructor(e,t,n){this._context=e,this._size=t,this._tileSize=n,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){let n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),r=new t.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return r.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(r.texture),{id:e,fbo:n,texture:r,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((t=>e.id!==t)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw Error(`No free RenderPool available, call freeAllObjects() required!`);let e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(let e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((e=>!e.inUse))}}let co={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class lo{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new so(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){var n;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((n=>!e._layers[n].isHidden(t))),this._coordsAscending={};for(let t in e.tileManagers){this._coordsAscending[t]={};let r=e.tileManagers[t].getVisibleCoordinates(),i=e.tileManagers[t].getSource(),a=i instanceof he?i.terrainTileRanges:null;for(let e of r){let r=this.terrain.tileManager.getTerrainCoords(e,a);for(let e in r)(n=this._coordsAscending[t])[e]||(n[e]=[]),this._coordsAscending[t][e].push(r[e])}}this._rttFingerprints={};for(let t of e._order){let n=e._layers[t],r=n.source;if(co[n.type]&&!this._rttFingerprints[r]){this._rttFingerprints[r]={};let t=e.tileManagers[r]?.getState().revision??0;for(let e in this._coordsAscending[r])this._rttFingerprints[r][e]=`${this._coordsAscending[r][e].map((e=>e.key)).sort().join()}#${t}`}}for(let e of this._renderableTiles)for(let t in this._rttFingerprints){let n=this._rttFingerprints[t][e.tileID.key];n&&n!==e.rttFingerprint[t]&&(e.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;let r=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),i=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(co[i]&&(this._prevType&&co[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(co[this._prevType]||co[i]&&o){this._prevType=i;let e=this._stacks.length-1,n=this._stacks[e]||[];for(let i of this._renderableTiles){if(this.pool.isFull()&&(Zi(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[e]){let t=this.pool.getObjectForId(i.rtt[e].id);if(t.stamp===i.rtt[e].stamp){this.pool.useObject(t);continue}}let o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),i.rtt[e]={id:o.id,stamp:o.stamp},a.context.bindFramebuffer.set(o.fbo.framebuffer),a.context.clear({color:t.bo.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e of n){let t=a.style._layers[e],n=t.source?this._coordsAscending[t.source][i.tileID.key]:[i.tileID];a.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),a._renderTileClippingMasks(t,n,!0),a.renderLayer(a,a.style.tileManagers[t.source],t,n,r),t.source&&(i.rttFingerprint[t.source]=this._rttFingerprints[t.source][i.tileID.key])}}return Zi(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),co[i]}return!1}}let uo={"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":`MapLibre logo`,"Map.Title":`Map`,"Marker.Title":`Map marker`,"NavigationControl.ResetBearing":`Drag to rotate map, click to reset north`,"NavigationControl.ZoomIn":`Zoom in`,"NavigationControl.ZoomOut":`Zoom out`,"Popup.Close":`Close popup`,"ScaleControl.Feet":`ft`,"ScaleControl.Meters":`m`,"ScaleControl.Kilometers":`km`,"ScaleControl.Miles":`mi`,"ScaleControl.NauticalMiles":`nm`,"GlobeControl.Enable":`Enable globe`,"GlobeControl.Disable":`Disable globe`,"TerrainControl.Enable":`Enable terrain`,"TerrainControl.Disable":`Disable terrain`,"CooperativeGesturesHandler.WindowsHelpText":`Use Ctrl + scroll to zoom the map`,"CooperativeGesturesHandler.MacHelpText":`Use ⌘ + scroll to zoom the map`,"CooperativeGesturesHandler.MobileHelpText":`Use two fingers to move the map`},fo=n,po={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:eo,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:`high-performance`,failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:t.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:`sans-serif`,pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0,anisotropicFilterPitch:20},mo=class extends $a{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(e){var n;let r=Object.assign(Object.assign(Object.assign({},po),e),{canvasContextAttributes:Object.assign(Object.assign({},po.canvasContextAttributes),e.canvasContextAttributes)});if(r.minZoom!=null&&r.maxZoom!=null&&r.minZoom>r.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(r.minPitch!=null&&r.maxPitch!=null&&r.minPitch>r.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(r.minPitch!=null&&r.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(r.maxPitch!=null&&r.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);let i=new en,a=new an;r.minZoom!==void 0&&i.setMinZoom(r.minZoom),r.maxZoom!==void 0&&i.setMaxZoom(r.maxZoom),r.minPitch!==void 0&&i.setMinPitch(r.minPitch),r.maxPitch!==void 0&&i.setMaxPitch(r.maxPitch),r.renderWorldCopies!==void 0&&i.setRenderWorldCopies(r.renderWorldCopies),r.transformConstrain!==null&&i.setConstrainOverride(r.transformConstrain),super(i,a,{bearingSnap:r.bearingSnap,zoomSnap:r.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ro,this._controls=[],this._mapId=t.ad(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(let e of Object.values(this.style._layers))if(e.type===`custom`&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(let[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new t.n(`webglcontextlost`,{originalEvent:e}))}else this.fire(new t.n(`webglcontextlost`,{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new t.n(`webglcontextrestored`,{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._zoomSnap=r.zoomSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},uo),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this._zoomLevelsToOverscale=r.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=r.transformCameraUpdate,this.transformConstrain=r.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(r.anisotropicFilterPitch),r.reduceMotion!==void 0&&(s.prefersReducedMotion=r.reduceMotion),this._imageQueueHandle=u.addThrottleControl((()=>this.isMoving())),this._requestManager=new f(r.transformRequest),this._container=this._resolveContainer(r.container),r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on(`move`,(()=>this._update(!1))),this.on(`moveend`,(()=>this._update(!1))),this.on(`zoom`,(()=>this._update(!0))),this.on(`terrain`,(()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)})),this.once(`idle`,(()=>this._idleTriggered=!0)),typeof window<`u`&&(this._ownerWindow.addEventListener(`online`,this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Qa(this,r),this._hash=r.hash?new na(typeof r.hash==`string`&&r.hash||void 0).addTo(this):void 0,(n=this._hash)!=null&&n._onHashChange()||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));let o=typeof r.style==`string`||r.style?.projection?.type!==`globe`;this.resize(null,o),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new to(typeof r.attributionControl==`boolean`?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new no,r.logoPosition),this.on(`style.load`,(()=>{if(o||this._resizeTransform(),this.transform.unmodified){let e=t.V(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(e)}})),this.on(`data`,(e=>{this._update(e.dataType===`style`),this.fire(new t.n(`${e.dataType}data`,e))})),this.on(`dataloading`,(e=>{this.fire(new t.n(`${e.dataType}dataloading`,e))})),this.on(`dataabort`,(e=>{this.fire(new t.n(`sourcedataabort`,e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,n){if(n===void 0&&(n=e.getDefaultPosition?e.getDefaultPosition():`top-right`),!e?.onAdd)return this.fire(new t.l(Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let r=e.onAdd(this);this._controls.push(e);let i=this._controlPositions[n];return n.includes(`bottom`)?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(e){if(!e?.onRemove)return this.fire(new t.l(Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return ze(this.transform,e)}calculateCameraOptionsFromTo(e,t,n,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLat(n,this.transform)),super.calculateCameraOptionsFromTo(e,t,n,r)}resize(e,n=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(n);let r=!this._moving;return r&&(this.stop(),this.fire(new t.n(`movestart`,e)).fire(new t.n(`move`,e))),this.fire(new t.n(`resize`,e)),r&&this.fire(new t.n(`moveend`,e)),this}_resizeInternal(e=!0){let[t,n]=this._containerDimensions(),r=this._getClampedPixelRatio(t,n);if(this._resizeCanvas(t,n,r),this.painter.resize(t,n,r),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let r=this._getClampedPixelRatio(t,n);this._resizeCanvas(t,n,r),this.painter.resize(t,n,r)}this._resizeTransform(e)}_resizeTransform(e=!0){var t;let[n,r]=this._containerDimensions();this.transform.resize(n,r,e),(t=this._requestedCameraState)==null||t.resize(n,r,e)}_getClampedPixelRatio(e,t){let{0:n,1:r}=this._maxCanvasSize,i=this.getPixelRatio(),a=e*i,o=t*i;return Math.min(a>n?n/a:1,o>r?r/o:1)*i}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(re.convert(e)),this._update()}setMinZoom(e){if((e??=-2)>=-2&&e<=this.transform.maxZoom){let n=this.transform.zoom,r=this._getTransformForUpdate();return r.setMinZoom(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.zoom&&this.fire(new t.n(`zoomstart`)).fire(new t.n(`zoom`)).fire(new t.n(`zoomend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e??=22)>=this.transform.minZoom){let n=this.transform.zoom,r=this._getTransformForUpdate();return r.setMaxZoom(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.zoom&&this.fire(new t.n(`zoomstart`)).fire(new t.n(`zoom`)).fire(new t.n(`zoomend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e??=0)<0)throw Error(`minPitch must be greater than or equal to 0`);if(e>=0&&e<=this.transform.maxPitch){let n=this.transform.pitch,r=this._getTransformForUpdate();return r.setMinPitch(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.pitch&&this.fire(new t.n(`pitchstart`)).fire(new t.n(`pitch`)).fire(new t.n(`pitchend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e??=60)>180)throw Error(`maxPitch must be less than or equal to 180`);if(e>=this.transform.minPitch){let n=this.transform.pitch,r=this._getTransformForUpdate();return r.setMaxPitch(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.pitch&&this.fire(new t.n(`pitchstart`)).fire(new t.n(`pitch`)).fire(new t.n(`pitchend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e??=20)>180)throw Error(`anisotropicFilterPitch must be less than or equal to 180`);if(e<0)throw Error(`anisotropicFilterPitch must be greater than or equal to 0`);return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.W.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){return this._moving||this.handlers?.isMoving()}isZooming(){return this._zooming||this.handlers?.isZooming()}isRotating(){return this._rotating||this.handlers?.isRotating()}_createDelegatedListener(e,t,n){if(e===`mouseenter`||e===`mouseover`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e))),o=a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a});o.length?r||(r=!0,n.call(this,new fa(e,this,i.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}}if(e===`mouseleave`||e===`mouseout`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e)));(a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a})).length?r=!0:r&&(r=!1,n.call(this,new fa(e,this,i.originalEvent)))},mouseout:t=>{r&&(r=!1,n.call(this,new fa(e,this,t.originalEvent)))}}}}{let r=e=>{let r=t.filter((e=>this.getLayer(e))),i=r.length===0?[]:this.queryRenderedFeatures(e.point,{layers:r});i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:t,listener:n,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){var n;this._delegatedListeners||={},(n=this._delegatedListeners)[e]||(n[e]=[]),this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,n){if(!this._delegatedListeners?.[e])return;let r=this._delegatedListeners[e];for(let e=0;e<r.length;e++){let i=r[e];if(i.listener===n&&i.layers.length===t.length&&i.layers.every((e=>t.includes(e)))){for(let e in i.delegates)this.off(e,i.delegates[e]);r.splice(e,1);return}}}on(e,t,n){if(n===void 0)return super.on(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);this._saveDelegatedListener(e,i);for(let e in i.delegates)this.on(e,i.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,n)}}}once(e,t,n){if(n===void 0)return super.once(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);for(let t in i.delegates){let a=i.delegates[t];i.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,n),a(...t)}}this._saveDelegatedListener(e,i);for(let e in i.delegates)this.once(e,i.delegates[e]);return this}off(e,t,n){return n===void 0?super.off(e,t):(this._removeDelegatedListener(e,typeof t==`string`?[t]:t,n),this)}queryRenderedFeatures(e,n){if(!this.style)return[];let r,i=e instanceof t.P||Array.isArray(e),a=i?e:[[0,0],[this.transform.width,this.transform.height]];if(n||=(i?{}:e)||{},a instanceof t.P||typeof a[0]==`number`)r=[t.P.convert(a)];else{let e=t.P.convert(a[0]),n=t.P.convert(a[1]);r=[e,new t.P(n.x,e.y),n,new t.P(e.x,n.y),e]}return this.style.queryRenderedFeatures(r,n,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,n){return!1!==(n=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n)).diff&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(e,n))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var n,r;if((n=this._diffStyleRequest)==null||n.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once(`style.load`,(()=>this._updateStyle(e,t)));let i=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Hn(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof e==`string`?this.style.loadURL(e,t,i):this.style.loadJSON(e,t,i),this):(this._frameRequest&&=(this._frameRequest.abort(),null),(r=this.style?.projection)==null||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Hn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,n){return t._(this,void 0,void 0,(function*(){var r;if((r=this._diffStyleRequest)==null||r.abort(),typeof e==`string`){let r=e;this._diffStyleRequest=new AbortController;let i=this._diffStyleRequest;try{let e=yield this._requestManager.transformRequest(r,`Style`);if(i.signal.aborted)return void(this._diffStyleRequest=null);let a=yield t.k(e,i);this._diffStyleRequest=null,this._updateDiff(a.data,n)}catch(e){this._diffStyleRequest=null,t.$(e)||this.fire(new t.l(t.d(e)))}}else typeof e==`object`&&(this._diffStyleRequest=null,this._updateDiff(e,n))}))}_updateDiff(e,n){try{this.style.setState(e,n)&&this._update(!0)}catch(r){t.w(`Unable to perform style diff: ${t.d(r).message}. Rebuilding the style from scratch.`),this._updateStyle(e,n)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();t.w(`There is no style added to the map.`)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let n=this.style?.tileManagers[e];if(n!==void 0)return n.loaded();this.fire(new t.l(Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),e){let n=this.style.tileManagers[e.source];if(!n)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&n.reload();for(let n in this.style._layers){let r=this.style._layers[n];r.type===`hillshade`&&r.source===e.source&&t.w(`You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`),r.type===`color-relief`&&r.source===e.source&&t.w(`You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`)}this.terrain=new oo(this.painter,n,e),this.painter.renderToTexture=new lo(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{t.dataType===`style`?this.terrain.tileManager.freeRtt():t.dataType===`source`&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),t.source?.type===`image`?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on(`data`,this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.n(`terrain`,{terrain:e})),this}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style?.tileManagers;for(let t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,n){if(n){let r=this.getSource(n);if(!r)throw Error(`There is no source with ID "${n}", cannot set LOD parameters`);r.calculateTileZoom=Ie(Math.max(1,e),Math.max(1,t))}else for(let n in this.style.tileManagers)this.style.tileManagers[n].getSource().calculateTileZoom=Ie(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,n){let r=this.style.tileManagers[e];if(!r)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);n===void 0?r.reload(!0):r.refreshTiles(n.map((e=>new t.aa(e.z,e.x,e.y))))}addImage(e,n,r={}){let{pixelRatio:i=1,sdf:a=!1,stretchX:o,stretchY:c,content:l,textFitWidth:u,textFitHeight:d}=r;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||t.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new t.l(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`")));{let{width:r,height:s,data:f}=n,p=n;return this.style.addImage(e,{data:new t.R({width:r,height:s},new Uint8Array(f)),pixelRatio:i,stretchX:o,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{let{width:r,height:f,data:p}=s.getImageData(n);this.style.addImage(e,{data:new t.R({width:r,height:f},p),pixelRatio:i,stretchX:o,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0})}}updateImage(e,n){let r=this.style.getImage(e);if(!r)return this.fire(new t.l(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:o}=n instanceof HTMLImageElement||t.b(n)?s.getImageData(n):n;if(i===void 0||a===void 0)return this.fire(new t.l(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`")));if(i!==r.data.width||a!==r.data.height)return this.fire(new t.l(Error(`The width and height of the updated image must be that same as the previous version of the image`)));let c=!(n instanceof HTMLImageElement||t.b(n));return r.data.replace(o,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.l(Error(`Missing required image id`))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return t._(this,void 0,void 0,(function*(){return u.getImage(yield this._requestManager.transformRequest(e,`Image`),new AbortController)}))}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)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,n,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0)})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}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)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupResizeObserver(){let e=!1,t=ta((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50),n=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new n((n=>{e?t(n):e=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(e){if(typeof e==`string`){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&typeof e==`object`&&e.nodeType===1)return e;throw Error(`Invalid type: 'container' must be a String or HTMLElement.`)}_setupContainer(){let e=this._container;e.classList.add(`maplibregl-map`);let t=this._canvasContainer=d.create(`div`,`maplibregl-canvas-container`,e);this._interactive&&t.classList.add(`maplibregl-interactive`),this._canvas=d.create(`canvas`,`maplibregl-canvas`,t),this._canvas.addEventListener(`webglcontextlost`,this._contextLost,!1),this._canvas.addEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.setAttribute(`tabindex`,this._interactive?`0`:`-1`),this._canvas.setAttribute(`aria-label`,this._getUIString(`Map.Title`)),this._canvas.setAttribute(`role`,`region`);let n=this._containerDimensions(),r=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],r);let i=this._controlContainer=d.create(`div`,`maplibregl-control-container`,e),a=this._controlPositions={};for(let e of[`top-left`,`top-right`,`bottom-left`,`bottom-right`])a[e]=d.create(`div`,`maplibregl-ctrl-${e} `,i);this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_resizeCanvas(e,t,n){this._canvas.width=Math.floor(n*e),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0}),t=null;this._canvas.addEventListener(`webglcontextcreationerror`,(n=>{t={requestedAttributes:e},n&&(t.statusMessage=n.statusMessage,t.type=n.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext(`webgl2`,e)||this._canvas.getContext(`webgl`,e),!n){let e=`Failed to initialize WebGL`;throw t?(t.message=e,Error(JSON.stringify(t))):Error(e)}this.painter=new ea(n,this.transform)}migrateProjection(e,n){super.migrateProjection(e,n),this.painter.transform=e,this.fire(new t.n(`projectiontransition`,{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?._loaded?(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)}_render(e){var n;let r=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let a=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this.transform.zoom,n=l();this.style.zoomHistory.update(e,n);let i=new t.J(e,{now:n,fadeDuration:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=i.crossFadingFactor();o===1&&o===this._crossFadingFactor||(a=!0,this._crossFadingFactor=o),this.style.update(i)}let o=this.style.projection?.transitionState>0!==i;(n=this.style.projection)==null||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(this.style.projection?.transitionState,this.style.projection?.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||o)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this.transform,this.showCollisionBoxes,r,this._crossSourceCollisions,o),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:r,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new t.n(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.n(`load`))),this.style&&(this.style.hasTransitions()||a)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.n(`idle`)),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){var e,n;this._hash&&this._hash.remove();for(let e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),(e=this._diffStyleRequest)==null||e.abort(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<`u`&&this._ownerWindow.removeEventListener(`online`,this._onWindowOnline,!1),u.removeThrottleControl(this._imageQueueHandle),(n=this._resizeObserver)==null||n.disconnect();let r=this.painter.context.gl.getExtension(`WEBGL_lose_context`);r!=null&&r.loseContext&&r.loseContext(),this._canvas.removeEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.removeEventListener(`webglcontextlost`,this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener(`scroll`,this._onMapScroll,!1),this._container.classList.remove(`maplibregl-map`),this._removed=!0,this.fire(new t.n(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!t.$(e)&&!function(e){return e.message===fi}(e))throw e}}),(()=>{}),this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=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()}get version(){return fo}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},ho={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class go{constructor(e,n,r=!1){this.mousedown=e=>{this.startMove(e,d.mousePos(this.element,e)),window.addEventListener(`mousemove`,this.mousemove),window.addEventListener(`mouseup`,this.mouseup)},this.mousemove=e=>{this.move(e,d.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{e.targetTouches.length===1?(this._startPos=this._lastPos=d.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener(`touchmove`,this.touchmove,{passive:!1}),window.addEventListener(`touchend`,this.touchend)):this.reset()},this.touchmove=e=>{e.targetTouches.length===1?(this._lastPos=d.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{e.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;let i=new Ea;this._rotatePitchHandler=new Sa({clickTolerance:3,move:(e,i)=>{let a=n.getBoundingClientRect(),o=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return{bearingDelta:t.cx(new t.P(e.x,i.y),i,o),pitchDelta:r?-.5*(i.y-e.y):void 0}},moveStateManager:i,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(`mousedown`,this.mousedown),n.addEventListener(`touchstart`,this.touchstart,{passive:!1}),n.addEventListener(`touchcancel`,this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),d.disableDrag()}move(e,t){let n=this.map,{bearingDelta:r,pitchDelta:i}=this._rotatePitchHandler.dragMove(e,t)||{};r&&n.setBearing(n.getBearing()+r),i&&n.setPitch(n.getPitch()+i)}off(){let e=this.element;e.removeEventListener(`mousedown`,this.mousedown),e.removeEventListener(`touchstart`,this.touchstart),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend),e.removeEventListener(`touchcancel`,this.reset),this.offTemp()}offTemp(){d.enableDrag(),window.removeEventListener(`mousemove`,this.mousemove),window.removeEventListener(`mouseup`,this.mouseup),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend)}}let _o;function vo(e,n,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let a=new t.W(e.lng,e.lat);if(e=new t.W(e.lng,e.lat),n){let i=new t.W(e.lng-360,e.lat),a=new t.W(e.lng+360,e.lat),o=r.locationToScreenPoint(e).distSqr(n);r.locationToScreenPoint(i).distSqr(n)<o?e=i:r.locationToScreenPoint(a).distSqr(n)<o&&(e=a)}for(;Math.abs(e.lng-r.center.lng)>180;){let t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}let yo={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%)`};function bo(e,t,n){let r=e.classList;for(let e in yo)r.remove(`maplibregl-${n}-anchor-${e}`);r.add(`maplibregl-${n}-anchor-${t}`)}class xo extends t.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new t.n(`click`,{originalEvent:e}))},this._onKeyPress=e=>{e.code!==`Space`&&e.code!==`Enter`||this.togglePopup()},this._onMapClick=e=>{let t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;let t=this._map.loaded()&&!this._map.isMoving();(e?.type===`terrain`||e?.type===`render`&&!t)&&this._map.once(`render`,this._update),this._lngLat=vo(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let n=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?n=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?r=`rotateX(0deg)`:this._pitchAlignment===`map`&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&e.type!==`moveend`||(this._pos=this._pos.round()),this._element.style.transform=`${yo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${n}`,s.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity(e?.type===`moveend`)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){let t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents=`none`,this._state===`pending`&&(this._state=`active`,this.fire(new t.n(`dragstart`))),this.fire(new t.n(`drag`)))},this._onUp=()=>{this._element.style.pointerEvents=`auto`,this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),this._state===`active`&&this.fire(new t.n(`dragend`)),this._state=`inactive`},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state=`pending`,this._map.on(`mousemove`,this._onMove),this._map.on(`touchmove`,this._onMove),this._map.once(`mouseup`,this._onUp),this._map.once(`touchend`,this._onUp))},this._anchor=e?.anchor||`center`,this._color=e?.color||`#3FB1CE`,this._scale=e?.scale||1,this._draggable=e?.draggable||!1,this._clickTolerance=e?.clickTolerance||0,this._subpixelPositioning=e?.subpixelPositioning||!1,this._isDragging=!1,this._state=`inactive`,this._rotation=e?.rotation||0,this._rotationAlignment=e?.rotationAlignment||`auto`,this._pitchAlignment=e?.pitchAlignment&&e.pitchAlignment!==`auto`?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e?.element)this._element=e.element,this._offset=t.P.convert(e?.offset||[0,0]);else{this._defaultMarker=!0,this._element=d.create(`div`);let n=d.createNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttributeNS(null,`display`,`block`),n.setAttributeNS(null,`height`,`41px`),n.setAttributeNS(null,`width`,`27px`),n.setAttributeNS(null,`viewBox`,`0 0 27 41`);let r=d.createNS(`http://www.w3.org/2000/svg`,`g`);r.setAttributeNS(null,`stroke`,`none`),r.setAttributeNS(null,`stroke-width`,`1`),r.setAttributeNS(null,`fill`,`none`),r.setAttributeNS(null,`fill-rule`,`evenodd`);let i=d.createNS(`http://www.w3.org/2000/svg`,`g`);i.setAttributeNS(null,`fill-rule`,`nonzero`);let a=d.createNS(`http://www.w3.org/2000/svg`,`g`);a.setAttributeNS(null,`transform`,`translate(3.0, 29.0)`),a.setAttributeNS(null,`fill`,`#000000`);for(let e of[{rx:`10.5`,ry:`5.25002273`},{rx:`10.5`,ry:`5.25002273`},{rx:`9.5`,ry:`4.77275007`},{rx:`8.5`,ry:`4.29549936`},{rx:`7.5`,ry:`3.81822308`},{rx:`6.5`,ry:`3.34094679`},{rx:`5.5`,ry:`2.86367051`},{rx:`4.5`,ry:`2.38636864`}]){let t=d.createNS(`http://www.w3.org/2000/svg`,`ellipse`);t.setAttributeNS(null,`opacity`,`0.04`),t.setAttributeNS(null,`cx`,`10.5`),t.setAttributeNS(null,`cy`,`5.80029008`),t.setAttributeNS(null,`rx`,e.rx),t.setAttributeNS(null,`ry`,e.ry),a.appendChild(t)}let o=d.createNS(`http://www.w3.org/2000/svg`,`g`);o.setAttributeNS(null,`fill`,this._color);let s=d.createNS(`http://www.w3.org/2000/svg`,`path`);s.setAttributeNS(null,`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`),o.appendChild(s);let c=d.createNS(`http://www.w3.org/2000/svg`,`g`);c.setAttributeNS(null,`opacity`,`0.25`),c.setAttributeNS(null,`fill`,`#000000`);let l=d.createNS(`http://www.w3.org/2000/svg`,`path`);l.setAttributeNS(null,`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`),c.appendChild(l);let u=d.createNS(`http://www.w3.org/2000/svg`,`g`);u.setAttributeNS(null,`transform`,`translate(6.0, 7.0)`),u.setAttributeNS(null,`fill`,`#FFFFFF`);let f=d.createNS(`http://www.w3.org/2000/svg`,`g`);f.setAttributeNS(null,`transform`,`translate(8.0, 8.0)`);let p=d.createNS(`http://www.w3.org/2000/svg`,`circle`);p.setAttributeNS(null,`fill`,`#000000`),p.setAttributeNS(null,`opacity`,`0.25`),p.setAttributeNS(null,`cx`,`5.5`),p.setAttributeNS(null,`cy`,`5.5`),p.setAttributeNS(null,`r`,`5.4999962`);let m=d.createNS(`http://www.w3.org/2000/svg`,`circle`);m.setAttributeNS(null,`fill`,`#FFFFFF`),m.setAttributeNS(null,`cx`,`5.5`),m.setAttributeNS(null,`cy`,`5.5`),m.setAttributeNS(null,`r`,`5.4999962`),f.appendChild(p),f.appendChild(m),i.appendChild(a),i.appendChild(o),i.appendChild(c),i.appendChild(u),i.appendChild(f),n.appendChild(i),n.setAttributeNS(null,`height`,41*this._scale+`px`),n.setAttributeNS(null,`width`,27*this._scale+`px`),this._element.appendChild(n),this._offset=t.P.convert(e?.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,(e=>{e.preventDefault()})),this._element.addEventListener(`mousedown`,(e=>{e.preventDefault()})),bo(this._element,this._anchor,`marker`),e?.className)for(let t of e.className.split(` `))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute(`aria-label`)||this._element.setAttribute(`aria-label`,e._getUIString(`Marker.Title`)),this._element.hasAttribute(`role`)||this._element.setAttribute(`role`,`button`),e.getCanvasContainer().appendChild(this._element),e.on(`move`,this._update),e.on(`moveend`,this._update),e.on(`terrain`,this._update),e.on(`projectiontransition`,this._update),this._element.addEventListener(`click`,this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on(`click`,this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off(`click`,this._onMapClick),this._map.off(`move`,this._update),this._map.off(`moveend`,this._update),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler),this._map.off(`mouseup`,this._onUp),this._map.off(`touchend`,this._onUp),this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),delete this._map),this._element.removeEventListener(`click`,this._onClick),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener(`keypress`,this._onKeyPress),this._originalTabIndex||this._element.removeAttribute(`tabindex`)),e){if(!(`offset`in e.options)){let t=38.1,n=13.5,r=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-13.5,-1*(t-n)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute(`tabindex`),this._originalTabIndex||this._element.setAttribute(`tabindex`,`0`),this._element.addEventListener(`keypress`,this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered||e&&(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map))),this}_updateOpacity(e=!1){var n;let r=this._map?.terrain,i=this._map.transform.isLocationOccluded(this._lngLat);if(!r||i){let e=i?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle(`maplibregl-marker-covered`,i));return}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}let a=this._map,o=a.terrain.depthAtPoint(this._pos),s=a.terrain.getElevationForLngLat(this._lngLat,a.transform);if(a.transform.lngLatToCameraDepth(this._lngLat,s)-o<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove(`maplibregl-marker-covered`);let c=-this._offset.y/a.transform.pixelsPerMeter,l=Math.sin(a.getPitch()*Math.PI/180)*c,u=a.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=a.transform.lngLatToCameraDepth(this._lngLat,s+l)-u>.006;(n=this._popup)!=null&&n.isOpen()&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity,this._element.classList.toggle(`maplibregl-marker-covered`,d)}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on(`mousedown`,this._addDragHandler),this._map.on(`touchstart`,this._addDragHandler)):(this._map.off(`mousedown`,this._addDragHandler),this._map.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 this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!==`auto`?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),e!==void 0&&(this._opacity=String(e)),t!==void 0&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}}let So={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Co=0,wo=!1,To={maxWidth:100,unit:`metric`};function Eo(e,t,n){let r=n?.maxWidth||100,i=e._container.clientHeight/2,a=e._container.clientWidth/2,o=e.unproject([a-r/2,i]),s=e.unproject([a+r/2,i]),c=Math.round(e.project(s).x-e.project(o).x),l=Math.min(r,c,e._container.clientWidth),u=o.distanceTo(s);if(n?.unit===`imperial`){let n=3.2808*u;n>5280?Do(t,l,n/5280,e._getUIString(`ScaleControl.Miles`)):Do(t,l,n,e._getUIString(`ScaleControl.Feet`))}else n?.unit===`nautical`?Do(t,l,u/1852,e._getUIString(`ScaleControl.NauticalMiles`)):u>=1e3?Do(t,l,u/1e3,e._getUIString(`ScaleControl.Kilometers`)):Do(t,l,u,e._getUIString(`ScaleControl.Meters`))}function Do(e,t,n,r){let i=function(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}(n),t*n}(n);e.style.width=i/n*t+`px`,e.innerHTML=`${i} ${r}`}let Oo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},ko=[`a[href]`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable]:not([contenteditable='false'])`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].join(`, `);function Ao(e){if(e){if(typeof e==`number`){let n=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(n,n),"top-right":new t.P(-n,n),bottom:new t.P(0,-e),"bottom-left":new t.P(n,-n),"bottom-right":new t.P(-n,-n),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){let n=t.P.convert(e);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e[`top-left`]||[0,0]),"top-right":t.P.convert(e[`top-right`]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e[`bottom-left`]||[0,0]),"bottom-right":t.P.convert(e[`bottom-right`]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Ao(new t.P(0,0))}let jo=n;e.AJAXError=t.cG,e.EXTENT=t.a6,e.Event=t.n,e.Evented=t.E,e.LngLat=t.W,e.MercatorCoordinate=t.a7,e.Point=t.P,e.addProtocol=t.cH,e.config=t.c,e.removeProtocol=t.cI,e.AttributionControl=to,e.BoxZoomHandler=va,e.CanvasSource=_e,e.CooperativeGesturesHandler=Ja,e.DoubleClickZoomHandler=Ha,e.DragPanHandler=Ga,e.DragRotateHandler=Ka,e.EdgeInsets=qt,e.FullscreenControl=class extends t.E{constructor(e={}){var n;super(),this._onFullscreenChange=()=>{let e=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;e?.shadowRoot?.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=(n=e.pseudo)!=null&&n,e!=null&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w(`Full screen control 'container' must be a DOM element.`)),`onfullscreenchange`in document?this._fullscreenchange=`fullscreenchange`:`onmozfullscreenchange`in document?this._fullscreenchange=`mozfullscreenchange`:`onwebkitfullscreenchange`in document?this._fullscreenchange=`webkitfullscreenchange`:`onmsfullscreenchange`in document&&(this._fullscreenchange=`MSFullscreenChange`)}onAdd(e){return this._map=e,this._container||=this._map.getContainer(),this._controlContainer=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=d.create(`button`,`maplibregl-ctrl-fullscreen`,this._controlContainer);d.create(`span`,`maplibregl-ctrl-icon`,e).setAttribute(`aria-hidden`,`true`),e.type=`button`,this._updateTitle(),this._fullscreenButton.addEventListener(`click`,this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute(`aria-label`,e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?`FullscreenControl.Exit`:`FullscreenControl.Enter`)}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(`maplibregl-ctrl-shrink`),this._fullscreenButton.classList.toggle(`maplibregl-ctrl-fullscreen`),this._updateTitle(),this._fullscreen?(this.fire(new t.n(`fullscreenstart`)),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.n(`fullscreenend`)),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle(`maplibregl-pseudo-fullscreen`),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=me,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.n(`outofmaxbounds`,e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`BACKGROUND`:case`BACKGROUND_ERROR`:this._watchState=`BACKGROUND`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`);break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!==`OFF`&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!==`ACTIVE_LOCK`||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove(`maplibregl-user-location-dot-stale`),this.fire(new t.n(`geolocate`,e)),this._finish()}},this._updateCamera=e=>{let n=new t.W(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,i=this._map.getBearing(),a=t.e({bearing:i},this.options.fitBoundsOptions),o=re.fromLngLat(n,r);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let n=new t.W(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(e.code===1){this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.disabled=!0;let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&wo)return;this._setErrorState()}this._watchState!==`OFF`&&this.options.showUserLocation&&this._dotElement.classList.add(`maplibregl-user-location-dot-stale`),this.fire(new t.n(`error`,e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=e=>{if(!this._map)return;let n=e?.[0]instanceof ResizeObserverEntry;e.geolocateSource||this._watchState!==`ACTIVE_LOCK`||n||this._map.isZooming()||(this._watchState=`BACKGROUND`,this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this.fire(new t.n(`trackuserlocationend`)),this.fire(new t.n(`userlocationlostfocus`)))},this._setupUI=()=>{this._map&&(this._container.addEventListener(`contextmenu`,(e=>{e.preventDefault()})),this._geolocateButton=d.create(`button`,`maplibregl-ctrl-geolocate`,this._container),d.create(`span`,`maplibregl-ctrl-icon`,this._geolocateButton).setAttribute(`aria-hidden`,`true`),this._geolocateButton.type=`button`,this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w(`Geolocation support is not available so the GeolocateControl will be disabled.`);let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}else{let e=this._map._getUIString(`GeolocateControl.FindMyLocation`);this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute(`aria-pressed`,`false`),this._watchState=`OFF`),this.options.showUserLocation&&(this._dotElement=d.create(`div`,`maplibregl-user-location-dot`),this._userLocationDotMarker=new xo({element:this._dotElement}),this._circleElement=d.create(`div`,`maplibregl-user-location-accuracy-circle`),this._accuracyCircleMarker=new xo({element:this._circleElement,pitchAlignment:`map`}),this.options.trackUserLocation&&(this._watchState=`OFF`),this._map.on(`zoom`,this._onUpdate),this._map.on(`move`,this._onUpdate),this._map.on(`rotate`,this._onUpdate),this._map.on(`pitch`,this._onUpdate)),this._geolocateButton.addEventListener(`click`,(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on(`movestart`,this._onMoveStart)}},this.options=t.e({},So,e)}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(_o!==void 0&&!e)return _o;if(window.navigator.permissions===void 0)return _o=!!window.navigator.geolocation,_o;try{_o=(yield window.navigator.permissions.query({name:`geolocation`})).state!==`denied`}catch{_o=!!window.navigator.geolocation}return _o}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.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(`movestart`,this._onMoveStart),this._map.off(`zoom`,this._onUpdate),this._map.off(`move`,this._onUpdate),this._map.off(`rotate`,this._onUpdate),this._map.off(`pitch`,this._onUpdate),this._map=void 0,Co=0,wo=!1}_isOutOfMapMaxBounds(e){let t=this._map.getMaxBounds(),n=e.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case`WAITING_ACTIVE`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`);break;case`ACTIVE_LOCK`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`BACKGROUND`:this._watchState=`BACKGROUND_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:case`OFF`:case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;let t=this._map.project(e),n=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(n)/100,i=2*this._accuracy/r;this._circleElement.style.width=`${i.toFixed(2)}px`,this._circleElement.style.height=`${i.toFixed(2)}px`}trigger(){if(!this._setup)return t.w(`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 t.n(`trackuserlocationstart`));break;case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:Co--,wo=!1,this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this.fire(new t.n(`trackuserlocationend`));break;case`BACKGROUND`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.n(`trackuserlocationstart`)),this.fire(new t.n(`userlocationfocus`));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case`WAITING_ACTIVE`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`ACTIVE_LOCK`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`OFF`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState===`OFF`&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let e;this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`true`),Co++,Co>1?(e={maximumAge:6e5,timeout:0},wo=!0):(e=this.options.positionOptions,wo=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`false`),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{let e=this._map.getProjection()?.type;this._map.setProjection(e!==`mercator`&&e?{type:`mercator`}:{type:`globe`}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove(`maplibregl-ctrl-globe`),this._globeButton.classList.remove(`maplibregl-ctrl-globe-enabled`),this._map.getProjection()?.type===`globe`?(this._globeButton.classList.add(`maplibregl-ctrl-globe-enabled`),this._globeButton.title=this._map._getUIString(`GlobeControl.Disable`)):(this._globeButton.classList.add(`maplibregl-ctrl-globe`),this._globeButton.title=this._map._getUIString(`GlobeControl.Enable`))}}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._globeButton=d.create(`button`,`maplibregl-ctrl-globe`,this._container),d.create(`span`,`maplibregl-ctrl-icon`,this._globeButton).setAttribute(`aria-hidden`,`true`),this._globeButton.type=`button`,this._globeButton.addEventListener(`click`,this._toggleProjection),this._updateGlobeIcon(),this._map.on(`styledata`,this._updateGlobeIcon),this._map.on(`projectiontransition`,this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off(`styledata`,this._updateGlobeIcon),this._map.off(`projectiontransition`,this._updateGlobeIcon),this._globeButton.removeEventListener(`click`,this._toggleProjection),this._map=void 0}},e.Hash=na,e.ImageSource=he,e.KeyboardHandler=Ra,e.LngLatBounds=re,e.LogoControl=no,e.Map=mo,e.MapLibreMap=mo,e.MapMouseEvent=fa,e.MapTouchEvent=pa,e.MapWheelEvent=ma,e.Marker=xo,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),n=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute(`aria-disabled`,t.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,n.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{let n=this._map._getUIString(`NavigationControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)},this.options=t.e({},ho,e),this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._container.addEventListener(`contextmenu`,(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton(`maplibregl-ctrl-zoom-in`,(e=>this._map.zoomIn({},{originalEvent:e}))),d.create(`span`,`maplibregl-ctrl-icon`,this._zoomInButton).setAttribute(`aria-hidden`,`true`),this._zoomOutButton=this._createButton(`maplibregl-ctrl-zoom-out`,(e=>this._map.zoomOut({},{originalEvent:e}))),d.create(`span`,`maplibregl-ctrl-icon`,this._zoomOutButton).setAttribute(`aria-hidden`,`true`)),this.options.showCompass&&(this._compass=this._createButton(`maplibregl-ctrl-compass`,(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=d.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`zoom`,this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,`ResetBearing`),this.options.visualizePitch&&this._map.on(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on(`roll`,this._rotateCompassArrow),this._map.on(`rotate`,this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new go(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off(`zoom`,this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off(`roll`,this._rotateCompassArrow),this._map.off(`rotate`,this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let n=d.create(`button`,e,this._container);return n.type=`button`,n.addEventListener(`click`,t),n}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:``)},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off(`move`,this._update),this._map.off(`move`,this._onClose),this._map.off(`click`,this._onClose),this._map.off(`remove`,this.remove),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`mousemove`,this._update),this._map.off(`mouseup`,this._update),this._map.off(`drag`,this._update),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`),delete this._map,this.fire(new t.n(`close`))),this),this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=d.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=d.create(`div`,`maplibregl-popup-tip`,this._container),this._container.appendChild(this._content),this.options.className)for(let e of this.options.className.split(` `))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute(`aria-label`,this._map._getUIString(`Popup.Close`)),this._trackPointer&&this._container.classList.add(`maplibregl-popup-track-pointer`)}let t;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=vo(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),e&&`point`in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;let n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor,i=Ao(this.options.offset);if(!r){let e=this._container.offsetWidth,t=this._container.offsetHeight,a=function(e){return e?{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding),o;o=n.y+i.bottom.y<t+a.top?[`top`]:n.y>this._map.transform.height-t-a.bottom?[`bottom`]:[],n.x<e/2+a.left?o.push(`left`):n.x>this._map.transform.width-e/2-a.right&&o.push(`right`),r=o.length===0?`bottom`:o.join(`-`)}let a=n.add(i[r]);this.options.subpixelPositioning||(a=a.round()),this._container.style.transform=`${yo[r]} translate(${a.x}px,${a.y}px)`,bo(this._container,r,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(Oo),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on(`click`,this._onClose),this.options.closeOnMove&&this._map.on(`move`,this._onClose),this._map.on(`remove`,this.remove),this._map.on(`terrain`,this._update),this._map.on(`projectiontransition`,this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on(`mousemove`,this._update),this._map.on(`mouseup`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)):this._map.on(`move`,this._update),this.fire(new t.n(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on(`move`,this._update),this._map.off(`mousemove`,this._update),this._container&&this._container.classList.remove(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`)),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off(`move`,this._update),this._map.on(`mousemove`,this._update),this._map.on(`drag`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),n=document.createElement(`body`),r;for(n.innerHTML=e;r=n.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=d.create(`div`,`maplibregl-popup-content`,this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=d.create(`button`,`maplibregl-popup-close-button`,this._content),this._closeButton.type=`button`,this._closeButton.innerHTML=`×`,this._closeButton.addEventListener(`click`,this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(ko);e&&e.focus()}},e.RasterDEMTileSource=se,e.RasterTileSource=oe,e.ScaleControl=class{constructor(e){this._onMove=()=>{Eo(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Eo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},To),e)}getDefaultPosition(){return`bottom-left`}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-scale`,e.getContainer()),this._map.on(`move`,this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off(`move`,this._onMove),this._map=void 0}},e.ScrollZoomHandler=Va,e.Style=Hn,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove(`maplibregl-ctrl-terrain`),this._terrainButton.classList.remove(`maplibregl-ctrl-terrain-enabled`),this._map.terrain?(this._terrainButton.classList.add(`maplibregl-ctrl-terrain-enabled`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Disable`)):(this._terrainButton.classList.add(`maplibregl-ctrl-terrain`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Enable`))},this.options=e}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._terrainButton=d.create(`button`,`maplibregl-ctrl-terrain`,this._container),d.create(`span`,`maplibregl-ctrl-icon`,this._terrainButton).setAttribute(`aria-hidden`,`true`),this._terrainButton.type=`button`,this._terrainButton.addEventListener(`click`,this._toggleTerrain),this._updateTerrainIcon(),this._map.on(`terrain`,this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off(`terrain`,this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=Ia,e.TwoFingersTouchRotateHandler=Pa,e.TwoFingersTouchZoomHandler=Ma,e.TwoFingersTouchZoomRotateHandler=qa,e.VectorTileSource=ae,e.VideoSource=ge,e.addSourceType=(e,n)=>t._(void 0,void 0,void 0,(function*(){if(ye(e))throw Error(`A source type called "${e}" already exists.`);((e,t)=>{ve[e]=t})(e,n)})),e.clearPrewarmedResources=function(){let e=M;e&&(e.isPreloaded()&&e.numActive()===1?(e.release(k),M=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()`))},e.createTileMesh=hn,e.getGlobalDispatcher=ee,e.getMaxParallelImageRequests=function(){return t.c.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return Ce().getRTLTextPluginStatus()},e.getVersion=function(){return jo},e.getWorkerCount=function(){return A.workerCount},e.getWorkerUrl=function(){return t.c.WORKER_URL},e.importScriptInWorkers=function(e){return ee().broadcast(`IS`,e)},e.isTimeFrozen=function(){return c.isFrozen()},e.now=l,e.prewarm=function(){P().acquire(k)},e.restoreNow=function(){c.restoreNow()},e.setMaxParallelImageRequests=function(e){t.c.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){c.setNow(e)},e.setRTLTextPlugin=function(e,t){return Ce().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){A.workerCount=e},e.setWorkerUrl=function(e){t.c.WORKER_URL=e}})),e}))}));function p(e){e(`EPSG:4326`,`+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees`),e(`EPSG:4269`,`+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees`),e(`EPSG:3857`,`+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs`);for(var t=1;t<=60;++t)e(`EPSG:`+(32600+t),`+proj=utm +zone=`+t+` +datum=WGS84 +units=m`),e(`EPSG:`+(32700+t),`+proj=utm +zone=`+t+` +south +datum=WGS84 +units=m`);e(`EPSG:5041`,`+title=WGS 84 / UPS North (E,N) +proj=stere +lat_0=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m`),e(`EPSG:5042`,`+title=WGS 84 / UPS South (E,N) +proj=stere +lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m`),e.WGS84=e[`EPSG:4326`],e[`EPSG:3785`]=e[`EPSG:3857`],e.GOOGLE=e[`EPSG:3857`],e[`EPSG:900913`]=e[`EPSG:3857`],e[`EPSG:102113`]=e[`EPSG:3857`]}var m=o((()=>{})),h,g,_,v,y,b,x,S,C,w,T,E,D,O,k=o((()=>{h=6378137,g=6356752.314,_=.0066943799901413165,v=484813681109536e-20,y=Math.PI/2,b=.16666666666666666,x=.04722222222222222,S=.022156084656084655,C=1e-10,w=.017453292519943295,T=57.29577951308232,E=Math.PI/4,D=Math.PI*2,O=3.14159265359})),A,j=o((()=>{A={},A.greenwich=0,A.lisbon=-9.131906111111,A.paris=2.337229166667,A.bogota=-74.080916666667,A.madrid=-3.687938888889,A.rome=12.452333333333,A.bern=7.439583333333,A.jakarta=106.807719444444,A.ferro=-17.666666666667,A.brussels=4.367975,A.stockholm=18.058277777778,A.athens=23.7163375,A.oslo=10.722916666667})),M,N=o((()=>{M={mm:{to_meter:.001},cm:{to_meter:.01},ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937},fath:{to_meter:1.8288},kmi:{to_meter:1852},"us-ch":{to_meter:20.1168402336805},"us-mi":{to_meter:1609.34721869444},km:{to_meter:1e3},"ind-ft":{to_meter:.30479841},"ind-yd":{to_meter:.91439523},mi:{to_meter:1609.344},yd:{to_meter:.9144},ch:{to_meter:20.1168},link:{to_meter:.201168},dm:{to_meter:.1},in:{to_meter:.0254},"ind-ch":{to_meter:20.11669506},"us-in":{to_meter:.025400050800101},"us-yd":{to_meter:.914401828803658}}}));function P(e,t){if(e[t])return e[t];for(var n=Object.keys(e),r=t.toLowerCase().replace(F,``),i=-1,a,o;++i<n.length;)if(a=n[i],o=a.toLowerCase().replace(F,``),o===r)return e[a]}var F,ee=o((()=>{F=/[\s_\-\/\(\)]/g}));function I(e){var t={},n=e.split(`+`).map(function(e){return e.trim()}).filter(function(e){return e}).reduce(function(e,t){var n=t.split(`=`);return n.push(!0),e[n[0].toLowerCase()]=n[1],e},{}),r,i,a,o={proj:`projName`,datum:`datumCode`,rf:function(e){t.rf=parseFloat(e)},lat_0:function(e){t.lat0=e*w},lat_1:function(e){t.lat1=e*w},lat_2:function(e){t.lat2=e*w},lat_ts:function(e){t.lat_ts=e*w},lon_0:function(e){t.long0=e*w},lon_1:function(e){t.long1=e*w},lon_2:function(e){t.long2=e*w},alpha:function(e){t.alpha=parseFloat(e)*w},gamma:function(e){t.rectified_grid_angle=parseFloat(e)*w},lonc:function(e){t.longc=e*w},x_0:function(e){t.x0=parseFloat(e)},y_0:function(e){t.y0=parseFloat(e)},k_0:function(e){t.k0=parseFloat(e)},k:function(e){t.k0=parseFloat(e)},a:function(e){t.a=parseFloat(e)},b:function(e){t.b=parseFloat(e)},r:function(e){t.a=t.b=parseFloat(e)},r_a:function(){t.R_A=!0},zone:function(e){t.zone=parseInt(e,10)},south:function(){t.utmSouth=!0},towgs84:function(e){t.datum_params=e.split(`,`).map(function(e){return parseFloat(e)})},to_meter:function(e){t.to_meter=parseFloat(e)},units:function(e){t.units=e;var n=P(M,e);n&&(t.to_meter=n.to_meter)},from_greenwich:function(e){t.from_greenwich=e*w},pm:function(e){t.from_greenwich=(P(A,e)||parseFloat(e))*w},nadgrids:function(e){e===`@null`?t.datumCode=`none`:t.nadgrids=e},axis:function(e){var n=`ewnsud`;e.length===3&&n.indexOf(e.substr(0,1))!==-1&&n.indexOf(e.substr(1,1))!==-1&&n.indexOf(e.substr(2,1))!==-1&&(t.axis=e)},approx:function(){t.approx=!0},over:function(){t.over=!0}};for(r in n)i=n[r],r in o?(a=o[r],typeof a==`function`?a(i):t[a]=i):t[r]=i;return typeof t.datumCode==`string`&&t.datumCode!==`WGS84`&&(t.datumCode=t.datumCode.toLowerCase()),t.projStr=e,t}var L=o((()=>{k(),j(),N(),ee()})),te,ne=o((()=>{te=class{static getId(e){let t=e.find(e=>Array.isArray(e)&&e[0]===`ID`);return t&&t.length>=3?{authority:t[1],code:parseInt(t[2],10)}:null}static convertUnit(e,t=`unit`){if(!e||e.length<3)return{type:t,name:`unknown`,conversion_factor:null};let n=e[1],r=parseFloat(e[2])||null,i=e.find(e=>Array.isArray(e)&&e[0]===`ID`);return{type:t,name:n,conversion_factor:r,id:i?{authority:i[1],code:parseInt(i[2],10)}:null}}static convertAxis(e){let t=e[1]||`Unknown`,n,r=t.match(/^\((.)\)$/);if(r){let t=r[1].toUpperCase();if(t===`E`)n=`east`;else if(t===`N`)n=`north`;else if(t===`U`)n=`up`;else if(e[2])n=e[2];else throw Error(`Unknown axis abbreviation: ${t}`)}else n=e[2]||`unknown`;let i=e.find(e=>Array.isArray(e)&&e[0]===`ORDER`),a=i?parseInt(i[1],10):null,o=e.find(e=>Array.isArray(e)&&(e[0]===`LENGTHUNIT`||e[0]===`ANGLEUNIT`||e[0]===`SCALEUNIT`)),s=this.convertUnit(o);return{name:t,direction:n,unit:s,order:a}}static extractAxes(e){return e.filter(e=>Array.isArray(e)&&e[0]===`AXIS`).map(e=>this.convertAxis(e)).sort((e,t)=>(e.order||0)-(t.order||0))}static convert(e,t={}){switch(e[0]){case`PROJCRS`:t.type=`ProjectedCRS`,t.name=e[1],t.base_crs=e.find(e=>Array.isArray(e)&&e[0]===`BASEGEOGCRS`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`BASEGEOGCRS`)):null,t.conversion=e.find(e=>Array.isArray(e)&&e[0]===`CONVERSION`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`CONVERSION`)):null;let n=e.find(e=>Array.isArray(e)&&e[0]===`CS`);n&&(t.coordinate_system={type:n[1],axis:this.extractAxes(e)});let r=e.find(e=>Array.isArray(e)&&e[0]===`LENGTHUNIT`);if(r){let e=this.convertUnit(r);t.coordinate_system.unit=e}t.id=this.getId(e);break;case`BASEGEOGCRS`:case`GEOGCRS`:case`GEODCRS`:t.type=e[0]===`GEODCRS`?`GeodeticCRS`:`GeographicCRS`,t.name=e[1];let i=e.find(e=>Array.isArray(e)&&(e[0]===`DATUM`||e[0]===`ENSEMBLE`));if(i){let n=this.convert(i);i[0]===`ENSEMBLE`?t.datum_ensemble=n:t.datum=n;let r=e.find(e=>Array.isArray(e)&&e[0]===`PRIMEM`);r&&r[1]!==`Greenwich`&&(n.prime_meridian={name:r[1],longitude:parseFloat(r[2])})}t.coordinate_system={type:`ellipsoidal`,axis:this.extractAxes(e)},t.id=this.getId(e);break;case`DATUM`:t.type=`GeodeticReferenceFrame`,t.name=e[1],t.ellipsoid=e.find(e=>Array.isArray(e)&&e[0]===`ELLIPSOID`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`ELLIPSOID`)):null;break;case`ENSEMBLE`:t.type=`DatumEnsemble`,t.name=e[1],t.members=e.filter(e=>Array.isArray(e)&&e[0]===`MEMBER`).map(e=>({type:`DatumEnsembleMember`,name:e[1],id:this.getId(e)}));let a=e.find(e=>Array.isArray(e)&&e[0]===`ENSEMBLEACCURACY`);a&&(t.accuracy=parseFloat(a[1]));let o=e.find(e=>Array.isArray(e)&&e[0]===`ELLIPSOID`);o&&(t.ellipsoid=this.convert(o)),t.id=this.getId(e);break;case`ELLIPSOID`:t.type=`Ellipsoid`,t.name=e[1],t.semi_major_axis=parseFloat(e[2]),t.inverse_flattening=parseFloat(e[3]),e.find(e=>Array.isArray(e)&&e[0]===`LENGTHUNIT`)&&this.convert(e.find(e=>Array.isArray(e)&&e[0]===`LENGTHUNIT`),t);break;case`CONVERSION`:t.type=`Conversion`,t.name=e[1],t.method=e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)):null,t.parameters=e.filter(e=>Array.isArray(e)&&e[0]===`PARAMETER`).map(e=>this.convert(e));break;case`METHOD`:t.type=`Method`,t.name=e[1],t.id=this.getId(e);break;case`PARAMETER`:t.type=`Parameter`,t.name=e[1],t.value=parseFloat(e[2]),t.unit=this.convertUnit(e.find(e=>Array.isArray(e)&&(e[0]===`LENGTHUNIT`||e[0]===`ANGLEUNIT`||e[0]===`SCALEUNIT`))),t.id=this.getId(e);break;case`BOUNDCRS`:t.type=`BoundCRS`;let s=e.find(e=>Array.isArray(e)&&e[0]===`SOURCECRS`);if(s){let e=s.find(e=>Array.isArray(e));t.source_crs=e?this.convert(e):null}let c=e.find(e=>Array.isArray(e)&&e[0]===`TARGETCRS`);if(c){let e=c.find(e=>Array.isArray(e));t.target_crs=e?this.convert(e):null}let l=e.find(e=>Array.isArray(e)&&e[0]===`ABRIDGEDTRANSFORMATION`);l?t.transformation=this.convert(l):t.transformation=null;break;case`ABRIDGEDTRANSFORMATION`:if(t.type=`Transformation`,t.name=e[1],t.method=e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)):null,t.parameters=e.filter(e=>Array.isArray(e)&&(e[0]===`PARAMETER`||e[0]===`PARAMETERFILE`)).map(e=>{if(e[0]===`PARAMETER`)return this.convert(e);if(e[0]===`PARAMETERFILE`)return{name:e[1],value:e[2],id:{authority:`EPSG`,code:8656}}}),t.parameters.length===7){let e=t.parameters[6];e.name===`Scale difference`&&(e.value=Math.round((e.value-1)*0xe8d4a51000)/1e6)}t.id=this.getId(e);break;case`AXIS`:t.coordinate_system||={type:`unspecified`,axis:[]},t.coordinate_system.axis.push(this.convertAxis(e));break;case`LENGTHUNIT`:let u=this.convertUnit(e,`LinearUnit`);t.coordinate_system&&t.coordinate_system.axis&&t.coordinate_system.axis.forEach(e=>{e.unit||=u}),u.conversion_factor&&u.conversion_factor!==1&&(t.semi_major_axis&&={value:t.semi_major_axis,unit:u});break;default:t.keyword=e[0];break}return t}}})),R,re=o((()=>{ne(),R=class extends te{static convert(e,t={}){return super.convert(e,t),t.coordinate_system&&t.coordinate_system.subtype===`Cartesian`&&delete t.coordinate_system,t.usage&&delete t.usage,t}}})),ie,ae=o((()=>{ne(),ie=class extends te{static convert(e,t={}){super.convert(e,t);let n=e.find(e=>Array.isArray(e)&&e[0]===`CS`);n&&(t.coordinate_system={subtype:n[1],axis:this.extractAxes(e)});let r=e.find(e=>Array.isArray(e)&&e[0]===`USAGE`);if(r){let e=r.find(e=>Array.isArray(e)&&e[0]===`SCOPE`),n=r.find(e=>Array.isArray(e)&&e[0]===`AREA`),i=r.find(e=>Array.isArray(e)&&e[0]===`BBOX`);t.usage={},e&&(t.usage.scope=e[1]),n&&(t.usage.area=n[1]),i&&(t.usage.bbox=i.slice(1))}return t}}}));function oe(e){return e.find(e=>Array.isArray(e)&&e[0]===`USAGE`)?`2019`:(e.find(e=>Array.isArray(e)&&e[0]===`CS`)||e[0]===`BOUNDCRS`||e[0]===`PROJCRS`||e[0],`2015`)}function se(e){return(oe(e)===`2019`?ie:R).convert(e)}var ce=o((()=>{re(),ae()}));function le(e){let t=e.toUpperCase();return t.includes(`PROJCRS`)||t.includes(`GEOGCRS`)||t.includes(`BOUNDCRS`)||t.includes(`VERTCRS`)||t.includes(`LENGTHUNIT`)||t.includes(`ANGLEUNIT`)||t.includes(`SCALEUNIT`)?`WKT2`:(t.includes(`PROJCS`)||t.includes(`GEOGCS`)||t.includes(`LOCAL_CS`)||t.includes(`VERT_CS`)||t.includes(`UNIT`),`WKT1`)}var ue=o((()=>{}));function de(e){if(typeof e!=`string`)throw Error(`not a string`);this.text=e.trim(),this.level=0,this.place=0,this.root=null,this.stack=[],this.currentObject=null,this.state=me}function fe(e){return new de(e).output()}var pe,me,he,ge,_e,ve,ye,be,xe,Se,Ce,we,Te=o((()=>{pe=fe,me=1,he=2,ge=3,_e=4,ve=5,ye=-1,be=/\s/,xe=/[A-Za-z]/,Se=/[A-Za-z84_]/,Ce=/[,\]]/,we=/[\d\.E\-\+]/,de.prototype.readCharicter=function(){var e=this.text[this.place++];if(this.state!==_e)for(;be.test(e);){if(this.place>=this.text.length)return;e=this.text[this.place++]}switch(this.state){case me:return this.neutral(e);case he:return this.keyword(e);case _e:return this.quoted(e);case ve:return this.afterquote(e);case ge:return this.number(e);case ye:return}},de.prototype.afterquote=function(e){if(e===`"`){this.word+=`"`,this.state=_e;return}if(Ce.test(e)){this.word=this.word.trim(),this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in afterquote yet, index `+this.place)},de.prototype.afterItem=function(e){if(e===`,`){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=me;return}if(e===`]`){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=me,this.currentObject=this.stack.pop(),this.currentObject||(this.state=ye);return}},de.prototype.number=function(e){if(we.test(e)){this.word+=e;return}if(Ce.test(e)){this.word=parseFloat(this.word),this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in number yet, index `+this.place)},de.prototype.quoted=function(e){if(e===`"`){this.state=ve;return}this.word+=e},de.prototype.keyword=function(e){if(Se.test(e)){this.word+=e;return}if(e===`[`){var t=[];t.push(this.word),this.level++,this.root===null?this.root=t:this.currentObject.push(t),this.stack.push(this.currentObject),this.currentObject=t,this.state=me;return}if(Ce.test(e)){this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in keyword yet, index `+this.place)},de.prototype.neutral=function(e){if(xe.test(e)){this.word=e,this.state=he;return}if(e===`"`){this.word=``,this.state=_e;return}if(we.test(e)){this.word=e,this.state=ge;return}if(Ce.test(e)){this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in neutral yet, index `+this.place)},de.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===ye)return this.root;throw Error(`unable to parse string "`+this.text+`". State is `+this.state)}}));function Ee(e,t,n){Array.isArray(t)&&(n.unshift(t),t=null);var r=t?{}:e,i=n.reduce(function(e,t){return De(t,e),e},r);t&&(e[t]=i)}function De(e,t){if(!Array.isArray(e)){t[e]=!0;return}var n=e.shift();if(n===`PARAMETER`&&(n=e.shift()),e.length===1){if(Array.isArray(e[0])){t[n]={},De(e[0],t[n]);return}t[n]=e[0];return}if(!e.length){t[n]=!0;return}if(n===`TOWGS84`){t[n]=e;return}if(n===`AXIS`){n in t||(t[n]=[]),t[n].push(e);return}Array.isArray(n)||(t[n]={});var r;switch(n){case`UNIT`:case`PRIMEM`:case`VERT_DATUM`:t[n]={name:e[0].toLowerCase(),convert:e[1]},e.length===3&&De(e[2],t[n]);return;case`SPHEROID`:case`ELLIPSOID`:t[n]={name:e[0],a:e[1],rf:e[2]},e.length===4&&De(e[3],t[n]);return;case`EDATUM`:case`ENGINEERINGDATUM`:case`LOCAL_DATUM`:case`DATUM`:case`VERT_CS`:case`VERTCRS`:case`VERTICALCRS`:e[0]=[`name`,e[0]],Ee(t,n,e);return;case`COMPD_CS`:case`COMPOUNDCRS`:case`FITTED_CS`:case`PROJECTEDCRS`:case`PROJCRS`:case`GEOGCS`:case`GEOCCS`:case`PROJCS`:case`LOCAL_CS`:case`GEODCRS`:case`GEODETICCRS`:case`GEODETICDATUM`:case`ENGCRS`:case`ENGINEERINGCRS`:e[0]=[`name`,e[0]],Ee(t,n,e),t[n].type=n;return;default:for(r=-1;++r<e.length;)if(!Array.isArray(e[r]))return De(e,t[n]);return Ee(t,n,e)}}var Oe=o((()=>{}));function ke(e){return e*je}function Ae(e){let t=(e.projName||``).toLowerCase().replace(/_/g,` `);e.long0===void 0&&e.longc!==void 0&&(e.long0=e.longc),!e.lat_ts&&e.lat1&&(t===`stereographic south pole`||t===`polar stereographic (variant b)`)?(e.lat0=ke(e.lat1>0?90:-90),e.lat_ts=e.lat1,delete e.lat1):!e.lat_ts&&e.lat0&&(t===`polar stereographic`||t===`polar stereographic (variant a)`)&&(e.lat_ts=e.lat0,e.lat0=ke(e.lat0>0?90:-90),delete e.lat1)}var je,Me=o((()=>{je=.017453292519943295}));function Ne(e){let t={units:null,to_meter:void 0};return typeof e==`string`?(t.units=e.toLowerCase(),t.units===`metre`&&(t.units=`meter`),t.units===`meter`&&(t.to_meter=1)):e&&e.name&&(t.units=e.name.toLowerCase(),t.units===`metre`&&(t.units=`meter`),t.to_meter=e.conversion_factor),t}function Pe(e){return typeof e==`object`?e.value*e.unit.conversion_factor:e}function z(e,t){e.ellipsoid.radius?(t.a=e.ellipsoid.radius,t.rf=0):(t.a=Pe(e.ellipsoid.semi_major_axis),e.ellipsoid.inverse_flattening===void 0?e.ellipsoid.semi_major_axis!==void 0&&e.ellipsoid.semi_minor_axis!==void 0&&(t.rf=t.a/(t.a-Pe(e.ellipsoid.semi_minor_axis))):t.rf=e.ellipsoid.inverse_flattening)}function Fe(e,t={}){return!e||typeof e!=`object`?e:e.type===`BoundCRS`?(Fe(e.source_crs,t),e.transformation&&(e.transformation.method&&e.transformation.method.name===`NTv2`?t.nadgrids=e.transformation.parameters[0].value:t.datum_params=e.transformation.parameters.map(e=>e.value)),t):(Object.keys(e).forEach(n=>{let r=e[n];if(r!==null)switch(n){case`name`:if(t.srsCode)break;t.name=r,t.srsCode=r;break;case`type`:r===`GeographicCRS`?t.projName=`longlat`:r===`GeodeticCRS`?e.coordinate_system&&e.coordinate_system.subtype===`Cartesian`?t.projName=`geocent`:t.projName=`longlat`:r===`ProjectedCRS`&&e.conversion&&e.conversion.method&&(t.projName=e.conversion.method.name);break;case`datum`:case`datum_ensemble`:r.ellipsoid&&(t.ellps=r.ellipsoid.name,z(r,t)),r.prime_meridian&&(t.from_greenwich=r.prime_meridian.longitude*Math.PI/180);break;case`ellipsoid`:t.ellps=r.name,z(r,t);break;case`prime_meridian`:t.long0=(r.longitude||0)*Math.PI/180;break;case`coordinate_system`:if(r.axis){let e={east:`e`,north:`n`,west:`w`,south:`s`,up:`u`,down:`d`,geocentricx:`e`,geocentricy:`n`,geocentricz:`u`},n=r.axis.map(t=>e[t.direction.toLowerCase()]);if(n.every(Boolean)&&(t.axis=n.join(``),t.axis.length===2&&(t.axis+=`u`)),r.unit){let{units:e,to_meter:n}=Ne(r.unit);t.units=e,t.to_meter=n}else if(r.axis[0]&&r.axis[0].unit){let{units:e,to_meter:n}=Ne(r.axis[0].unit);t.units=e,t.to_meter=n}}break;case`id`:r.authority&&r.code&&(t.title=r.authority+`:`+r.code);break;case`conversion`:r.method&&r.method.name&&(t.projName=r.method.name),r.parameters&&r.parameters.forEach(e=>{let n=e.name.toLowerCase().replace(/\s+/g,`_`),r=e.value;e.unit&&e.unit.conversion_factor?t[n]=r*e.unit.conversion_factor:e.unit===`degree`?t[n]=r*Math.PI/180:t[n]=r});break;case`unit`:r.name&&(t.units=r.name.toLowerCase(),t.units===`metre`&&(t.units=`meter`)),r.conversion_factor&&(t.to_meter=r.conversion_factor);break;case`base_crs`:Fe(r,t),t.datumCode=r.id?r.id.authority+`_`+r.id.code:r.name;break;default:break}}),t.latitude_of_false_origin!==void 0&&(t.lat0=t.latitude_of_false_origin),t.longitude_of_false_origin!==void 0&&(t.long0=t.longitude_of_false_origin),t.latitude_of_standard_parallel!==void 0&&(t.lat0=t.latitude_of_standard_parallel,t.lat1=t.latitude_of_standard_parallel),t.latitude_of_1st_standard_parallel!==void 0&&(t.lat1=t.latitude_of_1st_standard_parallel),t.latitude_of_2nd_standard_parallel!==void 0&&(t.lat2=t.latitude_of_2nd_standard_parallel),t.latitude_of_projection_centre!==void 0&&(t.lat0=t.latitude_of_projection_centre),t.longitude_of_projection_centre!==void 0&&(t.longc=t.longitude_of_projection_centre),t.easting_at_false_origin!==void 0&&(t.x0=t.easting_at_false_origin),t.northing_at_false_origin!==void 0&&(t.y0=t.northing_at_false_origin),t.latitude_of_natural_origin!==void 0&&(t.lat0=t.latitude_of_natural_origin),t.longitude_of_natural_origin!==void 0&&(t.long0=t.longitude_of_natural_origin),t.longitude_of_origin!==void 0&&(t.long0=t.longitude_of_origin),t.false_easting!==void 0&&(t.x0=t.false_easting),t.easting_at_projection_centre&&(t.x0=t.easting_at_projection_centre),t.false_northing!==void 0&&(t.y0=t.false_northing),t.northing_at_projection_centre&&(t.y0=t.northing_at_projection_centre),t.standard_parallel_1!==void 0&&(t.lat1=t.standard_parallel_1),t.standard_parallel_2!==void 0&&(t.lat2=t.standard_parallel_2),t.scale_factor_at_natural_origin!==void 0&&(t.k0=t.scale_factor_at_natural_origin),t.scale_factor_at_projection_centre!==void 0&&(t.k0=t.scale_factor_at_projection_centre),t.scale_factor_on_pseudo_standard_parallel!==void 0&&(t.k0=t.scale_factor_on_pseudo_standard_parallel),t.azimuth!==void 0&&(t.alpha=t.azimuth),t.azimuth_at_projection_centre!==void 0&&(t.alpha=t.azimuth_at_projection_centre),t.angle_from_rectified_to_skew_grid&&(t.rectified_grid_angle=t.angle_from_rectified_to_skew_grid),Ae(t),t)}var Ie=o((()=>{Me()}));function Le(e,t){var n=t[0],r=t[1];!(n in e)&&r in e&&(e[n]=e[r],t.length===3&&(e[n]=t[2](e[n])))}function Re(e){for(var t=Object.keys(e),n=0,r=t.length;n<r;++n){var i=t[n];Ve.indexOf(i)!==-1&&ze(e[i]),typeof e[i]==`object`&&Re(e[i])}}function ze(e){if(e.AUTHORITY){var t=Object.keys(e.AUTHORITY)[0];t&&t in e.AUTHORITY&&(e.title=t+`:`+e.AUTHORITY[t])}if(e.type===`GEOGCS`?e.projName=`longlat`:e.type===`LOCAL_CS`?(e.projName=`identity`,e.local=!0):typeof e.PROJECTION==`object`?e.projName=Object.keys(e.PROJECTION)[0]:e.projName=e.PROJECTION,e.AXIS){for(var n=``,r=0,i=e.AXIS.length;r<i;++r){var a=[e.AXIS[r][0].toLowerCase(),e.AXIS[r][1].toLowerCase()];a[0].indexOf(`north`)!==-1||(a[0]===`y`||a[0]===`lat`)&&a[1]===`north`?n+=`n`:a[0].indexOf(`south`)!==-1||(a[0]===`y`||a[0]===`lat`)&&a[1]===`south`?n+=`s`:a[0].indexOf(`east`)!==-1||(a[0]===`x`||a[0]===`lon`)&&a[1]===`east`?n+=`e`:(a[0].indexOf(`west`)!==-1||(a[0]===`x`||a[0]===`lon`)&&a[1]===`west`)&&(n+=`w`)}n.length===2&&(n+=`u`),n.length===3&&(e.axis=n)}e.UNIT&&(e.units=e.UNIT.name.toLowerCase(),e.units===`metre`&&(e.units=`meter`),e.UNIT.convert&&(e.type===`GEOGCS`?e.DATUM&&e.DATUM.SPHEROID&&(e.to_meter=e.UNIT.convert*e.DATUM.SPHEROID.a):e.to_meter=e.UNIT.convert));var o=e.GEOGCS;e.type===`GEOGCS`&&(o=e),o&&(o.PRIMEM&&o.PRIMEM.convert&&(e.from_greenwich=ke(o.PRIMEM.convert)),o.DATUM?e.datumCode=o.DATUM.name.toLowerCase():e.datumCode=o.name.toLowerCase(),e.datumCode.slice(0,2)===`d_`&&(e.datumCode=e.datumCode.slice(2)),e.datumCode===`new_zealand_1949`&&(e.datumCode=`nzgd49`),(e.datumCode===`wgs_1984`||e.datumCode===`world_geodetic_system_1984`)&&(e.PROJECTION===`Mercator_Auxiliary_Sphere`&&(e.sphere=!0),e.datumCode=`wgs84`),e.datumCode===`belge_1972`&&(e.datumCode=`rnb72`),o.DATUM&&o.DATUM.SPHEROID&&(e.ellps=o.DATUM.SPHEROID.name.replace(`_19`,``).replace(/[Cc]larke\_18/,`clrk`),e.ellps.toLowerCase().slice(0,13)===`international`&&(e.ellps=`intl`),e.a=o.DATUM.SPHEROID.a,e.rf=parseFloat(o.DATUM.SPHEROID.rf)),o.DATUM&&o.DATUM.TOWGS84&&(e.datum_params=o.DATUM.TOWGS84),~e.datumCode.indexOf(`osgb_1936`)&&(e.datumCode=`osgb36`),~e.datumCode.indexOf(`osni_1952`)&&(e.datumCode=`osni52`),(~e.datumCode.indexOf(`tm65`)||~e.datumCode.indexOf(`geodetic_datum_of_1965`))&&(e.datumCode=`ire65`),e.datumCode===`ch1903+`&&(e.datumCode=`ch1903`),~e.datumCode.indexOf(`israel`)&&(e.datumCode=`isr93`)),e.b&&!isFinite(e.b)&&(e.b=e.a),e.rectified_grid_angle&&=ke(e.rectified_grid_angle);function s(t){return t*(e.to_meter||1)}[[`standard_parallel_1`,`Standard_Parallel_1`],[`standard_parallel_1`,`Latitude of 1st standard parallel`],[`standard_parallel_2`,`Standard_Parallel_2`],[`standard_parallel_2`,`Latitude of 2nd standard parallel`],[`false_easting`,`False_Easting`],[`false_easting`,`False easting`],[`false-easting`,`Easting at false origin`],[`false_northing`,`False_Northing`],[`false_northing`,`False northing`],[`false_northing`,`Northing at false origin`],[`central_meridian`,`Central_Meridian`],[`central_meridian`,`Longitude of natural origin`],[`central_meridian`,`Longitude of false origin`],[`latitude_of_origin`,`Latitude_Of_Origin`],[`latitude_of_origin`,`Central_Parallel`],[`latitude_of_origin`,`Latitude of natural origin`],[`latitude_of_origin`,`Latitude of false origin`],[`scale_factor`,`Scale_Factor`],[`k0`,`scale_factor`],[`latitude_of_center`,`Latitude_Of_Center`],[`latitude_of_center`,`Latitude_of_center`],[`lat0`,`latitude_of_center`,ke],[`longitude_of_center`,`Longitude_Of_Center`],[`longitude_of_center`,`Longitude_of_center`],[`longc`,`longitude_of_center`,ke],[`x0`,`false_easting`,s],[`y0`,`false_northing`,s],[`long0`,`central_meridian`,ke],[`lat0`,`latitude_of_origin`,ke],[`lat0`,`standard_parallel_1`,ke],[`lat1`,`standard_parallel_1`,ke],[`lat2`,`standard_parallel_2`,ke],[`azimuth`,`Azimuth`],[`alpha`,`azimuth`,ke],[`srsCode`,`name`]].forEach(function(t){return Le(e,t)}),Ae(e)}function Be(e){if(typeof e==`object`)return Fe(e);let t=le(e);var n=pe(e);if(t===`WKT2`)return Fe(se(n));var r=n[0],i={};return De(n,i),Re(i),i[r]}var Ve,He=o((()=>{ce(),ue(),Te(),Oe(),Ie(),Me(),Ve=[`PROJECTEDCRS`,`PROJCRS`,`GEOGCS`,`GEOCCS`,`PROJCS`,`LOCAL_CS`,`GEODCRS`,`GEODETICCRS`,`GEODETICDATUM`,`ENGCRS`,`ENGINEERINGCRS`]}));function Ue(e){var t=this;if(arguments.length===2){var n=arguments[1];typeof n==`string`?n.charAt(0)===`+`?Ue[e]=I(arguments[1]):Ue[e]=Be(arguments[1]):n&&typeof n==`object`&&!(`projName`in n)?Ue[e]=Be(arguments[1]):(Ue[e]=n,n||delete Ue[e])}else if(arguments.length===1){if(Array.isArray(e))return e.map(function(e){return Array.isArray(e)?Ue.apply(t,e):Ue(e)});if(typeof e==`string`){if(e in Ue)return Ue[e]}else `EPSG`in e?Ue[`EPSG:`+e.EPSG]=e:`ESRI`in e?Ue[`ESRI:`+e.ESRI]=e:`IAU2000`in e?Ue[`IAU2000:`+e.IAU2000]=e:console.log(e);return}}var We=o((()=>{m(),L(),He(),p(Ue)}));function Ge(e){return typeof e==`string`}function B(e){return e in Ue}function Ke(e){return e.indexOf(`+`)!==0&&e.indexOf(`[`)!==-1||typeof e==`object`&&!(`srsCode`in e)}function qe(e){if(e.title)return e.title.toLowerCase().indexOf(`epsg:`)===0&&Xe.indexOf(e.title.substr(5))>-1;var t=P(e,`authority`);if(t){var n=P(t,`epsg`);return n&&Xe.indexOf(n)>-1}}function Je(e){var t=P(e,`extension`);if(t)return P(t,`proj4`)}function Ye(e){return e[0]===`+`}function V(e){let t;if(Ge(e))if(B(e))t=Ue[e];else if(Ke(e)){t=Be(e);var n=Je(t);n&&(t=I(n))}else Ye(e)&&(t=I(e));else t=`projName`in e?e:Be(e);return t&&qe(t)?Ue[`EPSG:3857`]:t}var Xe,Ze=o((()=>{We(),He(),L(),ee(),Xe=[`3857`,`900913`,`3785`,`102113`]}));function H(e,t){e||={};var n,r;if(!t)return e;for(r in t)n=t[r],n!==void 0&&(e[r]=n);return e}var Qe=o((()=>{}));function $e(e,t,n){var r=e*t;return n/Math.sqrt(1-r*r)}var et=o((()=>{}));function tt(e){return e<0?-1:1}var nt=o((()=>{}));function U(e,t){return t||Math.abs(e)<=3.14159265359?e:e-tt(e)*D}var rt=o((()=>{k(),nt()}));function it(e,t,n){var r=e*n,i=.5*e;return r=((1-r)/(1+r))**i,Math.tan(.5*(y-t))/r}var at=o((()=>{k()}));function ot(e,t){for(var n=.5*e,r,i,a=y-2*Math.atan(t),o=0;o<=15;o++)if(r=e*Math.sin(a),i=y-2*Math.atan(t*((1-r)/(1+r))**n)-a,a+=i,Math.abs(i)<=1e-10)return a;return-9999}var st=o((()=>{k()}));function ct(){var e=this.b/this.a;this.es=1-e*e,`x0`in this||(this.x0=0),`y0`in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=$e(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function lt(e){var t=e.x,n=e.y;if(n*57.29577951308232>90&&n*57.29577951308232<-90&&t*57.29577951308232>180&&t*57.29577951308232<-180)return null;var r,i;if(Math.abs(Math.abs(n)-y)<=1e-10)return null;if(this.sphere)r=this.x0+this.a*this.k0*U(t-this.long0,this.over),i=this.y0+this.a*this.k0*Math.log(Math.tan(E+.5*n));else{var a=Math.sin(n),o=it(this.e,n,a);r=this.x0+this.a*this.k0*U(t-this.long0,this.over),i=this.y0-this.a*this.k0*Math.log(o)}return e.x=r,e.y=i,e}function ut(e){var t=e.x-this.x0,n=e.y-this.y0,r,i;if(this.sphere)i=y-2*Math.atan(Math.exp(-n/(this.a*this.k0)));else{var a=Math.exp(-n/(this.a*this.k0));if(i=ot(this.e,a),i===-9999)return null}return r=U(this.long0+t/(this.a*this.k0),this.over),e.x=r,e.y=i,e}var dt,ft,pt=o((()=>{et(),rt(),at(),st(),k(),dt=[`Mercator`,`Popular Visualisation Pseudo Mercator`,`Mercator_1SP`,`Mercator_Auxiliary_Sphere`,`Mercator_Variant_A`,`merc`],ft={init:ct,forward:lt,inverse:ut,names:dt}}));function mt(){}function ht(e){return e}var gt,_t,vt=o((()=>{gt=[`longlat`,`identity`],_t={init:mt,forward:ht,inverse:ht,names:gt}}));function yt(e,t){var n=Tt.length;return e.names?(Tt[n]=e,e.names.forEach(function(e){wt[e.toLowerCase()]=n}),this):(console.log(t),!0)}function bt(e){return e.replace(/[-\(\)\s]+/g,` `).trim().replace(/ /g,`_`)}function xt(e){if(!e)return!1;var t=e.toLowerCase();if(wt[t]!==void 0&&Tt[wt[t]]||(t=bt(t),t in wt&&Tt[wt[t]]))return Tt[wt[t]]}function St(){Ct.forEach(yt)}var Ct,wt,Tt,Et,Dt=o((()=>{pt(),vt(),Ct=[ft,_t],wt={},Tt=[],Et={start:St,add:yt,get:xt}})),Ot,kt=o((()=>{Ot={MERIT:{a:6378137,rf:298.257,ellipseName:`MERIT 1983`},SGS85:{a:6378136,rf:298.257,ellipseName:`Soviet Geodetic System 85`},GRS80:{a:6378137,rf:298.257222101,ellipseName:`GRS 1980(IUGG, 1980)`},IAU76:{a:6378140,rf:298.257,ellipseName:`IAU 1976`},airy:{a:6377563.396,b:6356256.91,ellipseName:`Airy 1830`},APL4:{a:6378137,rf:298.25,ellipseName:`Appl. Physics. 1965`},NWL9D:{a:6378145,rf:298.25,ellipseName:`Naval Weapons Lab., 1965`},mod_airy:{a:6377340.189,b:6356034.446,ellipseName:`Modified Airy`},andrae:{a:6377104.43,rf:300,ellipseName:`Andrae 1876 (Den., Iclnd.)`},aust_SA:{a:6378160,rf:298.25,ellipseName:`Australian Natl & S. Amer. 1969`},GRS67:{a:6378160,rf:298.247167427,ellipseName:`GRS 67(IUGG 1967)`},bessel:{a:6377397.155,rf:299.1528128,ellipseName:`Bessel 1841`},bess_nam:{a:6377483.865,rf:299.1528128,ellipseName:`Bessel 1841 (Namibia)`},clrk66:{a:6378206.4,b:6356583.8,ellipseName:`Clarke 1866`},clrk80:{a:6378249.145,rf:293.4663,ellipseName:`Clarke 1880 mod.`},clrk80ign:{a:6378249.2,b:6356515,rf:293.4660213,ellipseName:`Clarke 1880 (IGN)`},clrk58:{a:6378293.645208759,rf:294.2606763692654,ellipseName:`Clarke 1858`},CPM:{a:6375738.7,rf:334.29,ellipseName:`Comm. des Poids et Mesures 1799`},delmbr:{a:6376428,rf:311.5,ellipseName:`Delambre 1810 (Belgium)`},engelis:{a:6378136.05,rf:298.2566,ellipseName:`Engelis 1985`},evrst30:{a:6377276.345,rf:300.8017,ellipseName:`Everest 1830`},evrst48:{a:6377304.063,rf:300.8017,ellipseName:`Everest 1948`},evrst56:{a:6377301.243,rf:300.8017,ellipseName:`Everest 1956`},evrst69:{a:6377295.664,rf:300.8017,ellipseName:`Everest 1969`},evrstSS:{a:6377298.556,rf:300.8017,ellipseName:`Everest (Sabah & Sarawak)`},fschr60:{a:6378166,rf:298.3,ellipseName:`Fischer (Mercury Datum) 1960`},fschr60m:{a:6378155,rf:298.3,ellipseName:`Fischer 1960`},fschr68:{a:6378150,rf:298.3,ellipseName:`Fischer 1968`},helmert:{a:6378200,rf:298.3,ellipseName:`Helmert 1906`},hough:{a:6378270,rf:297,ellipseName:`Hough`},intl:{a:6378388,rf:297,ellipseName:`International 1909 (Hayford)`},kaula:{a:6378163,rf:298.24,ellipseName:`Kaula 1961`},lerch:{a:6378139,rf:298.257,ellipseName:`Lerch 1979`},mprts:{a:6397300,rf:191,ellipseName:`Maupertius 1738`},new_intl:{a:6378157.5,b:6356772.2,ellipseName:`New International 1967`},plessis:{a:6376523,rf:6355863,ellipseName:`Plessis 1817 (France)`},krass:{a:6378245,rf:298.3,ellipseName:`Krassovsky, 1942`},SEasia:{a:6378155,b:6356773.3205,ellipseName:`Southeast Asia`},walbeck:{a:6376896,b:6355834.8467,ellipseName:`Walbeck`},WGS60:{a:6378165,rf:298.3,ellipseName:`WGS 60`},WGS66:{a:6378145,rf:298.25,ellipseName:`WGS 66`},WGS7:{a:6378135,rf:298.26,ellipseName:`WGS 72`},WGS84:{a:6378137,rf:298.257223563,ellipseName:`WGS 84`},sphere:{a:6370997,b:6370997,ellipseName:`Normal Sphere (r=6370997)`}}}));function At(e,t,n,r){var i=e*e,a=t*t,o=(i-a)/i,s=0;r?(e*=1-o*(b+o*(x+o*S)),i=e*e,o=0):s=Math.sqrt(o);var c=(i-a)/a;return{es:o,e:s,ep2:c}}function jt(e,t,n,r,i){if(!e){var a=P(Ot,r);a||=Mt,e=a.a,t=a.b,n=a.rf}return n&&!t&&(t=(1-1/n)*e),(n===0||Math.abs(e-t)<1e-10)&&(i=!0,t=e),{a:e,b:t,rf:n,sphere:i}}var Mt,Nt=o((()=>{k(),kt(),ee(),Mt=Ot.WGS84})),Pt,Ft,It=o((()=>{for(var e in Pt={wgs84:{towgs84:`0,0,0`,ellipse:`WGS84`,datumName:`WGS84`},ch1903:{towgs84:`674.374,15.056,405.346`,ellipse:`bessel`,datumName:`swiss`},ggrs87:{towgs84:`-199.87,74.79,246.62`,ellipse:`GRS80`,datumName:`Greek_Geodetic_Reference_System_1987`},nad83:{towgs84:`0,0,0`,ellipse:`GRS80`,datumName:`North_American_Datum_1983`},nad27:{nadgrids:`@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat`,ellipse:`clrk66`,datumName:`North_American_Datum_1927`},potsdam:{towgs84:`598.1,73.7,418.2,0.202,0.045,-2.455,6.7`,ellipse:`bessel`,datumName:`Potsdam Rauenberg 1950 DHDN`},carthage:{towgs84:`-263.0,6.0,431.0`,ellipse:`clark80`,datumName:`Carthage 1934 Tunisia`},hermannskogel:{towgs84:`577.326,90.129,463.919,5.137,1.474,5.297,2.4232`,ellipse:`bessel`,datumName:`Hermannskogel`},mgi:{towgs84:`577.326,90.129,463.919,5.137,1.474,5.297,2.4232`,ellipse:`bessel`,datumName:`Militar-Geographische Institut`},osni52:{towgs84:`482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15`,ellipse:`airy`,datumName:`Irish National`},ire65:{towgs84:`482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15`,ellipse:`mod_airy`,datumName:`Ireland 1965`},rassadiran:{towgs84:`-133.63,-157.5,-158.62`,ellipse:`intl`,datumName:`Rassadiran`},nzgd49:{towgs84:`59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993`,ellipse:`intl`,datumName:`New Zealand Geodetic Datum 1949`},osgb36:{towgs84:`446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894`,ellipse:`airy`,datumName:`Ordnance Survey of Great Britain 1936`},s_jtsk:{towgs84:`589,76,480`,ellipse:`bessel`,datumName:`S-JTSK (Ferro)`},beduaram:{towgs84:`-106,-87,188`,ellipse:`clrk80`,datumName:`Beduaram`},gunung_segara:{towgs84:`-403,684,41`,ellipse:`bessel`,datumName:`Gunung Segara Jakarta`},rnb72:{towgs84:`106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1`,ellipse:`intl`,datumName:`Reseau National Belge 1972`},EPSG_5451:{towgs84:`6.41,-49.05,-11.28,1.5657,0.5242,6.9718,-5.7649`},IGNF_LURESG:{towgs84:`-192.986,13.673,-39.309,-0.4099,-2.9332,2.6881,0.43`},EPSG_4614:{towgs84:`-119.4248,-303.65872,-11.00061,1.164298,0.174458,1.096259,3.657065`},EPSG_4615:{towgs84:`-494.088,-312.129,279.877,-1.423,-1.013,1.59,-0.748`},ESRI_37241:{towgs84:`-76.822,257.457,-12.817,2.136,-0.033,-2.392,-0.031`},ESRI_37249:{towgs84:`-440.296,58.548,296.265,1.128,10.202,4.559,-0.438`},ESRI_37245:{towgs84:`-511.151,-181.269,139.609,1.05,2.703,1.798,3.071`},EPSG_4178:{towgs84:`24.9,-126.4,-93.2,-0.063,-0.247,-0.041,1.01`},EPSG_4622:{towgs84:`-472.29,-5.63,-304.12,0.4362,-0.8374,0.2563,1.8984`},EPSG_4625:{towgs84:`126.93,547.94,130.41,-2.7867,5.1612,-0.8584,13.8227`},EPSG_5252:{towgs84:`0.023,0.036,-0.068,0.00176,0.00912,-0.01136,0.00439`},EPSG_4314:{towgs84:`597.1,71.4,412.1,0.894,0.068,-1.563,7.58`},EPSG_4282:{towgs84:`-178.3,-316.7,-131.5,5.278,6.077,10.979,19.166`},EPSG_4231:{towgs84:`-83.11,-97.38,-117.22,0.005693,-0.044698,0.044285,0.1218`},EPSG_4274:{towgs84:`-230.994,102.591,25.199,0.633,-0.239,0.9,1.95`},EPSG_4134:{towgs84:`-180.624,-225.516,173.919,-0.81,-1.898,8.336,16.71006`},EPSG_4254:{towgs84:`18.38,192.45,96.82,0.056,-0.142,-0.2,-0.0013`},EPSG_4159:{towgs84:`-194.513,-63.978,-25.759,-3.4027,3.756,-3.352,-0.9175`},EPSG_4687:{towgs84:`0.072,-0.507,-0.245,0.0183,-0.0003,0.007,-0.0093`},EPSG_4227:{towgs84:`-83.58,-397.54,458.78,-17.595,-2.847,4.256,3.225`},EPSG_4746:{towgs84:`599.4,72.4,419.2,-0.062,-0.022,-2.723,6.46`},EPSG_4745:{towgs84:`612.4,77,440.2,-0.054,0.057,-2.797,2.55`},EPSG_6311:{towgs84:`8.846,-4.394,-1.122,-0.00237,-0.146528,0.130428,0.783926`},EPSG_4289:{towgs84:`565.7381,50.4018,465.2904,-0.395026,0.330772,-1.876073,4.07244`},EPSG_4230:{towgs84:`-68.863,-134.888,-111.49,-0.53,-0.14,0.57,-3.4`},EPSG_4154:{towgs84:`-123.02,-158.95,-168.47`},EPSG_4156:{towgs84:`570.8,85.7,462.8,4.998,1.587,5.261,3.56`},EPSG_4299:{towgs84:`482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15`},EPSG_4179:{towgs84:`33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84`},EPSG_4313:{towgs84:`-106.8686,52.2978,-103.7239,0.3366,-0.457,1.8422,-1.2747`},EPSG_4194:{towgs84:`163.511,127.533,-159.789`},EPSG_4195:{towgs84:`105,326,-102.5`},EPSG_4196:{towgs84:`-45,417,-3.5`},EPSG_4611:{towgs84:`-162.619,-276.959,-161.764,0.067753,-2.243648,-1.158828,-1.094246`},EPSG_4633:{towgs84:`137.092,131.66,91.475,-1.9436,-11.5993,-4.3321,-7.4824`},EPSG_4641:{towgs84:`-408.809,366.856,-412.987,1.8842,-0.5308,2.1655,-121.0993`},EPSG_4643:{towgs84:`-480.26,-438.32,-643.429,16.3119,20.1721,-4.0349,-111.7002`},EPSG_4300:{towgs84:`482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15`},EPSG_4188:{towgs84:`482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15`},EPSG_4660:{towgs84:`982.6087,552.753,-540.873,6.681627,-31.611492,-19.848161,16.805`},EPSG_4662:{towgs84:`97.295,-263.247,310.882,-1.5999,0.8386,3.1409,13.3259`},EPSG_3906:{towgs84:`577.88891,165.22205,391.18289,4.9145,-0.94729,-13.05098,7.78664`},EPSG_4307:{towgs84:`-209.3622,-87.8162,404.6198,0.0046,3.4784,0.5805,-1.4547`},EPSG_6892:{towgs84:`-76.269,-16.683,68.562,-6.275,10.536,-4.286,-13.686`},EPSG_4690:{towgs84:`221.597,152.441,176.523,2.403,1.3893,0.884,11.4648`},EPSG_4691:{towgs84:`218.769,150.75,176.75,3.5231,2.0037,1.288,10.9817`},EPSG_4629:{towgs84:`72.51,345.411,79.241,-1.5862,-0.8826,-0.5495,1.3653`},EPSG_4630:{towgs84:`165.804,216.213,180.26,-0.6251,-0.4515,-0.0721,7.4111`},EPSG_4692:{towgs84:`217.109,86.452,23.711,0.0183,-0.0003,0.007,-0.0093`},EPSG_9333:{towgs84:`0,0,0,-0.008393,0.000749,-0.010276,0`},EPSG_9059:{towgs84:`0,0,0`},EPSG_4312:{towgs84:`601.705,84.263,485.227,4.7354,1.3145,5.393,-2.3887`},EPSG_4123:{towgs84:`-96.062,-82.428,-121.753,4.801,0.345,-1.376,1.496`},EPSG_4309:{towgs84:`-124.45,183.74,44.64,-0.4384,0.5446,-0.9706,-2.1365`},ESRI_104106:{towgs84:`-283.088,-70.693,117.445,-1.157,0.059,-0.652,-4.058`},EPSG_4281:{towgs84:`-219.247,-73.802,269.529`},EPSG_4322:{towgs84:`0,0,4.5`},EPSG_4324:{towgs84:`0,0,1.9`},EPSG_4284:{towgs84:`43.822,-108.842,-119.585,1.455,-0.761,0.737,0.549`},EPSG_4277:{towgs84:`446.448,-125.157,542.06,0.15,0.247,0.842,-20.489`},EPSG_4207:{towgs84:`-282.1,-72.2,120,-1.529,0.145,-0.89,-4.46`},EPSG_4688:{towgs84:`347.175,1077.618,2623.677,33.9058,-70.6776,9.4013,186.0647`},EPSG_4689:{towgs84:`410.793,54.542,80.501,-2.5596,-2.3517,-0.6594,17.3218`},EPSG_4720:{towgs84:`0,0,4.5`},EPSG_4273:{towgs84:`278.3,93,474.5,7.889,0.05,-6.61,6.21`},EPSG_4240:{towgs84:`204.64,834.74,293.8`},EPSG_4817:{towgs84:`278.3,93,474.5,7.889,0.05,-6.61,6.21`},ESRI_104131:{towgs84:`426.62,142.62,460.09,4.98,4.49,-12.42,-17.1`},EPSG_4265:{towgs84:`-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68`},EPSG_4263:{towgs84:`-111.92,-87.85,114.5,1.875,0.202,0.219,0.032`},EPSG_4298:{towgs84:`-689.5937,623.84046,-65.93566,-0.02331,1.17094,-0.80054,5.88536`},EPSG_4270:{towgs84:`-253.4392,-148.452,386.5267,0.15605,0.43,-0.1013,-0.0424`},EPSG_4229:{towgs84:`-121.8,98.1,-10.7`},EPSG_4220:{towgs84:`-55.5,-348,-229.2`},EPSG_4214:{towgs84:`12.646,-155.176,-80.863`},EPSG_4232:{towgs84:`-345,3,223`},EPSG_4238:{towgs84:`-1.977,-13.06,-9.993,0.364,0.254,0.689,-1.037`},EPSG_4168:{towgs84:`-170,33,326`},EPSG_4131:{towgs84:`199,931,318.9`},EPSG_4152:{towgs84:`-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0`},EPSG_5228:{towgs84:`572.213,85.334,461.94,4.9732,1.529,5.2484,3.5378`},EPSG_8351:{towgs84:`485.021,169.465,483.839,7.786342,4.397554,4.102655,0`},EPSG_4683:{towgs84:`-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06`},EPSG_4133:{towgs84:`0,0,0`},EPSG_7373:{towgs84:`0.819,-0.5762,-1.6446,-0.00378,-0.03317,0.00318,0.0693`},EPSG_9075:{towgs84:`-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0`},EPSG_9072:{towgs84:`-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0`},EPSG_9294:{towgs84:`1.16835,-1.42001,-2.24431,-0.00822,-0.05508,0.01818,0.23388`},EPSG_4212:{towgs84:`-267.434,173.496,181.814,-13.4704,8.7154,7.3926,14.7492`},EPSG_4191:{towgs84:`-44.183,-0.58,-38.489,2.3867,2.7072,-3.5196,-8.2703`},EPSG_4237:{towgs84:`52.684,-71.194,-13.975,-0.312,-0.1063,-0.3729,1.0191`},EPSG_4740:{towgs84:`-1.08,-0.27,-0.9`},EPSG_4124:{towgs84:`419.3836,99.3335,591.3451,0.850389,1.817277,-7.862238,-0.99496`},EPSG_5681:{towgs84:`584.9636,107.7175,413.8067,1.1155,0.2824,-3.1384,7.9922`},EPSG_4141:{towgs84:`23.772,17.49,17.859,-0.3132,-1.85274,1.67299,-5.4262`},EPSG_4204:{towgs84:`-85.645,-273.077,-79.708,2.289,-1.421,2.532,3.194`},EPSG_4319:{towgs84:`226.702,-193.337,-35.371,-2.229,-4.391,9.238,0.9798`},EPSG_4200:{towgs84:`24.82,-131.21,-82.66`},EPSG_4130:{towgs84:`0,0,0`},EPSG_4127:{towgs84:`-82.875,-57.097,-156.768,-2.158,1.524,-0.982,-0.359`},EPSG_4149:{towgs84:`674.374,15.056,405.346`},EPSG_4617:{towgs84:`-0.991,1.9072,0.5129,0.02579,0.00965,0.01166,0`},EPSG_4663:{towgs84:`-210.502,-66.902,-48.476,2.094,-15.067,-5.817,0.485`},EPSG_4664:{towgs84:`-211.939,137.626,58.3,-0.089,0.251,0.079,0.384`},EPSG_4665:{towgs84:`-105.854,165.589,-38.312,-0.003,-0.026,0.024,-0.048`},EPSG_4666:{towgs84:`631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43`},EPSG_4756:{towgs84:`-192.873,-39.382,-111.202,-0.00205,-0.0005,0.00335,0.0188`},EPSG_4723:{towgs84:`-179.483,-69.379,-27.584,-7.862,8.163,6.042,-13.925`},EPSG_4726:{towgs84:`8.853,-52.644,180.304,-0.393,-2.323,2.96,-24.081`},EPSG_4267:{towgs84:`-8.0,160.0,176.0`},EPSG_5365:{towgs84:`-0.16959,0.35312,0.51846,0.03385,-0.16325,0.03446,0.03693`},EPSG_4218:{towgs84:`304.5,306.5,-318.1`},EPSG_4242:{towgs84:`-33.722,153.789,94.959,-8.581,-4.478,4.54,8.95`},EPSG_4216:{towgs84:`-292.295,248.758,429.447,4.9971,2.99,6.6906,1.0289`},ESRI_104105:{towgs84:`631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43`},ESRI_104129:{towgs84:`0,0,0`},EPSG_4673:{towgs84:`174.05,-25.49,112.57`},EPSG_4202:{towgs84:`-124,-60,154`},EPSG_4203:{towgs84:`-117.763,-51.51,139.061,0.292,0.443,0.277,-0.191`},EPSG_3819:{towgs84:`595.48,121.69,515.35,4.115,-2.9383,0.853,-3.408`},EPSG_8694:{towgs84:`-93.799,-132.737,-219.073,-1.844,0.648,-6.37,-0.169`},EPSG_4145:{towgs84:`275.57,676.78,229.6`},EPSG_4283:{towgs84:`0.06155,-0.01087,-0.04019,0.039492,0.032722,0.032898,-0.009994`},EPSG_4317:{towgs84:`2.3287,-147.0425,-92.0802,-0.309248,0.324822,0.497299,5.689063`},EPSG_4272:{towgs84:`59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993`},EPSG_4248:{towgs84:`-307.7,265.3,-363.5`},EPSG_5561:{towgs84:`24,-121,-76`},EPSG_5233:{towgs84:`-0.293,766.95,87.713,0.195704,1.695068,3.473016,-0.039338`},ESRI_104130:{towgs84:`-86,-98,-119`},ESRI_104102:{towgs84:`682,-203,480`},ESRI_37207:{towgs84:`7,-10,-26`},EPSG_4675:{towgs84:`59.935,118.4,-10.871`},ESRI_104109:{towgs84:`-89.121,-348.182,260.871`},ESRI_104112:{towgs84:`-185.583,-230.096,281.361`},ESRI_104113:{towgs84:`25.1,-275.6,222.6`},IGNF_WGS72G:{towgs84:`0,12,6`},IGNF_NTFG:{towgs84:`-168,-60,320`},IGNF_EFATE57G:{towgs84:`-127,-769,472`},IGNF_PGP50G:{towgs84:`324.8,153.6,172.1`},IGNF_REUN47G:{towgs84:`94,-948,-1262`},IGNF_CSG67G:{towgs84:`-186,230,110`},IGNF_GUAD48G:{towgs84:`-467,-16,-300`},IGNF_TAHI51G:{towgs84:`162,117,154`},IGNF_TAHAAG:{towgs84:`65,342,77`},IGNF_NUKU72G:{towgs84:`84,274,65`},IGNF_PETRELS72G:{towgs84:`365,194,166`},IGNF_WALL78G:{towgs84:`253,-133,-127`},IGNF_MAYO50G:{towgs84:`-382,-59,-262`},IGNF_TANNAG:{towgs84:`-139,-967,436`},IGNF_IGN72G:{towgs84:`-13,-348,292`},IGNF_ATIGG:{towgs84:`1118,23,66`},IGNF_FANGA84G:{towgs84:`150.57,158.33,118.32`},IGNF_RUSAT84G:{towgs84:`202.13,174.6,-15.74`},IGNF_KAUE70G:{towgs84:`126.74,300.1,-75.49`},IGNF_MOP90G:{towgs84:`-10.8,-1.8,12.77`},IGNF_MHPF67G:{towgs84:`338.08,212.58,-296.17`},IGNF_TAHI79G:{towgs84:`160.61,116.05,153.69`},IGNF_ANAA92G:{towgs84:`1.5,3.84,4.81`},IGNF_MARQUI72G:{towgs84:`330.91,-13.92,58.56`},IGNF_APAT86G:{towgs84:`143.6,197.82,74.05`},IGNF_TUBU69G:{towgs84:`237.17,171.61,-77.84`},IGNF_STPM50G:{towgs84:`11.363,424.148,373.13`},EPSG_4150:{towgs84:`674.374,15.056,405.346`},EPSG_4754:{towgs84:`-208.4058,-109.8777,-2.5764`},ESRI_104101:{towgs84:`372.87,149.23,585.29`},EPSG_4693:{towgs84:`0,-0.15,0.68`},EPSG_6207:{towgs84:`293.17,726.18,245.36`},EPSG_4153:{towgs84:`-133.63,-157.5,-158.62`},EPSG_4132:{towgs84:`-241.54,-163.64,396.06`},EPSG_4221:{towgs84:`-154.5,150.7,100.4`},EPSG_4266:{towgs84:`-80.7,-132.5,41.1`},EPSG_4193:{towgs84:`-70.9,-151.8,-41.4`},EPSG_5340:{towgs84:`-0.41,0.46,-0.35`},EPSG_4246:{towgs84:`-294.7,-200.1,525.5`},EPSG_4318:{towgs84:`-3.2,-5.7,2.8`},EPSG_4121:{towgs84:`-199.87,74.79,246.62`},EPSG_4223:{towgs84:`-260.1,5.5,432.2`},EPSG_4158:{towgs84:`-0.465,372.095,171.736`},EPSG_4285:{towgs84:`-128.16,-282.42,21.93`},EPSG_4613:{towgs84:`-404.78,685.68,45.47`},EPSG_4607:{towgs84:`195.671,332.517,274.607`},EPSG_4475:{towgs84:`-381.788,-57.501,-256.673`},EPSG_4208:{towgs84:`-157.84,308.54,-146.6`},EPSG_4743:{towgs84:`70.995,-335.916,262.898`},EPSG_4710:{towgs84:`-323.65,551.39,-491.22`},EPSG_7881:{towgs84:`-0.077,0.079,0.086`},EPSG_4682:{towgs84:`283.729,735.942,261.143`},EPSG_4739:{towgs84:`-156,-271,-189`},EPSG_4679:{towgs84:`-80.01,253.26,291.19`},EPSG_4750:{towgs84:`-56.263,16.136,-22.856`},EPSG_4644:{towgs84:`-10.18,-350.43,291.37`},EPSG_4695:{towgs84:`-103.746,-9.614,-255.95`},EPSG_4292:{towgs84:`-355,21,72`},EPSG_4302:{towgs84:`-61.702,284.488,472.052`},EPSG_4143:{towgs84:`-124.76,53,466.79`},EPSG_4606:{towgs84:`-153,153,307`},EPSG_4699:{towgs84:`-770.1,158.4,-498.2`},EPSG_4247:{towgs84:`-273.5,110.6,-357.9`},EPSG_4160:{towgs84:`8.88,184.86,106.69`},EPSG_4161:{towgs84:`-233.43,6.65,173.64`},EPSG_9251:{towgs84:`-9.5,122.9,138.2`},EPSG_9253:{towgs84:`-78.1,101.6,133.3`},EPSG_4297:{towgs84:`-198.383,-240.517,-107.909`},EPSG_4269:{towgs84:`0,0,0`},EPSG_4301:{towgs84:`-147,506,687`},EPSG_4618:{towgs84:`-59,-11,-52`},EPSG_4612:{towgs84:`0,0,0`},EPSG_4678:{towgs84:`44.585,-131.212,-39.544`},EPSG_4250:{towgs84:`-130,29,364`},EPSG_4144:{towgs84:`214,804,268`},EPSG_4147:{towgs84:`-17.51,-108.32,-62.39`},EPSG_4259:{towgs84:`-254.1,-5.36,-100.29`},EPSG_4164:{towgs84:`-76,-138,67`},EPSG_4211:{towgs84:`-378.873,676.002,-46.255`},EPSG_4182:{towgs84:`-422.651,-172.995,84.02`},EPSG_4224:{towgs84:`-143.87,243.37,-33.52`},EPSG_4225:{towgs84:`-205.57,168.77,-4.12`},EPSG_5527:{towgs84:`-67.35,3.88,-38.22`},EPSG_4752:{towgs84:`98,390,-22`},EPSG_4310:{towgs84:`-30,190,89`},EPSG_9248:{towgs84:`-192.26,65.72,132.08`},EPSG_4680:{towgs84:`124.5,-63.5,-281`},EPSG_4701:{towgs84:`-79.9,-158,-168.9`},EPSG_4706:{towgs84:`-146.21,112.63,4.05`},EPSG_4805:{towgs84:`682,-203,480`},EPSG_4201:{towgs84:`-165,-11,206`},EPSG_4210:{towgs84:`-157,-2,-299`},EPSG_4183:{towgs84:`-104,167,-38`},EPSG_4139:{towgs84:`11,72,-101`},EPSG_4668:{towgs84:`-86,-98,-119`},EPSG_4717:{towgs84:`-2,151,181`},EPSG_4732:{towgs84:`102,52,-38`},EPSG_4280:{towgs84:`-377,681,-50`},EPSG_4209:{towgs84:`-138,-105,-289`},EPSG_4261:{towgs84:`31,146,47`},EPSG_4658:{towgs84:`-73,46,-86`},EPSG_4721:{towgs84:`265.025,384.929,-194.046`},EPSG_4222:{towgs84:`-136,-108,-292`},EPSG_4601:{towgs84:`-255,-15,71`},EPSG_4602:{towgs84:`725,685,536`},EPSG_4603:{towgs84:`72,213.7,93`},EPSG_4605:{towgs84:`9,183,236`},EPSG_4621:{towgs84:`137,248,-430`},EPSG_4657:{towgs84:`-28,199,5`},EPSG_4316:{towgs84:`103.25,-100.4,-307.19`},EPSG_4642:{towgs84:`-13,-348,292`},EPSG_4698:{towgs84:`145,-187,103`},EPSG_4192:{towgs84:`-206.1,-174.7,-87.7`},EPSG_4311:{towgs84:`-265,120,-358`},EPSG_4135:{towgs84:`58,-283,-182`},ESRI_104138:{towgs84:`198,-226,-347`},EPSG_4245:{towgs84:`-11,851,5`},EPSG_4142:{towgs84:`-125,53,467`},EPSG_4213:{towgs84:`-106,-87,188`},EPSG_4253:{towgs84:`-133,-77,-51`},EPSG_4129:{towgs84:`-132,-110,-335`},EPSG_4713:{towgs84:`-77,-128,142`},EPSG_4239:{towgs84:`217,823,299`},EPSG_4146:{towgs84:`295,736,257`},EPSG_4155:{towgs84:`-83,37,124`},EPSG_4165:{towgs84:`-173,253,27`},EPSG_4672:{towgs84:`175,-38,113`},EPSG_4236:{towgs84:`-637,-549,-203`},EPSG_4251:{towgs84:`-90,40,88`},EPSG_4271:{towgs84:`-2,374,172`},EPSG_4175:{towgs84:`-88,4,101`},EPSG_4716:{towgs84:`298,-304,-375`},EPSG_4315:{towgs84:`-23,259,-9`},EPSG_4744:{towgs84:`-242.2,-144.9,370.3`},EPSG_4244:{towgs84:`-97,787,86`},EPSG_4293:{towgs84:`616,97,-251`},EPSG_4714:{towgs84:`-127,-769,472`},EPSG_4736:{towgs84:`260,12,-147`},EPSG_6883:{towgs84:`-235,-110,393`},EPSG_6894:{towgs84:`-63,176,185`},EPSG_4205:{towgs84:`-43,-163,45`},EPSG_4256:{towgs84:`41,-220,-134`},EPSG_4262:{towgs84:`639,405,60`},EPSG_4604:{towgs84:`174,359,365`},EPSG_4169:{towgs84:`-115,118,426`},EPSG_4620:{towgs84:`-106,-129,165`},EPSG_4184:{towgs84:`-203,141,53`},EPSG_4616:{towgs84:`-289,-124,60`},EPSG_9403:{towgs84:`-307,-92,127`},EPSG_4684:{towgs84:`-133,-321,50`},EPSG_4708:{towgs84:`-491,-22,435`},EPSG_4707:{towgs84:`114,-116,-333`},EPSG_4709:{towgs84:`145,75,-272`},EPSG_4712:{towgs84:`-205,107,53`},EPSG_4711:{towgs84:`124,-234,-25`},EPSG_4718:{towgs84:`230,-199,-752`},EPSG_4719:{towgs84:`211,147,111`},EPSG_4724:{towgs84:`208,-435,-229`},EPSG_4725:{towgs84:`189,-79,-202`},EPSG_4735:{towgs84:`647,1777,-1124`},EPSG_4722:{towgs84:`-794,119,-298`},EPSG_4728:{towgs84:`-307,-92,127`},EPSG_4734:{towgs84:`-632,438,-609`},EPSG_4727:{towgs84:`912,-58,1227`},EPSG_4729:{towgs84:`185,165,42`},EPSG_4730:{towgs84:`170,42,84`},EPSG_4733:{towgs84:`276,-57,149`},ESRI_37218:{towgs84:`230,-199,-752`},ESRI_37240:{towgs84:`-7,215,225`},ESRI_37221:{towgs84:`252,-209,-751`},ESRI_4305:{towgs84:`-123,-206,219`},ESRI_104139:{towgs84:`-73,-247,227`},EPSG_4748:{towgs84:`51,391,-36`},EPSG_4219:{towgs84:`-384,664,-48`},EPSG_4255:{towgs84:`-333,-222,114`},EPSG_4257:{towgs84:`-587.8,519.75,145.76`},EPSG_4646:{towgs84:`-963,510,-359`},EPSG_6881:{towgs84:`-24,-203,268`},EPSG_6882:{towgs84:`-183,-15,273`},EPSG_4715:{towgs84:`-104,-129,239`},IGNF_RGF93GDD:{towgs84:`0,0,0`},IGNF_RGM04GDD:{towgs84:`0,0,0`},IGNF_RGSPM06GDD:{towgs84:`0,0,0`},IGNF_RGTAAF07GDD:{towgs84:`0,0,0`},IGNF_RGFG95GDD:{towgs84:`0,0,0`},IGNF_RGNCG:{towgs84:`0,0,0`},IGNF_RGPFGDD:{towgs84:`0,0,0`},IGNF_ETRS89G:{towgs84:`0,0,0`},IGNF_RGR92GDD:{towgs84:`0,0,0`},EPSG_4173:{towgs84:`0,0,0`},EPSG_4180:{towgs84:`0,0,0`},EPSG_4619:{towgs84:`0,0,0`},EPSG_4667:{towgs84:`0,0,0`},EPSG_4075:{towgs84:`0,0,0`},EPSG_6706:{towgs84:`0,0,0`},EPSG_7798:{towgs84:`0,0,0`},EPSG_4661:{towgs84:`0,0,0`},EPSG_4669:{towgs84:`0,0,0`},EPSG_8685:{towgs84:`0,0,0`},EPSG_4151:{towgs84:`0,0,0`},EPSG_9702:{towgs84:`0,0,0`},EPSG_4758:{towgs84:`0,0,0`},EPSG_4761:{towgs84:`0,0,0`},EPSG_4765:{towgs84:`0,0,0`},EPSG_8997:{towgs84:`0,0,0`},EPSG_4023:{towgs84:`0,0,0`},EPSG_4670:{towgs84:`0,0,0`},EPSG_4694:{towgs84:`0,0,0`},EPSG_4148:{towgs84:`0,0,0`},EPSG_4163:{towgs84:`0,0,0`},EPSG_4167:{towgs84:`0,0,0`},EPSG_4189:{towgs84:`0,0,0`},EPSG_4190:{towgs84:`0,0,0`},EPSG_4176:{towgs84:`0,0,0`},EPSG_4659:{towgs84:`0,0,0`},EPSG_3824:{towgs84:`0,0,0`},EPSG_3889:{towgs84:`0,0,0`},EPSG_4046:{towgs84:`0,0,0`},EPSG_4081:{towgs84:`0,0,0`},EPSG_4558:{towgs84:`0,0,0`},EPSG_4483:{towgs84:`0,0,0`},EPSG_5013:{towgs84:`0,0,0`},EPSG_5264:{towgs84:`0,0,0`},EPSG_5324:{towgs84:`0,0,0`},EPSG_5354:{towgs84:`0,0,0`},EPSG_5371:{towgs84:`0,0,0`},EPSG_5373:{towgs84:`0,0,0`},EPSG_5381:{towgs84:`0,0,0`},EPSG_5393:{towgs84:`0,0,0`},EPSG_5489:{towgs84:`0,0,0`},EPSG_5593:{towgs84:`0,0,0`},EPSG_6135:{towgs84:`0,0,0`},EPSG_6365:{towgs84:`0,0,0`},EPSG_5246:{towgs84:`0,0,0`},EPSG_7886:{towgs84:`0,0,0`},EPSG_8431:{towgs84:`0,0,0`},EPSG_8427:{towgs84:`0,0,0`},EPSG_8699:{towgs84:`0,0,0`},EPSG_8818:{towgs84:`0,0,0`},EPSG_4757:{towgs84:`0,0,0`},EPSG_9140:{towgs84:`0,0,0`},EPSG_8086:{towgs84:`0,0,0`},EPSG_4686:{towgs84:`0,0,0`},EPSG_4737:{towgs84:`0,0,0`},EPSG_4702:{towgs84:`0,0,0`},EPSG_4747:{towgs84:`0,0,0`},EPSG_4749:{towgs84:`0,0,0`},EPSG_4674:{towgs84:`0,0,0`},EPSG_4755:{towgs84:`0,0,0`},EPSG_4759:{towgs84:`0,0,0`},EPSG_4762:{towgs84:`0,0,0`},EPSG_4763:{towgs84:`0,0,0`},EPSG_4764:{towgs84:`0,0,0`},EPSG_4166:{towgs84:`0,0,0`},EPSG_4170:{towgs84:`0,0,0`},EPSG_5546:{towgs84:`0,0,0`},EPSG_7844:{towgs84:`0,0,0`},EPSG_4818:{towgs84:`589,76,480`},EPSG_10328:{towgs84:`0,0,0`},EPSG_9782:{towgs84:`0,0,0`},EPSG_9777:{towgs84:`0,0,0`},EPSG_10690:{towgs84:`0,0,0`},EPSG_10639:{towgs84:`0,0,0`},EPSG_10739:{towgs84:`0,0,0`},EPSG_7686:{towgs84:`0,0,0`},EPSG_8900:{towgs84:`0,0,0`},EPSG_5886:{towgs84:`0,0,0`},EPSG_7683:{towgs84:`0,0,0`},EPSG_6668:{towgs84:`0,0,0`},EPSG_20046:{towgs84:`0,0,0`},EPSG_10299:{towgs84:`0,0,0`},EPSG_10310:{towgs84:`0,0,0`},EPSG_10475:{towgs84:`0,0,0`},EPSG_4742:{towgs84:`0,0,0`},EPSG_10671:{towgs84:`0,0,0`},EPSG_10762:{towgs84:`0,0,0`},EPSG_10725:{towgs84:`0,0,0`},EPSG_10791:{towgs84:`0,0,0`},EPSG_10800:{towgs84:`0,0,0`},EPSG_10305:{towgs84:`0,0,0`},EPSG_10941:{towgs84:`0,0,0`},EPSG_10968:{towgs84:`0,0,0`},EPSG_10875:{towgs84:`0,0,0`},EPSG_6318:{towgs84:`0,0,0`},EPSG_10910:{towgs84:`0,0,0`}},Pt)Ft=Pt[e],Ft.datumName&&(Pt[Ft.datumName]=Ft)}));function Lt(e,t,n,r,i,a,o){var s={};return e===void 0||e===`none`?s.datum_type=5:s.datum_type=4,t&&(s.datum_params=t.map(parseFloat),(s.datum_params[0]!==0||s.datum_params[1]!==0||s.datum_params[2]!==0)&&(s.datum_type=1),s.datum_params.length>3&&(s.datum_params[3]!==0||s.datum_params[4]!==0||s.datum_params[5]!==0||s.datum_params[6]!==0)&&(s.datum_type=2,s.datum_params[3]*=v,s.datum_params[4]*=v,s.datum_params[5]*=v,s.datum_params[6]=s.datum_params[6]/1e6+1)),o&&(s.datum_type=3,s.grids=o),s.a=n,s.b=r,s.es=i,s.ep2=a,s}var Rt=o((()=>{k()}));function zt(e,t,n){return t instanceof ArrayBuffer?Bt(e,t,n):{ready:Vt(e,t)}}function Bt(e,t,n){var r=!0;n!==void 0&&n.includeErrorFields===!1&&(r=!1);var i=new DataView(t),a=Kt(i),o=qt(i,a),s={header:o,subgrids:Yt(i,o,a,r)};return $t[e]=s,s}async function Vt(e,t){for(var n=[],r=await t.getImageCount(),i=r-1;i>=0;i--){var a=await t.getImage(i),o=await a.readRasters(),s=[a.getWidth(),a.getHeight()],c=a.getBoundingBox().map(Wt),l=[a.fileDirectory.ModelPixelScale[0],a.fileDirectory.ModelPixelScale[1]].map(Wt),u=c[0]+(s[0]-1)*l[0],d=c[3]-(s[1]-1)*l[1],f=o[0],p=o[1],m=[];for(let e=s[1]-1;e>=0;e--)for(let t=s[0]-1;t>=0;t--){var h=e*s[0]+t;m.push([-Gt(p[h]),Gt(f[h])])}n.push({del:l,lim:s,ll:[-u,d],cvs:m})}var g={header:{nSubgrids:r},subgrids:n};return $t[e]=g,g}function Ht(e){return e===void 0?null:e.split(`,`).map(Ut)}function Ut(e){if(e.length===0)return null;var t=e[0]===`@`;return t&&(e=e.slice(1)),e===`null`?{name:`null`,mandatory:!t,grid:null,isNull:!0}:{name:e,mandatory:!t,grid:$t[e]||null,isNull:!1}}function Wt(e){return e*Math.PI/180}function Gt(e){return e/3600*Math.PI/180}function Kt(e){var t=e.getInt32(8,!1);return t===11?!1:(t=e.getInt32(8,!0),t!==11&&console.warn(`Failed to detect nadgrid endian-ness, defaulting to little-endian`),!0)}function qt(e,t){return{nFields:e.getInt32(8,t),nSubgridFields:e.getInt32(24,t),nSubgrids:e.getInt32(40,t),shiftType:Jt(e,56,64).trim(),fromSemiMajorAxis:e.getFloat64(120,t),fromSemiMinorAxis:e.getFloat64(136,t),toSemiMajorAxis:e.getFloat64(152,t),toSemiMinorAxis:e.getFloat64(168,t)}}function Jt(e,t,n){return String.fromCharCode.apply(null,new Uint8Array(e.buffer.slice(t,n)))}function Yt(e,t,n,r){for(var i=176,a=[],o=0;o<t.nSubgrids;o++){var s=Zt(e,i,n),c=Qt(e,i,s,n,r),l=Math.round(1+(s.upperLongitude-s.lowerLongitude)/s.longitudeInterval),u=Math.round(1+(s.upperLatitude-s.lowerLatitude)/s.latitudeInterval);a.push({ll:[Gt(s.lowerLongitude),Gt(s.lowerLatitude)],del:[Gt(s.longitudeInterval),Gt(s.latitudeInterval)],lim:[l,u],count:s.gridNodeCount,cvs:Xt(c)});var d=16;r===!1&&(d=8),i+=176+s.gridNodeCount*d}return a}function Xt(e){return e.map(function(e){return[Gt(e.longitudeShift),Gt(e.latitudeShift)]})}function Zt(e,t,n){return{name:Jt(e,t+8,t+16).trim(),parent:Jt(e,t+24,t+24+8).trim(),lowerLatitude:e.getFloat64(t+72,n),upperLatitude:e.getFloat64(t+88,n),lowerLongitude:e.getFloat64(t+104,n),upperLongitude:e.getFloat64(t+120,n),latitudeInterval:e.getFloat64(t+136,n),longitudeInterval:e.getFloat64(t+152,n),gridNodeCount:e.getInt32(t+168,n)}}function Qt(e,t,n,r,i){var a=t+176,o=16;i===!1&&(o=8);for(var s=[],c=0;c<n.gridNodeCount;c++){var l={latitudeShift:e.getFloat32(a+c*o,r),longitudeShift:e.getFloat32(a+c*o+4,r)};i!==!1&&(l.latitudeAccuracy=e.getFloat32(a+c*o+8,r),l.longitudeAccuracy=e.getFloat32(a+c*o+12,r)),s.push(l)}return s}var $t,en=o((()=>{$t={}}));function tn(e,t){if(!(this instanceof tn))return new tn(e);this.forward=null,this.inverse=null,this.init=null,this.name,this.names=null,this.title,t||=function(e){if(e)throw e};var n=V(e);if(typeof n!=`object`){t(`Could not parse to valid json: `+e);return}var r=tn.projections.get(n.projName);if(!r){t(`Could not get projection name from: `+e);return}if(n.datumCode&&n.datumCode!==`none`){var i=P(Pt,n.datumCode);i&&(n.datum_params=n.datum_params||(i.towgs84?i.towgs84.split(`,`):null),n.ellps=i.ellipse,n.datumName=i.datumName?i.datumName:n.datumCode)}n.k0=n.k0||1,n.axis=n.axis||`enu`,n.ellps=n.ellps||`wgs84`,n.lat1=n.lat1||n.lat0;var a=jt(n.a,n.b,n.rf,n.ellps,n.sphere),o=At(a.a,a.b,a.rf,n.R_A),s=Ht(n.nadgrids),c=n.datum||Lt(n.datumCode,n.datum_params,a.a,a.b,o.es,o.ep2,s);H(this,n),H(this,r),this.a=a.a,this.b=a.b,this.rf=a.rf,this.sphere=a.sphere,this.es=o.es,this.e=o.e,this.ep2=o.ep2,this.datum=c,`init`in this&&typeof this.init==`function`&&this.init(),t(null,this)}var nn=o((()=>{Ze(),Qe(),Dt(),Nt(),It(),Rt(),ee(),en(),tn.projections=Et,tn.projections.start()}));function rn(e,t){return e.datum_type===t.datum_type?e.a!==t.a||Math.abs(e.es-t.es)>5e-11?!1:e.datum_type===1?e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]:e.datum_type===2?e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]&&e.datum_params[3]===t.datum_params[3]&&e.datum_params[4]===t.datum_params[4]&&e.datum_params[5]===t.datum_params[5]&&e.datum_params[6]===t.datum_params[6]:!0:!1}function an(e,t,n){var r=e.x,i=e.y,a=e.z?e.z:0,o,s,c,l;if(i<-y&&i>-1.001*y)i=-y;else if(i>y&&i<1.001*y)i=y;else if(i<-y)return{x:-1/0,y:-1/0,z:e.z};else if(i>y)return{x:1/0,y:1/0,z:e.z};return r>Math.PI&&(r-=2*Math.PI),s=Math.sin(i),l=Math.cos(i),c=s*s,o=n/Math.sqrt(1-t*c),{x:(o+a)*l*Math.cos(r),y:(o+a)*l*Math.sin(r),z:(o*(1-t)+a)*s}}function on(e,t,n,r){var i=1e-12,a=i*i,o=30,s,c,l,u,d,f,p,m,h,g,_,v,b,x=e.x,S=e.y,C=e.z?e.z:0,w,T,E;if(s=Math.sqrt(x*x+S*S),c=Math.sqrt(x*x+S*S+C*C),s/n<i){if(w=0,c/n<i)return T=y,E=-r,{x:e.x,y:e.y,z:e.z}}else w=Math.atan2(S,x);l=C/c,u=s/c,d=1/Math.sqrt(1-t*(2-t)*u*u),m=u*(1-t)*d,h=l*d,b=0;do b++,p=n/Math.sqrt(1-t*h*h),E=s*m+C*h-p*(1-t*h*h),f=t*p/(p+E),d=1/Math.sqrt(1-f*(2-f)*u*u),g=u*(1-f)*d,_=l*d,v=_*m-g*h,m=g,h=_;while(v*v>a&&b<o);return T=Math.atan(_/Math.abs(g)),{x:w,y:T,z:E}}function sn(e,t,n){if(t===1)return{x:e.x+n[0],y:e.y+n[1],z:e.z+n[2]};if(t===2){var r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6];return{x:l*(e.x-c*e.y+s*e.z)+r,y:l*(c*e.x+e.y-o*e.z)+i,z:l*(-s*e.x+o*e.y+e.z)+a}}}function cn(e,t,n){if(t===1)return{x:e.x-n[0],y:e.y-n[1],z:e.z-n[2]};if(t===2){var r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=(e.x-r)/l,d=(e.y-i)/l,f=(e.z-a)/l;return{x:u+c*d-s*f,y:-c*u+d+o*f,z:s*u-o*d+f}}}var ln=o((()=>{k()}));function un(e){return e===1||e===2}function dn(e,t,n){if(rn(e,t)||e.datum_type===5||t.datum_type===5)return n;var r=e.a,i=e.es;if(e.datum_type===3){if(fn(e,!1,n)!==0)return;r=h,i=_}var a=t.a,o=t.b,s=t.es;if(t.datum_type===3&&(a=h,o=g,s=_),i===s&&r===a&&!un(e.datum_type)&&!un(t.datum_type)||(n=an(n,i,r),un(e.datum_type)&&(n=sn(n,e.datum_type,e.datum_params)),un(t.datum_type)&&(n=cn(n,t.datum_type,t.datum_params)),n=on(n,s,a,o),!(t.datum_type===3&&fn(t,!0,n)!==0)))return n}function fn(e,t,n){if(e.grids===null||e.grids.length===0)return console.log(`Grid shift grids not found`),-1;var r={x:-n.x,y:n.y},i={x:NaN,y:NaN},a=[];outer:for(var o=0;o<e.grids.length;o++){var s=e.grids[o];if(a.push(s.name),s.isNull){i=r;break}if(s.grid===null){if(s.mandatory)return console.log(`Unable to find mandatory grid '`+s.name+`'`),-1;continue}for(var c=s.grid.subgrids,l=0,u=c.length;l<u;l++){var d=c[l],f=(Math.abs(d.del[1])+Math.abs(d.del[0]))/1e4,p=d.ll[0]-f,m=d.ll[1]-f,h=d.ll[0]+(d.lim[0]-1)*d.del[0]+f,g=d.ll[1]+(d.lim[1]-1)*d.del[1]+f;if(!(m>r.y||p>r.x||g<r.y||h<r.x)&&(i=pn(r,t,d),!isNaN(i.x)))break outer}}return isNaN(i.x)?(console.log(`Failed to find a grid shift table for location '`+-r.x*T+` `+r.y*T+` tried: '`+a+`'`),-1):(n.x=-i.x,n.y=i.y,0)}function pn(e,t,n){var r={x:NaN,y:NaN};if(isNaN(e.x))return r;var i={x:e.x,y:e.y};i.x-=n.ll[0],i.y-=n.ll[1],i.x=U(i.x-Math.PI)+Math.PI;var a=mn(i,n);if(t){if(isNaN(a.x))return r;a.x=i.x-a.x,a.y=i.y-a.y;var o=9,s=1e-12,c,l;do{if(l=mn(a,n),isNaN(l.x)){console.log(`Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.`);break}c={x:i.x-(l.x+a.x),y:i.y-(l.y+a.y)},a.x+=c.x,a.y+=c.y}while(o--&&Math.abs(c.x)>s&&Math.abs(c.y)>s);if(o<0)return console.log(`Inverse grid shift iterator failed to converge.`),r;r.x=U(a.x+n.ll[0]),r.y=a.y+n.ll[1]}else isNaN(a.x)||(r.x=e.x+a.x,r.y=e.y+a.y);return r}function mn(e,t){var n={x:e.x/t.del[0],y:e.y/t.del[1]},r={x:Math.floor(n.x),y:Math.floor(n.y)},i={x:n.x-1*r.x,y:n.y-1*r.y},a={x:NaN,y:NaN},o;if(r.x<0||r.x>=t.lim[0]||r.y<0||r.y>=t.lim[1])return a;o=r.y*t.lim[0]+r.x;var s={x:t.cvs[o][0],y:t.cvs[o][1]};o++;var c={x:t.cvs[o][0],y:t.cvs[o][1]};o+=t.lim[0];var l={x:t.cvs[o][0],y:t.cvs[o][1]};o--;var u={x:t.cvs[o][0],y:t.cvs[o][1]},d=i.x*i.y,f=i.x*(1-i.y),p=(1-i.x)*(1-i.y),m=(1-i.x)*i.y;return a.x=p*s.x+f*c.x+m*u.x+d*l.x,a.y=p*s.y+f*c.y+m*u.y+d*l.y,a}var hn=o((()=>{k(),ln(),rt()}));function gn(e,t,n){var r=n.x,i=n.y,a=n.z||0,o,s,c,l={};for(c=0;c<3;c++)if(!(t&&c===2&&n.z===void 0))switch(c===0?(o=r,s=`ew`.indexOf(e.axis[c])===-1?`y`:`x`):c===1?(o=i,s=`ns`.indexOf(e.axis[c])===-1?`x`:`y`):(o=a,s=`z`),e.axis[c]){case`e`:l[s]=o;break;case`w`:l[s]=-o;break;case`n`:l[s]=o;break;case`s`:l[s]=-o;break;case`u`:n[s]!==void 0&&(l.z=o);break;case`d`:n[s]!==void 0&&(l.z=-o);break;default:return null}return l}var _n=o((()=>{}));function vn(e){var t={x:e[0],y:e[1]};return e.length>2&&(t.z=e[2]),e.length>3&&(t.m=e[3]),t}var yn=o((()=>{}));function bn(e){xn(e.x),xn(e.y)}function xn(e){if(typeof Number.isFinite==`function`){if(Number.isFinite(e))return;throw TypeError(`coordinates must be finite numbers`)}if(typeof e!=`number`||e!==e||!isFinite(e))throw TypeError(`coordinates must be finite numbers`)}var Sn=o((()=>{}));function Cn(e,t){return(e.datum.datum_type===1||e.datum.datum_type===2||e.datum.datum_type===3)&&t.datumCode!==`WGS84`||(t.datum.datum_type===1||t.datum.datum_type===2||t.datum.datum_type===3)&&e.datumCode!==`WGS84`}function wn(e,t,n,r){var i;n=Array.isArray(n)?vn(n):{x:n.x,y:n.y,z:n.z,m:n.m};var a=n.z!==void 0;if(bn(n),e.datum&&t.datum&&Cn(e,t)&&(i=new tn(`WGS84`),n=wn(e,i,n,r),e=i),r&&e.axis!==`enu`&&(n=gn(e,!1,n)),e.projName===`longlat`)n={x:n.x*w,y:n.y*w,z:n.z||0};else if(e.to_meter&&(n={x:n.x*e.to_meter,y:n.y*e.to_meter,z:n.z||0}),n=e.inverse(n),!n)return;if(e.from_greenwich&&(n.x+=e.from_greenwich),n=dn(e.datum,t.datum,n),n)return n=n,t.from_greenwich&&(n={x:n.x-t.from_greenwich,y:n.y,z:n.z||0}),t.projName===`longlat`?n={x:n.x*T,y:n.y*T,z:n.z||0}:(n=t.forward(n),t.to_meter&&(n={x:n.x/t.to_meter,y:n.y/t.to_meter,z:n.z||0})),r&&t.axis!==`enu`?gn(t,!0,n):(n&&!a&&t.projName!==`geocent`&&delete n.z,n)}var Tn=o((()=>{k(),hn(),_n(),nn(),yn(),Sn()}));function En(e,t,n,r){var i,a,o;return Array.isArray(n)?(i=wn(e,t,n,r)||{x:NaN,y:NaN},n.length>2?e.name!==void 0&&e.name===`geocent`||t.name!==void 0&&t.name===`geocent`?typeof i.z==`number`?[i.x,i.y,i.z].concat(n.slice(3)):[i.x,i.y,n[2]].concat(n.slice(3)):[i.x,i.y].concat(n.slice(2)):[i.x,i.y]):(a=wn(e,t,n,r),o=Object.keys(n),o.length===2||o.forEach(function(r){if(e.name!==void 0&&e.name===`geocent`||t.name!==void 0&&t.name===`geocent`){if(r===`x`||r===`y`||r===`z`)return}else if(r===`x`||r===`y`)return;a[r]=n[r]}),a)}function Dn(e){return e instanceof tn?e:typeof e==`object`&&`oProj`in e?e.oProj:tn(e)}function On(e,t,n){var r,i,a=!1,o;return t===void 0?(i=Dn(e),r=kn,a=!0):(t.x!==void 0||Array.isArray(t))&&(n=t,i=Dn(e),r=kn,a=!0),r||=Dn(e),i||=Dn(t),n?En(r,i,n):(o={forward:function(e,t){return En(r,i,e,t)},inverse:function(e,t){return En(i,r,e,t)}},a&&(o.oProj=i),o)}var kn,An=o((()=>{nn(),Tn(),kn=tn(`WGS84`)}));function jn(e,t){return t||=5,zn(In({lat:e[1],lon:e[0]}),t)}function Mn(e){var t=Ln(Un(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat,t.lon,t.lat]:[t.left,t.bottom,t.right,t.top]}function Nn(e){var t=Ln(Un(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}function Pn(e){return Math.PI/180*e}function Fn(e){return e/Math.PI*180}function In(e){var t=e.lat,n=e.lon,r=6378137,i=.00669438,a=.9996,o,s,c,l,u,d,f,p=Pn(t),m=Pn(n),h,g=Math.floor((n+180)/6)+1;n===180&&(g=60),t>=56&&t<64&&n>=3&&n<12&&(g=32),t>=72&&t<84&&(n>=0&&n<9?g=31:n>=9&&n<21?g=33:n>=21&&n<33?g=35:n>=33&&n<42&&(g=37)),o=(g-1)*6-180+3,h=Pn(o),s=i/(1-i),c=r/Math.sqrt(1-i*Math.sin(p)*Math.sin(p)),l=Math.tan(p)*Math.tan(p),u=s*Math.cos(p)*Math.cos(p),d=Math.cos(p)*(m-h),f=r*((1-i/4-3*i*i/64-5*i*i*i/256)*p-(3*i/8+3*i*i/32+45*i*i*i/1024)*Math.sin(2*p)+(15*i*i/256+45*i*i*i/1024)*Math.sin(4*p)-35*i*i*i/3072*Math.sin(6*p));var _=a*c*(d+(1-l+u)*d*d*d/6+(5-18*l+l*l+72*u-58*s)*d*d*d*d*d/120)+5e5,v=a*(f+c*Math.tan(p)*(d*d/2+(5-l+9*u+4*u*u)*d*d*d*d/24+(61-58*l+l*l+600*u-330*s)*d*d*d*d*d*d/720));return t<0&&(v+=1e7),{northing:Math.round(v),easting:Math.round(_),zoneNumber:g,zoneLetter:Rn(t)}}function Ln(e){var t=e.northing,n=e.easting,r=e.zoneLetter,i=e.zoneNumber;if(i<0||i>60)return null;var a=.9996,o=6378137,s=.00669438,c,l=(1-Math.sqrt(1-s))/(1+Math.sqrt(1-s)),u,d,f,p,m,h,g,_,v,y=n-5e5,b=t;r<`N`&&(b-=1e7),g=(i-1)*6-180+3,c=s/(1-s),h=b/a,_=h/(o*(1-s/4-3*s*s/64-5*s*s*s/256)),v=_+(3*l/2-27*l*l*l/32)*Math.sin(2*_)+(21*l*l/16-55*l*l*l*l/32)*Math.sin(4*_)+151*l*l*l/96*Math.sin(6*_),u=o/Math.sqrt(1-s*Math.sin(v)*Math.sin(v)),d=Math.tan(v)*Math.tan(v),f=c*Math.cos(v)*Math.cos(v),p=o*(1-s)/(1-s*Math.sin(v)*Math.sin(v))**1.5,m=y/(u*a);var x=v-u*Math.tan(v)/p*(m*m/2-(5+3*d+10*f-4*f*f-9*c)*m*m*m*m/24+(61+90*d+298*f+45*d*d-252*c-3*f*f)*m*m*m*m*m*m/720);x=Fn(x);var S=(m-(1+2*d+f)*m*m*m/6+(5-2*f+28*d-3*f*f+8*c+24*d*d)*m*m*m*m*m/120)/Math.cos(v);S=g+Fn(S);var C;if(e.accuracy){var w=Ln({northing:e.northing+e.accuracy,easting:e.easting+e.accuracy,zoneLetter:e.zoneLetter,zoneNumber:e.zoneNumber});C={top:w.lat,right:w.lon,bottom:x,left:S}}else C={lat:x,lon:S};return C}function Rn(e){var t=`Z`;return 84>=e&&e>=72?t=`X`:72>e&&e>=64?t=`W`:64>e&&e>=56?t=`V`:56>e&&e>=48?t=`U`:48>e&&e>=40?t=`T`:40>e&&e>=32?t=`S`:32>e&&e>=24?t=`R`:24>e&&e>=16?t=`Q`:16>e&&e>=8?t=`P`:8>e&&e>=0?t=`N`:0>e&&e>=-8?t=`M`:-8>e&&e>=-16?t=`L`:-16>e&&e>=-24?t=`K`:-24>e&&e>=-32?t=`J`:-32>e&&e>=-40?t=`H`:-40>e&&e>=-48?t=`G`:-48>e&&e>=-56?t=`F`:-56>e&&e>=-64?t=`E`:-64>e&&e>=-72?t=`D`:-72>e&&e>=-80&&(t=`C`),t}function zn(e,t){var n=`00000`+e.easting,r=`00000`+e.northing;return e.zoneNumber+e.zoneLetter+Bn(e.easting,e.northing,e.zoneNumber)+n.substr(n.length-5,t)+r.substr(r.length-5,t)}function Bn(e,t,n){var r=Vn(n);return Hn(Math.floor(e/1e5),Math.floor(t/1e5)%20,r)}function Vn(e){var t=e%qn;return t===0&&(t=qn),t}function Hn(e,t,n){var r=n-1,i=Jn.charCodeAt(r),a=Yn.charCodeAt(r),o=i+e-1,s=a+t,c=!1;return o>er&&(o=o-er+Xn-1,c=!0),(o===Zn||i<Zn&&o>Zn||(o>Zn||i<Zn)&&c)&&o++,(o===Qn||i<Qn&&o>Qn||(o>Qn||i<Qn)&&c)&&(o++,o===Zn&&o++),o>er&&(o=o-er+Xn-1),s>$n?(s=s-$n+Xn-1,c=!0):c=!1,(s===Zn||a<Zn&&s>Zn||(s>Zn||a<Zn)&&c)&&s++,(s===Qn||a<Qn&&s>Qn||(s>Qn||a<Qn)&&c)&&(s++,s===Zn&&s++),s>$n&&(s=s-$n+Xn-1),String.fromCharCode(o)+String.fromCharCode(s)}function Un(e){if(e&&e.length===0)throw`MGRSPoint coverting from nothing`;for(var t=e.length,n=null,r=``,i,a=0;!/[A-Z]/.test(i=e.charAt(a));){if(a>=2)throw`MGRSPoint bad conversion from: `+e;r+=i,a++}var o=parseInt(r,10);if(a===0||a+3>t)throw`MGRSPoint bad conversion from: `+e;var s=e.charAt(a++);if(s<=`A`||s===`B`||s===`Y`||s>=`Z`||s===`I`||s===`O`)throw`MGRSPoint zone letter `+s+` not handled: `+e;n=e.substring(a,a+=2);for(var c=Vn(o),l=Wn(n.charAt(0),c),u=Gn(n.charAt(1),c);u<Kn(s);)u+=2e6;var d=t-a;if(d%2!=0)throw`MGRSPoint has to have an even number
|
||
of digits after the zone letter and two 100km letters - front
|
||
half for easting meters, second half for
|
||
northing meters`+e;var f=d/2,p=0,m=0,h,g,_,v,y;return f>0&&(h=1e5/10**f,g=e.substring(a,a+f),p=parseFloat(g)*h,_=e.substring(a+f),m=parseFloat(_)*h),v=p+l,y=m+u,{easting:v,northing:y,zoneLetter:s,zoneNumber:o,accuracy:h}}function Wn(e,t){for(var n=Jn.charCodeAt(t-1),r=1e5,i=!1;n!==e.charCodeAt(0);){if(n++,n===Zn&&n++,n===Qn&&n++,n>er){if(i)throw`Bad character: `+e;n=Xn,i=!0}r+=1e5}return r}function Gn(e,t){if(e>`V`)throw`MGRSPoint given invalid Northing `+e;for(var n=Yn.charCodeAt(t-1),r=0,i=!1;n!==e.charCodeAt(0);){if(n++,n===Zn&&n++,n===Qn&&n++,n>$n){if(i)throw`Bad character: `+e;n=Xn,i=!0}r+=1e5}return r}function Kn(e){var t;switch(e){case`C`:t=11e5;break;case`D`:t=2e6;break;case`E`:t=28e5;break;case`F`:t=37e5;break;case`G`:t=46e5;break;case`H`:t=55e5;break;case`J`:t=64e5;break;case`K`:t=73e5;break;case`L`:t=82e5;break;case`M`:t=91e5;break;case`N`:t=0;break;case`P`:t=8e5;break;case`Q`:t=17e5;break;case`R`:t=26e5;break;case`S`:t=35e5;break;case`T`:t=44e5;break;case`U`:t=53e5;break;case`V`:t=62e5;break;case`W`:t=7e6;break;case`X`:t=79e5;break;default:t=-1}if(t>=0)return t;throw`Invalid zone letter: `+e}var qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr=o((()=>{qn=6,Jn=`AJSAJS`,Yn=`AFAFAF`,Xn=65,Zn=73,Qn=79,$n=86,er=90,tr={forward:jn,inverse:Mn,toPoint:Nn}}));function rr(e,t,n){if(!(this instanceof rr))return new rr(e,t,n);if(Array.isArray(e))this.x=e[0],this.y=e[1],this.z=e[2]||0;else if(typeof e==`object`)this.x=e.x,this.y=e.y,this.z=e.z||0;else if(typeof e==`string`&&t===void 0){var r=e.split(`,`);this.x=parseFloat(r[0]),this.y=parseFloat(r[1]),this.z=parseFloat(r[2])||0}else this.x=e,this.y=t,this.z=n||0;console.warn(`proj4.Point will be removed in version 3, use proj4.toPoint`)}var ir=o((()=>{nr(),rr.fromMGRS=function(e){return new rr(Nn(e))},rr.prototype.toMGRS=function(e){return jn([this.x,this.y],e)}}));function ar(e){var t=[];t[0]=or-e*(sr+e*(cr+e*(lr+e*ur))),t[1]=e*(dr-e*(cr+e*(lr+e*ur)));var n=e*e;return t[2]=n*(fr-e*(pr+e*mr)),n*=e,t[3]=n*(hr-e*gr),t[4]=n*e*_r,t}var or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr=o((()=>{or=1,sr=.25,cr=.046875,lr=.01953125,ur=.01068115234375,dr=.75,fr=.46875,pr=.013020833333333334,mr=.007120768229166667,hr=.3645833333333333,gr=.005696614583333333,_r=.3076171875}));function yr(e,t,n,r){return n*=t,t*=t,r[0]*e-n*(r[1]+t*(r[2]+t*(r[3]+t*r[4])))}var br=o((()=>{}));function xr(e,t,n){for(var r=1/(1-t),i=e,a=Sr;a;--a){var o=Math.sin(i),s=1-t*o*o;if(s=(yr(i,o,Math.cos(i),n)-e)*(s*Math.sqrt(s))*r,i-=s,Math.abs(s)<1e-10)return i}return i}var Sr,Cr=o((()=>{br(),k(),Sr=20}));function wr(){this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0,this.long0=this.long0===void 0?0:this.long0,this.lat0=this.lat0===void 0?0:this.lat0,this.es&&(this.en=ar(this.es),this.ml0=yr(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Tr(e){var t=e.x,n=e.y,r=U(t-this.long0,this.over),i,a,o,s=Math.sin(n),c=Math.cos(n);if(this.es){var l=c*r,u=l**2,d=this.ep2*c**2,f=d**2,p=(Math.abs(c)>1e-10?Math.tan(n):0)**2,m=p**2;i=1-this.es*s**2,l/=Math.sqrt(i);var h=yr(n,s,c,this.en);a=this.a*(this.k0*l*(1+u/6*(1-p+d+u/20*(5-18*p+m+14*d-58*p*d+u/42*(61+179*m-m*p-479*p)))))+this.x0,o=this.a*(this.k0*(h-this.ml0+s*r*l/2*(1+u/12*(5-p+9*d+4*f+u/30*(61+m-58*p+270*d-330*p*d+u/56*(1385+543*m-m*p-3111*p))))))+this.y0}else{var g=c*Math.sin(r);if(Math.abs(Math.abs(g)-1)<1e-10)return 93;if(a=.5*this.a*this.k0*Math.log((1+g)/(1-g))+this.x0,o=c*Math.cos(r)/Math.sqrt(1-g**2),g=Math.abs(o),g>=1){if(g-1>1e-10)return 93;o=0}else o=Math.acos(o);n<0&&(o=-o),o=this.a*this.k0*(o-this.lat0)+this.y0}return e.x=a,e.y=o,e}function Er(e){var t,n,r,i,a=(e.x-this.x0)*(1/this.a),o=(e.y-this.y0)*(1/this.a);if(!this.es){var s=Math.exp(a/this.k0),c=.5*(s-1/s),l=this.lat0+o/this.k0,u=Math.cos(l);t=Math.sqrt((1-u**2)/(1+c**2)),r=Math.asin(t),o<0&&(r=-r),i=c===0&&u===0?0:U(Math.atan2(c,u)+this.long0,this.over)}else if(t=this.ml0+o/this.k0,n=xr(t,this.es,this.en),Math.abs(n)<y){var d=Math.sin(n),f=Math.cos(n),p=Math.abs(f)>1e-10?Math.tan(n):0,m=this.ep2*f**2,h=m**2,g=p**2,_=g**2;t=1-this.es*d**2;var v=a*Math.sqrt(t)/this.k0,b=v**2;t*=p,r=n-t*b/(1-this.es)*.5*(1-b/12*(5+3*g-9*m*g+m-4*h-b/30*(61+90*g-252*m*g+45*_+46*m-b/56*(1385+3633*g+4095*_+1574*_*g)))),i=U(this.long0+v*(1-b/6*(1+2*g+m-b/20*(5+28*g+24*_+8*m*g+6*m-b/42*(61+662*g+1320*_+720*_*g))))/f,this.over)}else r=y*tt(o),i=0;return e.x=i,e.y=r,e}var Dr,Or,kr=o((()=>{vr(),br(),Cr(),rt(),k(),nt(),Dr=[`Fast_Transverse_Mercator`,`Fast Transverse Mercator`],Or={init:wr,forward:Tr,inverse:Er,names:Dr}}));function Ar(e){var t=Math.exp(e);return t=(t-1/t)/2,t}var jr=o((()=>{}));function Mr(e,t){e=Math.abs(e),t=Math.abs(t);var n=Math.max(e,t),r=Math.min(e,t)/(n||1);return n*Math.sqrt(1+r**2)}var Nr=o((()=>{}));function Pr(e){var t=1+e,n=t-1;return n===0?e:e*Math.log(t)/n}var Fr=o((()=>{}));function Ir(e){var t=Math.abs(e);return t=Pr(t*(1+t/(Mr(1,t)+1))),e<0?-t:t}var Lr=o((()=>{Nr(),Fr()}));function Rr(e,t){for(var n=2*Math.cos(2*t),r=e.length-1,i=e[r],a=0,o;--r>=0;)o=-a+n*i+e[r],a=i,i=o;return t+o*Math.sin(2*t)}var zr=o((()=>{}));function Br(e,t){for(var n=2*Math.cos(t),r=e.length-1,i=e[r],a=0,o;--r>=0;)o=-a+n*i+e[r],a=i,i=o;return Math.sin(t)*o}var Vr=o((()=>{}));function Hr(e){var t=Math.exp(e);return t=(t+1/t)/2,t}var Ur=o((()=>{}));function Wr(e,t,n){for(var r=Math.sin(t),i=Math.cos(t),a=Ar(n),o=Hr(n),s=2*i*o,c=-2*r*a,l=e.length-1,u=e[l],d=0,f=0,p=0,m,h;--l>=0;)m=f,h=d,f=u,d=p,u=-m+s*f-c*d+e[l],p=-h+c*f+s*d;return s=r*o,c=i*a,[s*u-c*p,s*p+c*u]}var Gr=o((()=>{jr(),Ur()}));function Kr(){if(!this.approx&&(isNaN(this.es)||this.es<=0))throw Error(`Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.`);this.approx&&(Or.init.apply(this),this.forward=Or.forward,this.inverse=Or.inverse),this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0,this.long0=this.long0===void 0?0:this.long0,this.lat0=this.lat0===void 0?0:this.lat0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var e=this.es/(1+Math.sqrt(1-this.es)),t=e/(2-e),n=t;this.cgb[0]=t*(2+t*(-2/3+t*(-2+t*(116/45+t*(26/45+-2854/675*t))))),this.cbg[0]=t*(-2+t*(2/3+t*(4/3+t*(-82/45+t*(32/45+4642/4725*t))))),n*=t,this.cgb[1]=n*(7/3+t*(-8/5+t*(-227/45+t*(2704/315+2323/945*t)))),this.cbg[1]=n*(5/3+t*(-16/15+t*(-13/9+t*(904/315+-1522/945*t)))),n*=t,this.cgb[2]=n*(56/15+t*(-136/35+t*(-1262/105+73814/2835*t))),this.cbg[2]=n*(-26/15+t*(34/21+t*(8/5+-12686/2835*t))),n*=t,this.cgb[3]=n*(4279/630+t*(-332/35+-399572/14175*t)),this.cbg[3]=n*(1237/630+t*(-12/5+-24832/14175*t)),n*=t,this.cgb[4]=n*(4174/315+-144838/6237*t),this.cbg[4]=n*(-734/315+109598/31185*t),n*=t,this.cgb[5]=601676/22275*n,this.cbg[5]=444337/155925*n,n=t**2,this.Qn=this.k0/(1+t)*(1+n*(1/4+n*(1/64+n/256))),this.utg[0]=t*(-.5+t*(2/3+t*(-37/96+t*(1/360+t*(81/512+-96199/604800*t))))),this.gtu[0]=t*(.5+t*(-2/3+t*(5/16+t*(41/180+t*(-127/288+7891/37800*t))))),this.utg[1]=n*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+1118711/3870720*t)))),this.gtu[1]=n*(13/48+t*(-3/5+t*(557/1440+t*(281/630+-1983433/1935360*t)))),n*=t,this.utg[2]=n*(-17/480+t*(37/840+t*(209/4480+-5569/90720*t))),this.gtu[2]=n*(61/240+t*(-103/140+t*(15061/26880+167603/181440*t))),n*=t,this.utg[3]=n*(-4397/161280+t*(11/504+830251/7257600*t)),this.gtu[3]=n*(49561/161280+t*(-179/168+6601661/7257600*t)),n*=t,this.utg[4]=n*(-4583/161280+108847/3991680*t),this.gtu[4]=n*(34729/80640+-3418889/1995840*t),n*=t,this.utg[5]=-20648693/638668800*n,this.gtu[5]=212378941/319334400*n;var r=Rr(this.cbg,this.lat0);this.Zb=-this.Qn*(r+Br(this.gtu,2*r))}function qr(e){var t=U(e.x-this.long0,this.over),n=e.y;n=Rr(this.cbg,n);var r=Math.sin(n),i=Math.cos(n),a=Math.sin(t),o=Math.cos(t);n=Math.atan2(r,o*i),t=Math.atan2(a*i,Mr(r,i*o)),t=Ir(Math.tan(t));var s=Wr(this.gtu,2*n,2*t);n+=s[0],t+=s[1];var c,l;return Math.abs(t)<=2.623395162778?(c=this.a*(this.Qn*t)+this.x0,l=this.a*(this.Qn*n+this.Zb)+this.y0):(c=1/0,l=1/0),e.x=c,e.y=l,e}function Jr(e){var t=(e.x-this.x0)*(1/this.a),n=(e.y-this.y0)*(1/this.a);n=(n-this.Zb)/this.Qn,t/=this.Qn;var r,i;if(Math.abs(t)<=2.623395162778){var a=Wr(this.utg,2*n,2*t);n+=a[0],t+=a[1],t=Math.atan(Ar(t));var o=Math.sin(n),s=Math.cos(n),c=Math.sin(t),l=Math.cos(t);n=Math.atan2(o*l,Mr(c,l*s)),t=Math.atan2(c,l*s),r=U(t+this.long0,this.over),i=Rr(this.cgb,n)}else r=1/0,i=1/0;return e.x=r,e.y=i,e}var Yr,Xr,Zr=o((()=>{kr(),jr(),Nr(),Lr(),zr(),Vr(),Gr(),rt(),Yr=[`Extended_Transverse_Mercator`,`Extended Transverse Mercator`,`etmerc`,`Transverse_Mercator`,`Transverse Mercator`,`Gauss Kruger`,`Gauss_Kruger`,`tmerc`],Xr={init:Kr,forward:qr,inverse:Jr,names:Yr}}));function Qr(e,t){if(e===void 0){if(e=Math.floor((U(t)+Math.PI)*30/Math.PI)+1,e<0)return 0;if(e>60)return 60}return e}var $r=o((()=>{rt()}));function ei(){var e=Qr(this.zone,this.long0);if(e===void 0)throw Error(`unknown utm zone`);this.lat0=0,this.long0=(6*Math.abs(e)-183)*w,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,Xr.init.apply(this),this.forward=Xr.forward,this.inverse=Xr.inverse}var ti,ni,ri,ii=o((()=>{$r(),Zr(),k(),ti=`etmerc`,ni=[`Universal Transverse Mercator System`,`utm`],ri={init:ei,names:ni,dependsOn:ti}}));function ai(e,t){return((1-e)/(1+e))**t}var oi=o((()=>{}));function si(){var e=Math.sin(this.lat0),t=Math.cos(this.lat0);t*=t,this.rc=Math.sqrt(1-this.es)/(1-this.es*e*e),this.C=Math.sqrt(1+this.es*t*t/(1-this.es)),this.phic0=Math.asin(e/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+E)/(Math.tan(.5*this.lat0+E)**+this.C*ai(this.e*e,this.ratexp))}function ci(e){var t=e.x,n=e.y;return e.y=2*Math.atan(this.K*Math.tan(.5*n+E)**+this.C*ai(this.e*Math.sin(n),this.ratexp))-y,e.x=this.C*t,e}function li(e){for(var t=1e-14,n=e.x/this.C,r=e.y,i=(Math.tan(.5*r+E)/this.K)**(1/this.C),a=ui;a>0&&(r=2*Math.atan(i*ai(this.e*Math.sin(e.y),-.5*this.e))-y,!(Math.abs(r-e.y)<t));--a)e.y=r;return a?(e.x=n,e.y=r,e):null}var ui,di,fi,pi=o((()=>{oi(),k(),ui=20,di=[`gauss`],fi={init:si,forward:ci,inverse:li,names:di}}));function mi(){fi.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||=`Oblique Stereographic Alternative`)}function hi(e){var t,n,r,i;return e.x=U(e.x-this.long0,this.over),fi.forward.apply(this,[e]),t=Math.sin(e.y),n=Math.cos(e.y),r=Math.cos(e.x),i=this.k0*this.R2/(1+this.sinc0*t+this.cosc0*n*r),e.x=i*n*Math.sin(e.x),e.y=i*(this.cosc0*t-this.sinc0*n*r),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function gi(e){var t,n,r,i,a;if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,a=Mr(e.x,e.y)){var o=2*Math.atan2(a,this.R2);t=Math.sin(o),n=Math.cos(o),i=Math.asin(n*this.sinc0+e.y*t*this.cosc0/a),r=Math.atan2(e.x*t,a*this.cosc0*n-e.y*this.sinc0*t)}else i=this.phic0,r=0;return e.x=r,e.y=i,fi.inverse.apply(this,[e]),e.x=U(e.x+this.long0,this.over),e}var _i,vi,yi=o((()=>{pi(),rt(),Nr(),_i=[`Stereographic_North_Pole`,`Oblique_Stereographic`,`sterea`,`Oblique Stereographic Alternative`,`Double_Stereographic`],vi={init:mi,forward:hi,inverse:gi,names:_i}}));function bi(e,t,n){return t*=n,Math.tan(.5*(y+e))*((1-t)/(1+t))**(.5*n)}function xi(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=1e-10&&(this.k0=.5*(1+tt(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=1e-10&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt((1+this.e)**+(1+this.e)*(1-this.e)**(1-this.e)),this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=1e-10&&Math.abs(Math.cos(this.lat_ts))>1e-10&&(this.k0=.5*this.cons*$e(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/it(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=$e(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(bi(this.lat0,this.sinlat0,this.e))-y,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function Si(e){var t=e.x,n=e.y,r=Math.sin(n),i=Math.cos(n),a,o,s,c,l,u,d=U(t-this.long0,this.over);return Math.abs(Math.abs(t-this.long0)-Math.PI)<=1e-10&&Math.abs(n+this.lat0)<=1e-10?(e.x=NaN,e.y=NaN,e):this.sphere?(a=2*this.k0/(1+this.sinlat0*r+this.coslat0*i*Math.cos(d)),e.x=this.a*a*i*Math.sin(d)+this.x0,e.y=this.a*a*(this.coslat0*r-this.sinlat0*i*Math.cos(d))+this.y0,e):(o=2*Math.atan(bi(n,r,this.e))-y,c=Math.cos(o),s=Math.sin(o),Math.abs(this.coslat0)<=1e-10?(l=it(this.e,n*this.con,this.con*r),u=2*this.a*this.k0*l/this.cons,e.x=this.x0+u*Math.sin(t-this.long0),e.y=this.y0-this.con*u*Math.cos(t-this.long0),e):(Math.abs(this.sinlat0)<1e-10?(a=2*this.a*this.k0/(1+c*Math.cos(d)),e.y=a*s):(a=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*s+this.cosX0*c*Math.cos(d))),e.y=a*(this.cosX0*s-this.sinX0*c*Math.cos(d))+this.y0),e.x=a*c*Math.sin(d)+this.x0,e))}function Ci(e){e.x-=this.x0,e.y-=this.y0;var t,n,r,i,a,o=Math.sqrt(e.x*e.x+e.y*e.y);if(this.sphere){var s=2*Math.atan(o/(2*this.a*this.k0));return t=this.long0,n=this.lat0,o<=1e-10?(e.x=t,e.y=n,e):(n=Math.asin(Math.cos(s)*this.sinlat0+e.y*Math.sin(s)*this.coslat0/o),t=Math.abs(this.coslat0)<1e-10?this.lat0>0?U(this.long0+Math.atan2(e.x,-1*e.y),this.over):U(this.long0+Math.atan2(e.x,e.y),this.over):U(this.long0+Math.atan2(e.x*Math.sin(s),o*this.coslat0*Math.cos(s)-e.y*this.sinlat0*Math.sin(s)),this.over),e.x=t,e.y=n,e)}else if(Math.abs(this.coslat0)<=1e-10){if(o<=1e-10)return n=this.lat0,t=this.long0,e.x=t,e.y=n,e;e.x*=this.con,e.y*=this.con,r=o*this.cons/(2*this.a*this.k0),n=this.con*ot(this.e,r),t=this.con*U(this.con*this.long0+Math.atan2(e.x,-1*e.y),this.over)}else i=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),t=this.long0,o<=1e-10?a=this.X0:(a=Math.asin(Math.cos(i)*this.sinX0+e.y*Math.sin(i)*this.cosX0/o),t=U(this.long0+Math.atan2(e.x*Math.sin(i),o*this.cosX0*Math.cos(i)-e.y*this.sinX0*Math.sin(i)),this.over)),n=-1*ot(this.e,Math.tan(.5*(y+a)));return e.x=t,e.y=n,e}var wi,Ti,Ei=o((()=>{k(),nt(),et(),at(),st(),rt(),wi=[`stere`,`Stereographic_South_Pole`,`Polar_Stereographic_variant_A`,`Polar_Stereographic_variant_B`,`Polar_Stereographic`],Ti={init:xi,forward:Si,inverse:Ci,names:wi,ssfn_:bi}}));function Di(){var e=this.lat0;this.lambda0=this.long0;var t=Math.sin(e),n=this.a,r=1/this.rf,i=2*r-r**2,a=this.e=Math.sqrt(i);this.R=this.k0*n*Math.sqrt(1-i)/(1-i*t**2),this.alpha=Math.sqrt(1+i/(1-i)*Math.cos(e)**4),this.b0=Math.asin(t/this.alpha);var o=Math.log(Math.tan(Math.PI/4+this.b0/2)),s=Math.log(Math.tan(Math.PI/4+e/2)),c=Math.log((1+a*t)/(1-a*t));this.K=o-this.alpha*s+this.alpha*a/2*c}function Oi(e){var t=Math.log(Math.tan(Math.PI/4-e.y/2)),n=this.e/2*Math.log((1+this.e*Math.sin(e.y))/(1-this.e*Math.sin(e.y))),r=-this.alpha*(t+n)+this.K,i=2*(Math.atan(Math.exp(r))-Math.PI/4),a=this.alpha*(e.x-this.lambda0),o=Math.atan(Math.sin(a)/(Math.sin(this.b0)*Math.tan(i)+Math.cos(this.b0)*Math.cos(a))),s=Math.asin(Math.cos(this.b0)*Math.sin(i)-Math.sin(this.b0)*Math.cos(i)*Math.cos(a));return e.y=this.R/2*Math.log((1+Math.sin(s))/(1-Math.sin(s)))+this.y0,e.x=this.R*o+this.x0,e}function ki(e){for(var t=e.x-this.x0,n=e.y-this.y0,r=t/this.R,i=2*(Math.atan(Math.exp(n/this.R))-Math.PI/4),a=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(r)),o=Math.atan(Math.sin(r)/(Math.cos(this.b0)*Math.cos(r)-Math.sin(this.b0)*Math.tan(i))),s=this.lambda0+o/this.alpha,c=0,l=a,u=-1e3,d=0;Math.abs(l-u)>1e-7;){if(++d>20)return;c=1/this.alpha*(Math.log(Math.tan(Math.PI/4+a/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(l))/2)),u=l,l=2*Math.atan(Math.exp(c))-Math.PI/2}return e.x=s,e.y=l,e}var Ai,ji,Mi=o((()=>{Ai=[`somerc`],ji={init:Di,forward:Oi,inverse:ki,names:Ai}}));function Ni(e){var t=[`Hotine_Oblique_Mercator`,`Hotine_Oblique_Mercator_variant_A`,`Hotine_Oblique_Mercator_Azimuth_Natural_Origin`],n=typeof e.projName==`object`?Object.keys(e.projName)[0]:e.projName;return`no_uoff`in e||`no_off`in e||t.indexOf(n)!==-1||t.indexOf(bt(n))!==-1}function Pi(){var e,t,n,r,i,a,o,s,c,l,u=0,d,f=0,p=0,m=0,h=0,g=0,_=0;this.no_off=Ni(this),this.no_rot=`no_rot`in this;var v=!1;`alpha`in this&&(v=!0);var b=!1;if(`rectified_grid_angle`in this&&(b=!0),v&&(_=this.alpha),b&&(u=this.rectified_grid_angle),v||b)f=this.longc;else if(p=this.long1,h=this.lat1,m=this.long2,g=this.lat2,Math.abs(h-g)<=Li||(e=Math.abs(h))<=Li||Math.abs(e-y)<=Li||Math.abs(Math.abs(this.lat0)-y)<=Li||Math.abs(Math.abs(g)-y)<=Li)throw Error();var x=1-this.es;t=Math.sqrt(x),Math.abs(this.lat0)>1e-10?(s=Math.sin(this.lat0),n=Math.cos(this.lat0),e=1-this.es*s*s,this.B=n*n,this.B=Math.sqrt(1+this.es*this.B*this.B/x),this.A=this.B*this.k0*t/e,r=this.B*t/(n*Math.sqrt(e)),i=r*r-1,i<=0?i=0:(i=Math.sqrt(i),this.lat0<0&&(i=-i)),this.E=i+=r,this.E*=it(this.e,this.lat0,s)**+this.B):(this.B=1/t,this.A=this.k0,this.E=r=i=1),v||b?(v?(d=Math.asin(Math.sin(_)/r),b||(u=_)):(d=u,_=Math.asin(r*Math.sin(d))),this.lam0=f-Math.asin(.5*(i-1/i)*Math.tan(d))/this.B):(a=it(this.e,h,Math.sin(h))**+this.B,o=it(this.e,g,Math.sin(g))**+this.B,i=this.E/a,c=(o-a)/(o+a),l=this.E*this.E,l=(l-o*a)/(l+o*a),e=p-m,e<-Math.PI?m-=D:e>Math.PI&&(m+=D),this.lam0=U(.5*(p+m)-Math.atan(l*Math.tan(.5*this.B*(p-m))/c)/this.B,this.over),d=Math.atan(2*Math.sin(this.B*U(p-this.lam0,this.over))/(i-1/i)),u=_=Math.asin(r*Math.sin(d))),this.singam=Math.sin(d),this.cosgam=Math.cos(d),this.sinrot=Math.sin(u),this.cosrot=Math.cos(u),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.no_off?this.u_0=0:(this.u_0=Math.abs(this.ArB*Math.atan(Math.sqrt(r*r-1)/Math.cos(_))),this.lat0<0&&(this.u_0=-this.u_0)),i=.5*d,this.v_pole_n=this.ArB*Math.log(Math.tan(E-i)),this.v_pole_s=this.ArB*Math.log(Math.tan(E+i))}function Fi(e){var t={},n,r,i,a,o,s,c,l;if(e.x-=this.lam0,Math.abs(Math.abs(e.y)-y)>1e-10){if(o=this.E/it(this.e,e.y,Math.sin(e.y))**+this.B,s=1/o,n=.5*(o-s),r=.5*(o+s),a=Math.sin(this.B*e.x),i=(n*this.singam-a*this.cosgam)/r,Math.abs(Math.abs(i)-1)<1e-10)throw Error();l=.5*this.ArB*Math.log((1-i)/(1+i)),s=Math.cos(this.B*e.x),c=Math.abs(s)<Li?this.A*e.x:this.ArB*Math.atan2(n*this.cosgam+a*this.singam,s)}else l=e.y>0?this.v_pole_n:this.v_pole_s,c=this.ArB*e.y;return this.no_rot?(t.x=c,t.y=l):(c-=this.u_0,t.x=l*this.cosrot+c*this.sinrot,t.y=c*this.cosrot-l*this.sinrot),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function Ii(e){var t,n,r,i,a,o,s,c={};if(e.x=(e.x-this.x0)*(1/this.a),e.y=(e.y-this.y0)*(1/this.a),this.no_rot?(n=e.y,t=e.x):(n=e.x*this.cosrot-e.y*this.sinrot,t=e.y*this.cosrot+e.x*this.sinrot+this.u_0),r=Math.exp(-this.BrA*n),i=.5*(r-1/r),a=.5*(r+1/r),o=Math.sin(this.BrA*t),s=(o*this.cosgam+i*this.singam)/a,Math.abs(Math.abs(s)-1)<1e-10)c.x=0,c.y=s<0?-y:y;else{if(c.y=this.E/Math.sqrt((1+s)/(1-s)),c.y=ot(this.e,c.y**(1/this.B)),c.y===1/0)throw Error();c.x=-this.rB*Math.atan2(i*this.cosgam-o*this.singam,Math.cos(this.BrA*t))}return c.x+=this.lam0,c}var Li,Ri,zi,Bi=o((()=>{at(),rt(),st(),k(),Dt(),Li=1e-7,Ri=[`Hotine_Oblique_Mercator`,`Hotine Oblique Mercator`,`Hotine_Oblique_Mercator_variant_A`,`Hotine_Oblique_Mercator_Variant_B`,`Hotine_Oblique_Mercator_Azimuth_Natural_Origin`,`Hotine_Oblique_Mercator_Two_Point_Natural_Origin`,`Hotine_Oblique_Mercator_Azimuth_Center`,`Oblique_Mercator`,`omerc`],zi={init:Pi,forward:Fi,inverse:Ii,names:Ri}}));function Vi(){if(this.lat2||=this.lat1,this.k0||=1,this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<1e-10)){var e=this.b/this.a;this.e=Math.sqrt(1-e*e);var t=Math.sin(this.lat1),n=Math.cos(this.lat1),r=$e(this.e,t,n),i=it(this.e,this.lat1,t),a=Math.sin(this.lat2),o=Math.cos(this.lat2),s=$e(this.e,a,o),c=it(this.e,this.lat2,a),l=Math.abs(Math.abs(this.lat0)-y)<1e-10?0:it(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>1e-10?this.ns=Math.log(r/s)/Math.log(i/c):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=r/(this.ns*i**+this.ns),this.rh=this.a*this.f0*l**+this.ns,this.title||=`Lambert Conformal Conic`}}function Hi(e){var t=e.x,n=e.y;Math.abs(2*Math.abs(n)-Math.PI)<=1e-10&&(n=tt(n)*(y-2*C));var r=Math.abs(Math.abs(n)-y),i,a;if(r>1e-10)i=it(this.e,n,Math.sin(n)),a=this.a*this.f0*i**+this.ns;else{if(r=n*this.ns,r<=0)return null;a=0}var o=this.ns*U(t-this.long0,this.over);return e.x=this.k0*(a*Math.sin(o))+this.x0,e.y=this.k0*(this.rh-a*Math.cos(o))+this.y0,e}function Ui(e){var t,n,r,i,a,o=(e.x-this.x0)/this.k0,s=this.rh-(e.y-this.y0)/this.k0;this.ns>0?(t=Math.sqrt(o*o+s*s),n=1):(t=-Math.sqrt(o*o+s*s),n=-1);var c=0;if(t!==0&&(c=Math.atan2(n*o,n*s)),t!==0||this.ns>0){if(n=1/this.ns,r=(t/(this.a*this.f0))**+n,i=ot(this.e,r),i===-9999)return null}else i=-y;return a=U(c/this.ns+this.long0,this.over),e.x=a,e.y=i,e}var Wi,Gi,Ki=o((()=>{et(),at(),nt(),rt(),st(),k(),Wi=[`Lambert Tangential Conformal Conic Projection`,`Lambert_Conformal_Conic`,`Lambert_Conformal_Conic_1SP`,`Lambert_Conformal_Conic_2SP`,`lcc`,`Lambert Conic Conformal (1SP)`,`Lambert Conic Conformal (2SP)`],Gi={init:Vi,forward:Hi,inverse:Ui,names:Wi}}));function qi(){this.a=6377397.155,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||=.863937979737193,this.long0||=.4334234309119251,this.k0||=.9999,this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.cos(this.fi0)**4/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)))**(this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.tan(this.fi0/2+this.s45)**+this.alfa*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.sin(this.fi0)**2),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq}function Ji(e){var t,n,r,i,a,o,s,c=e.x,l=e.y,u=U(c-this.long0,this.over);return t=((1+this.e*Math.sin(l))/(1-this.e*Math.sin(l)))**(this.alfa*this.e/2),n=2*(Math.atan(this.k*Math.tan(l/2+this.s45)**+this.alfa/t)-this.s45),r=-u*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(n)+Math.sin(this.ad)*Math.cos(n)*Math.cos(r)),a=Math.asin(Math.cos(n)*Math.sin(r)/Math.cos(i)),o=this.n*a,s=this.ro0*Math.tan(this.s0/2+this.s45)**+this.n/Math.tan(i/2+this.s45)**+this.n,e.y=s*Math.cos(o)/1,e.x=s*Math.sin(o)/1,this.czech||(e.y*=-1,e.x*=-1),e}function Yi(e){var t,n,r,i,a,o,s,c,l=e.x;e.x=e.y,e.y=l,this.czech||(e.y*=-1,e.x*=-1),o=Math.sqrt(e.x*e.x+e.y*e.y),a=Math.atan2(e.y,e.x),i=a/Math.sin(this.s0),r=2*(Math.atan((this.ro0/o)**(1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),t=Math.asin(Math.cos(this.ad)*Math.sin(r)-Math.sin(this.ad)*Math.cos(r)*Math.cos(i)),n=Math.asin(Math.cos(r)*Math.sin(i)/Math.cos(t)),e.x=this.long0-n/this.alfa,s=t,c=0;var u=0;do e.y=2*(Math.atan(this.k**(-1/this.alfa)*Math.tan(t/2+this.s45)**(1/this.alfa)*((1+this.e*Math.sin(s))/(1-this.e*Math.sin(s)))**(this.e/2))-this.s45),Math.abs(s-e.y)<1e-10&&(c=1),s=e.y,u+=1;while(c===0&&u<15);return u>=15?null:e}var Xi,Zi,Qi=o((()=>{rt(),Xi=[`Krovak`,`Krovak Modified`,`Krovak (North Orientated)`,`Krovak Modified (North Orientated)`,`krovak`],Zi={init:qi,forward:Ji,inverse:Yi,names:Xi}}));function $i(e,t,n,r,i){return e*i-t*Math.sin(2*i)+n*Math.sin(4*i)-r*Math.sin(6*i)}var ea=o((()=>{}));function ta(e){return 1-.25*e*(1+e/16*(3+1.25*e))}var na=o((()=>{}));function ra(e){return .375*e*(1+.25*e*(1+.46875*e))}var ia=o((()=>{}));function aa(e){return .05859375*e*e*(1+.75*e)}var oa=o((()=>{}));function sa(e){return e*e*e*(35/3072)}var ca=o((()=>{}));function la(e,t,n){var r=t*n;return e/Math.sqrt(1-r*r)}var ua=o((()=>{}));function da(e){return Math.abs(e)<y?e:e-tt(e)*Math.PI}var fa=o((()=>{k(),nt()}));function pa(e,t,n,r,i){for(var a=e/t,o,s=0;s<15;s++)if(o=(e-(t*a-n*Math.sin(2*a)+r*Math.sin(4*a)-i*Math.sin(6*a)))/(t-2*n*Math.cos(2*a)+4*r*Math.cos(4*a)-6*i*Math.cos(6*a)),a+=o,Math.abs(o)<=1e-10)return a;return NaN}var ma=o((()=>{}));function ha(){this.sphere||(this.e0=ta(this.es),this.e1=ra(this.es),this.e2=aa(this.es),this.e3=sa(this.es),this.ml0=this.a*$i(this.e0,this.e1,this.e2,this.e3,this.lat0))}function ga(e){var t,n,r=e.x,i=e.y;if(r=U(r-this.long0,this.over),this.sphere)t=this.a*Math.asin(Math.cos(i)*Math.sin(r)),n=this.a*(Math.atan2(Math.tan(i),Math.cos(r))-this.lat0);else{var a=Math.sin(i),o=Math.cos(i),s=la(this.a,this.e,a),c=Math.tan(i)*Math.tan(i),l=r*Math.cos(i),u=l*l,d=this.es*o*o/(1-this.es),f=this.a*$i(this.e0,this.e1,this.e2,this.e3,i);t=s*l*(1-u*c*(1/6-(8-c+8*d)*u/120)),n=f-this.ml0+s*a/o*u*(.5+(5-c+6*d)*u/24)}return e.x=t+this.x0,e.y=n+this.y0,e}function _a(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,n=e.y/this.a,r,i;if(this.sphere){var a=n+this.lat0;r=Math.asin(Math.sin(a)*Math.cos(t)),i=Math.atan2(Math.tan(t),Math.cos(a))}else{var o=pa(this.ml0/this.a+n,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(o)-y)<=1e-10)return e.x=this.long0,e.y=y,n<0&&(e.y*=-1),e;var s=la(this.a,this.e,Math.sin(o)),c=s*s*s/this.a/this.a*(1-this.es),l=Math.tan(o)**2,u=t*this.a/s,d=u*u;r=o-s*Math.tan(o)/c*u*u*(.5-(1+3*l)*u*u/24),i=u*(1-d*(l/3+(1+3*l)*l*d/15))/Math.cos(o)}return e.x=U(i+this.long0,this.over),e.y=da(r),e}var va,ya,ba=o((()=>{ea(),na(),ia(),oa(),ca(),ua(),rt(),fa(),ma(),k(),va=[`Cassini`,`Cassini_Soldner`,`cass`],ya={init:ha,forward:ga,inverse:_a,names:va}}));function W(e,t){var n;return e>1e-7?(n=e*t,(1-e*e)*(t/(1-n*n)-.5/e*Math.log((1-n)/(1+n)))):2*t}var xa=o((()=>{}));function Sa(){var e=Math.abs(this.lat0);if(Math.abs(e-y)<1e-10?this.mode=this.lat0<0?1:2:Math.abs(e)<1e-10?this.mode=3:this.mode=4,this.es>0){var t;switch(this.qp=W(this.e,1),this.mmf=.5/(1-this.es),this.apa=Ta(this.es),this.mode){case 2:this.dd=1;break;case 1:this.dd=1;break;case 3:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case 4:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=W(this.e,t)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*t*t)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd;break}}else this.mode===4&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function Ca(e){var t,n,r,i,a,o,s,c,l,u,d=e.x,f=e.y;if(d=U(d-this.long0,this.over),this.sphere){if(a=Math.sin(f),u=Math.cos(f),r=Math.cos(d),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(n=this.mode===this.EQUIT?1+u*r:1+this.sinph0*a+this.cosph0*u*r,n<=1e-10)return null;n=Math.sqrt(2/n),t=n*u*Math.sin(d),n*=this.mode===this.EQUIT?a:this.cosph0*a-this.sinph0*u*r}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(r=-r),Math.abs(f+this.lat0)<1e-10)return null;n=E-f*.5,n=2*(this.mode===this.S_POLE?Math.cos(n):Math.sin(n)),t=n*Math.sin(d),n*=r}}else{switch(s=0,c=0,l=0,r=Math.cos(d),i=Math.sin(d),a=Math.sin(f),o=W(this.e,a),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(s=o/this.qp,c=Math.sqrt(1-s*s)),this.mode){case this.OBLIQ:l=1+this.sinb1*s+this.cosb1*c*r;break;case this.EQUIT:l=1+c*r;break;case this.N_POLE:l=y+f,o=this.qp-o;break;case this.S_POLE:l=f-y,o=this.qp+o;break}if(Math.abs(l)<1e-10)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:l=Math.sqrt(2/l),n=this.mode===this.OBLIQ?this.ymf*l*(this.cosb1*s-this.sinb1*c*r):(l=Math.sqrt(2/(1+c*r)))*s*this.ymf,t=this.xmf*l*c*i;break;case this.N_POLE:case this.S_POLE:o>=0?(t=(l=Math.sqrt(o))*i,n=r*(this.mode===this.S_POLE?l:-l)):t=n=0;break}}return e.x=this.a*t+this.x0,e.y=this.a*n+this.y0,e}function wa(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,n=e.y/this.a,r,i,a,o,s,c,l;if(this.sphere){var u=0,d,f=0;if(d=Math.sqrt(t*t+n*n),i=d*.5,i>1)return null;switch(i=2*Math.asin(i),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(f=Math.sin(i),u=Math.cos(i)),this.mode){case this.EQUIT:i=Math.abs(d)<=1e-10?0:Math.asin(n*f/d),t*=f,n=u*d;break;case this.OBLIQ:i=Math.abs(d)<=1e-10?this.lat0:Math.asin(u*this.sinph0+n*f*this.cosph0/d),t*=f*this.cosph0,n=(u-Math.sin(i)*this.sinph0)*d;break;case this.N_POLE:n=-n,i=y-i;break;case this.S_POLE:i-=y;break}r=n===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(t,n)}else{if(l=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(t/=this.dd,n*=this.dd,c=Math.sqrt(t*t+n*n),c<1e-10)return e.x=this.long0,e.y=this.lat0,e;o=2*Math.asin(.5*c/this.rq),a=Math.cos(o),t*=o=Math.sin(o),this.mode===this.OBLIQ?(l=a*this.sinb1+n*o*this.cosb1/c,s=this.qp*l,n=c*this.cosb1*a-n*this.sinb1*o):(l=n*o/c,s=this.qp*l,n=c*a)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(n=-n),s=t*t+n*n,!s)return e.x=this.long0,e.y=this.lat0,e;l=1-s/this.qp,this.mode===this.S_POLE&&(l=-l)}r=Math.atan2(t,n),i=Ea(Math.asin(l),this.apa)}return e.x=U(this.long0+r,this.over),e.y=i,e}function Ta(e){var t,n=[];return n[0]=e*Da,t=e*e,n[0]+=t*Oa,n[1]=t*Aa,t*=e,n[0]+=t*ka,n[1]+=t*ja,n[2]=t*Ma,n}function Ea(e,t){var n=e+e;return e+t[0]*Math.sin(n)+t[1]*Math.sin(n+n)+t[2]*Math.sin(n+n+n)}var Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa=o((()=>{k(),xa(),rt(),Da=.3333333333333333,Oa=.17222222222222222,ka=.10257936507936508,Aa=.06388888888888888,ja=.0664021164021164,Ma=.016415012942191543,Na=[`Lambert Azimuthal Equal Area`,`Lambert_Azimuthal_Equal_Area`,`laea`],Pa={init:Sa,forward:Ca,inverse:wa,names:Na,S_POLE:1,N_POLE:2,EQUIT:3,OBLIQ:4}}));function Ia(e){return Math.abs(e)>1&&(e=e>1?1:-1),Math.asin(e)}var La=o((()=>{}));function Ra(){Math.abs(this.lat1+this.lat2)<1e-10||(this.temp=this.b/this.a,this.es=1-this.temp**2,this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=$e(this.e3,this.sin_po,this.cos_po),this.qs1=W(this.e3,this.sin_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=$e(this.e3,this.sin_po,this.cos_po),this.qs2=W(this.e3,this.sin_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=W(this.e3,this.sin_po),Math.abs(this.lat1-this.lat2)>1e-10?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)}function za(e){var t=e.x,n=e.y;this.sin_phi=Math.sin(n),this.cos_phi=Math.cos(n);var r=W(this.e3,this.sin_phi),i=this.a*Math.sqrt(this.c-this.ns0*r)/this.ns0,a=this.ns0*U(t-this.long0,this.over),o=i*Math.sin(a)+this.x0,s=this.rh-i*Math.cos(a)+this.y0;return e.x=o,e.y=s,e}function Ba(e){var t,n,r,i,a,o;return e.x-=this.x0,e.y=this.rh-e.y+this.y0,this.ns0>=0?(t=Math.sqrt(e.x*e.x+e.y*e.y),r=1):(t=-Math.sqrt(e.x*e.x+e.y*e.y),r=-1),i=0,t!==0&&(i=Math.atan2(r*e.x,r*e.y)),r=t*this.ns0/this.a,this.sphere?o=Math.asin((this.c-r*r)/(2*this.ns0)):(n=(this.c-r*r)/this.ns0,o=this.phi1z(this.e3,n)),a=U(i/this.ns0+this.long0,this.over),e.x=a,e.y=o,e}function Va(e,t){var n,r,i,a,o,s=Ia(.5*t);if(e<1e-10)return s;for(var c=e*e,l=1;l<=25;l++)if(n=Math.sin(s),r=Math.cos(s),i=e*n,a=1-i*i,o=.5*a*a/r*(t/(1-c)-n/a+.5/e*Math.log((1-i)/(1+i))),s+=o,Math.abs(o)<=1e-7)return s;return null}var Ha,Ua,Wa=o((()=>{et(),xa(),rt(),La(),k(),Ha=[`Albers_Conic_Equal_Area`,`Albers_Equal_Area`,`Albers`,`aea`],Ua={init:Ra,forward:za,inverse:Ba,names:Ha,phi1z:Va}}));function Ga(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function Ka(e){var t,n,r,i,a,o,s,c,l=e.x,u=e.y;return r=U(l-this.long0,this.over),t=Math.sin(u),n=Math.cos(u),i=Math.cos(r),o=this.sin_p14*t+this.cos_p14*n*i,a=1,o>0||Math.abs(o)<=1e-10?(s=this.x0+this.a*a*n*Math.sin(r)/o,c=this.y0+this.a*a*(this.cos_p14*t-this.sin_p14*n*i)/o):(s=this.x0+this.infinity_dist*n*Math.sin(r),c=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*n*i)),e.x=s,e.y=c,e}function qa(e){var t,n,r,i,a,o;return e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,(t=Math.sqrt(e.x*e.x+e.y*e.y))?(i=Math.atan2(t,this.rc),n=Math.sin(i),r=Math.cos(i),o=Ia(r*this.sin_p14+e.y*n*this.cos_p14/t),a=Math.atan2(e.x*n,t*this.cos_p14*r-e.y*this.sin_p14*n),a=U(this.long0+a,this.over)):(o=this.phic0,a=0),e.x=a,e.y=o,e}var Ja,Ya,Xa=o((()=>{rt(),La(),k(),Ja=[`gnom`],Ya={init:Ga,forward:Ka,inverse:qa,names:Ja}}));function Za(e,t){var n=1-(1-e*e)/(2*e)*Math.log((1-e)/(1+e));if(Math.abs(Math.abs(t)-n)<1e-6)return t<0?-1*y:y;for(var r=Math.asin(.5*t),i,a,o,s,c=0;c<30;c++)if(a=Math.sin(r),o=Math.cos(r),s=e*a,i=(1-s*s)**2/(2*o)*(t/(1-e*e)-a/(1-s*s)+.5/e*Math.log((1-s)/(1+s))),r+=i,Math.abs(i)<=1e-10)return r;return NaN}var Qa=o((()=>{k()}));function $a(){this.sphere||(this.k0=$e(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function eo(e){var t=e.x,n=e.y,r,i,a=U(t-this.long0,this.over);if(this.sphere)r=this.x0+this.a*a*Math.cos(this.lat_ts),i=this.y0+this.a*Math.sin(n)/Math.cos(this.lat_ts);else{var o=W(this.e,Math.sin(n));r=this.x0+this.a*this.k0*a,i=this.y0+this.a*o*.5/this.k0}return e.x=r,e.y=i,e}function to(e){e.x-=this.x0,e.y-=this.y0;var t,n;return this.sphere?(t=U(this.long0+e.x/this.a/Math.cos(this.lat_ts),this.over),n=Math.asin(e.y/this.a*Math.cos(this.lat_ts))):(n=Za(this.e,2*e.y*this.k0/this.a),t=U(this.long0+e.x/(this.a*this.k0),this.over)),e.x=t,e.y=n,e}var no,ro,io=o((()=>{rt(),xa(),et(),Qa(),no=[`cea`],ro={init:$a,forward:eo,inverse:to,names:no}}));function ao(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||`Equidistant Cylindrical (Plate Carre)`,this.rc=Math.cos(this.lat_ts)}function oo(e){var t=e.x,n=e.y,r=U(t-this.long0,this.over),i=da(n-this.lat0);return e.x=this.x0+this.a*r*this.rc,e.y=this.y0+this.a*i,e}function so(e){var t=e.x,n=e.y;return e.x=U(this.long0+(t-this.x0)/(this.a*this.rc),this.over),e.y=da(this.lat0+(n-this.y0)/this.a),e}var co,lo,uo=o((()=>{rt(),fa(),co=[`Equirectangular`,`Equidistant_Cylindrical`,`Equidistant_Cylindrical_Spherical`,`eqc`],lo={init:ao,forward:oo,inverse:so,names:co}}));function fo(){this.temp=this.b/this.a,this.es=1-this.temp**2,this.e=Math.sqrt(this.es),this.e0=ta(this.es),this.e1=ra(this.es),this.e2=aa(this.es),this.e3=sa(this.es),this.ml0=this.a*$i(this.e0,this.e1,this.e2,this.e3,this.lat0)}function po(e){var t=e.x,n=e.y,r,i,a,o=U(t-this.long0,this.over);if(a=o*Math.sin(n),this.sphere)Math.abs(n)<=1e-10?(r=this.a*o,i=-1*this.a*this.lat0):(r=this.a*Math.sin(a)/Math.tan(n),i=this.a*(da(n-this.lat0)+(1-Math.cos(a))/Math.tan(n)));else if(Math.abs(n)<=1e-10)r=this.a*o,i=-1*this.ml0;else{var s=la(this.a,this.e,Math.sin(n))/Math.tan(n);r=s*Math.sin(a),i=this.a*$i(this.e0,this.e1,this.e2,this.e3,n)-this.ml0+s*(1-Math.cos(a))}return e.x=r+this.x0,e.y=i+this.y0,e}function mo(e){var t,n,r=e.x-this.x0,i=e.y-this.y0,a,o,s,c,l;if(this.sphere)if(Math.abs(i+this.a*this.lat0)<=1e-10)t=U(r/this.a+this.long0,this.over),n=0;else{o=this.lat0+i/this.a,s=r*r/this.a/this.a+o*o,c=o;var u;for(a=ho;a;--a)if(u=Math.tan(c),l=-1*(o*(c*u+1)-c-.5*(c*c+s)*u)/((c-o)/u-1),c+=l,Math.abs(l)<=1e-10){n=c;break}t=U(this.long0+Math.asin(r*Math.tan(c)/this.a)/Math.sin(n),this.over)}else if(Math.abs(i+this.ml0)<=1e-10)n=0,t=U(this.long0+r/this.a,this.over);else{o=(this.ml0+i)/this.a,s=r*r/this.a/this.a+o*o,c=o;var d,f,p,m,h;for(a=ho;a;--a)if(h=this.e*Math.sin(c),d=Math.sqrt(1-h*h)*Math.tan(c),f=this.a*$i(this.e0,this.e1,this.e2,this.e3,c),p=this.e0-2*this.e1*Math.cos(2*c)+4*this.e2*Math.cos(4*c)-6*this.e3*Math.cos(6*c),m=f/this.a,l=(o*(d*m+1)-m-.5*d*(m*m+s))/(this.es*Math.sin(2*c)*(m*m+s-2*o*m)/(4*d)+(o-m)*(d*p-2/Math.sin(2*c))-p),c-=l,Math.abs(l)<=1e-10){n=c;break}d=Math.sqrt(1-this.es*Math.sin(n)**2)*Math.tan(n),t=U(this.long0+Math.asin(r*d/this.a)/Math.sin(n),this.over)}return e.x=t,e.y=n,e}var ho,go,_o,vo=o((()=>{na(),ia(),oa(),ca(),rt(),fa(),ea(),k(),ua(),ho=20,go=[`Polyconic`,`American_Polyconic`,`poly`],_o={init:fo,forward:po,inverse:mo,names:go}}));function yo(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013}function bo(e){var t,n=e.x,r=e.y-this.lat0,i=n-this.long0,a=r/v*1e-5,o=i,s=1,c=0;for(t=1;t<=10;t++)s*=a,c+=this.A[t]*s;var l=c,u=o,d=1,f=0,p,m,h=0,g=0;for(t=1;t<=6;t++)p=d*l-f*u,m=f*l+d*u,d=p,f=m,h=h+this.B_re[t]*d-this.B_im[t]*f,g=g+this.B_im[t]*d+this.B_re[t]*f;return e.x=g*this.a+this.x0,e.y=h*this.a+this.y0,e}function xo(e){var t,n=e.x,r=e.y,i=n-this.x0,a=(r-this.y0)/this.a,o=i/this.a,s=1,c=0,l,u,d=0,f=0;for(t=1;t<=6;t++)l=s*a-c*o,u=c*a+s*o,s=l,c=u,d=d+this.C_re[t]*s-this.C_im[t]*c,f=f+this.C_im[t]*s+this.C_re[t]*c;for(var p=0;p<this.iterations;p++){var m=d,h=f,g,_,y=a,b=o;for(t=2;t<=6;t++)g=m*d-h*f,_=h*d+m*f,m=g,h=_,y+=(t-1)*(this.B_re[t]*m-this.B_im[t]*h),b+=(t-1)*(this.B_im[t]*m+this.B_re[t]*h);m=1,h=0;var x=this.B_re[1],S=this.B_im[1];for(t=2;t<=6;t++)g=m*d-h*f,_=h*d+m*f,m=g,h=_,x+=t*(this.B_re[t]*m-this.B_im[t]*h),S+=t*(this.B_im[t]*m+this.B_re[t]*h);var C=x*x+S*S;d=(y*x+b*S)/C,f=(b*x-y*S)/C}var w=d,T=f,E=1,D=0;for(t=1;t<=9;t++)E*=w,D+=this.D[t]*E;var O=this.lat0+D*v*1e5;return e.x=this.long0+T,e.y=O,e}var So,Co,wo=o((()=>{k(),So=[`New_Zealand_Map_Grid`,`nzmg`],Co={init:yo,forward:bo,inverse:xo,names:So}}));function To(){}function Eo(e){var t=e.x,n=e.y,r=U(t-this.long0,this.over),i=this.x0+this.a*r,a=this.y0+this.a*Math.log(Math.tan(Math.PI/4+n/2.5))*1.25;return e.x=i,e.y=a,e}function Do(e){e.x-=this.x0,e.y-=this.y0;var t=U(this.long0+e.x/this.a,this.over),n=2.5*(Math.atan(Math.exp(.8*e.y/this.a))-Math.PI/4);return e.x=t,e.y=n,e}var Oo,ko,Ao=o((()=>{rt(),Oo=[`Miller_Cylindrical`,`mill`],ko={init:To,forward:Eo,inverse:Do,names:Oo}}));function jo(){this.long0=this.long0||0,this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=ar(this.es)}function Mo(e){var t,n,r=e.x,i=e.y;if(r=U(r-this.long0,this.over),this.sphere){if(!this.m)i=this.n===1?i:Math.asin(this.n*Math.sin(i));else for(var a=this.n*Math.sin(i),o=Po;o;--o){var s=(this.m*i+Math.sin(i)-a)/(this.m+Math.cos(i));if(i-=s,Math.abs(s)<1e-10)break}t=this.a*this.C_x*r*(this.m+Math.cos(i)),n=this.a*this.C_y*i}else{var c=Math.sin(i),l=Math.cos(i);n=this.a*yr(i,c,l,this.en),t=this.a*r*l/Math.sqrt(1-this.es*c*c)}return e.x=t,e.y=n,e}function No(e){var t,n,r,i;return e.x-=this.x0,r=e.x/this.a,e.y-=this.y0,t=e.y/this.a,this.sphere?(t/=this.C_y,r/=this.C_x*(this.m+Math.cos(t)),this.m?t=Ia((this.m*t+Math.sin(t))/this.n):this.n!==1&&(t=Ia(Math.sin(t)/this.n)),r=U(r+this.long0,this.over),t=da(t)):(t=xr(e.y/this.a,this.es,this.en),i=Math.abs(t),i<y?(i=Math.sin(t),n=this.long0+e.x*Math.sqrt(1-this.es*i*i)/(this.a*Math.cos(t)),r=U(n,this.over)):i-1e-10<y&&(r=this.long0)),e.x=r,e.y=t,e}var Po,Fo,Io,Lo=o((()=>{rt(),fa(),vr(),br(),Cr(),k(),La(),Po=20,Fo=[`Sinusoidal`,`sinu`],Io={init:jo,forward:Mo,inverse:No,names:Fo}}));function Ro(){this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0,this.long0=this.long0===void 0?0:this.long0}function zo(e){for(var t=e.x,n=e.y,r=U(t-this.long0,this.over),i=n,a=Math.PI*Math.sin(n);;){var o=-(i+Math.sin(i)-a)/(1+Math.cos(i));if(i+=o,Math.abs(o)<1e-10)break}i/=2,Math.PI/2-Math.abs(n)<1e-10&&(r=0);var s=.900316316158*this.a*r*Math.cos(i)+this.x0,c=1.4142135623731*this.a*Math.sin(i)+this.y0;return e.x=s,e.y=c,e}function Bo(e){var t,n;e.x-=this.x0,e.y-=this.y0,n=e.y/(1.4142135623731*this.a),Math.abs(n)>.999999999999&&(n=.999999999999),t=Math.asin(n);var r=U(this.long0+e.x/(.900316316158*this.a*Math.cos(t)),this.over);r<-Math.PI&&(r=-Math.PI),r>Math.PI&&(r=Math.PI),n=(2*t+Math.sin(2*t))/Math.PI,Math.abs(n)>1&&(n=1);var i=Math.asin(n);return e.x=r,e.y=i,e}var Vo,Ho,Uo=o((()=>{rt(),k(),Vo=[`Mollweide`,`moll`],Ho={init:Ro,forward:zo,inverse:Bo,names:Vo}}));function Wo(){Math.abs(this.lat1+this.lat2)<1e-10||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-this.temp**2,this.e=Math.sqrt(this.es),this.e0=ta(this.es),this.e1=ra(this.es),this.e2=aa(this.es),this.e3=sa(this.es),this.sin_phi=Math.sin(this.lat1),this.cos_phi=Math.cos(this.lat1),this.ms1=$e(this.e,this.sin_phi,this.cos_phi),this.ml1=$i(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<1e-10?this.ns=this.sin_phi:(this.sin_phi=Math.sin(this.lat2),this.cos_phi=Math.cos(this.lat2),this.ms2=$e(this.e,this.sin_phi,this.cos_phi),this.ml2=$i(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=$i(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))}function Go(e){var t=e.x,n=e.y,r;if(this.sphere)r=this.a*(this.g-n);else{var i=$i(this.e0,this.e1,this.e2,this.e3,n);r=this.a*(this.g-i)}var a=this.ns*U(t-this.long0,this.over),o=this.x0+r*Math.sin(a),s=this.y0+this.rh-r*Math.cos(a);return e.x=o,e.y=s,e}function Ko(e){e.x-=this.x0,e.y=this.rh-e.y+this.y0;var t,n,r,i;this.ns>=0?(n=Math.sqrt(e.x*e.x+e.y*e.y),t=1):(n=-Math.sqrt(e.x*e.x+e.y*e.y),t=-1);var a=0;return n!==0&&(a=Math.atan2(t*e.x,t*e.y)),this.sphere?(i=U(this.long0+a/this.ns,this.over),r=da(this.g-n/this.a),e.x=i,e.y=r,e):(r=pa(this.g-n/this.a,this.e0,this.e1,this.e2,this.e3),i=U(this.long0+a/this.ns,this.over),e.x=i,e.y=r,e)}var qo,Jo,Yo=o((()=>{na(),ia(),oa(),ca(),et(),ea(),rt(),fa(),ma(),k(),qo=[`Equidistant_Conic`,`eqdc`],Jo={init:Wo,forward:Go,inverse:Ko,names:qo}}));function Xo(){this.R=this.a}function Zo(e){var t=e.x,n=e.y,r=U(t-this.long0,this.over),i,a;Math.abs(n)<=1e-10&&(i=this.x0+this.R*r,a=this.y0);var o=Ia(2*Math.abs(n/Math.PI));(Math.abs(r)<=1e-10||Math.abs(Math.abs(n)-y)<=1e-10)&&(i=this.x0,a=n>=0?this.y0+Math.PI*this.R*Math.tan(.5*o):this.y0+Math.PI*this.R*-Math.tan(.5*o));var s=.5*Math.abs(Math.PI/r-r/Math.PI),c=s*s,l=Math.sin(o),u=Math.cos(o),d=u/(l+u-1),f=d*d,p=d*(2/l-1),m=p*p,h=Math.PI*this.R*(s*(d-m)+Math.sqrt(c*(d-m)*(d-m)-(m+c)*(f-m)))/(m+c);r<0&&(h=-h),i=this.x0+h;var g=c+d;return h=Math.PI*this.R*(p*g-s*Math.sqrt((m+c)*(c+1)-g*g))/(m+c),a=n>=0?this.y0+h:this.y0-h,e.x=i,e.y=a,e}function Qo(e){var t,n,r,i,a,o,s,c,l,u,d,f,p;return e.x-=this.x0,e.y-=this.y0,d=Math.PI*this.R,r=e.x/d,i=e.y/d,a=r*r+i*i,o=-Math.abs(i)*(1+a),s=o-2*i*i+r*r,c=-2*o+1+2*i*i+a*a,p=i*i/c+(2*s*s*s/c/c/c-9*o*s/c/c)/27,l=(o-s*s/3/c)/c,u=2*Math.sqrt(-l/3),d=3*p/l/u,Math.abs(d)>1&&(d=d>=0?1:-1),f=Math.acos(d)/3,n=e.y>=0?(-u*Math.cos(f+Math.PI/3)-s/3/c)*Math.PI:-(-u*Math.cos(f+Math.PI/3)-s/3/c)*Math.PI,t=Math.abs(r)<1e-10?this.long0:U(this.long0+Math.PI*(a-1+Math.sqrt(1+2*(r*r-i*i)+a*a))/2/r,this.over),e.x=t,e.y=n,e}var $o,es,ts=o((()=>{rt(),k(),La(),$o=[`Van_der_Grinten_I`,`VanDerGrinten`,`Van_der_Grinten`,`vandg`],es={init:Xo,forward:Zo,inverse:Qo,names:$o}}));function ns(e,t,n,r,i,a){let o=r-t,s=Math.atan((1-a)*Math.tan(e)),c=Math.atan((1-a)*Math.tan(n)),l=Math.sin(s),u=Math.cos(s),d=Math.sin(c),f=Math.cos(c),p=o,m,h=100,g,_,v,y,b,x,S,C,w,T,E,D,O,k;do{if(g=Math.sin(p),_=Math.cos(p),v=Math.sqrt(f*g*(f*g)+(u*d-l*f*_)*(u*d-l*f*_)),v===0)return{azi1:0,s12:0};y=l*d+u*f*_,b=Math.atan2(v,y),x=u*f*g/v,S=1-x*x,C=S===0?0:y-2*l*d/S,w=a/16*S*(4+a*(4-3*S)),m=p,p=o+(1-w)*a*x*(b+w*v*(C+w*y*(-1+2*C*C)))}while(Math.abs(p-m)>1e-12&&--h>0);return h===0?{azi1:NaN,s12:NaN}:(T=S*(i*i-i*(1-a)*(i*(1-a)))/(i*(1-a)*(i*(1-a))),E=1+T/16384*(4096+T*(-768+T*(320-175*T))),D=T/1024*(256+T*(-128+T*(74-47*T))),O=D*v*(C+D/4*(y*(-1+2*C*C)-D/6*C*(-3+4*v*v)*(-3+4*C*C))),k=i*(1-a)*E*(b-O),{azi1:Math.atan2(f*g,u*d-l*f*_),s12:k})}function rs(e,t,n,r,i,a){let o=Math.atan((1-a)*Math.tan(e)),s=Math.sin(o),c=Math.cos(o),l=Math.sin(n),u=Math.cos(n),d=Math.atan2(s,c*u),f=c*l,p=1-f*f,m=p*(i*i-i*(1-a)*(i*(1-a)))/(i*(1-a)*(i*(1-a))),h=1+m/16384*(4096+m*(-768+m*(320-175*m))),g=m/1024*(256+m*(-128+m*(74-47*m))),_=r/(i*(1-a)*h),v,y=100,b,x,S,C;do b=Math.cos(2*d+_),x=Math.sin(_),S=Math.cos(_),C=g*x*(b+g/4*(S*(-1+2*b*b)-g/6*b*(-3+4*x*x)*(-3+4*b*b))),v=_,_=r/(i*(1-a)*h)+C;while(Math.abs(_-v)>1e-12&&--y>0);if(y===0)return{lat2:NaN,lon2:NaN};let w=s*x-c*S*u,T=Math.atan2(s*S+c*x*u,(1-a)*Math.sqrt(f*f+w*w)),E=Math.atan2(x*l,c*S-s*x*u),D=a/16*p*(4+a*(4-3*p));return{lat2:T,lon2:t+(E-(1-D)*a*f*(_+D*x*(b+D*S*(-1+2*b*b))))}}var is=o((()=>{}));function as(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0),this.f=this.es/(1+Math.sqrt(1-this.es))}function os(e){var t=e.x,n=e.y,r=Math.sin(e.y),i=Math.cos(e.y),a=U(t-this.long0,this.over),o,s,c,l,u,d,f,p,m,h,g;return this.sphere?Math.abs(this.sin_p12-1)<=1e-10?(e.x=this.x0+this.a*(y-n)*Math.sin(a),e.y=this.y0-this.a*(y-n)*Math.cos(a),e):Math.abs(this.sin_p12+1)<=1e-10?(e.x=this.x0+this.a*(y+n)*Math.sin(a),e.y=this.y0+this.a*(y+n)*Math.cos(a),e):(m=this.sin_p12*r+this.cos_p12*i*Math.cos(a),f=Math.acos(m),p=f?f/Math.sin(f):1,e.x=this.x0+this.a*p*i*Math.sin(a),e.y=this.y0+this.a*p*(this.cos_p12*r-this.sin_p12*i*Math.cos(a)),e):(o=ta(this.es),s=ra(this.es),c=aa(this.es),l=sa(this.es),Math.abs(this.sin_p12-1)<=1e-10?(u=this.a*$i(o,s,c,l,y),d=this.a*$i(o,s,c,l,n),e.x=this.x0+(u-d)*Math.sin(a),e.y=this.y0-(u-d)*Math.cos(a),e):Math.abs(this.sin_p12+1)<=1e-10?(u=this.a*$i(o,s,c,l,y),d=this.a*$i(o,s,c,l,n),e.x=this.x0+(u+d)*Math.sin(a),e.y=this.y0+(u+d)*Math.cos(a),e):Math.abs(t)<1e-10&&Math.abs(n-this.lat0)<1e-10?(e.x=e.y=0,e):(h=ns(this.lat0,this.long0,n,t,this.a,this.f),g=h.azi1,e.x=h.s12*Math.sin(g),e.y=h.s12*Math.cos(g),e))}function ss(e){e.x-=this.x0,e.y-=this.y0;var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;return this.sphere?(t=Math.sqrt(e.x*e.x+e.y*e.y),t>2*y*this.a?void 0:(n=t/this.a,r=Math.sin(n),i=Math.cos(n),a=this.long0,Math.abs(t)<=1e-10?o=this.lat0:(o=Ia(i*this.sin_p12+e.y*r*this.cos_p12/t),s=Math.abs(this.lat0)-y,a=Math.abs(s)<=1e-10?this.lat0>=0?U(this.long0+Math.atan2(e.x,-e.y),this.over):U(this.long0-Math.atan2(-e.x,e.y),this.over):U(this.long0+Math.atan2(e.x*r,t*this.cos_p12*i-e.y*this.sin_p12*r),this.over)),e.x=a,e.y=o,e)):(c=ta(this.es),l=ra(this.es),u=aa(this.es),d=sa(this.es),Math.abs(this.sin_p12-1)<=1e-10?(f=this.a*$i(c,l,u,d,y),t=Math.sqrt(e.x*e.x+e.y*e.y),p=f-t,o=pa(p/this.a,c,l,u,d),a=U(this.long0+Math.atan2(e.x,-1*e.y),this.over),e.x=a,e.y=o,e):Math.abs(this.sin_p12+1)<=1e-10?(f=this.a*$i(c,l,u,d,y),t=Math.sqrt(e.x*e.x+e.y*e.y),p=t-f,o=pa(p/this.a,c,l,u,d),a=U(this.long0+Math.atan2(e.x,e.y),this.over),e.x=a,e.y=o,e):(m=Math.atan2(e.x,e.y),h=Math.sqrt(e.x*e.x+e.y*e.y),g=rs(this.lat0,this.long0,m,h,this.a,this.f),e.x=g.lon2,e.y=g.lat2,e))}var cs,ls,us=o((()=>{rt(),k(),ea(),na(),ia(),oa(),ca(),La(),ma(),is(),cs=[`Azimuthal_Equidistant`,`aeqd`],ls={init:as,forward:os,inverse:ss,names:cs}}));function ds(){this.sin_p14=Math.sin(this.lat0||0),this.cos_p14=Math.cos(this.lat0||0)}function fs(e){var t,n,r,i,a,o,s,c,l=e.x,u=e.y;return r=U(l-(this.long0||0),this.over),t=Math.sin(u),n=Math.cos(u),i=Math.cos(r),o=this.sin_p14*t+this.cos_p14*n*i,a=1,(o>0||Math.abs(o)<=1e-10)&&(s=this.a*a*n*Math.sin(r),c=(this.y0||0)+this.a*a*(this.cos_p14*t-this.sin_p14*n*i)),e.x=s,e.y=c,e}function ps(e){var t,n,r,i,a,o,s,c,l;return e.x-=this.x0||0,e.y-=this.y0||0,t=Math.sqrt(e.x*e.x+e.y*e.y),n=Ia(t/this.a),r=Math.sin(n),i=Math.cos(n),c=this.long0||0,l=this.lat0||0,o=c,Math.abs(t)<=1e-10?(s=l,e.x=o,e.y=s,e):(s=Ia(i*this.sin_p14+e.y*r*this.cos_p14/t),a=Math.abs(l)-y,Math.abs(a)<=1e-10?(o=U(l>=0?c+Math.atan2(e.x,-e.y):c-Math.atan2(-e.x,e.y),this.over),e.x=o,e.y=s,e):(o=U(c+Math.atan2(e.x*r,t*this.cos_p14*i-e.y*this.sin_p14*r),this.over),e.x=o,e.y=s,e))}var ms,hs,gs=o((()=>{rt(),La(),k(),ms=[`ortho`],hs={init:ds,forward:fs,inverse:ps,names:ms}}));function _s(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||`Quadrilateralized Spherical Cube`,this.lat0>=y-E/2?this.face=Ss.TOP:this.lat0<=-(y-E/2)?this.face=Ss.BOTTOM:Math.abs(this.long0)<=E?this.face=Ss.FRONT:Math.abs(this.long0)<=y+E?this.face=this.long0>0?Ss.RIGHT:Ss.LEFT:this.face=Ss.BACK,this.es!==0&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)}function vs(e){var t={x:0,y:0},n,r,i,a,o,s,c={value:0};if(e.x-=this.long0,n=this.es===0?e.y:Math.atan(this.one_minus_f_squared*Math.tan(e.y)),r=e.x,this.face===Ss.TOP)a=y-n,r>=E&&r<=y+E?(c.value=Cs.AREA_0,i=r-y):r>y+E||r<=-(y+E)?(c.value=Cs.AREA_1,i=r>0?r-O:r+O):r>-(y+E)&&r<=-E?(c.value=Cs.AREA_2,i=r+y):(c.value=Cs.AREA_3,i=r);else if(this.face===Ss.BOTTOM)a=y+n,r>=E&&r<=y+E?(c.value=Cs.AREA_0,i=-r+y):r<E&&r>=-E?(c.value=Cs.AREA_1,i=-r):r<-E&&r>=-(y+E)?(c.value=Cs.AREA_2,i=-r-y):(c.value=Cs.AREA_3,i=r>0?-r+O:-r-O);else{var l,u,d,f,p,m,h;this.face===Ss.RIGHT?r=xs(r,+y):this.face===Ss.BACK?r=xs(r,+O):this.face===Ss.LEFT&&(r=xs(r,-y)),f=Math.sin(n),p=Math.cos(n),m=Math.sin(r),h=Math.cos(r),l=p*h,u=p*m,d=f,this.face===Ss.FRONT?(a=Math.acos(l),i=bs(a,d,u,c)):this.face===Ss.RIGHT?(a=Math.acos(u),i=bs(a,d,-l,c)):this.face===Ss.BACK?(a=Math.acos(-l),i=bs(a,d,-u,c)):this.face===Ss.LEFT?(a=Math.acos(-u),i=bs(a,d,l,c)):(a=i=0,c.value=Cs.AREA_0)}return s=Math.atan(12/O*(i+Math.acos(Math.sin(i)*Math.cos(E))-y)),o=Math.sqrt((1-Math.cos(a))/(Math.cos(s)*Math.cos(s))/(1-Math.cos(Math.atan(1/Math.cos(i))))),c.value===Cs.AREA_1?s+=y:c.value===Cs.AREA_2?s+=O:c.value===Cs.AREA_3&&(s+=1.5*O),t.x=o*Math.cos(s),t.y=o*Math.sin(s),t.x=t.x*this.a+this.x0,t.y=t.y*this.a+this.y0,e.x=t.x,e.y=t.y,e}function ys(e){var t={lam:0,phi:0},n,r,i,a,o,s,c,l,u,d={value:0};if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,r=Math.atan(Math.sqrt(e.x*e.x+e.y*e.y)),n=Math.atan2(e.y,e.x),e.x>=0&&e.x>=Math.abs(e.y)?d.value=Cs.AREA_0:e.y>=0&&e.y>=Math.abs(e.x)?(d.value=Cs.AREA_1,n-=y):e.x<0&&-e.x>=Math.abs(e.y)?(d.value=Cs.AREA_2,n=n<0?n+O:n-O):(d.value=Cs.AREA_3,n+=y),u=O/12*Math.tan(n),o=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),s=Math.atan(o),i=Math.cos(n),a=Math.tan(r),c=1-i*i*a*a*(1-Math.cos(Math.atan(1/Math.cos(s)))),c<-1?c=-1:c>1&&(c=1),this.face===Ss.TOP)l=Math.acos(c),t.phi=y-l,d.value===Cs.AREA_0?t.lam=s+y:d.value===Cs.AREA_1?t.lam=s<0?s+O:s-O:d.value===Cs.AREA_2?t.lam=s-y:t.lam=s;else if(this.face===Ss.BOTTOM)l=Math.acos(c),t.phi=l-y,d.value===Cs.AREA_0?t.lam=-s+y:d.value===Cs.AREA_1?t.lam=-s:d.value===Cs.AREA_2?t.lam=-s-y:t.lam=s<0?-s-O:-s+O;else{var f=c,p,m;u=f*f,m=u>=1?0:Math.sqrt(1-u)*Math.sin(s),u+=m*m,p=u>=1?0:Math.sqrt(1-u),d.value===Cs.AREA_1?(u=p,p=-m,m=u):d.value===Cs.AREA_2?(p=-p,m=-m):d.value===Cs.AREA_3&&(u=p,p=m,m=-u),this.face===Ss.RIGHT?(u=f,f=-p,p=u):this.face===Ss.BACK?(f=-f,p=-p):this.face===Ss.LEFT&&(u=f,f=p,p=-u),t.phi=Math.acos(-m)-y,t.lam=Math.atan2(p,f),this.face===Ss.RIGHT?t.lam=xs(t.lam,-y):this.face===Ss.BACK?t.lam=xs(t.lam,-O):this.face===Ss.LEFT&&(t.lam=xs(t.lam,+y))}if(this.es!==0){var h=+(t.phi<0),g=Math.tan(t.phi),_=this.b/Math.sqrt(g*g+this.one_minus_f_squared);t.phi=Math.atan(Math.sqrt(this.a*this.a-_*_)/(this.one_minus_f*_)),h&&(t.phi=-t.phi)}return t.lam+=this.long0,e.x=t.lam,e.y=t.phi,e}function bs(e,t,n,r){var i;return e<1e-10?(r.value=Cs.AREA_0,i=0):(i=Math.atan2(t,n),Math.abs(i)<=E?r.value=Cs.AREA_0:i>E&&i<=y+E?(r.value=Cs.AREA_1,i-=y):i>y+E||i<=-(y+E)?(r.value=Cs.AREA_2,i=i>=0?i-O:i+O):(r.value=Cs.AREA_3,i+=y)),i}function xs(e,t){var n=e+t;return n<-3.14159265359?n+=D:n>3.14159265359&&(n-=D),n}var Ss,Cs,ws,Ts,Es=o((()=>{k(),Ss={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},Cs={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4},ws=[`Quadrilateralized Spherical Cube`,`Quadrilateralized_Spherical_Cube`,`qsc`],Ts={init:_s,forward:vs,inverse:ys,names:ws}}));function Ds(e,t,n,r){for(var i=t;r;--r){var a=e(i);if(i-=a,Math.abs(a)<n)break}return i}function Os(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||`Robinson`}function ks(e){var t=U(e.x-this.long0,this.over),n=Math.abs(e.y),r=Math.floor(n*Fs);r<0?r=0:r>=Ls&&(r=Ls-1),n=T*(n-Is*r);var i={x:Rs(js[r],n)*t,y:Rs(Ms[r],n)};return e.y<0&&(i.y=-i.y),i.x=i.x*this.a*Ns+this.x0,i.y=i.y*this.a*Ps+this.y0,i}function As(e){var t={x:(e.x-this.x0)/(this.a*Ns),y:Math.abs(e.y-this.y0)/(this.a*Ps)};if(t.y>=1)t.x/=js[Ls][0],t.y=e.y<0?-y:y;else{var n=Math.floor(t.y*Ls);for(n<0?n=0:n>=Ls&&(n=Ls-1);;)if(Ms[n][0]>t.y)--n;else if(Ms[n+1][0]<=t.y)++n;else break;var r=Ms[n],i=5*(t.y-r[0])/(Ms[n+1][0]-r[0]);i=Ds(function(e){return(Rs(r,e)-t.y)/zs(r,e)},i,C,100),t.x/=Rs(js[n],i),t.y=(5*n+i)*w,e.y<0&&(t.y=-t.y)}return t.x=U(t.x+this.long0,this.over),t}var js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs=o((()=>{k(),rt(),js=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-9.86701e-7],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,1.8736e-8],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,9.34959e-7],[.7986,-.00755338,-500009e-10,9.35324e-7],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],Ms=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,422642e-15],[.124,.0124,5.07171e-9,-1.60604e-9],[.186,.0123999,-1.90189e-8,6.00152e-9],[.248,.0124002,7.10039e-8,-2.24e-8],[.31,.0123992,-2.64997e-7,8.35986e-8],[.372,.0124029,9.88983e-7,-3.11994e-7],[.434,.0123893,-369093e-11,-4.35621e-7],[.4958,.0123198,-102252e-10,-3.45523e-7],[.5571,.0121916,-154081e-10,-5.82288e-7],[.6176,.0119938,-241424e-10,-5.25327e-7],[.6769,.011713,-320223e-10,-5.16405e-7],[.7346,.0113541,-397684e-10,-6.09052e-7],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-1.40374e-9],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],Ns=.8487,Ps=1.3523,Fs=T/5,Is=1/Fs,Ls=18,Rs=function(e,t){return e[0]+t*(e[1]+t*(e[2]+t*e[3]))},zs=function(e,t){return e[1]+t*(2*e[2]+t*3*e[3])},Bs=[`Robinson`,`robin`],Vs={init:Os,forward:ks,inverse:As,names:Bs}}));function Us(){this.name=`geocent`}function Ws(e){return an(e,this.es,this.a)}function Gs(e){return on(e,this.es,this.a,this.b)}var Ks,qs,Js=o((()=>{ln(),Ks=[`Geocentric`,`geocentric`,`geocent`,`Geocent`],qs={init:Us,forward:Ws,inverse:Gs,names:Ks}}));function Ys(){if(Object.keys($s).forEach(function(e){if(this[e]===void 0)this[e]=$s[e].def;else if($s[e].num&&isNaN(this[e]))throw Error(`Invalid parameter value, must be numeric `+e+` = `+this[e]);else $s[e].num&&(this[e]=parseFloat(this[e]));$s[e].degrees&&(this[e]=this[e]*w)}.bind(this)),Math.abs(Math.abs(this.lat0)-y)<1e-10?this.mode=this.lat0<0?Qs.S_POLE:Qs.N_POLE:Math.abs(this.lat0)<1e-10?this.mode=Qs.EQUIT:(this.mode=Qs.OBLIQ,this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0)),this.pn1=this.h/this.a,this.pn1<=0||this.pn1>1e10)throw Error(`Invalid height`);this.p=1+this.pn1,this.rp=1/this.p,this.h1=1/this.pn1,this.pfact=(this.p+1)*this.h1,this.es=0;var e=this.tilt,t=this.azi;this.cg=Math.cos(t),this.sg=Math.sin(t),this.cw=Math.cos(e),this.sw=Math.sin(e)}function Xs(e){e.x-=this.long0;var t=Math.sin(e.y),n=Math.cos(e.y),r=Math.cos(e.x),i,a;switch(this.mode){case Qs.OBLIQ:a=this.sinph0*t+this.cosph0*n*r;break;case Qs.EQUIT:a=n*r;break;case Qs.S_POLE:a=-t;break;case Qs.N_POLE:a=t;break}switch(a=this.pn1/(this.p-a),i=a*n*Math.sin(e.x),this.mode){case Qs.OBLIQ:a*=this.cosph0*t-this.sinph0*n*r;break;case Qs.EQUIT:a*=t;break;case Qs.N_POLE:a*=-(n*r);break;case Qs.S_POLE:a*=n*r;break}var o=a*this.cg+i*this.sg,s=1/(o*this.sw*this.h1+this.cw);return i=(i*this.cg-a*this.sg)*this.cw*s,a=o*s,e.x=i*this.a,e.y=a*this.a,e}function Zs(e){e.x/=this.a,e.y/=this.a;var t={x:e.x,y:e.y},n,r,i=1/(this.pn1-e.y*this.sw);n=this.pn1*e.x*i,r=this.pn1*e.y*this.cw*i,e.x=n*this.cg+r*this.sg,e.y=r*this.cg-n*this.sg;var a=Mr(e.x,e.y);if(Math.abs(a)<1e-10)t.x=0,t.y=e.y;else{var o,s=1-a*a*this.pfact;switch(s=(this.p-Math.sqrt(s))/(this.pn1/a+a/this.pn1),o=Math.sqrt(1-s*s),this.mode){case Qs.OBLIQ:t.y=Math.asin(o*this.sinph0+e.y*s*this.cosph0/a),e.y=(o-this.sinph0*Math.sin(t.y))*a,e.x*=s*this.cosph0;break;case Qs.EQUIT:t.y=Math.asin(e.y*s/a),e.y=o*a,e.x*=s;break;case Qs.N_POLE:t.y=Math.asin(o),e.y=-e.y;break;case Qs.S_POLE:t.y=-Math.asin(o);break}t.x=Math.atan2(e.x,e.y)}return e.x=t.x+this.long0,e.y=t.y,e}var Qs,$s,ec,tc,nc=o((()=>{k(),Nr(),Qs={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3},$s={h:{def:1e5,num:!0},azi:{def:0,num:!0,degrees:!0},tilt:{def:0,num:!0,degrees:!0},long0:{def:0,num:!0},lat0:{def:0,num:!0}},ec=[`Tilted_Perspective`,`tpers`],tc={init:Ys,forward:Xs,inverse:Zs,names:ec}}));function rc(){if(this.flip_axis=+(this.sweep===`x`),this.h=Number(this.h),this.radius_g_1=this.h/this.a,this.radius_g_1<=0||this.radius_g_1>1e10)throw Error();if(this.radius_g=1+this.radius_g_1,this.C=this.radius_g*this.radius_g-1,this.es!==0){var e=1-this.es,t=1/e;this.radius_p=Math.sqrt(e),this.radius_p2=e,this.radius_p_inv2=t,this.shape=`ellipse`}else this.radius_p=1,this.radius_p2=1,this.radius_p_inv2=1,this.shape=`sphere`;this.title||=`Geostationary Satellite View`}function ic(e){var t=e.x,n=e.y,r,i,a,o;if(t-=this.long0,this.shape===`ellipse`){n=Math.atan(this.radius_p2*Math.tan(n));var s=this.radius_p/Mr(this.radius_p*Math.cos(n),Math.sin(n));if(i=s*Math.cos(t)*Math.cos(n),a=s*Math.sin(t)*Math.cos(n),o=s*Math.sin(n),(this.radius_g-i)*i-a*a-o*o*this.radius_p_inv2<0)return e.x=NaN,e.y=NaN,e;r=this.radius_g-i,this.flip_axis?(e.x=this.radius_g_1*Math.atan(a/Mr(o,r)),e.y=this.radius_g_1*Math.atan(o/r)):(e.x=this.radius_g_1*Math.atan(a/r),e.y=this.radius_g_1*Math.atan(o/Mr(a,r)))}else this.shape===`sphere`&&(r=Math.cos(n),i=Math.cos(t)*r,a=Math.sin(t)*r,o=Math.sin(n),r=this.radius_g-i,this.flip_axis?(e.x=this.radius_g_1*Math.atan(a/Mr(o,r)),e.y=this.radius_g_1*Math.atan(o/r)):(e.x=this.radius_g_1*Math.atan(a/r),e.y=this.radius_g_1*Math.atan(o/Mr(a,r))));return e.x*=this.a,e.y*=this.a,e}function ac(e){var t=-1,n=0,r=0,i,a,o,s;if(e.x/=this.a,e.y/=this.a,this.shape===`ellipse`){this.flip_axis?(r=Math.tan(e.y/this.radius_g_1),n=Math.tan(e.x/this.radius_g_1)*Mr(1,r)):(n=Math.tan(e.x/this.radius_g_1),r=Math.tan(e.y/this.radius_g_1)*Mr(1,n));var c=r/this.radius_p;if(i=n*n+c*c+t*t,a=2*this.radius_g*t,o=a*a-4*i*this.C,o<0)return e.x=NaN,e.y=NaN,e;s=(-a-Math.sqrt(o))/(2*i),t=this.radius_g+s*t,n*=s,r*=s,e.x=Math.atan2(n,t),e.y=Math.atan(r*Math.cos(e.x)/t),e.y=Math.atan(this.radius_p_inv2*Math.tan(e.y))}else if(this.shape===`sphere`){if(this.flip_axis?(r=Math.tan(e.y/this.radius_g_1),n=Math.tan(e.x/this.radius_g_1)*Math.sqrt(1+r*r)):(n=Math.tan(e.x/this.radius_g_1),r=Math.tan(e.y/this.radius_g_1)*Math.sqrt(1+n*n)),i=n*n+r*r+t*t,a=2*this.radius_g*t,o=a*a-4*i*this.C,o<0)return e.x=NaN,e.y=NaN,e;s=(-a-Math.sqrt(o))/(2*i),t=this.radius_g+s*t,n*=s,r*=s,e.x=Math.atan2(n,t),e.y=Math.atan(r*Math.cos(e.x)/t)}return e.x+=this.long0,e}var oc,sc,cc=o((()=>{Nr(),oc=[`Geostationary Satellite View`,`Geostationary_Satellite`,`geos`],sc={init:rc,forward:ic,inverse:ac,names:oc}}));function lc(){this.es=0,this.long0=this.long0===void 0?0:this.long0,this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0}function uc(e){var t=U(e.x-this.long0,this.over),n=e.y,r=Math.asin(gc*Math.sin(n)),i=r*r,a=i*i*i;return e.x=t*Math.cos(r)/(gc*(fc+3*pc*i+a*(7*mc+9*hc*i))),e.y=r*(fc+pc*i+a*(mc+hc*i)),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function dc(e){e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a;var t=1e-9,n=12,r=e.y,i,a,o,s,c,l;for(l=0;l<n&&(i=r*r,a=i*i*i,o=r*(fc+pc*i+a*(mc+hc*i))-e.y,s=fc+3*pc*i+a*(7*mc+9*hc*i),r-=c=o/s,!(Math.abs(c)<t));++l);return i=r*r,a=i*i*i,e.x=gc*e.x*(fc+3*pc*i+a*(7*mc+9*hc*i))/Math.cos(r),e.y=Math.asin(Math.sin(r)/gc),e.x=U(e.x+this.long0,this.over),e}var fc,pc,mc,hc,gc,_c,vc,yc=o((()=>{rt(),fc=1.340264,pc=-.081106,mc=893e-6,hc=.003796,gc=Math.sqrt(3)/2,_c=[`eqearth`,`Equal Earth`,`Equal_Earth`],vc={init:lc,forward:uc,inverse:dc,names:_c}}));function bc(){var e;if(this.phi1=this.lat1,Math.abs(this.phi1)<Tc)throw Error();this.es?(this.en=ar(this.es),this.m1=yr(this.phi1,this.am1=Math.sin(this.phi1),e=Math.cos(this.phi1),this.en),this.am1=e/(Math.sqrt(1-this.es*this.am1*this.am1)*this.am1),this.inverse=Sc,this.forward=xc):(Math.abs(this.phi1)+Tc>=y?this.cphi1=0:this.cphi1=1/Math.tan(this.phi1),this.inverse=wc,this.forward=Cc)}function xc(e){var t=U(e.x-(this.long0||0),this.over),n=e.y,r=this.am1+this.m1-yr(n,i=Math.sin(n),a=Math.cos(n),this.en),i=a*t/(r*Math.sqrt(1-this.es*i*i)),a;return e.x=r*Math.sin(i),e.y=this.am1-r*Math.cos(i),e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function Sc(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,n=Mr(e.x,e.y=this.am1-e.y),r,i=xr(this.am1+this.m1-n,this.es,this.en);if((t=Math.abs(i))<y)t=Math.sin(i),r=n*Math.atan2(e.x,e.y)*Math.sqrt(1-this.es*t*t)/Math.cos(i);else if(Math.abs(t-y)<=Tc)r=0;else throw Error();return e.x=U(r+(this.long0||0),this.over),e.y=da(i),e}function Cc(e){var t=U(e.x-(this.long0||0),this.over),n=e.y,r,i=this.cphi1+this.phi1-n;return Math.abs(i)>Tc?(e.x=i*Math.sin(r=t*Math.cos(n)/i),e.y=this.cphi1-i*Math.cos(r)):e.x=e.y=0,e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function wc(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,n,r=Mr(e.x,e.y=this.cphi1-e.y);if(n=this.cphi1+this.phi1-r,Math.abs(n)>y)throw Error();return t=Math.abs(Math.abs(n)-y)<=Tc?0:r*Math.atan2(e.x,e.y)/Math.cos(n),e.x=U(t+(this.long0||0),this.over),e.y=da(n),e}var Tc,Ec,Dc,Oc=o((()=>{fa(),rt(),Nr(),vr(),Cr(),br(),k(),Tc=1e-10,Ec=[`bonne`,`Bonne (Werner lat_1=90)`],Dc={init:bc,names:Ec}}));function kc(){if(this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.title=this.title||`General Oblique Transformation`,this.isIdentity=gt.includes(this.o_proj),!this.o_proj)throw Error(`Missing parameter: o_proj`);if(this.o_proj===`ob_tran`)throw Error(`Invalid value for o_proj: `+this.o_proj);let e=tn(this.projStr.replace(`+proj=ob_tran`,``).replace(`+o_proj=`,`+proj=`).trim());if(!e)throw Error(`Invalid parameter: o_proj. Unknown projection `+this.o_proj);e.long0=0,this.obliqueProjection=e;let t,n=Object.keys(Rc),r=e=>{if(this[e]===void 0)return;let t=parseFloat(this[e])*w;if(isNaN(t))throw Error(`Invalid value for `+e+`: `+this[e]);return t};for(let e=0;e<n.length;e++){let i=Rc[n[e]],a=Object.entries(i);if(a.some(([e])=>this[e]!==void 0)){t=i;for(let e=0;e<a.length;e++){let[t,n]=a[e],i=r(t);if(i===void 0)throw Error(`Missing parameter: `+t+`.`);this[n]=i}break}}if(!t)throw Error(`No valid parameters provided for ob_tran projection.`);let{lamp:i,phip:a}=Mc(this,t);this.lamp=i,Math.abs(a)>1e-10?(this.cphip=Math.cos(a),this.sphip=Math.sin(a),this.projectionType=Lc.OBLIQUE):this.projectionType=Lc.TRANSVERSE}function Ac(e){return this.projectionType.forward(this,e)}function jc(e){return this.projectionType.inverse(this,e)}function Mc(e,t){let n,r;if(t===Rc.ROTATE){let t=e.oLongC,i=e.oLatC,a=e.oAlpha;if(Math.abs(Math.abs(i)-y)<=1e-10)throw Error(`Invalid value for o_lat_c: `+e.o_lat_c+` should be < 90°`);r=t+Math.atan2(-1*Math.cos(a),-1*Math.sin(a)*Math.sin(i)),n=Math.asin(Math.cos(i)*Math.sin(a))}else if(t===Rc.NEW_POLE)r=e.oLongP,n=e.oLatP;else{let t=e.oLong1,i=e.oLat1,a=e.oLong2,o=e.oLat2,s=Math.abs(i);if(Math.abs(i)>y-1e-10)throw Error(`Invalid value for o_lat_1: `+e.o_lat_1+` should be < 90°`);if(Math.abs(o)>y-1e-10)throw Error(`Invalid value for o_lat_2: `+e.o_lat_2+` should be < 90°`);if(Math.abs(i-o)<1e-10)throw Error(`Invalid value for o_lat_1 and o_lat_2: o_lat_1 should be different from o_lat_2`);if(s<1e-10)throw Error(`Invalid value for o_lat_1: o_lat_1 should be different from zero`);r=Math.atan2(Math.cos(i)*Math.sin(o)*Math.cos(t)-Math.sin(i)*Math.cos(o)*Math.cos(a),Math.sin(i)*Math.cos(o)*Math.sin(a)-Math.cos(i)*Math.sin(o)*Math.sin(t)),n=Math.atan(-1*Math.cos(r-t)/Math.tan(i))}return{lamp:r,phip:n}}function Nc(e,t){let{x:n,y:r}=t;n+=e.long0;let i=Math.cos(n),a=Math.sin(r),o=Math.cos(r);t.x=U(Math.atan2(o*Math.sin(n),e.sphip*o*i+e.cphip*a)+e.lamp),t.y=Math.asin(e.sphip*a-e.cphip*o*i);let s=e.obliqueProjection.forward(t);return e.isIdentity&&(s.x*=T,s.y*=T),s}function Pc(e,t){let{x:n,y:r}=t;n+=e.long0;let i=Math.cos(r),a=Math.cos(n);t.x=U(Math.atan2(i*Math.sin(n),Math.sin(r))+e.lamp),t.y=Math.asin(-1*i*a);let o=e.obliqueProjection.forward(t);return e.isIdentity&&(o.x*=T,o.y*=T),o}function Fc(e,t){e.isIdentity&&(t.x*=w,t.y*=w);let{x:n,y:r}=e.obliqueProjection.inverse(t);if(n<Number.MAX_VALUE){n-=e.lamp;let i=Math.cos(n),a=Math.sin(r),o=Math.cos(r);t.x=Math.atan2(o*Math.sin(n),e.sphip*o*i-e.cphip*a),t.y=Math.asin(e.sphip*a+e.cphip*o*i)}return t.x=U(t.x+e.long0),t}function Ic(e,t){e.isIdentity&&(t.x*=w,t.y*=w);let{x:n,y:r}=e.obliqueProjection.inverse(t);if(n<Number.MAX_VALUE){let i=Math.cos(r);n-=e.lamp,t.x=Math.atan2(i*Math.sin(n),-1*Math.sin(r)),t.y=Math.asin(i*Math.cos(n))}return t.x=U(t.x+e.long0),t}var Lc,Rc,zc,Bc,Vc=o((()=>{rt(),k(),nn(),vt(),Lc={OBLIQUE:{forward:Nc,inverse:Fc},TRANSVERSE:{forward:Pc,inverse:Ic}},Rc={ROTATE:{o_alpha:`oAlpha`,o_lon_c:`oLongC`,o_lat_c:`oLatC`},NEW_POLE:{o_lat_p:`oLatP`,o_lon_p:`oLongP`},NEW_EQUATOR:{o_lon_1:`oLong1`,o_lat_1:`oLat1`,o_lon_2:`oLong2`,o_lat_2:`oLat2`}},zc=[`General Oblique Transformation`,`General_Oblique_Transformation`,`ob_tran`],Bc={init:kc,forward:Ac,inverse:jc,names:zc}}));function Hc(e){e.Proj.projections.add(Or),e.Proj.projections.add(Xr),e.Proj.projections.add(ri),e.Proj.projections.add(vi),e.Proj.projections.add(Ti),e.Proj.projections.add(ji),e.Proj.projections.add(zi),e.Proj.projections.add(Gi),e.Proj.projections.add(Zi),e.Proj.projections.add(ya),e.Proj.projections.add(Pa),e.Proj.projections.add(Ua),e.Proj.projections.add(Ya),e.Proj.projections.add(ro),e.Proj.projections.add(lo),e.Proj.projections.add(_o),e.Proj.projections.add(Co),e.Proj.projections.add(ko),e.Proj.projections.add(Io),e.Proj.projections.add(Ho),e.Proj.projections.add(Jo),e.Proj.projections.add(es),e.Proj.projections.add(ls),e.Proj.projections.add(hs),e.Proj.projections.add(Ts),e.Proj.projections.add(Vs),e.Proj.projections.add(qs),e.Proj.projections.add(tc),e.Proj.projections.add(sc),e.Proj.projections.add(vc),e.Proj.projections.add(Dc),e.Proj.projections.add(Bc)}var Uc=o((()=>{kr(),Zr(),ii(),yi(),Ei(),Mi(),Bi(),Ki(),Qi(),ba(),Fa(),Wa(),Xa(),io(),uo(),vo(),wo(),Ao(),Lo(),Uo(),Yo(),ts(),us(),gs(),Es(),Hs(),Js(),nc(),cc(),yc(),Oc(),Vc()})),Wc,Gc=o((()=>{An(),nn(),ir(),yn(),We(),en(),Tn(),nr(),Uc(),Wc=Object.assign(On,{defaultDatum:`WGS84`,Proj:tn,WGS84:new tn(`WGS84`),Point:rr,toPoint:vn,defs:Ue,nadgrid:zt,transform:wn,mgrs:tr,version:`__VERSION__`}),Hc(Wc)}));function Kc(){}function qc(e=qc.DEFAULT_IMAGE,t=qc.DEFAULT_MAPPING,n=Pm,r=Pm,i=zm,a=Vm,o=Km,s=G,c=1,l=ih){Object.defineProperty(this,"id",{value:Ch++}),this.uuid=yh.generateUUID(),this.name=``,this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=s,this.offset=new K(0,0),this.repeat=new K(1,1),this.center=new K(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new bh,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=l,this.version=0,this.onUpdate=null}function Jc(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Sh.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.`),{})}function Yc(e,t,n){this.width=e,this.height=t,this.scissor=new wh(0,0,e,t),this.scissorTest=!1,this.viewport=new wh(0,0,e,t),n||={},this.texture=new qc(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=n.generateMipmaps===void 0?!1:n.generateMipmaps,this.texture.minFilter=n.minFilter===void 0?zm:n.minFilter,this.depthBuffer=n.depthBuffer===void 0?!0:n.depthBuffer,this.stencilBuffer=n.stencilBuffer===void 0?!1:n.stencilBuffer,this.depthTexture=n.depthTexture===void 0?null:n.depthTexture}function Xc(e,t,n){Yc.call(this,e,t,n),this.samples=4}function Zc(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Bh.fromArray(e,a);let o=i.x*Math.abs(Bh.x)+i.y*Math.abs(Bh.y)+i.z*Math.abs(Bh.z),s=t.dot(Bh),c=n.dot(Bh),l=r.dot(Bh);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}function Qc(){Object.defineProperty(this,"id",{value:lg++}),this.uuid=yh.generateUUID(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=Qc.DefaultUp.clone();let e=new q,t=new ag,n=new Th,r=new q(1,1,1);function i(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(i),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Zh},normalMatrix:{value:new bh}}),this.matrix=new Zh,this.matrixWorld=new Zh,this.matrixAutoUpdate=Qc.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new cg,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}function $c(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}function el(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function tl(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}function nl(){Object.defineProperty(this,"id",{value:Hg++}),this.uuid=yh.generateUUID(),this.name=``,this.type=`Material`,this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,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=mh,this.stencilZFail=mh,this.stencilZPass=mh,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.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}function rl(e){nl.call(this),this.type=`MeshBasicMaterial`,this.color=new Bg(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.skinning=!1,this.morphTargets=!1,this.setValues(e)}function il(e,t,n){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n===!0,this.usage=hh,this.updateRange={offset:0,count:-1},this.version=0}function al(e,t,n){il.call(this,new Int8Array(e),t,n)}function ol(e,t,n){il.call(this,new Uint8Array(e),t,n)}function sl(e,t,n){il.call(this,new Uint8ClampedArray(e),t,n)}function cl(e,t,n){il.call(this,new Int16Array(e),t,n)}function ll(e,t,n){il.call(this,new Uint16Array(e),t,n)}function ul(e,t,n){il.call(this,new Int32Array(e),t,n)}function dl(e,t,n){il.call(this,new Uint32Array(e),t,n)}function fl(e,t,n){il.call(this,new Uint16Array(e),t,n)}function pl(e,t,n){il.call(this,new Float32Array(e),t,n)}function ml(e,t,n){il.call(this,new Float64Array(e),t,n)}function hl(e){if(e.length===0)return-1/0;let t=e[0];for(let n=1,r=e.length;n<r;++n)e[n]>t&&(t=e[n]);return t}function gl(e,t){return new Kg[e](t)}function _l(){Object.defineProperty(this,"id",{value:qg+=2}),this.uuid=yh.generateUUID(),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={}}function vl(e=new _l,t=new rl){Qc.call(this),this.type=`Mesh`,this.geometry=e,this.material=t,this.updateMorphTargets()}function yl(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side!==2,s),c===null)return null;h_.copy(s),h_.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(h_);return l<n.near||l>n.far?null:{distance:l,point:h_.clone(),object:e}}function bl(e,t,n,r,i,a,o,s,c,l,u,d){r_.fromBufferAttribute(i,l),i_.fromBufferAttribute(i,u),a_.fromBufferAttribute(i,d);let f=e.morphTargetInfluences;if(t.morphTargets&&a&&f){l_.set(0,0,0),u_.set(0,0,0),d_.set(0,0,0);for(let e=0,t=a.length;e<t;e++){let t=f[e],n=a[e];t!==0&&(o_.fromBufferAttribute(n,l),s_.fromBufferAttribute(n,u),c_.fromBufferAttribute(n,d),o?(l_.addScaledVector(o_,t),u_.addScaledVector(s_,t),d_.addScaledVector(c_,t)):(l_.addScaledVector(o_.sub(r_),t),u_.addScaledVector(s_.sub(i_),t),d_.addScaledVector(c_.sub(a_),t)))}r_.add(l_),i_.add(u_),a_.add(d_)}e.isSkinnedMesh&&(e.boneTransform(l,r_),e.boneTransform(u,i_),e.boneTransform(d,a_));let p=yl(e,t,n,r,r_,i_,a_,m_);if(p){s&&(Y.fromBufferAttribute(s,l),f_.fromBufferAttribute(s,u),p_.fromBufferAttribute(s,d),p.uv=Ig.getUV(m_,r_,i_,a_,Y,f_,p_,new K)),c&&(Y.fromBufferAttribute(c,l),f_.fromBufferAttribute(c,u),p_.fromBufferAttribute(c,d),p.uv2=Ig.getUV(m_,r_,i_,a_,Y,f_,p_,new K));let e=new Vg(l,u,d);Ig.getNormal(r_,i_,a_,e.normal),p.face=e}return p}function xl(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture)?t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function Sl(e){let t={};for(let n=0;n<e.length;n++){let r=xl(e[n]);for(let e in r)t[e]=r[e]}return t}function Cl(e){nl.call(this),this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.vertexShader=v_,this.fragmentShader=y_,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!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,e!==void 0&&(e.attributes!==void 0&&console.error(`THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.`),this.setValues(e))}function wl(){Qc.call(this),this.type=`Camera`,this.matrixWorldInverse=new Zh,this.projectionMatrix=new Zh,this.projectionMatrixInverse=new Zh}function Tl(e=50,t=1,n=.1,r=2e3){wl.call(this),this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function El(e,t,n){if(Qc.call(this),this.type=`CubeCamera`,n.isWebGLCubeRenderTarget!==!0){console.error(`THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.`);return}this.renderTarget=n;let r=new Tl(b_,x_,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new q(1,0,0)),this.add(r);let i=new Tl(b_,x_,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new q(-1,0,0)),this.add(i);let a=new Tl(b_,x_,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new q(0,1,0)),this.add(a);let o=new Tl(b_,x_,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new q(0,-1,0)),this.add(o);let s=new Tl(b_,x_,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new q(0,0,1)),this.add(s);let c=new Tl(b_,x_,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new q(0,0,-1)),this.add(c),this.update=function(e,t){this.parent===null&&this.updateMatrixWorld();let l=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;let d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,i),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(u),e.xr.enabled=l}}function Dl(e,t,n,r,i,a,o,s,c,l){e=e===void 0?[]:e,t=t===void 0?301:t,o=o===void 0?Gm:o,qc.call(this,e,t,n,r,i,a,o,s,c,l),this.flipY=!1,this._needsFlipEnvMap=!0}function Ol(e,t,n){Number.isInteger(t)&&(console.warn(`THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )`),t=n),Yc.call(this,e,e,t),t||={},this.texture=new Dl(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture._needsFlipEnvMap=!1}function kl(e,t,n,r,i,a,o,s,c,l,u,d){qc.call(this,null,a,o,s,c,l,r,i,u,d),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=c===void 0?Im:c,this.minFilter=l===void 0?Im:l,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}function Al(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){t!==!0&&n!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function jl(e,t){let n=t.isWebGL2,r=new WeakMap;function i(t,r){let i=t.array,a=t.usage,o=e.createBuffer();e.bindBuffer(r,o),e.bufferData(r,i,a),t.onUploadCallback();let s=5126;return i instanceof Float32Array?s=5126:i instanceof Float64Array?console.warn(`THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.`):i instanceof Uint16Array?t.isFloat16BufferAttribute?n?s=5131:console.warn(`THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.`):s=5123:i instanceof Int16Array?s=5122:i instanceof Uint32Array?s=5125:i instanceof Int32Array?s=5124:i instanceof Int8Array?s=5120:i instanceof Uint8Array&&(s=5121),{buffer:o,type:s,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}function a(t,r,i){let a=r.array,o=r.updateRange;e.bindBuffer(i,t),o.count===-1?e.bufferSubData(i,0,a):(n?e.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):e.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1)}function o(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)}function s(t){t.isInterleavedBufferAttribute&&(t=t.data);let n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))}function c(e,t){if(e.isGLBufferAttribute){let t=r.get(e);(!t||t.version<e.version)&&r.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version});return}e.isInterleavedBufferAttribute&&(e=e.data);let n=r.get(e);n===void 0?r.set(e,i(e,t)):n.version<e.version&&(a(n.buffer,e,t),n.version=e.version)}return{get:o,remove:s,update:c}}function Ml(e,t,n,r,i){let a=new Bg(0),o=0,s,c,l=null,u=0,d=null;function f(n,i,f,m){let h=i.isScene===!0?i.background:null;h&&h.isTexture&&(h=t.get(h));let g=e.xr,_=g.getSession&&g.getSession();_&&_.environmentBlendMode===`additive`&&(h=null),h===null?p(a,o):h&&h.isColor&&(p(h,1),m=!0),(e.autoClear||m)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),h&&(h.isCubeTexture||h.isWebGLCubeRenderTarget||h.mapping===306)?(c===void 0&&(c=new vl(new g_(1,1,1),new Cl({name:`BackgroundCubeMaterial`,uniforms:xl(D_.cube.uniforms),vertexShader:D_.cube.vertexShader,fragmentShader:D_.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute(`normal`),c.geometry.deleteAttribute(`uv`),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),h.isWebGLCubeRenderTarget&&(h=h.texture),c.material.uniforms.envMap.value=h,c.material.uniforms.flipEnvMap.value=h.isCubeTexture&&h._needsFlipEnvMap?-1:1,(l!==h||u!==h.version||d!==e.toneMapping)&&(c.material.needsUpdate=!0,l=h,u=h.version,d=e.toneMapping),n.unshift(c,c.geometry,c.material,0,0,null)):h&&h.isTexture&&(s===void 0&&(s=new vl(new T_(2,2),new Cl({name:`BackgroundMaterial`,uniforms:xl(D_.background.uniforms),vertexShader:D_.background.vertexShader,fragmentShader:D_.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute(`normal`),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(s)),s.material.uniforms.t2D.value=h,h.matrixAutoUpdate===!0&&h.updateMatrix(),s.material.uniforms.uvTransform.value.copy(h.matrix),(l!==h||u!==h.version||d!==e.toneMapping)&&(s.material.needsUpdate=!0,l=h,u=h.version,d=e.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null))}function p(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,i)}return{getClearColor:function(){return a},setClearColor:function(e,t=1){a.set(e),o=t,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(e){o=e,p(a,o)},render:f}}function Nl(e,t,n,r){let i=e.getParameter(34921),a=r.isWebGL2?null:t.get(`OES_vertex_array_object`),o=r.isWebGL2||a!==null,s={},c=h(null),l=c;function u(t,r,i,a,s){let c=!1;if(o){let e=m(a,i,r);l!==e&&(l=e,f(l.object)),c=g(a,s),c&&_(a,s)}else{let e=r.wireframe===!0;(l.geometry!==a.id||l.program!==i.id||l.wireframe!==e)&&(l.geometry=a.id,l.program=i.id,l.wireframe=e,c=!0)}t.isInstancedMesh===!0&&(c=!0),s!==null&&n.update(s,34963),c&&(C(t,r,i,a),s!==null&&e.bindBuffer(34963,n.get(s).buffer))}function d(){return r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()}function f(t){return r.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function p(t){return r.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function m(e,t,n){let r=n.wireframe===!0,i=s[e.id];i===void 0&&(i={},s[e.id]=i);let a=i[t.id];a===void 0&&(a={},i[t.id]=a);let o=a[r];return o===void 0&&(o=h(d()),a[r]=o),o}function h(e){let t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function g(e,t){let n=l.attributes,r=e.attributes,i=0;for(let e in r){let t=n[e],a=r[e];if(t===void 0||t.attribute!==a||t.data!==a.data)return!0;i++}return l.attributesNum!==i||l.index!==t}function _(e,t){let n={},r=e.attributes,i=0;for(let e in r){let t=r[e],a={};a.attribute=t,t.data&&(a.data=t.data),n[e]=a,i++}l.attributes=n,l.attributesNum=i,l.index=t}function v(){let e=l.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function y(e){b(e,0)}function b(n,i){let a=l.newAttributes,o=l.enabledAttributes,s=l.attributeDivisors;a[n]=1,o[n]===0&&(e.enableVertexAttribArray(n),o[n]=1),s[n]!==i&&((r.isWebGL2?e:t.get(`ANGLE_instanced_arrays`))[r.isWebGL2?`vertexAttribDivisor`:`vertexAttribDivisorANGLE`](n,i),s[n]=i)}function x(){let t=l.newAttributes,n=l.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function S(t,n,i,a,o,s){r.isWebGL2===!0&&(i===5124||i===5125)?e.vertexAttribIPointer(t,n,i,o,s):e.vertexAttribPointer(t,n,i,a,o,s)}function C(i,a,o,s){if(r.isWebGL2===!1&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&t.get(`ANGLE_instanced_arrays`)===null)return;v();let c=s.attributes,l=o.getAttributes(),u=a.defaultAttributeValues;for(let t in l){let r=l[t];if(r>=0){let a=c[t];if(a!==void 0){let t=a.normalized,i=a.itemSize,o=n.get(a);if(o===void 0)continue;let c=o.buffer,l=o.type,u=o.bytesPerElement;if(a.isInterleavedBufferAttribute){let n=a.data,o=n.stride,d=a.offset;n&&n.isInstancedInterleavedBuffer?(b(r,n.meshPerAttribute),s._maxInstanceCount===void 0&&(s._maxInstanceCount=n.meshPerAttribute*n.count)):y(r),e.bindBuffer(34962,c),S(r,i,l,t,o*u,d*u)}else a.isInstancedBufferAttribute?(b(r,a.meshPerAttribute),s._maxInstanceCount===void 0&&(s._maxInstanceCount=a.meshPerAttribute*a.count)):y(r),e.bindBuffer(34962,c),S(r,i,l,t,0,0)}else if(t===`instanceMatrix`){let t=n.get(i.instanceMatrix);if(t===void 0)continue;let a=t.buffer,o=t.type;b(r+0,1),b(r+1,1),b(r+2,1),b(r+3,1),e.bindBuffer(34962,a),e.vertexAttribPointer(r+0,4,o,!1,64,0),e.vertexAttribPointer(r+1,4,o,!1,64,16),e.vertexAttribPointer(r+2,4,o,!1,64,32),e.vertexAttribPointer(r+3,4,o,!1,64,48)}else if(t===`instanceColor`){let t=n.get(i.instanceColor);if(t===void 0)continue;let a=t.buffer,o=t.type;b(r,1),e.bindBuffer(34962,a),e.vertexAttribPointer(r,3,o,!1,12,0)}else if(u!==void 0){let n=u[t];if(n!==void 0)switch(n.length){case 2:e.vertexAttrib2fv(r,n);break;case 3:e.vertexAttrib3fv(r,n);break;case 4:e.vertexAttrib4fv(r,n);break;default:e.vertexAttrib1fv(r,n)}}}}x()}function w(){D();for(let e in s){let t=s[e];for(let e in t){let n=t[e];for(let e in n)p(n[e].object),delete n[e];delete t[e]}delete s[e]}}function T(e){if(s[e.id]===void 0)return;let t=s[e.id];for(let e in t){let n=t[e];for(let e in n)p(n[e].object),delete n[e];delete t[e]}delete s[e.id]}function E(e){for(let t in s){let n=s[t];if(n[e.id]===void 0)continue;let r=n[e.id];for(let e in r)p(r[e].object),delete r[e];delete n[e.id]}}function D(){O(),l!==c&&(l=c,f(l.object))}function O(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:u,reset:D,resetDefaultState:O,dispose:w,releaseStatesOfGeometry:T,releaseStatesOfProgram:E,initAttributes:v,enableAttribute:y,disableUnusedAttributes:x}}function Pl(e,t,n,r){let i=r.isWebGL2,a;function o(e){a=e}function s(t,r){e.drawArrays(a,t,r),n.update(r,a,1)}function c(r,o,s){if(s===0)return;let c,l;if(i)c=e,l=`drawArraysInstanced`;else if(c=t.get(`ANGLE_instanced_arrays`),l=`drawArraysInstancedANGLE`,c===null){console.error(`THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.`);return}c[l](a,r,o,s),n.update(o,a,s)}this.setMode=o,this.render=s,this.renderInstances=c}function Fl(e,t,n){let r;function i(){if(r!==void 0)return r;let n=t.get(`EXT_texture_filter_anisotropic`);return r=n===null?0:e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT),r}function a(t){if(t===`highp`){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?`mediump`:`lowp`}let o=typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<`u`&&e instanceof WebGL2ComputeRenderingContext,s=n.precision===void 0?`highp`:n.precision,c=a(s);c!==s&&(console.warn(`THREE.WebGLRenderer:`,s,`not supported, using`,c,`instead.`),s=c);let l=n.logarithmicDepthBuffer===!0,u=e.getParameter(34930),d=e.getParameter(35660),f=e.getParameter(3379),p=e.getParameter(34076),m=e.getParameter(34921),h=e.getParameter(36347),g=e.getParameter(36348),_=e.getParameter(36349),v=d>0,y=o||!!t.get(`OES_texture_float`),b=v&&y,x=o?e.getParameter(36183):0;return{isWebGL2:o,getMaxAnisotropy:i,getMaxPrecision:a,precision:s,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:h,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:b,maxSamples:x}}function Il(e){let t=this,n=null,r=0,i=!1,a=!1,o=new Tg,s=new bh,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,a){let o=e.length!==0||t||r!==0||i;return i=t,n=u(e,a,0),r=e.length,o},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1,l()},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length<t)&&(l=new Float32Array(t));for(let t=0,n=r;t!==a;++t,n+=4)o.copy(e[t]).applyMatrix4(i,s),o.normal.toArray(l,n),l[n+3]=o.constant}c.value=l,c.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,l}}function Ll(e){let t=new WeakMap;function n(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function r(r){if(r&&r.isTexture){let a=r.mapping;if(a===303||a===304)if(t.has(r)){let e=t.get(r).texture;return n(e,r.mapping)}else{let a=r.image;if(a&&a.height>0){let o=e.getRenderList(),s=e.getRenderTarget(),c=new Ol(a.height/2);return c.fromEquirectangularTexture(e,r),t.set(r,c),e.setRenderTarget(s),e.setRenderList(o),r.addEventListener(`dispose`,i),n(c.texture,r.mapping)}else return null}}return r}function i(e){let n=e.target;n.removeEventListener(`dispose`,i);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function a(){t=new WeakMap}return{get:r,dispose:a}}function Rl(e){let t={};return{has:function(n){if(t[n]!==void 0)return t[n]!==null;let r;switch(n){case`WEBGL_depth_texture`:r=e.getExtension(`WEBGL_depth_texture`)||e.getExtension(`MOZ_WEBGL_depth_texture`)||e.getExtension(`WEBKIT_WEBGL_depth_texture`);break;case`EXT_texture_filter_anisotropic`:r=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`:r=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`:r=e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`);break;default:r=e.getExtension(n)}return t[n]=r,r!==null},get:function(e){return this.has(e)||console.warn(`THREE.WebGLRenderer: `+e+` extension not supported.`),t[e]}}}function zl(e,t,n,r){let i=new WeakMap,a=new WeakMap;function o(e){let s=e.target,c=i.get(s);c.index!==null&&t.remove(c.index);for(let e in c.attributes)t.remove(c.attributes[e]);s.removeEventListener(`dispose`,o),i.delete(s);let l=a.get(c);l&&(t.remove(l),a.delete(c)),r.releaseStatesOfGeometry(c),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){let r=i.get(t);return r||(t.addEventListener(`dispose`,o),t.isBufferGeometry?r=t:t.isGeometry&&(t._bufferGeometry===void 0&&(t._bufferGeometry=new _l().setFromObject(e)),r=t._bufferGeometry),i.set(t,r),n.memory.geometries++,r)}function c(e){let n=e.attributes;for(let e in n)t.update(n[e],34962);let r=e.morphAttributes;for(let e in r){let n=r[e];for(let e=0,r=n.length;e<r;e++)t.update(n[e],34962)}}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t<r;t+=3){let r=e[t+0],i=e[t+1],a=e[t+2];n.push(r,i,i,a,a,r)}}else{let e=i.array;o=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){let e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}let s=new(hl(n)>65535?dl:ll)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.version<n.version&&l(e)}else l(e);return a.get(e)}return{get:s,update:c,getWireframeAttribute:u}}function Bl(e,t,n,r){let i=r.isWebGL2,a;function o(e){a=e}let s,c;function l(e){s=e.type,c=e.bytesPerElement}function u(t,r){e.drawElements(a,r,s,t*c),n.update(r,a,1)}function d(r,o,l){if(l===0)return;let u,d;if(i)u=e,d=`drawElementsInstanced`;else if(u=t.get(`ANGLE_instanced_arrays`),d=`drawElementsInstancedANGLE`,u===null){console.error(`THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.`);return}u[d](a,o,s,r*c,l),n.update(o,a,l)}this.setMode=o,this.setIndex=l,this.render=u,this.renderInstances=d}function Vl(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(e,t,r){switch(n.calls++,t){case 4:n.triangles+=e/3*r;break;case 1:n.lines+=e/2*r;break;case 3:n.lines+=r*(e-1);break;case 2:n.lines+=r*e;break;case 0:n.points+=r*e;break;default:console.error(`THREE.WebGLInfo: Unknown draw mode:`,t);break}}function i(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:i,update:r}}function Hl(e,t){return e[0]-t[0]}function Ul(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Wl(e){let t={},n=new Float32Array(8),r=[];for(let e=0;e<8;e++)r[e]=[e,0];function i(i,a,o,s){let c=i.morphTargetInfluences,l=c===void 0?0:c.length,u=t[a.id];if(u===void 0){u=[];for(let e=0;e<l;e++)u[e]=[e,0];t[a.id]=u}for(let e=0;e<l;e++){let t=u[e];t[0]=e,t[1]=c[e]}u.sort(Ul);for(let e=0;e<8;e++)e<l&&u[e][1]?(r[e][0]=u[e][0],r[e][1]=u[e][1]):(r[e][0]=2**53-1,r[e][1]=0);r.sort(Hl);let d=o.morphTargets&&a.morphAttributes.position,f=o.morphNormals&&a.morphAttributes.normal,p=0;for(let e=0;e<8;e++){let t=r[e],i=t[0],o=t[1];i!==2**53-1&&o?(d&&a.getAttribute(`morphTarget`+e)!==d[i]&&a.setAttribute(`morphTarget`+e,d[i]),f&&a.getAttribute(`morphNormal`+e)!==f[i]&&a.setAttribute(`morphNormal`+e,f[i]),n[e]=o,p+=o):(d&&a.hasAttribute(`morphTarget`+e)===!0&&a.deleteAttribute(`morphTarget`+e),f&&a.hasAttribute(`morphNormal`+e)===!0&&a.deleteAttribute(`morphNormal`+e),n[e]=0)}let m=a.morphTargetsRelative?1:1-p;s.getUniforms().setValue(e,`morphTargetBaseInfluence`,m),s.getUniforms().setValue(e,`morphTargetInfluences`,n)}return{update:i}}function Gl(e,t,n,r){let i=new WeakMap;function a(e){let a=r.render.frame,o=e.geometry,c=t.get(e,o);return i.get(c)!==a&&(o.isGeometry&&c.updateFromObject(e),t.update(c),i.set(c,a)),e.isInstancedMesh&&(e.hasEventListener(`dispose`,s)===!1&&e.addEventListener(`dispose`,s),n.update(e.instanceMatrix,34962),e.instanceColor!==null&&n.update(e.instanceColor,34962)),c}function o(){i=new WeakMap}function s(e){let t=e.target;t.removeEventListener(`dispose`,s),n.remove(t.instanceMatrix),t.instanceColor!==null&&n.remove(t.instanceColor)}return{update:a,dispose:o}}function Kl(e=null,t=1,n=1,r=1){qc.call(this,null),this.image={data:e,width:t,height:n,depth:r},this.magFilter=Im,this.minFilter=Im,this.wrapR=Pm,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function ql(e=null,t=1,n=1,r=1){qc.call(this,null),this.image={data:e,width:t,height:n,depth:r},this.magFilter=Im,this.minFilter=Im,this.wrapR=Pm,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function Jl(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=M_[i];if(a===void 0&&(a=new Float32Array(i),M_[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Yl(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function Xl(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function Zl(e,t){let n=N_[t];n===void 0&&(n=new Int32Array(t),N_[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function Ql(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function $l(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Yl(n,t))return;e.uniform2fv(this.addr,t),Xl(n,t)}}function eu(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(t.r!==void 0)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Yl(n,t))return;e.uniform3fv(this.addr,t),Xl(n,t)}}function tu(e,t){let n=this.cache;if(t.x!==void 0)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Yl(n,t))return;e.uniform4fv(this.addr,t),Xl(n,t)}}function nu(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Yl(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Xl(n,t)}else{if(Yl(n,r))return;I_.set(r),e.uniformMatrix2fv(this.addr,!1,I_),Xl(n,r)}}function ru(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Yl(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Xl(n,t)}else{if(Yl(n,r))return;F_.set(r),e.uniformMatrix3fv(this.addr,!1,F_),Xl(n,r)}}function iu(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(Yl(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Xl(n,t)}else{if(Yl(n,r))return;P_.set(r),e.uniformMatrix4fv(this.addr,!1,P_),Xl(n,r)}}function au(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTexture2D(t||O_,i)}function ou(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||k_,i)}function su(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||A_,i)}function cu(e,t,n){let r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTextureCube(t||j_,i)}function lu(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function uu(e,t){let n=this.cache;Yl(n,t)||(e.uniform2iv(this.addr,t),Xl(n,t))}function du(e,t){let n=this.cache;Yl(n,t)||(e.uniform3iv(this.addr,t),Xl(n,t))}function fu(e,t){let n=this.cache;Yl(n,t)||(e.uniform4iv(this.addr,t),Xl(n,t))}function pu(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function mu(e){switch(e){case 5126:return Ql;case 35664:return $l;case 35665:return eu;case 35666:return tu;case 35674:return nu;case 35675:return ru;case 35676:return iu;case 5124:case 35670:return lu;case 35667:case 35671:return uu;case 35668:case 35672:return du;case 35669:case 35673:return fu;case 5125:return pu;case 35678:case 36198:case 36298:case 36306:case 35682:return au;case 35679:case 36299:case 36307:return su;case 35680:case 36300:case 36308:case 36293:return cu;case 36289:case 36303:case 36311:case 36292:return ou}}function hu(e,t){e.uniform1fv(this.addr,t)}function gu(e,t){e.uniform1iv(this.addr,t)}function _u(e,t){e.uniform2iv(this.addr,t)}function vu(e,t){e.uniform3iv(this.addr,t)}function yu(e,t){e.uniform4iv(this.addr,t)}function bu(e,t){let n=Jl(t,this.size,2);e.uniform2fv(this.addr,n)}function xu(e,t){let n=Jl(t,this.size,3);e.uniform3fv(this.addr,n)}function Su(e,t){let n=Jl(t,this.size,4);e.uniform4fv(this.addr,n)}function Cu(e,t){let n=Jl(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function wu(e,t){let n=Jl(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Tu(e,t){let n=Jl(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Eu(e,t,n){let r=t.length,i=Zl(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.safeSetTexture2D(t[e]||O_,i[e])}function Du(e,t,n){let r=t.length,i=Zl(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.safeSetTextureCube(t[e]||j_,i[e])}function Ou(e){switch(e){case 5126:return hu;case 35664:return bu;case 35665:return xu;case 35666:return Su;case 35674:return Cu;case 35675:return wu;case 35676:return Tu;case 5124:case 35670:return gu;case 35667:case 35671:return _u;case 35668:case 35672:return vu;case 35669:case 35673:return yu;case 35678:case 36198:case 36298:case 36306:case 35682:return Eu;case 35680:case 36300:case 36308:case 36293:return Du}}function ku(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=mu(t.type)}function Au(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=Ou(t.type)}function ju(e){this.id=e,this.seq=[],this.map={}}function Mu(e,t){e.seq.push(t),e.map[t.id]=t}function Nu(e,t,n){let r=e.name,i=r.length;for(L_.lastIndex=0;;){let a=L_.exec(r),o=L_.lastIndex,s=a[1],c=a[2]===`]`,l=a[3];if(c&&(s|=0),l===void 0||l===`[`&&o+2===i){Mu(n,l===void 0?new ku(s,e,t):new Au(s,e,t));break}else{let e=n.map[s];e===void 0&&(e=new ju(s),Mu(n,e)),n=e}}}function Pu(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,35718);for(let r=0;r<n;++r){let n=e.getActiveUniform(t,r);Nu(n,e.getUniformLocation(t,n.name),this)}}function Fu(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}function Iu(e){let t=e.split(`
|
||
`);for(let e=0;e<t.length;e++)t[e]=e+1+`: `+t[e];return t.join(`
|
||
`)}function Lu(e){switch(e){case ih:return[`Linear`,`( value )`];case ah:return[`sRGB`,`( value )`];case sh:return[`RGBE`,`( value )`];case lh:return[`RGBM`,`( value, 7.0 )`];case uh:return[`RGBM`,`( value, 16.0 )`];case dh:return[`RGBD`,`( value, 256.0 )`];case oh:return[`Gamma`,`( value, float( GAMMA_FACTOR ) )`];case ch:return[`LogLuv`,`( value )`];default:return console.warn(`THREE.WebGLProgram: Unsupported encoding:`,e),[`Linear`,`( value )`]}}function Ru(e,t,n){let r=e.getShaderParameter(t,35713),i=e.getShaderInfoLog(t).trim();if(r&&i===``)return``;let a=e.getShaderSource(t);return`THREE.WebGLShader: gl.getShaderInfoLog() `+n+`
|
||
`+i+Iu(a)}function zu(e,t){let n=Lu(t);return`vec4 `+e+`( vec4 value ) { return `+n[0]+`ToLinear`+n[1]+`; }`}function Bu(e,t){let n=Lu(t);return`vec4 `+e+`( vec4 value ) { return LinearTo`+n[0]+n[1]+`; }`}function Vu(e,t){let n;switch(t){case 1:n=`Linear`;break;case 2:n=`Reinhard`;break;case 3:n=`OptimizedCineon`;break;case 4:n=`ACESFilmic`;break;case 5:n=`Custom`;break;default:console.warn(`THREE.WebGLProgram: Unsupported toneMapping:`,t),n=`Linear`}return`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}function Hu(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||e.shaderID===`physical`?`#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.rendererExtensionShaderTextureLod?`#extension GL_EXT_shader_texture_lod : enable`:``].filter(Gu).join(`
|
||
`)}function Uu(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(`
|
||
`)}function Wu(e,t){let n={},r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){let r=e.getActiveAttrib(t,i).name;n[r]=e.getAttribLocation(t,r)}return n}function Gu(e){return e!==``}function Ku(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 qu(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Ju(e){return e.replace(z_,Yu)}function Yu(e,t){let n=E_[t];if(n===void 0)throw Error(`Can not resolve #include <`+t+`>`);return Ju(n)}function Xu(e){return e.replace(V_,Qu).replace(B_,Zu)}function Zu(e,t,n,r){return console.warn(`WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.`),Qu(e,t,n,r)}function Qu(e,t,n,r){let i=``;for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,`[ `+e+` ]`).replace(/UNROLLED_LOOP_INDEX/g,e);return i}function $u(e){let t=`precision `+e.precision+` float;
|
||
precision `+e.precision+` int;`;return e.precision===`highp`?t+=`
|
||
#define HIGH_PRECISION`:e.precision===`mediump`?t+=`
|
||
#define MEDIUM_PRECISION`:e.precision===`lowp`&&(t+=`
|
||
#define LOW_PRECISION`),t}function ed(e){let t=`SHADOWMAP_TYPE_BASIC`;return e.shadowMapType===1?t=`SHADOWMAP_TYPE_PCF`:e.shadowMapType===2?t=`SHADOWMAP_TYPE_PCF_SOFT`:e.shadowMapType===3&&(t=`SHADOWMAP_TYPE_VSM`),t}function td(e){let t=`ENVMAP_TYPE_CUBE`;if(e.envMap)switch(e.envMapMode){case 301:case 302:t=`ENVMAP_TYPE_CUBE`;break;case 306:case 307:t=`ENVMAP_TYPE_CUBE_UV`;break}return t}function nd(e){let t=`ENVMAP_MODE_REFLECTION`;if(e.envMap)switch(e.envMapMode){case 302:case 307:t=`ENVMAP_MODE_REFRACTION`;break}return t}function rd(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`;break}return t}function id(e,t,n,r){let i=e.getContext(),a=n.defines,o=n.vertexShader,s=n.fragmentShader,c=ed(n),l=td(n),u=nd(n),d=rd(n),f=e.gammaFactor>0?e.gammaFactor:1,p=n.isWebGL2?``:Hu(n),m=Uu(a),h=i.createProgram(),g,_,v=n.glslVersion?`#version `+n.glslVersion+`
|
||
`:``;n.isRawShaderMaterial?(g=[m].filter(Gu).join(`
|
||
`),g.length>0&&(g+=`
|
||
`),_=[p,m].filter(Gu).join(`
|
||
`),_.length>0&&(_+=`
|
||
`)):(g=[$u(n),`#define SHADER_NAME `+n.shaderName,m,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.supportsVertexTextures?`#define VERTEX_TEXTURES`:``,`#define GAMMA_FACTOR `+f,`#define MAX_BONES `+n.maxBones,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMap&&n.objectSpaceNormalMap?`#define OBJECTSPACE_NORMALMAP`:``,n.normalMap&&n.tangentSpaceNormalMap?`#define TANGENTSPACE_NORMALMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.displacementMap&&n.supportsVertexTextures?`#define USE_DISPLACEMENTMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.vertexTangents?`#define USE_TANGENT`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexUvs?`#define USE_UV`:``,n.uvsVertexOnly?`#define UVS_VERTEX_ONLY`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.useVertexTexture?`#define BONE_TEXTURE`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.logarithmicDepthBuffer&&n.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`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#ifdef USE_COLOR`,` attribute vec3 color;`,`#endif`,`#ifdef USE_MORPHTARGETS`,` attribute vec3 morphTarget0;`,` attribute vec3 morphTarget1;`,` attribute vec3 morphTarget2;`,` attribute vec3 morphTarget3;`,` #ifdef USE_MORPHNORMALS`,` attribute vec3 morphNormal0;`,` attribute vec3 morphNormal1;`,` attribute vec3 morphNormal2;`,` attribute vec3 morphNormal3;`,` #else`,` attribute vec3 morphTarget4;`,` attribute vec3 morphTarget5;`,` attribute vec3 morphTarget6;`,` attribute vec3 morphTarget7;`,` #endif`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,`
|
||
`].filter(Gu).join(`
|
||
`),_=[p,$u(n),`#define SHADER_NAME `+n.shaderName,m,n.alphaTest?`#define ALPHATEST `+n.alphaTest+(n.alphaTest%1?``:`.0`):``,`#define GAMMA_FACTOR `+f,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMap&&n.objectSpaceNormalMap?`#define OBJECTSPACE_NORMALMAP`:``,n.normalMap&&n.tangentSpaceNormalMap?`#define TANGENTSPACE_NORMALMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.sheen?`#define USE_SHEEN`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.vertexTangents?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexUvs?`#define USE_UV`:``,n.uvsVertexOnly?`#define UVS_VERTEX_ONLY`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.physicallyCorrectLights?`#define PHYSICALLY_CORRECT_LIGHTS`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?`#define USE_LOGDEPTHBUF_EXT`:``,(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?`#define TEXTURE_LOD_EXT`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:E_.tonemapping_pars_fragment,n.toneMapping===0?``:Vu(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,E_.encodings_pars_fragment,n.map?zu(`mapTexelToLinear`,n.mapEncoding):``,n.matcap?zu(`matcapTexelToLinear`,n.matcapEncoding):``,n.envMap?zu(`envMapTexelToLinear`,n.envMapEncoding):``,n.emissiveMap?zu(`emissiveMapTexelToLinear`,n.emissiveMapEncoding):``,n.lightMap?zu(`lightMapTexelToLinear`,n.lightMapEncoding):``,Bu(`linearToOutputTexel`,n.outputEncoding),n.depthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,`
|
||
`].filter(Gu).join(`
|
||
`)),o=Ju(o),o=Ku(o,n),o=qu(o,n),s=Ju(s),s=Ku(s,n),s=qu(s,n),o=Xu(o),s=Xu(s),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(v=`#version 300 es
|
||
`,g=[`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(`
|
||
`)+`
|
||
`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#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(`
|
||
`)+`
|
||
`+_);let y=v+g+o,b=v+_+s,x=Fu(i,35633,y),S=Fu(i,35632,b);if(i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h),e.debug.checkShaderErrors){let e=i.getProgramInfoLog(h).trim(),t=i.getShaderInfoLog(x).trim(),n=i.getShaderInfoLog(S).trim(),r=!0,a=!0;if(i.getProgramParameter(h,35714)===!1){r=!1;let t=Ru(i,x,`vertex`),n=Ru(i,S,`fragment`);console.error(`THREE.WebGLProgram: shader error: `,i.getError(),`35715`,i.getProgramParameter(h,35715),`gl.getProgramInfoLog`,e,t,n)}else e===``?(t===``||n===``)&&(a=!1):console.warn(`THREE.WebGLProgram: gl.getProgramInfoLog()`,e);a&&(this.diagnostics={runnable:r,programLog:e,vertexShader:{log:t,prefix:g},fragmentShader:{log:n,prefix:_}})}i.deleteShader(x),i.deleteShader(S);let C;this.getUniforms=function(){return C===void 0&&(C=new Pu(i,h)),C};let w;return this.getAttributes=function(){return w===void 0&&(w=Wu(i,h)),w},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.name=n.shaderName,this.id=R_++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}function ad(e,t,n,r,i,a){let o=[],s=r.isWebGL2,c=r.logarithmicDepthBuffer,l=r.floatVertexTextures,u=r.maxVertexUniforms,d=r.vertexTextures,f=r.precision,p={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`},m=`precision.isWebGL2.supportsVertexTextures.outputEncoding.instancing.instancingColor.map.mapEncoding.matcap.matcapEncoding.envMap.envMapMode.envMapEncoding.envMapCubeUV.lightMap.lightMapEncoding.aoMap.emissiveMap.emissiveMapEncoding.bumpMap.normalMap.objectSpaceNormalMap.tangentSpaceNormalMap.clearcoatMap.clearcoatRoughnessMap.clearcoatNormalMap.displacementMap.specularMap.roughnessMap.metalnessMap.gradientMap.alphaMap.combine.vertexColors.vertexTangents.vertexUvs.uvsVertexOnly.fog.useFog.fogExp2.flatShading.sizeAttenuation.logarithmicDepthBuffer.skinning.maxBones.useVertexTexture.morphTargets.morphNormals.maxMorphTargets.maxMorphNormals.premultipliedAlpha.numDirLights.numPointLights.numSpotLights.numHemiLights.numRectAreaLights.numDirLightShadows.numPointLightShadows.numSpotLightShadows.shadowMapEnabled.shadowMapType.toneMapping.physicallyCorrectLights.alphaTest.doubleSided.flipSided.numClippingPlanes.numClipIntersection.depthPacking.dithering.sheen.transmissionMap`.split(`.`);function h(e){let t=e.skeleton.bones;if(l)return 1024;{let e=Math.floor((u-20)/4),n=Math.min(e,t.length);return n<t.length?(console.warn(`THREE.WebGLRenderer: Skeleton has `+t.length+` bones. This GPU supports `+n+`.`),0):n}}function g(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=ih,t}function _(i,o,u,m,_){let v=m.fog,y=i.isMeshStandardMaterial?m.environment:null,b=t.get(i.envMap||y),x=p[i.type],S=_.isSkinnedMesh?h(_):0;i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&console.warn(`THREE.WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let C,w;if(x){let e=D_[x];C=e.vertexShader,w=e.fragmentShader}else C=i.vertexShader,w=i.fragmentShader;let T=e.getRenderTarget();return{isWebGL2:s,shaderID:x,shaderName:i.type,vertexShader:C,fragmentShader:w,defines:i.defines,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,instancing:_.isInstancedMesh===!0,instancingColor:_.isInstancedMesh===!0&&_.instanceColor!==null,supportsVertexTextures:d,outputEncoding:T===null?e.outputEncoding:g(T.texture),map:!!i.map,mapEncoding:g(i.map),matcap:!!i.matcap,matcapEncoding:g(i.matcap),envMap:!!b,envMapMode:b&&b.mapping,envMapEncoding:g(b),envMapCubeUV:!!b&&(b.mapping===306||b.mapping===307),lightMap:!!i.lightMap,lightMapEncoding:g(i.lightMap),aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,emissiveMapEncoding:g(i.emissiveMap),bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,objectSpaceNormalMap:i.normalMapType===1,tangentSpaceNormalMap:i.normalMapType===0,clearcoatMap:!!i.clearcoatMap,clearcoatRoughnessMap:!!i.clearcoatRoughnessMap,clearcoatNormalMap:!!i.clearcoatNormalMap,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,specularMap:!!i.specularMap,alphaMap:!!i.alphaMap,gradientMap:!!i.gradientMap,sheen:!!i.sheen,transmissionMap:!!i.transmissionMap,combine:i.combine,vertexTangents:i.normalMap&&i.vertexTangents,vertexColors:i.vertexColors,vertexUvs:!!i.map||!!i.bumpMap||!!i.normalMap||!!i.specularMap||!!i.alphaMap||!!i.emissiveMap||!!i.roughnessMap||!!i.metalnessMap||!!i.clearcoatMap||!!i.clearcoatRoughnessMap||!!i.clearcoatNormalMap||!!i.displacementMap||!!i.transmissionMap,uvsVertexOnly:!(i.map||i.bumpMap||i.normalMap||i.specularMap||i.alphaMap||i.emissiveMap||i.roughnessMap||i.metalnessMap||i.clearcoatNormalMap||i.transmissionMap)&&!!i.displacementMap,fog:!!v,useFog:i.fog,fogExp2:v&&v.isFogExp2,flatShading:i.flatShading,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:c,skinning:i.skinning&&S>0,maxBones:S,useVertexTexture:l,morphTargets:i.morphTargets,morphNormals:i.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:i.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===2,flipSided:i.side===1,depthPacking:i.depthPacking===void 0?!1:i.depthPacking,index0AttributeName:i.index0AttributeName,extensionDerivatives:i.extensions&&i.extensions.derivatives,extensionFragDepth:i.extensions&&i.extensions.fragDepth,extensionDrawBuffers:i.extensions&&i.extensions.drawBuffers,extensionShaderTextureLOD:i.extensions&&i.extensions.shaderTextureLOD,rendererExtensionFragDepth:s||n.has(`EXT_frag_depth`),rendererExtensionDrawBuffers:s||n.has(`WEBGL_draw_buffers`),rendererExtensionShaderTextureLod:s||n.has(`EXT_shader_texture_lod`),customProgramCacheKey:i.customProgramCacheKey()}}function v(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);if(t.isRawShaderMaterial===!1){for(let e=0;e<m.length;e++)n.push(t[m[e]]);n.push(e.outputEncoding),n.push(e.gammaFactor)}return n.push(t.customProgramCacheKey),n.join()}function y(e){let t=p[e.type],n;if(t){let e=D_[t];n=__.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r;for(let e=0,t=o.length;e<t;e++){let t=o[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return r===void 0&&(r=new id(e,n,t,i),o.push(r)),r}function x(e){if(--e.usedTimes===0){let t=o.indexOf(e);o[t]=o[o.length-1],o.pop(),e.destroy()}}return{getParameters:_,getProgramCacheKey:v,getUniforms:y,acquireProgram:b,releaseProgram:x,programs:o}}function od(){let e=new WeakMap;function t(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function n(t){e.delete(t)}function r(t,n,r){e.get(t)[n]=r}function i(){e=new WeakMap}return{get:t,remove:n,update:r,dispose:i}}function sd(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.program===t.program?e.material.id===t.material.id?e.z===t.z?e.id-t.id:e.z-t.z:e.material.id-t.material.id:e.program.id-t.program.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function cd(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function ld(e){let t=[],n=0,r=[],i=[],a={id:-1};function o(){n=0,r.length=0,i.length=0}function s(r,i,o,s,c,l){let u=t[n],d=e.get(o);return u===void 0?(u={id:r.id,object:r,geometry:i,material:o,program:d.program||a,groupOrder:s,renderOrder:r.renderOrder,z:c,group:l},t[n]=u):(u.id=r.id,u.object=r,u.geometry=i,u.material=o,u.program=d.program||a,u.groupOrder=s,u.renderOrder=r.renderOrder,u.z=c,u.group=l),n++,u}function c(e,t,n,a,o,c){let l=s(e,t,n,a,o,c);(n.transparent===!0?i:r).push(l)}function l(e,t,n,a,o,c){let l=s(e,t,n,a,o,c);(n.transparent===!0?i:r).unshift(l)}function u(e,t){r.length>1&&r.sort(e||sd),i.length>1&&i.sort(t||cd)}function d(){for(let e=n,r=t.length;e<r;e++){let n=t[e];if(n.id===null)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.program=null,n.group=null}}return{opaque:r,transparent:i,init:o,push:c,unshift:l,finish:d,sort:u}}function ud(e){let t=new WeakMap;function n(n,r){let i=t.get(n),a;return i===void 0?(a=new ld(e),t.set(n,new WeakMap),t.get(n).set(r,a)):(a=i.get(r),a===void 0&&(a=new ld(e),i.set(r,a))),a}function r(){t=new WeakMap}return{get:n,dispose:r}}function dd(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new q,color:new Bg};break;case`SpotLight`:n={position:new q,direction:new q,color:new Bg,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new q,color:new Bg,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new q,skyColor:new Bg,groundColor:new Bg};break;case`RectAreaLight`:n={color:new Bg,position:new q,halfWidth:new q,halfHeight:new q};break}return e[t.id]=n,n}}}function fd(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`SpotLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`PointLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}function pd(e,t){return!!t.castShadow-+!!e.castShadow}function md(e,t){let n=new dd,r=fd(),i={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++)i.probe.push(new q);let a=new q,o=new Zh,s=new Zh;function c(a){let o=0,s=0,c=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;a.sort(pd);for(let e=0,t=a.length;e<t;e++){let t=a[e],_=t.color,v=t.intensity,y=t.distance,b=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)o+=_.r*v,s+=_.g*v,c+=_.b*v;else if(t.isLightProbe)for(let e=0;e<9;e++)i.probe[e].addScaledVector(t.sh.coefficients[e],v);else if(t.isDirectionalLight){let e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity),t.castShadow){let e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.directionalShadow[l]=n,i.directionalShadowMap[l]=b,i.directionalShadowMatrix[l]=t.shadow.matrix,m++}i.directional[l]=e,l++}else if(t.isSpotLight){let e=n.get(t);if(e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(_).multiplyScalar(v),e.distance=y,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,t.castShadow){let e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.spotShadow[d]=n,i.spotShadowMap[d]=b,i.spotShadowMatrix[d]=t.shadow.matrix,g++}i.spot[d]=e,d++}else if(t.isRectAreaLight){let e=n.get(t);e.color.copy(_).multiplyScalar(v),e.halfWidth.set(t.width*.5,0,0),e.halfHeight.set(0,t.height*.5,0),i.rectArea[f]=e,f++}else if(t.isPointLight){let e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity),e.distance=t.distance,e.decay=t.decay,t.castShadow){let e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,i.pointShadow[u]=n,i.pointShadowMap[u]=b,i.pointShadowMatrix[u]=t.shadow.matrix,h++}i.point[u]=e,u++}else if(t.isHemisphereLight){let e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(v),e.groundColor.copy(t.groundColor).multiplyScalar(v),i.hemi[p]=e,p++}}f>0&&(t.isWebGL2||e.has(`OES_texture_float_linear`)===!0?(i.rectAreaLTC1=X.LTC_FLOAT_1,i.rectAreaLTC2=X.LTC_FLOAT_2):e.has(`OES_texture_half_float_linear`)===!0?(i.rectAreaLTC1=X.LTC_HALF_1,i.rectAreaLTC2=X.LTC_HALF_2):console.error(`THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.`)),i.ambient[0]=o,i.ambient[1]=s,i.ambient[2]=c;let _=i.hash;(_.directionalLength!==l||_.pointLength!==u||_.spotLength!==d||_.rectAreaLength!==f||_.hemiLength!==p||_.numDirectionalShadows!==m||_.numPointShadows!==h||_.numSpotShadows!==g)&&(i.directional.length=l,i.spot.length=d,i.rectArea.length=f,i.point.length=u,i.hemi.length=p,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=h,i.pointShadowMap.length=h,i.spotShadow.length=g,i.spotShadowMap.length=g,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=h,i.spotShadowMatrix.length=g,_.directionalLength=l,_.pointLength=u,_.spotLength=d,_.rectAreaLength=f,_.hemiLength=p,_.numDirectionalShadows=m,_.numPointShadows=h,_.numSpotShadows=g,i.version=H_++)}function l(e,t){let n=0,r=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){let f=e[t];if(f.isDirectionalLight){let e=i.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(d),n++}else if(f.isSpotLight){let e=i.spot[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(d),c++}else if(f.isRectAreaLight){let e=i.rectArea[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),s.identity(),o.copy(f.matrixWorld),o.premultiply(d),s.extractRotation(o),e.halfWidth.set(f.width*.5,0,0),e.halfHeight.set(0,f.height*.5,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),l++}else if(f.isPointLight){let e=i.point[r];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),r++}else if(f.isHemisphereLight){let e=i.hemi[u];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(d),e.direction.normalize(),u++}}}return{setup:c,setupView:l,state:i}}function hd(e,t){let n=new md(e,t),r=[],i=[];function a(){r.length=0,i.length=0}function o(e){r.push(e)}function s(e){i.push(e)}function c(){n.setup(r)}function l(e){n.setupView(r,e)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:l,pushLight:o,pushShadow:s}}function gd(e,t){let n=new WeakMap;function r(r,i=0){let a;return n.has(r)===!1?(a=new hd(e,t),n.set(r,[]),n.get(r).push(a)):i>=n.get(r).length?(a=new hd(e,t),n.get(r).push(a)):a=n.get(r)[i],a}function i(){n=new WeakMap}return{get:r,dispose:i}}function _d(e){nl.call(this),this.type=`MeshDepthMaterial`,this.depthPacking=fh,this.skinning=!1,this.morphTargets=!1,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)}function vd(e){nl.call(this),this.type=`MeshDistanceMaterial`,this.referencePosition=new q,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}function yd(e,t,n){let r=new w_,i=new K,a=new K,o=new wh,s=[],c=[],l={},u={0:1,1:0,2:2},d=new Cl({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new K},radius:{value:4}},vertexShader:W_,fragmentShader:U_}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new _l;p.setAttribute(`position`,new il(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new vl(p,d),h=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(t,s,c){if(h.enabled===!1||h.autoUpdate===!1&&h.needsUpdate===!1||t.length===0)return;let l=e.getRenderTarget(),u=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);for(let l=0,u=t.length;l<u;l++){let u=t[l],d=u.shadow;if(d===void 0){console.warn(`THREE.WebGLShadowMap:`,u,`has no shadow.`);continue}if(d.autoUpdate===!1&&d.needsUpdate===!1)continue;i.copy(d.mapSize);let p=d.getFrameExtents();if(i.multiply(p),a.copy(d.mapSize),(i.x>n||i.y>n)&&(i.x>n&&(a.x=Math.floor(n/p.x),i.x=a.x*p.x,d.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/p.y),i.y=a.y*p.y,d.mapSize.y=a.y)),d.map===null&&!d.isPointLightShadow&&this.type===3){let e={minFilter:zm,magFilter:zm,format:Km};d.map=new Yc(i.x,i.y,e),d.map.texture.name=u.name+`.shadowMap`,d.mapPass=new Yc(i.x,i.y,e),d.camera.updateProjectionMatrix()}if(d.map===null){let e={minFilter:Im,magFilter:Im,format:Km};d.map=new Yc(i.x,i.y,e),d.map.texture.name=u.name+`.shadowMap`,d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();let m=d.getViewportCount();for(let e=0;e<m;e++){let t=d.getViewport(e);o.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),f.viewport(o),d.updateMatrices(u,e),r=d.getFrustum(),b(s,c,d.camera,u,this.type)}!d.isPointLightShadow&&this.type===3&&g(d,c),d.needsUpdate=!1}h.needsUpdate=!1,e.setRenderTarget(l,u,d)};function g(n,r){let i=t.update(m);d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,i,d,m,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,i,f,m,null)}function _(e,t,n){let r=e<<0|t<<1|n<<2,i=s[r];return i===void 0&&(i=new _d({depthPacking:ph,morphTargets:e,skinning:t}),s[r]=i),i}function v(e,t,n){let r=e<<0|t<<1|n<<2,i=c[r];return i===void 0&&(i=new vd({morphTargets:e,skinning:t}),c[r]=i),i}function y(t,n,r,i,a,o,s){let c=null,d=_,f=t.customDepthMaterial;if(i.isPointLight===!0&&(d=v,f=t.customDistanceMaterial),f===void 0){let e=!1;r.morphTargets===!0&&(e=n.morphAttributes&&n.morphAttributes.position&&n.morphAttributes.position.length>0);let i=!1;t.isSkinnedMesh===!0&&(r.skinning===!0?i=!0:console.warn(`THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:`,t));let a=t.isInstancedMesh===!0;c=d(e,i,a)}else c=f;if(e.localClippingEnabled&&r.clipShadows===!0&&r.clippingPlanes.length!==0){let e=c.uuid,t=r.uuid,n=l[e];n===void 0&&(n={},l[e]=n);let i=n[t];i===void 0&&(i=c.clone(),n[t]=i),c=i}return c.visible=r.visible,c.wireframe=r.wireframe,s===3?c.side=r.shadowSide===null?r.side:r.shadowSide:c.side=r.shadowSide===null?u[r.side]:r.shadowSide,c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,i.isPointLight===!0&&c.isMeshDistanceMaterial===!0&&(c.referencePosition.setFromMatrixPosition(i.matrixWorld),c.nearDistance=a,c.farDistance=o),c}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),i=n.material;if(Array.isArray(i)){let t=r.groups;for(let c=0,l=t.length;c<l;c++){let l=t[c],u=i[l.materialIndex];if(u&&u.visible){let t=y(n,r,u,o,a.near,a.far,s);e.renderBufferDirect(a,null,r,t,n,l)}}}else if(i.visible){let t=y(n,r,i,o,a.near,a.far,s);e.renderBufferDirect(a,null,r,t,n,null)}}let c=n.children;for(let e=0,t=c.length;e<t;e++)b(c[e],i,a,o,s)}}function bd(e,t,n){let r=n.isWebGL2;function i(){let t=!1,n=new wh,r=null,i=new wh(0,0,0,0);return{setMask:function(n){r!==n&&!t&&(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){s===!0&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),i.equals(n)===!1&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}}function a(){let t=!1,n=null,r=null,i=null;return{setTest:function(e){e?ee(2929):I(2929)},setMask:function(r){n!==r&&!t&&(e.depthMask(r),n=r)},setFunc:function(t){if(r!==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: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);break;default:e.depthFunc(515)}else e.depthFunc(515);r=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,n=null,r=null,i=null}}}function o(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(e){t||(e?ee(2960):I(2960))},setMask:function(r){n!==r&&!t&&(e.stencilMask(r),n=r)},setFunc:function(t,n,o){(r!==t||i!==n||a!==o)&&(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){(o!==t||s!==n||c!==r)&&(e.stencilOp(t,n,r),o=t,s=n,c=r)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}}let s=new i,c=new a,l=new o,u={},d=null,f=null,p=null,m=null,h=null,g=null,_=null,v=null,y=null,b=!1,x=null,S=null,C=null,w=null,T=null,E=e.getParameter(35661),D=!1,O=0,k=e.getParameter(7938);k.indexOf(`WebGL`)===-1?k.indexOf(`OpenGL ES`)!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),D=O>=2):(O=parseFloat(/^WebGL (\d)/.exec(k)[1]),D=O>=1);let A=null,j={},M=new wh,N=new wh;function P(t,n,r){let i=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<r;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,i);return a}let F={};F[3553]=P(3553,3553,1),F[34067]=P(34067,34069,6),s.setClear(0,0,0,1),c.setClear(1),l.setClear(0),ee(2929),c.setFunc(3),ie(!1),ae(1),ee(2884),R(0);function ee(t){u[t]!==!0&&(e.enable(t),u[t]=!0)}function I(t){u[t]!==!1&&(e.disable(t),u[t]=!1)}function L(t){return d===t?!1:(e.useProgram(t),d=t,!0)}let te={100:32774,101:32778,102:32779};if(r)te[103]=32775,te[104]=32776;else{let e=t.get(`EXT_blend_minmax`);e!==null&&(te[103]=e.MIN_EXT,te[104]=e.MAX_EXT)}let ne={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function R(t,n,r,i,a,o,s,c){if(t===0){f&&=(I(3042),!1);return}if(f||=(ee(3042),!0),t!==5){if(t!==p||c!==b){if((m!==100||_!==100)&&(e.blendEquation(32774),m=100,_=100),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);break}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);break}h=null,g=null,v=null,y=null,p=t,b=c}return}a||=n,o||=r,s||=i,(n!==m||a!==_)&&(e.blendEquationSeparate(te[n],te[a]),m=n,_=a),(r!==h||i!==g||o!==v||s!==y)&&(e.blendFuncSeparate(ne[r],ne[i],ne[o],ne[s]),h=r,g=i,v=o,y=s),p=t,b=null}function re(e,t){e.side===2?I(2884):ee(2884);let n=e.side===1;t&&(n=!n),ie(n),e.blending===1&&e.transparent===!1?R(0):R(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),c.setFunc(e.depthFunc),c.setTest(e.depthTest),c.setMask(e.depthWrite),s.setMask(e.colorWrite);let r=e.stencilWrite;l.setTest(r),r&&(l.setMask(e.stencilWriteMask),l.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),l.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),se(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function ie(t){x!==t&&(t?e.frontFace(2304):e.frontFace(2305),x=t)}function ae(t){t===0?I(2884):(ee(2884),t!==S&&(t===1?e.cullFace(1029):t===2?e.cullFace(1028):e.cullFace(1032))),S=t}function oe(t){t!==C&&(D&&e.lineWidth(t),C=t)}function se(t,n,r){t?(ee(32823),(w!==n||T!==r)&&(e.polygonOffset(n,r),w=n,T=r)):I(32823)}function ce(e){e?ee(3089):I(3089)}function le(t){t===void 0&&(t=33984+E-1),A!==t&&(e.activeTexture(t),A=t)}function ue(t,n){A===null&&le();let r=j[A];r===void 0&&(r={type:void 0,texture:void 0},j[A]=r),(r.type!==t||r.texture!==n)&&(e.bindTexture(t,n||F[t]),r.type=t,r.texture=n)}function de(){let t=j[A];t!==void 0&&t.type!==void 0&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)}function fe(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function pe(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function me(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error(`THREE.WebGLState:`,e)}}function he(t){M.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),M.copy(t))}function ge(t){N.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),N.copy(t))}function _e(){u={},A=null,j={},d=null,f=null,p=null,m=null,h=null,g=null,_=null,v=null,y=null,b=!1,x=null,S=null,C=null,w=null,T=null,s.reset(),c.reset(),l.reset()}return{buffers:{color:s,depth:c,stencil:l},enable:ee,disable:I,useProgram:L,setBlending:R,setMaterial:re,setFlipSided:ie,setCullFace:ae,setLineWidth:oe,setPolygonOffset:se,setScissorTest:ce,activeTexture:le,bindTexture:ue,unbindTexture:de,compressedTexImage2D:fe,texImage2D:pe,texImage3D:me,scissor:he,viewport:ge,reset:_e}}function xd(e,t,n,r,i,a,o){let s=i.isWebGL2,c=i.maxTextures,l=i.maxCubemapSize,u=i.maxTextureSize,d=i.maxSamples,f=new WeakMap,p,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):document.createElementNS(`http://www.w3.org/1999/xhtml`,`canvas`)}function g(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||t===!0)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let r=t?yh.floorPowerOfTwo:Math.floor,a=r(i*e.width),o=r(i*e.height);p===void 0&&(p=h(a,o));let s=n?h(a,o):p;return s.width=a,s.height=o,s.getContext(`2d`).drawImage(e,0,0,a,o),console.warn(`THREE.WebGLRenderer: Texture has been resized from (`+e.width+`x`+e.height+`) to (`+a+`x`+o+`).`),s}else return`data`in e&&console.warn(`THREE.WebGLRenderer: Image in DataTexture is too big (`+e.width+`x`+e.height+`).`),e;return e}function _(e){return yh.isPowerOfTwo(e.width)&&yh.isPowerOfTwo(e.height)}function v(e){return s?!1:e.wrapS!==1001||e.wrapT!==1001||e.minFilter!==1003&&e.minFilter!==1006}function y(e,t){return e.generateMipmaps&&t&&e.minFilter!==1003&&e.minFilter!==1006}function b(t,n,i,a){e.generateMipmap(t);let o=r.get(n);o.__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function x(n,r,i){if(s===!1)return r;if(n!==null){if(e[n]!==void 0)return e[n];console.warn(`THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let a=r;return r===6403&&(i===5126&&(a=33326),i===5131&&(a=33325),i===5121&&(a=33321)),r===6407&&(i===5126&&(a=34837),i===5131&&(a=34843),i===5121&&(a=32849)),r===6408&&(i===5126&&(a=34836),i===5131&&(a=34842),i===5121&&(a=32856)),(a===33325||a===33326||a===34842||a===34836)&&t.get(`EXT_color_buffer_float`),a}function S(e){return e===1003||e===1004||e===1005?9728:9729}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),T(t),t.isVideoTexture&&f.delete(t),o.memory.textures--}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),E(t),o.memory.textures--}function T(t){let n=r.get(t);n.__webglInit!==void 0&&(e.deleteTexture(n.__webglTexture),r.remove(t))}function E(t){let n=r.get(t),i=r.get(t.texture);if(t){if(i.__webglTexture!==void 0&&e.deleteTexture(i.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer&&e.deleteRenderbuffer(n.__webglColorRenderbuffer),n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer);r.remove(t.texture),r.remove(t)}}let D=0;function O(){D=0}function k(){let e=D;return e>=c&&console.warn(`THREE.WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+c),D+=1,e}function A(e,t){let i=r.get(e);if(e.isVideoTexture&&le(e),e.version>0&&i.__version!==e.version){let n=e.image;if(n===void 0)console.warn(`THREE.WebGLRenderer: Texture marked for update but image is undefined`);else if(n.complete===!1)console.warn(`THREE.WebGLRenderer: Texture marked for update but image is incomplete`);else{L(i,e,t);return}}n.activeTexture(33984+t),n.bindTexture(3553,i.__webglTexture)}function j(e,t){let i=r.get(e);if(e.version>0&&i.__version!==e.version){L(i,e,t);return}n.activeTexture(33984+t),n.bindTexture(35866,i.__webglTexture)}function M(e,t){let i=r.get(e);if(e.version>0&&i.__version!==e.version){L(i,e,t);return}n.activeTexture(33984+t),n.bindTexture(32879,i.__webglTexture)}function N(e,t){let i=r.get(e);if(e.version>0&&i.__version!==e.version){te(i,e,t);return}n.activeTexture(33984+t),n.bindTexture(34067,i.__webglTexture)}let P={[Nm]:10497,[Pm]:33071,[Fm]:33648},F={[Im]:9728,[Lm]:9984,[Rm]:9986,[zm]:9729,[Bm]:9985,[Vm]:9987};function ee(n,a,o){o?(e.texParameteri(n,10242,P[a.wrapS]),e.texParameteri(n,10243,P[a.wrapT]),(n===32879||n===35866)&&e.texParameteri(n,32882,P[a.wrapR]),e.texParameteri(n,10240,F[a.magFilter]),e.texParameteri(n,10241,F[a.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),(n===32879||n===35866)&&e.texParameteri(n,32882,33071),(a.wrapS!==1001||a.wrapT!==1001)&&console.warn(`THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.`),e.texParameteri(n,10240,S(a.magFilter)),e.texParameteri(n,10241,S(a.minFilter)),a.minFilter!==1003&&a.minFilter!==1006&&console.warn(`THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.`));let c=t.get(`EXT_texture_filter_anisotropic`);if(c){if(a.type===1015&&t.get(`OES_texture_float_linear`)===null||a.type===1016&&(s||t.get(`OES_texture_half_float_linear`))===null)return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function I(t,n){t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C),t.__webglTexture=e.createTexture(),o.memory.textures++)}function L(t,r,i){let o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),I(t,r),n.activeTexture(33984+i),n.bindTexture(o,t.__webglTexture),e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment);let c=v(r)&&_(r.image)===!1,l=g(r.image,c,!1,u),d=_(l)||s,f=a.convert(r.format),p=a.convert(r.type),m=x(r.internalFormat,f,p);ee(o,r,d);let h,S=r.mipmaps;if(r.isDepthTexture)m=6402,s?m=r.type===1015?36012:r.type===1014?33190:r.type===1020?35056:33189:r.type===1015&&console.error(`WebGLRenderer: Floating point depth texture requires WebGL2.`),r.format===1026&&m===6402&&r.type!==1012&&r.type!==1014&&(console.warn(`THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.`),r.type=Hm,p=a.convert(r.type)),r.format===1027&&m===6402&&(m=34041,r.type!==1020&&(console.warn(`THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.`),r.type=Wm,p=a.convert(r.type))),n.texImage2D(3553,0,m,l.width,l.height,0,f,p,null);else if(r.isDataTexture)if(S.length>0&&d){for(let e=0,t=S.length;e<t;e++)h=S[e],n.texImage2D(3553,e,m,h.width,h.height,0,f,p,h.data);r.generateMipmaps=!1,t.__maxMipLevel=S.length-1}else n.texImage2D(3553,0,m,l.width,l.height,0,f,p,l.data),t.__maxMipLevel=0;else if(r.isCompressedTexture){for(let e=0,t=S.length;e<t;e++)h=S[e],r.format!==1023&&r.format!==1022?f===null?console.warn(`THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`):n.compressedTexImage2D(3553,e,m,h.width,h.height,0,h.data):n.texImage2D(3553,e,m,h.width,h.height,0,f,p,h.data);t.__maxMipLevel=S.length-1}else if(r.isDataTexture2DArray)n.texImage3D(35866,0,m,l.width,l.height,l.depth,0,f,p,l.data),t.__maxMipLevel=0;else if(r.isDataTexture3D)n.texImage3D(32879,0,m,l.width,l.height,l.depth,0,f,p,l.data),t.__maxMipLevel=0;else if(S.length>0&&d){for(let e=0,t=S.length;e<t;e++)h=S[e],n.texImage2D(3553,e,m,f,p,h);r.generateMipmaps=!1,t.__maxMipLevel=S.length-1}else n.texImage2D(3553,0,m,f,p,l),t.__maxMipLevel=0;y(r,d)&&b(o,r,l.width,l.height),t.__version=r.version,r.onUpdate&&r.onUpdate(r)}function te(t,r,i){if(r.image.length!==6)return;I(t,r),n.activeTexture(33984+i),n.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,r.flipY);let o=r&&(r.isCompressedTexture||r.image[0].isCompressedTexture),c=r.image[0]&&r.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)!o&&!c?u[e]=g(r.image[e],!1,!0,l):u[e]=c?r.image[e].image:r.image[e];let d=u[0],f=_(d)||s,p=a.convert(r.format),m=a.convert(r.type),h=x(r.internalFormat,p,m);ee(34067,r,f);let v;if(o){for(let e=0;e<6;e++){v=u[e].mipmaps;for(let t=0;t<v.length;t++){let i=v[t];r.format!==1023&&r.format!==1022?p===null?console.warn(`THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()`):n.compressedTexImage2D(34069+e,t,h,i.width,i.height,0,i.data):n.texImage2D(34069+e,t,h,i.width,i.height,0,p,m,i.data)}}t.__maxMipLevel=v.length-1}else{v=r.mipmaps;for(let e=0;e<6;e++)if(c){n.texImage2D(34069+e,0,h,u[e].width,u[e].height,0,p,m,u[e].data);for(let t=0;t<v.length;t++){let r=v[t].image[e].image;n.texImage2D(34069+e,t+1,h,r.width,r.height,0,p,m,r.data)}}else{n.texImage2D(34069+e,0,h,p,m,u[e]);for(let t=0;t<v.length;t++){let r=v[t];n.texImage2D(34069+e,t+1,h,p,m,r.image[e])}}t.__maxMipLevel=v.length}y(r,f)&&b(34067,r,d.width,d.height),t.__version=r.version,r.onUpdate&&r.onUpdate(r)}function ne(t,i,o,s){let c=a.convert(i.texture.format),l=a.convert(i.texture.type),u=x(i.texture.internalFormat,c,l);n.texImage2D(s,0,u,i.width,i.height,0,c,l,null),e.bindFramebuffer(36160,t),e.framebufferTexture2D(36160,o,s,r.get(i.texture).__webglTexture,0),e.bindFramebuffer(36160,null)}function R(t,n,r){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let i=33189;if(r){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===1015?i=36012:t.type===1014&&(i=33190));let r=ce(n);e.renderbufferStorageMultisample(36161,r,i,n.width,n.height)}else e.renderbufferStorage(36161,i,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){if(r){let t=ce(n);e.renderbufferStorageMultisample(36161,t,35056,n.width,n.height)}else e.renderbufferStorage(36161,34041,n.width,n.height);e.framebufferRenderbuffer(36160,33306,36161,t)}else{let t=a.convert(n.texture.format),i=a.convert(n.texture.type),o=x(n.texture.internalFormat,t,i);if(r){let t=ce(n);e.renderbufferStorageMultisample(36161,t,o,n.width,n.height)}else e.renderbufferStorage(36161,o,n.width,n.height)}e.bindRenderbuffer(36161,null)}function re(t,n){if(n&&n.isWebGLCubeRenderTarget)throw Error(`Depth Texture with cube render targets is not supported`);if(e.bindFramebuffer(36160,t),!(n.depthTexture&&n.depthTexture.isDepthTexture))throw Error(`renderTarget.depthTexture must be an instance of THREE.DepthTexture`);(!r.get(n.depthTexture).__webglTexture||n.depthTexture.image.width!==n.width||n.depthTexture.image.height!==n.height)&&(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),A(n.depthTexture,0);let i=r.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===1026)e.framebufferTexture2D(36160,36096,3553,i,0);else if(n.depthTexture.format===1027)e.framebufferTexture2D(36160,33306,3553,i,0);else throw Error(`Unknown depthTexture format`)}function ie(t){let n=r.get(t),i=t.isWebGLCubeRenderTarget===!0;if(t.depthTexture){if(i)throw Error(`target.depthTexture not supported in Cube render targets`);re(n.__webglFramebuffer,t)}else if(i){n.__webglDepthbuffer=[];for(let r=0;r<6;r++)e.bindFramebuffer(36160,n.__webglFramebuffer[r]),n.__webglDepthbuffer[r]=e.createRenderbuffer(),R(n.__webglDepthbuffer[r],t,!1)}else e.bindFramebuffer(36160,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),R(n.__webglDepthbuffer,t,!1);e.bindFramebuffer(36160,null)}function ae(t){let i=r.get(t),c=r.get(t.texture);t.addEventListener(`dispose`,w),c.__webglTexture=e.createTexture(),o.memory.textures++;let l=t.isWebGLCubeRenderTarget===!0,u=t.isWebGLMultisampleRenderTarget===!0,d=_(t)||s;if(s&&t.texture.format===1022&&(t.texture.type===1015||t.texture.type===1016)&&(t.texture.format=Km,console.warn(`THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.`)),l){i.__webglFramebuffer=[];for(let t=0;t<6;t++)i.__webglFramebuffer[t]=e.createFramebuffer()}else if(i.__webglFramebuffer=e.createFramebuffer(),u)if(s){i.__webglMultisampledFramebuffer=e.createFramebuffer(),i.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,i.__webglColorRenderbuffer);let n=a.convert(t.texture.format),r=a.convert(t.texture.type),o=x(t.texture.internalFormat,n,r),s=ce(t);e.renderbufferStorageMultisample(36161,s,o,t.width,t.height),e.bindFramebuffer(36160,i.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,i.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(i.__webglDepthRenderbuffer=e.createRenderbuffer(),R(i.__webglDepthRenderbuffer,t,!0)),e.bindFramebuffer(36160,null)}else console.warn(`THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.`);if(l){n.bindTexture(34067,c.__webglTexture),ee(34067,t.texture,d);for(let e=0;e<6;e++)ne(i.__webglFramebuffer[e],t,36064,34069+e);y(t.texture,d)&&b(34067,t.texture,t.width,t.height),n.bindTexture(34067,null)}else n.bindTexture(3553,c.__webglTexture),ee(3553,t.texture,d),ne(i.__webglFramebuffer,t,36064,3553),y(t.texture,d)&&b(3553,t.texture,t.width,t.height),n.bindTexture(3553,null);t.depthBuffer&&ie(t)}function oe(e){let t=e.texture;if(y(t,_(e)||s)){let i=e.isWebGLCubeRenderTarget?34067:3553,a=r.get(t).__webglTexture;n.bindTexture(i,a),b(i,t,e.width,e.height),n.bindTexture(i,null)}}function se(t){if(t.isWebGLMultisampleRenderTarget)if(s){let n=r.get(t);e.bindFramebuffer(36008,n.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,n.__webglFramebuffer);let i=t.width,a=t.height,o=16384;t.depthBuffer&&(o|=256),t.stencilBuffer&&(o|=1024),e.blitFramebuffer(0,0,i,a,0,0,i,a,o,9728),e.bindFramebuffer(36160,n.__webglMultisampledFramebuffer)}else console.warn(`THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.`)}function ce(e){return s&&e.isWebGLMultisampleRenderTarget?Math.min(d,e.samples):0}function le(e){let t=o.render.frame;f.get(e)!==t&&(f.set(e,t),e.update())}let ue=!1,de=!1;function fe(e,t){e&&e.isWebGLRenderTarget&&(ue===!1&&(console.warn(`THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead.`),ue=!0),e=e.texture),A(e,t)}function pe(e,t){e&&e.isWebGLCubeRenderTarget&&(de===!1&&(console.warn(`THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead.`),de=!0),e=e.texture),N(e,t)}this.allocateTextureUnit=k,this.resetTextureUnits=O,this.setTexture2D=A,this.setTexture2DArray=j,this.setTexture3D=M,this.setTextureCube=N,this.setupRenderTarget=ae,this.updateRenderTargetMipmap=oe,this.updateMultisampleRenderTarget=se,this.safeSetTexture2D=fe,this.safeSetTextureCube=pe}function Sd(e,t,n){let r=n.isWebGL2;function i(e){let n;if(e===1009)return 5121;if(e===1017)return 32819;if(e===1018)return 32820;if(e===1019)return 33635;if(e===1010)return 5120;if(e===1011)return 5122;if(e===1012)return 5123;if(e===1013)return 5124;if(e===1014)return 5125;if(e===1015)return 5126;if(e===1016)return r?5131:(n=t.get(`OES_texture_half_float`),n===null?null:n.HALF_FLOAT_OES);if(e===1021)return 6406;if(e===1022)return 6407;if(e===1023)return 6408;if(e===1024)return 6409;if(e===1025)return 6410;if(e===1026)return 6402;if(e===1027)return 34041;if(e===1028)return 6403;if(e===1029)return 36244;if(e===1030)return 33319;if(e===1031)return 33320;if(e===1032)return 36248;if(e===1033)return 36249;if(e===33776||e===33777||e===33778||e===33779)if(n=t.get(`WEBGL_compressed_texture_s3tc`),n!==null){if(e===33776)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===33777)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===33778)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===33779)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===35840||e===35841||e===35842||e===35843)if(n=t.get(`WEBGL_compressed_texture_pvrtc`),n!==null){if(e===35840)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===35841)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===35842)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===35843)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===36196)return n=t.get(`WEBGL_compressed_texture_etc1`),n===null?null:n.COMPRESSED_RGB_ETC1_WEBGL;if((e===37492||e===37496)&&(n=t.get(`WEBGL_compressed_texture_etc`),n!==null)){if(e===37492)return n.COMPRESSED_RGB8_ETC2;if(e===37496)return n.COMPRESSED_RGBA8_ETC2_EAC}if(e===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)return n=t.get(`WEBGL_compressed_texture_astc`),n===null?null:e;if(e===36492)return n=t.get(`EXT_texture_compression_bptc`),n===null?null:e;if(e===1020)return r?34042:(n=t.get(`WEBGL_depth_texture`),n===null?null:n.UNSIGNED_INT_24_8_WEBGL)}return{convert:i}}function Cd(e=[]){Tl.call(this),this.cameras=e}function wd(){Qc.call(this),this.type=`Group`}function Td(){this._targetRay=null,this._grip=null,this._hand=null}function Ed(e,t){let n=this,r=null,i=1,a=null,o=`local-floor`,s=null,c=[],l=new Map,u=new Tl;u.layers.enable(1),u.viewport=new wh;let d=new Tl;d.layers.enable(2),d.viewport=new wh;let f=[u,d],p=new Cd;p.layers.enable(1),p.layers.enable(2);let m=null,h=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=c[e];return t===void 0&&(t=new Td,c[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=c[e];return t===void 0&&(t=new Td,c[e]=t),t.getGripSpace()},this.getHand=function(e){let t=c[e];return t===void 0&&(t=new Td,c[e]=t),t.getHandSpace()};function g(e){let t=l.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function _(){l.forEach(function(e,t){e.disconnect(t)}),l.clear(),e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),E.stop(),n.isPresenting=!1,n.dispatchEvent({type:`sessionend`})}function v(e){a=e,E.setContext(r),E.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return a},this.getSession=function(){return r},this.setSession=function(e){if(r=e,r!==null){r.addEventListener(`select`,g),r.addEventListener(`selectstart`,g),r.addEventListener(`selectend`,g),r.addEventListener(`squeeze`,g),r.addEventListener(`squeezestart`,g),r.addEventListener(`squeezeend`,g),r.addEventListener(`end`,_);let e=t.getContextAttributes();e.xrCompatible!==!0&&t.makeXRCompatible();let n={antialias:e.antialias,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:i},a=new XRWebGLLayer(r,t,n);r.updateRenderState({baseLayer:a}),r.requestReferenceSpace(o).then(v),r.addEventListener(`inputsourceschange`,y)}};function y(e){let t=r.inputSources;for(let e=0;e<c.length;e++)l.set(t[e],c[e]);for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=l.get(n);r&&(r.dispatchEvent({type:`disconnected`,data:n}),l.delete(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=l.get(n);r&&r.dispatchEvent({type:`connected`,data:n})}}let b=new q,x=new q;function S(e,t,n){b.setFromMatrixPosition(t.matrixWorld),x.setFromMatrixPosition(n.matrixWorld);let r=b.distanceTo(x),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();let g=o+m,_=s+m,v=f-h,y=p+(r-h),S=c*s/_*g,C=l*s/_*g;e.projectionMatrix.makePerspective(v,y,S,C,g,_)}function C(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.getCamera=function(e){p.near=d.near=u.near=e.near,p.far=d.far=u.far=e.far,(m!==p.near||h!==p.far)&&(r.updateRenderState({depthNear:p.near,depthFar:p.far}),m=p.near,h=p.far);let t=e.parent,n=p.cameras;C(p,t);for(let e=0;e<n.length;e++)C(n[e],t);e.matrixWorld.copy(p.matrixWorld);let i=e.children;for(let e=0,t=i.length;e<t;e++)i[e].updateMatrixWorld(!0);return n.length===2?S(p,u,d):p.projectionMatrix.copy(u.projectionMatrix),p};let w=null;function T(t,n){if(s=n.getViewerPose(a),s!==null){let t=s.views,n=r.renderState.baseLayer;e.setFramebuffer(n.framebuffer);let i=!1;t.length!==p.cameras.length&&(p.cameras.length=0,i=!0);for(let e=0;e<t.length;e++){let r=t[e],a=n.getViewport(r),o=f[e];o.matrix.fromArray(r.transform.matrix),o.projectionMatrix.fromArray(r.projectionMatrix),o.viewport.set(a.x,a.y,a.width,a.height),e===0&&p.matrix.copy(o.matrix),i===!0&&p.cameras.push(o)}}let i=r.inputSources;for(let e=0;e<c.length;e++){let t=c[e],r=i[e];t.update(r,n,a)}w&&w(t,n)}let E=new Al;E.setAnimationLoop(T),this.setAnimationLoop=function(e){w=e},this.dispose=function(){}}function Dd(e){function t(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)}function n(e,t,n,_){t.isMeshBasicMaterial?r(e,t):t.isMeshLambertMaterial?(r(e,t),c(e,t)):t.isMeshToonMaterial?(r(e,t),u(e,t)):t.isMeshPhongMaterial?(r(e,t),l(e,t)):t.isMeshStandardMaterial?(r(e,t),t.isMeshPhysicalMaterial?f(e,t):d(e,t)):t.isMeshMatcapMaterial?(r(e,t),p(e,t)):t.isMeshDepthMaterial?(r(e,t),m(e,t)):t.isMeshDistanceMaterial?(r(e,t),h(e,t)):t.isMeshNormalMaterial?(r(e,t),g(e,t)):t.isLineBasicMaterial?(i(e,t),t.isLineDashedMaterial&&a(e,t)):t.isPointsMaterial?o(e,t,n,_):t.isSpriteMaterial?s(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function r(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map),n.alphaMap&&(t.alphaMap.value=n.alphaMap),n.specularMap&&(t.specularMap.value=n.specularMap);let r=e.get(n).envMap;if(r){t.envMap.value=r,t.flipEnvMap.value=r.isCubeTexture&&r._needsFlipEnvMap?-1:1,t.reflectivity.value=n.reflectivity,t.refractionRatio.value=n.refractionRatio;let i=e.get(r).__maxMipLevel;i!==void 0&&(t.maxMipLevel.value=i)}n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity);let i;n.map?i=n.map:n.specularMap?i=n.specularMap:n.displacementMap?i=n.displacementMap:n.normalMap?i=n.normalMap:n.bumpMap?i=n.bumpMap:n.roughnessMap?i=n.roughnessMap:n.metalnessMap?i=n.metalnessMap:n.alphaMap?i=n.alphaMap:n.emissiveMap?i=n.emissiveMap:n.clearcoatMap?i=n.clearcoatMap:n.clearcoatNormalMap?i=n.clearcoatNormalMap:n.clearcoatRoughnessMap&&(i=n.clearcoatRoughnessMap),i!==void 0&&(i.isWebGLRenderTarget&&(i=i.texture),i.matrixAutoUpdate===!0&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix));let a;n.aoMap?a=n.aoMap:n.lightMap&&(a=n.lightMap),a!==void 0&&(a.isWebGLRenderTarget&&(a=a.texture),a.matrixAutoUpdate===!0&&a.updateMatrix(),t.uv2Transform.value.copy(a.matrix))}function i(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}function a(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function o(e,t,n,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=r*.5,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap);let i;t.map?i=t.map:t.alphaMap&&(i=t.alphaMap),i!==void 0&&(i.matrixAutoUpdate===!0&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}function s(e,t){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);let n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap),n!==void 0&&(n.matrixAutoUpdate===!0&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}function c(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function l(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,t.side===1&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===1&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function u(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,t.side===1&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===1&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function d(t,n){t.roughness.value=n.roughness,t.metalness.value=n.metalness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap),n.bumpMap&&(t.bumpMap.value=n.bumpMap,t.bumpScale.value=n.bumpScale,n.side===1&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,t.normalScale.value.copy(n.normalScale),n.side===1&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}function f(e,t){d(e,t),e.reflectivity.value=t.reflectivity,e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.sheen&&e.sheen.value.copy(t.sheen),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,t.side===1&&e.clearcoatNormalScale.value.negate()),e.transmission.value=t.transmission,t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap)}function p(e,t){t.matcap&&(e.matcap.value=t.matcap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===1&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===1&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function m(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function h(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}function g(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===1&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===1&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function Od(){let e=document.createElementNS(`http://www.w3.org/1999/xhtml`,`canvas`);return e.style.display=`block`,e}function kd(e){e||={};let t=e.canvas===void 0?Od():e.canvas,n=e.context===void 0?null:e.context,r=e.alpha===void 0?!1:e.alpha,i=e.depth===void 0?!0:e.depth,a=e.stencil===void 0?!0:e.stencil,o=e.antialias===void 0?!1:e.antialias,s=e.premultipliedAlpha===void 0?!0:e.premultipliedAlpha,c=e.preserveDrawingBuffer===void 0?!1:e.preserveDrawingBuffer,l=e.powerPreference===void 0?`default`:e.powerPreference,u=e.failIfMajorPerformanceCaveat===void 0?!1:e.failIfMajorPerformanceCaveat,d=null,f=null,p=[];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=ih,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;let m=this,h=!1,g=null,_=0,v=0,y=null,b=null,x=-1,S=null,C=new wh,w=new wh,T=null,E=t.width,D=t.height,O=1,k=null,A=null,j=new wh(0,0,E,D),M=new wh(0,0,E,D),N=!1,P=new w_,F=!1,ee=!1,I=new Zh,L=new q,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ne(){return y===null?O:1}let R=n;function re(e,n){for(let r=0;r<e.length;r++){let i=e[r],a=t.getContext(i,n);if(a!==null)return a}return null}try{let e={alpha:r,depth:i,stencil:a,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(t.addEventListener(`webglcontextlost`,Oe,!1),t.addEventListener(`webglcontextrestored`,ke,!1),R===null){let t=[`webgl2`,`webgl`,`experimental-webgl`];if(m.isWebGL1Renderer===!0&&t.shift(),R=re(t,e),R===null)throw re(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}R.getShaderPrecisionFormat===void 0&&(R.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error(`THREE.WebGLRenderer: `+e.message),e}let ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e,ve,ye,be,xe,Se,Ce,we;function Te(){ie=new Rl(R),ae=new Fl(R,ie,e),ae.isWebGL2===!1&&(ie.get(`WEBGL_depth_texture`),ie.get(`OES_texture_float`),ie.get(`OES_texture_half_float`),ie.get(`OES_texture_half_float_linear`),ie.get(`OES_standard_derivatives`),ie.get(`OES_element_index_uint`),ie.get(`OES_vertex_array_object`),ie.get(`ANGLE_instanced_arrays`)),ie.get(`OES_texture_float_linear`),Ce=new Sd(R,ie,ae),oe=new bd(R,ie,ae),oe.scissor(w.copy(M).multiplyScalar(O).floor()),oe.viewport(C.copy(j).multiplyScalar(O).floor()),se=new Vl(R),ce=new od,le=new xd(R,ie,oe,ce,ae,Ce,se),ue=new Ll(m),de=new jl(R,ae),we=new Nl(R,ie,de,ae),fe=new zl(R,de,se,we),pe=new Gl(R,fe,de,se),be=new Wl(R),ve=new Il(ce),me=new ad(m,ue,ie,ae,we,ve),he=new Dd(ce),ge=new ud(ce),_e=new gd(ie,ae),ye=new Ml(m,ue,oe,pe,s),xe=new Pl(R,ie,se,ae),Se=new Bl(R,ie,se,ae),se.programs=me.programs,m.capabilities=ae,m.extensions=ie,m.properties=ce,m.renderLists=ge,m.state=oe,m.info=se}Te();let Ee=new Ed(m,R);this.xr=Ee;let De=new yd(m,pe,ae.maxTextureSize);this.shadowMap=De,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){let e=ie.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=ie.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(e){e!==void 0&&(O=e,this.setSize(E,D,!1))},this.getSize=function(e){return e===void 0&&(console.warn(`WebGLRenderer: .getsize() now requires a Vector2 as an argument`),e=new K),e.set(E,D)},this.setSize=function(e,n,r){if(Ee.isPresenting){console.warn(`THREE.WebGLRenderer: Can't change size while VR device is presenting.`);return}E=e,D=n,t.width=Math.floor(e*O),t.height=Math.floor(n*O),r!==!1&&(t.style.width=e+`px`,t.style.height=n+`px`),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e===void 0&&(console.warn(`WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument`),e=new K),e.set(E*O,D*O).floor()},this.setDrawingBufferSize=function(e,n,r){E=e,D=n,O=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e===void 0&&(console.warn(`WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument`),e=new wh),e.copy(C)},this.getViewport=function(e){return e.copy(j)},this.setViewport=function(e,t,n,r){e.isVector4?j.set(e.x,e.y,e.z,e.w):j.set(e,t,n,r),oe.viewport(C.copy(j).multiplyScalar(O).floor())},this.getScissor=function(e){return e.copy(M)},this.setScissor=function(e,t,n,r){e.isVector4?M.set(e.x,e.y,e.z,e.w):M.set(e,t,n,r),oe.scissor(w.copy(M).multiplyScalar(O).floor())},this.getScissorTest=function(){return N},this.setScissorTest=function(e){oe.setScissorTest(N=e)},this.setOpaqueSort=function(e){k=e},this.setTransparentSort=function(e){A=e},this.getClearColor=function(e){return e===void 0&&(console.warn(`WebGLRenderer: .getClearColor() now requires a Color as an argument`),e=new Bg),e.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor.apply(ye,arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha.apply(ye,arguments)},this.clear=function(e,t,n){let r=0;(e===void 0||e)&&(r|=16384),(t===void 0||t)&&(r|=256),(n===void 0||n)&&(r|=1024),R.clear(r)},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`,Oe,!1),t.removeEventListener(`webglcontextrestored`,ke,!1),ge.dispose(),_e.dispose(),ce.dispose(),ue.dispose(),pe.dispose(),we.dispose(),Ee.dispose(),Fe.stop()};function Oe(e){e.preventDefault(),console.log(`THREE.WebGLRenderer: Context Lost.`),h=!0}function ke(){console.log(`THREE.WebGLRenderer: Context Restored.`),h=!1,Te()}function Ae(e){let t=e.target;t.removeEventListener(`dispose`,Ae),je(t)}function je(e){Me(e),ce.remove(e)}function Me(e){let t=ce.get(e).program;t!==void 0&&me.releaseProgram(t)}function Ne(e,t){e.render(function(e){m.renderBufferImmediate(e,t)})}this.renderBufferImmediate=function(e,t){we.initAttributes();let n=ce.get(e);e.hasPositions&&!n.position&&(n.position=R.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=R.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=R.createBuffer()),e.hasColors&&!n.color&&(n.color=R.createBuffer());let r=t.getAttributes();e.hasPositions&&(R.bindBuffer(34962,n.position),R.bufferData(34962,e.positionArray,35048),we.enableAttribute(r.position),R.vertexAttribPointer(r.position,3,5126,!1,0,0)),e.hasNormals&&(R.bindBuffer(34962,n.normal),R.bufferData(34962,e.normalArray,35048),we.enableAttribute(r.normal),R.vertexAttribPointer(r.normal,3,5126,!1,0,0)),e.hasUvs&&(R.bindBuffer(34962,n.uv),R.bufferData(34962,e.uvArray,35048),we.enableAttribute(r.uv),R.vertexAttribPointer(r.uv,2,5126,!1,0,0)),e.hasColors&&(R.bindBuffer(34962,n.color),R.bufferData(34962,e.colorArray,35048),we.enableAttribute(r.color),R.vertexAttribPointer(r.color,3,5126,!1,0,0)),we.disableUnusedAttributes(),R.drawArrays(4,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=te);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=Be(e,t,r,i);oe.setMaterial(r,o);let c=n.index,l=n.attributes.position;if(c===null){if(l===void 0||l.count===0)return}else if(c.count===0)return;let u=1;r.wireframe===!0&&(c=fe.getWireframeAttribute(n),u=2),(r.morphTargets||r.morphNormals)&&be.update(i,n,r,s),we.setup(i,r,s,n,c);let d,f=xe;c!==null&&(d=de.get(c),f=Se,f.setIndex(d));let p=c===null?l.count:c.count,m=n.drawRange.start*u,h=n.drawRange.count*u,g=a===null?0:a.start*u,_=a===null?1/0:a.count*u,v=Math.max(m,g),y=Math.min(p,m+h,g+_)-1,b=Math.max(0,y-v+1);if(b!==0){if(i.isMesh)r.wireframe===!0?(oe.setLineWidth(r.wireframeLinewidth*ne()),f.setMode(1)):f.setMode(4);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),oe.setLineWidth(e*ne()),i.isLineSegments?f.setMode(1):i.isLineLoop?f.setMode(2):f.setMode(3)}else i.isPoints?f.setMode(0):i.isSprite&&f.setMode(4);if(i.isInstancedMesh)f.renderInstances(v,b,i.count);else if(n.isInstancedBufferGeometry){let e=Math.min(n.instanceCount,n._maxInstanceCount);f.renderInstances(v,b,e)}else f.render(v,b)}},this.compile=function(e,t){f=_e.get(e),f.init(),e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(f.pushLight(e),e.castShadow&&f.pushShadow(e))}),f.setupLights();let n=new WeakMap;e.traverse(function(t){let r=t.material;if(r)if(Array.isArray(r))for(let i=0;i<r.length;i++){let a=r[i];n.has(a)===!1&&(ze(a,e,t),n.set(a))}else n.has(r)===!1&&(ze(r,e,t),n.set(r))})};let Pe=null;function z(e){Ee.isPresenting||Pe&&Pe(e)}let Fe=new Al;Fe.setAnimationLoop(z),typeof window<`u`&&Fe.setContext(window),this.setAnimationLoop=function(e){Pe=e,Ee.setAnimationLoop(e),e===null?Fe.stop():Fe.start()},this.render=function(e,t){let n,r;if(arguments[2]!==void 0&&(console.warn(`THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.`),n=arguments[2]),arguments[3]!==void 0&&(console.warn(`THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.`),r=arguments[3]),t!==void 0&&t.isCamera!==!0){console.error(`THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(h===!0)return;we.resetDefaultState(),x=-1,S=null,e.autoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.updateMatrixWorld(),Ee.enabled===!0&&Ee.isPresenting===!0&&(t=Ee.getCamera(t)),e.isScene===!0&&e.onBeforeRender(m,e,t,n||y),f=_e.get(e,p.length),f.init(),p.push(f),I.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),P.setFromProjectionMatrix(I),ee=this.localClippingEnabled,F=ve.init(this.clippingPlanes,ee,t),d=ge.get(e,t),d.init(),Ie(e,t,0,m.sortObjects),d.finish(),m.sortObjects===!0&&d.sort(k,A),F===!0&&ve.beginShadows();let i=f.state.shadowsArray;De.render(i,e,t),f.setupLights(),f.setupLightsView(t),F===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset(),n!==void 0&&this.setRenderTarget(n),ye.render(d,e,t,r);let a=d.opaque,o=d.transparent;a.length>0&&Le(a,e,t),o.length>0&&Le(o,e,t),e.isScene===!0&&e.onAfterRender(m,e,t),y!==null&&(le.updateRenderTargetMipmap(y),le.updateMultisampleRenderTarget(y)),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1),p.pop(),f=p.length>0?p[p.length-1]:null,d=null};function Ie(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)f.pushLight(e),e.castShadow&&f.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||P.intersectsSprite(e)){r&&L.setFromMatrixPosition(e.matrixWorld).applyMatrix4(I);let t=pe.update(e),i=e.material;i.visible&&d.push(e,t,i,n,L.z,null)}}else if(e.isImmediateRenderObject)r&&L.setFromMatrixPosition(e.matrixWorld).applyMatrix4(I),d.push(e,null,e.material,n,L.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==se.render.frame&&(e.skeleton.update(),e.skeleton.frame=se.render.frame),!e.frustumCulled||P.intersectsObject(e))){r&&L.setFromMatrixPosition(e.matrixWorld).applyMatrix4(I);let t=pe.update(e),i=e.material;if(Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&d.push(e,t,s,n,L.z,o)}}else i.visible&&d.push(e,t,i,n,L.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Ie(i[e],t,n,r)}function Le(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=a.object,s=a.geometry,c=r===null?a.material:r,l=a.group;if(n.isArrayCamera){let e=n.cameras;for(let n=0,r=e.length;n<r;n++){let r=e[n];o.layers.test(r.layers)&&(oe.viewport(C.copy(r.viewport)),f.setupLightsView(r),Re(o,t,r,s,c,l))}}else Re(o,t,n,s,c,l)}}function Re(e,t,n,r,i,a){if(e.onBeforeRender(m,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject){let r=Be(n,t,i,e);oe.setMaterial(i),we.reset(),Ne(e,r)}else m.renderBufferDirect(n,t,r,i,e,a);e.onAfterRender(m,t,n,r,i,a)}function ze(e,t,n){t.isScene!==!0&&(t=te);let r=ce.get(e),i=f.state.lights,a=f.state.shadowsArray,o=i.state.version,s=me.getParameters(e,i.state,a,t,n),c=me.getProgramCacheKey(s),l=r.program,u=!0;if(l===void 0)e.addEventListener(`dispose`,Ae);else if(l.cacheKey!==c)Me(e);else if(r.lightsStateVersion!==o)u=!1;else if(s.shaderID!==void 0){let n=e.isMeshStandardMaterial?t.environment:null;r.envMap=ue.get(e.envMap||n);return}else u=!1;u&&(s.uniforms=me.getUniforms(e),e.onBeforeCompile(s,m),l=me.acquireProgram(s,c),r.program=l,r.uniforms=s.uniforms,r.outputEncoding=s.outputEncoding);let d=r.uniforms;(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(r.numClippingPlanes=ve.numPlanes,r.numIntersection=ve.numIntersection,d.clippingPlanes=ve.uniform),r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=ue.get(e.envMap||r.environment),r.needsLights=He(e),r.lightsStateVersion=o,r.needsLights&&(d.ambientLightColor.value=i.state.ambient,d.lightProbe.value=i.state.probe,d.directionalLights.value=i.state.directional,d.directionalLightShadows.value=i.state.directionalShadow,d.spotLights.value=i.state.spot,d.spotLightShadows.value=i.state.spotShadow,d.rectAreaLights.value=i.state.rectArea,d.ltc_1.value=i.state.rectAreaLTC1,d.ltc_2.value=i.state.rectAreaLTC2,d.pointLights.value=i.state.point,d.pointLightShadows.value=i.state.pointShadow,d.hemisphereLights.value=i.state.hemi,d.directionalShadowMap.value=i.state.directionalShadowMap,d.directionalShadowMatrix.value=i.state.directionalShadowMatrix,d.spotShadowMap.value=i.state.spotShadowMap,d.spotShadowMatrix.value=i.state.spotShadowMatrix,d.pointShadowMap.value=i.state.pointShadowMap,d.pointShadowMatrix.value=i.state.pointShadowMatrix);let p=r.program.getUniforms();r.uniformsList=Pu.seqWithValue(p.seq,d)}function Be(e,t,n,r){t.isScene!==!0&&(t=te),le.resetTextureUnits();let i=t.fog,a=n.isMeshStandardMaterial?t.environment:null,o=y===null?m.outputEncoding:y.texture.encoding,s=ue.get(n.envMap||a),c=ce.get(n),l=f.state.lights;if(F===!0&&(ee===!0||e!==S)){let t=e===S&&n.id===x;ve.setState(n,e,t)}n.version===c.__version?n.fog&&c.fog!==i?ze(n,t,r):c.environment===a?c.needsLights&&c.lightsStateVersion!==l.state.version||c.numClippingPlanes!==void 0&&(c.numClippingPlanes!==ve.numPlanes||c.numIntersection!==ve.numIntersection)?ze(n,t,r):c.outputEncoding===o?c.envMap!==s&&ze(n,t,r):ze(n,t,r):ze(n,t,r):(ze(n,t,r),c.__version=n.version);let u=!1,d=!1,p=!1,h=c.program,g=h.getUniforms(),_=c.uniforms;if(oe.useProgram(h.program)&&(u=!0,d=!0,p=!0),n.id!==x&&(x=n.id,d=!0),u||S!==e){if(g.setValue(R,`projectionMatrix`,e.projectionMatrix),ae.logarithmicDepthBuffer&&g.setValue(R,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),S!==e&&(S=e,d=!0,p=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){let t=g.map.cameraPosition;t!==void 0&&t.setValue(R,L.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&g.setValue(R,`isOrthographic`,e.isOrthographicCamera===!0),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||n.skinning)&&g.setValue(R,`viewMatrix`,e.matrixWorldInverse)}if(n.skinning){g.setOptional(R,r,`bindMatrix`),g.setOptional(R,r,`bindMatrixInverse`);let e=r.skeleton;if(e){let t=e.bones;if(ae.floatVertexTextures){if(e.boneTexture===null){let n=Math.sqrt(t.length*4);n=yh.ceilPowerOfTwo(n),n=Math.max(n,4);let r=new Float32Array(n*n*4);r.set(e.boneMatrices);let i=new kl(r,n,n,Km,Um);e.boneMatrices=r,e.boneTexture=i,e.boneTextureSize=n}g.setValue(R,`boneTexture`,e.boneTexture,le),g.setValue(R,`boneTextureSize`,e.boneTextureSize)}else g.setOptional(R,e,`boneMatrices`)}}return(d||c.receiveShadow!==r.receiveShadow)&&(c.receiveShadow=r.receiveShadow,g.setValue(R,`receiveShadow`,r.receiveShadow)),d&&(g.setValue(R,`toneMappingExposure`,m.toneMappingExposure),c.needsLights&&Ve(_,p),i&&n.fog&&he.refreshFogUniforms(_,i),he.refreshMaterialUniforms(_,n,O,D),Pu.upload(R,c.uniformsList,_,le)),n.isShaderMaterial&&n.uniformsNeedUpdate===!0&&(Pu.upload(R,c.uniformsList,_,le),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&g.setValue(R,`center`,r.center),g.setValue(R,`modelViewMatrix`,r.modelViewMatrix),g.setValue(R,`normalMatrix`,r.normalMatrix),g.setValue(R,`modelMatrix`,r.matrixWorld),h}function Ve(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function He(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.setFramebuffer=function(e){g!==e&&y===null&&R.bindFramebuffer(36160,e),g=e},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return v},this.getRenderList=function(){return d},this.setRenderList=function(e){d=e},this.getRenderTarget=function(){return y},this.setRenderTarget=function(e,t=0,n=0){y=e,_=t,v=n,e&&ce.get(e).__webglFramebuffer===void 0&&le.setupRenderTarget(e);let r=g,i=!1;if(e){let n=ce.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=n[t],i=!0):r=e.isWebGLMultisampleRenderTarget?ce.get(e).__webglMultisampledFramebuffer:n,C.copy(e.viewport),w.copy(e.scissor),T=e.scissorTest}else C.copy(j).multiplyScalar(O).floor(),w.copy(M).multiplyScalar(O).floor(),T=N;if(b!==r&&(R.bindFramebuffer(36160,r),b=r),oe.viewport(C),oe.scissor(w),oe.setScissorTest(T),i){let r=ce.get(e.texture);R.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,n)}},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(!(e&&e.isWebGLRenderTarget)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let s=ce.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(s=s[o]),s){let o=!1;s!==b&&(R.bindFramebuffer(36160,s),o=!0);try{let o=e.texture,s=o.format,c=o.type;if(s!==1023&&Ce.convert(s)!==R.getParameter(35739)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(c!==1009&&Ce.convert(c)!==R.getParameter(35738)&&!(c===1015&&(ae.isWebGL2||ie.get(`OES_texture_float`)||ie.get(`WEBGL_color_buffer_float`)))&&!(c===1016&&(ae.isWebGL2?ie.get(`EXT_color_buffer_float`):ie.get(`EXT_color_buffer_half_float`)))){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}R.checkFramebufferStatus(36160)===36053?t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&R.readPixels(t,n,r,i,Ce.convert(s),Ce.convert(c),a):console.error(`THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.`)}finally{o&&R.bindFramebuffer(36160,b)}}},this.copyFramebufferToTexture=function(e,t,n=0){let r=2**-n,i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r),o=Ce.convert(t.format);le.setTexture2D(t,0),R.copyTexImage2D(3553,n,o,e.x,e.y,i,a,0),oe.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){let i=t.image.width,a=t.image.height,o=Ce.convert(n.format),s=Ce.convert(n.type);le.setTexture2D(n,0),R.pixelStorei(37440,n.flipY),R.pixelStorei(37441,n.premultiplyAlpha),R.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?R.texSubImage2D(3553,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?R.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):R.texSubImage2D(3553,r,e.x,e.y,o,s,t.image),r===0&&n.generateMipmaps&&R.generateMipmap(3553),oe.unbindTexture()},this.initTexture=function(e){le.setTexture2D(e,0),oe.unbindTexture()},this.resetState=function(){oe.reset(),we.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}function Ad(e){kd.call(this,e)}function jd(e,t){this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=hh,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=yh.generateUUID()}function Md(e,t,n,r){this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r===!0}function Nd(e){nl.call(this),this.type=`SpriteMaterial`,this.color=new Bg(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}function Pd(e){if(Qc.call(this),this.type=`Sprite`,q_===void 0){q_=new _l;let e=new jd(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);q_.setIndex([0,1,2,0,2,3]),q_.setAttribute(`position`,new Md(e,3,0,!1)),q_.setAttribute(`uv`,new Md(e,2,3,!1))}this.geometry=q_,this.material=e===void 0?new Nd:e,this.center=new K(.5,.5)}function Fd(e,t,n,r,i,a){Z_.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?Q_.copy(Z_):(Q_.x=a*Z_.x-i*Z_.y,Q_.y=i*Z_.x+a*Z_.y),e.copy(t),e.x+=Q_.x,e.y+=Q_.y,e.applyMatrix4($_)}function Id(){Qc.call(this),this._currentLevel=0,this.type=`LOD`,Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function Ld(e,t){e&&e.isGeometry&&console.error(`THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`),vl.call(this,e,t),this.type=`SkinnedMesh`,this.bindMode=`attached`,this.bindMatrix=new Zh,this.bindMatrixInverse=new Zh}function Rd(){Qc.call(this),this.type=`Bone`}function zd(e=[],t=[]){this.uuid=yh.generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}function Bd(e,t,n){vl.call(this,e,t),this.instanceMatrix=new il(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}function Vd(e){nl.call(this),this.type=`LineBasicMaterial`,this.color=new Bg(16777215),this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.morphTargets=!1,this.setValues(e)}function Hd(e=new _l,t=new Vd){Qc.call(this),this.type=`Line`,this.geometry=e,this.material=t,this.updateMorphTargets()}function Ud(e,t){Hd.call(this,e,t),this.type=`LineSegments`}function Wd(e,t){Hd.call(this,e,t),this.type=`LineLoop`}function Gd(e){nl.call(this),this.type=`PointsMaterial`,this.color=new Bg(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}function Kd(e=new _l,t=new Gd){Qc.call(this),this.type=`Points`,this.geometry=e,this.material=t,this.updateMorphTargets()}function qd(e,t,n,r,i,a,o){let s=Dv.distanceSqToPoint(e);if(s<n){let n=new q;Dv.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:o})}}function Jd(e,t,n,r,i,a,o,s,c){qc.call(this,e,t,n,r,i,a,o,s,c),this.format=o===void 0?Gm:o,this.minFilter=a===void 0?zm:a,this.magFilter=i===void 0?zm:i,this.generateMipmaps=!1;let l=this;function u(){l.needsUpdate=!0,e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&e.requestVideoFrameCallback(u)}function Yd(e,t,n,r,i,a,o,s,c,l,u,d){qc.call(this,null,a,o,s,c,l,r,i,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Xd(e,t,n,r,i,a,o,s,c){qc.call(this,e,t,n,r,i,a,o,s,c),this.needsUpdate=!0}function Zd(e,t,n,r,i,a,o,s,c,l){if(l=l===void 0?qm:l,l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);n===void 0&&l===1026&&(n=Hm),n===void 0&&l===1027&&(n=Wm),qc.call(this,null,r,i,a,o,s,l,n,c),this.image={width:e,height:t},this.magFilter=o===void 0?Im:o,this.minFilter=s===void 0?Im:s,this.flipY=!1,this.generateMipmaps=!1}function Qd(){Object.defineProperty(this,"id",{value:Av+=2}),this.uuid=yh.generateUUID(),this.name=``,this.type=`Geometry`,this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function $d(e,t,n,r,i){let a,o;if(i===Af(e,t,n,r)>0)for(a=t;a<n;a+=r)o=Df(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=Df(a,e[a],e[a+1],o);return o&&yf(o,o.next)&&(Of(o),o=o.next),o}function ef(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(yf(n,n.next)||vf(n.prev,n,n.next)===0)){if(Of(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function tf(e,t,n,r,i,a,o){if(!e)return;!o&&a&&ff(e,r,i,a);let s=e,c,l;for(;e.prev!==e.next;){if(c=e.prev,l=e.next,a?rf(e,r,i,a):nf(e)){t.push(c.i/n),t.push(e.i/n),t.push(l.i/n),Of(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=af(ef(e),t,n),tf(e,t,n,r,i,a,2)):o===2&&of(e,t,n,r,i,a):tf(ef(e),t,n,r,i,a,1);break}}}function nf(e){let t=e.prev,n=e,r=e.next;if(vf(t,n,r)>=0)return!1;let i=e.next.next;for(;i!==e.prev;){if(gf(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&vf(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function rf(e,t,n,r){let i=e.prev,a=e,o=e.next;if(vf(i,a,o)>=0)return!1;let s=i.x<a.x?i.x<o.x?i.x:o.x:a.x<o.x?a.x:o.x,c=i.y<a.y?i.y<o.y?i.y:o.y:a.y<o.y?a.y:o.y,l=i.x>a.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,d=mf(s,c,t,n,r),f=mf(l,u,t,n,r),p=e.prevZ,m=e.nextZ;for(;p&&p.z>=d&&m&&m.z<=f;){if(p!==e.prev&&p!==e.next&&gf(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&vf(p.prev,p,p.next)>=0||(p=p.prevZ,m!==e.prev&&m!==e.next&&gf(i.x,i.y,a.x,a.y,o.x,o.y,m.x,m.y)&&vf(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&gf(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&vf(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=f;){if(m!==e.prev&&m!==e.next&&gf(i.x,i.y,a.x,a.y,o.x,o.y,m.x,m.y)&&vf(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function af(e,t,n){let r=e;do{let i=r.prev,a=r.next.next;!yf(i,a)&&bf(i,r,r.next,a)&&wf(i,a)&&wf(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),Of(r),Of(r.next),r=e=a),r=r.next}while(r!==e);return ef(r)}function of(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&_f(o,e)){let s=Ef(o,e);o=ef(o,o.next),s=ef(s,s.next),tf(o,t,n,r,i,a),tf(s,t,n,r,i,a);return}e=e.next}o=o.next}while(o!==e)}function sf(e,t,n,r){let i=[],a,o,s,c,l;for(a=0,o=t.length;a<o;a++)s=t[a]*r,c=a<o-1?t[a+1]*r:e.length,l=$d(e,s,c,r,!1),l===l.next&&(l.steiner=!0),i.push(hf(l));for(i.sort(cf),a=0;a<i.length;a++)lf(i[a],n),n=ef(n,n.next);return n}function cf(e,t){return e.x-t.x}function lf(e,t){if(t=uf(e,t),t){let n=Ef(t,e);ef(t,t.next),ef(n,n.next)}}function uf(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a){if(a=e,e===r){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!o)return null;if(r===a)return o;let s=o,c=o.x,l=o.y,u=1/0,d;n=o;do r>=n.x&&n.x>=c&&r!==n.x&&gf(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)&&(d=Math.abs(i-n.y)/(r-n.x),wf(n,e)&&(d<u||d===u&&(n.x>o.x||n.x===o.x&&df(o,n)))&&(o=n,u=d)),n=n.next;while(n!==s);return o}function df(e,t){return vf(e.prev,e,t.prev)<0&&vf(t.next,e,e.next)<0}function ff(e,t,n,r){let i=e;do i.z===null&&(i.z=mf(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,pf(i)}function pf(e){let t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ,r);t++);for(c=l;s>0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function mf(e,t,n,r,i){return e=32767*(e-n)*i,t=32767*(t-r)*i,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function hf(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function gf(e,t,n,r,i,a,o,s){return(i-o)*(t-s)-(e-o)*(a-s)>=0&&(e-o)*(r-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function _f(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Cf(e,t)&&(wf(e,t)&&wf(t,e)&&Tf(e,t)&&(vf(e.prev,e,t.prev)||vf(e,t.prev,t))||yf(e,t)&&vf(e.prev,e,e.next)>0&&vf(t.prev,t,t.next)>0)}function vf(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function yf(e,t){return e.x===t.x&&e.y===t.y}function bf(e,t,n,r){let i=Sf(vf(e,t,n)),a=Sf(vf(e,t,r)),o=Sf(vf(n,r,e)),s=Sf(vf(n,r,t));return!!(i!==a&&o!==s||i===0&&xf(e,n,t)||a===0&&xf(e,r,t)||o===0&&xf(n,e,r)||s===0&&xf(n,t,r))}function xf(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Sf(e){return e>0?1:e<0?-1:0}function Cf(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&bf(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function wf(e,t){return vf(e.prev,e,e.next)<0?vf(e,t,e.next)>=0&&vf(e,e.prev,t)>=0:vf(e,t,e.prev)<0||vf(e,e.next,t)<0}function Tf(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Ef(e,t){let n=new kf(e.i,e.x,e.y),r=new kf(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Df(e,t,n,r){let i=new kf(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Of(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 kf(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Af(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function jf(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Mf(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}function Nf(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);return t.extrudePath!==void 0&&(n.options.extrudePath=t.extrudePath.toJSON()),n}function Pf(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);return t.extrudePath!==void 0&&(n.options.extrudePath=t.extrudePath.toJSON()),n}function Ff(e,t,n){_l.call(this),this.type=`ParametricBufferGeometry`,this.parameters={func:e,slices:t,stacks:n};let r=[],i=[],a=[],o=[],s=1e-5,c=new q,l=new q,u=new q,d=new q,f=new q;e.length<3&&console.error(`THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.`);let p=t+1;for(let r=0;r<=n;r++){let p=r/n;for(let n=0;n<=t;n++){let r=n/t;e(r,p,l),i.push(l.x,l.y,l.z),r-s>=0?(e(r-s,p,u),d.subVectors(l,u)):(e(r+s,p,u),d.subVectors(u,l)),p-s>=0?(e(r,p-s,u),f.subVectors(l,u)):(e(r,p+s,u),f.subVectors(u,l)),c.crossVectors(d,f).normalize(),a.push(c.x,c.y,c.z),o.push(r,p)}}for(let e=0;e<n;e++)for(let n=0;n<t;n++){let t=e*p+n,i=e*p+n+1,a=(e+1)*p+n+1,o=(e+1)*p+n;r.push(t,i,o),r.push(i,a,o)}this.setIndex(r),this.setAttribute(`position`,new pl(i,3)),this.setAttribute(`normal`,new pl(a,3)),this.setAttribute(`uv`,new pl(o,2))}function If(e,t,n){Qd.call(this),this.type=`ParametricGeometry`,this.parameters={func:e,slices:t,stacks:n},this.fromBufferGeometry(new Ff(e,t,n)),this.mergeVertices()}function Lf(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}function Rf(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}function zf(e){nl.call(this),this.type=`ShadowMaterial`,this.color=new Bg(0),this.transparent=!0,this.setValues(e)}function Bf(e){Cl.call(this,e),this.type=`RawShaderMaterial`}function Vf(e){nl.call(this),this.defines={STANDARD:``},this.type=`MeshStandardMaterial`,this.color=new Bg(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 Bg(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(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.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(e)}function Hf(e){Vf.call(this),this.defines={STANDARD:``,PHYSICAL:``},this.type=`MeshPhysicalMaterial`,this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new K(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(e){this.reflectivity=yh.clamp(2.5*(e-1)/(e+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(e)}function Uf(e){nl.call(this),this.type=`MeshPhongMaterial`,this.color=new Bg(16777215),this.specular=new Bg(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bg(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(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.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Wf(e){nl.call(this),this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new Bg(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bg(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(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.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Gf(e){nl.call(this),this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Kf(e){nl.call(this),this.type=`MeshLambertMaterial`,this.color=new Bg(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bg(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.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function qf(e){nl.call(this),this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new Bg(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Jf(e){Vd.call(this),this.type=`LineDashedMaterial`,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function Yf(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n}function Xf(e,t,n,r){Yf.call(this,e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Zf(e,t,n,r){Yf.call(this,e,t,n,r)}function Qf(e,t,n,r){Yf.call(this,e,t,n,r)}function $f(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=Hv.convertArray(t,this.TimeBufferType),this.values=Hv.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}function ep(e,t,n){$f.call(this,e,t,n)}function tp(e,t,n,r){$f.call(this,e,t,n,r)}function np(e,t,n,r){$f.call(this,e,t,n,r)}function rp(e,t,n,r){Yf.call(this,e,t,n,r)}function ip(e,t,n,r){$f.call(this,e,t,n,r)}function ap(e,t,n,r){$f.call(this,e,t,n,r)}function op(e,t,n,r){$f.call(this,e,t,n,r)}function sp(e,t=-1,n,r=nh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=yh.generateUUID(),this.duration<0&&this.resetDuration()}function cp(e){switch(e.toLowerCase()){case`scalar`:case`double`:case`float`:case`number`:case`integer`:return np;case`vector`:case`vector2`:case`vector3`:case`vector4`:return op;case`color`:return tp;case`quaternion`:return ip;case`bool`:case`boolean`:return ep;case`string`:return ap}throw Error(`THREE.KeyframeTrack: Unsupported typeName: `+e)}function lp(e){if(e.type===void 0)throw Error(`THREE.KeyframeTrack: track type undefined, can not parse`);let t=cp(e.type);if(e.times===void 0){let t=[],n=[];Hv.flattenJSON(e.keys,t,n,`value`),e.times=t,e.values=n}return t.parse===void 0?new t(e.name,e.times,e.values,e.interpolation):t.parse(e)}function up(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}function dp(e){this.manager=e===void 0?Wv:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}function fp(e){dp.call(this,e)}function pp(e){dp.call(this,e)}function mp(e){dp.call(this,e)}function hp(e){dp.call(this,e)}function gp(e){dp.call(this,e)}function _p(e){dp.call(this,e)}function vp(e){dp.call(this,e)}function yp(){this.type=`Curve`,this.arcLengthDivisions=200}function bp(e,t,n,r,i,a,o,s){yp.call(this),this.type=`EllipseCurve`,this.aX=e||0,this.aY=t||0,this.xRadius=n||1,this.yRadius=r||1,this.aStartAngle=i||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function xp(e,t,n,r,i,a){bp.call(this,e,t,n,n,r,i,a),this.type=`ArcCurve`}function Sp(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}function Cp(e=[],t=!1,n=`centripetal`,r=.5){yp.call(this),this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}function wp(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Tp(e,t){let n=1-e;return n*n*t}function Ep(e,t){return 2*(1-e)*e*t}function Dp(e,t){return e*e*t}function Op(e,t,n,r){return Tp(e,t)+Ep(e,n)+Dp(e,r)}function kp(e,t){let n=1-e;return n*n*n*t}function Ap(e,t){let n=1-e;return 3*n*n*e*t}function jp(e,t){return 3*(1-e)*e*e*t}function Mp(e,t){return e*e*e*t}function Np(e,t,n,r,i){return kp(e,t)+Ap(e,n)+jp(e,r)+Mp(e,i)}function Pp(e=new K,t=new K,n=new K,r=new K){yp.call(this),this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}function Fp(e=new q,t=new q,n=new q,r=new q){yp.call(this),this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}function Ip(e=new K,t=new K){yp.call(this),this.type=`LineCurve`,this.v1=e,this.v2=t}function Lp(e=new q,t=new q){yp.call(this),this.type=`LineCurve3`,this.v1=e,this.v2=t}function Rp(e=new K,t=new K,n=new K){yp.call(this),this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}function zp(e=new q,t=new q,n=new q){yp.call(this),this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}function Bp(e=[]){yp.call(this),this.type=`SplineCurve`,this.points=e}function Vp(){yp.call(this),this.type=`CurvePath`,this.curves=[],this.autoClose=!1}function Hp(e){Vp.call(this),this.type=`Path`,this.currentPoint=new K,e&&this.setFromPoints(e)}function Up(e){Hp.call(this,e),this.uuid=yh.generateUUID(),this.type=`Shape`,this.holes=[]}function Wp(e,t=1){Qc.call(this),this.type=`Light`,this.color=new Bg(e),this.intensity=t}function Gp(e,t,n){Wp.call(this,e,n),this.type=`HemisphereLight`,this.position.copy(Qc.DefaultUp),this.updateMatrix(),this.groundColor=new Bg(t)}function Kp(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new K(512,512),this.map=null,this.mapPass=null,this.matrix=new Zh,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new w_,this._frameExtents=new K(1,1),this._viewportCount=1,this._viewports=[new wh(0,0,1,1)]}function qp(){Kp.call(this,new Tl(50,1,.5,500)),this.focus=1}function Jp(e,t,n,r,i,a){Wp.call(this,e,t),this.type=`SpotLight`,this.position.copy(Qc.DefaultUp),this.updateMatrix(),this.target=new Qc,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=n===void 0?0:n,this.angle=r===void 0?Math.PI/3:r,this.penumbra=i===void 0?0:i,this.decay=a===void 0?1:a,this.shadow=new qp}function Yp(){Kp.call(this,new Tl(90,1,.5,500)),this._frameExtents=new K(4,2),this._viewportCount=6,this._viewports=[new wh(2,1,1,1),new wh(0,1,1,1),new wh(3,1,1,1),new wh(1,1,1,1),new wh(3,0,1,1),new wh(1,0,1,1)],this._cubeDirections=[new q(1,0,0),new q(-1,0,0),new q(0,0,1),new q(0,0,-1),new q(0,1,0),new q(0,-1,0)],this._cubeUps=[new q(0,1,0),new q(0,1,0),new q(0,1,0),new q(0,1,0),new q(0,0,1),new q(0,0,-1)]}function Xp(e,t,n,r){Wp.call(this,e,t),this.type=`PointLight`,Object.defineProperty(this,"power",{get:function(){return this.intensity*4*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=n===void 0?0:n,this.decay=r===void 0?1:r,this.shadow=new Yp}function Zp(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){wl.call(this),this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}function Qp(){Kp.call(this,new Zp(-5,5,5,-5,.5,500))}function $p(e,t){Wp.call(this,e,t),this.type=`DirectionalLight`,this.position.copy(Qc.DefaultUp),this.updateMatrix(),this.target=new Qc,this.shadow=new Qp}function em(e,t){Wp.call(this,e,t),this.type=`AmbientLight`}function tm(e,t,n,r){Wp.call(this,e,t),this.type=`RectAreaLight`,this.width=n===void 0?10:n,this.height=r===void 0?10:r}function nm(e,t){Wp.call(this,void 0,t),this.type=`LightProbe`,this.sh=e===void 0?new Zv:e}function rm(e){dp.call(this,e),this.textures={}}function im(){_l.call(this),this.type=`InstancedBufferGeometry`,this.instanceCount=1/0}function am(e,t,n,r){typeof n==`number`&&(r=n,n=!1,console.error(`THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.`)),il.call(this,e,t,n),this.meshPerAttribute=r||1}function om(e){dp.call(this,e)}function sm(e){typeof createImageBitmap>`u`&&console.warn(`THREE.ImageBitmapLoader: createImageBitmap() not supported.`),typeof fetch>`u`&&console.warn(`THREE.ImageBitmapLoader: fetch() not supported.`),dp.call(this,e),this.options={premultiplyAlpha:`none`}}function cm(){this.type=`ShapePath`,this.color=new Bg,this.subPaths=[],this.currentPath=null}function lm(e){this.type=`Font`,this.data=e}function um(e,t,n){let r=Array.from?Array.from(e):String(e).split(``),i=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,o=[],s=0,c=0;for(let e=0;e<r.length;e++){let t=r[e];if(t===`
|
||
`)s=0,c-=a;else{let e=dm(t,i,s,c,n);s+=e.offsetX,o.push(e.path)}}return o}function dm(e,t,n,r,i){let a=i.glyphs[e]||i.glyphs[`?`];if(!a){console.error(`THREE.Font: character "`+e+`" does not exists in font family `+i.familyName+`.`);return}let o=new cm,s,c,l,u,d,f,p,m;if(a.o){let e=a._cachedOutline||=a.o.split(` `);for(let i=0,a=e.length;i<a;)switch(e[i++]){case`m`:s=e[i++]*t+n,c=e[i++]*t+r,o.moveTo(s,c);break;case`l`:s=e[i++]*t+n,c=e[i++]*t+r,o.lineTo(s,c);break;case`q`:l=e[i++]*t+n,u=e[i++]*t+r,d=e[i++]*t+n,f=e[i++]*t+r,o.quadraticCurveTo(d,f,l,u);break;case`b`:l=e[i++]*t+n,u=e[i++]*t+r,d=e[i++]*t+n,f=e[i++]*t+r,p=e[i++]*t+n,m=e[i++]*t+r,o.bezierCurveTo(d,f,p,m,l,u);break}}return{offsetX:a.ha*t,path:o}}function fm(e){dp.call(this,e)}function pm(e){dp.call(this,e)}function mm(e,t,n){nm.call(this,void 0,n);let r=new Bg().set(e),i=new Bg().set(t),a=new q(r.r,r.g,r.b),o=new q(i.r,i.g,i.b),s=Math.sqrt(Math.PI),c=s*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(s),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(c)}function hm(e,t){nm.call(this,void 0,t);let n=new Bg().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}function gm(){this.type=`StereoCamera`,this.aspect=1,this.eyeSep=.064,this.cameraL=new Tl,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Tl,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}}function _m(e,t,n){this.binding=e,this.valueSize=n;let r,i,a;switch(t){case`quaternion`:r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case`string`:case`bool`:r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}function vm(e,t,n){let r=n||ym.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}function ym(e,t,n){this.path=t,this.parsedPath=n||ym.parseTrackName(t),this.node=ym.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function bm(){this.uuid=yh.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}function xm(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Sm(e,t,n){jd.call(this,e,t),this.meshPerAttribute=n||1}function Cm(e,t,n,r,i){this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,this.version=0}function wm(e,t,n,r){this.ray=new Xh(e,t),this.near=n||0,this.far=r||1/0,this.camera=null,this.layers=new cg,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn(`THREE.Raycaster: params.PointCloud has been renamed to params.Points.`),this.Points}}})}function Tm(e,t){return e.distance-t.distance}function Em(e,t,n,r){if(e.layers.test(t.layers)&&e.raycast(t,n),r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)Em(r[e],t,n,!0)}}function Dm(e){Qc.call(this),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}function Om(e){let t=[];e&&e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,Om(e.children[n]));return t}function km(){let e=[],t=[],n=[],r=ky;for(let i=0;i<jy;i++){let a=2**r;t.push(a);let o=1/a;i>ky-Oy?o=Ay[i-ky+Oy-1]:i==0&&(o=0),n.push(o);let s=1/(a-1),c=-s/2,l=1+s/2,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=new Float32Array(108),f=new Float32Array(72),p=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];d.set(r,18*e),f.set(u,12*e);let i=[e,e,e,e,e,e];p.set(i,6*e)}let m=new _l;m.setAttribute(`position`,new il(d,3)),m.setAttribute(`uv`,new il(f,2)),m.setAttribute(`faceIndex`,new il(p,1)),e.push(m),r>Oy&&r--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}function Am(e){console.warn(`THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.`),Cp.call(this,e),this.type=`catmullrom`,this.closed=!0}function jm(e){console.warn(`THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.`),Cp.call(this,e),this.type=`catmullrom`}function Mm(e){console.warn(`THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.`),Cp.call(this,e),this.type=`catmullrom`}var Nm,Pm,Fm,Im,Lm,Rm,zm,Bm,Vm,G,Hm,Um,Wm,Gm,Km,qm,Jm,Ym,Xm,Zm,Qm,$m,eh,th,nh,rh,ih,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,K,bh,xh,Sh,Ch,wh,Th,q,Eh,Dh,Oh,kh,J,Ah,jh,Mh,Nh,Ph,Fh,Ih,Lh,Rh,zh,Bh,Vh,Hh,Uh,Wh,Gh,Kh,qh,Jh,Yh,Xh,Zh,Qh,$h,eg,tg,ng,rg,ig,ag,og,sg,cg,lg,ug,dg,fg,pg,mg,hg,gg,_g,vg,yg,bg,xg,Sg,Cg,wg,Tg,Eg,Dg,Og,kg,Ag,jg,Mg,Ng,Pg,Fg,Ig,Lg,Rg,zg,Bg,Vg,Hg,Ug,Wg,Gg,Kg,qg,Jg,Yg,Xg,Zg,Qg,$g,e_,t_,n_,r_,i_,a_,o_,s_,c_,l_,u_,d_,Y,f_,p_,m_,h_,g_,__,v_,y_,b_,x_,S_,C_,w_,T_,E_,X,D_,O_,k_,A_,j_,M_,N_,P_,F_,I_,L_,R_,z_,B_,V_,H_,U_,W_,G_,K_,q_,J_,Y_,X_,Z_,Q_,$_,ev,tv,nv,rv,iv,av,ov,sv,cv,lv,uv,dv,fv,pv,mv,hv,gv,_v,vv,yv,bv,xv,Sv,Cv,wv,Tv,Ev,Dv,Ov,kv,Av,jv,Mv,Nv,Pv,Fv,Iv,Lv,Rv,zv,Bv,Vv,Hv,Uv,Wv,Gv,Kv,qv,Jv,Yv,Xv,Zv,Qv,$v,ey,ty,ny,ry,iy,ay,oy,sy,cy,ly,uy,dy,fy,py,my,hy,gy,_y,vy,yy,by,xy,Sy,Cy,wy,Ty,Ey,Dy,Oy,ky,Ay,jy,eee,My,Ny,Py,Fy,Iy=o((()=>{Nm=1e3,Pm=1001,Fm=1002,Im=1003,Lm=1004,Rm=1005,zm=1006,Bm=1007,Vm=1008,G=1009,Hm=1012,Um=1015,Wm=1020,Gm=1022,Km=1023,qm=1026,Jm=2201,Ym=2202,Xm=2300,Zm=2301,Qm=2302,$m=2400,eh=2401,th=2402,nh=2500,rh=2501,ih=3e3,ah=3001,oh=3007,sh=3002,ch=3003,lh=3004,uh=3005,dh=3006,fh=3200,ph=3201,mh=7680,hh=35044,gh=35048,Object.assign(Kc.prototype,{addEventListener:function(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)},hasEventListener:function(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(this._listeners===void 0)return;let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}},dispatchEvent:function(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e)}}}),_h=[];for(let e=0;e<256;e++)_h[e]=(e<16?`0`:``)+e.toString(16);vh=1234567,yh={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(_h[e&255]+_h[e>>8&255]+_h[e>>16&255]+_h[e>>24&255]+`-`+_h[t&255]+_h[t>>8&255]+`-`+_h[t>>16&15|64]+_h[t>>24&255]+`-`+_h[n&63|128]+_h[n>>8&255]+`-`+_h[n>>16&255]+_h[n>>24&255]+_h[r&255]+_h[r>>8&255]+_h[r>>16&255]+_h[r>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-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 e!==void 0&&(vh=e%2147483647),vh=vh*16807%2147483647,(vh-1)/2147483646},degToRad:function(e){return e*yh.DEG2RAD},radToDeg:function(e){return e*yh.RAD2DEG},isPowerOfTwo:function(e){return(e&e-1)==0&&e!==0},ceilPowerOfTwo:function(e){return 2**Math.ceil(Math.log(e)/Math.LN2)},floorPowerOfTwo:function(e){return 2**Math.floor(Math.log(e)/Math.LN2)},setQuaternionFromProperEuler:function(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}},K=class{constructor(e=0,t=0){Object.defineProperty(this,"isVector2",{value:!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 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 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 t===void 0?(this.x+=e.x,this.y+=e.y,this):(console.warn(`THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.`),this.addVectors(e,t))}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 t===void 0?(this.x-=e.x,this.y-=e.y,this):(console.warn(`THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.`),this.subVectors(e,t))}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){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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,n){return n!==void 0&&console.warn(`THREE.Vector2: offset has been removed from .fromBufferAttribute().`),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}},bh=class{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),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,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return new this.constructor().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let 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){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,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).copy(this).invert().transpose()}transposeIntoArray(e){let 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,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.elements,i=r[0],a=r[3],o=r[6],s=r[1],c=r[4],l=r[7];return r[0]=t*i+n*s,r[3]=t*a+n*c,r[6]=t*o+n*l,r[1]=-n*i+t*s,r[4]=-n*a+t*c,r[7]=-n*o+t*l,this}translate(e,t){let n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}},Sh={getDataURL:function(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{xh===void 0&&(xh=document.createElementNS(`http://www.w3.org/1999/xhtml`,`canvas`)),xh.width=e.width,xh.height=e.height;let n=xh.getContext(`2d`);e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=xh}return t.width>2048||t.height>2048?t.toDataURL(`image/jpeg`,.6):t.toDataURL(`image/png`)}},Ch=0,qc.DEFAULT_IMAGE=void 0,qc.DEFAULT_MAPPING=300,qc.prototype=Object.assign(Object.create(Kc.prototype),{constructor:qc,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(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:function(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={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(this.image!==void 0){let r=this.image;if(r.uuid===void 0&&(r.uuid=yh.generateUUID()),!t&&e.images[r.uuid]===void 0){let t;if(Array.isArray(r)){t=[];for(let e=0,n=r.length;e<n;e++)r[e].isDataTexture?t.push(Jc(r[e].image)):t.push(Jc(r[e]))}else t=Jc(r);e.images[r.uuid]={uuid:r.uuid,url:t}}n.image=r.uuid}return t||(e.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:`dispose`})},transformUv:function(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Nm:e.x-=Math.floor(e.x);break;case Pm:e.x=e.x<0?0:1;break;case Fm:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Nm:e.y-=Math.floor(e.y);break;case Pm:e.y=e.y<0?0:1;break;case Fm:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(qc.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),wh=class{constructor(e=0,t=0,n=0,r=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=e,this.y=t,this.z=n,this.w=r}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,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,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 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 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=e.w===void 0?1:e.w,this}add(e,t){return t===void 0?(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this):(console.warn(`THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.`),this.addVectors(e,t))}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 t===void 0?(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this):(console.warn(`THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.`),this.subVectors(e,t))}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}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let 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,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-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){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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,n){return n!==void 0&&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}},Yc.prototype=Object.assign(Object.create(Kc.prototype),{constructor:Yc,isWebGLRenderTarget:!0,setSize:function(e,t){(this.width!==e||this.height!==t)&&(this.width=e,this.height=t,this.texture.image.width=e,this.texture.image.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:`dispose`})}}),Xc.prototype=Object.assign(Object.create(Yc.prototype),{constructor:Xc,isWebGLMultisampleRenderTarget:!0,copy:function(e){return Yc.prototype.copy.call(this,e),this.samples=e.samples,this}}),Th=class{constructor(e=0,t=0,n=0,r=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=e,this._y=t,this._z=n,this._w=r}static slerp(e,t,n,r){return n.copy(e).slerp(t,r)}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,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,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,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 Error(`THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.`);let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-6?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yh.clamp(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),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 e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e,t){return t===void 0?this.multiplyQuaternions(this,e):(console.warn(`THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.`),this.multiplyQuaternions(e,t))}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),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._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(){}},q=class{constructor(e=0,t=0,n=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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 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 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 t===void 0?(this.x+=e.x,this.y+=e.y,this.z+=e.z,this):(console.warn(`THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.`),this.addVectors(e,t))}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 t===void 0?(this.x-=e.x,this.y-=e.y,this.z-=e.z,this):(console.warn(`THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.`),this.subVectors(e,t))}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 t===void 0?(this.x*=e.x,this.y*=e.y,this.z*=e.z,this):(console.warn(`THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.`),this.multiplyVectors(e,t))}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(Dh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Dh.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*r-o*n,l=s*n+o*t-i*r,u=s*r+i*n-a*t,d=-i*t-a*n-o*r;return this.x=c*s+d*-i+l*-o-u*-a,this.y=l*s+d*-a+u*-i-c*-o,this.z=u*s+d*-o+c*-a-l*-i,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,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){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t===void 0?this.crossVectors(this,e):(console.warn(`THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.`),this.crossVectors(e,t))}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Eh.copy(this).projectOnVector(e),this.sub(Eh)}reflect(e){return this.sub(Eh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(yh.clamp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}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,n){return n!==void 0&&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}},Eh=new q,Dh=new Th,Oh=class{constructor(e,t){Object.defineProperty(this,"isBox3",{value:!0}),this.min=e===void 0?new q(1/0,1/0,1/0):e,this.max=t===void 0?new q(-1/0,-1/0,-1/0):t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,c=e.length;s<c;s+=3){let c=e[s],l=e[s+1],u=e[s+2];c<t&&(t=c),l<n&&(n=l),u<r&&(r=u),c>i&&(i=c),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,n,r),this.max.set(i,a,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,c=e.count;s<c;s++){let c=e.getX(s),l=e.getY(s),u=e.getZ(s);c<t&&(t=c),l<n&&(n=l),u<r&&(r=u),c>i&&(i=c),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,n,r),this.max.set(i,a,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=J.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 e===void 0&&(console.warn(`THREE.Box3: .getCenter() target is now required`),e=new q),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return e===void 0&&(console.warn(`THREE.Box3: .getSize() target is now required`),e=new q),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);let t=e.geometry;t!==void 0&&(t.boundingBox===null&&t.computeBoundingBox(),Ah.copy(t.boundingBox),Ah.applyMatrix4(e.matrixWorld),this.union(Ah));let n=e.children;for(let e=0,t=n.length;e<t;e++)this.expandByObject(n[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===void 0&&(console.warn(`THREE.Box3: .getParameter() target is now required`),t=new q),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,J),J.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Lh),Rh.subVectors(this.max,Lh),jh.subVectors(e.a,Lh),Mh.subVectors(e.b,Lh),Nh.subVectors(e.c,Lh),Ph.subVectors(Mh,jh),Fh.subVectors(Nh,Mh),Ih.subVectors(jh,Nh);let t=[0,-Ph.z,Ph.y,0,-Fh.z,Fh.y,0,-Ih.z,Ih.y,Ph.z,0,-Ph.x,Fh.z,0,-Fh.x,Ih.z,0,-Ih.x,-Ph.y,Ph.x,0,-Fh.y,Fh.x,0,-Ih.y,Ih.x,0];return!Zc(t,jh,Mh,Nh,Rh)||(t=[1,0,0,0,1,0,0,0,1],!Zc(t,jh,Mh,Nh,Rh))?!1:(zh.crossVectors(Ph,Fh),t=[zh.x,zh.y,zh.z],Zc(t,jh,Mh,Nh,Rh))}clampPoint(e,t){return t===void 0&&(console.warn(`THREE.Box3: .clampPoint() target is now required`),t=new q),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return J.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return e===void 0&&console.error(`THREE.Box3: .getBoundingSphere() target is now required`),this.getCenter(e.center),e.radius=this.getSize(J).length()*.5,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()?this:(kh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kh),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)}},kh=[new q,new q,new q,new q,new q,new q,new q,new q],J=new q,Ah=new Oh,jh=new q,Mh=new q,Nh=new q,Ph=new q,Fh=new q,Ih=new q,Lh=new q,Rh=new q,zh=new q,Bh=new q,Vh=new Oh,Hh=class{constructor(e,t){this.center=e===void 0?new q:e,this.radius=t===void 0?-1:t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Vh.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}clone(){return new this.constructor().copy(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){let 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){let n=this.center.distanceToSquared(e);return t===void 0&&(console.warn(`THREE.Sphere: .clampPoint() target is now required`),t=new q),t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return e===void 0&&(console.warn(`THREE.Sphere: .getBoundingBox() target is now required`),e=new Oh),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*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}},Uh=new q,Wh=new q,Gh=new q,Kh=new q,qh=new q,Jh=new q,Yh=new q,Xh=class{constructor(e,t){this.origin=e===void 0?new q:e,this.direction=t===void 0?new q(0,0,-1):t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}clone(){return new this.constructor().copy(this)}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t===void 0&&(console.warn(`THREE.Ray: .at() target is now required`),t=new q),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,Uh)),this}closestPointToPoint(e,t){t===void 0&&(console.warn(`THREE.Ray: .closestPointToPoint() target is now required`),t=new q),t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Uh.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Uh.copy(this.direction).multiplyScalar(t).add(this.origin),Uh.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Wh.copy(e).add(t).multiplyScalar(.5),Gh.copy(t).sub(e).normalize(),Kh.copy(this.origin).sub(Wh);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Gh),o=Kh.dot(this.direction),s=-Kh.dot(Gh),c=Kh.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(Gh).multiplyScalar(d).add(Wh),f}intersectSphere(e,t){Uh.subVectors(e.center,this.origin);let n=Uh.dot(this.direction),r=Uh.dot(Uh)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||n!==n)&&(n=i),(a<r||r!==r)&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Uh)!==null}intersectTriangle(e,t,n,r,i){qh.subVectors(t,e),Jh.subVectors(n,e),Yh.crossVectors(qh,Jh);let a=this.direction.dot(Yh),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Kh.subVectors(this.origin,e);let s=o*this.direction.dot(Jh.crossVectors(Kh,Jh));if(s<0)return null;let c=o*this.direction.dot(qh.cross(Kh));if(c<0||s+c>a)return null;let l=-o*Kh.dot(Yh);return l<0?null:this.at(l/a,i)}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)}},Zh=class e{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),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,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,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 e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/Qh.setFromMatrixColumn(e,0).length(),i=1/Qh.setFromMatrixColumn(e,1).length(),a=1/Qh.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,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.`);let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*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(eg,e,tg)}lookAt(e,t,n){let r=this.elements;return ig.subVectors(e,t),ig.lengthSq()===0&&(ig.z=1),ig.normalize(),ng.crossVectors(n,ig),ng.lengthSq()===0&&(Math.abs(n.z)===1?ig.x+=1e-4:ig.z+=1e-4,ig.normalize(),ng.crossVectors(n,ig)),ng.normalize(),rg.crossVectors(ig,ng),r[0]=ng.x,r[4]=rg.x,r[8]=ig.x,r[1]=ng.y,r[5]=rg.y,r[9]=ig.y,r[2]=ng.z,r[6]=rg.z,r[10]=ig.z,this}multiply(e,t){return t===void 0?this.multiplyMatrices(this,e):(console.warn(`THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.`),this.multiplyMatrices(e,t))}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],ee=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*ee,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*ee,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*ee,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*ee,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,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,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n){return this.set(1,t,n,0,e,1,n,0,e,t,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=Qh.set(r[0],r[1],r[2]).length(),a=Qh.set(r[4],r[5],r[6]).length(),o=Qh.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],$h.copy(this);let s=1/i,c=1/a,l=1/o;return $h.elements[0]*=s,$h.elements[1]*=s,$h.elements[2]*=s,$h.elements[4]*=c,$h.elements[5]*=c,$h.elements[6]*=c,$h.elements[8]*=l,$h.elements[9]*=l,$h.elements[10]*=l,t.setFromRotationMatrix($h),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a){a===void 0&&console.warn(`THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.`);let o=this.elements,s=2*i/(t-e),c=2*i/(n-r),l=(t+e)/(t-e),u=(n+r)/(n-r),d=-(a+i)/(a-i),f=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=f,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,r,i,a){let o=this.elements,s=1/(t-e),c=1/(n-r),l=1/(a-i),u=(t+e)*s,d=(n+r)*c,f=(a+i)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-f,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Qh=new q,$h=new Zh,eg=new q(0,0,0),tg=new q(1,1,1),ng=new q,rg=new q,ig=new q,ag=class e{constructor(t=0,n=0,r=0,i=e.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=n,this._z=r,this._order=i}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,n,r){return this._x=e,this._y=t,this._z=n,this._order=r||this._order,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,n){let r=yh.clamp,i=e.elements,a=i[0],o=i[4],s=i[8],c=i[1],l=i[5],u=i[9],d=i[2],f=i[6],p=i[10];switch(t||=this._order,t){case`XYZ`:this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(f,l),this._z=0);break;case`YXZ`:this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,a),this._z=0);break;case`ZXY`:this._x=Math.asin(r(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,a));break;case`ZYX`:this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,l));break;case`YZX`:this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(s,p));break;case`XZY`:this._z=Math.asin(-r(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n!==!1&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return og.makeRotationFromQuaternion(e),this.setFromRotationMatrix(og,t,n)}setFromVector3(e,t){return this.set(e.x,e.y,e.z,t||this._order)}reorder(e){return sg.setFromEuler(this),this.setFromQuaternion(sg,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],e[3]!==void 0&&(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 q(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}},ag.DefaultOrder=`XYZ`,ag.RotationOrders=[`XYZ`,`YZX`,`ZXY`,`XZY`,`YXZ`,`ZYX`],og=new Zh,sg=new Th,cg=class{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(this.mask&e.mask)!==0}},lg=0,ug=new q,dg=new Th,fg=new Zh,pg=new q,mg=new q,hg=new q,gg=new Th,_g=new q(1,0,0),vg=new q(0,1,0),yg=new q(0,0,1),bg={type:`added`},xg={type:`removed`},Qc.DefaultUp=new q(0,1,0),Qc.DefaultMatrixAutoUpdate=!0,Qc.prototype=Object.assign(Object.create(Kc.prototype),{constructor:Qc,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(e,t){return dg.setFromAxisAngle(e,t),this.quaternion.multiply(dg),this},rotateOnWorldAxis:function(e,t){return dg.setFromAxisAngle(e,t),this.quaternion.premultiply(dg),this},rotateX:function(e){return this.rotateOnAxis(_g,e)},rotateY:function(e){return this.rotateOnAxis(vg,e)},rotateZ:function(e){return this.rotateOnAxis(yg,e)},translateOnAxis:function(e,t){return ug.copy(e).applyQuaternion(this.quaternion),this.position.add(ug.multiplyScalar(t)),this},translateX:function(e){return this.translateOnAxis(_g,e)},translateY:function(e){return this.translateOnAxis(vg,e)},translateZ:function(e){return this.translateOnAxis(yg,e)},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(fg.copy(this.matrixWorld).invert())},lookAt:function(e,t,n){e.isVector3?pg.copy(e):pg.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),mg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?fg.lookAt(mg,pg,this.up):fg.lookAt(pg,mg,this.up),this.quaternion.setFromRotationMatrix(fg),r&&(fg.extractRotation(r.matrixWorld),dg.setFromRotationMatrix(fg),this.quaternion.premultiply(dg.invert()))},add:function(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?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(bg)):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)},remove:function(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(xg)),this},clear:function(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(xg)}return this.children.length=0,this},attach:function(e){return this.updateWorldMatrix(!0,!1),fg.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),fg.multiply(e.parent.matrixWorld)),e.applyMatrix4(fg),e.updateWorldMatrix(!1,!1),this.add(e),this},getObjectById:function(e){return this.getObjectByProperty(`id`,e)},getObjectByName:function(e){return this.getObjectByProperty(`name`,e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}},getWorldPosition:function(e){return e===void 0&&(console.warn(`THREE.Object3D: .getWorldPosition() target is now required`),e=new q),this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(e){return e===void 0&&(console.warn(`THREE.Object3D: .getWorldQuaternion() target is now required`),e=new Th),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mg,e,hg),e},getWorldScale:function(e){return e===void 0&&(console.warn(`THREE.Object3D: .getWorldScale() target is now required`),e=new q),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mg,gg,e),e},getWorldDirection:function(e){e===void 0&&(console.warn(`THREE.Object3D: .getWorldDirection() target is now required`),e=new q),this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)},traverseVisible:function(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)},traverseAncestors:function(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)},updateWorldMatrix:function(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}},toJSON:function(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),JSON.stringify(this.userData)!==`{}`&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON());function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}},clone:function(e){return new this.constructor().copy(this,e)},copy:function(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)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}}),Sg=new q,Cg=new q,wg=new bh,Tg=class{constructor(e,t){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=e===void 0?new q(1,0,0):e,this.constant=t===void 0?0:t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Sg.subVectors(n,t).cross(Cg.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}clone(){return new this.constructor().copy(this)}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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===void 0&&(console.warn(`THREE.Plane: .projectPoint() target is now required`),t=new q),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){t===void 0&&(console.warn(`THREE.Plane: .intersectLine() target is now required`),t=new q);let n=e.delta(Sg),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):void 0;let i=-(e.start.dot(this.normal)+this.constant)/r;if(!(i<0||i>1))return t.copy(n).multiplyScalar(i).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e===void 0&&(console.warn(`THREE.Plane: .coplanarPoint() target is now required`),e=new q),e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||wg.getNormalMatrix(e),r=this.coplanarPoint(Sg).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},Eg=new q,Dg=new q,Og=new q,kg=new q,Ag=new q,jg=new q,Mg=new q,Ng=new q,Pg=new q,Fg=new q,Ig=class e{constructor(e,t,n){this.a=e===void 0?new q:e,this.b=t===void 0?new q:t,this.c=n===void 0?new q:n}static getNormal(e,t,n,r){r===void 0&&(console.warn(`THREE.Triangle: .getNormal() target is now required`),r=new q),r.subVectors(n,t),Eg.subVectors(e,t),r.cross(Eg);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Eg.subVectors(r,t),Dg.subVectors(n,t),Og.subVectors(e,t);let a=Eg.dot(Eg),o=Eg.dot(Dg),s=Eg.dot(Og),c=Dg.dot(Dg),l=Dg.dot(Og),u=a*c-o*o;if(i===void 0&&(console.warn(`THREE.Triangle: .getBarycoord() target is now required`),i=new q),u===0)return i.set(-2,-1,-1);let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,kg),kg.x>=0&&kg.y>=0&&kg.x+kg.y<=1}static getUV(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,kg),s.set(0,0),s.addScaledVector(i,kg.x),s.addScaledVector(a,kg.y),s.addScaledVector(o,kg.z),s}static isFrontFacing(e,t,n,r){return Eg.subVectors(n,t),Dg.subVectors(e,t),Eg.cross(Dg).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),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 Eg.subVectors(this.c,this.b),Dg.subVectors(this.a,this.b),Eg.cross(Dg).length()*.5}getMidpoint(e){return e===void 0&&(console.warn(`THREE.Triangle: .getMidpoint() target is now required`),e=new q),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e===void 0&&(console.warn(`THREE.Triangle: .getPlane() target is now required`),e=new Tg),e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getUV(t,n,r,i,a){return e.getUV(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){t===void 0&&(console.warn(`THREE.Triangle: .closestPointToPoint() target is now required`),t=new q);let n=this.a,r=this.b,i=this.c,a,o;Ag.subVectors(r,n),jg.subVectors(i,n),Ng.subVectors(e,n);let s=Ag.dot(Ng),c=jg.dot(Ng);if(s<=0&&c<=0)return t.copy(n);Pg.subVectors(e,r);let l=Ag.dot(Pg),u=jg.dot(Pg);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Ag,a);Fg.subVectors(e,i);let f=Ag.dot(Fg),p=jg.dot(Fg);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(jg,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Mg.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Mg,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Ag,a).addScaledVector(jg,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Lg={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},Rg={h:0,s:0,l:0},zg={h:0,s:0,l:0},Bg=class{constructor(e,t,n){return Object.defineProperty(this,"isColor",{value:!0}),t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e==`number`?this.setHex(e):typeof e==`string`&&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=(e&255)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=yh.euclideanModulo(e,1),t=yh.clamp(t,0,1),n=yh.clamp(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=$c(i,r,e+1/3),this.g=$c(i,r,e),this.b=$c(i,r,e-1/3)}return this}setStyle(e){function t(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){let e,r=n[1],i=n[2];switch(r){case`rgb`:case`rgba`:if(e=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))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=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))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=/^(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){let n=parseFloat(e[1])/360,r=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,r,i)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let e=n[1],t=e.length;if(t===3)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(t===6)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){let t=Lg[e];return t===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(t),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=e.r**+t,this.g=e.g**+t,this.b=e.b**+t,this}copyLinearToGamma(e,t=2){let n=t>0?1/t:1;return this.r=e.r**+n,this.g=e.g**+n,this.b=e.b**+n,this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=el(e.r),this.g=el(e.g),this.b=el(e.b),this}copyLinearToSRGB(e){return this.r=tl(e.r),this.g=tl(e.g),this.b=tl(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return(`000000`+this.getHex().toString(16)).slice(-6)}getHSL(e){e===void 0&&(console.warn(`THREE.Color: .getHSL() target is now required`),e={h:0,s:0,l:0});let t=this.r,n=this.g,r=this.b,i=Math.max(t,n,r),a=Math.min(t,n,r),o,s,c=(a+i)/2;if(a===i)o=0,s=0;else{let e=i-a;switch(s=c<=.5?e/(i+a):e/(2-i-a),i){case t:o=(n-r)/e+(n<r?6:0);break;case n:o=(r-t)/e+2;break;case r:o=(t-n)/e+4;break}o/=6}return e.h=o,e.s=s,e.l=c,e}getStyle(){return`rgb(`+(this.r*255|0)+`,`+(this.g*255|0)+`,`+(this.b*255|0)+`)`}offsetHSL(e,t,n){return this.getHSL(Rg),Rg.h+=e,Rg.s+=t,Rg.l+=n,this.setHSL(Rg.h,Rg.s,Rg.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}lerpHSL(e,t){this.getHSL(Rg),e.getHSL(zg);let n=yh.lerp(Rg.h,zg.h,t),r=yh.lerp(Rg.s,zg.s,t),i=yh.lerp(Rg.l,zg.l,t);return this.setHSL(n,r,i),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),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}},Bg.NAMES=Lg,Bg.prototype.r=1,Bg.prototype.g=1,Bg.prototype.b=1,Vg=class{constructor(e,t,n,r,i,a=0){this.a=e,this.b=t,this.c=n,this.normal=r&&r.isVector3?r:new q,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Bg,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}},Hg=0,nl.prototype=Object.assign(Object.create(Kc.prototype),{constructor:nl,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: '`+t+`' parameter is undefined.`);continue}if(t===`shading`){console.warn(`THREE.`+this.type+`: .shading has been removed. Use the boolean .flatShading instead.`),this.flatShading=n===1;continue}let r=this[t];if(r===void 0){console.warn(`THREE.`+this.type+`: '`+t+`' is not a property of this material.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}},toJSON:function(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,this.combine!==void 0&&(n.combine=this.combine),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.flatShading===!0&&(n.flatShading=this.flatShading),this.side!==0&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(n.morphTargets=!0),this.morphNormals===!0&&(n.morphNormals=!0),this.skinning===!0&&(n.skinning=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),JSON.stringify(this.userData)!==`{}`&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n},clone:function(){return new this.constructor().copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,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;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,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.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:`dispose`})}}),Object.defineProperty(nl.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),rl.prototype=Object.create(nl.prototype),rl.prototype.constructor=rl,rl.prototype.isMeshBasicMaterial=!0,rl.prototype.copy=function(e){return nl.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this},Ug=new q,Wg=new K,Object.defineProperty(il.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(il.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(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:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){let t=this.array,n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];i===void 0&&(console.warn(`THREE.BufferAttribute.copyColorsArray(): color is undefined`,r),i=new Bg),t[n++]=i.r,t[n++]=i.g,t[n++]=i.b}return this},copyVector2sArray:function(e){let t=this.array,n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];i===void 0&&(console.warn(`THREE.BufferAttribute.copyVector2sArray(): vector is undefined`,r),i=new K),t[n++]=i.x,t[n++]=i.y}return this},copyVector3sArray:function(e){let t=this.array,n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];i===void 0&&(console.warn(`THREE.BufferAttribute.copyVector3sArray(): vector is undefined`,r),i=new q),t[n++]=i.x,t[n++]=i.y,t[n++]=i.z}return this},copyVector4sArray:function(e){let t=this.array,n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];i===void 0&&(console.warn(`THREE.BufferAttribute.copyVector4sArray(): vector is undefined`,r),i=new wh),t[n++]=i.x,t[n++]=i.y,t[n++]=i.z,t[n++]=i.w}return this},applyMatrix3:function(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Wg.fromBufferAttribute(this,t),Wg.applyMatrix3(e),this.setXY(t,Wg.x,Wg.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ug.fromBufferAttribute(this,t),Ug.applyMatrix3(e),this.setXYZ(t,Ug.x,Ug.y,Ug.z);return this},applyMatrix4:function(e){for(let t=0,n=this.count;t<n;t++)Ug.x=this.getX(t),Ug.y=this.getY(t),Ug.z=this.getZ(t),Ug.applyMatrix4(e),this.setXYZ(t,Ug.x,Ug.y,Ug.z);return this},applyNormalMatrix:function(e){for(let t=0,n=this.count;t<n;t++)Ug.x=this.getX(t),Ug.y=this.getY(t),Ug.z=this.getZ(t),Ug.applyNormalMatrix(e),this.setXYZ(t,Ug.x,Ug.y,Ug.z);return this},transformDirection:function(e){for(let t=0,n=this.count;t<n;t++)Ug.x=this.getX(t),Ug.y=this.getY(t),Ug.z=this.getZ(t),Ug.transformDirection(e),this.setXYZ(t,Ug.x,Ug.y,Ug.z);return this},set:function(e,t=0){return this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this},setXYZ:function(e,t,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this},setXYZW:function(e,t,n,r,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),al.prototype=Object.create(il.prototype),al.prototype.constructor=al,ol.prototype=Object.create(il.prototype),ol.prototype.constructor=ol,sl.prototype=Object.create(il.prototype),sl.prototype.constructor=sl,cl.prototype=Object.create(il.prototype),cl.prototype.constructor=cl,ll.prototype=Object.create(il.prototype),ll.prototype.constructor=ll,ul.prototype=Object.create(il.prototype),ul.prototype.constructor=ul,dl.prototype=Object.create(il.prototype),dl.prototype.constructor=dl,fl.prototype=Object.create(il.prototype),fl.prototype.constructor=fl,fl.prototype.isFloat16BufferAttribute=!0,pl.prototype=Object.create(il.prototype),pl.prototype.constructor=pl,ml.prototype=Object.create(il.prototype),ml.prototype.constructor=ml,Gg=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,r,i,a=e.faces;for(r=0;r<a.length;r++){let e=a[r];e.materialIndex!==i&&(i=e.materialIndex,n!==void 0&&(n.count=r*3-n.start,t.push(n)),n={start:r*3,materialIndex:i})}n!==void 0&&(n.count=r*3-n.start,t.push(n)),this.groups=t}fromGeometry(e){let t=e.faces,n=e.vertices,r=e.faceVertexUvs,i=r[0]&&r[0].length>0,a=r[1]&&r[1].length>0,o=e.morphTargets,s=o.length,c;if(s>0){c=[];for(let e=0;e<s;e++)c[e]={name:o[e].name,data:[]};this.morphTargets.position=c}let l=e.morphNormals,u=l.length,d;if(u>0){d=[];for(let e=0;e<u;e++)d[e]={name:l[e].name,data:[]};this.morphTargets.normal=d}let f=e.skinIndices,p=e.skinWeights,m=f.length===n.length,h=p.length===n.length;n.length>0&&t.length===0&&console.error(`THREE.DirectGeometry: Faceless geometries are not supported.`);for(let e=0;e<t.length;e++){let g=t[e];this.vertices.push(n[g.a],n[g.b],n[g.c]);let _=g.vertexNormals;if(_.length===3)this.normals.push(_[0],_[1],_[2]);else{let e=g.normal;this.normals.push(e,e,e)}let v=g.vertexColors;if(v.length===3)this.colors.push(v[0],v[1],v[2]);else{let e=g.color;this.colors.push(e,e,e)}if(i===!0){let t=r[0][e];t===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv `,e),this.uvs.push(new K,new K,new K)):this.uvs.push(t[0],t[1],t[2])}if(a===!0){let t=r[1][e];t===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 `,e),this.uvs2.push(new K,new K,new K)):this.uvs2.push(t[0],t[1],t[2])}for(let e=0;e<s;e++){let t=o[e].vertices;c[e].data.push(t[g.a],t[g.b],t[g.c])}for(let t=0;t<u;t++){let n=l[t].vertexNormals[e];d[t].data.push(n.a,n.b,n.c)}m&&this.skinIndices.push(f[g.a],f[g.b],f[g.c]),h&&this.skinWeights.push(p[g.a],p[g.b],p[g.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Kg={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray<`u`?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array},qg=1,Jg=new Zh,Yg=new Qc,Xg=new q,Zg=new Oh,Qg=new Oh,$g=new q,_l.prototype=Object.assign(Object.create(Kc.prototype),{constructor:_l,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){return Array.isArray(e)?this.index=new(hl(e)>65535?dl:ll)(e,1):this.index=e,this},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},hasAttribute:function(e){return this.attributes[e]!==void 0},addGroup:function(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new bh().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(e){return Jg.makeRotationX(e),this.applyMatrix4(Jg),this},rotateY:function(e){return Jg.makeRotationY(e),this.applyMatrix4(Jg),this},rotateZ:function(e){return Jg.makeRotationZ(e),this.applyMatrix4(Jg),this},translate:function(e,t,n){return Jg.makeTranslation(e,t,n),this.applyMatrix4(Jg),this},scale:function(e,t,n){return Jg.makeScale(e,t,n),this.applyMatrix4(Jg),this},lookAt:function(e){return Yg.lookAt(e),Yg.updateMatrix(),this.applyMatrix4(Yg.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xg).negate(),this.translate(Xg.x,Xg.y,Xg.z),this},setFromObject:function(e){let t=e.geometry;if(e.isPoints||e.isLine){let e=new pl(t.vertices.length*3,3),n=new pl(t.colors.length*3,3);if(this.setAttribute(`position`,e.copyVector3sArray(t.vertices)),this.setAttribute(`color`,n.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let e=new pl(t.lineDistances.length,1);this.setAttribute(`lineDistance`,e.copyArray(t.lineDistances))}t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute(`position`,new pl(t,3)),this},updateFromObject:function(e){let t=e.geometry;if(e.isMesh){let e=t.__directGeometry;if(t.elementsNeedUpdate===!0&&(e=void 0,t.elementsNeedUpdate=!1),e===void 0)return this.fromGeometry(t);e.verticesNeedUpdate=t.verticesNeedUpdate,e.normalsNeedUpdate=t.normalsNeedUpdate,e.colorsNeedUpdate=t.colorsNeedUpdate,e.uvsNeedUpdate=t.uvsNeedUpdate,e.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=e}if(t.verticesNeedUpdate===!0){let e=this.attributes.position;e!==void 0&&(e.copyVector3sArray(t.vertices),e.needsUpdate=!0),t.verticesNeedUpdate=!1}if(t.normalsNeedUpdate===!0){let e=this.attributes.normal;e!==void 0&&(e.copyVector3sArray(t.normals),e.needsUpdate=!0),t.normalsNeedUpdate=!1}if(t.colorsNeedUpdate===!0){let e=this.attributes.color;e!==void 0&&(e.copyColorsArray(t.colors),e.needsUpdate=!0),t.colorsNeedUpdate=!1}if(t.uvsNeedUpdate){let e=this.attributes.uv;e!==void 0&&(e.copyVector2sArray(t.uvs),e.needsUpdate=!0),t.uvsNeedUpdate=!1}if(t.lineDistancesNeedUpdate){let e=this.attributes.lineDistance;e!==void 0&&(e.copyArray(t.lineDistances),e.needsUpdate=!0),t.lineDistancesNeedUpdate=!1}return t.groupsNeedUpdate&&(t.computeGroups(e.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=new Gg().fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){let t=new Float32Array(e.vertices.length*3);if(this.setAttribute(`position`,new il(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){let t=new Float32Array(e.normals.length*3);this.setAttribute(`normal`,new il(t,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let t=new Float32Array(e.colors.length*3);this.setAttribute(`color`,new il(t,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let t=new Float32Array(e.uvs.length*2);this.setAttribute(`uv`,new il(t,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let t=new Float32Array(e.uvs2.length*2);this.setAttribute(`uv2`,new il(t,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(let t in e.morphTargets){let n=[],r=e.morphTargets[t];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=new pl(t.data.length*3,3);i.name=t.name,n.push(i.copyVector3sArray(t.data))}this.morphAttributes[t]=n}if(e.skinIndices.length>0){let t=new pl(e.skinIndices.length*4,4);this.setAttribute(`skinIndex`,t.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let t=new pl(e.skinWeights.length*4,4);this.setAttribute(`skinWeight`,t.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new Oh);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".`,this),this.boundingBox.set(new q(-1/0,-1/0,-1/0),new q(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Zg.setFromBufferAttribute(n),this.morphTargetsRelative?($g.addVectors(this.boundingBox.min,Zg.min),this.boundingBox.expandByPoint($g),$g.addVectors(this.boundingBox.max,Zg.max),this.boundingBox.expandByPoint($g)):(this.boundingBox.expandByPoint(Zg.min),this.boundingBox.expandByPoint(Zg.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:function(){this.boundingSphere===null&&(this.boundingSphere=new Hh);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".`,this),this.boundingSphere.set(new q,1/0);return}if(e){let n=this.boundingSphere.center;if(Zg.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Qg.setFromBufferAttribute(n),this.morphTargetsRelative?($g.addVectors(Zg.min,Qg.min),Zg.expandByPoint($g),$g.addVectors(Zg.max,Qg.max),Zg.expandByPoint($g)):(Zg.expandByPoint(Qg.min),Zg.expandByPoint(Qg.max))}Zg.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)$g.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared($g));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)$g.fromBufferAttribute(a,t),o&&(Xg.fromBufferAttribute(e,t),$g.add(Xg)),r=Math.max(r,n.distanceToSquared($g))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}},computeFaceNormals:function(){},computeVertexNormals:function(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new il(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new q,i=new q,a=new q,o=new q,s=new q,c=new q,l=new q,u=new q;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}},merge:function(e,t){if(!(e&&e.isBufferGeometry)){console.error(`THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.`,e);return}t===void 0&&(t=0,console.warn(`THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.`));let n=this.attributes;for(let r in n){if(e.attributes[r]===void 0)continue;let i=n[r].array,a=e.attributes[r],o=a.array,s=a.itemSize*t,c=Math.min(o.length,i.length-s);for(let e=0,t=s;e<c;e++,t++)i[t]=o[e]}return this},normalizeNormals:function(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)$g.fromBufferAttribute(e,t),$g.normalize(),e.setXYZ(t,$g.x,$g.y,$g.z)},toNonIndexed:function(){function e(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let e=0,i=t.length;e<i;e++){o=t[e]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new il(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.`),this;let t=new _l,n=this.index.array,r=this.attributes;for(let i in r){let a=r[i],o=e(a,n);t.setAttribute(i,o)}let i=this.morphAttributes;for(let r in i){let a=[],o=i[r];for(let t=0,r=o.length;t<r;t++){let r=o[t],i=e(r,n);a.push(i)}t.morphAttributes[r]=a}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let e=0,n=a.length;e<n;e++){let n=a[e];t.addGroup(n.start,n.count,n.materialIndex)}return t},toJSON:function(){let 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),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t],i=r.toJSON(e.data);r.name!==``&&(i.name=r.name),e.data.attributes[t]=i}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t],i=r.toJSON(e.data);r.name!==``&&(i.name=r.name),a.push(i)}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e},clone:function(){return new _l().copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:`dispose`})}}),e_=new Zh,t_=new Xh,n_=new Hh,r_=new q,i_=new q,a_=new q,o_=new q,s_=new q,c_=new q,l_=new q,u_=new q,d_=new q,Y=new K,f_=new K,p_=new K,m_=new q,h_=new q,vl.prototype=Object.assign(Object.create(Qc.prototype),{constructor:vl,isMesh:!0,copy:function(e){return Qc.prototype.copy.call(this,e),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this},updateMorphTargets:function(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}},raycast:function(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;if(r===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),n_.copy(n.boundingSphere),n_.applyMatrix4(i),e.ray.intersectsSphere(n_)===!1)||(e_.copy(i).invert(),t_.copy(e.ray).applyMatrix4(e_),n.boundingBox!==null&&t_.intersectsBox(n.boundingBox)===!1))return;let a;if(n.isBufferGeometry){let i=n.index,o=n.attributes.position,s=n.morphAttributes.position,c=n.morphTargetsRelative,l=n.attributes.uv,u=n.attributes.uv2,d=n.groups,f=n.drawRange;if(i!==null)if(Array.isArray(r))for(let n=0,p=d.length;n<p;n++){let p=d[n],m=r[p.materialIndex],h=Math.max(p.start,f.start),g=Math.min(p.start+p.count,f.start+f.count);for(let n=h,r=g;n<r;n+=3){let r=i.getX(n),d=i.getX(n+1),f=i.getX(n+2);a=bl(this,m,e,t_,o,s,c,l,u,r,d,f),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=p.materialIndex,t.push(a))}}else{let n=Math.max(0,f.start),d=Math.min(i.count,f.start+f.count);for(let f=n,p=d;f<p;f+=3){let n=i.getX(f),d=i.getX(f+1),p=i.getX(f+2);a=bl(this,r,e,t_,o,s,c,l,u,n,d,p),a&&(a.faceIndex=Math.floor(f/3),t.push(a))}}else if(o!==void 0)if(Array.isArray(r))for(let n=0,i=d.length;n<i;n++){let i=d[n],p=r[i.materialIndex],m=Math.max(i.start,f.start),h=Math.min(i.start+i.count,f.start+f.count);for(let n=m,r=h;n<r;n+=3){let r=n,d=n+1,f=n+2;a=bl(this,p,e,t_,o,s,c,l,u,r,d,f),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.materialIndex,t.push(a))}}else{let n=Math.max(0,f.start),i=Math.min(o.count,f.start+f.count);for(let d=n,f=i;d<f;d+=3){let n=d,i=d+1,f=d+2;a=bl(this,r,e,t_,o,s,c,l,u,n,i,f),a&&(a.faceIndex=Math.floor(d/3),t.push(a))}}}else if(n.isGeometry){let i=Array.isArray(r),o=n.vertices,s=n.faces,c,l=n.faceVertexUvs[0];l.length>0&&(c=l);for(let n=0,l=s.length;n<l;n++){let l=s[n],u=i?r[l.materialIndex]:r;if(u===void 0)continue;let d=o[l.a],f=o[l.b],p=o[l.c];if(a=yl(this,u,e,t_,d,f,p,m_),a){if(c&&c[n]){let e=c[n];Y.copy(e[0]),f_.copy(e[1]),p_.copy(e[2]),a.uv=Ig.getUV(m_,d,f,p,Y,f_,p_,new K)}a.face=l,a.faceIndex=n,t.push(a)}}}}}),g_=class extends _l{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxBufferGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new pl(c,3)),this.setAttribute(`normal`,new pl(l,3)),this.setAttribute(`uv`,new pl(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new q;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}},__={clone:xl,merge:Sl},v_=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,y_=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`,Cl.prototype=Object.create(nl.prototype),Cl.prototype.constructor=Cl,Cl.prototype.isShaderMaterial=!0,Cl.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=xl(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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this},Cl.prototype.toJSON=function(e){let t=nl.prototype.toJSON.call(this,e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:`t`,value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:`c`,value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:`v2`,value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:`v3`,value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:`v4`,value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:`m3`,value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:`m4`,value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t},wl.prototype=Object.assign(Object.create(Qc.prototype),{constructor:wl,isCamera:!0,copy:function(e,t){return Qc.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){e===void 0&&(console.warn(`THREE.Camera: .getWorldDirection() target is now required`),e=new q),this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){Qc.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(e,t){Qc.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return new this.constructor().copy(this)}}),Tl.prototype=Object.assign(Object.create(wl.prototype),{constructor:Tl,isPerspectiveCamera:!0,copy:function(e,t){return wl.prototype.copy.call(this,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=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){let t=.5*this.getFilmHeight()/e;this.fov=yh.RAD2DEG*2*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){let e=Math.tan(yh.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/e},getEffectiveFOV:function(){return yh.RAD2DEG*2*Math.atan(Math.tan(yh.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(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=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let e=this.near,t=e*Math.tan(yh.DEG2RAD*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){let t=Qc.prototype.toJSON.call(this,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,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}),b_=90,x_=1,El.prototype=Object.create(Qc.prototype),El.prototype.constructor=El,Dl.prototype=Object.create(qc.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isCubeTexture=!0,Object.defineProperty(Dl.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),Ol.prototype=Object.create(Yc.prototype),Ol.prototype.constructor=Ol,Ol.prototype.isWebGLCubeRenderTarget=!0,Ol.prototype.fromEquirectangularTexture=function(e,t){this.texture.type=t.type,this.texture.format=Km,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
||
|
||
varying vec3 vWorldDirection;
|
||
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
|
||
}
|
||
`,fragmentShader:`
|
||
|
||
uniform sampler2D tEquirect;
|
||
|
||
varying vec3 vWorldDirection;
|
||
|
||
#include <common>
|
||
|
||
void main() {
|
||
|
||
vec3 direction = normalize( vWorldDirection );
|
||
|
||
vec2 sampleUV = equirectUv( direction );
|
||
|
||
gl_FragColor = texture2D( tEquirect, sampleUV );
|
||
|
||
}
|
||
`},r=new g_(5,5,5),i=new Cl({name:`CubemapFromEquirect`,uniforms:xl(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new vl(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=zm),new El(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this},Ol.prototype.clear=function(e,t,n,r){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)},kl.prototype=Object.create(qc.prototype),kl.prototype.constructor=kl,kl.prototype.isDataTexture=!0,S_=new Hh,C_=new q,w_=class{constructor(e,t,n,r,i,a){this.planes=[e===void 0?new Tg:e,t===void 0?new Tg:t,n===void 0?new Tg:n,r===void 0?new Tg:r,i===void 0?new Tg:i,a===void 0?new Tg:a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}clone(){return new this.constructor().copy(this)}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=this.planes,n=e.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],f=n[9],p=n[10],m=n[11],h=n[12],g=n[13],_=n[14],v=n[15];return t[0].setComponents(o-r,u-s,m-d,v-h).normalize(),t[1].setComponents(o+r,u+s,m+d,v+h).normalize(),t[2].setComponents(o+i,u+c,m+f,v+g).normalize(),t[3].setComponents(o-i,u-c,m-f,v-g).normalize(),t[4].setComponents(o-a,u-l,m-p,v-_).normalize(),t[5].setComponents(o+a,u+l,m+p,v+_).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),S_.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(S_)}intersectsSprite(e){return S_.center.set(0,0,0),S_.radius=.7071067811865476,S_.applyMatrix4(e.matrixWorld),this.intersectsSphere(S_)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(C_.x=r.normal.x>0?e.max.x:e.min.x,C_.y=r.normal.y>0?e.max.y:e.min.y,C_.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(C_)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}},T_=class extends _l{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneBufferGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new pl(p,3)),this.setAttribute(`normal`,new pl(m,3)),this.setAttribute(`uv`,new pl(h,2))}},E_={alphamap_fragment:`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
|
||
#endif`,alphamap_pars_fragment:`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,alphatest_fragment:`#ifdef ALPHATEST
|
||
if ( diffuseColor.a < ALPHATEST ) discard;
|
||
#endif`,aomap_fragment:`#ifdef USE_AOMAP
|
||
float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
|
||
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
||
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
||
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
||
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
|
||
#endif
|
||
#endif`,aomap_pars_fragment:`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,begin_vertex:`vec3 transformed = vec3( position );`,beginnormal_vertex:`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,bsdfs:`vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
|
||
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
||
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
||
vec4 r = roughness * c0 + c1;
|
||
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
||
return vec2( -1.04, 1.04 ) * a004 + r.zw;
|
||
}
|
||
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
||
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
|
||
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
||
if( cutoffDistance > 0.0 ) {
|
||
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
||
}
|
||
return distanceFalloff;
|
||
#else
|
||
if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
||
return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
||
}
|
||
return 1.0;
|
||
#endif
|
||
}
|
||
vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
|
||
return RECIPROCAL_PI * diffuseColor;
|
||
}
|
||
vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
|
||
float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
|
||
return ( 1.0 - specularColor ) * fresnel + specularColor;
|
||
}
|
||
vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
|
||
float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
|
||
vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
|
||
return Fr * fresnel + F0;
|
||
}
|
||
float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
float a2 = pow2( alpha );
|
||
float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
return 1.0 / ( gl * gv );
|
||
}
|
||
float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
float a2 = pow2( alpha );
|
||
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
return 0.5 / max( gv + gl, EPSILON );
|
||
}
|
||
float D_GGX( const in float alpha, const in float dotNH ) {
|
||
float a2 = pow2( alpha );
|
||
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
||
return RECIPROCAL_PI * a2 / pow2( denom );
|
||
}
|
||
vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( incidentLight.direction + viewDir );
|
||
float dotNL = saturate( dot( normal, incidentLight.direction ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
|
||
vec3 F = F_Schlick( specularColor, dotLH );
|
||
float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
return F * ( G * D );
|
||
}
|
||
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
||
const float LUT_SIZE = 64.0;
|
||
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||
float dotNV = saturate( dot( N, V ) );
|
||
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
||
uv = uv * LUT_SCALE + LUT_BIAS;
|
||
return uv;
|
||
}
|
||
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
||
float l = length( f );
|
||
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
||
}
|
||
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
||
float x = dot( v1, v2 );
|
||
float y = abs( x );
|
||
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
||
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
||
float v = a / b;
|
||
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
||
return cross( v1, v2 ) * theta_sintheta;
|
||
}
|
||
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
||
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
||
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
||
vec3 lightNormal = cross( v1, v2 );
|
||
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
||
vec3 T1, T2;
|
||
T1 = normalize( V - N * dot( V, N ) );
|
||
T2 = - cross( N, T1 );
|
||
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
||
vec3 coords[ 4 ];
|
||
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
||
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
||
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
||
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
||
coords[ 0 ] = normalize( coords[ 0 ] );
|
||
coords[ 1 ] = normalize( coords[ 1 ] );
|
||
coords[ 2 ] = normalize( coords[ 2 ] );
|
||
coords[ 3 ] = normalize( coords[ 3 ] );
|
||
vec3 vectorFormFactor = vec3( 0.0 );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
||
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
||
return vec3( result );
|
||
}
|
||
vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
|
||
return specularColor * brdf.x + brdf.y;
|
||
}
|
||
void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
||
vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
|
||
vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
|
||
vec3 FssEss = F * brdf.x + brdf.y;
|
||
float Ess = brdf.x + brdf.y;
|
||
float Ems = 1.0 - Ess;
|
||
vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
||
singleScatter += FssEss;
|
||
multiScatter += Fms * Ems;
|
||
}
|
||
float G_BlinnPhong_Implicit( ) {
|
||
return 0.25;
|
||
}
|
||
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
||
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
||
}
|
||
vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
|
||
vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
|
||
float dotNH = saturate( dot( geometry.normal, halfDir ) );
|
||
float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
|
||
vec3 F = F_Schlick( specularColor, dotLH );
|
||
float G = G_BlinnPhong_Implicit( );
|
||
float D = D_BlinnPhong( shininess, dotNH );
|
||
return F * ( G * D );
|
||
}
|
||
float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
|
||
return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
|
||
}
|
||
float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
|
||
return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
|
||
}
|
||
#if defined( USE_SHEEN )
|
||
float D_Charlie(float roughness, float NoH) {
|
||
float invAlpha = 1.0 / roughness;
|
||
float cos2h = NoH * NoH;
|
||
float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
|
||
}
|
||
float V_Neubelt(float NoV, float NoL) {
|
||
return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
|
||
}
|
||
vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
|
||
vec3 N = geometry.normal;
|
||
vec3 V = geometry.viewDir;
|
||
vec3 H = normalize( V + L );
|
||
float dotNH = saturate( dot( N, H ) );
|
||
return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
|
||
}
|
||
#endif`,bumpmap_pars_fragment:`#ifdef USE_BUMPMAP
|
||
uniform sampler2D bumpMap;
|
||
uniform float bumpScale;
|
||
vec2 dHdxy_fwd() {
|
||
vec2 dSTdx = dFdx( vUv );
|
||
vec2 dSTdy = dFdy( vUv );
|
||
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
|
||
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
|
||
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
|
||
return vec2( dBx, dBy );
|
||
}
|
||
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
|
||
vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
|
||
vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
|
||
vec3 vN = surf_norm;
|
||
vec3 R1 = cross( vSigmaY, vN );
|
||
vec3 R2 = cross( vN, vSigmaX );
|
||
float fDet = dot( vSigmaX, R1 );
|
||
fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
||
return normalize( abs( fDet ) * surf_norm - vGrad );
|
||
}
|
||
#endif`,clipping_planes_fragment:`#if NUM_CLIPPING_PLANES > 0
|
||
vec4 plane;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
||
plane = clippingPlanes[ i ];
|
||
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
||
bool clipped = true;
|
||
#pragma unroll_loop_start
|
||
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
||
plane = clippingPlanes[ i ];
|
||
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
||
}
|
||
#pragma unroll_loop_end
|
||
if ( clipped ) discard;
|
||
#endif
|
||
#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,color_fragment:`#ifdef USE_COLOR
|
||
diffuseColor.rgb *= vColor;
|
||
#endif`,color_pars_fragment:`#ifdef USE_COLOR
|
||
varying vec3 vColor;
|
||
#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
||
vColor = vec3( 1.0 );
|
||
#endif
|
||
#ifdef USE_COLOR
|
||
vColor.xyz *= color.xyz;
|
||
#endif
|
||
#ifdef USE_INSTANCING_COLOR
|
||
vColor.xyz *= instanceColor.xyz;
|
||
#endif`,common:`#define PI 3.141592653589793
|
||
#define PI2 6.283185307179586
|
||
#define PI_HALF 1.5707963267948966
|
||
#define RECIPROCAL_PI 0.3183098861837907
|
||
#define RECIPROCAL_PI2 0.15915494309189535
|
||
#define EPSILON 1e-6
|
||
#ifndef saturate
|
||
#define saturate(a) clamp( a, 0.0, 1.0 )
|
||
#endif
|
||
#define whiteComplement(a) ( 1.0 - saturate( a ) )
|
||
float pow2( const in float x ) { return x*x; }
|
||
float pow3( const in float x ) { return x*x*x; }
|
||
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
||
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
|
||
highp float rand( const in vec2 uv ) {
|
||
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
||
return fract(sin(sn) * c);
|
||
}
|
||
#ifdef HIGH_PRECISION
|
||
float precisionSafeLength( vec3 v ) { return length( v ); }
|
||
#else
|
||
float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
||
float precisionSafeLength( vec3 v ) {
|
||
float maxComponent = max3( abs( v ) );
|
||
return length( v / maxComponent ) * maxComponent;
|
||
}
|
||
#endif
|
||
struct IncidentLight {
|
||
vec3 color;
|
||
vec3 direction;
|
||
bool visible;
|
||
};
|
||
struct ReflectedLight {
|
||
vec3 directDiffuse;
|
||
vec3 directSpecular;
|
||
vec3 indirectDiffuse;
|
||
vec3 indirectSpecular;
|
||
};
|
||
struct GeometricContext {
|
||
vec3 position;
|
||
vec3 normal;
|
||
vec3 viewDir;
|
||
#ifdef CLEARCOAT
|
||
vec3 clearcoatNormal;
|
||
#endif
|
||
};
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
}
|
||
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
||
}
|
||
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
||
float distance = dot( planeNormal, point - pointOnPlane );
|
||
return - distance * planeNormal + point;
|
||
}
|
||
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
||
return sign( dot( point - pointOnPlane, planeNormal ) );
|
||
}
|
||
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
||
return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
|
||
}
|
||
mat3 transposeMat3( const in mat3 m ) {
|
||
mat3 tmp;
|
||
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
||
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
||
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
||
return tmp;
|
||
}
|
||
float linearToRelativeLuminance( const in vec3 color ) {
|
||
vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
|
||
return dot( weights, color.rgb );
|
||
}
|
||
bool isPerspectiveMatrix( mat4 m ) {
|
||
return m[ 2 ][ 3 ] == - 1.0;
|
||
}
|
||
vec2 equirectUv( in vec3 dir ) {
|
||
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
||
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||
return vec2( u, v );
|
||
}`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV
|
||
#define cubeUV_maxMipLevel 8.0
|
||
#define cubeUV_minMipLevel 4.0
|
||
#define cubeUV_maxTileSize 256.0
|
||
#define cubeUV_minTileSize 16.0
|
||
float getFace( vec3 direction ) {
|
||
vec3 absDirection = abs( direction );
|
||
float face = - 1.0;
|
||
if ( absDirection.x > absDirection.z ) {
|
||
if ( absDirection.x > absDirection.y )
|
||
face = direction.x > 0.0 ? 0.0 : 3.0;
|
||
else
|
||
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||
} else {
|
||
if ( absDirection.z > absDirection.y )
|
||
face = direction.z > 0.0 ? 2.0 : 5.0;
|
||
else
|
||
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||
}
|
||
return face;
|
||
}
|
||
vec2 getUV( vec3 direction, float face ) {
|
||
vec2 uv;
|
||
if ( face == 0.0 ) {
|
||
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
||
} else if ( face == 1.0 ) {
|
||
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
||
} else if ( face == 2.0 ) {
|
||
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
||
} else if ( face == 3.0 ) {
|
||
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
||
} else if ( face == 4.0 ) {
|
||
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
||
} else {
|
||
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
||
}
|
||
return 0.5 * ( uv + 1.0 );
|
||
}
|
||
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
||
float face = getFace( direction );
|
||
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
||
mipInt = max( mipInt, cubeUV_minMipLevel );
|
||
float faceSize = exp2( mipInt );
|
||
float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
|
||
vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );
|
||
vec2 f = fract( uv );
|
||
uv += 0.5 - f;
|
||
if ( face > 2.0 ) {
|
||
uv.y += faceSize;
|
||
face -= 3.0;
|
||
}
|
||
uv.x += face * faceSize;
|
||
if ( mipInt < cubeUV_maxMipLevel ) {
|
||
uv.y += 2.0 * cubeUV_maxTileSize;
|
||
}
|
||
uv.y += filterInt * 2.0 * cubeUV_minTileSize;
|
||
uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );
|
||
uv *= texelSize;
|
||
vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
|
||
uv.x += texelSize;
|
||
vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
|
||
uv.y += texelSize;
|
||
vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
|
||
uv.x -= texelSize;
|
||
vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
|
||
vec3 tm = mix( tl, tr, f.x );
|
||
vec3 bm = mix( bl, br, f.x );
|
||
return mix( tm, bm, f.y );
|
||
}
|
||
#define r0 1.0
|
||
#define v0 0.339
|
||
#define m0 - 2.0
|
||
#define r1 0.8
|
||
#define v1 0.276
|
||
#define m1 - 1.0
|
||
#define r4 0.4
|
||
#define v4 0.046
|
||
#define m4 2.0
|
||
#define r5 0.305
|
||
#define v5 0.016
|
||
#define m5 3.0
|
||
#define r6 0.21
|
||
#define v6 0.0038
|
||
#define m6 4.0
|
||
float roughnessToMip( float roughness ) {
|
||
float mip = 0.0;
|
||
if ( roughness >= r1 ) {
|
||
mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
|
||
} else if ( roughness >= r4 ) {
|
||
mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
|
||
} else if ( roughness >= r5 ) {
|
||
mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
|
||
} else if ( roughness >= r6 ) {
|
||
mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
|
||
} else {
|
||
mip = - 2.0 * log2( 1.16 * roughness ); }
|
||
return mip;
|
||
}
|
||
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
||
float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );
|
||
float mipF = fract( mip );
|
||
float mipInt = floor( mip );
|
||
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
||
if ( mipF == 0.0 ) {
|
||
return vec4( color0, 1.0 );
|
||
} else {
|
||
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
||
return vec4( mix( color0, color1, mipF ), 1.0 );
|
||
}
|
||
}
|
||
#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal;
|
||
#ifdef USE_INSTANCING
|
||
mat3 m = mat3( instanceMatrix );
|
||
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
|
||
transformedNormal = m * transformedNormal;
|
||
#endif
|
||
transformedNormal = normalMatrix * transformedNormal;
|
||
#ifdef FLIP_SIDED
|
||
transformedNormal = - transformedNormal;
|
||
#endif
|
||
#ifdef USE_TANGENT
|
||
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
||
#ifdef FLIP_SIDED
|
||
transformedTangent = - transformedTangent;
|
||
#endif
|
||
#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
|
||
#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vUv );
|
||
emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,encodings_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,encodings_pars_fragment:`
|
||
vec4 LinearToLinear( in vec4 value ) {
|
||
return value;
|
||
}
|
||
vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
|
||
return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
|
||
}
|
||
vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
|
||
return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
|
||
}
|
||
vec4 sRGBToLinear( in vec4 value ) {
|
||
return 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 );
|
||
}
|
||
vec4 LinearTosRGB( in vec4 value ) {
|
||
return 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 );
|
||
}
|
||
vec4 RGBEToLinear( in vec4 value ) {
|
||
return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
|
||
}
|
||
vec4 LinearToRGBE( in vec4 value ) {
|
||
float maxComponent = max( max( value.r, value.g ), value.b );
|
||
float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
|
||
return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
|
||
}
|
||
vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
|
||
return vec4( value.rgb * value.a * maxRange, 1.0 );
|
||
}
|
||
vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
|
||
float maxRGB = max( value.r, max( value.g, value.b ) );
|
||
float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
|
||
M = ceil( M * 255.0 ) / 255.0;
|
||
return vec4( value.rgb / ( M * maxRange ), M );
|
||
}
|
||
vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
|
||
return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
|
||
}
|
||
vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
|
||
float maxRGB = max( value.r, max( value.g, value.b ) );
|
||
float D = max( maxRange / maxRGB, 1.0 );
|
||
D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
|
||
return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
|
||
}
|
||
const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
|
||
vec4 LinearToLogLuv( in vec4 value ) {
|
||
vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
|
||
Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
|
||
vec4 vResult;
|
||
vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
|
||
float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
|
||
vResult.w = fract( Le );
|
||
vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
|
||
return vResult;
|
||
}
|
||
const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
|
||
vec4 LogLuvToLinear( in vec4 value ) {
|
||
float Le = value.z * 255.0 + value.w;
|
||
vec3 Xp_Y_XYZp;
|
||
Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
|
||
Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
|
||
Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
|
||
vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
|
||
return vec4( max( vRGB, 0.0 ), 1.0 );
|
||
}`,envmap_fragment:`#ifdef USE_ENVMAP
|
||
#ifdef ENV_WORLDPOS
|
||
vec3 cameraToFrag;
|
||
if ( isOrthographic ) {
|
||
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
||
} else {
|
||
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
||
}
|
||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||
#ifdef ENVMAP_MODE_REFLECTION
|
||
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
||
#else
|
||
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
||
#endif
|
||
#else
|
||
vec3 reflectVec = vReflect;
|
||
#endif
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
|
||
#else
|
||
vec4 envColor = vec4( 0.0 );
|
||
#endif
|
||
#ifndef ENVMAP_TYPE_CUBE_UV
|
||
envColor = envMapTexelToLinear( envColor );
|
||
#endif
|
||
#ifdef ENVMAP_BLENDING_MULTIPLY
|
||
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
||
#elif defined( ENVMAP_BLENDING_MIX )
|
||
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
||
#elif defined( ENVMAP_BLENDING_ADD )
|
||
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
||
#endif
|
||
#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP
|
||
uniform float envMapIntensity;
|
||
uniform float flipEnvMap;
|
||
uniform int maxMipLevel;
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
uniform samplerCube envMap;
|
||
#else
|
||
uniform sampler2D envMap;
|
||
#endif
|
||
|
||
#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP
|
||
uniform float reflectivity;
|
||
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
|
||
#define ENV_WORLDPOS
|
||
#endif
|
||
#ifdef ENV_WORLDPOS
|
||
varying vec3 vWorldPosition;
|
||
uniform float refractionRatio;
|
||
#else
|
||
varying vec3 vReflect;
|
||
#endif
|
||
#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP
|
||
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
|
||
#define ENV_WORLDPOS
|
||
#endif
|
||
#ifdef ENV_WORLDPOS
|
||
|
||
varying vec3 vWorldPosition;
|
||
#else
|
||
varying vec3 vReflect;
|
||
uniform float refractionRatio;
|
||
#endif
|
||
#endif`,envmap_physical_pars_fragment:`#if defined( USE_ENVMAP )
|
||
#ifdef ENVMAP_MODE_REFRACTION
|
||
uniform float refractionRatio;
|
||
#endif
|
||
vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
|
||
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
|
||
#ifdef TEXTURE_LOD_EXT
|
||
vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
|
||
#else
|
||
vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
|
||
#endif
|
||
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
|
||
#else
|
||
vec4 envMapColor = vec4( 0.0 );
|
||
#endif
|
||
return PI * envMapColor.rgb * envMapIntensity;
|
||
}
|
||
float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {
|
||
float maxMIPLevelScalar = float( maxMIPLevel );
|
||
float sigma = PI * roughness * roughness / ( 1.0 + roughness );
|
||
float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );
|
||
return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
|
||
}
|
||
vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {
|
||
#ifdef ENVMAP_MODE_REFLECTION
|
||
vec3 reflectVec = reflect( -viewDir, normal );
|
||
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
||
#else
|
||
vec3 reflectVec = refract( -viewDir, normal, refractionRatio );
|
||
#endif
|
||
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
||
float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
|
||
#ifdef TEXTURE_LOD_EXT
|
||
vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
|
||
#else
|
||
vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
|
||
#endif
|
||
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
|
||
#endif
|
||
return envMapColor.rgb * envMapIntensity;
|
||
}
|
||
#endif`,envmap_vertex:`#ifdef USE_ENVMAP
|
||
#ifdef ENV_WORLDPOS
|
||
vWorldPosition = worldPosition.xyz;
|
||
#else
|
||
vec3 cameraToVertex;
|
||
if ( isOrthographic ) {
|
||
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
||
} else {
|
||
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
||
}
|
||
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
||
#ifdef ENVMAP_MODE_REFLECTION
|
||
vReflect = reflect( cameraToVertex, worldNormal );
|
||
#else
|
||
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
||
#endif
|
||
#endif
|
||
#endif`,fog_vertex:`#ifdef USE_FOG
|
||
fogDepth = - mvPosition.z;
|
||
#endif`,fog_pars_vertex:`#ifdef USE_FOG
|
||
varying float fogDepth;
|
||
#endif`,fog_fragment:`#ifdef USE_FOG
|
||
#ifdef FOG_EXP2
|
||
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
|
||
#else
|
||
float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
|
||
#endif
|
||
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
||
#endif`,fog_pars_fragment:`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float fogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP
|
||
uniform sampler2D gradientMap;
|
||
#endif
|
||
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
||
float dotNL = dot( normal, lightDirection );
|
||
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
||
#ifdef USE_GRADIENTMAP
|
||
return texture2D( gradientMap, coord ).rgb;
|
||
#else
|
||
return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
|
||
#endif
|
||
}`,lightmap_fragment:`#ifdef USE_LIGHTMAP
|
||
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
|
||
reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
|
||
#endif`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,lights_lambert_vertex:`vec3 diffuse = vec3( 1.0 );
|
||
GeometricContext geometry;
|
||
geometry.position = mvPosition.xyz;
|
||
geometry.normal = normalize( transformedNormal );
|
||
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
||
GeometricContext backGeometry;
|
||
backGeometry.position = geometry.position;
|
||
backGeometry.normal = -geometry.normal;
|
||
backGeometry.viewDir = geometry.viewDir;
|
||
vLightFront = vec3( 0.0 );
|
||
vIndirectFront = vec3( 0.0 );
|
||
#ifdef DOUBLE_SIDED
|
||
vLightBack = vec3( 0.0 );
|
||
vIndirectBack = vec3( 0.0 );
|
||
#endif
|
||
IncidentLight directLight;
|
||
float dotNL;
|
||
vec3 directLightColor_Diffuse;
|
||
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
|
||
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry );
|
||
#ifdef DOUBLE_SIDED
|
||
vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
|
||
vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );
|
||
#endif
|
||
#if NUM_POINT_LIGHTS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||
getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
|
||
dotNL = dot( geometry.normal, directLight.direction );
|
||
directLightColor_Diffuse = PI * directLight.color;
|
||
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||
#ifdef DOUBLE_SIDED
|
||
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
||
#endif
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_SPOT_LIGHTS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||
getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
|
||
dotNL = dot( geometry.normal, directLight.direction );
|
||
directLightColor_Diffuse = PI * directLight.color;
|
||
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||
#ifdef DOUBLE_SIDED
|
||
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
||
#endif
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_DIR_LIGHTS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||
getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );
|
||
dotNL = dot( geometry.normal, directLight.direction );
|
||
directLightColor_Diffuse = PI * directLight.color;
|
||
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||
#ifdef DOUBLE_SIDED
|
||
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
||
#endif
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_HEMI_LIGHTS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
|
||
#ifdef DOUBLE_SIDED
|
||
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
|
||
#endif
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif`,lights_pars_begin:`uniform bool receiveShadow;
|
||
uniform vec3 ambientLightColor;
|
||
uniform vec3 lightProbe[ 9 ];
|
||
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
||
float x = normal.x, y = normal.y, z = normal.z;
|
||
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
||
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
||
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
||
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
||
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
||
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
||
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
||
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
||
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
||
return result;
|
||
}
|
||
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
|
||
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
|
||
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
||
return irradiance;
|
||
}
|
||
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
||
vec3 irradiance = ambientLightColor;
|
||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
irradiance *= PI;
|
||
#endif
|
||
return irradiance;
|
||
}
|
||
#if NUM_DIR_LIGHTS > 0
|
||
struct DirectionalLight {
|
||
vec3 direction;
|
||
vec3 color;
|
||
};
|
||
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
||
void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
|
||
directLight.color = directionalLight.color;
|
||
directLight.direction = directionalLight.direction;
|
||
directLight.visible = true;
|
||
}
|
||
#endif
|
||
#if NUM_POINT_LIGHTS > 0
|
||
struct PointLight {
|
||
vec3 position;
|
||
vec3 color;
|
||
float distance;
|
||
float decay;
|
||
};
|
||
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
||
void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
|
||
vec3 lVector = pointLight.position - geometry.position;
|
||
directLight.direction = normalize( lVector );
|
||
float lightDistance = length( lVector );
|
||
directLight.color = pointLight.color;
|
||
directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
|
||
directLight.visible = ( directLight.color != vec3( 0.0 ) );
|
||
}
|
||
#endif
|
||
#if NUM_SPOT_LIGHTS > 0
|
||
struct SpotLight {
|
||
vec3 position;
|
||
vec3 direction;
|
||
vec3 color;
|
||
float distance;
|
||
float decay;
|
||
float coneCos;
|
||
float penumbraCos;
|
||
};
|
||
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
||
void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
|
||
vec3 lVector = spotLight.position - geometry.position;
|
||
directLight.direction = normalize( lVector );
|
||
float lightDistance = length( lVector );
|
||
float angleCos = dot( directLight.direction, spotLight.direction );
|
||
if ( angleCos > spotLight.coneCos ) {
|
||
float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
||
directLight.color = spotLight.color;
|
||
directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
|
||
directLight.visible = true;
|
||
} else {
|
||
directLight.color = vec3( 0.0 );
|
||
directLight.visible = false;
|
||
}
|
||
}
|
||
#endif
|
||
#if NUM_RECT_AREA_LIGHTS > 0
|
||
struct RectAreaLight {
|
||
vec3 color;
|
||
vec3 position;
|
||
vec3 halfWidth;
|
||
vec3 halfHeight;
|
||
};
|
||
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
||
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
||
#endif
|
||
#if NUM_HEMI_LIGHTS > 0
|
||
struct HemisphereLight {
|
||
vec3 direction;
|
||
vec3 skyColor;
|
||
vec3 groundColor;
|
||
};
|
||
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
||
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
|
||
float dotNL = dot( geometry.normal, hemiLight.direction );
|
||
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
||
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
irradiance *= PI;
|
||
#endif
|
||
return irradiance;
|
||
}
|
||
#endif`,lights_toon_fragment:`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
struct ToonMaterial {
|
||
vec3 diffuseColor;
|
||
};
|
||
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
irradiance *= PI;
|
||
#endif
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
}
|
||
#define RE_Direct RE_Direct_Toon
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
|
||
#define Material_LightProbeLOD( material ) (0)`,lights_phong_fragment:`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
struct BlinnPhongMaterial {
|
||
vec3 diffuseColor;
|
||
vec3 specularColor;
|
||
float specularShininess;
|
||
float specularStrength;
|
||
};
|
||
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
irradiance *= PI;
|
||
#endif
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
|
||
}
|
||
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
}
|
||
#define RE_Direct RE_Direct_BlinnPhong
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
|
||
#define Material_LightProbeLOD( material ) (0)`,lights_physical_fragment:`PhysicalMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
||
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
||
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
||
material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;
|
||
material.specularRoughness = min( material.specularRoughness, 1.0 );
|
||
#ifdef REFLECTIVITY
|
||
material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
|
||
#else
|
||
material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
material.clearcoat = clearcoat;
|
||
material.clearcoatRoughness = clearcoatRoughness;
|
||
#ifdef USE_CLEARCOATMAP
|
||
material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
|
||
#endif
|
||
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
||
material.clearcoatRoughness += geometryRoughness;
|
||
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
material.sheenColor = sheen;
|
||
#endif`,lights_physical_pars_fragment:`struct PhysicalMaterial {
|
||
vec3 diffuseColor;
|
||
float specularRoughness;
|
||
vec3 specularColor;
|
||
#ifdef CLEARCOAT
|
||
float clearcoat;
|
||
float clearcoatRoughness;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
vec3 sheenColor;
|
||
#endif
|
||
};
|
||
#define MAXIMUM_SPECULAR_COEFFICIENT 0.16
|
||
#define DEFAULT_SPECULAR_COEFFICIENT 0.04
|
||
float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
|
||
return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
|
||
}
|
||
#if NUM_RECT_AREA_LIGHTS > 0
|
||
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 normal = geometry.normal;
|
||
vec3 viewDir = geometry.viewDir;
|
||
vec3 position = geometry.position;
|
||
vec3 lightPos = rectAreaLight.position;
|
||
vec3 halfWidth = rectAreaLight.halfWidth;
|
||
vec3 halfHeight = rectAreaLight.halfHeight;
|
||
vec3 lightColor = rectAreaLight.color;
|
||
float roughness = material.specularRoughness;
|
||
vec3 rectCoords[ 4 ];
|
||
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
||
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
||
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
||
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
||
vec4 t1 = texture2D( ltc_1, uv );
|
||
vec4 t2 = texture2D( ltc_2, uv );
|
||
mat3 mInv = mat3(
|
||
vec3( t1.x, 0, t1.y ),
|
||
vec3( 0, 1, 0 ),
|
||
vec3( t1.z, 0, t1.w )
|
||
);
|
||
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
||
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
||
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
||
}
|
||
#endif
|
||
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
irradiance *= PI;
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
|
||
vec3 ccIrradiance = ccDotNL * directLight.color;
|
||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
ccIrradiance *= PI;
|
||
#endif
|
||
float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
|
||
reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
|
||
#else
|
||
float clearcoatDHR = 0.0;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
|
||
material.specularRoughness,
|
||
directLight.direction,
|
||
geometry,
|
||
material.sheenColor
|
||
);
|
||
#else
|
||
reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
|
||
#endif
|
||
reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
}
|
||
void 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) {
|
||
#ifdef CLEARCOAT
|
||
float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
|
||
reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
|
||
float ccDotNL = ccDotNV;
|
||
float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
|
||
#else
|
||
float clearcoatDHR = 0.0;
|
||
#endif
|
||
float clearcoatInv = 1.0 - clearcoatDHR;
|
||
vec3 singleScattering = vec3( 0.0 );
|
||
vec3 multiScattering = vec3( 0.0 );
|
||
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
||
BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
|
||
vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
|
||
reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;
|
||
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
||
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
||
}
|
||
#define RE_Direct RE_Direct_Physical
|
||
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
||
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
||
}`,lights_fragment_begin:`
|
||
GeometricContext geometry;
|
||
geometry.position = - vViewPosition;
|
||
geometry.normal = normal;
|
||
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
||
#ifdef CLEARCOAT
|
||
geometry.clearcoatNormal = clearcoatNormal;
|
||
#endif
|
||
IncidentLight directLight;
|
||
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
PointLight pointLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
||
PointLightShadow pointLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||
pointLight = pointLights[ i ];
|
||
getPointDirectLightIrradiance( pointLight, geometry, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
||
pointLightShadow = pointLightShadows[ i ];
|
||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometry, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
SpotLight spotLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||
spotLight = spotLights[ i ];
|
||
getSpotDirectLightIrradiance( spotLight, geometry, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
spotLightShadow = spotLightShadows[ i ];
|
||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometry, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
||
DirectionalLight directionalLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||
directionalLight = directionalLights[ i ];
|
||
getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
||
directionalLightShadow = directionalLightShadows[ i ];
|
||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometry, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
||
RectAreaLight rectAreaLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
||
rectAreaLight = rectAreaLights[ i ];
|
||
RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if defined( RE_IndirectDiffuse )
|
||
vec3 iblIrradiance = vec3( 0.0 );
|
||
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
||
irradiance += getLightProbeIrradiance( lightProbe, geometry );
|
||
#if ( NUM_HEMI_LIGHTS > 0 )
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
#if defined( RE_IndirectSpecular )
|
||
vec3 radiance = vec3( 0.0 );
|
||
vec3 clearcoatRadiance = vec3( 0.0 );
|
||
#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse )
|
||
#ifdef USE_LIGHTMAP
|
||
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
|
||
vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
|
||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
lightMapIrradiance *= PI;
|
||
#endif
|
||
irradiance += lightMapIrradiance;
|
||
#endif
|
||
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
||
iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );
|
||
#endif
|
||
#endif
|
||
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
||
radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );
|
||
#ifdef CLEARCOAT
|
||
clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );
|
||
#endif
|
||
#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse )
|
||
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
|
||
#endif
|
||
#if defined( RE_IndirectSpecular )
|
||
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
|
||
#endif`,logdepthbuf_fragment:`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
||
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGDEPTHBUF
|
||
#ifdef USE_LOGDEPTHBUF_EXT
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#else
|
||
uniform float logDepthBufFC;
|
||
#endif
|
||
#endif`,logdepthbuf_vertex:`#ifdef USE_LOGDEPTHBUF
|
||
#ifdef USE_LOGDEPTHBUF_EXT
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#else
|
||
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
||
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
||
gl_Position.z *= gl_Position.w;
|
||
}
|
||
#endif
|
||
#endif`,map_fragment:`#ifdef USE_MAP
|
||
vec4 texelColor = texture2D( map, vUv );
|
||
texelColor = mapTexelToLinear( texelColor );
|
||
diffuseColor *= texelColor;
|
||
#endif`,map_pars_fragment:`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
||
#endif
|
||
#ifdef USE_MAP
|
||
vec4 mapTexel = texture2D( map, uv );
|
||
diffuseColor *= mapTexelToLinear( mapTexel );
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
||
#endif`,map_particle_pars_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||
uniform mat3 uvTransform;
|
||
#endif
|
||
#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif
|
||
#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,metalnessmap_fragment:`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS
|
||
objectNormal *= morphTargetBaseInfluence;
|
||
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
||
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
||
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
||
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
||
#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS
|
||
uniform float morphTargetBaseInfluence;
|
||
#ifndef USE_MORPHNORMALS
|
||
uniform float morphTargetInfluences[ 8 ];
|
||
#else
|
||
uniform float morphTargetInfluences[ 4 ];
|
||
#endif
|
||
#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS
|
||
transformed *= morphTargetBaseInfluence;
|
||
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
||
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
||
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
||
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
||
#ifndef USE_MORPHNORMALS
|
||
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
||
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
||
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
||
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
||
#endif
|
||
#endif`,normal_fragment_begin:`#ifdef FLAT_SHADED
|
||
vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
|
||
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
|
||
vec3 normal = normalize( cross( fdx, fdy ) );
|
||
#else
|
||
vec3 normal = normalize( vNormal );
|
||
#ifdef DOUBLE_SIDED
|
||
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
#endif
|
||
#ifdef USE_TANGENT
|
||
vec3 tangent = normalize( vTangent );
|
||
vec3 bitangent = normalize( vBitangent );
|
||
#ifdef DOUBLE_SIDED
|
||
tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
#endif
|
||
#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
|
||
mat3 vTBN = mat3( tangent, bitangent, normal );
|
||
#endif
|
||
#endif
|
||
#endif
|
||
vec3 geometryNormal = normal;`,normal_fragment_maps:`#ifdef OBJECTSPACE_NORMALMAP
|
||
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
||
#ifdef FLIP_SIDED
|
||
normal = - normal;
|
||
#endif
|
||
#ifdef DOUBLE_SIDED
|
||
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
#endif
|
||
normal = normalize( normalMatrix * normal );
|
||
#elif defined( TANGENTSPACE_NORMALMAP )
|
||
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
||
mapN.xy *= normalScale;
|
||
#ifdef USE_TANGENT
|
||
normal = normalize( vTBN * mapN );
|
||
#else
|
||
normal = perturbNormal2Arb( -vViewPosition, normal, mapN );
|
||
#endif
|
||
#elif defined( USE_BUMPMAP )
|
||
normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
|
||
#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP
|
||
uniform sampler2D normalMap;
|
||
uniform vec2 normalScale;
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
uniform mat3 normalMatrix;
|
||
#endif
|
||
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
|
||
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
|
||
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
|
||
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
|
||
vec2 st0 = dFdx( vUv.st );
|
||
vec2 st1 = dFdy( vUv.st );
|
||
float scale = sign( st1.t * st0.s - st0.t * st1.s );
|
||
vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
|
||
vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
|
||
vec3 N = normalize( surf_norm );
|
||
mat3 tsn = mat3( S, T, N );
|
||
mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
return normalize( tsn * mapN );
|
||
}
|
||
#endif`,clearcoat_normal_fragment_begin:`#ifdef CLEARCOAT
|
||
vec3 clearcoatNormal = geometryNormal;
|
||
#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
#ifdef USE_TANGENT
|
||
clearcoatNormal = normalize( vTBN * clearcoatMapN );
|
||
#else
|
||
clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );
|
||
#endif
|
||
#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP
|
||
uniform sampler2D clearcoatMap;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
uniform sampler2D clearcoatRoughnessMap;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
uniform sampler2D clearcoatNormalMap;
|
||
uniform vec2 clearcoatNormalScale;
|
||
#endif`,packing:`vec3 packNormalToRGB( const in vec3 normal ) {
|
||
return normalize( normal ) * 0.5 + 0.5;
|
||
}
|
||
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
||
return 2.0 * rgb.xyz - 1.0;
|
||
}
|
||
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
|
||
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
||
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
||
const float ShiftRight8 = 1. / 256.;
|
||
vec4 packDepthToRGBA( const in float v ) {
|
||
vec4 r = vec4( fract( v * PackFactors ), v );
|
||
r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
|
||
}
|
||
float unpackRGBAToDepth( const in vec4 v ) {
|
||
return dot( v, UnpackFactors );
|
||
}
|
||
vec4 pack2HalfToRGBA( vec2 v ) {
|
||
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
|
||
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
|
||
}
|
||
vec2 unpackRGBATo2Half( vec4 v ) {
|
||
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
||
}
|
||
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
||
return ( viewZ + near ) / ( near - far );
|
||
}
|
||
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
|
||
return linearClipZ * ( near - far ) - near;
|
||
}
|
||
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
||
return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
|
||
}
|
||
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
|
||
return ( near * far ) / ( ( far - near ) * invClipZ - far );
|
||
}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 );
|
||
#ifdef USE_INSTANCING
|
||
mvPosition = instanceMatrix * mvPosition;
|
||
#endif
|
||
mvPosition = modelViewMatrix * mvPosition;
|
||
gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,dithering_pars_fragment:`#ifdef DITHERING
|
||
vec3 dithering( vec3 color ) {
|
||
float grid_position = rand( gl_FragCoord.xy );
|
||
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
||
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
||
return color + dither_shift_RGB;
|
||
}
|
||
#endif`,roughnessmap_fragment:`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,shadowmap_pars_fragment:`#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
struct DirectionalLightShadow {
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
struct SpotLightShadow {
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
struct PointLightShadow {
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
float shadowCameraNear;
|
||
float shadowCameraFar;
|
||
};
|
||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
||
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
||
}
|
||
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
||
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
||
}
|
||
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
||
float occlusion = 1.0;
|
||
vec2 distribution = texture2DDistribution( shadow, uv );
|
||
float hard_shadow = step( compare , distribution.x );
|
||
if (hard_shadow != 1.0 ) {
|
||
float distance = compare - distribution.x ;
|
||
float variance = max( 0.00000, distribution.y * distribution.y );
|
||
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
||
}
|
||
return occlusion;
|
||
}
|
||
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
shadowCoord.z += shadowBias;
|
||
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
|
||
bool inFrustum = all( inFrustumVec );
|
||
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
|
||
bool frustumTest = all( frustumTestVec );
|
||
if ( frustumTest ) {
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
float dx0 = - texelSize.x * shadowRadius;
|
||
float dy0 = - texelSize.y * shadowRadius;
|
||
float dx1 = + texelSize.x * shadowRadius;
|
||
float dy1 = + texelSize.y * shadowRadius;
|
||
float dx2 = dx0 / 2.0;
|
||
float dy2 = dy0 / 2.0;
|
||
float dx3 = dx1 / 2.0;
|
||
float dy3 = dy1 / 2.0;
|
||
shadow = (
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
||
) * ( 1.0 / 17.0 );
|
||
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
float dx = texelSize.x;
|
||
float dy = texelSize.y;
|
||
vec2 uv = shadowCoord.xy;
|
||
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
||
uv -= f * texelSize;
|
||
shadow = (
|
||
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
||
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
||
f.x ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
||
f.x ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
||
f.y ) +
|
||
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
||
f.y ) +
|
||
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
||
f.x ),
|
||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
||
f.x ),
|
||
f.y )
|
||
) * ( 1.0 / 9.0 );
|
||
#elif defined( SHADOWMAP_TYPE_VSM )
|
||
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||
#else
|
||
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||
#endif
|
||
}
|
||
return shadow;
|
||
}
|
||
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
||
vec3 absV = abs( v );
|
||
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
||
absV *= scaleToCube;
|
||
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
||
vec2 planar = v.xy;
|
||
float almostATexel = 1.5 * texelSizeY;
|
||
float almostOne = 1.0 - almostATexel;
|
||
if ( absV.z >= almostOne ) {
|
||
if ( v.z > 0.0 )
|
||
planar.x = 4.0 - v.x;
|
||
} else if ( absV.x >= almostOne ) {
|
||
float signX = sign( v.x );
|
||
planar.x = v.z * signX + 2.0 * signX;
|
||
} else if ( absV.y >= almostOne ) {
|
||
float signY = sign( v.y );
|
||
planar.x = v.x + 2.0 * signY + 2.0;
|
||
planar.y = v.z * signY - 2.0;
|
||
}
|
||
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
||
}
|
||
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
||
vec3 lightToPosition = shadowCoord.xyz;
|
||
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
||
vec3 bd3D = normalize( lightToPosition );
|
||
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
||
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
||
return (
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
||
) * ( 1.0 / 9.0 );
|
||
#else
|
||
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
||
#endif
|
||
}
|
||
#endif`,shadowmap_pars_vertex:`#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
struct DirectionalLightShadow {
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
struct SpotLightShadow {
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
struct PointLightShadow {
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
float shadowCameraNear;
|
||
float shadowCameraFar;
|
||
};
|
||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#endif`,shadowmap_vertex:`#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
|
||
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
||
vec4 shadowWorldPosition;
|
||
#endif
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
||
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
|
||
vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
||
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif`,shadowmask_pars_fragment:`float getShadowMask() {
|
||
float shadow = 1.0;
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
directionalLight = directionalLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||
spotLight = spotLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
PointLightShadow pointLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
pointLight = pointLightShadows[ i ];
|
||
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
return shadow;
|
||
}`,skinbase_vertex:`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING
|
||
uniform mat4 bindMatrix;
|
||
uniform mat4 bindMatrixInverse;
|
||
#ifdef BONE_TEXTURE
|
||
uniform highp sampler2D boneTexture;
|
||
uniform int boneTextureSize;
|
||
mat4 getBoneMatrix( const in float i ) {
|
||
float j = i * 4.0;
|
||
float x = mod( j, float( boneTextureSize ) );
|
||
float y = floor( j / float( boneTextureSize ) );
|
||
float dx = 1.0 / float( boneTextureSize );
|
||
float dy = 1.0 / float( boneTextureSize );
|
||
y = dy * ( y + 0.5 );
|
||
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
||
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
||
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
||
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
||
mat4 bone = mat4( v1, v2, v3, v4 );
|
||
return bone;
|
||
}
|
||
#else
|
||
uniform mat4 boneMatrices[ MAX_BONES ];
|
||
mat4 getBoneMatrix( const in float i ) {
|
||
mat4 bone = boneMatrices[ int(i) ];
|
||
return bone;
|
||
}
|
||
#endif
|
||
#endif`,skinning_vertex:`#ifdef USE_SKINNING
|
||
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
||
vec4 skinned = vec4( 0.0 );
|
||
skinned += boneMatX * skinVertex * skinWeight.x;
|
||
skinned += boneMatY * skinVertex * skinWeight.y;
|
||
skinned += boneMatZ * skinVertex * skinWeight.z;
|
||
skinned += boneMatW * skinVertex * skinWeight.w;
|
||
transformed = ( bindMatrixInverse * skinned ).xyz;
|
||
#endif`,skinnormal_vertex:`#ifdef USE_SKINNING
|
||
mat4 skinMatrix = mat4( 0.0 );
|
||
skinMatrix += skinWeight.x * boneMatX;
|
||
skinMatrix += skinWeight.y * boneMatY;
|
||
skinMatrix += skinWeight.z * boneMatZ;
|
||
skinMatrix += skinWeight.w * boneMatW;
|
||
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
||
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
||
#ifdef USE_TANGENT
|
||
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
||
#endif
|
||
#endif`,specularmap_fragment:`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,tonemapping_pars_fragment:`#ifndef saturate
|
||
#define saturate(a) clamp( a, 0.0, 1.0 )
|
||
#endif
|
||
uniform float toneMappingExposure;
|
||
vec3 LinearToneMapping( vec3 color ) {
|
||
return toneMappingExposure * color;
|
||
}
|
||
vec3 ReinhardToneMapping( vec3 color ) {
|
||
color *= toneMappingExposure;
|
||
return saturate( color / ( vec3( 1.0 ) + color ) );
|
||
}
|
||
vec3 OptimizedCineonToneMapping( vec3 color ) {
|
||
color *= toneMappingExposure;
|
||
color = max( vec3( 0.0 ), color - 0.004 );
|
||
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
||
}
|
||
vec3 RRTAndODTFit( vec3 v ) {
|
||
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
||
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
||
return a / b;
|
||
}
|
||
vec3 ACESFilmicToneMapping( vec3 color ) {
|
||
const mat3 ACESInputMat = mat3(
|
||
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
||
vec3( 0.04823, 0.01566, 0.83777 )
|
||
);
|
||
const mat3 ACESOutputMat = mat3(
|
||
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
||
vec3( -0.07367, -0.00605, 1.07602 )
|
||
);
|
||
color *= toneMappingExposure / 0.6;
|
||
color = ACESInputMat * color;
|
||
color = RRTAndODTFit( color );
|
||
color = ACESOutputMat * color;
|
||
return saturate( color );
|
||
}
|
||
vec3 CustomToneMapping( vec3 color ) { return color; }`,transmissionmap_fragment:`#ifdef USE_TRANSMISSIONMAP
|
||
totalTransmission *= texture2D( transmissionMap, vUv ).r;
|
||
#endif`,transmissionmap_pars_fragment:`#ifdef USE_TRANSMISSIONMAP
|
||
uniform sampler2D transmissionMap;
|
||
#endif`,uv_pars_fragment:`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
|
||
varying vec2 vUv;
|
||
#endif`,uv_pars_vertex:`#ifdef USE_UV
|
||
#ifdef UVS_VERTEX_ONLY
|
||
vec2 vUv;
|
||
#else
|
||
varying vec2 vUv;
|
||
#endif
|
||
uniform mat3 uvTransform;
|
||
#endif`,uv_vertex:`#ifdef USE_UV
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
#endif`,uv2_pars_fragment:`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
||
varying vec2 vUv2;
|
||
#endif`,uv2_pars_vertex:`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
||
attribute vec2 uv2;
|
||
varying vec2 vUv2;
|
||
uniform mat3 uv2Transform;
|
||
#endif`,uv2_vertex:`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
||
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
|
||
#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
|
||
vec4 worldPosition = vec4( transformed, 1.0 );
|
||
#ifdef USE_INSTANCING
|
||
worldPosition = instanceMatrix * worldPosition;
|
||
#endif
|
||
worldPosition = modelMatrix * worldPosition;
|
||
#endif`,background_frag:`uniform sampler2D t2D;
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vec4 texColor = texture2D( t2D, vUv );
|
||
gl_FragColor = mapTexelToLinear( texColor );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
}`,background_vert:`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,cube_frag:`#include <envmap_common_pars_fragment>
|
||
uniform float opacity;
|
||
varying vec3 vWorldDirection;
|
||
#include <cube_uv_reflection_fragment>
|
||
void main() {
|
||
vec3 vReflect = vWorldDirection;
|
||
#include <envmap_fragment>
|
||
gl_FragColor = envColor;
|
||
gl_FragColor.a *= opacity;
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
}`,cube_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,depth_frag:`#if DEPTH_PACKING == 3200
|
||
uniform float opacity;
|
||
#endif
|
||
#include <common>
|
||
#include <packing>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
varying vec2 vHighPrecisionZW;
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#if DEPTH_PACKING == 3200
|
||
diffuseColor.a = opacity;
|
||
#endif
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
||
#if DEPTH_PACKING == 3200
|
||
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
||
#elif DEPTH_PACKING == 3201
|
||
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
||
#endif
|
||
}`,depth_vert:`#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
varying vec2 vHighPrecisionZW;
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <skinbase_vertex>
|
||
#ifdef USE_DISPLACEMENTMAP
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinnormal_vertex>
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vHighPrecisionZW = gl_Position.zw;
|
||
}`,distanceRGBA_frag:`#define DISTANCE
|
||
uniform vec3 referencePosition;
|
||
uniform float nearDistance;
|
||
uniform float farDistance;
|
||
varying vec3 vWorldPosition;
|
||
#include <common>
|
||
#include <packing>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main () {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
float dist = length( vWorldPosition - referencePosition );
|
||
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
||
dist = saturate( dist );
|
||
gl_FragColor = packDepthToRGBA( dist );
|
||
}`,distanceRGBA_vert:`#define DISTANCE
|
||
varying vec3 vWorldPosition;
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <skinbase_vertex>
|
||
#ifdef USE_DISPLACEMENTMAP
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinnormal_vertex>
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vWorldPosition = worldPosition.xyz;
|
||
}`,equirect_frag:`uniform sampler2D tEquirect;
|
||
varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vec3 direction = normalize( vWorldDirection );
|
||
vec2 sampleUV = equirectUv( direction );
|
||
vec4 texColor = texture2D( tEquirect, sampleUV );
|
||
gl_FragColor = mapTexelToLinear( texColor );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
}`,equirect_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,linedashed_frag:`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
uniform float dashSize;
|
||
uniform float totalSize;
|
||
varying float vLineDistance;
|
||
#include <common>
|
||
#include <color_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
||
discard;
|
||
}
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <logdepthbuf_fragment>
|
||
#include <color_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
}`,linedashed_vert:`uniform float scale;
|
||
attribute float lineDistance;
|
||
varying float vLineDistance;
|
||
#include <common>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
vLineDistance = scale * lineDistance;
|
||
#include <color_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshbasic_frag:`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <uv2_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <specularmap_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
#ifdef USE_LIGHTMAP
|
||
|
||
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
|
||
reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
|
||
#else
|
||
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
||
#endif
|
||
#include <aomap_fragment>
|
||
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
||
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
||
#include <envmap_fragment>
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshbasic_vert:`#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <uv2_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <uv2_vertex>
|
||
#include <color_vertex>
|
||
#include <skinbase_vertex>
|
||
#ifdef USE_ENVMAP
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <envmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshlambert_frag:`uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float opacity;
|
||
varying vec3 vLightFront;
|
||
varying vec3 vIndirectFront;
|
||
#ifdef DOUBLE_SIDED
|
||
varying vec3 vLightBack;
|
||
varying vec3 vIndirectBack;
|
||
#endif
|
||
#include <common>
|
||
#include <packing>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <uv2_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <fog_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <shadowmask_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <specularmap_fragment>
|
||
#include <emissivemap_fragment>
|
||
#ifdef DOUBLE_SIDED
|
||
reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
|
||
#else
|
||
reflectedLight.indirectDiffuse += vIndirectFront;
|
||
#endif
|
||
#include <lightmap_fragment>
|
||
reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
|
||
#ifdef DOUBLE_SIDED
|
||
reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
|
||
#else
|
||
reflectedLight.directDiffuse = vLightFront;
|
||
#endif
|
||
reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
#include <envmap_fragment>
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshlambert_vert:`#define LAMBERT
|
||
varying vec3 vLightFront;
|
||
varying vec3 vIndirectFront;
|
||
#ifdef DOUBLE_SIDED
|
||
varying vec3 vLightBack;
|
||
varying vec3 vIndirectBack;
|
||
#endif
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <uv2_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <uv2_vertex>
|
||
#include <color_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <envmap_vertex>
|
||
#include <lights_lambert_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshmatcap_frag:`#define MATCAP
|
||
uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
uniform sampler2D matcap;
|
||
varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
vec3 viewDir = normalize( vViewPosition );
|
||
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
||
vec3 y = cross( viewDir, x );
|
||
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
||
#ifdef USE_MATCAP
|
||
vec4 matcapColor = texture2D( matcap, uv );
|
||
matcapColor = matcapTexelToLinear( matcapColor );
|
||
#else
|
||
vec4 matcapColor = vec4( 1.0 );
|
||
#endif
|
||
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshmatcap_vert:`#define MATCAP
|
||
varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
}`,meshtoon_frag:`#define TOON
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <packing>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <uv2_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <gradientmap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <lights_toon_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_toon_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshtoon_vert:`#define TOON
|
||
varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <uv2_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <uv2_vertex>
|
||
#include <color_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
#include <worldpos_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshphong_frag:`#define PHONG
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform vec3 specular;
|
||
uniform float shininess;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <packing>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <uv2_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <lights_phong_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <specularmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_phong_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
||
#include <envmap_fragment>
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshphong_vert:`#define PHONG
|
||
varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <uv2_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <uv2_vertex>
|
||
#include <color_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
#include <worldpos_vertex>
|
||
#include <envmap_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshphysical_frag:`#define STANDARD
|
||
#ifdef PHYSICAL
|
||
#define REFLECTIVITY
|
||
#define CLEARCOAT
|
||
#define TRANSMISSION
|
||
#endif
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float roughness;
|
||
uniform float metalness;
|
||
uniform float opacity;
|
||
#ifdef TRANSMISSION
|
||
uniform float transmission;
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
uniform float reflectivity;
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
uniform float clearcoat;
|
||
uniform float clearcoatRoughness;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
uniform vec3 sheen;
|
||
#endif
|
||
varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif
|
||
#include <common>
|
||
#include <packing>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <uv2_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <transmissionmap_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <lights_pars_begin>
|
||
#include <lights_physical_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <clearcoat_pars_fragment>
|
||
#include <roughnessmap_pars_fragment>
|
||
#include <metalnessmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#ifdef TRANSMISSION
|
||
float totalTransmission = transmission;
|
||
#endif
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <roughnessmap_fragment>
|
||
#include <metalnessmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <clearcoat_normal_fragment_begin>
|
||
#include <clearcoat_normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <transmissionmap_fragment>
|
||
#include <lights_physical_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
||
#ifdef TRANSMISSION
|
||
diffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshphysical_vert:`#define STANDARD
|
||
varying vec3 vViewPosition;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <uv2_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <uv2_vertex>
|
||
#include <color_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
#include <worldpos_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,normal_frag:`#define NORMAL
|
||
uniform float opacity;
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
||
varying vec3 vViewPosition;
|
||
#endif
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif
|
||
#include <packing>
|
||
#include <uv_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
|
||
}`,normal_vert:`#define NORMAL
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
||
varying vec3 vViewPosition;
|
||
#endif
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
||
vViewPosition = - mvPosition.xyz;
|
||
#endif
|
||
}`,points_frag:`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <color_pars_fragment>
|
||
#include <map_particle_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_particle_fragment>
|
||
#include <color_fragment>
|
||
#include <alphatest_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
}`,points_vert:`uniform float size;
|
||
uniform float scale;
|
||
#include <common>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <color_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <project_vertex>
|
||
gl_PointSize = size;
|
||
#ifdef USE_SIZEATTENUATION
|
||
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
||
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
||
#endif
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <fog_vertex>
|
||
}`,shadow_frag:`uniform vec3 color;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <packing>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <shadowmask_pars_fragment>
|
||
void main() {
|
||
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
}`,shadow_vert:`#include <common>
|
||
#include <fog_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
void main() {
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,sprite_frag:`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
#include <clipping_planes_fragment>
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
#include <tonemapping_fragment>
|
||
#include <encodings_fragment>
|
||
#include <fog_fragment>
|
||
}`,sprite_vert:`uniform float rotation;
|
||
uniform vec2 center;
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
||
vec2 scale;
|
||
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
||
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
||
#ifndef USE_SIZEATTENUATION
|
||
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
||
if ( isPerspective ) scale *= - mvPosition.z;
|
||
#endif
|
||
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
||
vec2 rotatedPosition;
|
||
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
||
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
||
mvPosition.xy += rotatedPosition;
|
||
gl_Position = projectionMatrix * mvPosition;
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
}`},X={common:{diffuse:{value:new Bg(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new bh},uv2Transform:{value:new bh},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},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 K(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 Bg(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 Bg(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new bh}},sprite:{diffuse:{value:new Bg(15658734)},opacity:{value:1},center:{value:new K(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new bh}}},D_={basic:{uniforms:Sl([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.fog]),vertexShader:E_.meshbasic_vert,fragmentShader:E_.meshbasic_frag},lambert:{uniforms:Sl([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.fog,X.lights,{emissive:{value:new Bg(0)}}]),vertexShader:E_.meshlambert_vert,fragmentShader:E_.meshlambert_frag},phong:{uniforms:Sl([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.fog,X.lights,{emissive:{value:new Bg(0)},specular:{value:new Bg(1118481)},shininess:{value:30}}]),vertexShader:E_.meshphong_vert,fragmentShader:E_.meshphong_frag},standard:{uniforms:Sl([X.common,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.roughnessmap,X.metalnessmap,X.fog,X.lights,{emissive:{value:new Bg(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:E_.meshphysical_vert,fragmentShader:E_.meshphysical_frag},toon:{uniforms:Sl([X.common,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.gradientmap,X.fog,X.lights,{emissive:{value:new Bg(0)}}]),vertexShader:E_.meshtoon_vert,fragmentShader:E_.meshtoon_frag},matcap:{uniforms:Sl([X.common,X.bumpmap,X.normalmap,X.displacementmap,X.fog,{matcap:{value:null}}]),vertexShader:E_.meshmatcap_vert,fragmentShader:E_.meshmatcap_frag},points:{uniforms:Sl([X.points,X.fog]),vertexShader:E_.points_vert,fragmentShader:E_.points_frag},dashed:{uniforms:Sl([X.common,X.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:E_.linedashed_vert,fragmentShader:E_.linedashed_frag},depth:{uniforms:Sl([X.common,X.displacementmap]),vertexShader:E_.depth_vert,fragmentShader:E_.depth_frag},normal:{uniforms:Sl([X.common,X.bumpmap,X.normalmap,X.displacementmap,{opacity:{value:1}}]),vertexShader:E_.normal_vert,fragmentShader:E_.normal_frag},sprite:{uniforms:Sl([X.sprite,X.fog]),vertexShader:E_.sprite_vert,fragmentShader:E_.sprite_frag},background:{uniforms:{uvTransform:{value:new bh},t2D:{value:null}},vertexShader:E_.background_vert,fragmentShader:E_.background_frag},cube:{uniforms:Sl([X.envmap,{opacity:{value:1}}]),vertexShader:E_.cube_vert,fragmentShader:E_.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:E_.equirect_vert,fragmentShader:E_.equirect_frag},distanceRGBA:{uniforms:Sl([X.common,X.displacementmap,{referencePosition:{value:new q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:E_.distanceRGBA_vert,fragmentShader:E_.distanceRGBA_frag},shadow:{uniforms:Sl([X.lights,X.fog,{color:{value:new Bg(0)},opacity:{value:1}}]),vertexShader:E_.shadow_vert,fragmentShader:E_.shadow_frag}},D_.physical={uniforms:Sl([D_.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new K(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new Bg(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:E_.meshphysical_vert,fragmentShader:E_.meshphysical_frag},Kl.prototype=Object.create(qc.prototype),Kl.prototype.constructor=Kl,Kl.prototype.isDataTexture2DArray=!0,ql.prototype=Object.create(qc.prototype),ql.prototype.constructor=ql,ql.prototype.isDataTexture3D=!0,O_=new qc,k_=new Kl,A_=new ql,j_=new Dl,M_=[],N_=[],P_=new Float32Array(16),F_=new Float32Array(9),I_=new Float32Array(4),Au.prototype.updateCache=function(e){let t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Xl(t,e)},ju.prototype.setValue=function(e,t,n){let r=this.seq;for(let i=0,a=r.length;i!==a;++i){let a=r[i];a.setValue(e,t[a.id],n)}},L_=/(\w+)(\])?(\[|\.)?/g,Pu.prototype.setValue=function(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)},Pu.prototype.setOptional=function(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)},Pu.upload=function(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}},Pu.seqWithValue=function(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n},R_=0,z_=/^[ \t]*#include +<([\w\d./]+)>/gm,B_=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,V_=/#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,H_=0,_d.prototype=Object.create(nl.prototype),_d.prototype.constructor=_d,_d.prototype.isMeshDepthMaterial=!0,_d.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,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},vd.prototype=Object.create(nl.prototype),vd.prototype.constructor=vd,vd.prototype.isMeshDistanceMaterial=!0,vd.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this},U_=`uniform sampler2D shadow_pass;
|
||
uniform vec2 resolution;
|
||
uniform float radius;
|
||
#include <packing>
|
||
void main() {
|
||
float mean = 0.0;
|
||
float squared_mean = 0.0;
|
||
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
|
||
for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
|
||
#ifdef HORIZONTAL_PASS
|
||
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
|
||
mean += distribution.x;
|
||
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
||
#else
|
||
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );
|
||
mean += depth;
|
||
squared_mean += depth * depth;
|
||
#endif
|
||
}
|
||
mean = mean * HALF_SAMPLE_RATE;
|
||
squared_mean = squared_mean * HALF_SAMPLE_RATE;
|
||
float std_dev = sqrt( squared_mean - mean * mean );
|
||
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
||
}`,W_=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,Cd.prototype=Object.assign(Object.create(Tl.prototype),{constructor:Cd,isArrayCamera:!0}),wd.prototype=Object.assign(Object.create(Qc.prototype),{constructor:wd,isGroup:!0}),Object.assign(Td.prototype,{constructor:Td,getHandSpace:function(){if(this._hand===null&&(this._hand=new wd,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints=[],this._hand.inputState={pinching:!1},window.XRHand))for(let e=0;e<=window.XRHand.LITTLE_PHALANX_TIP;e++){let e=new wd;e.matrixAutoUpdate=!1,e.visible=!1,this._hand.joints.push(e),this._hand.add(e)}return this._hand},getTargetRaySpace:function(){return this._targetRay===null&&(this._targetRay=new wd,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return this._grip===null&&(this._grip=new wd,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this},update:function(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`)if(c&&e.hand){a=!0;for(let r=0;r<=window.XRHand.LITTLE_PHALANX_TIP;r++)if(e.hand[r]){let i=t.getJointPose(e.hand[r],n),a=c.joints[r];i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.jointRadius=i.radius),a.visible=i!==null;let o=c.joints[window.XRHand.INDEX_PHALANX_TIP],s=c.joints[window.XRHand.THUMB_PHALANX_TIP],l=o.position.distanceTo(s.position);c.inputState.pinching&&l>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&l<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}}else o!==null&&(r=t.getPose(e.targetRaySpace,n),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale))),s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale)));return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}}),Object.assign(Ed.prototype,Kc.prototype),Ad.prototype=Object.assign(Object.create(kd.prototype),{constructor:Ad,isWebGL1Renderer:!0}),G_=class extends Qc{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.background!==null&&(t.object.background=this.background.toJSON(e)),this.environment!==null&&(t.object.environment=this.environment.toJSON(e)),this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},Object.defineProperty(jd.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(jd.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this},set:function(e,t=0){return this.array.set(e,t),this},clone:function(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yh.generateUUID()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new jd(new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),this.stride);return t.setUsage(this.usage),t},onUpload:function(e){return this.onUploadCallback=e,this},toJSON:function(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yh.generateUUID()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(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}}}),K_=new q,Object.defineProperties(Md.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(e){this.data.needsUpdate=e}}}),Object.assign(Md.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(e){for(let t=0,n=this.data.count;t<n;t++)K_.x=this.getX(t),K_.y=this.getY(t),K_.z=this.getZ(t),K_.applyMatrix4(e),this.setXYZ(t,K_.x,K_.y,K_.z);return this},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this},setXYZ:function(e,t,n,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this},setXYZW:function(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this},clone:function(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new il(new this.array.constructor(e),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Md(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}),Nd.prototype=Object.create(nl.prototype),Nd.prototype.constructor=Nd,Nd.prototype.isSpriteMaterial=!0,Nd.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this},J_=new q,Y_=new q,X_=new q,Z_=new K,Q_=new K,$_=new Zh,ev=new q,tv=new q,nv=new q,rv=new K,iv=new K,av=new K,Pd.prototype=Object.assign(Object.create(Qc.prototype),{constructor:Pd,isSprite:!0,raycast:function(e,t){e.camera===null&&console.error(`THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Y_.setFromMatrixScale(this.matrixWorld),$_.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),X_.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Y_.multiplyScalar(-X_.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;Fd(ev.set(-.5,-.5,0),X_,a,Y_,r,i),Fd(tv.set(.5,-.5,0),X_,a,Y_,r,i),Fd(nv.set(.5,.5,0),X_,a,Y_,r,i),rv.set(0,0),iv.set(1,0),av.set(1,1);let o=e.ray.intersectTriangle(ev,tv,nv,!1,J_);if(o===null&&(Fd(tv.set(-.5,.5,0),X_,a,Y_,r,i),iv.set(0,1),o=e.ray.intersectTriangle(ev,nv,tv,!1,J_),o===null))return;let s=e.ray.origin.distanceTo(J_);s<e.near||s>e.far||t.push({distance:s,point:J_.clone(),uv:Ig.getUV(J_,ev,tv,nv,rv,iv,av,new K),face:null,object:this})},copy:function(e){return Qc.prototype.copy.call(this,e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}),ov=new q,sv=new q,Id.prototype=Object.assign(Object.create(Qc.prototype),{constructor:Id,isLOD:!0,copy:function(e){Qc.prototype.copy.call(this,e,!1);let t=e.levels;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.addLevel(n.object.clone(),n.distance)}return this.autoUpdate=e.autoUpdate,this},addLevel:function(e,t=0){t=Math.abs(t);let n=this.levels,r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,object:e}),this.add(e),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r&&!(e<t[n].distance);n++);return t[n-1].object}return null},raycast:function(e,t){if(this.levels.length>0){ov.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(ov);this.getObjectForDistance(n).raycast(e,t)}},update:function(e){let t=this.levels;if(t.length>1){ov.setFromMatrixPosition(e.matrixWorld),sv.setFromMatrixPosition(this.matrixWorld);let n=ov.distanceTo(sv)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r<i&&n>=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}},toJSON:function(e){let t=Qc.prototype.toJSON.call(this,e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let e=0,r=n.length;e<r;e++){let r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance})}return t}}),cv=new q,lv=new wh,uv=new wh,dv=new q,fv=new Zh,Ld.prototype=Object.assign(Object.create(vl.prototype),{constructor:Ld,isSkinnedMesh:!0,copy:function(e){return vl.prototype.copy.call(this,e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this},bind:function(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){let e=new wh,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.x=t.getX(n),e.y=t.getY(n),e.z=t.getZ(n),e.w=t.getW(n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}},updateMatrixWorld:function(e){vl.prototype.updateMatrixWorld.call(this,e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn(`THREE.SkinnedMesh: Unrecognized bindMode: `+this.bindMode)},boneTransform:function(e,t){let n=this.skeleton,r=this.geometry;lv.fromBufferAttribute(r.attributes.skinIndex,e),uv.fromBufferAttribute(r.attributes.skinWeight,e),cv.fromBufferAttribute(r.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let r=uv.getComponent(e);if(r!==0){let i=lv.getComponent(e);fv.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(dv.copy(cv).applyMatrix4(fv),r)}}return t.applyMatrix4(this.bindMatrixInverse)}}),Rd.prototype=Object.assign(Object.create(Qc.prototype),{constructor:Rd,isBone:!0}),pv=new Zh,mv=new Zh,Object.assign(zd.prototype,{init:function(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)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 Zh)}},calculateInverses:function(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new Zh;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}},pose:function(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let 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:function(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:mv;pv.multiplyMatrices(i,t[r]),pv.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)},clone:function(){return new zd(this.bones,this.boneInverses)},getBoneByName:function(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}},dispose:function(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)},fromJSON:function(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(console.warn(`THREE.Skeleton: No bone found with UUID:`,r),i=new Rd),this.bones.push(i),this.boneInverses.push(new Zh().fromArray(e.boneInverses[n]))}return this.init(),this},toJSON:function(){let e={metadata:{version:4.5,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}}),hv=new Zh,gv=new Zh,_v=[],vv=new vl,Bd.prototype=Object.assign(Object.create(vl.prototype),{constructor:Bd,isInstancedMesh:!0,copy:function(e){return vl.prototype.copy.call(this,e),this.instanceMatrix.copy(e.instanceMatrix),this.count=e.count,this},getColorAt:function(e,t){t.fromArray(this.instanceColor.array,e*3)},getMatrixAt:function(e,t){t.fromArray(this.instanceMatrix.array,e*16)},raycast:function(e,t){let n=this.matrixWorld,r=this.count;if(vv.geometry=this.geometry,vv.material=this.material,vv.material!==void 0)for(let i=0;i<r;i++){this.getMatrixAt(i,hv),gv.multiplyMatrices(n,hv),vv.matrixWorld=gv,vv.raycast(e,_v);for(let e=0,n=_v.length;e<n;e++){let n=_v[e];n.instanceId=i,n.object=this,t.push(n)}_v.length=0}},setColorAt:function(e,t){this.instanceColor===null&&(this.instanceColor=new il(new Float32Array(this.count*3),3)),t.toArray(this.instanceColor.array,e*3)},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,e*16)},updateMorphTargets:function(){},dispose:function(){this.dispatchEvent({type:`dispose`})}}),Vd.prototype=Object.create(nl.prototype),Vd.prototype.constructor=Vd,Vd.prototype.isLineBasicMaterial=!0,Vd.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.morphTargets=e.morphTargets,this},yv=new q,bv=new q,xv=new Zh,Sv=new Xh,Cv=new Hh,Hd.prototype=Object.assign(Object.create(Qc.prototype),{constructor:Hd,isLine:!0,copy:function(e){return Qc.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},computeLineDistances:function(){let e=this.geometry;if(e.isBufferGeometry)if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)yv.fromBufferAttribute(t,e-1),bv.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=yv.distanceTo(bv);e.setAttribute(`lineDistance`,new pl(n,1))}else console.warn(`THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);else if(e.isGeometry){let t=e.vertices,n=e.lineDistances;n[0]=0;for(let e=1,r=t.length;e<r;e++)n[e]=n[e-1],n[e]+=t[e-1].distanceTo(t[e])}return this},raycast:function(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold;if(n.boundingSphere===null&&n.computeBoundingSphere(),Cv.copy(n.boundingSphere),Cv.applyMatrix4(r),Cv.radius+=i,e.ray.intersectsSphere(Cv)===!1)return;xv.copy(r).invert(),Sv.copy(e.ray).applyMatrix4(xv);let a=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,s=new q,c=new q,l=new q,u=new q,d=this.isLineSegments?2:1;if(n.isBufferGeometry){let r=n.index,i=n.attributes.position;if(r!==null){let n=r.array;for(let r=0,a=n.length-1;r<a;r+=d){let a=n[r],d=n[r+1];if(s.fromBufferAttribute(i,a),c.fromBufferAttribute(i,d),Sv.distanceSqToSegment(s,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);let f=e.ray.origin.distanceTo(u);f<e.near||f>e.far||t.push({distance:f,point:l.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}else for(let n=0,r=i.count-1;n<r;n+=d){if(s.fromBufferAttribute(i,n),c.fromBufferAttribute(i,n+1),Sv.distanceSqToSegment(s,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(u);r<e.near||r>e.far||t.push({distance:r,point:l.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else if(n.isGeometry){let r=n.vertices,i=r.length;for(let n=0;n<i-1;n+=d){if(Sv.distanceSqToSegment(r[n],r[n+1],u,l)>o)continue;u.applyMatrix4(this.matrixWorld);let i=e.ray.origin.distanceTo(u);i<e.near||i>e.far||t.push({distance:i,point:l.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}},updateMorphTargets:function(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}}),wv=new q,Tv=new q,Ud.prototype=Object.assign(Object.create(Hd.prototype),{constructor:Ud,isLineSegments:!0,computeLineDistances:function(){let e=this.geometry;if(e.isBufferGeometry)if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)wv.fromBufferAttribute(t,e),Tv.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+wv.distanceTo(Tv);e.setAttribute(`lineDistance`,new pl(n,1))}else console.warn(`THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);else if(e.isGeometry){let t=e.vertices,n=e.lineDistances;for(let e=0,r=t.length;e<r;e+=2)wv.copy(t[e]),Tv.copy(t[e+1]),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+wv.distanceTo(Tv)}return this}}),Wd.prototype=Object.assign(Object.create(Hd.prototype),{constructor:Wd,isLineLoop:!0}),Gd.prototype=Object.create(nl.prototype),Gd.prototype.constructor=Gd,Gd.prototype.isPointsMaterial=!0,Gd.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this},Ev=new Zh,Dv=new Xh,Ov=new Hh,kv=new q,Kd.prototype=Object.assign(Object.create(Qc.prototype),{constructor:Kd,isPoints:!0,copy:function(e){return Qc.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},raycast:function(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ov.copy(n.boundingSphere),Ov.applyMatrix4(r),Ov.radius+=i,e.ray.intersectsSphere(Ov)===!1)return;Ev.copy(r).invert(),Dv.copy(e.ray).applyMatrix4(Ev);let a=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a;if(n.isBufferGeometry){let i=n.index,a=n.attributes.position;if(i!==null){let n=i.array;for(let i=0,s=n.length;i<s;i++){let s=n[i];kv.fromBufferAttribute(a,s),qd(kv,s,o,r,e,t,this)}}else for(let n=0,i=a.count;n<i;n++)kv.fromBufferAttribute(a,n),qd(kv,n,o,r,e,t,this)}else{let i=n.vertices;for(let n=0,a=i.length;n<a;n++)qd(i[n],n,o,r,e,t,this)}},updateMorphTargets:function(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}}),Jd.prototype=Object.assign(Object.create(qc.prototype),{constructor:Jd,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),Yd.prototype=Object.create(qc.prototype),Yd.prototype.constructor=Yd,Yd.prototype.isCompressedTexture=!0,Xd.prototype=Object.create(qc.prototype),Xd.prototype.constructor=Xd,Xd.prototype.isCanvasTexture=!0,Zd.prototype=Object.create(qc.prototype),Zd.prototype.constructor=Zd,Zd.prototype.isDepthTexture=!0,Av=0,jv=new Zh,Mv=new Qc,Nv=new q,Qd.prototype=Object.assign(Object.create(Kc.prototype),{constructor:Qd,isGeometry:!0,applyMatrix4:function(e){let t=new bh().getNormalMatrix(e);for(let t=0,n=this.vertices.length;t<n;t++)this.vertices[t].applyMatrix4(e);for(let e=0,n=this.faces.length;e<n;e++){let n=this.faces[e];n.normal.applyMatrix3(t).normalize();for(let e=0,r=n.vertexNormals.length;e<r;e++)n.vertexNormals[e].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return jv.makeRotationX(e),this.applyMatrix4(jv),this},rotateY:function(e){return jv.makeRotationY(e),this.applyMatrix4(jv),this},rotateZ:function(e){return jv.makeRotationZ(e),this.applyMatrix4(jv),this},translate:function(e,t,n){return jv.makeTranslation(e,t,n),this.applyMatrix4(jv),this},scale:function(e,t,n){return jv.makeScale(e,t,n),this.applyMatrix4(jv),this},lookAt:function(e){return Mv.lookAt(e),Mv.updateMatrix(),this.applyMatrix4(Mv.matrix),this},fromBufferGeometry:function(e){let t=this,n=e.index===null?void 0:e.index,r=e.attributes;if(r.position===void 0)return console.error(`THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.`),this;let i=r.position,a=r.normal,o=r.color,s=r.uv,c=r.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let e=0;e<i.count;e++)t.vertices.push(new q().fromBufferAttribute(i,e)),o!==void 0&&t.colors.push(new Bg().fromBufferAttribute(o,e));function l(e,n,r,i){let l=o===void 0?[]:[t.colors[e].clone(),t.colors[n].clone(),t.colors[r].clone()],u=new Vg(e,n,r,a===void 0?[]:[new q().fromBufferAttribute(a,e),new q().fromBufferAttribute(a,n),new q().fromBufferAttribute(a,r)],l,i);t.faces.push(u),s!==void 0&&t.faceVertexUvs[0].push([new K().fromBufferAttribute(s,e),new K().fromBufferAttribute(s,n),new K().fromBufferAttribute(s,r)]),c!==void 0&&t.faceVertexUvs[1].push([new K().fromBufferAttribute(c,e),new K().fromBufferAttribute(c,n),new K().fromBufferAttribute(c,r)])}let u=e.groups;if(u.length>0)for(let e=0;e<u.length;e++){let t=u[e],r=t.start,i=t.count;for(let e=r,a=r+i;e<a;e+=3)n===void 0?l(e,e+1,e+2,t.materialIndex):l(n.getX(e),n.getX(e+1),n.getX(e+2),t.materialIndex)}else if(n!==void 0)for(let e=0;e<n.count;e+=3)l(n.getX(e),n.getX(e+1),n.getX(e+2));else for(let e=0;e<i.count;e+=3)l(e,e+1,e+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Nv).negate(),this.translate(Nv.x,Nv.y,Nv.z),this},normalize:function(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,r=new Zh;return r.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(r),this},computeFaceNormals:function(){let e=new q,t=new q;for(let n=0,r=this.faces.length;n<r;n++){let r=this.faces[n],i=this.vertices[r.a],a=this.vertices[r.b],o=this.vertices[r.c];e.subVectors(o,a),t.subVectors(i,a),e.cross(t),e.normalize(),r.normal.copy(e)}},computeVertexNormals:function(e=!0){let t=Array(this.vertices.length);for(let e=0,n=this.vertices.length;e<n;e++)t[e]=new q;if(e){let e=new q,n=new q;for(let r=0,i=this.faces.length;r<i;r++){let i=this.faces[r],a=this.vertices[i.a],o=this.vertices[i.b],s=this.vertices[i.c];e.subVectors(s,o),n.subVectors(a,o),e.cross(n),t[i.a].add(e),t[i.b].add(e),t[i.c].add(e)}}else{this.computeFaceNormals();for(let e=0,n=this.faces.length;e<n;e++){let n=this.faces[e];t[n.a].add(n.normal),t[n.b].add(n.normal),t[n.c].add(n.normal)}}for(let e=0,n=this.vertices.length;e<n;e++)t[e].normalize();for(let e=0,n=this.faces.length;e<n;e++){let n=this.faces[e],r=n.vertexNormals;r.length===3?(r[0].copy(t[n.a]),r[1].copy(t[n.b]),r[2].copy(t[n.c])):(r[0]=t[n.a].clone(),r[1]=t[n.b].clone(),r[2]=t[n.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],n=t.vertexNormals;n.length===3?(n[0].copy(t.normal),n[1].copy(t.normal),n[2].copy(t.normal)):(n[0]=t.normal.clone(),n[1]=t.normal.clone(),n[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.__originalFaceNormal?t.__originalFaceNormal.copy(t.normal):t.__originalFaceNormal=t.normal.clone(),t.__originalVertexNormals||=[];for(let e=0,n=t.vertexNormals.length;e<n;e++)t.__originalVertexNormals[e]?t.__originalVertexNormals[e].copy(t.vertexNormals[e]):t.__originalVertexNormals[e]=t.vertexNormals[e].clone()}let e=new Qd;e.faces=this.faces;for(let t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let e=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let t=0,r=this.faces.length;t<r;t++){let t=new q,r={a:new q,b:new q,c:new q};e.push(t),n.push(r)}}let n=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],r=n.faceNormals[e],i=n.vertexNormals[e];r.copy(t.normal),i.a.copy(t.vertexNormals[0]),i.b.copy(t.vertexNormals[1]),i.c.copy(t.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.normal=t.__originalFaceNormal,t.vertexNormals=t.__originalVertexNormals}},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new Oh),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new Hh),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,n=0){if(!(e&&e.isGeometry)){console.error(`THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.`,e);return}let r,i=this.vertices.length,a=this.vertices,o=e.vertices,s=this.faces,c=e.faces,l=this.colors,u=e.colors;t!==void 0&&(r=new bh().getNormalMatrix(t));for(let e=0,n=o.length;e<n;e++){let n=o[e].clone();t!==void 0&&n.applyMatrix4(t),a.push(n)}for(let e=0,t=u.length;e<t;e++)l.push(u[e].clone());for(let e=0,t=c.length;e<t;e++){let t=c[e],a,o,l=t.vertexNormals,u=t.vertexColors,d=new Vg(t.a+i,t.b+i,t.c+i);d.normal.copy(t.normal),r!==void 0&&d.normal.applyMatrix3(r).normalize();for(let e=0,t=l.length;e<t;e++)a=l[e].clone(),r!==void 0&&a.applyMatrix3(r).normalize(),d.vertexNormals.push(a);d.color.copy(t.color);for(let e=0,t=u.length;e<t;e++)o=u[e],d.vertexColors.push(o.clone());d.materialIndex=t.materialIndex+n,s.push(d)}for(let t=0,n=e.faceVertexUvs.length;t<n;t++){let n=e.faceVertexUvs[t];this.faceVertexUvs[t]===void 0&&(this.faceVertexUvs[t]=[]);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=[];for(let e=0,t=r.length;e<t;e++)i.push(r[e].clone());this.faceVertexUvs[t].push(i)}}},mergeMesh:function(e){if(!(e&&e.isMesh)){console.error(`THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.`,e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)},mergeVertices:function(e=4){let t={},n=[],r=[],i=10**e;for(let e=0,a=this.vertices.length;e<a;e++){let a=this.vertices[e],o=Math.round(a.x*i)+`_`+Math.round(a.y*i)+`_`+Math.round(a.z*i);t[o]===void 0?(t[o]=e,n.push(this.vertices[e]),r[e]=n.length-1):r[e]=r[t[o]]}let a=[];for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.a=r[t.a],t.b=r[t.b],t.c=r[t.c];let n=[t.a,t.b,t.c];for(let t=0;t<3;t++)if(n[t]===n[(t+1)%3]){a.push(e);break}}for(let e=a.length-1;e>=0;e--){let t=a[e];this.faces.splice(t,1);for(let e=0,n=this.faceVertexUvs.length;e<n;e++)this.faceVertexUvs[e].splice(t,1)}let o=this.vertices.length-n.length;return this.vertices=n,o},setFromPoints:function(e){this.vertices=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];this.vertices.push(new q(n.x,n.y,n.z||0))}return this},sortFacesByMaterialIndex:function(){let e=this.faces,t=e.length;for(let n=0;n<t;n++)e[n]._id=n;function n(e,t){return e.materialIndex-t.materialIndex}e.sort(n);let r=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,o;r&&r.length===t&&(a=[]),i&&i.length===t&&(o=[]);for(let n=0;n<t;n++){let t=e[n]._id;a&&a.push(r[t]),o&&o.push(i[t])}a&&(this.faceVertexUvs[0]=a),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){let e={metadata:{version:4.5,type:`Geometry`,generator:`Geometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}let t=[];for(let e=0;e<this.vertices.length;e++){let n=this.vertices[e];t.push(n.x,n.y,n.z)}let n=[],r=[],i={},a=[],o={},s=[],c={};for(let e=0;e<this.faces.length;e++){let t=this.faces[e],r=this.faceVertexUvs[0][e]!==void 0,i=t.normal.length()>0,a=t.vertexNormals.length>0,o=t.color.r!==1||t.color.g!==1||t.color.b!==1,s=t.vertexColors.length>0,c=0;if(c=l(c,0,0),c=l(c,1,!0),c=l(c,2,!1),c=l(c,3,r),c=l(c,4,i),c=l(c,5,a),c=l(c,6,o),c=l(c,7,s),n.push(c),n.push(t.a,t.b,t.c),n.push(t.materialIndex),r){let t=this.faceVertexUvs[0][e];n.push(f(t[0]),f(t[1]),f(t[2]))}if(i&&n.push(u(t.normal)),a){let e=t.vertexNormals;n.push(u(e[0]),u(e[1]),u(e[2]))}if(o&&n.push(d(t.color)),s){let e=t.vertexColors;n.push(d(e[0]),d(e[1]),d(e[2]))}}function l(e,t,n){return n?e|1<<t:e&~(1<<t)}function u(e){let t=e.x.toString()+e.y.toString()+e.z.toString();return i[t]===void 0?(i[t]=r.length/3,r.push(e.x,e.y,e.z),i[t]):i[t]}function d(e){let t=e.r.toString()+e.g.toString()+e.b.toString();return o[t]===void 0?(o[t]=a.length,a.push(e.getHex()),o[t]):o[t]}function f(e){let t=e.x.toString()+e.y.toString();return c[t]===void 0?(c[t]=s.length/2,s.push(e.x,e.y),c[t]):c[t]}return e.data={},e.data.vertices=t,e.data.normals=r,a.length>0&&(e.data.colors=a),s.length>0&&(e.data.uvs=[s]),e.data.faces=n,e},clone:function(){return new Qd().copy(this)},copy:function(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let e=0,n=t.length;e<n;e++)this.vertices.push(t[e].clone());let n=e.colors;for(let e=0,t=n.length;e<t;e++)this.colors.push(n[e].clone());let r=e.faces;for(let e=0,t=r.length;e<t;e++)this.faces.push(r[e].clone());for(let t=0,n=e.faceVertexUvs.length;t<n;t++){let n=e.faceVertexUvs[t];this.faceVertexUvs[t]===void 0&&(this.faceVertexUvs[t]=[]);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=[];for(let e=0,t=r.length;e<t;e++){let t=r[e];i.push(t.clone())}this.faceVertexUvs[t].push(i)}}let i=e.morphTargets;for(let e=0,t=i.length;e<t;e++){let t={};if(t.name=i[e].name,i[e].vertices!==void 0){t.vertices=[];for(let n=0,r=i[e].vertices.length;n<r;n++)t.vertices.push(i[e].vertices[n].clone())}if(i[e].normals!==void 0){t.normals=[];for(let n=0,r=i[e].normals.length;n<r;n++)t.normals.push(i[e].normals[n].clone())}this.morphTargets.push(t)}let a=e.morphNormals;for(let e=0,t=a.length;e<t;e++){let t={};if(a[e].vertexNormals!==void 0){t.vertexNormals=[];for(let n=0,r=a[e].vertexNormals.length;n<r;n++){let r=a[e].vertexNormals[n],i={};i.a=r.a.clone(),i.b=r.b.clone(),i.c=r.c.clone(),t.vertexNormals.push(i)}}if(a[e].faceNormals!==void 0){t.faceNormals=[];for(let n=0,r=a[e].faceNormals.length;n<r;n++)t.faceNormals.push(a[e].faceNormals[n].clone())}this.morphNormals.push(t)}let o=e.skinWeights;for(let e=0,t=o.length;e<t;e++)this.skinWeights.push(o[e].clone());let s=e.skinIndices;for(let e=0,t=s.length;e<t;e++)this.skinIndices.push(s[e].clone());let c=e.lineDistances;for(let e=0,t=c.length;e<t;e++)this.lineDistances.push(c[e]);let l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:`dispose`})}}),new q,new q,new q,new Ig,Pv={triangulate:function(e,t,n){n||=2;let r=t&&t.length,i=r?t[0]*n:e.length,a=$d(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l,u,d,f,p;if(r&&(a=sf(e,t,a,n)),e.length>80*n){s=l=e[0],c=u=e[1];for(let t=n;t<i;t+=n)d=e[t],f=e[t+1],d<s&&(s=d),f<c&&(c=f),d>l&&(l=d),f>u&&(u=f);p=Math.max(l-s,u-c),p=p===0?0:1/p}return tf(a,o,n,s,c,p),o}},Fv={area:function(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5},isClockWise:function(e){return Fv.area(e)<0},triangulateShape:function(e,t){let n=[],r=[],i=[];jf(e),Mf(n,e);let a=e.length;t.forEach(jf);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Mf(n,t[e]);let o=Pv.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}},Iv=class extends _l{constructor(e,t){super(),this.type=`ExtrudeBufferGeometry`,this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];a(n)}this.setAttribute(`position`,new pl(r,3)),this.setAttribute(`uv`,new pl(i,2)),this.computeVertexNormals();function a(e){let a=[],o=t.curveSegments===void 0?12:t.curveSegments,s=t.steps===void 0?1:t.steps,c=t.depth===void 0?100:t.depth,l=t.bevelEnabled===void 0?!0:t.bevelEnabled,u=t.bevelThickness===void 0?6:t.bevelThickness,d=t.bevelSize===void 0?u-2:t.bevelSize,f=t.bevelOffset===void 0?0:t.bevelOffset,p=t.bevelSegments===void 0?3:t.bevelSegments,m=t.extrudePath,h=t.UVGenerator===void 0?Lv:t.UVGenerator;t.amount!==void 0&&(console.warn(`THREE.ExtrudeBufferGeometry: amount has been renamed to depth.`),c=t.amount);let g,_=!1,v,y,b,x;m&&(g=m.getSpacedPoints(s),_=!0,l=!1,v=m.computeFrenetFrames(s,!1),y=new q,b=new q,x=new q),l||(p=0,u=0,d=0,f=0);let S=e.extractPoints(o),C=S.shape,w=S.holes;if(!Fv.isClockWise(C)){C=C.reverse();for(let e=0,t=w.length;e<t;e++){let t=w[e];Fv.isClockWise(t)&&(w[e]=t.reverse())}}let T=Fv.triangulateShape(C,w),E=C;for(let e=0,t=w.length;e<t;e++){let t=w[e];C=C.concat(t)}function D(e,t,n){return t||console.error(`THREE.ExtrudeGeometry: vec does not exist`),t.clone().multiplyScalar(n).add(e)}let O=C.length,k=T.length;function A(e,t,n){let r,i,a,o=e.x-t.x,s=e.y-t.y,c=n.x-e.x,l=n.y-e.y,u=o*o+s*s,d=o*l-s*c;if(Math.abs(d)>2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new K(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new K(r/a,i/a)}let j=[];for(let e=0,t=E.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),j[e]=A(E[e],E[n],E[r]);let M=[],N,P=j.concat();for(let e=0,t=w.length;e<t;e++){let t=w[e];N=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),N[e]=A(t[e],t[r],t[i]);M.push(N),P=P.concat(N)}for(let e=0;e<p;e++){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){let t=D(E[e],j[e],r);te(t.x,t.y,-n)}for(let e=0,t=w.length;e<t;e++){let t=w[e];N=M[e];for(let e=0,i=t.length;e<i;e++){let i=D(t[e],N[e],r);te(i.x,i.y,-n)}}}let F=d+f;for(let e=0;e<O;e++){let t=l?D(C[e],P[e],F):C[e];_?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(b).add(y),te(x.x,x.y,x.z)):te(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<O;t++){let n=l?D(C[t],P[t],F):C[t];_?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),x.copy(g[e]).add(b).add(y),te(x.x,x.y,x.z)):te(n.x,n.y,c/s*e)}for(let e=p-1;e>=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){let t=D(E[e],j[e],r);te(t.x,t.y,c+n)}for(let e=0,t=w.length;e<t;e++){let t=w[e];N=M[e];for(let e=0,i=t.length;e<i;e++){let i=D(t[e],N[e],r);_?te(i.x,i.y+g[s-1].y,g[s-1].x+n):te(i.x,i.y,c+n)}}}ee(),I();function ee(){let e=r.length/3;if(l){let e=0,t=O*e;for(let e=0;e<k;e++){let n=T[e];ne(n[2]+t,n[1]+t,n[0]+t)}e=s+p*2,t=O*e;for(let e=0;e<k;e++){let n=T[e];ne(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<k;e++){let t=T[e];ne(t[2],t[1],t[0])}for(let e=0;e<k;e++){let t=T[e];ne(t[0]+O*s,t[1]+O*s,t[2]+O*s)}}n.addGroup(e,r.length/3-e,0)}function I(){let e=r.length/3,t=0;L(E,t),t+=E.length;for(let e=0,n=w.length;e<n;e++){let n=w[e];L(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}function L(e,t){let n=e.length;for(;--n>=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e<n;e++){let n=O*e,a=O*(e+1);R(t+r+n,t+i+n,t+i+a,t+r+a)}}}function te(e,t,n){a.push(e),a.push(t),a.push(n)}function ne(e,t,i){re(e),re(t),re(i);let a=r.length/3,o=h.generateTopUV(n,r,a-3,a-2,a-1);ie(o[0]),ie(o[1]),ie(o[2])}function R(e,t,i,a){re(e),re(t),re(a),re(t),re(i),re(a);let o=r.length/3,s=h.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);ie(s[0]),ie(s[1]),ie(s[3]),ie(s[1]),ie(s[2]),ie(s[3])}function re(e){r.push(a[e*3+0]),r.push(a[e*3+1]),r.push(a[e*3+2])}function ie(e){i.push(e.x),i.push(e.y)}}}toJSON(){let e=_l.prototype.toJSON.call(this),t=this.parameters.shapes,n=this.parameters.options;return Nf(t,n,e)}},Lv={generateTopUV:function(e,t,n,r,i){let a=t[n*3],o=t[n*3+1],s=t[r*3],c=t[r*3+1],l=t[i*3],u=t[i*3+1];return[new K(a,o),new K(s,c),new K(l,u)]},generateSideWallUV:function(e,t,n,r,i,a){let o=t[n*3],s=t[n*3+1],c=t[n*3+2],l=t[r*3],u=t[r*3+1],d=t[r*3+2],f=t[i*3],p=t[i*3+1],m=t[i*3+2],h=t[a*3],g=t[a*3+1],_=t[a*3+2];return Math.abs(s-u)<.01?[new K(o,1-c),new K(l,1-d),new K(f,1-m),new K(h,1-_)]:[new K(s,1-c),new K(u,1-d),new K(p,1-m),new K(g,1-_)]}},Rv=class extends Qd{constructor(e,t){super(),this.type=`ExtrudeGeometry`,this.parameters={shapes:e,options:t},this.fromBufferGeometry(new Iv(e,t)),this.mergeVertices()}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Pf(t,n,e)}},Ff.prototype=Object.create(_l.prototype),Ff.prototype.constructor=Ff,If.prototype=Object.create(Qd.prototype),If.prototype.constructor=If,zv=class extends _l{constructor(e,t=12){super(),this.type=`ShapeBufferGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new pl(r,3)),this.setAttribute(`normal`,new pl(i,3)),this.setAttribute(`uv`,new pl(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Fv.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Fv.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Fv.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}toJSON(){let e=_l.prototype.toJSON.call(this),t=this.parameters.shapes;return Lf(t,e)}},Bv=class extends Qd{constructor(e,t){super(),this.type=`ShapeGeometry`,typeof t==`object`&&(console.warn(`THREE.ShapeGeometry: Options parameter has been removed.`),t=t.curveSegments),this.parameters={shapes:e,curveSegments:t},this.fromBufferGeometry(new zv(e,t)),this.mergeVertices()}toJSON(){let e=Qd.prototype.toJSON.call(this),t=this.parameters.shapes;return Rf(t,e)}},zf.prototype=Object.create(nl.prototype),zf.prototype.constructor=zf,zf.prototype.isShadowMaterial=!0,zf.prototype.copy=function(e){return nl.prototype.copy.call(this,e),this.color.copy(e.color),this},Bf.prototype=Object.create(Cl.prototype),Bf.prototype.constructor=Bf,Bf.prototype.isRawShaderMaterial=!0,Vf.prototype=Object.create(nl.prototype),Vf.prototype.constructor=Vf,Vf.prototype.isMeshStandardMaterial=!0,Vf.prototype.copy=function(e){return nl.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.vertexTangents=e.vertexTangents,this},Hf.prototype=Object.create(Vf.prototype),Hf.prototype.constructor=Hf,Hf.prototype.isMeshPhysicalMaterial=!0,Hf.prototype.copy=function(e){return Vf.prototype.copy.call(this,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.reflectivity=e.reflectivity,e.sheen?this.sheen=(this.sheen||new Bg).copy(e.sheen):this.sheen=null,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this},Uf.prototype=Object.create(nl.prototype),Uf.prototype.constructor=Uf,Uf.prototype.isMeshPhongMaterial=!0,Uf.prototype.copy=function(e){return nl.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Wf.prototype=Object.create(nl.prototype),Wf.prototype.constructor=Wf,Wf.prototype.isMeshToonMaterial=!0,Wf.prototype.copy=function(e){return nl.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Gf.prototype=Object.create(nl.prototype),Gf.prototype.constructor=Gf,Gf.prototype.isMeshNormalMaterial=!0,Gf.prototype.copy=function(e){return nl.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Kf.prototype=Object.create(nl.prototype),Kf.prototype.constructor=Kf,Kf.prototype.isMeshLambertMaterial=!0,Kf.prototype.copy=function(e){return nl.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},qf.prototype=Object.create(nl.prototype),qf.prototype.constructor=qf,qf.prototype.isMeshMatcapMaterial=!0,qf.prototype.copy=function(e){return nl.prototype.copy.call(this,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.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Jf.prototype=Object.create(Vd.prototype),Jf.prototype.constructor=Jf,Jf.prototype.isLineDashedMaterial=!0,Jf.prototype.copy=function(e){return Vd.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this},Vv=Object.freeze({__proto__:null,ShadowMaterial:zf,SpriteMaterial:Nd,RawShaderMaterial:Bf,ShaderMaterial:Cl,PointsMaterial:Gd,MeshPhysicalMaterial:Hf,MeshStandardMaterial:Vf,MeshPhongMaterial:Uf,MeshToonMaterial:Wf,MeshNormalMaterial:Gf,MeshLambertMaterial:Kf,MeshDepthMaterial:_d,MeshDistanceMaterial:vd,MeshBasicMaterial:rl,MeshMatcapMaterial:qf,LineDashedMaterial:Jf,LineBasicMaterial:Vd,Material:nl}),Hv={arraySlice:function(e,t,n){return Hv.isTypedArray(e)?new e.constructor(e.subarray(t,n===void 0?e.length:n)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r},sortedArray:function(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i},flattenJSON:function(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0)if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push.apply(n,o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)},subclip:function(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e<a.tracks.length;++e){let t=a.tracks[e],s=t.getValueSize(),c=[],l=[];for(let e=0;e<t.times.length;++e){let a=t.times[e]*i;if(!(a<n||a>=r)){c.push(t.times[e]);for(let n=0;n<s;++n)l.push(t.values[e*s+n])}}c.length!==0&&(t.times=Hv.convertArray(c,t.times.constructor),t.values=Hv.convertArray(l,t.values.constructor),o.push(t))}a.tracks=o;let s=1/0;for(let e=0;e<a.tracks.length;++e)s>a.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*s);return a.resetDuration(),a},makeClipAdditive:function(e,t=0,n=e,r=30){r<=0&&(r=30);let i=n.tracks.length,a=t/r;for(let t=0;t<i;++t){let r=n.tracks[t],i=r.ValueTypeName;if(i===`bool`||i===`string`)continue;let o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===i});if(o===void 0)continue;let s=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=c/3);let l=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);let d=r.times.length-1,f;if(a<=r.times[0]){let e=s,t=c-s;f=Hv.arraySlice(r.values,e,t)}else if(a>=r.times[d]){let e=d*c+s,t=e+c-s;f=Hv.arraySlice(r.values,e,t)}else{let e=r.createInterpolant(),t=s,n=c-s;e.evaluate(a),f=Hv.arraySlice(e.resultBuffer,t,n)}i===`quaternion`&&new Th().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;e<p;++e){let t=e*u+l;if(i===`quaternion`)Th.multiplyQuaternionsFlat(o.values,t,f,0,o.values,t);else{let e=u-l*2;for(let n=0;n<e;++n)o.values[t+n]-=f[n]}}}return e.blendMode=rh,e}},Object.assign(Yf.prototype,{evaluate:function(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,e,i)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(r===void 0)return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,i,e)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t},interpolate_:function(){throw Error(`call to abstract method`)},intervalChanged_:function(){}}),Object.assign(Yf.prototype,{beforeStart_:Yf.prototype.copySampleValue_,afterEnd_:Yf.prototype.copySampleValue_}),Xf.prototype=Object.assign(Object.create(Yf.prototype),{constructor:Xf,DefaultSettings_:{endingStart:$m,endingEnd:$m},intervalChanged_:function(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case eh:i=e,o=2*t-n;break;case th:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case eh:a=e,s=2*n-t;break;case th:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l},interpolate_:function(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}}),Zf.prototype=Object.assign(Object.create(Yf.prototype),{constructor:Zf,interpolate_:function(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}}),Qf.prototype=Object.assign(Object.create(Yf.prototype),{constructor:Qf,interpolate_:function(e){return this.copySampleValue_(e-1)}}),Object.assign($f,{toJSON:function(e){let t=e.constructor,n;if(t.toJSON!==void 0)n=t.toJSON(e);else{n={name:e.name,times:Hv.convertArray(e.times,Array),values:Hv.convertArray(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}}),Object.assign($f.prototype,{constructor:$f,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:Zm,InterpolantFactoryMethodDiscrete:function(e){return new Qf(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new Zf(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new Xf(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){let t;switch(e){case Xm:t=this.InterpolantFactoryMethodDiscrete;break;case Zm:t=this.InterpolantFactoryMethodLinear;break;case Qm:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Xm;case this.InterpolantFactoryMethodLinear:return Zm;case this.InterpolantFactoryMethodSmooth:return Qm}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this},scale:function(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this},trim:function(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=Hv.arraySlice(n,i,a),this.values=Hv.arraySlice(this.values,i*e,a*e)}return this},validate:function(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Hv.isTypedArray(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e},optimize:function(){let e=Hv.arraySlice(this.times),t=Hv.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===Qm,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==s[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=Hv.arraySlice(e,0,a),this.values=Hv.arraySlice(t,0,a*n)),this},clone:function(){let e=Hv.arraySlice(this.times,0),t=Hv.arraySlice(this.values,0),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}),ep.prototype=Object.assign(Object.create($f.prototype),{constructor:ep,ValueTypeName:`bool`,ValueBufferType:Array,DefaultInterpolation:Xm,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),tp.prototype=Object.assign(Object.create($f.prototype),{constructor:tp,ValueTypeName:`color`}),np.prototype=Object.assign(Object.create($f.prototype),{constructor:np,ValueTypeName:`number`}),rp.prototype=Object.assign(Object.create(Yf.prototype),{constructor:rp,interpolate_:function(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Th.slerpFlat(i,0,a,c-o,a,c,s);return i}}),ip.prototype=Object.assign(Object.create($f.prototype),{constructor:ip,ValueTypeName:`quaternion`,DefaultInterpolation:Zm,InterpolantFactoryMethodLinear:function(e){return new rp(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),ap.prototype=Object.assign(Object.create($f.prototype),{constructor:ap,ValueTypeName:`string`,ValueBufferType:Array,DefaultInterpolation:Xm,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),op.prototype=Object.assign(Object.create($f.prototype),{constructor:op,ValueTypeName:`vector`}),Object.assign(sp,{parse:function(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(lp(n[e]).scale(r));let i=new sp(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i},toJSON:function(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push($f.toJSON(n[e]));return r},CreateFromMorphTargetSequence:function(e,t,n,r){let i=t.length,a=[];for(let e=0;e<i;e++){let o=[],s=[];o.push((e+i-1)%i,e,(e+1)%i),s.push(0,1,0);let c=Hv.getKeyframeOrder(o);o=Hv.sortedArray(o,1,c),s=Hv.sortedArray(s,1,c),!r&&o[0]===0&&(o.push(i),s.push(s[0])),a.push(new np(`.morphTargetInfluences[`+t[e].name+`]`,o,s).scale(1/n))}return new sp(e,-1,a)},findByName:function(e,t){let n=e;if(!Array.isArray(e)){let t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null},CreateClipsFromMorphTargetSequences:function(e,t,n){let r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){let n=e[t],a=n.name.match(i);if(a&&a.length>1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(sp.CreateFromMorphTargetSequence(e,r[e],t,n));return a},parseAnimation:function(e,t){if(!e)return console.error(`THREE.AnimationClip: No animation in JSONLoader data.`),null;let n=function(e,t,n,r,i){if(n.length!==0){let a=[],o=[];Hv.flattenJSON(n,a,o,r),a.length!==0&&i.push(new e(t,a,o))}},r=[],i=e.name||`default`,a=e.fps||30,o=e.blendMode,s=e.length||-1,c=e.hierarchy||[];for(let e=0;e<c.length;e++){let i=c[e].keys;if(!(!i||i.length===0))if(i[0].morphTargets){let e={},t;for(t=0;t<i.length;t++)if(i[t].morphTargets)for(let n=0;n<i[t].morphTargets.length;n++)e[i[t].morphTargets[n]]=-1;for(let n in e){let e=[],a=[];for(let r=0;r!==i[t].morphTargets.length;++r){let r=i[t];e.push(r.time),a.push(+(r.morphTarget===n))}r.push(new np(`.morphTargetInfluence[`+n+`]`,e,a))}s=e.length*(a||1)}else{let a=`.bones[`+t[e].name+`]`;n(op,a+`.position`,i,`pos`,r),n(ip,a+`.quaternion`,i,`rot`,r),n(op,a+`.scale`,i,`scl`,r)}}return r.length===0?null:new sp(i,s,r,o)}}),Object.assign(sp.prototype,{resetDuration:function(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let e=this.tracks[n];t=Math.max(t,e.times[e.times.length-1])}return this.duration=t,this},trim:function(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},validate:function(){let e=!0;for(let t=0;t<this.tracks.length;t++)e&&=this.tracks[t].validate();return e},optimize:function(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this},clone:function(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new sp(this.name,this.duration,e,this.blendMode)},toJSON:function(){return sp.toJSON(this)}}),Uv={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Wv=new up,Object.assign(dp.prototype,{load:function(){},loadAsync:function(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})},parse:function(){},setCrossOrigin:function(e){return this.crossOrigin=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}}),Gv={},fp.prototype=Object.assign(Object.create(dp.prototype),{constructor:fp,load:function(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=Uv.get(e);if(a!==void 0)return i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a;if(Gv[e]!==void 0){Gv[e].push({onLoad:t,onProgress:n,onError:r});return}let o=e.match(/^data:(.*?)(;base64)?,(.*)$/),s;if(o){let n=o[1],a=!!o[2],s=o[3];s=decodeURIComponent(s),a&&(s=atob(s));try{let r,a=(this.responseType||``).toLowerCase();switch(a){case`arraybuffer`:case`blob`:let e=new Uint8Array(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);r=a===`blob`?new Blob([e.buffer],{type:n}):e.buffer;break;case`document`:r=new DOMParser().parseFromString(s,n);break;case`json`:r=JSON.parse(s);break;default:r=s;break}setTimeout(function(){t&&t(r),i.manager.itemEnd(e)},0)}catch(t){setTimeout(function(){r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)},0)}}else{Gv[e]=[],Gv[e].push({onLoad:t,onProgress:n,onError:r}),s=new XMLHttpRequest,s.open(`GET`,e,!0),s.addEventListener(`load`,function(t){let n=this.response,r=Gv[e];if(delete Gv[e],this.status===200||this.status===0){this.status===0&&console.warn(`THREE.FileLoader: HTTP Status 0 received.`),Uv.add(e,n);for(let e=0,t=r.length;e<t;e++){let t=r[e];t.onLoad&&t.onLoad(n)}i.manager.itemEnd(e)}else{for(let e=0,n=r.length;e<n;e++){let n=r[e];n.onError&&n.onError(t)}i.manager.itemError(e),i.manager.itemEnd(e)}},!1),s.addEventListener(`progress`,function(t){let n=Gv[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onProgress&&r.onProgress(t)}},!1),s.addEventListener(`error`,function(t){let n=Gv[e];delete Gv[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onError&&r.onError(t)}i.manager.itemError(e),i.manager.itemEnd(e)},!1),s.addEventListener(`abort`,function(t){let n=Gv[e];delete Gv[e];for(let e=0,r=n.length;e<r;e++){let r=n[e];r.onError&&r.onError(t)}i.manager.itemError(e),i.manager.itemEnd(e)},!1),this.responseType!==void 0&&(s.responseType=this.responseType),this.withCredentials!==void 0&&(s.withCredentials=this.withCredentials),s.overrideMimeType&&s.overrideMimeType(this.mimeType===void 0?`text/plain`:this.mimeType);for(let e in this.requestHeader)s.setRequestHeader(e,this.requestHeader[e]);s.send(null)}return i.manager.itemStart(e),s},setResponseType:function(e){return this.responseType=e,this},setMimeType:function(e){return this.mimeType=e,this}}),pp.prototype=Object.assign(Object.create(dp.prototype),{constructor:pp,load:function(e,t,n,r){let i=this,a=new fp(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)},parse:function(e){let t=[];for(let n=0;n<e.length;n++){let r=sp.parse(e[n]);t.push(r)}return t}}),mp.prototype=Object.assign(Object.create(dp.prototype),{constructor:mp,load:function(e,t,n,r){let i=this,a=[],o=new Yd,s=new fp(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let c=0;function l(l){s.load(e[l],function(e){let n=i.parse(e,!0);a[l]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},c+=1,c===6&&(n.mipmapCount===1&&(o.minFilter=zm),o.image=a,o.format=n.format,o.needsUpdate=!0,t&&t(o))},n,r)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)l(t);else s.load(e,function(e){let n=i.parse(e,!0);if(n.isCubemap){let e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){a[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)a[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),a[t].format=n.format,a[t].width=n.width,a[t].height=n.height}o.image=a}else o.image.width=n.width,o.image.height=n.height,o.mipmaps=n.mipmaps;n.mipmapCount===1&&(o.minFilter=zm),o.format=n.format,o.needsUpdate=!0,t&&t(o)},n,r);return o}}),hp.prototype=Object.assign(Object.create(dp.prototype),{constructor:hp,load:function(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=Uv.get(e);if(a!==void 0)return i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a;let o=document.createElementNS(`http://www.w3.org/1999/xhtml`,`img`);function s(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1),Uv.add(e,this),t&&t(this),i.manager.itemEnd(e)}function c(t){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.substr(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(e),o.src=e,o}}),gp.prototype=Object.assign(Object.create(dp.prototype),{constructor:gp,load:function(e,t,n,r){let i=new Dl,a=new hp(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function s(n){a.load(e[n],function(e){i.images[n]=e,o++,o===6&&(i.needsUpdate=!0,t&&t(i))},void 0,r)}for(let t=0;t<e.length;++t)s(t);return i}}),_p.prototype=Object.assign(Object.create(dp.prototype),{constructor:_p,load:function(e,t,n,r){let i=this,a=new kl,o=new fp(this.manager);return o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(i.withCredentials),o.load(e,function(e){let n=i.parse(e);n&&(n.image===void 0?n.data!==void 0&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data):a.image=n.image,a.wrapS=n.wrapS===void 0?Pm:n.wrapS,a.wrapT=n.wrapT===void 0?Pm:n.wrapT,a.magFilter=n.magFilter===void 0?zm:n.magFilter,a.minFilter=n.minFilter===void 0?zm:n.minFilter,a.anisotropy=n.anisotropy===void 0?1:n.anisotropy,n.format!==void 0&&(a.format=n.format),n.type!==void 0&&(a.type=n.type),n.mipmaps!==void 0&&(a.mipmaps=n.mipmaps,a.minFilter=Vm),n.mipmapCount===1&&(a.minFilter=zm),a.needsUpdate=!0,t&&t(a,n))},n,r),a}}),vp.prototype=Object.assign(Object.create(dp.prototype),{constructor:vp,load:function(e,t,n,r){let i=new qc,a=new hp(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(n){i.image=n,i.format=e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?Gm:Km,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}}),Object.assign(yp.prototype,{getPoint:function(){return console.warn(`THREE.Curve: .getPoint() not implemented.`),null},getPointAt:function(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){let e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(e===void 0&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)},getTangent:function(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new K:new q);return s.copy(o).sub(a).normalize(),s},getTangentAt:function(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)},computeFrenetFrames:function(e,t){let n=new q,r=[],i=[],a=[],o=new q,s=new Zh;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new q),r[t].normalize()}i[0]=new q,a[0]=new q;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(yh.clamp(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(yh.clamp(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){let e={metadata:{version:4.5,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),bp.prototype=Object.create(yp.prototype),bp.prototype.constructor=bp,bp.prototype.isEllipseCurve=!0,bp.prototype.getPoint=function(e,t){let n=t||new K,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)},bp.prototype.copy=function(e){return yp.prototype.copy.call(this,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},bp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);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},bp.prototype.fromJSON=function(e){return yp.prototype.fromJSON.call(this,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},xp.prototype=Object.create(bp.prototype),xp.prototype.constructor=xp,xp.prototype.isArcCurve=!0,Kv=new q,qv=new Sp,Jv=new Sp,Yv=new Sp,Cp.prototype=Object.create(yp.prototype),Cp.prototype.constructor=Cp,Cp.prototype.isCatmullRomCurve3=!0,Cp.prototype.getPoint=function(e,t=new q){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Kv.subVectors(r[0],r[1]).add(r[0]),c=Kv);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Kv.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Kv),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),qv.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),Jv.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),Yv.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(qv.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),Jv.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),Yv.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(qv.calc(s),Jv.calc(s),Yv.calc(s)),n},Cp.prototype.copy=function(e){yp.prototype.copy.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},Cp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},Cp.prototype.fromJSON=function(e){yp.prototype.fromJSON.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new q().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},Pp.prototype=Object.create(yp.prototype),Pp.prototype.constructor=Pp,Pp.prototype.isCubicBezierCurve=!0,Pp.prototype.getPoint=function(e,t=new K){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Np(e,r.x,i.x,a.x,o.x),Np(e,r.y,i.y,a.y,o.y)),n},Pp.prototype.copy=function(e){return yp.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Pp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Pp.prototype.fromJSON=function(e){return yp.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},Fp.prototype=Object.create(yp.prototype),Fp.prototype.constructor=Fp,Fp.prototype.isCubicBezierCurve3=!0,Fp.prototype.getPoint=function(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Np(e,r.x,i.x,a.x,o.x),Np(e,r.y,i.y,a.y,o.y),Np(e,r.z,i.z,a.z,o.z)),n},Fp.prototype.copy=function(e){return yp.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Fp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Fp.prototype.fromJSON=function(e){return yp.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},Ip.prototype=Object.create(yp.prototype),Ip.prototype.constructor=Ip,Ip.prototype.isLineCurve=!0,Ip.prototype.getPoint=function(e,t=new K){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n},Ip.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Ip.prototype.getTangent=function(e,t){let n=t||new K;return n.copy(this.v2).sub(this.v1).normalize(),n},Ip.prototype.copy=function(e){return yp.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Ip.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Ip.prototype.fromJSON=function(e){return yp.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Lp.prototype=Object.create(yp.prototype),Lp.prototype.constructor=Lp,Lp.prototype.isLineCurve3=!0,Lp.prototype.getPoint=function(e,t=new q){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n},Lp.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Lp.prototype.copy=function(e){return yp.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Lp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Lp.prototype.fromJSON=function(e){return yp.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Rp.prototype=Object.create(yp.prototype),Rp.prototype.constructor=Rp,Rp.prototype.isQuadraticBezierCurve=!0,Rp.prototype.getPoint=function(e,t=new K){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Op(e,r.x,i.x,a.x),Op(e,r.y,i.y,a.y)),n},Rp.prototype.copy=function(e){return yp.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Rp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Rp.prototype.fromJSON=function(e){return yp.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},zp.prototype=Object.create(yp.prototype),zp.prototype.constructor=zp,zp.prototype.isQuadraticBezierCurve3=!0,zp.prototype.getPoint=function(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Op(e,r.x,i.x,a.x),Op(e,r.y,i.y,a.y),Op(e,r.z,i.z,a.z)),n},zp.prototype.copy=function(e){return yp.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},zp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},zp.prototype.fromJSON=function(e){return yp.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Bp.prototype=Object.create(yp.prototype),Bp.prototype.constructor=Bp,Bp.prototype.isSplineCurve=!0,Bp.prototype.getPoint=function(e,t=new K){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(wp(o,s.x,c.x,l.x,u.x),wp(o,s.y,c.y,l.y,u.y)),n},Bp.prototype.copy=function(e){yp.prototype.copy.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this},Bp.prototype.toJSON=function(){let e=yp.prototype.toJSON.call(this);e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e},Bp.prototype.fromJSON=function(e){yp.prototype.fromJSON.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new K().fromArray(n))}return this},Xv=Object.freeze({__proto__:null,ArcCurve:xp,CatmullRomCurve3:Cp,CubicBezierCurve:Pp,CubicBezierCurve3:Fp,EllipseCurve:bp,LineCurve:Ip,LineCurve3:Lp,QuadraticBezierCurve:Rp,QuadraticBezierCurve3:zp,SplineCurve:Bp}),Vp.prototype=Object.assign(Object.create(yp.prototype),{constructor:Vp,add:function(e){this.curves.push(e)},closePath:function(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Ip(t,e))},getPoint:function(e){let t=e*this.getLength(),n=this.getCurveLengths(),r=0;for(;r<n.length;){if(n[r]>=t){let e=n[r]-t,i=this.curves[r],a=i.getLength(),o=a===0?0:1-e/a;return i.getPointAt(o)}r++}return null},getLength:function(){let e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e},getSpacedPoints:function(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t},getPoints:function(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a&&a.isEllipseCurve?e*2:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t},copy:function(e){yp.prototype.copy.call(this,e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this},toJSON:function(){let e=yp.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e},fromJSON:function(e){yp.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new Xv[n.type]().fromJSON(n))}return this}}),Hp.prototype=Object.assign(Object.create(Vp.prototype),{constructor:Hp,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this},moveTo:function(e,t){return this.currentPoint.set(e,t),this},lineTo:function(e,t){let n=new Ip(this.currentPoint.clone(),new K(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this},quadraticCurveTo:function(e,t,n,r){let i=new Rp(this.currentPoint.clone(),new K(e,t),new K(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this},bezierCurveTo:function(e,t,n,r,i,a){let o=new Pp(this.currentPoint.clone(),new K(e,t),new K(n,r),new K(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this},splineThru:function(e){let t=new Bp([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this},arc:function(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this},absarc:function(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this},ellipse:function(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this},absellipse:function(e,t,n,r,i,a,o,s){let c=new bp(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this},copy:function(e){return Vp.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){let e=Vp.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return Vp.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),Up.prototype=Object.assign(Object.create(Hp.prototype),{constructor:Up,getPointsHoles:function(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){Hp.prototype.copy.call(this,e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this},toJSON:function(){let e=Hp.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e},fromJSON:function(e){Hp.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new Hp().fromJSON(n))}return this}}),Wp.prototype=Object.assign(Object.create(Qc.prototype),{constructor:Wp,isLight:!0,copy:function(e){return Qc.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){let t=Qc.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}),Gp.prototype=Object.assign(Object.create(Wp.prototype),{constructor:Gp,isHemisphereLight:!0,copy:function(e){return Wp.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(Kp.prototype,{_projScreenMatrix:new Zh,_lightPositionWorld:new q,_lookTarget:new q,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){let t=this.camera,n=this.matrix,r=this._projScreenMatrix,i=this._lookTarget,a=this._lightPositionWorld;a.setFromMatrixPosition(e.matrixWorld),t.position.copy(a),i.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(i),t.updateMatrixWorld(),r.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),qp.prototype=Object.assign(Object.create(Kp.prototype),{constructor:qp,isSpotLightShadow:!0,updateMatrices:function(e){let t=this.camera,n=yh.RAD2DEG*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;(n!==t.fov||r!==t.aspect||i!==t.far)&&(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),Kp.prototype.updateMatrices.call(this,e)}}),Jp.prototype=Object.assign(Object.create(Wp.prototype),{constructor:Jp,isSpotLight:!0,copy:function(e){return Wp.prototype.copy.call(this,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}}),Yp.prototype=Object.assign(Object.create(Kp.prototype),{constructor:Yp,isPointLightShadow:!0,updateMatrices:function(e,t=0){let n=this.camera,r=this.matrix,i=this._lightPositionWorld,a=this._lookTarget,o=this._projScreenMatrix;i.setFromMatrixPosition(e.matrixWorld),n.position.copy(i),a.copy(n.position),a.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(a),n.updateMatrixWorld(),r.makeTranslation(-i.x,-i.y,-i.z),o.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(o)}}),Xp.prototype=Object.assign(Object.create(Wp.prototype),{constructor:Xp,isPointLight:!0,copy:function(e){return Wp.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),Zp.prototype=Object.assign(Object.create(wl.prototype),{constructor:Zp,isOrthographicCamera:!0,copy:function(e,t){return wl.prototype.copy.call(this,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=e.view===null?null:Object.assign({},e.view),this},setViewOffset:function(e,t,n,r,i,a){this.view===null&&(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=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){let t=Qc.prototype.toJSON.call(this,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,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}),Qp.prototype=Object.assign(Object.create(Kp.prototype),{constructor:Qp,isDirectionalLightShadow:!0,updateMatrices:function(e){Kp.prototype.updateMatrices.call(this,e)}}),$p.prototype=Object.assign(Object.create(Wp.prototype),{constructor:$p,isDirectionalLight:!0,copy:function(e){return Wp.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),em.prototype=Object.assign(Object.create(Wp.prototype),{constructor:em,isAmbientLight:!0}),tm.prototype=Object.assign(Object.create(Wp.prototype),{constructor:tm,isRectAreaLight:!0,copy:function(e){return Wp.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){let t=Wp.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}}),Zv=class{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new q)}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){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*r*1.092548),t.addScaledVector(a[5],r*i*1.092548),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],n*i*1.092548),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*i),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],2*.429043*n*i),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],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){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}},nm.prototype=Object.assign(Object.create(Wp.prototype),{constructor:nm,isLightProbe:!0,copy:function(e){return Wp.prototype.copy.call(this,e),this.sh.copy(e.sh),this},fromJSON:function(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this},toJSON:function(e){let t=Wp.prototype.toJSON.call(this,e);return t.object.sh=this.sh.toArray(),t}}),rm.prototype=Object.assign(Object.create(dp.prototype),{constructor:rm,load:function(e,t,n,r){let i=this,a=new fp(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)},parse:function(e){let t=this.textures;function n(e){return t[e]===void 0&&console.warn(`THREE.MaterialLoader: Undefined texture`,e),t[e]}let r=new Vv[e.type];if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=new Bg().setHex(e.sheen)),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==1&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.skinning!==void 0&&(r.skinning=e.skinning),e.morphTargets!==void 0&&(r.morphTargets=e.morphTargets),e.morphNormals!==void 0&&(r.morphNormals=e.morphNormals),e.dithering!==void 0&&(r.dithering=e.dithering),e.vertexTangents!==void 0&&(r.vertexTangents=e.vertexTangents),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors==`number`?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let t in e.uniforms){let i=e.uniforms[t];switch(r.uniforms[t]={},i.type){case`t`:r.uniforms[t].value=n(i.value);break;case`c`:r.uniforms[t].value=new Bg().setHex(i.value);break;case`v2`:r.uniforms[t].value=new K().fromArray(i.value);break;case`v3`:r.uniforms[t].value=new q().fromArray(i.value);break;case`v4`:r.uniforms[t].value=new wh().fromArray(i.value);break;case`m3`:r.uniforms[t].value=new bh().fromArray(i.value);break;case`m4`:r.uniforms[t].value=new Zh().fromArray(i.value);break;default:r.uniforms[t].value=i.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(let t in e.extensions)r.extensions[t]=e.extensions[t];if(e.shading!==void 0&&(r.flatShading=e.shading===1),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),r.normalScale=new K().fromArray(t)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new K().fromArray(e.clearcoatNormalScale)),e.transmission!==void 0&&(r.transmission=e.transmission),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),r},setTextures:function(e){return this.textures=e,this}}),Qv={decodeText:function(e){if(typeof TextDecoder<`u`)return new TextDecoder().decode(e);let t=``;for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}},extractUrlBase:function(e){let t=e.lastIndexOf(`/`);return t===-1?`./`:e.substr(0,t+1)}},im.prototype=Object.assign(Object.create(_l.prototype),{constructor:im,isInstancedBufferGeometry:!0,copy:function(e){return _l.prototype.copy.call(this,e),this.instanceCount=e.instanceCount,this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){let e=_l.prototype.toJSON.call(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}),am.prototype=Object.assign(Object.create(il.prototype),{constructor:am,isInstancedBufferAttribute:!0,copy:function(e){return il.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},toJSON:function(){let e=il.prototype.toJSON.call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}),om.prototype=Object.assign(Object.create(dp.prototype),{constructor:om,load:function(e,t,n,r){let i=this,a=new fp(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)},parse:function(e){let t={},n={};function r(e,n){if(t[n]!==void 0)return t[n];let r=e.interleavedBuffers[n],a=i(e,r.buffer),o=new jd(gl(r.type,a),r.stride);return o.uuid=r.uuid,t[n]=o,o}function i(e,t){if(n[t]!==void 0)return n[t];let r=e.arrayBuffers[t],i=new Uint32Array(r).buffer;return n[t]=i,i}let a=e.isInstancedBufferGeometry?new im:new _l,o=e.data.index;if(o!==void 0){let e=gl(o.type,o.array);a.setIndex(new il(e,1))}let s=e.data.attributes;for(let t in s){let n=s[t],i;if(n.isInterleavedBufferAttribute)i=new Md(r(e.data,n.data),n.itemSize,n.offset,n.normalized);else{let e=gl(n.type,n.array);i=new(n.isInstancedBufferAttribute?am:il)(e,n.itemSize,n.normalized)}n.name!==void 0&&(i.name=n.name),a.setAttribute(t,i)}let c=e.data.morphAttributes;if(c)for(let t in c){let n=c[t],i=[];for(let t=0,a=n.length;t<a;t++){let a=n[t],o;o=a.isInterleavedBufferAttribute?new Md(r(e.data,a.data),a.itemSize,a.offset,a.normalized):new il(gl(a.type,a.array),a.itemSize,a.normalized),a.name!==void 0&&(o.name=a.name),i.push(o)}a.morphAttributes[t]=i}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(l!==void 0)for(let e=0,t=l.length;e!==t;++e){let t=l[e];a.addGroup(t.start,t.count,t.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let e=new q;u.center!==void 0&&e.fromArray(u.center),a.boundingSphere=new Hh(e,u.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}),sm.prototype=Object.assign(Object.create(dp.prototype),{constructor:sm,isImageBitmapLoader:!0,setOptions:function(e){return this.options=e,this},load:function(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=Uv.get(e);if(a!==void 0)return i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a;let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,i.options)}).then(function(n){Uv.add(e,n),t&&t(n),i.manager.itemEnd(e)}).catch(function(t){r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}),i.manager.itemStart(e)}}),Object.assign(cm.prototype,{moveTo:function(e,t){return this.currentPath=new Hp,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this},lineTo:function(e,t){return this.currentPath.lineTo(e,t),this},quadraticCurveTo:function(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this},bezierCurveTo:function(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,t){function n(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n],i=new Up;i.curves=r.curves,t.push(i)}return t}function r(e,t){let n=t.length,r=!1;for(let i=n-1,a=0;a<n;i=a++){let n=t[i],o=t[a],s=o.x-n.x,c=o.y-n.y;if(Math.abs(c)>2**-52){if(c<0&&(n=t[a],s=-s,o=t[i],c=-c),e.y<n.y||e.y>o.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=c*(e.x-n.x)-s*(e.y-n.y);if(t===0)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return r}let i=Fv.isClockWise,a=this.subPaths;if(a.length===0)return[];if(t===!0)return n(a);let o,s,c,l=[];if(a.length===1)return s=a[0],c=new Up,c.curves=s.curves,l.push(c),l;let u=!i(a[0].getPoints());u=e?!u:u;let d=[],f=[],p=[],m=0,h;f[m]=void 0,p[m]=[];for(let t=0,n=a.length;t<n;t++)s=a[t],h=s.getPoints(),o=i(h),o=e?!o:o,o?(!u&&f[m]&&m++,f[m]={s:new Up,p:h},f[m].s.curves=s.curves,u&&m++,p[m]=[]):p[m].push({h:s,p:h[0]});if(!f[0])return n(a);if(f.length>1){let e=!1,t=[];for(let e=0,t=f.length;e<t;e++)d[e]=[];for(let n=0,i=f.length;n<i;n++){let i=p[n];for(let a=0;a<i.length;a++){let o=i[a],s=!0;for(let i=0;i<f.length;i++)r(o.p,f[i].p)&&(n!==i&&t.push({froms:n,tos:i,hole:a}),s?(s=!1,d[i].push(o)):e=!0);s&&d[n].push(o)}}t.length>0&&(e||(p=d))}let g;for(let e=0,t=f.length;e<t;e++){c=f[e].s,l.push(c),g=p[e];for(let e=0,t=g.length;e<t;e++)c.holes.push(g[e].h)}return l}}),Object.assign(lm.prototype,{isFont:!0,generateShapes:function(e,t=100){let n=[],r=um(e,t,this.data);for(let e=0,t=r.length;e<t;e++)Array.prototype.push.apply(n,r[e].toShapes());return n}}),fm.prototype=Object.assign(Object.create(dp.prototype),{constructor:fm,load:function(e,t,n,r){let i=this,a=new fp(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(e){let n;try{n=JSON.parse(e)}catch{console.warn(`THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead.`),n=JSON.parse(e.substring(65,e.length-2))}let r=i.parse(n);t&&t(r)},n,r)},parse:function(e){return new lm(e)}}),ey={getContext:function(){return $v===void 0&&($v=new(window.AudioContext||window.webkitAudioContext)),$v},setContext:function(e){$v=e}},pm.prototype=Object.assign(Object.create(dp.prototype),{constructor:pm,load:function(e,t,n,r){let i=this,a=new fp(i.manager);a.setResponseType(`arraybuffer`),a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{let e=n.slice(0);ey.getContext().decodeAudioData(e,function(e){t(e)})}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}}),mm.prototype=Object.assign(Object.create(nm.prototype),{constructor:mm,isHemisphereLightProbe:!0,copy:function(e){return nm.prototype.copy.call(this,e),this},toJSON:function(e){return nm.prototype.toJSON.call(this,e)}}),hm.prototype=Object.assign(Object.create(nm.prototype),{constructor:hm,isAmbientLightProbe:!0,copy:function(e){return nm.prototype.copy.call(this,e),this},toJSON:function(e){return nm.prototype.toJSON.call(this,e)}}),ty=new Zh,ny=new Zh,Object.assign(gm.prototype,{update:function(e){let 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;let n=e.projectionMatrix.clone(),r=t.eyeSep/2,i=r*t.near/t.focus,a=t.near*Math.tan(yh.DEG2RAD*t.fov*.5)/t.zoom,o,s;ny.elements[12]=-r,ty.elements[12]=r,o=-a*t.aspect+i,s=a*t.aspect+i,n.elements[0]=2*t.near/(s-o),n.elements[8]=(s+o)/(s-o),this.cameraL.projectionMatrix.copy(n),o=-a*t.aspect-i,s=a*t.aspect-i,n.elements[0]=2*t.near/(s-o),n.elements[8]=(s+o)/(s-o),this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(ny),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(ty)}}),ry=class extends Qc{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(this.isPlaying===!0){console.warn(`THREE.Audio: Audio is already playing.`);return}if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}this._startedAt=this.context.currentTime+e;let 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(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress%=this.duration||this.buffer.duration),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}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||=[],this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&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(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn(`THREE.Audio: this Audio has no playback control.`),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn(`THREE.Audio: this Audio has no playback control.`);return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}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}},iy=class{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,t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}},Object.assign(_m.prototype,{accumulate:function(e,t){let n=this.buffer,r=this.valueSize,i=e*r+r,a=this.cumulativeWeight;if(a===0){for(let e=0;e!==r;++e)n[i+e]=n[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=a},accumulateAdditive:function(e){let t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e},apply:function(e){let t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){let e=t*this._origIndex;this._mixBufferRegion(n,r,e,1-i,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}},saveOriginalState:function(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)},_setAdditiveIdentityNumeric:function(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]},_select:function(e,t,n,r,i){if(r>=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]},_slerp:function(e,t,n,r){Th.slerpFlat(e,t,e,t,e,n,r)},_slerpAdditive:function(e,t,n,r,i){let a=this._workIndex*i;Th.multiplyQuaternionsFlat(e,a,e,t,e,n),Th.slerpFlat(e,t,e,t,e,a,r)},_lerp:function(e,t,n,r,i){let a=1-r;for(let o=0;o!==i;++o){let i=t+o;e[i]=e[i]*a+e[n+o]*r}},_lerpAdditive:function(e,t,n,r,i){for(let a=0;a!==i;++a){let i=t+a;e[i]=e[i]+e[n+a]*r}}}),ay=`\\[\\]\\.:\\/`,oy=RegExp(`[\\[\\]\\.:\\/]`,`g`),sy=`[^\\[\\]\\.:\\/]`,cy=`[^`+ay.replace(`\\.`,``)+`]`,ly=`((?:WC+[\\/:])*)`.replace(`WC`,sy),uy=`(WCOD+)?`.replace(`WCOD`,cy),dy=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,sy),fy=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,sy),py=RegExp(`^`+ly+uy+dy+fy+`$`),my=[`material`,`materials`,`bones`],Object.assign(vm.prototype,{getValue:function(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)},setValue:function(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)},bind:function(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()},unbind:function(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}),Object.assign(ym,{Composite:vm,create:function(e,t,n){return e&&e.isAnimationObjectGroup?new ym.Composite(e,t,n):new ym(e,t,n)},sanitizeNodeName:function(e){return e.replace(/\s/g,`_`).replace(oy,``)},parseTrackName:function(e){let t=py.exec(e);if(!t)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);my.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n},findNode:function(e,t){if(!t||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}}),Object.assign(ym.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,t){e[t]=this.node[this.propertyName]},function(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]},function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]},function(e,t){this.resolvedProperty.toArray(e,t)}],SetterByBindingTypeAndVersioning:[[function(e,t){this.targetObject[this.propertyName]=e[t]},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]},function(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0},function(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty.fromArray(e,t)},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){let e=this.node,t=this.parsedPath,n=t.objectName,r=t.propertyName,i=t.propertyIndex;if(e||(e=ym.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error(`THREE.PropertyBinding: Trying to update node for track: `+this.path+` but it wasn't found.`);return}if(n){let r=t.objectIndex;switch(n){case`materials`:if(!e.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!e.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}e=e.material.materials;break;case`bones`:if(!e.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===r){r=t;break}break;default:if(e[n]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}e=e[n]}if(r!==void 0){if(e[r]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,e);return}e=e[r]}}let a=e[r];if(a===void 0){let n=t.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+n+`.`+r+` but it wasn't found.`,e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate===void 0?e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate):o=this.Versioning.NeedsUpdate;let s=this.BindingType.Direct;if(i!==void 0){if(r===`morphTargetInfluences`){if(!e.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}e.morphTargetDictionary[i]!==void 0&&(i=e.morphTargetDictionary[i])}else{console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.`,this);return}}s=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=i}else a.fromArray!==void 0&&a.toArray!==void 0?(s=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(s=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][o]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(ym.prototype,{_getValue_unbound:ym.prototype.getValue,_setValue_unbound:ym.prototype.setValue}),Object.assign(bm.prototype,{isAnimationObjectGroup:!0,add:function(){let e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,a=i.length,o,s=e.length,c=this.nCachedObjects_;for(let l=0,u=arguments.length;l!==u;++l){let u=arguments[l],d=u.uuid,f=t[d];if(f===void 0){f=s++,t[d]=f,e.push(u);for(let e=0,t=a;e!==t;++e)i[e].push(new ym(u,n[e],r[e]))}else if(f<c){o=e[f];let s=--c,l=e[s];t[l.uuid]=f,e[f]=l,t[d]=s,e[s]=u;for(let e=0,t=a;e!==t;++e){let t=i[e],a=t[s],o=t[f];t[f]=a,o===void 0&&(o=new ym(u,n[e],r[e])),t[s]=o}}else e[f]!==o&&console.error(`THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.`)}this.nCachedObjects_=c},remove:function(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){let o=arguments[a],s=o.uuid,c=t[s];if(c!==void 0&&c>=i){let a=i++,l=e[a];t[l.uuid]=c,e[c]=l,t[s]=a,e[a]=o;for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[a],i=t[c];t[c]=r,t[a]=i}}}this.nCachedObjects_=i},uncache:function(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){let s=arguments[o].uuid,c=t[s];if(c!==void 0)if(delete t[s],c<i){let o=--i,s=e[o],l=--a,u=e[l];t[s.uuid]=c,e[c]=s,t[u.uuid]=o,e[o]=u,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e],r=t[o],i=t[l];t[c]=r,t[o]=i,t.pop()}}else{let i=--a,o=e[i];i>0&&(t[o.uuid]=c),e[c]=o,e.pop();for(let e=0,t=r;e!==t;++e){let t=n[e];t[c]=t[i],t.pop()}}}this.nCachedObjects_=i},subscribe_:function(e,t){let n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(r!==void 0)return i[r];let a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=Array(c);r=i.length,n[e]=r,a.push(e),o.push(t),i.push(u);for(let n=l,r=s.length;n!==r;++n){let r=s[n];u[n]=new ym(r,e,t)}return u},unsubscribe_:function(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],c=e[o];t[c]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}}),hy=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let i=t.tracks,a=i.length,o=Array(a),s={endingStart:$m,endingEnd:$m};for(let e=0;e!==a;++e){let t=i[e].createInterpolant(null);o[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Jm,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&&this.timeScale!==0&&this._startTime===null&&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,n){if(e.fadeOut(t),this.fadeIn(t),n){let n=this._clip.duration,r=e._clip.duration,i=r/n,a=n/r;e.warp(1,i,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(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,n){let r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let s=o.parameterPositions,c=o.sampleValues;return s[0]=i,s[1]=i+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(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,n,r){if(!this.enabled){this._updateWeight(e);return}let i=this._startTime;if(i!==null){let r=(e-i)*n;if(r<0||n===0)return;this._startTime=null,t=n*r}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case rh:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case nh:default:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===Ym;if(e===0)return i===-1?r:a&&(i&1)==1?t-r:r;if(n===2200){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));handle_stop:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break handle_stop}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e<0?-1:1})}}else{if(i===-1&&(e>=0?(i=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);let o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:`finished`,action:this,direction:e>0?1:-1});else{if(o===1){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:`loop`,action:this,loopDelta:n})}}else this.time=r;if(a&&(i&1)==1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=eh,r.endingEnd=eh):(e?r.endingStart=this.zeroSlopeAtStart?eh:$m:r.endingStart=th,t?r.endingEnd=this.zeroSlopeAtEnd?eh:$m:r.endingEnd=th)}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}},xm.prototype=Object.assign(Object.create(Kc.prototype),{constructor:xm,_bindAction:function(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];l===void 0&&(l={},c[s]=l);for(let e=0;e!==i;++e){let i=r[e],c=i.name,u=l[c];if(u!==void 0)a[e]=u;else{if(u=a[e],u!==void 0){u._cacheIndex===null&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new _m(ym.create(n,c,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let 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:function(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions},_addInactiveAction:function(e,t,n){let r=this._actions,i=this._actionsByClip,a=i[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=a;else{let t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e},_removeInactiveAction:function(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let i=e._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,c=s[s.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,s[l]=c,s.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],s.length===0&&delete a[i],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];--n.referenceCount===0&&this._removeInactiveBinding(n)}},_lendAction:function(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i},_takeBackAction:function(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i},_addInactiveBinding:function(e,t,n){let r=this._bindingsByRootAndName,i=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=i.length,i.push(e)},_removeInactiveBinding:function(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],c=e._cacheIndex;s._cacheIndex=c,t[c]=s,t.pop(),delete o[i],Object.keys(o).length===0&&delete a[r]},_lendBinding:function(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i},_takeBackBinding:function(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i},_lendControlInterpolant:function(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new Zf(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=t,e[t]=n),n},_takeBackControlInterpolant:function(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t,n){let r=t||this._root,i=r.uuid,a=typeof e==`string`?sp.findByName(r,e):e,o=a===null?e:a.uuid,s=this._actionsByClip[o],c=null;if(n===void 0&&(n=a===null?nh:a.blendMode),s!==void 0){let e=s.actionByRoot[i];if(e!==void 0&&e.blendMode===n)return e;c=s.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;let l=new hy(this,a,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,i),l},existingAction:function(e,t){let n=t||this._root,r=n.uuid,i=typeof e==`string`?sp.findByName(n,e):e,a=i?i.uuid:e,o=this._actionsByClip[a];return o===void 0?null:o.actionByRoot[r]||null},stopAllAction:function(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this},update:function(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(r,e,i,a);let o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this},setTime:function(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)},getRoot:function(){return this._root},uncacheClip:function(e){let t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(i!==void 0){let e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){let r=e[n];this._deactivateAction(r);let i=r._cacheIndex,a=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,a._cacheIndex=i,t[i]=a,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}},uncacheRoot:function(e){let t=e.uuid,n=this._actionsByClip;for(let e in n){let r=n[e].actionByRoot[t];r!==void 0&&(this._deactivateAction(r),this._removeInactiveAction(r))}let r=this._bindingsByRootAndName[t];if(r!==void 0)for(let e in r){let t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}},uncacheAction:function(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}),gy=class e{constructor(e){typeof e==`string`&&(console.warn(`THREE.Uniform: Type parameter is no longer needed.`),e=arguments[1]),this.value=e}clone(){return new e(this.value.clone===void 0?this.value:this.value.clone())}},Sm.prototype=Object.assign(Object.create(jd.prototype),{constructor:Sm,isInstancedInterleavedBuffer:!0,copy:function(e){return jd.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},clone:function(e){let t=jd.prototype.clone.call(this,e);return t.meshPerAttribute=this.meshPerAttribute,t},toJSON:function(e){let t=jd.prototype.toJSON.call(this,e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}),Object.defineProperty(Cm.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(Cm.prototype,{isGLBufferAttribute:!0,setBuffer:function(e){return this.buffer=e,this},setType:function(e,t){return this.type=e,this.elementSize=t,this},setItemSize:function(e){return this.itemSize=e,this},setCount:function(e){return this.count=e,this}}),Object.assign(wm.prototype,{set:function(e,t){this.ray.set(e,t)},setFromCamera:function(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:function(e,t,n){let r=n||[];return Em(e,this,r,t),r.sort(Tm),r},intersectObjects:function(e,t,n){let r=n||[];if(Array.isArray(e)===!1)return console.warn(`THREE.Raycaster.intersectObjects: objects is not an Array.`),r;for(let n=0,i=e.length;n<i;n++)Em(e[n],this,r,t);return r.sort(Tm),r}}),_y=new K,vy=class{constructor(e,t){Object.defineProperty(this,"isBox2",{value:!0}),this.min=e===void 0?new K(1/0,1/0):e,this.max=t===void 0?new K(-1/0,-1/0):t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=_y.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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 e===void 0&&(console.warn(`THREE.Box2: .getCenter() target is now required`),e=new K),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return e===void 0&&(console.warn(`THREE.Box2: .getSize() target is now required`),e=new K),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===void 0&&(console.warn(`THREE.Box2: .getParameter() target is now required`),t=new K),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===void 0&&(console.warn(`THREE.Box2: .clampPoint() target is now required`),t=new K),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _y.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)}},yy=new q,by=new q,xy=class{constructor(e,t){this.start=e===void 0?new q:e,this.end=t===void 0?new q:t}set(e,t){return this.start.copy(e),this.end.copy(t),this}clone(){return new this.constructor().copy(this)}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e===void 0&&(console.warn(`THREE.Line3: .getCenter() target is now required`),e=new q),e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e===void 0&&(console.warn(`THREE.Line3: .delta() target is now required`),e=new q),e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return t===void 0&&(console.warn(`THREE.Line3: .at() target is now required`),t=new q),this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){yy.subVectors(e,this.start),by.subVectors(this.end,this.start);let n=by.dot(by),r=by.dot(yy)/n;return t&&(r=yh.clamp(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return n===void 0&&(console.warn(`THREE.Line3: .closestPointToPoint() target is now required`),n=new q),this.delta(n).multiplyScalar(r).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)}},Dm.prototype=Object.create(Qc.prototype),Dm.prototype.constructor=Dm,Dm.prototype.isImmediateRenderObject=!0,Sy=new q,Cy=new Zh,wy=new Zh,Ty=class extends Ud{constructor(e){let t=Om(e),n=new _l,r=[],i=[],a=new Bg(0,0,1),o=new Bg(0,1,0);for(let e=0;e<t.length;e++){let n=t[e];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(a.r,a.g,a.b),i.push(o.r,o.g,o.b))}n.setAttribute(`position`,new pl(r,3)),n.setAttribute(`color`,new pl(i,3));let s=new Vd({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,s),this.type=`SkeletonHelper`,this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,n=this.geometry,r=n.getAttribute(`position`);wy.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){let i=t[e];i.parent&&i.parent.isBone&&(Cy.multiplyMatrices(wy,i.matrixWorld),Sy.setFromMatrixPosition(Cy),r.setXYZ(n,Sy.x,Sy.y,Sy.z),Cy.multiplyMatrices(wy,i.parent.matrixWorld),Sy.setFromMatrixPosition(Cy),r.setXYZ(n+1,Sy.x,Sy.y,Sy.z),n+=2)}n.getAttribute(`position`).needsUpdate=!0,super.updateMatrixWorld(e)}},Ey=class extends Ud{constructor(e=10,t=10,n=4473924,r=8947848){n=new Bg(n),r=new Bg(r);let i=t/2,a=e/t,o=e/2,s=[],c=[];for(let e=0,l=0,u=-o;e<=t;e++,u+=a){s.push(-o,0,u,o,0,u),s.push(u,0,-o,u,0,o);let t=e===i?n:r;t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3}let l=new _l;l.setAttribute(`position`,new pl(s,3)),l.setAttribute(`color`,new pl(c,3));let u=new Vd({vertexColors:!0,toneMapped:!1});super(l,u),this.type=`GridHelper`}},Dy=new Float32Array(1),new Int32Array(Dy.buffer),Oy=4,ky=8,Ay=[.125,.215,.35,.446,.526,.582],jy=5+Ay.length,{_lodPlanes:eee,_sizeLods:My,_sigmas:Ny}=km(),Py=(1+Math.sqrt(5))/2,Fy=1/Py,-Fy,-Fy,-Py,yp.create=function(e,t){return console.log(`THREE.Curve.create() has been deprecated`),e.prototype=Object.create(yp.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(Vp.prototype,{createPointsGeometry:function(e){console.warn(`THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.`);let t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn(`THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.`);let t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn(`THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.`);let t=new Qd;for(let n=0,r=e.length;n<r;n++){let r=e[n];t.vertices.push(new q(r.x,r.y,r.z||0))}return t}}),Object.assign(Hp.prototype,{fromPoints:function(e){return console.warn(`THREE.Path: .fromPoints() has been renamed to .setFromPoints().`),this.setFromPoints(e)}}),Am.prototype=Object.create(Cp.prototype),jm.prototype=Object.create(Cp.prototype),Mm.prototype=Object.create(Cp.prototype),Object.assign(Mm.prototype,{initFromArray:function(){console.error(`THREE.Spline: .initFromArray() has been removed.`)},getControlPointsArray:function(){console.error(`THREE.Spline: .getControlPointsArray() has been removed.`)},reparametrizeByArcLength:function(){console.error(`THREE.Spline: .reparametrizeByArcLength() has been removed.`)}}),Ey.prototype.setColors=function(){console.error(`THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.`)},Ty.prototype.update=function(){console.error(`THREE.SkeletonHelper: update() no longer needs to be called.`)},Object.assign(dp.prototype,{extractUrlBase:function(e){return console.warn(`THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.`),Qv.extractUrlBase(e)}}),dp.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.`)}},Object.assign(vy.prototype,{center:function(e){return console.warn(`THREE.Box2: .center() has been renamed to .getCenter().`),this.getCenter(e)},empty:function(){return console.warn(`THREE.Box2: .empty() has been renamed to .isEmpty().`),this.isEmpty()},isIntersectionBox:function(e){return console.warn(`THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().`),this.intersectsBox(e)},size:function(e){return console.warn(`THREE.Box2: .size() has been renamed to .getSize().`),this.getSize(e)}}),Object.assign(Oh.prototype,{center:function(e){return console.warn(`THREE.Box3: .center() has been renamed to .getCenter().`),this.getCenter(e)},empty:function(){return console.warn(`THREE.Box3: .empty() has been renamed to .isEmpty().`),this.isEmpty()},isIntersectionBox:function(e){return console.warn(`THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().`),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn(`THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().`),this.intersectsSphere(e)},size:function(e){return console.warn(`THREE.Box3: .size() has been renamed to .getSize().`),this.getSize(e)}}),Object.assign(Hh.prototype,{empty:function(){return console.warn(`THREE.Sphere: .empty() has been renamed to .isEmpty().`),this.isEmpty()}}),w_.prototype.setFromMatrix=function(e){return console.warn(`THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().`),this.setFromProjectionMatrix(e)},xy.prototype.center=function(e){return console.warn(`THREE.Line3: .center() has been renamed to .getCenter().`),this.getCenter(e)},Object.assign(yh,{random16:function(){return console.warn(`THREE.Math: .random16() has been deprecated. Use Math.random() instead.`),Math.random()},nearestPowerOfTwo:function(e){return console.warn(`THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().`),yh.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn(`THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().`),yh.ceilPowerOfTwo(e)}}),Object.assign(bh.prototype,{flattenToArrayOffset:function(e,t){return console.warn(`THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.`),this.toArray(e,t)},multiplyVector3:function(e){return console.warn(`THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.`),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error(`THREE.Matrix3: .multiplyVector3Array() has been removed.`)},applyToBufferAttribute:function(e){return console.warn(`THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.`),e.applyMatrix3(this)},applyToVector3Array:function(){console.error(`THREE.Matrix3: .applyToVector3Array() has been removed.`)},getInverse:function(e){return console.warn(`THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.`),this.copy(e).invert()}}),Object.assign(Zh.prototype,{extractPosition:function(e){return console.warn(`THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().`),this.copyPosition(e)},flattenToArrayOffset:function(e,t){return console.warn(`THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.`),this.toArray(e,t)},getPosition:function(){return console.warn(`THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.`),new q().setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(e){return console.warn(`THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().`),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn(`THREE.Matrix4: .multiplyToArray() has been removed.`)},multiplyVector3:function(e){return console.warn(`THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.`),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn(`THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.`),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error(`THREE.Matrix4: .multiplyVector3Array() has been removed.`)},rotateAxis:function(e){console.warn(`THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.`),e.transformDirection(this)},crossVector:function(e){return console.warn(`THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.`),e.applyMatrix4(this)},translate:function(){console.error(`THREE.Matrix4: .translate() has been removed.`)},rotateX:function(){console.error(`THREE.Matrix4: .rotateX() has been removed.`)},rotateY:function(){console.error(`THREE.Matrix4: .rotateY() has been removed.`)},rotateZ:function(){console.error(`THREE.Matrix4: .rotateZ() has been removed.`)},rotateByAxis:function(){console.error(`THREE.Matrix4: .rotateByAxis() has been removed.`)},applyToBufferAttribute:function(e){return console.warn(`THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.`),e.applyMatrix4(this)},applyToVector3Array:function(){console.error(`THREE.Matrix4: .applyToVector3Array() has been removed.`)},makeFrustum:function(e,t,n,r,i,a){return console.warn(`THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.`),this.makePerspective(e,t,r,n,i,a)},getInverse:function(e){return console.warn(`THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.`),this.copy(e).invert()}}),Tg.prototype.isIntersectionLine=function(e){return console.warn(`THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().`),this.intersectsLine(e)},Object.assign(Th.prototype,{multiplyVector3:function(e){return console.warn(`THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.`),e.applyQuaternion(this)},inverse:function(){return console.warn(`THREE.Quaternion: .inverse() has been renamed to invert().`),this.invert()}}),Object.assign(Xh.prototype,{isIntersectionBox:function(e){return console.warn(`THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().`),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn(`THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().`),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn(`THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().`),this.intersectsSphere(e)}}),Object.assign(Ig.prototype,{area:function(){return console.warn(`THREE.Triangle: .area() has been renamed to .getArea().`),this.getArea()},barycoordFromPoint:function(e,t){return console.warn(`THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().`),this.getBarycoord(e,t)},midpoint:function(e){return console.warn(`THREE.Triangle: .midpoint() has been renamed to .getMidpoint().`),this.getMidpoint(e)},normal:function(e){return console.warn(`THREE.Triangle: .normal() has been renamed to .getNormal().`),this.getNormal(e)},plane:function(e){return console.warn(`THREE.Triangle: .plane() has been renamed to .getPlane().`),this.getPlane(e)}}),Object.assign(Ig,{barycoordFromPoint:function(e,t,n,r,i){return console.warn(`THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().`),Ig.getBarycoord(e,t,n,r,i)},normal:function(e,t,n,r){return console.warn(`THREE.Triangle: .normal() has been renamed to .getNormal().`),Ig.getNormal(e,t,n,r)}}),Object.assign(Up.prototype,{extractAllPoints:function(e){return console.warn(`THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.`),this.extractPoints(e)},extrude:function(e){return console.warn(`THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.`),new Rv(this,e)},makeGeometry:function(e){return console.warn(`THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.`),new Bv(this,e)}}),Object.assign(K.prototype,{fromAttribute:function(e,t,n){return console.warn(`THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().`),this.fromBufferAttribute(e,t,n)},distanceToManhattan:function(e){return console.warn(`THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().`),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn(`THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().`),this.manhattanLength()}}),Object.assign(q.prototype,{setEulerFromRotationMatrix:function(){console.error(`THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.`)},setEulerFromQuaternion:function(){console.error(`THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.`)},getPositionFromMatrix:function(e){return console.warn(`THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().`),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn(`THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().`),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn(`THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().`),this.setFromMatrixColumn(t,e)},applyProjection:function(e){return console.warn(`THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.`),this.applyMatrix4(e)},fromAttribute:function(e,t,n){return console.warn(`THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().`),this.fromBufferAttribute(e,t,n)},distanceToManhattan:function(e){return console.warn(`THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().`),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn(`THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().`),this.manhattanLength()}}),Object.assign(wh.prototype,{fromAttribute:function(e,t,n){return console.warn(`THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().`),this.fromBufferAttribute(e,t,n)},lengthManhattan:function(){return console.warn(`THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().`),this.manhattanLength()}}),Object.assign(Qd.prototype,{computeTangents:function(){console.error(`THREE.Geometry: .computeTangents() has been removed.`)},computeLineDistances:function(){console.error(`THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.`)},applyMatrix:function(e){return console.warn(`THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().`),this.applyMatrix4(e)}}),Object.assign(Qc.prototype,{getChildByName:function(e){return console.warn(`THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().`),this.getObjectByName(e)},renderDepth:function(){console.warn(`THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.`)},translate:function(e,t){return console.warn(`THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.`),this.translateOnAxis(t,e)},getWorldRotation:function(){console.error(`THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.`)},applyMatrix:function(e){return console.warn(`THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().`),this.applyMatrix4(e)}}),Object.defineProperties(Qc.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.`)}}}),Object.assign(vl.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(vl.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.`)}}}),Object.defineProperties(Id.prototype,{objects:{get:function(){return console.warn(`THREE.LOD: .objects has been renamed to .levels.`),this.levels}}}),Object.defineProperty(zd.prototype,"useVertexTexture",{get:function(){console.warn(`THREE.Skeleton: useVertexTexture has been removed.`)},set:function(){console.warn(`THREE.Skeleton: useVertexTexture has been removed.`)}}),Ld.prototype.initBones=function(){console.error(`THREE.SkinnedMesh: initBones() has been removed.`)},Object.defineProperty(yp.prototype,"__arcLengthDivisions",{get:function(){return console.warn(`THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.`),this.arcLengthDivisions},set:function(e){console.warn(`THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.`),this.arcLengthDivisions=e}}),Tl.prototype.setLens=function(e,t){console.warn(`THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.`),t!==void 0&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Wp.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(il.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===gh},set:function(){console.warn(`THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.`),this.setUsage(gh)}}}),Object.assign(il.prototype,{setDynamic:function(e){return console.warn(`THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.`),this.setUsage(e===!0?gh:hh),this},copyIndicesArray:function(){console.error(`THREE.BufferAttribute: .copyIndicesArray() has been removed.`)},setArray:function(){console.error(`THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers`)}}),Object.assign(_l.prototype,{addIndex:function(e){console.warn(`THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().`),this.setIndex(e)},addAttribute:function(e,t){return console.warn(`THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().`),!(t&&t.isBufferAttribute)&&!(t&&t.isInterleavedBufferAttribute)?(console.warn(`THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).`),this.setAttribute(e,new il(arguments[1],arguments[2]))):e===`index`?(console.warn(`THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.`),this.setIndex(t),this):this.setAttribute(e,t)},addDrawCall:function(e,t,n){n!==void 0&&console.warn(`THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.`),console.warn(`THREE.BufferGeometry: .addDrawCall() is now .addGroup().`),this.addGroup(e,t)},clearDrawCalls:function(){console.warn(`THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().`),this.clearGroups()},computeTangents:function(){console.warn(`THREE.BufferGeometry: .computeTangents() has been removed.`)},computeOffsets:function(){console.warn(`THREE.BufferGeometry: .computeOffsets() has been removed.`)},removeAttribute:function(e){return console.warn(`THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().`),this.deleteAttribute(e)},applyMatrix:function(e){return console.warn(`THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().`),this.applyMatrix4(e)}}),Object.defineProperties(_l.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}}}),Object.defineProperties(im.prototype,{maxInstancedCount:{get:function(){return console.warn(`THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.`),this.instanceCount},set:function(e){console.warn(`THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.`),this.instanceCount=e}}}),Object.defineProperties(wm.prototype,{linePrecision:{get:function(){return console.warn(`THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.`),this.params.Line.threshold},set:function(e){console.warn(`THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.`),this.params.Line.threshold=e}}}),Object.defineProperties(jd.prototype,{dynamic:{get:function(){return console.warn(`THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.`),this.usage===gh},set:function(e){console.warn(`THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.`),this.setUsage(e)}}}),Object.assign(jd.prototype,{setDynamic:function(e){return console.warn(`THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.`),this.setUsage(e===!0?gh:hh),this},setArray:function(){console.error(`THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers`)}}),Object.assign(Iv.prototype,{getArrays:function(){console.error(`THREE.ExtrudeBufferGeometry: .getArrays() has been removed.`)},addShapeList:function(){console.error(`THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.`)},addShape:function(){console.error(`THREE.ExtrudeBufferGeometry: .addShape() has been removed.`)}}),Object.assign(G_.prototype,{dispose:function(){console.error(`THREE.Scene: .dispose() has been removed.`)}}),Object.defineProperties(gy.prototype,{dynamic:{set:function(){console.warn(`THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.`)}},onUpdate:{value:function(){return console.warn(`THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.`),this}}}),Object.defineProperties(nl.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 Bg}},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=e===1}},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}}}),Object.defineProperties(Uf.prototype,{metal:{get:function(){return console.warn(`THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.`),!1},set:function(){console.warn(`THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead`)}}}),Object.defineProperties(Hf.prototype,{transparency:{get:function(){return console.warn(`THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission.`),this.transmission},set:function(e){console.warn(`THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission.`),this.transmission=e}}}),Object.defineProperties(Cl.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}}}),Object.assign(kd.prototype,{clearTarget:function(e,t,n,r){console.warn(`THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.`),this.setRenderTarget(e),this.clear(t,n,r)},animate:function(e){console.warn(`THREE.WebGLRenderer: .animate() is now .setAnimationLoop().`),this.setAnimationLoop(e)},getCurrentRenderTarget:function(){return console.warn(`THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().`),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn(`THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().`),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn(`THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.`),this.capabilities.precision},resetGLState:function(){return console.warn(`THREE.WebGLRenderer: .resetGLState() is now .state.reset().`),this.state.reset()},supportsFloatTextures:function(){return console.warn(`THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).`),this.extensions.get(`OES_texture_float`)},supportsHalfFloatTextures:function(){return console.warn(`THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).`),this.extensions.get(`OES_texture_half_float`)},supportsStandardDerivatives:function(){return console.warn(`THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).`),this.extensions.get(`OES_standard_derivatives`)},supportsCompressedTextureS3TC:function(){return console.warn(`THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).`),this.extensions.get(`WEBGL_compressed_texture_s3tc`)},supportsCompressedTexturePVRTC:function(){return console.warn(`THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).`),this.extensions.get(`WEBGL_compressed_texture_pvrtc`)},supportsBlendMinMax:function(){return console.warn(`THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).`),this.extensions.get(`EXT_blend_minmax`)},supportsVertexTextures:function(){return console.warn(`THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.`),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn(`THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).`),this.extensions.get(`ANGLE_instanced_arrays`)},enableScissorTest:function(e){console.warn(`THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().`),this.setScissorTest(e)},initMaterial:function(){console.warn(`THREE.WebGLRenderer: .initMaterial() has been removed.`)},addPrePlugin:function(){console.warn(`THREE.WebGLRenderer: .addPrePlugin() has been removed.`)},addPostPlugin:function(){console.warn(`THREE.WebGLRenderer: .addPostPlugin() has been removed.`)},updateShadowMap:function(){console.warn(`THREE.WebGLRenderer: .updateShadowMap() has been removed.`)},setFaceCulling:function(){console.warn(`THREE.WebGLRenderer: .setFaceCulling() has been removed.`)},allocTextureUnit:function(){console.warn(`THREE.WebGLRenderer: .allocTextureUnit() has been removed.`)},setTexture:function(){console.warn(`THREE.WebGLRenderer: .setTexture() has been removed.`)},setTexture2D:function(){console.warn(`THREE.WebGLRenderer: .setTexture2D() has been removed.`)},setTextureCube:function(){console.warn(`THREE.WebGLRenderer: .setTextureCube() has been removed.`)},getActiveMipMapLevel:function(){return console.warn(`THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().`),this.getActiveMipmapLevel()}}),Object.defineProperties(kd.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=e===!0?ah:ih}},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(yd.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(Yc.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}}}),Object.defineProperties(ry.prototype,{load:{value:function(e){console.warn(`THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.`);let t=this;return new pm().load(e,function(e){t.setBuffer(e)}),this}},startTime:{set:function(){console.warn(`THREE.Audio: .startTime is now .play( delay ).`)}}}),iy.prototype.getData=function(){return console.warn(`THREE.AudioAnalyser: .getData() is now .getFrequencyData().`),this.getFrequencyData()},El.prototype.updateCubeMap=function(e,t){return console.warn(`THREE.CubeCamera: .updateCubeMap() is now .update().`),this.update(e,t)},El.prototype.clear=function(e,t,n,r){return console.warn(`THREE.CubeCamera: .clear() is now .renderTarget.clear().`),this.renderTarget.clear(e,t,n,r)},Sh.crossOrigin=void 0,Sh.loadTexture=function(e,t,n,r){console.warn(`THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.`);let i=new vp;i.setCrossOrigin(this.crossOrigin);let a=i.load(e,n,void 0,r);return t&&(a.mapping=t),a},Sh.loadTextureCube=function(e,t,n,r){console.warn(`THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.`);let i=new gp;i.setCrossOrigin(this.crossOrigin);let a=i.load(e,n,void 0,r);return t&&(a.mapping=t),a},Sh.loadCompressedTexture=function(){console.error(`THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.`)},Sh.loadCompressedTextureCube=function(){console.error(`THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.`)},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`124`}}))}));function Ly(e,t){if(!e)throw Error(t||`loader assertion failed.`)}var Ry=o((()=>{})),zy,By,Vy,Hy=o((()=>{zy={self:typeof self<`u`&&self,window:typeof window<`u`&&window,global:typeof global<`u`&&global,document:typeof document<`u`&&document},zy.self||zy.window||zy.global,zy.window||zy.self||zy.global,zy.global||zy.self||zy.window,zy.document,By=!!(typeof process!=`object`||String(process)!==`[object process]`||process.browser),Vy=typeof process<`u`&&process.version&&/v([0-9]*)/.exec(process.version),Vy&&parseFloat(Vy[1])})),Uy,Wy,Gy,Ky=o((()=>{Uy=globalThis,globalThis.document,Wy=globalThis.process||{},globalThis.console,Gy=globalThis.navigator||{}}));function qy(e){if(typeof window<`u`&&window.process?.type===`renderer`||typeof process<`u`&&process.versions?.electron)return!0;let t=typeof navigator<`u`&&navigator.userAgent,n=e||t;return!!(n&&n.indexOf(`Electron`)>=0)}var Jy=o((()=>{}));function Yy(){return!(typeof process==`object`&&String(process)===`[object process]`&&!process?.browser)||qy()}var Xy=o((()=>{Jy()}));function Zy(e){return!e&&!Yy()?`Node`:qy(e)?`Electron`:(e||Gy.userAgent||``).indexOf(`Edge`)>-1?`Edge`:globalThis.chrome?`Chrome`:globalThis.safari?`Safari`:globalThis.mozInnerScreenX?`Firefox`:`Unknown`}var tee=o((()=>{Xy(),Jy(),Ky()})),Qy,$y=o((()=>{Ky(),Xy(),tee(),Jy(),Qy=`4.1.1`}));function eb(e,t){if(!e)throw Error(t||`Assertion failed`)}var tb=o((()=>{}));function nb(e){if(!e)return 0;let t;switch(typeof e){case`number`:t=e;break;case`object`:t=e.logLevel||e.priority||0;break;default:return 0}return eb(Number.isFinite(t)&&t>=0),t}function nee(e){let{logLevel:t,message:n}=e;e.logLevel=nb(t);let r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case`string`:case`function`:n!==void 0&&r.unshift(n),e.message=t;break;case`object`:Object.assign(e,t);break;default:}typeof e.message==`function`&&(e.message=e.message());let i=typeof e.message;return eb(i===`string`||i===`object`),Object.assign(e,{args:r},e.opts)}var rb=o((()=>{tb()})),ib,ab,ob=o((()=>{rb(),ib=()=>{},ab=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log(`warn`,0,e,t,{once:!0})}error(e,...t){return this._log(`error`,0,e,t)}log(e,t,...n){return this._log(`log`,e,t,n)}info(e,t,...n){return this._log(`info`,e,t,n)}once(e,t,...n){return this._log(`once`,e,t,n,{once:!0})}_log(e,t,n,r,i={}){let a=nee({logLevel:t,message:n,args:this._buildArgs(t,n,r),opts:i});return this._createLogFunction(e,a,i)}_buildArgs(e,t,n){return[e,t,...n]}_createLogFunction(e,t,n){if(!this._shouldLog(t.logLevel))return ib;let r=this._getOnceTag(n.tag??t.tag??t.message);if((n.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return ib;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=nb(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e==`string`?e:String(e)}catch{return}}}}));function ree(e){try{let t=window[e],n=`__storage_test__`;return t.setItem(n,n),t.removeItem(n),t}catch{return null}}var sb,cb=o((()=>{sb=class{constructor(e,t,n=`sessionStorage`){this.storage=ree(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}}));function lb(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}function ub(e,t=8){let n=Math.max(t-e.length,0);return`${` `.repeat(n)}${e}`}var db=o((()=>{}));function fb(e){return typeof e==`string`?(e=e.toUpperCase(),mb[e]||mb.WHITE):e}function pb(e,t,n){return!Yy&&typeof e==`string`&&(t&&(e=`\u001b[${fb(t)}m${e}\u001b[39m`),n&&(e=`\u001b[${fb(n)+hb}m${e}\u001b[49m`)),e}var mb,hb,gb=o((()=>{$y(),(function(e){e[e.BLACK=30]=`BLACK`,e[e.RED=31]=`RED`,e[e.GREEN=32]=`GREEN`,e[e.YELLOW=33]=`YELLOW`,e[e.BLUE=34]=`BLUE`,e[e.MAGENTA=35]=`MAGENTA`,e[e.CYAN=36]=`CYAN`,e[e.WHITE=37]=`WHITE`,e[e.BRIGHT_BLACK=90]=`BRIGHT_BLACK`,e[e.BRIGHT_RED=91]=`BRIGHT_RED`,e[e.BRIGHT_GREEN=92]=`BRIGHT_GREEN`,e[e.BRIGHT_YELLOW=93]=`BRIGHT_YELLOW`,e[e.BRIGHT_BLUE=94]=`BRIGHT_BLUE`,e[e.BRIGHT_MAGENTA=95]=`BRIGHT_MAGENTA`,e[e.BRIGHT_CYAN=96]=`BRIGHT_CYAN`,e[e.BRIGHT_WHITE=97]=`BRIGHT_WHITE`})(mb||={}),hb=10}));function _b(e,t=[`constructor`]){let n=Object.getOwnPropertyNames(Object.getPrototypeOf(e)),r=e;for(let i of n){let n=r[i];typeof n==`function`&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}var vb=o((()=>{}));function yb(){let e;if(Yy()&&Uy.performance)e=Uy?.performance?.now?.();else if(`hrtime`in Wy){let t=Wy?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var bb=o((()=>{$y()}));function xb(e,t,n){if(typeof t==`string`){let r=n.time?ub(lb(n.total)):``;t=n.time?`${e}: ${r} ${t}`:`${e}: ${t}`,t=pb(t,n.color,n.background)}return t}function Sb(e){for(let t in e)for(let n in e[t])return n||`untitled`;return`empty`}var Cb,wb,Tb,Eb=o((()=>{$y(),ob(),cb(),db(),gb(),vb(),tb(),bb(),rb(),Cb={debug:Yy()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},wb={enabled:!0,level:0},Tb=class extends ab{constructor({id:e}={id:``}){super({level:0}),this.VERSION=Qy,this._startTs=yb(),this._deltaTs=yb(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new sb(`__probe-${this.id}__`,{[this.id]:wb}),this.timeStamp(`${this.id} started`),_b(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((yb()-this._startTs).toPrecision(10))}getDelta(){return Number((yb()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw Error(t||`Assertion failed`)}warn(e,...t){return this._log(`warn`,0,e,t,{method:Cb.warn,once:!0})}error(e,...t){return this._log(`error`,0,e,t,{method:Cb.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed \
|
||
in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...n){return this._log(`log`,e,t,n,{method:Cb.log,time:!0,once:!0})}log(e,t,...n){return this._log(`log`,e,t,n,{method:Cb.debug})}info(e,t,...n){return this._log(`info`,e,t,n,{method:console.info})}once(e,t,...n){return this._log(`once`,e,t,n,{method:Cb.debug||Cb.info,once:!0})}table(e,t,n){return t?this._log(`table`,e,t,n&&[n]||[],{method:console.table||ib,tag:Sb(t)}):ib}time(e,t){return this._log(`time`,e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log(`time`,e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log(`time`,e,t,[],{method:console.timeStamp||ib})}group(e,t,n={collapsed:!1}){let r=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log(`group`,e,t,[],{method:r})}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log(`groupEnd`,e,``,[],{method:console.groupEnd||ib})}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let n=t.method;eb(n),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=yb();let r=xb(this.id,t.message,t);return n.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(wb),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...wb};this._storage.setConfiguration({[this.id]:{...t,...e}})}},Tb.VERSION=Qy})),Db=o((()=>{globalThis.probe={}})),Ob=o((()=>{Eb(),ob(),gb(),db(),vb(),cb(),bb(),Db(),new Tb({id:`@probe.gl/log`})}));function kb(){let e=new Tb({id:`loaders.gl`});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=jb,globalThis.probe||={},globalThis.probe.loaders=e,e}var Ab,jb,Mb,Nb=o((()=>{Ob(),Ab=`4.4.2`,jb=`v${Ab}`,Mb=kb()})),Pb,Fb,Ib,Lb,Rb,zb,Bb,Vb,Hb,Ub,Wb,Gb,Kb,qb=o((()=>{Pb=e=>typeof e==`boolean`,Fb=e=>typeof e==`function`,Ib=e=>typeof e==`object`&&!!e,Lb=e=>Ib(e)&&e.constructor==={}.constructor,Rb=e=>typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,zb=e=>Ib(e)&&typeof e.byteLength==`number`&&typeof e.slice==`function`,Bb=e=>!!e&&Fb(e[Symbol.iterator]),Vb=e=>!!e&&Fb(e[Symbol.asyncIterator]),Hb=e=>typeof Response<`u`&&e instanceof Response||Ib(e)&&Fb(e.arrayBuffer)&&Fb(e.text)&&Fb(e.json),Ub=e=>typeof Blob<`u`&&e instanceof Blob,Wb=e=>typeof ReadableStream<`u`&&e instanceof ReadableStream||Ib(e)&&Fb(e.tee)&&Fb(e.cancel)&&Fb(e.getReader),Gb=e=>Ib(e)&&Fb(e.read)&&Fb(e.pipe)&&Pb(e.readable),Kb=e=>Wb(e)||Gb(e)}));function iee(e,t){return Jb(e||{},t)}function Jb(e,t,n=0){if(n>3)return t;let r={...e};for(let[e,i]of Object.entries(t))i&&typeof i==`object`&&!Array.isArray(i)?r[e]=Jb(r[e]||{},t[e],n+1):r[e]=t[e];return r}var aee=o((()=>{})),Yb,oee=o((()=>{Yb=`latest`}));function see(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version=`4.4.2`),globalThis._loadersgl_.version}var Xb,Zb=o((()=>{Xb=see()}));function Qb(e,t){if(!e)throw Error(t||`loaders.gl assertion failed.`)}var $b=o((()=>{})),ex,tx,nx,rx,ix=o((()=>{ex={self:typeof self<`u`&&self,window:typeof window<`u`&&window,global:typeof global<`u`&&global,document:typeof document<`u`&&document},ex.self||ex.window||ex.global,ex.window||ex.self||ex.global,ex.global||ex.self||ex.window,ex.document,tx=typeof process!=`object`||String(process)!==`[object process]`||process.browser,nx=typeof window<`u`&&window.orientation!==void 0,rx=typeof process<`u`&&process.version&&/v([0-9]*)/.exec(process.version),rx&&parseFloat(rx[1])})),ax,ox=o((()=>{$b(),ax=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:`loaders.gl`,type:e,payload:t})}done(e){Qb(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Qb(this.isRunning),this.isRunning=!1,this._reject(e)}}})),sx,cx=o((()=>{sx=class{terminate(){}}}));function lx(e){Qb(e.source&&!e.url||!e.source&&e.url);let t=px.get(e.source||e.url);return t||(e.url&&(t=ux(e.url),px.set(e.url,t)),e.source&&(t=dx(e.source),px.set(e.source,t))),Qb(t),t}function ux(e){return e.startsWith(`http`)?dx(fx(e)):e}function dx(e){let t=new Blob([e],{type:`application/javascript`});return URL.createObjectURL(t)}function fx(e){return`\
|
||
try {
|
||
importScripts('${e}');
|
||
} catch (error) {
|
||
console.error(error);
|
||
throw error;
|
||
}`}var px,mx=o((()=>{$b(),px=new Map}));function hx(e,t=!0,n){let r=n||new Set;if(e){if(gx(e))r.add(e);else if(gx(e.buffer))r.add(e.buffer);else if(!ArrayBuffer.isView(e)&&t&&typeof e==`object`)for(let n in e)hx(e[n],t,r)}return n===void 0?Array.from(r):[]}function gx(e){return e?e instanceof ArrayBuffer||typeof MessagePort<`u`&&e instanceof MessagePort||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas:!1}var _x=o((()=>{})),vx,yx,bx=o((()=>{cx(),ix(),$b(),mx(),_x(),vx=()=>{},yx=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL=``;static isSupported(){return typeof Worker<`u`&&tx||sx!==void 0&&!tx}constructor(e){let{name:t,source:n,url:r}=e;Qb(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=vx,this.onError=e=>console.log(e),this.worker=tx?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=vx,this.onError=vx,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t||=hx(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t=`Failed to load `;return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),Error(t)}_createBrowserWorker(){this._loadableURL=lx({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(Error(`No data received`))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url)e=new sx(this.url.includes(`:/`)||this.url.startsWith(`/`)?this.url:`./${this.url}`,{eval:!1,type:this.url.endsWith(`.ts`)||this.url.endsWith(`.mjs`)?`module`:`commonjs`});else if(this.source)e=new sx(this.source,{eval:!0});else throw Error(`no worker`);return e.on(`message`,e=>{this.onMessage(e)}),e.on(`error`,e=>{this.onError(e)}),e.on(`exit`,e=>{}),e}}})),xx,Sx=o((()=>{ix(),bx(),ox(),xx=class{name=`unnamed`;source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return yx.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){let r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:`Starting job`,name:t.name,workerThread:e,backlog:this.jobQueue.length});let n=new ax(t.name,e);e.onMessage=e=>t.onMessage(n,e.type,e.payload),e.onError=e=>t.onError(n,e),t.onStart(n);try{await n.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!tx||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){return this.idleQueue.length>0?this.idleQueue.shift()||null:this.count<this._getMaxConcurrency()?(this.count++,new yx({name:`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`,source:this.source,url:this.url})):null}_getMaxConcurrency(){return nx?this.maxMobileConcurrency:this.maxConcurrency}}})),Cx,wx,Tx=o((()=>{Sx(),bx(),Cx={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},wx=class e{props;workerPools=new Map;static _workerFarm;static isSupported(){return yx.isSupported()}static getWorkerFarm(t={}){return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}constructor(e){this.props={...Cx},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:n,url:r}=e,i=this.workerPools.get(t);return i||(i=new xx({name:t,source:n,url:r}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}}));function Ex(e,t={}){let n=t[e.id]||{},r=tx?`${e.id}-worker.js`:`${e.id}-worker-node.js`,i=n.workerUrl;if(!i&&e.id===`compression`&&(i=t.workerUrl),(t._workerType||t?.core?._workerType)===`test`&&(i=tx?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let t=e.version;t===`latest`&&(t=Yb);let n=t?`@${t}`:``;i=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return Qb(i),i}var Dx=o((()=>{$b(),ix(),oee()}));function Ox(e,t=Xb){Qb(e,`no worker provided`);let n=e.version;return!(!t||!n)}var kx=o((()=>{$b(),Zb()})),Ax=o((()=>{$b(),ix(),ox(),bx(),Tx(),Sx(),_x(),cx(),Dx(),kx(),Zb()}));function jx(e,t){if(!wx.isSupported())return!1;let n=t?._nodeWorkers??t?.core?._nodeWorkers;if(!tx&&!n)return!1;let r=t?.worker??t?.core?.worker;return!!(e.worker&&r)}async function Mx(e,t,n,r,i){let a=e.id,o=Ex(e,n),s=wx.getWorkerFarm(n?.core).getWorkerPool({name:a,url:o});n=JSON.parse(JSON.stringify(n)),r=JSON.parse(JSON.stringify(r||{}));let c=await s.startJob(`process-on-worker`,Nx.bind(null,i));return c.postMessage(`process`,{input:t,options:n,context:r}),await(await c.result).result}async function Nx(e,t,n,r){switch(n){case`done`:t.done(r);break;case`error`:t.error(Error(r.error));break;case`process`:let{id:i,input:a,options:o}=r;try{let n=await e(a,o);t.postMessage(`done`,{id:i,result:n})}catch(e){let n=e instanceof Error?e.message:`unknown error`;t.postMessage(`error`,{id:i,error:n})}break;default:console.warn(`parse-with-worker unknown message ${n}`)}}var Px=o((()=>{Ax()}));function Fx(e,t,n){if(n||=e.byteLength,e.byteLength<n||t.byteLength<n)return!1;let r=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<r.length;++e)if(r[e]!==i[e])return!1;return!0}function Ix(...e){return Lx(e)}function Lx(e){let t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;return r.buffer}var Rx=o((()=>{}));async function zx(e){let t=[];for await(let n of e)t.push(Bx(n));return Ix(...t)}function Bx(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){let{buffer:t,byteOffset:n,byteLength:r}=e;return Vx(t,n,r)}return Vx(e)}function Vx(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}var Hx=o((()=>{Rx()}));function Ux(){let e;if(typeof window<`u`&&window.performance)e=window.performance.now();else if(typeof process<`u`&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Wx=o((()=>{})),Gx,Kx=o((()=>{Wx(),Gx=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Ux(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Ux()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}})),qx,Jx=o((()=>{Kx(),qx=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t=`count`){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){let{name:t,type:n}=e,r=this.stats[t];return r||(r=e instanceof Gx?e:new Gx(t,n),this.stats[t]=r),r}}})),Yx=o((()=>{Jx(),Kx(),Wx()}));function Xx(e){for(let t in Qx)if(e.startsWith(t)){let n=Qx[t];e=e.replace(t,n)}return!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&(e=`${Zx}${e}`),e}var Zx,Qx,$x=o((()=>{Zx=``,Qx={}}));function eS(e){return e}var tS=o((()=>{}));function nS(e){return e&&typeof e==`object`&&e.isBuffer}function rS(e){if(nS(e))return eS(e);if(e instanceof ArrayBuffer)return e;if(Rb(e))return aS(e);if(ArrayBuffer.isView(e)){let t=e.buffer;return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(typeof e==`string`){let t=e;return new TextEncoder().encode(t).buffer}if(e&&typeof e==`object`&&e._toArrayBuffer)return e._toArrayBuffer();throw Error(`toArrayBuffer`)}function iS(e){if(e instanceof ArrayBuffer)return e;if(Rb(e))return aS(e);let{buffer:t,byteOffset:n,byteLength:r}=e;return t instanceof ArrayBuffer&&n===0&&r===t.byteLength?t:aS(t,n,r)}function aS(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function oS(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}var sS=o((()=>{qb(),tS()}));function cS(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(t+1):e}function lS(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(0,t):``}var uS=o((()=>{})),dS=o((()=>{Ry(),Hy(),Nb(),qb(),aee(),Ax(),Px(),Rx(),Hx(),Yx(),$x(),sS(),uS()})),fS,pS=o((()=>{fS=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}}));function mS(e,t){return e.toLowerCase()===t.toLowerCase()}function cee(e){let t=_S.exec(e);return t?t[1]:e}function hS(e){let t=gS.exec(e);return t?t[1]:``}var gS,_S,vS=o((()=>{gS=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,_S=/^([-\w.]+\/[-\w.+]+)/}));function lee(e){let t=e.match(bS);return t&&t[0]}function yS(e){return e.replace(bS,``)}function uee(e){if(e.length<50)return e;let t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}var bS,xS=o((()=>{bS=/\?.*/}));function SS(e){return Hb(e)?e.url:Ub(e)?(`name`in e?e.name:``)||``:typeof e==`string`?e:``}function CS(e){if(Hb(e)){let t=e.headers.get(`content-type`)||``,n=yS(e.url);return cee(t)||hS(n)}return Ub(e)?e.type||``:typeof e==`string`?hS(e):``}function wS(e){return Hb(e)?e.headers[`content-length`]||-1:Ub(e)?e.size:typeof e==`string`?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}var TS=o((()=>{dS(),vS(),xS()}));async function ES(e){if(Hb(e))return e;let t={},n=wS(e);n>=0&&(t[`content-length`]=String(n));let r=SS(e),i=CS(e);i&&(t[`content-type`]=i);let a=await kS(e);a&&(t[`x-first-bytes`]=a),typeof e==`string`&&(e=new TextEncoder().encode(e));let o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:r}),o}async function DS(e){if(!e.ok)throw await OS(e)}async function OS(e){let t=uee(e.url),n=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;n=n.length>100?`${n.slice(0,100)}...`:n;let r={reason:e.statusText,url:e.url,response:e};try{let t=e.headers.get(`Content-Type`);r.reason=!e.bodyUsed&&t?.includes(`application/json`)?await e.json():await e.text()}catch{}return new fS(n,r)}async function kS(e){if(typeof e==`string`)return`data:,${e.slice(0,5)}`;if(e instanceof Blob){let t=e.slice(0,5);return await new Promise(e=>{let n=new FileReader;n.onload=t=>e(t?.target?.result),n.readAsDataURL(t)})}return e instanceof ArrayBuffer?`data:base64,${AS(e.slice(0,5))}`:null}function AS(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)}var jS=o((()=>{dS(),pS(),TS(),xS()}));function MS(e){return!NS(e)&&!PS(e)}function NS(e){return e.startsWith(`http:`)||e.startsWith(`https:`)}function PS(e){return e.startsWith(`data:`)}async function FS(e,t){if(typeof e==`string`){let n=Xx(e);return MS(n)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(n,t):await fetch(n,t)}return await ES(e)}var IS=o((()=>{dS(),jS()})),LS,RS,zS,BS=o((()=>{Ob(),LS=new Tb({id:`loaders.gl`}),RS=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},zS=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}}})),VS,HS,US=o((()=>{dS(),BS(),VS={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new zS,useLocalLibraries:!1,CDN:`https://unpkg.com/@loaders.gl`,worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:By,_nodeWorkers:!1,_workerType:``,limit:0,_limitMB:0,batchSize:`auto`,batchDebounceMs:0,metadata:!1,transforms:[]}},HS={baseUri:`core.baseUrl`,fetch:`core.fetch`,mimeType:`core.mimeType`,fallbackMimeType:`core.fallbackMimeType`,ignoreRegisteredLoaders:`core.ignoreRegisteredLoaders`,nothrow:`core.nothrow`,log:`core.log`,useLocalLibraries:`core.useLocalLibraries`,CDN:`core.CDN`,worker:`core.worker`,maxConcurrency:`core.maxConcurrency`,maxMobileConcurrency:`core.maxMobileConcurrency`,reuseWorkers:`core.reuseWorkers`,_nodeWorkers:`core.nodeWorkers`,_workerType:`core._workerType`,_worker:`core._workerType`,limit:`core.limit`,_limitMB:`core._limitMB`,batchSize:`core.batchSize`,batchDebounceMs:`core.batchDebounceMs`,metadata:`core.metadata`,transforms:`core.transforms`,throws:`nothrow`,dataType:`(no longer used)`,uri:`core.baseUrl`,method:`core.fetch.method`,headers:`core.fetch.headers`,body:`core.fetch.body`,mode:`core.fetch.mode`,credentials:`core.fetch.credentials`,cache:`core.fetch.cache`,redirect:`core.fetch.redirect`,referrer:`core.fetch.referrer`,referrerPolicy:`core.fetch.referrerPolicy`,integrity:`core.fetch.integrity`,keepalive:`core.fetch.keepalive`,signal:`core.fetch.signal`}}));function WS(){globalThis.loaders=globalThis.loaders||{};let{loaders:e}=globalThis;return e._state||={},e._state}function GS(){let e=WS();return e.globalOptions=e.globalOptions||{...VS,core:{...VS.core}},qS(e.globalOptions)}function KS(e,t,n,r){return n||=[],n=Array.isArray(n)?n:[n],JS(e,n),qS(ZS(t,e,r))}function qS(e){let t=eC(e);tC(t);for(let e of rC)t.core&&t.core[e]!==void 0&&delete t[e];return t.core&&t.core._workerType!==void 0&&delete t._worker,t}function JS(e,t){YS(e,null,VS,HS,t);for(let n of t){let r=e&&e[n.id]||{},i=n.options&&n.options[n.id]||{},a=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};YS(r,n.id,i,a,t)}}function YS(e,t,n,r,i){let a=t||`Top level`,o=t?`${t}.`:``;for(let s in e){let c=!t&&Ib(e[s]),l=s===`baseUri`&&!t,u=s===`workerUrl`&&t;if(!(s in n)&&!l&&!u){if(s in r)LS.level>0&&LS.warn(`${a} loader option \'${o}${s}\' no longer supported, use \'${r[s]}\'`)();else if(!c&&LS.level>0){let e=XS(s,i);LS.warn(`${a} loader option \'${o}${s}\' not recognized. ${e}`)()}}}}function XS(e,t){let n=e.toLowerCase(),r=``;for(let i of t)for(let t in i.options){if(e===t)return`Did you mean \'${i.id}.${t}\'?`;let a=t.toLowerCase();(n.startsWith(a)||a.startsWith(n))&&(r||=`Did you mean \'${i.id}.${t}\'?`)}return r}function ZS(e,t,n){let r=e.options||{},i={...r};return r.core&&(i.core={...r.core}),tC(i),i.core?.log===null&&(i.core={...i.core,log:new RS}),QS(i,qS(GS())),QS(i,qS(t)),$S(i,n),nC(i),i}function QS(e,t){for(let n in t)if(n in t){let r=t[n];Lb(r)&&Lb(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function $S(e,t){t&&e.core?.baseUrl===void 0&&(e.core||={},e.core.baseUrl=lS(yS(t)))}function eC(e){let t={...e};return e.core&&(t.core={...e.core}),t}function tC(e){e.baseUri!==void 0&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=e.baseUri));for(let t of rC)if(e[t]!==void 0){let n=e.core=e.core||{};n[t]===void 0&&(n[t]=e[t])}let t=e._worker;t!==void 0&&(e.core||={},e.core._workerType===void 0&&(e.core._workerType=t))}function nC(e){let t=e.core;if(t)for(let n of rC)t[n]!==void 0&&(e[n]=t[n])}var rC,iC=o((()=>{dS(),BS(),US(),xS(),rC=[`baseUrl`,`fetch`,`mimeType`,`fallbackMimeType`,`ignoreRegisteredLoaders`,`nothrow`,`log`,`useLocalLibraries`,`CDN`,`worker`,`maxConcurrency`,`maxMobileConcurrency`,`reuseWorkers`,`_nodeWorkers`,`_workerType`,`limit`,`_limitMB`,`batchSize`,`batchDebounceMs`,`metadata`,`transforms`]}));function aC(e){return e?(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions)):!1}function oC(e){Ly(e,`null loader`),Ly(aC(e),`invalid loader`);let t;return Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}var sC=o((()=>{dS()}));function cC(e){let t=uC();e=Array.isArray(e)?e:[e];for(let n of e){let e=oC(n);t.find(t=>e===t)||t.unshift(e)}}function lC(){return uC()}var uC,dC=o((()=>{sC(),iC(),uC=()=>{let e=WS();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry}}));async function fC(e,t=[],n,r){if(!gC(e))return null;let i=qS(n||{});if(i.core||={},e instanceof Response&&pC(e)){let n=mC(await e.clone().text(),t,{...i,core:{...i.core,nothrow:!0}},r);if(n)return n}let a=mC(e,t,{...i,core:{...i.core,nothrow:!0}},r);if(a)return a;if(Ub(e)&&(e=await e.slice(0,10).arrayBuffer(),a=mC(e,t,i,r)),!a&&e instanceof Response&&pC(e)&&(a=mC(await e.clone().text(),t,i,r)),!a&&!i.core.nothrow)throw Error(_C(e));return a}function pC(e){let t=CS(e);return!!(t&&(t.startsWith(`text/`)||t===`application/json`||t.endsWith(`+json`)))}function mC(e,t=[],n,r){if(!gC(e))return null;let i=qS(n||{});if(i.core||={},t&&!Array.isArray(t))return oC(t);let a=[];t&&(a=a.concat(t)),i.core.ignoreRegisteredLoaders||a.push(...lC()),vC(a);let o=hC(e,a,i,r);if(!o&&!i.core.nothrow)throw Error(_C(e));return o}function hC(e,t,n,r){let i=SS(e),a=CS(e),o=yS(i)||r?.url,s=null,c=``;return n?.core?.mimeType&&(s=xC(t,n?.core?.mimeType),c=`match forced by supplied MIME type ${n?.core?.mimeType}`),s||=yC(t,o),c||=s?`matched url ${o}`:``,s||=xC(t,a),c||=s?`matched MIME type ${a}`:``,s||=SC(t,e),c||=s?`matched initial data ${EC(e)}`:``,n?.core?.fallbackMimeType&&(s||=xC(t,n?.core?.fallbackMimeType),c||=s?`matched fallback MIME type ${a}`:``),c&&Mb.log(1,`selectLoader selected ${s?.name}: ${c}.`),s}function gC(e){return!(e instanceof Response&&e.status===204)}function _C(e){let t=SS(e),n=CS(e),r=`No valid loader found (`;r+=t?`${cS(t)}, `:`no url provided, `,r+=`MIME type: ${n?`"${n}"`:`not provided`}, `;let i=e?EC(e):``;return r+=i?` first bytes: "${i}"`:`first bytes: not available`,r+=`)`,r}function vC(e){for(let t of e)oC(t)}function yC(e,t){let n=t&&OC.exec(t),r=n&&n[1];return r?bC(e,r):null}function bC(e,t){t=t.toLowerCase();for(let n of e)for(let e of n.extensions)if(e.toLowerCase()===t)return n;return null}function xC(e,t){for(let n of e)if(n.mimeTypes?.some(e=>mS(t,e))||mS(t,`application/x.${n.id}`))return n;return null}function SC(e,t){if(!t)return null;for(let n of e)if(typeof t==`string`){if(CC(t,n))return n}else if(ArrayBuffer.isView(t)){if(wC(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&wC(t,0,n))return n;return null}function CC(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function wC(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(r=>TC(e,t,n,r))}function TC(e,t,n,r){if(zb(r))return Fx(r,e,r.byteLength);switch(typeof r){case`function`:return r(iS(e));case`string`:return r===DC(e,t,r.length);default:return!1}}function EC(e,t=5){return typeof e==`string`?e.slice(0,t):ArrayBuffer.isView(e)?DC(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?DC(e,0,t):``}function DC(e,t,n){if(e.byteLength<t+n)return``;let r=new DataView(e),i=``;for(let e=0;e<n;e++)i+=String.fromCharCode(r.getUint8(t+e));return i}var OC,kC=o((()=>{dS(),sC(),iC(),TS(),vS(),dC(),xS(),OC=/\.([^.]+)$/}));function*AC(e,t){let n=t?.chunkSize||jC,r=0,i=new TextEncoder;for(;r<e.length;){let t=Math.min(e.length-r,n),a=e.slice(r,r+t);r+=t,yield iS(i.encode(a))}}var jC,MC=o((()=>{dS(),jC=256*1024}));function*NC(e,t={}){let{chunkSize:n=PC}=t,r=0;for(;r<e.byteLength;){let t=Math.min(e.byteLength-r,n),i=new ArrayBuffer(t),a=new Uint8Array(e,r,t);new Uint8Array(i).set(a),r+=t,yield i}}var PC,FC=o((()=>{PC=256*1024}));async function*IC(e,t){let n=t?.chunkSize||LC,r=0;for(;r<e.size;){let t=r+n,i=await e.slice(r,t).arrayBuffer();r=t,yield i}}var LC,RC=o((()=>{LC=1024*1024}));function zC(e,t){return By?BC(e,t):dee(e,t)}async function*BC(e,t){let n=e.getReader(),r;try{for(;;){let e=r||n.read();t?._streamReadAhead&&(r=n.read());let{done:i,value:a}=await e;if(i)return;yield rS(a)}}catch{n.releaseLock()}}async function*dee(e,t){for await(let t of e)yield rS(t)}var VC=o((()=>{dS()}));function HC(e,t){if(typeof e==`string`)return AC(e,t);if(e instanceof ArrayBuffer)return NC(e,t);if(Ub(e))return IC(e,t);if(Kb(e))return zC(e,t);if(Hb(e)){let n=e.body;if(!n)throw Error(`Readable stream not available on Response`);return zC(n,t)}throw Error(`makeIterator`)}var UC=o((()=>{MC(),FC(),RC(),VC(),dS()}));function WC(e,t,n){if(t.text&&typeof e==`string`)return e;if(nS(e)&&(e=e.buffer),zb(e)){let n=oS(e);return t.text&&!t.binary?new TextDecoder(`utf8`).decode(n):rS(n)}throw Error(KC)}async function GC(e,t,n){if(typeof e==`string`||zb(e))return WC(e,t,n);if(Ub(e)&&(e=await ES(e)),Hb(e))return await DS(e),t.binary?await e.arrayBuffer():await e.text();if(Kb(e)&&(e=HC(e,n)),Bb(e)||Vb(e))return zx(e);throw Error(KC)}var KC,qC=o((()=>{dS(),UC(),jS(),KC=`Cannot convert supplied data type`}));function JC(e,t){let n=GS(),r=e||n,i=r.fetch??r.core?.fetch;return typeof i==`function`?i:Ib(i)?e=>FS(e,i):t?.fetch?t?.fetch:FS}var YC=o((()=>{dS(),IS(),iC()}));function XC(e,t,n){if(n)return n;let r={fetch:JC(t,e),...e};if(r.url){let e=yS(r.url);r.baseUrl=e,r.queryString=lee(r.url),r.filename=cS(e),r.baseUrl=lS(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}function ZC(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){let e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}var QC=o((()=>{YC(),xS(),dS()}));async function $C(e,t,n,r){t&&!Array.isArray(t)&&!aC(t)&&(r=void 0,n=t,t=void 0),e=await e,n||={};let i=SS(e),a=ZC(t,r),o=await fC(e,a,n);if(!o)return null;let s=KS(n,o,a,i);return r=XC({url:i,_parse:$C,loaders:a},s,r||null),await ew(o,e,s,r)}async function ew(e,t,n,r){if(Ox(e),n=iee(e.options,n),Hb(t)){let{ok:e,redirected:n,status:i,statusText:a,type:o,url:s}=t;r.response={headers:Object.fromEntries(t.headers.entries()),ok:e,redirected:n,status:i,statusText:a,type:o,url:s}}t=await GC(t,e,n);let i=e;if(i.parseTextSync&&typeof t==`string`)return i.parseTextSync(t,n,r);if(jx(e,n))return await Mx(e,t,n,r,$C);if(i.parseText&&typeof t==`string`)return await i.parseText(t,n,r);if(i.parse)return await i.parse(t,n,r);throw Qb(!i.parseSync),Error(`${e.id} loader - no parser found and worker is disabled`)}var tw=o((()=>{dS(),Ax(),sC(),iC(),qC(),QC(),TS(),kC()}));function nw(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rw(e){return Array.isArray(e)?e.length===0||typeof e[0]==`number`:!1}function fee(e){return nw(e)||rw(e)}var pee=o((()=>{})),iw=o((()=>{pee()}));async function aw(e,t,n,r){let i,a;!Array.isArray(t)&&!aC(t)?(i=[],a=t,r=void 0):(i=t,a=n);let o=JC(a),s=e;return typeof e==`string`&&(s=await o(e)),Ub(e)&&(s=await o(e)),typeof e==`string`&&(qS(a||{}).core?.baseUrl||(a={...a,core:{...a?.core,baseUrl:e}})),await $C(s,i,a)}var mee=o((()=>{dS(),sC(),YC(),iC(),tw()})),ow=o((()=>{IS(),pS(),iC(),dC(),kC(),tw(),sC(),qC(),QC(),TS(),iw(),dS(),mee(),YC(),Ax(),UC()})),sw,cw=o((()=>{sw=`4.4.2`}));function hee(e){switch(e){case`auto`:return dw||uw||fw;case`imagebitmap`:return dw;case`image`:return uw;case`data`:return fw;default:throw Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function gee(){if(dw)return`imagebitmap`;if(uw)return`image`;if(fw)return`data`;throw Error(`Install '@loaders.gl/polyfills' to parse images under Node.js`)}var lw,uw,dw,fw,pw=o((()=>{dS(),lw=globalThis.loaders?.parseImageNode,uw=typeof Image<`u`,dw=typeof ImageBitmap<`u`,fw=By?!0:!!lw}));function _ee(e){let t=yee(e);if(!t)throw Error(`Not an image`);return t}function vee(e){switch(_ee(e)){case`data`:return e;case`image`:case`imagebitmap`:let t=document.createElement(`canvas`),n=t.getContext(`2d`);if(!n)throw Error(`getImageData`);return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw Error(`getImageData`)}}function yee(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap?`imagebitmap`:typeof Image<`u`&&e instanceof Image?`image`:e&&typeof e==`object`&&e.data&&e.width&&e.height?`data`:null}var mw=o((()=>{}));function hw(e){return e&&(_w.test(e)||vw.test(e))}function bee(e,t){if(hw(t)){let t=new TextDecoder().decode(e);try{typeof unescape==`function`&&typeof encodeURIComponent==`function`&&(t=unescape(encodeURIComponent(t)))}catch(e){throw Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return gw(e,t)}function gw(e,t){if(hw(t))throw Error(`SVG cannot be parsed directly to imagebitmap`);return new Blob([new Uint8Array(e)])}var _w,vw,yw=o((()=>{_w=/^data:image\/svg\+xml/,vw=/\.svg((\?|#).*)?$/}));async function bw(e,t,n){let r=bee(e,n),i=self.URL||self.webkitURL,a=typeof r!=`string`&&i.createObjectURL(r);try{return await xee(a||r,t)}finally{a&&i.revokeObjectURL(a)}}async function xee(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((e,t)=>{try{n.onload=()=>e(n),n.onerror=e=>{let n=e instanceof Error?e.message:`error`;t(Error(n))}}catch(e){t(e)}})}var xw=o((()=>{yw()}));async function See(e,t,n){let r;r=hw(n)?await bw(e,t,n):gw(e,n);let i=t&&t.imagebitmap;return await Cee(r,i)}async function Cee(e,t=null){if((wee(t)||!Sw)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Sw=!1}return await createImageBitmap(e)}function wee(e){if(!e)return!0;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var Sw,Tee=o((()=>{yw(),xw(),Sw=!0}));function Eee(e){return!Aee(e,`ftyp`,4)||!(e[8]&96)?null:Dee(e)}function Dee(e){switch(Oee(e,8,12).replace(`\0`,` `).trim()){case`avif`:case`avis`:return{extension:`avif`,mimeType:`image/avif`};default:return null}}function Oee(e,t,n){return String.fromCharCode(...e.slice(t,n))}function kee(e){return[...e].map(e=>e.charCodeAt(0))}function Aee(e,t,n=0){let r=kee(t);for(let t=0;t<r.length;++t)if(r[t]!==e[t+n])return!1;return!0}var jee=o((()=>{}));function Cw(e){let t=ww(e);return Nee(t)||Iee(t)||Pee(t)||Fee(t)||Mee(t)}function Mee(e){let t=Eee(new Uint8Array(e instanceof DataView?e.buffer:e));return t?{mimeType:t.mimeType,width:0,height:0}:null}function Nee(e){let t=ww(e);return t.byteLength>=24&&t.getUint32(0,Tw)===2303741511?{mimeType:`image/png`,width:t.getUint32(16,Tw),height:t.getUint32(20,Tw)}:null}function Pee(e){let t=ww(e);return t.byteLength>=10&&t.getUint32(0,Tw)===1195984440?{mimeType:`image/gif`,width:t.getUint16(6,Ew),height:t.getUint16(8,Ew)}:null}function Fee(e){let t=ww(e);return t.byteLength>=14&&t.getUint16(0,Tw)===16973&&t.getUint32(2,Ew)===t.byteLength?{mimeType:`image/bmp`,width:t.getUint32(18,Ew),height:t.getUint32(22,Ew)}:null}function Iee(e){let t=ww(e);if(!(t.byteLength>=3&&t.getUint16(0,Tw)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:r}=Lee(),i=2;for(;i+9<t.byteLength;){let e=t.getUint16(i,Tw);if(r.has(e))return{mimeType:`image/jpeg`,height:t.getUint16(i+5,Tw),width:t.getUint16(i+7,Tw)};if(!n.has(e))return null;i+=2,i+=t.getUint16(i,Tw)}return null}function Lee(){let e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function ww(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw Error(`toDataView`)}var Tw,Ew,Dw=o((()=>{jee(),Tw=!1,Ew=!0}));async function Ree(e,t){let{mimeType:n}=Cw(e)||{},r=globalThis.loaders?.parseImageNode;return Ly(r),await r(e,n)}var zee=o((()=>{dS(),Dw()}));async function Bee(e,t,n){t||={};let r=(t.image||{}).type||`auto`,{url:i}=n||{},a=Vee(r),o;switch(a){case`imagebitmap`:o=await See(e,t,i);break;case`image`:o=await bw(e,t,i);break;case`data`:o=await Ree(e,t);break;default:Ly(!1)}return r===`data`&&(o=vee(o)),o}function Vee(e){switch(e){case`auto`:case`data`:return gee();default:return hee(e),e}}var Hee=o((()=>{dS(),pw(),mw(),xw(),Tee(),zee()})),Ow,kw,Aw,jw,Uee=o((()=>{cw(),Hee(),Dw(),Ow=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`ico`,`svg`,`avif`],kw=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/avif`,`image/bmp`,`image/vnd.microsoft.icon`,`image/svg+xml`],Aw={image:{type:`auto`,decode:!0}},jw={dataType:null,batchType:null,id:`image`,module:`images`,name:`Images`,version:sw,mimeTypes:kw,extensions:Ow,parse:Bee,tests:[e=>!!Cw(new DataView(e))],options:Aw}})),Wee=o((()=>{Uee(),cw(),mw(),Dw(),pw(),dS()})),Mw,Nw=o((()=>{Ob(),Mw=new Tb({id:`deck`})}));function Gee(e){Fw=e}function Pw(e,t,n,r){Mw.level>0&&Fw[e]&&Fw[e].call(null,t,n,r)}var Fw,Iw=o((()=>{Nw(),Fw={}}));function Kee(e){let t=e[0],n=e[e.length-1];return t===`{`&&n===`}`||t===`[`&&n===`]`}var Lw,qee=o((()=>{Lw={dataType:null,batchType:null,id:`JSON`,name:`JSON`,module:``,version:``,options:{},extensions:[`json`,`geojson`],mimeTypes:[`application/json`,`application/geo+json`],testText:Kee,parseTextSync:JSON.parse}}));function Jee(){let e=`9.3.3`,t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(Mw.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:Mw,_registerLoggers:Gee},cC([Lw,[jw,{imagebitmap:{premultiplyAlpha:`none`}}]])),e}var Rw,zw=o((()=>{ow(),Wee(),Nw(),Iw(),qee(),Rw=Jee()}));function Bw(e,t){if(!e){let e=Error(t||`shadertools: assertion failed.`);throw Error.captureStackTrace?.(e,Bw),e}}var Vw=o((()=>{}));function Yee(e){let t={};for(let[n,r]of Object.entries(e))t[n]=Hw(r);return t}function Hw(e){let t=Uw(e);if(t!==`object`)return{value:e,...Ww[t],type:t};if(typeof e==`object`)return e?e.type===void 0?e.value===void 0?{type:`object`,value:e}:(t=Uw(e.value),{...e,...Ww[t],type:t}):{...e,...Ww[e.type],type:e.type}:{type:`object`,value:null};throw Error(`props`)}function Uw(e){return Array.isArray(e)||ArrayBuffer.isView(e)?`array`:typeof e}var Ww,Gw=o((()=>{Ww={number:{type:`number`,validate(e,t){return Number.isFinite(e)&&typeof t==`object`&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:`array`,validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}}})),Kw,qw,Jw=o((()=>{Kw=`#ifdef MODULE_LOGDEPTH
|
||
logdepth_adjustPosition(gl_Position);
|
||
#endif
|
||
`,qw=`#ifdef MODULE_MATERIAL
|
||
fragColor = material_filterColor(fragColor);
|
||
#endif
|
||
|
||
#ifdef MODULE_LIGHTING
|
||
fragColor = lighting_filterColor(fragColor);
|
||
#endif
|
||
|
||
#ifdef MODULE_FOG
|
||
fragColor = fog_filterColor(fragColor);
|
||
#endif
|
||
|
||
#ifdef MODULE_PICKING
|
||
fragColor = picking_filterHighlightColor(fragColor);
|
||
fragColor = picking_filterPickingColor(fragColor);
|
||
#endif
|
||
|
||
#ifdef MODULE_LOGDEPTH
|
||
logdepth_setFragDepth();
|
||
#endif
|
||
`}));function Yw(e){let t={vertex:{},fragment:{}};for(let n in e){let r=e[n],i=Xw(n);typeof r==`string`&&(r={order:0,injection:r}),t[i][n]=r}return t}function Xw(e){let t=e.slice(0,2);switch(t){case`vs`:return`vertex`;case`fs`:return`fragment`;default:throw Error(t)}}function Zw(e,t,n,r=!1){let i=t===`vertex`;for(let t in n){let r=n[t];r.sort((e,t)=>e.order-t.order),tT.length=r.length;for(let e=0,t=r.length;e<t;++e)tT[e]=r[e].injection;let a=`${tT.join(`
|
||
`)}\n`;switch(t){case`vs:#decl`:i&&(e=e.replace(nT,a));break;case`vs:#main-start`:i&&(e=e.replace($w,e=>e+a));break;case`vs:#main-end`:i&&(e=e.replace(eT,e=>a+e));break;case`fs:#decl`:i||(e=e.replace(nT,a));break;case`fs:#main-start`:i||(e=e.replace($w,e=>e+a));break;case`fs:#main-end`:i||(e=e.replace(eT,e=>a+e));break;default:e=e.replace(t,e=>e+a)}}return e=e.replace(nT,``),r&&(e=e.replace(/\}\s*$/,e=>e+Qw[t])),e}var Qw,$w,eT,tT,nT,rT=o((()=>{Jw(),Qw={vertex:Kw,fragment:qw},$w=/void\s+main\s*\([^)]*\)\s*\{\n?/,eT=/}\n?[^{}]*$/,tT=[],nT=`__LUMA_INJECT_DECLARATIONS__`}));function iT(e){e.map(e=>Xee(e))}function Xee(e){if(e.instance)return;iT(e.dependencies||[]);let{propTypes:t={},deprecations:n=[],inject:r={}}=e,i={normalizedInjections:Yw(r),parsedDeprecations:oT(n)};t&&(i.propValidators=Yee(t)),e.instance=i;let a={};t&&(a=Object.entries(t).reduce((e,[t,n])=>{let r=n?.value;return r&&(e[t]=r),e},{})),e.defaultUniforms={...e.defaultUniforms,...a}}function aT(e,t,n){e.deprecations?.forEach(e=>{e.regex?.test(t)&&(e.deprecated?n.deprecated(e.old,e.new)():n.removed(e.old,e.new)())})}function oT(e){return e.forEach(e=>{switch(e.type){case`function`:e.regex=RegExp(`\\b${e.old}\\(`);break;default:e.regex=RegExp(`${e.type} ${e.old};`)}}),e}var sT=o((()=>{Gw(),rT()}));function cT(e){iT(e);let t={},n={};lT({modules:e,level:0,moduleMap:t,moduleDepth:n});let r=Object.keys(n).sort((e,t)=>n[t]-n[e]).map(e=>t[e]);return iT(r),r}function lT(e){let{modules:t,level:n,moduleMap:r,moduleDepth:i}=e;if(n>=5)throw Error(`Possible loop in shader dependency graph`);for(let e of t)r[e.name]=e,(i[e.name]===void 0||i[e.name]<n)&&(i[e.name]=n);for(let e of t)e.dependencies&&lT({modules:e.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}var uT=o((()=>{sT()}));function dT(e){return`${e.name}Uniforms`}function Zee(e,t){let n=t===`wgsl`?e.source:t===`vertex`?e.vs:e.fs;if(!n)return null;let r=dT(e);return mT(n,t===`wgsl`?`wgsl`:`glsl`,r)}function Qee(e,t){let n=Object.keys(e.uniformTypes||{});if(!n.length)return null;let r=Zee(e,t);return r?{moduleName:e.name,uniformBlockName:dT(e),stage:t,expectedUniformNames:n,actualUniformNames:r,matches:_T(n,r)}:null}function $ee(e,t,n={}){let r=Qee(e,t);if(!r||r.matches)return r;let i=vT(r);return n.log?.error?.(i,r)(),n.throwOnError!==!1&&Bw(!1,i),r}function fT(e){let t=[],n=yT(e);for(let e of n.matchAll(CT)){let n=e[1]?.trim()||null;t.push({blockName:e[2],body:e[3],instanceName:e[4]||null,layoutQualifier:n,hasLayoutQualifier:!!n,isStd140:!!(n&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(n))})}return t}function pT(e,t,n,r){let i=fT(e).filter(e=>!e.isStd140),a=new Set;for(let e of i){if(a.has(e.blockName))continue;a.add(e.blockName);let i=r?.label?`${r.label} `:``,o=e.hasLayoutQualifier?`declares ${bT(e.layoutQualifier)} instead of layout(std140)`:`does not declare layout(std140)`,s=`${i}${t} shader uniform block ${e.blockName} ${o}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;n?.warn?.(s,e)()}return i}function mT(e,t,n){let r=t===`wgsl`?hT(e,n):gT(e,n);if(!r)return null;let i=[];for(let e of r.split(`
|
||
`)){let n=e.replace(/\/\/.*$/,``).trim();if(!n||n.startsWith(`#`))continue;let r=t===`wgsl`?n.match(/^([A-Za-z0-9_]+)\s*:/):n.match(ST);r&&i.push(r[1])}return i}function hT(e,t){let n=RegExp(`\\bstruct\\s+${t}\\b`,`m`).exec(e);if(!n)return null;let r=e.indexOf(`{`,n.index);if(r<0)return null;let i=0;for(let t=r;t<e.length;t++){let n=e[t];if(n===`{`){i++;continue}if(n===`}`&&(i--,i===0))return e.slice(r+1,t)}return null}function gT(e,t){return fT(e).find(e=>e.blockName===t)?.body||null}function _T(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function vT(e){let{expectedUniformNames:t,actualUniformNames:n}=e,r=t.filter(e=>!n.includes(e)),i=n.filter(e=>!t.includes(e)),a=[`Expected ${t.length} fields, found ${n.length}.`],o=ete(t,n);return o&&a.push(o),r.length&&a.push(`Missing from shader block (${r.length}): ${xT(r)}.`),i.length&&a.push(`Unexpected in shader block (${i.length}): ${xT(i)}.`),t.length<=12&&n.length<=12&&(r.length||i.length)&&(a.push(`Expected: ${t.join(`, `)}.`),a.push(`Actual: ${n.join(`, `)}.`)),`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes. ${a.join(` `)}`}function yT(e){return e.replace(/\/\*[\s\S]*?\*\//g,``).replace(/\/\/.*$/gm,``)}function bT(e){return e.replace(/\s+/g,` `).trim()}function ete(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return`First mismatch at field ${r+1}: expected ${e[r]}, found ${t[r]}.`;return e.length>t.length?`Shader block ends after field ${t.length}; expected next field ${e[t.length]}.`:t.length>e.length?`Shader block has extra field ${t.length}: ${t[e.length]}.`:null}function xT(e,t=8){if(e.length<=t)return e.join(`, `);let n=e.length-t;return`${e.slice(0,t).join(`, `)}, ... (${n} more)`}var ST,CT,wT=o((()=>{Vw(),ST=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,CT=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g}));function TT(e){switch(e?.gpu.toLowerCase()){case`apple`:return`#define APPLE_GPU
|
||
// Apple optimizes away the calculation necessary for emulated fp64
|
||
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
||
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
||
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
|
||
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
||
`;case`nvidia`:return`#define NVIDIA_GPU
|
||
// Nvidia optimizes away the calculation necessary for emulated fp64
|
||
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
||
`;case`intel`:return`#define INTEL_GPU
|
||
// Intel optimizes away the calculation necessary for emulated fp64
|
||
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
||
// Intel's built-in 'tan' function doesn't have acceptable precision
|
||
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
||
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
|
||
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
||
`;case`amd`:return`#define AMD_GPU
|
||
`;default:return`#define DEFAULT_GPU
|
||
// Prevent driver from optimizing away the calculation necessary for emulated fp64
|
||
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
||
// Headless Chrome's software shader 'tan' function doesn't have acceptable precision
|
||
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
||
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
||
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
||
`}}var ET=o((()=>{}));function DT(e,t){if(Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw Error(`luma.gl v9 only supports GLSL 3.00 shader sources`);switch(t){case`vertex`:return e=OT(e,jT),e;case`fragment`:return e=OT(e,MT),e;default:throw Error(t)}}function OT(e,t){for(let[n,r]of t)e=e.replace(n,r);return e}function kT(e){return RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,`g`)}var AT,jT,MT,tte=o((()=>{AT=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
||
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,`textureLod(`],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,`texture(`]],jT=[...AT,[kT(`attribute`),`in $1`],[kT(`varying`),`out $1`]],MT=[...AT,[kT(`varying`),`in $1`]]}));function NT(e,t){let n=``;for(let r in e){let i=e[r];if(n+=`void ${i.signature} {\n`,i.header&&(n+=` ${i.header}`),t[r]){let e=t[r];e.sort((e,t)=>e.order-t.order);for(let t of e)n+=` ${t.injection}\n`}i.footer&&(n+=` ${i.footer}`),n+=`}
|
||
`}return n}function PT(e){let t={vertex:{},fragment:{}};for(let n of e){let e,r;typeof n==`string`?(e={},r=n):(e=n,r=e.hook),r=r.trim();let[i,a]=r.split(`:`),o=r.replace(/\(.+/,``),s=Object.assign(e,{signature:a});switch(i){case`vs`:t.vertex[o]=s;break;case`fs`:t.fragment[o]=s;break;default:throw Error(i)}}return t}var nte=o((()=>{}));function rte(e,t){return{name:ite(e,t),language:`glsl`,version:ate(e)}}function ite(e,t=`unnamed`){let n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function ate(e){let t=100,n=e.match(/[^\s]+/g);if(n&&n.length>=2&&n[0]===`#version`){let e=parseInt(n[1],10);Number.isFinite(e)&&(t=e)}if(t!==100&&t!==300)throw Error(`Invalid GLSL version ${t}`);return t}var FT=o((()=>{}));function IT(e){let t=e.split(``),n=0,r=0,i=!1,a=!1,o=!1;for(;n<e.length;){let s=e[n],c=e[n+1];if(a){o?o=!1:s===`\\`?o=!0:s===`"`&&(a=!1),n++;continue}if(i){s===`
|
||
`||s===`\r`?i=!1:t[n]=` `,n++;continue}if(r>0){if(s===`/`&&c===`*`){t[n]=` `,t[n+1]=` `,r++,n+=2;continue}if(s===`*`&&c===`/`){t[n]=` `,t[n+1]=` `,r--,n+=2;continue}s!==`
|
||
`&&s!==`\r`&&(t[n]=` `),n++;continue}if(s===`"`){a=!0,n++;continue}if(s===`/`&&c===`/`){t[n]=` `,t[n+1]=` `,i=!0,n+=2;continue}if(s===`/`&&c===`*`){t[n]=` `,t[n+1]=` `,r=1,n+=2;continue}n++}return t.join(``)}function LT(e,t){let n=IT(e),r=[];for(let i of t){i.lastIndex=0;let a;for(a=i.exec(n);a;){let o=i===t[0],s=a.index,c=a[0].length;r.push({match:e.slice(s,s+c),index:s,length:c,bindingToken:a[o?1:2],groupToken:a[o?2:1],accessDeclaration:a[3]?.trim(),name:a[4]}),a=i.exec(n)}}return r.sort((e,t)=>e.index-t.index)}function RT(e,t,n){let r=LT(e,t);if(!r.length)return e;let i=``,a=0;for(let t of r)i+=e.slice(a,t.index),i+=n(t),a=t.index+t.length;return i+=e.slice(a),i}function zT(e){return/@binding\(\s*auto\s*\)/.test(IT(e))}function BT(e,t){return LT(e,t===UT||t===WT?KT:t).find(e=>e.bindingToken===`auto`)}var VT,HT,UT,WT,GT,KT,qT=o((()=>{VT=`(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)`,HT=`\\s*`,UT=[RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${HT}@group\\(\\s*(\\d+)\\s*\\)${HT}${VT}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)${HT}@binding\\(\\s*(auto|\\d+)\\s*\\)${HT}${VT}`,`g`)],WT=[RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${HT}@group\\(\\s*(\\d+)\\s*\\)${HT}${VT}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)${HT}@binding\\(\\s*(auto|\\d+)\\s*\\)${HT}${VT}`,`g`)],GT=[RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${HT}@group\\(\\s*(\\d+)\\s*\\)${HT}${VT}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)${HT}@binding\\(\\s*(\\d+)\\s*\\)${HT}${VT}`,`g`)],KT=[RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${VT}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${VT}`,`g`),RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${VT}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${VT}`,`g`)]}));function JT(e,t=[]){let n=IT(e),r=new Map;for(let e of t)r.set(XT(e.name,e.group,e.location),e.moduleName);let i=[];for(let e of $T){e.lastIndex=0;let t;for(t=e.exec(n);t;){let a=e===$T[0],o=Number(t[a?1:2]),s=Number(t[a?2:1]),c=t[3]?.trim(),l=t[4],u=t[5].trim(),d=r.get(XT(l,s,o));i.push(YT({name:l,group:s,binding:o,owner:d?`module`:`application`,moduleName:d,accessDeclaration:c,resourceType:u})),t=e.exec(n)}}return i.sort((e,t)=>e.group===t.group?e.binding===t.binding?e.name.localeCompare(t.name):e.binding-t.binding:e.group-t.group)}function YT(e){let t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:`unknown`,moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){let n=e.accessDeclaration.split(`,`).map(e=>e.trim());if(n[0]===`uniform`)return{...t,kind:`uniform`,access:`uniform`};if(n[0]===`storage`){let e=n[1]||`read_write`;return{...t,kind:e===`read`?`read-only-storage`:`storage`,access:e}}}return e.resourceType===`sampler`||e.resourceType===`sampler_comparison`?{...t,kind:`sampler`,samplerKind:e.resourceType===`sampler_comparison`?`comparison`:`filtering`}:e.resourceType.startsWith(`texture_storage_`)?{...t,kind:`storage-texture`,access:ote(e.resourceType),viewDimension:ZT(e.resourceType)}:e.resourceType.startsWith(`texture_`)?{...t,kind:`texture`,viewDimension:ZT(e.resourceType),sampleType:QT(e.resourceType),multisampled:e.resourceType.startsWith(`texture_multisampled_`)}:t}function XT(e,t,n){return`${t}:${n}:${e}`}function ZT(e){if(e.includes(`cube_array`))return`cube-array`;if(e.includes(`2d_array`))return`2d-array`;if(e.includes(`cube`))return`cube`;if(e.includes(`3d`))return`3d`;if(e.includes(`2d`))return`2d`;if(e.includes(`1d`))return`1d`}function QT(e){if(e.startsWith(`texture_depth_`))return`depth`;if(e.includes(`<i32>`))return`sint`;if(e.includes(`<u32>`))return`uint`;if(e.includes(`<f32>`))return`float`}function ote(e){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e)?.[1]}var $T,eE=o((()=>{qT(),$T=[RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${VT}\\s*:\\s*([^;]+);`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${VT}\\s*:\\s*([^;]+);`,`g`)]}));function ste(e){let t=cT(e.modules||[]),{source:n,bindingAssignments:r}=lte(e.platformInfo,{...e,source:e.source,stage:`vertex`,modules:t});return{source:n,getUniforms:nE(t),bindingAssignments:r,bindingTable:JT(n,r)}}function cte(e){let{vs:t,fs:n}=e,r=cT(e.modules||[]);return{vs:tE(e.platformInfo,{...e,source:t,stage:`vertex`,modules:r}),fs:tE(e.platformInfo,{...e,source:n,stage:`fragment`,modules:r}),getUniforms:nE(r)}}function lte(e,t){let{source:n,stage:r,modules:i,hookFunctions:a=[],inject:o={},log:s}=t;Bw(typeof n==`string`,`shader source must be a string`);let c=n,l=``,u=PT(a),d={},f={},p={};for(let e in o){let t=typeof o[e]==`string`?{injection:o[e],order:0}:o[e],n=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(n){let r=n[2],i=n[3];r?i===`decl`?f[e]=[t]:p[e]=[t]:d[e]=[t]}else p[e]=[t]}let m=i,h=fte(c),g=dte(h.source),_=aE(m,t._bindingRegistry,g),v=[];for(let e of m){s&&aT(e,c,s);let n=pte(rE(e,`wgsl`,s),e,{usedBindingsByGroup:g,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:_});v.push(...n.bindingAssignments);let i=n.source;l+=i;let a=e.injections?.[r]||{};for(let e in a){let t=/^(v|f)s:#([\w-]+)$/.exec(e);if(t){let n=t[2]===`decl`?f:p;n[e]=n[e]||[],n[e].push(a[e])}else d[e]=d[e]||[],d[e].push(a[e])}}return l+=_E,l=Zw(l,r,f),l+=NT(u[r],d),l+=fE(v),l+=h.source,l=Zw(l,r,p),dE(l),{source:l,bindingAssignments:v}}function tE(e,t){let{source:n,stage:r,language:i=`glsl`,modules:a,defines:o={},hookFunctions:s=[],inject:c={},prologue:l=!0,log:u}=t;Bw(typeof n==`string`,`shader source must be a string`);let d=i===`glsl`?rte(n).version:-1,f=e.shaderLanguageVersion,p=d===100?`#version 100`:`#version 300 es`,m=n.split(`
|
||
`).slice(1).join(`
|
||
`),h={};a.forEach(e=>{Object.assign(h,e.defines)}),Object.assign(h,o);let g=``;switch(i){case`wgsl`:break;case`glsl`:g=l?`\
|
||
${p}
|
||
|
||
// ----- PROLOGUE -------------------------
|
||
${`#define SHADER_TYPE_${r.toUpperCase()}`}
|
||
|
||
${TT(e)}
|
||
${r===`fragment`?yE:``}
|
||
|
||
// ----- APPLICATION DEFINES -------------------------
|
||
|
||
${ute(h)}
|
||
|
||
`:`${p}
|
||
`;break}let _=PT(s),v={},y={},b={};for(let e in c){let t=typeof c[e]==`string`?{injection:c[e],order:0}:c[e],n=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(n){let r=n[2],i=n[3];r?i===`decl`?y[e]=[t]:b[e]=[t]:v[e]=[t]}else b[e]=[t]}for(let e of a){u&&aT(e,m,u);let t=rE(e,r,u);g+=t;let n=e.instance?.normalizedInjections[r]||{};for(let e in n){let t=/^(v|f)s:#([\w-]+)$/.exec(e);if(t){let r=t[2]===`decl`?y:b;r[e]=r[e]||[],r[e].push(n[e])}else v[e]=v[e]||[],v[e].push(n[e])}}return g+=`// ----- MAIN SHADER SOURCE -------------------------`,g+=_E,g=Zw(g,r,y),g+=NT(_[r],v),g+=m,g=Zw(g,r,b),i===`glsl`&&d!==f&&(g=DT(g,r)),i===`glsl`&&pT(g,r,u),g.trim()}function nE(e){return function(t){let n={};for(let r of e){let e=r.getUniforms?.(t,n);Object.assign(n,e)}return n}}function ute(e={}){let t=``;for(let n in e){let r=e[n];(r||Number.isFinite(r))&&(t+=`#define ${n.toUpperCase()} ${e[n]}\n`)}return t}function rE(e,t,n){let r;switch(t){case`vertex`:r=e.vs||``;break;case`fragment`:r=e.fs||``;break;case`wgsl`:r=e.source||``;break;default:Bw(!1)}if(!e.name)throw Error(`Shader module must have a name`);$ee(e,t,{log:n});let i=e.name.toUpperCase().replace(/[^0-9a-z]/gi,`_`),a=`\
|
||
// ----- MODULE ${e.name} ---------------
|
||
|
||
`;return t!==`wgsl`&&(a+=`#define MODULE_${i}\n`),a+=`${r}\n`,a}function dte(e){let t=new Map;for(let n of LT(e,GT)){let e=Number(n.bindingToken),r=Number(n.groupToken);sE(r,e,n.name),lE(t,r,e,`application binding "${n.name}"`)}return t}function fte(e){let t=LT(e,WT),n=new Map;for(let e of t){if(e.bindingToken===`auto`)continue;let t=Number(e.bindingToken),r=Number(e.groupToken);sE(r,t,e.name),lE(n,r,t,`application binding "${e.name}"`)}let r={sawSupportedBindingDeclaration:t.length>0},i=RT(e,WT,e=>iE(e,n,r));if(zT(e)&&!r.sawSupportedBindingDeclaration)throw Error(`Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:i}}function pte(e,t,n){let r=[],i={sawSupportedBindingDeclaration:LT(e,UT).length>0,nextHintedBindingLocation:typeof t.firstBindingSlot==`number`?t.firstBindingSlot:null},a=RT(e,UT,e=>mte(e,{module:t,context:n,bindingAssignments:r,relocationState:i}));if(zT(e)&&!i.sawSupportedBindingDeclaration)throw Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:a,bindingAssignments:r}}function mte(e,t){let{module:n,context:r,bindingAssignments:i,relocationState:a}=t,{match:o,bindingToken:s,groupToken:c,name:l}=e,u=Number(c);if(s===`auto`){let e=pE(u,n.name,l),t=r.bindingRegistry?.get(e),s=t===void 0?a.nextHintedBindingLocation===null?uE(u,r.usedBindingsByGroup):uE(u,r.usedBindingsByGroup,a.nextHintedBindingLocation):t;return cE(n.name,u,s,l),t!==void 0&&oE(r.reservedBindingKeysByGroup,u,s,e)?(i.push({moduleName:n.name,name:l,group:u,location:s}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${s})`)):(lE(r.usedBindingsByGroup,u,s,`module "${n.name}" binding "${l}"`),r.bindingRegistry?.set(e,s),i.push({moduleName:n.name,name:l,group:u,location:s}),a.nextHintedBindingLocation!==null&&t===void 0&&(a.nextHintedBindingLocation=s+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${s})`))}let d=Number(s);return cE(n.name,u,d,l),lE(r.usedBindingsByGroup,u,d,`module "${n.name}" binding "${l}"`),i.push({moduleName:n.name,name:l,group:u,location:d}),o}function iE(e,t,n){let{match:r,bindingToken:i,groupToken:a,name:o}=e,s=Number(a);if(i===`auto`){let e=gte(s,t);return sE(s,e,o),lE(t,s,e,`application binding "${o}"`),r.replace(/@binding\(\s*auto\s*\)/,`@binding(${e})`)}return n.sawSupportedBindingDeclaration=!0,r}function aE(e,t,n){let r=new Map;if(!t)return r;for(let i of e)for(let e of hte(i)){let a=pE(e.group,i.name,e.name),o=t.get(a);if(o!==void 0){let t=r.get(e.group)||new Map,i=t.get(o);if(i&&i!==a)throw Error(`Duplicate WGSL binding reservation for modules "${i}" and "${a}": group ${e.group}, binding ${o}.`);lE(n,e.group,o,`registered module binding "${a}"`),t.set(o,a),r.set(e.group,t)}}return r}function oE(e,t,n,r){let i=e.get(t);if(!i)return!1;let a=i.get(n);if(!a)return!1;if(a!==r)throw Error(`Registered module binding "${r}" collided with "${a}": group ${t}, binding ${n}.`);return!0}function hte(e){let t=[],n=e.source||``;for(let e of LT(n,UT))t.push({name:e.name,group:Number(e.groupToken)});return t}function sE(e,t,n){if(e===0&&t>=vE)throw Error(`Application binding "${n}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${vE}.`)}function cE(e,t,n,r){if(t===0&&n<vE)throw Error(`Module "${e}" binding "${r}" in group 0 uses reserved application binding ${n}. Module-owned explicit group-0 bindings must be ${vE} or higher.`)}function lE(e,t,n,r){let i=e.get(t)||new Set;if(i.has(n))throw Error(`Duplicate WGSL binding assignment for ${r}: group ${t}, binding ${n}.`);i.add(n),e.set(t,i)}function uE(e,t,n){let r=t.get(e)||new Set,i=n??(e===0?vE:r.size>0?Math.max(...r)+1:0);for(;r.has(i);)i++;return i}function gte(e,t){let n=t.get(e)||new Set,r=0;for(;n.has(r);)r++;return r}function dE(e){let t=BT(e,UT);if(!t)return;let n=mE(e,t.index);throw n?Error(`Unresolved @binding(auto) for module "${n}" binding "${t.name}" remained in assembled WGSL source.`):hE(e,t.index)?Error(`Unresolved @binding(auto) for application binding "${t.name}" remained in assembled WGSL source.`):Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${gE(t.match)}".`)}function fE(e){if(e.length===0)return``;let t=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
|
||
`;for(let n of e)t+=`// ${n.moduleName}.${n.name} -> @group(${n.group}) @binding(${n.location})\n`;return t+=`
|
||
`,t}function pE(e,t,n){return`${e}:${t}:${n}`}function mE(e,t){let n=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,r,i;for(i=n.exec(e);i&&i.index<=t;)r=i[1],i=n.exec(e);return r}function hE(e,t){let n=e.indexOf(_E);return n>=0?t>n:!0}function gE(e){return e.replace(/\s+/g,` `).trim()}var _E,vE,yE,bE=o((()=>{uT(),ET(),rT(),tte(),sT(),wT(),nte(),Vw(),FT(),eE(),qT(),_E=`\n\n${nT}\n`,vE=100,yE=`precision highp float;
|
||
`}));function xE(e,t){let n=e.split(`
|
||
`),r=[],i=[],a=!0;for(let e of n){let n=e.match(DE)||e.match(CE),o=e.match(wE),s=e.match(TE),c=e.match(OE)||e.match(EE);if(n||o){let e=(n||o)?.[1],r=!!t?.defines?.[e],s=n?r:!r,c=a&&s;i.push({parentActive:a,branchTaken:s,active:c}),a=c}else if(s){let e=i[i.length-1];if(!e)throw Error(`Encountered #else without matching #ifdef or #ifndef`);e.active=e.parentActive&&!e.branchTaken,e.branchTaken=!0,a=e.active}else c?(i.pop(),a=i.length?i[i.length-1].active:!0):a&&r.push(e)}if(i.length>0)throw Error(`Unterminated conditional block in shader source`);return r.join(`
|
||
`)}var SE,CE,wE,TE,EE,DE,OE,kE=o((()=>{SE=`([a-zA-Z_][a-zA-Z0-9_]*)`,CE=RegExp(`^\\s*\\#\\s*ifdef\\s*${SE}\\s*$`),wE=RegExp(`^\\s*\\#\\s*ifndef\\s*${SE}\\s*(?:\\/\\/.*)?$`),TE=/^\s*\#\s*else\s*(?:\/\/.*)?$/,EE=/^\s*\#\s*endif\s*$/,DE=RegExp(`^\\s*\\#\\s*ifdef\\s*${SE}\\s*(?:\\/\\/.*)?$`),OE=/^\s*\#\s*endif\s*(?:\/\/.*)?$/})),AE,jE=o((()=>{sT(),bE(),eE(),kE(),AE=class e{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return e.defaultShaderAssembler=e.defaultShaderAssembler||new e,e.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e==`string`?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e==`string`?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let t=this._getModuleList(e.modules),n=this._hookFunctions,{source:r,getUniforms:i,bindingAssignments:a}=ste({...e,source:e.source,_bindingRegistry:this._wgslBindingRegistry,modules:t,hookFunctions:n}),o={...t.reduce((e,t)=>(Object.assign(e,t.defines),e),{}),...e.defines},s=e.platformInfo.shaderLanguage===`wgsl`?xE(r,{defines:o}):r;return{source:s,getUniforms:i,modules:t,bindingAssignments:a,bindingTable:JT(s,a)}}assembleGLSLShaderPair(e){let t=this._getModuleList(e.modules),n=this._hookFunctions;return{...cte({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n}),modules:t}}_getModuleList(e=[]){let t=Array(this._defaultModules.length+e.length),n={},r=0;for(let e=0,i=this._defaultModules.length;e<i;++e){let i=this._defaultModules[e],a=i.name;t[r++]=i,n[a]=!0}for(let i=0,a=e.length;i<a;++i){let a=e[i],o=a.name;n[o]||(t[r++]=a,n[o]=!0)}return t.length=r,iT(t),t}}}));function ME(e){let{input:t,inputChannels:n,output:r}=e||{};if(!t)return FE;if(!n)throw Error(`inputChannels`);return`\
|
||
#version 300 es
|
||
in ${NE(n)} ${t};
|
||
out vec4 ${r};
|
||
void main() {
|
||
${r} = ${PE(t,n)};
|
||
}`}function NE(e){switch(e){case 1:return`float`;case 2:return`vec2`;case 3:return`vec3`;case 4:return`vec4`;default:throw Error(`invalid channels: ${e}`)}}function PE(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw Error(`invalid channels: ${t}`)}}var FE,IE=o((()=>{FE=`#version 300 es
|
||
out vec4 transform_output;
|
||
void main() {
|
||
transform_output = vec4(0);
|
||
}`}));function LE(e,{precision:t=HE.precision}={}){return e=_te(e),`${parseFloat(e.toPrecision(t))}`}function RE(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function zE(e,t,n){return yte(e,e=>Math.max(t,Math.min(n,e)))}function BE(e,t,n){return RE(e)?e.map((e,r)=>BE(e,t[r],n)):n*t+(1-n)*e}function VE(e,t,n){let r=HE.EPSILON;n&&(HE.EPSILON=n);try{if(e===t)return!0;if(RE(e)&&RE(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!VE(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e==`number`&&typeof t==`number`?Math.abs(e-t)<=HE.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{HE.EPSILON=r}}function _te(e){return Math.round(e/HE.EPSILON)*HE.EPSILON}function vte(e){return e.clone?e.clone():Array(e.length)}function yte(e,t,n){if(RE(e)){let r=e;n||=vte(r);for(let i=0;i<n.length&&i<r.length;++i){let r=typeof e==`number`?e:e[i];n[i]=t(r,i,n)}return n}return t(e)}var HE,UE=o((()=>{1/Math.PI*180,1/180*Math.PI,globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}},HE=globalThis.mathgl.config})),WE,GE=o((()=>{UE(),WE=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:RE(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(HE)}formatString(e){let t=``;for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?`, `:``)+LE(this[n],e);return`${e.printTypes?this.constructor.name:``}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!VE(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let r=0;r<this.ELEMENTS;++r){let i=e[r],a=typeof t==`number`?t:t[r];this[r]=i+n*(a-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if(typeof e==`number`)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(HE.debug&&!this.validate())throw Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e&&=Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}}}));function KE(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}function qE(e){if(!Number.isFinite(e))throw Error(`Invalid number ${JSON.stringify(e)}`);return e}function JE(e,t,n=``){if(HE.debug&&!KE(e,t))throw Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}var YE=o((()=>{UE()}));function XE(e,t){if(!e)throw Error(`math.gl assertion ${t}`)}var ZE=o((()=>{})),QE,$E=o((()=>{GE(),YE(),ZE(),QE=class extends WE{get x(){return this[0]}set x(e){this[0]=qE(e)}get y(){return this[1]}set y(e){this[1]=qE(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){let r=this[n]-e[n];t+=r*r}return qE(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return qE(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return XE(e>=0&&e<this.ELEMENTS,`index is out of range`),qE(this[e])}setComponent(e,t){return XE(e>=0&&e<this.ELEMENTS,`index is out of range`),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}})),eD,tD=o((()=>{eD=typeof Float32Array<`u`?Float32Array:Array,Math.PI/180}));function nD(){let e=new eD(2);return eD!=Float32Array&&(e[0]=0,e[1]=0),e}function rD(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function iD(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function aD(e,t){return e[0]=-t[0],e[1]=-t[1],e}function oD(e,t,n,r){let i=t[0],a=t[1];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e}function sD(e,t,n){let r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e}var cD,lD=o((()=>{tD(),cD=iD,(function(){let e=nD();return function(t,n,r,i,a,o){let s,c;for(n||=2,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],a(e,e,o),t[s]=e[0],t[s+1]=e[1];return t}})()}));function uD(e,t,n){let r=t[0],i=t[1],a=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/a,e[1]=(n[1]*r+n[5]*i)/a,e}function dD(e,t,n){let r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a||1;return e[0]=(n[0]*r+n[4]*i+n[8]*a)/o,e[1]=(n[1]*r+n[5]*i+n[9]*a)/o,e[2]=(n[2]*r+n[6]*i+n[10]*a)/o,e}function fD(e,t,n){let r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2],e}var pD=o((()=>{}));function mD(){let e=new eD(3);return eD!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function hD(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function gD(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function _D(e){let t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r}function bte(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function xte(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ste(e,t,n){let r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-a*s,e[1]=a*o-r*c,e[2]=r*s-i*o,e}function Cte(e,t,n,r){let i=t[0],a=t[1],o=t[2];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e[2]=o+r*(n[2]-o),e}function vD(e,t,n){let r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o||=1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e}function wte(e,t,n){let r=t[0],i=t[1],a=t[2];return e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8],e}function Tte(e,t,n){let r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],c=t[1],l=t[2],u=i*l-a*c,d=a*s-r*l,f=r*c-i*s,p=i*f-a*d,m=a*u-r*f,h=r*d-i*u,g=o*2;return u*=g,d*=g,f*=g,p*=2,m*=2,h*=2,e[0]=s+u+p,e[1]=c+d+m,e[2]=l+f+h,e}function Ete(e,t,n,r){let i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function Dte(e,t,n,r){let i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function Ote(e,t,n,r){let i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function kte(e,t){let n=e[0],r=e[1],i=e[2],a=t[0],o=t[1],s=t[2],c=Math.sqrt((n*n+r*r+i*i)*(a*a+o*o+s*s)),l=c&&xte(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var yD,bD,xD,SD=o((()=>{tD(),yD=gD,bD=hD,xD=_D,(function(){let e=mD();return function(t,n,r,i,a,o){let s,c;for(n||=3,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}})()})),CD,wD,TD,Ate=o((()=>{$E(),UE(),YE(),SD(),pD(),CD=[0,0,0],TD=class e extends QE{static get ZERO(){return wD||(wD=new e(0,0,0),Object.freeze(wD)),wD}constructor(e=0,t=0,n=0){super(-0,-0,-0),arguments.length===1&&RE(e)?this.copy(e):(HE.debug&&(qE(e),qE(t),qE(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return HE.debug&&(qE(e.x),qE(e.y),qE(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=qE(e)}angle(e){return kte(this,e)}cross(e){return Ste(this,this,e),this.check()}rotateX({radians:e,origin:t=CD}){return Ete(this,this,t,e),this.check()}rotateY({radians:e,origin:t=CD}){return Dte(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=CD}){return Ote(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return vD(this,this,e),this.check()}transformAsVector(e){return dD(this,this,e),this.check()}transformByMatrix3(e){return wte(this,this,e),this.check()}transformByMatrix2(e){return fD(this,this,e),this.check()}transformByQuaternion(e){return Tte(this,this,e),this.check()}}})),ED,DD=o((()=>{GE(),YE(),UE(),ED=class extends WE{toString(){let e=`[`;if(HE.printRowMajor){e+=`row-major:`;for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+=`column-major:`;for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+=`]`,e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=qE(n),this}getColumn(e,t=Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[n+e];return t}setColumn(e,t){let n=e*this.RANK;for(let e=0;e<this.RANK;++e)this[n+e]=t[e];return this}}}));function jte(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 Mte(e,t){if(e===t){let n=t[1],r=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function OD(e,t){let n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=n*s-r*o,y=n*c-i*o,b=n*l-a*o,x=r*c-i*s,S=r*l-a*s,C=i*l-a*c,w=u*h-d*m,T=u*g-f*m,E=u*_-p*m,D=d*g-f*h,O=d*_-p*h,k=f*_-p*g,A=v*k-y*O+b*D+x*E-S*T+C*w;return A?(A=1/A,e[0]=(s*k-c*O+l*D)*A,e[1]=(i*O-r*k-a*D)*A,e[2]=(h*C-g*S+_*x)*A,e[3]=(f*S-d*C-p*x)*A,e[4]=(c*E-o*k-l*T)*A,e[5]=(n*k-i*E+a*T)*A,e[6]=(g*b-m*C-_*y)*A,e[7]=(u*C-f*b+p*y)*A,e[8]=(o*O-s*E+l*w)*A,e[9]=(r*E-n*O-a*w)*A,e[10]=(m*S-h*b+_*v)*A,e[11]=(d*b-u*S-p*v)*A,e[12]=(s*T-o*D-c*w)*A,e[13]=(n*D-r*T+i*w)*A,e[14]=(h*y-m*x-g*v)*A,e[15]=(u*x-d*y+f*v)*A,e):null}function kD(e){let t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=n*s-r*o,b=l*m-u*p,x=l*h-d*p,S=u*h-d*m,C=t*S-n*x+r*b,w=a*S-o*x+s*b,T=l*y-u*v+d*_,E=p*y-m*v+h*_;return c*C-i*w+g*T-f*E}function AD(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=n[0],b=n[1],x=n[2],S=n[3];return e[0]=y*r+b*s+x*d+S*h,e[1]=y*i+b*c+x*f+S*g,e[2]=y*a+b*l+x*p+S*_,e[3]=y*o+b*u+x*m+S*v,y=n[4],b=n[5],x=n[6],S=n[7],e[4]=y*r+b*s+x*d+S*h,e[5]=y*i+b*c+x*f+S*g,e[6]=y*a+b*l+x*p+S*_,e[7]=y*o+b*u+x*m+S*v,y=n[8],b=n[9],x=n[10],S=n[11],e[8]=y*r+b*s+x*d+S*h,e[9]=y*i+b*c+x*f+S*g,e[10]=y*a+b*l+x*p+S*_,e[11]=y*o+b*u+x*m+S*v,y=n[12],b=n[13],x=n[14],S=n[15],e[12]=y*r+b*s+x*d+S*h,e[13]=y*i+b*c+x*f+S*g,e[14]=y*a+b*l+x*p+S*_,e[15]=y*o+b*u+x*m+S*v,e}function jD(e,t,n){let r=n[0],i=n[1],a=n[2],o,s,c,l,u,d,f,p,m,h,g,_;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*a+t[12],e[13]=t[1]*r+t[5]*i+t[9]*a+t[13],e[14]=t[2]*r+t[6]*i+t[10]*a+t[14],e[15]=t[3]*r+t[7]*i+t[11]*a+t[15]):(o=t[0],s=t[1],c=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],e[0]=o,e[1]=s,e[2]=c,e[3]=l,e[4]=u,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=g,e[11]=_,e[12]=o*r+u*i+m*a+t[12],e[13]=s*r+d*i+h*a+t[13],e[14]=c*r+f*i+g*a+t[14],e[15]=l*r+p*i+_*a+t[15]),e}function MD(e,t,n){let r=n[0],i=n[1],a=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ND(e,t,n,r){let i=r[0],a=r[1],o=r[2],s=Math.sqrt(i*i+a*a+o*o),c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j;return s<1e-6?null:(s=1/s,i*=s,a*=s,o*=s,l=Math.sin(n),c=Math.cos(n),u=1-c,d=t[0],f=t[1],p=t[2],m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],b=t[9],x=t[10],S=t[11],C=i*i*u+c,w=a*i*u+o*l,T=o*i*u-a*l,E=i*a*u-o*l,D=a*a*u+c,O=o*a*u+i*l,k=i*o*u+a*l,A=a*o*u-i*l,j=o*o*u+c,e[0]=d*C+h*w+y*T,e[1]=f*C+g*w+b*T,e[2]=p*C+_*w+x*T,e[3]=m*C+v*w+S*T,e[4]=d*E+h*D+y*O,e[5]=f*E+g*D+b*O,e[6]=p*E+_*D+x*O,e[7]=m*E+v*D+S*O,e[8]=d*k+h*A+y*j,e[9]=f*k+g*A+b*j,e[10]=p*k+_*A+x*j,e[11]=m*k+v*A+S*j,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function PD(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=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]=a*i+l*r,e[5]=o*i+u*r,e[6]=s*i+d*r,e[7]=c*i+f*r,e[8]=l*i-a*r,e[9]=u*i-o*r,e[10]=d*i-s*r,e[11]=f*i-c*r,e}function FD(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[8],u=t[9],d=t[10],f=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]=a*i-l*r,e[1]=o*i-u*r,e[2]=s*i-d*r,e[3]=c*i-f*r,e[8]=a*r+l*i,e[9]=o*r+u*i,e[10]=s*r+d*i,e[11]=c*r+f*i,e}function ID(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=t[5],d=t[6],f=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]=a*i+l*r,e[1]=o*i+u*r,e[2]=s*i+d*r,e[3]=c*i+f*r,e[4]=l*i-a*r,e[5]=u*i-o*r,e[6]=d*i-s*r,e[7]=f*i-c*r,e}function LD(e,t){let n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,c=i+i,l=n*o,u=r*o,d=r*s,f=i*o,p=i*s,m=i*c,h=a*o,g=a*s,_=a*c;return e[0]=1-d-m,e[1]=u+_,e[2]=f-g,e[3]=0,e[4]=u-_,e[5]=1-l-m,e[6]=p+h,e[7]=0,e[8]=f+g,e[9]=p-h,e[10]=1-l-d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function RD(e,t,n,r,i,a,o){let s=1/(n-t),c=1/(i-r),l=1/(a-o);return e[0]=a*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a*2*c,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*c,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e}function zD(e,t,n,r,i){let a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let t=1/(r-i);e[10]=(i+r)*t,e[14]=2*i*r*t}else e[10]=-1,e[14]=-2*r;return e}function BD(e,t,n,r,i,a,o){let s=1/(t-n),c=1/(r-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*c,e[14]=(o+a)*l,e[15]=1,e}function VD(e,t,n,r){let i,a,o,s,c,l,u,d,f,p,m=t[0],h=t[1],g=t[2],_=r[0],v=r[1],y=r[2],b=n[0],x=n[1],S=n[2];return Math.abs(m-b)<1e-6&&Math.abs(h-x)<1e-6&&Math.abs(g-S)<1e-6?jte(e):(d=m-b,f=h-x,p=g-S,i=1/Math.sqrt(d*d+f*f+p*p),d*=i,f*=i,p*=i,a=v*p-y*f,o=y*d-_*p,s=_*f-v*d,i=Math.sqrt(a*a+o*o+s*s),i?(i=1/i,a*=i,o*=i,s*=i):(a=0,o=0,s=0),c=f*s-p*o,l=p*a-d*s,u=d*o-f*a,i=Math.sqrt(c*c+l*l+u*u),i?(i=1/i,c*=i,l*=i,u*=i):(c=0,l=0,u=0),e[0]=a,e[1]=c,e[2]=d,e[3]=0,e[4]=o,e[5]=l,e[6]=f,e[7]=0,e[8]=s,e[9]=u,e[10]=p,e[11]=0,e[12]=-(a*m+o*h+s*g),e[13]=-(c*m+l*h+u*g),e[14]=-(d*m+f*h+p*g),e[15]=1,e)}var HD,UD,WD=o((()=>{tD(),HD=zD,UD=BD}));function GD(){let e=new eD(4);return eD!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function KD(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function qD(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}var JD=o((()=>{tD(),(function(){let e=GD();return function(t,n,r,i,a,o){let s,c;for(n||=4,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}})()}));function YD(){return oO||(oO=new aO([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(oO)),oO}function XD(){return sO||(sO=new aO,Object.freeze(sO)),sO}function ZD(e){if(e>Math.PI*2)throw Error(`expected radians`)}function QD(e,t,n,r,i,a){let o=2*a/(n-t),s=2*a/(i-r),c=(n+t)/(n-t),l=(i+r)/(i-r),u=-2*a;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}var $D,eO,tO,nO,rO,iO,aO,oO,sO,cO=o((()=>{DD(),YE(),pD(),WD(),lD(),SD(),JD(),(function(e){e[e.COL0ROW0=0]=`COL0ROW0`,e[e.COL0ROW1=1]=`COL0ROW1`,e[e.COL0ROW2=2]=`COL0ROW2`,e[e.COL0ROW3=3]=`COL0ROW3`,e[e.COL1ROW0=4]=`COL1ROW0`,e[e.COL1ROW1=5]=`COL1ROW1`,e[e.COL1ROW2=6]=`COL1ROW2`,e[e.COL1ROW3=7]=`COL1ROW3`,e[e.COL2ROW0=8]=`COL2ROW0`,e[e.COL2ROW1=9]=`COL2ROW1`,e[e.COL2ROW2=10]=`COL2ROW2`,e[e.COL2ROW3=11]=`COL2ROW3`,e[e.COL3ROW0=12]=`COL3ROW0`,e[e.COL3ROW1=13]=`COL3ROW1`,e[e.COL3ROW2=14]=`COL3ROW2`,e[e.COL3ROW3=15]=`COL3ROW3`})($D||={}),eO=45*Math.PI/180,tO=1,nO=.1,rO=500,iO=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),aO=class extends ED{static get IDENTITY(){return XD()}static get ZERO(){return YD()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return $D}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=c,this[9]=l,this[10]=u,this[11]=d,this[12]=f,this[13]=p,this[14]=m,this[15]=h,this.check()}setRowMajor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){return this[0]=e,this[1]=i,this[2]=c,this[3]=f,this[4]=t,this[5]=a,this[6]=l,this[7]=p,this[8]=n,this[9]=o,this[10]=u,this[11]=m,this[12]=r,this[13]=s,this[14]=d,this[15]=h,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(iO)}fromObject(e){return this.check()}fromQuaternion(e){return LD(this,e),this.check()}frustum(e){let{left:t,right:n,bottom:r,top:i,near:a=nO,far:o=rO}=e;return o===1/0?QD(this,t,n,r,i,a):RD(this,t,n,r,i,a,o),this.check()}lookAt(e){let{eye:t,center:n=[0,0,0],up:r=[0,1,0]}=e;return VD(this,t,n,r),this.check()}ortho(e){let{left:t,right:n,bottom:r,top:i,near:a=nO,far:o=rO}=e;return UD(this,t,n,r,i,a,o),this.check()}orthographic(e){let{fovy:t=eO,aspect:n=tO,focalDistance:r=1,near:i=nO,far:a=rO}=e;ZD(t);let o=t/2,s=r*Math.tan(o),c=s*n;return this.ortho({left:-c,right:c,bottom:-s,top:s,near:i,far:a})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:n=1,near:r=.1,far:i=500}=e;return ZD(t),HD(this,t,n,r,i),this.check()}determinant(){return kD(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e||=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t||=[-0,-0,-0];let n=this.getScale(t),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e||=[-0,-0,-0,-0,-0,-0,-0,-0,-0],t||=[-0,-0,-0];let n=this.getScale(t),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return Mte(this,this),this.check()}invert(){return OD(this,this),this.check()}multiplyLeft(e){return AD(this,e,this),this.check()}multiplyRight(e){return AD(this,this,e),this.check()}rotateX(e){return PD(this,this,e),this.check()}rotateY(e){return FD(this,this,e),this.check()}rotateZ(e){return ID(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return ND(this,this,e,t),this.check()}scale(e){return MD(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return jD(this,this,e),this.check()}transform(e,t){return e.length===4?(t=qD(t||[-0,-0,-0,-0],e,this),JE(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:n}=e,r;switch(n){case 2:r=sD(t||[-0,-0],e,this);break;case 3:r=vD(t||[-0,-0,-0],e,this);break;default:throw Error(`Illegal vector`)}return JE(r,e.length),r}transformAsVector(e,t){let n;switch(e.length){case 2:n=uD(t||[-0,-0],e,this);break;case 3:n=dD(t||[-0,-0,-0],e,this);break;default:throw Error(`Illegal vector`)}return JE(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}}})),lO=o((()=>{$E(),UE(),YE(),lD(),pD(),Ate(),SD(),DD(),tD(),cO(),GE(),JD(),ZE(),WD()}));function uO(e,t=[],n=0){let r=Math.fround(e),i=e-r;return t[n]=r,t[n+1]=i,t}function dO(e){return e-Math.fround(e)}function fO(e){let t=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let i=n*4+r;uO(e[r*4+n],t,i*2)}return t}var pO=o((()=>{}));function mO(e,t=!0){return e??t}function hO(e=[0,0,0],t=!0){return t?e.map(e=>e/255):[...e]}function gO(e,t=!0){let n=hO(e.slice(0,3),t),r=Number.isFinite(e[3]),i=r?e[3]:1;return[n[0],n[1],n[2],t&&r?i/255:i]}var _O=o((()=>{})),vO,yO,bO=o((()=>{vO=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
||
|
||
// All these functions are for substituting tan() function from Intel GPU only
|
||
const float TWO_PI = 6.2831854820251465;
|
||
const float PI_2 = 1.5707963705062866;
|
||
const float PI_16 = 0.1963495463132858;
|
||
|
||
const float SIN_TABLE_0 = 0.19509032368659973;
|
||
const float SIN_TABLE_1 = 0.3826834261417389;
|
||
const float SIN_TABLE_2 = 0.5555702447891235;
|
||
const float SIN_TABLE_3 = 0.7071067690849304;
|
||
|
||
const float COS_TABLE_0 = 0.9807852506637573;
|
||
const float COS_TABLE_1 = 0.9238795042037964;
|
||
const float COS_TABLE_2 = 0.8314695954322815;
|
||
const float COS_TABLE_3 = 0.7071067690849304;
|
||
|
||
const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!
|
||
const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!
|
||
const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!
|
||
const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!
|
||
|
||
float sin_taylor_fp32(float a) {
|
||
float r, s, t, x;
|
||
|
||
if (a == 0.0) {
|
||
return 0.0;
|
||
}
|
||
|
||
x = -a * a;
|
||
s = a;
|
||
r = a;
|
||
|
||
r = r * x;
|
||
t = r * INVERSE_FACTORIAL_3;
|
||
s = s + t;
|
||
|
||
r = r * x;
|
||
t = r * INVERSE_FACTORIAL_5;
|
||
s = s + t;
|
||
|
||
r = r * x;
|
||
t = r * INVERSE_FACTORIAL_7;
|
||
s = s + t;
|
||
|
||
r = r * x;
|
||
t = r * INVERSE_FACTORIAL_9;
|
||
s = s + t;
|
||
|
||
return s;
|
||
}
|
||
|
||
void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {
|
||
if (a == 0.0) {
|
||
sin_t = 0.0;
|
||
cos_t = 1.0;
|
||
}
|
||
sin_t = sin_taylor_fp32(a);
|
||
cos_t = sqrt(1.0 - sin_t * sin_t);
|
||
}
|
||
|
||
float tan_taylor_fp32(float a) {
|
||
float sin_a;
|
||
float cos_a;
|
||
|
||
if (a == 0.0) {
|
||
return 0.0;
|
||
}
|
||
|
||
// 2pi range reduction
|
||
float z = floor(a / TWO_PI);
|
||
float r = a - TWO_PI * z;
|
||
|
||
float t;
|
||
float q = floor(r / PI_2 + 0.5);
|
||
int j = int(q);
|
||
|
||
if (j < -2 || j > 2) {
|
||
return 1.0 / 0.0;
|
||
}
|
||
|
||
t = r - PI_2 * q;
|
||
|
||
q = floor(t / PI_16 + 0.5);
|
||
int k = int(q);
|
||
int abs_k = int(abs(float(k)));
|
||
|
||
if (abs_k > 4) {
|
||
return 1.0 / 0.0;
|
||
} else {
|
||
t = t - PI_16 * q;
|
||
}
|
||
|
||
float u = 0.0;
|
||
float v = 0.0;
|
||
|
||
float sin_t, cos_t;
|
||
float s, c;
|
||
sincos_taylor_fp32(t, sin_t, cos_t);
|
||
|
||
if (k == 0) {
|
||
s = sin_t;
|
||
c = cos_t;
|
||
} else {
|
||
if (abs(float(abs_k) - 1.0) < 0.5) {
|
||
u = COS_TABLE_0;
|
||
v = SIN_TABLE_0;
|
||
} else if (abs(float(abs_k) - 2.0) < 0.5) {
|
||
u = COS_TABLE_1;
|
||
v = SIN_TABLE_1;
|
||
} else if (abs(float(abs_k) - 3.0) < 0.5) {
|
||
u = COS_TABLE_2;
|
||
v = SIN_TABLE_2;
|
||
} else if (abs(float(abs_k) - 4.0) < 0.5) {
|
||
u = COS_TABLE_3;
|
||
v = SIN_TABLE_3;
|
||
}
|
||
if (k > 0) {
|
||
s = u * sin_t + v * cos_t;
|
||
c = u * cos_t - v * sin_t;
|
||
} else {
|
||
s = u * sin_t - v * cos_t;
|
||
c = u * cos_t + v * sin_t;
|
||
}
|
||
}
|
||
|
||
if (j == 0) {
|
||
sin_a = s;
|
||
cos_a = c;
|
||
} else if (j == 1) {
|
||
sin_a = c;
|
||
cos_a = -s;
|
||
} else if (j == -1) {
|
||
sin_a = -c;
|
||
cos_a = s;
|
||
} else {
|
||
sin_a = -s;
|
||
cos_a = -c;
|
||
}
|
||
return sin_a / cos_a;
|
||
}
|
||
#endif
|
||
|
||
float tan_fp32(float a) {
|
||
#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
||
return tan_taylor_fp32(a);
|
||
#else
|
||
return tan(a);
|
||
#endif
|
||
}
|
||
`,yO={name:`fp32`,vs:vO}})),xO,Nte=o((()=>{xO=`
|
||
layout(std140) uniform fp64arithmeticUniforms {
|
||
uniform float ONE;
|
||
uniform float SPLIT;
|
||
} fp64;
|
||
|
||
/*
|
||
About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
|
||
The purpose of this workaround is to prevent shader compilers from
|
||
optimizing away necessary arithmetic operations by swapping their sequences
|
||
or transform the equation to some 'equivalent' form.
|
||
|
||
These helpers implement Dekker/Veltkamp-style error tracking. If the compiler
|
||
folds constants or reassociates the arithmetic, the high/low split can stop
|
||
tracking the rounding error correctly. That failure mode tends to look fine in
|
||
simple coordinate setup, but then breaks down inside iterative arithmetic such
|
||
as fp64 Mandelbrot loops.
|
||
|
||
The method is to multiply an artifical variable, ONE, which will be known to
|
||
the compiler to be 1 only at runtime. The whole expression is then represented
|
||
as a polynomial with respective to ONE. In the coefficients of all terms, only one a
|
||
and one b should appear
|
||
|
||
err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
|
||
*/
|
||
|
||
float prevent_fp64_optimization(float value) {
|
||
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
||
return value + fp64.ONE * 0.0;
|
||
#else
|
||
return value;
|
||
#endif
|
||
}
|
||
|
||
// Divide float number to high and low floats to extend fraction bits
|
||
vec2 split(float a) {
|
||
// Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker
|
||
// split into a constant expression and reassociate the recovery steps.
|
||
float split = prevent_fp64_optimization(fp64.SPLIT);
|
||
float t = prevent_fp64_optimization(a * split);
|
||
float temp = t - a;
|
||
float a_hi = t - temp;
|
||
float a_lo = a - a_hi;
|
||
return vec2(a_hi, a_lo);
|
||
}
|
||
|
||
// Divide float number again when high float uses too many fraction bits
|
||
vec2 split2(vec2 a) {
|
||
vec2 b = split(a.x);
|
||
b.y += a.y;
|
||
return b;
|
||
}
|
||
|
||
// Special sum operation when a > b
|
||
vec2 quickTwoSum(float a, float b) {
|
||
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
||
float sum = (a + b) * fp64.ONE;
|
||
float err = b - (sum - a) * fp64.ONE;
|
||
#else
|
||
float sum = a + b;
|
||
float err = b - (sum - a);
|
||
#endif
|
||
return vec2(sum, err);
|
||
}
|
||
|
||
// General sum operation
|
||
vec2 twoSum(float a, float b) {
|
||
float s = (a + b);
|
||
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
||
float v = (s * fp64.ONE - a) * fp64.ONE;
|
||
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);
|
||
#else
|
||
float v = s - a;
|
||
float err = (a - (s - v)) + (b - v);
|
||
#endif
|
||
return vec2(s, err);
|
||
}
|
||
|
||
vec2 twoSub(float a, float b) {
|
||
float s = (a - b);
|
||
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
||
float v = (s * fp64.ONE - a) * fp64.ONE;
|
||
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);
|
||
#else
|
||
float v = s - a;
|
||
float err = (a - (s - v)) - (b + v);
|
||
#endif
|
||
return vec2(s, err);
|
||
}
|
||
|
||
vec2 twoSqr(float a) {
|
||
float prod = a * a;
|
||
vec2 a_fp64 = split(a);
|
||
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
||
float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *
|
||
a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;
|
||
#else
|
||
float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
|
||
#endif
|
||
return vec2(prod, err);
|
||
}
|
||
|
||
vec2 twoProd(float a, float b) {
|
||
float prod = a * b;
|
||
vec2 a_fp64 = split(a);
|
||
vec2 b_fp64 = split(b);
|
||
// twoProd is especially sensitive because mul_fp64 and div_fp64 both depend
|
||
// on the split terms and cross terms staying in the original evaluation
|
||
// order. If the compiler folds or reassociates them, the low part tends to
|
||
// collapse to zero or NaN on some drivers.
|
||
float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);
|
||
float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);
|
||
float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);
|
||
float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);
|
||
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
||
float err1 = (highProduct - prod) * fp64.ONE;
|
||
float err2 = crossProduct1 * fp64.ONE * fp64.ONE;
|
||
float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;
|
||
float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;
|
||
#else
|
||
float err1 = highProduct - prod;
|
||
float err2 = crossProduct1;
|
||
float err3 = crossProduct2;
|
||
float err4 = lowProduct;
|
||
#endif
|
||
float err = ((err1 + err2) + err3) + err4;
|
||
return vec2(prod, err);
|
||
}
|
||
|
||
vec2 sum_fp64(vec2 a, vec2 b) {
|
||
vec2 s, t;
|
||
s = twoSum(a.x, b.x);
|
||
t = twoSum(a.y, b.y);
|
||
s.y += t.x;
|
||
s = quickTwoSum(s.x, s.y);
|
||
s.y += t.y;
|
||
s = quickTwoSum(s.x, s.y);
|
||
return s;
|
||
}
|
||
|
||
vec2 sub_fp64(vec2 a, vec2 b) {
|
||
vec2 s, t;
|
||
s = twoSub(a.x, b.x);
|
||
t = twoSub(a.y, b.y);
|
||
s.y += t.x;
|
||
s = quickTwoSum(s.x, s.y);
|
||
s.y += t.y;
|
||
s = quickTwoSum(s.x, s.y);
|
||
return s;
|
||
}
|
||
|
||
vec2 mul_fp64(vec2 a, vec2 b) {
|
||
vec2 prod = twoProd(a.x, b.x);
|
||
// y component is for the error
|
||
prod.y += a.x * b.y;
|
||
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
||
prod = split2(prod);
|
||
#endif
|
||
prod = quickTwoSum(prod.x, prod.y);
|
||
prod.y += a.y * b.x;
|
||
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
||
prod = split2(prod);
|
||
#endif
|
||
prod = quickTwoSum(prod.x, prod.y);
|
||
return prod;
|
||
}
|
||
|
||
vec2 div_fp64(vec2 a, vec2 b) {
|
||
float xn = 1.0 / b.x;
|
||
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
||
vec2 yn = mul_fp64(a, vec2(xn, 0));
|
||
#else
|
||
vec2 yn = a * xn;
|
||
#endif
|
||
float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
|
||
vec2 prod = twoProd(xn, diff);
|
||
return sum_fp64(yn, prod);
|
||
}
|
||
|
||
vec2 sqrt_fp64(vec2 a) {
|
||
if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
|
||
if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
|
||
|
||
float x = 1.0 / sqrt(a.x);
|
||
float yn = a.x * x;
|
||
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
||
vec2 yn_sqr = twoSqr(yn) * fp64.ONE;
|
||
#else
|
||
vec2 yn_sqr = twoSqr(yn);
|
||
#endif
|
||
float diff = sub_fp64(a, yn_sqr).x;
|
||
vec2 prod = twoProd(x * 0.5, diff);
|
||
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
||
return sum_fp64(split(yn), prod);
|
||
#else
|
||
return sum_fp64(vec2(yn, 0.0), prod);
|
||
#endif
|
||
}
|
||
`})),SO,Pte=o((()=>{SO=`struct Fp64ArithmeticUniforms {
|
||
ONE: f32,
|
||
SPLIT: f32,
|
||
};
|
||
|
||
@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;
|
||
|
||
fn fp64_nan(seed: f32) -> f32 {
|
||
let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);
|
||
return bitcast<f32>(nanBits);
|
||
}
|
||
|
||
fn fp64_runtime_zero() -> f32 {
|
||
return fp64arithmetic.ONE * 0.0;
|
||
}
|
||
|
||
fn prevent_fp64_optimization(value: f32) -> f32 {
|
||
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
return value + fp64_runtime_zero();
|
||
#else
|
||
return value;
|
||
#endif
|
||
}
|
||
|
||
fn split(a: f32) -> vec2f {
|
||
let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());
|
||
let t = prevent_fp64_optimization(a * splitValue);
|
||
let temp = prevent_fp64_optimization(t - a);
|
||
let aHi = prevent_fp64_optimization(t - temp);
|
||
let aLo = prevent_fp64_optimization(a - aHi);
|
||
return vec2f(aHi, aLo);
|
||
}
|
||
|
||
fn split2(a: vec2f) -> vec2f {
|
||
var b = split(a.x);
|
||
b.y = b.y + a.y;
|
||
return b;
|
||
}
|
||
|
||
fn quickTwoSum(a: f32, b: f32) -> vec2f {
|
||
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);
|
||
let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);
|
||
#else
|
||
let sum = prevent_fp64_optimization(a + b);
|
||
let err = prevent_fp64_optimization(b - (sum - a));
|
||
#endif
|
||
return vec2f(sum, err);
|
||
}
|
||
|
||
fn twoSum(a: f32, b: f32) -> vec2f {
|
||
let s = prevent_fp64_optimization(a + b);
|
||
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
|
||
let err =
|
||
prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
|
||
fp64arithmetic.ONE *
|
||
fp64arithmetic.ONE *
|
||
fp64arithmetic.ONE) +
|
||
prevent_fp64_optimization(b - v);
|
||
#else
|
||
let v = prevent_fp64_optimization(s - a);
|
||
let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);
|
||
#endif
|
||
return vec2f(s, err);
|
||
}
|
||
|
||
fn twoSub(a: f32, b: f32) -> vec2f {
|
||
let s = prevent_fp64_optimization(a - b);
|
||
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
|
||
let err =
|
||
prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
|
||
fp64arithmetic.ONE *
|
||
fp64arithmetic.ONE *
|
||
fp64arithmetic.ONE) -
|
||
prevent_fp64_optimization(b + v);
|
||
#else
|
||
let v = prevent_fp64_optimization(s - a);
|
||
let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);
|
||
#endif
|
||
return vec2f(s, err);
|
||
}
|
||
|
||
fn twoSqr(a: f32) -> vec2f {
|
||
let prod = prevent_fp64_optimization(a * a);
|
||
let aFp64 = split(a);
|
||
let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);
|
||
let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);
|
||
let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);
|
||
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
let err =
|
||
(prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +
|
||
crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +
|
||
lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
|
||
#else
|
||
let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);
|
||
#endif
|
||
return vec2f(prod, err);
|
||
}
|
||
|
||
fn twoProd(a: f32, b: f32) -> vec2f {
|
||
let prod = prevent_fp64_optimization(a * b);
|
||
let aFp64 = split(a);
|
||
let bFp64 = split(b);
|
||
let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);
|
||
let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);
|
||
let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);
|
||
let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);
|
||
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
let err1 = (highProduct - prod) * fp64arithmetic.ONE;
|
||
let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;
|
||
let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
|
||
let err4 =
|
||
lowProduct *
|
||
fp64arithmetic.ONE *
|
||
fp64arithmetic.ONE *
|
||
fp64arithmetic.ONE *
|
||
fp64arithmetic.ONE;
|
||
#else
|
||
let err1 = highProduct - prod;
|
||
let err2 = crossProduct1;
|
||
let err3 = crossProduct2;
|
||
let err4 = lowProduct;
|
||
#endif
|
||
let err12InputA = prevent_fp64_optimization(err1);
|
||
let err12InputB = prevent_fp64_optimization(err2);
|
||
let err12 = prevent_fp64_optimization(err12InputA + err12InputB);
|
||
let err123InputA = prevent_fp64_optimization(err12);
|
||
let err123InputB = prevent_fp64_optimization(err3);
|
||
let err123 = prevent_fp64_optimization(err123InputA + err123InputB);
|
||
let err1234InputA = prevent_fp64_optimization(err123);
|
||
let err1234InputB = prevent_fp64_optimization(err4);
|
||
let err = prevent_fp64_optimization(err1234InputA + err1234InputB);
|
||
return vec2f(prod, err);
|
||
}
|
||
|
||
fn sum_fp64(a: vec2f, b: vec2f) -> vec2f {
|
||
var s = twoSum(a.x, b.x);
|
||
let t = twoSum(a.y, b.y);
|
||
s.y = prevent_fp64_optimization(s.y + t.x);
|
||
s = quickTwoSum(s.x, s.y);
|
||
s.y = prevent_fp64_optimization(s.y + t.y);
|
||
s = quickTwoSum(s.x, s.y);
|
||
return s;
|
||
}
|
||
|
||
fn sub_fp64(a: vec2f, b: vec2f) -> vec2f {
|
||
var s = twoSub(a.x, b.x);
|
||
let t = twoSub(a.y, b.y);
|
||
s.y = prevent_fp64_optimization(s.y + t.x);
|
||
s = quickTwoSum(s.x, s.y);
|
||
s.y = prevent_fp64_optimization(s.y + t.y);
|
||
s = quickTwoSum(s.x, s.y);
|
||
return s;
|
||
}
|
||
|
||
fn mul_fp64(a: vec2f, b: vec2f) -> vec2f {
|
||
var prod = twoProd(a.x, b.x);
|
||
let crossProduct1 = prevent_fp64_optimization(a.x * b.y);
|
||
prod.y = prevent_fp64_optimization(prod.y + crossProduct1);
|
||
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
|
||
prod = split2(prod);
|
||
#endif
|
||
prod = quickTwoSum(prod.x, prod.y);
|
||
let crossProduct2 = prevent_fp64_optimization(a.y * b.x);
|
||
prod.y = prevent_fp64_optimization(prod.y + crossProduct2);
|
||
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
|
||
prod = split2(prod);
|
||
#endif
|
||
prod = quickTwoSum(prod.x, prod.y);
|
||
return prod;
|
||
}
|
||
|
||
fn div_fp64(a: vec2f, b: vec2f) -> vec2f {
|
||
let xn = prevent_fp64_optimization(1.0 / b.x);
|
||
let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));
|
||
let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);
|
||
let prod = twoProd(xn, diff);
|
||
return sum_fp64(yn, prod);
|
||
}
|
||
|
||
fn sqrt_fp64(a: vec2f) -> vec2f {
|
||
if (a.x == 0.0 && a.y == 0.0) {
|
||
return vec2f(0.0, 0.0);
|
||
}
|
||
if (a.x < 0.0) {
|
||
let nanValue = fp64_nan(a.x);
|
||
return vec2f(nanValue, nanValue);
|
||
}
|
||
|
||
let x = prevent_fp64_optimization(1.0 / sqrt(a.x));
|
||
let yn = prevent_fp64_optimization(a.x * x);
|
||
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
||
let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;
|
||
#else
|
||
let ynSqr = twoSqr(yn);
|
||
#endif
|
||
let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);
|
||
let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);
|
||
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
|
||
return sum_fp64(split(yn), prod);
|
||
#else
|
||
return sum_fp64(vec2f(yn, 0.0), prod);
|
||
#endif
|
||
}
|
||
`})),CO,wO,Fte=o((()=>{pO(),Nte(),Pte(),CO={ONE:1,SPLIT:4097},wO={name:`fp64arithmetic`,source:SO,fs:xO,vs:xO,defaultUniforms:CO,uniformTypes:{ONE:`f32`,SPLIT:`f32`},fp64ify:uO,fp64LowPart:dO,fp64ifyMatrix4:fO}})),TO,EO,DO,OO=o((()=>{TO=`layout(std140) uniform floatColorsUniforms {
|
||
float useByteColors;
|
||
} floatColors;
|
||
|
||
vec3 floatColors_normalize(vec3 inputColor) {
|
||
return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;
|
||
}
|
||
|
||
vec4 floatColors_normalize(vec4 inputColor) {
|
||
return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;
|
||
}
|
||
|
||
vec4 floatColors_premultiplyAlpha(vec4 inputColor) {
|
||
return vec4(inputColor.rgb * inputColor.a, inputColor.a);
|
||
}
|
||
|
||
vec4 floatColors_unpremultiplyAlpha(vec4 inputColor) {
|
||
return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);
|
||
}
|
||
|
||
vec4 floatColors_premultiply_alpha(vec4 inputColor) {
|
||
return floatColors_premultiplyAlpha(inputColor);
|
||
}
|
||
|
||
vec4 floatColors_unpremultiply_alpha(vec4 inputColor) {
|
||
return floatColors_unpremultiplyAlpha(inputColor);
|
||
}
|
||
`,EO=`struct floatColorsUniforms {
|
||
useByteColors: f32
|
||
};
|
||
|
||
@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms;
|
||
|
||
fn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> {
|
||
return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);
|
||
}
|
||
|
||
fn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> {
|
||
return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);
|
||
}
|
||
|
||
fn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {
|
||
return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);
|
||
}
|
||
|
||
fn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {
|
||
return select(
|
||
vec4<f32>(0.0),
|
||
vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a),
|
||
inputColor.a > 0.0
|
||
);
|
||
}
|
||
|
||
fn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
||
return floatColors_premultiplyAlpha(inputColor);
|
||
}
|
||
|
||
fn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
||
return floatColors_unpremultiplyAlpha(inputColor);
|
||
}
|
||
`,DO={name:`floatColors`,props:{},uniforms:{},vs:TO,fs:TO,source:EO,uniformTypes:{useByteColors:`f32`},defaultUniforms:{useByteColors:!0}}}));function Ite(e={},t){let n={},r=mO(e.useByteColors,!0);return e.highlightedObjectColor===void 0||(e.highlightedObjectColor===null?n.isHighlightActive=!1:(n.isHighlightActive=!0,n.highlightedObjectColor=e.highlightedObjectColor.slice(0,3))),e.highlightColor&&(n.highlightColor=gO(e.highlightColor,r)),e.isActive!==void 0&&(n.isActive=!!e.isActive,n.isAttribute=!!e.isAttribute),e.useByteColors!==void 0&&(n.useByteColors=!!e.useByteColors),n}var kO,AO,jO,MO,Lte=o((()=>{_O(),kO=[0,1,1,1],AO=`layout(std140) uniform pickingUniforms {
|
||
float isActive;
|
||
float isAttribute;
|
||
float isHighlightActive;
|
||
float useByteColors;
|
||
vec3 highlightedObjectColor;
|
||
vec4 highlightColor;
|
||
} picking;
|
||
|
||
out vec4 picking_vRGBcolor_Avalid;
|
||
|
||
// Normalize unsigned byte color to 0-1 range
|
||
vec3 picking_normalizeColor(vec3 color) {
|
||
return picking.useByteColors > 0.5 ? color / 255.0 : color;
|
||
}
|
||
|
||
// Normalize unsigned byte color to 0-1 range
|
||
vec4 picking_normalizeColor(vec4 color) {
|
||
return picking.useByteColors > 0.5 ? color / 255.0 : color;
|
||
}
|
||
|
||
bool picking_isColorZero(vec3 color) {
|
||
return dot(color, vec3(1.0)) < 0.00001;
|
||
}
|
||
|
||
bool picking_isColorValid(vec3 color) {
|
||
return dot(color, vec3(1.0)) > 0.00001;
|
||
}
|
||
|
||
// Check if this vertex is highlighted
|
||
bool isVertexHighlighted(vec3 vertexColor) {
|
||
vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
||
return
|
||
bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));
|
||
}
|
||
|
||
// Set the current picking color
|
||
void picking_setPickingColor(vec3 pickingColor) {
|
||
pickingColor = picking_normalizeColor(pickingColor);
|
||
|
||
if (bool(picking.isActive)) {
|
||
// Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable
|
||
picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));
|
||
|
||
if (!bool(picking.isAttribute)) {
|
||
// Stores the picking color so that the fragment shader can render it during picking
|
||
picking_vRGBcolor_Avalid.rgb = pickingColor;
|
||
}
|
||
} else {
|
||
// Do the comparison with selected item color in vertex shader as it should mean fewer compares
|
||
picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));
|
||
}
|
||
}
|
||
|
||
void picking_setPickingAttribute(float value) {
|
||
if (bool(picking.isAttribute)) {
|
||
picking_vRGBcolor_Avalid.r = value;
|
||
}
|
||
}
|
||
|
||
void picking_setPickingAttribute(vec2 value) {
|
||
if (bool(picking.isAttribute)) {
|
||
picking_vRGBcolor_Avalid.rg = value;
|
||
}
|
||
}
|
||
|
||
void picking_setPickingAttribute(vec3 value) {
|
||
if (bool(picking.isAttribute)) {
|
||
picking_vRGBcolor_Avalid.rgb = value;
|
||
}
|
||
}
|
||
`,jO=`layout(std140) uniform pickingUniforms {
|
||
float isActive;
|
||
float isAttribute;
|
||
float isHighlightActive;
|
||
float useByteColors;
|
||
vec3 highlightedObjectColor;
|
||
vec4 highlightColor;
|
||
} picking;
|
||
|
||
in vec4 picking_vRGBcolor_Avalid;
|
||
|
||
/*
|
||
* Returns highlight color if this item is selected.
|
||
*/
|
||
vec4 picking_filterHighlightColor(vec4 color) {
|
||
// If we are still picking, we don't highlight
|
||
if (picking.isActive > 0.5) {
|
||
return color;
|
||
}
|
||
|
||
bool selected = bool(picking_vRGBcolor_Avalid.a);
|
||
|
||
if (selected) {
|
||
// Blend in highlight color based on its alpha value
|
||
float highLightAlpha = picking.highlightColor.a;
|
||
float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
|
||
float highLightRatio = highLightAlpha / blendedAlpha;
|
||
|
||
vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);
|
||
return vec4(blendedRGB, blendedAlpha);
|
||
} else {
|
||
return color;
|
||
}
|
||
}
|
||
|
||
/*
|
||
* Returns picking color if picking enabled else unmodified argument.
|
||
*/
|
||
vec4 picking_filterPickingColor(vec4 color) {
|
||
if (bool(picking.isActive)) {
|
||
if (picking_vRGBcolor_Avalid.a == 0.0) {
|
||
discard;
|
||
}
|
||
return picking_vRGBcolor_Avalid;
|
||
}
|
||
return color;
|
||
}
|
||
|
||
/*
|
||
* Returns picking color if picking is enabled if not
|
||
* highlight color if this item is selected, otherwise unmodified argument.
|
||
*/
|
||
vec4 picking_filterColor(vec4 color) {
|
||
vec4 highlightColor = picking_filterHighlightColor(color);
|
||
return picking_filterPickingColor(highlightColor);
|
||
}
|
||
`,MO={props:{},uniforms:{},name:`picking`,uniformTypes:{isActive:`f32`,isAttribute:`f32`,isHighlightActive:`f32`,useByteColors:`f32`,highlightedObjectColor:`vec3<f32>`,highlightColor:`vec4<f32>`},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:kO},vs:AO,fs:jO,getUniforms:Ite}}));function Rte(e,t){let n=e.stats,r=!1;for(let i of t)n[i]||(e.get(i),r=!0);let i=Object.keys(n).length,a=FO.get(e);if(!r&&a?.orderedStatNames===t&&a.statCount===i)return;let o={},s=IO.get(t);s||(s=new Set(t),IO.set(t,s));for(let e of t)n[e]&&(o[e]=n[e]);for(let[e,t]of Object.entries(n))s.has(e)||(o[e]=t);for(let e of Object.keys(n))delete n[e];Object.assign(n,o),FO.set(e,{orderedStatNames:t,statCount:i})}var NO,PO,FO,IO,LO,RO,zO=o((()=>{Yx(),NO=`GPU Time and Memory`,PO=[`Adapter`,`GPU`,`GPU Type`,`GPU Backend`,`Frame Rate`,`CPU Time`,`GPU Time`,`GPU Memory`,`Buffer Memory`,`Texture Memory`,`Referenced Buffer Memory`,`Referenced Texture Memory`,`Swap Chain Texture`],FO=new WeakMap,IO=new WeakMap,LO=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new qx({id:e}));let t=this.stats.get(e);return e===NO&&Rte(t,PO),t}},RO=new LO})),Z,BO=o((()=>{Ob(),Z=new Tb({id:`luma.gl`})}));function VO(e=`id`){return HO[e]=HO[e]||1,`${e}-${HO[e]++}`}var HO,UO=o((()=>{HO={}}));function WO(e,t){let n={...t};for(let t in e)e[t]!==void 0&&(n[t]=e[t]);return n}function GO(e,t){let n=e.stats,r=!1;for(let i of t)n[i]||(e.get(i),r=!0);let i=Object.keys(n).length,a=ok.get(e);if(!r&&a?.orderedStatNames===t&&a.statCount===i)return;let o={},s=sk.get(t);s||(s=new Set(t),sk.set(t,s));for(let e of t)n[e]&&(o[e]=n[e]);for(let[e,t]of Object.entries(n))s.has(e)||(o[e]=t);for(let e of Object.keys(n))delete n[e];Object.assign(n,o),ok.set(e,{orderedStatNames:t,statCount:i})}function KO(e){return e.type===`webgl`?ak:ik}function qO(e){let t=e.userData[QO];return t?.enabled?t:null}function JO(){return globalThis.performance?.now?.()??Date.now()}function YO(e,t){let n=qO(e);if(!(!n||!n.activeDefaultFramebufferAcquireDepth))switch(n.transientCanvasResourceCreates=(n.transientCanvasResourceCreates||0)+1,t){case`Texture`:n.transientCanvasTextureCreates=(n.transientCanvasTextureCreates||0)+1;break;case`TextureView`:n.transientCanvasTextureViewCreates=(n.transientCanvasTextureViewCreates||0)+1;break;case`Sampler`:n.transientCanvasSamplerCreates=(n.transientCanvasSamplerCreates||0)+1;break;case`Framebuffer`:n.transientCanvasFramebufferCreates=(n.transientCanvasFramebufferCreates||0)+1;break;default:break}}function XO(e){let t=Object.getPrototypeOf(e);for(;t;){let n=Object.getPrototypeOf(t);if(!n||n===ck.prototype)return ZO(t)||e[Symbol.toStringTag]||e.constructor.name;t=n}return e[Symbol.toStringTag]||e.constructor.name}function ZO(e){let t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag);return typeof t?.get==`function`?t.get.call(e):typeof t?.value==`string`?t.value:null}var QO,$O,ek,tk,nk,rk,ik,ak,ok,sk,ck,lk=o((()=>{UO(),QO=`cpu-hotspot-profiler`,$O=`GPU Resource Counts`,ek=`Resource Counts`,tk=`GPU Time and Memory`,nk=[`Resources`,`Buffers`,`Textures`,`Samplers`,`TextureViews`,`Framebuffers`,`QuerySets`,`Shaders`,`RenderPipelines`,`ComputePipelines`,`PipelineLayouts`,`VertexArrays`,`RenderPasss`,`ComputePasss`,`CommandEncoders`,`CommandBuffers`],rk=[`Resources`,`Buffers`,`Textures`,`Samplers`,`TextureViews`,`Framebuffers`,`QuerySets`,`Shaders`,`RenderPipelines`,`SharedRenderPipelines`,`ComputePipelines`,`PipelineLayouts`,`VertexArrays`,`RenderPasss`,`ComputePasss`,`CommandEncoders`,`CommandBuffers`],ik=nk.flatMap(e=>[`${e} Created`,`${e} Active`]),ak=rk.flatMap(e=>[`${e} Created`,`${e} Active`]),ok=new WeakMap,sk=new WeakMap,ck=class{static defaultProps={id:`undefined`,handle:void 0,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,t,n){if(!e)throw Error(`no device`);this._device=e,this.props=WO(t,n);let r=this.props.id===`undefined`?VO(this[Symbol.toStringTag]):this.props.id;this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||=(this.destroyAttachedResources(),this.removeStats(),!0)}removeStats(){let e=qO(this._device),t=e?JO():0,n=[this._device.statsManager.getStats($O),this._device.statsManager.getStats(ek)],r=KO(this._device);for(let e of n)GO(e,r);let i=this.getStatsName();for(let e of n)e.get(`Resources Active`).decrementCount(),e.get(`${i}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(JO()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let n=qO(this._device),r=n?JO():0,i=this._device.statsManager.getStats(tk);this.allocatedBytes>0&&this.allocatedBytesName&&(i.get(`GPU Memory`).subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),i.get(`GPU Memory`).addCount(e),i.get(`${t} Memory`).addCount(e),n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(JO()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=qO(this._device),n=t?JO():0,r=this._device.statsManager.getStats(tk);r.get(`GPU Memory`).subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(JO()-n)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=qO(this._device),n=t?JO():0,r=[this._device.statsManager.getStats($O),this._device.statsManager.getStats(ek)],i=KO(this._device);for(let e of r)GO(e,i);for(let t of r)t.get(`Resources Created`).incrementCount(),t.get(`Resources Active`).incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(JO()-n)),YO(this._device,e)}getStatsName(){return XO(this)}}})),uk,dk=o((()=>{lk(),uk=class e extends ck{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return`Buffer`}usage;indexType;updateTimestamp;constructor(t,n){let r={...n};(n.usage||0)&e.INDEX&&!n.indexType&&(n.data instanceof Uint32Array?r.indexType=`uint32`:n.data instanceof Uint16Array?r.indexType=`uint16`:n.data instanceof Uint8Array&&(r.indexType=`uint8`)),delete r.data,super(t,r,e.defaultProps),this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(t,n,r){let i=null,a;ArrayBuffer.isView(t)?(i=t,a=t.buffer):a=t;let o=Math.min(t?t.byteLength:r,e.DEBUG_DATA_MAX_LENGTH);if(a===null)this.debugData=new ArrayBuffer(o);else{let e=Math.min(i?.byteOffset||0,a.byteLength),t=Math.max(0,a.byteLength-e),n=Math.min(o,t);this.debugData=new Uint8Array(a,e,n).slice().buffer}}static defaultProps={...ck.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:`uint16`,onMapped:void 0}}})),fk,pk,mk,hk=o((()=>{fk=class{getDataTypeInfo(e){let[t,n,r]=mk[e],i=e.includes(`norm`);return{signedType:t,primitiveType:n,byteLength:r,normalized:i,integer:!i&&!e.startsWith(`float`),signed:e.startsWith(`s`)}}getNormalizedDataType(e){let t=e;switch(t){case`uint8`:return`unorm8`;case`sint8`:return`snorm8`;case`uint16`:return`unorm16`;case`sint16`:return`snorm16`;default:return t}}alignTo(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let t=ArrayBuffer.isView(e)?e.constructor:e;if(t===Uint8ClampedArray)return`uint8`;let n=Object.values(mk).find(e=>t===e[4]);if(!n)throw Error(t.name);return n[0]}getTypedArrayConstructor(e){let[,,,,t]=mk[e];return t}},pk=new fk,mk={uint8:[`uint8`,`u32`,1,!1,Uint8Array],sint8:[`sint8`,`i32`,1,!1,Int8Array],unorm8:[`uint8`,`f32`,1,!0,Uint8Array],snorm8:[`sint8`,`f32`,1,!0,Int8Array],uint16:[`uint16`,`u32`,2,!1,Uint16Array],sint16:[`sint16`,`i32`,2,!1,Int16Array],unorm16:[`uint16`,`u32`,2,!0,Uint16Array],snorm16:[`sint16`,`i32`,2,!0,Int16Array],float16:[`float16`,`f16`,2,!1,Uint16Array],float32:[`float32`,`f32`,4,!1,Float32Array],uint32:[`uint32`,`u32`,4,!1,Uint32Array],sint32:[`sint32`,`i32`,4,!1,Int32Array]}})),gk,_k,vk=o((()=>{hk(),gk=class{getVertexFormatInfo(e){let t;e.endsWith(`-webgl`)&&(e.replace(`-webgl`,``),t=!0);let[n,r]=e.split(`x`),i=n,a=r?parseInt(r):1,o=pk.getDataTypeInfo(i),s={type:i,components:a,byteLength:o.byteLength*a,integer:o.integer,signed:o.signed,normalized:o.normalized};return t&&(s.webglOnly=!0),s}makeVertexFormat(e,t,n){let r=n?pk.getNormalizedDataType(e):e;switch(r){case`unorm8`:return t===1?`unorm8`:t===3?`unorm8x3-webgl`:`${r}x${t}`;case`snorm8`:return t===1?`snorm8`:t===3?`snorm8x3-webgl`:`${r}x${t}`;case`uint8`:case`sint8`:if(t===1||t===3)throw Error(`size: ${t}`);return`${r}x${t}`;case`uint16`:return t===1?`uint16`:t===3?`uint16x3-webgl`:`${r}x${t}`;case`sint16`:return t===1?`sint16`:t===3?`sint16x3-webgl`:`${r}x${t}`;case`unorm16`:return t===1?`unorm16`:t===3?`unorm16x3-webgl`:`${r}x${t}`;case`snorm16`:return t===1?`snorm16`:t===3?`snorm16x3-webgl`:`${r}x${t}`;case`float16`:if(t===1||t===3)throw Error(`size: ${t}`);return`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,n){if(!t||t>4)throw Error(`size ${t}`);let r=t,i=pk.getDataType(e);return this.makeVertexFormat(i,r,n)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case`f32`:t=`float32`;break;case`i32`:t=`sint32`;break;case`u32`:t=`uint32`;break;case`f16`:return e.components<=2?`float16x2`:`float16x4`}return e.components===1?t:`${t}x${e.components}`}},_k=new gk}));function yk(e){let t=Rk[e];if(!t)throw Error(`Unsupported texture format ${e}`);return t}function bk(){return Rk}var xk,Sk,Ck,wk,Tk,Ek,Dk,Ok,kk,Ak,jk,Mk,Nk,Pk,Fk,Ik,Lk,Rk,zk=o((()=>{xk=`texture-compression-bc`,Sk=`texture-compression-astc`,Ck=`texture-compression-etc2`,wk=`texture-compression-etc1-webgl`,Tk=`texture-compression-pvrtc-webgl`,Ek=`texture-compression-atc-webgl`,Dk=`float32-renderable-webgl`,Ok=`float16-renderable-webgl`,kk=`rgb9e5ufloat-renderable-webgl`,Ak=`snorm8-renderable-webgl`,jk=`norm16-webgl`,Mk=`norm16-renderable-webgl`,Nk=`snorm16-renderable-webgl`,Pk=`float32-filterable`,Fk=`float16-filterable-webgl`,Ik={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Ak},rg8snorm:{render:Ak},"rgb8snorm-webgl":{},rgba8snorm:{render:Ak},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:jk,render:Mk},rg16unorm:{f:jk,render:Mk},"rgb16unorm-webgl":{f:jk,render:!1},rgba16unorm:{f:jk,render:Mk},r16snorm:{f:jk,render:Nk},rg16snorm:{f:jk,render:Nk},"rgb16snorm-webgl":{f:jk,render:!1},rgba16snorm:{f:jk,render:Nk},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Ok,filter:`float16-filterable-webgl`},rg16float:{render:Ok,filter:Fk},rgba16float:{render:Ok,filter:Fk},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Dk,filter:Pk},rg32float:{render:!1,filter:Pk},"rgb32float-webgl":{render:Dk,filter:Pk},rgba32float:{render:Dk,filter:Pk},"rgba4unorm-webgl":{channels:`rgba`,bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:`rgb`,bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:`rgba`,bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:`rgb`,packed:!0,render:kk},rg11b10ufloat:{channels:`rgb`,bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Dk},rgb10a2unorm:{channels:`rgba`,bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:`rgba`,bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:`stencil`,bitsPerChannel:[8,0,0,0],dataType:`uint8`},depth16unorm:{attachment:`depth`,bitsPerChannel:[16,0,0,0],dataType:`uint16`},depth24plus:{attachment:`depth`,bitsPerChannel:[24,0,0,0],dataType:`uint32`},depth32float:{attachment:`depth`,bitsPerChannel:[32,0,0,0],dataType:`float32`},"depth24plus-stencil8":{attachment:`depth-stencil`,bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:`depth-stencil`,bitsPerChannel:[32,8,0,0],packed:!0}},Lk={"bc1-rgb-unorm-webgl":{f:xk},"bc1-rgb-unorm-srgb-webgl":{f:xk},"bc1-rgba-unorm":{f:xk},"bc1-rgba-unorm-srgb":{f:xk},"bc2-rgba-unorm":{f:xk},"bc2-rgba-unorm-srgb":{f:xk},"bc3-rgba-unorm":{f:xk},"bc3-rgba-unorm-srgb":{f:xk},"bc4-r-unorm":{f:xk},"bc4-r-snorm":{f:xk},"bc5-rg-unorm":{f:xk},"bc5-rg-snorm":{f:xk},"bc6h-rgb-ufloat":{f:xk},"bc6h-rgb-float":{f:xk},"bc7-rgba-unorm":{f:xk},"bc7-rgba-unorm-srgb":{f:xk},"etc2-rgb8unorm":{f:Ck},"etc2-rgb8unorm-srgb":{f:Ck},"etc2-rgb8a1unorm":{f:Ck},"etc2-rgb8a1unorm-srgb":{f:Ck},"etc2-rgba8unorm":{f:Ck},"etc2-rgba8unorm-srgb":{f:Ck},"eac-r11unorm":{f:Ck},"eac-r11snorm":{f:Ck},"eac-rg11unorm":{f:Ck},"eac-rg11snorm":{f:Ck},"astc-4x4-unorm":{f:Sk},"astc-4x4-unorm-srgb":{f:Sk},"astc-5x4-unorm":{f:Sk},"astc-5x4-unorm-srgb":{f:Sk},"astc-5x5-unorm":{f:Sk},"astc-5x5-unorm-srgb":{f:Sk},"astc-6x5-unorm":{f:Sk},"astc-6x5-unorm-srgb":{f:Sk},"astc-6x6-unorm":{f:Sk},"astc-6x6-unorm-srgb":{f:Sk},"astc-8x5-unorm":{f:Sk},"astc-8x5-unorm-srgb":{f:Sk},"astc-8x6-unorm":{f:Sk},"astc-8x6-unorm-srgb":{f:Sk},"astc-8x8-unorm":{f:Sk},"astc-8x8-unorm-srgb":{f:Sk},"astc-10x5-unorm":{f:Sk},"astc-10x5-unorm-srgb":{f:Sk},"astc-10x6-unorm":{f:Sk},"astc-10x6-unorm-srgb":{f:Sk},"astc-10x8-unorm":{f:Sk},"astc-10x8-unorm-srgb":{f:Sk},"astc-10x10-unorm":{f:Sk},"astc-10x10-unorm-srgb":{f:Sk},"astc-12x10-unorm":{f:Sk},"astc-12x10-unorm-srgb":{f:Sk},"astc-12x12-unorm":{f:Sk},"astc-12x12-unorm-srgb":{f:Sk},"pvrtc-rgb4unorm-webgl":{f:Tk},"pvrtc-rgba4unorm-webgl":{f:Tk},"pvrtc-rgb2unorm-webgl":{f:Tk},"pvrtc-rgba2unorm-webgl":{f:Tk},"etc1-rbg-unorm-webgl":{f:wk},"atc-rgb-unorm-webgl":{f:Ek},"atc-rgba-unorm-webgl":{f:Ek},"atc-rgbai-unorm-webgl":{f:Ek}},Rk={...Ik,...Lk}}));function Bk({format:e,width:t,height:n,depth:r,byteAlignment:i}){let{bytesPerPixel:a,bytesPerBlock:o=a,blockWidth:s=1,blockHeight:c=1,compressed:l=!1}=Zk.getInfo(e),u=l?Math.ceil(t/s):t,d=l?Math.ceil(n/c):n,f=u*o,p=Math.ceil(f/i)*i,m=d,h=p*m*r;return{bytesPerPixel:a,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:r,bytesPerImage:p*m,byteLength:h}}function Vk(e){let t=yk(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=Hk(e),i=e.startsWith(`depth`)||e.startsWith(`stencil`),a=r?.signed,o=r?.integer,s=r?.webgl,c=!!r?.compressed;return n.render&&=!i&&!c,n.filter&&=!i&&!a&&!o&&!s,n}function Hk(e){let t=Uk(e);if(Zk.isCompressed(e)){t.channels=`rgb`,t.components=3,t.bytesPerPixel=1,t.srgb=!1,t.compressed=!0,t.bytesPerBlock=Gk(e);let n=Wk(e);n&&(t.blockWidth=n.blockWidth,t.blockHeight=n.blockHeight)}let n=t.packed?null:Kk.exec(e);if(n){let[,r,i,a,o,s]=n,c=`${a}${i}`,l=pk.getDataTypeInfo(c),u=l.byteLength*8,d=r?.length??1,f=[u,d>=2?u:0,d>=3?u:0,d>=4?u:0];t={format:e,attachment:t.attachment,dataType:l.signedType,components:d,channels:r,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:f,bytesPerPixel:l.byteLength*d,packed:t.packed,srgb:t.srgb},s===`-webgl`&&(t.webgl=!0),o===`-srgb`&&(t.srgb=!0)}return e.endsWith(`-webgl`)&&(t.webgl=!0),e.endsWith(`-srgb`)&&(t.srgb=!0),t}function Uk(e){let t=yk(e),n=t.bytesPerPixel||1,r=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,{...t,format:e,attachment:t.attachment||`color`,channels:t.channels||`r`,components:t.components||t.channels?.length||1,bytesPerPixel:n,bitsPerChannel:r,dataType:t.dataType||`uint8`,srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}function Wk(e){let t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){let[,e,n]=t;return{blockWidth:Number(e),blockHeight:Number(n)}}return e.startsWith(`bc`)||e.startsWith(`etc1`)||e.startsWith(`etc2`)||e.startsWith(`eac`)||e.startsWith(`atc`)||e.startsWith(`pvrtc-rgb4`)||e.startsWith(`pvrtc-rgba4`)?{blockWidth:4,blockHeight:4}:e.startsWith(`pvrtc-rgb2`)||e.startsWith(`pvrtc-rgba2`)?{blockWidth:8,blockHeight:4}:null}function Gk(e){return e.startsWith(`bc1`)||e.startsWith(`bc4`)||e.startsWith(`etc1`)||e.startsWith(`etc2-rgb8`)||e.startsWith(`etc2-rgb8a1`)||e.startsWith(`eac-r11`)||e===`atc-rgb-unorm-webgl`?8:e.startsWith(`bc2`)||e.startsWith(`bc3`)||e.startsWith(`bc5`)||e.startsWith(`bc6h`)||e.startsWith(`bc7`)||e.startsWith(`etc2-rgba8`)||e.startsWith(`eac-rg11`)||e.startsWith(`astc`)||e===`atc-rgba-unorm-webgl`||e===`atc-rgbai-unorm-webgl`?16:e.startsWith(`pvrtc`)?8:16}var Kk,qk,Jk,Yk,Xk,Zk,Qk=o((()=>{hk(),zk(),Kk=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,qk=[`rgb`,`rgba`,`bgra`],Jk=[`depth`,`stencil`],Yk=[`bc1`,`bc2`,`bc3`,`bc4`,`bc5`,`bc6`,`bc7`,`etc1`,`etc2`,`eac`,`atc`,`astc`,`pvrtc`],Xk=class{isColor(e){return qk.some(t=>e.startsWith(t))}isDepthStencil(e){return Jk.some(t=>e.startsWith(t))}isCompressed(e){return Yk.some(t=>e.startsWith(t))}getInfo(e){return Hk(e)}getCapabilities(e){return Vk(e)}computeMemoryLayout(e){return Bk(e)}},Zk=new Xk}));function $k(e){return typeof ImageData<`u`&&e instanceof ImageData||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLVideoElement<`u`&&e instanceof HTMLVideoElement||typeof VideoFrame<`u`&&e instanceof VideoFrame||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas}function eA(e){if(typeof ImageData<`u`&&e instanceof ImageData||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if(typeof HTMLVideoElement<`u`&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if(typeof VideoFrame<`u`&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw Error(`Unknown image type`)}var tA=o((()=>{}));function zte(e,t){return[nA(e),...t.map(nA).filter(e=>e!==void 0)].filter(e=>e!==void 0)}function nA(e){if(e!==void 0){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(nA);if(typeof e==`object`){if(Bte(e)){let t=String(e);if(t!==`[object Object]`)return t}return Vte(e)?Hte(e):e.constructor?.name||`Object`}return String(e)}}function Bte(e){return`toString`in e&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString}function Vte(e){return`message`in e&&`type`in e}function Hte(e){let t=typeof e.type==`string`?e.type:`message`,n=typeof e.message==`string`?e.message:``,r=typeof e.lineNum==`number`?e.lineNum:null,i=typeof e.linePos==`number`?e.linePos:null;return`${t}${r!==null&&i!==null?` @ ${r}:${i}`:r===null?``:` @ ${r}`}: ${n}`.trim()}function Ute(e,t){return e==null?t===void 0?!1:t!==`production`:!!e}function Wte(){return Ute(Z.get(`debug`),Gte())}function Gte(){let e=globalThis.process;if(e?.env)return e.env.NODE_ENV}var rA,iA,aA,oA=o((()=>{zO(),BO(),UO(),dk(),vk(),Qk(),tA(),zk(),rA=class{},iA=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},aA=class e{static defaultProps={id:null,powerPreference:`high-performance`,failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[n,r]=e.getDevicePixelSize();Z.log(1,`${e} resized => ${n}x${r}px`)()},onPositionChange:(e,t)=>{let[n,r]=e.getPosition();Z.log(1,`${e} repositioned => ${n},${r}`)()},onVisibilityChange:e=>Z.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>Z.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:Wte(),debugGPUTime:!1,debugShaders:Z.get(`debug-shaders`)||void 0,debugFramebuffers:!!Z.get(`debug-framebuffers`),debugFactories:!!Z.get(`debug-factories`),debugWebGL:!!Z.get(`debug-webgl`),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};get[Symbol.toStringTag](){return`Device`}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=RO;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(t){this.props={...e.defaultProps,...t},this.id=this.props.id||VO(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return _k.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Zk.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){return 1+Math.floor(Math.log2(Math.max(e,t,n)))}isExternalImage(e){return $k(e)}getExternalImageSize(e){return eA(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Zk.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(bk()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){if(!this.props.onError(e,t)){let r=zte(t,n);return Z.error(this.type===`webgl`?`%cWebGL`:`%cWebGPU`,`color: white; background: red; padding: 2px 6px; border-radius: 3px;`,e.message,...r)}return()=>{}}debug(){if(this.props.debug)debugger;else Z.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
||
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw Error(`Device has no default CanvasContext. See props.createCanvasContext`);return this.canvasContext}createFence(){throw Error(`createFence() not implemented`)}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw Error(`not implemented`)}_createSharedRenderPipelineWebGL(e){throw Error(`_createSharedRenderPipelineWebGL() not implemented`)}_createBindGroupLayoutWebGPU(e,t){throw Error(`_createBindGroupLayoutWebGPU() not implemented`)}_createBindGroupWebGPU(e,t,n,r,i){throw Error(`_createBindGroupWebGPU() not implemented`)}_supportsDebugGPUTime(){return this.features.has(`timestamp-query`)&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:`timestamp`,count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&=(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw Error(`not implemented`)}readPixelsToBufferWebGL(e,t){throw Error(`not implemented`)}setParametersWebGL(e){throw Error(`not implemented`)}getParametersWebGL(e){throw Error(`not implemented`)}withParametersWebGL(e,t){throw Error(`not implemented`)}clearWebGL(e){throw Error(`not implemented`)}resetWebGL(){throw Error(`not implemented`)}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=Zk.getCapabilities(e),n=e=>(typeof e==`string`?this.features.has(e):e)??!0,r=n(t.create);return{format:e,create:r,render:r&&n(t.render),filter:r&&n(t.filter),blend:r&&n(t.blend),store:r&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&uk.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType=`uint32`:e.data instanceof Uint16Array?t.indexType=`uint16`:e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType=`uint16`)),!t.indexType))throw Error(`indices buffer content must be of type uint16 or uint32`);return t}}})),sA,cA,lA,uA,Kte=o((()=>{oA(),zO(),BO(),sA=`set luma.log.level=1 (or higher) to trace rendering`,cA="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",lA=class e{static defaultProps={...aA.defaultProps,type:`best-available`,adapters:void 0,waitForPageLoad:!0};stats=RO;log=Z;VERSION=`9.3.3`;spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Z.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Z.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)(),Error(`luma.gl - multiple versions detected: see console log`);Z.error(`This version of luma.gl has already been initialized`)()}Z.log(1,`${this.VERSION} - ${sA}`)(),globalThis.luma=this}async createDevice(t={}){let n={...e.defaultProps,...t},r=this.selectAdapter(n.type,n.adapters);if(!r)throw Error(cA);return n.waitForPageLoad&&await r.pageLoaded,await r.create(n)}async attachDevice(e,t){let n=this._getTypeFromHandle(e,t.adapters),r=n&&this.selectAdapter(n,t.adapters);if(!r)throw Error(cA);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,e])=>e).filter(e=>e.isSupported?.()).map(e=>e.type)}getBestAvailableAdapterType(e=[]){let t=[`webgpu`,`webgl`,`null`],n=this._getAdapterMap(e);for(let e of t)if(n.get(e)?.isSupported?.())return e;return null}selectAdapter(e,t=[]){let n=e;e===`best-available`&&(n=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return n&&r.get(n)||null}enforceWebGL2(e=!0,t=[]){let n=this._getAdapterMap(t).get(`webgl`);n||Z.warn(`enforceWebGL2: webgl adapter not found`)(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(t){Object.assign(e.defaultProps,t)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?`webgl`:typeof GPUDevice<`u`&&e instanceof GPUDevice||e?.queue?`webgpu`:e===null?`null`:(e instanceof WebGLRenderingContext?Z.warn(`WebGL1 is not supported`,e)():Z.warn(`Unknown handle type`,e)(),null)}},uA=new lA}));function qte(){return mA||=pA()||typeof window>`u`?Promise.resolve():new Promise(e=>window.addEventListener(`load`,()=>e())),mA}var dA,fA,pA,mA,Jte=o((()=>{$y(),dA=class{get pageLoaded(){return qte()}},fA=Yy()&&typeof document<`u`,pA=()=>fA&&document.readyState===`complete`,mA=null})),hA,Yte=o((()=>{hA=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:`device-pixel-content-box`})}catch{this._resizeObserver.observe(this.props.canvas,{box:`content-box`})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&=(clearTimeout(this._observeDevicePixelRatioTimeout),null),this._observeDevicePixelRatioMediaQuery&&=(this._observeDevicePixelRatioMediaQuery.removeEventListener(`change`,this._handleDevicePixelRatioChange),null),this._trackPositionInterval&&=(clearInterval(this._trackPositionInterval),null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener(`change`,this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener(`change`,this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&=(clearInterval(this._trackPositionInterval),null)},e)}}}));function Xte(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var Zte=o((()=>{}));function gA(e,t){if(!e){let e=Error(t??`luma.gl assertion failed.`);throw Error.captureStackTrace?.(e,gA),e}}function _A(e,t){return gA(e,t),e}var vA=o((()=>{}));function Qte(e){if(typeof e==`string`){let t=document.getElementById(e);if(!t)throw Error(`${e} is not an HTML element`);return t}return e||document.body}function $te(e){let t=document.getElementById(e);if(!xA.isHTMLCanvas(t))throw Error(`Object is not a canvas element`);return t}function ene(e){let{width:t,height:n}=e,r=document.createElement(`canvas`);r.id=VO(`lumagl-auto-created-canvas`),r.width=t||1,r.height=n||1,r.style.width=Number.isFinite(t)?`${t}px`:`100%`,r.style.height=Number.isFinite(n)?`${n}px`:`100%`,e?.visible||(r.style.visibility=`hidden`);let i=Qte(e?.container||null);return i.insertBefore(r,i.firstChild),r}function tne(e,t,n,r,i){let a=e,o=yA(a[0],t,n),s=bA(a[1],t,r,i),c=yA(a[0]+1,t,n),l=c===n-1?c:c-1;c=bA(a[1]+1,t,r,i);let u;return i?(c=c===0?c:c+1,u=s,s=c):u=c===r-1?c:c-1,{x:o,y:s,width:Math.max(l-o+1,1),height:Math.max(u-s+1,1)}}function yA(e,t,n){return Math.min(Math.round(e*t),n-1)}function bA(e,t,n,r){return r?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}var xA,SA=o((()=>{$y(),Yte(),UO(),Zte(),vA(),xA=class e{static isHTMLCanvas(e){return typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:`opaque`,colorSpace:`srgb`,trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=Xte();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(t){this.props={...e.defaultProps,...t},t=this.props,this.initialized=this._initializedResolvers.promise,Yy()?t.canvas?typeof t.canvas==`string`?this.canvas=$te(t.canvas):this.canvas=t.canvas:this.canvas=ene(t):this.canvas={width:t.width||1,height:t.height||1},e.isHTMLCanvas(this.canvas)?(this.id=t.id||this.canvas.id,this.type=`html-canvas`,this.htmlCanvas=this.canvas):e.isOffscreenCanvas(this.canvas)?(this.id=t.id||`offscreen-canvas`,this.type=`offscreen-canvas`,this.offscreenCanvas=this.canvas):(this.id=t.id||`node-canvas-context`,this.type=`node`),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new hA({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:e=>this._handleResize(e),onIntersection:e=>this._handleIntersection(e),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return`useDevicePixels`in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<`u`&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[r,i]=this.getDrawingBufferSize();return tne(e,n,r,i,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id===`lumagl-auto-created-canvas`&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let n=_A(t.contentBoxSize?.[0]);this.cssWidth=n.inlineSize,this.cssHeight=n.blockSize;let r=this.getDevicePixelSize(),i=t.devicePixelContentBoxSize?.[0]?.inlineSize||n.inlineSize*devicePixelRatio,a=t.devicePixelContentBoxSize?.[0]?.blockSize||n.blockSize*devicePixelRatio,[o,s]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(i,o)),this.devicePixelHeight=Math.max(1,Math.min(a,s)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels==`number`){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let e=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:e})}}}}})),CA,nne=o((()=>{SA(),CA=class extends xA{static defaultProps=xA.defaultProps}})),wA,rne=o((()=>{SA(),wA=class extends xA{}})),TA,EA=o((()=>{lk(),TA=class e extends ck{static defaultProps={...ck.defaultProps,type:`color-sampler`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`,addressModeW:`clamp-to-edge`,magFilter:`nearest`,minFilter:`nearest`,mipmapFilter:`none`,lodMinClamp:0,lodMaxClamp:32,compare:`less-equal`,maxAnisotropy:1};get[Symbol.toStringTag](){return`Sampler`}constructor(t,n){n=e.normalizeProps(t,n),super(t,n,e.defaultProps)}static normalizeProps(e,t){return t}}})),DA,OA,kA=o((()=>{lk(),EA(),BO(),Qk(),DA={"1d":`1d`,"2d":`2d`,"2d-array":`2d`,cube:`2d`,"cube-array":`2d`,"3d":`3d`},OA=class e extends ck{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return`Texture`}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(t,n,r){if(n=e.normalizeProps(t,n),super(t,n,e.defaultProps),this.dimension=this.props.dimension,this.baseDimension=DA[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension===`cube`&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(t.isExternalImage(n.data)){let e=t.getExternalImageSize(n.data);this.width=e?.width||1,this.height=e?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&Z.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=r?.byteAlignment||1,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof TA?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:n,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??n})}computeMemoryLayout(e={}){let{width:t=this.width,height:n=this.height,depthOrArrayLayers:r=this.depth}=this._normalizeTextureReadOptions(e),{format:i,byteAlignment:a}=this;return Zk.computeMemoryLayout({format:i,width:t,height:n,depth:r,byteAlignment:a})}readBuffer(e,t){throw Error(`readBuffer not implemented`)}readDataAsync(e){throw Error(`readBuffer not implemented`)}writeBuffer(e,t){throw Error(`readBuffer not implemented`)}writeData(e,t){throw Error(`readBuffer not implemented`)}readDataSyncWebGL(e){throw Error(`readDataSyncWebGL not available`)}generateMipmapsWebGL(){throw Error(`generateMipmapsWebGL not available`)}static normalizeProps(e,t){let n={...t},{width:r,height:i}=n;return typeof r==`number`&&(n.width=Math.max(1,Math.ceil(r))),typeof i==`number`&&(n.height=Math.max(1,Math.ceil(i))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:`all`,colorSpace:`srgb`,premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:`all`})}_normalizeCopyImageDataOptions(e){let{data:t,depth:n,...r}=e,i=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??n});return{data:t,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a=this.device.getExternalImageSize(t.image),o={...e.defaultCopyExternalImageOptions,...i,...a,...n};return o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depth=Math.min(o.depth,i.depthOrArrayLayers-o.z),o}_normalizeTextureReadOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a={...e.defaultTextureReadOptions,...i,...n};return a.width=Math.min(a.width,i.width-a.x),a.height=Math.min(a.height,i.height-a.y),a.depthOrArrayLayers=Math.min(a.depthOrArrayLayers,i.depthOrArrayLayers-a.z),a}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),n=Zk.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(n),this.dimension){case`2d`:case`cube`:case`cube-array`:case`2d-array`:case`3d`:return t;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!==`all`)throw Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case`color`:return;case`depth`:throw Error(`${this} color readback does not support depth formats (${this.format})`);case`stencil`:throw Error(`${this} color readback does not support stencil formats (${this.format})`);case`depth-stencil`:throw Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a={...e.defaultTextureWriteOptions,...i,...n};a.width=Math.min(a.width,i.width-a.x),a.height=Math.min(a.height,i.height-a.y),a.depthOrArrayLayers=Math.min(a.depthOrArrayLayers,i.depthOrArrayLayers-a.z);let o=Zk.computeMemoryLayout({format:this.format,width:a.width,height:a.height,depth:a.depthOrArrayLayers,byteAlignment:this.byteAlignment}),s=o.bytesPerPixel*a.width;if(a.bytesPerRow=n.bytesPerRow??o.bytesPerRow,a.rowsPerImage=n.rowsPerImage??a.height,a.bytesPerRow<s)throw Error(`bytesPerRow (${a.bytesPerRow}) must be at least ${s} for ${this.format}`);if(a.rowsPerImage<a.height)throw Error(`rowsPerImage (${a.rowsPerImage}) must be at least ${a.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&a.bytesPerRow%c!==0)throw Error(`bytesPerRow (${a.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return a}_getMipLevelSize(e){return{width:Math.max(1,this.width>>e),height:this.baseDimension===`1d`?1:Math.max(1,this.height>>e),depthOrArrayLayers:this.dimension===`3d`?Math.max(1,this.depth>>e):this.depth}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){let{width:n,height:r,depthOrArrayLayers:i}=this._getMipLevelSize(t);e+=Zk.computeMemoryLayout({format:this.format,width:n,height:r,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}static defaultProps={...ck.defaultProps,data:null,dimension:`2d`,format:`rgba8unorm`,usage:e.SAMPLE|e.RENDER|e.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:`all`};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:`all`,colorSpace:`srgb`,premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:`all`};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:`all`}}})),AA,ine=o((()=>{lk(),AA=class e extends ck{get[Symbol.toStringTag](){return`TextureView`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...ck.defaultProps,format:void 0,dimension:void 0,aspect:`all`,baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}}));function ane(e,t,n){let r=``,i=t.split(/\r?\n/),a=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(n?.showSourceCode||`no`){case`all`:let t=0;for(let e=1;e<=i.length;e++){let o=i[e-1],s=a[t];for(o&&s&&(r+=MA(o,e,n));a.length>t&&s.lineNum===e;){let e=a[t++];e&&(r+=jA(e,i,e.lineNum,{...n,inlineSource:!1}))}}for(;a.length>t;){let e=a[t++];e&&(r+=jA(e,[],0,{...n,inlineSource:!1}))}return r;case`issues`:case`no`:for(let t of e)r+=jA(t,i,t.lineNum,{inlineSource:n?.showSourceCode!==`no`});return r}}function jA(e,t,n,r){if(r?.inlineSource)return`
|
||
${one(t,n)}${e.linePos>0?`${` `.repeat(e.linePos+5)}^^^\n`:``}${e.type.toUpperCase()}: ${e.message}
|
||
|
||
`;let i=e.type===`error`?`red`:`orange`;return r?.html?`<div class='luma-compiler-log-${e.type}' style="color:${i};"><b> ${e.type.toUpperCase()}: ${e.message}</b></div>`:`${e.type.toUpperCase()}: ${e.message}`}function one(e,t,n){let r=``;for(let i=t-2;i<=t;i++){let a=e[i-1];a!==void 0&&(r+=MA(a,t,n))}return r}function MA(e,t,n){let r=n?.html?cne(e):e;return`${sne(String(t),4)}: ${r}${n?.html?`<br/>`:`
|
||
`}`}function sne(e,t){let n=``;for(let r=e.length;r<t;++r)n+=` `;return n+e}function cne(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}var lne=o((()=>{}));function une(e){return dne(e.source)||e.id||VO(`unnamed ${e.stage}-shader`)}function dne(e,t=`unnamed`){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e)?.[1]??t}var NA,PA=o((()=>{lk(),UO(),lne(),NA=class e extends ck{get[Symbol.toStringTag](){return`Shader`}stage;source;compilationStatus=`pending`;constructor(t,n){n={...n,debugShaders:n.debugShaders||t.props.debugShaders||`errors`},super(t,{id:une(n),...n},e.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case`never`:return;case`errors`:if(this.compilationStatus===`success`)return;break;case`warnings`:case`always`:break}let t=await this.getCompilationInfo();e===`warnings`&&t?.length===0||this._displayShaderLog(t,this.id)}_displayShaderLog(e,t){if(typeof document>`u`||!document?.createElement)return;let n=t,r=`${this.stage} shader "${n}"`,i=ane(e,this.source,{showSourceCode:`all`,html:!0}),a=this.getTranslatedSource(),o=document.createElement(`div`);o.innerHTML=`\
|
||
<h1>Compilation error in ${r}</h1>
|
||
<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;">
|
||
<button id="copy">Copy source</button><br/>
|
||
<button id="close">Close</button>
|
||
</div>
|
||
<code><pre>${i}</pre></code>`,a&&(o.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${a}</pre></code>`),o.style.top=`0`,o.style.left=`0`,o.style.background=`white`,o.style.position=`fixed`,o.style.zIndex=`9999`,o.style.maxWidth=`100vw`,o.style.maxHeight=`100vh`,o.style.overflowY=`auto`,document.body.appendChild(o),o.querySelector(`.luma-compiler-log-error`)?.scrollIntoView(),o.querySelector(`button#close`).onclick=()=>{o.remove()},o.querySelector(`button#copy`).onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...ck.defaultProps,language:`auto`,stage:void 0,source:``,sourceMap:null,entryPoint:`main`,debugShaders:void 0}}})),FA,fne=o((()=>{lk(),kA(),BO(),FA=class e extends ck{get[Symbol.toStringTag](){return`Framebuffer`}width;height;constructor(t,n={}){super(t,n,e.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(t=>t.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||n!==this.width,this.width=n,this.height=r}t&&(Z.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw Error(`Framebuffer has noattachments`);this.colorAttachments=this.props.colorAttachments.map((e,t)=>{if(typeof e==`string`){let n=this.createColorTexture(e,t);return this.attachResource(n),n.view}return e instanceof OA?e.view:e});let e=this.props.depthStencilAttachment;if(e)if(typeof e==`string`){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof OA?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:OA.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:`linear`,minFilter:`linear`}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:OA.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((n,r)=>{let i=n.texture.clone({width:e,height:t});this.destroyAttachedResource(n),this.colorAttachments[r]=i.view,this.attachResource(i.view)}),this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}static defaultProps={...ck.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}})),IA,LA=o((()=>{lk(),IA=class e extends ck{get[Symbol.toStringTag](){return`RenderPipeline`}shaderLayout;bufferLayout;linkStatus=`pending`;hash=``;sharedRenderPipeline=null;get isPending(){return this.linkStatus===`pending`||this.vs.compilationStatus===`pending`||this.fs?.compilationStatus===`pending`}get isErrored(){return this.linkStatus===`error`||this.vs.compilationStatus===`error`||this.fs?.compilationStatus===`error`}constructor(t,n){super(t,n,e.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...ck.defaultProps,vs:null,vertexEntryPoint:`vertexMain`,vsConstants:{},fs:null,fragmentEntryPoint:`fragmentMain`,fsConstants:{},shaderLayout:null,bufferLayout:[],topology:`triangle-list`,colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0}}})),RA,pne=o((()=>{lk(),RA=class extends ck{get[Symbol.toStringTag](){return`SharedRenderPipeline`}constructor(e,t){super(e,t,{...ck.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}})),zA,BA=o((()=>{lk(),zA=class e extends ck{get[Symbol.toStringTag](){return`ComputePipeline`}hash=``;shaderLayout;constructor(t,n){super(t,n,e.defaultProps),this.shaderLayout=n.shaderLayout}static defaultProps={...ck.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}})),VA,mne=o((()=>{BA(),LA(),BO(),UO(),VA=class e{static defaultProps={...IA.defaultProps};static getDefaultPipelineFactory(t){let n=t.getModuleData(`@luma.gl/core`);return n.defaultPipelineFactory||=new e(t),n.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return`PipelineFactory`}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...IA.defaultProps,...e},n=this._renderPipelineCache,r=this._hashRenderPipeline(t),i=n[r]?.resource;if(i)n[r].useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: ${n[r].resource} reused, count=${n[r].useCount}, (id=${e.id})`)();else{let e=this.device.type===`webgl`&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;i=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:VO(`unnamed-cached`),_sharedRenderPipeline:e}),i.hash=r,n[r]={resource:i,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: ${i} created, count=${n[r].useCount}`)()}return i}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...zA.defaultProps,...e},n=this._computePipelineCache,r=this._hashComputePipeline(t),i=n[r]?.resource;return i?(n[r].useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: ${n[r].resource} reused, count=${n[r].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),i.hash=r,n[r]={resource:i,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: ${i} created, count=${n[r].useCount}`)()),i}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),n=e.hash;t[n].useCount--,t[n].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&Z.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(Z.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.device.props.debugFactories&&Z.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),n=this._sharedRenderPipelineCache[t];return n||(n={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=n),n.useCount++,n.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[t];n&&(n.useCount--,n.useCount===0&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof IA&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof zA&&(t=this._computePipelineCache),e instanceof IA&&(t=this._renderPipelineCache),!t)throw Error(`${this}`);if(!t[e.hash])throw Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device;return`${t}/C/${this._getHash(e.shader.source)}SL${this._getHash(JSON.stringify(e.shaderLayout))}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),i=this._getHash(JSON.stringify(e.shaderLayout)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case`webgl`:let s=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${n}V${r}T${e.topology}P${s}SL${i}BL${a}`;default:let c=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),l=this._getHash(JSON.stringify(e.parameters)),u=this._getWebGPUAttachmentHash(e);return`${o}/R/${t}/${n}V${r}T${e.topology}EP${c}P${l}SL${i}BL${a}A${u}`}}_hashSharedRenderPipeline(e){return`webgl/S/${e.vs?this._getHash(e.vs.source):0}/${e.fs?this._getHash(e.fs.source):0}V${this._getWebGLVaryingHash(e)}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:n=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:n}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],n=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:n}))}}})),HA,hne=o((()=>{PA(),BO(),HA=class e{static defaultProps={...NA.defaultProps};static getDefaultShaderFactory(t){let n=t.getModuleData(`@luma.gl/core`);return n.defaultShaderFactory||=new e(t),n.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return`ShaderFactory`}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),n=this._cache[t];if(n)n.useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: Reusing shader ${n.resource.id} count=${n.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={resource:r,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: Created new shader ${r.id}`)()}return n.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,n.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],n.resource.destroy(),this.device.props.debugFactories&&Z.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else if(n.useCount<0)throw Error(`ShaderFactory: Shader ${e.id} released too many times`);else this.device.props.debugFactories&&Z.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}_hashShader(e){return`${e.stage}:${e.source}`}}}));function gne(e,t,n){let r=e.bindings.find(e=>e.name===t||`${e.name.toLocaleLowerCase()}uniforms`===t.toLocaleLowerCase());return!r&&!n?.ignoreWarnings&&Z.warn(`Binding ${t} not set: Not found in shader layout.`)(),r||null}function UA(e,t){if(!t)return{};if(_ne(t))return Object.fromEntries(Object.entries(t).map(([e,t])=>[Number(e),{...t}]));let n={};for(let[r,i]of Object.entries(t)){let t=gne(e,r)?.group??0;n[t]||={},n[t][r]=i}return n}function WA(e){let t={};for(let n of Object.values(e))Object.assign(t,n);return t}function _ne(e){let t=Object.keys(e);return t.length>0&&t.every(e=>/^\d+$/.test(e))}var vne=o((()=>{BO()})),GA,yne=o((()=>{lk(),GA=class e extends ck{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return`RenderPass`}constructor(t,n){n=e.normalizeProps(t,n),super(t,n,e.defaultProps)}static normalizeProps(e,t){return t}static defaultProps={...ck.defaultProps,framebuffer:null,parameters:void 0,clearColor:e.defaultClearColor,clearColors:void 0,clearDepth:e.defaultClearDepth,clearStencil:e.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}})),KA,qA=o((()=>{lk(),KA=class e extends ck{get[Symbol.toStringTag](){return`CommandEncoder`}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(t,n){super(t,n,e.defaultProps),this._timeProfilingQuerySet=n.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,n=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let e=0;e<t;e+=2)r+=n[e+1]-n[e];this._gpuTimeMs=Number(r)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let t=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||t.timestampQuerySet!==void 0||t.beginTimestampIndex!==void 0||t.endTimestampIndex!==void 0)return t;let n=this._timeProfilingSlotCount;return n+1>=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:n,endTimestampIndex:n+1})}_supportsTimestampQueries(){return this.device.features.has(`timestamp-query`)}static defaultProps={...ck.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}})),JA,YA=o((()=>{lk(),JA=class e extends ck{get[Symbol.toStringTag](){return`CommandBuffer`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...ck.defaultProps}}}));function XA(e){let t=aj[ej(e)];if(!t)throw Error(`Unsupported variable shader type: ${e}`);return t}function ZA(e){let t=ij[$A(e)];if(!t)throw Error(`Unsupported attribute shader type: ${e}`);let[n,r]=t,i=n===`i32`||n===`u32`,a=n!==`u32`;return{primitiveType:n,components:r,byteLength:rj[n]*r,integer:i,signed:a}}function QA(e,t){return t===1?e:`vec${t}<${e}>`}function $A(e){return oj[e]||e}function ej(e){return sj[e]||e}var tj,nj,rj,ij,aj,oj,sj,cj=o((()=>{tj=class{getVariableShaderTypeInfo(e){return XA(e)}getAttributeShaderTypeInfo(e){return ZA(e)}makeShaderAttributeType(e,t){return QA(e,t)}resolveAttributeShaderTypeAlias(e){return $A(e)}resolveVariableShaderTypeAlias(e){return ej(e)}},nj=new tj,rj={f32:4,f16:2,i32:4,u32:4},ij={f32:[`f32`,1],"vec2<f32>":[`f32`,2],"vec3<f32>":[`f32`,3],"vec4<f32>":[`f32`,4],f16:[`f16`,1],"vec2<f16>":[`f16`,2],"vec3<f16>":[`f16`,3],"vec4<f16>":[`f16`,4],i32:[`i32`,1],"vec2<i32>":[`i32`,2],"vec3<i32>":[`i32`,3],"vec4<i32>":[`i32`,4],u32:[`u32`,1],"vec2<u32>":[`u32`,2],"vec3<u32>":[`u32`,3],"vec4<u32>":[`u32`,4]},aj={f32:{type:`f32`,components:1},f16:{type:`f16`,components:1},i32:{type:`i32`,components:1},u32:{type:`u32`,components:1},"vec2<f32>":{type:`f32`,components:2},"vec3<f32>":{type:`f32`,components:3},"vec4<f32>":{type:`f32`,components:4},"vec2<f16>":{type:`f16`,components:2},"vec3<f16>":{type:`f16`,components:3},"vec4<f16>":{type:`f16`,components:4},"vec2<i32>":{type:`i32`,components:2},"vec3<i32>":{type:`i32`,components:3},"vec4<i32>":{type:`i32`,components:4},"vec2<u32>":{type:`u32`,components:2},"vec3<u32>":{type:`u32`,components:3},"vec4<u32>":{type:`u32`,components:4},"mat2x2<f32>":{type:`f32`,components:4},"mat2x3<f32>":{type:`f32`,components:6},"mat2x4<f32>":{type:`f32`,components:8},"mat3x2<f32>":{type:`f32`,components:6},"mat3x3<f32>":{type:`f32`,components:9},"mat3x4<f32>":{type:`f32`,components:12},"mat4x2<f32>":{type:`f32`,components:8},"mat4x3<f32>":{type:`f32`,components:12},"mat4x4<f32>":{type:`f32`,components:16},"mat2x2<f16>":{type:`f16`,components:4},"mat2x3<f16>":{type:`f16`,components:6},"mat2x4<f16>":{type:`f16`,components:8},"mat3x2<f16>":{type:`f16`,components:6},"mat3x3<f16>":{type:`f16`,components:9},"mat3x4<f16>":{type:`f16`,components:12},"mat4x2<f16>":{type:`f16`,components:8},"mat4x3<f16>":{type:`f16`,components:12},"mat4x4<f16>":{type:`f16`,components:16},"mat2x2<i32>":{type:`i32`,components:4},"mat2x3<i32>":{type:`i32`,components:6},"mat2x4<i32>":{type:`i32`,components:8},"mat3x2<i32>":{type:`i32`,components:6},"mat3x3<i32>":{type:`i32`,components:9},"mat3x4<i32>":{type:`i32`,components:12},"mat4x2<i32>":{type:`i32`,components:8},"mat4x3<i32>":{type:`i32`,components:12},"mat4x4<i32>":{type:`i32`,components:16},"mat2x2<u32>":{type:`u32`,components:4},"mat2x3<u32>":{type:`u32`,components:6},"mat2x4<u32>":{type:`u32`,components:8},"mat3x2<u32>":{type:`u32`,components:6},"mat3x3<u32>":{type:`u32`,components:9},"mat3x4<u32>":{type:`u32`,components:12},"mat4x2<u32>":{type:`u32`,components:8},"mat4x3<u32>":{type:`u32`,components:12},"mat4x4<u32>":{type:`u32`,components:16}},oj={vec2i:`vec2<i32>`,vec3i:`vec3<i32>`,vec4i:`vec4<i32>`,vec2u:`vec2<u32>`,vec3u:`vec3<u32>`,vec4u:`vec4<u32>`,vec2f:`vec2<f32>`,vec3f:`vec3<f32>`,vec4f:`vec4<f32>`,vec2h:`vec2<f16>`,vec3h:`vec3<f16>`,vec4h:`vec4<f16>`},sj={vec2i:`vec2<i32>`,vec3i:`vec3<i32>`,vec4i:`vec4<i32>`,vec2u:`vec2<u32>`,vec3u:`vec3<u32>`,vec4u:`vec4<u32>`,vec2f:`vec2<f32>`,vec3f:`vec3<f32>`,vec4f:`vec4<f32>`,vec2h:`vec2<f16>`,vec3h:`vec3<f16>`,vec4h:`vec4<f16>`,mat2x2f:`mat2x2<f32>`,mat2x3f:`mat2x3<f32>`,mat2x4f:`mat2x4<f32>`,mat3x2f:`mat3x2<f32>`,mat3x3f:`mat3x3<f32>`,mat3x4f:`mat3x4<f32>`,mat4x2f:`mat4x2<f32>`,mat4x3f:`mat4x3<f32>`,mat4x4f:`mat4x4<f32>`,mat2x2i:`mat2x2<i32>`,mat2x3i:`mat2x3<i32>`,mat2x4i:`mat2x4<i32>`,mat3x2i:`mat3x2<i32>`,mat3x3i:`mat3x3<i32>`,mat3x4i:`mat3x4<i32>`,mat4x2i:`mat4x2<i32>`,mat4x3i:`mat4x3<i32>`,mat4x4i:`mat4x4<i32>`,mat2x2u:`mat2x2<u32>`,mat2x3u:`mat2x3<u32>`,mat2x4u:`mat2x4<u32>`,mat3x2u:`mat3x2<u32>`,mat3x3u:`mat3x3<u32>`,mat3x4u:`mat3x4<u32>`,mat4x2u:`mat4x2<u32>`,mat4x3u:`mat4x3<u32>`,mat4x4u:`mat4x4<u32>`,mat2x2h:`mat2x2<f16>`,mat2x3h:`mat2x3<f16>`,mat2x4h:`mat2x4<f16>`,mat3x2h:`mat3x2<f16>`,mat3x3h:`mat3x3<f16>`,mat3x4h:`mat3x4<f16>`,mat4x2h:`mat4x2<f16>`,mat4x3h:`mat4x3<f16>`,mat4x4h:`mat4x4<f16>`}}));function lj(e,t){let n={};for(let r of e.attributes){let i=dj(e,t,r.name);i&&(n[r.name]=i)}return n}function uj(e,t,n=16){let r=lj(e,t),i=Array(n).fill(null);for(let e of Object.values(r))i[e.location]=e;return i}function dj(e,t,n){let r=bne(e,n),i=xne(t,n);if(!r)return null;let a=nj.getAttributeShaderTypeInfo(r.type),o=_k.getCompatibleVertexFormat(a),s=i?.vertexFormat||o,c=_k.getVertexFormatInfo(s);return{attributeName:i?.attributeName||r.name,bufferName:i?.bufferName||r.name,location:r.location,shaderType:r.type,primitiveType:a.primitiveType,shaderComponents:a.components,vertexFormat:s,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:a.integer,stepMode:i?.stepMode||r.stepMode||`vertex`,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function bne(e,t){let n=e.attributes.find(e=>e.name===t);return n||Z.warn(`shader layout attribute "${t}" not present in shader`),n||null}function xne(e,t){Sne(e);let n=Cne(e,t);return n||(n=wne(e,t),n)?n:(Z.warn(`layout for attribute "${t}" not present in buffer layout`),null)}function Sne(e){for(let t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Z.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Cne(e,t){for(let n of e)if(n.format&&n.name===t)return{attributeName:n.name,bufferName:t,stepMode:n.stepMode,vertexFormat:n.format,byteOffset:0,byteStride:n.byteStride||0};return null}function wne(e,t){for(let n of e){let e=n.byteStride;if(typeof n.byteStride!=`number`)for(let t of n.attributes||[]){let n=_k.getVertexFormatInfo(t.format);e+=n.byteLength}let r=n.attributes?.find(e=>e.attribute===t);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:e}}return null}var fj=o((()=>{BO(),cj(),vk()})),pj,mj=o((()=>{fj(),lk(),pj=class e extends ck{static defaultProps={...ck.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return`VertexArray`}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(t,n){super(t,n,e.defaultProps),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=Array(this.maxVertexAttributes).fill(null),this.attributeInfos=uj(n.shaderLayout,n.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(Error(`constant attributes not supported`),this)()}}})),hj,gj=o((()=>{lk(),hj=class e extends ck{static defaultProps={...ck.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return`TransformFeedback`}constructor(t,n){super(t,n,e.defaultProps)}}})),_j,vj=o((()=>{lk(),_j=class e extends ck{get[Symbol.toStringTag](){return`QuerySet`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...ck.defaultProps,type:void 0,count:void 0}}})),yj,bj=o((()=>{lk(),yj=class e extends ck{static defaultProps={...ck.defaultProps};get[Symbol.toStringTag](){return`Fence`}constructor(t,n={}){super(t,n,e.defaultProps)}}}));function xj(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}function Sj(e){let[,,,,t]=Cj[e];return t}var Cj,wj=o((()=>{Cj={uint8:[`uint8`,`u32`,1,!1,Uint8Array],sint8:[`sint8`,`i32`,1,!1,Int8Array],unorm8:[`uint8`,`f32`,1,!0,Uint8Array],snorm8:[`sint8`,`f32`,1,!0,Int8Array],uint16:[`uint16`,`u32`,2,!1,Uint16Array],sint16:[`sint16`,`i32`,2,!1,Int16Array],unorm16:[`uint16`,`u32`,2,!0,Uint16Array],snorm16:[`sint16`,`i32`,2,!0,Int16Array],float16:[`float16`,`f16`,2,!1,Uint16Array],float32:[`float32`,`f32`,4,!1,Float32Array],uint32:[`uint32`,`u32`,4,!1,Uint32Array],sint32:[`sint32`,`i32`,4,!1,Int32Array]}}));function Tne(e,t={}){let n={...e},r=t.layout??`std140`,i={},a=0;for(let[e,t]of Object.entries(n))a=Dj(i,e,t,a,r);return a=xj(a,kj(n,r)),{layout:r,byteLength:a*4,uniformTypes:n,fields:i}}function Tj(e,t){let n=ej(e),r=XA(n),i=/^mat(\d)x(\d)<.+>$/.exec(n);if(i){let e=Number(i[1]),a=Number(i[2]),o=Aj(a,n,r.type,t),s=Nj(o.size,o.alignment,t);return{alignment:o.alignment,size:e*s,components:e*a,columns:e,rows:a,columnStride:s,shaderType:n,type:r.type}}let a=/^vec(\d)<.+>$/.exec(n);return a?Aj(Number(a[1]),n,r.type,t):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:n,type:r.type}}function Ej(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Dj(e,t,n,r,i){if(typeof n==`string`){let a=Tj(n,i),o=xj(r,a.alignment);return e[t]={offset:o,...a},o+a.size}if(Array.isArray(n)){if(Array.isArray(n[0]))throw Error(`Nested arrays are not supported for ${t}`);let a=n[0],o=n[1],s=jj(a,i),c=xj(r,kj(n,i));for(let n=0;n<o;n++)Dj(e,`${t}[${n}]`,a,c+n*s,i);return c+s*o}if(Ej(n)){let a=kj(n,i),o=xj(r,a);for(let[r,a]of Object.entries(n))o=Dj(e,`${t}.${r}`,a,o,i);return xj(o,a)}throw Error(`Unsupported CompositeShaderType for ${t}`)}function Oj(e,t){if(typeof e==`string`)return Tj(e,t).size;if(Array.isArray(e)){let n=e[0],r=e[1];if(Array.isArray(n))throw Error(`Nested arrays are not supported`);return jj(n,t)*r}let n=0;for(let r of Object.values(e)){let e=r;n=xj(n,kj(e,t)),n+=Oj(e,t)}return xj(n,kj(e,t))}function kj(e,t){if(typeof e==`string`)return Tj(e,t).alignment;if(Array.isArray(e)){let n=e[0],r=kj(n,t);return Pj(t)?Math.max(r,4):r}let n=1;for(let r of Object.values(e)){let e=kj(r,t);n=Math.max(n,e)}return Fj(t)?Math.max(n,4):n}function Aj(e,t,n,r){return{alignment:e===2?2:4,size:e===3?3:e,components:e,columns:1,rows:e,columnStride:e===3?3:e,shaderType:t,type:n}}function jj(e,t){return Mj(Oj(e,t),kj(e,t),t)}function Mj(e,t,n){return xj(e,Pj(n)?4:t)}function Nj(e,t,n){return n===`std140`?4:xj(e,t)}function Pj(e){return e===`std140`||e===`wgsl-uniform`}function Fj(e){return e===`std140`||e===`wgsl-uniform`}var Ij=o((()=>{wj(),cj()}));function Lj(e){return(!zj||zj.byteLength<e)&&(zj=new ArrayBuffer(e)),zj}function Rj(e,t){return new e(Lj(e.BYTES_PER_ELEMENT*t),0,t)}var zj,Bj=o((()=>{}));function Vj(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Hj(e){return Array.isArray(e)?e.length===0||typeof e[0]==`number`:Vj(e)}var Uj=o((()=>{}));function Wj(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function Gj(e,t,n){return Array.prototype.slice.call(e,t,n)}var Kj,qj=o((()=>{Bj(),Uj(),BO(),Ij(),Kj=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[n,r]of Object.entries(e)){let e=this.layout.uniformTypes[n];e?this._flattenCompositeValue(t,n,e,r):this.layout.fields[n]&&(t[n]=r)}return t}getData(e){let t=Lj(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[e,t]of Object.entries(r))this._writeLeafValue(n,e,t);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,n,r){if(r!==void 0){if(typeof n==`string`||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(n)){let i=n[0],a=n[1];if(Array.isArray(i))throw Error(`Nested arrays are not supported for ${t}`);if(typeof i==`string`&&Hj(r)){this._flattenPackedArray(e,t,i,a,r);return}if(!Array.isArray(r)){Z.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let n=0;n<Math.min(r.length,a);n++){let a=r[n];a!==void 0&&this._flattenCompositeValue(e,`${t}[${n}]`,i,a)}return}if(Ej(n)&&Wj(r)){for(let[i,a]of Object.entries(r)){if(a===void 0)continue;let r=`${t}.${i}`;this._flattenCompositeValue(e,r,n[i],a)}return}Z.warn(`Unsupported uniform value for ${t}:`,r)()}}_flattenPackedArray(e,t,n,r,i){let a=i,o=Tj(n,this.layout.layout).components;for(let n=0;n<r;n++){let r=n*o;if(r>=a.length)break;o===1?e[`${t}[${n}]`]=Number(a[r]):e[`${t}[${n}]`]=Gj(i,r,r+o)}}_writeLeafValue(e,t,n){let r=this.layout.fields[t];if(!r){Z.warn(`Uniform ${t} not found in layout`)();return}let{type:i,components:a,columns:o,rows:s,offset:c,columnStride:l}=r,u=e[i];if(a===1){u[c]=Number(n);return}let d=n;if(o===1){for(let e=0;e<a;e++)u[c+e]=Number(d[e]??0);return}let f=0;for(let e=0;e<o;e++){let t=c+e*l;for(let e=0;e<s;e++)u[t+e]=Number(d[f++]??0)}}}}));function Jj(e,t,n=16){if(e===t)return!0;let r=e,i=t;if(!Hj(r)||!Hj(i)||r.length!==i.length)return!1;let a=Math.min(n,Xj);if(r.length>a)return!1;for(let e=0;e<r.length;++e)if(i[e]!==r[e])return!1;return!0}function Yj(e){return Hj(e)?e.slice():e}var Xj,Zj=o((()=>{Uj(),Xj=128})),Qj,$j=o((()=>{Zj(),Qj=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw=`initialized`;constructor(e){if(this.name=e?.name||`unnamed`,e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(t=>t.type===`uniform`&&t.name===e?.name);if(!t)throw Error(e?.name);let n=t;for(let e of n.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Jj(this.uniforms[e],t)||(this.uniforms[e]=Yj(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}}));function Ene(e){return e.type===`webgpu`?`wgsl-uniform`:`std140`}var eM,tM,Dne=o((()=>{dk(),BO(),Ij(),$j(),qj(),eM=1024,tM=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[n,r]of Object.entries(t)){let t=n,i=Tne(r.uniformTypes??{},{layout:r.layout??Ene(e)}),a=new Kj(i);this.shaderBlockLayouts.set(t,i),this.shaderBlockWriters.set(t,a);let o=new Qj({name:n});o.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(t,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e)){let e=t,r=this.shaderBlockWriters.get(e)?.getFlatUniformValues(n||{});this.uniformBlocks.get(e)?.setUniforms(r||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,eM)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array}createUniformBuffer(e,t){t&&this.setUniforms(t);let n=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:uk.UNIFORM|uk.COPY_DST,byteLength:n}),i=this.getUniformBufferData(e);return r.write(i),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:uk.UNIFORM|uk.COPY_DST,byteLength:t});this.uniformBuffers.set(e,n)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&Z.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),r=!1;if(n&&t?.needsRedraw){r||=t.needsRedraw;let i=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(i);let a=this.uniformBlocks.get(e)?.getAllUniforms();Z.log(4,`Writing to uniform buffer ${String(e)}`,i,a)()}return r}}})),nM=o((()=>{Kte(),Jte(),oA(),nne(),rne(),lk(),dk(),kA(),ine(),PA(),EA(),fne(),LA(),pne(),mne(),hne(),vne(),yne(),BA(),qA(),YA(),mj(),gj(),vj(),bj(),Ij(),qj(),$j(),Dne(),hk(),wj(),cj(),vk(),Qk(),tA(),BO(),vA(),Bj(),fj(),zk()})),rM,One=o((()=>{rM=`precision highp int;
|
||
|
||
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
||
struct AmbientLight {
|
||
vec3 color;
|
||
};
|
||
|
||
struct PointLight {
|
||
vec3 color;
|
||
vec3 position;
|
||
vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
|
||
};
|
||
|
||
struct SpotLight {
|
||
vec3 color;
|
||
vec3 position;
|
||
vec3 direction;
|
||
vec3 attenuation;
|
||
vec2 coneCos;
|
||
};
|
||
|
||
struct DirectionalLight {
|
||
vec3 color;
|
||
vec3 direction;
|
||
};
|
||
|
||
struct UniformLight {
|
||
vec3 color;
|
||
vec3 position;
|
||
vec3 direction;
|
||
vec3 attenuation;
|
||
vec2 coneCos;
|
||
};
|
||
|
||
layout(std140) uniform lightingUniforms {
|
||
int enabled;
|
||
int directionalLightCount;
|
||
int pointLightCount;
|
||
int spotLightCount;
|
||
vec3 ambientColor;
|
||
UniformLight lights[5];
|
||
} lighting;
|
||
|
||
PointLight lighting_getPointLight(int index) {
|
||
UniformLight light = lighting.lights[index];
|
||
return PointLight(light.color, light.position, light.attenuation);
|
||
}
|
||
|
||
SpotLight lighting_getSpotLight(int index) {
|
||
UniformLight light = lighting.lights[lighting.pointLightCount + index];
|
||
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
|
||
}
|
||
|
||
DirectionalLight lighting_getDirectionalLight(int index) {
|
||
UniformLight light =
|
||
lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
|
||
return DirectionalLight(light.color, light.direction);
|
||
}
|
||
|
||
float getPointLightAttenuation(PointLight pointLight, float distance) {
|
||
return pointLight.attenuation.x
|
||
+ pointLight.attenuation.y * distance
|
||
+ pointLight.attenuation.z * distance * distance;
|
||
}
|
||
|
||
float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
|
||
vec3 light_direction = normalize(positionWorldspace - spotLight.position);
|
||
float coneFactor = smoothstep(
|
||
spotLight.coneCos.y,
|
||
spotLight.coneCos.x,
|
||
dot(normalize(spotLight.direction), light_direction)
|
||
);
|
||
float distanceAttenuation = getPointLightAttenuation(
|
||
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
|
||
distance(spotLight.position, positionWorldspace)
|
||
);
|
||
return distanceAttenuation / max(coneFactor, 0.0001);
|
||
}
|
||
|
||
// #endif
|
||
`})),iM,kne=o((()=>{iM=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
||
const MAX_LIGHTS: i32 = 5;
|
||
|
||
struct AmbientLight {
|
||
color: vec3<f32>,
|
||
};
|
||
|
||
struct PointLight {
|
||
color: vec3<f32>,
|
||
position: vec3<f32>,
|
||
attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
|
||
};
|
||
|
||
struct SpotLight {
|
||
color: vec3<f32>,
|
||
position: vec3<f32>,
|
||
direction: vec3<f32>,
|
||
attenuation: vec3<f32>,
|
||
coneCos: vec2<f32>,
|
||
};
|
||
|
||
struct DirectionalLight {
|
||
color: vec3<f32>,
|
||
direction: vec3<f32>,
|
||
};
|
||
|
||
struct UniformLight {
|
||
color: vec3<f32>,
|
||
position: vec3<f32>,
|
||
direction: vec3<f32>,
|
||
attenuation: vec3<f32>,
|
||
coneCos: vec2<f32>,
|
||
};
|
||
|
||
struct lightingUniforms {
|
||
enabled: i32,
|
||
directionalLightCount: i32,
|
||
pointLightCount: i32,
|
||
spotLightCount: i32,
|
||
ambientColor: vec3<f32>,
|
||
lights: array<UniformLight, 5>,
|
||
};
|
||
|
||
@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;
|
||
|
||
fn lighting_getPointLight(index: i32) -> PointLight {
|
||
let light = lighting.lights[index];
|
||
return PointLight(light.color, light.position, light.attenuation);
|
||
}
|
||
|
||
fn lighting_getSpotLight(index: i32) -> SpotLight {
|
||
let light = lighting.lights[lighting.pointLightCount + index];
|
||
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
|
||
}
|
||
|
||
fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
|
||
let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
|
||
return DirectionalLight(light.color, light.direction);
|
||
}
|
||
|
||
fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
|
||
return pointLight.attenuation.x
|
||
+ pointLight.attenuation.y * distance
|
||
+ pointLight.attenuation.z * distance * distance;
|
||
}
|
||
|
||
fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {
|
||
let lightDirection = normalize(positionWorldspace - spotLight.position);
|
||
let coneFactor = smoothstep(
|
||
spotLight.coneCos.y,
|
||
spotLight.coneCos.x,
|
||
dot(normalize(spotLight.direction), lightDirection)
|
||
);
|
||
let distanceAttenuation = getPointLightAttenuation(
|
||
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
|
||
distance(spotLight.position, positionWorldspace)
|
||
);
|
||
return distanceAttenuation / max(coneFactor, 0.0001);
|
||
}
|
||
`}));function Ane(e,t={}){if(e&&={...e},!e)return oM();e.lights&&(e={...e,...Mne(e.lights),lights:void 0});let{useByteColors:n,ambientLight:r,pointLights:i,spotLights:a,directionalLights:o}=e||{};if(!(r||i&&i.length>0||a&&a.length>0||o&&o.length>0))return{...oM(),enabled:0};let s={...oM(),...jne({useByteColors:n,ambientLight:r,pointLights:i,spotLights:a,directionalLights:o})};return e.enabled!==void 0&&(s.enabled=+!!e.enabled),s}function jne({useByteColors:e,ambientLight:t,pointLights:n=[],spotLights:r=[],directionalLights:i=[]}){let a=sM(),o=0,s=0,c=0,l=0;for(let t of n){if(o>=cM)break;a[o]={...a[o],color:aM(t,e),position:t.position,attenuation:t.attenuation||[1,0,0]},o++,s++}for(let t of r){if(o>=cM)break;a[o]={...a[o],color:aM(t,e),position:t.position,direction:t.direction,attenuation:t.attenuation||[1,0,0],coneCos:Pne(t)},o++,c++}for(let t of i){if(o>=cM)break;a[o]={...a[o],color:aM(t,e),direction:t.direction},o++,l++}return n.length+r.length+i.length>cM&&Z.warn(`MAX_LIGHTS exceeded, truncating to ${cM}`)(),{ambientColor:aM(t,e),directionalLightCount:l,pointLightCount:s,spotLightCount:c,lights:a}}function Mne(e){let t={pointLights:[],spotLights:[],directionalLights:[]};for(let n of e||[])switch(n.type){case`ambient`:t.ambientLight=n;break;case`directional`:t.directionalLights?.push(n);break;case`point`:t.pointLights?.push(n);break;case`spot`:t.spotLights?.push(n);break;default:}return t}function aM(e={},t){let{color:n=[0,0,0],intensity:r=1}=e;return hO(n,mO(t,!0)).map(e=>e*r)}function oM(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:sM()}}function sM(){return Array.from({length:cM},()=>Nne())}function Nne(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function Pne(e){let t=e.innerConeAngle??0,n=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(n)]}var cM,lM,uM,dM=o((()=>{nM(),One(),kne(),_O(),cM=5,lM={color:`vec3<f32>`,position:`vec3<f32>`,direction:`vec3<f32>`,attenuation:`vec3<f32>`,coneCos:`vec2<f32>`},uM={props:{},uniforms:{},name:`lighting`,defines:{},uniformTypes:{enabled:`i32`,directionalLightCount:`i32`,pointLightCount:`i32`,spotLightCount:`i32`,ambientColor:`vec3<f32>`,lights:[lM,cM]},defaultUniforms:oM(),bindingLayout:[{name:`lighting`,group:2}],firstBindingSlot:0,source:iM,vs:rM,fs:rM,getUniforms:Ane}})),fM,pM,mM=o((()=>{fM=`layout(std140) uniform phongMaterialUniforms {
|
||
uniform bool unlit;
|
||
uniform float ambient;
|
||
uniform float diffuse;
|
||
uniform float shininess;
|
||
uniform vec3 specularColor;
|
||
} material;
|
||
`,pM=`layout(std140) uniform phongMaterialUniforms {
|
||
uniform bool unlit;
|
||
uniform float ambient;
|
||
uniform float diffuse;
|
||
uniform float shininess;
|
||
uniform vec3 specularColor;
|
||
} material;
|
||
|
||
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
|
||
vec3 halfway_direction = normalize(light_direction + view_direction);
|
||
float lambertian = dot(light_direction, normal_worldspace);
|
||
float specular = 0.0;
|
||
if (lambertian > 0.0) {
|
||
float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
|
||
specular = pow(specular_angle, material.shininess);
|
||
}
|
||
lambertian = max(lambertian, 0.0);
|
||
return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;
|
||
}
|
||
|
||
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
|
||
vec3 lightColor = surfaceColor;
|
||
|
||
if (material.unlit) {
|
||
return surfaceColor;
|
||
}
|
||
|
||
if (lighting.enabled == 0) {
|
||
return lightColor;
|
||
}
|
||
|
||
vec3 view_direction = normalize(cameraPosition - position_worldspace);
|
||
lightColor = material.ambient * surfaceColor * lighting.ambientColor;
|
||
|
||
for (int i = 0; i < lighting.pointLightCount; i++) {
|
||
PointLight pointLight = lighting_getPointLight(i);
|
||
vec3 light_position_worldspace = pointLight.position;
|
||
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
||
float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));
|
||
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
|
||
}
|
||
|
||
for (int i = 0; i < lighting.spotLightCount; i++) {
|
||
SpotLight spotLight = lighting_getSpotLight(i);
|
||
vec3 light_position_worldspace = spotLight.position;
|
||
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
||
float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
|
||
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);
|
||
}
|
||
|
||
for (int i = 0; i < lighting.directionalLightCount; i++) {
|
||
DirectionalLight directionalLight = lighting_getDirectionalLight(i);
|
||
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
||
}
|
||
|
||
return lightColor;
|
||
}
|
||
`})),hM,gM=o((()=>{hM=`struct phongMaterialUniforms {
|
||
unlit: u32,
|
||
ambient: f32,
|
||
diffuse: f32,
|
||
shininess: f32,
|
||
specularColor: vec3<f32>,
|
||
};
|
||
|
||
@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;
|
||
|
||
fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {
|
||
let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);
|
||
var lambertian: f32 = dot(light_direction, normal_worldspace);
|
||
var specular: f32 = 0.0;
|
||
if (lambertian > 0.0) {
|
||
let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
|
||
specular = pow(specular_angle, phongMaterial.shininess);
|
||
}
|
||
lambertian = max(lambertian, 0.0);
|
||
return (
|
||
lambertian * phongMaterial.diffuse * surfaceColor +
|
||
specular * floatColors_normalize(phongMaterial.specularColor)
|
||
) * color;
|
||
}
|
||
|
||
fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
|
||
var lightColor: vec3<f32> = surfaceColor;
|
||
|
||
if (phongMaterial.unlit != 0u) {
|
||
return surfaceColor;
|
||
}
|
||
|
||
if (lighting.enabled == 0) {
|
||
return lightColor;
|
||
}
|
||
|
||
let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);
|
||
lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;
|
||
|
||
for (var i: i32 = 0; i < lighting.pointLightCount; i++) {
|
||
let pointLight: PointLight = lighting_getPointLight(i);
|
||
let light_position_worldspace: vec3<f32> = pointLight.position;
|
||
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
||
let light_attenuation = getPointLightAttenuation(
|
||
pointLight,
|
||
distance(light_position_worldspace, position_worldspace)
|
||
);
|
||
lightColor += lighting_getLightColor(
|
||
surfaceColor,
|
||
light_direction,
|
||
view_direction,
|
||
normal_worldspace,
|
||
pointLight.color / light_attenuation
|
||
);
|
||
}
|
||
|
||
for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
|
||
let spotLight: SpotLight = lighting_getSpotLight(i);
|
||
let light_position_worldspace: vec3<f32> = spotLight.position;
|
||
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
||
let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
|
||
lightColor += lighting_getLightColor(
|
||
surfaceColor,
|
||
light_direction,
|
||
view_direction,
|
||
normal_worldspace,
|
||
spotLight.color / light_attenuation
|
||
);
|
||
}
|
||
|
||
for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
|
||
let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
|
||
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
||
}
|
||
|
||
return lightColor;
|
||
}
|
||
|
||
fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{
|
||
var lightColor = vec3<f32>(0, 0, 0);
|
||
let surfaceColor = vec3<f32>(0, 0, 0);
|
||
|
||
if (lighting.enabled != 0) {
|
||
let view_direction = normalize(cameraPosition - position_worldspace);
|
||
|
||
for (var i: i32 = 0; i < lighting.pointLightCount; i++) {
|
||
let pointLight: PointLight = lighting_getPointLight(i);
|
||
let light_position_worldspace: vec3<f32> = pointLight.position;
|
||
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
||
let light_attenuation = getPointLightAttenuation(
|
||
pointLight,
|
||
distance(light_position_worldspace, position_worldspace)
|
||
);
|
||
lightColor += lighting_getLightColor(
|
||
surfaceColor,
|
||
light_direction,
|
||
view_direction,
|
||
normal_worldspace,
|
||
pointLight.color / light_attenuation
|
||
);
|
||
}
|
||
|
||
for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
|
||
let spotLight: SpotLight = lighting_getSpotLight(i);
|
||
let light_position_worldspace: vec3<f32> = spotLight.position;
|
||
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
||
let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
|
||
lightColor += lighting_getLightColor(
|
||
surfaceColor,
|
||
light_direction,
|
||
view_direction,
|
||
normal_worldspace,
|
||
spotLight.color / light_attenuation
|
||
);
|
||
}
|
||
|
||
for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
|
||
let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
|
||
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
||
}
|
||
}
|
||
return lightColor;
|
||
}
|
||
`})),_M,vM,yM=o((()=>{OO(),dM(),mM(),gM(),_M=[38.25,38.25,38.25],vM={props:{},name:`gouraudMaterial`,bindingLayout:[{name:`gouraudMaterial`,group:3}],vs:pM.replace(`phongMaterial`,`gouraudMaterial`),fs:fM.replace(`phongMaterial`,`gouraudMaterial`),source:hM.replaceAll(`phongMaterial`,`gouraudMaterial`),defines:{LIGHTING_VERTEX:!0},dependencies:[uM,DO],uniformTypes:{unlit:`i32`,ambient:`f32`,diffuse:`f32`,shininess:`f32`,specularColor:`vec3<f32>`},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:_M},getUniforms(e){return{...vM.defaultUniforms,...e}}}})),bM=o((()=>{sT(),uT(),wT(),bE(),jE(),FT(),IE(),kE(),rT(),lO(),pO(),_O(),bO(),Fte(),OO(),Lte(),dM(),yM(),gM(),mM()})),xM,SM,CM,wM=o((()=>{xM=`struct LayerUniforms {
|
||
opacity: f32,
|
||
};
|
||
|
||
@group(0) @binding(auto)
|
||
var<uniform> layer: LayerUniforms;
|
||
`,SM=`layout(std140) uniform layerUniforms {
|
||
uniform float opacity;
|
||
} layer;
|
||
`,CM={name:`layer`,source:xM,vs:SM,fs:SM,getUniforms:e=>({opacity:e.opacity**(1/2.2)}),uniformTypes:{opacity:`f32`}}})),TM,EM,DM=o((()=>{TM=`
|
||
|
||
@must_use
|
||
fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {
|
||
return vec4(fragColor.rgb * fragColor.a, fragColor.a);
|
||
};
|
||
`,EM={name:`color`,dependencies:[],source:TM,getUniforms:e=>({})}})),OM,kM,AM,jM,MM,NM=o((()=>{OM=`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
|
||
|
||
struct VertexGeometry {
|
||
position: vec4<f32>,
|
||
worldPosition: vec3<f32>,
|
||
worldPositionAlt: vec3<f32>,
|
||
normal: vec3<f32>,
|
||
uv: vec2<f32>,
|
||
pickingColor: vec3<f32>,
|
||
};
|
||
|
||
var<private> geometry_: VertexGeometry = VertexGeometry(
|
||
vec4<f32>(0.0, 0.0, 1.0, 0.0),
|
||
vec3<f32>(0.0, 0.0, 0.0),
|
||
vec3<f32>(0.0, 0.0, 0.0),
|
||
vec3<f32>(0.0, 0.0, 0.0),
|
||
vec2<f32>(0.0, 0.0),
|
||
vec3<f32>(0.0, 0.0, 0.0)
|
||
);
|
||
|
||
struct FragmentGeometry {
|
||
uv: vec2<f32>,
|
||
};
|
||
|
||
var<private> fragmentGeometry: FragmentGeometry;
|
||
|
||
fn smoothedge(edge: f32, x: f32) -> f32 {
|
||
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
||
}
|
||
`,kM=`#define SMOOTH_EDGE_RADIUS 0.5`,AM=`\
|
||
${kM}
|
||
|
||
struct VertexGeometry {
|
||
vec4 position;
|
||
vec3 worldPosition;
|
||
vec3 worldPositionAlt;
|
||
vec3 normal;
|
||
vec2 uv;
|
||
vec3 pickingColor;
|
||
} geometry = VertexGeometry(
|
||
vec4(0.0, 0.0, 1.0, 0.0),
|
||
vec3(0.0),
|
||
vec3(0.0),
|
||
vec3(0.0),
|
||
vec2(0.0),
|
||
vec3(0.0)
|
||
);
|
||
`,jM=`\
|
||
${kM}
|
||
|
||
struct FragmentGeometry {
|
||
vec2 uv;
|
||
} geometry;
|
||
|
||
float smoothedge(float edge, float x) {
|
||
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
||
}
|
||
`,MM={name:`geometry`,source:OM,vs:AM,fs:jM}})),PM,FM,IM=o((()=>{(function(e){e[e.Start=1]=`Start`,e[e.Move=2]=`Move`,e[e.End=4]=`End`,e[e.Cancel=8]=`Cancel`})(PM||={}),(function(e){e[e.None=0]=`None`,e[e.Left=1]=`Left`,e[e.Right=2]=`Right`,e[e.Up=4]=`Up`,e[e.Down=8]=`Down`,e[e.Horizontal=3]=`Horizontal`,e[e.Vertical=12]=`Vertical`,e[e.All=15]=`All`})(FM||={})})),LM,RM=o((()=>{(function(e){e[e.Possible=1]=`Possible`,e[e.Began=2]=`Began`,e[e.Changed=4]=`Changed`,e[e.Ended=8]=`Ended`,e[e.Recognized=8]=`Recognized`,e[e.Cancelled=16]=`Cancelled`,e[e.Failed=32]=`Failed`})(LM||={})})),zM,BM,VM,HM,UM,WM=o((()=>{zM=`auto`,BM=`manipulation`,VM=`none`,HM=`pan-x`,UM=`pan-y`}));function GM(e){if(e.includes(`none`))return VM;let t=e.includes(HM),n=e.includes(UM);return t&&n?VM:t||n?t?HM:UM:e.includes(`manipulation`)?BM:zM}var KM=o((()=>{WM()})),qM,JM=o((()=>{WM(),KM(),qM=class{constructor(e,t){this.actions=``,this.manager=e,this.set(t)}set(e){e===`compute`&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return GM(e.join(` `))}}}));function YM(e){return e.trim().split(/\s+/g)}var XM=o((()=>{}));function ZM(e,t,n){if(e)for(let r of YM(t))e.addEventListener(r,n,!1)}function QM(e,t,n){if(e)for(let r of YM(t))e.removeEventListener(r,n,!1)}var Fne=o((()=>{XM()}));function $M(e){return(e.ownerDocument||e).defaultView}var Ine=o((()=>{}));function Lne(e,t){let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}var Rne=o((()=>{}));function eN(e){let t=e.length;if(t===1)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let n=0,r=0,i=0;for(;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:Math.round(n/t),y:Math.round(r/t)}}var tN=o((()=>{}));function nN(e){let t=[],n=0;for(;n<e.pointers.length;)t[n]={clientX:Math.round(e.pointers[n].clientX),clientY:Math.round(e.pointers[n].clientY)},n++;return{timeStamp:Date.now(),pointers:t,center:eN(t),deltaX:e.deltaX,deltaY:e.deltaY}}var zne=o((()=>{tN()}));function rN(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function iN(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}var aN=o((()=>{}));function Bne(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.atan2(r,n)*180/Math.PI}function oN(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.atan2(r,n)*180/Math.PI}var sN=o((()=>{}));function cN(e,t){return e===t?FM.None:Math.abs(e)>=Math.abs(t)?e<0?FM.Left:FM.Right:t<0?FM.Up:FM.Down}var lN=o((()=>{IM()}));function Vne(e,t){let n=t.center,r=e.offsetDelta,i=e.prevDelta,a=e.prevInput;return(t.eventType===PM.Start||a?.eventType===PM.End)&&(i=e.prevDelta={x:a?.deltaX||0,y:a?.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),{deltaX:i.x+(n.x-r.x),deltaY:i.y+(n.y-r.y)}}var Hne=o((()=>{IM()}));function uN(e,t,n){return{x:t/e||0,y:n/e||0}}var dN=o((()=>{}));function Une(e,t){return iN(t[0],t[1])/iN(e[0],e[1])}var Wne=o((()=>{aN()}));function Gne(e,t){return oN(t[1],t[0])-oN(e[1],e[0])}var Kne=o((()=>{sN()}));function fN(e,t){let n=e.lastInterval||t,r=t.timeStamp-n.timeStamp,i,a,o,s;if(t.eventType!==PM.Cancel&&(r>25||n.velocity===void 0)){let c=t.deltaX-n.deltaX,l=t.deltaY-n.deltaY,u=uN(r,c,l);a=u.x,o=u.y,i=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,s=cN(c,l),e.lastInterval=t}else i=n.velocity,a=n.velocityX,o=n.velocityY,s=n.direction;t.velocity=i,t.velocityX=a,t.velocityY=o,t.direction=s}var pN=o((()=>{IM(),dN(),lN()}));function mN(e,t){let{session:n}=e,{pointers:r}=t,{length:i}=r;n.firstInput||=nN(t),i>1&&!n.firstMultiple?n.firstMultiple=nN(t):i===1&&(n.firstMultiple=!1);let{firstInput:a,firstMultiple:o}=n,s=o?o.center:a.center,c=t.center=eN(r);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=Bne(s,c),t.distance=rN(s,c);let{deltaX:l,deltaY:u}=Vne(n,t);t.deltaX=l,t.deltaY=u,t.offsetDirection=cN(t.deltaX,t.deltaY);let d=uN(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=d.x,t.overallVelocityY=d.y,t.overallVelocity=Math.abs(d.x)>Math.abs(d.y)?d.x:d.y,t.scale=o?Une(o.pointers,r):1,t.rotation=o?Gne(o.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length;let f=e.element;return Lne(t.srcEvent.target,f)&&(f=t.srcEvent.target),t.target=f,fN(n,t),t}var hN=o((()=>{Rne(),zne(),tN(),aN(),sN(),lN(),Hne(),dN(),Wne(),Kne(),pN()}));function gN(e,t,n){let r=n.pointers.length,i=n.changedPointers.length,a=t&PM.Start&&r-i===0,o=t&(PM.End|PM.Cancel)&&r-i===0;n.isFirst=!!a,n.isFinal=!!o,a&&(e.session={}),n.eventType=t;let s=mN(e,n);e.emit(`hammer.input`,s),e.recognize(s),e.session.prevInput=s}var _N=o((()=>{IM(),hN()})),vN,yN=o((()=>{Fne(),Ine(),_N(),vN=class{constructor(e){this.evEl=``,this.evWin=``,this.evTarget=``,this.domHandler=e=>{this.manager.options.enable&&this.handler(e)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){gN(this.manager,e,t)}init(){ZM(this.element,this.evEl,this.domHandler),ZM(this.target,this.evTarget,this.domHandler),ZM($M(this.element),this.evWin,this.domHandler)}destroy(){QM(this.element,this.evEl,this.domHandler),QM(this.target,this.evTarget,this.domHandler),QM($M(this.element),this.evWin,this.domHandler)}}})),bN,xN,SN,CN,wN=o((()=>{IM(),yN(),bN={pointerdown:PM.Start,pointermove:PM.Move,pointerup:PM.End,pointercancel:PM.Cancel,pointerout:PM.Cancel},xN=`pointerdown`,SN=`pointermove pointerup pointercancel`,CN=class extends vN{constructor(e){super(e),this.evEl=xN,this.evWin=SN,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,n=!1,r=bN[e.type],i=e.pointerType,a=i===`touch`,o=t.findIndex(t=>t.pointerId===e.pointerId);r&PM.Start&&(e.buttons||a)?o<0&&(t.push(e),o=t.length-1):r&(PM.End|PM.Cancel)&&(n=!0),!(o<0)&&(t[o]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:i,srcEvent:e}),n&&t.splice(o,1))}}}));function TN(e,t){let n=t[0].toUpperCase()+t.slice(1);for(let r of EN){let i=r?r+n:t;if(i in e)return i}}var EN,DN=o((()=>{EN=[``,`webkit`,`Moz`,`MS`,`ms`,`o`]})),ON,kN,AN,jN,MN=o((()=>{JM(),wN(),XM(),DN(),RM(),ON=1,kN=2,AN={touchAction:`compute`,enable:!0,inputTarget:null,cssProps:{userSelect:`none`,userDrag:`none`,touchCallout:`none`,tapHighlightColor:`rgba(0,0,0,0)`}},jN=class{constructor(e,t){this.options={...AN,...t,cssProps:{...AN.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new CN(this),this.touchAction=new qM(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?kN:ON}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let n,{recognizers:r}=this,{curRecognizer:i}=t;(!i||i&&i.state&LM.Recognized)&&(i=t.curRecognizer=null);let a=0;for(;a<r.length;)n=r[a],t.stopped!==kN&&(!i||n===i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&(LM.Began|LM.Changed|LM.Ended)&&(i=t.curRecognizer=n),a++}get(e){let{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(let t of e)this.add(t);return this}let t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let t of e)this.remove(t);return this}let t=typeof e==`string`?this.get(e):e;if(t){let{recognizers:e}=this,n=e.indexOf(t);n!==-1&&(e.splice(n,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;let{handlers:n}=this;for(let r of YM(e))n[r]=n[r]||[],n[r].push(t)}off(e,t){if(!e)return;let{handlers:n}=this;for(let r of YM(e))t?n[r]&&n[r].splice(n[r].indexOf(t),1):delete n[r]}emit(e,t){let n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;let r=t;r.type=e,r.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](r),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:t}=this;if(t){for(let[n,r]of Object.entries(this.options.cssProps)){let i=TN(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=r):t.style[i]=this.oldCssProps[i]||``}e||(this.oldCssProps={})}}}}));function NN(){return PN++}var PN,FN=o((()=>{PN=1}));function IN(e){return e&LM.Cancelled?`cancel`:e&LM.Ended?`end`:e&LM.Changed?`move`:e&LM.Began?`start`:``}var LN=o((()=>{RM()})),RN,zN=o((()=>{RM(),FN(),LN(),RN=class{constructor(e){this.options=e,this.id=NN(),this.state=LM.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let t of e)this.recognizeWith(t);return this}let t;if(typeof e==`string`){if(t=this.manager.get(e),!t)throw Error(`Cannot find recognizer ${e}`)}else t=e;let{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let t of e)this.dropRecognizeWith(t);return this}let t;return t=typeof e==`string`?this.manager.get(e):e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(let t of e)this.requireFailure(t);return this}let t;if(typeof e==`string`){if(t=this.manager.get(e),!t)throw Error(`Cannot find recognizer ${e}`)}else t=e;let{requireFail:n}=this;return n.indexOf(t)===-1&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let t of e)this.dropRequireFailure(t);return this}let t;if(t=typeof e==`string`?this.manager.get(e):e,t){let e=this.requireFail.indexOf(t);e>-1&&this.requireFail.splice(e,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t<LM.Ended&&this.manager.emit(this.options.event+IN(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=LM.Ended&&this.manager.emit(this.options.event+IN(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=LM.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(LM.Failed|LM.Possible)))return!1;e++}return!0}recognize(e){let t={...e};if(!this.options.enable){this.reset(),this.state=LM.Failed;return}this.state&(LM.Recognized|LM.Cancelled|LM.Failed)&&(this.state=LM.Possible),this.state=this.process(t),this.state&(LM.Began|LM.Changed|LM.Ended|LM.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}}})),BN,VN=o((()=>{zN(),RM(),IM(),BN=class extends RN{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}process(e){let{state:t}=this,{eventType:n}=e,r=t&(LM.Began|LM.Changed),i=this.attrTest(e);return r&&(n&PM.Cancel||!i)?t|LM.Cancelled:r||i?n&PM.End?t|LM.Ended:t&LM.Began?t|LM.Changed:LM.Began:LM.Failed}}})),HN,UN=o((()=>{zN(),WM(),IM(),RM(),aN(),HN=class extends RN{constructor(e={}){super({enable:!0,event:`tap`,pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[BM]}process(e){let{options:t}=this,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&PM.Start&&this.count===0)return this.failTimeout();if(r&&i&&n){if(e.eventType!==PM.End)return this.failTimeout();let n=this.pTime?e.timeStamp-this.pTime<t.interval:!0,r=!this.pCenter||rN(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!r||!n?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=LM.Recognized,this.tryEmit(this._input)},t.interval),LM.Began):LM.Recognized}return LM.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=LM.Failed},this.options.interval),LM.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===LM.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}}})),WN,GN,KN=o((()=>{VN(),IM(),RM(),WM(),WN=[``,`start`,`move`,`end`,`cancel`,`up`,`down`,`left`,`right`],GN=class extends BN{constructor(e={}){super({enable:!0,pointers:1,event:`pan`,threshold:10,direction:FM.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&FM.Horizontal&&t.push(UM),e&FM.Vertical&&t.push(HM),t}getEventNames(){return WN.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,n=!0,{distance:r}=e,{direction:i}=e,a=e.deltaX,o=e.deltaY;return i&t.direction||(t.direction&FM.Horizontal?(i=a===0?FM.None:a<0?FM.Left:FM.Right,n=a!==this.pX,r=Math.abs(e.deltaX)):(i=o===0?FM.None:o<0?FM.Up:FM.Down,n=o!==this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&!!(i&t.direction)}attrTest(e){return super.attrTest(e)&&(!!(this.state&LM.Began)||!(this.state&LM.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=FM[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}}})),qN=o((()=>{VN(),IM(),KN()})),JN,YN,XN=o((()=>{VN(),WM(),RM(),JN=[``,`start`,`move`,`end`,`cancel`,`in`,`out`],YN=class extends BN{constructor(e={}){super({enable:!0,event:`pinch`,threshold:0,pointers:2,...e})}getTouchAction(){return[VM]}getEventNames(){return JN.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||!!(this.state&LM.Began))}emit(e){if(e.scale!==1){let t=e.scale<1?`in`:`out`;e.additionalEvent=this.options.event+t}super.emit(e)}}})),ZN=o((()=>{VN(),RM()})),QN=o((()=>{zN(),RM(),IM()})),$N=o((()=>{IM(),RM(),MN(),yN(),JM(),wN(),zN(),VN(),UN(),KN(),qN(),XN(),ZN(),QN()})),eP,tP=o((()=>{eP=class{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}}})),nP,rP=o((()=>{nP=typeof navigator<`u`&&navigator.userAgent?navigator.userAgent.toLowerCase():``,typeof window<`u`||global})),iP,aP,oP,sP,cP,lP=o((()=>{tP(),rP(),iP=nP.indexOf(`firefox`)!==-1,aP=4.000244140625,oP=40,sP=.25,cP=class extends eP{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;globalThis.WheelEvent&&(iP&&e.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(t/=globalThis.devicePixelRatio),e.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(t*=oP)),t!==0&&t%aP===0&&(t=Math.floor(t/aP)),e.shiftKey&&t&&(t*=sP),this.callback({type:`wheel`,center:{x:e.clientX,y:e.clientY},delta:-t,srcEvent:e,pointerType:`mouse`,target:e.target})},e.addEventListener(`wheel`,this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener(`wheel`,this.handleEvent)}enableEventType(e,t){e===`wheel`&&(this.options.enable=t)}}})),uP,dP,fP=o((()=>{tP(),uP=[`mousedown`,`mousemove`,`mouseup`,`mouseover`,`mouseout`,`mouseleave`],dP=class extends eP{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;let{enable:r}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,uP.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){uP.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){switch(e){case`pointermove`:this.enableMoveEvent=t;break;case`pointerover`:this.enableOverEvent=t;break;case`pointerout`:this.enableOutEvent=t;break;case`pointerenter`:this.enableEnterEvent=t;break;case`pointerleave`:this.enableLeaveEvent=t;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type===`mouseover`&&this._emit(`pointerover`,e)}handleOutEvent(e){this.enableOutEvent&&e.type===`mouseout`&&this._emit(`pointerout`,e)}handleEnterEvent(e){this.enableEnterEvent&&e.type===`mouseenter`&&this._emit(`pointerenter`,e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type===`mouseleave`&&this._emit(`pointerleave`,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case`mousedown`:e.button>=0&&(this.pressed=!0);break;case`mousemove`:e.buttons===0&&(this.pressed=!1),this.pressed||this._emit(`pointermove`,e);break;case`mouseup`:this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:`mouse`,target:t.target})}}})),pP,mP,hP=o((()=>{tP(),pP=[`keydown`,`keyup`],mP=class extends eP{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=e=>{let t=e.target||e.srcElement;t.tagName===`INPUT`&&t.type===`text`||t.tagName===`TEXTAREA`||(this.enableDownEvent&&e.type===`keydown`&&this.callback({type:`keydown`,srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&e.type===`keyup`&&this.callback({type:`keyup`,srcEvent:e,key:e.key,target:e.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline=`none`,pP.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){pP.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===`keydown`&&(this.enableDownEvent=t),e===`keyup`&&(this.enableUpEvent=t)}}})),gP,_P=o((()=>{tP(),gP=class extends eP{constructor(e,t,n){super(e,t,n),this.handleEvent=e=>{this.options.enable&&this.callback({type:`contextmenu`,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:`mouse`,target:e.target})},e.addEventListener(`contextmenu`,this.handleEvent)}destroy(){this.element.removeEventListener(`contextmenu`,this.handleEvent)}enableEventType(e,t){e===`contextmenu`&&(this.options.enable=t)}}}));function vP(e){let t=CP[e.srcEvent.type];if(!t)return null;let{buttons:n,button:r}=e.srcEvent,i=!1,a=!1,o=!1;return t===xP?(i=!!(n&DP),a=!!(n&kP),o=!!(n&OP)):(i=r===wP,a=r===TP,o=r===EP),{leftButton:i,middleButton:a,rightButton:o}}function yP(e,t){let n=e.center;if(!n)return null;let r=t.getBoundingClientRect(),i=r.width/t.offsetWidth||1,a=r.height/t.offsetHeight||1;return{center:n,offsetCenter:{x:(n.x-r.left-t.clientLeft)/i,y:(n.y-r.top-t.clientTop)/a}}}var bP,xP,SP,CP,wP,TP,EP,DP,OP,kP,qne=o((()=>{bP=1,xP=2,SP=4,CP={pointerdown:bP,pointermove:xP,pointerup:SP,mousedown:bP,mousemove:xP,mouseup:SP},wP=0,TP=1,EP=2,DP=1,OP=2,kP=4})),AP,jP,Jne=o((()=>{qne(),AP={srcElement:`root`,priority:0},jP=class{constructor(e,t){this.handleEvent=e=>{if(this.isEmpty())return;let t=this._normalizeEvent(e),n=e.srcEvent.target;for(;n&&n!==t.rootElement;){if(this._emit(t,n),t.handled)return;n=n.parentNode}this._emit(t,`root`)},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,r=!1,i=!1){let{handlers:a,handlersByElement:o}=this,s={...AP,...n},c=o.get(s.srcElement);c||(c=[],o.set(s.srcElement,c));let l={type:e,handler:t,srcElement:s.srcElement,priority:s.priority};r&&(l.once=!0),i&&(l.passive=!0),a.push(l),this._active=this._active||!l.passive;let u=c.length-1;for(;u>=0&&!(c[u].priority>=l.priority);)u--;c.splice(u+1,0,l)}remove(e,t){let{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){let a=n[i];if(a.type===e&&a.handler===t){n.splice(i,1);let e=r.get(a.srcElement);e.splice(e.indexOf(a),1),e.length===0&&r.delete(a.srcElement)}}this._active=n.some(e=>!e.passive)}_emit(e,t){let n=this.handlersByElement.get(t);if(n){let t=!1,r=()=>{e.handled=!0},i=()=>{e.handled=!0,t=!0},a=[];for(let o=0;o<n.length;o++){let{type:s,handler:c,once:l}=n[o];if(c({...e,type:s,stopPropagation:r,stopImmediatePropagation:i}),l&&a.push(n[o]),t)break}for(let e=0;e<a.length;e++){let{type:t,handler:n}=a[e];this.remove(t,n)}}}_normalizeEvent(e){let t=this.eventManager.getElement();return{...e,...vP(e),...yP(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}}}));function Yne(e){if(`recognizer`in e)return e;let t,n=Array.isArray(e)?[...e]:[e];return t=typeof n[0]==`function`?new(n.shift())(n.shift()||{}):n.shift(),{recognizer:t,recognizeWith:typeof n[0]==`string`?[n[0]]:n[0],requireFailure:typeof n[1]==`string`?[n[1]]:n[1]}}var MP,Xne=o((()=>{$N(),lP(),fP(),hP(),_P(),Jne(),MP=class{constructor(e=null,t={}){if(this._onBasicInput=e=>{this.manager.emit(e.srcEvent.type,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={recognizers:[],events:{},touchAction:`compute`,tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,e){this.manager=new jN(e,this.options);for(let e of this.options.recognizers){let{recognizer:t,recognizeWith:n,requireFailure:r}=Yne(e);this.manager.add(t),n&&t.recognizeWith(n),r&&t.requireFailure(r)}this.manager.on(`hammer.input`,this._onBasicInput),this.wheelInput=new cP(e,this._onOtherEvent,{enable:!1}),this.moveInput=new dP(e,this._onOtherEvent,{enable:!1}),this.keyInput=new mP(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new gP(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){let{manager:n}=this;if(!n)return;let r=n.get(e);r&&(r.set({enable:t}),n.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,n,r,i){if(typeof e!=`string`){n=t;for(let[t,a]of Object.entries(e))this._addEventHandler(t,a,n,r,i);return}let{manager:a,events:o}=this;if(!a)return;let s=o.get(e);if(!s){let t=this._getRecognizerName(e)||e;s=new jP(this,t),o.set(e,s),a&&a.on(e,s.handleEvent)}s.add(e,t,n,r,i),s.isEmpty()||this._toggleRecognizer(s.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!=`string`){for(let[t,n]of Object.entries(e))this._removeEventHandler(t,n);return}let{events:n}=this,r=n.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:e}=r,t=!1;for(let r of n.values())if(r.recognizerName===e&&!r.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}}})),NP=o((()=>{Xne(),$N()})),PP,FP,IP,LP,RP,zP=o((()=>{Nw(),NP(),PP={DEFAULT:`default`,LNGLAT:`lnglat`,METER_OFFSETS:`meter-offsets`,LNGLAT_OFFSETS:`lnglat-offsets`,CARTESIAN:`cartesian`},Object.defineProperty(PP,"IDENTITY",{get:()=>(Mw.deprecated(`COORDINATE_SYSTEM.IDENTITY`,`COORDINATE_SYSTEM.CARTESIAN`)(),PP.CARTESIAN)}),FP={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},IP={common:0,meters:1,pixels:2},LP={click:`onClick`,dblclick:`onClick`,panstart:`onDragStart`,panmove:`onDrag`,panend:`onDragEnd`},RP={multipan:[GN,{threshold:10,direction:FM.Vertical,pointers:2}],pinch:[YN,{},null,[`multipan`]],pan:[GN,{threshold:1},[`pinch`],[`multipan`]],dblclick:[HN,{event:`dblclick`,taps:2}],click:[HN,{event:`click`},null,[`dblclick`]]}}));function Zne(e,t){if(e===t)return!0;if(Array.isArray(e)){let n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}function BP(e){let t={},n;return r=>{for(let i in r)if(!Zne(r[i],t[i])){n=e(r),t=r;break}return n}}var VP=o((()=>{}));function HP(e){let t=YP[e];if(t===void 0)throw Error(`Invalid coordinateSystem: ${e}`);return t}function UP(e,t,n=JP){n.length<3&&(n=[n[0],n[1],0]);let r=n,i,a=!0;switch(i=t===`lnglat-offsets`||t===`meter-offsets`?n:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case FP.WEB_MERCATOR:(t===`lnglat`||t===`cartesian`)&&(i=[0,0,0],a=!1);break;case FP.WEB_MERCATOR_AUTO_OFFSET:t===`lnglat`?r=i:t===`cartesian`&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],i=e.unprojectPosition(r),r[0]-=n[0],r[1]-=n[1],r[2]-=n[2]);break;case FP.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case FP.GLOBE:a=!1,i=null;break;default:a=!1}return{geospatialOrigin:i,shaderCoordinateOrigin:r,offsetMode:a}}function Qne(e,t,n){let{viewMatrixUncentered:r,projectionMatrix:i}=e,{viewMatrix:a,viewProjectionMatrix:o}=e,s=WP,c=WP,l=e.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:d,offsetMode:f}=UP(e,t,n);return f&&(c=e.projectPosition(u||d),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,s=qD([],c,o),a=r||a,o=AD([],i,a),o=AD([],o,GP)),{viewMatrix:a,viewProjectionMatrix:o,projectionCenter:s,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:d,geospatialOrigin:u}}function $ne({viewport:e,devicePixelRatio:t=1,modelMatrix:n=null,coordinateSystem:r=`default`,coordinateOrigin:i=JP,autoWrapLongitude:a=!1}){r==="default"&&(r=e.isGeospatial?`lnglat`:`cartesian`);let o=XP({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i});return o.wrapLongitude=a,o.modelMatrix=n||KP,o}function ere({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r}){let{projectionCenter:i,viewProjectionMatrix:a,originCommon:o,cameraPosCommon:s,shaderCoordinateOrigin:c,geospatialOrigin:l}=Qne(e,n,r),u=e.getDistanceScales(),d=[e.width*t,e.height*t],f=qD([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={coordinateSystem:HP(n),projectionMode:e.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:i,pseudoMeters:!!e._pseudoMeters,viewportSize:d,devicePixelRatio:t,focalDistance:f,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:qP,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:a,modelMatrix:KP,cameraPosition:s};if(l){let t=e.getDistanceScales(l);switch(n){case`meter-offsets`:p.commonUnitsPerWorldUnit=t.unitsPerMeter,p.commonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case`lnglat`:case`lnglat-offsets`:e._pseudoMeters||(p.commonUnitsPerMeter=t.unitsPerMeter),p.commonUnitsPerWorldUnit=t.unitsPerDegree,p.commonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case`cartesian`:p.commonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.commonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]];break;default:break}}return p}var WP,GP,KP,qP,JP,YP,XP,ZP=o((()=>{lO(),zP(),VP(),WP=[0,0,0,0],GP=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],KP=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],qP=[0,0,0],JP=[0,0,0],YP={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3},XP=BP(ere)})),QP,$P,eF,tF,nF,tre=o((()=>{zP(),ZP(),QP=[`default`,`lnglat`,`meter-offsets`,`lnglat-offsets`,`cartesian`].map(e=>`const COORDINATE_SYSTEM_${e.toUpperCase().replaceAll(`-`,`_`)}: i32 = ${HP(e)};`).join(``),$P=Object.keys(FP).map(e=>`const PROJECTION_MODE_${e}: i32 = ${FP[e]};`).join(``),eF=Object.keys(IP).map(e=>`const UNIT_${e.toUpperCase()}: i32 = ${IP[e]};`).join(``),tF=`\
|
||
${QP}
|
||
${$P}
|
||
${eF}
|
||
|
||
const TILE_SIZE: f32 = 512.0;
|
||
const PI: f32 = 3.1415926536;
|
||
const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0);
|
||
const ZERO_64_LOW: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);
|
||
const EARTH_RADIUS: f32 = 6370972.0; // meters
|
||
const GLOBE_RADIUS: f32 = 256.0;
|
||
|
||
// -----------------------------------------------------------------------------
|
||
// Uniform block (converted from GLSL uniform block)
|
||
// -----------------------------------------------------------------------------
|
||
struct ProjectUniforms {
|
||
wrapLongitude: i32,
|
||
coordinateSystem: i32,
|
||
commonUnitsPerMeter: vec3<f32>,
|
||
projectionMode: i32,
|
||
scale: f32,
|
||
commonUnitsPerWorldUnit: vec3<f32>,
|
||
commonUnitsPerWorldUnit2: vec3<f32>,
|
||
center: vec4<f32>,
|
||
modelMatrix: mat4x4<f32>,
|
||
viewProjectionMatrix: mat4x4<f32>,
|
||
viewportSize: vec2<f32>,
|
||
devicePixelRatio: f32,
|
||
focalDistance: f32,
|
||
cameraPosition: vec3<f32>,
|
||
coordinateOrigin: vec3<f32>,
|
||
commonOrigin: vec3<f32>,
|
||
pseudoMeters: i32,
|
||
};
|
||
|
||
@group(0) @binding(auto)
|
||
var<uniform> project: ProjectUniforms;
|
||
|
||
// -----------------------------------------------------------------------------
|
||
// Geometry data shared across the project helpers.
|
||
// The active layer shader is responsible for populating this private module
|
||
// state before calling the project functions below.
|
||
// -----------------------------------------------------------------------------
|
||
|
||
// Structure to carry additional geometry data used by deck.gl filters.
|
||
struct Geometry {
|
||
worldPosition: vec3<f32>,
|
||
worldPositionAlt: vec3<f32>,
|
||
position: vec4<f32>,
|
||
normal: vec3<f32>,
|
||
uv: vec2<f32>,
|
||
pickingColor: vec3<f32>,
|
||
};
|
||
|
||
var<private> geometry: Geometry;
|
||
`,nF=`\
|
||
${tF}
|
||
|
||
// -----------------------------------------------------------------------------
|
||
// Functions
|
||
// -----------------------------------------------------------------------------
|
||
|
||
// Returns an adjustment factor for commonUnitsPerMeter
|
||
fn _project_size_at_latitude(lat: f32) -> f32 {
|
||
let y = clamp(lat, -89.9, 89.9);
|
||
return 1.0 / cos(radians(y));
|
||
}
|
||
|
||
// Overloaded version: scales a value in meters at a given latitude.
|
||
fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 {
|
||
return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat);
|
||
}
|
||
|
||
// Computes a non-linear scale factor based on geometry.
|
||
// (Note: This function relies on "geometry" being provided.)
|
||
fn project_size() -> f32 {
|
||
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
|
||
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
|
||
project.pseudoMeters == 0) {
|
||
if (geometry.position.w == 0.0) {
|
||
return _project_size_at_latitude(geometry.worldPosition.y);
|
||
}
|
||
let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
|
||
let y2 = y * y;
|
||
let y4 = y2 * y2;
|
||
let y6 = y4 * y2;
|
||
return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
|
||
}
|
||
return 1.0;
|
||
}
|
||
|
||
// Overloads to scale offsets (meters to world units)
|
||
fn project_size_float(meters: f32) -> f32 {
|
||
return meters * project.commonUnitsPerMeter.z * project_size();
|
||
}
|
||
|
||
fn project_size_vec2(meters: vec2<f32>) -> vec2<f32> {
|
||
return meters * project.commonUnitsPerMeter.xy * project_size();
|
||
}
|
||
|
||
fn project_size_vec3(meters: vec3<f32>) -> vec3<f32> {
|
||
return meters * project.commonUnitsPerMeter * project_size();
|
||
}
|
||
|
||
fn project_size_vec4(meters: vec4<f32>) -> vec4<f32> {
|
||
return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w);
|
||
}
|
||
|
||
// Returns a rotation matrix aligning the z‑axis with the given up vector.
|
||
fn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> {
|
||
let uz = normalize(up);
|
||
let ux = select(
|
||
vec3<f32>(1.0, 0.0, 0.0),
|
||
normalize(vec3<f32>(uz.y, -uz.x, 0.0)),
|
||
abs(uz.z) == 1.0
|
||
);
|
||
let uy = cross(uz, ux);
|
||
return mat3x3<f32>(ux, uy, uz);
|
||
}
|
||
|
||
// Since WGSL does not support "out" parameters, we return a struct.
|
||
struct RotationResult {
|
||
needsRotation: bool,
|
||
transform: mat3x3<f32>,
|
||
};
|
||
|
||
fn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult {
|
||
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
||
return RotationResult(true, project_get_orientation_matrix(commonPosition));
|
||
} else {
|
||
return RotationResult(false, mat3x3<f32>()); // identity alternative if needed
|
||
};
|
||
}
|
||
|
||
// Projects a normal vector from the current coordinate system to world space.
|
||
fn project_normal(vector: vec3<f32>) -> vec3<f32> {
|
||
let normal_modelspace = project.modelMatrix * vec4<f32>(vector, 0.0);
|
||
var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
|
||
let rotResult = project_needs_rotation(geometry.position.xyz);
|
||
if (rotResult.needsRotation) {
|
||
n = rotResult.transform * n;
|
||
}
|
||
return n;
|
||
}
|
||
|
||
// Applies a scale offset based on y-offset (dy)
|
||
fn project_offset_(offset: vec4<f32>) -> vec4<f32> {
|
||
let dy: f32 = offset.y;
|
||
let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
|
||
return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w);
|
||
}
|
||
|
||
// Projects lng/lat coordinates to a unit tile [0,1]
|
||
fn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {
|
||
var x = lnglat.x;
|
||
if (project.wrapLongitude != 0) {
|
||
x = ((x + 180.0) % 360.0) - 180.0;
|
||
}
|
||
let y = clamp(lnglat.y, -89.9, 89.9);
|
||
return vec2<f32>(
|
||
radians(x) + PI,
|
||
PI + log(tan(PI * 0.25 + radians(y) * 0.5))
|
||
) * WORLD_SCALE;
|
||
}
|
||
|
||
// Projects lng/lat/z coordinates for a globe projection.
|
||
fn project_globe_(lnglatz: vec3<f32>) -> vec3<f32> {
|
||
let lambda = radians(lnglatz.x);
|
||
let phi = radians(lnglatz.y);
|
||
let cosPhi = cos(phi);
|
||
let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
|
||
return vec3<f32>(
|
||
sin(lambda) * cosPhi,
|
||
-cos(lambda) * cosPhi,
|
||
sin(phi)
|
||
) * D;
|
||
}
|
||
|
||
// Projects positions (with an optional 64-bit low part) from the input
|
||
// coordinate system to the common space.
|
||
fn project_position_vec4_f64(position: vec4<f32>, position64Low: vec3<f32>) -> vec4<f32> {
|
||
var position_world = project.modelMatrix * position;
|
||
|
||
// Work around for a Mac+NVIDIA bug:
|
||
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
||
return vec4<f32>(
|
||
project_mercator_(position_world.xy),
|
||
_project_size_at_latitude_m(position_world.z, position_world.y),
|
||
position_world.w
|
||
);
|
||
}
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
|
||
position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w);
|
||
}
|
||
}
|
||
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
||
return vec4<f32>(
|
||
project_globe_(position_world.xyz),
|
||
position_world.w
|
||
);
|
||
}
|
||
}
|
||
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
||
if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
|
||
return vec4<f32>(
|
||
project_mercator_(position_world.xy) - project.commonOrigin.xy,
|
||
project_size_float(position_world.z),
|
||
position_world.w
|
||
);
|
||
}
|
||
}
|
||
}
|
||
if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
|
||
(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
|
||
(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
||
project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
|
||
position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w);
|
||
}
|
||
|
||
return project_offset_(position_world) +
|
||
project_offset_(project.modelMatrix * vec4<f32>(position64Low, 0.0));
|
||
}
|
||
|
||
// Overloaded versions for different input types.
|
||
fn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> {
|
||
return project_position_vec4_f64(position, ZERO_64_LOW);
|
||
}
|
||
|
||
fn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> {
|
||
let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low);
|
||
return projected_position.xyz;
|
||
}
|
||
|
||
fn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> {
|
||
let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW);
|
||
return projected_position.xyz;
|
||
}
|
||
|
||
fn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> {
|
||
let projected_position = project_position_vec4_f64(vec4<f32>(position, 0.0, 1.0), ZERO_64_LOW);
|
||
return projected_position.xy;
|
||
}
|
||
|
||
// Transforms a common space position to clip space.
|
||
fn project_common_position_to_clipspace_with_projection(position: vec4<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> {
|
||
return viewProjectionMatrix * position + center;
|
||
}
|
||
|
||
// Uses the project viewProjectionMatrix and center.
|
||
fn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> {
|
||
return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center);
|
||
}
|
||
|
||
// Returns a clip space offset corresponding to a given number of screen pixels.
|
||
fn project_pixel_size_to_clipspace(pixels: vec2<f32>) -> vec2<f32> {
|
||
let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
|
||
return offset * project.focalDistance;
|
||
}
|
||
|
||
fn project_meter_size_to_pixel(meters: f32) -> f32 {
|
||
return project_size_float(meters) * project.scale;
|
||
}
|
||
|
||
fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 {
|
||
if (unit == UNIT_METERS) {
|
||
return project_meter_size_to_pixel(size);
|
||
} else if (unit == UNIT_COMMON) {
|
||
return size * project.scale;
|
||
}
|
||
// UNIT_PIXELS: no scaling applied.
|
||
return size;
|
||
}
|
||
|
||
fn project_pixel_size_float(pixels: f32) -> f32 {
|
||
return pixels / project.scale;
|
||
}
|
||
|
||
fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
|
||
return pixels / project.scale;
|
||
}
|
||
`})),rF,iF,aF,oF,nre=o((()=>{zP(),ZP(),rF=[`default`,`lnglat`,`meter-offsets`,`lnglat-offsets`,`cartesian`].map(e=>`const int COORDINATE_SYSTEM_${e.toUpperCase().replaceAll(`-`,`_`)} = ${HP(e)};`).join(``),iF=Object.keys(FP).map(e=>`const int PROJECTION_MODE_${e} = ${FP[e]};`).join(``),aF=Object.keys(IP).map(e=>`const int UNIT_${e.toUpperCase()} = ${IP[e]};`).join(``),oF=`\
|
||
${rF}
|
||
${iF}
|
||
${aF}
|
||
layout(std140) uniform projectUniforms {
|
||
bool wrapLongitude;
|
||
int coordinateSystem;
|
||
vec3 commonUnitsPerMeter;
|
||
int projectionMode;
|
||
float scale;
|
||
vec3 commonUnitsPerWorldUnit;
|
||
vec3 commonUnitsPerWorldUnit2;
|
||
vec4 center;
|
||
mat4 modelMatrix;
|
||
mat4 viewProjectionMatrix;
|
||
vec2 viewportSize;
|
||
float devicePixelRatio;
|
||
float focalDistance;
|
||
vec3 cameraPosition;
|
||
vec3 coordinateOrigin;
|
||
vec3 commonOrigin;
|
||
bool pseudoMeters;
|
||
} project;
|
||
const float TILE_SIZE = 512.0;
|
||
const float PI = 3.1415926536;
|
||
const float WORLD_SCALE = TILE_SIZE / (PI * 2.0);
|
||
const vec3 ZERO_64_LOW = vec3(0.0);
|
||
const float EARTH_RADIUS = 6370972.0;
|
||
const float GLOBE_RADIUS = 256.0;
|
||
float project_size_at_latitude(float lat) {
|
||
float y = clamp(lat, -89.9, 89.9);
|
||
return 1.0 / cos(radians(y));
|
||
}
|
||
float project_size() {
|
||
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
|
||
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
|
||
project.pseudoMeters == false) {
|
||
if (geometry.position.w == 0.0) {
|
||
return project_size_at_latitude(geometry.worldPosition.y);
|
||
}
|
||
float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
|
||
float y2 = y * y;
|
||
float y4 = y2 * y2;
|
||
float y6 = y4 * y2;
|
||
return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
|
||
}
|
||
return 1.0;
|
||
}
|
||
float project_size_at_latitude(float meters, float lat) {
|
||
return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);
|
||
}
|
||
float project_size(float meters) {
|
||
return meters * project.commonUnitsPerMeter.z * project_size();
|
||
}
|
||
vec2 project_size(vec2 meters) {
|
||
return meters * project.commonUnitsPerMeter.xy * project_size();
|
||
}
|
||
vec3 project_size(vec3 meters) {
|
||
return meters * project.commonUnitsPerMeter * project_size();
|
||
}
|
||
vec4 project_size(vec4 meters) {
|
||
return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);
|
||
}
|
||
mat3 project_get_orientation_matrix(vec3 up) {
|
||
vec3 uz = normalize(up);
|
||
vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));
|
||
vec3 uy = cross(uz, ux);
|
||
return mat3(ux, uy, uz);
|
||
}
|
||
bool project_needs_rotation(vec3 commonPosition, out mat3 transform) {
|
||
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
||
transform = project_get_orientation_matrix(commonPosition);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
vec3 project_normal(vec3 vector) {
|
||
vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);
|
||
vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
|
||
mat3 rotation;
|
||
if (project_needs_rotation(geometry.position.xyz, rotation)) {
|
||
n = rotation * n;
|
||
}
|
||
return n;
|
||
}
|
||
vec4 project_offset_(vec4 offset) {
|
||
float dy = offset.y;
|
||
vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
|
||
return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);
|
||
}
|
||
vec2 project_mercator_(vec2 lnglat) {
|
||
float x = lnglat.x;
|
||
if (project.wrapLongitude) {
|
||
x = mod(x + 180., 360.0) - 180.;
|
||
}
|
||
float y = clamp(lnglat.y, -89.9, 89.9);
|
||
return vec2(
|
||
radians(x) + PI,
|
||
PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
|
||
) * WORLD_SCALE;
|
||
}
|
||
vec3 project_globe_(vec3 lnglatz) {
|
||
float lambda = radians(lnglatz.x);
|
||
float phi = radians(lnglatz.y);
|
||
float cosPhi = cos(phi);
|
||
float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
|
||
return vec3(
|
||
sin(lambda) * cosPhi,
|
||
-cos(lambda) * cosPhi,
|
||
sin(phi)
|
||
) * D;
|
||
}
|
||
vec4 project_position(vec4 position, vec3 position64Low) {
|
||
vec4 position_world = project.modelMatrix * position;
|
||
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
||
return vec4(
|
||
project_mercator_(position_world.xy),
|
||
project_size_at_latitude(position_world.z, position_world.y),
|
||
position_world.w
|
||
);
|
||
}
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
|
||
position_world.xyz += project.coordinateOrigin;
|
||
}
|
||
}
|
||
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
||
return vec4(
|
||
project_globe_(position_world.xyz),
|
||
position_world.w
|
||
);
|
||
}
|
||
}
|
||
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
||
if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
|
||
return vec4(
|
||
project_mercator_(position_world.xy) - project.commonOrigin.xy,
|
||
project_size(position_world.z),
|
||
position_world.w
|
||
);
|
||
}
|
||
}
|
||
}
|
||
if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
|
||
(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
|
||
(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
||
project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
|
||
position_world.xyz -= project.coordinateOrigin;
|
||
}
|
||
return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));
|
||
}
|
||
vec4 project_position(vec4 position) {
|
||
return project_position(position, ZERO_64_LOW);
|
||
}
|
||
vec3 project_position(vec3 position, vec3 position64Low) {
|
||
vec4 projected_position = project_position(vec4(position, 1.0), position64Low);
|
||
return projected_position.xyz;
|
||
}
|
||
vec3 project_position(vec3 position) {
|
||
vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);
|
||
return projected_position.xyz;
|
||
}
|
||
vec2 project_position(vec2 position) {
|
||
vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);
|
||
return projected_position.xy;
|
||
}
|
||
vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {
|
||
return viewProjectionMatrix * position + center;
|
||
}
|
||
vec4 project_common_position_to_clipspace(vec4 position) {
|
||
return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);
|
||
}
|
||
vec2 project_pixel_size_to_clipspace(vec2 pixels) {
|
||
vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
|
||
return offset * project.focalDistance;
|
||
}
|
||
float project_size_to_pixel(float meters) {
|
||
return project_size(meters) * project.scale;
|
||
}
|
||
vec2 project_size_to_pixel(vec2 meters) {
|
||
return project_size(meters) * project.scale;
|
||
}
|
||
float project_size_to_pixel(float size, int unit) {
|
||
if (unit == UNIT_METERS) return project_size_to_pixel(size);
|
||
if (unit == UNIT_COMMON) return size * project.scale;
|
||
return size;
|
||
}
|
||
float project_pixel_size(float pixels) {
|
||
return pixels / project.scale;
|
||
}
|
||
vec2 project_pixel_size(vec2 pixels) {
|
||
return pixels / project.scale;
|
||
}
|
||
`}));function rre(e=sF){return`viewport`in e?$ne(e):{}}var sF,cF,lF=o((()=>{bM(),NM(),ZP(),tre(),nre(),sF={},cF={name:`project`,dependencies:[yO,MM],source:nF,vs:oF,getUniforms:rre,uniformTypes:{wrapLongitude:`f32`,coordinateSystem:`i32`,commonUnitsPerMeter:`vec3<f32>`,projectionMode:`i32`,scale:`f32`,commonUnitsPerWorldUnit:`vec3<f32>`,commonUnitsPerWorldUnit2:`vec3<f32>`,center:`vec4<f32>`,modelMatrix:`mat4x4<f32>`,viewProjectionMatrix:`mat4x4<f32>`,viewportSize:`vec2<f32>`,devicePixelRatio:`f32`,focalDistance:`f32`,cameraPosition:`vec3<f32>`,coordinateOrigin:`vec3<f32>`,commonOrigin:`vec3<f32>`,pseudoMeters:`f32`}}})),uF,dF,fF,ire=o((()=>{lF(),uF=`// Define a structure to hold both the clip-space position and the common position.
|
||
struct ProjectResult {
|
||
clipPosition: vec4<f32>,
|
||
commonPosition: vec4<f32>,
|
||
};
|
||
|
||
// This function mimics the GLSL version with the 'out' parameter by returning both values.
|
||
fn project_position_to_clipspace_and_commonspace(
|
||
position: vec3<f32>,
|
||
position64Low: vec3<f32>,
|
||
offset: vec3<f32>
|
||
) -> ProjectResult {
|
||
// Compute the projected position.
|
||
let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low);
|
||
|
||
// Start with the provided offset.
|
||
var finalOffset: vec3<f32> = offset;
|
||
|
||
// Get whether a rotation is needed and the rotation matrix.
|
||
let rotationResult = project_needs_rotation(projectedPosition);
|
||
|
||
// If rotation is needed, update the offset.
|
||
if (rotationResult.needsRotation) {
|
||
finalOffset = rotationResult.transform * offset;
|
||
}
|
||
|
||
// Compute the common position.
|
||
let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0);
|
||
|
||
// Convert to clip-space.
|
||
let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition);
|
||
|
||
return ProjectResult(clipPosition, commonPosition);
|
||
}
|
||
|
||
// A convenience overload that returns only the clip-space position.
|
||
fn project_position_to_clipspace(
|
||
position: vec3<f32>,
|
||
position64Low: vec3<f32>,
|
||
offset: vec3<f32>
|
||
) -> vec4<f32> {
|
||
return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;
|
||
}
|
||
`,dF=`vec4 project_position_to_clipspace(
|
||
vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
|
||
) {
|
||
vec3 projectedPosition = project_position(position, position64Low);
|
||
mat3 rotation;
|
||
if (project_needs_rotation(projectedPosition, rotation)) {
|
||
// offset is specified as ENU
|
||
// when in globe projection, rotate offset so that the ground alighs with the surface of the globe
|
||
offset = rotation * offset;
|
||
}
|
||
commonPosition = vec4(projectedPosition + offset, 1.0);
|
||
return project_common_position_to_clipspace(commonPosition);
|
||
}
|
||
|
||
vec4 project_position_to_clipspace(
|
||
vec3 position, vec3 position64Low, vec3 offset
|
||
) {
|
||
vec4 commonPosition;
|
||
return project_position_to_clipspace(position, position64Low, offset, commonPosition);
|
||
}
|
||
`,fF={name:`project32`,dependencies:[cF],source:uF,vs:dF}}));function are(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function pF(e,t){let n=qD([],t,e);return KD(n,n,1/n[3]),n}function mF(e,t,n){return e<t?t:e>n?n:e}function hF(e){return Math.log(e)*Math.LOG2E}var gF,_F=o((()=>{lO(),gF=Math.log2||hF}));function vF(e,t){if(!e)throw Error(t||`@math.gl/web-mercator: assertion failed.`)}var yF=o((()=>{}));function bF(e){return gF(e)}function xF(e){let[t,n]=e;vF(Number.isFinite(t)),vF(Number.isFinite(n)&&n>=-90&&n<=90,`invalid latitude`);let r=t*FF,i=n*FF;return[LF*(r+NF)/(2*NF),LF*(NF+Math.log(Math.tan(PF+i*.5)))/(2*NF)]}function SF(e){let[t,n]=e,r=t/LF*(2*NF)-NF,i=2*(Math.atan(Math.exp(n/LF*(2*NF)-NF))-PF);return[r*IF,i*IF]}function CF(e){let{latitude:t}=e;return vF(Number.isFinite(t)),bF(RF*Math.cos(t*FF))-9}function wF(e){let t=Math.cos(e*FF);return LF/RF/t}function TF(e){let{latitude:t,longitude:n,highPrecision:r=!1}=e;vF(Number.isFinite(t)&&Number.isFinite(n));let i=LF,a=Math.cos(t*FF),o=i/360,s=o/a,c=i/RF/a,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,s,c],degreesPerUnit:[1/o,1/s,1/c]};if(r){let e=FF*Math.tan(t*FF)/a,n=o*e/2,r=i/RF*e,u=r/s*c;l.unitsPerDegree2=[0,n,r],l.unitsPerMeter2=[u,0,u]}return l}function EF(e,t){let[n,r,i]=e,[a,o,s]=t,{unitsPerMeter:c,unitsPerMeter2:l}=TF({longitude:n,latitude:r,highPrecision:!0}),u=xF(e);u[0]+=a*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let d=SF(u),f=(i||0)+(s||0);return Number.isFinite(i)||Number.isFinite(s)?[d[0],d[1],f]:d}function DF(e){let{height:t,pitch:n,bearing:r,altitude:i,scale:a,center:o}=e,s=are();jD(s,s,[0,0,-i]),PD(s,s,-n*FF),ID(s,s,r*FF);let c=a/t;return MD(s,s,[c,c,c]),o&&jD(s,s,bte([],o)),s}function OF(e){let{width:t,height:n,altitude:r,pitch:i=0,offset:a,center:o,scale:s,nearZMultiplier:c=1,farZMultiplier:l=1}=e,{fovy:u=kF(BF)}=e;r!==void 0&&(u=kF(r));let d=u*FF,f=i*FF,p=AF(u),m=p;o&&(m+=o[2]*s/Math.cos(f)/n);let h=d*(.5+(a?a[1]:0)/n),g=Math.sin(h)*m/Math.sin(mF(Math.PI/2-f-h,.01,Math.PI-.01)),_=Math.sin(f)*g+m,v=m*10,y=Math.min(_*l,v);return{fov:d,aspect:t/n,focalDistance:p,near:c,far:y}}function kF(e){return 2*Math.atan(.5/e)*IF}function AF(e){return .5/Math.tan(.5*e*FF)}function jF(e,t){let[n,r,i=0]=e;return vF(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),pF(t,[n,r,i,1])}function MF(e,t,n=0){let[r,i,a]=e;if(vF(Number.isFinite(r)&&Number.isFinite(i),`invalid pixel coordinate`),Number.isFinite(a))return pF(t,[r,i,a,1]);let o=pF(t,[r,i,0,1]),s=pF(t,[r,i,1,1]),c=o[2],l=s[2];return oD([],o,s,c===l?0:((n||0)-c)/(l-c))}var NF,PF,FF,IF,LF,RF,zF,BF,VF=o((()=>{_F(),lO(),yF(),NF=Math.PI,PF=NF/4,FF=NF/180,IF=180/NF,LF=512,RF=4003e4,zF=85.051129,BF=1.5}));function HF(e){let{width:t,height:n,bounds:r,minExtent:i=0,maxZoom:a=24,offset:o=[0,0]}=e,[[s,c],[l,u]]=r,d=UF(e.padding),f=xF([s,mF(u,-zF,zF)]),p=xF([l,mF(c,-zF,zF)]),m=[Math.max(Math.abs(p[0]-f[0]),i),Math.max(Math.abs(p[1]-f[1]),i)],h=[t-d.left-d.right-Math.abs(o[0])*2,n-d.top-d.bottom-Math.abs(o[1])*2];vF(h[0]>0&&h[1]>0);let g=h[0]/m[0],_=h[1]/m[1],v=(d.right-d.left)/2/g,y=(d.top-d.bottom)/2/_,b=SF([(p[0]+f[0])/2+v,(p[1]+f[1])/2+y]),x=Math.min(a,gF(Math.abs(Math.min(g,_))));return vF(Number.isFinite(x)),{longitude:b[0],latitude:b[1],zoom:x}}function UF(e=0){return typeof e==`number`?{top:e,bottom:e,left:e,right:e}:(vF(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}var WF=o((()=>{yF(),_F(),VF()}));function GF(e,t=0){let{width:n,height:r,unproject:i}=e,a={targetZ:t},o=i([0,r],a),s=i([n,r],a),c,l;return(e.fovy?.5*e.fovy*qF:Math.atan(.5/e.altitude))>(90-e.pitch)*qF-.01?(c=KF(e,0,t),l=KF(e,n,t)):(c=i([0,0],a),l=i([n,0],a)),[o,s,l,c]}function KF(e,t,n){let{pixelUnprojectionMatrix:r}=e,i=pF(r,[t,0,1,1]),a=pF(r,[t,e.height,1,1]),o=SF(oD([],i,a,(n*e.distanceScales.unitsPerMeter[2]-i[2])/(a[2]-i[2])));return o.push(n),o}var qF,JF=o((()=>{lO(),VF(),_F(),qF=Math.PI/180})),YF=o((()=>{VF(),WF(),JF()})),XF=o((()=>{VF()})),ZF=o((()=>{VF()})),QF=o((()=>{YF(),JF(),WF(),XF(),ZF(),VF()}));function $F(e,t){let[n,r,i]=e,a=MF([n,r,i],t);return Number.isFinite(i)?a:[a[0],a[1],0]}function eI({viewport:e,center:t}){return new aO(e.viewProjectionMatrix).invert().transform(t)}function tI({viewport:e,shadowMatrices:t}){let n=[],r=e.pixelUnprojectionMatrix,i=e.isGeospatial?void 0:1,a=[[0,0,i],[e.width,0,i],[0,e.height,i],[e.width,e.height,i],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>$F(e,r));for(let r of t){let t=r.clone().translate(new TD(e.center).negate()),i=a.map(e=>t.transform(e)),o=new aO().ortho({left:Math.min(...i.map(e=>e[0])),right:Math.max(...i.map(e=>e[0])),bottom:Math.min(...i.map(e=>e[1])),top:Math.max(...i.map(e=>e[1])),near:Math.min(...i.map(e=>-e[2])),far:Math.max(...i.map(e=>-e[2]))});n.push(o.multiplyRight(r))}return n}function nI(e){let{shadowEnabled:t=!0,project:n}=e;if(!t||!n||!e.shadowMatrices||!e.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};let r=cF.getUniforms(n),i=oI({viewport:n.viewport,center:r.center}),a=[],o=sI({shadowMatrices:e.shadowMatrices,viewport:n.viewport}).slice();for(let t=0;t<e.shadowMatrices.length;t++){let e=o[t],s=e.clone().translate(new TD(n.viewport.center).negate());r.coordinateSystem===HP(`lnglat`)&&r.projectionMode===FP.WEB_MERCATOR?(o[t]=s,a[t]=i):(o[t]=e.clone().multiplyRight(lI),a[t]=s.transform(i))}let s={drawShadowMap:!!e.drawToShadowMap,useShadowMap:e.shadowMaps?e.shadowMaps.length>0:!1,color:e.shadowColor||cI,lightId:e.shadowLightId||0,lightCount:e.shadowMatrices.length,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};for(let e=0;e<o.length;e++)s[`viewProjectionMatrix${e}`]=o[e],s[`projectCenter${e}`]=a[e];for(let t=0;t<2;t++)s[`shadow_uShadowMap${t}`]=e.shadowMaps&&e.shadowMaps[t]||e.dummyShadowMap;return s}var rI,iI,aI,oI,sI,cI,lI,uI,dI=o((()=>{zP(),lF(),lO(),VP(),QF(),ZP(),rI=`
|
||
layout(std140) uniform shadowUniforms {
|
||
bool drawShadowMap;
|
||
bool useShadowMap;
|
||
vec4 color;
|
||
highp int lightId;
|
||
float lightCount;
|
||
mat4 viewProjectionMatrix0;
|
||
mat4 viewProjectionMatrix1;
|
||
vec4 projectCenter0;
|
||
vec4 projectCenter1;
|
||
} shadow;
|
||
`,iI=`
|
||
${rI}
|
||
|
||
const int max_lights = 2;
|
||
|
||
out vec3 shadow_vPosition[max_lights];
|
||
|
||
vec4 shadow_setVertexPosition(vec4 position_commonspace) {
|
||
mat4 viewProjectionMatrices[max_lights];
|
||
viewProjectionMatrices[0] = shadow.viewProjectionMatrix0;
|
||
viewProjectionMatrices[1] = shadow.viewProjectionMatrix1;
|
||
vec4 projectCenters[max_lights];
|
||
projectCenters[0] = shadow.projectCenter0;
|
||
projectCenters[1] = shadow.projectCenter1;
|
||
|
||
if (shadow.drawShadowMap) {
|
||
return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]);
|
||
}
|
||
if (shadow.useShadowMap) {
|
||
for (int i = 0; i < max_lights; i++) {
|
||
if(i < int(shadow.lightCount)) {
|
||
vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]);
|
||
shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;
|
||
}
|
||
}
|
||
}
|
||
return gl_Position;
|
||
}
|
||
|
||
`,aI=`
|
||
${rI}
|
||
|
||
const int max_lights = 2;
|
||
uniform sampler2D shadow_uShadowMap0;
|
||
uniform sampler2D shadow_uShadowMap1;
|
||
|
||
in vec3 shadow_vPosition[max_lights];
|
||
|
||
const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);
|
||
const vec4 bitUnpackShift = 1.0 / bitPackShift;
|
||
const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
|
||
|
||
float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {
|
||
vec4 rgbaDepth = texture(shadowMap, position.xy);
|
||
|
||
float z = dot(rgbaDepth, bitUnpackShift);
|
||
return smoothstep(0.001, 0.01, position.z - z);
|
||
}
|
||
|
||
vec4 shadow_filterShadowColor(vec4 color) {
|
||
if (shadow.drawShadowMap) {
|
||
vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);
|
||
rgbaDepth -= rgbaDepth.gbaa * bitMask;
|
||
return rgbaDepth;
|
||
}
|
||
if (shadow.useShadowMap) {
|
||
float shadowAlpha = 0.0;
|
||
shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);
|
||
if(shadow.lightCount > 1.0) {
|
||
shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);
|
||
}
|
||
shadowAlpha *= shadow.color.a / shadow.lightCount;
|
||
float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);
|
||
|
||
return vec4(
|
||
mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha),
|
||
blendedAlpha
|
||
);
|
||
}
|
||
return color;
|
||
}
|
||
|
||
`,oI=BP(eI),sI=BP(tI),cI=[0,0,0,1],lI=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],uI={name:`shadow`,dependencies:[cF],vs:iI,fs:aI,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
||
position = shadow_setVertexPosition(geometry.position);
|
||
`,"fs:DECKGL_FILTER_COLOR":`
|
||
color = shadow_filterShadowColor(color);
|
||
`},getUniforms:nI,uniformTypes:{drawShadowMap:`f32`,useShadowMap:`f32`,color:`vec4<f32>`,lightId:`i32`,lightCount:`f32`,viewProjectionMatrix0:`mat4x4<f32>`,viewProjectionMatrix1:`mat4x4<f32>`,projectCenter0:`vec4<f32>`,projectCenter1:`vec4<f32>`}}})),fI,pI,mI=o((()=>{bM(),fI=`struct pickingUniforms {
|
||
isActive: f32,
|
||
isAttribute: f32,
|
||
isHighlightActive: f32,
|
||
useByteColors: f32,
|
||
highlightedObjectColor: vec3<f32>,
|
||
highlightColor: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(auto) var<uniform> picking: pickingUniforms;
|
||
|
||
fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {
|
||
return select(color, color / 255.0, picking.useByteColors > 0.5);
|
||
}
|
||
|
||
fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {
|
||
return select(color, color / 255.0, picking.useByteColors > 0.5);
|
||
}
|
||
|
||
fn picking_isColorZero(color: vec3<f32>) -> bool {
|
||
return dot(color, vec3<f32>(1.0)) < 0.00001;
|
||
}
|
||
|
||
fn picking_isColorValid(color: vec3<f32>) -> bool {
|
||
return dot(color, vec3<f32>(1.0)) > 0.00001;
|
||
}
|
||
`,pI={...MO,source:fI,defaultUniforms:{...MO.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
||
// for picking depth values
|
||
picking_setPickingAttribute(position.z / position.w);
|
||
`,"vs:DECKGL_FILTER_COLOR":`
|
||
picking_setPickingColor(geometry.pickingColor);
|
||
`,"fs:DECKGL_FILTER_COLOR":{order:99,injection:`
|
||
// use highlight color if this fragment belongs to the selected object.
|
||
color = picking_filterHighlightColor(color);
|
||
|
||
// use picking color if rendering to picking FBO.
|
||
color = picking_filterPickingColor(color);
|
||
`}}}}));function hI(e){let t=AE.getDefaultShaderAssembler();for(let e of gI)t.addDefaultModule(e);t._hookFunctions.length=0;let n=e===`glsl`?_I:vI;for(let e of n)t.addShaderHook(e);return t}var gI,_I,vI,yI=o((()=>{bM(),wM(),DM(),NM(),ire(),mI(),gI=[MM],_I=[`vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)`,`vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)`,`vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)`,`fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)`],vI=[]})),bI,xI,SI,CI,wI=o((()=>{bI=[255,255,255],xI=1,SI=0,CI=class{constructor(e={}){this.type=`ambient`;let{color:t=bI}=e,{intensity:n=xI}=e;this.id=e.id||`ambient-${SI++}`,this.color=t,this.intensity=n}}})),TI,EI,DI,OI,kI,AI=o((()=>{lO(),TI=[255,255,255],EI=1,DI=[0,0,-1],OI=0,kI=class{constructor(e={}){this.type=`directional`;let{color:t=TI}=e,{intensity:n=EI}=e,{direction:r=DI}=e,{_shadow:i=!1}=e;this.id=e.id||`directional-${OI++}`,this.color=t,this.intensity=n,this.type=`directional`,this.direction=new TD(r).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}}})),jI,MI=o((()=>{jI=class{constructor(e,t={id:`pass`}){let{id:n}=t;this.id=n,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}}}));function NI(e=0,t={}){let n={},r=(i,a)=>{let o=i.props._offset,s=i.id,c=i.parent&&i.parent.id,l;if(c&&!(c in t)&&r(i.parent,!1),c in n){let e=n[c]=n[c]||NI(t[c],t);l=e(i,a),n[s]=e}else Number.isFinite(o)?(l=o+(t[c]||0),n[s]=null):l=e;return a&&l>=e&&(e=l+1),t[s]=l,l};return r}function PI(e,{shaderModuleProps:t,target:n,viewport:r}){let i=t?.project?.devicePixelRatio??e.canvasContext.cssToDeviceRatio(),[,a]=e.canvasContext.getDrawingBufferSize(),o=n?n.height:a,s=r;return[s.x*i,o-(s.y+s.height)*i,s.width*i,s.height*i]}function FI(e,...t){for(let n of t)if(n)for(let t in n)e[t]?Object.assign(e[t],n[t]):e[t]=n[t];return e}var II,LI,RI=o((()=>{MI(),II={depthWriteEnabled:!0,depthCompare:`less-equal`,blendColorOperation:`add`,blendColorSrcFactor:`src-alpha`,blendColorDstFactor:`one`,blendAlphaOperation:`add`,blendAlphaSrcFactor:`one-minus-dst-alpha`,blendAlphaDstFactor:`one`},LI=class extends jI{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let t=this.device.canvasContext,n=e.target??t.getCurrentFramebuffer(),[r,i]=t.getDrawingBufferSize(),a=e.clearCanvas??!0,o=e.clearColor??(a?[0,0,0,0]:!1),s=a?1:!1,c=a?0:!1,l=e.colorMask??15,u={viewport:[0,0,r,i]};e.colorMask&&(u.colorMask=l),e.scissorRect&&(u.scissorRect=e.scissorRect);let d=this.device.beginRenderPass({framebuffer:n,parameters:u,clearColor:o,clearDepth:s,clearStencil:c});try{return this._drawLayers(d,e)}finally{d.end(),this.device.submit()}}_drawLayers(e,t){let{target:n,shaderModuleProps:r,viewports:i,views:a,onViewportActive:o,clearStack:s=!0}=t;t.pass=t.pass||`unknown`,s&&(this._lastRenderIndex=-1);let c=[];for(let s of i){let i=a&&a[s.id];o?.(s);let l=this._getDrawLayerParams(s,t),u=s.subViewports||[s];for(let a of u){let o=this._drawLayersInViewport(e,{target:n,shaderModuleProps:r,viewport:a,view:i,pass:t.pass,layers:t.layers},l);c.push(o)}}return c}_getDrawLayerParams(e,{layers:t,pass:n,isPicking:r=!1,layerFilter:i,cullRect:a,views:o,effects:s,shaderModuleProps:c},l=!1){let u=[],d=NI(this._lastRenderIndex+1),f={layer:t[0],viewport:e,isPicking:r,renderPass:n,cullRect:a},p={};for(let r=0;r<t.length;r++){let a=t[r],m=this._shouldDrawLayer(a,f,i,p),h={shouldDrawLayer:m};m&&!l&&(h.shouldDrawLayer=!0,h.layerRenderIndex=d(a,m),h.shaderModuleProps=this._getShaderModuleProps(a,s,n,c),h.layerParameters={...a.context.device.type===`webgpu`?II:null,...a.context.deck?.props.parameters,...o?.[e.id]?.props.parameters,...this.getLayerParameters(a,r,e)}),u[r]=h}return u}_drawLayersInViewport(e,{layers:t,shaderModuleProps:n,pass:r,target:i,viewport:a,view:o},s){let c=PI(this.device,{shaderModuleProps:n,target:i,viewport:a});if(o){let{clear:e,clearColor:t,clearDepth:n,clearStencil:r}=o.props;if(e){let e=[0,0,0,0],a=1,o=0;Array.isArray(t)?e=[...t.slice(0,3),t[3]||255].map(e=>e/255):t===!1&&(e=!1),n!==void 0&&(a=n),r!==void 0&&(o=r),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:c,scissorRect:c},clearColor:e,clearDepth:a,clearStencil:o}).end()}}let l={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:c});for(let n=0;n<t.length;n++){let i=t[n],o=s[n],{shouldDrawLayer:c}=o;if(c&&i.props.pickable&&l.pickableCount++,i.isComposite&&l.compositeCount++,i.isDrawable&&o.shouldDrawLayer){let{layerRenderIndex:t,shaderModuleProps:n,layerParameters:s}=o;l.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,t),n.project&&(n.project.viewport=a),i.context.renderPass=e;try{i._drawLayer({renderPass:e,shaderModuleProps:n,uniforms:{layerIndex:t},parameters:s})}catch(e){i.raiseError(e,`drawing ${i} to ${r}`)}}}return l}shouldDrawLayer(e){return!0}getShaderModuleProps(e,t,n){return null}getLayerParameters(e,t,n){return e.props.parameters}_shouldDrawLayer(e,t,n,r){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;t.layer=e;let i=e.parent;for(;i;){if(!i.props.visible||!i.filterSubLayer(t))return!1;t.layer=i,i=i.parent}if(n){let e=t.layer.id;if(e in r||(r[e]=n(t)),!r[e])return!1}return e.activateViewport(t.viewport),!0}_getShaderModuleProps(e,t,n,r){let i=this.device.canvasContext.cssToDeviceRatio(),a=e.internalState?.propsInTransition||e.props,o={layer:a,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:i,modelMatrix:a.modelMatrix,coordinateSystem:a.coordinateSystem,coordinateOrigin:a.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(t)for(let n of t)FI(o,n.getShaderModuleProps?.(e,o));for(let t of e.context.defaultShaderModules)t.name in o||(o[t.name]={});return FI(o,this.getShaderModuleProps(e,t,o),r)}}})),zI,BI=o((()=>{RI(),zI=class extends LI{constructor(e,t){super(e,t);let n=e.createTexture({format:`rgba8unorm`,width:1,height:1,sampler:{minFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`}}),r=e.createTexture({format:`depth16unorm`,width:1,height:1});this.fbo=e.createFramebuffer({id:`shadowmap`,width:1,height:1,colorAttachments:[n],depthStencilAttachment:r})}delete(){this.fbo&&=(this.fbo.destroy(),null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],i=r.width*n,a=r.height*n,o=[1,1,1,1];(i!==t.width||a!==t.height)&&t.resize({width:i,height:a}),super.render({...e,clearColor:o,target:t,pass:`shadow`})}getLayerParameters(e,t,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:`less-equal`}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}}})),VI,HI,UI,WI,GI=o((()=>{wI(),AI(),lO(),BI(),dI(),VI={color:[255,255,255],intensity:1},HI=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],UI=[0,0,0,200/255],WI=class{constructor(e={}){this.id=`lighting-effect`,this.shadowColor=UI,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),n._addDefaultShaderModule(uI),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let n=e[t];switch(n.type){case`ambient`:this.ambientLight=n;break;case`directional`:this.directionalLights.push(n);break;case`point`:this.pointLights.push(n);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:n,onViewportActive:r,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let a=0;a<this.shadowPasses.length;a++)this.shadowPasses[a].render({layers:e,layerFilter:t,viewports:n,onViewportActive:r,views:i,shaderModuleProps:{shadow:{shadowLightId:a,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,t){let n=this.shadow?{project:t.project,shadowMaps:this.shadowPasses.map(e=>e.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},i=e.props.material;return{shadow:n,lighting:r,phongMaterial:i,gouraudMaterial:i}}cleanup(e){for(let e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(uI))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let n=new aO().lookAt({eye:new TD(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){let n=new zI(e);this.shadowPasses[t]=n}}_applyDefaultLights(){let{ambientLight:e,pointLights:t,directionalLights:n}=this;!e&&t.length===0&&n.length===0&&(this.ambientLight=new CI(VI),this.directionalLights.push(new kI(HI[0]),new kI(HI[1])))}_getLights(e){let t=[];this.ambientLight&&t.push(this.ambientLight);for(let n of this.pointLights)t.push(n.getProjectedLight({layer:e}));for(let n of this.directionalLights)t.push(n.getProjectedLight({layer:e}));return t}}})),KI,qI,JI=o((()=>{KI=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:r,padding:i=0,copy:a=!1,initialize:o=!1,maxCount:s}){let c=r||e&&e.constructor||Float32Array,l=t*n+i;if(ArrayBuffer.isView(e)){if(l<=e.length)return e;if(l*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new c(e.buffer,0,l)}let u=1/0;s&&(u=s*n+i);let d=this._allocate(c,l,o,u);return e&&a?d.set(e):o||d.fill(0,0,4),this._release(e),d}release(e){this._release(e)}_allocate(e,t,n,r){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>r&&(i=r);let a=this._pool,o=e.BYTES_PER_ELEMENT*i,s=a.findIndex(e=>e.byteLength>=o);if(s>=0){let t=new e(a.splice(s,1)[0],0,i);return n&&t.fill(0),t}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:n}=e,{byteLength:r}=n,i=t.findIndex(e=>e.byteLength>=r);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}},qI=new KI}));function YI(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function XI(e,t){let n=e%t;return n<0?t+n:n}function ZI(e){return[e[12],e[13],e[14]]}function QI(e){return{left:$I(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:$I(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:$I(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:$I(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:$I(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:$I(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}function $I(e,t,n,r){rL.set(e,t,n);let i=rL.len();return{distance:r/i,normal:new TD(-e/i,-t/i,-n/i)}}function eL(e){return e-Math.fround(e)}function tL(e,t){let{size:n=1,startIndex:r=0}=t,i=t.endIndex===void 0?e.length:t.endIndex,a=(i-r)/n;iL=qI.allocate(iL,a,{type:Float32Array,size:n*2});let o=r,s=0;for(;o<i;){for(let t=0;t<n;t++){let r=e[o++];iL[s+t]=r,iL[s+t+n]=eL(r)}s+=n*2}return iL.subarray(0,a*n*2)}function nL(e){let t=null,n=!1;for(let r of e)r&&(t?(n||=(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],!0),t[0][0]=Math.min(t[0][0],r[0][0]),t[0][1]=Math.min(t[0][1],r[0][1]),t[1][0]=Math.max(t[1][0],r[1][0]),t[1][1]=Math.max(t[1][1],r[1][1])):t=r);return t}var rL,iL,aL=o((()=>{JI(),lO(),rL=new TD}));function oL({width:e,height:t,orthographic:n,fovyRadians:r,focalDistance:i,padding:a,near:o,far:s}){let c=e/t,l=n?new aO().orthographic({fovy:r,aspect:c,focalDistance:i,near:o,far:s}):new aO().perspective({fovy:r,aspect:c,near:o,far:s});if(a){let{left:n=0,right:r=0,top:i=0,bottom:o=0}=a,s=zE((n+e-r)/2,0,e)-e/2,c=zE((i+t-o)/2,0,t)-t/2;l[8]-=s*2/e,l[9]+=c*2/t}return l}var sL,cL,lL,uL,dL,fL=o((()=>{Nw(),aL(),lO(),QF(),zP(),sL=Math.PI/180,cL=YI(),lL=[0,0,0],uL={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]},dL=class e{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||`viewport`,this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||uL,this.focalDistance=e.focalDistance||1,this.position=e.position||lL,this.modelMatrix=e.modelMatrix||null;let{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?FP.WEB_MERCATOR:FP.WEB_MERCATOR_AUTO_OFFSET:FP.IDENTITY}equals(t){return t instanceof e?this===t?!0:t.width===this.width&&t.height===this.height&&t.scale===this.scale&&VE(t.projectionMatrix,this.projectionMatrix)&&VE(t.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:t=!0}={}){let n=jF(this.projectPosition(e),this.pixelProjectionMatrix),[r,i]=n,a=t?i:this.height-i;return e.length===2?[r,a]:[r,a,n[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[r,i,a]=e,o=t?i:this.height-i,s=n&&n*this.distanceScales.unitsPerMeter[2],c=MF([r,o,a],this.pixelUnprojectionMatrix,s),[l,u,d]=this.unprojectPosition(c);return Number.isFinite(a)?[l,u,d]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){let[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(e){let[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(e){if(this.isGeospatial){let t=xF(e);return t[1]=zE(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?SF(e):e}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,0],t),r=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),a=this.unproject([this.width,this.height],t);return[Math.min(n[0],r[0],i[0],a[0]),Math.min(n[1],r[1],i[1],a[1]),Math.max(n[0],r[0],i[0],a[0]),Math.max(n[1],r[1],i[1],a[1])]}getDistanceScales(e){return e&&this.isGeospatial?TF({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:r=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+r}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,QI(this.viewProjectionMatrix)),this._frustumPlanes}panByPosition(e,t,n){return null}_initProps(e){let t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=CF({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||TF({latitude:n,longitude:t}));let r=2**this.zoom;this.scale=r;let{position:i,modelMatrix:a}=e,o=lL;if(i&&(o=a?new aO(a).transformAsVector(i,[]):i),this.isGeospatial){let e=this.projectPosition([t,n,0]);this.center=new TD(o).scale(this.distanceScales.unitsPerMeter).add(e)}else this.center=this.projectPosition(o)}_initMatrices(e){let{viewMatrix:t=cL,projectionMatrix:n=null,orthographic:r=!1,fovyRadians:i,fovy:a=75,near:o=.1,far:s=1e3,padding:c=null,focalDistance:l=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=new aO().multiplyRight(t).translate(new TD(this.center).negate()),this.projectionMatrix=n||oL({width:this.width,height:this.height,orthographic:r,fovyRadians:i||a*sL,focalDistance:l,padding:c,near:o,far:s});let u=YI();AD(u,u,this.projectionMatrix),AD(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=OD([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=ZI(this.viewMatrixInverse);let d=YI(),f=YI();MD(d,d,[this.width/2,-this.height/2,1]),jD(d,d,[1,-1,0]),AD(f,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=f,this.pixelUnprojectionMatrix=OD(YI(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||Mw.warn(`Pixel project matrix not invertible`)()}},dL.displayName=`Viewport`})),pL,mL=o((()=>{fL(),QF(),lO(),pL=class e extends dL{constructor(e={}){let{latitude:t=0,longitude:n=0,zoom:r=0,pitch:i=0,bearing:a=0,nearZMultiplier:o=.1,farZMultiplier:s=1.01,nearZ:c,farZ:l,orthographic:u=!1,projectionMatrix:d,repeat:f=!1,worldOffset:p=0,position:m,padding:h,legacyMeterSizes:g=!1}=e,{width:_,height:v,altitude:y=1.5}=e,b=2**r;_||=1,v||=1;let x,S=null;if(d)y=d[5]/2,x=kF(y);else{e.fovy?(x=e.fovy,y=AF(x)):x=kF(y);let n;if(h){let{top:e=0,bottom:t=0}=h;n=[0,zE((e+v-t)/2,0,v)-v/2]}S=OF({width:_,height:v,scale:b,center:m&&[0,0,m[2]*wF(t)],offset:n,pitch:i,fovy:x,nearZMultiplier:o,farZMultiplier:s}),Number.isFinite(c)&&(S.near=c),Number.isFinite(l)&&(S.far=l)}let C=DF({height:v,pitch:i,bearing:a,scale:b,altitude:y});p&&(C=new aO().translate([512*p,0,0]).multiplyLeft(C)),super({...e,width:_,height:v,viewMatrix:C,longitude:n,latitude:t,zoom:r,...S,fovy:x,focalDistance:y}),this.latitude=t,this.longitude=n,this.zoom=r,this.pitch=i,this.bearing=a,this.altitude=y,this.fovy=x,this.orthographic=u,this._subViewports=f?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let t=this.getBounds(),n=Math.floor((t[0]+180)/360),r=Math.ceil((t[2]-180)/360);for(let t=n;t<=r;t++){let n=t?new e({...this,worldOffset:t}):this;this._subViewports.push(n)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*wF(e[1])]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)/wF(n)]}addMetersToLngLat(e,t){return EF(e,t)}panByPosition(e,t,n){let r=MF(t,this.pixelUnprojectionMatrix),i=rD([],this.projectFlat(e),aD([],r)),a=rD([],this.center,i),[o,s]=this.unprojectFlat(a);return{longitude:o,latitude:s}}panByPosition3D(e,t){let n=e[2]||0,r=cD([],e,this.unproject(t,{targetZ:n}));return{longitude:this.longitude+r[0],latitude:this.latitude+r[1]}}getBounds(e={}){let t=GF(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(t,n={}){let{width:r,height:i}=this,{longitude:a,latitude:o,zoom:s}=HF({width:r,height:i,bounds:t,...n});return new e({width:r,height:i,longitude:a,latitude:o,zoom:s})}},pL.displayName=`WebMercatorViewport`}));function hL(e,t,n=!1){let r=t.projectPosition(e);if(n&&t instanceof pL){let[n,i,a=0]=e;r[2]=a*t.getDistanceScales([n,i]).unitsPerMeter[2]}return r}function gL(e){let{viewport:t,modelMatrix:n,coordinateOrigin:r}=e,{coordinateSystem:i,fromCoordinateSystem:a,fromCoordinateOrigin:o}=e;return i==="default"&&(i=t.isGeospatial?`lnglat`:`cartesian`),a===void 0?a=i:a==="default"&&(a=t.isGeospatial?`lnglat`:`cartesian`),o===void 0&&(o=r),{viewport:t,coordinateSystem:i,coordinateOrigin:r,modelMatrix:n,fromCoordinateSystem:a,fromCoordinateOrigin:o}}function _L(e,{viewport:t,modelMatrix:n,coordinateSystem:r,coordinateOrigin:i,offsetMode:a}){let[o,s,c=0]=e;switch(n&&([o,s,c]=qD([],[o,s,c,1],n)),r){case`default`:return _L(e,{viewport:t,modelMatrix:n,coordinateSystem:t.isGeospatial?`lnglat`:`cartesian`,coordinateOrigin:i,offsetMode:a});case`lnglat`:return hL([o,s,c],t,a);case`lnglat-offsets`:return hL([o+i[0],s+i[1],c+(i[2]||0)],t,a);case`meter-offsets`:return hL(EF(i,[o,s,c]),t,a);case`cartesian`:return t.isGeospatial?[o+i[0],s+i[1],c+i[2]]:t.projectPosition([o,s,c]);default:throw Error(`Invalid coordinateSystem: ${r}`)}}function vL(e,t){let{viewport:n,coordinateSystem:r,coordinateOrigin:i,modelMatrix:a,fromCoordinateSystem:o,fromCoordinateOrigin:s}=gL(t),{autoOffset:c=!0}=t,{geospatialOrigin:l=yL,shaderCoordinateOrigin:u=yL,offsetMode:d=!1}=c?UP(n,r,i):{},f=_L(e,{viewport:n,modelMatrix:a,coordinateSystem:o,coordinateOrigin:s,offsetMode:d});if(d){let e=n.projectPosition(l||u);yD(f,f,e)}return f}var yL,bL=o((()=>{ZP(),mL(),lO(),QF(),yL=[0,0,0]})),xL,SL,CL,wL=o((()=>{xL=1,SL=1,CL=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:n=1/0,rate:r=1,repeat:i=1}=e,a=xL++,o={time:0,delay:t,duration:n,rate:r,repeat:i};return this._setChannelTime(o,this.time),this.channels.set(a,o),a}removeChannel(e){this.channels.delete(e);for(let[t,n]of this.animations)n.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let e of t)this._setChannelTime(e,this.time);let n=this.animations.values();for(let e of n){let{animation:t,channel:n}=e;t.setTime(this.getTime(n))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let n=SL++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let n=t-e.delay;n>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}}}));function TL(e){let t=typeof window<`u`?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return t?t.call(window,e):setTimeout(()=>e(typeof performance<`u`?performance.now():Date.now()),1e3/60)}function EL(e){let t=typeof window<`u`?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(t){t.call(window,e);return}clearTimeout(e)}var DL=o((()=>{})),OL,kL,AL,jL=o((()=>{nM(),DL(),Yx(),OL=0,kL=`Animation Loop`,AL=class e{static defaultAnimationLoopProps={device:null,onAddHTML:()=>``,onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw=`initialized`;_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(t){if(this.props={...e.defaultAnimationLoopProps,...t},t=this.props,!t.device)throw Error(`No device provided`);this.stats=t.stats||new qx({id:`animation-loop-${OL++}`}),this.sharedStats=uA.stats.get(kL),this.frameRate=this.stats.get(`Frame Rate`),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get(`CPU Time`),this.gpuTime=this.stats.get(`GPU Time`),this.setProps({autoResizeViewport:t.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return`autoResizeViewport`in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(this._cancelAnimationFrame(),this._requestAnimationFrame(),this):null}catch(e){let t=e instanceof Error?e:Error(`Unknown error`);throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&=(this._resolveNextFrame(this),this._nextFramePromise=null,null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw(`waitForRender`),this._nextFramePromise||=new Promise(e=>{this._resolveNextFrame=e}),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw(`toDataURL`),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw Error(`OffscreenCanvas`)}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=TL(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(EL(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw Error(`loop`);let t=e?.canvas,n=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:n,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw Error(`animationProps`);return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw(`drawing buffer resized`),n!==this.animationProps.aspect&&this.setNeedsRedraw(`drawing buffer aspect changed`),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=n,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw Error(`No device provided`);this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement(`div`);document.body.appendChild(e),e.style.position=`relative`;let t=document.createElement(`div`);t.style.position=`absolute`,t.style.left=`10px`,t.style.bottom=`10px`,t.style.width=`300px`,t.style.background=`white`,this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize();return{width:e,height:t,aspect:e>0&&t>0?e/t:1}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<`u`?performance.now():Date.now());if(this._lastFrameTime){let e=t-this._lastFrameTime;e>0&&this.frameRate.addTime(e)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener(`mousemove`,this._onMousemove.bind(this)),this.canvas.addEventListener(`mouseleave`,this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}}));function ML(e=`id`){return NL[e]=NL[e]||1,`${e}-${NL[e]++}`}var NL,PL=o((()=>{NL={}}));function FL(e,t){if(t instanceof RL)return t;let n=IL(e,t),{attributes:r,bufferLayout:i}=LL(e,t);return new RL({topology:t.topology||`triangle-list`,bufferLayout:i,vertexCount:t.vertexCount,indices:n,attributes:r})}function IL(e,t){if(!t.indices)return;let n=t.indices.value;return e.createBuffer({usage:uk.INDEX,data:n})}function LL(e,t){let n=[],r={};for(let[i,a]of Object.entries(t.attributes)){let t=i;switch(i){case`POSITION`:t=`positions`;break;case`NORMAL`:t=`normals`;break;case`TEXCOORD_0`:t=`texCoords`;break;case`TEXCOORD_1`:t=`texCoords1`;break;case`COLOR_0`:t=`colors`;break}if(a){r[t]=e.createBuffer({data:a.value,id:`${i}-buffer`});let{value:o,size:s,normalized:c}=a;if(s===void 0)throw Error(`Attribute ${i} is missing a size`);n.push({name:t,format:_k.getVertexFormatFromAttribute(o,s,c)})}}return{attributes:r,bufferLayout:n,vertexCount:t._calculateVertexCount(t.attributes,t.indices)}}var RL,zL=o((()=>{nM(),PL(),RL=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||ML(`geometry`),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&uk.INDEX))throw Error(`Index buffer must have INDEX usage`)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}}));function BL(e,t){let n={},r=`Values`;if(e.attributes.length===0&&!e.varyings?.length)return{"No attributes or varyings":{[r]:`N/A`}};for(let t of e.attributes)if(t){let e=`${t.location} ${t.name}: ${t.type}`;n[`in ${e}`]={[r]:t.stepMode||`vertex`}}for(let t of e.varyings||[]){let e=`${t.location} ${t.name}`;n[`out ${e}`]={[r]:JSON.stringify(t)}}return n}var VL=o((()=>{}));function HL(e,t,n){if(e.device.type!==`webgl`)return;let r=sre(e.device);if(!r.flushing){if(lre(e)){UL(e,n,r);return}t&&cre(t)&&t.handle!==null&&(r.queuedFramebuffers.includes(t)||r.queuedFramebuffers.push(t))}}function UL(e,t,n){if(n.queuedFramebuffers.length===0)return;let{gl:r}=e.device,i=r.getParameter(36010),a=r.getParameter(36006),[o,s]=e.device.getDefaultCanvasContext().getDrawingBufferSize(),c=WL(t.top,KL),l=WL(t.left,KL);n.flushing=!0;try{for(let e of n.queuedFramebuffers){let[n,i,a,u,d]=ore({framebuffer:e,targetWidth:o,targetHeight:s,topPx:c,leftPx:l,minimap:t.minimap});r.bindFramebuffer(36008,e.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,e.width,e.height,n,i,a,u,16384,9728),c+=d+KL}}finally{r.bindFramebuffer(36008,i),r.bindFramebuffer(36009,a),n.flushing=!1}}function ore(e){let{framebuffer:t,targetWidth:n,targetHeight:r,topPx:i,leftPx:a,minimap:o}=e,s=o?Math.max(Math.floor(n/4),1):n,c=o?Math.max(Math.floor(r/4),1):r,l=Math.min(s/t.width,c/t.height),u=Math.max(Math.floor(t.width*l),1),d=Math.max(Math.floor(t.height*l),1),f=a,p=Math.max(r-i-d,0);return[f,p,f+u,p+d,d]}function sre(e){return e.userData[GL]||={flushing:!1,queuedFramebuffers:[]},e.userData[GL]}function cre(e){return`colorAttachments`in e}function lre(e){let t=e.props.framebuffer;return!t||t.handle===null}function WL(e,t){if(!e)return t;let n=Number.parseInt(e,10);return Number.isFinite(n)?n:t}var GL,KL,ure=o((()=>{GL=`__debugFramebufferState`,KL=8}));function qL(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!qL(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!t.hasOwnProperty(i)||!qL(e[i],t[i],n-1))return!1;return!0}return!1}var dre=o((()=>{})),JL,fre=o((()=>{nM(),JL=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}mergeBufferLayouts(e,t){let n=[...e];for(let e of t){let t=n.findIndex(t=>t.name===e.name);t<0?n.push(e):n[t]=e}return n}getBufferIndex(e){let t=this.bufferLayouts.findIndex(t=>t.name===e);return t===-1&&Z.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}}));function YL(e,t){let n=1/0;for(let r of e){let e=t[r];e!==void 0&&(n=Math.min(n,e))}return n}function pre(e,t){let n=Object.fromEntries(e.attributes.map(e=>[e.name,e.location])),r=t.slice();return r.sort((e,t)=>{let r=e.attributes?e.attributes.map(e=>e.attribute):[e.name],i=t.attributes?t.attributes.map(e=>e.attribute):[t.name];return YL(r,n)-YL(i,n)}),r}var mre=o((()=>{}));function XL(e,t){if(!e||!t.some(e=>e.bindingLayout?.length))return e;let n={...e,bindings:e.bindings.map(e=>({...e}))};`attributes`in(e||{})&&(n.attributes=e?.attributes||[]);for(let e of t)for(let t of e.bindingLayout||[])for(let e of gre(t.name)){let r=n.bindings.find(t=>t.name===e);r?.group===0&&(r.group=t.group)}return n}function hre(e){return!!(e.uniformTypes&&!_re(e.uniformTypes))}function gre(e){let t=new Set([e,`${e}Uniforms`]);return e.endsWith(`Uniforms`)||t.add(`${e}Sampler`),[...t]}function _re(e){for(let t in e)return!1;return!0}var ZL=o((()=>{}));function vre(e){return fee(e)||typeof e==`number`||typeof e==`boolean`}function yre(e,t={}){let n={bindings:{},uniforms:{}};return Object.keys(e).forEach(r=>{let i=e[r];Object.prototype.hasOwnProperty.call(t,r)||vre(i)?n.uniforms[r]=i:n.bindings[r]=i}),n}var bre=o((()=>{iw()}));function QL(e={},t={},n={}){let r={...e};for(let[i,a]of Object.entries(t))a!==void 0&&(r[i]=$L(e[i],a,n[i]));return r}function $L(e,t,n){if(!n||typeof n==`string`)return eR(t);if(Array.isArray(n)){if(tR(t)||!Array.isArray(t))return eR(t);let r=Array.isArray(e)&&!tR(e)?[...e]:[],i=r.slice();for(let e=0;e<t.length;e++){let a=t[e];a!==void 0&&(i[e]=$L(r[e],a,n[0]))}return i}if(!nR(t))return eR(t);let r=n,i=nR(e)?e:{},a={...i};for(let[e,n]of Object.entries(t))n!==void 0&&(a[e]=$L(i[e],n,r[e]));return a}function eR(e){return ArrayBuffer.isView(e)?Array.prototype.slice.call(e):Array.isArray(e)?tR(e)?e.slice():e.map(e=>e===void 0?void 0:eR(e)):nR(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===void 0?void 0:eR(t)])):e}function tR(e){return ArrayBuffer.isView(e)||Array.isArray(e)&&(e.length===0||typeof e[0]==`number`)}function nR(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function xre(e){return!!e?.dependencies}var rR,iR=o((()=>{nM(),bM(),bre(),rR=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,t){Object.assign(this.options,t);let n=cT(Object.values(e).filter(xre));for(let t of n)e[t.name]=t;Z.log(1,`Creating ShaderInputs with modules`,Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[t,n]of Object.entries(e))n&&(this._addModule(n),n.name&&t!==n.name&&!this.options.disableWarnings&&Z.warn(`Module name: ${t} vs ${n.name}`)())}destroy(){}setProps(e){for(let t of Object.keys(e)){let n=t,r=e[n]||{},i=this.modules[n];if(!i)this.options.disableWarnings||Z.warn(`Module ${t} not found`)();else{let e=this.moduleUniforms[n],t=this.moduleBindings[n],{uniforms:a,bindings:o}=yre(i.getUniforms?.(r,e)||r,i.uniformTypes);this.moduleUniforms[n]=QL(e,a,i.uniformTypes),this.moduleBindings[n]={...t,...o}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){let e={};for(let[t,n]of Object.entries(this.moduleUniforms))for(let[r,i]of Object.entries(n))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(i)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=QL({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}}));function aR(e){return e?Array.isArray(e)?e[0]??null:e:null}function Sre(e){let{dimension:t,data:n}=e;if(!n)return null;switch(t){case`1d`:{let e=aR(n);if(!e)return null;let{width:t}=oR(e);return{width:t,height:1}}case`2d`:{let e=aR(n);return e?oR(e):null}case`3d`:case`2d-array`:{if(!Array.isArray(n)||n.length===0)return null;let e=aR(n[0]);return e?oR(e):null}case`cube`:{let e=Object.keys(n)[0]??null;if(!e)return null;let t=n[e],r=aR(t);return r?oR(r):null}case`cube-array`:{if(!Array.isArray(n)||n.length===0)return null;let e=n[0],t=Object.keys(e)[0]??null;if(!t)return null;let r=aR(e[t]);return r?oR(r):null}default:return null}}function oR(e){if($k(e))return eA(e);if(typeof e==`object`&&`width`in e&&`height`in e)return{width:e.width,height:e.height};throw Error(`Unsupported mip-level data`)}function Cre(e){return typeof e==`object`&&!!e&&`data`in e&&`width`in e&&`height`in e}function wre(e){return ArrayBuffer.isView(e)}function sR(e){let{textureFormat:t,format:n}=e;if(t&&n&&t!==n)throw Error(`Conflicting texture formats "${t}" and "${n}" provided for the same mip level`);return t??n}function cR(e){let t=hR[e];if(t===void 0)throw Error(`Invalid cube face: ${e}`);return t}function Tre(e,t){return 6*e+cR(t)}function lR(e){throw Error(`setTexture1DData not supported in WebGL.`)}function Ere(e){return Array.isArray(e)?e:[e]}function uR(e,t,n,r){let i=Ere(t),a=e,o=[];for(let e=0;e<i.length;e++){let t=i[e];if($k(t))o.push({type:`external-image`,image:t,z:a,mipLevel:e});else if(Cre(t))o.push({type:`texture-data`,data:t,textureFormat:sR(t),z:a,mipLevel:e});else if(wre(t)&&n)o.push({type:`texture-data`,data:{data:t,width:Math.max(1,n.width>>e),height:Math.max(1,n.height>>e),...r?{format:r}:{}},textureFormat:r,z:a,mipLevel:e});else throw Error(`Unsupported 2D mip-level payload`)}return o}function dR(e){let t=[];for(let n=0;n<e.length;n++)t.push(...uR(n,e[n]));return t}function fR(e){let t=[];for(let n=0;n<e.length;n++)t.push(...uR(n,e[n]));return t}function pR(e){let t=[];for(let[n,r]of Object.entries(e)){let e=cR(n);t.push(...uR(e,r))}return t}function mR(e){let t=[];return e.forEach((e,n)=>{for(let[r,i]of Object.entries(e)){let e=Tre(n,r);t.push(...uR(e,i))}}),t}var hR,Dre=o((()=>{nM(),hR={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5}}));function Ore(e){if(!e.data)return[];let t=e.width&&e.height?{width:e.width,height:e.height}:void 0,n=`format`in e?e.format:void 0;switch(e.dimension){case`1d`:return lR(e.data);case`2d`:return uR(0,e.data,t,n);case`3d`:return dR(e.data);case`2d-array`:return fR(e.data);case`cube`:return pR(e.data);case`cube-array`:return mR(e.data);default:throw Error(`Unhandled dimension ${e.dimension}`)}}function kre(e,t,n,r){if(t.length===0)return{subresources:t,mipLevels:1,format:r.format,hasExplicitMipChain:!1};let i=new Map;for(let e of t){let t=i.get(e.z)??[];t.push(e),i.set(e.z,t)}let a=t.some(e=>e.mipLevel>0),o=r.format,s=1/0,c=[];for(let[t,r]of i){let i=[...r].sort((e,t)=>e.mipLevel-t.mipLevel),a=i[0];if(!a||a.mipLevel!==0)throw Error(`DynamicTexture: slice ${t} is missing mip level 0`);let l=_R(e,a);if(l.width!==n.width||l.height!==n.height)throw Error(`DynamicTexture: slice ${t} base level dimensions ${l.width}x${l.height} do not match expected ${n.width}x${n.height}`);let u=gR(a);if(u){if(o&&o!==u)throw Error(`DynamicTexture: slice ${t} base level format "${u}" does not match texture format "${o}"`);o=u}let d=o&&e.isTextureFormatCompressed(o)?Are(e,l.width,l.height,o):e.getMipLevelCount(l.width,l.height),f=0;for(let t=0;t<i.length;t++){let n=i[t];if(!n||n.mipLevel!==t||t>=d)break;let r=_R(e,n),a=Math.max(1,l.width>>t),s=Math.max(1,l.height>>t);if(r.width!==a||r.height!==s)break;let u=gR(n);if(u&&(o||=u,u!==o))break;f++,c.push(n)}s=Math.min(s,f)}let l=Number.isFinite(s)?Math.max(1,s):1;return{subresources:c.filter(e=>e.mipLevel<l),mipLevels:l,format:o,hasExplicitMipChain:a}}function gR(e){if(e.type===`texture-data`)return e.textureFormat??sR(e.data)}function _R(e,t){switch(t.type){case`external-image`:return e.getExternalImageSize(t.image);case`texture-data`:return{width:t.data.width,height:t.data.height};default:throw Error(`Unsupported texture subresource`)}}function Are(e,t,n,r){let{blockWidth:i=1,blockHeight:a=1}=e.getTextureFormatInfo(r),o=1;for(let e=1;;e++){let r=Math.max(1,t>>e),s=Math.max(1,n>>e);if(r<i||s<a)break;o++}return o}async function vR(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(vR));if(e&&typeof e==`object`&&e.constructor===Object){let t=e,n=await Promise.all(Object.values(t).map(vR)),r=Object.keys(t),i={};for(let e=0;e<r.length;e++)i[r[e]]=n[e];return i}return e}var yR,bR=o((()=>{nM(),PL(),Dre(),yR=class e{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw Error(`Texture not initialized yet`);return this._texture}get sampler(){if(!this._sampler)throw Error(`Sampler not initialized yet`);return this._sampler}get view(){if(!this._view)throw Error(`View not initialized yet`);return this._view}get[Symbol.toStringTag](){return`DynamicTexture`}toString(){let e=this._texture?.width??this.props.width??`?`,t=this._texture?.height??this.props.height??`?`;return`DynamicTexture:"${this.id}":${e}x${t}px:(${this.isReady?`ready`:`loading...`})`}constructor(t,n){this.device=t;let r=ML(`dynamic-texture`),i=n;this.props={...e.defaultProps,id:r,...n,data:null},this.id=this.props.id,this.ready=new Promise((e,t)=>{this.resolveReady=e,this.rejectReady=t}),this.initAsync(i)}async initAsync(e){try{let t=await this._loadAllData(e);this._checkNotDestroyed();let n=t.data?Ore({...t,width:e.width,height:e.height,format:e.format}):[],r=`format`in e&&e.format!==void 0,i=`usage`in e&&e.usage!==void 0,a=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:Sre(t)||{width:this.props.width||1,height:this.props.height||1};if(!a||a.width<=0||a.height<=0)throw Error(`${this} size could not be determined or was zero`);let o=kre(this.device,n,a,{format:r?e.format:void 0}),s=o.format??this.props.format,c={...this.props,...a,format:s,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(s)&&!i&&(c.usage=OA.SAMPLE|OA.COPY_DST);let l=this.props.mipmaps&&!o.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(s);if(this.device.type===`webgpu`&&l){let e=this.props.dimension===`3d`?OA.SAMPLE|OA.STORAGE|OA.COPY_DST|OA.COPY_SRC:OA.SAMPLE|OA.RENDER|OA.COPY_DST|OA.COPY_SRC;c.usage|=e}let u=this.device.getMipLevelCount(c.width,c.height),d=o.hasExplicitMipChain?o.mipLevels:this.props.mipLevels===`auto`?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),f={...c,mipLevels:d};this._texture=this.device.createTexture(f),this._sampler=this.texture.sampler,this._view=this.texture.view,o.subresources.length&&this._setTextureSubresources(o.subresources),this.props.mipmaps&&!o.hasExplicitMipChain&&!l&&Z.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),l&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),Z.info(0,`${this} created`)()}catch(e){let t=e instanceof Error?e:Error(String(e));this.rejectReady(t)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type===`webgl`?this.texture.generateMipmapsWebGL():this.device.type===`webgpu`?this.device.generateMipmapsWebGPU(this.texture):Z.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let t=e instanceof TA?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t}async readBuffer(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=this.device.createBuffer({byteLength:i.byteLength,usage:uk.COPY_DST|uk.MAP_READ});this.texture.readBuffer({...e,width:t,height:n,depthOrArrayLayers:r},a);let o=this.device.createFence();return await o.signaled,o.destroy(),a}async readAsync(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=await this.readBuffer(e),o=await a.readAsync(0,i.byteLength);return a.destroy(),o.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let t=this.texture;return this._texture=t.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,t.destroy(),Z.info(`${this} resized`),!0}getCubeFaceIndex(e){let t=hR[e];if(t===void 0)throw Error(`Invalid cube face: ${e}`);return t}getCubeArrayFaceIndex(e,t){return 6*e+this.getCubeFaceIndex(t)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!==`1d`)throw Error(`${this} is not 1d`);let t=lR(e);this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),this.texture.props.dimension!==`2d`)throw Error(`${this} is not 2d`);let n=uR(t,e);this._setTextureSubresources(n)}setTexture3DData(e){if(this.texture.props.dimension!==`3d`)throw Error(`${this} is not 3d`);let t=dR(e);this._setTextureSubresources(t)}setTextureArrayData(e){if(this.texture.props.dimension!==`2d-array`)throw Error(`${this} is not 2d-array`);let t=fR(e);this._setTextureSubresources(t)}setTextureCubeData(e){if(this.texture.props.dimension!==`cube`)throw Error(`${this} is not cube`);let t=pR(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if(this.texture.props.dimension!==`cube-array`)throw Error(`${this} is not cube-array`);let t=mR(e);this._setTextureSubresources(t)}_setTextureSubresources(e){for(let t of e){let{z:e,mipLevel:n}=t;switch(t.type){case`external-image`:let{image:r,flipY:i}=t;this.texture.copyExternalImage({image:r,z:e,mipLevel:n,flipY:i});break;case`texture-data`:let{data:a,textureFormat:o}=t;if(o&&o!==this.texture.format)throw Error(`${this} mip level ${n} uses format "${o}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:e,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw Error(`Unsupported 2D mip-level payload`)}}}async _loadAllData(e){let t=await vR(e.data);return{dimension:e.dimension??`2d`,data:t??null}}_checkNotDestroyed(){this.destroyed&&Z.warn(`${this} already destroyed`)}_checkReady(){this.isReady||Z.warn(`${this} Cannot perform this operation before ready`)}static defaultProps={...OA.defaultProps,dimension:`2d`,data:null,mipmaps:!1}}}));function jre(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}var xR,SR,CR,wR,TR=o((()=>{nM(),bM(),zL(),VL(),ure(),dre(),fre(),mre(),ZL(),PL(),iR(),bR(),xR=2,SR=1e4,CR=`render pipeline initialization failed`,wR=class e{static defaultProps={...IA.defaultProps,source:void 0,vs:null,fs:null,id:`unnamed`,handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:AE.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate=`newly created`;_needsRedraw=`initializing`;_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return`Model`}toString(){return`Model(${this.id})`}constructor(t,n){this.props={...e.defaultProps,...n},n=this.props,this.id=n.id||ML(`model`),this.device=t,Object.assign(this.userData,n.userData),this.material=n.material||null;let r=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]),i=n.shaderInputs||new rR(r,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);let a=jre(t),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=XL(this.props.shaderLayout,o)||null,this.device.type===`webgpu`&&this.props.source){let{source:e,getUniforms:n,bindingTable:r}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:a,...this.props,modules:o});this.source=e,this._getModuleUniforms=n,this._bindingTable=r;let i=t.getShaderLayout?.(this.source);this.props.shaderLayout=XL(this.props.shaderLayout||i||null,o)||null}else{let{vs:e,fs:t,getUniforms:n}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:a,...this.props,modules:o});this.vs=e,this.fs=t,this._getModuleUniforms=n,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,n.geometry&&this.setGeometry(n.geometry),this.pipelineFactory=n.pipelineFactory||VA.getDefaultPipelineFactory(this.device),this.shaderFactory=n.shaderFactory||HA.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),`isInstanced`in n&&(this.isInstanced=n.isInstanced),n.instanceCount&&this.setInstanceCount(n.instanceCount),n.vertexCount&&this.setVertexCount(n.vertexCount),n.indexBuffer&&this.setIndexBuffer(n.indexBuffer),n.attributes&&this.setAttributes(n.attributes),n.constantAttributes&&this.setConstantAttributes(n.constantAttributes),n.bindings&&this.setBindings(n.bindings),n.transformFeedback&&(this.transformFeedback=n.transformFeedback)}destroy(){this._destroyed||=(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw(`contents of bound textures or buffers updated`);let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t=this._areBindingsLoading();if(t)return Z.info(xR,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)Z.info(xR,`>>> DRAWING ABORTED ${this.id}: ${CR}`)(),n=!1;else{let t=this._getBindings(),r=this._getBindGroups(),{indexBuffer:i}=this.vertexArray,a=i?i.byteLength/(i.indexType===`uint32`?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:a,transformFeedback:this.transformFeedback||void 0,bindings:t,bindGroups:r,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?this._needsRedraw=CR:this._needsRedraw=`waiting for resource initialization`,n}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&FL(this.device,e);if(t){this.setTopology(t.topology||`triangle-list`);let e=new JL(this.bufferLayout);this.bufferLayout=e.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate(`topology`))}setBufferLayout(e){let t=new JL(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate(`bufferLayout`),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){qL(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate(`parameters`))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw(`instanceCount`)}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw(`vertexCount`)}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new tM(this.device,this.shaderInputs.modules);for(let[e,t]of Object.entries(this.shaderInputs.modules))if(hre(t)&&!this.material?.ownsModule(e)){let t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw(`shaderInputs`)}setMaterial(e){this.material=e,this.setNeedsRedraw(`material`)}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw(`shaderInputs`)}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw(`bindings`)}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw(`transformFeedback`)}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw(`indexBuffer`)}setAttributes(e,t){let n=t?.disableWarnings??this.props.disableWarnings;e.indices&&Z.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=pre(this.pipeline.shaderLayout,this.bufferLayout);let r=new JL(this.bufferLayout);for(let[t,i]of Object.entries(e)){let e=r.getBufferLayout(t);if(!e){n||Z.warn(`Model(${this.id}): Missing layout for buffer "${t}".`)();continue}let a=r.getAttributeNamesForBuffer(e),o=!1;for(let e of a){let t=this._attributeInfos[e];if(t){let e=this.device.type===`webgpu`?r.getBufferIndex(t.bufferName):t.location;this.vertexArray.setBuffer(e,i),o=!0}}!o&&!n&&Z.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${t}"`)()}this.setNeedsRedraw(`attributes`)}setConstantAttributes(e,t){for(let[n,r]of Object.entries(e)){let e=this._attributeInfos[n];e?this.vertexArray.setConstantWebGL(e.location,r):(t?.disableWarnings??this.props.disableWarnings)||Z.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw(`constants`)}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof yR&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof yR&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[t,n]of Object.entries(this.bindings))n instanceof yR?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},t=e.bindings.length?UA(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return t;for(let[e,n]of Object.entries(this.material.getBindingsByGroup())){let r=Number(e);t[r]={...t[r]||{},...n}}return t}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let t of Object.values(this.bindings))t instanceof AA?e=Math.max(e,t.texture.updateTimestamp):t instanceof uk||t instanceof OA?e=Math.max(e,t.updateTimestamp):t instanceof yR?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof TA||(e=Math.max(e,t.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[e]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(t=>t.name===e)&&e!==`positions`&&delete t[e];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw(`geometry attributes`)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(Z.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:`vertex`,source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=n:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:`fragment`,source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:n,fs:r}),this._attributeInfos=lj(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=Z.level>3?0:SR;Z.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,Z.group(xR,`>>> DRAWING MODEL ${this.id}`,{collapsed:Z.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=BL(this.pipeline.shaderLayout,this.id);Z.table(xR,e)();let t=this.shaderInputs.getDebugTable();Z.table(xR,t)();let n=this._getAttributeDebugTable();Z.table(xR,this._attributeInfos)(),Z.table(xR,n)(),Z.groupEnd(xR)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let n=e.props.framebuffer;HL(e,n,{id:n?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,n]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:r?this._getBufferOrConstantValues(r,n.bufferDataType):`null`}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,n=t.indexType===`uint32`?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:`indices`,type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){let n=pk.getTypedArrayConstructor(t);return(e instanceof uk?new n(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[n,r]of Object.entries(e))this.material.ownsBinding(n)||(t[n]=r);return t}}})),ER,Mre=o((()=>{nM(),bM(),TR(),ER=class e{device;model;transformFeedback;static defaultProps={...wR.defaultProps,outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type===`webgl`}constructor(t,n=e.defaultProps){if(!e.isSupported(t))throw Error(`BufferTransform not yet implemented on WebGPU`);this.device=t,this.model=new wR(this.device,{id:n.id||`buffer-transform-model`,fs:n.fs||ME(),topology:n.topology||`point-list`,varyings:n.outputs||n.varyings,...n}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:n.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw Error(`BufferTransform#getBuffer`);if(t instanceof uk)return t.readAsync();let{buffer:n,byteOffset:r=0,byteLength:i=n.byteLength}=t;return n.readAsync(r,i)}}})),DR,Nre=o((()=>{PL(),DR=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:t={},indices:n=null,vertexCount:r=null}=e;this.id=e.id||ML(`geometry`),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[e,n]of Object.entries(t)){let t=ArrayBuffer.isView(n)?{value:n}:n;if(!ArrayBuffer.isView(t.value))throw Error(`${this._print(e)}: must be typed array or object with value as typed array`);if((e===`POSITION`||e===`positions`)&&!t.size&&(t.size=3),e===`indices`){if(this.indices)throw Error(`Multiple indices detected`);this.indices=t}else this.attributes[e]=t}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(let t of Object.values(e)){let{value:e,size:r,constant:i}=t;!i&&e&&r!==void 0&&r>=1&&(n=Math.min(n,e.length/r))}return n}}})),OR=o((()=>{wL(),jL(),nM(),TR(),bR(),iR(),ZL(),PL(),Mre(),bM(),Nre(),lO(),zL(),iw(),DL()}));function kR(e,t,n){let{byLayer:r,byAlpha:i}=e,a,o=r.get(t);return o?(o.viewports.push(n),a=o.a):(a=r.size+1,a<=255?(o={a,layer:t,viewports:[n]},r.set(t,o),i[a]=o):(Mw.warn(`Too many pickable layers, only picking the first 255`)(),a=0)),[0,0,0,a/255]}function Pre(e,t){let n=e.byAlpha[t[3]];return n&&{pickedLayer:n.layer,pickedViewports:n.viewports,pickedObjectIndex:n.layer.decodePickingColor(t)}}var AR,jR,MR=o((()=>{RI(),Nw(),AR={blendColorOperation:`add`,blendColorSrcFactor:`one`,blendColorDstFactor:`zero`,blendAlphaOperation:`add`,blendAlphaSrcFactor:`constant`,blendAlphaDstFactor:`zero`},jR=class extends LI{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return`pickingFBO`in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:t,views:n,viewports:r,onViewportActive:i,pickingFBO:a,deviceRect:{x:o,y:s,width:c,height:l},cullRect:u,effects:d,pass:f=`picking`,pickZ:p,shaderModuleProps:m,clearColor:h}){this.pickZ=p;let g=this._resetColorEncoder(p),_=[o,s,c,l],v=super._render({target:a,layers:e,layerFilter:t,views:n,viewports:r,onViewportActive:i,cullRect:u,effects:d?.filter(e=>e.useInPicking),pass:f,isPicking:!0,shaderModuleProps:m,clearColor:h??[0,0,0,0],colorMask:15,scissorRect:_});return this._colorEncoderState=null,{decodePickingColor:g&&Pre.bind(null,g),stats:v}}shouldDrawLayer(e){let{pickable:t,operation:n}=e.props;return t&&n.includes(`draw`)||n.includes(`terrain`)||n.includes(`mask`)}getShaderModuleProps(e,t,n){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,t,n){let r={...e.props.parameters},{pickable:i,operation:a}=e.props;return this._colorEncoderState?i&&a.includes(`draw`)?(Object.assign(r,AR),r.blend=!0,this.device.type===`webgpu`?r.blendConstant=kR(this._colorEncoderState,e,n):r.blendColor=kR(this._colorEncoderState,e,n),a.includes(`terrain`)&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor=`one`)):a.includes(`terrain`)&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}})),NR,PR,FR,IR,LR,RR,zR,BR=o((()=>{NR={NO_STATE:`Awaiting state`,MATCHED:`Matched. State transferred from previous layer`,INITIALIZED:`Initialized`,AWAITING_GC:`Discarded. Awaiting garbage collection`,AWAITING_FINALIZATION:`No longer matched. Awaiting garbage collection`,FINALIZED:`Finalized! Awaiting garbage collection`},PR=Symbol.for(`component`),FR=Symbol.for(`propTypes`),IR=Symbol.for(`deprecatedProps`),LR=Symbol.for(`asyncPropDefaults`),RR=Symbol.for(`asyncPropOriginal`),zR=Symbol.for(`asyncPropResolved`)}));function VR(e,t=()=>!0){return Array.isArray(e)?HR(e,t,[]):t(e)?[e]:[]}function HR(e,t,n){let r=-1;for(;++r<e.length;){let i=e[r];Array.isArray(i)?HR(i,t,n):t(i)&&n.push(i)}return n}function Fre({target:e,source:t,start:n=0,count:r=1}){let i=t.length,a=r*i,o=0;for(let r=n;o<i;o++)e[r++]=t[o];for(;o<a;)o<a-o?(e.copyWithin(n+o,n,n+o),o*=2):(e.copyWithin(n+o,n,n+a-o),o=a);return e}var UR=o((()=>{})),WR,Ire=o((()=>{ow(),WR=class{constructor(e,t,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let n=++this._loadCount,r=e;typeof e==`string`&&(r=aw(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let e of this._subscribers)e.onChange(this.getData())}}})),GR,Lre=o((()=>{Ire(),GR=class{constructor(e){this.protocol=e.protocol||`resource://`,this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:n=!1,persistent:r=!0}){let i=this._resources[e];i?i.setData(t,n):(i=new WR(e,t,this._context),this._resources[e]=i),i.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let e in t){let n=t[e],r=this._resources[n.resourceId];r&&r.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:r=`default`}){let{_resources:i,protocol:a}=this;e.startsWith(a)&&(e=e.replace(a,``),i[e]||this.add({resourceId:e,data:null,persistent:!1}));let o=i[e];if(this._track(n,r,o,t),o)return o.getData()}prune(){this._pruneRequest||=setTimeout(()=>this._prune(),0)}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,n,r){let i=this._consumers,a=i[e]=i[e]||{},o=a[t],s=o&&o.resourceId&&this._resources[o.resourceId];s&&(s.unsubscribe(o),this.prune()),n&&(o?(o.onChange=r,o.resourceId=n.id):o={onChange:r,resourceId:n.id},a[t]=o,n.subscribe(o))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}}})),KR,qR,JR,YR=o((()=>{OR(),yI(),BR(),Nw(),Iw(),UR(),Yx(),Lre(),fL(),KR=`layerManager.setLayers`,qR=`layerManager.activateViewport`,JR=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{Pw(qR,this,e),e&&(this.context.viewport=e)};let{deck:n,stats:r,viewport:i,timeline:a}=t||{};this.layers=[],this.resourceManager=new GR({device:e,protocol:`deck://`}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:n,shaderAssembler:hI(e?.info?.shadingLanguage||`glsl`),defaultShaderModules:[CM],renderPass:void 0,stats:r||new qx({id:`deck.gl`}),viewport:i||new dL({id:`DEFAULT-INITIAL-VIEWPORT`}),timeline:a||new CL,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let n of this.layers){let r=n.getNeedsRedraw(e);t||=r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?`layers changed`:this._defaultShaderModulesChanged?`shader modules changed`:this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>t.id.indexOf(e)===0)):this.layers}setProps(e){`debug`in e&&(this._debug=e.debug),`userData`in e&&(this.context.userData=e.userData),`layers`in e&&(this._nextLayers=e.layers),`onError`in e&&(this.context.onError=e.onError)}setLayers(e,t){Pw(KR,this,t,e),this._lastRenderedLayers=e;let n=VR(e,Boolean);for(let e of n)e.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,n=t.findIndex(t=>t.name===e.name);n>=0&&(t.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,n){n.raiseError(t,`${e} of ${n}`)}_updateLayers(e,t){let n={};for(let t of e)n[t.id]?Mw.warn(`Multiple old layers with same id ${t.id}`)():n[t.id]=t;if(this._defaultShaderModulesChanged){for(let t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,n,r),this._finalizeOldLayers(n);let i=!1;for(let e of r)if(e.hasUniformTransition()){i=`Uniform transition in ${e}`;break}this._needsUpdate=i,this.layers=r}_updateSublayersRecursively(e,t,n){for(let r of e){r.context=this.context;let e=t[r.id];e===null&&Mw.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let i=null;try{this._debug&&e!==r&&r.validateProps(),e?(this._transferLayerState(e,r),this._updateLayer(r)):this._initializeLayer(r),n.push(r),i=r.isComposite?r.getSubLayers():null}catch(e){this._handleError(`matching`,e,r)}i&&this._updateSublayersRecursively(i,t,n)}}_finalizeOldLayers(e){for(let t in e){let n=e[t];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=NR.INITIALIZED}catch(t){this._handleError(`initialization`,t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=NR.MATCHED,t!==e&&(e.lifecycle=NR.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError(`update`,t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=NR.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=NR.FINALIZED}catch(t){this._handleError(`finalization`,t,e)}}}}));function XR(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!XR(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!t.hasOwnProperty(i)||!XR(e[i],t[i],n-1))return!1;return!0}return!1}var ZR=o((()=>{})),QR,Rre=o((()=>{ZR(),Nw(),UR(),QR=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw=`First render`,this._needsUpdate=`Initialize`,this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>t.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e==`string`?this.getView(e):e,n=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}unproject(e,t){let n=this.getViewports(),r={x:e[0],y:e[1]};for(let i=n.length-1;i>=0;--i){let a=n[i];if(a.containsPixel(r)){let n=e.slice();return n[0]-=a.x,n[1]-=a.y,a.unproject(n,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),(`width`in e||`height`in e)&&this._setSize(e.width,e.height),`pickPosition`in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate(`Size changed`))}_setViews(e){e=VR(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate(`views changed`),this.views=e}_setViewState(e){e?(XR(e,this.viewState,3)||this.setNeedsUpdate(`viewState changed`),this.viewState=e):Mw.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){let n=t.type;return new n({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,t,n,r){let i=e.controller;if(i&&n){let a={...t,...i,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return(!r||r.constructor!==i.type)&&(r=this._createController(e,a)),r&&r.setProps(a),r}return null}_rebuildViewports(){let{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let r=e.length;r--;){let i=e[r],a=this.getViewState(i),o=i.makeViewport({viewState:a,width:this.width,height:this.height}),s=t[i.id],c=!!i.controller;c&&!s&&(n=!0),(n||!c)&&s&&(s.finalize(),s=null),this.controllers[i.id]=this._updateController(i,a,o,s),o&&this._viewports.unshift(o)}for(let e in t){let n=t[e];n&&!this.controllers[e]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length===t.length?e.some((n,r)=>!e[r].equals(t[r])):!0}}}));function $R(e){switch(typeof e){case`number`:if(!Number.isFinite(e))throw Error(`Could not parse position string ${e}`);return{type:`literal`,value:e};case`string`:try{return new az(zre(e)).parseExpression()}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not parse position string ${e}: ${n}`)}default:throw Error(`Could not parse position string ${e}`)}}function ez(e,t){switch(e.type){case`literal`:return e.value;case`percentage`:return Math.round(e.value*t);case`binary`:let n=ez(e.left,t),r=ez(e.right,t);return e.operator===`+`?n+r:n-r;default:throw Error(`Unknown layout expression type`)}}function tz(e,t){return ez(e,t)}function zre(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`+`||r===`-`||r===`(`||r===`)`||r===`%`){t.push({type:`symbol`,value:r}),n++;continue}if(nz(r)||r===`.`){let i=n,a=r===`.`;for(n++;n<e.length;){let t=e[n];if(nz(t)){n++;continue}if(t===`.`&&!a){a=!0,n++;continue}break}let o=e.slice(i,n);if(!iz.test(o))throw Error(`Invalid number token`);t.push({type:`number`,value:parseFloat(o)});continue}if(rz(r)){let r=n;for(;n<e.length&&rz(e[n]);)n++;let i=e.slice(r,n).toLowerCase();t.push({type:`word`,value:i});continue}throw Error(`Invalid token in position string`)}return t}function nz(e){return e>=`0`&&e<=`9`}function rz(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`}function Bre(e){return!!(e&&e.type===`symbol`&&(e.value===`+`||e.value===`-`))}var iz,az,Vre=o((()=>{iz=/^(?:\d+\.?\d*|\.\d+)$/,az=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw Error(`Unexpected token at end of expression`);return e}parseBinaryExpression(){let e=this.parseFactor(),t=this.peek();for(;Bre(t);){this.index++;let n=this.parseFactor();e={type:`binary`,operator:t.value,left:e,right:n},t=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw Error(`Unexpected end of expression`);if(e.type===`symbol`&&e.value===`+`)return this.index++,this.parseFactor();if(e.type===`symbol`&&e.value===`-`)return this.index++,{type:`binary`,operator:`-`,left:{type:`literal`,value:0},right:this.parseFactor()};if(e.type===`symbol`&&e.value===`(`){this.index++;let e=this.parseBinaryExpression();if(!this.consumeSymbol(`)`))throw Error(`Missing closing parenthesis`);return e}if(e.type===`word`&&e.value===`calc`){if(this.index++,!this.consumeSymbol(`(`))throw Error(`Missing opening parenthesis after calc`);let e=this.parseBinaryExpression();if(!this.consumeSymbol(`)`))throw Error(`Missing closing parenthesis`);return e}if(e.type===`number`){this.index++;let t=e.value,n=this.peek();return n&&n.type===`symbol`&&n.value===`%`?(this.index++,{type:`percentage`,value:t/100}):(n&&n.type===`word`&&n.value===`px`&&this.index++,{type:`literal`,value:t})}throw Error(`Unexpected token in expression`)}consumeSymbol(e){let t=this.peek();return t&&t.type===`symbol`&&t.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}}}));function Hre(e,t){let n={...e};for(let e in t)e!==`id`&&(Array.isArray(n[e])&&Array.isArray(t[e])?n[e]=Ure(n[e],t[e]):n[e]=t[e]);return n}function Ure(e,t){e=e.slice();for(let n=0;n<t.length;n++){let r=t[n];Number.isFinite(r)&&(e[n]=r)}return e}var oz=o((()=>{})),sz,cz=o((()=>{Vre(),ZR(),oz(),sz=class{constructor(e){let{id:t,x:n=0,y:r=0,width:i=`100%`,height:a=`100%`,padding:o=null}=e;this.id=t||this.constructor.displayName||`view`,this.props={...e,id:this.id},this._x=$R(n),this._y=$R(r),this._width=$R(i),this._height=$R(a),this._padding=o&&{left:$R(o.left||0),right:$R(o.right||0),top:$R(o.top||0),bottom:$R(o.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&XR(this.props,e.props,2)}clone(e){let t=this.constructor;return new t({...this.props,...e})}makeViewport({width:e,height:t,viewState:n}){n=this.filterViewState(n);let r=this.getDimensions({width:e,height:t});return!r.height||!r.width?null:new(this.getViewportType(n))({...n,...this.props,...r})}getViewStateId(){let{viewState:e}=this.props;return typeof e==`string`?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState==`object`?this.props.viewState.id?Hre(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:t}){let n={x:tz(this._x,e),y:tz(this._y,t),width:tz(this._width,e),height:tz(this._height,t)};return this._padding&&(n.padding={left:tz(this._padding.left,e),top:tz(this._padding.top,t),right:tz(this._padding.right,e),bottom:tz(this._padding.bottom,t)}),n}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e==`function`?{type:e}:{type:this.ControllerType,...e}:null}}})),lz,uz=o((()=>{lz=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&=(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}})),dz,fz,pz,mz,hz,gz=o((()=>{uz(),dz=()=>{},fz={BREAK:1,SNAP_TO_END:2,IGNORE:3},pz=e=>e,mz=fz.BREAK,hz=class{constructor(e){this._onTransitionUpdate=e=>{let{time:t,settings:{interpolator:n,startProps:r,endProps:i,duration:a,easing:o}}=e,s=o(t/a),c=n.interpolateProps(r,i,s);this.propsInTransition=this.getControllerState({...this.props,...c}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new lz(e.timeline),this.onViewStateChange=e.onViewStateChange||dz,this.onStateChange=e.onStateChange||dz}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let r=n;if(this.transition.inProgress){let{interruption:e,endProps:t}=this.transition.settings;r={...n,...e===fz.SNAP_TO_END?t:this.propsInTransition||n}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:n}=e;return(t>0||t===`auto`)&&!!n}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===fz.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let n=this.getControllerState(e),r=this.getControllerState(t).shortestPathFrom(n),i=t.transitionInterpolator,a=i.getDuration?i.getDuration(e,t):t.transitionDuration;if(a===0)return;let o=i.initializeProps(e,r);this.propsInTransition={};let s={duration:a,easing:t.transitionEasing||pz,interpolator:i,interruption:t.transitionInterruption||mz,startProps:o.start,endProps:o.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(s),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}}}));function _z(e,t){if(!e)throw Error(t||`deck.gl: assertion failed.`)}var vz=o((()=>{})),yz,bz=o((()=>{lO(),vz(),yz=class{constructor(e){let{compare:t,extract:n,required:r}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=r}arePropsEqual(e,t){for(let n of this._propsToCompare)if(!(n in e)||!(n in t)||!VE(e[n],t[n]))return!1;return!0}initializeProps(e,t){let n={},r={};for(let i of this._propsToExtract)(i in e||i in t)&&(n[i]=e[i],r[i]=t[i]);return this._checkRequiredProps(n),this._checkRequiredProps(r),{start:n,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let n=e[t];_z(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}}}));function xz(){let e=256/Ez,t=Math.PI/180*256;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[1/e,1/e,1/e],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,1/e]}}function Sz(e){let t=Math.PI*Math.cos(e*Math.PI/180);return Math.log2(t)}function Cz(e,t){let n=qD([],t,e);return KD(n,n,1/n[3]),n}var wz,Tz,Ez,Dz,Oz=o((()=>{lO(),fL(),zP(),QF(),wz=Math.PI/180,Tz=180/Math.PI,Ez=6370972,Dz=class extends dL{constructor(e={}){let{longitude:t=0,zoom:n=0,nearZMultiplier:r=.5,farZMultiplier:i=1,resolution:a=10}=e,{latitude:o=0,height:s,altitude:c=1.5,fovy:l}=e;o=Math.max(Math.min(o,zF),-zF),s||=1,l?c=AF(l):l=kF(c);let u=2**(n-Sz(o)),d=e.nearZ??r,f=e.farZ??(c+256*2*u/s)*i,p=new aO().lookAt({eye:[0,-c,0],up:[0,0,1]});p.rotateX(o*wz),p.rotateZ(-t*wz),p.scale(u/s),super({...e,height:s,viewMatrix:p,longitude:t,latitude:o,zoom:n,distanceScales:xz(),fovy:l,focalDistance:c,near:d,far:f}),this.scale=u,this.latitude=o,this.longitude=t,this.fovy=l,this.resolution=a}get projectionMode(){return FP.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),r=this.unproject([this.width/2,0],t),i=this.unproject([this.width,this.height/2],t),a=this.unproject([this.width/2,this.height],t);return i[0]<this.longitude&&(i[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],i[0],r[0],a[0]),Math.min(n[1],i[1],r[1],a[1]),Math.max(n[0],i[0],r[0],a[0]),Math.max(n[1],i[1],r[1],a[1])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[r,i,a]=e,o=t?i:this.height-i,{pixelUnprojectionMatrix:s}=this,c;if(Number.isFinite(a))c=Cz(s,[r,o,a,1]);else{let e=Cz(s,[r,o,-1,1]),t=Cz(s,[r,o,1,1]),i=((n||0)/Ez+1)*256,a=xD(yD([],e,t)),l=xD(e),u=xD(t),d=4*((4*l*u-(a-l-u)**2)/16)/a;c=Cte([],e,t,(Math.sqrt(l-d)-Math.sqrt(Math.max(0,i*i-d)))/Math.sqrt(a))}let[l,u,d]=this.unprojectPosition(c);return Number.isFinite(a)?[l,u,d]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){let[t,n,r=0]=e,i=t*wz,a=n*wz,o=Math.cos(a),s=(r/Ez+1)*256;return[Math.sin(i)*o*s,-Math.cos(i)*o*s,Math.sin(a)*s]}unprojectPosition(e){let[t,n,r]=e,i=bD(e),a=Math.asin(r/i);return[Math.atan2(t,-n)*Tz,a*Tz,(i/256-1)*Ez]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,t,n],r,i){let a=.25/2**(this.zoom-Sz(this.latitude)),o=e+a*(i[0]-r[0]),s=t-a*(i[1]-r[1]);s=Math.max(Math.min(s,zF),-zF);let c={longitude:o,latitude:s,zoom:n-Sz(t)};return c.zoom+=Sz(c.latitude),c}},Dz.displayName=`GlobeViewport`})),kz,Az,jz,Mz=o((()=>{bz(),lO(),Nw(),Oz(),kz=[`longitude`,`latitude`,`zoom`,`bearing`,`pitch`],Az=[`longitude`,`latitude`,`zoom`],jz=class extends yz{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:kz,required:Az},super(n.transitionProps),this.opts=n}initializeProps(e,t){let n=super.initializeProps(e,t),{makeViewport:r,around:i}=this.opts;if(r&&i)if(r(e)instanceof Dz)Mw.warn(`around not supported in GlobeView`)();else{let a=r(e),o=r(t),s=a.unproject(i);n.start.around=i,Object.assign(n.end,{around:o.project(s),aroundPosition:s,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){let r={};for(let i of this._propsToExtract)r[i]=BE(e[i]||0,t[i]||0,n);if(t.aroundPosition&&this.opts.makeViewport){let i=this.opts.makeViewport({...t,...r});Object.assign(r,i.panByPosition(t.aroundPosition,BE(e.around,t.around,n)))}return r}}})),Nz,Pz,Fz,Iz,Lz,Rz,zz=o((()=>{gz(),Mz(),ZR(),Nz={transitionDuration:0},Pz=300,Fz=e=>1-(1-e)*(1-e),Iz={WHEEL:[`wheel`],PAN:[`panstart`,`panmove`,`panend`],PINCH:[`pinchstart`,`pinchmove`,`pinchend`],MULTI_PAN:[`multipanstart`,`multipanmove`,`multipanend`],DOUBLE_CLICK:[`dblclick`],KEYBOARD:[`keydown`]},Lz={},Rz=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode=`rotate`,this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new hz({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case`panstart`:return t?!1:this._onPanStart(e);case`panmove`:return this._onPan(e);case`panend`:return this._onPanEnd(e);case`pinchstart`:return t?!1:this._onPinchStart(e);case`pinchmove`:return this._onPinch(e);case`pinchend`:return this._onPinchEnd(e);case`multipanstart`:return t?!1:this._onMultiPanStart(e);case`multipanmove`:return this._onMultiPan(e);case`multipanend`:return this._onMultiPanEnd(e);case`dblclick`:return this._onDoubleClick(e);case`wheel`:return this._onWheel(e);case`keydown`:return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:n}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-n]}isPointInBounds(e,t){let{width:n,height:r}=this.props;if(t&&t.handled)return!1;let i=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=r;return i&&t&&t.stopPropagation(),i}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,`transitionInterpolator`in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:n}=e;this.inertia=Number.isFinite(n)?n:n===!0?Pz:0;let{scrollZoom:r=!0,dragPan:i=!0,dragRotate:a=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=!!this.onViewStateChange;if(this.toggleEvents(Iz.WHEEL,u&&r),this.toggleEvents(Iz.PAN,u),this.toggleEvents(Iz.PINCH,u&&(s||c)),this.toggleEvents(Iz.MULTI_PAN,u&&c),this.toggleEvents(Iz.DOUBLE_CLICK,u&&o),this.toggleEvents(Iz.KEYBOARD,u&&l),this.scrollZoom=r,this.dragPan=i,this.dragRotate=a,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=c,this.keyboard=l,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds)&&e.maxBounds){let t=new this.ControllerState({...e,makeViewport:this.makeViewport}),n=t.getViewportProps();Object.keys(n).some(t=>!XR(n[t],e[t],1))&&this.updateViewport(t)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,n={}){let r={...e.getViewportProps(),...t},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),i){let e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode===`pan`)&&(n=!n);let r=this.controllerState[n?`panStart`:`rotateStart`]({pos:t});return this._panMove=n,this.updateViewport(r,Nz,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),n=this.controllerState.pan({pos:t});return this.updateViewport(n,Nz,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Fz},{isDragging:!1,isPanning:!0})}else{let e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),n=this.controllerState.rotate({pos:t});return this.updateViewport(n,Nz,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Fz},{isDragging:!1,isRotating:!0})}else{let e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:n=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:i}=e,a=2/(1+Math.exp(-Math.abs(i*n)));i<0&&a!==0&&(a=1/a);let o=r?{...this._getTransitionProps({around:t}),transitionDuration:250}:Nz,s=this.controllerState.zoom({pos:t,scale:a});return this.updateViewport(s,o,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.rotateStart({pos:t});return this.updateViewport(n,Nz,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let t=this.getCenter(e);t[0]-=e.deltaX;let n=this.controllerState.rotate({pos:t});return this.updateViewport(n,Nz,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){let n=this.getCenter(e),r=[n[0],n[1]+=e.velocityY*t/2],i=this.controllerState.rotate({pos:r});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Fz},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{let e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return Lz._startPinchRotation=e.rotation,Lz._lastPinchEvent=e,this.updateViewport(n,Nz,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:n}=e,r=this.getCenter(e);t=t.zoom({pos:r,scale:n})}if(this.touchRotate){let{rotation:n}=e;t=t.rotate({deltaAngleX:Lz._startPinchRotation-n})}return this.updateViewport(t,Nz,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Lz._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:n}=Lz;if(this.touchZoom&&t&&n&&e.scale!==n.scale){let r=this.getCenter(e),i=this.controllerState.rotateEnd(),a=Math.log2(e.scale),o=2**(a+(a-Math.log2(n.scale))/(e.deltaTime-n.deltaTime)*t/2);i=i.zoom({pos:r,scale:o}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:r}),transitionDuration:t,transitionEasing:Fz},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Lz._startPinchRotation=null,Lz._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e),r=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(r,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let t=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:r,rotateSpeedX:i,rotateSpeedY:a}=this.keyboard===!0?{}:this.keyboard,{controllerState:o}=this,s,c={};switch(e.srcEvent.code){case`Minus`:s=t?o.zoomOut(n).zoomOut(n):o.zoomOut(n),c.isZooming=!0;break;case`Equal`:s=t?o.zoomIn(n).zoomIn(n):o.zoomIn(n),c.isZooming=!0;break;case`ArrowLeft`:t?(s=o.rotateLeft(i),c.isRotating=!0):(s=o.moveLeft(r),c.isPanning=!0);break;case`ArrowRight`:t?(s=o.rotateRight(i),c.isRotating=!0):(s=o.moveRight(r),c.isPanning=!0);break;case`ArrowUp`:t?(s=o.rotateUp(a),c.isRotating=!0):(s=o.moveUp(r),c.isPanning=!0);break;case`ArrowDown`:t?(s=o.rotateDown(a),c.isRotating=!0):(s=o.moveDown(r),c.isPanning=!0);break;default:return!1}return this.updateViewport(s,this._getTransitionProps(),c),!0}_getTransitionProps(e){let{transition:t}=this;return!t||!t.transitionInterpolator?Nz:e?{...t,transitionInterpolator:new jz({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t}}})),Bz,Vz=o((()=>{Bz=class{constructor(e,t,n){this.makeViewport=n,this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}}));function Hz([e,t]){if(Math.abs(t)>90&&(t=Math.sign(t)*90),Number.isFinite(e)){let[n,r]=xF([e,t]);return[n,zE(r,0,Gz)]}let[,n]=xF([0,t]);return[e,zE(n,0,Gz)]}var Uz,Wz,Gz,Kz,qz,Jz,Yz=o((()=>{lO(),zz(),Vz(),QF(),vz(),aL(),Mz(),Uz=5,Wz=1.2,Gz=512,Kz=[[-1/0,-90],[1/0,90]],qz=class extends Bz{constructor(e){let{width:t,height:n,latitude:r,longitude:i,zoom:a,bearing:o=0,pitch:s=0,altitude:c=1.5,position:l=[0,0,0],maxZoom:u=20,minZoom:d=0,maxPitch:f=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:h,startRotatePos:g,startRotateLngLat:_,startBearing:v,startPitch:y,startZoom:b,normalize:x=!0}=e;_z(Number.isFinite(i)),_z(Number.isFinite(r)),_z(Number.isFinite(a));let S=e.maxBounds||(x?Kz:null);super({width:t,height:n,latitude:r,longitude:i,zoom:a,bearing:o,pitch:s,altitude:c,maxZoom:u,minZoom:d,maxPitch:f,minPitch:p,normalize:x,position:l,maxBounds:S},{startPanLngLat:m,startZoomLngLat:h,startRotatePos:g,startRotateLngLat:_,startBearing:v,startPitch:y,startZoom:b},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){let n=this.getState().startPanLngLat||this._unproject(t);if(!n)return this;let r=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(r)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t===void 0?void 0:this._unproject3D(e,t),startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:r,startRotateLngLat:i,startBearing:a,startPitch:o}=this.getState();if(!r||a===void 0||o===void 0)return this;let s;if(s=e?this._getNewRotation(e,r,o,a):{bearing:a+t,pitch:o+n},i){let e=this.makeViewport({...this.getViewportProps(),...s}),t=`panByPosition3D`in e?`panByPosition3D`:`panByPosition`;return this._getUpdatedState({...s,...e[t](i,r)})}return this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:r,startZoomLngLat:i}=this.getState();if(i||=(r=this.getViewportProps().zoom,this._unproject(t)||this._unproject(e)),!i)return this;let a=this._constrainZoom(r+Math.log2(n)),o=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...o.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:r,longitude:i}=n;return Math.abs(r-t.bearing)>180&&(n.bearing=r<0?r+360:r-360),Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}applyConstraints(e){let{maxPitch:t,minPitch:n,pitch:r,longitude:i,bearing:a,normalize:o,maxBounds:s}=e;if(o&&((i<-180||i>180)&&(e.longitude=XI(i+180,360)-180),(a<-180||a>180)&&(e.bearing=XI(a+180,360)-180)),e.pitch=zE(r,n,t),e.zoom=this._constrainZoom(e.zoom,e),s){let t=Hz(s[0]),n=Hz(s[1]),r=2**e.zoom,i=e.width/2/r,a=e.height/2/r,[o,c]=SF([t[0]+i,t[1]+a]),[l,u]=SF([n[0]-i,n[1]-a]);e.longitude=zE(e.longitude,o,l),e.latitude=zE(e.latitude,c,u)}return e}_constrainZoom(e,t){t||=this.getViewportProps();let{maxZoom:n,maxBounds:r}=t,i=r!==null&&t.width>0&&t.height>0,{minZoom:a}=t;if(i){let e=Hz(r[0]),i=Hz(r[1]),o=i[0]-e[0],s=i[1]-e[1];Number.isFinite(o)&&o>0&&(a=Math.max(a,Math.log2(t.width/o))),Number.isFinite(s)&&s>0&&(a=Math.max(a,Math.log2(t.height/s))),a>n&&(a=n)}return zE(e,a,n)}_zoomFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.zoom({pos:[t/2,n/2],scale:e})}_panFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.pan({startPos:[t/2,n/2],pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,n,r){let i=e[0]-t[0],a=e[1]-t[1],o=e[1],s=t[1],{width:c,height:l}=this.getViewportProps(),u=i/c,d=0;a>0?Math.abs(l-s)>Uz&&(d=a/(s-l)*Wz):a<0&&s>Uz&&(d=1-o/s),d=zE(d,-1,1);let{minPitch:f,maxPitch:p}=this.getViewportProps(),m=r+180*u,h=n;return d>0?h=n+d*(p-n):d<0&&(h=n-d*(f-n)),{pitch:h,bearing:m}}},Jz=class extends Rz{constructor(){super(...arguments),this.ControllerState=qz,this.transition={transitionDuration:300,transitionInterpolator:new jz({transitionProps:{compare:[`longitude`,`latitude`,`zoom`,`bearing`,`pitch`,`position`],required:[`longitude`,`latitude`,`zoom`]}})},this.dragMode=`pan`,this.rotationPivot=`center`,this._getAltitude=e=>{if(this.rotationPivot===`2d`)return 0;if(this.rotationPivot===`3d`&&this.pickPosition){let{x:t,y:n}=this.props,r=this.pickPosition(t+e[0],n+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){`rotationPivot`in e&&(this.rotationPivot=e.rotationPivot||`center`),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:Kz),super.setProps(e)}updateViewport(e,t=null,n={}){let r=e.getState();n.isDragging&&r.startRotateLngLat?n={...n,rotationPivotPosition:r.startRotateLngLat}:n.isDragging===!1&&(n={...n,rotationPivotPosition:void 0}),super.updateViewport(e,t,n)}}})),Xz,Zz=o((()=>{cz(),mL(),Yz(),Xz=class extends sz{constructor(e={}){super(e)}getViewportType(){return pL}get ControllerType(){return Jz}},Xz.displayName=`MapView`}));function Qz(e,t){return(e.order??1/0)-(t.order??1/0)}var $z,eB,tB=o((()=>{ZR(),GI(),$z=new WI,eB=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw=`Initial render`,this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){let n=t.findIndex(t=>Qz(t,e)>0);n<0?t.push(e):t.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){`effects`in e&&(XR(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let e of this.effects)t[e.id]=e;let n=[];for(let r of e){let e=t[r.id],i=r;e&&e!==r?e.setProps?(e.setProps(r.props),i=e):e.cleanup(this._context):e||r.setup(this._context),n.push(i),delete t[r.id]}for(let e in t)t[e].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(e=>e instanceof WI)||this._resolvedEffects.push($z),this._needsRedraw=`effects changed`}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}})),nB,rB=o((()=>{RI(),nB=class extends LI{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes(`draw`)||t.includes(`terrain`)}render(e){return this._render(e)}}})),iB,aB,oB=o((()=>{Iw(),rB(),MR(),iB=`deckRenderer.renderLayers`,aB=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new nB(e),this.pickLayersPass=new jR(e),this.renderCount=0,this._needsRedraw=`Initial render`,this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw=`layerFilter changed`),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw=`drawPickingColors changed`)}renderLayers(e){if(!e.viewports.length)return;let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};n.effects&&this._preRender(n.effects,n);let r=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);let i=t.render({...n,target:r}),a=`stats`in i?i.stats:i;n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,Pw(iB,this,a,e),this._updateStats(a)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:n}of e)t+=n;this.stats.get(`Layers rendered`).addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let n of e)t.preRenderStats[n.id]=n.preRender(t),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize(),[n,r]=t;e.length===0&&[0,1].map(t=>{let i=this.device.createTexture({sampler:{minFilter:`linear`,magFilter:`linear`},width:n,height:r});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(let n of e)n.resize(t)}_postRender(e,t){let{renderBuffers:n}=this,r={...t,inputBuffer:n[0],swapBuffer:n[1]};for(let i of e)if(i.postRender){r.target=i.id===this.lastPostProcessEffect?t.target:void 0;let e=i.postRender(r);r.inputBuffer=e,r.swapBuffer=e===n[0]?n[1]:n[0]}}}}));function sB({pickedColors:e,decodePickingColor:t,deviceX:n,deviceY:r,deviceRadius:i,deviceRect:a}){let{x:o,y:s,width:c,height:l}=a,u=i*i,d=-1,f=0;for(let t=0;t<l;t++){let i=t+s-r,a=i*i;if(a>u)f+=4*c;else for(let t=0;t<c;t++){if(e[f+3]-1>=0){let e=t+o-n,r=e*e+a;r<=u&&(u=r,d=f)}f+=4}}if(d>=0){let n=e.slice(d,d+4),r=t(n);if(r){let e=Math.floor(d/4/c),t=d/4-e*c;return{...r,pickedColor:n,pickedX:o+t,pickedY:s+e}}Mw.error(`Picked non-existent layer. Is picking buffer corrupt?`)()}return lB}function cB({pickedColors:e,decodePickingColor:t}){let n=new Map;if(e){for(let r=0;r<e.length;r+=4)if(e[r+3]-1>=0){let i=e.slice(r,r+4),a=i.join(`,`);if(!n.has(a)){let e=t(i);e?n.set(a,{...e,color:i}):Mw.error(`Picked non-existent layer. Is picking buffer corrupt?`)()}}}return Array.from(n.values())}var lB,uB=o((()=>{Nw(),lB={pickedColor:null,pickedObjectIndex:-1}}));function dB({pickInfo:e,viewports:t,pixelRatio:n,x:r,y:i,z:a}){let o=t[0];t.length>1&&(o=mB(e?.pickedViewports||t,{x:r,y:i}));let s;if(o){let e=[r-o.x,i-o.y];a!==void 0&&(e[2]=a),s=o.unproject(e)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:r,y:i,pixel:[r,i],coordinate:s,devicePixel:e&&`pickedX`in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:n}}function fB(e){let{pickInfo:t,lastPickedInfo:n,mode:r,layers:i}=e,{pickedColor:a,pickedLayer:o,pickedObjectIndex:s}=t,c=o?[o]:[];if(r===`hover`){let e=n.index,t=n.layerId,r=o?o.props.id:null;if(r!==t||s!==e){if(r!==t){let e=i.find(e=>e.props.id===t);e&&c.unshift(e)}n.layerId=r,n.index=s,n.info=null}}let l=dB(e),u=new Map;return u.set(null,l),c.forEach(e=>{let t={...l};e===o&&(t.color=a,t.index=s,t.picked=!0),t=pB({layer:e,info:t,mode:r});let i=t.layer;e===o&&r===`hover`&&(n.info=t),u.set(i.id,t),r===`hover`&&i.updateAutoHighlight(t)}),u}function pB({layer:e,info:t,mode:n}){for(;e&&t;){let r=t.layer||null;t.sourceLayer=r,t.layer=e,t=e.getPickingInfo({info:t,mode:n,sourceLayer:r}),e=e.parent}return t}function mB(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.containsPixel(t))return r}return e[0]}var hB=o((()=>{})),gB,_B=o((()=>{nM(),MR(),Nw(),uB(),hB(),gB=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new jR(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){`layerFilter`in e&&(this.layerFilter=e.layerFilter),`_pickable`in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:n,viewports:r},i=this.lastPickedInfo.info){let a=i&&i.layer&&i.layer.id,o=i&&i.viewport&&i.viewport.id,s=a?n.find(e=>e.id===a):null,c=o&&r.find(e=>e.id===o)||r[0],l={x:e,y:t,viewport:c,coordinate:c&&c.unproject([e-c.x,t-c.y]),layer:s};return{...i,...l}}_resizeBuffer(){if(!this.pickingFBO){let e=this.device.createTexture({format:`rgba8unorm`,width:1,height:1,usage:OA.RENDER_ATTACHMENT|OA.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:`depth16unorm`}),this.device.isTextureFormatRenderable(`rgba32float`)){let e=this.device.createTexture({format:`rgba32float`,width:1,height:1,usage:OA.RENDER_ATTACHMENT|OA.COPY_SRC}),t=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:`depth16unorm`});this.depthFBO=t}}let{canvas:e}=this.device.getDefaultCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:n,x:r,y:i,radius:a=0,depth:o=1,mode:s=`query`,unproject3D:c,onViewportActive:l,effects:u}){let d=this.device.canvasContext.cssToDeviceRatio(),f=this._getPickable(e);if(!f||n.length===0)return{result:[],emptyInfo:dB({viewports:n,x:r,y:i,pixelRatio:d})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],h=Math.round(a*d),{width:g,height:_}=this.pickingFBO,v=this._getPickingRect({deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceWidth:g,deviceHeight:_}),y={x:r-a,y:i-a,width:a*2+1,height:a*2+1},b,x=[],S=new Set;for(let e=0;e<o;e++){let a;a=v?sB({...await this._drawAndSampleAsync({layers:f,views:t,viewports:n,onViewportActive:l,deviceRect:v,cullRect:y,effects:u,pass:`picking:${s}`}),deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceRect:v}):{pickedColor:null,pickedObjectIndex:-1};let p,g=this._getDepthLayers(a,f,c);if(g.length>0){let{pickedColors:e}=await this._drawAndSampleAsync({layers:g,views:t,viewports:n,onViewportActive:l,deviceRect:{x:a.pickedX??m[0],y:a.pickedY??m[1],width:1,height:1},cullRect:y,effects:u,pass:`picking:${s}:z`},!0);e[3]&&(p=e[0])}a.pickedLayer&&e+1<o&&(S.add(a.pickedLayer),a.pickedLayer.disablePickingIndex(a.pickedObjectIndex)),b=fB({pickInfo:a,lastPickedInfo:this.lastPickedInfo,mode:s,layers:f,viewports:n,x:r,y:i,z:p,pixelRatio:d});for(let e of b.values())e.layer&&x.push(e);if(!a.pickedColor)break}for(let e of S)e.restorePickingColors();return{result:x,emptyInfo:b.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:r,y:i,radius:a=0,depth:o=1,mode:s=`query`,unproject3D:c,onViewportActive:l,effects:u}){let d=this.device.canvasContext.cssToDeviceRatio(),f=this._getPickable(e);if(!f||n.length===0)return{result:[],emptyInfo:dB({viewports:n,x:r,y:i,pixelRatio:d})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],h=Math.round(a*d),{width:g,height:_}=this.pickingFBO,v=this._getPickingRect({deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceWidth:g,deviceHeight:_}),y={x:r-a,y:i-a,width:a*2+1,height:a*2+1},b,x=[],S=new Set;for(let e=0;e<o;e++){let a;a=v?sB({...this._drawAndSample({layers:f,views:t,viewports:n,onViewportActive:l,deviceRect:v,cullRect:y,effects:u,pass:`picking:${s}`}),deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceRect:v}):{pickedColor:null,pickedObjectIndex:-1};let p,g=this._getDepthLayers(a,f,c);if(g.length>0){let{pickedColors:e}=this._drawAndSample({layers:g,views:t,viewports:n,onViewportActive:l,deviceRect:{x:a.pickedX??m[0],y:a.pickedY??m[1],width:1,height:1},cullRect:y,effects:u,pass:`picking:${s}:z`},!0);e[3]&&(p=e[0])}a.pickedLayer&&e+1<o&&(S.add(a.pickedLayer),a.pickedLayer.disablePickingIndex(a.pickedObjectIndex)),b=fB({pickInfo:a,lastPickedInfo:this.lastPickedInfo,mode:s,layers:f,viewports:n,x:r,y:i,z:p,pixelRatio:d});for(let e of b.values())e.layer&&x.push(e);if(!a.pickedColor)break}for(let e of S)e.restorePickingColors();return{result:x,emptyInfo:b.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:r,y:i,width:a=1,height:o=1,mode:s=`query`,maxObjects:c=null,onViewportActive:l,effects:u}){let d=this._getPickable(e);if(!d||n.length===0)return[];this._resizeBuffer();let f=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=p.x,h=p.y+p.height,g=this.device.canvasContext.cssToDevicePixels([r+a,i+o],!0),_=g.x+g.width,v=g.y,y={x:m,y:v,width:_-m,height:h-v},b=cB(await this._drawAndSampleAsync({layers:d,views:t,viewports:n,onViewportActive:l,deviceRect:y,cullRect:{x:r,y:i,width:a,height:o},effects:u,pass:`picking:${s}`})),x=new Map,S=[],C=Number.isFinite(c);for(let e=0;e<b.length&&!(C&&S.length>=c);e++){let t=b[e],n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:f};n=pB({layer:t.pickedLayer,info:n,mode:s});let a=n.layer.id;x.has(a)||x.set(a,new Set);let o=x.get(a),c=n.object??n.index;o.has(c)||(o.add(c),S.push(n))}return S}_pickVisibleObjects({layers:e,views:t,viewports:n,x:r,y:i,width:a=1,height:o=1,mode:s=`query`,maxObjects:c=null,onViewportActive:l,effects:u}){let d=this._getPickable(e);if(!d||n.length===0)return[];this._resizeBuffer();let f=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=p.x,h=p.y+p.height,g=this.device.canvasContext.cssToDevicePixels([r+a,i+o],!0),_=g.x+g.width,v=g.y,y={x:m,y:v,width:_-m,height:h-v},b=cB(this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:l,deviceRect:y,cullRect:{x:r,y:i,width:a,height:o},effects:u,pass:`picking:${s}`})),x=new Map,S=[],C=Number.isFinite(c);for(let e=0;e<b.length&&!(C&&S.length>=c);e++){let t=b[e],n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:f};n=pB({layer:t.pickedLayer,info:n,mode:s});let a=n.layer.id;x.has(a)||x.set(a,new Set);let o=x.get(a),c=n.object??n.index;o.has(c)||(o.add(c),S.push(n))}return S}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:a,effects:o,pass:s},c=!1){let l=c?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:a,effects:o,pass:s,pickZ:c,preRenderStats:{},isPicking:!0};for(let e of o)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));let{decodePickingColor:d,stats:f}=this.pickLayersPass.render(u);this._updateStats(f);let{x:p,y:m,width:h,height:g}=i,_=l.colorAttachments[0]?.texture;if(!_)throw Error(`Picking framebuffer color attachment is missing`);let v=await this._readTextureDataAsync(_,{x:p,y:m,width:h,height:g},c?Float32Array:Uint8Array);if(!c){let e=!1;for(let t=3;t<v.length;t+=4)if(v[t]!==0){e=!0;break}!e&&v.length>0&&Mw.warn(`Async pick readback returned only zero alpha values`,{deviceRect:i,bytes:Array.from(v.subarray(0,Math.min(v.length,16)))})()}return{pickedColors:v,decodePickingColor:d}}async _readTextureDataAsync(e,t,n){let{width:r,height:i}=t,a=e.computeMemoryLayout(t),o=this.device.createBuffer({byteLength:a.byteLength,usage:uk.COPY_DST|uk.MAP_READ});try{e.readBuffer(t,o);let s=await o.readAsync(0,a.byteLength),c=n.BYTES_PER_ELEMENT;if(a.bytesPerRow%c!==0)throw Error(`Texture readback row stride ${a.bytesPerRow} is not aligned to ${c}-byte elements.`);let l=new n(s.buffer,s.byteOffset,a.byteLength/c),u=r*4,d=a.bytesPerRow/c;if(d<u)throw Error(`Texture readback row stride ${d} is smaller than packed row length ${u}.`);let f=new n(r*i*4);for(let e=0;e<i;e++){let t=e*d;f.set(l.subarray(t,t+u),e*u)}return f}finally{o.destroy()}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:a,effects:o,pass:s},c=!1){let l=c?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:a,effects:o,pass:s,pickZ:c,preRenderStats:{},isPicking:!0};for(let e of o)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));let{decodePickingColor:d,stats:f}=this.pickLayersPass.render(u);this._updateStats(f);let{x:p,y:m,width:h,height:g}=i,_=new(c?Float32Array:Uint8Array)(h*g*4);return this.device.readPixelsToArrayWebGL(l,{sourceX:p,sourceY:m,sourceWidth:h,sourceHeight:g,target:_}),{pickedColors:_,decodePickingColor:d}}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:n}of e)t+=n;this.stats.get(`Layers picked`).addCount(t)}_getDepthLayers(e,t,n){if(!n||!this.depthFBO)return[];let{pickedLayer:r}=e,i=r?.state?.terrainDrawMode===`drape`;return r&&!i?[r]:t.filter(e=>e.props.operation.includes(`terrain`))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:r,deviceHeight:i}){let a=Math.max(0,e-n),o=Math.max(0,t-n),s=Math.min(r,e+n+1)-a,c=Math.min(i,t+n+1)-o;return s<=0||c<=0?null:{x:a,y:o,width:s,height:c}}}})),vB,yB,bB,xB,SB=o((()=>{zP(),ZR(),vB={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},yB=`top-left`,bB=`root`,xB=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add(`deck-widget-container`),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!XR(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let n=e.reduce((e,t)=>(e[t.id]=t,e),{});for(let r of this.getWidgets()){let{viewId:i}=r;if(i){let e=n[i];e&&(r.onViewportChange&&r.onViewportChange(e),r.onRedraw?.({viewports:[e],layers:t}))}else{if(r.onViewportChange)for(let t of e)r.onViewportChange(t);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=n,this._updateContainers()}onHover(e,t){for(let n of this.getWidgets()){let{viewId:r}=n;(!r||r===e.viewport?.id)&&n.onHover?.(e,t)}}onEvent(e,t){let n=LP[t.type];if(n)for(let r of this.getWidgets()){let{viewId:i}=r;(!i||i===e.viewport?.id)&&r[n]?.(e,t)}}_setWidgets(e){let t={};for(let e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(let e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let n of e){let e=t[n.id];e?e.viewId!==n.viewId||e.placement!==n.placement?(this._removeWidget(e),this._addWidget(n)):n!==e&&(e.setProps(n.props),n=e):this._addWidget(n),t[n.id]=null,this.resolvedWidgets.push(n)}for(let e in t){let n=t[e];n&&this._removeWidget(n)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:n=yB}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!=`string`)return e;let n=e||bB,r=this.containers[n];r||(r=document.createElement(`div`),r.style.pointerEvents=`none`,r.style.position=`absolute`,r.style.overflow=`hidden`,this.parentElement?.append(r),this.containers[n]=r);let i=r.querySelector(`.${t}`);return i||(i=globalThis.document.createElement(`div`),i.className=t,i.style.position=`absolute`,i.style.zIndex=`2`,Object.assign(i.style,vB[t]),r.append(i)),i}_updateContainers(){let e=this.deck.width,t=this.deck.height;for(let n in this.containers){let r=this.lastViewports[n]||null,i=n===bB||r,a=this.containers[n];i?(a.style.display=`block`,a.style.left=`${r?r.x:0}px`,a.style.top=`${r?r.y:0}px`,a.style.width=`${r?r.width:e}px`,a.style.height=`${r?r.height:t}px`):a.style.display=`none`}}}}));function CB(e,t){t&&Object.entries(t).map(([t,n])=>{t.startsWith(`--`)?e.style.setProperty(t,n):e.style[t]=n})}function wB(e,t){t&&Object.keys(t).map(t=>{t.startsWith(`--`)?e.style.removeProperty(t):e.style[t]=``})}var TB=o((()=>{})),EB,DB=o((()=>{ZR(),TB(),EB=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,n=this.rootElement;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!XR(t.style,e.style,1)&&(wB(n,t.style),CB(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=[`deck-widget`,this.className,this.props.className],t=document.createElement(`div`);return e.filter(e=>typeof e==`string`&&e.length>0).forEach(e=>t.classList.add(e)),CB(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}},EB.defaultProps={id:`widget`,style:{},_container:null,className:``}})),OB,kB,AB=o((()=>{DB(),OB={zIndex:`1`,position:`absolute`,pointerEvents:`none`,color:`#a0a7b4`,backgroundColor:`#29323c`,padding:`10px`,top:`0`,left:`0`,display:`none`},kB=class extends EB{constructor(e={}){super(e),this.id=`default-tooltip`,this.placement=`fill`,this.className=`deck-tooltip`,this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement(`div`);return e.className=this.className,Object.assign(e.style,OB),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,n=t&&t.props.getTooltip;if(!n)return;let r=n(e);this.setTooltip(r,e.x,e.y)}setTooltip(e,t,n){let r=this.rootElement;if(r){if(typeof e==`string`)r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display=`none`;return}this.isVisible=!0,r.style.display=`block`,r.style.transform=`translate(${t}px, ${n}px)`,e&&typeof e==`object`&&`style`in e&&Object.assign(r.style,e.style)}}},kB.defaultProps={...EB.defaultProps}})),jB,MB=o((()=>{(function(e){e[e.DEPTH_BUFFER_BIT=256]=`DEPTH_BUFFER_BIT`,e[e.STENCIL_BUFFER_BIT=1024]=`STENCIL_BUFFER_BIT`,e[e.COLOR_BUFFER_BIT=16384]=`COLOR_BUFFER_BIT`,e[e.POINTS=0]=`POINTS`,e[e.LINES=1]=`LINES`,e[e.LINE_LOOP=2]=`LINE_LOOP`,e[e.LINE_STRIP=3]=`LINE_STRIP`,e[e.TRIANGLES=4]=`TRIANGLES`,e[e.TRIANGLE_STRIP=5]=`TRIANGLE_STRIP`,e[e.TRIANGLE_FAN=6]=`TRIANGLE_FAN`,e[e.ZERO=0]=`ZERO`,e[e.ONE=1]=`ONE`,e[e.SRC_COLOR=768]=`SRC_COLOR`,e[e.ONE_MINUS_SRC_COLOR=769]=`ONE_MINUS_SRC_COLOR`,e[e.SRC_ALPHA=770]=`SRC_ALPHA`,e[e.ONE_MINUS_SRC_ALPHA=771]=`ONE_MINUS_SRC_ALPHA`,e[e.DST_ALPHA=772]=`DST_ALPHA`,e[e.ONE_MINUS_DST_ALPHA=773]=`ONE_MINUS_DST_ALPHA`,e[e.DST_COLOR=774]=`DST_COLOR`,e[e.ONE_MINUS_DST_COLOR=775]=`ONE_MINUS_DST_COLOR`,e[e.SRC_ALPHA_SATURATE=776]=`SRC_ALPHA_SATURATE`,e[e.CONSTANT_COLOR=32769]=`CONSTANT_COLOR`,e[e.ONE_MINUS_CONSTANT_COLOR=32770]=`ONE_MINUS_CONSTANT_COLOR`,e[e.CONSTANT_ALPHA=32771]=`CONSTANT_ALPHA`,e[e.ONE_MINUS_CONSTANT_ALPHA=32772]=`ONE_MINUS_CONSTANT_ALPHA`,e[e.FUNC_ADD=32774]=`FUNC_ADD`,e[e.FUNC_SUBTRACT=32778]=`FUNC_SUBTRACT`,e[e.FUNC_REVERSE_SUBTRACT=32779]=`FUNC_REVERSE_SUBTRACT`,e[e.BLEND_EQUATION=32777]=`BLEND_EQUATION`,e[e.BLEND_EQUATION_RGB=32777]=`BLEND_EQUATION_RGB`,e[e.BLEND_EQUATION_ALPHA=34877]=`BLEND_EQUATION_ALPHA`,e[e.BLEND_DST_RGB=32968]=`BLEND_DST_RGB`,e[e.BLEND_SRC_RGB=32969]=`BLEND_SRC_RGB`,e[e.BLEND_DST_ALPHA=32970]=`BLEND_DST_ALPHA`,e[e.BLEND_SRC_ALPHA=32971]=`BLEND_SRC_ALPHA`,e[e.BLEND_COLOR=32773]=`BLEND_COLOR`,e[e.ARRAY_BUFFER_BINDING=34964]=`ARRAY_BUFFER_BINDING`,e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]=`ELEMENT_ARRAY_BUFFER_BINDING`,e[e.LINE_WIDTH=2849]=`LINE_WIDTH`,e[e.ALIASED_POINT_SIZE_RANGE=33901]=`ALIASED_POINT_SIZE_RANGE`,e[e.ALIASED_LINE_WIDTH_RANGE=33902]=`ALIASED_LINE_WIDTH_RANGE`,e[e.CULL_FACE_MODE=2885]=`CULL_FACE_MODE`,e[e.FRONT_FACE=2886]=`FRONT_FACE`,e[e.DEPTH_RANGE=2928]=`DEPTH_RANGE`,e[e.DEPTH_WRITEMASK=2930]=`DEPTH_WRITEMASK`,e[e.DEPTH_CLEAR_VALUE=2931]=`DEPTH_CLEAR_VALUE`,e[e.DEPTH_FUNC=2932]=`DEPTH_FUNC`,e[e.STENCIL_CLEAR_VALUE=2961]=`STENCIL_CLEAR_VALUE`,e[e.STENCIL_FUNC=2962]=`STENCIL_FUNC`,e[e.STENCIL_FAIL=2964]=`STENCIL_FAIL`,e[e.STENCIL_PASS_DEPTH_FAIL=2965]=`STENCIL_PASS_DEPTH_FAIL`,e[e.STENCIL_PASS_DEPTH_PASS=2966]=`STENCIL_PASS_DEPTH_PASS`,e[e.STENCIL_REF=2967]=`STENCIL_REF`,e[e.STENCIL_VALUE_MASK=2963]=`STENCIL_VALUE_MASK`,e[e.STENCIL_WRITEMASK=2968]=`STENCIL_WRITEMASK`,e[e.STENCIL_BACK_FUNC=34816]=`STENCIL_BACK_FUNC`,e[e.STENCIL_BACK_FAIL=34817]=`STENCIL_BACK_FAIL`,e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]=`STENCIL_BACK_PASS_DEPTH_FAIL`,e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]=`STENCIL_BACK_PASS_DEPTH_PASS`,e[e.STENCIL_BACK_REF=36003]=`STENCIL_BACK_REF`,e[e.STENCIL_BACK_VALUE_MASK=36004]=`STENCIL_BACK_VALUE_MASK`,e[e.STENCIL_BACK_WRITEMASK=36005]=`STENCIL_BACK_WRITEMASK`,e[e.VIEWPORT=2978]=`VIEWPORT`,e[e.SCISSOR_BOX=3088]=`SCISSOR_BOX`,e[e.COLOR_CLEAR_VALUE=3106]=`COLOR_CLEAR_VALUE`,e[e.COLOR_WRITEMASK=3107]=`COLOR_WRITEMASK`,e[e.UNPACK_ALIGNMENT=3317]=`UNPACK_ALIGNMENT`,e[e.PACK_ALIGNMENT=3333]=`PACK_ALIGNMENT`,e[e.MAX_TEXTURE_SIZE=3379]=`MAX_TEXTURE_SIZE`,e[e.MAX_VIEWPORT_DIMS=3386]=`MAX_VIEWPORT_DIMS`,e[e.SUBPIXEL_BITS=3408]=`SUBPIXEL_BITS`,e[e.RED_BITS=3410]=`RED_BITS`,e[e.GREEN_BITS=3411]=`GREEN_BITS`,e[e.BLUE_BITS=3412]=`BLUE_BITS`,e[e.ALPHA_BITS=3413]=`ALPHA_BITS`,e[e.DEPTH_BITS=3414]=`DEPTH_BITS`,e[e.STENCIL_BITS=3415]=`STENCIL_BITS`,e[e.POLYGON_OFFSET_UNITS=10752]=`POLYGON_OFFSET_UNITS`,e[e.POLYGON_OFFSET_FACTOR=32824]=`POLYGON_OFFSET_FACTOR`,e[e.TEXTURE_BINDING_2D=32873]=`TEXTURE_BINDING_2D`,e[e.SAMPLE_BUFFERS=32936]=`SAMPLE_BUFFERS`,e[e.SAMPLES=32937]=`SAMPLES`,e[e.SAMPLE_COVERAGE_VALUE=32938]=`SAMPLE_COVERAGE_VALUE`,e[e.SAMPLE_COVERAGE_INVERT=32939]=`SAMPLE_COVERAGE_INVERT`,e[e.COMPRESSED_TEXTURE_FORMATS=34467]=`COMPRESSED_TEXTURE_FORMATS`,e[e.VENDOR=7936]=`VENDOR`,e[e.RENDERER=7937]=`RENDERER`,e[e.VERSION=7938]=`VERSION`,e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]=`IMPLEMENTATION_COLOR_READ_TYPE`,e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]=`IMPLEMENTATION_COLOR_READ_FORMAT`,e[e.BROWSER_DEFAULT_WEBGL=37444]=`BROWSER_DEFAULT_WEBGL`,e[e.STATIC_DRAW=35044]=`STATIC_DRAW`,e[e.STREAM_DRAW=35040]=`STREAM_DRAW`,e[e.DYNAMIC_DRAW=35048]=`DYNAMIC_DRAW`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.BUFFER_SIZE=34660]=`BUFFER_SIZE`,e[e.BUFFER_USAGE=34661]=`BUFFER_USAGE`,e[e.CURRENT_VERTEX_ATTRIB=34342]=`CURRENT_VERTEX_ATTRIB`,e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]=`VERTEX_ATTRIB_ARRAY_ENABLED`,e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]=`VERTEX_ATTRIB_ARRAY_SIZE`,e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]=`VERTEX_ATTRIB_ARRAY_STRIDE`,e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]=`VERTEX_ATTRIB_ARRAY_TYPE`,e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]=`VERTEX_ATTRIB_ARRAY_NORMALIZED`,e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]=`VERTEX_ATTRIB_ARRAY_POINTER`,e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]=`VERTEX_ATTRIB_ARRAY_BUFFER_BINDING`,e[e.CULL_FACE=2884]=`CULL_FACE`,e[e.FRONT=1028]=`FRONT`,e[e.BACK=1029]=`BACK`,e[e.FRONT_AND_BACK=1032]=`FRONT_AND_BACK`,e[e.BLEND=3042]=`BLEND`,e[e.DEPTH_TEST=2929]=`DEPTH_TEST`,e[e.DITHER=3024]=`DITHER`,e[e.POLYGON_OFFSET_FILL=32823]=`POLYGON_OFFSET_FILL`,e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]=`SAMPLE_ALPHA_TO_COVERAGE`,e[e.SAMPLE_COVERAGE=32928]=`SAMPLE_COVERAGE`,e[e.SCISSOR_TEST=3089]=`SCISSOR_TEST`,e[e.STENCIL_TEST=2960]=`STENCIL_TEST`,e[e.NO_ERROR=0]=`NO_ERROR`,e[e.INVALID_ENUM=1280]=`INVALID_ENUM`,e[e.INVALID_VALUE=1281]=`INVALID_VALUE`,e[e.INVALID_OPERATION=1282]=`INVALID_OPERATION`,e[e.OUT_OF_MEMORY=1285]=`OUT_OF_MEMORY`,e[e.CONTEXT_LOST_WEBGL=37442]=`CONTEXT_LOST_WEBGL`,e[e.CW=2304]=`CW`,e[e.CCW=2305]=`CCW`,e[e.DONT_CARE=4352]=`DONT_CARE`,e[e.FASTEST=4353]=`FASTEST`,e[e.NICEST=4354]=`NICEST`,e[e.GENERATE_MIPMAP_HINT=33170]=`GENERATE_MIPMAP_HINT`,e[e.BYTE=5120]=`BYTE`,e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.INT=5124]=`INT`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.DOUBLE=5130]=`DOUBLE`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.ALPHA=6406]=`ALPHA`,e[e.RGB=6407]=`RGB`,e[e.RGBA=6408]=`RGBA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.FRAGMENT_SHADER=35632]=`FRAGMENT_SHADER`,e[e.VERTEX_SHADER=35633]=`VERTEX_SHADER`,e[e.COMPILE_STATUS=35713]=`COMPILE_STATUS`,e[e.DELETE_STATUS=35712]=`DELETE_STATUS`,e[e.LINK_STATUS=35714]=`LINK_STATUS`,e[e.VALIDATE_STATUS=35715]=`VALIDATE_STATUS`,e[e.ATTACHED_SHADERS=35717]=`ATTACHED_SHADERS`,e[e.ACTIVE_ATTRIBUTES=35721]=`ACTIVE_ATTRIBUTES`,e[e.ACTIVE_UNIFORMS=35718]=`ACTIVE_UNIFORMS`,e[e.MAX_VERTEX_ATTRIBS=34921]=`MAX_VERTEX_ATTRIBS`,e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]=`MAX_VERTEX_UNIFORM_VECTORS`,e[e.MAX_VARYING_VECTORS=36348]=`MAX_VARYING_VECTORS`,e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]=`MAX_COMBINED_TEXTURE_IMAGE_UNITS`,e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]=`MAX_VERTEX_TEXTURE_IMAGE_UNITS`,e[e.MAX_TEXTURE_IMAGE_UNITS=34930]=`MAX_TEXTURE_IMAGE_UNITS`,e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]=`MAX_FRAGMENT_UNIFORM_VECTORS`,e[e.SHADER_TYPE=35663]=`SHADER_TYPE`,e[e.SHADING_LANGUAGE_VERSION=35724]=`SHADING_LANGUAGE_VERSION`,e[e.CURRENT_PROGRAM=35725]=`CURRENT_PROGRAM`,e[e.NEVER=512]=`NEVER`,e[e.LESS=513]=`LESS`,e[e.EQUAL=514]=`EQUAL`,e[e.LEQUAL=515]=`LEQUAL`,e[e.GREATER=516]=`GREATER`,e[e.NOTEQUAL=517]=`NOTEQUAL`,e[e.GEQUAL=518]=`GEQUAL`,e[e.ALWAYS=519]=`ALWAYS`,e[e.KEEP=7680]=`KEEP`,e[e.REPLACE=7681]=`REPLACE`,e[e.INCR=7682]=`INCR`,e[e.DECR=7683]=`DECR`,e[e.INVERT=5386]=`INVERT`,e[e.INCR_WRAP=34055]=`INCR_WRAP`,e[e.DECR_WRAP=34056]=`DECR_WRAP`,e[e.NEAREST=9728]=`NEAREST`,e[e.LINEAR=9729]=`LINEAR`,e[e.NEAREST_MIPMAP_NEAREST=9984]=`NEAREST_MIPMAP_NEAREST`,e[e.LINEAR_MIPMAP_NEAREST=9985]=`LINEAR_MIPMAP_NEAREST`,e[e.NEAREST_MIPMAP_LINEAR=9986]=`NEAREST_MIPMAP_LINEAR`,e[e.LINEAR_MIPMAP_LINEAR=9987]=`LINEAR_MIPMAP_LINEAR`,e[e.TEXTURE_MAG_FILTER=10240]=`TEXTURE_MAG_FILTER`,e[e.TEXTURE_MIN_FILTER=10241]=`TEXTURE_MIN_FILTER`,e[e.TEXTURE_WRAP_S=10242]=`TEXTURE_WRAP_S`,e[e.TEXTURE_WRAP_T=10243]=`TEXTURE_WRAP_T`,e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE=5890]=`TEXTURE`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_BINDING_CUBE_MAP=34068]=`TEXTURE_BINDING_CUBE_MAP`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]=`MAX_CUBE_MAP_TEXTURE_SIZE`,e[e.TEXTURE0=33984]=`TEXTURE0`,e[e.ACTIVE_TEXTURE=34016]=`ACTIVE_TEXTURE`,e[e.REPEAT=10497]=`REPEAT`,e[e.CLAMP_TO_EDGE=33071]=`CLAMP_TO_EDGE`,e[e.MIRRORED_REPEAT=33648]=`MIRRORED_REPEAT`,e[e.TEXTURE_WIDTH=4096]=`TEXTURE_WIDTH`,e[e.TEXTURE_HEIGHT=4097]=`TEXTURE_HEIGHT`,e[e.FLOAT_VEC2=35664]=`FLOAT_VEC2`,e[e.FLOAT_VEC3=35665]=`FLOAT_VEC3`,e[e.FLOAT_VEC4=35666]=`FLOAT_VEC4`,e[e.INT_VEC2=35667]=`INT_VEC2`,e[e.INT_VEC3=35668]=`INT_VEC3`,e[e.INT_VEC4=35669]=`INT_VEC4`,e[e.BOOL=35670]=`BOOL`,e[e.BOOL_VEC2=35671]=`BOOL_VEC2`,e[e.BOOL_VEC3=35672]=`BOOL_VEC3`,e[e.BOOL_VEC4=35673]=`BOOL_VEC4`,e[e.FLOAT_MAT2=35674]=`FLOAT_MAT2`,e[e.FLOAT_MAT3=35675]=`FLOAT_MAT3`,e[e.FLOAT_MAT4=35676]=`FLOAT_MAT4`,e[e.SAMPLER_2D=35678]=`SAMPLER_2D`,e[e.SAMPLER_CUBE=35680]=`SAMPLER_CUBE`,e[e.LOW_FLOAT=36336]=`LOW_FLOAT`,e[e.MEDIUM_FLOAT=36337]=`MEDIUM_FLOAT`,e[e.HIGH_FLOAT=36338]=`HIGH_FLOAT`,e[e.LOW_INT=36339]=`LOW_INT`,e[e.MEDIUM_INT=36340]=`MEDIUM_INT`,e[e.HIGH_INT=36341]=`HIGH_INT`,e[e.FRAMEBUFFER=36160]=`FRAMEBUFFER`,e[e.RENDERBUFFER=36161]=`RENDERBUFFER`,e[e.RGBA4=32854]=`RGBA4`,e[e.RGB5_A1=32855]=`RGB5_A1`,e[e.RGB565=36194]=`RGB565`,e[e.DEPTH_COMPONENT16=33189]=`DEPTH_COMPONENT16`,e[e.STENCIL_INDEX=6401]=`STENCIL_INDEX`,e[e.STENCIL_INDEX8=36168]=`STENCIL_INDEX8`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e[e.RENDERBUFFER_WIDTH=36162]=`RENDERBUFFER_WIDTH`,e[e.RENDERBUFFER_HEIGHT=36163]=`RENDERBUFFER_HEIGHT`,e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]=`RENDERBUFFER_INTERNAL_FORMAT`,e[e.RENDERBUFFER_RED_SIZE=36176]=`RENDERBUFFER_RED_SIZE`,e[e.RENDERBUFFER_GREEN_SIZE=36177]=`RENDERBUFFER_GREEN_SIZE`,e[e.RENDERBUFFER_BLUE_SIZE=36178]=`RENDERBUFFER_BLUE_SIZE`,e[e.RENDERBUFFER_ALPHA_SIZE=36179]=`RENDERBUFFER_ALPHA_SIZE`,e[e.RENDERBUFFER_DEPTH_SIZE=36180]=`RENDERBUFFER_DEPTH_SIZE`,e[e.RENDERBUFFER_STENCIL_SIZE=36181]=`RENDERBUFFER_STENCIL_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]=`FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`,e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]=`FRAMEBUFFER_ATTACHMENT_OBJECT_NAME`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE`,e[e.COLOR_ATTACHMENT0=36064]=`COLOR_ATTACHMENT0`,e[e.DEPTH_ATTACHMENT=36096]=`DEPTH_ATTACHMENT`,e[e.STENCIL_ATTACHMENT=36128]=`STENCIL_ATTACHMENT`,e[e.DEPTH_STENCIL_ATTACHMENT=33306]=`DEPTH_STENCIL_ATTACHMENT`,e[e.NONE=0]=`NONE`,e[e.FRAMEBUFFER_COMPLETE=36053]=`FRAMEBUFFER_COMPLETE`,e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]=`FRAMEBUFFER_INCOMPLETE_ATTACHMENT`,e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]=`FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT`,e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]=`FRAMEBUFFER_INCOMPLETE_DIMENSIONS`,e[e.FRAMEBUFFER_UNSUPPORTED=36061]=`FRAMEBUFFER_UNSUPPORTED`,e[e.FRAMEBUFFER_BINDING=36006]=`FRAMEBUFFER_BINDING`,e[e.RENDERBUFFER_BINDING=36007]=`RENDERBUFFER_BINDING`,e[e.READ_FRAMEBUFFER=36008]=`READ_FRAMEBUFFER`,e[e.DRAW_FRAMEBUFFER=36009]=`DRAW_FRAMEBUFFER`,e[e.MAX_RENDERBUFFER_SIZE=34024]=`MAX_RENDERBUFFER_SIZE`,e[e.INVALID_FRAMEBUFFER_OPERATION=1286]=`INVALID_FRAMEBUFFER_OPERATION`,e[e.UNPACK_FLIP_Y_WEBGL=37440]=`UNPACK_FLIP_Y_WEBGL`,e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]=`UNPACK_PREMULTIPLY_ALPHA_WEBGL`,e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]=`UNPACK_COLORSPACE_CONVERSION_WEBGL`,e[e.READ_BUFFER=3074]=`READ_BUFFER`,e[e.UNPACK_ROW_LENGTH=3314]=`UNPACK_ROW_LENGTH`,e[e.UNPACK_SKIP_ROWS=3315]=`UNPACK_SKIP_ROWS`,e[e.UNPACK_SKIP_PIXELS=3316]=`UNPACK_SKIP_PIXELS`,e[e.PACK_ROW_LENGTH=3330]=`PACK_ROW_LENGTH`,e[e.PACK_SKIP_ROWS=3331]=`PACK_SKIP_ROWS`,e[e.PACK_SKIP_PIXELS=3332]=`PACK_SKIP_PIXELS`,e[e.TEXTURE_BINDING_3D=32874]=`TEXTURE_BINDING_3D`,e[e.UNPACK_SKIP_IMAGES=32877]=`UNPACK_SKIP_IMAGES`,e[e.UNPACK_IMAGE_HEIGHT=32878]=`UNPACK_IMAGE_HEIGHT`,e[e.MAX_3D_TEXTURE_SIZE=32883]=`MAX_3D_TEXTURE_SIZE`,e[e.MAX_ELEMENTS_VERTICES=33e3]=`MAX_ELEMENTS_VERTICES`,e[e.MAX_ELEMENTS_INDICES=33001]=`MAX_ELEMENTS_INDICES`,e[e.MAX_TEXTURE_LOD_BIAS=34045]=`MAX_TEXTURE_LOD_BIAS`,e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]=`MAX_FRAGMENT_UNIFORM_COMPONENTS`,e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]=`MAX_VERTEX_UNIFORM_COMPONENTS`,e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]=`MAX_ARRAY_TEXTURE_LAYERS`,e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]=`MIN_PROGRAM_TEXEL_OFFSET`,e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]=`MAX_PROGRAM_TEXEL_OFFSET`,e[e.MAX_VARYING_COMPONENTS=35659]=`MAX_VARYING_COMPONENTS`,e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]=`FRAGMENT_SHADER_DERIVATIVE_HINT`,e[e.RASTERIZER_DISCARD=35977]=`RASTERIZER_DISCARD`,e[e.VERTEX_ARRAY_BINDING=34229]=`VERTEX_ARRAY_BINDING`,e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]=`MAX_VERTEX_OUTPUT_COMPONENTS`,e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]=`MAX_FRAGMENT_INPUT_COMPONENTS`,e[e.MAX_SERVER_WAIT_TIMEOUT=37137]=`MAX_SERVER_WAIT_TIMEOUT`,e[e.MAX_ELEMENT_INDEX=36203]=`MAX_ELEMENT_INDEX`,e[e.RED=6403]=`RED`,e[e.RGB8=32849]=`RGB8`,e[e.RGBA8=32856]=`RGBA8`,e[e.RGB10_A2=32857]=`RGB10_A2`,e[e.TEXTURE_3D=32879]=`TEXTURE_3D`,e[e.TEXTURE_WRAP_R=32882]=`TEXTURE_WRAP_R`,e[e.TEXTURE_MIN_LOD=33082]=`TEXTURE_MIN_LOD`,e[e.TEXTURE_MAX_LOD=33083]=`TEXTURE_MAX_LOD`,e[e.TEXTURE_BASE_LEVEL=33084]=`TEXTURE_BASE_LEVEL`,e[e.TEXTURE_MAX_LEVEL=33085]=`TEXTURE_MAX_LEVEL`,e[e.TEXTURE_COMPARE_MODE=34892]=`TEXTURE_COMPARE_MODE`,e[e.TEXTURE_COMPARE_FUNC=34893]=`TEXTURE_COMPARE_FUNC`,e[e.SRGB=35904]=`SRGB`,e[e.SRGB8=35905]=`SRGB8`,e[e.SRGB8_ALPHA8=35907]=`SRGB8_ALPHA8`,e[e.COMPARE_REF_TO_TEXTURE=34894]=`COMPARE_REF_TO_TEXTURE`,e[e.RGBA32F=34836]=`RGBA32F`,e[e.RGB32F=34837]=`RGB32F`,e[e.RGBA16F=34842]=`RGBA16F`,e[e.RGB16F=34843]=`RGB16F`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_BINDING_2D_ARRAY=35869]=`TEXTURE_BINDING_2D_ARRAY`,e[e.R11F_G11F_B10F=35898]=`R11F_G11F_B10F`,e[e.RGB9_E5=35901]=`RGB9_E5`,e[e.RGBA32UI=36208]=`RGBA32UI`,e[e.RGB32UI=36209]=`RGB32UI`,e[e.RGBA16UI=36214]=`RGBA16UI`,e[e.RGB16UI=36215]=`RGB16UI`,e[e.RGBA8UI=36220]=`RGBA8UI`,e[e.RGB8UI=36221]=`RGB8UI`,e[e.RGBA32I=36226]=`RGBA32I`,e[e.RGB32I=36227]=`RGB32I`,e[e.RGBA16I=36232]=`RGBA16I`,e[e.RGB16I=36233]=`RGB16I`,e[e.RGBA8I=36238]=`RGBA8I`,e[e.RGB8I=36239]=`RGB8I`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.R8=33321]=`R8`,e[e.RG8=33323]=`RG8`,e[e.R16F=33325]=`R16F`,e[e.R32F=33326]=`R32F`,e[e.RG16F=33327]=`RG16F`,e[e.RG32F=33328]=`RG32F`,e[e.R8I=33329]=`R8I`,e[e.R8UI=33330]=`R8UI`,e[e.R16I=33331]=`R16I`,e[e.R16UI=33332]=`R16UI`,e[e.R32I=33333]=`R32I`,e[e.R32UI=33334]=`R32UI`,e[e.RG8I=33335]=`RG8I`,e[e.RG8UI=33336]=`RG8UI`,e[e.RG16I=33337]=`RG16I`,e[e.RG16UI=33338]=`RG16UI`,e[e.RG32I=33339]=`RG32I`,e[e.RG32UI=33340]=`RG32UI`,e[e.R8_SNORM=36756]=`R8_SNORM`,e[e.RG8_SNORM=36757]=`RG8_SNORM`,e[e.RGB8_SNORM=36758]=`RGB8_SNORM`,e[e.RGBA8_SNORM=36759]=`RGBA8_SNORM`,e[e.RGB10_A2UI=36975]=`RGB10_A2UI`,e[e.TEXTURE_IMMUTABLE_FORMAT=37167]=`TEXTURE_IMMUTABLE_FORMAT`,e[e.TEXTURE_IMMUTABLE_LEVELS=33503]=`TEXTURE_IMMUTABLE_LEVELS`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.HALF_FLOAT=5131]=`HALF_FLOAT`,e[e.RG=33319]=`RG`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.INT_2_10_10_10_REV=36255]=`INT_2_10_10_10_REV`,e[e.CURRENT_QUERY=34917]=`CURRENT_QUERY`,e[e.QUERY_RESULT=34918]=`QUERY_RESULT`,e[e.QUERY_RESULT_AVAILABLE=34919]=`QUERY_RESULT_AVAILABLE`,e[e.ANY_SAMPLES_PASSED=35887]=`ANY_SAMPLES_PASSED`,e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]=`ANY_SAMPLES_PASSED_CONSERVATIVE`,e[e.MAX_DRAW_BUFFERS=34852]=`MAX_DRAW_BUFFERS`,e[e.DRAW_BUFFER0=34853]=`DRAW_BUFFER0`,e[e.DRAW_BUFFER1=34854]=`DRAW_BUFFER1`,e[e.DRAW_BUFFER2=34855]=`DRAW_BUFFER2`,e[e.DRAW_BUFFER3=34856]=`DRAW_BUFFER3`,e[e.DRAW_BUFFER4=34857]=`DRAW_BUFFER4`,e[e.DRAW_BUFFER5=34858]=`DRAW_BUFFER5`,e[e.DRAW_BUFFER6=34859]=`DRAW_BUFFER6`,e[e.DRAW_BUFFER7=34860]=`DRAW_BUFFER7`,e[e.DRAW_BUFFER8=34861]=`DRAW_BUFFER8`,e[e.DRAW_BUFFER9=34862]=`DRAW_BUFFER9`,e[e.DRAW_BUFFER10=34863]=`DRAW_BUFFER10`,e[e.DRAW_BUFFER11=34864]=`DRAW_BUFFER11`,e[e.DRAW_BUFFER12=34865]=`DRAW_BUFFER12`,e[e.DRAW_BUFFER13=34866]=`DRAW_BUFFER13`,e[e.DRAW_BUFFER14=34867]=`DRAW_BUFFER14`,e[e.DRAW_BUFFER15=34868]=`DRAW_BUFFER15`,e[e.MAX_COLOR_ATTACHMENTS=36063]=`MAX_COLOR_ATTACHMENTS`,e[e.COLOR_ATTACHMENT1=36065]=`COLOR_ATTACHMENT1`,e[e.COLOR_ATTACHMENT2=36066]=`COLOR_ATTACHMENT2`,e[e.COLOR_ATTACHMENT3=36067]=`COLOR_ATTACHMENT3`,e[e.COLOR_ATTACHMENT4=36068]=`COLOR_ATTACHMENT4`,e[e.COLOR_ATTACHMENT5=36069]=`COLOR_ATTACHMENT5`,e[e.COLOR_ATTACHMENT6=36070]=`COLOR_ATTACHMENT6`,e[e.COLOR_ATTACHMENT7=36071]=`COLOR_ATTACHMENT7`,e[e.COLOR_ATTACHMENT8=36072]=`COLOR_ATTACHMENT8`,e[e.COLOR_ATTACHMENT9=36073]=`COLOR_ATTACHMENT9`,e[e.COLOR_ATTACHMENT10=36074]=`COLOR_ATTACHMENT10`,e[e.COLOR_ATTACHMENT11=36075]=`COLOR_ATTACHMENT11`,e[e.COLOR_ATTACHMENT12=36076]=`COLOR_ATTACHMENT12`,e[e.COLOR_ATTACHMENT13=36077]=`COLOR_ATTACHMENT13`,e[e.COLOR_ATTACHMENT14=36078]=`COLOR_ATTACHMENT14`,e[e.COLOR_ATTACHMENT15=36079]=`COLOR_ATTACHMENT15`,e[e.SAMPLER_3D=35679]=`SAMPLER_3D`,e[e.SAMPLER_2D_SHADOW=35682]=`SAMPLER_2D_SHADOW`,e[e.SAMPLER_2D_ARRAY=36289]=`SAMPLER_2D_ARRAY`,e[e.SAMPLER_2D_ARRAY_SHADOW=36292]=`SAMPLER_2D_ARRAY_SHADOW`,e[e.SAMPLER_CUBE_SHADOW=36293]=`SAMPLER_CUBE_SHADOW`,e[e.INT_SAMPLER_2D=36298]=`INT_SAMPLER_2D`,e[e.INT_SAMPLER_3D=36299]=`INT_SAMPLER_3D`,e[e.INT_SAMPLER_CUBE=36300]=`INT_SAMPLER_CUBE`,e[e.INT_SAMPLER_2D_ARRAY=36303]=`INT_SAMPLER_2D_ARRAY`,e[e.UNSIGNED_INT_SAMPLER_2D=36306]=`UNSIGNED_INT_SAMPLER_2D`,e[e.UNSIGNED_INT_SAMPLER_3D=36307]=`UNSIGNED_INT_SAMPLER_3D`,e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]=`UNSIGNED_INT_SAMPLER_CUBE`,e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]=`UNSIGNED_INT_SAMPLER_2D_ARRAY`,e[e.MAX_SAMPLES=36183]=`MAX_SAMPLES`,e[e.SAMPLER_BINDING=35097]=`SAMPLER_BINDING`,e[e.PIXEL_PACK_BUFFER=35051]=`PIXEL_PACK_BUFFER`,e[e.PIXEL_UNPACK_BUFFER=35052]=`PIXEL_UNPACK_BUFFER`,e[e.PIXEL_PACK_BUFFER_BINDING=35053]=`PIXEL_PACK_BUFFER_BINDING`,e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]=`PIXEL_UNPACK_BUFFER_BINDING`,e[e.COPY_READ_BUFFER=36662]=`COPY_READ_BUFFER`,e[e.COPY_WRITE_BUFFER=36663]=`COPY_WRITE_BUFFER`,e[e.COPY_READ_BUFFER_BINDING=36662]=`COPY_READ_BUFFER_BINDING`,e[e.COPY_WRITE_BUFFER_BINDING=36663]=`COPY_WRITE_BUFFER_BINDING`,e[e.FLOAT_MAT2x3=35685]=`FLOAT_MAT2x3`,e[e.FLOAT_MAT2x4=35686]=`FLOAT_MAT2x4`,e[e.FLOAT_MAT3x2=35687]=`FLOAT_MAT3x2`,e[e.FLOAT_MAT3x4=35688]=`FLOAT_MAT3x4`,e[e.FLOAT_MAT4x2=35689]=`FLOAT_MAT4x2`,e[e.FLOAT_MAT4x3=35690]=`FLOAT_MAT4x3`,e[e.UNSIGNED_INT_VEC2=36294]=`UNSIGNED_INT_VEC2`,e[e.UNSIGNED_INT_VEC3=36295]=`UNSIGNED_INT_VEC3`,e[e.UNSIGNED_INT_VEC4=36296]=`UNSIGNED_INT_VEC4`,e[e.UNSIGNED_NORMALIZED=35863]=`UNSIGNED_NORMALIZED`,e[e.SIGNED_NORMALIZED=36764]=`SIGNED_NORMALIZED`,e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]=`VERTEX_ATTRIB_ARRAY_INTEGER`,e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]=`VERTEX_ATTRIB_ARRAY_DIVISOR`,e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]=`TRANSFORM_FEEDBACK_BUFFER_MODE`,e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]=`MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS`,e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]=`TRANSFORM_FEEDBACK_VARYINGS`,e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]=`TRANSFORM_FEEDBACK_BUFFER_START`,e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]=`TRANSFORM_FEEDBACK_BUFFER_SIZE`,e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]=`TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN`,e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]=`MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS`,e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]=`MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS`,e[e.INTERLEAVED_ATTRIBS=35980]=`INTERLEAVED_ATTRIBS`,e[e.SEPARATE_ATTRIBS=35981]=`SEPARATE_ATTRIBS`,e[e.TRANSFORM_FEEDBACK_BUFFER=35982]=`TRANSFORM_FEEDBACK_BUFFER`,e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]=`TRANSFORM_FEEDBACK_BUFFER_BINDING`,e[e.TRANSFORM_FEEDBACK=36386]=`TRANSFORM_FEEDBACK`,e[e.TRANSFORM_FEEDBACK_PAUSED=36387]=`TRANSFORM_FEEDBACK_PAUSED`,e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]=`TRANSFORM_FEEDBACK_ACTIVE`,e[e.TRANSFORM_FEEDBACK_BINDING=36389]=`TRANSFORM_FEEDBACK_BINDING`,e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]=`FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING`,e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]=`FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE`,e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]=`FRAMEBUFFER_ATTACHMENT_RED_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]=`FRAMEBUFFER_ATTACHMENT_GREEN_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]=`FRAMEBUFFER_ATTACHMENT_BLUE_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]=`FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]=`FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]=`FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE`,e[e.FRAMEBUFFER_DEFAULT=33304]=`FRAMEBUFFER_DEFAULT`,e[e.DEPTH24_STENCIL8=35056]=`DEPTH24_STENCIL8`,e[e.DRAW_FRAMEBUFFER_BINDING=36006]=`DRAW_FRAMEBUFFER_BINDING`,e[e.READ_FRAMEBUFFER_BINDING=36010]=`READ_FRAMEBUFFER_BINDING`,e[e.RENDERBUFFER_SAMPLES=36011]=`RENDERBUFFER_SAMPLES`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER`,e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]=`FRAMEBUFFER_INCOMPLETE_MULTISAMPLE`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e[e.UNIFORM_BUFFER_BINDING=35368]=`UNIFORM_BUFFER_BINDING`,e[e.UNIFORM_BUFFER_START=35369]=`UNIFORM_BUFFER_START`,e[e.UNIFORM_BUFFER_SIZE=35370]=`UNIFORM_BUFFER_SIZE`,e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]=`MAX_VERTEX_UNIFORM_BLOCKS`,e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]=`MAX_FRAGMENT_UNIFORM_BLOCKS`,e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]=`MAX_COMBINED_UNIFORM_BLOCKS`,e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]=`MAX_UNIFORM_BUFFER_BINDINGS`,e[e.MAX_UNIFORM_BLOCK_SIZE=35376]=`MAX_UNIFORM_BLOCK_SIZE`,e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]=`MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS`,e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]=`MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS`,e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]=`UNIFORM_BUFFER_OFFSET_ALIGNMENT`,e[e.ACTIVE_UNIFORM_BLOCKS=35382]=`ACTIVE_UNIFORM_BLOCKS`,e[e.UNIFORM_TYPE=35383]=`UNIFORM_TYPE`,e[e.UNIFORM_SIZE=35384]=`UNIFORM_SIZE`,e[e.UNIFORM_BLOCK_INDEX=35386]=`UNIFORM_BLOCK_INDEX`,e[e.UNIFORM_OFFSET=35387]=`UNIFORM_OFFSET`,e[e.UNIFORM_ARRAY_STRIDE=35388]=`UNIFORM_ARRAY_STRIDE`,e[e.UNIFORM_MATRIX_STRIDE=35389]=`UNIFORM_MATRIX_STRIDE`,e[e.UNIFORM_IS_ROW_MAJOR=35390]=`UNIFORM_IS_ROW_MAJOR`,e[e.UNIFORM_BLOCK_BINDING=35391]=`UNIFORM_BLOCK_BINDING`,e[e.UNIFORM_BLOCK_DATA_SIZE=35392]=`UNIFORM_BLOCK_DATA_SIZE`,e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]=`UNIFORM_BLOCK_ACTIVE_UNIFORMS`,e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]=`UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES`,e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]=`UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER`,e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]=`UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER`,e[e.OBJECT_TYPE=37138]=`OBJECT_TYPE`,e[e.SYNC_CONDITION=37139]=`SYNC_CONDITION`,e[e.SYNC_STATUS=37140]=`SYNC_STATUS`,e[e.SYNC_FLAGS=37141]=`SYNC_FLAGS`,e[e.SYNC_FENCE=37142]=`SYNC_FENCE`,e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]=`SYNC_GPU_COMMANDS_COMPLETE`,e[e.UNSIGNALED=37144]=`UNSIGNALED`,e[e.SIGNALED=37145]=`SIGNALED`,e[e.ALREADY_SIGNALED=37146]=`ALREADY_SIGNALED`,e[e.TIMEOUT_EXPIRED=37147]=`TIMEOUT_EXPIRED`,e[e.CONDITION_SATISFIED=37148]=`CONDITION_SATISFIED`,e[e.WAIT_FAILED=37149]=`WAIT_FAILED`,e[e.SYNC_FLUSH_COMMANDS_BIT=1]=`SYNC_FLUSH_COMMANDS_BIT`,e[e.COLOR=6144]=`COLOR`,e[e.DEPTH=6145]=`DEPTH`,e[e.STENCIL=6146]=`STENCIL`,e[e.MIN=32775]=`MIN`,e[e.MAX=32776]=`MAX`,e[e.DEPTH_COMPONENT24=33190]=`DEPTH_COMPONENT24`,e[e.STREAM_READ=35041]=`STREAM_READ`,e[e.STREAM_COPY=35042]=`STREAM_COPY`,e[e.STATIC_READ=35045]=`STATIC_READ`,e[e.STATIC_COPY=35046]=`STATIC_COPY`,e[e.DYNAMIC_READ=35049]=`DYNAMIC_READ`,e[e.DYNAMIC_COPY=35050]=`DYNAMIC_COPY`,e[e.DEPTH_COMPONENT32F=36012]=`DEPTH_COMPONENT32F`,e[e.DEPTH32F_STENCIL8=36013]=`DEPTH32F_STENCIL8`,e[e.INVALID_INDEX=4294967295]=`INVALID_INDEX`,e[e.TIMEOUT_IGNORED=-1]=`TIMEOUT_IGNORED`,e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]=`MAX_CLIENT_WAIT_TIMEOUT_WEBGL`,e[e.UNMASKED_VENDOR_WEBGL=37445]=`UNMASKED_VENDOR_WEBGL`,e[e.UNMASKED_RENDERER_WEBGL=37446]=`UNMASKED_RENDERER_WEBGL`,e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]=`MAX_TEXTURE_MAX_ANISOTROPY_EXT`,e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]=`TEXTURE_MAX_ANISOTROPY_EXT`,e[e.R16_EXT=33322]=`R16_EXT`,e[e.RG16_EXT=33324]=`RG16_EXT`,e[e.RGB16_EXT=32852]=`RGB16_EXT`,e[e.RGBA16_EXT=32859]=`RGBA16_EXT`,e[e.R16_SNORM_EXT=36760]=`R16_SNORM_EXT`,e[e.RG16_SNORM_EXT=36761]=`RG16_SNORM_EXT`,e[e.RGB16_SNORM_EXT=36762]=`RGB16_SNORM_EXT`,e[e.RGBA16_SNORM_EXT=36763]=`RGBA16_SNORM_EXT`,e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]=`COMPRESSED_RGB_S3TC_DXT1_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]=`COMPRESSED_RGBA_S3TC_DXT1_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]=`COMPRESSED_RGBA_S3TC_DXT3_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]=`COMPRESSED_RGBA_S3TC_DXT5_EXT`,e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]=`COMPRESSED_SRGB_S3TC_DXT1_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT`,e[e.COMPRESSED_RED_RGTC1_EXT=36283]=`COMPRESSED_RED_RGTC1_EXT`,e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]=`COMPRESSED_SIGNED_RED_RGTC1_EXT`,e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]=`COMPRESSED_RED_GREEN_RGTC2_EXT`,e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]=`COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT`,e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]=`COMPRESSED_RGBA_BPTC_UNORM_EXT`,e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]=`COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT`,e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]=`COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT`,e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]=`COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT`,e[e.COMPRESSED_R11_EAC=37488]=`COMPRESSED_R11_EAC`,e[e.COMPRESSED_SIGNED_R11_EAC=37489]=`COMPRESSED_SIGNED_R11_EAC`,e[e.COMPRESSED_RG11_EAC=37490]=`COMPRESSED_RG11_EAC`,e[e.COMPRESSED_SIGNED_RG11_EAC=37491]=`COMPRESSED_SIGNED_RG11_EAC`,e[e.COMPRESSED_RGB8_ETC2=37492]=`COMPRESSED_RGB8_ETC2`,e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]=`COMPRESSED_RGBA8_ETC2_EAC`,e[e.COMPRESSED_SRGB8_ETC2=37494]=`COMPRESSED_SRGB8_ETC2`,e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]=`COMPRESSED_SRGB8_ALPHA8_ETC2_EAC`,e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]=`COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2`,e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]=`COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2`,e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]=`COMPRESSED_RGB_PVRTC_4BPPV1_IMG`,e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]=`COMPRESSED_RGBA_PVRTC_4BPPV1_IMG`,e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]=`COMPRESSED_RGB_PVRTC_2BPPV1_IMG`,e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]=`COMPRESSED_RGBA_PVRTC_2BPPV1_IMG`,e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]=`COMPRESSED_RGB_ETC1_WEBGL`,e[e.COMPRESSED_RGB_ATC_WEBGL=35986]=`COMPRESSED_RGB_ATC_WEBGL`,e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]=`COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL`,e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]=`COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL`,e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]=`COMPRESSED_RGBA_ASTC_4x4_KHR`,e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]=`COMPRESSED_RGBA_ASTC_5x4_KHR`,e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]=`COMPRESSED_RGBA_ASTC_5x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]=`COMPRESSED_RGBA_ASTC_6x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]=`COMPRESSED_RGBA_ASTC_6x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]=`COMPRESSED_RGBA_ASTC_8x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]=`COMPRESSED_RGBA_ASTC_8x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]=`COMPRESSED_RGBA_ASTC_8x8_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]=`COMPRESSED_RGBA_ASTC_10x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]=`COMPRESSED_RGBA_ASTC_10x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]=`COMPRESSED_RGBA_ASTC_10x8_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]=`COMPRESSED_RGBA_ASTC_10x10_KHR`,e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]=`COMPRESSED_RGBA_ASTC_12x10_KHR`,e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]=`COMPRESSED_RGBA_ASTC_12x12_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]=`COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]=`COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]=`COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]=`COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]=`COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]=`COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]=`COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR`,e[e.QUERY_COUNTER_BITS_EXT=34916]=`QUERY_COUNTER_BITS_EXT`,e[e.CURRENT_QUERY_EXT=34917]=`CURRENT_QUERY_EXT`,e[e.QUERY_RESULT_EXT=34918]=`QUERY_RESULT_EXT`,e[e.QUERY_RESULT_AVAILABLE_EXT=34919]=`QUERY_RESULT_AVAILABLE_EXT`,e[e.TIME_ELAPSED_EXT=35007]=`TIME_ELAPSED_EXT`,e[e.TIMESTAMP_EXT=36392]=`TIMESTAMP_EXT`,e[e.GPU_DISJOINT_EXT=36795]=`GPU_DISJOINT_EXT`,e[e.COMPLETION_STATUS_KHR=37297]=`COMPLETION_STATUS_KHR`,e[e.DEPTH_CLAMP_EXT=34383]=`DEPTH_CLAMP_EXT`,e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]=`FIRST_VERTEX_CONVENTION_WEBGL`,e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]=`LAST_VERTEX_CONVENTION_WEBGL`,e[e.PROVOKING_VERTEX_WEBL=36431]=`PROVOKING_VERTEX_WEBL`,e[e.POLYGON_MODE_WEBGL=2880]=`POLYGON_MODE_WEBGL`,e[e.POLYGON_OFFSET_LINE_WEBGL=10754]=`POLYGON_OFFSET_LINE_WEBGL`,e[e.LINE_WEBGL=6913]=`LINE_WEBGL`,e[e.FILL_WEBGL=6914]=`FILL_WEBGL`,e[e.MAX_CLIP_DISTANCES_WEBGL=3378]=`MAX_CLIP_DISTANCES_WEBGL`,e[e.MAX_CULL_DISTANCES_WEBGL=33529]=`MAX_CULL_DISTANCES_WEBGL`,e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]=`MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL`,e[e.CLIP_DISTANCE0_WEBGL=12288]=`CLIP_DISTANCE0_WEBGL`,e[e.CLIP_DISTANCE1_WEBGL=12289]=`CLIP_DISTANCE1_WEBGL`,e[e.CLIP_DISTANCE2_WEBGL=12290]=`CLIP_DISTANCE2_WEBGL`,e[e.CLIP_DISTANCE3_WEBGL=12291]=`CLIP_DISTANCE3_WEBGL`,e[e.CLIP_DISTANCE4_WEBGL=12292]=`CLIP_DISTANCE4_WEBGL`,e[e.CLIP_DISTANCE5_WEBGL=12293]=`CLIP_DISTANCE5_WEBGL`,e[e.CLIP_DISTANCE6_WEBGL=12294]=`CLIP_DISTANCE6_WEBGL`,e[e.CLIP_DISTANCE7_WEBGL=12295]=`CLIP_DISTANCE7_WEBGL`,e[e.POLYGON_OFFSET_CLAMP_EXT=36379]=`POLYGON_OFFSET_CLAMP_EXT`,e[e.LOWER_LEFT_EXT=36001]=`LOWER_LEFT_EXT`,e[e.UPPER_LEFT_EXT=36002]=`UPPER_LEFT_EXT`,e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]=`NEGATIVE_ONE_TO_ONE_EXT`,e[e.ZERO_TO_ONE_EXT=37727]=`ZERO_TO_ONE_EXT`,e[e.CLIP_ORIGIN_EXT=37724]=`CLIP_ORIGIN_EXT`,e[e.CLIP_DEPTH_MODE_EXT=37725]=`CLIP_DEPTH_MODE_EXT`,e[e.SRC1_COLOR_WEBGL=35065]=`SRC1_COLOR_WEBGL`,e[e.SRC1_ALPHA_WEBGL=34185]=`SRC1_ALPHA_WEBGL`,e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]=`ONE_MINUS_SRC1_COLOR_WEBGL`,e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]=`ONE_MINUS_SRC1_ALPHA_WEBGL`,e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]=`MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL`,e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]=`MIRROR_CLAMP_TO_EDGE_EXT`})(jB||={})})),NB=o((()=>{MB()}));function PB(e=!0){let t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext){t.getContext=t.originalGetContext,t.originalGetContext=void 0;return}t.originalGetContext=t.getContext,t.getContext=function(e,t){if(e===`webgl`||e===`experimental-webgl`){let e=this.originalGetContext(`webgl2`,t);return e instanceof HTMLElement&&FB(e),e}return this.originalGetContext(e,t)}}function FB(e){e.getExtension(`EXT_color_buffer_float`);let t={...IB,WEBGL_disjoint_timer_query:e.getExtension(`EXT_disjoint_timer_query_webgl2`),WEBGL_draw_buffers:LB(e),OES_vertex_array_object:RB(e),ANGLE_instanced_arrays:zB(e)},n=e.getExtension;e.getExtension=function(r){return n.call(e,r)||(r in t?t[r]:null)};let r=e.getSupportedExtensions;e.getSupportedExtensions=function(){return(r.apply(e)||[])?.concat(Object.keys(t))}}var IB,LB,RB,zB,BB=o((()=>{IB={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},LB=e=>({drawBuffersWEBGL(t){return e.drawBuffers(t)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),RB=e=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return e.createVertexArray()},deleteVertexArrayOES(t){return e.deleteVertexArray(t)},isVertexArrayOES(t){return e.isVertexArray(t)},bindVertexArrayOES(t){return e.bindVertexArray(t)}}),zB=e=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...t){return e.drawArraysInstanced(...t)},drawElementsInstancedANGLE(...t){return e.drawElementsInstanced(...t)},vertexAttribDivisorANGLE(...t){return e.vertexAttribDivisor(...t)}})}));async function VB(e,t){let n=document.getElementsByTagName(`head`)[0];if(!n)throw Error(`loadScript`);let r=document.createElement(`script`);return r.setAttribute(`type`,`text/javascript`),r.setAttribute(`src`,e),t&&(r.id=t),new Promise((t,i)=>{r.onload=t,r.onerror=t=>i(Error(`Unable to load script '${e}': ${t}`)),n.appendChild(r)})}var HB=o((()=>{}));function UB(e){let t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}var WB=o((()=>{}));async function GB(e){if(!globalThis.SPECTOR)try{await VB(e.debugSpectorJSUrl||XB.debugSpectorJSUrl)}catch(e){Z.warn(String(e))}}function KB(e){if(e={...XB,...e},!e.debugSpectorJS)return null;if(!JB&&globalThis.SPECTOR&&!globalThis.luma?.spector){Z.probe(qB,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;JB=new e,globalThis.luma&&(globalThis.luma.spector=JB)}if(!JB)return null;if(YB||(YB=!0,JB.spyCanvases(),JB?.onCaptureStarted.add(e=>Z.info(`Spector capture started:`,e)()),JB?.onCapture.add(e=>{Z.info(`Spector capture complete:`,e)(),JB?.getResultUI(),JB?.resultView.display(),JB?.resultView.addCapture(e)})),e.gl){let t=e.gl,n=UB(t),r=n.device;JB?.startCapture(e.gl,500),n.device=r,new Promise(e=>setTimeout(e,2e3)).then(e=>{Z.info(`Spector capture stopped after 2 seconds`)(),JB?.stopCapture()})}return JB}var qB,JB,YB,XB,ZB=o((()=>{nM(),HB(),WB(),qB=1,JB=null,YB=!1,XB={debugSpectorJS:Z.get(`debug-spectorjs`),debugSpectorJSUrl:`https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js`,gl:void 0}}));function QB(e){return e.luma=e.luma||{},e.luma}async function $B(){Yy()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await VB(oV))}function eV(e,t={}){return t.debugWebGL||t.traceWebGL?nV(e,t):tV(e)}function tV(e){let t=QB(e);return t.realContext?t.realContext:e}function nV(e,t){if(!globalThis.WebGLDebugUtils)return Z.warn(`webgl-debug not loaded`)(),e;let n=QB(e);if(n.debugContext)return n.debugContext;globalThis.WebGLDebugUtils.init({...jB,...e});let r=globalThis.WebGLDebugUtils.makeDebugContext(e,iV.bind(null,t),aV.bind(null,t));for(let e in jB)!(e in r)&&typeof jB[e]==`number`&&(r[e]=jB[e]);class i{}Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.setPrototypeOf(i,r);let a=Object.create(i);return n.realContext=e,n.debugContext=a,a.luma=n,a.debug=!0,a}function rV(e,t){t=Array.from(t).map(e=>e===void 0?`undefined`:e);let n=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return n=`${n.slice(0,100)}${n.length>100?`...`:``}`,`gl.${e}(${n})`}function iV(e,t,n,r){r=Array.from(r).map(e=>e===void 0?`undefined`:e);let i=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${n}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(n,r)})`;throw Z.error(`%cWebGL`,`color: white; background: red; padding: 2px 6px; border-radius: 3px;`,i)(),Error(i)}function aV(e,t,n){let r=``;e.traceWebGL&&Z.level>=1&&(r=rV(t,n),Z.info(1,`%cWebGL`,`color: white; background: blue; padding: 2px 6px; border-radius: 3px;`,r)());for(let e of n)e===void 0&&(r||=rV(t,n))}var oV,sV=o((()=>{nM(),NB(),$y(),HB(),oV=`https://unpkg.com/webgl-debug@2.0.1/index.js`})),cV,lV,uV,dV,fV=o((()=>{cV=`modulepreload`,lV=function(e){return`/`+e},uV={},dV=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=lV(t,n),t in uV)return;uV[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:cV,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})}}));function pV(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext?!0:!!(e&&typeof e.createVertexArray==`function`)}var mV,hV,gV,_V=o((()=>{nM(),BB(),ZB(),sV(),fV(),mV=1,hV=class extends dA{type=`webgl`;constructor(){super(),aA.defaultProps={...aA.defaultProps,...XB}}enforceWebGL2(e){PB(e)}isSupported(){return typeof WebGL2RenderingContext<`u`}isDeviceHandle(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<`u`&&e instanceof WebGLRenderingContext&&Z.warn(`WebGL1 is not supported`,e)(),!1)}async attach(e,t={}){let{WebGLDevice:n}=await dV(async()=>{let{WebGLDevice:e}=await Promise.resolve().then(()=>(xW(),yW));return{WebGLDevice:e}},void 0);if(e instanceof n)return e;let r=n.getDeviceFromContext(e);if(r)return r;if(!pV(e))throw Error(`Invalid WebGL2RenderingContext`);let i=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...i}})}async create(e={}){let{WebGLDevice:t}=await dV(async()=>{let{WebGLDevice:e}=await Promise.resolve().then(()=>(xW(),yW));return{WebGLDevice:e}},void 0),n=[];(e.debugWebGL||e.debug)&&n.push($B()),e.debugSpectorJS&&n.push(GB(e));let r=await Promise.allSettled(n);for(let e of r)e.status===`rejected`&&Z.error(`Failed to initialize debug libraries ${e.reason}`)();try{let n=new t(e);Z.groupCollapsed(mV,`WebGLDevice ${n.id} created`)();let r=`\
|
||
${n._reused?`Reusing`:`Created`} device with WebGL2 ${n.props.debug?`debug `:``}context: \
|
||
${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return Z.probe(mV,r)(),Z.table(mV,n.info)(),n}finally{Z.groupEnd(mV)(),Z.info(mV,`%cWebGL call tracing: luma.log.set('debug-webgl') `,`color: white; background: blue; padding: 2px 6px; border-radius: 3px;`)()}}},gV=new hV}));function vV(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function yV(e,t,n){return t[e]===void 0?n[e]:t[e]}var bV,xV,SV,CV,wV,TV,EV,DV,OV,kV,AV,jV,MV=o((()=>{bV={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},xV=(e,t,n)=>t?e.enable(n):e.disable(n),SV=(e,t,n)=>e.hint(n,t),CV=(e,t,n)=>e.pixelStorei(n,t),wV=(e,t,n)=>{let r=n===36006?36009:36008;return e.bindFramebuffer(r,t)},TV=(e,t,n)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[n];e.bindBuffer(r,t)},EV={3042:xV,32773:(e,t)=>e.blendColor(...t),32777:`blendEquation`,34877:`blendEquation`,32969:`blendFunc`,32968:`blendFunc`,32971:`blendFunc`,32970:`blendFunc`,3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:xV,2885:(e,t)=>e.cullFace(t),2929:xV,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:xV,35723:SV,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:wV,36010:wV,34964:TV,36662:TV,36663:TV,35053:TV,35055:TV,2886:(e,t)=>e.frontFace(t),33170:SV,2849:(e,t)=>e.lineWidth(t),32823:xV,32824:`polygonOffset`,10752:`polygonOffset`,35977:xV,32926:xV,32928:xV,32938:`sampleCoverage`,32939:`sampleCoverage`,3089:xV,3088:(e,t)=>e.scissor(...t),2960:xV,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:`stencilFuncFront`,2967:`stencilFuncFront`,2963:`stencilFuncFront`,34816:`stencilFuncBack`,36003:`stencilFuncBack`,36004:`stencilFuncBack`,2964:`stencilOpFront`,2965:`stencilOpFront`,2966:`stencilOpFront`,34817:`stencilOpBack`,34818:`stencilOpBack`,34819:`stencilOpBack`,2978:(e,t)=>e.viewport(...t),34383:xV,10754:xV,12288:xV,12289:xV,12290:xV,12291:xV,12292:xV,12293:xV,12294:xV,12295:xV,3333:CV,3317:CV,37440:CV,37441:CV,37443:CV,3330:CV,3332:CV,3331:CV,3314:CV,32878:CV,3316:CV,3315:CV,32877:CV,framebuffer:(e,t)=>{let n=t&&`handle`in t?t.handle:t;return e.bindFramebuffer(36160,n)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let n=typeof t==`number`?[t,t]:t;e.blendEquationSeparate(...n)},blendFunc:(e,t)=>{let n=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...n)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=vV(t)?t:[t,t];let[n,r]=t;e.stencilMaskSeparate(1028,n),e.stencilMaskSeparate(1029,r)},stencilFunc:(e,t)=>{t=vV(t)&&t.length===3?[...t,...t]:t;let[n,r,i,a,o,s]=t;e.stencilFuncSeparate(1028,n,r,i),e.stencilFuncSeparate(1029,a,o,s)},stencilOp:(e,t)=>{t=vV(t)&&t.length===3?[...t,...t]:t;let[n,r,i,a,o,s]=t;e.stencilOpSeparate(1028,n,r,i),e.stencilOpSeparate(1029,a,o,s)},viewport:(e,t)=>e.viewport(...t)},DV={blendEquation:(e,t,n)=>e.blendEquationSeparate(yV(32777,t,n),yV(34877,t,n)),blendFunc:(e,t,n)=>e.blendFuncSeparate(yV(32969,t,n),yV(32968,t,n),yV(32971,t,n),yV(32970,t,n)),polygonOffset:(e,t,n)=>e.polygonOffset(yV(32824,t,n),yV(10752,t,n)),sampleCoverage:(e,t,n)=>e.sampleCoverage(yV(32938,t,n),yV(32939,t,n)),stencilFuncFront:(e,t,n)=>e.stencilFuncSeparate(1028,yV(2962,t,n),yV(2967,t,n),yV(2963,t,n)),stencilFuncBack:(e,t,n)=>e.stencilFuncSeparate(1029,yV(34816,t,n),yV(36003,t,n),yV(36004,t,n)),stencilOpFront:(e,t,n)=>e.stencilOpSeparate(1028,yV(2964,t,n),yV(2965,t,n),yV(2966,t,n)),stencilOpBack:(e,t,n)=>e.stencilOpSeparate(1029,yV(34817,t,n),yV(34818,t,n),yV(34819,t,n))},OV={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,n)=>e({[t]:n}),hint:(e,t,n)=>e({[t]:n}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,n)=>e({36007:n}),bindTransformFeedback:(e,t,n)=>e({36389:n}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,n)=>{switch(t){case 36160:return e({36006:n,36010:n});case 36009:return e({36006:n});case 36008:return e({36010:n});default:return null}},bindBuffer:(e,t,n)=>{let r={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return r?e({[r]:n}):{valueChanged:!0}},blendColor:(e,t,n,r,i)=>e({32773:new Float32Array([t,n,r,i])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,n)=>e({32777:t,34877:n}),blendFunc:(e,t,n)=>e({32969:t,32968:n,32971:t,32970:n}),blendFuncSeparate:(e,t,n,r,i)=>e({32969:t,32968:n,32971:r,32970:i}),clearColor:(e,t,n,r,i)=>e({3106:new Float32Array([t,n,r,i])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,n,r,i)=>e({3107:[t,n,r,i]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,n)=>e({2928:new Float32Array([t,n])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,n)=>e({32824:t,10752:n}),sampleCoverage:(e,t,n)=>e({32938:t,32939:n}),scissor:(e,t,n,r,i)=>e({3088:new Int32Array([t,n,r,i])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,n)=>e({[t===1028?2968:36005]:n}),stencilFunc:(e,t,n,r)=>e({2962:t,2967:n,2963:r,34816:t,36003:n,36004:r}),stencilFuncSeparate:(e,t,n,r,i)=>e({[t===1028?2962:34816]:n,[t===1028?2967:36003]:r,[t===1028?2963:36004]:i}),stencilOp:(e,t,n,r)=>e({2964:t,2965:n,2966:r,34817:t,34818:n,34819:r}),stencilOpSeparate:(e,t,n,r,i)=>e({[t===1028?2964:34817]:n,[t===1028?2965:34818]:r,[t===1028?2966:34819]:i}),viewport:(e,t,n,r,i)=>e({2978:[t,n,r,i]})},kV=(e,t)=>e.isEnabled(t),AV={3042:kV,2884:kV,2929:kV,3024:kV,32823:kV,32926:kV,32928:kV,3089:kV,2960:kV,35977:kV},jV=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])}));function NV(e,t){if(IV(t))return;let n={};for(let r in t){let i=Number(r),a=EV[r];a&&(typeof a==`string`?n[a]=!0:a(e,t[r],i))}let r=e.lumaState?.cache;if(r)for(let i in n){let n=DV[i];n(e,t,r)}}function PV(e,t=bV){if(typeof t==`number`){let n=t,r=AV[n];return r?r(e,n):e.getParameter(n)}let n=Array.isArray(t)?t:Object.keys(t),r={};for(let t of n){let n=AV[t];r[t]=n?n(e,Number(t)):e.getParameter(Number(t))}return r}function FV(e){NV(e,bV)}function IV(e){for(let t in e)return!1;return!0}var LV=o((()=>{MV()}));function RV(e,t){if(e===t)return!0;if(zV(e)&&zV(t)&&e.length===t.length){for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}function zV(e){return Array.isArray(e)||ArrayBuffer.isView(e)}var BV=o((()=>{}));function VV(e,t){let n=e[t].bind(e);e[t]=function(t){if(t===void 0||jV.has(t))return n(t);let r=WV.get(e);return t in r.cache||(r.cache[t]=n(t)),r.enable?r.cache[t]:n(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function HV(e,t,n){if(!e[t])return;let r=e[t].bind(e);e[t]=function(...t){let{valueChanged:i,oldValue:a}=n(WV.get(e)._updateCache,...t);return i&&r(...t),a},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function UV(e){let t=e.useProgram.bind(e);e.useProgram=function(n){let r=WV.get(e);r.program!==n&&(t(n),r.program=n)}}var WV,GV=o((()=>{LV(),BV(),MV(),WV=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];NV(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?PV(e):Object.assign({},bV),this.initialized)throw Error(`WebGLStateTracker`);this.initialized=!0,this.gl.lumaState=this,UV(e);for(let t in OV){let n=OV[t];HV(e,t,n)}VV(e,`getParameter`),VV(e,`isEnabled`)}_updateCache(e){let t=!1,n,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let i in e){let a=e[i],o=this.cache[i];RV(a,o)||(t=!0,n=o,r&&!(i in r)&&(r[i]=o),this.cache[i]=a)}return{valueChanged:t,oldValue:n}}}}));function KV(e,t,n){let r=``,i=e=>{let t=e.statusMessage;t&&(r||=t)};e.addEventListener(`webglcontextcreationerror`,i,!1);let a=n.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...n,failIfMajorPerformanceCaveat:!0},s=null;try{s||=e.getContext(`webgl2`,o),!s&&o.failIfMajorPerformanceCaveat&&(r||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let n=!1;if(!s&&a&&(o.failIfMajorPerformanceCaveat=!1,s=e.getContext(`webgl2`,o),n=!0),s||(s=e.getContext(`webgl`,{}),s&&(s=null,r||=`Your browser only supports WebGL1`)),!s)throw r||=`Your browser does not support WebGL`,Error(`Failed to create WebGL context: ${r}`);let i=UB(s);i.softwareRenderer=n;let{onContextLost:c,onContextRestored:l}=t;return e.addEventListener(`webglcontextlost`,e=>c(e),!1),e.addEventListener(`webglcontextrestored`,e=>l(e),!1),s}finally{e.removeEventListener(`webglcontextcreationerror`,i,!1)}}var qV=o((()=>{WB()}));function JV(e,t,n){return n[t]===void 0&&(n[t]=e.getExtension(t)||null),n[t]}var YV=o((()=>{}));function XV(e,t){let n=e.getParameter(7936),r=e.getParameter(7937);JV(e,`WEBGL_debug_renderer_info`,t);let i=t.WEBGL_debug_renderer_info,a=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),s=a||n,c=o||r,l=e.getParameter(7938),u=ZV(s,c),d=QV(s,c);return{type:`webgl`,gpu:u,gpuType:$V(s,c),gpuBackend:d,vendor:s,renderer:c,version:l,shadingLanguage:`glsl`,shadingLanguageVersion:300}}function ZV(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?`nvidia`:/INTEL/i.exec(e)||/INTEL/i.exec(t)?`intel`:/Apple/i.exec(e)||/Apple/i.exec(t)?`apple`:/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?`amd`:/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?`software`:`unknown`}function QV(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?`metal`:/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?`opengl`:`unknown`}function $V(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return`cpu`;switch(ZV(e,t)){case`apple`:return eH(e,t)?`integrated`:`unknown`;case`intel`:return`integrated`;case`software`:return`cpu`;case`unknown`:return`unknown`;default:return`discrete`}}function eH(e,t){return/Apple (M\d|A\d|GPU)/i.test(`${e} ${t}`)}var tH=o((()=>{YV()}));function nH(e){switch(e){case`uint8`:return 5121;case`sint8`:return 5120;case`unorm8`:return 5121;case`snorm8`:return 5120;case`uint16`:return 5123;case`sint16`:return 5122;case`unorm16`:return 5123;case`snorm16`:return 5122;case`uint32`:return 5125;case`sint32`:return 5124;case`float16`:return 5131;case`float32`:return 5126}throw Error(String(e))}var rH=o((()=>{}));function iH(e){return e in jH}function aH(e,t,n){return oH(e,t,n,new Set)}function oH(e,t,n,r){let i=jH[t];if(!i||r.has(t))return!1;r.add(t);let a=(i.features||[]).every(t=>oH(e,t,n,r));return r.delete(t),a?(i.extensions||[]).every(t=>!!JV(e,t,n)):!1}function sH(e,t,n){let r=t.create,i=MH[t.format];i?.gl===void 0&&(r=!1),i?.x&&(r&&=!!JV(e,i.x,n)),t.format===`stencil8`&&(r=!1);let a=i?.r===!1?!1:i?.r===void 0||aH(e,i.r,n),o=r&&t.render&&a&&cH(e,t.format,n);return{format:t.format,create:r&&t.create,render:o,filter:r&&t.filter,blend:r&&t.blend,store:r&&t.store}}function cH(e,t,n){let r=MH[t],i=r?.gl;if(i===void 0||r?.x&&!JV(e,r.x,n))return!1;let a=e.getParameter(32873),o=e.getParameter(36006),s=e.createTexture(),c=e.createFramebuffer();if(!s||!c)return!1;let l=Number(e.getError());for(;l!==0;)l=e.getError();let u=!1;try{if(e.bindTexture(3553,s),e.texStorage2D(3553,1,i,1,1),Number(e.getError())!==0)return!1;e.bindFramebuffer(36160,c),e.framebufferTexture2D(36160,36064,3553,s,0),u=Number(e.checkFramebufferStatus(36160))===36053&&Number(e.getError())===0}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(c),e.bindTexture(3553,a),e.deleteTexture(s)}return u}function lH(e){let t=MH[e],n=fH(e),r=Zk.getInfo(e);return r.compressed&&(t.dataFormat=n),{internalFormat:n,format:t?.dataFormat||dH(r.channels,r.integer,r.normalized,n),type:r.dataType?nH(r.dataType):t?.types?.[0]||5121,compressed:r.compressed||!1}}function uH(e){switch(Zk.getInfo(e).attachment){case`depth`:return 36096;case`stencil`:return 36128;case`depth-stencil`:return 33306;default:throw Error(`Not a depth stencil format: ${e}`)}}function dH(e,t,n,r){if(r===6408||r===6407)return r;switch(e){case`r`:return t&&!n?36244:6403;case`rg`:return t&&!n?33320:33319;case`rgb`:return t&&!n?36248:6407;case`rgba`:return t&&!n?36249:6408;case`bgra`:throw Error(`bgra pixels not supported by WebGL`);default:return 6408}}function fH(e){let t=MH[e]?.gl;if(t===void 0)throw Error(`Unsupported texture format ${e}`);return t}var pH,mH,hH,gH,_H,vH,yH,bH,xH,SH,CH,wH,TH,EH,DH,OH,kH,AH,jH,MH,NH=o((()=>{nM(),YV(),rH(),pH=`WEBGL_compressed_texture_s3tc`,mH=`WEBGL_compressed_texture_s3tc_srgb`,hH=`EXT_texture_compression_rgtc`,gH=`EXT_texture_compression_bptc`,_H=`WEBGL_compressed_texture_etc`,vH=`WEBGL_compressed_texture_astc`,yH=`WEBGL_compressed_texture_etc1`,bH=`WEBGL_compressed_texture_pvrtc`,xH=`WEBGL_compressed_texture_atc`,SH=`EXT_texture_norm16`,CH=`EXT_render_snorm`,wH=`EXT_color_buffer_float`,TH=`snorm8-renderable-webgl`,EH=`norm16-renderable-webgl`,DH=`snorm16-renderable-webgl`,OH=`float16-renderable-webgl`,kH=`float32-renderable-webgl`,AH=`rgb9e5ufloat-renderable-webgl`,jH={"float32-renderable-webgl":{extensions:[wH]},"float16-renderable-webgl":{extensions:[`EXT_color_buffer_half_float`]},"rgb9e5ufloat-renderable-webgl":{extensions:[`WEBGL_render_shared_exponent`]},"snorm8-renderable-webgl":{extensions:[CH]},"norm16-webgl":{extensions:[SH]},"norm16-renderable-webgl":{features:[`norm16-webgl`]},"snorm16-renderable-webgl":{features:[`norm16-webgl`],extensions:[CH]},"float32-filterable":{extensions:[`OES_texture_float_linear`]},"float16-filterable-webgl":{extensions:[`OES_texture_half_float_linear`]},"texture-filterable-anisotropic-webgl":{extensions:[`EXT_texture_filter_anisotropic`]},"texture-blend-float-webgl":{extensions:[`EXT_float_blend`]},"texture-compression-bc":{extensions:[pH,mH,hH,gH]},"texture-compression-bc5-webgl":{extensions:[hH]},"texture-compression-bc7-webgl":{extensions:[gH]},"texture-compression-etc2":{extensions:[_H]},"texture-compression-astc":{extensions:[vH]},"texture-compression-etc1-webgl":{extensions:[yH]},"texture-compression-pvrtc-webgl":{extensions:[bH]},"texture-compression-atc-webgl":{extensions:[xH]}},MH={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:TH},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:TH},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:OH},r16unorm:{gl:33322,rb:!0,r:EH},r16snorm:{gl:36760,r:DH},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:TH},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:OH},rg16unorm:{gl:33324,r:EH},rg16snorm:{gl:36761,r:DH},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:kH},rgb9e5ufloat:{gl:35901,r:AH},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:kH},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:OH},rgba16unorm:{gl:32859,rb:!0,r:EH},rgba16snorm:{gl:36763,r:DH},"rgb32float-webgl":{gl:34837,x:wH,r:kH,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:kH},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:pH},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:mH},"bc1-rgba-unorm":{gl:33777,x:pH},"bc1-rgba-unorm-srgb":{gl:35916,x:mH},"bc2-rgba-unorm":{gl:33778,x:pH},"bc2-rgba-unorm-srgb":{gl:35918,x:mH},"bc3-rgba-unorm":{gl:33779,x:pH},"bc3-rgba-unorm-srgb":{gl:35919,x:mH},"bc4-r-unorm":{gl:36283,x:hH},"bc4-r-snorm":{gl:36284,x:hH},"bc5-rg-unorm":{gl:36285,x:hH},"bc5-rg-snorm":{gl:36286,x:hH},"bc6h-rgb-ufloat":{gl:36495,x:gH},"bc6h-rgb-float":{gl:36494,x:gH},"bc7-rgba-unorm":{gl:36492,x:gH},"bc7-rgba-unorm-srgb":{gl:36493,x:gH},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}})),PH,FH,IH=o((()=>{nM(),YV(),NH(),PH={"depth-clip-control":`EXT_depth_clamp`,"timestamp-query":`EXT_disjoint_timer_query_webgl2`,"compilation-status-async-webgl":`KHR_parallel_shader_compile`,"polygon-mode-webgl":`WEBGL_polygon_mode`,"provoking-vertex-webgl":`WEBGL_provoking_vertex`,"shader-clip-cull-distance-webgl":`WEBGL_clip_cull_distance`,"shader-noperspective-interpolation-webgl":`NV_shader_noperspective_interpolation`,"shader-conservative-depth-webgl":`EXT_conservative_depth`},FH=class extends iA{gl;extensions;testedFeatures=new Set;constructor(e,t,n){super([],n),this.gl=e,this.extensions=t,JV(e,`EXT_color_buffer_float`,t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),iH(e)&&aH(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(e=>e!==`polygon-mode-webgl`);for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(PH),...Object.keys(jH)]}getWebGLFeature(e){let t=PH[e];return typeof t==`string`?!!JV(this.gl,t,this.extensions):!!t}}})),LH,RH=o((()=>{nM(),LH=class extends rA{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}}));function zH(e){return e<34069?e+34069:e}function BH(e){switch(e){case 36053:return`success`;case 36054:return`Mismatched attachments`;case 36055:return`No attachments`;case 36057:return`Height/width mismatch`;case 36061:return`Unsupported or split attachments`;case 36182:return`Samples mismatch`;default:return`${e}`}}var VH,HH=o((()=>{nM(),NH(),VH=class extends FA{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let n=t.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;e<this.colorAttachments.length;++e){let t=this.colorAttachments[e];if(t){let n=36064+e;this._attachTextureView(n,t)}}if(this.depthStencilAttachment){let e=uH(this.depthStencilAttachment.props.format);this._attachTextureView(e,this.depthStencilAttachment)}if(this.device.props.debug){let e=this.gl.checkFramebufferStatus(36160);if(e!==36053)throw Error(`Framebuffer ${BH(e)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){let{gl:n}=this.device,{texture:r}=t,i=t.props.baseMipLevel,a=t.props.baseArrayLayer;switch(n.bindTexture(r.glTarget,r.handle),r.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,r.handle,i,a);break;case 34067:let t=zH(a);n.framebufferTexture2D(36160,e,t,r.handle,i);break;case 3553:n.framebufferTexture2D(36160,e,3553,r.handle,i);break;default:throw Error(`Illegal texture type`)}n.bindTexture(r.glTarget,null)}resizeAttachments(e,t){if(this.handle===null){this.width=e,this.height=t;return}super.resizeAttachments(e,t)}}})),UH,WH=o((()=>{nM(),HH(),UH=class extends CA{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return`WebGLCanvasContext`}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new VH(this.device,{id:`canvas-context-framebuffer`,handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}})),GH,KH=o((()=>{nM(),GH=class extends wA{device;handle=null;context2d;get[Symbol.toStringTag](){return`WebGLPresentationContext`}constructor(e,t={}){super(t),this.device=e;let n=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw Error(`${n}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let r=this.canvas.getContext(`2d`);if(!r)throw Error(`${n}: Failed to create 2d presentation context`);this.context2d=r,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,n]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||n===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||n!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${n} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}}));function qH(e=`id`){return JH[e]=JH[e]||1,`${e}-${JH[e]++}`}var JH,YH=o((()=>{JH={}}));function XH(e){return e&uk.INDEX?34963:e&uk.VERTEX?34962:e&uk.UNIFORM?35345:34962}function ZH(e){return e&uk.INDEX||e&uk.VERTEX?35044:e&uk.UNIFORM?35048:35044}var QH,$H=o((()=>{nM(),QH=class extends uk{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let n=typeof t==`object`?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=XH(this.props.usage),this.glUsage=ZH(this.props.usage),this.glIndexType=this.props.indexType===`uint32`?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory(`Buffer`):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,n=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.props.handle?this.trackReferencedMemory(n,`Buffer`):this.trackAllocatedMemory(n)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array);let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,`Buffer`):this.trackAllocatedMemory(e),this}write(e,t=0){let n=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=36663;this.gl.bindBuffer(r,this.handle),this.gl.bufferSubData(r,t,n),this.gl.bindBuffer(r,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){let r=new ArrayBuffer(n);await e(r,`copied`),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,n){return await e((await this.readAsync(t,n)).buffer,`copied`)}readSyncWebGL(e=0,t){t??=this.byteLength-e;let n=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,t),n}}}));function eU(e){let t=e.split(/\r?\n/),n=[];for(let e of t){if(e.length<=1)continue;let t=e.trim(),r=e.split(`:`),i=r[0]?.trim();if(r.length===2){let[e,a]=r;if(!e||!a){n.push({message:t,type:tU(i||`info`),lineNum:0,linePos:0});continue}n.push({message:a.trim(),type:tU(e),lineNum:0,linePos:0});continue}let[a,o,s,...c]=r;if(!a||!o||!s){n.push({message:r.slice(1).join(`:`).trim()||t,type:tU(i||`info`),lineNum:0,linePos:0});continue}let l=parseInt(s,10);Number.isNaN(l)&&(l=0);let u=parseInt(o,10);Number.isNaN(u)&&(u=0),n.push({message:c.join(`:`).trim(),type:tU(a),lineNum:l,linePos:u})}return n}function tU(e){let t=[`warning`,`error`,`info`],n=e.toLowerCase();return t.includes(n)?n:`info`}var nU=o((()=>{})),rU,iU=o((()=>{nM(),nU(),rU=class extends NA{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case`vertex`:this.handle=this.props.handle||this.device.gl.createShader(35633);break;case`fragment`:this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let n=this._compile(this.source);n&&typeof n.catch==`function`&&n.catch(()=>{this.compilationStatus=`error`})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?eU(e):[]}getTranslatedSource(){return this.device.getExtension(`WEBGL_debug_shaders`).WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith(`#version `)?e:`#version 300 es\n${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus=`pending`;return}if(!this.device.features.has(`compilation-status-async-webgl`)){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus===`error`)throw Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return Z.once(1,`Shader compilation is asynchronous`)(),this._waitForCompilationComplete().then(()=>{Z.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has(`compilation-status-async-webgl`)){await e(10);return}let{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?`success`:`error`}}}));function aU(e,t,n,r){if(mU(t))return r(e);let i=e;i.pushState();try{return oU(e,t),NV(i.gl,n),r(e)}finally{i.popState()}}function oU(e,t){let n=e,{gl:r}=n;if(t.cullMode)switch(t.cullMode){case`none`:r.disable(2884);break;case`front`:r.enable(2884),r.cullFace(1028);break;case`back`:r.enable(2884),r.cullFace(1029);break}if(t.frontFace&&r.frontFace(fU(`frontFace`,t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has(`depth-clip-control`)&&r.enable(34383),t.depthBias!==void 0&&(r.enable(32823),r.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has(`provoking-vertex-webgl`)){let e=n.getExtension(`WEBGL_provoking_vertex`).WEBGL_provoking_vertex,r=fU(`provokingVertex`,t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(r)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has(`polygon-mode-webgl`)){if(t.polygonMode){let e=n.getExtension(`WEBGL_polygon_mode`).WEBGL_polygon_mode,r=fU(`polygonMode`,t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,r),e?.polygonModeWEBGL(1029,r)}t.polygonOffsetLine&&r.enable(10754)}if(e.features.has(`shader-clip-cull-distance-webgl`)&&(t.clipDistance0&&r.enable(12288),t.clipDistance1&&r.enable(12289),t.clipDistance2&&r.enable(12290),t.clipDistance3&&r.enable(12291),t.clipDistance4&&r.enable(12292),t.clipDistance5&&r.enable(12293),t.clipDistance6&&r.enable(12294),t.clipDistance7&&r.enable(12295)),t.depthWriteEnabled!==void 0&&r.depthMask(pU(`depthWriteEnabled`,t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare===`always`?r.disable(2929):r.enable(2929),r.depthFunc(sU(`depthCompare`,t.depthCompare))),t.clearDepth!==void 0&&r.clearDepth(t.clearDepth),t.stencilWriteMask){let e=t.stencilWriteMask;r.stencilMaskSeparate(1028,e),r.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&Z.warn(`stencilReadMask not supported under WebGL`),t.stencilCompare){let e=t.stencilReadMask||4294967295,n=sU(`depthCompare`,t.stencilCompare);t.stencilCompare===`always`?r.disable(2960):r.enable(2960),r.stencilFuncSeparate(1028,n,0,e),r.stencilFuncSeparate(1029,n,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let e=cU(`stencilPassOperation`,t.stencilPassOperation),n=cU(`stencilFailOperation`,t.stencilFailOperation),i=cU(`stencilDepthFailOperation`,t.stencilDepthFailOperation);r.stencilOpSeparate(1028,n,i,e),r.stencilOpSeparate(1029,n,i,e)}switch(t.blend){case!0:r.enable(3042);break;case!1:r.disable(3042);break;default:}if(t.blendColorOperation||t.blendAlphaOperation){let e=lU(`blendColorOperation`,t.blendColorOperation||`add`),n=lU(`blendAlphaOperation`,t.blendAlphaOperation||`add`);r.blendEquationSeparate(e,n);let i=uU(`blendColorSrcFactor`,t.blendColorSrcFactor||`one`),a=uU(`blendColorDstFactor`,t.blendColorDstFactor||`zero`),o=uU(`blendAlphaSrcFactor`,t.blendAlphaSrcFactor||`one`),s=uU(`blendAlphaDstFactor`,t.blendAlphaDstFactor||`zero`);r.blendFuncSeparate(i,a,o,s)}}function sU(e,t){return fU(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function cU(e,t){return fU(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function lU(e,t){return fU(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function uU(e,t,n=`color`){return fU(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:n===`color`?32769:32771,"one-minus-constant":n===`color`?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function dU(e,t){return`Illegal parameter ${t} for ${e}`}function fU(e,t,n){if(!(t in n))throw Error(dU(e,t));return n[t]}function pU(e,t){return t}function mU(e){let t=!0;for(let n in e){t=!1;break}return t}var hU=o((()=>{nM(),LV()}));function gU(e){let t={};return e.addressModeU&&(t[10242]=_U(e.addressModeU)),e.addressModeV&&(t[10243]=_U(e.addressModeV)),e.addressModeW&&(t[32882]=_U(e.addressModeW)),e.magFilter&&(t[10240]=vU(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=yU(e.minFilter||`linear`,e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type===`comparison-sampler`&&(t[34892]=34894),e.compare&&(t[34893]=sU(`compare`,e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function _U(e){switch(e){case`clamp-to-edge`:return 33071;case`repeat`:return 10497;case`mirror-repeat`:return 33648}}function vU(e){switch(e){case`nearest`:return 9728;case`linear`:return 9729}}function yU(e,t=`none`){if(!t)return vU(e);switch(t){case`none`:return vU(e);case`nearest`:switch(e){case`nearest`:return 9984;case`linear`:return 9985}break;case`linear`:switch(e){case`nearest`:return 9986;case`linear`:return 9987}}}var bU=o((()=>{hU()})),xU,SU=o((()=>{nM(),bU(),xU=class extends TA{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=gU(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&=(this.device.gl.deleteSampler(this.handle),void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,n]of Object.entries(e)){let e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,n);break;default:this.device.gl.samplerParameteri(this.handle,e,n);break}}}}}));function CU(e,t,n){if(wU(t))return n(e);let{nocatch:r=!0}=t,i=WV.get(e);i.push(),NV(e,t);let a;if(r)a=n(e),i.pop();else try{a=n(e)}finally{i.pop()}return a}function wU(e){for(let t in e)return!1;return!0}var TU=o((()=>{LV(),GV()})),EU,DU=o((()=>{nM(),EU=class extends AA{device;gl;handle;texture;constructor(e,t){super(e,{...OA.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}}));function OU(e){return kU[e]}var kU,AU=o((()=>{kU={5124:`sint32`,5125:`uint32`,5122:`sint16`,5123:`uint16`,5120:`sint8`,5121:`uint8`,5126:`float32`,5131:`float16`,33635:`uint16`,32819:`uint16`,32820:`uint16`,33640:`uint32`,35899:`uint32`,35902:`uint32`,34042:`uint32`,36269:`uint32`}}));function jU(e,t=0){return t?new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT):e}function MU(e,t){if(t%e.BYTES_PER_ELEMENT!==0)throw Error(`Texture byteOffset ${t} must align to typed array element size ${e.BYTES_PER_ELEMENT}`);return t/e.BYTES_PER_ELEMENT}function NU(e){switch(e){case`1d`:break;case`2d`:return 3553;case`3d`:return 32879;case`cube`:return 34067;case`2d-array`:return 35866;case`cube-array`:break}throw Error(e)}function PU(e,t,n){return t===`cube`?34069+n:e}var FU,IU=o((()=>{nM(),NH(),bU(),TU(),DU(),AU(),FU=class extends OA{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let n=lH(this.props.format);this.glTarget=NU(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:i,height:a,depth:o,mipLevels:s,glTarget:c,glInternalFormat:l}=this;if(!this.compressed)switch(r){case`2d`:case`cube`:this.gl.texStorage2D(c,s,l,i,a);break;case`2d-array`:case`3d`:this.gl.texStorage3D(c,s,l,i,a,o);break;default:throw Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),`Texture`):this.trackAllocatedMemory(this.getAllocatedByteLength(),`Texture`),this.setSampler(this.props.sampler),this.view=new EU(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory(`Texture`):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory(`Texture`)),this.destroyed=!0)}createView(e){return new EU(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let t=gU(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw Error(`WebGL does not support sourceX/sourceY)`);let{glFormat:n,glType:r}=this,{image:i,depth:a,mipLevel:o,x:s,y:c,z:l,width:u,height:d}=t,f=PU(this.glTarget,this.dimension,l),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),CU(this.gl,p,()=>{switch(this.dimension){case`2d`:case`cube`:this.gl.texSubImage2D(f,o,s,c,u,d,n,r,i);break;case`2d-array`:case`3d`:this.gl.texSubImage3D(f,o,s,c,l,u,d,a,n,r,i);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw Error(`${this} readBuffer requires a destination buffer`);let n=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,i=this.computeMemoryLayout(n);if(t.byteLength<r+i.byteLength)throw Error(`${this} readBuffer target is too small (${t.byteLength} < ${r+i.byteLength})`);let a=t;this.gl.bindBuffer(35051,a.handle);try{this._readColorTextureLayers(n,i,e=>{this.gl.readPixels(n.x,n.y,n.width,n.height,this.glFormat,this.glType,r+e)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){let n=this._normalizeTextureWriteOptions(t),{width:r,height:i,depthOrArrayLayers:a,mipLevel:o,byteOffset:s,x:c,y:l,z:u}=n,{glFormat:d,glType:f,compressed:p}=this,m=PU(this.glTarget,this.dimension,u);if(p)throw Error(`writeBuffer for compressed textures is not implemented in WebGL`);let{bytesPerPixel:h}=this.device.getTextureFormatInfo(this.format),g=h?n.bytesPerRow/h:void 0,_={3317:this.byteAlignment,...g===void 0?{}:{3314:g},32878:n.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),CU(this.gl,_,()=>{switch(this.dimension){case`2d`:case`cube`:this.gl.texSubImage2D(m,o,c,l,r,i,d,f,s);break;case`2d-array`:case`3d`:this.gl.texSubImage3D(m,o,c,l,u,r,i,a,d,f,s);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){let n=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:i,height:a,depthOrArrayLayers:o,mipLevel:s,x:c,y:l,z:u,byteOffset:d}=n,{glFormat:f,glType:p,compressed:m}=this,h=PU(this.glTarget,this.dimension,u),g;if(!m){let{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);e&&(g=n.bytesPerRow/e)}let _=this.compressed?{}:{3317:this.byteAlignment,...g===void 0?{}:{3314:g},32878:n.rowsPerImage},v=MU(r,d),y=m?jU(r,d):r,b=this._getMipLevelSize(s),x=c===0&&l===0&&u===0&&i===b.width&&a===b.height&&o===b.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),CU(this.gl,_,()=>{switch(this.dimension){case`2d`:case`cube`:m?x?this.gl.compressedTexImage2D(h,s,f,i,a,0,y):this.gl.compressedTexSubImage2D(h,s,c,l,i,a,f,y):this.gl.texSubImage2D(h,s,c,l,i,a,f,p,r,v);break;case`2d-array`:case`3d`:m?x?this.gl.compressedTexImage3D(h,s,f,i,a,o,0,y):this.gl.compressedTexSubImage3D(h,s,c,l,u,i,a,o,f,y):this.gl.texSubImage3D(h,s,c,l,u,i,a,o,f,p,r,v);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),n=this.computeMemoryLayout(t),r=Sj(OU(this.glType)),i=new r(n.byteLength/r.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,n,e=>{let a=new r(i.buffer,i.byteOffset+e,n.bytesPerImage/r.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,a)}),i.buffer}_readColorTextureLayers(e,t,n){let r=this._getFramebuffer(),i=t.bytesPerRow/t.bytesPerPixel,a={3333:this.byteAlignment,...i===e.width?{}:{3330:i}},o=this.gl.getParameter(3074),s=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),CU(this.gl,a,()=>{for(let i=0;i<e.depthOrArrayLayers;i++)this._attachReadSubresource(r,e.mipLevel,e.z+i),n(i*t.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,s||null),this.gl.readBuffer(o)}}_attachReadSubresource(e,t,n){let r=`${t}:${n}`;if(this._framebufferAttachmentKey!==r){switch(this.dimension){case`2d`:this.gl.framebufferTexture2D(36160,36064,3553,this.handle,t);break;case`cube`:this.gl.framebufferTexture2D(36160,36064,PU(this.glTarget,this.dimension,n),this.handle,t);break;case`2d-array`:case`3d`:this.gl.framebufferTextureLayer(36160,36064,this.handle,t,n);break;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let t=Number(this.gl.checkFramebufferStatus(36160));if(t!==36053)throw Error(`${e} incomplete for ${this} readback (${t})`)}this._framebufferAttachmentKey=r}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(Z.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!e?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(e){Z.warn(`Error generating mipmap for ${this}: ${e.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){Z.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,n]of Object.entries(e)){let e=Number(t),r=n;switch(e){case 33082:case 33083:this.gl.texParameterf(this.glTarget,e,r);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,e,r);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,e,r);break;case 34046:this.device.features.has(`texture-filterable-anisotropic-webgl`)&&this.gl.texParameteri(this.glTarget,e,r);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,r);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}}}));function LU(e,t,n,r){let i=e,a=r;a===!0&&(a=1),a===!1&&(a=0);let o=typeof a==`number`?[a]:a;switch(n){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof r!=`number`)throw Error(`samplers must be set to integers`);return e.uniform1i(t,r);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:return e.uniform1iv(t,o);case 35667:return e.uniform2iv(t,o);case 35668:return e.uniform3iv(t,o);case 35669:return e.uniform4iv(t,o);case 35670:return e.uniform1iv(t,o);case 35671:return e.uniform2iv(t,o);case 35672:return e.uniform3iv(t,o);case 35673:return e.uniform4iv(t,o);case 5125:return i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw Error(`Illegal uniform`)}var RU=o((()=>{}));function zU(e){switch(e){case`point-list`:return 0;case`line-list`:return 1;case`line-strip`:return 3;case`triangle-list`:return 4;case`triangle-strip`:return 5;default:throw Error(e)}}function BU(e){switch(e){case`point-list`:return 0;case`line-list`:return 1;case`line-strip`:return 1;case`triangle-list`:return 4;case`triangle-strip`:return 4;default:throw Error(e)}}var VU=o((()=>{}));function HU(e,t){let n={...e,attributes:e.attributes.map(e=>({...e})),bindings:e.bindings.map(e=>({...e}))};for(let e of t?.attributes||[]){let t=n.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):Z.warn(`shader layout attribute ${e.name} not present in shader`)}for(let e of t?.bindings||[]){let t=UU(n,e.name);if(!t){Z.warn(`shader layout binding ${e.name} not present in shader`);continue}Object.assign(t,e)}return n}function UU(e,t){return e.bindings.find(e=>e.name===t||e.name===`${t}Uniforms`||`${e.name}Uniforms`===t)}function WU(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,``)]}var GU,KU=o((()=>{nM(),hU(),RU(),$H(),HH(),IU(),DU(),VU(),GU=class extends IA{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return`WEBGLRenderPipeline`}constructor(e,t){super(e,t),this.device=e;let n=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=n,this.handle=n.handle,this.vs=n.vs,this.fs=n.fs,this.linkStatus=n.linkStatus,this.introspectedLayout=n.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?HU(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let n=WA(UA(this.shaderLayout,e));for(let[e,r]of Object.entries(n)){let n=UU(this.shaderLayout,e);if(n){switch(r||Z.warn(`Unsetting binding "${e}" in render pipeline "${this.id}"`)(),n.type){case`uniform`:if(!(r instanceof QH)&&!(r.buffer instanceof QH))throw Error(`buffer value`);break;case`texture`:if(!(r instanceof EU||r instanceof FU||r instanceof VH))throw Error(`${this} Bad texture binding for ${e}`);break;case`sampler`:Z.warn(`Ignoring sampler ${e}`)();break;default:throw Error(n.type)}this.bindings[e]=r}else{let n=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(`, `);t?.disableWarnings||Z.warn(`No binding "${e}" in render pipeline "${this.id}", expected one of ${n}`,r)()}}}draw(e){this._syncLinkStatus();let t=e.bindGroups?WA(e.bindGroups):e.bindings||this.bindings,{renderPass:n,parameters:r=this.props.parameters,topology:i=this.props.topology,vertexArray:a,vertexCount:o,instanceCount:s,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u,uniforms:d=this.uniforms}=e,f=zU(i),p=!!a.indexBuffer,m=a.indexBuffer?.glIndexType;if(this.linkStatus!==`success`)return Z.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(t))return Z.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),a.bindBeforeRender(n),u&&u.begin(this.props.topology),this._applyBindings(t,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(d);let h=n;return aU(this.device,r,h.glParameters,()=>{p&&c?this.device.gl.drawElementsInstanced(f,o||0,m,l,s||0):p?this.device.gl.drawElements(f,o||0,m,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,s||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),a.unbindAfterRender(n),!0}_areTexturesRenderable(e){let t=!0;for(let n of this.shaderLayout.bindings)WU(e,n.name)||(Z.warn(`Binding ${n.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!==`success`)return;let{gl:n}=this.device;n.useProgram(this.handle);let r=0,i=0;for(let t of this.shaderLayout.bindings){let a=WU(e,t.name);if(!a)throw Error(`No value for binding ${t.name} in ${this.id}`);switch(t.type){case`uniform`:let{name:e}=t,o=n.getUniformBlockIndex(this.handle,e);if(o===4294967295)throw Error(`Invalid uniform block name ${e}`);if(n.uniformBlockBinding(this.handle,o,i),a instanceof QH)n.bindBufferBase(35345,i,a.handle);else{let e=a;n.bindBufferRange(35345,i,e.buffer.handle,e.offset||0,e.size||e.buffer.byteLength-(e.offset||0))}i+=1;break;case`texture`:if(!(a instanceof EU||a instanceof FU||a instanceof VH))throw Error(`texture`);let s;if(a instanceof EU)s=a.texture;else if(a instanceof FU)s=a;else if(a instanceof VH&&a.colorAttachments[0]instanceof EU)Z.warn(`Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead`)(),s=a.colorAttachments[0].texture;else throw Error(`No texture`);n.activeTexture(33984+r),n.bindTexture(s.glTarget,s.handle),r+=1;break;case`sampler`:break;case`storage`:case`read-only-storage`:throw Error(`binding type '${t.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:n,location:r,type:i,textureUnit:a}=t,o=e[n]??a;o!==void 0&&LU(this.device.gl,r,i,o)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}}));function Wre(e){return ZU[e]}function qU(e){return YU[e]}function JU(e){return!!XU[e]}function Gre(e){return XU[e]}var YU,XU,ZU,QU=o((()=>{YU={5126:`f32`,35664:`vec2<f32>`,35665:`vec3<f32>`,35666:`vec4<f32>`,5124:`i32`,35667:`vec2<i32>`,35668:`vec3<i32>`,35669:`vec4<i32>`,5125:`u32`,36294:`vec2<u32>`,36295:`vec3<u32>`,36296:`vec4<u32>`,35670:`f32`,35671:`vec2<f32>`,35672:`vec3<f32>`,35673:`vec4<f32>`,35674:`mat2x2<f32>`,35685:`mat2x3<f32>`,35686:`mat2x4<f32>`,35687:`mat3x2<f32>`,35675:`mat3x3<f32>`,35688:`mat3x4<f32>`,35689:`mat4x2<f32>`,35690:`mat4x3<f32>`,35676:`mat4x4<f32>`},XU={35678:{viewDimension:`2d`,sampleType:`float`},35680:{viewDimension:`cube`,sampleType:`float`},35679:{viewDimension:`3d`,sampleType:`float`},35682:{viewDimension:`3d`,sampleType:`depth`},36289:{viewDimension:`2d-array`,sampleType:`float`},36292:{viewDimension:`2d-array`,sampleType:`depth`},36293:{viewDimension:`cube`,sampleType:`float`},36298:{viewDimension:`2d`,sampleType:`sint`},36299:{viewDimension:`3d`,sampleType:`sint`},36300:{viewDimension:`cube`,sampleType:`sint`},36303:{viewDimension:`2d-array`,sampleType:`uint`},36306:{viewDimension:`2d`,sampleType:`uint`},36307:{viewDimension:`3d`,sampleType:`uint`},36308:{viewDimension:`cube`,sampleType:`uint`},36311:{viewDimension:`2d-array`,sampleType:`uint`}},ZU={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}}));function Kre(e,t){let n={attributes:[],bindings:[]};n.attributes=qre(e,t);let r=Xre(e,t);for(let e of r){let t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));n.bindings.push({type:`uniform`,name:e.name,group:0,location:e.location,visibility:!!e.vertex&(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}let i=Yre(e,t),a=0;for(let e of i)if(JU(e.type)){let{viewDimension:t,sampleType:r}=Gre(e.type);n.bindings.push({type:`texture`,name:e.name,group:0,location:a,viewDimension:t,sampleType:r}),e.textureUnit=a,a+=1}i.length&&(n.uniforms=i);let o=Jre(e,t);return o?.length&&(n.varyings=o),n}function qre(e,t){let n=[],r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){let r=e.getActiveAttrib(t,i);if(!r)throw Error(`activeInfo`);let{name:a,type:o}=r,s=e.getAttribLocation(t,a);if(s>=0){let e=qU(o),t=/instance/i.test(a)?`instance`:`vertex`;n.push({name:a,location:s,stepMode:t,type:e})}}return n.sort((e,t)=>e.location-t.location),n}function Jre(e,t){let n=[],r=e.getProgramParameter(t,35971);for(let i=0;i<r;i++){let r=e.getTransformFeedbackVarying(t,i);if(!r)throw Error(`activeInfo`);let{name:a,type:o,size:s}=r,{type:c,components:l}=XA(qU(o));n.push({location:i,name:a,type:c,size:s*l})}return n.sort((e,t)=>e.location-t.location),n}function Yre(e,t){let n=[],r=e.getProgramParameter(t,35718);for(let i=0;i<r;i++){let r=e.getActiveUniform(t,i);if(!r)throw Error(`activeInfo`);let{name:a,size:o,type:s}=r,{name:c,isArray:l}=Zre(a),u=e.getUniformLocation(t,c),d={location:u,name:c,size:o,type:s,isArray:l};if(n.push(d),d.size>1)for(let r=0;r<d.size;r++){let i=`${c}[${r}]`;u=e.getUniformLocation(t,i);let a={...d,name:i,location:u};n.push(a)}}return n}function Xre(e,t){let n=(n,r)=>e.getActiveUniformBlockParameter(t,n,r),r=[],i=e.getProgramParameter(t,35382);for(let a=0;a<i;a++){let i={name:e.getActiveUniformBlockName(t,a)||``,location:n(a,35391),byteLength:n(a,35392),vertex:n(a,35396),fragment:n(a,35398),uniformCount:n(a,35394),uniforms:[]},o=n(a,35395)||[],s=e.getActiveUniforms(t,o,35383),c=e.getActiveUniforms(t,o,35384),l=e.getActiveUniforms(t,o,35387),u=e.getActiveUniforms(t,o,35388);for(let n=0;n<i.uniformCount;++n){let r=o[n];if(r!==void 0){let a=e.getActiveUniform(t,r);if(!a)throw Error(`activeInfo`);let o=qU(s[n]);i.uniforms.push({name:a.name,format:o,type:s[n],arrayLength:c[n],byteOffset:l[n],byteStride:u[n]})}}let d=new Set(i.uniforms.map(e=>e.name.split(`.`)[0]).filter(e=>!!e)),f=i.name.replace(/Uniforms$/,``);if(d.size===1&&!d.has(i.name)&&!d.has(f)){let[e]=d;Z.warn(`Uniform block "${i.name}" uses GLSL instance "${e}". luma.gl binds uniform buffers by block name ("${i.name}") and alias ("${f}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}r.push(i)}return r.sort((e,t)=>e.location-t.location),r}function Zre(e){if(e[e.length-1]!==`]`)return{name:e,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:_A(t?.[1],`Failed to parse GLSL uniform name ${e}`),length:+!!t?.[2],isArray:!!t?.[2]}}var $U=o((()=>{nM(),QU()})),eW,tW,Qre=o((()=>{nM(),$U(),QU(),eW=4,tW=class extends RA{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus=`pending`;constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders(),Z.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Kre(this.device.gl,this.handle),Z.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Z.time(eW,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Z.timeEnd(eW,`linkProgram for ${this.id}`)(),!this.device.features.has(`compilation-status-async-webgl`)){let e=this._getLinkStatus();this._reportLinkStatus(e);return}Z.once(1,`RenderPipeline linking is asynchronous`)(),await this._waitForLinkComplete(),Z.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case`success`:return;default:let t=e===`link-error`?`Link error`:`Validation error`;switch(this.vs.compilationStatus){case`error`:throw this.vs.debugShader(),Error(`${this} ${t} during compilation of ${this.vs}`);case`pending`:await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case`success`:break}switch(this.fs?.compilationStatus){case`error`:throw this.fs.debugShader(),Error(`${this} ${t} during compilation of ${this.fs}`);case`pending`:await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case`success`:break}let n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(Error(`${t} during ${e}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus=`success`,`success`):(this.linkStatus=`error`,`validation-error`)):(this.linkStatus=`error`,`link-error`)}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,n=e.getProgramParameter(this.handle,35718);for(let r=0;r<n;r++){let n=e.getActiveUniform(this.handle,r);if(n&&JU(n.type)){let r=n.name.endsWith(`[0]`),i=r?n.name.slice(0,-3):n.name,a=e.getUniformLocation(this.handle,i);a!==null&&(t=this._assignSamplerUniform(a,n,r,t))}}}_assignSamplerUniform(e,t,n,r){let{gl:i}=this.device;if(n&&t.size>1){let n=Int32Array.from({length:t.size},(e,t)=>r+t);return i.uniform1iv(e,n),r+t.size}return i.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has(`compilation-status-async-webgl`)){await e(10);return}let{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}}}));function $re(e,t){let n=t.sourceBuffer,r=t.destinationBuffer;e.gl.bindBuffer(36662,n.handle),e.gl.bindBuffer(36663,r.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function eie(e,t){throw Error(`copyBufferToTexture is not supported in WebGL`)}function tie(e,t){let{sourceTexture:n,mipLevel:r=0,aspect:i=`all`,width:a=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:s,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:d,rowsPerImage:f}=t;if(n instanceof OA){n.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:a,height:o,depthOrArrayLayers:s,mipLevel:r,aspect:i,byteOffset:u},l);return}if(i!==`all`)throw Error(`aspect not supported in WebGL`);if(r!==0||s!==void 0||d||f)throw Error(`not implemented`);let{framebuffer:p,destroyFramebuffer:m}=nW(n),h;try{let t=l,n=a||p.width,r=o||p.height,i=lH(_A(p.colorAttachments[0]).texture.props.format),s=i.format,d=i.type;e.gl.bindBuffer(35051,t.handle),h=e.gl.bindFramebuffer(36160,p.handle),e.gl.readPixels(c[0],c[1],n,r,s,d,u)}finally{e.gl.bindBuffer(35051,null),h!==void 0&&e.gl.bindFramebuffer(36160,h),m&&p.destroy()}}function nie(e,t){let{sourceTexture:n,destinationMipLevel:r=0,origin:i=[0,0],destinationOrigin:a=[0,0,0],destinationTexture:o}=t,{width:s=t.destinationTexture.width,height:c=t.destinationTexture.height}=t,{framebuffer:l,destroyFramebuffer:u}=nW(n),[d=0,f=0]=i,[p,m,h]=a,g=e.gl.bindFramebuffer(36160,l.handle),_,v;if(o instanceof FU)_=o,s=Number.isFinite(s)?s:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),v=_.glTarget;else throw Error(`invalid destination`);switch(v){case 3553:case 34067:e.gl.copyTexSubImage2D(v,r,p,m,d,f,s,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(v,r,p,m,h,d,f,s,c);break;default:}_&&_._unbind(),e.gl.bindFramebuffer(36160,g),u&&l.destroy()}function nW(e){if(e instanceof OA){let{width:t,height:n,id:r}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${r}`,width:t,height:n,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var rW,rie=o((()=>{nM(),NH(),IU(),rW=class extends JA{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case`copy-buffer-to-buffer`:$re(this.device,t.options);break;case`copy-buffer-to-texture`:eie(this.device,t.options);break;case`copy-texture-to-buffer`:tie(this.device,t.options);break;case`copy-texture-to-texture`:nie(this.device,t.options);break;default:throw Error(t.name)}}}})),iW,aW,oW=o((()=>{nM(),TU(),LV(),iW=[1,2,4,8],aW=class extends GA{device;handle=null;glParameters={};constructor(e,t){super(e,t),this.device=e;let n=this.props.framebuffer,r=!n||n.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let i;if(!t?.parameters?.viewport)if(!r&&n){let{width:e,height:t}=n;i=[0,0,e,t]}else{let[t,n]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,t,n]}if(this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters}),!r&&n?.colorAttachments.length){let e=n.colorAttachments.map((e,t)=>36064+t);this.device.gl.drawBuffers(e)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=+!this.props.stencilReadOnly,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),`colorMask`in e&&(t.colorMask=iW.map(t=>!!(t&e.colorMask))),this.glParameters=t,NV(this.device.gl,t)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((e,t)=>{e&&this.clearColorBuffer(t,e)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&CU(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){CU(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw Error(`clearColorBuffer: color must be typed array`)}})}}})),sW,cW=o((()=>{nM(),rie(),oW(),sW=class extends KA{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new rW(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new aW(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw Error(`ComputePass not supported in WebGL`)}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:`copy-buffer-to-buffer`,options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:`copy-buffer-to-texture`,options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:`copy-texture-to-buffer`,options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:`copy-texture-to-texture`,options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,n){throw Error(`resolveQuerySet is not supported in WebGL`)}writeTimestamp(e,t){e.writeTimestamp(t)}}}));function iie(e){let{target:t,source:n,start:r=0,count:i=1}=e,a=n.length,o=i*a,s=0;for(let e=r;s<a;s++)t[e++]=n[s]??0;for(;s<o;)s<o-s?(t.copyWithin(r+s,r,r+s),s*=2):(t.copyWithin(r+s,r,r+o-s),s=o);return e.target}var aie=o((()=>{}));function oie(e){return Array.isArray(e)?new Float32Array(e):e}function sie(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}var lW,uW=o((()=>{nM(),$y(),rH(),aie(),lW=class e extends pj{get[Symbol.toStringTag](){return`VertexArray`}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Zy()===`Chrome`}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&=(this.device.gl.deleteVertexArray(this.handle),void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw Error(`Use .setBuffer()`);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let n=t;if(n.glTarget===34963)throw Error(`Use .setIndexBuffer()`);let{size:r,type:i,stride:a,offset:o,normalized:s,integer:c,divisor:l}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),c?this.device.gl.vertexAttribIPointer(e,r,i,a,o):this.device.gl.vertexAttribPointer(e,r,i,s,a,o),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,l||0),this.attributes[e]=n,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttributeWebGL(e,t)}}_getAccessor(e){let t=this.attributeInfos[e];if(!t)throw Error(`Unknown attribute location ${e}`);let n=nH(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:+(t.stepMode===`instance`)}}_enable(t,n=!0){let r=e.isConstantAttributeZeroSupported(this.device)||t!==0;(n||r)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),n?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){let n=oie(t),r=n.byteLength*e,i=n.length*e;if(this.buffer&&r!==this.buffer.byteLength)throw Error(`Buffer size is immutable, byte length ${r} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:r}),a||=!sie(n,this.bufferValue),a){let e=Rj(t.constructor,i);iie({target:e,source:n,start:0,count:i}),this.buffer.write(e),this.bufferValue=t}return this.buffer}}}));function dW(e){return typeof e==`number`?Number.isInteger(e):/^\d+$/.test(e)}var fW,pW=o((()=>{nM(),SW(),VU(),fW=class extends hj{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e=`point-list`){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(BU(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,n]of Object.entries(e))this.setBuffer(t,n)})}setBuffer(e,t){let n=this._getVaryingIndex(e),{buffer:r,byteLength:i,byteOffset:a}=this._getBufferRange(t);if(n<0){this.unusedBuffers[e]=r,Z.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:r,byteLength:i,byteOffset:a},this.bindOnUse||this._bindBuffer(n,r,a,i)}getBuffer(e){if(dW(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!=`function`)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof QH)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:n=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:r}}_getVaryingIndex(e){if(dW(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:n,byteLength:r,byteOffset:i}=this._getBufferRange(t);this._bindBuffer(Number(e),n,i,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,r){let i=t&&t.handle;!i||r===void 0?this.gl.bindBufferBase(35982,e,i):this.gl.bindBufferRange(35982,e,i,n,r)}}})),mW,cie=o((()=>{nM(),mW=class extends _j{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return`QuerySet`}constructor(e,t){if(super(e,t),this.device=e,t.type===`timestamp`){if(t.count<2)throw Error(`Timestamp QuerySet requires at least two query slots`);this._timestampPairs=Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw Error(`WebGL occlusion QuerySet can only have one value`);let e=this.device.gl.createQuery();if(!e)throw Error(`WebGL query not supported`);this.handle=e}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type===`timestamp`?e===void 0?this._timestampPairs.some((e,t)=>this._isTimestampPairAvailable(t)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,n=e?.queryCount||this.props.count-t;if(this._validateRange(t,n),this.props.type===`timestamp`){let e=Array(n).fill(0n),r=Math.floor(t/2),i=Math.floor((t+n-1)/2);for(let a=r;a<=i;a++){let r=await this._consumeTimestampPairResult(a),i=a*2,o=i+1;i>=t&&i<t+n&&(e[i-t]=0n),o>=t&&o<t+n&&(e[o-t]=r)}return e}if(!this._occlusionQuery)throw Error(`Occlusion query has not been started`);return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,t){if(this.props.type!==`timestamp`)throw Error(`Timestamp durations require a timestamp QuerySet`);if(e<0||t>=this.props.count||t<=e)throw Error(`Timestamp duration range is out of bounds`);if(e%2!=0||t!==e+1)throw Error(`WebGL timestamp durations require adjacent even/odd query indices`);let n=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(n)/1e6}beginOcclusionQuery(){if(this.props.type!==`occlusion`)throw Error(`Occlusion queries require an occlusion QuerySet`);if(!this.handle)throw Error(`WebGL occlusion query is not available`);if(this._occlusionActive)throw Error(`Occlusion query is already active`);this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw Error(`Occlusion query is not active`);this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!==`timestamp`)throw Error(`Timestamp writes require a timestamp QuerySet`);let t=this._getTimestampPairIndex(e),n=this._timestampPairs[t];if(e%2==0){if(n.activeQuery)throw Error(`Timestamp query pair is already active`);let e=this.device.gl.createQuery();if(!e)throw Error(`WebGL query not supported`);let t={handle:e,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,e),n.activeQuery=t;return}if(!n.activeQuery)throw Error(`Timestamp query pair was ended before it was started`);this.device.gl.endQuery(35007),n.completedQueries.push(n.activeQuery),n.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw Error(`Query read range is out of bounds`)}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw Error(`Query index is out of bounds`);return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let t=!!this.device.gl.getParameter(36795);return e.disjoint=t,e.result=t?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw Error(`Timestamp query pair has no completed result`);let n=t.completedQueries.shift();try{return await this._consumeQueryResult(n)}finally{this.device.gl.deleteQuery(n.handle)}}_consumeQueryResult(e){return e.promise?e.promise:(this._pendingReads.add(e),e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?n(Error(`GPU timestamp query was invalidated by a disjoint event`)):t(e.result||0n)};r()}),e.promise)}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}})),hW,gW=o((()=>{nM(),hW=class extends yj{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let n=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n)throw Error(`Failed to create WebGL fence`);this.handle=n,this.signaled=new Promise(e=>{let t=()=>{let n=this.gl.clientWaitSync(this.handle,0,0);n===this.gl.ALREADY_SIGNALED||n===this.gl.CONDITION_SATISFIED?(this._signaled=!0,e()):setTimeout(t,1)};t()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}}));function _W(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function lie(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var uie=o((()=>{}));function die(e,t){let{sourceX:n=0,sourceY:r=0,sourceAttachment:i=0}=t||{},{target:a=null,sourceWidth:o,sourceHeight:s,sourceDepth:c,sourceFormat:l,sourceType:u}=t||{},{framebuffer:d,deleteFramebuffer:f}=vW(e),{gl:p,handle:m}=d;o||=d.width,s||=d.height;let h=d.colorAttachments[i]?.texture;if(!h)throw Error(`Invalid framebuffer attachment ${i}`);c=h?.depth||1,l||=h?.glFormat||6408,u||=h?.glType||5121,a=mie(a,u,l,o,s,c);let g=pk.getDataType(a);u||=Wre(g);let _=p.bindFramebuffer(36160,m);return p.readBuffer(36064+i),p.readPixels(n,r,o,s,l,u,a),p.readBuffer(36064),p.bindFramebuffer(36160,_||null),f&&d.destroy(),a}function fie(e,t){let{target:n,sourceX:r=0,sourceY:i=0,sourceFormat:a=6408,targetByteOffset:o=0}=t||{},{sourceWidth:s,sourceHeight:c,sourceType:l}=t||{},{framebuffer:u,deleteFramebuffer:d}=vW(e);s||=u.width,c||=u.height;let f=u;l||=5121;let p=n;if(!p){let e=_W(a),t=lie(l),n=o+s*c*e*t;p=f.device.createBuffer({byteLength:n})}let m=e.device.createCommandEncoder();return m.copyTextureToBuffer({sourceTexture:e,width:s,height:c,origin:[r,i],destinationBuffer:p,byteOffset:o}),m.destroy(),d&&u.destroy(),p}function vW(e){return e instanceof FA?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:pie(e),deleteFramebuffer:!0}}function pie(e,t){let{device:n,width:r,height:i,id:a}=e;return n.createFramebuffer({...t,id:`framebuffer-for-${a}`,width:r,height:i,colorAttachments:[e]})}function mie(e,t,n,r,i,a){if(e)return e;t||=5121;let o=OU(t),s=pk.getTypedArrayConstructor(o),c=_W(n);return new s(r*i*c)}var hie=o((()=>{nM(),QU(),uie(),AU()})),yW=c({WebGLDevice:()=>bW});function gie(e,t,n){switch(n.length){case 1:e.gl.vertexAttrib1fv(t,n);break;case 2:e.gl.vertexAttrib2fv(t,n);break;case 3:e.gl.vertexAttrib3fv(t,n);break;case 4:e.gl.vertexAttrib4fv(t,n);break;default:}}function _ie(e,t,n){e.gl.vertexAttribI4iv(t,n)}function vie(e,t,n){e.gl.vertexAttribI4uiv(t,n)}function yie(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}var bW,xW=o((()=>{nM(),GV(),qV(),WB(),tH(),IH(),RH(),WH(),KH(),ZB(),sV(),NH(),YH(),$H(),iU(),SU(),IU(),HH(),KU(),Qre(),cW(),uW(),pW(),cie(),gW(),hie(),LV(),TU(),YV(),bW=class e extends aA{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type=`webgl`;handle;features;limits;info;canvasContext;preferredColorFormat=`rgba8unorm`;preferredDepthFormat=`depth24plus`;commandEncoder;lost;_resolveContextLost;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return`WebGLDevice`}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case`unorm8x4-bgra`:return!1;default:return!0}}constructor(t){super({...t,id:t.id||qH(`webgl-device`)});let n=aA._getCanvasContextProps(t);if(!n)throw Error(`WebGLDevice requires props.createCanvasContext to be set`);let r=n.canvas?.gl??null,i=e.getDeviceFromContext(r);if(i)throw Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new UH(this,n),this.lost=new Promise(e=>{this._resolveContextLost=e});let a={...t.webgl};n.alphaMode===`premultiplied`&&(a.premultipliedAlpha=!0),t.powerPreference!==void 0&&(a.powerPreference=t.powerPreference),t.failIfMajorPerformanceCaveat!==void 0&&(a.failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat);let o=this.props._handle||KV(this.canvasContext.canvas,{onContextLost:e=>this._resolveContextLost?.({reason:`destroyed`,message:`Entered sleep mode, or too many apps or browser tabs are using the GPU.`}),onContextRestored:e=>console.log(`WebGL context restored`)},a);if(!o)throw Error(`WebGL context creation failed`);if(i=e.getDeviceFromContext(o),i){if(t._reuseDevices)return Z.log(1,`Not creating a new Device, instead returning a reference to Device ${i.id} already attached to WebGL context`,i)(),this.canvasContext.destroy(),i._reused=!0,i;throw Error(`WebGL context already attached to device ${i.id}`)}this.handle=o,this.gl=o,this.spectorJS=KB({...this.props,gl:this.handle});let s=UB(this.handle);s.device=this,s.extensions||={},this.extensions=s.extensions,this.info=XV(this.gl,this.extensions),this.limits=new LH(this.gl),this.features=new FH(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new WV(this.gl,{log:(...e)=>Z.log(1,...e)()}).trackState(this.gl,{copyState:!1}),(t.debug||t.debugWebGL)&&(this.gl=eV(this.gl,{debugWebGL:!0,traceWebGL:t.debugWebGL}),Z.warn(`WebGL debug mode activated. Performance reduced.`)()),t.debugWebGL&&(Z.level=Math.max(Z.level,1)),this.commandEncoder=new sW(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=UB(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw Error(`WebGL only supports a single canvas`)}createPresentationContext(e){return new GH(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new QH(this,t)}createTexture(e){return new FU(this,e)}createExternalTexture(e){throw Error(`createExternalTexture() not implemented`)}createSampler(e){return new xU(this,e)}createShader(e){return new rU(this,e)}createFramebuffer(e){return new VH(this,e)}createVertexArray(e){return new lW(this,e)}createTransformFeedback(e){return new fW(this,e)}createQuerySet(e){return new mW(this,e)}createFence(){return new hW(this)}createRenderPipeline(e){return new GU(this,e)}_createSharedRenderPipelineWebGL(e){return new tW(this,e)}createComputePipeline(e){throw Error(`ComputePipeline not supported in WebGL`)}createCommandEncoder(e={}){return new sW(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return die(e,t)}readPixelsToBufferWebGL(e,t){return fie(e,t)}setParametersWebGL(e){NV(this.gl,e)}getParametersWebGL(e){return PV(this.gl,e)}withParametersWebGL(e,t){return CU(this.gl,e,t)}resetWebGL(){Z.warn(`WebGLDevice.resetWebGL is deprecated, use only for debugging`)(),FV(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return sH(this.gl,e,this.extensions)}loseDevice(){let e=!1,t=this.getExtension(`WEBGL_lose_context`).WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:`destroyed`,message:`Application triggered context loss`}),e}pushState(){WV.get(this.gl).push()}popState(){WV.get(this.gl).pop()}getGLKey(e,t){let n=Number(e);for(let e in this.gl)if(this.gl[e]===n)return`GL.${e}`;return t?.emptyIfUnknown?``:String(e)}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((e,[n,r])=>(e[`${n}:${this.getGLKey(n,t)}`]=`${r}:${this.getGLKey(r,t)}`,e),{})}setConstantAttributeWebGL(e,t){let n=this.limits.maxVertexAttributes;this._constants=this._constants||Array(n).fill(null);let r=this._constants[e];switch(r&&yie(r,t)&&Z.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:gie(this,e,t);break;case Int32Array:_ie(this,e,t);break;case Uint32Array:vie(this,e,t);break;default:throw Error(`constant`)}}getExtension(e){return JV(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,n){e.luma=t,e.__SPECTOR_Metadata={props:n.spector,id:n.spector.id}}}})),SW=o((()=>{MB(),_V(),xW(),WH(),$H(),IU(),iU(),SU(),HH(),gW(),KU(),cW(),oW(),uW(),pW(),hU(),$U(),GV(),LV(),TU()}));function CW(){}var wW,TW,EW,bie=o((()=>{YR(),Rre(),Zz(),tB(),oB(),_B(),SB(),AB(),Nw(),ZR(),JI(),zw(),nM(),SW(),OR(),Yx(),NP(),vz(),zP(),wW=({isDragging:e})=>e?`grabbing`:`grab`,TW={id:``,width:`100%`,height:`100%`,style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:`auto`,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:`none`,eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:CW,onWebGLInitialized:CW,onResize:CW,onViewStateChange:CW,onInteractionStateChange:CW,onBeforeRender:CW,onAfterRender:CW,onLoad:CW,onError:e=>Mw.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:wW,getTooltip:null,debug:!1,drawPickingColors:!1},EW=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new qx({id:`deck.gl`}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw=`Initial render`,this._pickRequest={mode:`hover`,x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=e=>{let{_pickRequest:t}=this;if(e.type===`pointerleave`)t.x=-1,t.y=-1,t.radius=0;else if(e.leftButton||e.rightButton)return;else{let n=e.offsetCenter;if(!n)return;t.x=n.x,t.y=n.y,t.radius=this.props.pickingRadius}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{let t=LP[e.type],n=e.offsetCenter;if(!t||!n||!this.layerManager)return;let r=this.layerManager.getLayers(),i=this._getInternalPickingMode();if(i){if(i===`sync`){let t=e.type===`click`&&this._shouldUnproject3D(r)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(n.x,n.y,{unproject3D:!0},r))):this._getLastPointerDownPickingInfo(n.x,n.y,r);this._dispatchPickingEvent(t,e);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(n.x,n.y,r))).then(t=>{this._dispatchPickingEvent(t,e)}).catch(e=>this.props.onError?.(e))}},this._onPointerDown=e=>{let t=e.offsetCenter;if(!t)return;let n=this._getInternalPickingMode();if(!n)return;let r=this.layerManager?.getLayers()||[],i=++this._pointerDownPickSequence;if(n===`sync`){let e=this._pickPointSync({x:t.x,y:t.y,radius:this.props.pickingRadius}),n=this._getFirstPickedInfo(e);this._lastPointerDownInfo=n,this._lastPointerDownInfoPromise=Promise.resolve(n);return}let a=this._pickPointAsync(this._getPointPickOptions(t.x,t.y,{},r)).then(e=>this._getFirstPickedInfo(e)).then(e=>(i===this._pointerDownPickSequence&&(this._lastPointerDownInfo=e),e)).catch(e=>{this.props.onError?.(e);let n=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(t.x,t.y,r):{};return i===this._pointerDownPickSequence&&(this._lastPointerDownInfo=n),n});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=a},this.props={...TW,...e},e=this.props,e.viewState&&e.initialViewState&&Mw.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let t=this.device;if(!t&&e.gl){e.gl instanceof WebGLRenderingContext&&Mw.error(`WebGL1 context not supported.`)();let n=this.props.deviceProps?.onResize;t=gV.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(e,t)=>{let{width:r,height:i}=e.canvas;e.setDrawingBufferSize(r,i),this._needsRedraw=`Canvas resized`,n?.(e,t)}})}t||=this._createDevice(e),this.animationLoop=this._createAnimationLoop(t,e),this.setProps(e),e._typedArrayManagerProps&&qI.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get(`setProps Time`).timeStart(),`onLayerHover`in e&&Mw.removed(`onLayerHover`,`onHover`)(),`onLayerClick`in e&&Mw.removed(`onLayerClick`,`onClick`)(),e.initialViewState&&!XR(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),this._setCanvasSize(this.props);let t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id&&(this.animationLoop?.stop(),this.canvas!==e.device.canvasContext?.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),Mw.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get(`setProps Time`).timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return`Deck._animate`;let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let n=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),a=this.deckRenderer.needsRedraw(e);return t=t||n||r||i||a,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get(`Redraw Count`).incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return _z(this.viewManager),this.viewManager.views}getView(e){return _z(this.viewManager),this.viewManager.getView(e)}getViewports(e){return _z(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let t=(await this._pickAsync(`pickObjectAsync`,`pickObject Time`,e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync(`pickObjectsAsync`,`pickObjects Time`,e)}pickObject(e){let t=this._pick(`pickObject`,`pickObject Time`,e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick(`pickObject`,`pickMultipleObjects Time`,e).result}pickObjects(e){return this._pick(`pickObjects`,`pickObjects Time`,e)}_pickPositionForController(e,t){return this._getInternalPickingMode()===`sync`?this.pickObject({x:e,y:t,radius:0,unproject3D:!0}):null}_addResources(e,t=!1){for(let n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e===`auto`)return t===`webgpu`?`async`:`sync`;if(e===`sync`&&t===`webgpu`)throw Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(e=>e.props.pickable===`3d`)}_getPointPickOptions(e,t,n={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...n}}_pickPointSync(e){return this._pick(`pickObject`,`pickObject Time`,e)}_pickPointAsync(e){return this._pickAsync(`pickObjectAsync`,`pickObject Time`,e)}_getLastPointerDownPickingInfo(e,t,n=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:n,viewports:this.getViewports({x:e,y:t})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},n){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,i=!1;for(let t of e)r=t,i=t.layer?.onHover(t,n)||i;i||(this.props.onHover?.(r,n),this.widgetManager.onHover(r,n))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let n=LP[t.type];if(!n)return;let{layer:r}=e,i=r&&(r[n]||r.props[n]),a=this.props[n],o=!1;i&&(o=i.call(r,e,t)),o||(a?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,n){_z(this.deckPicker);let{stats:r}=this;r.get(`Pick Count`).incrementCount(),r.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return r.get(t).timeEnd(),i}_pick(e,t,n){_z(this.deckPicker);let{stats:r}=this;r.get(`Pick Count`).incrementCount(),r.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return r.get(t).timeEnd(),i}_createCanvas(e){let t=e.canvas;return typeof t==`string`&&(t=document.getElementById(t),_z(t)),t||(t=document.createElement(`canvas`),t.id=e.id||`deckgl-overlay`,e.width&&typeof e.width==`number`&&(t.width=e.width),e.height&&typeof e.height==`number`&&(t.height=e.height),(e.parent||document.body).appendChild(t)),Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;let{width:t,height:n}=e;if(t||t===0){let e=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=e}if(n||n===0){let t=Number.isFinite(n)?`${n}px`:n;this.canvas.style.position=e.style?.position||`absolute`,this.canvas.style.height=t}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let t=e.clientWidth??e.width,n=e.clientHeight??e.height;(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.viewManager?.setProps({width:t,height:n}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:t,height:n}))}_createAnimationLoop(e,t){let{gl:n,onError:r}=t;return new AL({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,n=typeof t==`object`?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(gV)||r.adapters.push(gV);let i={alphaMode:this.props.deviceProps?.type===`webgpu`?`premultiplied`:void 0},a=this.props.deviceProps?.onResize;return uA.createDevice({_reuseDevices:!0,type:`webgl`,...r,createCanvasContext:{...i,...n,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(e,t)=>{this._needsRedraw=`Canvas resized`,a?.(e,t)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new Xz({id:`default-view`})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(Error(`WebGL context is lost`))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,n=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},n),i=this._getInternalPickingMode(),a=++this._hoverPickSequence;if(e.event=null,!i)return;if(i===`sync`){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:e,emptyInfo:n})=>{a===this._hoverPickSequence&&this._applyHoverCallbacks({result:e,emptyInfo:n},t)}).catch(e=>this.props.onError?.(e))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type===`webgl`&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type===`webgl`&&this.props.onWebGLInitialized(this.device.gl);let t=new CL;t.play(),this.animationLoop.attachTimeline(t);let n=this.props.parent?.querySelector(`.deck-events-root`)||this.canvas;this.eventManager=new MP(n,{touchAction:this.props.touchAction,recognizers:Object.keys(RP).map(e=>{let[t,n,r,i]=RP[e],a=this.props.eventRecognizerOptions?.[e];return{recognizer:new t({...n,...a,event:e}),recognizeWith:r,requestFailure:i}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let e in LP)this.eventManager.on(e,this._onEvent);this.viewManager=new QR({timeline:t,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let r=this.viewManager.getViewports()[0];this.layerManager=new JR(this.device,{deck:this,stats:this.stats,viewport:r,timeline:t}),this.effectManager=new eB({deck:this,device:this.device}),this.deckRenderer=new aB(this.device,{stats:this.stats}),this.deckPicker=new gB(this.device,{stats:this.stats});let i=this.props.parent?.querySelector(`.deck-widgets-root`)||this.canvas?.parentElement;this.widgetManager=new xB({deck:this,parentElement:i}),this.widgetManager.addDefault(new kB),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){let{device:n,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:n,gl:r});let i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:`screen`,effects:this.effectManager.getEffects(),...t};this.deckRenderer?.renderLayers(i),i.pass===`screen`&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:n,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),Mw.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get(`frameRate`).timeEnd(),e.get(`frameRate`).timeStart();let t=this.animationLoop.stats;e.get(`GPU Time`).addTime(t.get(`GPU Time`).lastTiming),e.get(`CPU Time`).addTime(t.get(`CPU Time`).lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get(`frameRate`).getHz(),e.setPropsTime=t.get(`setProps Time`).time,e.updateAttributesTime=t.get(`Update Attributes`).time,e.framesRedrawn=t.get(`Redraw Count`).count,e.pickTime=t.get(`pickObject Time`).time+t.get(`pickMultipleObjects Time`).time+t.get(`pickObjects Time`).time,e.pickCount=t.get(`Pick Count`).count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get(`Layers rendered`).lastSampleCount,e.pickLayersCount=t.get(`Layers picked`).lastSampleCount,e.updateAttributesCount=t.get(`Layers updated`).count,e.updateAttributesCount=t.get(`Attributes updated`).count,e.gpuTime=t.get(`GPU Time`).time,e.cpuTime=t.get(`CPU Time`).time,e.gpuTimePerFrame=t.get(`GPU Time`).getAverageTime(),e.cpuTimePerFrame=t.get(`CPU Time`).getAverageTime();let n=uA.stats.get(`GPU Time and Memory`);e.bufferMemory=n.get(`Buffer Memory`).count,e.textureMemory=n.get(`Texture Memory`).count,e.renderbufferMemory=n.get(`Renderbuffer Memory`).count,e.gpuMemory=n.get(`GPU Memory`).count}},EW.defaultProps=TW,EW.VERSION=Rw}));function xie(e){switch(e){case`float64`:return Float64Array;case`uint8`:case`unorm8`:return Uint8ClampedArray;default:return Sj(e)}}function DW(e,t,n){if(t.size>4)return null;let r=n===`webgpu`&&t.type===`uint8`?`unorm8`:t.type;return{attribute:e,format:t.size>1?`${r}x${t.size}`:t.type,byteOffset:t.offset||0}}function OW(e){return e.stride||e.size*e.bytesPerElement}function Sie(e,t){return e.type===t.type&&e.size===t.size&&OW(e)===OW(t)&&(e.offset||0)===(t.offset||0)}var kW,AW=o((()=>{nM(),kW=pk.getDataType.bind(pk)}));function jW(e,t){t.offset&&Mw.removed(`shaderAttribute.offset`,`vertexOffset, elementOffset`)();let n=OW(e),r=t.vertexOffset===void 0?e.vertexOffset||0:t.vertexOffset,i=t.elementOffset||0,a=r*n+i*e.bytesPerElement+(e.offset||0);return{...t,offset:a,stride:n}}function Cie(e,t){let n=jW(e,t);return{high:n,low:{...n,offset:n.offset+e.size*4}}}var MW,wie=o((()=>{nM(),AW(),JI(),aL(),Nw(),MW=class{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||``,this.size=t.size||1;let r=t.logicalType||t.type,i=r===`float64`,{defaultValue:a}=t;a=Number.isFinite(a)?[a]:a||Array(this.size).fill(0);let o;o=i?`float32`:!r&&t.isIndexed?`uint32`:r||`float32`;let s=xie(r||o);this.doublePrecision=i,i&&t.fp64===!1&&(s=Float32Array),this.value=null,this.settings={...t,defaultType:s,defaultValue:a,logicalType:r,type:o,normalized:o.includes(`norm`),size:this.size,bytesPerElement:s.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*OW(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&=(this._buffer.delete(),null),qI.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let n={};if(this.state.constant){let r=this.value;if(t){let i=jW(this.getAccessor(),t),a=i.offset/r.BYTES_PER_ELEMENT,o=i.size||this.size;n[e]=r.subarray(a,a+o)}else n[e]=r}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){let n=this.getAccessor(),r=[],i={name:this.id,byteStride:OW(n)};if(this.doublePrecision){let i=Cie(n,t||{});r.push(DW(e,{...n,...i.high},this.device.type),DW(`${e}64Low`,{...n,...i.low},this.device.type))}else if(t){let i=jW(n,t);r.push(DW(e,{...n,...i},this.device.type))}else r.push(DW(e,n,this.device.type));return i.attributes=r.filter(Boolean),i}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:n,size:r}=this,i=n*r;if(t&&i&&t.length>=i){let n=Array(r).fill(1/0),a=Array(r).fill(-1/0);for(let e=0;e<i;)for(let i=0;i<r;i++){let r=t[e++];r<n[i]&&(n[i]=r),r>a[i]&&(a[i]=r)}e=[n,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,n;n=ArrayBuffer.isView(e)?{value:e}:e instanceof uk?{buffer:e}:e;let r={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)r.type=`float32`;else{let e=kW(n.value);r.type=r.normalized?e.replace(`int`,`norm`):e}r.bytesPerElement=n.value.BYTES_PER_ELEMENT,r.stride=OW(r)}if(t.bounds=null,n.constant){let e=n.value;if(e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e)),!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(n.buffer)t.externalBuffer=n.buffer,t.constant=!1,this.value=n.value||null;else if(n.value){this._checkExternalBuffer(n);let e=n.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:i}=this,a=OW(r),o=(r.vertexOffset||0)*a;if(this.doublePrecision&&e instanceof Float64Array&&(e=tL(e,r)),this.settings.isIndexed){let t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}let s=e.byteLength+o+a*2;(!i||i.byteLength<s)&&(i=this._createBuffer(s)),i.write(e,o)}return this.setAccessor(r),!0}updateSubBuffer(e={}){this.state.bounds=null;let t=this.value,{startOffset:n=0,endOffset:r}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?tL(t,{size:this.size,startIndex:n,endIndex:r}):t.subarray(n,r),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){let{state:n}=this,r=n.allocatedValue,i=qI.allocate(r,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=i;let{byteOffset:a}=this,{buffer:o}=this;return(!o||o.byteLength<i.byteLength+a)&&(o=this._createBuffer(i.byteLength+a),t&&r&&o.write(r instanceof Float64Array?tL(r,this):r,a)),n.allocatedValue=i,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:t}=e;if(!ArrayBuffer.isView(t))throw Error(`Attribute ${this.id} value is not TypedArray`);let n=this.settings.defaultType,r=!1;if(this.doublePrecision&&(r=t.BYTES_PER_ELEMENT<4),r)throw Error(`Attribute ${this.id} does not support ${t.constructor.name}`);!(t instanceof n)&&this.settings.normalized&&!(`normalized`in e)&&Mw.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case`snorm8`:return new Float32Array(e).map(e=>(e+128)/255*2-1);case`snorm16`:return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case`unorm8`:return new Float32Array(e).map(e=>e/255);case`unorm16`:return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,n){let{defaultValue:r,size:i}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let e=i;for(;--e>=0;)t[n+e]=r[e];return t}switch(i){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let a=i;for(;--a>=0;)t[n+a]=Number.isFinite(e[a])?e[a]:r[a]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:n}=this;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:t,type:n}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(t?uk.INDEX:uk.VERTEX)|uk.COPY_DST,indexType:t?n:void 0,byteLength:e}),this._buffer}}}));function NW(e,t=0,n=1/0){let r=IW,i={index:-1,data:e,target:[]};return e?typeof e[Symbol.iterator]==`function`?r=e:e.length>0&&(LW.length=e.length,r=LW):r=IW,(t>0||Number.isFinite(n))&&(r=(Array.isArray(r)?r:Array.from(r)).slice(t,n),i.index=t-1),{iterable:r,objectInfo:i}}function PW(e){return e&&e[Symbol.asyncIterator]}function FW(e,t){let{size:n,stride:r,offset:i,startIndices:a,nested:o}=t,s=e.BYTES_PER_ELEMENT,c=r?r/s:n,l=i?i/s:0,u=Math.floor((e.length-l)/c);return(t,{index:r,target:i})=>{if(!a){let t=r*c+l;for(let r=0;r<n;r++)i[r]=e[t+r];return i}let s=a[r],d=a[r+1]||u,f;if(o){f=Array(d-s);for(let t=s;t<d;t++){let r=t*c+l;i=Array(n);for(let t=0;t<n;t++)i[t]=e[r+t];f[t-s]=i}}else if(c===n)f=e.subarray(s*n+l,d*n+l);else{f=new e.constructor((d-s)*n);let t=0;for(let r=s;r<d;r++){let i=r*c+l;for(let r=0;r<n;r++)f[t++]=e[i+r]}}return f}}var IW,LW,RW=o((()=>{IW=[],LW=[]}));function Tie(e,t){if(e===BW||(t[0]<0&&(t[0]=0),t[0]>=t[1]))return e;let n=[],r=e.length,i=0;for(let a=0;a<r;a++){let r=e[a];r[1]<t[0]?(n.push(r),i=a+1):r[0]>t[1]?n.push(r):t=[Math.min(r[0],t[0]),Math.max(r[1],t[1])]}return n.splice(i,0,t),n}var zW,BW,Eie=o((()=>{zW=[],BW=[[0,1/0]]}));function VW(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:`interpolation`,duration:e});let n=e.type||`interpolation`;return{...HW[n],...t,...e,type:n}}var HW,UW=o((()=>{HW={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}}})),WW,GW=o((()=>{wie(),vz(),RW(),UR(),Eie(),AW(),UW(),WW=class extends MW{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:BW}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!Sie(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!=`function`&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,n=this.settings.transition;return VW(Array.isArray(t)?e[t.find(t=>e[t])]:e[t],n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:e=0,endRow:n=1/0}=t;this.state.updateRanges=Tie(this.state.updateRanges,[e,n])}else this.state.updateRanges=BW}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=zW}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:n}=this;return n.noAlloc?!1:n.update?(super.allocate(e,t.updateRanges!==BW),!0):!1}updateBuffer({numInstances:e,data:t,props:n,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:i},settings:{update:a,noAlloc:o}}=this,s=!0;if(a){for(let[o,s]of i)a.call(r,this,{data:t,startRow:o,endRow:s,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(r,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[t,n]of i){let r=Number.isFinite(t)?this.getVertexOffset(t):0,i=Number.isFinite(n)?this.getVertexOffset(n):o||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:r,endOffset:i})}this._checkAttributeArray()}else s=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),s}setConstantValue(e,t){if(t===void 0||typeof t==`function`)return!1;let n=this.settings.transform&&e?this.settings.transform.call(e,t):t;return this.device.type===`webgpu`?this.setConstantBufferValue(n,this.numInstances):(this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setConstantBufferValue(e,t){let n=this.settings.defaultType,r=this._normalizeValue(e,new n(this.size),0);if(this._hasConstantBufferValue(r,t))return this.constant=!1,this.clearNeedsUpdate(),!1;let i=new n(Math.max(t,1)*this.size);for(let e=0;e<i.length;e+=this.size)i.set(r,e);let a=this.setData({value:i});return this.constant=!1,this.clearNeedsUpdate(),a&&this.setNeedsRedraw(),a}_hasConstantBufferValue(e,t){let n=this.value,r=Math.max(t,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==r||n.length%this.size!==0)return!1;for(let t=0;t<n.length;t+=this.size)for(let r=0;r<this.size;r++)if(n[t+r]!==e[r])return!1;return!0}setExternalBuffer(e){let{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e?!0:(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e),!0)):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){let{state:n,settings:r}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(r.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;if(n.binaryValue=e,this.setNeedsRedraw(),r.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let i=e;_z(ArrayBuffer.isView(i.value),`invalid ${r.accessor}`);let a=!!i.size&&i.size!==this.size;return n.binaryAccessor=FW(i.value,{size:i.size||this.size,stride:i.stride,offset:i.offset,startIndices:t,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(let n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;let t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:r}=this.settings;if(r===`dynamic`?n.stepMode=e?e.isInstanced?`instance`:`vertex`:`instance`:n.stepMode=r??`vertex`,!t)return n;for(let e in t){let r=super._getBufferLayout(e,t[e]);n.attributes.push(...r.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:r,props:i,numInstances:a}){let{settings:o,state:s,value:c,size:l,startIndices:u}=e,{accessor:d,transform:f}=o,p=s.binaryAccessor||(typeof d==`function`?d:i[d]);_z(typeof p==`function`,`accessor "${d}" is not a function`);let m=e.getVertexOffset(n),{iterable:h,objectInfo:g}=NW(t,n,r);for(let t of h){g.index++;let n=p(t,g);if(f&&(n=f.call(this,n)),u){let t=(g.index<u.length-1?u[g.index+1]:a)-u[g.index];if(n&&Array.isArray(n[0])){let t=m;for(let r of n)e._normalizeValue(r,c,t),t+=l}else n&&n.length>l?c.set(n,m):(e._normalizeValue(n,g.target,0),Fre({target:c,source:g.target,start:m,count:t}));m+=t*l}else e._normalizeValue(n,c,m),m+=l}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update==`function`))throw Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n&&=Number.isFinite(e[3]);case 3:n&&=Number.isFinite(e[2]);case 2:n&&=Number.isFinite(e[1]);case 1:n&&=Number.isFinite(e[0]);break;default:n=!1}if(!n)throw Error(`Illegal attribute generated for ${this.id}`)}}}}));function KW(e){let{source:t,target:n,start:r=0,size:i,getData:a}=e,o=e.end||n.length,s=t.length,c=o-r;if(s>c){n.set(t.subarray(0,c),r);return}if(n.set(t,r),!a)return;let l=s;for(;l<c;){let e=a(l,t);for(let t=0;t<i;t++)n[r+l]=e[t]||0,l++}}function Die({source:e,target:t,size:n,getData:r,sourceStartIndices:i,targetStartIndices:a}){if(!i||!a)return KW({source:e,target:t,size:n,getData:r}),t;let o=0,s=0,c=r&&((e,t)=>r(e+s,t)),l=Math.min(i.length,a.length);for(let r=1;r<l;r++){let l=i[r]*n,u=a[r]*n;KW({source:e.subarray(o,l),target:t,start:s,end:u,size:n,getData:c}),o=l,s=u}return s<t.length&&KW({source:[],target:t,start:s,size:n,getData:c}),t}var Oie=o((()=>{}));function kie(e){let{device:t,settings:n,value:r}=e,i=new WW(t,n);return i.setData({value:r instanceof Float64Array?new Float64Array:new Float32Array,normalized:n.normalized}),i}function qW(e){switch(e){case 1:return`float`;case 2:return`vec2`;case 3:return`vec3`;case 4:return`vec4`;default:throw Error(`No defined attribute type for size "${e}"`)}}function JW(e){switch(e){case 1:return`float32`;case 2:return`float32x2`;case 3:return`float32x3`;case 4:return`float32x4`;default:throw Error(`invalid type size`)}}function YW(e){e.push(e.shift())}function Aie(e,t){let{doublePrecision:n,settings:r,value:i,size:a}=e,o=n&&i instanceof Float64Array?2:1,s=0,{shaderAttributes:c}=e.settings;if(c)for(let e of Object.values(c))s=Math.max(s,e.vertexOffset??0);return(r.noAlloc?i.length:(t+s)*a)*o}function XW({device:e,source:t,target:n}){return(!n||n.byteLength<t.byteLength)&&(n?.destroy(),n=e.createBuffer({byteLength:t.byteLength,usage:t.usage})),n}function ZW({device:e,buffer:t,attribute:n,fromLength:r,toLength:i,fromStartIndices:a,getData:o=e=>e}){let s=n.doublePrecision&&n.value instanceof Float64Array?2:1,c=n.size*s,l=n.byteOffset,u=n.settings.bytesPerElement<4?l/n.settings.bytesPerElement*4:l,d=n.startIndices,f=a&&d,p=n.isConstant;if(!f&&t&&r>=i)return t;let m=n.value instanceof Float64Array?Float32Array:n.value.constructor,h=p?n.value:new m(n.getBuffer().readSyncWebGL(l,i*m.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!p){let e=o;o=(t,r)=>n.normalizeConstant(e(t,r))}let g=p?(e,t)=>o(h,t):(e,t)=>o(h.subarray(e+l,e+l+c),t),_=t?new Float32Array(t.readSyncWebGL(u,r*4).buffer):new Float32Array,v=new Float32Array(i);return Die({source:_,target:v,sourceStartIndices:a,targetStartIndices:d,size:c,getData:g}),(!t||t.byteLength<v.byteLength+u)&&(t?.destroy(),t=e.createBuffer({byteLength:v.byteLength+u,usage:35050})),t.write(v,u),t}var QW=o((()=>{Oie(),GW()})),$W,eG=o((()=>{uz(),QW(),$W=class{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new lz(n),this.attribute=t,this.attributeInTransition=kie(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=Aie(this.attribute,t),this.transition.start({...e,duration:n})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}}}));function tG(e){return e.doublePrecision&&e.value instanceof Float64Array}function jie(e,t){let n=t.size,r=qW(n),i=JW(n),a=t.getBufferLayout();return tG(t)?new ER(e,{vs:aG,bufferLayout:[{name:`aFrom`,byteStride:8*n,attributes:[{attribute:`aFrom`,format:i,byteOffset:0},{attribute:`aFrom64Low`,format:i,byteOffset:4*n}]},{name:`aTo`,byteStride:8*n,attributes:[{attribute:`aTo`,format:i,byteOffset:0},{attribute:`aTo64Low`,format:i,byteOffset:4*n}]}],modules:[wO,rG],defines:{ATTRIBUTE_TYPE:r,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:[`vCurrent`,`vCurrent64Low`],bufferMode:35980,disableWarnings:!0}):new ER(e,{vs:iG,bufferLayout:[{name:`aFrom`,format:i},{name:`aTo`,format:a.attributes[0].format}],modules:[rG],defines:{ATTRIBUTE_TYPE:r},varyings:[`vCurrent`],disableWarnings:!0})}var nG,rG,iG,aG,Mie=o((()=>{OR(),bM(),QW(),eG(),nG=class extends $W{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type=`interpolation`,this.transform=jie(e,t)}start(e,t){let n=this.currentLength,r=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:i,attribute:a}=this;YW(i),i[0]=ZW({device:this.device,buffer:i[0],attribute:a,fromLength:n,toLength:this.currentLength,fromStartIndices:r,getData:e.enter}),i[1]=XW({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);let{transform:o}=this,s=o.model,c=Math.floor(this.currentLength/a.size);tG(a)&&(c/=2),s.setVertexCount(c),a.isConstant?(s.setAttributes({aFrom:i[0]}),s.setConstantAttributes({aTo:a.value})):s.setAttributes({aFrom:i[0],aTo:a.getBuffer()}),o.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){let{duration:e,easing:t}=this.settings,{time:n}=this.transition,r=n/e;t&&(r=t(r));let{model:i}=this.transform,a={time:r};i.shaderInputs.setProps({interpolation:a}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},rG={name:`interpolation`,vs:`layout(std140) uniform interpolationUniforms {
|
||
float time;
|
||
} interpolation;
|
||
`,uniformTypes:{time:`f32`}},iG=`#version 300 es
|
||
#define SHADER_NAME interpolation-transition-vertex-shader
|
||
|
||
in ATTRIBUTE_TYPE aFrom;
|
||
in ATTRIBUTE_TYPE aTo;
|
||
out ATTRIBUTE_TYPE vCurrent;
|
||
|
||
void main(void) {
|
||
vCurrent = mix(aFrom, aTo, interpolation.time);
|
||
gl_Position = vec4(0.0);
|
||
}
|
||
`,aG=`#version 300 es
|
||
#define SHADER_NAME interpolation-transition-vertex-shader
|
||
|
||
in ATTRIBUTE_TYPE aFrom;
|
||
in ATTRIBUTE_TYPE aFrom64Low;
|
||
in ATTRIBUTE_TYPE aTo;
|
||
in ATTRIBUTE_TYPE aTo64Low;
|
||
out ATTRIBUTE_TYPE vCurrent;
|
||
out ATTRIBUTE_TYPE vCurrent64Low;
|
||
|
||
vec2 mix_fp64(vec2 a, vec2 b, float x) {
|
||
vec2 range = sub_fp64(b, a);
|
||
return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));
|
||
}
|
||
|
||
void main(void) {
|
||
for (int i=0; i<ATTRIBUTE_SIZE; i++) {
|
||
vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time);
|
||
vCurrent[i] = value.x;
|
||
vCurrent64Low[i] = value.y;
|
||
}
|
||
gl_Position = vec4(0.0);
|
||
}
|
||
`}));function Nie(e,t){let n=qW(t.size),r=JW(t.size);return new ER(e,{vs:cG,fs:lG,bufferLayout:[{name:`aPrev`,format:r},{name:`aCur`,format:r},{name:`aTo`,format:t.getBufferLayout().attributes[0].format}],varyings:[`vNext`],modules:[sG],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:`always`,blendColorOperation:`max`,blendColorSrcFactor:`one`,blendColorDstFactor:`one`,blendAlphaOperation:`max`,blendAlphaSrcFactor:`one`,blendAlphaDstFactor:`one`}})}function Pie(e){return e.createTexture({data:new Uint8Array(4),format:`rgba8unorm`,width:1,height:1})}function Fie(e,t){return e.createFramebuffer({id:`spring-transition-is-transitioning-framebuffer`,width:1,height:1,colorAttachments:[t]})}var oG,sG,cG,lG,Iie=o((()=>{OR(),QW(),eG(),oG=class extends $W{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type=`spring`,this.texture=Pie(e),this.framebuffer=Fie(e,this.texture),this.transform=Nie(e,t)}start(e,t){let n=this.currentLength,r=this.currentStartIndices;super.start(e,t);let{buffers:i,attribute:a}=this;for(let t=0;t<2;t++)i[t]=ZW({device:this.device,buffer:i[t],attribute:a,fromLength:n,toLength:this.currentLength,fromStartIndices:r,getData:e.enter});i[2]=XW({device:this.device,source:i[0],target:i[2]}),this.setBuffer(i[1]);let{model:o}=this.transform;o.setVertexCount(Math.floor(this.currentLength/a.size)),a.isConstant?o.setConstantAttributes({aTo:a.value}):o.setAttributes({aTo:a.getBuffer()})}onUpdate(){let{buffers:e,transform:t,framebuffer:n,transition:r}=this,i=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});let a={stiffness:i.stiffness,damping:i.damping};t.model.shaderInputs.setProps({spring:a}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),YW(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(n)[0]>0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},sG={name:`spring`,vs:`layout(std140) uniform springUniforms {
|
||
float damping;
|
||
float stiffness;
|
||
} spring;
|
||
`,uniformTypes:{damping:`f32`,stiffness:`f32`}},cG=`#version 300 es
|
||
#define SHADER_NAME spring-transition-vertex-shader
|
||
|
||
#define EPSILON 0.00001
|
||
|
||
in ATTRIBUTE_TYPE aPrev;
|
||
in ATTRIBUTE_TYPE aCur;
|
||
in ATTRIBUTE_TYPE aTo;
|
||
out ATTRIBUTE_TYPE vNext;
|
||
out float vIsTransitioningFlag;
|
||
|
||
ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {
|
||
ATTRIBUTE_TYPE velocity = cur - prev;
|
||
ATTRIBUTE_TYPE delta = dest - cur;
|
||
ATTRIBUTE_TYPE force = delta * spring.stiffness;
|
||
ATTRIBUTE_TYPE resistance = velocity * spring.damping;
|
||
return force - resistance + velocity + cur;
|
||
}
|
||
|
||
void main(void) {
|
||
bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;
|
||
vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;
|
||
|
||
vNext = getNextValue(aCur, aPrev, aTo);
|
||
gl_Position = vec4(0, 0, 0, 1);
|
||
gl_PointSize = 100.0;
|
||
}
|
||
`,lG=`#version 300 es
|
||
#define SHADER_NAME spring-transition-is-transitioning-fragment-shader
|
||
|
||
in float vIsTransitioningFlag;
|
||
|
||
out vec4 fragColor;
|
||
|
||
void main(void) {
|
||
if (vIsTransitioningFlag == 0.0) {
|
||
discard;
|
||
}
|
||
fragColor = vec4(1.0);
|
||
}`})),uG,dG,Lie=o((()=>{Mie(),Iie(),Nw(),uG={interpolation:nG,spring:oG},dG=class{constructor(e,{id:t,timeline:n}){if(!e)throw Error(`AttributeTransitionManager is constructed without device`);this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(let n in e){let r=e[n],i=r.getTransitionSetting(t);i&&this._updateAttribute(n,r,i)}for(let n in this.transitions){let r=e[n];(!r||!r.getTransitionSetting(t))&&this._removeTransition(n)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let e in this.transitions)this.transitions[e].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){let r=this.transitions[e],i=!r||r.type!==n.type;if(i){r&&this._removeTransition(e);let a=uG[n.type];a?this.transitions[e]=new a({attribute:t,timeline:this.timeline,device:this.device}):(Mw.error(`unsupported transition type '${n.type}'`)(),i=!1)}(i||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}}})),fG,pG,mG,hG,gG,_G,vG,yG=o((()=>{GW(),Nw(),VP(),aL(),Iw(),Lie(),fG=`attributeManager.invalidate`,pG=`attributeManager.updateStart`,mG=`attributeManager.updateEnd`,hG=`attribute.updateStart`,gG=`attribute.allocate`,_G=`attribute.updateEnd`,vG=class{constructor(e,{id:t=`attribute-manager`,stats:n,timeline:r}={}){this.mergeBoundsMemoized=BP(nL),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new dG(e,{id:`${t}-transitions`,timeline:r}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:`instance`})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let n=this._invalidateTrigger(e,t);Pw(fG,this,e,n)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Pw(fG,this,`all`)}update({data:e,numInstances:t,startIndices:n=null,transitions:r,props:i={},buffers:a={},context:o={}}){let s=!1;Pw(pG,this),this.stats&&this.stats.get(`Update Attributes`).timeStart();for(let r in this.attributes){let c=this.attributes[r],l=c.settings.accessor;c.startIndices=n,c.numInstances=t,i[r]&&Mw.removed(`props.${r}`,`data.attributes.${r}`)(),c.setExternalBuffer(a[r])||c.setBinaryValue(typeof l==`string`?a[l]:void 0,e.startIndices)||typeof l==`string`&&!a[l]&&c.setConstantValue(o,i[l])||c.needsUpdate()&&(s=!0,this._updateAttribute({attribute:c,numInstances:t,data:e,props:i,context:o})),this.needsRedraw=this.needsRedraw||c.needsRedraw()}s&&Pw(mG,this,t),this.stats&&(this.stats.get(`Update Attributes`).timeEnd(),s&&this.stats.get(`Attributes updated`).incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(e=>this.attributes[e]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:n}=this,r={...n.getAttributes()};for(let i in t){let a=t[i];a.needsRedraw(e)&&!n.hasAttribute(i)&&(r[i]=a)}return r}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(let n in e){let r=e[n],i={...r,id:n,size:r.isIndexed&&1||r.size||1,...t};this.attributes[n]=new WW(this.device,i)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:n,updateTriggers:r}=this,i=r[e];return i&&i.forEach(e=>{let r=n[e];r&&r.setNeedsUpdate(r.id,t)}),i}_updateAttribute(e){let{attribute:t,numInstances:n}=e;if(Pw(hG,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(n)&&Pw(gG,t,n),t.updateBuffer(e)&&(this.needsRedraw=!0,Pw(_G,t,n))}}})),bG,Rie=o((()=>{lO(),uz(),bG=class extends lz{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:n,duration:r,easing:i}}=this,a=i(e/r);this._value=BE(t,n,a)}}}));function xG(e,t,n,r,i){let a=t-e;return(n-t)*i+-a*r+a+t}function zie(e,t,n,r,i){if(Array.isArray(n)){let a=[];for(let o=0;o<n.length;o++)a[o]=xG(e[o],t[o],n[o],r,i);return a}return xG(e,t,n,r,i)}function SG(e,t){if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++){let i=e[r]-t[r];n+=i*i}return Math.sqrt(n)}return Math.abs(e-t)}var CG,wG,Bie=o((()=>{uz(),CG=1e-5,wG=class extends lz{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:t,damping:n,stiffness:r}=this.settings,{_prevValue:i=e,_currValue:a=e}=this,o=zie(i,a,t,n,r),s=SG(o,t),c=SG(o,a);s<CG&&c<CG&&(o=t,this.end()),this._prevValue=a,this._currValue=o}}})),TG,EG,Vie=o((()=>{UW(),Rie(),Bie(),Nw(),TG={interpolation:bG,spring:wG},EG=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,r){let{transitions:i}=this;if(i.has(e)){let n=i.get(e),{value:r=n.settings.fromValue}=n;t=r,this.remove(e)}if(r=VW(r),!r)return;let a=TG[r.type];if(!a){Mw.error(`unsupported transition type '${r.type}'`)();return}let o=new a(this.timeline);o.start({...r,fromValue:t,toValue:n}),i.set(e,o)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}}}));function Hie(e){let t=e[FR];for(let n in t){let r=t[n],{validate:i}=r;if(i&&!i(e[n],r))throw Error(`Invalid prop ${n}: ${e[n]}`)}}function Uie(e,t){let n=DG({newProps:e,oldProps:t,propTypes:e[FR],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),r=Gie(e,t),i=!1;return r||(i=Kie(e,t)),{dataChanged:r,propsChanged:n,updateTriggersChanged:i,extensionsChanged:qie(e,t),transitionsChanged:Wie(e,t)}}function Wie(e,t){if(!e.transitions)return!1;let n={},r=e[FR],i=!1;for(let a in e.transitions){let o=r[a],s=o&&o.type;(s===`number`||s===`color`||s===`array`)&&OG(e[a],t[a],o)&&(n[a]=!0,i=!0)}return i?n:!1}function DG({newProps:e,oldProps:t,ignoreProps:n={},propTypes:r={},triggerName:i=`props`}){if(t===e)return!1;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return`${i} changed shallowly`;for(let a of Object.keys(e))if(!(a in n)){if(!(a in t))return`${i}.${a} added`;let n=OG(e[a],t[a],r[a]);if(n)return`${i}.${a} ${n}`}for(let a of Object.keys(t))if(!(a in n)){if(!(a in e))return`${i}.${a} dropped`;if(!Object.hasOwnProperty.call(e,a)){let n=OG(e[a],t[a],r[a]);if(n)return`${i}.${a} ${n}`}}return!1}function OG(e,t,n){let r=n&&n.equal;return r&&!r(e,t,n)||!r&&(r=e&&t&&e.equals,r&&!r.call(e,t))?`changed deeply`:!r&&t!==e?`changed shallowly`:null}function Gie(e,t){if(t===null)return`oldProps is null, initial diff`;let n=!1,{dataComparator:r,_dataDiff:i}=e;return r?r(e.data,t.data)||(n=`Data comparator detected a change`):e.data!==t.data&&(n=`A new data container was supplied`),n&&i&&(n=i(e.data,t.data)||n),n}function Kie(e,t){if(t===null||`all`in e.updateTriggers&&kG(e,t,`all`))return{all:!0};let n={},r=!1;for(let i in e.updateTriggers)i!==`all`&&kG(e,t,i)&&(n[i]=!0,r=!0);return r?n:!1}function qie(e,t){if(t===null)return!0;let n=t.extensions,{extensions:r}=e;if(r===n)return!1;if(!n||!r||r.length!==n.length)return!0;for(let e=0;e<r.length;e++)if(!r[e].equals(n[e]))return!0;return!1}function kG(e,t,n){let r=e.updateTriggers[n];r??={};let i=t.updateTriggers[n];return i??={},DG({oldProps:i,newProps:r,triggerName:n})}var AG=o((()=>{BR()}));function Jie(e){if(!Xie(e))throw Error(jG);if(typeof e.count==`function`)return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(Yie(e))return Object.keys(e).length;throw Error(MG)}function Yie(e){return typeof e==`object`&&!!e&&e.constructor===Object}function Xie(e){return typeof e==`object`&&!!e}var jG,MG,NG=o((()=>{jG=`count(): argument not an object`,MG=`count(): argument not a container`}));function PG(e,t){if(!t)return e;let n={...e,...t};if(`defines`in t&&(n.defines={...e.defines,...t.defines}),`modules`in t&&(n.modules=(e.modules||[]).concat(t.modules),t.modules.some(e=>e.name===`project64`))){let e=n.modules.findIndex(e=>e.name===`project32`);e>=0&&n.modules.splice(e,1)}if(`inject`in t)if(!e.inject)n.inject=t.inject;else{let r={...e.inject};for(let e in t.inject)r[e]=(r[e]||``)+t.inject[e];n.inject=r}return n}var FG=o((()=>{}));function Zie(e,t,n,r){if(n instanceof OA)return n;n.constructor&&n.constructor.name!==`Object`&&(n={data:n});let i=null;n.compressed&&(i={minFilter:`linear`,mipmapFilter:n.data.length>1?`nearest`:`linear`});let{width:a,height:o}=n.data,s=t.createTexture({...n,sampler:{...IG,...i,...r},mipLevels:t.getMipLevelCount(a,o)});return t.type===`webgl`?s.generateMipmapsWebGL():t.type===`webgpu`&&t.generateMipmapsWebGPU(s),LG[s.id]=e,s}function Qie(e,t){!t||!(t instanceof OA)||LG[t.id]===e&&(t.delete(),delete LG[t.id])}var IG,LG,$ie=o((()=>{nM(),IG={minFilter:`linear`,mipmapFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`},LG={}}));function eae(e){let t={},n={},r={};for(let[i,a]of Object.entries(e)){let e=a?.deprecatedFor;if(e)r[i]=Array.isArray(e)?e:[e];else{let e=tae(i,a);t[i]=e,n[i]=e.value}}return{propTypes:t,defaultProps:n,deprecatedProps:r}}function tae(e,t){switch(BG(t)){case`object`:return RG(e,t);case`array`:return RG(e,{type:`array`,value:t,compare:!1});case`boolean`:return RG(e,{type:`boolean`,value:t});case`number`:return RG(e,{type:`number`,value:t});case`function`:return RG(e,{type:`function`,value:t,compare:!0});default:return{name:e,type:`unknown`,value:t}}}function RG(e,t){return`type`in t?{name:e,...VG[t.type],...t}:`value`in t?{name:e,type:BG(t.value),...t}:{name:e,type:`object`,value:t}}function zG(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function BG(e){return zG(e)?`array`:e===null?`null`:typeof e}var VG,nae=o((()=>{$ie(),ZR(),VG={boolean:{validate(e,t){return!0},equal(e,t,n){return!!e==!!t}},number:{validate(e,t){return Number.isFinite(e)&&(!(`max`in t)||e<=t.max)&&(!(`min`in t)||e>=t.min)}},color:{validate(e,t){return t.optional&&!e||zG(e)&&(e.length===3||e.length===4)},equal(e,t,n){return XR(e,t,1)}},accessor:{validate(e,t){let n=BG(e);return n===`function`||n===BG(t.value)},equal(e,t,n){return typeof t==`function`?!0:XR(e,t,1)}},array:{validate(e,t){return t.optional&&!e||zG(e)},equal(e,t,n){let{compare:r}=n;return r?XR(e,t,Number.isInteger(r)?r:+!!r):e===t}},object:{equal(e,t,n){if(n.ignore)return!0;let{compare:r}=n;return r?XR(e,t,Number.isInteger(r)?r:+!!r):e===t}},function:{validate(e,t){return t.optional&&!e||typeof e==`function`},equal(e,t,n){return!n.compare&&n.ignore!==!1||e===t}},data:{transform:(e,t,n)=>{if(!e)return e;let{dataTransform:r}=n.props;return r?r(e):typeof e.shape==`string`&&e.shape.endsWith(`-table`)&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,n)=>{let r=n.context;return!r||!r.device?null:Zie(n.id,r.device,e,{...t.parameters,...n.props.textureParameters})},release:(e,t,n)=>{Qie(n.id,e)}}}}));function rae(e,t){let n;for(let e=t.length-1;e>=0;e--){let r=t[e];`extensions`in r&&(n=r.extensions)}let r=HG(e.constructor,n),i=Object.create(r);i[PR]=e,i[RR]={},i[zR]={};for(let e=0;e<t.length;++e){let n=t[e];for(let e in n)i[e]=n[e]}return Object.freeze(i),i}function HG(e,t){if(!(e instanceof qG.constructor))return{};let n=GG;if(t)for(let e of t){let t=e.constructor;t&&(n+=`:${t.extensionName||t.name}`)}return WG(e,n)||(e[n]=iae(e,t||[]))}function iae(e,t){if(!e.prototype)return null;let n=HG(Object.getPrototypeOf(e)),r=eae(WG(e,`defaultProps`)||{}),i=Object.assign(Object.create(null),n,r.defaultProps),a=Object.assign(Object.create(null),n?.[FR],r.propTypes),o=Object.assign(Object.create(null),n?.[IR],r.deprecatedProps);for(let e of t){let t=HG(e.constructor);t&&(Object.assign(i,t),Object.assign(a,t[FR]),Object.assign(o,t[IR]))}return aae(i,e),sae(i,a),oae(i,o),i[FR]=a,i[IR]=o,t.length===0&&!UG(e,`_propTypes`)&&(e._propTypes=a),i}function aae(e,t){let n=lae(t);Object.defineProperties(e,{id:{writable:!0,value:n}})}function oae(e,t){for(let n in t)Object.defineProperty(e,n,{enumerable:!1,set(e){let r=`${this.id}: ${n}`;for(let r of t[n])UG(this,r)||(this[r]=e);Mw.deprecated(r,t[n].join(`/`))()}})}function sae(e,t){let n={},r={};for(let e in t){let i=t[e],{name:a,value:o}=i;i.async&&(n[a]=o,r[a]=cae(a))}e[LR]=n,e[RR]={},Object.defineProperties(e,r)}function cae(e){return{enumerable:!0,set(t){typeof t==`string`||t instanceof Promise||PW(t)?this[RR][e]=t:this[zR][e]=t},get(){if(this[zR]){if(e in this[zR])return this[zR][e]||this[LR][e];if(e in this[RR]){let t=this[PR]&&this[PR].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[LR][e]}}return this[LR][e]}}}function UG(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function WG(e,t){return UG(e,t)&&e[t]}function lae(e){let t=e.componentName;return t||Mw.warn(`${e.name}.componentName not specified`)(),t||e.name}var GG,uae=o((()=>{Nw(),RW(),nae(),BR(),JG(),GG=`_mergedDefaultProps`})),KG,qG,JG=o((()=>{BR(),uae(),KG=0,qG=class{constructor(...e){this.props=rae(this,e),this.id=this.props.id,this.count=KG++}clone(e){let{props:t}=this,n={};for(let e in t[LR])e in t[zR]?n[e]=t[zR][e]:e in t[RR]&&(n[e]=t[RR][e]);return new this.constructor({...t,...n,...e})}},qG.componentName=`Component`,qG.defaultProps={}})),YG,XG,ZG=o((()=>{RW(),BR(),YG=Object.freeze({}),XG=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||YG}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[PR]||this.component;let t=e[zR]||{},n=e[RR]||e,r=e[LR]||{};for(let e in t){let n=t[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,n),t[e]=this.getAsyncProp(e)}for(let e in n){let t=n[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,t)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t==`string`&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(PW(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let n=this.asyncProps[e];return t===n.resolvedValue||t===n.lastValue?!1:(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){let r=this.asyncProps[e];r&&n>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let n=this.asyncProps[e];if(n){n.pendingLoadCount++;let r=n.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(n,t),this._setAsyncPropValue(e,t,r),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if(e!==`data`){this._setPropValue(e,t);return}let n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;let r=n.pendingLoadCount,i=[],a=0;for await(let n of t){if(!this.component)return;let{dataTransform:t}=this.component.props;i=t?t(n,i):i.concat(n),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:a,endRow:i.length}]}),a=i.length,this._setAsyncPropValue(e,i,r)}this._onResolve(e,i)}_postProcessValue(e,t){let n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let n=this.component&&this.component.props[FR];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}})),QG,dae=o((()=>{ZG(),QG=class extends XG{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){let n=this.layer,r=n?.props.fetch;return r?r(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){let n=this.layer;if(n){let r=n.props.onDataLoad;e===`data`&&r&&r(t,{propName:e,layer:n})}}_onError(e,t){let n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}}}));function fae(e){let{blendConstant:t,...n}=e;return t?{pipelineParameters:n,renderPassParameters:{blendConstant:t}}:{pipelineParameters:n}}function pae(e,t,n,r){for(let i of e)i.device.type===`webgpu`?(mae(i,t),i.setParameters({...i.parameters,...r?.pipelineParameters})):i.setParameters(n)}function mae(e,t){let n=t.props.framebuffer||(t.framebuffer??null);if(!n)return;let r=n.colorAttachments.map(e=>e?.texture?.format??null),i=n.depthStencilAttachment?.texture?.format,a=e;(!hae(a.props.colorAttachmentFormats,r)||a.props.depthStencilAttachmentFormat!==i)&&(a.props.colorAttachmentFormats=r,a.props.depthStencilAttachmentFormat=i,a._setPipelineNeedsUpdate(`attachment formats`))}function hae(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var $G,eK,tK,nK,rK,iK,aK,oK,sK,cK,lK,uK=o((()=>{nM(),SW(),yG(),Vie(),AG(),BR(),NG(),Nw(),Iw(),vz(),VP(),FG(),bL(),JI(),JG(),dae(),QF(),ow(),$G=`layer.changeFlag`,eK=`layer.initialize`,tK=`layer.update`,nK=`layer.finalize`,rK=`layer.matched`,iK=2**24-1,aK=Object.freeze([]),oK=BP(({oldViewport:e,viewport:t})=>e.equals(t)),sK=new Uint8ClampedArray,cK={data:{type:`data`,value:aK,async:!0},dataComparator:{type:`function`,value:null,optional:!0},_dataDiff:{type:`function`,value:e=>e&&e.__diff,optional:!0},dataTransform:{type:`function`,value:null,optional:!0},onDataLoad:{type:`function`,value:null,optional:!0},onError:{type:`function`,value:null,optional:!0},fetch:{type:`function`,value:(e,{propName:t,layer:n,loaders:r,loadOptions:i,signal:a})=>{let{resourceManager:o}=n.context;i||=n.getLoadOptions(),r||=n.props.loaders,a&&(i={...i,core:{...i?.core,fetch:{...i?.core?.fetch,signal:a}}});let s=o.contains(e);return!s&&!i&&(o.add({resourceId:e,data:aw(e,r),persistent:!1}),s=!0),s?o.subscribe({resourceId:e,onChange:e=>n.internalState?.reloadAsyncProp(t,e),consumerId:n.id,requestId:t}):aw(e,r,i)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:`number`,min:0,max:1,value:1},operation:`draw`,onHover:{type:`function`,value:null,optional:!0},onClick:{type:`function`,value:null,optional:!0},onDragStart:{type:`function`,value:null,optional:!0},onDrag:{type:`function`,value:null,optional:!0},onDragEnd:{type:`function`,value:null,optional:!0},coordinateSystem:`default`,coordinateOrigin:{type:`array`,value:[0,0,0],compare:!0},modelMatrix:{type:`array`,value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:`XYZ`,colorFormat:`RGBA`,parameters:{type:`object`,value:{},optional:!0,compare:2},loadOptions:{type:`object`,value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:`array`,value:[],optional:!0,ignore:!0},getPolygonOffset:{type:`function`,value:({layerIndex:e})=>[0,-e*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:`accessor`,value:[0,0,128,128]}},lK=class extends qG{constructor(){super(...arguments),this.internalState=null,this.lifecycle=NR.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,`layerName`)?this.layerName:``}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){_z(this.internalState);let t=this.internalState.viewport||this.context.viewport,[n,r,i]=jF(_L(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),t.pixelProjectionMatrix);return e.length===2?[n,r]:[n,r,i]}unproject(e){return _z(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){return _z(this.internalState),vL(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e===`lnglat`||e===`cartesian`}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){_z(e instanceof Uint8Array);let[t,n,r]=e;return t+n*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Jie(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds([`positions`,`instancePositions`])}getShaders(e){e=PG(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=PG(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(let e of n)t.invalidateAll(e);else t.invalidateAll();if(t){let{props:n}=e,r=this.internalState.hasPickingBuffer,i=Number.isInteger(n.highlightedObjectIndex)||!!n.pickable||n.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(r!==i){this.internalState.hasPickingBuffer=i;let{pickingColors:e,instancePickingColors:n}=t.attributes,r=e||n;r&&(i&&r.constant&&(r.constant=!1,t.invalidate(r.id)),!r.value&&!i&&(r.constant=!0,r.value=[0,0,0]))}}}finalizeState(e){for(let e of this.getModels())e.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!oK({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e=`all`){let t=this.getAttributeManager();t&&(e===`all`?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let n in e)e[n].layoutChanged()&&(t=!0);for(let n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,n=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),n=Object.create(this.props);for(let e in t)Object.defineProperty(n,e,{value:t[e]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let n=Math.floor(sK.length/4);if(this.internalState.usesPickingColorCache=!0,n<t){t>iK&&Mw.warn(`Layer has too many data objects. Picking might not be able to distinguish all objects.`)(),sK=qI.allocate(sK,t,{size:4,copy:!0,maxCount:Math.max(t,iK)});let e=Math.floor(sK.length/4),r=[0,0,0];for(let t=n;t<e;t++)this.encodePickingColor(t,r),sK[t*4+0]=r[0],sK[t*4+1]=r[1],sK[t*4+2]=r[2],sK[t*4+3]=0}e.value=sK.subarray(0,t*4)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;if(n){let n=this.getAttributeManager();e.setBufferLayout(n.getBufferLayouts(e)),t=n.getAttributes()}let r=e.userData?.excludeAttributes||{},i={},a={};for(let n in t){if(r[n])continue;let o=t[n].getValue();for(let r in o){let s=o[r];s instanceof uk?t[n].settings.isIndexed?e.setIndexBuffer(s):i[r]=s:s&&(a[r]=s)}}e.setAttributes(i),e.setConstantAttributes(a)}disablePickingIndex(e){let t=this.props.data;if(!(`attributes`in t)){this._disablePickingIndex(e);return}let{pickingColors:n,instancePickingColors:r}=this.getAttributeManager().attributes,i=n||r,a=i&&t.attributes&&t.attributes[i.id];if(a&&a.value){let n=a.value,r=this.encodePickingColor(e);for(let e=0;e<t.length;e++){let t=i.getVertexOffset(e);n[t]===r[0]&&n[t+1]===r[1]&&n[t+2]===r[2]&&this._disablePickingIndex(e)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,r=t||n;if(!r)return;let i=r.getVertexOffset(e),a=r.getVertexOffset(e+1);r.buffer.write(new Uint8Array(a-i),i)}restorePickingColors(){let{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==sK.buffer&&(n.value=sK.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){_z(!this.internalState),Pw(eK,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:`uint8`,size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new QG({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(Mw.deprecated(`layer.state.attributeManager`,`layer.getAttributeManager()`)(),e)}),this.internalState.uniformTransitions=new EG(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let e of this.props.extensions)e.initializeState.call(this,this.context,e);this.setChangeFlags({dataChanged:`init`,propsChanged:`init`,viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Pw(rK,this,this===e);let{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(Pw(tK,this,e),!e)return;this.context.stats.get(`Layer updates`).incrementCount();let t=this.props,n=this.context,r=this.internalState,i=n.viewport,a=this._updateUniformTransition();r.propsInTransition=a,n.viewport=r.viewport||i,this.props=a;try{let e=this._getUpdateParams(),t=this.getModels();if(n.device)this.updateState(e);else try{this.updateState(e)}catch{}for(let t of this.props.extensions)t.updateState.call(this,e,t);this.setNeedsRedraw(),this._updateAttributes();let r=this.getModels()[0]!==t[0];this._postUpdate(e,r)}finally{n.viewport=i,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){Pw(nK,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:r={}}){this._updateAttributeTransition();let i=this.props,a=this.context;this.props=this.internalState.propsInTransition||i;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:i}=this.props,o=i&&i(n)||[0,0];a.device instanceof bW&&a.device.setParametersWebGL({polygonOffset:o});let s=a.device instanceof bW?null:fae(r);if(pae(this.getModels(),e,r,s),a.device instanceof bW)a.device.withParametersWebGL(r,()=>{let i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:a};for(let e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)});else{s?.renderPassParameters&&e.setParameters(s.renderPassParameters);let i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:a};for(let e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)}}finally{this.props=i}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let n in e)if(e[n]){let r=!1;switch(n){case`dataChanged`:let i=e[n],a=t[n];i&&Array.isArray(a)&&(t.dataChanged=Array.isArray(i)?a.concat(i):i,r=!0);default:t[n]||(t[n]=e[n],r=!0)}r&&Pw($G,this,n,e)}let n=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let n=Uie(e,t);if(n.updateTriggersChanged)for(let e in n.updateTriggersChanged)n.updateTriggersChanged[e]&&this.invalidateAttribute(e);if(n.transitionsChanged)for(let r in n.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(n)}validateProps(){Hie(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&typeof n==`function`&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new vG(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:n,oldProps:r}=e,i=this.state.model;i?.isInstanced&&i.setInstanceCount(this.getNumInstances());let{autoHighlight:a,highlightedObjectIndex:o,highlightColor:s}=n;if(t||r.autoHighlight!==a||r.highlightedObjectIndex!==o||r.highlightColor!==s){let e={};Array.isArray(s)&&(e.highlightColor=s),(t||r.autoHighlight!==a||o!==r.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(o)&&o>=0?this.encodePickingColor(o):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t||=this.internalState.needsRedraw&&this.id;let n=this.getAttributeManager(),r=n?n.getNeedsRedraw(e):!1;if(t||=r,t)for(let e of this.props.extensions)e.onNeedsRedraw.call(this,e);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}},lK.defaultProps=cK,lK.layerName=`Layer`})),dK,fK,pK=o((()=>{uK(),Iw(),UR(),BR(),dK=`compositeLayer.renderLayers`,fK=class extends lK{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){let{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if(typeof e==`function`){let t={index:-1,data:this.props.data,target:[]};return(n,r)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,r)}return e}getSubLayerProps(e={}){let{opacity:t,pickable:n,visible:r,parameters:i,getPolygonOffset:a,highlightedObjectIndex:o,autoHighlight:s,highlightColor:c,coordinateSystem:l,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:m,fetch:h,operation:g,_subLayerProps:_}=this.props,v={id:``,updateTriggers:{},opacity:t,pickable:n,visible:r,parameters:i,getPolygonOffset:a,highlightedObjectIndex:o,autoHighlight:s,highlightColor:c,coordinateSystem:l,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:m,fetch:h,operation:g},y=_&&e.id&&_[e.id],b=y&&y.updateTriggers,x=e.id||`sublayer`;if(y){let t=this.props[FR],n=e.type?e.type._propTypes:{};for(let e in y){let r=n[e]||t[e];r&&r.type===`accessor`&&(y[e]=this.getSubLayerAccessor(y[e]))}}Object.assign(v,e,y),v.id=`${this.props.id}-${x}`,v.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...b};for(let e of m){let t=e.getSubLayerProps.call(this,e);t&&Object.assign(v,t,{updateTriggers:Object.assign(v.updateTriggers,t.updateTriggers)})}return v}_updateAutoHighlight(e){for(let t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers,r=!n||this.needsUpdate();r&&(n=VR(this.renderLayers(),Boolean),this.internalState.subLayers=n),Pw(dK,this,r,n);for(let e of n)e.parent=this}},fK.layerName=`CompositeLayer`}));function mK(e,t=0){let n=Math.min(180,e)*gK;return 256*2*Math.sin(n/2)*2**t}function hK(e,t=0){let n=e/2**t;return Math.asin(Math.min(1,n/256/2))*2*_K}var gK,_K,vK,yK,bK=o((()=>{lO(),zz(),Yz(),aL(),Mz(),Oz(),QF(),gK=Math.PI/180,_K=180/Math.PI,vK=class extends qz{constructor(e){let{startPanPos:t,...n}=e;n.normalize=!1,super(n),t!==void 0&&(this._state.startPanPos=t)}panStart({pos:e}){let{latitude:t,longitude:n,zoom:r}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[n,t],startPanPos:e,startZoom:r})}pan({pos:e,startPos:t}){let n=this.getState(),r=n.startPanLngLat||this._unproject(t);if(!r)return this;let i=n.startZoom??this.getViewportProps().zoom,a=n.startPanPos||t,o=[r[0],r[1],i],s=this.makeViewport(this.getViewportProps()).panByPosition(o,e,a);return this._getUpdatedState(s)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let t=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:t})}applyConstraints(e){let{longitude:t,latitude:n,maxBounds:r}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(t<-180||t>180)&&(e.longitude=XI(t+180,360)-180),e.latitude=zE(n,-zF,zF),r&&(e.longitude=zE(e.longitude,r[0][0],r[1][0]),e.latitude=zE(e.latitude,r[0][1],r[1][1])),r){let t=e.zoom-Sz(n),i=r[1][0]-r[0][0],a=r[1][1]-r[0][1];if(a>0&&a<85.051129*2){let n=Math.min(hK(e.height,t),a)/2;e.latitude=zE(e.latitude,r[0][1]+n,r[1][1]-n)}if(i>0&&i<360){let n=Math.min(hK(e.width/Math.cos(e.latitude*gK),t),i)/2;e.longitude=zE(e.longitude,r[0][0]+n,r[1][0]-n)}}return e.latitude!==n&&(e.zoom+=Sz(e.latitude)-Sz(n)),e}_constrainZoom(e,t){t||=this.getViewportProps();let{latitude:n,maxZoom:r,maxBounds:i}=t,{minZoom:a}=t,o=Sz(0),s=Sz(n)-o;if(i!==null&&t.width>0&&t.height>0){let e=i[0][1],n=i[1][1],s=Math.sign(e)===Math.sign(n)?Math.min(Math.abs(e),Math.abs(n)):0,c=mK(i[1][0]-i[0][0])*Math.cos(s*gK),l=mK(i[1][1]-i[0][1]);c>0&&(a=Math.max(a,Math.log2(t.width/c)+o)),l>0&&(a=Math.max(a,Math.log2(t.height/l)+o)),a>r&&(a=r)}return zE(e,a+s,r+s)}},yK=class extends Rz{constructor(){super(...arguments),this.ControllerState=vK,this.transition={transitionDuration:300,transitionInterpolator:new jz([`longitude`,`latitude`,`zoom`])},this.dragMode=`pan`}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}}})),xK,SK,CK=o((()=>{cz(),Oz(),mL(),bK(),xK={cullMode:`back`},SK=class extends sz{constructor(e={}){super({...e,parameters:{...xK,...e.parameters}})}getViewportType(e){return e.zoom>12?pL:Dz}get ControllerType(){return yK}},SK.displayName=`GlobeView`})),wK,TK=o((()=>{RW(),JI(),vz(),nM(),wK=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=qI,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:n={},getGeometry:r,geometryBuffer:i,positionFormat:a,dataChanged:o,normalize:s=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=i&&i.size||(a===`XY`?2:3),this.buffers=n,this.normalize=s,i&&(_z(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),s||(n.vertexPositions=i)),this.geometryBuffer=n.vertexPositions,Array.isArray(o))for(let e of o)this._rebuildGeometry(e);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?FW(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:n,buffers:r,_attributeDefs:i,typedArrayManager:a}=this;for(let o in i)if(o in r)a.release(n[o]),n[o]=null;else{let r=i[o];r.copy=t,n[o]=a.allocate(n[o],e,r)}}_forEachGeometry(e,t,n){let{data:r,getGeometry:i}=this,{iterable:a,objectInfo:o}=NW(r,t,n);for(let t of a)o.index++,e(i?i(t,o):null,o.index)}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:r}=this,{data:i,geometryBuffer:a}=this,{startRow:o=0,endRow:s=1/0}=e||{},c={};if(e||(t=[0],n=[0]),this.normalize||!a)this._forEachGeometry((e,t)=>{let r=e&&this.normalizeGeometry(e);c[t]=r,n[t+1]=n[t]+(r?this.getGeometrySize(r):0)},o,s),r=n[n.length-1];else if(n=i.startIndices,r=n[i.length]||0,ArrayBuffer.isView(a))r||=a.length/this.positionSize;else if(a instanceof uk){let e=this.positionSize*4;r||=a.byteLength/e}else if(a.buffer){let e=a.stride||this.positionSize*4;r||=a.buffer.byteLength/e}else if(a.value){let e=a.value,t=a.stride/e.BYTES_PER_ELEMENT||this.positionSize;r||=e.length/t}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=r;let l={};this._forEachGeometry((e,i)=>{let a=c[i]||e;l.vertexStart=n[i],l.indexStart=t[i],l.geometrySize=(i<n.length-1?n[i+1]:r)-n[i],l.geometryIndex=i,this.updateGeometryAttributes(a,l)},o,s),this.vertexCount=t[t.length-1]}}})),EK=o((()=>{zw(),yI(),zP(),GI(),wI(),AI(),bL(),ZP(),bM(),OR(),MI(),RI(),MR(),bie(),YR(),GW(),yG(),uK(),pK(),oB(),fL(),mL(),Oz(),lO(),QF(),aL(),cz(),Zz(),zz(),Vz(),Mz(),CK(),Yz(),bK(),ZR(),gz(),bz(),Nw(),vz(),RW(),TK(),UR(),NG(),VP(),FG(),AG(),TB(),DB(),JG(),ZG()})),DK,OK=o((()=>{JK(),EK(),DK=class{constructor(e){_z(e.id,`id is required`),this.id=e.id,this.type=`custom`,this.renderingMode=e.renderingMode||`3d`,this.slot=e.slot,this.beforeId=e.beforeId,this.map=null}onAdd(e,t){this.map=e}render(e,t){this.map&&LK(this.map.__deck,this.map,this,t)}}}));function kK(e){return e.props.beforeId?`deck-layer-group-before:${e.props.beforeId}`:e.props.slot?`deck-layer-group-slot:${e.props.slot}`:`deck-layer-group-last`}function AK(e,t,n){if(!e||!e.style||!e.style._loaded)return;let r=VR(n,Boolean);if(t!==n){let n=VR(t,Boolean),i=new Set(n.map(e=>kK(e))),a=new Set(r.map(e=>kK(e)));for(let t of i)a.has(t)||e.getLayer(t)&&e.removeLayer(t)}let i={};for(let t of r){let n=kK(t),r=e.getLayer(n);if(r)i[n]=r.implementation||r;else{let r=new DK({id:n,slot:t.props.slot,beforeId:t.props.beforeId});i[n]=r,e.addLayer(r,t.props.beforeId)}}let a=e.style._order;for(let[t,n]of Object.entries(i)){let r=n.beforeId||jK,i=r===jK?a.length:a.indexOf(r);if(a.indexOf(t)!==i-1){let n=r===jK?void 0:r;e.moveLayer(t,n)}}}var jK,MK=o((()=>{EK(),OK(),jK=`__UNDEFINED__`}));function NK({map:e,deck:t}){if(e.__deck)return e.__deck;let n=t.props._customRender,r=t.props.onLoad,i={...t.props,_customRender:()=>{e.triggerRepaint(),n?.(``)}};return i.views||=zK(e),Object.assign(i,{width:null,height:null,touchAction:`unset`,viewState:BK(e)}),t.isInitialized?PK(t,e):i.onLoad=()=>{r?.(),PK(t,e)},t.setProps(i),e.__deck=t,e.on(`render`,()=>{t.isInitialized&&UK(t,e)}),t}function PK(e,t){let n=()=>{e.isInitialized?WK(e,t):t.off(`move`,n)};t.on(`move`,n)}function FK(e){e.__deck?.finalize(),e.__deck=null}function IK(e,t){return t?{depthWriteEnabled:!0,depthCompare:`less-equal`,depthBias:0,blend:!0,blendColorSrcFactor:`src-alpha`,blendColorDstFactor:`one-minus-src-alpha`,blendAlphaSrcFactor:`one`,blendAlphaDstFactor:`one-minus-src-alpha`,blendColorOperation:`add`,blendAlphaOperation:`add`}:{}}function LK(e,t,n,r){if(!e.isInitialized)return;let{currentViewport:i}=e.userData,a=!1;i||(i=HK(e,t,r),e.userData.currentViewport=i,a=!0),i&&e._drawLayers(`mapbox-repaint`,{viewports:[i],layerFilter:t=>{if(e.props.layerFilter&&!e.props.layerFilter(t))return!1;let r=t.layer;return r.props.beforeId===n.beforeId&&r.props.slot===n.slot},clearStack:a,clearCanvas:!1})}function RK(e){let t=e.getProjection?.(),n=t?.type||t?.name;if(n===`globe`)return`globe`;if(n&&n!==`mercator`)throw Error(`Unsupported projection`);return`mercator`}function zK(e){return RK(e)===`globe`?new SK({id:GK}):new Xz({id:GK})}function BK(e){let{lng:t,lat:n}=e.getCenter(),r={longitude:(t+540)%360-180,latitude:n,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&VK(e,r),r}function VK(e,t){if(e.getFreeCameraOptions){let{position:n}=e.getFreeCameraOptions();if(!n||n.z===void 0)return;let r=e.transform.height,{longitude:i,latitude:a,pitch:o}=t,s=n.x*KK,c=(1-n.y)*KK,l=n.z*KK,u=xF([i,a]),d=s-u[0],f=c-u[1],p=Math.sqrt(d*d+f*f),m=o*qK,h=1.5*r,g=m<.001?h*Math.cos(m)/l:h*Math.sin(m)/p;t.zoom=Math.log2(g),t.position=[0,0,(l-h*Math.cos(m)/g)/wF(a)]}else typeof e.transform.elevation==`number`&&(t.position=[0,0,e.transform.elevation])}function HK(e,t,n){let r=BK(t),i=e.getView(`mapbox`)||zK(t);n&&(i.props.nearZMultiplier=.2);let a=n?.nearZ??t.transform._nearZ,o=n?.farZ??t.transform._farZ;return Number.isFinite(a)&&(r.nearZ=a/t.transform.height,r.farZ=o/t.transform.height),i.makeViewport({width:e.width,height:e.height,viewState:r})}function UK(e,t){let n=VR(e.props.layers,Boolean).some(e=>e&&!t.getLayer(kK(e))),r=e.getViewports(),i=r.findIndex(e=>e.id===GK),a=r.length>1||i<0;if(n||a){if(i>=0){r=r.slice();let n=HK(e,t);n?r[i]=n:r.splice(i,1)}e._drawLayers(`mapbox-repaint`,{viewports:r,layerFilter:n=>(!e.props.layerFilter||e.props.layerFilter(n))&&(n.viewport.id!==`mapbox`||!t.getLayer(kK(n.layer))),clearCanvas:!1})}else{let t=e.device,n=t?.gl;e.props.onBeforeRender?.({device:t,gl:n}),e.props.onAfterRender?.({device:t,gl:n})}e.userData.currentViewport=null}function WK(e,t){e.setProps({viewState:BK(t)}),e.needsRedraw({clearRedrawFlags:!0})}var GK,KK,qK,JK=o((()=>{EK(),MK(),QF(),GK=`mapbox`,KK=512,qK=Math.PI/180})),YK,XK=o((()=>{EK(),JK(),MK(),YK=class{constructor(e){this._handleStyleChange=()=>{this._resolveLayers(this._map,this._deck,this._props.layers,this._props.layers),this._map&&RK(this._map)&&this._deck?.setProps({views:this._getViews(this._map)})},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:e,clientHeight:t}=this._map.getContainer();Object.assign(this._container.style,{width:`${e}px`,height:`${t}px`})}},this._updateViewState=()=>{let e=this._deck,t=this._map;e&&t&&(e.setProps({views:this._getViews(t),viewState:BK(t)}),e.isInitialized&&e.redraw())},this._handleMouseEvent=e=>{let t=this._deck;if(!t||!t.isInitialized)return;let n={type:e.type,offsetCenter:e.point,srcEvent:e},r=this._lastMouseDownPoint;switch(!e.point&&r&&(n.deltaX=e.originalEvent.clientX-r.clientX,n.deltaY=e.originalEvent.clientY-r.clientY,n.offsetCenter={x:r.x+n.deltaX,y:r.y+n.deltaY}),n.type){case`mousedown`:t._onPointerDown(n),this._lastMouseDownPoint={...e.point,clientX:e.originalEvent.clientX,clientY:e.originalEvent.clientY};break;case`dragstart`:n.type=`panstart`,t._onEvent(n);break;case`drag`:n.type=`panmove`,t._onEvent(n);break;case`dragend`:n.type=`panend`,t._onEvent(n);break;case`click`:n.tapCount=1,t._onEvent(n);break;case`dblclick`:n.type=`click`,n.tapCount=2,t._onEvent(n);break;case`mousemove`:n.type=`pointermove`,t._onPointerMove(n);break;case`mouseout`:n.type=`pointerleave`,t._onPointerMove(n);break;default:return}};let{interleaved:t=!1}=e;this._interleaved=t,this._props=this.filterProps(e)}filterProps(e){let{interleaved:t=!1,useDevicePixels:n,...r}=e;return!t&&n!==void 0&&(r.useDevicePixels=n),r}setProps(e){this._interleaved&&e.layers&&this._resolveLayers(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,this.filterProps(e)),this._deck&&this._map&&this._deck.setProps({...this._props,views:this._getViews(this._map),parameters:{...IK(this._map,this._interleaved),...this._props.parameters}})}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let t=document.createElement(`div`);return Object.assign(t.style,{position:`absolute`,left:0,top:0,textAlign:`initial`,pointerEvents:`none`}),this._container=t,this._deck=new EW({...this._props,parent:t,parameters:{...IK(e,!1),...this._props.parameters},views:this._getViews(e),viewState:BK(e)}),e.on(`resize`,this._updateContainerSize),e.on(`render`,this._updateViewState),e.on(`mousedown`,this._handleMouseEvent),e.on(`dragstart`,this._handleMouseEvent),e.on(`drag`,this._handleMouseEvent),e.on(`dragend`,this._handleMouseEvent),e.on(`mousemove`,this._handleMouseEvent),e.on(`mouseout`,this._handleMouseEvent),e.on(`click`,this._handleMouseEvent),e.on(`dblclick`,this._handleMouseEvent),this._updateContainerSize(),t}_onAddInterleaved(e){let t=e.painter.context.gl;return t instanceof WebGLRenderingContext&&Mw.warn(`Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility`)(),this._deck=NK({map:e,deck:new EW({...this._props,views:this._getViews(e),gl:t,parameters:{...IK(e,!0),...this._props.parameters}})}),e.on(`styledata`,this._handleStyleChange),this._resolveLayers(e,this._deck,[],this._props.layers),document.createElement(`div`)}_resolveLayers(e,t,n,r){AK(e,n,r)}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off(`resize`,this._updateContainerSize),e.off(`render`,this._updateViewState),e.off(`mousedown`,this._handleMouseEvent),e.off(`dragstart`,this._handleMouseEvent),e.off(`drag`,this._handleMouseEvent),e.off(`dragend`,this._handleMouseEvent),e.off(`mousemove`,this._handleMouseEvent),e.off(`mouseout`,this._handleMouseEvent),e.off(`click`,this._handleMouseEvent),e.off(`dblclick`,this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off(`styledata`,this._handleStyleChange),this._resolveLayers(e,this._deck,this._props.layers,[]),FK(e)}getDefaultPosition(){return`top-left`}pickObject(e){return _z(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return _z(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return _z(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}_getViews(e){if(!this._props.views)return zK(e);let t=Array.isArray(this._props.views)?this._props.views:[this._props.views];return t.some(e=>e.id===`mapbox`)?this._props.views:[zK(e),...t]}}})),ZK=o((()=>{XK()})),QK,$K,eq=o((()=>{QK=`layout(std140) uniform iconUniforms {
|
||
float sizeScale;
|
||
vec2 iconsTextureDim;
|
||
float sizeBasis;
|
||
float sizeMinPixels;
|
||
float sizeMaxPixels;
|
||
bool billboard;
|
||
highp int sizeUnits;
|
||
float alphaCutoff;
|
||
} icon;
|
||
`,$K={name:`icon`,vs:QK,fs:QK,uniformTypes:{sizeScale:`f32`,iconsTextureDim:`vec2<f32>`,sizeBasis:`f32`,sizeMinPixels:`f32`,sizeMaxPixels:`f32`,billboard:`f32`,sizeUnits:`i32`,alphaCutoff:`f32`}}})),tq,nq=o((()=>{tq=`#version 300 es
|
||
#define SHADER_NAME icon-layer-vertex-shader
|
||
in vec2 positions;
|
||
in vec3 instancePositions;
|
||
in vec3 instancePositions64Low;
|
||
in float instanceSizes;
|
||
in float instanceAngles;
|
||
in vec4 instanceColors;
|
||
in vec3 instancePickingColors;
|
||
in vec4 instanceIconFrames;
|
||
in float instanceColorModes;
|
||
in vec2 instanceOffsets;
|
||
in vec2 instancePixelOffset;
|
||
out float vColorMode;
|
||
out vec4 vColor;
|
||
out vec2 vTextureCoords;
|
||
out vec2 uv;
|
||
vec2 rotate_by_angle(vec2 vertex, float angle) {
|
||
float angle_radian = angle * PI / 180.0;
|
||
float cos_angle = cos(angle_radian);
|
||
float sin_angle = sin(angle_radian);
|
||
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
|
||
return rotationMatrix * vertex;
|
||
}
|
||
void main(void) {
|
||
geometry.worldPosition = instancePositions;
|
||
geometry.uv = positions;
|
||
geometry.pickingColor = instancePickingColors;
|
||
uv = positions;
|
||
vec2 iconSize = instanceIconFrames.zw;
|
||
float sizePixels = clamp(
|
||
project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
|
||
icon.sizeMinPixels, icon.sizeMaxPixels
|
||
);
|
||
float iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y;
|
||
float instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint;
|
||
vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
|
||
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
|
||
pixelOffset += instancePixelOffset;
|
||
pixelOffset.y *= -1.0;
|
||
if (icon.billboard) {
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
vec3 offset = vec3(pixelOffset, 0.0);
|
||
DECKGL_FILTER_SIZE(offset, geometry);
|
||
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
|
||
} else {
|
||
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
|
||
DECKGL_FILTER_SIZE(offset_common, geometry);
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
}
|
||
vTextureCoords = mix(
|
||
instanceIconFrames.xy,
|
||
instanceIconFrames.xy + iconSize,
|
||
(positions.xy + 1.0) / 2.0
|
||
) / icon.iconsTextureDim;
|
||
vColor = instanceColors;
|
||
DECKGL_FILTER_COLOR(vColor, geometry);
|
||
vColorMode = instanceColorModes;
|
||
}
|
||
`})),rq,iq=o((()=>{rq=`#version 300 es
|
||
#define SHADER_NAME icon-layer-fragment-shader
|
||
precision highp float;
|
||
uniform sampler2D iconsTexture;
|
||
in float vColorMode;
|
||
in vec4 vColor;
|
||
in vec2 vTextureCoords;
|
||
in vec2 uv;
|
||
out vec4 fragColor;
|
||
void main(void) {
|
||
geometry.uv = uv;
|
||
vec4 texColor = texture(iconsTexture, vTextureCoords);
|
||
vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);
|
||
float a = texColor.a * layer.opacity * vColor.a;
|
||
if (a < icon.alphaCutoff) {
|
||
discard;
|
||
}
|
||
fragColor = vec4(color, a);
|
||
DECKGL_FILTER_COLOR(fragColor, geometry);
|
||
}
|
||
`})),aq,oq=o((()=>{aq=`struct IconUniforms {
|
||
sizeScale: f32,
|
||
iconsTextureDim: vec2<f32>,
|
||
sizeBasis: f32,
|
||
sizeMinPixels: f32,
|
||
sizeMaxPixels: f32,
|
||
billboard: i32,
|
||
sizeUnits: i32,
|
||
alphaCutoff: f32
|
||
};
|
||
|
||
@group(0) @binding(auto) var<uniform> icon: IconUniforms;
|
||
@group(0) @binding(auto) var iconsTexture : texture_2d<f32>;
|
||
@group(0) @binding(auto) var iconsTextureSampler : sampler;
|
||
|
||
fn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> {
|
||
let angle_radian = angle_deg * PI / 180.0;
|
||
let c = cos(angle_radian);
|
||
let s = sin(angle_radian);
|
||
let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c));
|
||
return rotation * vertex;
|
||
}
|
||
|
||
struct Attributes {
|
||
@location(0) positions: vec2<f32>,
|
||
|
||
@location(1) instancePositions: vec3<f32>,
|
||
@location(2) instancePositions64Low: vec3<f32>,
|
||
@location(3) instanceSizes: f32,
|
||
@location(4) instanceAngles: f32,
|
||
@location(5) instanceColors: vec4<f32>,
|
||
@location(6) instancePickingColors: vec3<f32>,
|
||
@location(7) instanceIconFrames: vec4<f32>,
|
||
@location(8) instanceColorModes: f32,
|
||
@location(9) instanceOffsets: vec2<f32>,
|
||
@location(10) instancePixelOffset: vec2<f32>,
|
||
};
|
||
|
||
struct Varyings {
|
||
@builtin(position) position: vec4<f32>,
|
||
|
||
@location(0) vColorMode: f32,
|
||
@location(1) vColor: vec4<f32>,
|
||
@location(2) vTextureCoords: vec2<f32>,
|
||
@location(3) uv: vec2<f32>,
|
||
@location(4) pickingColor: vec3<f32>,
|
||
};
|
||
|
||
@vertex
|
||
fn vertexMain(inp: Attributes) -> Varyings {
|
||
// write geometry fields used by filters + FS
|
||
geometry.worldPosition = inp.instancePositions;
|
||
geometry.uv = inp.positions;
|
||
geometry.pickingColor = inp.instancePickingColors;
|
||
|
||
var outp: Varyings;
|
||
outp.uv = inp.positions;
|
||
|
||
let iconSize = inp.instanceIconFrames.zw;
|
||
|
||
// convert size in meters to pixels, then clamp
|
||
let sizePixels = clamp(
|
||
project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),
|
||
icon.sizeMinPixels, icon.sizeMaxPixels
|
||
);
|
||
|
||
// scale icon height to match instanceSize
|
||
let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0);
|
||
let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0);
|
||
|
||
// scale and rotate vertex in "pixel" units; then add per-instance pixel offset
|
||
var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets;
|
||
pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale;
|
||
pixelOffset = pixelOffset + inp.instancePixelOffset;
|
||
pixelOffset.y = pixelOffset.y * -1.0;
|
||
|
||
if (icon.billboard != 0) {
|
||
var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position);
|
||
// DECKGL_FILTER_GL_POSITION(pos, geometry);
|
||
|
||
var offset = vec3<f32>(pixelOffset, 0.0);
|
||
// DECKGL_FILTER_SIZE(offset, geometry);
|
||
let clipOffset = project_pixel_size_to_clipspace(offset.xy);
|
||
pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w);
|
||
outp.position = pos;
|
||
} else {
|
||
var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);
|
||
// DECKGL_FILTER_SIZE(offset_common, geometry);
|
||
var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position);
|
||
// DECKGL_FILTER_GL_POSITION(pos, geometry);
|
||
outp.position = pos;
|
||
}
|
||
|
||
let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5;
|
||
outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim;
|
||
|
||
outp.vColor = inp.instanceColors;
|
||
// DECKGL_FILTER_COLOR(outp.vColor, geometry);
|
||
|
||
outp.vColorMode = inp.instanceColorModes;
|
||
outp.pickingColor = inp.instancePickingColors;
|
||
|
||
return outp;
|
||
}
|
||
|
||
@fragment
|
||
fn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {
|
||
// expose to deck.gl filter hooks
|
||
geometry.uv = inp.uv;
|
||
|
||
let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords);
|
||
|
||
// if colorMode == 0, use pixel color from the texture
|
||
// if colorMode == 1 (or picking), use texture as transparency mask
|
||
let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode);
|
||
let a = texColor.a * layer.opacity * inp.vColor.a;
|
||
|
||
if (a < icon.alphaCutoff) {
|
||
discard;
|
||
}
|
||
|
||
if (picking.isActive > 0.5) {
|
||
if (!picking_isColorValid(inp.pickingColor)) {
|
||
discard;
|
||
}
|
||
return vec4<f32>(inp.pickingColor, 1.0);
|
||
}
|
||
|
||
var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a));
|
||
|
||
if (picking.isHighlightActive > 0.5) {
|
||
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
||
if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {
|
||
let highLightAlpha = picking.highlightColor.a;
|
||
let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
|
||
if (blendedAlpha > 0.0) {
|
||
let highLightRatio = highLightAlpha / blendedAlpha;
|
||
fragColor = vec4<f32>(
|
||
mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
|
||
blendedAlpha
|
||
);
|
||
} else {
|
||
fragColor = vec4<f32>(fragColor.rgb, 0.0);
|
||
}
|
||
}
|
||
}
|
||
|
||
return fragColor;
|
||
}
|
||
`}));function sq(e){return 2**Math.ceil(Math.log2(e))}function cq(e,t,n,r){let i=Math.min(n/t.width,r/t.height),a=Math.floor(t.width*i),o=Math.floor(t.height*i);return i===1?{image:t,width:a,height:o}:(e.canvas.height=o,e.canvas.width=a,e.clearRect(0,0,a,o),e.drawImage(t,0,0,t.width,t.height,0,0,a,o),{image:e.canvas,width:a,height:o})}function lq(e){return e&&(e.id||e.url)}function uq(e){let{device:t}=e;t.type===`webgl`?e.generateMipmapsWebGL():t.type===`webgpu`&&t.generateMipmapsWebGPU(e)}function dq(e,t,n,r){let{width:i,height:a,device:o}=e,s=o.createTexture({format:`rgba8unorm`,width:t,height:n,sampler:r,mipLevels:o.getMipLevelCount(t,n)}),c=o.createCommandEncoder();c.copyTextureToTexture({sourceTexture:e,destinationTexture:s,width:i,height:a});let l=c.finish();return o.submit(l),uq(s),e.destroy(),s}function fq(e,t,n){for(let r=0;r<t.length;r++){let{icon:i,xOffset:a}=t[r],o=lq(i);e[o]={...i,x:a,y:n}}}function pq({icons:e,buffer:t,mapping:n={},xOffset:r=0,yOffset:i=0,rowHeight:a=0,canvasWidth:o}){let s=[];for(let c=0;c<e.length;c++){let l=e[c];if(!n[lq(l)]){let{height:e,width:c}=l;r+c+t>o&&(fq(n,s,i),r=0,i=a+i+t,a=0,s=[]),s.push({icon:l,xOffset:r}),r=r+c+t,a=Math.max(a,e)}}return s.length>0&&fq(n,s,i),{mapping:n,rowHeight:a,xOffset:r,yOffset:i,canvasWidth:o,canvasHeight:sq(a+i+t)}}function mq(e,t,n){if(!e||!t)return null;n||={};let r={},{iterable:i,objectInfo:a}=NW(e);for(let e of i){a.index++;let i=t(e,a),o=lq(i);if(!i)throw Error(`Icon is missing.`);if(!i.url)throw Error(`Icon url is missing.`);!r[o]&&(!n[o]||i.url!==n[o].url)&&(r[o]={...i,source:e,sourceIndex:a.index})}return r}var hq,gq,_q,vq,yq,bq,xq=o((()=>{ow(),EK(),hq=1024,gq=4,_q=()=>{},vq={minFilter:`linear`,mipmapFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`},yq={x:0,y:0,width:0,height:0},bq=class{constructor(e,{onUpdate:t=_q,onError:n=_q}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=gq,this._canvasWidth=hq,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=t,this.onError=n}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let t=this._autoPacking?lq(e):e;return this._mapping[t]||yq}setProps({loadOptions:e,autoPacking:t,iconAtlas:n,iconMapping:r,textureParameters:i}){e&&(this._loadOptions=e),t!==void 0&&(this._autoPacking=t),r&&(this._mapping=r),n&&(this._texture?.delete(),this._texture=null,this._externalTexture=n),i&&(this._samplerParameters=i)}get isLoaded(){return this._pendingCount===0}packIcons(e,t){if(!this._autoPacking||typeof document>`u`)return;let n=Object.values(mq(e,t,this._mapping)||{});if(n.length>0){let{mapping:e,xOffset:t,yOffset:r,rowHeight:i,canvasHeight:a}=pq({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=i,this._mapping=e,this._xOffset=t,this._yOffset=r,this._canvasHeight=a,this._texture||=this.device.createTexture({format:`rgba8unorm`,data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||vq,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)}),this._texture.height!==this._canvasHeight&&(this._texture=dq(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||vq)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement(`canvas`),this._loadIcons(n)}}_loadIcons(e){let t=this._canvas.getContext(`2d`,{willReadFrequently:!0});for(let n of e)this._pendingCount++,aw(n.url,this._loadOptions).then(e=>{let r=lq(n),i=this._mapping[r],{x:a,y:o,width:s,height:c}=i,{image:l,width:u,height:d}=cq(t,e,s,c),f=a+(s-u)/2,p=o+(c-d)/2;this._texture?.copyExternalImage({image:l,x:f,y:p,width:u,height:d}),i.x=f,i.y=p,i.width=u,i.height=d,this._texture&&uq(this._texture),this.onUpdate(u!==s||d!==c)}).catch(e=>{this.onError({url:n.url,source:n.source,sourceIndex:n.sourceIndex,loadOptions:this._loadOptions,error:e})}).finally(()=>{this._pendingCount--})}}})),Sq,Cq,wq,Tq=o((()=>{EK(),OR(),eq(),nq(),iq(),oq(),xq(),Sq=[0,0,0,255],Cq={iconAtlas:{type:`image`,value:null,async:!0},iconMapping:{type:`object`,value:{},async:!0},sizeScale:{type:`number`,value:1,min:0},billboard:!0,sizeUnits:`pixels`,sizeBasis:`height`,sizeMinPixels:{type:`number`,min:0,value:0},sizeMaxPixels:{type:`number`,min:0,value:2**53-1},alphaCutoff:{type:`number`,value:.05,min:0,max:1},getPosition:{type:`accessor`,value:e=>e.position},getIcon:{type:`accessor`,value:e=>e.icon},getColor:{type:`accessor`,value:Sq},getSize:{type:`accessor`,value:1},getAngle:{type:`accessor`,value:0},getPixelOffset:{type:`accessor`,value:[0,0]},onIconError:{type:`function`,value:null,optional:!0},textureParameters:{type:`object`,ignore:!0,value:null}},wq=class extends lK{getShaders(){return super.getShaders({vs:tq,fs:rq,source:aq,modules:[fF,EM,pI,$K]})}initializeState(){this.state={iconManager:new bq(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`},instanceSizes:{size:1,transition:!0,accessor:`getSize`,defaultValue:1},instanceIconDefs:{size:7,accessor:`getIcon`,transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:`unorm8`,transition:!0,accessor:`getColor`,defaultValue:Sq},instanceAngles:{size:1,transition:!0,accessor:`getAngle`},instancePixelOffset:{size:2,transition:!0,accessor:`getPixelOffset`}})}updateState(e){super.updateState(e);let{props:t,oldProps:n,changeFlags:r}=e,i=this.getAttributeManager(),{iconAtlas:a,iconMapping:o,data:s,getIcon:c,textureParameters:l}=t,{iconManager:u}=this.state;if(typeof a==`string`)return;let d=a||this.internalState.isAsyncPropLoading(`iconAtlas`);u.setProps({loadOptions:t.loadOptions,autoPacking:!d,iconAtlas:a,iconMapping:d?o:null,textureParameters:l}),d?n.iconMapping!==t.iconMapping&&i.invalidate(`getIcon`):(r.dataChanged||r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getIcon))&&u.packIcons(s,c),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:t,sizeBasis:n,sizeMinPixels:r,sizeMaxPixels:i,sizeUnits:a,billboard:o,alphaCutoff:s}=this.props,{iconManager:c}=this.state,l=c.getTexture();if(l){let e=this.state.model,c={iconsTexture:l,iconsTextureDim:[l.width,l.height],sizeUnits:IP[a],sizeScale:t,sizeBasis:+(n===`height`),sizeMinPixels:r,sizeMaxPixels:i,billboard:o,alphaCutoff:s};e.shaderInputs.setProps({icon:c}),e.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new wR(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new DR({topology:`triangle-strip`,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(e){e?(this.getAttributeManager()?.invalidate(`getIcon`),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){let t=this.getCurrentLayer()?.props.onIconError;t?t(e):Mw.error(e.error.message)()}getInstanceIconDef(e){let{x:t,y:n,width:r,height:i,mask:a,anchorX:o=r/2,anchorY:s=i/2}=this.state.iconManager.getIconMapping(e);return[r/2-o,i/2-s,t,n,r,i,+!!a]}},wq.defaultProps=Cq,wq.layerName=`IconLayer`})),Eq,Dq,Oq=o((()=>{Eq=`layout(std140) uniform pointCloudUniforms {
|
||
float radiusPixels;
|
||
highp int sizeUnits;
|
||
} pointCloud;
|
||
`,Dq={name:`pointCloud`,source:``,vs:Eq,fs:Eq,uniformTypes:{radiusPixels:`f32`,sizeUnits:`i32`}}})),kq,Aq=o((()=>{kq=`#version 300 es
|
||
#define SHADER_NAME point-cloud-layer-vertex-shader
|
||
in vec3 positions;
|
||
in vec3 instanceNormals;
|
||
in vec4 instanceColors;
|
||
in vec3 instancePositions;
|
||
in vec3 instancePositions64Low;
|
||
in vec3 instancePickingColors;
|
||
out vec4 vColor;
|
||
out vec2 unitPosition;
|
||
void main(void) {
|
||
geometry.worldPosition = instancePositions;
|
||
geometry.normal = project_normal(instanceNormals);
|
||
unitPosition = positions.xy;
|
||
geometry.uv = unitPosition;
|
||
geometry.pickingColor = instancePickingColors;
|
||
vec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);
|
||
DECKGL_FILTER_SIZE(offset, geometry);
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
|
||
vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
|
||
vColor = vec4(lightColor, instanceColors.a * layer.opacity);
|
||
DECKGL_FILTER_COLOR(vColor, geometry);
|
||
}
|
||
`})),jq,Mq=o((()=>{jq=`#version 300 es
|
||
#define SHADER_NAME point-cloud-layer-fragment-shader
|
||
precision highp float;
|
||
in vec4 vColor;
|
||
in vec2 unitPosition;
|
||
out vec4 fragColor;
|
||
void main(void) {
|
||
geometry.uv = unitPosition.xy;
|
||
float distToCenter = length(unitPosition);
|
||
if (distToCenter > 1.0) {
|
||
discard;
|
||
}
|
||
fragColor = vColor;
|
||
DECKGL_FILTER_COLOR(fragColor, geometry);
|
||
}
|
||
`})),Nq,Pq=o((()=>{Nq=`struct PointCloudUniforms {
|
||
radiusPixels: f32,
|
||
sizeUnits: i32,
|
||
};
|
||
|
||
@group(0) @binding(0)
|
||
var<uniform> pointCloudUniforms: PointCloudUniforms;
|
||
|
||
struct ConstantAttributes {
|
||
instanceNormals: vec3<f32>,
|
||
instanceColors: vec4<f32>,
|
||
instancePositions: vec3<f32>,
|
||
instancePositions64Low: vec3<f32>,
|
||
instancePickingColors: vec3<f32>
|
||
};
|
||
|
||
const constants = ConstantAttributes(
|
||
vec3<f32>(1.0, 0.0, 0.0),
|
||
vec4<f32>(0.0, 0.0, 0.0, 1.0),
|
||
vec3<f32>(0.0),
|
||
vec3<f32>(0.0),
|
||
vec3<f32>(0.0)
|
||
);
|
||
|
||
struct Attributes {
|
||
@builtin(instance_index) instanceIndex : u32,
|
||
@builtin(vertex_index) vertexIndex : u32,
|
||
@location(0) positions: vec3<f32>,
|
||
@location(1) instancePositions: vec3<f32>,
|
||
@location(2) instancePositions64Low: vec3<f32>,
|
||
@location(3) instanceNormals: vec3<f32>,
|
||
@location(4) instanceColors: vec4<f32>,
|
||
@location(5) instancePickingColors: vec3<f32>
|
||
};
|
||
|
||
struct Varyings {
|
||
@builtin(position) position: vec4<f32>,
|
||
@location(0) vColor: vec4<f32>,
|
||
@location(1) unitPosition: vec2<f32>,
|
||
@location(2) pickingColor: vec3<f32>,
|
||
};
|
||
|
||
@vertex
|
||
fn vertexMain(attributes: Attributes) -> Varyings {
|
||
var varyings: Varyings;
|
||
|
||
geometry.worldPosition = attributes.instancePositions;
|
||
|
||
let centerResult = project_position_to_clipspace_and_commonspace(
|
||
attributes.instancePositions,
|
||
attributes.instancePositions64Low,
|
||
vec3<f32>(0.0)
|
||
);
|
||
geometry.position = centerResult.commonPosition;
|
||
geometry.normal = project_normal(attributes.instanceNormals);
|
||
|
||
// position on the containing square in [-1, 1] space
|
||
varyings.unitPosition = attributes.positions.xy;
|
||
geometry.uv = varyings.unitPosition;
|
||
geometry.pickingColor = attributes.instancePickingColors;
|
||
|
||
// Find the center of the point and add the current vertex
|
||
let offset = vec3<f32>(
|
||
attributes.positions.xy *
|
||
project_unit_size_to_pixel(pointCloudUniforms.radiusPixels, pointCloudUniforms.sizeUnits),
|
||
0.0
|
||
);
|
||
// DECKGL_FILTER_SIZE(offset, geometry);
|
||
|
||
varyings.position = centerResult.clipPosition;
|
||
// DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
let clipPixels = project_pixel_size_to_clipspace(offset.xy);
|
||
varyings.position.x += clipPixels.x;
|
||
varyings.position.y += clipPixels.y;
|
||
|
||
// Apply lighting
|
||
let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
|
||
|
||
// Apply opacity to instance color, or return instance picking color
|
||
varyings.vColor = vec4(lightColor, attributes.instanceColors.a * layer.opacity);
|
||
// DECKGL_FILTER_COLOR(vColor, geometry);
|
||
varyings.pickingColor = attributes.instancePickingColors;
|
||
|
||
return varyings;
|
||
}
|
||
|
||
@fragment
|
||
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
||
// var geometry: Geometry;
|
||
// geometry.uv = unitPosition.xy;
|
||
|
||
let distToCenter = length(varyings.unitPosition);
|
||
if (distToCenter > 1.0) {
|
||
discard;
|
||
}
|
||
|
||
var fragColor: vec4<f32>;
|
||
|
||
fragColor = varyings.vColor;
|
||
|
||
if (picking.isActive > 0.5) {
|
||
if (!picking_isColorValid(varyings.pickingColor)) {
|
||
discard;
|
||
}
|
||
return vec4<f32>(varyings.pickingColor, 1.0);
|
||
}
|
||
|
||
if (picking.isHighlightActive > 0.5) {
|
||
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
||
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
||
let highLightAlpha = picking.highlightColor.a;
|
||
let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
|
||
if (blendedAlpha > 0.0) {
|
||
let highLightRatio = highLightAlpha / blendedAlpha;
|
||
fragColor = vec4<f32>(
|
||
mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
|
||
blendedAlpha
|
||
);
|
||
} else {
|
||
fragColor = vec4<f32>(fragColor.rgb, 0.0);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Apply premultiplied alpha as required by transparent canvas
|
||
fragColor = deckgl_premultiplied_alpha(fragColor);
|
||
|
||
return fragColor;
|
||
}
|
||
`}));function Fq(e){let{header:t,attributes:n}=e;if(!(!t||!n)&&(e.length=t.vertexCount,n.POSITION&&(n.instancePositions=n.POSITION),n.NORMAL&&(n.instanceNormals=n.NORMAL),n.COLOR_0)){let{size:e,value:t}=n.COLOR_0;n.instanceColors={size:e,type:`unorm8`,value:t}}}var Iq,Lq,Rq,zq,Bq=o((()=>{EK(),OR(),Oq(),Aq(),Mq(),Pq(),Iq=[0,0,0,255],Lq=[0,0,1],Rq={sizeUnits:`pixels`,pointSize:{type:`number`,min:0,value:10},getPosition:{type:`accessor`,value:e=>e.position},getNormal:{type:`accessor`,value:Lq},getColor:{type:`accessor`,value:Iq},material:!0,radiusPixels:{deprecatedFor:`pointSize`}},zq=class extends lK{getShaders(){return super.getShaders({vs:kq,fs:jq,source:Nq,modules:[fF,EM,vM,pI,Dq]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`},instanceNormals:{size:3,transition:!0,accessor:`getNormal`,defaultValue:Lq},instanceColors:{size:this.props.colorFormat.length,type:`unorm8`,transition:!0,accessor:`getColor`,defaultValue:Iq}})}updateState(e){let{changeFlags:t,props:n}=e;super.updateState(e),t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),t.dataChanged&&Fq(n.data)}draw({uniforms:e}){let{pointSize:t,sizeUnits:n}=this.props,r=this.state.model,i={sizeUnits:IP[n],radiusPixels:t};r.shaderInputs.setProps({pointCloud:i}),r.draw(this.context.renderPass)}_getModel(){let e=[];for(let t=0;t<3;t++){let n=t/3*Math.PI*2;e.push(Math.cos(n)*2,Math.sin(n)*2,0)}return new wR(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new DR({topology:`triangle-list`,attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}},zq.layerName=`PointCloudLayer`,zq.defaultProps=Rq})),Vq,Hq,Uq=o((()=>{Vq=`layout(std140) uniform scatterplotUniforms {
|
||
float radiusScale;
|
||
float radiusMinPixels;
|
||
float radiusMaxPixels;
|
||
float lineWidthScale;
|
||
float lineWidthMinPixels;
|
||
float lineWidthMaxPixels;
|
||
float stroked;
|
||
float filled;
|
||
bool antialiasing;
|
||
bool billboard;
|
||
highp int radiusUnits;
|
||
highp int lineWidthUnits;
|
||
} scatterplot;
|
||
`,Hq={name:`scatterplot`,vs:Vq,fs:Vq,source:``,uniformTypes:{radiusScale:`f32`,radiusMinPixels:`f32`,radiusMaxPixels:`f32`,lineWidthScale:`f32`,lineWidthMinPixels:`f32`,lineWidthMaxPixels:`f32`,stroked:`f32`,filled:`f32`,antialiasing:`f32`,billboard:`f32`,radiusUnits:`i32`,lineWidthUnits:`i32`}}})),Wq,Gq=o((()=>{Wq=`#version 300 es
|
||
#define SHADER_NAME scatterplot-layer-vertex-shader
|
||
in vec3 positions;
|
||
in vec3 instancePositions;
|
||
in vec3 instancePositions64Low;
|
||
in float instanceRadius;
|
||
in float instanceLineWidths;
|
||
in vec4 instanceFillColors;
|
||
in vec4 instanceLineColors;
|
||
in vec3 instancePickingColors;
|
||
in vec2 instancePixelOffset;
|
||
out vec4 vFillColor;
|
||
out vec4 vLineColor;
|
||
out vec2 unitPosition;
|
||
out float innerUnitRadius;
|
||
out float outerRadiusPixels;
|
||
void main(void) {
|
||
geometry.worldPosition = instancePositions;
|
||
outerRadiusPixels = clamp(
|
||
project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),
|
||
scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
|
||
);
|
||
float lineWidthPixels = clamp(
|
||
project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),
|
||
scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
|
||
);
|
||
outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
|
||
float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;
|
||
unitPosition = edgePadding * positions.xy;
|
||
geometry.uv = unitPosition;
|
||
geometry.pickingColor = instancePickingColors;
|
||
innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;
|
||
if (scatterplot.billboard) {
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
vec3 offset = edgePadding * positions * outerRadiusPixels;
|
||
offset.xy += instancePixelOffset;
|
||
DECKGL_FILTER_SIZE(offset, geometry);
|
||
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
|
||
} else {
|
||
vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);
|
||
offset.xy += project_pixel_size(instancePixelOffset);
|
||
DECKGL_FILTER_SIZE(offset, geometry);
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
}
|
||
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
|
||
DECKGL_FILTER_COLOR(vFillColor, geometry);
|
||
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
|
||
DECKGL_FILTER_COLOR(vLineColor, geometry);
|
||
}
|
||
`})),Kq,qq=o((()=>{Kq=`#version 300 es
|
||
#define SHADER_NAME scatterplot-layer-fragment-shader
|
||
precision highp float;
|
||
in vec4 vFillColor;
|
||
in vec4 vLineColor;
|
||
in vec2 unitPosition;
|
||
in float innerUnitRadius;
|
||
in float outerRadiusPixels;
|
||
out vec4 fragColor;
|
||
void main(void) {
|
||
geometry.uv = unitPosition;
|
||
float distToCenter = length(unitPosition) * outerRadiusPixels;
|
||
float inCircle = scatterplot.antialiasing ?
|
||
smoothedge(distToCenter, outerRadiusPixels) :
|
||
step(distToCenter, outerRadiusPixels);
|
||
if (inCircle == 0.0) {
|
||
discard;
|
||
}
|
||
if (scatterplot.stroked > 0.5) {
|
||
float isLine = scatterplot.antialiasing ?
|
||
smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :
|
||
step(innerUnitRadius * outerRadiusPixels, distToCenter);
|
||
if (scatterplot.filled > 0.5) {
|
||
fragColor = mix(vFillColor, vLineColor, isLine);
|
||
} else {
|
||
if (isLine == 0.0) {
|
||
discard;
|
||
}
|
||
fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);
|
||
}
|
||
} else if (scatterplot.filled < 0.5) {
|
||
discard;
|
||
} else {
|
||
fragColor = vFillColor;
|
||
}
|
||
fragColor.a *= inCircle;
|
||
DECKGL_FILTER_COLOR(fragColor, geometry);
|
||
}
|
||
`})),Jq,Yq=o((()=>{Jq=`// Main shaders
|
||
|
||
struct ScatterplotUniforms {
|
||
radiusScale: f32,
|
||
radiusMinPixels: f32,
|
||
radiusMaxPixels: f32,
|
||
lineWidthScale: f32,
|
||
lineWidthMinPixels: f32,
|
||
lineWidthMaxPixels: f32,
|
||
stroked: f32,
|
||
filled: i32,
|
||
antialiasing: i32,
|
||
billboard: i32,
|
||
radiusUnits: i32,
|
||
lineWidthUnits: i32,
|
||
};
|
||
|
||
struct ConstantAttributeUniforms {
|
||
instancePositions: vec3<f32>,
|
||
instancePositions64Low: vec3<f32>,
|
||
instanceRadius: f32,
|
||
instanceLineWidths: f32,
|
||
instanceFillColors: vec4<f32>,
|
||
instanceLineColors: vec4<f32>,
|
||
instancePickingColors: vec3<f32>,
|
||
instancePixelOffset: vec2<f32>,
|
||
|
||
instancePositionsConstant: i32,
|
||
instancePositions64LowConstant: i32,
|
||
instanceRadiusConstant: i32,
|
||
instanceLineWidthsConstant: i32,
|
||
instanceFillColorsConstant: i32,
|
||
instanceLineColorsConstant: i32,
|
||
instancePickingColorsConstant: i32,
|
||
instancePixelOffsetConstant: i32
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms;
|
||
|
||
struct ConstantAttributes {
|
||
instancePositions: vec3<f32>,
|
||
instancePositions64Low: vec3<f32>,
|
||
instanceRadius: f32,
|
||
instanceLineWidths: f32,
|
||
instanceFillColors: vec4<f32>,
|
||
instanceLineColors: vec4<f32>,
|
||
instancePickingColors: vec3<f32>,
|
||
instancePixelOffset: vec2<f32>
|
||
};
|
||
|
||
const constants = ConstantAttributes(
|
||
vec3<f32>(0.0),
|
||
vec3<f32>(0.0),
|
||
0.0,
|
||
0.0,
|
||
vec4<f32>(0.0, 0.0, 0.0, 1.0),
|
||
vec4<f32>(0.0, 0.0, 0.0, 1.0),
|
||
vec3<f32>(0.0),
|
||
vec2<f32>(0.0)
|
||
);
|
||
|
||
struct Attributes {
|
||
@builtin(instance_index) instanceIndex : u32,
|
||
@builtin(vertex_index) vertexIndex : u32,
|
||
@location(0) positions: vec3<f32>,
|
||
@location(1) instancePositions: vec3<f32>,
|
||
@location(2) instancePositions64Low: vec3<f32>,
|
||
@location(3) instanceRadius: f32,
|
||
@location(4) instanceLineWidths: f32,
|
||
@location(5) instanceFillColors: vec4<f32>,
|
||
@location(6) instanceLineColors: vec4<f32>,
|
||
@location(7) instancePickingColors: vec3<f32>,
|
||
@location(8) instancePixelOffset: vec2<f32>
|
||
};
|
||
|
||
struct Varyings {
|
||
@builtin(position) position: vec4<f32>,
|
||
@location(0) vFillColor: vec4<f32>,
|
||
@location(1) vLineColor: vec4<f32>,
|
||
@location(2) unitPosition: vec2<f32>,
|
||
@location(3) innerUnitRadius: f32,
|
||
@location(4) outerRadiusPixels: f32,
|
||
@location(5) pickingColor: vec3<f32>,
|
||
};
|
||
|
||
@vertex
|
||
fn vertexMain(attributes: Attributes) -> Varyings {
|
||
var varyings: Varyings;
|
||
|
||
// Draw an inline geometry constant array clip space triangle to verify that rendering works.
|
||
// var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));
|
||
// if (attributes.instanceIndex == 0) {
|
||
// varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0);
|
||
// return varyings;
|
||
// }
|
||
|
||
geometry.worldPosition = attributes.instancePositions;
|
||
|
||
// Multiply out radius and clamp to limits
|
||
varyings.outerRadiusPixels = clamp(
|
||
project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),
|
||
scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
|
||
);
|
||
|
||
// Multiply out line width and clamp to limits
|
||
let lineWidthPixels = clamp(
|
||
project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),
|
||
scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
|
||
);
|
||
|
||
// outer radius needs to offset by half stroke width
|
||
varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
|
||
// Expand geometry to accommodate edge smoothing
|
||
let edgePadding = select(
|
||
(varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,
|
||
1.0,
|
||
scatterplot.antialiasing != 0
|
||
);
|
||
|
||
// position on the containing square in [-1, 1] space
|
||
varyings.unitPosition = edgePadding * attributes.positions.xy;
|
||
geometry.uv = varyings.unitPosition;
|
||
geometry.pickingColor = attributes.instancePickingColors;
|
||
|
||
varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;
|
||
|
||
if (scatterplot.billboard != 0) {
|
||
varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);
|
||
// DECKGL_FILTER_GL_POSITION(varyings.position, geometry);
|
||
var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels;
|
||
offset = vec3<f32>(offset.xy + attributes.instancePixelOffset, offset.z);
|
||
// DECKGL_FILTER_SIZE(offset, geometry);
|
||
let clipPixels = project_pixel_size_to_clipspace(offset.xy);
|
||
varyings.position = vec4<f32>(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w);
|
||
} else {
|
||
var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);
|
||
offset = vec3<f32>(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z);
|
||
// DECKGL_FILTER_SIZE(offset, geometry);
|
||
varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);
|
||
// DECKGL_FILTER_GL_POSITION(varyings.position, geometry);
|
||
}
|
||
|
||
// Apply opacity to instance color, or return instance picking color
|
||
varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity);
|
||
// DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);
|
||
varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity);
|
||
// DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);
|
||
varyings.pickingColor = attributes.instancePickingColors;
|
||
|
||
return varyings;
|
||
}
|
||
|
||
@fragment
|
||
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
||
// var geometry: Geometry;
|
||
// geometry.uv = unitPosition;
|
||
|
||
let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;
|
||
let inCircle = select(
|
||
smoothedge(distToCenter, varyings.outerRadiusPixels),
|
||
step(distToCenter, varyings.outerRadiusPixels),
|
||
scatterplot.antialiasing != 0
|
||
);
|
||
|
||
if (inCircle == 0.0) {
|
||
discard;
|
||
}
|
||
|
||
var fragColor: vec4<f32>;
|
||
|
||
if (scatterplot.stroked != 0) {
|
||
let isLine = select(
|
||
smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),
|
||
step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),
|
||
scatterplot.antialiasing != 0
|
||
);
|
||
|
||
if (scatterplot.filled != 0) {
|
||
fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);
|
||
} else {
|
||
if (isLine == 0.0) {
|
||
discard;
|
||
}
|
||
fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);
|
||
}
|
||
} else if (scatterplot.filled == 0) {
|
||
discard;
|
||
} else {
|
||
fragColor = varyings.vFillColor;
|
||
}
|
||
|
||
fragColor.a *= inCircle;
|
||
|
||
if (picking.isActive > 0.5) {
|
||
if (!picking_isColorValid(varyings.pickingColor)) {
|
||
discard;
|
||
}
|
||
return vec4<f32>(varyings.pickingColor, 1.0);
|
||
}
|
||
|
||
if (picking.isHighlightActive > 0.5) {
|
||
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
||
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
||
let highLightAlpha = picking.highlightColor.a;
|
||
let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
|
||
if (blendedAlpha > 0.0) {
|
||
let highLightRatio = highLightAlpha / blendedAlpha;
|
||
fragColor = vec4<f32>(
|
||
mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
|
||
blendedAlpha
|
||
);
|
||
} else {
|
||
fragColor = vec4<f32>(fragColor.rgb, 0.0);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Apply premultiplied alpha as required by transparent canvas
|
||
fragColor = deckgl_premultiplied_alpha(fragColor);
|
||
|
||
return fragColor;
|
||
// return vec4<f32>(0, 0, 1, 1);
|
||
}
|
||
`})),Xq,Zq,Qq,$q=o((()=>{EK(),OR(),Uq(),Gq(),qq(),Yq(),Xq=[0,0,0,255],Zq={radiusUnits:`meters`,radiusScale:{type:`number`,min:0,value:1},radiusMinPixels:{type:`number`,min:0,value:0},radiusMaxPixels:{type:`number`,min:0,value:2**53-1},lineWidthUnits:`meters`,lineWidthScale:{type:`number`,min:0,value:1},lineWidthMinPixels:{type:`number`,min:0,value:0},lineWidthMaxPixels:{type:`number`,min:0,value:2**53-1},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:`accessor`,value:e=>e.position},getRadius:{type:`accessor`,value:1},getFillColor:{type:`accessor`,value:Xq},getLineColor:{type:`accessor`,value:Xq},getLineWidth:{type:`accessor`,value:1},getPixelOffset:{type:`accessor`,value:[0,0]},strokeWidth:{deprecatedFor:`getLineWidth`},outline:{deprecatedFor:`stroked`},getColor:{deprecatedFor:[`getFillColor`,`getLineColor`]}},Qq=class extends lK{getShaders(){return super.getShaders({vs:Wq,fs:Kq,source:Jq,modules:[fF,EM,pI,Hq]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`},instanceRadius:{size:1,transition:!0,accessor:`getRadius`,defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:`unorm8`,accessor:`getFillColor`,defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:`unorm8`,accessor:`getLineColor`,defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:`getLineWidth`,defaultValue:1},instancePixelOffset:{size:2,transition:!0,accessor:`getPixelOffset`}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:t,radiusScale:n,radiusMinPixels:r,radiusMaxPixels:i,stroked:a,filled:o,billboard:s,antialiasing:c,lineWidthUnits:l,lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:f}=this.props,p={stroked:a,filled:o,billboard:s,antialiasing:c,radiusUnits:IP[t],radiusScale:n,radiusMinPixels:r,radiusMaxPixels:i,lineWidthUnits:IP[l],lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:f},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new wR(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new DR({topology:`triangle-strip`,attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}},Qq.defaultProps=Zq,Qq.layerName=`ScatterplotLayer`}));function eJ(e,t,n={}){return tJ(e,n)===t?!1:(rJ(e,n),!0)}function tJ(e,t={}){return Math.sign(nJ(e,t))}function nJ(e,t={}){let{start:n=0,end:r=e.length,plane:i=`xy`}=t,a=t.size||2,o=0,s=aJ[i[0]],c=aJ[i[1]];for(let t=n,i=r-a;t<r;t+=a)o+=(e[t+s]-e[i+s])*(e[t+c]+e[i+c]),i=t;return o/2}function rJ(e,t){let{start:n=0,end:r=e.length,size:i=2}=t,a=(r-n)/i,o=Math.floor(a/2);for(let t=0;t<o;++t){let r=n+t*i,o=n+(a-1-t)*i;for(let t=0;t<i;++t){let n=e[r+t];e[r+t]=e[o+t],e[o+t]=n}}}var iJ,aJ,oJ=o((()=>{iJ={CLOCKWISE:1,COUNTER_CLOCKWISE:-1},aJ={x:0,y:1,z:2}}));function sJ(e,t){let n=t.length,r=e.length;if(r>0){let i=!0;for(let a=0;a<n;a++)if(e[r-n+a]!==t[a]){i=!1;break}if(i)return!1}for(let i=0;i<n;i++)e[r+i]=t[i];return!0}function cJ(e,t){let n=t.length;for(let r=0;r<n;r++)e[r]=t[r]}function lJ(e,t,n,r,i=[]){let a=r+t*n;for(let t=0;t<n;t++)i[t]=e[a+t];return i}var uJ=o((()=>{}));function dJ(e,t,n,r,i=[]){let a,o;if(n&8)a=(r[3]-e[1])/(t[1]-e[1]),o=3;else if(n&4)a=(r[1]-e[1])/(t[1]-e[1]),o=1;else if(n&2)a=(r[2]-e[0])/(t[0]-e[0]),o=2;else if(n&1)a=(r[0]-e[0])/(t[0]-e[0]),o=0;else return null;for(let n=0;n<e.length;n++)i[n]=(o&1)===n?r[o]:a*(t[n]-e[n])+e[n];return i}function fJ(e,t){let n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}var pJ=o((()=>{}));function mJ(e,t){let{size:n=2,broken:r=!1,gridResolution:i=10,gridOffset:a=[0,0],startIndex:o=0,endIndex:s=e.length}=t||{},c=(s-o)/n,l=[],u=[l],d=lJ(e,0,n,o),f,p,m=_J(d,i,a,[]),h=[];sJ(l,d);for(let t=1;t<c;t++){for(f=lJ(e,t,n,o,f),p=fJ(f,m);p;){dJ(d,f,p,m,h);let e=fJ(h,m);e&&(dJ(d,h,e,m,h),p=e),sJ(l,h),cJ(d,h),vJ(m,i,p),r&&l.length>n&&(l=[],u.push(l),sJ(l,d)),p=fJ(f,m)}sJ(l,f),cJ(d,f)}return r?u:u[0]}function hJ(e,t=null,n){if(!e.length)return[];let{size:r=2,gridResolution:i=10,gridOffset:a=[0,0],edgeTypes:o=!1}=n||{},s=[],c=[{pos:e,types:o?Array(e.length/r).fill(SJ):null,holes:t||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:e,types:t,holes:n}=c.shift();yJ(e,r,n[0]||e.length,l),u=_J(l[0],i,a,u);let d=fJ(l[1],u);if(d){let i=gJ(e,t,r,0,n[0]||e.length,u,d),a={pos:i[0].pos,types:i[0].types,holes:[]},s={pos:i[1].pos,types:i[1].types,holes:[]};c.push(a,s);for(let c=0;c<n.length;c++)i=gJ(e,t,r,n[c],n[c+1]||e.length,u,d),i[0]&&(a.holes.push(a.pos.length),a.pos=bJ(a.pos,i[0].pos),o&&(a.types=bJ(a.types,i[0].types))),i[1]&&(s.holes.push(s.pos.length),s.pos=bJ(s.pos,i[1].pos),o&&(s.types=bJ(s.types,i[1].types)))}else{let r={positions:e};o&&(r.edgeTypes=t),n.length&&(r.holeIndices=n),s.push(r)}}return s}function gJ(e,t,n,r,i,a,o){let s=(i-r)/n,c=[],l=[],u=[],d=[],f=[],p,m,h,g=lJ(e,s-1,n,r),_=Math.sign(o&8?g[1]-a[3]:g[0]-a[2]),v=t&&t[s-1],y=0,b=0;for(let i=0;i<s;i++)p=lJ(e,i,n,r,p),m=Math.sign(o&8?p[1]-a[3]:p[0]-a[2]),h=t&&t[r/n+i],m&&_&&_!==m&&(dJ(g,p,o,a,f),sJ(c,f)&&u.push(v),sJ(l,f)&&d.push(v)),m<=0?(sJ(c,p)&&u.push(h),y-=m):u.length&&(u[u.length-1]=xJ),m>=0?(sJ(l,p)&&d.push(h),b+=m):d.length&&(d[d.length-1]=xJ),cJ(g,p),_=m,v=h;return[y?{pos:c,types:t&&u}:null,b?{pos:l,types:t&&d}:null]}function _J(e,t,n,r){let i=Math.floor((e[0]-n[0])/t)*t+n[0],a=Math.floor((e[1]-n[1])/t)*t+n[1];return r[0]=i,r[1]=a,r[2]=i+t,r[3]=a+t,r}function vJ(e,t,n){n&8?(e[1]+=t,e[3]+=t):n&4?(e[1]-=t,e[3]-=t):n&2?(e[0]+=t,e[2]+=t):n&1&&(e[0]-=t,e[2]-=t)}function yJ(e,t,n,r){let i=1/0,a=-1/0,o=1/0,s=-1/0;for(let r=0;r<n;r+=t){let t=e[r],n=e[r+1];i=t<i?t:i,a=t>a?t:a,o=n<o?n:o,s=n>s?n:s}return r[0][0]=i,r[0][1]=o,r[1][0]=a,r[1][1]=s,r}function bJ(e,t){for(let n=0;n<t.length;n++)e.push(t[n]);return e}var xJ,SJ,CJ=o((()=>{pJ(),uJ(),xJ=0,SJ=1}));function wJ(e,t){let{size:n=2,startIndex:r=0,endIndex:i=e.length,normalize:a=!0}=t||{},o=e.slice(r,i);OJ(o,n,0,i-r);let s=mJ(o,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(a)for(let e of s)kJ(e,n);return s}function TJ(e,t=null,n){let{size:r=2,normalize:i=!0,edgeTypes:a=!1}=n||{};t||=[];let o=[],s=[],c=0,l=0;for(let i=0;i<=t.length;i++){let a=t[i]||e.length,u=l,d=EJ(e,r,c,a);for(let t=d;t<a;t++)o[l++]=e[t];for(let t=c;t<d;t++)o[l++]=e[t];OJ(o,r,u,l),DJ(o,r,u,l,n?.maxLatitude),c=a,s[i]=l}s.pop();let u=hJ(o,s,{size:r,gridResolution:360,gridOffset:[-180,-180],edgeTypes:a});if(i)for(let e of u)kJ(e.positions,r);return u}function EJ(e,t,n,r){let i=-1,a=-1;for(let o=n+1;o<r;o+=t){let t=Math.abs(e[o]);t>i&&(i=t,a=o-1)}return a}function DJ(e,t,n,r,i=AJ){let a=e[n],o=e[r-t];if(Math.abs(a-o)>180){let r=lJ(e,0,t,n);r[0]+=Math.round((o-a)/360)*360,sJ(e,r),r[1]=Math.sign(r[1])*i,sJ(e,r),r[0]=a,sJ(e,r)}}function OJ(e,t,n,r){let i=e[0],a;for(let o=n;o<r;o+=t){a=e[o];let t=a-i;(t>180||t<-180)&&(a-=Math.round(t/360)*360),e[o]=i=a}}function kJ(e,t){let n,r=e.length/t;for(let i=0;i<r&&(n=e[i*t],(n+180)%360==0);i++);let i=-Math.round(n/360)*360;if(i!==0)for(let n=0;n<r;n++)e[n*t]+=i}var AJ,jJ=o((()=>{CJ(),uJ(),AJ=85.051129})),MJ=o((()=>{lO(),oJ(),pJ(),CJ(),jJ()}));function NJ(e,t,n,r){let i;if(Array.isArray(e[0])){let n=e.length*t;i=Array(n);for(let n=0;n<e.length;n++)for(let r=0;r<t;r++)i[n*t+r]=e[n][r]||0}else i=e;return n?mJ(i,{size:t,gridResolution:n}):r?wJ(i,{size:t}):i}var PJ=o((()=>{MJ()}));function FJ(e){return Array.isArray(e[0])}var IJ,LJ,RJ,zJ,BJ=o((()=>{EK(),PJ(),IJ=1,LJ=2,RJ=4,zJ=class extends wK{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?NJ(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(FJ(e)){let t=0;for(let n of e)t+=this.getGeometrySize(n);return t}let t=this.getPathLength(e);return t<2?0:this.isClosed(e)?t<3?0:t+2:t}updateGeometryAttributes(e,t){if(t.geometrySize!==0)if(e&&FJ(e))for(let n of e){let e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e}else this._updateSegmentTypes(e,t),this._updatePositions(e,t)}_updateSegmentTypes(e,t){let n=this.attributes.segmentTypes,r=e?this.isClosed(e):!1,{vertexStart:i,geometrySize:a}=t;n.fill(0,i,i+a),r?(n[i]=RJ,n[i+a-2]=RJ):(n[i]+=IJ,n[i+a-2]+=LJ),n[i+a-1]=RJ}_updatePositions(e,t){let{positions:n}=this.attributes;if(!n||!e)return;let{vertexStart:r,geometrySize:i}=t,a=[,,,];for(let t=r,o=0;o<i;t++,o++)this.getPointOnPath(e,o,a),n[t*3]=a[0],n[t*3+1]=a[1],n[t*3+2]=a[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,t,n=[]){let{positionSize:r}=this;t*r>=e.length&&(t+=1-e.length/r);let i=t*r;return n[0]=e[i],n[1]=e[i+1],n[2]=r===3&&e[i+2]||0,n}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:t}=this,n=e.length-t;return e[0]===e[n]&&e[1]===e[n+1]&&(t===2||e[2]===e[n+2])}}})),VJ,HJ,UJ=o((()=>{VJ=`layout(std140) uniform pathUniforms {
|
||
float widthScale;
|
||
float widthMinPixels;
|
||
float widthMaxPixels;
|
||
float jointType;
|
||
float capType;
|
||
float miterLimit;
|
||
bool billboard;
|
||
highp int widthUnits;
|
||
} path;
|
||
`,HJ={name:`path`,vs:VJ,fs:VJ,uniformTypes:{widthScale:`f32`,widthMinPixels:`f32`,widthMaxPixels:`f32`,jointType:`f32`,capType:`f32`,miterLimit:`f32`,billboard:`f32`,widthUnits:`i32`}}})),WJ,GJ=o((()=>{WJ=`#version 300 es
|
||
#define SHADER_NAME path-layer-vertex-shader
|
||
in vec2 positions;
|
||
in float instanceTypes;
|
||
in vec3 instanceStartPositions;
|
||
in vec3 instanceEndPositions;
|
||
in vec3 instanceLeftPositions;
|
||
in vec3 instanceRightPositions;
|
||
in vec3 instanceLeftPositions64Low;
|
||
in vec3 instanceStartPositions64Low;
|
||
in vec3 instanceEndPositions64Low;
|
||
in vec3 instanceRightPositions64Low;
|
||
in float instanceStrokeWidths;
|
||
in vec4 instanceColors;
|
||
in vec3 instancePickingColors;
|
||
uniform float opacity;
|
||
out vec4 vColor;
|
||
out vec2 vCornerOffset;
|
||
out float vMiterLength;
|
||
out vec2 vPathPosition;
|
||
out float vPathLength;
|
||
out float vJointType;
|
||
const float EPSILON = 0.001;
|
||
const vec3 ZERO_OFFSET = vec3(0.0);
|
||
float flipIfTrue(bool flag) {
|
||
return -(float(flag) * 2. - 1.);
|
||
}
|
||
vec3 getLineJoinOffset(
|
||
vec3 prevPoint, vec3 currPoint, vec3 nextPoint,
|
||
vec2 width
|
||
) {
|
||
bool isEnd = positions.x > 0.0;
|
||
float sideOfPath = positions.y;
|
||
float isJoint = float(sideOfPath == 0.0);
|
||
vec3 deltaA3 = (currPoint - prevPoint);
|
||
vec3 deltaB3 = (nextPoint - currPoint);
|
||
mat3 rotationMatrix;
|
||
bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);
|
||
if (needsRotation) {
|
||
deltaA3 = deltaA3 * rotationMatrix;
|
||
deltaB3 = deltaB3 * rotationMatrix;
|
||
}
|
||
vec2 deltaA = deltaA3.xy / width;
|
||
vec2 deltaB = deltaB3.xy / width;
|
||
float lenA = length(deltaA);
|
||
float lenB = length(deltaB);
|
||
vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);
|
||
vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);
|
||
vec2 perpA = vec2(-dirA.y, dirA.x);
|
||
vec2 perpB = vec2(-dirB.y, dirB.x);
|
||
vec2 tangent = dirA + dirB;
|
||
tangent = length(tangent) > 0. ? normalize(tangent) : perpA;
|
||
vec2 miterVec = vec2(-tangent.y, tangent.x);
|
||
vec2 dir = isEnd ? dirA : dirB;
|
||
vec2 perp = isEnd ? perpA : perpB;
|
||
float L = isEnd ? lenA : lenB;
|
||
float sinHalfA = abs(dot(miterVec, perp));
|
||
float cosHalfA = abs(dot(dirA, miterVec));
|
||
float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);
|
||
float cornerPosition = sideOfPath * turnDirection;
|
||
float miterSize = 1.0 / max(sinHalfA, EPSILON);
|
||
miterSize = mix(
|
||
min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),
|
||
miterSize,
|
||
step(0.0, cornerPosition)
|
||
);
|
||
vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))
|
||
* (sideOfPath + isJoint * turnDirection);
|
||
bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));
|
||
bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));
|
||
bool isCap = isStartCap || isEndCap;
|
||
if (isCap) {
|
||
offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);
|
||
vJointType = path.capType;
|
||
} else {
|
||
vJointType = path.jointType;
|
||
}
|
||
vPathLength = L;
|
||
vCornerOffset = offsetVec;
|
||
vMiterLength = dot(vCornerOffset, miterVec * turnDirection);
|
||
vMiterLength = isCap ? isJoint : vMiterLength;
|
||
vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);
|
||
vPathPosition = vec2(
|
||
dot(offsetFromStartOfPath, perp),
|
||
dot(offsetFromStartOfPath, dir)
|
||
);
|
||
geometry.uv = vPathPosition;
|
||
float isValid = step(instanceTypes, 3.5);
|
||
vec3 offset = vec3(offsetVec * width * isValid, 0.0);
|
||
if (needsRotation) {
|
||
offset = rotationMatrix * offset;
|
||
}
|
||
return offset;
|
||
}
|
||
void clipLine(inout vec4 position, vec4 refPosition) {
|
||
if (position.w < EPSILON) {
|
||
float r = (EPSILON - refPosition.w) / (position.w - refPosition.w);
|
||
position = refPosition + (position - refPosition) * r;
|
||
}
|
||
}
|
||
void main() {
|
||
geometry.pickingColor = instancePickingColors;
|
||
vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);
|
||
float isEnd = positions.x;
|
||
vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);
|
||
vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);
|
||
vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);
|
||
vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);
|
||
vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);
|
||
vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);
|
||
geometry.worldPosition = currPosition;
|
||
vec2 widthPixels = vec2(clamp(
|
||
project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),
|
||
path.widthMinPixels, path.widthMaxPixels) / 2.0);
|
||
vec3 width;
|
||
if (path.billboard) {
|
||
vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);
|
||
vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);
|
||
vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);
|
||
clipLine(prevPositionScreen, currPositionScreen);
|
||
clipLine(nextPositionScreen, currPositionScreen);
|
||
clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));
|
||
width = vec3(widthPixels, 0.0);
|
||
DECKGL_FILTER_SIZE(width, geometry);
|
||
vec3 offset = getLineJoinOffset(
|
||
prevPositionScreen.xyz / prevPositionScreen.w,
|
||
currPositionScreen.xyz / currPositionScreen.w,
|
||
nextPositionScreen.xyz / nextPositionScreen.w,
|
||
project_pixel_size_to_clipspace(width.xy)
|
||
);
|
||
DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);
|
||
gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);
|
||
} else {
|
||
prevPosition = project_position(prevPosition, prevPosition64Low);
|
||
currPosition = project_position(currPosition, currPosition64Low);
|
||
nextPosition = project_position(nextPosition, nextPosition64Low);
|
||
width = vec3(project_pixel_size(widthPixels), 0.0);
|
||
DECKGL_FILTER_SIZE(width, geometry);
|
||
vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);
|
||
geometry.position = vec4(currPosition + offset, 1.0);
|
||
gl_Position = project_common_position_to_clipspace(geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
}
|
||
DECKGL_FILTER_COLOR(vColor, geometry);
|
||
}
|
||
`})),KJ,qJ=o((()=>{KJ=`#version 300 es
|
||
#define SHADER_NAME path-layer-fragment-shader
|
||
precision highp float;
|
||
in vec4 vColor;
|
||
in vec2 vCornerOffset;
|
||
in float vMiterLength;
|
||
in vec2 vPathPosition;
|
||
in float vPathLength;
|
||
in float vJointType;
|
||
out vec4 fragColor;
|
||
void main(void) {
|
||
geometry.uv = vPathPosition;
|
||
if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {
|
||
if (vJointType > 0.5 && length(vCornerOffset) > 1.0) {
|
||
discard;
|
||
}
|
||
if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {
|
||
discard;
|
||
}
|
||
}
|
||
fragColor = vColor;
|
||
DECKGL_FILTER_COLOR(fragColor, geometry);
|
||
}
|
||
`})),JJ,YJ,XJ,ZJ,QJ=o((()=>{EK(),OR(),BJ(),UJ(),GJ(),qJ(),JJ=[0,0,0,255],YJ={widthUnits:`meters`,widthScale:{type:`number`,min:0,value:1},widthMinPixels:{type:`number`,min:0,value:0},widthMaxPixels:{type:`number`,min:0,value:2**53-1},jointRounded:!1,capRounded:!1,miterLimit:{type:`number`,min:0,value:4},billboard:!1,_pathType:null,getPath:{type:`accessor`,value:e=>e.path},getColor:{type:`accessor`,value:JJ},getWidth:{type:`accessor`,value:1},rounded:{deprecatedFor:[`jointRounded`,`capRounded`]}},XJ={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e},ZJ=class extends lK{getShaders(){return super.getShaders({vs:WJ,fs:KJ,modules:[fF,pI,HJ]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds([`vertexPositions`])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:`float64`,fp64:this.use64bitPositions(),transition:XJ,accessor:`getPath`,update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:`uint8`,update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:`getWidth`,transition:XJ,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:`unorm8`,accessor:`getColor`,transition:XJ,defaultValue:JJ},instancePickingColors:{size:4,type:`uint8`,accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}}),this.setState({pathTesselator:new zJ({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:t,changeFlags:n}=e,r=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){let{pathTesselator:e}=this.state,i=t.data.attributes||{};e.updateGeometry({data:t.data,geometryBuffer:i.getPath,buffers:i,normalize:!t._pathType,loop:t._pathType===`loop`,getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),n.dataChanged||r.invalidateAll()}n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll())}getPickingInfo(e){let t=super.getPickingInfo(e),{index:n}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(e=>e.__source.index===n)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){let{jointRounded:t,capRounded:n,billboard:r,miterLimit:i,widthUnits:a,widthScale:o,widthMinPixels:s,widthMaxPixels:c}=this.props,l=this.state.model,u={jointType:Number(t),capType:Number(n),billboard:r,widthUnits:IP[a],widthScale:o,miterLimit:i,widthMinPixels:s,widthMaxPixels:c};l.shaderInputs.setProps({path:u}),l.draw(this.context.renderPass)}_getModel(){let e=[0,1,2,1,4,2,1,3,4,3,5,4],t=[0,0,0,-1,0,1,1,-1,1,1,1,0];return new wR(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new DR({topology:`triangle-list`,attributes:{indices:new Uint16Array(e),positions:{value:new Float32Array(t),size:2}}}),isInstanced:!0})}calculatePositions(e){let{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get(`positions`)}calculateSegmentTypes(e){let{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get(`segmentTypes`)}},ZJ.defaultProps=YJ,ZJ.layerName=`PathLayer`})),$J=s(((e,t)=>{t.exports=n,t.exports.default=n;function n(e,t,n){n||=2;var i=t&&t.length,o=i?t[0]*n:e.length,s=r(e,0,o,n,!0),c=[];if(!s||s.next===s.prev)return c;var l,d,f,p,m,h,g;if(i&&(s=u(e,t,s,n)),e.length>80*n){l=f=e[0],d=p=e[1];for(var _=n;_<o;_+=n)m=e[_],h=e[_+1],m<l&&(l=m),h<d&&(d=h),m>f&&(f=m),h>p&&(p=h);g=Math.max(f-l,p-d),g=g===0?0:32767/g}return a(s,c,n,l,d,g,0),c}function r(e,t,n,r,i){var a,o;if(i===N(e,t,n,r)>0)for(a=t;a<n;a+=r)o=A(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=A(a,e[a],e[a+1],o);return o&&S(o,o.next)&&(j(o),o=o.next),o}function i(e,t){if(!e)return e;t||=e;var n=e,r;do if(r=!1,!n.steiner&&(S(n,n.next)||x(n.prev,n,n.next)===0)){if(j(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function a(e,t,n,r,u,d,f){if(e){!f&&d&&h(e,r,u,d);for(var p=e,m,g;e.prev!==e.next;){if(m=e.prev,g=e.next,d?s(e,r,u,d):o(e)){t.push(m.i/n|0),t.push(e.i/n|0),t.push(g.i/n|0),j(e),e=g.next,p=g.next;continue}if(e=g,e===p){f?f===1?(e=c(i(e),t,n),a(e,t,n,r,u,d,2)):f===2&&l(e,t,n,r,u,d):a(i(e),t,n,r,u,d,1);break}}}}function o(e){var t=e.prev,n=e,r=e.next;if(x(t,n,r)>=0)return!1;for(var i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=i<a?i<o?i:o:a<o?a:o,d=s<c?s<l?s:l:c<l?c:l,f=i>a?i>o?i:o:a>o?a:o,p=s>c?s>l?s:l:c>l?c:l,m=r.next;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&y(i,s,a,c,o,l,m.x,m.y)&&x(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function s(e,t,n,r){var i=e.prev,a=e,o=e.next;if(x(i,a,o)>=0)return!1;for(var s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=s<c?s<l?s:l:c<l?c:l,m=u<d?u<f?u:f:d<f?d:f,h=s>c?s>l?s:l:c>l?c:l,g=u>d?u>f?u:f:d>f?d:f,v=_(p,m,t,n,r),b=_(h,g,t,n,r),S=e.prevZ,C=e.nextZ;S&&S.z>=v&&C&&C.z<=b;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0||(S=S.prevZ,C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;S&&S.z>=v;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;C&&C.z<=b;){if(C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function c(e,t,n){var r=e;do{var a=r.prev,o=r.next.next;!S(a,o)&&C(a,r,r.next,o)&&D(a,o)&&D(o,a)&&(t.push(a.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),j(r),j(r.next),r=e=o),r=r.next}while(r!==e);return i(r)}function l(e,t,n,r,o,s){var c=e;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&b(c,l)){var u=k(c,l);c=i(c,c.next),u=i(u,u.next),a(c,t,n,r,o,s,0),a(u,t,n,r,o,s,0);return}l=l.next}c=c.next}while(c!==e)}function u(e,t,n,i){var a=[],o,s,c,l,u;for(o=0,s=t.length;o<s;o++)c=t[o]*i,l=o<s-1?t[o+1]*i:e.length,u=r(e,c,l,i,!1),u===u.next&&(u.steiner=!0),a.push(v(u));for(a.sort(d),o=0;o<a.length;o++)n=f(a[o],n);return n}function d(e,t){return e.x-t.x}function f(e,t){var n=p(e,t);if(!n)return t;var r=k(n,e);return i(r,r.next),i(n,n.next)}function p(e,t){var n=t,r=e.x,i=e.y,a=-1/0,o;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=r&&s>a&&(a=s,o=n.x<n.next.x?n:n.next,s===r))return o}n=n.next}while(n!==t);if(!o)return null;var c=o,l=o.x,u=o.y,d=1/0,f;n=o;do r>=n.x&&n.x>=l&&r!==n.x&&y(i<u?r:a,i,l,u,i<u?a:r,i,n.x,n.y)&&(f=Math.abs(i-n.y)/(r-n.x),D(n,e)&&(f<d||f===d&&(n.x>o.x||n.x===o.x&&m(o,n)))&&(o=n,d=f)),n=n.next;while(n!==c);return o}function m(e,t){return x(e.prev,e,t.prev)<0&&x(t.next,e,e.next)<0}function h(e,t,n,r){var i=e;do i.z===0&&(i.z=_(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,g(i)}function g(e){var t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ,r);t++);for(c=l;s>0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function _(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function v(e){var t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function y(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function b(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!E(e,t)&&(D(e,t)&&D(t,e)&&O(e,t)&&(x(e.prev,e,t.prev)||x(e,t.prev,t))||S(e,t)&&x(e.prev,e,e.next)>0&&x(t.prev,t,t.next)>0)}function x(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function S(e,t){return e.x===t.x&&e.y===t.y}function C(e,t,n,r){var i=T(x(e,t,n)),a=T(x(e,t,r)),o=T(x(n,r,e)),s=T(x(n,r,t));return!!(i!==a&&o!==s||i===0&&w(e,n,t)||a===0&&w(e,r,t)||o===0&&w(n,e,r)||s===0&&w(n,t,r))}function w(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function T(e){return e>0?1:e<0?-1:0}function E(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&C(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function D(e,t){return x(e.prev,e,e.next)<0?x(e,t,e.next)>=0&&x(e,e.prev,t)>=0:x(e,t,e.prev)<0||x(e,e.next,t)<0}function O(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function k(e,t){var n=new M(e.i,e.x,e.y),r=new M(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function A(e,t,n,r){var i=new M(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function j(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 M(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}n.deviation=function(e,t,n,r){var i=t&&t.length,a=i?t[0]*n:e.length,o=Math.abs(N(e,0,a,n));if(i)for(var s=0,c=t.length;s<c;s++){var l=t[s]*n,u=s<c-1?t[s+1]*n:e.length;o-=Math.abs(N(e,l,u,n))}var d=0;for(s=0;s<r.length;s+=3){var f=r[s]*n,p=r[s+1]*n,m=r[s+2]*n;d+=Math.abs((e[f]-e[m])*(e[p+1]-e[f+1])-(e[f]-e[p])*(e[m+1]-e[f+1]))}return o===0&&d===0?0:Math.abs((d-o)/o)};function N(e,t,n,r){for(var i=0,a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}n.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var a=0;a<e[i].length;a++)for(var o=0;o<t;o++)n.vertices.push(e[i][a][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n}}));function eY(e){if(e=e&&e.positions||e,!Array.isArray(e)&&!ArrayBuffer.isView(e))throw Error(`invalid polygon`)}function tY(e){return`positions`in e?e.positions:e}function nY(e){return`holeIndices`in e?e.holeIndices:null}function rY(e){return Array.isArray(e[0])}function iY(e){return e.length>=1&&e[0].length>=2&&Number.isFinite(e[0][0])}function aY(e){let t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]}function oY(e,t,n,r){for(let i=0;i<t;i++)if(e[n+i]!==e[r-t+i])return!1;return!0}function sY(e,t,n,r,i){let a=t,o=n.length;for(let t=0;t<o;t++)for(let i=0;i<r;i++)e[a++]=n[t][i]||0;if(!aY(n))for(let t=0;t<r;t++)e[a++]=n[0][t]||0;return gY.start=t,gY.end=a,gY.size=r,eJ(e,i,gY),a}function cY(e,t,n,r,i=0,a,o){a||=n.length;let s=a-i;if(s<=0)return t;let c=t;for(let t=0;t<s;t++)e[c++]=n[i+t];if(!oY(n,r,i,a))for(let t=0;t<r;t++)e[c++]=n[i+t];return gY.start=t,gY.end=c,gY.size=r,eJ(e,o,gY),c}function lY(e,t){eY(e);let n=[],r=[];if(`positions`in e){let{positions:i,holeIndices:a}=e;if(a){let e=0;for(let o=0;o<=a.length;o++)e=cY(n,e,i,t,a[o-1],a[o],o===0?mY:hY),r.push(e);return r.pop(),{positions:n,holeIndices:r}}e=i}if(!rY(e))return cY(n,0,e,t,0,n.length,mY),n;if(!iY(e)){let i=0;for(let[a,o]of e.entries())i=sY(n,i,o,t,a===0?mY:hY),r.push(i);return r.pop(),{positions:n,holeIndices:r}}return sY(n,0,e,t,mY),n}function uY(e,t,n){let r=e.length/3,i=0;for(let a=0;a<r;a++){let o=(a+1)%r;i+=e[a*3+t]*e[o*3+n],i-=e[o*3+t]*e[a*3+n]}return Math.abs(i/2)}function dY(e,t,n,r){let i=e.length/3;for(let a=0;a<i;a++){let i=a*3,o=e[i+0],s=e[i+1],c=e[i+2];e[i+t]=o,e[i+n]=s,e[i+r]=c}}function fY(e,t,n,r){let i=nY(e);i&&=i.map(e=>e/t);let a=tY(e),o=r&&t===3;if(n){let e=a.length;a=a.slice();let r=[];for(let i=0;i<e;i+=t){r[0]=a[i],r[1]=a[i+1],o&&(r[2]=a[i+2]);let e=n(r);a[i]=e[0],a[i+1]=e[1],o&&(a[i+2]=e[2])}}if(o){let e=uY(a,0,1),t=uY(a,0,2),r=uY(a,1,2);if(!e&&!t&&!r)return[];e>t&&e>r||(t>r?(n||(a=a.slice()),dY(a,0,2,1)):(n||(a=a.slice()),dY(a,2,0,1)))}return(0,pY.default)(a,i,t)}var pY,mY,hY,gY,_Y=o((()=>{pY=u($J(),1),MJ(),mY=iJ.CLOCKWISE,hY=iJ.COUNTER_CLOCKWISE,gY={isClosed:!0}}));function vY(e){return Array.isArray(e)&&e.length>0&&!Number.isFinite(e[0])}var yY,bY=o((()=>{_Y(),EK(),MJ(),yY=class extends wK{constructor(e){let{fp64:t,IndexType:n=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:n,size:1}}})}get(e){let{attributes:t}=this;return e===`indices`?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);let t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw Error(`missing indices buffer`)}normalizeGeometry(e){if(this.normalize){let t=lY(e,this.positionSize);return this.opts.resolution?hJ(tY(t),nY(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?TJ(tY(t),nY(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(vY(e)){let t=0;for(let n of e)t+=this.getGeometrySize(n);return t}return tY(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&vY(e))for(let n of e){let e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{let n=e;this._updateIndices(n,t),this._updatePositions(n,t),this._updateVertexValid(n,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:n,indexStart:r}){let{attributes:i,indexStarts:a,typedArrayManager:o}=this,s=i.indices;if(!s||!e)return;let c=r,l=fY(e,this.positionSize,this.opts.preproject,this.opts.full3d);s=o.allocate(s,r+l.length,{copy:!0});for(let e=0;e<l.length;e++)s[c++]=l[e]+n;a[t+1]=r+l.length,i.indices=s}_updatePositions(e,{vertexStart:t,geometrySize:n}){let{attributes:{positions:r},positionSize:i}=this;if(!r||!e)return;let a=tY(e);for(let e=t,o=0;o<n;e++,o++){let t=a[o*i],n=a[o*i+1],s=i>2?a[o*i+2]:0;r[e*3]=t,r[e*3+1]=n,r[e*3+2]=s}}_updateVertexValid(e,{vertexStart:t,geometrySize:n}){let{positionSize:r}=this,i=this.attributes.vertexValid,a=e&&nY(e);if(e&&e.edgeTypes?i.set(e.edgeTypes,t):i.fill(1,t,t+n),a)for(let e=0;e<a.length;e++)i[t+a[e]/r-1]=0;i[t+n-1]=0}}})),xY,SY,CY=o((()=>{xY=`layout(std140) uniform solidPolygonUniforms {
|
||
bool extruded;
|
||
bool isWireframe;
|
||
float elevationScale;
|
||
} solidPolygon;
|
||
`,SY={name:`solidPolygon`,vs:xY,fs:xY,uniformTypes:{extruded:`f32`,isWireframe:`f32`,elevationScale:`f32`}}})),wY,TY=o((()=>{wY=`in vec4 fillColors;
|
||
in vec4 lineColors;
|
||
in vec3 pickingColors;
|
||
out vec4 vColor;
|
||
struct PolygonProps {
|
||
vec3 positions;
|
||
vec3 positions64Low;
|
||
vec3 normal;
|
||
float elevations;
|
||
};
|
||
vec3 project_offset_normal(vec3 vector) {
|
||
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
||
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {
|
||
return normalize(vector * project.commonUnitsPerWorldUnit);
|
||
}
|
||
return project_normal(vector);
|
||
}
|
||
void calculatePosition(PolygonProps props) {
|
||
vec3 pos = props.positions;
|
||
vec3 pos64Low = props.positions64Low;
|
||
vec3 normal = props.normal;
|
||
vec4 colors = solidPolygon.isWireframe ? lineColors : fillColors;
|
||
geometry.worldPosition = props.positions;
|
||
geometry.pickingColor = pickingColors;
|
||
if (solidPolygon.extruded) {
|
||
pos.z += props.elevations * solidPolygon.elevationScale;
|
||
}
|
||
gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
if (solidPolygon.extruded) {
|
||
#ifdef IS_SIDE_VERTEX
|
||
normal = project_offset_normal(normal);
|
||
#else
|
||
normal = project_normal(normal);
|
||
#endif
|
||
geometry.normal = normal;
|
||
vec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
|
||
vColor = vec4(lightColor, colors.a * layer.opacity);
|
||
} else {
|
||
vColor = vec4(colors.rgb, colors.a * layer.opacity);
|
||
}
|
||
DECKGL_FILTER_COLOR(vColor, geometry);
|
||
}
|
||
`})),EY,DY=o((()=>{TY(),EY=`\
|
||
#version 300 es
|
||
#define SHADER_NAME solid-polygon-layer-vertex-shader
|
||
in vec3 vertexPositions;
|
||
in vec3 vertexPositions64Low;
|
||
in float elevations;
|
||
${wY}
|
||
void main(void) {
|
||
PolygonProps props;
|
||
props.positions = vertexPositions;
|
||
props.positions64Low = vertexPositions64Low;
|
||
props.elevations = elevations;
|
||
props.normal = vec3(0.0, 0.0, 1.0);
|
||
calculatePosition(props);
|
||
}
|
||
`})),OY,kY=o((()=>{TY(),OY=`\
|
||
#version 300 es
|
||
#define SHADER_NAME solid-polygon-layer-vertex-shader-side
|
||
#define IS_SIDE_VERTEX
|
||
in vec2 positions;
|
||
in vec3 vertexPositions;
|
||
in vec3 nextVertexPositions;
|
||
in vec3 vertexPositions64Low;
|
||
in vec3 nextVertexPositions64Low;
|
||
in float elevations;
|
||
in float instanceVertexValid;
|
||
${wY}
|
||
void main(void) {
|
||
if(instanceVertexValid < 0.5){
|
||
gl_Position = vec4(0.);
|
||
return;
|
||
}
|
||
PolygonProps props;
|
||
vec3 pos;
|
||
vec3 pos64Low;
|
||
vec3 nextPos;
|
||
vec3 nextPos64Low;
|
||
#if RING_WINDING_ORDER_CW == 1
|
||
pos = vertexPositions;
|
||
pos64Low = vertexPositions64Low;
|
||
nextPos = nextVertexPositions;
|
||
nextPos64Low = nextVertexPositions64Low;
|
||
#else
|
||
pos = nextVertexPositions;
|
||
pos64Low = nextVertexPositions64Low;
|
||
nextPos = vertexPositions;
|
||
nextPos64Low = vertexPositions64Low;
|
||
#endif
|
||
props.positions = mix(pos, nextPos, positions.x);
|
||
props.positions64Low = mix(pos64Low, nextPos64Low, positions.x);
|
||
props.normal = vec3(
|
||
pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),
|
||
nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),
|
||
0.0);
|
||
props.elevations = elevations * positions.y;
|
||
calculatePosition(props);
|
||
}
|
||
`})),AY,jY=o((()=>{AY=`#version 300 es
|
||
#define SHADER_NAME solid-polygon-layer-fragment-shader
|
||
precision highp float;
|
||
in vec4 vColor;
|
||
out vec4 fragColor;
|
||
void main(void) {
|
||
fragColor = vColor;
|
||
geometry.uv = vec2(0.);
|
||
DECKGL_FILTER_COLOR(fragColor, geometry);
|
||
}
|
||
`})),MY,NY,PY,FY,IY=o((()=>{EK(),OR(),bY(),CY(),DY(),kY(),jY(),MY=[0,0,0,255],NY={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:`CW`,_full3d:!1,elevationScale:{type:`number`,min:0,value:1},getPolygon:{type:`accessor`,value:e=>e.polygon},getElevation:{type:`accessor`,value:1e3},getFillColor:{type:`accessor`,value:MY},getLineColor:{type:`accessor`,value:MY},material:!0},PY={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e},FY=class extends lK{getShaders(e){return super.getShaders({vs:e===`top`?EY:OY,fs:AY,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder===`CCW`?0:1},modules:[fF,vM,pI,SY]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds([`vertexPositions`])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:t}=this.props,{_full3d:n}=this.props;e.isGeospatial&&t==="default"&&(t=`lnglat`);let r;t===`lnglat`&&(r=n?e.projectPosition.bind(e):e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new yY({preproject:r,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let i=this.getAttributeManager();i.remove([`instancePickingColors`]),i.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:!0},vertexPositions:{size:3,type:`float64`,stepMode:`dynamic`,fp64:this.use64bitPositions(),transition:PY,accessor:`getPolygon`,update:this.calculatePositions,noAlloc:!0,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:`uint16`,stepMode:`instance`,update:this.calculateVertexValid,noAlloc:!0},elevations:{size:1,stepMode:`dynamic`,transition:PY,accessor:`getElevation`},fillColors:{size:this.props.colorFormat.length,type:`unorm8`,stepMode:`dynamic`,transition:PY,accessor:`getFillColor`,defaultValue:MY},lineColors:{size:this.props.colorFormat.length,type:`unorm8`,stepMode:`dynamic`,transition:PY,accessor:`getLineColor`,defaultValue:MY},pickingColors:{size:4,type:`uint8`,stepMode:`dynamic`,accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}})}getPickingInfo(e){let t=super.getPickingInfo(e),{index:n}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(e=>e.__source.index===n)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){let{extruded:t,filled:n,wireframe:r,elevationScale:i}=this.props,{topModel:a,sideModel:o,wireframeModel:s,polygonTesselator:c}=this.state,l={extruded:!!t,elevationScale:i,isWireframe:!1};s&&r&&(s.setInstanceCount(c.instanceCount-1),s.shaderInputs.setProps({solidPolygon:{...l,isWireframe:!0}}),s.draw(this.context.renderPass)),o&&n&&(o.setInstanceCount(c.instanceCount-1),o.shaderInputs.setProps({solidPolygon:l}),o.draw(this.context.renderPass)),a&&n&&(a.setVertexCount(c.vertexCount),a.shaderInputs.setProps({solidPolygon:l}),a.draw(this.context.renderPass))}updateState(e){super.updateState(e),this.updateGeometry(e);let{props:t,oldProps:n,changeFlags:r}=e,i=this.getAttributeManager();(r.extensionsChanged||t.filled!==n.filled||t.extruded!==n.extruded)&&(this.state.models?.forEach(e=>e.destroy()),this.setState(this._getModels()),i.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPolygon)){let{polygonTesselator:t}=this.state,r=e.data.attributes||{};t.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:r.getPolygon,buffers:r,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:n.dataChanged,full3d:e._full3d}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),n.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:t,extruded:n}=this.props,r,i,a;if(t){let t=this.getShaders(`top`);t.defines.NON_INSTANCED_MODEL=1;let n=this.getAttributeManager().getBufferLayouts({isInstanced:!1});r=new wR(this.context.device,{...t,id:`${e}-top`,topology:`triangle-list`,bufferLayout:n,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(n){let t=this.getAttributeManager().getBufferLayouts({isInstanced:!0});i=new wR(this.context.device,{...this.getShaders(`side`),id:`${e}-side`,bufferLayout:t,geometry:new DR({topology:`triangle-strip`,attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),a=new wR(this.context.device,{...this.getShaders(`side`),id:`${e}-wireframe`,bufferLayout:t,geometry:new DR({topology:`line-strip`,attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[i,a,r].filter(Boolean),topModel:r,sideModel:i,wireframeModel:a}}calculateIndices(e){let{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get(`indices`)}calculatePositions(e){let{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get(`positions`)}calculateVertexValid(e){e.value=this.state.polygonTesselator.get(`vertexValid`)}},FY.defaultProps=NY,FY.layerName=`SolidPolygonLayer`}));function LY({data:e,getIndex:t,dataRange:n,replace:r}){let{startRow:i=0,endRow:a=1/0}=n,o=e.length,s=o,c=o;for(let n=0;n<o;n++){let r=t(e[n]);if(s>n&&r>=i&&(s=n),r>=a){c=n;break}}let l=s,u=c-s===r.length?void 0:e.slice(c);for(let t=0;t<r.length;t++)e[l++]=r[t];if(u){for(let t=0;t<u.length;t++)e[l++]=u[t];e.length=l}return{startRow:s,endRow:s+r.length}}var RY=o((()=>{}));function zY(e,t){if(!e)return null;let n=`startIndices`in e?e.startIndices[t]:t,r=e.featureIds.value[n];return n===-1?null:BY(e,r,n)}function BY(e,t,n){let r={properties:{...e.properties[t]}};for(let t in e.numericProps)r.properties[t]=e.numericProps[t].value[n];return r}function VY(e,t){let n={points:null,lines:null,polygons:null};for(let r in n){let i=e[r].globalFeatureIds.value;n[r]=new Uint8ClampedArray(i.length*4);let a=[];for(let e=0;e<i.length;e++)t(i[e],a),n[r][e*4+0]=a[0],n[r][e*4+1]=a[1],n[r][e*4+2]=a[2],n[r][e*4+3]=255}return n}var HY=o((()=>{})),UY,WY,GY=o((()=>{UY=`layout(std140) uniform sdfUniforms {
|
||
float gamma;
|
||
bool enabled;
|
||
float buffer;
|
||
float outlineBuffer;
|
||
vec4 outlineColor;
|
||
} sdf;
|
||
`,WY={name:`sdf`,vs:UY,fs:UY,uniformTypes:{gamma:`f32`,enabled:`f32`,buffer:`f32`,outlineBuffer:`f32`,outlineColor:`vec4<f32>`}}})),KY,qY,JY,YY=o((()=>{KY={none:0,start:1,center:2,end:3},qY=`\
|
||
layout(std140) uniform textUniforms {
|
||
highp vec2 cutoffPixels;
|
||
highp ivec2 align;
|
||
highp float fontSize;
|
||
bool flipY;
|
||
} text;
|
||
|
||
#define ALIGN_MODE_START ${KY.start}
|
||
#define ALIGN_MODE_CENTER ${KY.center}
|
||
#define ALIGN_MODE_END ${KY.end}
|
||
`,JY={name:`text`,vs:qY,getUniforms:({contentCutoffPixels:e=[0,0],contentAlignHorizontal:t=`none`,contentAlignVertical:n=`none`,fontSize:r,viewport:i})=>({cutoffPixels:e,align:[KY[t],KY[n]],fontSize:r,flipY:i?.flipY??!1}),uniformTypes:{cutoffPixels:`vec2<f32>`,align:`vec2<i32>`,fontSize:`f32`,flipY:`f32`}}})),XY,ZY=o((()=>{XY=`#version 300 es
|
||
#define SHADER_NAME multi-icon-layer-vertex-shader
|
||
in vec2 positions;
|
||
in vec3 instancePositions;
|
||
in vec3 instancePositions64Low;
|
||
in float instanceSizes;
|
||
in float instanceAngles;
|
||
in vec4 instanceColors;
|
||
in vec3 instancePickingColors;
|
||
in vec4 instanceIconFrames;
|
||
in float instanceColorModes;
|
||
in vec2 instanceOffsets;
|
||
in vec2 instancePixelOffset;
|
||
in vec4 instanceClipRect;
|
||
out float vColorMode;
|
||
out vec4 vColor;
|
||
out vec2 vTextureCoords;
|
||
out vec2 uv;
|
||
vec2 rotate_by_angle(vec2 vertex, float angle) {
|
||
float angle_radian = angle * PI / 180.0;
|
||
float cos_angle = cos(angle_radian);
|
||
float sin_angle = sin(angle_radian);
|
||
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
|
||
return rotationMatrix * vertex;
|
||
}
|
||
float getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) {
|
||
if (clipEnd < clipStart) return 0.0;
|
||
if (mode == ALIGN_MODE_START) {
|
||
return max(- (anchor + clipStart), 0.0);
|
||
}
|
||
if (mode == ALIGN_MODE_CENTER) {
|
||
float _min = max(0., anchor + clipStart);
|
||
float _max = min(extent, anchor + clipEnd);
|
||
return _min < _max ? (_min + _max) / 2.0 - anchor : 0.0;
|
||
}
|
||
if (mode == ALIGN_MODE_END) {
|
||
return min(extent - (anchor + clipEnd), 0.);
|
||
}
|
||
return 0.0;
|
||
}
|
||
void main(void) {
|
||
geometry.worldPosition = instancePositions;
|
||
geometry.uv = positions;
|
||
geometry.pickingColor = instancePickingColors;
|
||
uv = positions;
|
||
vec2 iconSize = instanceIconFrames.zw;
|
||
float sizePixels = clamp(
|
||
project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
|
||
icon.sizeMinPixels, icon.sizeMaxPixels
|
||
);
|
||
float instanceScale = sizePixels / text.fontSize;
|
||
vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
|
||
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
|
||
pixelOffset += instancePixelOffset;
|
||
pixelOffset.y *= -1.0;
|
||
vec2 anchorPosScreen;
|
||
if (icon.billboard) {
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
|
||
anchorPosScreen = gl_Position.xy / gl_Position.w;
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
vec3 offset = vec3(pixelOffset, 0.0);
|
||
DECKGL_FILTER_SIZE(offset, geometry);
|
||
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
|
||
} else {
|
||
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
|
||
if (text.flipY) {
|
||
offset_common.y *= -1.;
|
||
}
|
||
DECKGL_FILTER_SIZE(offset_common, geometry);
|
||
vec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0));
|
||
anchorPosScreen = anchorPos.xy / anchorPos.w;
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
}
|
||
anchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio;
|
||
vec2 xy = project_size_to_pixel(instanceClipRect.xy);
|
||
vec2 wh = project_size_to_pixel(instanceClipRect.zw);
|
||
if (text.flipY) {
|
||
xy.y = -xy.y - wh.y;
|
||
}
|
||
if (text.align.x > 0 || text.align.y > 0) {
|
||
vec2 viewportPixels = project.viewportSize / project.devicePixelRatio;
|
||
vec2 scrollPixels = vec2(
|
||
getPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x),
|
||
-getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y)
|
||
);
|
||
pixelOffset += scrollPixels;
|
||
gl_Position.xy += project_pixel_size_to_clipspace(scrollPixels);
|
||
}
|
||
if (instanceClipRect.z >= 0.) {
|
||
if (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) {
|
||
gl_Position = vec4(0.0);
|
||
}
|
||
else if (text.cutoffPixels.x > 0.) {
|
||
float vpWidth = project.viewportSize.x / project.devicePixelRatio;
|
||
float l = max(anchorPosScreen.x + xy.x, 0.0);
|
||
float r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth);
|
||
if (r - l < text.cutoffPixels.x) {
|
||
gl_Position = vec4(0.0);
|
||
}
|
||
}
|
||
}
|
||
if (instanceClipRect.w >= 0.) {
|
||
if (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) {
|
||
gl_Position = vec4(0.0);
|
||
}
|
||
else if (text.cutoffPixels.y > 0.) {
|
||
float vpHeight = project.viewportSize.y / project.devicePixelRatio;
|
||
float t = max(anchorPosScreen.y - xy.y - wh.y, 0.0);
|
||
float b = min(anchorPosScreen.y - xy.y, vpHeight);
|
||
if (b - t < text.cutoffPixels.y) {
|
||
gl_Position = vec4(0.0);
|
||
}
|
||
}
|
||
}
|
||
vTextureCoords = mix(
|
||
instanceIconFrames.xy,
|
||
instanceIconFrames.xy + iconSize,
|
||
(positions.xy + 1.0) / 2.0
|
||
) / icon.iconsTextureDim;
|
||
vColor = instanceColors;
|
||
DECKGL_FILTER_COLOR(vColor, geometry);
|
||
vColorMode = instanceColorModes;
|
||
}
|
||
`})),QY,$Y=o((()=>{QY=`#version 300 es
|
||
#define SHADER_NAME multi-icon-layer-fragment-shader
|
||
precision highp float;
|
||
uniform sampler2D iconsTexture;
|
||
in vec4 vColor;
|
||
in vec2 vTextureCoords;
|
||
in vec2 uv;
|
||
out vec4 fragColor;
|
||
void main(void) {
|
||
geometry.uv = uv;
|
||
if (!bool(picking.isActive)) {
|
||
float alpha = texture(iconsTexture, vTextureCoords).a;
|
||
vec4 color = vColor;
|
||
if (sdf.enabled) {
|
||
float distance = alpha;
|
||
alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);
|
||
if (sdf.outlineBuffer > 0.0) {
|
||
float inFill = alpha;
|
||
float inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);
|
||
color = mix(sdf.outlineColor, vColor, inFill);
|
||
alpha = inBorder;
|
||
}
|
||
}
|
||
float a = alpha * color.a;
|
||
if (a < icon.alphaCutoff) {
|
||
discard;
|
||
}
|
||
fragColor = vec4(color.rgb, a * layer.opacity);
|
||
}
|
||
DECKGL_FILTER_COLOR(fragColor, geometry);
|
||
}
|
||
`})),eX,tX,nX,rX=o((()=>{EK(),Tq(),GY(),YY(),ZY(),$Y(),eX=192/256,tX={getIconOffsets:{type:`accessor`,value:e=>e.offsets},getContentBox:{type:`accessor`,value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:`color`,value:[0,0,0,255]},contentCutoffPixels:{type:`array`,value:[0,0]},contentAlignHorizontal:`none`,contentAlignVertical:`none`},nX=class extends wq{getShaders(){let e=super.getShaders();return{...e,modules:[...e.modules,JY,WY],vs:XY,fs:QY}}initializeState(){super.initializeState();let e=this.getAttributeManager(),t=e.attributes.instanceIconDefs;t.settings.update=this.calculateInstanceIconDefs,e.addInstanced({instancePickingColors:{type:`uint8`,size:4,accessor:(e,{index:t,target:n})=>this.encodePickingColor(t,n)},instanceClipRect:{size:4,accessor:`getContentBox`,defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);let{props:t,oldProps:n,changeFlags:r}=e,{outlineColor:i}=t;if(r.updateTriggersChanged&&(r.updateTriggersChanged.getIcon||r.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate(`instanceIconDefs`),i!==n.outlineColor){let e=[i[0]/255,i[1]/255,i[2]/255,(i[3]??255)/255];this.setState({outlineColor:e})}!t.sdf&&t.outlineWidth&&Mw.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:t,smoothing:n,fontSize:r,outlineWidth:i,contentCutoffPixels:a,contentAlignHorizontal:o,contentAlignVertical:s}=this.props,{outlineColor:c}=this.state,l=i?Math.max(n,eX*(1-i)):-1,u=this.state.model,d={buffer:eX,outlineBuffer:l,gamma:n,enabled:!!t,outlineColor:c},f={contentCutoffPixels:a,contentAlignHorizontal:o,contentAlignVertical:s,fontSize:r,viewport:this.context.viewport};if(u.shaderInputs.setProps({sdf:d,text:f}),super.draw(e),t&&i){let{iconManager:e}=this.state;e.getTexture()&&(u.shaderInputs.setProps({sdf:{...d,outlineBuffer:eX}}),u.draw(this.context.renderPass))}}calculateInstanceIconDefs(e,{startRow:t,endRow:n}){let{data:r,getIcon:i,getIconOffsets:a}=this.props,o=e.getVertexOffset(t),s=e.value,{iterable:c,objectInfo:l}=NW(r,t,n);for(let t of c){l.index++;let n=i(t,l),r=a(t,l);if(n){let t=0;for(let i of Array.from(n)){let n=super.getInstanceIconDef(i);n[0]=r[t*2],n[1]+=r[t*2+1],n[6]=1,s.set(n,o),o+=e.size,t++}}}}},nX.defaultProps=tX,nX.layerName=`MultiIconLayer`}));function iX(e,t,n,r,i,a,o,s,c){for(let l=t;l<t+r;l++)aX(e,n*a+l,a,i,o,s,c);for(let l=n;l<n+i;l++)aX(e,l*a+t,1,r,o,s,c)}function aX(e,t,n,r,i,a,o){a[0]=0,o[0]=-0x56bc75e2d63100000,o[1]=oX,i[0]=e[t];for(let s=1,c=0,l=0;s<r;s++){i[s]=e[t+s*n];let r=s*s;do{let e=a[c];l=(i[s]-i[e]+r-e*e)/(s-e)/2}while(l<=o[c]&&--c>-1);c++,a[c]=s,o[c]=l,o[c+1]=oX}for(let s=0,c=0;s<r;s++){for(;o[c+1]<s;)c++;let r=a[c],l=s-r;e[t+s*n]=i[r]+l*l}}var oX,sX,cX,lX=o((()=>{oX=0x56bc75e2d63100000,sX=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**(1/2.2);sX[e]=t*Math.abs(t)}sX[255]=-0x56bc75e2d63100000,cX=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i=`sans-serif`,fontWeight:a=`normal`,fontStyle:o=`normal`,lang:s=null}={}){this.buffer=t,this.radius=n,this.cutoff=r,this.lang=s;let c=this.size=e+t*4,l=this._createCanvas(c),u=this.ctx=l.getContext(`2d`,{willReadFrequently:!0});u.font=`${o} ${a} ${e}px ${i}`,u.textBaseline=`alphabetic`,u.textAlign=`left`,u.fillStyle=`black`,this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,e);let t=document.createElement(`canvas`);return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(e),o=Math.ceil(n),s=Math.floor(-i),c=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a)-s)),l=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(r))),u=c+2*this.buffer,d=l+2*this.buffer,f=Math.max(u*d,0),p=new Uint8ClampedArray(f),m={data:p,width:u,height:d,glyphWidth:c,glyphHeight:l,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(c===0||l===0)return m;let{ctx:h,buffer:g,gridInner:_,gridOuter:v}=this;this.lang&&(h.lang=this.lang),h.clearRect(g,g,c,l),h.fillText(e,g-s,g+o);let y=h.getImageData(g,g,c,l);v.fill(oX,0,f),_.fill(0,0,f);let b=3;for(let e=0;e<l;e++){let t=(e+g)*u+g;for(let e=0;e<c;e++,b+=4,t++){let e=y.data[b];if(e===0)continue;let n=sX[e];v[t]=Math.max(0,n),_[t]=Math.max(0,-n)}}iX(v,0,0,u,d,u,this.f,this.v,this.z);let x=Math.min(g,1);iX(_,g-x,g-x,c+2*x,l+2*x,u,this.f,this.v,this.z);let S=255/this.radius,C=255*(1-this.cutoff);for(let e=0;e<f;e++){let t=Math.sqrt(v[e])-Math.sqrt(_[e]);p[e]=Math.round(C-S*t)}return m}}}));function uX(e){return 2**Math.ceil(Math.log2(e))}function dX({characterSet:e,measureText:t,buffer:n,maxCanvasWidth:r,mapping:i={},xOffset:a=0,yOffsetMin:o=0,yOffsetMax:s=0}){let c=a,l=o,u=s;for(let a of e)if(!i[a]){let{advance:e,width:o,ascent:s,descent:d}=t(a),f=s+d;c+o+n*2>r&&(c=0,l=u),i[a]={x:c+n,y:l+n,width:o,height:f,advance:e,anchorX:o/2,anchorY:s},c+=o+n*2,u=Math.max(u,l+f+n*2)}return{mapping:i,xOffset:c,yOffsetMin:l,yOffsetMax:u,canvasHeight:uX(u)}}function fX(e,t,n,r){let i=0;for(let a=t;a<n;a++){let t=e[a];i+=r[t]?.advance||0}return i}function pX(e,t,n,r,i,a){let o=t,s=0;for(let c=t;c<n;c++){let t=fX(e,c,c+1,i);s+t>r&&(o<c&&a.push(c),o=c,s=0),s+=t}return s}function mX(e,t,n,r,i,a){let o=t,s=t,c=t,l=0;for(let u=t;u<n;u++)if((e[u]===` `||e[u+1]===` `||u+1===n)&&(c=u+1),c>s){let t=fX(e,s,c,i);l+t>r&&(o<s&&(a.push(s),o=s,l=0),t>r&&(t=pX(e,s,c,r,i,a),o=a[a.length-1])),s=c,l+=t}return l}function hX(e,t,n,r,i=0,a){a===void 0&&(a=e.length);let o=[];return t===`break-all`?pX(e,i,a,n,r,o):mX(e,i,a,n,r,o),o}function gX(e,t,n,r,i,a){let o=0,s=0;for(let i=t;i<n;i++){let t=r[e[i]];t&&(s=Math.max(s,t.height))}for(let a=t;a<n;a++){let t=e[a],n=r[t];n?(i[a]=o+n.anchorX,o+=n.advance):(Mw.warn(`Missing character: ${t} (${t.codePointAt(0)})`)(),i[a]=o,o+=yX)}a[0]=o,a[1]=s}function _X(e,t,n,r,i,a){let o=Array.from(e),s=o.length,c=Array(s),l=Array(s),u=Array(s),d=(r===`break-word`||r===`break-all`)&&isFinite(i)&&i>0,f=[0,0],p=[0,0],m=0,h=t+n/2,g=0,_=0;for(let e=0;e<=s;e++){let t=o[e];if((t===`
|
||
`||e===s)&&(_=e),_>g){let e=d?hX(o,r,i,a,g,_):bX;for(let t=0;t<=e.length;t++){let r=t===0?g:e[t-1],i=t<e.length?e[t]:_;gX(o,r,i,a,c,p);for(let e=r;e<i;e++)l[e]=h,u[e]=p[0];m++,h+=n,f[0]=Math.max(f[0],p[0])}g=_}t===`
|
||
`&&(c[g]=0,l[g]=0,u[g]=0,g++)}return f[1]=m*n,{x:c,y:l,rowWidth:u,size:f}}function vX({value:e,length:t,stride:n,offset:r,startIndices:i,characterSet:a}){let o=e.BYTES_PER_ELEMENT,s=n?n/o:1,c=r?r/o:0,l=i[t]||Math.ceil((e.length-c)/s),u=a&&new Set,d=Array(t),f=e;if(s>1||c>0){let t=e.constructor;f=new t(l);for(let t=0;t<l;t++)f[t]=e[t*s+c]}for(let e=0;e<t;e++){let t=i[e],n=i[e+1]||l,r=f.subarray(t,n);d[e]=String.fromCodePoint.apply(null,r),u&&r.forEach(u.add,u)}if(u)for(let e of u)a.add(String.fromCodePoint(e));return{texts:d,characterCount:l}}var yX,bX,xX=o((()=>{EK(),yX=32,bX=[]})),SX,CX=o((()=>{SX=class{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){let t=this._cache[e];return t&&(this._deleteOrder(e),this._appendOrder(e)),t}set(e,t){this._cache[e]?(this.delete(e),this._cache[e]=t,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=t,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){let t=this._order.indexOf(e);t>=0&&this._order.splice(t,1)}_appendOrder(e){this._order.push(e)}}}));function wX(){let e=[];for(let t=32;t<128;t++)e.push(String.fromCharCode(t));return e}function TX(e,t){let n;n=typeof t==`string`?new Set(Array.from(t)):new Set(t);let r=IX.get(e);if(!r)return n;for(let e in r.mapping)n.has(e)&&n.delete(e);return n}function EX(e,t){for(let n=0;n<e.length;n++)t.data[4*n+3]=e[n]}function DX(e,t,n,r){e.font=`${r} ${n}px ${t}`,e.fillStyle=`#000`,e.textBaseline=`alphabetic`,e.textAlign=`left`}function OX(e,t,n){if(n===void 0){let n=e.measureText(`A`);return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:t*NX,descent:t*PX}}let r=e.measureText(n);return r.actualBoundingBoxAscent?{advance:r.width,width:Math.ceil(r.actualBoundingBoxRight-r.actualBoundingBoxLeft),ascent:Math.ceil(r.actualBoundingBoxAscent),descent:Math.ceil(r.actualBoundingBoxDescent)}:{advance:r.width,width:r.width,ascent:t*NX,descent:t*PX}}function kX(e){Mw.assert(Number.isFinite(e)&&e>=FX,`Invalid cache limit`),IX=new SX(e)}function AX({fontSize:e,buffer:t,radius:n,cutoff:r,fontFamily:i,fontWeight:a}){let o=new cX({fontSize:e,buffer:t,radius:n,cutoff:r,fontFamily:i,fontWeight:`${a}`});return e=>{let{data:n,width:r,height:i}=o.draw(e),a=new ImageData(r,i);return EX(n,a),{data:a,left:t,top:t}}}var jX,MX,NX,PX,FX,IX,LX,RX=o((()=>{lX(),EK(),xX(),CX(),jX={fontFamily:`Monaco, monospace`,fontWeight:`normal`,characterSet:wX(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},MX=1024,NX=.9,PX=.3,FX=3,IX=new SX(FX),LX=class{constructor(){this.props={...jX}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(e={}){Object.assign(this.props,e),e._getFontRenderer&&(this._getFontRenderer=e._getFontRenderer),this._key=this._getKey();let t=TX(this._key,this.props.characterSet),n=IX.get(this._key);if(n&&t.size===0){this._atlas!==n&&(this._atlas=n);return}let r=this._generateFontAtlas(t,n);this._atlas=r,IX.set(this._key,r)}_generateFontAtlas(e,t){let{fontFamily:n,fontWeight:r,fontSize:i,buffer:a,sdf:o,radius:s,cutoff:c}=this.props,l=t&&t.data;l||(l=document.createElement(`canvas`),l.width=MX);let u=l.getContext(`2d`,{willReadFrequently:!0});DX(u,n,i,r);let d=e=>OX(u,i,e),f;this._getFontRenderer?f=this._getFontRenderer(this.props):o&&(f={measure:d,draw:AX(this.props)});let{mapping:p,canvasHeight:m,xOffset:h,yOffsetMin:g,yOffsetMax:_}=dX({measureText:e=>f?f.measure(e):d(e),buffer:a,characterSet:e,maxCanvasWidth:MX,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffsetMin:t.yOffsetMin,yOffsetMax:t.yOffsetMax}});if(l.height!==m){let e=l.height>0?u.getImageData(0,0,l.width,l.height):null;l.height=m,e&&u.putImageData(e,0,0)}if(DX(u,n,i,r),f)for(let t of e){let e=p[t],{data:n,left:r=0,top:i=0}=f.draw(t),a=e.x-r,o=e.y-i,s=Math.max(0,Math.round(a)),c=Math.max(0,Math.round(o)),d=Math.min(n.width,l.width-s),m=Math.min(n.height,l.height-c);u.putImageData(n,s,c,0,0,d,m),e.x+=s-a,e.y+=c-o}else for(let t of e){let e=p[t];u.fillText(t,e.x,e.y+e.anchorY)}let v=f?f.measure():d();return{baselineOffset:(v.ascent-v.descent)/2,xOffset:h,yOffsetMin:g,yOffsetMax:_,mapping:p,data:l,width:l.width,height:l.height}}_getKey(){let{fontFamily:e,fontWeight:t,fontSize:n,buffer:r,sdf:i,radius:a,cutoff:o}=this.props;return i?`${e} ${t} ${n} ${r} ${a} ${o}`:`${e} ${t} ${n} ${r}`}}})),zX,BX,VX=o((()=>{zX=`layout(std140) uniform textBackgroundUniforms {
|
||
bool billboard;
|
||
float sizeScale;
|
||
float sizeMinPixels;
|
||
float sizeMaxPixels;
|
||
vec4 borderRadius;
|
||
vec4 padding;
|
||
highp int sizeUnits;
|
||
bool stroked;
|
||
} textBackground;
|
||
`,BX={name:`textBackground`,vs:zX,fs:zX,uniformTypes:{billboard:`f32`,sizeScale:`f32`,sizeMinPixels:`f32`,sizeMaxPixels:`f32`,borderRadius:`vec4<f32>`,padding:`vec4<f32>`,sizeUnits:`i32`,stroked:`f32`}}})),HX,UX=o((()=>{HX=`#version 300 es
|
||
#define SHADER_NAME text-background-layer-vertex-shader
|
||
in vec2 positions;
|
||
in vec3 instancePositions;
|
||
in vec3 instancePositions64Low;
|
||
in vec4 instanceRects;
|
||
in vec4 instanceClipRect;
|
||
in float instanceSizes;
|
||
in float instanceAngles;
|
||
in vec2 instancePixelOffsets;
|
||
in float instanceLineWidths;
|
||
in vec4 instanceFillColors;
|
||
in vec4 instanceLineColors;
|
||
in vec3 instancePickingColors;
|
||
out vec4 vFillColor;
|
||
out vec4 vLineColor;
|
||
out float vLineWidth;
|
||
out vec2 uv;
|
||
out vec2 dimensions;
|
||
vec2 rotate_by_angle(vec2 vertex, float angle) {
|
||
float angle_radian = radians(angle);
|
||
float cos_angle = cos(angle_radian);
|
||
float sin_angle = sin(angle_radian);
|
||
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
|
||
return rotationMatrix * vertex;
|
||
}
|
||
void main(void) {
|
||
geometry.worldPosition = instancePositions;
|
||
geometry.uv = positions;
|
||
geometry.pickingColor = instancePickingColors;
|
||
uv = positions;
|
||
vLineWidth = instanceLineWidths;
|
||
float sizePixels = clamp(
|
||
project_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits),
|
||
textBackground.sizeMinPixels, textBackground.sizeMaxPixels
|
||
);
|
||
float instanceScale = sizePixels / text.fontSize;
|
||
dimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw;
|
||
vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions);
|
||
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles);
|
||
pixelOffset += instancePixelOffsets;
|
||
pixelOffset.y *= -1.0;
|
||
vec2 xy = project_size_to_pixel(instanceClipRect.xy);
|
||
vec2 wh = project_size_to_pixel(instanceClipRect.zw);
|
||
if (text.flipY) {
|
||
xy.y = -xy.y - wh.y;
|
||
}
|
||
if (instanceClipRect.z >= 0.0) {
|
||
dimensions.x = wh.x;
|
||
pixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x);
|
||
}
|
||
if (instanceClipRect.w >= 0.0) {
|
||
dimensions.y = wh.y;
|
||
pixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y);
|
||
}
|
||
if (textBackground.billboard) {
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
vec3 offset = vec3(pixelOffset, 0.0);
|
||
DECKGL_FILTER_SIZE(offset, geometry);
|
||
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
|
||
} else {
|
||
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
|
||
if (text.flipY) {
|
||
offset_common.y *= -1.;
|
||
}
|
||
DECKGL_FILTER_SIZE(offset_common, geometry);
|
||
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
|
||
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
||
}
|
||
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
|
||
DECKGL_FILTER_COLOR(vFillColor, geometry);
|
||
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
|
||
DECKGL_FILTER_COLOR(vLineColor, geometry);
|
||
}
|
||
`})),WX,GX=o((()=>{WX=`#version 300 es
|
||
#define SHADER_NAME text-background-layer-fragment-shader
|
||
precision highp float;
|
||
in vec4 vFillColor;
|
||
in vec4 vLineColor;
|
||
in float vLineWidth;
|
||
in vec2 uv;
|
||
in vec2 dimensions;
|
||
out vec4 fragColor;
|
||
float round_rect(vec2 p, vec2 size, vec4 radii) {
|
||
vec2 pixelPositionCB = (p - 0.5) * size;
|
||
vec2 sizeCB = size * 0.5;
|
||
float maxBorderRadius = min(size.x, size.y) * 0.5;
|
||
vec4 borderRadius = vec4(min(radii, maxBorderRadius));
|
||
borderRadius.xy =
|
||
(pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw;
|
||
borderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y;
|
||
vec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x;
|
||
return -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x);
|
||
}
|
||
float rect(vec2 p, vec2 size) {
|
||
vec2 pixelPosition = p * size;
|
||
return min(min(pixelPosition.x, size.x - pixelPosition.x),
|
||
min(pixelPosition.y, size.y - pixelPosition.y));
|
||
}
|
||
vec4 get_stroked_fragColor(float dist) {
|
||
float isBorder = smoothedge(dist, vLineWidth);
|
||
return mix(vFillColor, vLineColor, isBorder);
|
||
}
|
||
void main(void) {
|
||
geometry.uv = uv;
|
||
if (textBackground.borderRadius != vec4(0.0)) {
|
||
float distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);
|
||
float shapeAlpha = smoothedge(-distToEdge, 0.0);
|
||
if (shapeAlpha == 0.0) {
|
||
discard;
|
||
}
|
||
if (textBackground.stroked) {
|
||
fragColor = get_stroked_fragColor(distToEdge);
|
||
} else {
|
||
fragColor = vFillColor;
|
||
}
|
||
fragColor.a *= shapeAlpha;
|
||
} else {
|
||
if (textBackground.stroked) {
|
||
float distToEdge = rect(uv, dimensions);
|
||
fragColor = get_stroked_fragColor(distToEdge);
|
||
} else {
|
||
fragColor = vFillColor;
|
||
}
|
||
}
|
||
DECKGL_FILTER_COLOR(fragColor, geometry);
|
||
}
|
||
`})),KX,qX,JX=o((()=>{EK(),OR(),VX(),YY(),UX(),GX(),KX={billboard:!0,sizeScale:1,sizeUnits:`pixels`,sizeMinPixels:0,sizeMaxPixels:2**53-1,fontSize:1,borderRadius:{type:`object`,value:0},padding:{type:`array`,value:[0,0,0,0]},getPosition:{type:`accessor`,value:e=>e.position},getSize:{type:`accessor`,value:1},getAngle:{type:`accessor`,value:0},getPixelOffset:{type:`accessor`,value:[0,0]},getBoundingRect:{type:`accessor`,value:[0,0,0,0]},getClipRect:{type:`accessor`,value:[0,0,-1,-1]},getFillColor:{type:`accessor`,value:[0,0,0,255]},getLineColor:{type:`accessor`,value:[0,0,0,255]},getLineWidth:{type:`accessor`,value:1}},qX=class extends lK{getShaders(){return super.getShaders({vs:HX,fs:WX,modules:[fF,pI,BX,JY]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`},instanceSizes:{size:1,transition:!0,accessor:`getSize`,defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:`getAngle`},instanceRects:{size:4,accessor:`getBoundingRect`},instanceClipRect:{size:4,accessor:`getClipRect`,defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,accessor:`getPixelOffset`},instanceFillColors:{size:4,transition:!0,type:`unorm8`,accessor:`getFillColor`,defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:`unorm8`,accessor:`getLineColor`,defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:`getLineWidth`,defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:t}=e;t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:t,sizeScale:n,sizeUnits:r,sizeMinPixels:i,sizeMaxPixels:a,getLineWidth:o,fontSize:s}=this.props,{padding:c,borderRadius:l}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]),Array.isArray(l)||(l=[l,l,l,l]);let u=this.state.model,d={billboard:t,stroked:!!o,borderRadius:l,padding:c,sizeUnits:IP[r],sizeScale:n,sizeMinPixels:i,sizeMaxPixels:a},f={fontSize:s,viewport:this.context.viewport};u.shaderInputs.setProps({textBackground:d,text:f}),u.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,0,1,1,1];return new wR(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new DR({topology:`triangle-strip`,vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}},qX.defaultProps=KX,qX.layerName=`TextBackgroundLayer`})),YX,XX,ZX,QX,$X,eZ=o((()=>{EK(),rX(),RX(),xX(),JX(),YX={start:1,middle:0,end:-1},XX={top:1,center:0,bottom:-1},ZX=[0,0,0,255],QX={billboard:!0,sizeScale:1,sizeUnits:`pixels`,sizeMinPixels:0,sizeMaxPixels:2**53-1,background:!1,getBackgroundColor:{type:`accessor`,value:[255,255,255,255]},getBorderColor:{type:`accessor`,value:ZX},getBorderWidth:{type:`accessor`,value:0},backgroundBorderRadius:{type:`object`,value:0},backgroundPadding:{type:`array`,value:[0,0,0,0]},characterSet:{type:`object`,value:jX.characterSet},fontFamily:jX.fontFamily,fontWeight:jX.fontWeight,lineHeight:1,outlineWidth:{type:`number`,value:0,min:0},outlineColor:{type:`color`,value:ZX},fontSettings:{type:`object`,value:{},compare:1},wordBreak:`break-word`,maxWidth:{type:`number`,value:-1},contentCutoffPixels:{type:`array`,value:[0,0]},contentAlignHorizontal:`none`,contentAlignVertical:`none`,getText:{type:`accessor`,value:e=>e.text},getPosition:{type:`accessor`,value:e=>e.position},getColor:{type:`accessor`,value:ZX},getSize:{type:`accessor`,value:32},getAngle:{type:`accessor`,value:0},getTextAnchor:{type:`accessor`,value:`middle`},getAlignmentBaseline:{type:`accessor`,value:`center`},getPixelOffset:{type:`accessor`,value:[0,0]},getContentBox:{type:`accessor`,value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:[`background`,`getBackgroundColor`]}},$X=class extends fK{constructor(){super(...arguments),this.getBoundingRect=(e,t)=>{let{size:[n,r]}=this.transformParagraph(e,t),{getTextAnchor:i,getAlignmentBaseline:a}=this.props,o=YX[typeof i==`function`?i(e,t):i],s=XX[typeof a==`function`?a(e,t):a];return[(o-1)*n/2,(s-1)*r/2,n,r]},this.getIconOffsets=(e,t)=>{let{getTextAnchor:n,getAlignmentBaseline:r}=this.props,{x:i,y:a,rowWidth:o,size:[,s]}=this.transformParagraph(e,t),c=YX[typeof n==`function`?n(e,t):n],l=XX[typeof r==`function`?r(e,t):r],u=i.length,d=Array(u*2),f=0;for(let e=0;e<u;e++)d[f++]=(c-1)*o[e]/2+i[e],d[f++]=(l-1)*s/2+a[e];return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new LX},this.props.maxWidth>0&&Mw.once(1,`v8.9 breaking change: TextLayer maxWidth is now relative to text size`)()}updateState(e){let{props:t,oldProps:n,changeFlags:r}=e;(r.dataChanged||r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||t.lineHeight!==n.lineHeight||t.wordBreak!==n.wordBreak||t.maxWidth!==n.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:t,fontWeight:n,_getFontRenderer:r}=this.props,{fontAtlasManager:i,characterSet:a}=this.state,o={...e,characterSet:a,fontFamily:t,fontWeight:n,_getFontRenderer:r};if(!i.mapping)return i.setProps(o),!0;for(let e in o)if(o[e]!==i.props[e])return i.setProps(o),!0;return!1}_updateText(){let{data:e,characterSet:t}=this.props,n=e.attributes?.getText,{getText:r}=this.props,i=e.startIndices,a,o=t===`auto`&&new Set;if(n&&i){let{texts:t,characterCount:s}=vX({...ArrayBuffer.isView(n)?{value:n}:n,length:e.length,startIndices:i,characterSet:o});a=s,r=(e,{index:n})=>t[n]}else{let{iterable:t,objectInfo:n}=NW(e);i=[0],a=0;for(let e of t){n.index++;let t=Array.from(r(e,n)||``);o&&t.forEach(o.add,o),a+=t.length,i.push(a)}}this.setState({getText:r,startIndices:i,numInstances:a,characterSet:o||t})}transformParagraph(e,t){let{fontAtlasManager:n}=this.state,r=n.mapping,{baselineOffset:i}=n.atlas,{fontSize:a}=n.props,o=this.state.getText,{wordBreak:s,lineHeight:c,maxWidth:l}=this.props;return _X(o(e,t)||``,i,c*a,s,l*a,r)}renderLayers(){let{startIndices:e,numInstances:t,getText:n,fontAtlasManager:{atlas:r,mapping:i},styleVersion:a}=this.state,{data:o,_dataDiff:s,getPosition:c,getColor:l,getSize:u,getAngle:d,getPixelOffset:f,getBackgroundColor:p,getBorderColor:m,getBorderWidth:h,getContentBox:g,backgroundBorderRadius:_,backgroundPadding:v,background:y,billboard:b,fontSettings:x,outlineWidth:S,outlineColor:C,sizeScale:w,sizeUnits:T,sizeMinPixels:E,sizeMaxPixels:D,contentCutoffPixels:O,contentAlignHorizontal:k,contentAlignVertical:A,transitions:j,updateTriggers:M}=this.props,N=this.getSubLayerClass(`characters`,nX),P=this.getSubLayerClass(`background`,qX),{fontSize:F}=this.state.fontAtlasManager.props;return[y&&new P({getFillColor:p,getLineColor:m,getLineWidth:h,borderRadius:_,padding:v,getPosition:c,getSize:u,getAngle:d,getPixelOffset:f,getClipRect:g,billboard:b,sizeScale:w,sizeUnits:T,sizeMinPixels:E,sizeMaxPixels:D,fontSize:F,transitions:j&&{getPosition:j.getPosition,getAngle:j.getAngle,getSize:j.getSize,getFillColor:j.getBackgroundColor,getLineColor:j.getBorderColor,getLineWidth:j.getBorderWidth,getPixelOffset:j.getPixelOffset}},this.getSubLayerProps({id:`background`,updateTriggers:{getPosition:M.getPosition,getAngle:M.getAngle,getSize:M.getSize,getFillColor:M.getBackgroundColor,getLineColor:M.getBorderColor,getLineWidth:M.getBorderWidth,getPixelOffset:M.getPixelOffset,getBoundingRect:{getText:M.getText,getTextAnchor:M.getTextAnchor,getAlignmentBaseline:M.getAlignmentBaseline,styleVersion:a}}}),{data:o.attributes&&o.attributes.background?{length:o.length,attributes:o.attributes.background}:o,_dataDiff:s,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new N({sdf:x.sdf,smoothing:Number.isFinite(x.smoothing)?x.smoothing:jX.smoothing,outlineWidth:S/(x.radius||jX.radius),outlineColor:C,iconAtlas:r,iconMapping:i,getPosition:c,getColor:l,getSize:u,getAngle:d,getPixelOffset:f,getContentBox:g,billboard:b,sizeScale:w,sizeUnits:T,sizeMinPixels:E,sizeMaxPixels:D,fontSize:F,contentCutoffPixels:O,contentAlignHorizontal:k,contentAlignVertical:A,transitions:j&&{getPosition:j.getPosition,getAngle:j.getAngle,getColor:j.getColor,getSize:j.getSize,getPixelOffset:j.getPixelOffset,getContentBox:j.getContentBox}},this.getSubLayerProps({id:`characters`,updateTriggers:{all:M.getText,getPosition:M.getPosition,getAngle:M.getAngle,getColor:M.getColor,getSize:M.getSize,getPixelOffset:M.getPixelOffset,getContentBox:M.getContentBox,getIconOffsets:{getTextAnchor:M.getTextAnchor,getAlignmentBaseline:M.getAlignmentBaseline,styleVersion:a}}}),{data:o,_dataDiff:s,startIndices:e,numInstances:t,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){kX(e)}},$X.defaultProps=QX,$X.layerName=`TextLayer`}));function tZ({type:e,props:t}){let n={};for(let r in t)n[r]=e.defaultProps[t[r]];return n}function nZ(e,t){let{transitions:n,updateTriggers:r}=e.props,i={updateTriggers:{},transitions:n&&{getPosition:n.geometry}};for(let a in t){let o=t[a],s=e.props[a];a.startsWith(`get`)&&(s=e.getSubLayerAccessor(s),i.updateTriggers[o]=r[a],n&&(i.transitions[o]=n[a])),i[o]=s}return i}var rZ,iZ,aZ,oZ=o((()=>{Tq(),$q(),eZ(),QJ(),IY(),rZ={circle:{type:Qq,props:{filled:`filled`,stroked:`stroked`,lineWidthMaxPixels:`lineWidthMaxPixels`,lineWidthMinPixels:`lineWidthMinPixels`,lineWidthScale:`lineWidthScale`,lineWidthUnits:`lineWidthUnits`,pointRadiusMaxPixels:`radiusMaxPixels`,pointRadiusMinPixels:`radiusMinPixels`,pointRadiusScale:`radiusScale`,pointRadiusUnits:`radiusUnits`,pointAntialiasing:`antialiasing`,pointBillboard:`billboard`,getFillColor:`getFillColor`,getLineColor:`getLineColor`,getLineWidth:`getLineWidth`,getPointRadius:`getRadius`}},icon:{type:wq,props:{iconAtlas:`iconAtlas`,iconMapping:`iconMapping`,iconSizeMaxPixels:`sizeMaxPixels`,iconSizeMinPixels:`sizeMinPixels`,iconSizeScale:`sizeScale`,iconSizeUnits:`sizeUnits`,iconAlphaCutoff:`alphaCutoff`,iconBillboard:`billboard`,getIcon:`getIcon`,getIconAngle:`getAngle`,getIconColor:`getColor`,getIconPixelOffset:`getPixelOffset`,getIconSize:`getSize`}},text:{type:$X,props:{textSizeMaxPixels:`sizeMaxPixels`,textSizeMinPixels:`sizeMinPixels`,textSizeScale:`sizeScale`,textSizeUnits:`sizeUnits`,textBackground:`background`,textBackgroundPadding:`backgroundPadding`,textFontFamily:`fontFamily`,textFontWeight:`fontWeight`,textLineHeight:`lineHeight`,textMaxWidth:`maxWidth`,textOutlineColor:`outlineColor`,textOutlineWidth:`outlineWidth`,textWordBreak:`wordBreak`,textCharacterSet:`characterSet`,textBillboard:`billboard`,textFontSettings:`fontSettings`,getText:`getText`,getTextAngle:`getAngle`,getTextColor:`getColor`,getTextPixelOffset:`getPixelOffset`,getTextSize:`getSize`,getTextAnchor:`getTextAnchor`,getTextAlignmentBaseline:`getAlignmentBaseline`,getTextBackgroundColor:`getBackgroundColor`,getTextBorderColor:`getBorderColor`,getTextBorderWidth:`getBorderWidth`}}},iZ={type:ZJ,props:{lineWidthUnits:`widthUnits`,lineWidthScale:`widthScale`,lineWidthMinPixels:`widthMinPixels`,lineWidthMaxPixels:`widthMaxPixels`,lineJointRounded:`jointRounded`,lineCapRounded:`capRounded`,lineMiterLimit:`miterLimit`,lineBillboard:`billboard`,getLineColor:`getColor`,getLineWidth:`getWidth`}},aZ={type:FY,props:{extruded:`extruded`,filled:`filled`,wireframe:`wireframe`,elevationScale:`elevationScale`,material:`material`,_full3d:`_full3d`,getElevation:`getElevation`,getFillColor:`getFillColor`,getLineColor:`getLineColor`}}}));function sZ(e){if(Array.isArray(e))return e;switch(Mw.assert(e.type,`GeoJSON does not have type`),e.type){case`Feature`:return[e];case`FeatureCollection`:return Mw.assert(Array.isArray(e.features),`GeoJSON does not have features array`),e.features;default:return[{geometry:e}]}}function cZ(e,t,n={}){let r={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:i=0,endRow:a=e.length}=n;for(let n=i;n<a;n++){let i=e[n],{geometry:a}=i;if(a)if(a.type===`GeometryCollection`){Mw.assert(Array.isArray(a.geometries),`GeoJSON does not have geometries array`);let{geometries:e}=a;for(let a=0;a<e.length;a++){let o=e[a];lZ(o,r,t,i,n)}}else lZ(a,r,t,i,n)}return r}function lZ(e,t,n,r,i){let{type:a,coordinates:o}=e,{pointFeatures:s,lineFeatures:c,polygonFeatures:l,polygonOutlineFeatures:u}=t;if(!uZ(a,o)){Mw.warn(`${a} coordinates are malformed`)();return}switch(a){case`Point`:s.push(n({geometry:e},r,i));break;case`MultiPoint`:o.forEach(e=>{s.push(n({geometry:{type:`Point`,coordinates:e}},r,i))});break;case`LineString`:c.push(n({geometry:e},r,i));break;case`MultiLineString`:o.forEach(e=>{c.push(n({geometry:{type:`LineString`,coordinates:e}},r,i))});break;case`Polygon`:l.push(n({geometry:e},r,i)),o.forEach(e=>{u.push(n({geometry:{type:`LineString`,coordinates:e}},r,i))});break;case`MultiPolygon`:o.forEach(e=>{l.push(n({geometry:{type:`Polygon`,coordinates:e}},r,i)),e.forEach(e=>{u.push(n({geometry:{type:`LineString`,coordinates:e}},r,i))})});break;default:}}function uZ(e,t){let n=dZ[e];for(Mw.assert(n,`Unknown GeoJSON type ${e}`);t&&--n>0;)t=t[0];return t&&Number.isFinite(t[0])}var dZ,fZ=o((()=>{EK(),dZ={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4}}));function pZ(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function mZ(e){return e.geometry.coordinates}function hZ(e,t){let n=pZ(),{pointFeatures:r,lineFeatures:i,polygonFeatures:a,polygonOutlineFeatures:o}=e;return n.points.data=r,n.points._dataDiff=t.pointFeatures&&(()=>t.pointFeatures),n.points.getPosition=mZ,n.lines.data=i,n.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),n.lines.getPath=mZ,n.polygons.data=a,n.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),n.polygons.getPolygon=mZ,n.polygonsOutline.data=o,n.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),n.polygonsOutline.getPath=mZ,n}function gZ(e,t){let n=pZ(),{points:r,lines:i,polygons:a}=e,o=VY(e,t);n.points.data={length:r.positions.value.length/r.positions.size,attributes:{...r.attributes,getPosition:r.positions,instancePickingColors:{size:4,value:o.points}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},n.lines.data={length:i.pathIndices.value.length-1,startIndices:i.pathIndices.value,attributes:{...i.attributes,getPath:i.positions,instancePickingColors:{size:4,value:o.lines}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},n.lines._pathType=`open`;let s=a.positions.value.length/a.positions.size,c=Array(s).fill(1);for(let e of a.primitivePolygonIndices.value)c[e-1]=0;return n.polygons.data={length:a.polygonIndices.value.length-1,startIndices:a.polygonIndices.value,attributes:{...a.attributes,getPolygon:a.positions,instanceVertexValid:{size:1,value:new Uint16Array(c)},pickingColors:{size:4,value:o.polygons}},properties:a.properties,numericProps:a.numericProps,featureIds:a.featureIds},n.polygons._normalize=!1,a.triangles&&(n.polygons.data.attributes.indices=a.triangles.value),n.polygonsOutline.data={length:a.primitivePolygonIndices.value.length-1,startIndices:a.primitivePolygonIndices.value,attributes:{...a.attributes,getPath:a.positions,instancePickingColors:{size:4,value:o.polygons}},properties:a.properties,numericProps:a.numericProps,featureIds:a.featureIds},n.polygonsOutline._pathType=`open`,n}var _Z=o((()=>{HY()})),vZ,yZ,bZ,xZ=o((()=>{EK(),RY(),HY(),oZ(),fZ(),_Z(),vZ=[`points`,`linestrings`,`polygons`],yZ={...tZ(rZ.circle),...tZ(rZ.icon),...tZ(rZ.text),...tZ(iZ),...tZ(aZ),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:`object`,value:null},iconMapping:{type:`object`,value:{}},getIcon:{type:`accessor`,value:e=>e.properties.icon},getText:{type:`accessor`,value:e=>e.properties.text},pointType:`circle`,getRadius:{deprecatedFor:`getPointRadius`}},bZ=class extends fK{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:t}){if(!t.dataChanged)return;let{data:n}=this.props,r=n&&`points`in n&&`polygons`in n&&`lines`in n;this.setState({binary:r}),r?this._updateStateBinary({props:e,changeFlags:t}):this._updateStateJSON({props:e,changeFlags:t})}_updateStateBinary({props:e,changeFlags:t}){let n=gZ(e.data,this.encodePickingColor);this.setState({layerProps:n})}_updateStateJSON({props:e,changeFlags:t}){let n=sZ(e.data),r=this.getSubLayerRow.bind(this),i={},a={};if(Array.isArray(t.dataChanged)){let e=this.state.features;for(let t in e)i[t]=e[t].slice(),a[t]=[];for(let o of t.dataChanged){let t=cZ(n,r,o);for(let n in e)a[n].push(LY({data:i[n],getIndex:e=>e.__source.index,dataRange:o,replace:t[n]}))}}else i=cZ(n,r);let o=hZ(i,a);this.setState({features:i,featuresDiff:a,layerProps:o})}getPickingInfo(e){let t=super.getPickingInfo(e),{index:n,sourceLayer:r}=t;return t.featureType=vZ.find(e=>r.id.startsWith(`${this.id}-${e}-`)),n>=0&&r.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(t.index=this.props.data.points.globalFeatureIds.value[n]),t}_updateAutoHighlight(e){let t=`${this.id}-points-`,n=e.featureType===`points`;for(let r of this.getSubLayers())r.id.startsWith(t)===n&&r.updateAutoHighlight(e)}_renderPolygonLayer(){let{extruded:e,wireframe:t}=this.props,{layerProps:n}=this.state,r=`polygons-fill`,i=this.shouldRenderSubLayer(r,n.polygons?.data)&&this.getSubLayerClass(r,aZ.type);if(i){let a=nZ(this,aZ.props),o=e&&t;return o||delete a.getLineColor,a.updateTriggers.lineColors=o,new i(a,this.getSubLayerProps({id:r,updateTriggers:a.updateTriggers}),n.polygons)}return null}_renderLineLayers(){let{extruded:e,stroked:t}=this.props,{layerProps:n}=this.state,r=`polygons-stroke`,i=`linestrings`,a=!e&&t&&this.shouldRenderSubLayer(r,n.polygonsOutline?.data)&&this.getSubLayerClass(r,iZ.type),o=this.shouldRenderSubLayer(i,n.lines?.data)&&this.getSubLayerClass(i,iZ.type);if(a||o){let e=nZ(this,iZ.props);return[a&&new a(e,this.getSubLayerProps({id:r,updateTriggers:e.updateTriggers}),n.polygonsOutline),o&&new o(e,this.getSubLayerProps({id:i,updateTriggers:e.updateTriggers}),n.lines)]}return null}_renderPointLayers(){let{pointType:e}=this.props,{layerProps:t,binary:n}=this.state,{highlightedObjectIndex:r}=this.props;!n&&Number.isFinite(r)&&(r=t.points.data.findIndex(e=>e.__source.index===r));let i=new Set(e.split(`+`)),a=[];for(let e of i){let i=`points-${e}`,o=rZ[e],s=o&&this.shouldRenderSubLayer(i,t.points?.data)&&this.getSubLayerClass(i,o.type);if(s){let c=nZ(this,o.props),l=t.points;if(e===`text`&&n){let{instancePickingColors:e,...t}=l.data.attributes;l={...l,data:{...l.data,attributes:t}}}a.push(new s(c,this.getSubLayerProps({id:i,updateTriggers:c.updateTriggers,highlightedObjectIndex:r}),l))}}return a}renderLayers(){let{extruded:e}=this.props,t=this._renderPolygonLayer(),n=this._renderLineLayers(),r=this._renderPointLayers();return[!e&&t,n,r,e&&t]}getSubLayerAccessor(e){let{binary:t}=this.state;return!t||typeof e!=`function`?super.getSubLayerAccessor(e):(t,n)=>{let{data:r,index:i}=n;return e(zY(r,i),n)}}},bZ.layerName=`GeoJsonLayer`,bZ.defaultProps=yZ})),SZ=o((()=>{EK(),OR(),QF(),lO(),Tq(),Bq(),$q(),MJ(),QJ(),IY(),_Y(),RY(),xZ(),eZ(),rX(),JX()}));function CZ(e,t){if(!e)throw Error(t||`loader assertion failed.`)}function wZ(e){if(typeof window<`u`&&window.process?.type===`renderer`||typeof process<`u`&&process.versions?.electron)return!0;let t=typeof navigator<`u`&&navigator.userAgent,n=e||t;return!!(n&&n.indexOf(`Electron`)>=0)}function TZ(){return!(typeof process==`object`&&String(process)===`[object process]`&&!process?.browser)||wZ()}function EZ(e,t){if(!e)throw Error(t||`Assertion failed`)}function DZ(e){if(!e)return 0;let t;switch(typeof e){case`number`:t=e;break;case`object`:t=e.logLevel||e.priority||0;break;default:return 0}return EZ(Number.isFinite(t)&&t>=0),t}function OZ(e){let{logLevel:t,message:n}=e;e.logLevel=DZ(t);let r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case`string`:case`function`:n!==void 0&&r.unshift(n),e.message=t;break;case`object`:Object.assign(e,t);break;default:}typeof e.message==`function`&&(e.message=e.message());let i=typeof e.message;return EZ(i===`string`||i===`object`),Object.assign(e,{args:r},e.opts)}function kZ(e){try{let t=window[e],n=`__storage_test__`;return t.setItem(n,n),t.removeItem(n),t}catch{return null}}function AZ(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}function jZ(e,t=8){let n=Math.max(t-e.length,0);return`${` `.repeat(n)}${e}`}function MZ(e){return typeof e==`string`?(e=e.toUpperCase(),N6[e]||N6.WHITE):e}function NZ(e,t,n){return!TZ&&typeof e==`string`&&(t&&(e=`\u001b[${MZ(t)}m${e}\u001b[39m`),n&&(e=`\u001b[${MZ(n)+P6}m${e}\u001b[49m`)),e}function PZ(e,t=[`constructor`]){let n=Object.getOwnPropertyNames(Object.getPrototypeOf(e)),r=e;for(let i of n){let n=r[i];typeof n==`function`&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}function FZ(){let e;if(TZ()&&D6.performance)e=D6?.performance?.now?.();else if(`hrtime`in O6){let t=O6?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}function IZ(e,t,n){if(typeof t==`string`){let r=n.time?jZ(AZ(n.total)):``;t=n.time?`${e}: ${r} ${t}`:`${e}: ${t}`,t=NZ(t,n.color,n.background)}return t}function LZ(e){for(let t in e)for(let n in e[t])return n||`untitled`;return`empty`}function RZ(){let e=new L6({id:`loaders.gl`});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=R6,globalThis.probe||={},globalThis.probe.loaders=e,e}function zZ(e,t){return BZ(e||{},t)}function BZ(e,t,n=0){if(n>3)return t;let r={...e};for(let[e,i]of Object.entries(t))i&&typeof i==`object`&&!Array.isArray(i)?r[e]=BZ(r[e]||{},t[e],n+1):r[e]=t[e];return r}function VZ(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version=`4.4.2`),globalThis._loadersgl_.version}function HZ(e,t){if(!e)throw Error(t||`loaders.gl assertion failed.`)}function UZ(e){HZ(e.source&&!e.url||!e.source&&e.url);let t=s8.get(e.source||e.url);return t||(e.url&&(t=WZ(e.url),s8.set(e.url,t)),e.source&&(t=GZ(e.source),s8.set(e.source,t))),HZ(t),t}function WZ(e){return e.startsWith(`http`)?GZ(KZ(e)):e}function GZ(e){let t=new Blob([e],{type:`application/javascript`});return URL.createObjectURL(t)}function KZ(e){return`\
|
||
try {
|
||
importScripts('${e}');
|
||
} catch (error) {
|
||
console.error(error);
|
||
throw error;
|
||
}`}function qZ(e,t=!0,n){let r=n||new Set;if(e){if(JZ(e))r.add(e);else if(JZ(e.buffer))r.add(e.buffer);else if(!ArrayBuffer.isView(e)&&t&&typeof e==`object`)for(let n in e)qZ(e[n],t,r)}return n===void 0?Array.from(r):[]}function JZ(e){return e?e instanceof ArrayBuffer||typeof MessagePort<`u`&&e instanceof MessagePort||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas:!1}function YZ(e,t={}){let n=t[e.id]||{},r=n8?`${e.id}-worker.js`:`${e.id}-worker-node.js`,i=n.workerUrl;if(!i&&e.id===`compression`&&(i=t.workerUrl),(t._workerType||t?.core?._workerType)===`test`&&(i=n8?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let t=e.version;t===`latest`&&(t=$6);let n=t?`@${t}`:``;i=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return HZ(i),i}function XZ(e,t=e8){HZ(e,`no worker provided`);let n=e.version;return!(!t||!n)}function ZZ(e,t){if(!f8.isSupported())return!1;let n=t?._nodeWorkers??t?.core?._nodeWorkers;if(!n8&&!n)return!1;let r=t?.worker??t?.core?.worker;return!!(e.worker&&r)}async function QZ(e,t,n,r,i){let a=e.id,o=YZ(e,n),s=f8.getWorkerFarm(n?.core).getWorkerPool({name:a,url:o});n=JSON.parse(JSON.stringify(n)),r=JSON.parse(JSON.stringify(r||{}));let c=await s.startJob(`process-on-worker`,$Z.bind(null,i));return c.postMessage(`process`,{input:t,options:n,context:r}),await(await c.result).result}async function $Z(e,t,n,r){switch(n){case`done`:t.done(r);break;case`error`:t.error(Error(r.error));break;case`process`:let{id:i,input:a,options:o}=r;try{let n=await e(a,o);t.postMessage(`done`,{id:i,result:n})}catch(e){let n=e instanceof Error?e.message:`unknown error`;t.postMessage(`error`,{id:i,error:n})}break;default:console.warn(`parse-with-worker unknown message ${n}`)}}function eQ(e,t,n){if(n||=e.byteLength,e.byteLength<n||t.byteLength<n)return!1;let r=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<r.length;++e)if(r[e]!==i[e])return!1;return!0}function tQ(...e){return nQ(e)}function nQ(e){let t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;return r.buffer}async function rQ(e){let t=[];for await(let n of e)t.push(iQ(n));return tQ(...t)}function iQ(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){let{buffer:t,byteOffset:n,byteLength:r}=e;return aQ(t,n,r)}return aQ(e)}function aQ(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function oQ(e){for(let t in m8)if(e.startsWith(t)){let n=m8[t];e=e.replace(t,n)}return!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&(e=`${p8}${e}`),e}function sQ(e){return e}function cQ(e){return e&&typeof e==`object`&&e.isBuffer}function lQ(e){if(cQ(e))return sQ(e);if(e instanceof ArrayBuffer)return e;if(W6(e))return dQ(e);if(ArrayBuffer.isView(e)){let t=e.buffer;return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(typeof e==`string`){let t=e;return new TextEncoder().encode(t).buffer}if(e&&typeof e==`object`&&e._toArrayBuffer)return e._toArrayBuffer();throw Error(`toArrayBuffer`)}function uQ(e){if(e instanceof ArrayBuffer)return e;if(W6(e))return dQ(e);let{buffer:t,byteOffset:n,byteLength:r}=e;return t instanceof ArrayBuffer&&n===0&&r===t.byteLength?t:dQ(t,n,r)}function dQ(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function fQ(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}function pQ(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(t+1):e}function mQ(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(0,t):``}function hQ(e,t){return e.toLowerCase()===t.toLowerCase()}function gQ(e){let t=_8.exec(e);return t?t[1]:e}function _Q(e){let t=g8.exec(e);return t?t[1]:``}function vQ(e){let t=e.match(v8);return t&&t[0]}function yQ(e){return e.replace(v8,``)}function bQ(e){if(e.length<50)return e;let t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}function xQ(e){return J6(e)?e.url:Y6(e)?(`name`in e?e.name:``)||``:typeof e==`string`?e:``}function SQ(e){if(J6(e)){let t=e.headers.get(`content-type`)||``,n=yQ(e.url);return gQ(t)||_Q(n)}return Y6(e)?e.type||``:typeof e==`string`?_Q(e):``}function CQ(e){return J6(e)?e.headers[`content-length`]||-1:Y6(e)?e.size:typeof e==`string`?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}async function wQ(e){if(J6(e))return e;let t={},n=CQ(e);n>=0&&(t[`content-length`]=String(n));let r=xQ(e),i=SQ(e);i&&(t[`content-type`]=i);let a=await DQ(e);a&&(t[`x-first-bytes`]=a),typeof e==`string`&&(e=new TextEncoder().encode(e));let o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:r}),o}async function TQ(e){if(!e.ok)throw await EQ(e)}async function EQ(e){let t=bQ(e.url),n=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;n=n.length>100?`${n.slice(0,100)}...`:n;let r={reason:e.statusText,url:e.url,response:e};try{let t=e.headers.get(`Content-Type`);r.reason=!e.bodyUsed&&t?.includes(`application/json`)?await e.json():await e.text()}catch{}return new h8(n,r)}async function DQ(e){if(typeof e==`string`)return`data:,${e.slice(0,5)}`;if(e instanceof Blob){let t=e.slice(0,5);return await new Promise(e=>{let n=new FileReader;n.onload=t=>e(t?.target?.result),n.readAsDataURL(t)})}return e instanceof ArrayBuffer?`data:base64,${OQ(e.slice(0,5))}`:null}function OQ(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function kQ(e){return!AQ(e)&&!jQ(e)}function AQ(e){return e.startsWith(`http:`)||e.startsWith(`https:`)}function jQ(e){return e.startsWith(`data:`)}async function MQ(e,t){if(typeof e==`string`){let n=oQ(e);return kQ(n)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(n,t):await fetch(n,t)}return await wQ(e)}function NQ(){globalThis.loaders=globalThis.loaders||{};let{loaders:e}=globalThis;return e._state||={},e._state}function PQ(){let e=NQ();return e.globalOptions=e.globalOptions||{...S8,core:{...S8.core}},IQ(e.globalOptions)}function FQ(e,t,n,r){return n||=[],n=Array.isArray(n)?n:[n],LQ(e,n),IQ(BQ(t,e,r))}function IQ(e){let t=UQ(e);WQ(t);for(let e of w8)t.core&&t.core[e]!==void 0&&delete t[e];return t.core&&t.core._workerType!==void 0&&delete t._worker,t}function LQ(e,t){RQ(e,null,S8,C8,t);for(let n of t){let r=e&&e[n.id]||{},i=n.options&&n.options[n.id]||{},a=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};RQ(r,n.id,i,a,t)}}function RQ(e,t,n,r,i){let a=t||`Top level`,o=t?`${t}.`:``;for(let s in e){let c=!t&&H6(e[s]),l=s===`baseUri`&&!t,u=s===`workerUrl`&&t;if(!(s in n)&&!l&&!u){if(s in r)y8.level>0&&y8.warn(`${a} loader option \'${o}${s}\' no longer supported, use \'${r[s]}\'`)();else if(!c&&y8.level>0){let e=zQ(s,i);y8.warn(`${a} loader option \'${o}${s}\' not recognized. ${e}`)()}}}}function zQ(e,t){let n=e.toLowerCase(),r=``;for(let i of t)for(let t in i.options){if(e===t)return`Did you mean \'${i.id}.${t}\'?`;let a=t.toLowerCase();(n.startsWith(a)||a.startsWith(n))&&(r||=`Did you mean \'${i.id}.${t}\'?`)}return r}function BQ(e,t,n){let r=e.options||{},i={...r};return r.core&&(i.core={...r.core}),WQ(i),i.core?.log===null&&(i.core={...i.core,log:new b8}),VQ(i,IQ(PQ())),VQ(i,IQ(t)),HQ(i,n),GQ(i),i}function VQ(e,t){for(let n in t)if(n in t){let r=t[n];U6(r)&&U6(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function HQ(e,t){t&&e.core?.baseUrl===void 0&&(e.core||={},e.core.baseUrl=mQ(yQ(t)))}function UQ(e){let t={...e};return e.core&&(t.core={...e.core}),t}function WQ(e){e.baseUri!==void 0&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=e.baseUri));for(let t of w8)if(e[t]!==void 0){let n=e.core=e.core||{};n[t]===void 0&&(n[t]=e[t])}let t=e._worker;t!==void 0&&(e.core||={},e.core._workerType===void 0&&(e.core._workerType=t))}function GQ(e){let t=e.core;if(t)for(let n of w8)t[n]!==void 0&&(e[n]=t[n])}function KQ(e){return e?(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions)):!1}function qQ(e){CZ(e,`null loader`),CZ(KQ(e),`invalid loader`);let t;return Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function JQ(){return T8()}async function YQ(e,t=[],n,r){if(!$Q(e))return null;let i=IQ(n||{});if(i.core||={},e instanceof Response&&XQ(e)){let n=ZQ(await e.clone().text(),t,{...i,core:{...i.core,nothrow:!0}},r);if(n)return n}let a=ZQ(e,t,{...i,core:{...i.core,nothrow:!0}},r);if(a)return a;if(Y6(e)&&(e=await e.slice(0,10).arrayBuffer(),a=ZQ(e,t,i,r)),!a&&e instanceof Response&&XQ(e)&&(a=ZQ(await e.clone().text(),t,i,r)),!a&&!i.core.nothrow)throw Error(e$(e));return a}function XQ(e){let t=SQ(e);return!!(t&&(t.startsWith(`text/`)||t===`application/json`||t.endsWith(`+json`)))}function ZQ(e,t=[],n,r){if(!$Q(e))return null;let i=IQ(n||{});if(i.core||={},t&&!Array.isArray(t))return qQ(t);let a=[];t&&(a=a.concat(t)),i.core.ignoreRegisteredLoaders||a.push(...JQ()),t$(a);let o=QQ(e,a,i,r);if(!o&&!i.core.nothrow)throw Error(e$(e));return o}function QQ(e,t,n,r){let i=xQ(e),a=SQ(e),o=yQ(i)||r?.url,s=null,c=``;return n?.core?.mimeType&&(s=i$(t,n?.core?.mimeType),c=`match forced by supplied MIME type ${n?.core?.mimeType}`),s||=n$(t,o),c||=s?`matched url ${o}`:``,s||=i$(t,a),c||=s?`matched MIME type ${a}`:``,s||=a$(t,e),c||=s?`matched initial data ${l$(e)}`:``,n?.core?.fallbackMimeType&&(s||=i$(t,n?.core?.fallbackMimeType),c||=s?`matched fallback MIME type ${a}`:``),c&&z6.log(1,`selectLoader selected ${s?.name}: ${c}.`),s}function $Q(e){return!(e instanceof Response&&e.status===204)}function e$(e){let t=xQ(e),n=SQ(e),r=`No valid loader found (`;r+=t?`${pQ(t)}, `:`no url provided, `,r+=`MIME type: ${n?`"${n}"`:`not provided`}, `;let i=e?l$(e):``;return r+=i?` first bytes: "${i}"`:`first bytes: not available`,r+=`)`,r}function t$(e){for(let t of e)qQ(t)}function n$(e,t){let n=t&&E8.exec(t),r=n&&n[1];return r?r$(e,r):null}function r$(e,t){t=t.toLowerCase();for(let n of e)for(let e of n.extensions)if(e.toLowerCase()===t)return n;return null}function i$(e,t){for(let n of e)if(n.mimeTypes?.some(e=>hQ(t,e))||hQ(t,`application/x.${n.id}`))return n;return null}function a$(e,t){if(!t)return null;for(let n of e)if(typeof t==`string`){if(o$(t,n))return n}else if(ArrayBuffer.isView(t)){if(s$(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&s$(t,0,n))return n;return null}function o$(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function s$(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(r=>c$(e,t,n,r))}function c$(e,t,n,r){if(G6(r))return eQ(r,e,r.byteLength);switch(typeof r){case`function`:return r(uQ(e));case`string`:return r===u$(e,t,r.length);default:return!1}}function l$(e,t=5){return typeof e==`string`?e.slice(0,t):ArrayBuffer.isView(e)?u$(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?u$(e,0,t):``}function u$(e,t,n){if(e.byteLength<t+n)return``;let r=new DataView(e),i=``;for(let e=0;e<n;e++)i+=String.fromCharCode(r.getUint8(t+e));return i}function*d$(e,t){let n=t?.chunkSize||D8,r=0,i=new TextEncoder;for(;r<e.length;){let t=Math.min(e.length-r,n),a=e.slice(r,r+t);r+=t,yield uQ(i.encode(a))}}function*f$(e,t={}){let{chunkSize:n=O8}=t,r=0;for(;r<e.byteLength;){let t=Math.min(e.byteLength-r,n),i=new ArrayBuffer(t),a=new Uint8Array(e,r,t);new Uint8Array(i).set(a),r+=t,yield i}}async function*p$(e,t){let n=t?.chunkSize||k8,r=0;for(;r<e.size;){let t=r+n,i=await e.slice(r,t).arrayBuffer();r=t,yield i}}function m$(e,t){return T6?h$(e,t):g$(e,t)}async function*h$(e,t){let n=e.getReader(),r;try{for(;;){let e=r||n.read();t?._streamReadAhead&&(r=n.read());let{done:i,value:a}=await e;if(i)return;yield lQ(a)}}catch{n.releaseLock()}}async function*g$(e,t){for await(let t of e)yield lQ(t)}function _$(e,t){if(typeof e==`string`)return d$(e,t);if(e instanceof ArrayBuffer)return f$(e,t);if(Y6(e))return p$(e,t);if(Q6(e))return m$(e,t);if(J6(e)){let n=e.body;if(!n)throw Error(`Readable stream not available on Response`);return m$(n,t)}throw Error(`makeIterator`)}function v$(e,t,n){if(t.text&&typeof e==`string`)return e;if(cQ(e)&&(e=e.buffer),G6(e)){let n=fQ(e);return t.text&&!t.binary?new TextDecoder(`utf8`).decode(n):lQ(n)}throw Error(A8)}async function y$(e,t,n){if(typeof e==`string`||G6(e))return v$(e,t,n);if(Y6(e)&&(e=await wQ(e)),J6(e))return await TQ(e),t.binary?await e.arrayBuffer():await e.text();if(Q6(e)&&(e=_$(e,n)),K6(e)||q6(e))return rQ(e);throw Error(A8)}function b$(e,t){let n=PQ(),r=e||n,i=r.fetch??r.core?.fetch;return typeof i==`function`?i:H6(i)?e=>MQ(e,i):t?.fetch?t?.fetch:MQ}function x$(e,t,n){if(n)return n;let r={fetch:b$(t,e),...e};if(r.url){let e=yQ(r.url);r.baseUrl=e,r.queryString=vQ(r.url),r.filename=pQ(e),r.baseUrl=mQ(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}function S$(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){let e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}async function C$(e,t,n,r){t&&!Array.isArray(t)&&!KQ(t)&&(r=void 0,n=t,t=void 0),e=await e,n||={};let i=xQ(e),a=S$(t,r),o=await YQ(e,a,n);if(!o)return null;let s=FQ(n,o,a,i);return r=x$({url:i,_parse:C$,loaders:a},s,r||null),await w$(o,e,s,r)}async function w$(e,t,n,r){if(XZ(e),n=zZ(e.options,n),J6(t)){let{ok:e,redirected:n,status:i,statusText:a,type:o,url:s}=t;r.response={headers:Object.fromEntries(t.headers.entries()),ok:e,redirected:n,status:i,statusText:a,type:o,url:s}}t=await y$(t,e,n);let i=e;if(i.parseTextSync&&typeof t==`string`)return i.parseTextSync(t,n,r);if(ZZ(e,n))return await QZ(e,t,n,r,C$);if(i.parseText&&typeof t==`string`)return await i.parseText(t,n,r);if(i.parse)return await i.parse(t,n,r);throw HZ(!i.parseSync),Error(`${e.id} loader - no parser found and worker is disabled`)}function T$(e){switch(e.constructor){case Int8Array:return`int8`;case Uint8Array:case Uint8ClampedArray:return`uint8`;case Int16Array:return`int16`;case Uint16Array:return`uint16`;case Int32Array:return`int32`;case Uint32Array:return`uint32`;case Float32Array:return`float32`;case Float64Array:return`float64`;default:return`null`}}function E$(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=e.POSITION?e.POSITION.value:[],c=s&&s.length;for(let e=0;e<c;e+=3){let c=s[e],l=s[e+1],u=s[e+2];t=c<t?c:t,n=l<n?l:n,r=u<r?u:r,i=c>i?c:i,a=l>a?l:a,o=u>o?u:o}return[[t,n,r],[i,a,o]]}function D$(e,t={}){return{fields:k$(e),metadata:t}}function O$(e,t,n){let r=T$(t.value),i=n||A$(t);return{name:e,type:{type:`fixed-size-list`,listSize:t.size,children:[{name:`value`,type:r}]},nullable:!1,metadata:i}}function k$(e){let t=[];for(let n in e){let r=e[n];t.push(O$(n,r))}return t}function A$(e){let t={};return`byteOffset`in e&&(t.byteOffset=e.byteOffset.toString(10)),`byteStride`in e&&(t.byteStride=e.byteStride.toString(10)),`normalized`in e&&(t.normalized=e.normalized.toString()),t}async function j$(e,t,n,r){let i,a;!Array.isArray(t)&&!KQ(t)?(i=[],a=t,r=void 0):(i=t,a=n);let o=b$(a),s=e;return typeof e==`string`&&(s=await o(e)),Y6(e)&&(s=await o(e)),typeof e==`string`&&(IQ(a||{}).core?.baseUrl||(a={...a,core:{...a?.core,baseUrl:e}})),await C$(s,i,a)}function M$(e,t){return D$(t,N$(e))}function N$(e){let t={};return t.las_pointsOffset=e.pointsOffset.toString(10),t.las_pointsFormatId=e.pointsFormatId.toString(10),t.las_pointsStructSize=e.pointsStructSize.toString(10),t.las_pointsCount=e.pointsCount.toString(10),t.las_scale=JSON.stringify(e.scale),t.las_offset=JSON.stringify(e.offset),e.maxs!==void 0&&(t.las_maxs=JSON.stringify(e.maxs)),e.mins!==void 0&&(t.las_mins=JSON.stringify(e.mins)),t.las_totalToRead=e.totalToRead.toString(10),t.las_pointsFortotalReadmatId=e.totalRead.toString(10),e.versionAsString!==void 0&&(t.las_versionAsString=e.versionAsString),e.isCompressed!==void 0&&(t.las_isCompressed=e.isCompressed.toString()),t}function P$(){var e=e===void 0?{}:e,t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r=[],i=!1,a=!1,o=!1,s=!1;i=typeof window==`object`,a=typeof importScripts==`function`,o=typeof process==`object`&&typeof process.versions==`object`&&typeof process.versions.node==`string`,s=!i&&!o&&!a;var c=``;function l(t){return e.locateFile?e.locateFile(t,c):c+t}var u,d,f,p,m;o?(c=a?{dirname:e=>{let t=e.lastIndexOf(`/`);return t<=0?t===0?`/`:`.`:e.substring(0,t)},normalize:e=>e,join:(...e)=>e.filter(Boolean).join(`/`).replace(/\/+/g,`/`)}.dirname(c)+`/`:(typeof __dirname<`u`?__dirname:``)+`/`,u=function(e,t){var n=kn(e);return n?t?n:n.toString():(p||={},m||={dirname:e=>{let t=e.lastIndexOf(`/`);return t<=0?t===0?`/`:`.`:e.substring(0,t)},normalize:e=>e,join:(...e)=>e.filter(Boolean).join(`/`).replace(/\/+/g,`/`)},e=m.normalize(e),p.readFileSync(e,t?null:`utf8`))},f=function(e){var t=u(e,!0);return t.buffer||(t=new Uint8Array(t)),C(t.buffer),t},process.argv.length>1&&process.argv[1].replace(/\\/g,`/`),r=process.argv.slice(2),typeof module<`u`&&(module.exports=e),process.on(`uncaughtException`,function(e){if(!(e instanceof Hn))throw e}),process.on(`unhandledRejection`,De),e.inspect=function(){return`[Emscripten Module object]`}):s?(typeof read<`u`&&(u=function(e){var t=kn(e);return t?En(t):read(e)}),f=function(e){var t=kn(e);return t||(typeof readbuffer==`function`?new Uint8Array(readbuffer(e)):(t=read(e,`binary`),C(typeof t==`object`),t))},typeof scriptArgs<`u`?r=scriptArgs:typeof arguments<`u`&&(r=arguments),typeof print<`u`&&(typeof console>`u`&&(console={}),console.log=print,console.warn=console.error=typeof printErr<`u`?printErr:print)):(i||a)&&(a?c=self.location.href:document.currentScript&&(c=document.currentScript.src),c=c.indexOf(`blob:`)===0?``:c.substr(0,c.lastIndexOf(`/`)+1),u=function(e){try{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.send(null),t.responseText}catch(t){var n=kn(e);if(n)return En(n);throw t}},a&&(f=function(e){try{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}catch(t){var n=kn(e);if(n)return n;throw t}}),d=function(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=function(){if(r.status==200||r.status==0&&r.response){t(r.response);return}var i=kn(e);if(i){t(i.buffer);return}n()},r.onerror=n,r.send(null)});var h=e.print||console.log.bind(console),g=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&(r=e.arguments),e.thisProgram&&e.thisProgram,e.quit&&e.quit;function _(e){_.shown||={},_.shown[e]||(_.shown[e]=1,g(e))}var v=0,y=function(e){v=e},b=function(){return v},x=8;e.wasmBinary&&e.wasmBinary,e.noExitRuntime&&e.noExitRuntime;var S=!1;function C(e,t){e||De(`Assertion failed: `+t)}var w=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function T(e,t,n){for(var r=t+n,i=t;e[i]&&!(i>=r);)++i;if(i-t>16&&e.subarray&&w)return w.decode(e.subarray(t,i));for(var a=``;t<i;){var o=e[t++];if(!(o&128)){a+=String.fromCharCode(o);continue}var s=e[t++]&63;if((o&224)==192){a+=String.fromCharCode((o&31)<<6|s);continue}var c=e[t++]&63;if(o=(o&240)==224?(o&15)<<12|s<<6|c:(o&7)<<18|s<<12|c<<6|e[t++]&63,o<65536)a+=String.fromCharCode(o);else{var l=o-65536;a+=String.fromCharCode(55296|l>>10,56320|l&1023)}}return a}function E(e,t){return e?T(te,e,t):``}function D(e,t,n,r){if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343){var c=e.charCodeAt(++o);s=65536+((s&1023)<<10)|c&1023}if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|s&63}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|s&63}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|s&63}}return t[n]=0,n-i}function O(e,t,n){return D(e,te,t,n)}function k(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r>=55296&&r<=57343&&(r=65536+((r&1023)<<10)|e.charCodeAt(++n)&1023),r<=127?++t:r<=2047?t+=2:r<=65535?t+=3:t+=4}return t}var A=typeof TextDecoder<`u`?new TextDecoder(`utf-16le`):void 0;function j(e,t){for(var n=e,r=n>>1,i=r+t/2;!(r>=i)&&R[r];)++r;if(n=r<<1,n-e>32&&A)return A.decode(te.subarray(e,n));for(var a=0,o=``;;){var s=ne[e+a*2>>1];if(s==0||a==t/2)return o;++a,o+=String.fromCharCode(s)}}function M(e,t,n){if(n===void 0&&(n=2147483647),n<2)return 0;n-=2;for(var r=t,i=n<e.length*2?n/2:e.length,a=0;a<i;++a){var o=e.charCodeAt(a);ne[t>>1]=o,t+=2}return ne[t>>1]=0,t-r}function N(e){return e.length*2}function P(e,t){for(var n=0,r=``;!(n>=t/4);){var i=re[e+n*4>>2];if(i==0)break;if(++n,i>=65536){var a=i-65536;r+=String.fromCharCode(55296|a>>10,56320|a&1023)}else r+=String.fromCharCode(i)}return r}function F(e,t,n){if(n===void 0&&(n=2147483647),n<4)return 0;for(var r=t,i=r+n-4,a=0;a<e.length;++a){var o=e.charCodeAt(a);if(o>=55296&&o<=57343){var s=e.charCodeAt(++a);o=65536+((o&1023)<<10)|s&1023}if(re[t>>2]=o,t+=4,t+4>i)break}return re[t>>2]=0,t-r}function ee(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r>=55296&&r<=57343&&++n,t+=4}return t}var I,L,te,ne,R,re,ie,ae,oe;function se(t){I=t,e.HEAP8=L=new Int8Array(t),e.HEAP16=ne=new Int16Array(t),e.HEAP32=re=new Int32Array(t),e.HEAPU8=te=new Uint8Array(t),e.HEAPU16=R=new Uint16Array(t),e.HEAPU32=ie=new Uint32Array(t),e.HEAPF32=ae=new Float32Array(t),e.HEAPF64=oe=new Float64Array(t)}var ce=5265264,le=22176,ue=e.INITIAL_MEMORY||167772160;I=e.buffer?e.buffer:new ArrayBuffer(ue),ue=I.byteLength,se(I),re[le>>2]=ce;function de(t){for(;t.length>0;){var n=t.shift();if(typeof n==`function`){n(e);continue}var r=n.func;typeof r==`number`?n.arg===void 0?e.dynCall_v(r):e.dynCall_vi(r,n.arg):r(n.arg===void 0?null:n.arg)}}var fe=[],pe=[],me=[],he=[];function ge(){if(e.preRun)for(typeof e.preRun==`function`&&(e.preRun=[e.preRun]);e.preRun.length;)be(e.preRun.shift());de(fe)}function _e(){de(pe)}function ve(){de(me)}function ye(){if(e.postRun)for(typeof e.postRun==`function`&&(e.postRun=[e.postRun]);e.postRun.length;)xe(e.postRun.shift());de(he)}function be(e){fe.unshift(e)}function xe(e){he.unshift(e)}var Se=0,Ce=null,we=null;function Te(t){Se++,e.monitorRunDependencies&&e.monitorRunDependencies(Se)}function Ee(t){if(Se--,e.monitorRunDependencies&&e.monitorRunDependencies(Se),Se==0&&(Ce!==null&&(clearInterval(Ce),Ce=null),we)){var n=we;we=null,n()}}e.preloadedImages={},e.preloadedAudios={};function De(t){throw e.onAbort&&e.onAbort(t),t+=``,h(t),g(t),S=!0,t=`abort(`+t+`). Build with -s ASSERTIONS=1 for more info.`,t}var Oe=null;function ke(e,t){return String.prototype.startsWith?e.startsWith(t):e.indexOf(t)===0}var Ae=`data:application/octet-stream;base64,`;function je(e){return ke(e,Ae)}pe.push({func:function(){Fn()}}),Oe=`data:application/octet-stream;base64,AAAAAAAAAAAPDg0MCwoJCA4AAQMGCgoJDQECBAcLCwoMAwQFCAwMCwsGBwgJDQ0MCgoLDA0ODg0JCgsMDQ4PDggJCgsMDQ4PAAECAwQFBgcBAAECAwQFBgIBAAECAwQFAwIBAAECAwQEAwIBAAECAwUEAwIBAAECBgUEAwIBAAEHBgUEAwIBAMgPAAAoDQAAEBAAACAQAADIDwAAUA0AABAQAAAgEAAAEQAKABEREQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAARAA8KERERAwoHAAEACQsLAAAJBgsAAAsABhEAAAAREREAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAEQAKChEREQAKAAACAAkLAAAACQALAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAADAAAAAAJDAAAAAAADAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAANAAAABA0AAAAACQ4AAAAAAA4AAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAADwAAAAAPAAAAAAkQAAAAAAAQAAAQAAASAAAAEhISAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAASEhIAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAAKAAAAAAoAAAAACQsAAAAAAAsAAAsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAMAAAAAAkMAAAAAAAMAAAMAAAwMTIzNDU2Nzg5QUJDREVGGRJEOwI/LEcUPTMwChsGRktFNw9JDo4XA0AdPGkrNh9KLRwBICUpIQgMFRYiLhA4Pgs0MRhkdHV2L0EJfzkRI0MyQomKiwUEJignDSoeNYwHGkiTE5SVAAAAAAAAAAAASWxsZWdhbCBieXRlIHNlcXVlbmNlAERvbWFpbiBlcnJvcgBSZXN1bHQgbm90IHJlcHJlc2VudGFibGUATm90IGEgdHR5AFBlcm1pc3Npb24gZGVuaWVkAE9wZXJhdGlvbiBub3QgcGVybWl0dGVkAE5vIHN1Y2ggZmlsZSBvciBkaXJlY3RvcnkATm8gc3VjaCBwcm9jZXNzAEZpbGUgZXhpc3RzAFZhbHVlIHRvbyBsYXJnZSBmb3IgZGF0YSB0eXBlAE5vIHNwYWNlIGxlZnQgb24gZGV2aWNlAE91dCBvZiBtZW1vcnkAUmVzb3VyY2UgYnVzeQBJbnRlcnJ1cHRlZCBzeXN0ZW0gY2FsbABSZXNvdXJjZSB0ZW1wb3JhcmlseSB1bmF2YWlsYWJsZQBJbnZhbGlkIHNlZWsAQ3Jvc3MtZGV2aWNlIGxpbmsAUmVhZC1vbmx5IGZpbGUgc3lzdGVtAERpcmVjdG9yeSBub3QgZW1wdHkAQ29ubmVjdGlvbiByZXNldCBieSBwZWVyAE9wZXJhdGlvbiB0aW1lZCBvdXQAQ29ubmVjdGlvbiByZWZ1c2VkAEhvc3QgaXMgZG93bgBIb3N0IGlzIHVucmVhY2hhYmxlAEFkZHJlc3MgaW4gdXNlAEJyb2tlbiBwaXBlAEkvTyBlcnJvcgBObyBzdWNoIGRldmljZSBvciBhZGRyZXNzAEJsb2NrIGRldmljZSByZXF1aXJlZABObyBzdWNoIGRldmljZQBOb3QgYSBkaXJlY3RvcnkASXMgYSBkaXJlY3RvcnkAVGV4dCBmaWxlIGJ1c3kARXhlYyBmb3JtYXQgZXJyb3IASW52YWxpZCBhcmd1bWVudABBcmd1bWVudCBsaXN0IHRvbyBsb25nAFN5bWJvbGljIGxpbmsgbG9vcABGaWxlbmFtZSB0b28gbG9uZwBUb28gbWFueSBvcGVuIGZpbGVzIGluIHN5c3RlbQBObyBmaWxlIGRlc2NyaXB0b3JzIGF2YWlsYWJsZQBCYWQgZmlsZSBkZXNjcmlwdG9yAE5vIGNoaWxkIHByb2Nlc3MAQmFkIGFkZHJlc3MARmlsZSB0b28gbGFyZ2UAVG9vIG1hbnkgbGlua3MATm8gbG9ja3MgYXZhaWxhYmxlAFJlc291cmNlIGRlYWRsb2NrIHdvdWxkIG9jY3VyAFN0YXRlIG5vdCByZWNvdmVyYWJsZQBQcmV2aW91cyBvd25lciBkaWVkAE9wZXJhdGlvbiBjYW5jZWxlZABGdW5jdGlvbiBub3QgaW1wbGVtZW50ZWQATm8gbWVzc2FnZSBvZiBkZXNpcmVkIHR5cGUASWRlbnRpZmllciByZW1vdmVkAERldmljZSBub3QgYSBzdHJlYW0ATm8gZGF0YSBhdmFpbGFibGUARGV2aWNlIHRpbWVvdXQAT3V0IG9mIHN0cmVhbXMgcmVzb3VyY2VzAExpbmsgaGFzIGJlZW4gc2V2ZXJlZABQcm90b2NvbCBlcnJvcgBCYWQgbWVzc2FnZQBGaWxlIGRlc2NyaXB0b3IgaW4gYmFkIHN0YXRlAE5vdCBhIHNvY2tldABEZXN0aW5hdGlvbiBhZGRyZXNzIHJlcXVpcmVkAE1lc3NhZ2UgdG9vIGxhcmdlAFByb3RvY29sIHdyb25nIHR5cGUgZm9yIHNvY2tldABQcm90b2NvbCBub3QgYXZhaWxhYmxlAFByb3RvY29sIG5vdCBzdXBwb3J0ZWQAU29ja2V0IHR5cGUgbm90IHN1cHBvcnRlZABOb3Qgc3VwcG9ydGVkAFByb3RvY29sIGZhbWlseSBub3Qgc3VwcG9ydGVkAEFkZHJlc3MgZmFtaWx5IG5vdCBzdXBwb3J0ZWQgYnkgcHJvdG9jb2wAQWRkcmVzcyBub3QgYXZhaWxhYmxlAE5ldHdvcmsgaXMgZG93bgBOZXR3b3JrIHVucmVhY2hhYmxlAENvbm5lY3Rpb24gcmVzZXQgYnkgbmV0d29yawBDb25uZWN0aW9uIGFib3J0ZWQATm8gYnVmZmVyIHNwYWNlIGF2YWlsYWJsZQBTb2NrZXQgaXMgY29ubmVjdGVkAFNvY2tldCBub3QgY29ubmVjdGVkAENhbm5vdCBzZW5kIGFmdGVyIHNvY2tldCBzaHV0ZG93bgBPcGVyYXRpb24gYWxyZWFkeSBpbiBwcm9ncmVzcwBPcGVyYXRpb24gaW4gcHJvZ3Jlc3MAU3RhbGUgZmlsZSBoYW5kbGUAUmVtb3RlIEkvTyBlcnJvcgBRdW90YSBleGNlZWRlZABObyBtZWRpdW0gZm91bmQAV3JvbmcgbWVkaXVtIHR5cGUATm8gZXJyb3IgaW5mb3JtYXRpb24AAAAAAADgFgAAmRgAAGAQAAAAAAAA4BYAAEIZAABgEAAAAAAAAOAWAAAqGgAASA8AAAAAAAC4FgAANBsAAOAWAACfGgAAMAoAAAAAAADgFgAAaRsAAEgPAAAAAAAA4BYAAIobAABIDwAAAAAAALgWAAAPHAAA4BYAAHwcAABIDwAAAAAAAOAWAACVHAAASA8AAAAAAADgFgAAHh0AAEgPAAAAAAAA4BYAAHcdAABIDwAAAAAAAOAWAACQHQAASA8AAAAAAADgFgAAQh4AAEgPAAAAAAAA4BYAAIceAABgEAAAAAAAAOAWAACkHwAASA8AAAAAAAC4FgAAZyAAAOAWAADkHwAA8AoAAAAAAADgFgAAjyAAAGAQAAAAAAAAuBYAAMMiAADgFgAAAiIAABgLAAAAAAAA4BYAAOEiAABgEAAAAAAAAOAWAADQJAAAGAsAAAAAAADgFgAAkSUAAGAQAAAAAAAA4BYAAIAnAAAYCwAAAAAAAOAWAAA9KAAAYBAAAAAAAADgFgAAJCoAABgLAAAAAAAA4BYAAOkqAABgEAAAAAAAAOAWAADgLAAA8AoAAAAAAADgFgAAui0AAGAQAAAAAAAA4BYAANsvAADwCgAAAAAAAOAWAADTMAAAYBAAAAAAAADgFgAAMDMAAPAKAAAAAAAA4BYAACQ0AABgEAAAAAAAAOAWAAB5NgAA8AoAAAAAAADgFgAAizcAAGAQAAAAAAAA4BYAABw6AABgEAAAAAAAAOAWAACdOgAAYBAAAAAAAADgFgAAXjsAAPAKAAAAAAAA4BYAALU7AABgEAAAAAAAAOAWAADMPAAAGAsAAAAAAADgFgAATz0AAGAQAAAAAAAA4BYAAL4+AAAYCwAAAAAAAOAWAABBPwAAYBAAAAAAAADgFgAAsEAAABgLAAAAAAAA4BYAADNBAABgEAAAAAAAAOAWAACiQgAAGAsAAAAAAADgFgAAJUMAAGAQAAAAAAAA4BYAAJREAAAYCwAAAAAAAOAWAAAXRQAAYBAAAAAAAADgFgAAhkYAABgLAAAAAAAA4BYAAAlHAABgEAAAAAAAALgWAAB4SAAAiBcAAIBIAAAAAAAAIA0AAIgXAACJSAAAAQAAACANAAC4FgAAqkgAAIgXAAC6SAAAAAAAAEgNAACIFwAAy0gAAAEAAABIDQAAuBYAABhMAAC4FgAAN0wAALgWAABWTAAAuBYAAHVMAAC4FgAAlEwAALgWAACzTAAAuBYAANJMAAC4FgAA8UwAALgWAAAQTQAAuBYAAC9NAAC4FgAATk0AALgWAABtTQAAuBYAAIxNAACkFwAAn00AAAAAAAABAAAA8A0AAAAAAAC4FgAA4U0AAKQXAAAHTgAAAAAAAAEAAADwDQAAAAAAAKQXAABJTgAAAAAAAAEAAADwDQAAAAAAAKQXAACITgAAAAAAAAEAAADwDQAAAAAAAKQXAADHTgAAAAAAAAEAAADwDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALgWAADNTwAA4BYAAC1QAAAADwAAAAAAAOAWAADaTwAAEA8AAAAAAAC4FgAA+08AAOAWAAAIUAAA8A4AAAAAAADgFgAAhlAAAOgOAAAAAAAA4BYAAJNQAADoDgAAAAAAAOAWAACjUAAA6A4AAAAAAADgFgAAtVAAADgPAAAAAAAA4BYAAMZQAAA4DwAAAAAAAOAWAADXUAAAAA8AAAAAAADgFgAA+VAAAHgPAAAAAAAA4BYAAB1RAAAADwAAAAAAAOAWAABCUQAAeA8AAAAAAADgFgAAjlEAAAAPAAAAAAAAbBcAALZRAABsFwAAuFEAAGwXAAC7UQAAbBcAAL1RAABsFwAAv1EAAGwXAADBUQAAbBcAAMNRAABsFwAAxVEAAGwXAADHUQAAbBcAAMlRAABsFwAAy1EAAGwXAADNUQAAbBcAAM9RAABsFwAA0VEAAOAWAADTUQAA8A4AAAAAAADgFgAARlIAAOgOAAAAAAAAuBYAAGJSAACkFwAAe1IAAAAAAAABAAAAWBAAAAAAAADgFgAA9FIAAIgQAAAAAAAA4BYAABdTAACYEAAAAAAAALgWAAAuUwAA4BYAAHBTAACIEAAAAAAAAOAWAACSUwAASA8AAAAAAAAAAAAAAAoAAAEAAAACAAAAAwAAAAEAAAAEAAAAAAAAABAKAAABAAAABQAAAAYAAAACAAAABwAAAAAAAAAgCgAACAAAAAkAAAABAAAAAAAAADgKAAAKAAAACwAAAAIAAAABAAAADAAAAA0AAAACAAAAAwAAAAMAAAAAAAAASAoAAAgAAAAOAAAAAQAAAAAAAABYCgAACAAAAA8AAAABAAAAAAAAAIAKAAAIAAAAEAAAAAEAAAAAAAAAcAoAAAgAAAARAAAAAQAAAAAAAACQCgAACAAAABIAAAABAAAAAAAAAKAKAAAIAAAAEwAAAAEAAAAAAAAAsAoAAAgAAAAUAAAAAQAAAAAAAADACgAACAAAABUAAAABAAAAAAAAANAKAAABAAAAFgAAABcAAAAEAAAAGAAAAAAAAADgCgAACAAAABkAAAABAAAAAAAAAPgKAAAFAAAAGgAAABsAAAAAAAAA8AoAAAEAAAAcAAAAHQAAAAAAAAAICwAAAQAAAB4AAAAfAAAABgAAACAAAAAAAAAAIAsAACEAAAAiAAAABwAAAAgAAAAAAAAAGAsAACMAAAAkAAAABwAAAAkAAAAAAAAAMAsAAAEAAAAlAAAAJgAAAAoAAAAnAAAAAAAAAEALAAAoAAAAKQAAAAcAAAALAAAAAAAAAFALAAABAAAAKgAAACsAAAAMAAAALAAAAAAAAABgCwAALQAAAC4AAAAHAAAADQAAAAAAAABwCwAAAQAAAC8AAAAwAAAADgAAADEAAAAAAAAAgAsAADIAAAAzAAAABwAAAA8AAAAAAAAAkAsAAAEAAAA0AAAANQAAABAAAAA2AAAAAAAAAKALAAARAAAANwAAADgAAAAAAAAAsAsAAAEAAAA5AAAAOgAAABIAAAA7AAAAAAAAAMALAAATAAAAPAAAAD0AAAAAAAAA0AsAAAEAAAA+AAAAPwAAABQAAABAAAAAAAAAAOALAAAVAAAAQQAAAEIAAAAAAAAA8AsAAAEAAABDAAAARAAAABYAAABFAAAAAAAAAAAMAAAXAAAARgAAAEcAAAAAAAAAEAwAAAEAAABIAAAASQAAABgAAABKAAAAAAAAACAMAAABAAAASwAAAEwAAAAZAAAATQAAAAAAAAAwDAAAAQAAAE4AAABPAAAAGgAAAFAAAAAAAAAAQAwAABsAAABRAAAAUgAAAAAAAABQDAAAAQAAAFMAAABUAAAAHAAAAFUAAAAAAAAAYAwAAFYAAABXAAAABwAAAB0AAAAAAAAAcAwAAAEAAABYAAAAWQAAAB4AAABaAAAAAAAAAIAMAABbAAAAXAAAAAcAAAAfAAAAAAAAAJAMAAABAAAAXQAAAF4AAAAgAAAAXwAAAAAAAACgDAAAYAAAAGEAAAAHAAAAIQAAAAAAAACwDAAAAQAAAGIAAABjAAAAIgAAAGQAAAAAAAAAwAwAAGUAAABmAAAABwAAACMAAAAAAAAA0AwAAAEAAABnAAAAaAAAACQAAABpAAAAAAAAAOAMAABqAAAAawAAAAcAAAAlAAAAAAAAAPAMAAABAAAAbAAAAG0AAAAmAAAAbgAAAAAAAAAADQAAbwAAAHAAAAAHAAAAJwAAAAAAAAAQDQAAAQAAAHEAAAByAAAAKAAAAHMAAAAoDQAAyA8AACgNAAAIEAAAEBAAACgNAABQDQAAyA8AAFANAAAgEAAAyA8AAFANAAAIEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwDgAAdAAAAHUAAAB2AAAAdwAAAAIAAAABAAAAAQAAAAEAAAAAAAAAGA8AAHQAAAB4AAAAdgAAAHcAAAACAAAAAgAAAAIAAAACAAAAAAAAACgPAAB5AAAAegAAAAQAAAAAAAAAOA8AAHsAAAB8AAAABQAAAAAAAABIDwAACAAAAH0AAAABAAAAAAAAAFgPAAB7AAAAfgAAAAUAAAAAAAAAaA8AAHsAAAB/AAAABQAAAAAAAAC4DwAAdAAAAIAAAAB2AAAAdwAAAAMAAAAAAAAAiA8AAHQAAACBAAAAdgAAAHcAAAAEAAAAAAAAADgQAAB0AAAAggAAAHYAAAB3AAAAAgAAAAMAAAADAAAAAwAAAAAAAABIEAAAgwAAAIQAAAAGAAAAAAAAAHgQAACFAAAAhgAAAAcAAAABAAAABQAAAAYAAAACAAAAAAAAAKAQAACFAAAAhwAAAAgAAAADAAAABQAAAAYAAAAEAAAA4BcAAAQYAAAAAAAAsBAAAIgAAACJAAAAAQAAAExBU1ppcABvcGVuAGdldFBvaW50AGdldENvdW50AER5bmFtaWNMQVNaaXAAYWRkRmllbGRGbG9hdGluZwBhZGRGaWVsZFNpZ25lZABhZGRGaWVsZFVuc2lnbmVkAE5TdDNfXzIyMF9fc2hhcmVkX3B0cl9wb2ludGVySVBONmxhc3ppcDdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRU5TXzE0ZGVmYXVsdF9kZWxldGVJUzNfRUVOU185YWxsb2NhdG9ySVMzX0VFRUUATlN0M19fMjE0ZGVmYXVsdF9kZWxldGVJTjZsYXN6aXA3c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRQBOU3QzX18yMjBfX3NoYXJlZF9wdHJfcG9pbnRlcklQTjZsYXN6aXAyaW82cmVhZGVyMTBiYXNpY19maWxlSU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRU5TXzE0ZGVmYXVsdF9kZWxldGVJUzdfRUVOU185YWxsb2NhdG9ySVM3X0VFRUUATlN0M19fMjE0ZGVmYXVsdF9kZWxldGVJTjZsYXN6aXAyaW82cmVhZGVyMTBiYXNpY19maWxlSU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFAExBU0YATjZsYXN6aXAxM2ludmFsaWRfbWFnaWNFAGFsbG9jYXRvcjxUPjo6YWxsb2NhdGUoc2l6ZV90IG4pICduJyBleGNlZWRzIG1heGltdW0gc3VwcG9ydGVkIHNpemUARmlsZSBtYWdpYyBpcyBub3QgdmFsaWQATlN0M19fMjEwX19mdW5jdGlvbjZfX2Z1bmNJWk42bGFzemlwMmlvNnJlYWRlcjEwYmFzaWNfZmlsZUlOUzJfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRTExX3ZhbGlkYXRvcnNFdkVVbFJOUzNfNmhlYWRlckVFX05TXzlhbGxvY2F0b3JJU0JfRUVGdlNBX0VFRQBOU3QzX18yMTBfX2Z1bmN0aW9uNl9fYmFzZUlGdlJONmxhc3ppcDJpbzZoZWFkZXJFRUVFAE42bGFzemlwMjFvbGRfc3R5bGVfY29tcHJlc3Npb25FAE42bGFzemlwMTRub3RfY29tcHJlc3NlZEUAVGhlIGZpbGUgc2VlbXMgdG8gaGF2ZSBvbGQgc3R5bGUgY29tcHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZABUaGUgZmlsZSBkb2Vzbid0IHNlZW0gdG8gYmUgY29tcHJlc3NlZABaTjZsYXN6aXAyaW82cmVhZGVyMTBiYXNpY19maWxlSU5TXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUUxMV92YWxpZGF0b3JzRXZFVWxSTlMwXzZoZWFkZXJFRV8AbGFzemlwIGVuY29kZWQATjZsYXN6aXAxM25vX2xhc3ppcF92bHJFAE42bGFzemlwMjVsYXN6aXBfZm9ybWF0X3Vuc3VwcG9ydGVkRQBPbmx5IExBU3ppcCBQT0lOVFdJU0UgQ0hVTktFRCBkZWNvbXByZXNzb3IgaXMgc3VwcG9ydGVkAE5vIExBU3ppcCBWTFIgd2FzIGZvdW5kIGluIHRoZSBWTFJzIHNlY3Rpb24ATjZsYXN6aXAyMmNodW5rX3RhYmxlX3JlYWRfZXJyb3JFAENodW5rIHRhYmxlIG9mZnNldCA9PSAtMSBpcyBub3Qgc3VwcG9ydGVkIGF0IHRoaXMgdGltZQBONmxhc3ppcDEzbm90X3N1cHBvcnRlZEUATjZsYXN6aXAyNnVua25vd25fY2h1bmtfdGFibGVfZm9ybWF0RQBjaHVua19zaXplID09IHVpbnQubWF4IGlzIG5vdCBzdXBwb3J0ZWQgYXQgdGhpcyB0aW1lLgBUaGVyZSB3YXMgYSBwcm9ibGVtIHJlYWRpbmcgdGhlIGNodW5rIHRhYmxlAFRoZSBjaHVuayB0YWJsZSB2ZXJzaW9uIG51bWJlciBpcyB1bmtub3duAE42bGFzemlwMTFlbmRfb2ZfZmlsZUUAUmVhY2hlZCBFbmQgb2YgZmlsZQBJbnZhbGlkIG51bWJlciBvZiBzeW1ib2xzAE5TdDNfXzIyMF9fc2hhcmVkX3B0cl9wb2ludGVySVBONmxhc3ppcDhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOU18xNGRlZmF1bHRfZGVsZXRlSVM5X0VFTlNfOWFsbG9jYXRvcklTOV9FRUVFAE5TdDNfXzIxNGRlZmF1bHRfZGVsZXRlSU42bGFzemlwOGRlY29kZXJzMTBhcml0aG1ldGljSU5TMV8yaW8xOF9faWZzdHJlYW1fd3JhcHBlcklOUzFfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRUVFRUVFAE42bGFzemlwMTl1bmtub3duX3NjaGVtYV90eXBlRQBUaGUgTEFaIHNjaGVtYSBpcyBub3QgcmVjb2duaXplZABONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2ZpZWxkX2RlY29tcHJlc3NvcklOU184ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlNfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlNfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyMGR5bmFtaWNfZGVjb21wcmVzc29yRQBOU3QzX18yMjBfX3NoYXJlZF9wdHJfcG9pbnRlcklQTjZsYXN6aXA3Zm9ybWF0czI2ZHluYW1pY19maWVsZF9kZWNvbXByZXNzb3JJTlMxXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVFRU5TXzE0ZGVmYXVsdF9kZWxldGVJU0NfRUVOU185YWxsb2NhdG9ySVNDX0VFRUUATlN0M19fMjE0ZGVmYXVsdF9kZWxldGVJTjZsYXN6aXA3Zm9ybWF0czI2ZHluYW1pY19maWVsZF9kZWNvbXByZXNzb3JJTlMxXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOU18yaW8xOF9faWZzdHJlYW1fd3JhcHBlcklOU183c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMwXzVmaWVsZElOUzBfM2xhczdwb2ludDEwRU5TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNDX0VFRUVFRQBONmxhc3ppcDdmb3JtYXRzMTBiYXNlX2ZpZWxkRQBOU3QzX18yMjBfX3NoYXJlZF9wdHJfcG9pbnRlcklQTjZsYXN6aXA3Zm9ybWF0czI2ZHluYW1pY19kZWNvbXByZXNzb3JfZmllbGRJTlMxXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzJfNWZpZWxkSU5TMl8zbGFzN3BvaW50MTBFTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0VfRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTSV9FRU5TXzlhbGxvY2F0b3JJU0lfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSU5TMV8yaW8xOF9faWZzdHJlYW1fd3JhcHBlcklOUzFfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRUVFRU5TMl81ZmllbGRJTlMyXzNsYXM3cG9pbnQxMEVOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTRV9FRUVFRUVFRQBONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOU184ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlNfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlNfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRUVFRU5TMF81ZmllbGRJTlMwXzNsYXM3Z3BzdGltZUVOUzBfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTQ19FRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzVmaWVsZElOUzJfM2xhczdncHN0aW1lRU5TMl8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNFX0VFRUVFRU5TXzE0ZGVmYXVsdF9kZWxldGVJU0lfRUVOU185YWxsb2NhdG9ySVNJX0VFRUUATlN0M19fMjE0ZGVmYXVsdF9kZWxldGVJTjZsYXN6aXA3Zm9ybWF0czI2ZHluYW1pY19kZWNvbXByZXNzb3JfZmllbGRJTlMxXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzJfNWZpZWxkSU5TMl8zbGFzN2dwc3RpbWVFTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0VfRUVFRUVFRUUATjZsYXN6aXA3Zm9ybWF0czI2ZHluYW1pY19kZWNvbXByZXNzb3JfZmllbGRJTlNfOGRlY29kZXJzMTBhcml0aG1ldGljSU5TXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzBfNWZpZWxkSU5TMF8zbGFzM3JnYkVOUzBfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTQ19FRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzVmaWVsZElOUzJfM2xhczNyZ2JFTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0VfRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTSV9FRU5TXzlhbGxvY2F0b3JJU0lfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSU5TMV8yaW8xOF9faWZzdHJlYW1fd3JhcHBlcklOUzFfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRUVFRU5TMl81ZmllbGRJTlMyXzNsYXMzcmdiRU5TMl8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNFX0VFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOU18yaW8xOF9faWZzdHJlYW1fd3JhcHBlcklOU183c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMwXzVmaWVsZElOUzBfM2xhczEwZXh0cmFieXRlc0VOUzBfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTQ19FRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzVmaWVsZElOUzJfM2xhczEwZXh0cmFieXRlc0VOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTRV9FRUVFRUVOU18xNGRlZmF1bHRfZGVsZXRlSVNJX0VFTlNfOWFsbG9jYXRvcklTSV9FRUVFAE5TdDNfXzIxNGRlZmF1bHRfZGVsZXRlSU42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzVmaWVsZElOUzJfM2xhczEwZXh0cmFieXRlc0VOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTRV9FRUVFRUVFRQBONmxhc3ppcDdmb3JtYXRzMjFkeW5hbWljX2RlY29tcHJlc3NvcjFJTlNfOGRlY29kZXJzMTBhcml0aG1ldGljSU5TXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzBfMTlyZWNvcmRfZGVjb21wcmVzc29ySUpOUzBfNWZpZWxkSU5TMF8zbGFzN3BvaW50MTBFTlMwXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0RfRUVFRUVFRUVFAE5TdDNfXzIyMF9fc2hhcmVkX3B0cl9wb2ludGVySVBONmxhc3ppcDdmb3JtYXRzMjFkeW5hbWljX2RlY29tcHJlc3NvcjFJTlMxXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzJfMTlyZWNvcmRfZGVjb21wcmVzc29ySUpOUzJfNWZpZWxkSU5TMl8zbGFzN3BvaW50MTBFTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0ZfRUVFRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTS19FRU5TXzlhbGxvY2F0b3JJU0tfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjFkeW5hbWljX2RlY29tcHJlc3NvcjFJTlMxXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzJfMTlyZWNvcmRfZGVjb21wcmVzc29ySUpOUzJfNWZpZWxkSU5TMl8zbGFzN3BvaW50MTBFTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0ZfRUVFRUVFRUVFRUUATjZsYXN6aXA3Zm9ybWF0czIxZHluYW1pY19kZWNvbXByZXNzb3IxSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOU18yaW8xOF9faWZzdHJlYW1fd3JhcHBlcklOU183c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMwXzE5cmVjb3JkX2RlY29tcHJlc3NvcklKTlMwXzVmaWVsZElOUzBfM2xhczdwb2ludDEwRU5TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNEX0VFRUVOU0JfSU5TQ183Z3BzdGltZUVOU0VfSVNIX0VFRUVFRUVFRQBOU3QzX18yMjBfX3NoYXJlZF9wdHJfcG9pbnRlcklQTjZsYXN6aXA3Zm9ybWF0czIxZHluYW1pY19kZWNvbXByZXNzb3IxSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzE5cmVjb3JkX2RlY29tcHJlc3NvcklKTlMyXzVmaWVsZElOUzJfM2xhczdwb2ludDEwRU5TMl8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNGX0VFRUVOU0RfSU5TRV83Z3BzdGltZUVOU0dfSVNKX0VFRUVFRUVFRU5TXzE0ZGVmYXVsdF9kZWxldGVJU05fRUVOU185YWxsb2NhdG9ySVNOX0VFRUUATlN0M19fMjE0ZGVmYXVsdF9kZWxldGVJTjZsYXN6aXA3Zm9ybWF0czIxZHluYW1pY19kZWNvbXByZXNzb3IxSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzE5cmVjb3JkX2RlY29tcHJlc3NvcklKTlMyXzVmaWVsZElOUzJfM2xhczdwb2ludDEwRU5TMl8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNGX0VFRUVOU0RfSU5TRV83Z3BzdGltZUVOU0dfSVNKX0VFRUVFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyMWR5bmFtaWNfZGVjb21wcmVzc29yMUlOU184ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlNfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlNfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRUVFRU5TMF8xOXJlY29yZF9kZWNvbXByZXNzb3JJSk5TMF81ZmllbGRJTlMwXzNsYXM3cG9pbnQxMEVOUzBfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTRF9FRUVFTlNCX0lOU0NfM3JnYkVOU0VfSVNIX0VFRUVFRUVFRQBOU3QzX18yMjBfX3NoYXJlZF9wdHJfcG9pbnRlcklQTjZsYXN6aXA3Zm9ybWF0czIxZHluYW1pY19kZWNvbXByZXNzb3IxSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzE5cmVjb3JkX2RlY29tcHJlc3NvcklKTlMyXzVmaWVsZElOUzJfM2xhczdwb2ludDEwRU5TMl8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNGX0VFRUVOU0RfSU5TRV8zcmdiRU5TR19JU0pfRUVFRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTTl9FRU5TXzlhbGxvY2F0b3JJU05fRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjFkeW5hbWljX2RlY29tcHJlc3NvcjFJTlMxXzhkZWNvZGVyczEwYXJpdGhtZXRpY0lOUzFfMmlvMThfX2lmc3RyZWFtX3dyYXBwZXJJTlMxXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzJfMTlyZWNvcmRfZGVjb21wcmVzc29ySUpOUzJfNWZpZWxkSU5TMl8zbGFzN3BvaW50MTBFTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0ZfRUVFRU5TRF9JTlNFXzNyZ2JFTlNHX0lTSl9FRUVFRUVFRUVFRQBONmxhc3ppcDdmb3JtYXRzMjFkeW5hbWljX2RlY29tcHJlc3NvcjFJTlNfOGRlY29kZXJzMTBhcml0aG1ldGljSU5TXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TXzdzdHJlYW1zMTNtZW1vcnlfc3RyZWFtRUVFRUVOUzBfMTlyZWNvcmRfZGVjb21wcmVzc29ySUpOUzBfNWZpZWxkSU5TMF8zbGFzN3BvaW50MTBFTlMwXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJU0RfRUVFRU5TQl9JTlNDXzdncHN0aW1lRU5TRV9JU0hfRUVFRU5TQl9JTlNDXzNyZ2JFTlNFX0lTS19FRUVFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyMWR5bmFtaWNfZGVjb21wcmVzc29yMUlOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSU5TMV8yaW8xOF9faWZzdHJlYW1fd3JhcHBlcklOUzFfN3N0cmVhbXMxM21lbW9yeV9zdHJlYW1FRUVFRU5TMl8xOXJlY29yZF9kZWNvbXByZXNzb3JJSk5TMl81ZmllbGRJTlMyXzNsYXM3cG9pbnQxMEVOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElTRl9FRUVFTlNEX0lOU0VfN2dwc3RpbWVFTlNHX0lTSl9FRUVFTlNEX0lOU0VfM3JnYkVOU0dfSVNNX0VFRUVFRUVFRU5TXzE0ZGVmYXVsdF9kZWxldGVJU1FfRUVOU185YWxsb2NhdG9ySVNRX0VFRUUATlN0M19fMjE0ZGVmYXVsdF9kZWxldGVJTjZsYXN6aXA3Zm9ybWF0czIxZHluYW1pY19kZWNvbXByZXNzb3IxSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJTlMxXzJpbzE4X19pZnN0cmVhbV93cmFwcGVySU5TMV83c3RyZWFtczEzbWVtb3J5X3N0cmVhbUVFRUVFTlMyXzE5cmVjb3JkX2RlY29tcHJlc3NvcklKTlMyXzVmaWVsZElOUzJfM2xhczdwb2ludDEwRU5TMl8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSVNGX0VFRUVOU0RfSU5TRV83Z3BzdGltZUVOU0dfSVNKX0VFRUVOU0RfSU5TRV8zcmdiRU5TR19JU01fRUVFRUVFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUDEwYnVmX3N0cmVhbU5TXzE0ZGVmYXVsdF9kZWxldGVJUzFfRUVOU185YWxsb2NhdG9ySVMxX0VFRUUATlN0M19fMjE0ZGVmYXVsdF9kZWxldGVJMTBidWZfc3RyZWFtRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTNV9FRU5TXzlhbGxvY2F0b3JJUzVfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZmllbGRfZGVjb21wcmVzc29ySU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRUVFAE5TdDNfXzIyMF9fc2hhcmVkX3B0cl9wb2ludGVySVBONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2ZpZWxkX2RlY29tcHJlc3NvcklOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFRUVOU18xNGRlZmF1bHRfZGVsZXRlSVM4X0VFTlNfOWFsbG9jYXRvcklTOF9FRUVFAE5TdDNfXzIxNGRlZmF1bHRfZGVsZXRlSU42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZmllbGRfZGVjb21wcmVzc29ySU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJMTBidWZfc3RyZWFtRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRU5TMF81ZmllbGRJaU5TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSWlFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJMTBidWZfc3RyZWFtRUVOUzJfNWZpZWxkSWlOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElpRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTQ19FRU5TXzlhbGxvY2F0b3JJU0NfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFTlMyXzVmaWVsZElpTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJaUVFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRU5TMF81ZmllbGRJak5TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSWpFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJMTBidWZfc3RyZWFtRUVOUzJfNWZpZWxkSWpOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElqRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTQ19FRU5TXzlhbGxvY2F0b3JJU0NfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFTlMyXzVmaWVsZElqTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJakVFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRU5TMF81ZmllbGRJYU5TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSWFFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJMTBidWZfc3RyZWFtRUVOUzJfNWZpZWxkSWFOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElhRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTQ19FRU5TXzlhbGxvY2F0b3JJU0NfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFTlMyXzVmaWVsZElhTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJYUVFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRU5TMF81ZmllbGRJc05TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSXNFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJMTBidWZfc3RyZWFtRUVOUzJfNWZpZWxkSXNOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZElzRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTQ19FRU5TXzlhbGxvY2F0b3JJU0NfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFTlMyXzVmaWVsZElzTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJc0VFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRU5TMF81ZmllbGRJaE5TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSWhFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJMTBidWZfc3RyZWFtRUVOUzJfNWZpZWxkSWhOUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZEloRUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTQ19FRU5TXzlhbGxvY2F0b3JJU0NfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFTlMyXzVmaWVsZEloTlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJaEVFRUVFRUVFAE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TXzhkZWNvZGVyczEwYXJpdGhtZXRpY0kxMGJ1Zl9zdHJlYW1FRU5TMF81ZmllbGRJdE5TMF8yMHN0YW5kYXJkX2RpZmZfbWV0aG9kSXRFRUVFRUUATlN0M19fMjIwX19zaGFyZWRfcHRyX3BvaW50ZXJJUE42bGFzemlwN2Zvcm1hdHMyNmR5bmFtaWNfZGVjb21wcmVzc29yX2ZpZWxkSU5TMV84ZGVjb2RlcnMxMGFyaXRobWV0aWNJMTBidWZfc3RyZWFtRUVOUzJfNWZpZWxkSXROUzJfMjBzdGFuZGFyZF9kaWZmX21ldGhvZEl0RUVFRUVFTlNfMTRkZWZhdWx0X2RlbGV0ZUlTQ19FRU5TXzlhbGxvY2F0b3JJU0NfRUVFRQBOU3QzX18yMTRkZWZhdWx0X2RlbGV0ZUlONmxhc3ppcDdmb3JtYXRzMjZkeW5hbWljX2RlY29tcHJlc3Nvcl9maWVsZElOUzFfOGRlY29kZXJzMTBhcml0aG1ldGljSTEwYnVmX3N0cmVhbUVFTlMyXzVmaWVsZEl0TlMyXzIwc3RhbmRhcmRfZGlmZl9tZXRob2RJdEVFRUVFRUVFADZMQVNaaXAAUDZMQVNaaXAAUEs2TEFTWmlwAGlpAHYAdmkAdmlpaWkAdmlpaQBpaWkAMTNEeW5hbWljTEFTWmlwAFAxM0R5bmFtaWNMQVNaaXAAUEsxM0R5bmFtaWNMQVNaaXAAdm9pZABib29sAGNoYXIAc2lnbmVkIGNoYXIAdW5zaWduZWQgY2hhcgBzaG9ydAB1bnNpZ25lZCBzaG9ydABpbnQAdW5zaWduZWQgaW50AGxvbmcAdW5zaWduZWQgbG9uZwBmbG9hdABkb3VibGUAc3RkOjpzdHJpbmcAc3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4Ac3RkOjp3c3RyaW5nAHN0ZDo6dTE2c3RyaW5nAHN0ZDo6dTMyc3RyaW5nAGVtc2NyaXB0ZW46OnZhbABlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxjaGFyPgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxzaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2hvcnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGludD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8bG9uZz4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgbG9uZz4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MTZfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dWludDMyX3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxkb3VibGU+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmcgZG91YmxlPgBOMTBlbXNjcmlwdGVuMTFtZW1vcnlfdmlld0llRUUATjEwZW1zY3JpcHRlbjExbWVtb3J5X3ZpZXdJZEVFAE4xMGVtc2NyaXB0ZW4xMW1lbW9yeV92aWV3SWZFRQBOMTBlbXNjcmlwdGVuMTFtZW1vcnlfdmlld0ltRUUATjEwZW1zY3JpcHRlbjExbWVtb3J5X3ZpZXdJbEVFAE4xMGVtc2NyaXB0ZW4xMW1lbW9yeV92aWV3SWpFRQBOMTBlbXNjcmlwdGVuMTFtZW1vcnlfdmlld0lpRUUATjEwZW1zY3JpcHRlbjExbWVtb3J5X3ZpZXdJdEVFAE4xMGVtc2NyaXB0ZW4xMW1lbW9yeV92aWV3SXNFRQBOMTBlbXNjcmlwdGVuMTFtZW1vcnlfdmlld0loRUUATjEwZW1zY3JpcHRlbjExbWVtb3J5X3ZpZXdJYUVFAE4xMGVtc2NyaXB0ZW4xMW1lbW9yeV92aWV3SWNFRQBOMTBlbXNjcmlwdGVuM3ZhbEUATlN0M19fMjEyYmFzaWNfc3RyaW5nSURpTlNfMTFjaGFyX3RyYWl0c0lEaUVFTlNfOWFsbG9jYXRvcklEaUVFRUUATlN0M19fMjIxX19iYXNpY19zdHJpbmdfY29tbW9uSUxiMUVFRQBOU3QzX18yMTJiYXNpY19zdHJpbmdJRHNOU18xMWNoYXJfdHJhaXRzSURzRUVOU185YWxsb2NhdG9ySURzRUVFRQBOU3QzX18yMTJiYXNpY19zdHJpbmdJd05TXzExY2hhcl90cmFpdHNJd0VFTlNfOWFsbG9jYXRvckl3RUVFRQBOU3QzX18yMTJiYXNpY19zdHJpbmdJaE5TXzExY2hhcl90cmFpdHNJaEVFTlNfOWFsbG9jYXRvckloRUVFRQBOU3QzX18yMTJiYXNpY19zdHJpbmdJY05TXzExY2hhcl90cmFpdHNJY0VFTlNfOWFsbG9jYXRvckljRUVFRQAtKyAgIDBYMHgAKG51bGwpAC0wWCswWCAwWC0weCsweCAweABpbmYASU5GAG5hbgBOQU4ALgB0ZXJtaW5hdGluZyB3aXRoICVzIGV4Y2VwdGlvbiBvZiB0eXBlICVzOiAlcwB0ZXJtaW5hdGluZyB3aXRoICVzIGV4Y2VwdGlvbiBvZiB0eXBlICVzAHRlcm1pbmF0aW5nIHdpdGggJXMgZm9yZWlnbiBleGNlcHRpb24AdGVybWluYXRpbmcAdW5jYXVnaHQAU3Q5ZXhjZXB0aW9uAE4xMF9fY3h4YWJpdjExNl9fc2hpbV90eXBlX2luZm9FAFN0OXR5cGVfaW5mbwBOMTBfX2N4eGFiaXYxMjBfX3NpX2NsYXNzX3R5cGVfaW5mb0UATjEwX19jeHhhYml2MTE3X19jbGFzc190eXBlX2luZm9FAHRlcm1pbmF0ZV9oYW5kbGVyIHVuZXhwZWN0ZWRseSByZXR1cm5lZABzdGQ6OmJhZF9hbGxvYwBTdDliYWRfYWxsb2MAU3QxMWxvZ2ljX2Vycm9yAFN0MTNydW50aW1lX2Vycm9yAFN0MTJsZW5ndGhfZXJyb3IAU3QxMm91dF9vZl9yYW5nZQBOMTBfX2N4eGFiaXYxMTdfX3BiYXNlX3R5cGVfaW5mb0UATjEwX19jeHhhYml2MTE5X19wb2ludGVyX3R5cGVfaW5mb0UATjEwX19jeHhhYml2MTIwX19mdW5jdGlvbl90eXBlX2luZm9FAE4xMF9fY3h4YWJpdjEyOV9fcG9pbnRlcl90b19tZW1iZXJfdHlwZV9pbmZvRQBQdXJlIHZpcnR1YWwgZnVuY3Rpb24gY2FsbGVkIQBOMTBfX2N4eGFiaXYxMjNfX2Z1bmRhbWVudGFsX3R5cGVfaW5mb0UAdgBEbgBiAGMAaABhAHMAdABpAGoAbABtAGYAZABOMTBfX2N4eGFiaXYxMjFfX3ZtaV9jbGFzc190eXBlX2luZm9FAF9fY3hhX2d1YXJkX2FjcXVpcmUgZGV0ZWN0ZWQgcmVjdXJzaXZlIGluaXRpYWxpemF0aW9uAHN0ZDo6YmFkX2Z1bmN0aW9uX2NhbGwATlN0M19fMjE3YmFkX2Z1bmN0aW9uX2NhbGxFAE5TdDNfXzIxNF9fc2hhcmVkX2NvdW50RQBOU3QzX18yMTlfX3NoYXJlZF93ZWFrX2NvdW50RQBtdXRleCBsb2NrIGZhaWxlZABiYXNpY19zdHJpbmcAdW5zcGVjaWZpZWQgZ2VuZXJpY19jYXRlZ29yeSBlcnJvcgBVbmtub3duIGVycm9yICVkAGdlbmVyaWMATlN0M19fMjI0X19nZW5lcmljX2Vycm9yX2NhdGVnb3J5RQBOU3QzX18yMTJfX2RvX21lc3NhZ2VFAE5TdDNfXzIxNGVycm9yX2NhdGVnb3J5RQB1bnNwZWNpZmllZCBzeXN0ZW1fY2F0ZWdvcnkgZXJyb3IAc3lzdGVtAE5TdDNfXzIyM19fc3lzdGVtX2Vycm9yX2NhdGVnb3J5RQBOU3QzX18yMTJzeXN0ZW1fZXJyb3JFADogAHZlY3Rvcg==`;var Me=22368;function Ne(e){return Pn(e)}var Pe={},z=[];function Fe(e){if(e){var t=Pe[e];t.refcount++}}function Ie(e){if(!e||Pe[e])return e;for(var t in Pe)for(var n=+t,r=Pe[n].adjusted,i=r.length,a=0;a<i;a++)if(r[a]===e)return n;return e}function Le(e){var t=Pe[e];return t&&!t.caught&&(t.caught=!0,jn.uncaught_exceptions--),t&&(t.rethrown=!1),z.push(e),Fe(Ie(e)),e}function Re(e,t,n){throw Pe[e]={ptr:e,adjusted:[e],type:t,destructor:n,refcount:0,caught:!1,rethrown:!1},`uncaught_exception`in jn?jn.uncaught_exceptions++:jn.uncaught_exceptions=1,e}function ze(){return jn.uncaught_exceptions}function Be(){}function Ve(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw TypeError(`Unknown type size: `+e)}}function He(){for(var e=Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);Ue=e}var Ue=void 0;function We(e){for(var t=``,n=e;te[n];)t+=Ue[te[n++]];return t}var Ge={},B={},Ke={},qe=48,Je=57;function Ye(e){if(e===void 0)return`_unknown`;e=e.replace(/[^a-zA-Z0-9_]/g,`$`);var t=e.charCodeAt(0);return t>=qe&&t<=Je?`_`+e:e}function V(e,t){return e=Ye(e),Function(`body`,`return function `+e+`() {
|
||
"use strict"; return body.apply(this, arguments);
|
||
};
|
||
`)(t)}function Xe(e,t){var n=V(t,function(e){this.name=t,this.message=e;var n=Error(e).stack;n!==void 0&&(this.stack=this.toString()+`
|
||
`+n.replace(/^Error(:[^\n]*)?\n/,``))});return n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return this.message===void 0?this.name:this.name+`: `+this.message},n}var Ze=void 0;function H(e){throw new Ze(e)}var Qe=void 0;function $e(e){throw new Qe(e)}function et(e,t,n){e.forEach(function(e){Ke[e]=t});function r(t){var r=n(t);r.length!==e.length&&$e(`Mismatched type converter count`);for(var i=0;i<e.length;++i)tt(e[i],r[i])}var i=Array(t.length),a=[],o=0;t.forEach(function(e,t){B.hasOwnProperty(e)?i[t]=B[e]:(a.push(e),Ge.hasOwnProperty(e)||(Ge[e]=[]),Ge[e].push(function(){i[t]=B[e],++o,o===a.length&&r(i)}))}),a.length===0&&r(i)}function tt(e,t,n){if(n||={},!(`argPackAdvance`in t))throw TypeError(`registerType registeredInstance requires argPackAdvance`);var r=t.name;if(e||H(`type "`+r+`" must have a positive integer typeid pointer`),B.hasOwnProperty(e)){if(n.ignoreDuplicateRegistrations)return;H(`Cannot register type '`+r+`' twice`)}if(B[e]=t,delete Ke[e],Ge.hasOwnProperty(e)){var i=Ge[e];delete Ge[e],i.forEach(function(e){e()})}}function nt(e,t,n,r,i){var a=Ve(n);t=We(t),tt(e,{name:t,fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:i},argPackAdvance:8,readValueFromPointer:function(e){var r;if(n===1)r=L;else if(n===2)r=ne;else if(n===4)r=re;else throw TypeError(`Unknown boolean type size: `+t);return this.fromWireType(r[e>>a])},destructorFunction:null})}function U(e){if(!(this instanceof vt)||!(e instanceof vt))return!1;for(var t=this.$$.ptrType.registeredClass,n=this.$$.ptr,r=e.$$.ptrType.registeredClass,i=e.$$.ptr;t.baseClass;)n=t.upcast(n),t=t.baseClass;for(;r.baseClass;)i=r.upcast(i),r=r.baseClass;return t===r&&n===i}function rt(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function it(e){function t(e){return e.$$.ptrType.registeredClass.name}H(t(e)+` instance already deleted`)}var at=!1;function ot(e){}function st(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function ct(e){--e.count.value,e.count.value===0&&st(e)}function lt(e){return typeof FinalizationGroup>`u`?(lt=function(e){return e},e):(at=new FinalizationGroup(function(e){for(var t=e.next();!t.done;t=e.next()){var n=t.value;n.ptr?ct(n):console.warn(`object already deleted: `+n.ptr)}}),lt=function(e){return at.register(e,e.$$,e.$$),e},ot=function(e){at.unregister(e.$$)},lt(e))}function ut(){if(this.$$.ptr||it(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=lt(Object.create(Object.getPrototypeOf(this),{$$:{value:rt(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function dt(){this.$$.ptr||it(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&H(`Object already scheduled for deletion`),ot(this),ct(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function ft(){return!this.$$.ptr}var pt=void 0,mt=[];function ht(){for(;mt.length;){var e=mt.pop();e.$$.deleteScheduled=!1,e.delete()}}function gt(){return this.$$.ptr||it(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&H(`Object already scheduled for deletion`),mt.push(this),mt.length===1&&pt&&pt(ht),this.$$.deleteScheduled=!0,this}function _t(){vt.prototype.isAliasOf=U,vt.prototype.clone=ut,vt.prototype.delete=dt,vt.prototype.isDeleted=ft,vt.prototype.deleteLater=gt}function vt(){}var yt={};function bt(e,t,n){if(e[t].overloadTable===void 0){var r=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||H(`Function '`+n+`' called with an invalid number of arguments (`+arguments.length+`) - expects one of (`+e[t].overloadTable+`)!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[r.argCount]=r}}function xt(t,n,r){e.hasOwnProperty(t)?((r===void 0||e[t].overloadTable!==void 0&&e[t].overloadTable[r]!==void 0)&&H(`Cannot register public name '`+t+`' twice`),bt(e,t,t),e.hasOwnProperty(r)&&H(`Cannot register multiple overloads of a function with the same number of arguments (`+r+`)!`),e[t].overloadTable[r]=n):(e[t]=n,r!==void 0&&(e[t].numArguments=r))}function St(e,t,n,r,i,a,o,s){this.name=e,this.constructor=t,this.instancePrototype=n,this.rawDestructor=r,this.baseClass=i,this.getActualType=a,this.upcast=o,this.downcast=s,this.pureVirtualFunctions=[]}function Ct(e,t,n){for(;t!==n;)t.upcast||H(`Expected null or instance of `+n.name+`, got an instance of `+t.name),e=t.upcast(e),t=t.baseClass;return e}function wt(e,t){if(t===null)return this.isReference&&H(`null is not a valid `+this.name),0;t.$$||H(`Cannot pass "`+un(t)+`" as a `+this.name),t.$$.ptr||H(`Cannot pass deleted object as a pointer of type `+this.name);var n=t.$$.ptrType.registeredClass;return Ct(t.$$.ptr,n,this.registeredClass)}function Tt(e,t){var n;if(t===null)return this.isReference&&H(`null is not a valid `+this.name),this.isSmartPointer?(n=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,n),n):0;t.$$||H(`Cannot pass "`+un(t)+`" as a `+this.name),t.$$.ptr||H(`Cannot pass deleted object as a pointer of type `+this.name),!this.isConst&&t.$$.ptrType.isConst&&H(`Cannot convert argument of type `+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+` to parameter type `+this.name);var r=t.$$.ptrType.registeredClass;if(n=Ct(t.$$.ptr,r,this.registeredClass),this.isSmartPointer)switch(t.$$.smartPtr===void 0&&H(`Passing raw pointer to smart pointer is illegal`),this.sharingPolicy){case 0:t.$$.smartPtrType===this?n=t.$$.smartPtr:H(`Cannot convert argument of type `+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+` to parameter type `+this.name);break;case 1:n=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)n=t.$$.smartPtr;else{var i=t.clone();n=this.rawShare(n,cn(function(){i.delete()})),e!==null&&e.push(this.rawDestructor,n)}break;default:H(`Unsupporting sharing policy`)}return n}function Et(e,t){if(t===null)return this.isReference&&H(`null is not a valid `+this.name),0;t.$$||H(`Cannot pass "`+un(t)+`" as a `+this.name),t.$$.ptr||H(`Cannot pass deleted object as a pointer of type `+this.name),t.$$.ptrType.isConst&&H(`Cannot convert argument of type `+t.$$.ptrType.name+` to parameter type `+this.name);var n=t.$$.ptrType.registeredClass;return Ct(t.$$.ptr,n,this.registeredClass)}function Dt(e){return this.fromWireType(ie[e>>2])}function Ot(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function kt(e){this.rawDestructor&&this.rawDestructor(e)}function At(e){e!==null&&e.delete()}function jt(e,t,n){if(t===n)return e;if(n.baseClass===void 0)return null;var r=jt(e,t,n.baseClass);return r===null?null:n.downcast(r)}function Mt(){return Object.keys(It).length}function Nt(){var e=[];for(var t in It)It.hasOwnProperty(t)&&e.push(It[t]);return e}function Pt(e){pt=e,mt.length&&pt&&pt(ht)}function Ft(){e.getInheritedInstanceCount=Mt,e.getLiveInheritedInstances=Nt,e.flushPendingDeletes=ht,e.setDelayFunction=Pt}var It={};function Lt(e,t){for(t===void 0&&H(`ptr should not be undefined`);e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}function Rt(e,t){return t=Lt(e,t),It[t]}function zt(e,t){return(!t.ptrType||!t.ptr)&&$e(`makeClassHandle requires ptr and ptrType`),!!t.smartPtrType!=!!t.smartPtr&&$e(`Both smartPtrType and smartPtr must be specified`),t.count={value:1},lt(Object.create(e,{$$:{value:t}}))}function Bt(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var n=Rt(this.registeredClass,t);if(n!==void 0){if(n.$$.count.value===0)return n.$$.ptr=t,n.$$.smartPtr=e,n.clone();var r=n.clone();return this.destructor(e),r}function i(){return this.isSmartPointer?zt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):zt(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=yt[this.registeredClass.getActualType(t)];if(!a)return i.call(this);var o=this.isConst?a.constPointerType:a.pointerType,s=jt(t,this.registeredClass,o.registeredClass);return s===null?i.call(this):this.isSmartPointer?zt(o.registeredClass.instancePrototype,{ptrType:o,ptr:s,smartPtrType:this,smartPtr:e}):zt(o.registeredClass.instancePrototype,{ptrType:o,ptr:s})}function Vt(){Ht.prototype.getPointee=Ot,Ht.prototype.destructor=kt,Ht.prototype.argPackAdvance=8,Ht.prototype.readValueFromPointer=Dt,Ht.prototype.deleteObject=At,Ht.prototype.fromWireType=Bt}function Ht(e,t,n,r,i,a,o,s,c,l,u){this.name=e,this.registeredClass=t,this.isReference=n,this.isConst=r,this.isSmartPointer=i,this.pointeeType=a,this.sharingPolicy=o,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=l,this.rawDestructor=u,!i&&t.baseClass===void 0?r?(this.toWireType=wt,this.destructorFunction=null):(this.toWireType=Et,this.destructorFunction=null):this.toWireType=Tt}function Ut(t,n,r){e.hasOwnProperty(t)||$e(`Replacing nonexistant public symbol`),e[t].overloadTable!==void 0&&r!==void 0?e[t].overloadTable[r]=n:(e[t]=n,e[t].argCount=r)}function Wt(t,n){t=We(t);function r(e){for(var r=[],i=1;i<t.length;++i)r.push(`a`+i);var a=`return function `+(`dynCall_`+t+`_`+n)+`(`+r.join(`, `)+`) {
|
||
`;return a+=` return dynCall(rawFunction`+(r.length?`, `:``)+r.join(`, `)+`);
|
||
`,a+=`};
|
||
`,Function(`dynCall`,`rawFunction`,a)(e,n)}var i=e[`dynCall_`+t],a=r(i);return typeof a!=`function`&&H(`unknown function pointer with signature `+t+`: `+n),a}var Gt=void 0;function Kt(e){var t=Mn(e),n=We(t);return Nn(t),n}function qt(e,t){var n=[],r={};function i(e){if(!r[e]&&!B[e]){if(Ke[e]){Ke[e].forEach(i);return}n.push(e),r[e]=!0}}throw t.forEach(i),new Gt(e+`: `+n.map(Kt).join([`, `]))}function Jt(e,t,n,r,i,a,o,s,c,l,u,d,f){u=We(u),a=Wt(i,a),s&&=Wt(o,s),l&&=Wt(c,l),f=Wt(d,f);var p=Ye(u);xt(p,function(){qt(`Cannot construct `+u+` due to unbound types`,[r])}),et([e,t,n],r?[r]:[],function(t){t=t[0];var n,i;r?(n=t.registeredClass,i=n.instancePrototype):i=vt.prototype;var o=V(p,function(){if(Object.getPrototypeOf(this)!==c)throw new Ze(`Use 'new' to construct `+u);if(d.constructor_body===void 0)throw new Ze(u+` has no accessible constructor`);var e=d.constructor_body[arguments.length];if(e===void 0)throw new Ze(`Tried to invoke ctor of `+u+` with invalid number of parameters (`+arguments.length+`) - expected (`+Object.keys(d.constructor_body).toString()+`) parameters instead!`);return e.apply(this,arguments)}),c=Object.create(i,{constructor:{value:o}});o.prototype=c;var d=new St(u,o,c,f,n,a,s,l),m=new Ht(u,d,!0,!1,!1),h=new Ht(u+`*`,d,!1,!1,!1),g=new Ht(u+` const*`,d,!1,!0,!1);return yt[e]={pointerType:h,constPointerType:g},Ut(p,o),[m,h,g]})}function Yt(e,t){for(var n=[],r=0;r<e;r++)n.push(re[(t>>2)+r]);return n}function Xt(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Zt(e,t,n,r,i,a){C(t>0);var o=Yt(t,n);i=Wt(r,i);var s=[a],c=[];et([],[e],function(e){e=e[0];var n=`constructor `+e.name;if(e.registeredClass.constructor_body===void 0&&(e.registeredClass.constructor_body=[]),e.registeredClass.constructor_body[t-1]!==void 0)throw new Ze(`Cannot register multiple constructors with identical number of parameters (`+(t-1)+`) for class '`+e.name+`'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=function(){qt(`Cannot construct `+e.name+` due to unbound types`,o)},et([],o,function(r){return e.registeredClass.constructor_body[t-1]=function(){arguments.length!==t-1&&H(n+` called with `+arguments.length+` arguments, expected `+(t-1)),c.length=0,s.length=t;for(var e=1;e<t;++e)s[e]=r[e].toWireType(c,arguments[e-1]);var a=i.apply(null,s);return Xt(c),r[0].fromWireType(a)},[]}),[]})}function Qt(e,t){if(!(e instanceof Function))throw TypeError(`new_ called with constructor type `+typeof e+` which is not a function`);var n=V(e.name||`unknownFunctionName`,function(){});n.prototype=e.prototype;var r=new n,i=e.apply(r,t);return i instanceof Object?i:r}function $t(e,t,n,r,i){var a=t.length;a<2&&H(`argTypes array size mismatch! Must at least get return value and 'this' types!`);for(var o=t[1]!==null&&n!==null,s=!1,c=1;c<t.length;++c)if(t[c]!==null&&t[c].destructorFunction===void 0){s=!0;break}for(var l=t[0].name!==`void`,u=``,d=``,c=0;c<a-2;++c)u+=(c===0?``:`, `)+`arg`+c,d+=(c===0?``:`, `)+`arg`+c+`Wired`;var f=`return function `+Ye(e)+`(`+u+`) {
|
||
if (arguments.length !== `+(a-2)+`) {
|
||
throwBindingError('function `+e+` called with ' + arguments.length + ' arguments, expected `+(a-2)+` args!');
|
||
}
|
||
`;s&&(f+=`var destructors = [];
|
||
`);var p=s?`destructors`:`null`,m=[`throwBindingError`,`invoker`,`fn`,`runDestructors`,`retType`,`classParam`],h=[H,r,i,Xt,t[0],t[1]];o&&(f+=`var thisWired = classParam.toWireType(`+p+`, this);
|
||
`);for(var c=0;c<a-2;++c)f+=`var arg`+c+`Wired = argType`+c+`.toWireType(`+p+`, arg`+c+`); // `+t[c+2].name+`
|
||
`,m.push(`argType`+c),h.push(t[c+2]);if(o&&(d=`thisWired`+(d.length>0?`, `:``)+d),f+=(l?`var rv = `:``)+`invoker(fn`+(d.length>0?`, `:``)+d+`);
|
||
`,s)f+=`runDestructors(destructors);
|
||
`;else for(var c=o?1:2;c<t.length;++c){var g=c===1?`thisWired`:`arg`+(c-2)+`Wired`;t[c].destructorFunction!==null&&(f+=g+`_dtor(`+g+`); // `+t[c].name+`
|
||
`,m.push(g+`_dtor`),h.push(t[c].destructorFunction))}return l&&(f+=`var ret = retType.fromWireType(rv);
|
||
return ret;
|
||
`),f+=`}
|
||
`,m.push(f),Qt(Function,m).apply(null,h)}function en(e,t,n,r,i,a,o,s){var c=Yt(n,r);t=We(t),a=Wt(i,a),et([],[e],function(e){e=e[0];var r=e.name+`.`+t;s&&e.registeredClass.pureVirtualFunctions.push(t);function i(){qt(`Cannot call `+r+` due to unbound types`,c)}var l=e.registeredClass.instancePrototype,u=l[t];return u===void 0||u.overloadTable===void 0&&u.className!==e.name&&u.argCount===n-2?(i.argCount=n-2,i.className=e.name,l[t]=i):(bt(l,t,r),l[t].overloadTable[n-2]=i),et([],c,function(i){var s=$t(r,i,e,a,o);return l[t].overloadTable===void 0?(s.argCount=n-2,l[t]=s):l[t].overloadTable[n-2]=s,[]}),[]})}var tn=[],nn=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function rn(e){e>4&&--nn[e].refcount===0&&(nn[e]=void 0,tn.push(e))}function an(){for(var e=0,t=5;t<nn.length;++t)nn[t]!==void 0&&++e;return e}function on(){for(var e=5;e<nn.length;++e)if(nn[e]!==void 0)return nn[e];return null}function sn(){e.count_emval_handles=an,e.get_first_emval=on}function cn(e){switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=tn.length?tn.pop():nn.length;return nn[t]={refcount:1,value:e},t}}function ln(e,t){t=We(t),tt(e,{name:t,fromWireType:function(e){var t=nn[e].value;return rn(e),t},toWireType:function(e,t){return cn(t)},argPackAdvance:8,readValueFromPointer:Dt,destructorFunction:null})}function un(e){if(e===null)return`null`;var t=typeof e;return t===`object`||t===`array`||t===`function`?e.toString():``+e}function dn(e,t){switch(t){case 2:return function(e){return this.fromWireType(ae[e>>2])};case 3:return function(e){return this.fromWireType(oe[e>>3])};default:throw TypeError(`Unknown float type: `+e)}}function fn(e,t,n){var r=Ve(n);t=We(t),tt(e,{name:t,fromWireType:function(e){return e},toWireType:function(e,t){if(typeof t!=`number`&&typeof t!=`boolean`)throw TypeError(`Cannot convert "`+un(t)+`" to `+this.name);return t},argPackAdvance:8,readValueFromPointer:dn(t,r),destructorFunction:null})}function pn(e,t,n){switch(t){case 0:return n?function(e){return L[e]}:function(e){return te[e]};case 1:return n?function(e){return ne[e>>1]}:function(e){return R[e>>1]};case 2:return n?function(e){return re[e>>2]}:function(e){return ie[e>>2]};default:throw TypeError(`Unknown integer type: `+e)}}function mn(e,t,n,r,i){t=We(t),i===-1&&(i=4294967295);var a=Ve(n),o=function(e){return e};if(r===0){var s=32-8*n;o=function(e){return e<<s>>>s}}var c=t.indexOf(`unsigned`)!=-1;tt(e,{name:t,fromWireType:o,toWireType:function(e,n){if(typeof n!=`number`&&typeof n!=`boolean`)throw TypeError(`Cannot convert "`+un(n)+`" to `+this.name);if(n<r||n>i)throw TypeError(`Passing a number "`+un(n)+`" from JS side to C/C++ side to an argument of type "`+t+`", which is outside the valid range [`+r+`, `+i+`]!`);return c?n>>>0:n|0},argPackAdvance:8,readValueFromPointer:pn(t,a,r!==0),destructorFunction:null})}function hn(e,t,n){var r=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function i(e){e>>=2;var t=ie,n=t[e],i=t[e+1];return new r(I,i,n)}n=We(n),tt(e,{name:n,fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{ignoreDuplicateRegistrations:!0})}function gn(e,t){t=We(t);var n=t===`std::string`;tt(e,{name:t,fromWireType:function(e){var t=ie[e>>2],r;if(n)for(var i=e+4,a=0;a<=t;++a){var o=e+4+a;if(te[o]==0||a==t){var s=o-i,c=E(i,s);r===void 0?r=c:(r+=`\0`,r+=c),i=o+1}}else{for(var l=Array(t),a=0;a<t;++a)l[a]=String.fromCharCode(te[e+4+a]);r=l.join(``)}return Nn(e),r},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r,i=typeof t==`string`;i||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||H(`Cannot pass non-string to std::string`),r=n&&i?function(){return k(t)}:function(){return t.length};var a=r(),o=Pn(4+a+1);if(ie[o>>2]=a,n&&i)O(t,o+4,a+1);else if(i)for(var s=0;s<a;++s){var c=t.charCodeAt(s);c>255&&(Nn(o),H(`String has UTF-16 code units that do not fit in 8 bits`)),te[o+4+s]=c}else for(var s=0;s<a;++s)te[o+4+s]=t[s];return e!==null&&e.push(Nn,o),o},argPackAdvance:8,readValueFromPointer:Dt,destructorFunction:function(e){Nn(e)}})}function _n(e,t,n){n=We(n);var r,i,a,o,s;t===2?(r=j,i=M,o=N,a=function(){return R},s=1):t===4&&(r=P,i=F,o=ee,a=function(){return ie},s=2),tt(e,{name:n,fromWireType:function(e){for(var n=ie[e>>2],i=a(),o,c=e+4,l=0;l<=n;++l){var u=e+4+l*t;if(i[u>>s]==0||l==n){var d=u-c,f=r(c,d);o===void 0?o=f:(o+=`\0`,o+=f),c=u+t}}return Nn(e),o},toWireType:function(e,r){typeof r!=`string`&&H(`Cannot pass non-string to C++ string type `+n);var a=o(r),c=Pn(4+a+t);return ie[c>>2]=a>>s,i(r,c+4,a+t),e!==null&&e.push(Nn,c),c},argPackAdvance:8,readValueFromPointer:Dt,destructorFunction:function(e){Nn(e)}})}function vn(e,t){t=We(t),tt(e,{isVoid:!0,name:t,argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})}function yn(){De()}function bn(){return te.length}function xn(e){De(`OOM`)}function Sn(e){e>>>=0,xn(e)}function Cn(){De(`trap!`)}function wn(e,t,n){te.copyWithin(e,t,t+n)}He(),Ze=e.BindingError=Xe(Error,`BindingError`),Qe=e.InternalError=Xe(Error,`InternalError`),_t(),Vt(),Ft(),Gt=e.UnboundTypeError=Xe(Error,`UnboundTypeError`),sn();var Tn=!1;function En(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];r>255&&(Tn&&C(!1,`Character code `+r+` (`+String.fromCharCode(r)+`) at offset `+n+` not in 0x00-0xFF.`),r&=255),t.push(String.fromCharCode(r))}return t.join(``)}var Dn=typeof atob==`function`?atob:function(e){var t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,n=``,r,i,a,o,s,c,l,u=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``);do o=t.indexOf(e.charAt(u++)),s=t.indexOf(e.charAt(u++)),c=t.indexOf(e.charAt(u++)),l=t.indexOf(e.charAt(u++)),r=o<<2|s>>4,i=(s&15)<<4|c>>2,a=(c&3)<<6|l,n+=String.fromCharCode(r),c!==64&&(n+=String.fromCharCode(i)),l!==64&&(n+=String.fromCharCode(a));while(u<e.length);return n};function On(e){if(typeof o==`boolean`&&o){var t;try{t=Buffer.from(e,`base64`)}catch{t=new Buffer(e,`base64`)}return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}try{for(var n=Dn(e),r=new Uint8Array(n.length),i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}catch{throw Error(`Converting base64 string to bytes failed.`)}}function kn(e){if(je(e))return On(e.slice(Ae.length))}var An=(function(e,t,n){"use asm";var r=new e.Int8Array(n),i=new e.Int16Array(n),a=new e.Int32Array(n),o=new e.Uint8Array(n),s=new e.Uint16Array(n);new e.Float32Array(n);var c=new e.Float64Array(n),l=t.D|0,u=e.Math.imul,d=e.Math.clz32,f=t.a,p=t.b,m=t.c,h=t.d;t.e;var g=t.f,_=t.g;t.h,t.i,t.j;var v=t.k,y=t.l,b=t.m,x=t.n,S=t.o,C=t.p,w=t.q,T=t.r,E=t.s,D=t.t,O=t.u;t.v,t.w;var k=t.x;t.y;var A=t.z,j=t.A,M=t.B,N=t.C,P=22384;function F(){Rd(),zd()}function ee(){I(0)}function I(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;e=P,P=P+16|0,t=e+8|0,n=e,f=iu()|0,o=au()|0,i=su()|0,s=cu()|0,c=lu()|0,l=uu()|0,u=gu()|0,d=_u()|0,r=_u()|0,y(i|0,s|0,c|0,l|0,u|0,9,d|0,f|0,r|0,o|0,6204,vu()|0,138),bu(1),a[n>>2]=5,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],Du(6211,t),a[n>>2]=3,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],Lu(6216,t),a[n>>2]=10,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],Gu(6225,t),o=ed()|0,r=td()|0,f=rd()|0,d=id()|0,u=ad()|0,l=uu()|0,c=gu()|0,s=_u()|0,i=_u()|0,y(f|0,d|0,u|0,l|0,c|0,11,s|0,o|0,i|0,r|0,6234,vu()|0,139),fd(2),a[n>>2]=6,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],yd(6211,t),a[n>>2]=4,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],Ed(6248,t),a[n>>2]=5,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],Ed(6265,t),a[n>>2]=6,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],Ed(6280,t),a[n>>2]=7,a[n+4>>2]=0,a[t>>2]=a[n>>2],a[t+4>>2]=a[n+4>>2],Md(6216,t),P=e}function L(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0,c=0;r=P,P=P+32|0,s=r+16|0,i=r+8|0,c=r,o=J(20)|0,se(o,t,n),a[c>>2]=0,a[s>>2]=a[c>>2],le(i,o,s),t=a[i>>2]|0,a[i>>2]=a[e>>2],a[e>>2]=t,t=i+4|0,n=e+4|0,o=a[t>>2]|0,a[t>>2]=a[n>>2],a[n>>2]=o,ue(i),n=J(352)|0,ce(n,a[e>>2]|0),o=e+8|0,a[c>>2]=0,a[s>>2]=a[c>>2],ve(i,n,s),n=a[i>>2]|0,a[i>>2]=a[o>>2],a[o>>2]=n,o=i+4|0,n=e+12|0,t=a[o>>2]|0,a[o>>2]=a[n>>2],a[n>>2]=t,ye(i),P=r}function te(e,t){e|=0,t|=0,Bn(a[e+8>>2]|0,t)}function ne(e){return e|=0,e=(ws(a[e+8>>2]|0)|0)+107|0,o[e>>0]|o[e+1>>0]<<8|o[e+2>>0]<<16|o[e+3>>0]<<24|0}function R(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0,c=0;r=P,P=P+32|0,o=r+16|0,i=r+8|0,s=r,c=J(12)|0,Ts(c,t,n),a[s>>2]=0,a[o>>2]=a[s>>2],ks(i,c,o),c=a[i>>2]|0,a[i>>2]=a[e>>2],a[e>>2]=c,c=i+4|0,n=e+4|0,t=a[c>>2]|0,a[c>>2]=a[n>>2],a[n>>2]=t,As(i),n=e+8|0,t=J(12)|0,Es(t,a[e>>2]|0),a[s>>2]=0,a[o>>2]=a[s>>2],Is(i,t,o),t=a[i>>2]|0,a[i>>2]=a[n>>2],a[n>>2]=t,t=i+4|0,s=e+12|0,c=a[t>>2]|0,a[t>>2]=a[s>>2],a[s>>2]=c,Ls(i),Ds(i,a[n>>2]|0),n=e+16|0,s=a[i>>2]|0,c=i+4|0,t=a[c>>2]|0,a[i>>2]=0,a[c>>2]=0,a[o>>2]=a[n>>2],a[n>>2]=s,n=e+20|0,a[o+4>>2]=a[n>>2],a[n>>2]=t,Os(o),Os(i),P=r}function re(e,t){e|=0,t|=0;var n=0;e=e+16|0,n=a[e>>2]|0;a:do if(n|0)switch(t|0){case 4:nc(n);break a;case 8:rc(n),rc(a[e>>2]|0);break a;default:break a}while(0)}function ie(e,t){e|=0,t|=0;var n=0;n=e+16|0,e=a[n>>2]|0;a:do if(e|0){switch(t|0){case 1:Uc(e);break a;case 2:Wc(e);break a;case 8:nc(e),e=a[n>>2]|0;break;case 4:break;default:break a}nc(e)}while(0)}function ae(e,t){e|=0,t|=0;var n=0;n=e+16|0,e=a[n>>2]|0;a:do if(e|0){switch(t|0){case 1:Tl(e);break a;case 2:El(e);break a;case 8:rc(e),e=a[n>>2]|0;break;case 4:break;default:break a}rc(e)}while(0)}function oe(e,t){e|=0,t|=0,e=a[e+16>>2]|0,e|0&&b_[a[a[e>>2]>>2]&63](e,t)|0}function se(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,a[e+4>>2]=n,a[e+8>>2]=0,r[e+12>>0]=0,r[e+13>>0]=0,a[e+16>>2]=0}function ce(e,t){e|=0,t|=0,a[e>>2]=t,Pe(e+4|0,t),z(e+247|0),a[e+288>>2]=0,a[e+292>>2]=0,a[e+296>>2]=0,Fe(e+300|0),t=e+312|0,a[t>>2]=0,a[t+4>>2]=0,a[t+8>>2]=0,a[t+12>>2]=0,Ie(e+328|0),Le(e)}function le(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4296,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,de(e,r),P=n}function ue(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function de(e,t){e|=0,t|=0}function fe(e){e|=0,Bh(e),G(e)}function pe(e){e|=0,e=a[e+12>>2]|0,e|0&&G(e)}function me(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==6407?e+12|0:0)|0}function he(e){e|=0,ge(e,16)}function ge(e,t){e|=0,t|=0,_e(e)}function _e(e){e|=0,G(e)}function ve(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4324,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,be(e,r),P=n}function ye(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function be(e,t){e|=0,t|=0}function xe(e){e|=0,Bh(e),G(e)}function Se(e){e|=0,e=a[e+12>>2]|0,e|0&&(Te(e),G(e))}function Ce(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==6605?e+12|0:0)|0}function we(e){e|=0,ge(e,16)}function Te(e){e|=0,Ee(e+320|0),De(e+312|0),Oe(e+300|0),Me(e+288|0),ke(e+247|0),Ae(e+4|0)}function Ee(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function De(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function Oe(e){e|=0,je(e)}function ke(e){e|=0,e=e+34|0,e=o[e>>0]|o[e+1>>0]<<8|o[e+2>>0]<<16|o[e+3>>0]<<24,e|0&&jh(e)}function Ae(e){e|=0,Ne(a[e+12>>2]|0)}function je(e){e|=0;var t=0,n=0;t=a[e>>2]|0,n=t,t|0&&(a[e+4>>2]=n,ge(t,(a[e+8>>2]|0)-n|0))}function Me(e){e|=0;var t=0,n=0;t=a[e>>2]|0,n=t,t|0&&(a[e+4>>2]=n,ge(t,(a[e+8>>2]|0)-n|0))}function Ne(e){e|=0,kg(a[e+-4>>2]|0)}function Pe(e,t){e|=0,t|=0,a[e>>2]=t,a[e+4>>2]=0,a[e+8>>2]=0,a[e+12>>2]=Re(1048576)|0}function z(e){e|=0;var t=0;t=e+32|0,r[t>>0]=0,r[t+1>>0]=0,e=e+34|0,r[e>>0]=0,r[e+1>>0]=0,r[e+2>>0]=0,r[e+3>>0]=0}function Fe(e){e|=0,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0}function Ie(e){e|=0,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,a[e+12>>2]=0,e=e+16|0,a[e>>2]=-1,a[e+4>>2]=-1}function Le(e){e|=0;var t=0,n=0,i=0,o=0,s=0,c=0;if(c=P,P=P+64|0,o=c+32|0,n=c+56|0,t=c+16|0,s=c,ze(a[e>>2]|0,n,4),Xe(o,n,n+4|0),n=V(6693)|0,i=r[o+11>>0]|0,(n|0)==((i<<24>>24<0?a[o+4>>2]|0:i&255)|0)){if(i=(ig(o,0,-1,6693,n)|0)==0,$h(o),i){if(n=a[e>>2]|0,a[t>>2]=0,a[t+4>>2]=0,a[t+8>>2]=0,a[t+12>>2]=0,a[o>>2]=a[t>>2],a[o+4>>2]=a[t+4>>2],a[o+8>>2]=a[t+8>>2],a[o+12>>2]=a[t+12>>2],Ve(n,o),n=e+20|0,ze(a[e>>2]|0,n,227),He(e,n),i=Ue()|0,t=a[i>>2]|0,i=a[i+4>>2]|0,(t|0)!=(i|0))do We(o,t),Ge(o,n),B(o),t=t+24|0;while((t|0)!=(i|0));Ke(e),qe(e),Je(a[e>>2]|0),i=a[e>>2]|0,t=(a[e+116>>2]|0)+8|0,n=s,a[n>>2]=0,a[n+4>>2]=0,n=s+8|0,a[n>>2]=t,a[n+4>>2]=0,a[o>>2]=a[s>>2],a[o+4>>2]=a[s+4>>2],a[o+8>>2]=a[s+8>>2],a[o+12>>2]=a[s+12>>2],Ve(i,o),Ye(e+4|0),P=c;return}}else $h(o);c=h(8)|0,Be(c),g(c|0,2592,8)}function Re(e){e|=0;var t=0;return t=Og(e+68|0)|0,e=t+68&-64,a[e+-4>>2]=t,e|0}function ze(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0,l=0,u=0;c=e+13|0,r[c>>0]|0?r[e+12>>0]=1:(s=e+4|0,i=a[s>>2]|0,l=e+8|0,o=a[l>>2]|0,u=i-o|0,n=(u|0)<(n|0)?u:n,n&&(Kg(t|0,(a[e>>2]|0)+o|0,n|0)|0,o=a[l>>2]|0,i=a[s>>2]|0),u=o+n|0,a[l>>2]=u,a[e+16>>2]=n,(u|0)>=(i|0)&&(r[c>>0]=1))}function Be(e){e|=0,Jh(e,6791),a[e>>2]=4352}function Ve(e,t){e|=0,t|=0;var n=0,i=0,o=0;o=t+8|0,t=a[o>>2]|0,o=a[o+4>>2]|0,n=a[e+4>>2]|0,i=((n|0)<0)<<31>>31,(o|0)<(i|0)|(o|0)==(i|0)&t>>>0<n>>>0?a[e+8>>2]=t:r[e+12>>0]=1}function He(e,t){e|=0,t|=0;var n=0,i=0,a=0,o=0,s=0,u=0,d=0,f=0,p=0,m=0;p=t+179|0,r[l>>0]=r[p>>0],r[l+1>>0]=r[p+1>>0],r[l+2>>0]=r[p+2>>0],r[l+3>>0]=r[p+3>>0],r[l+4>>0]=r[p+4>>0],r[l+5>>0]=r[p+5>>0],r[l+6>>0]=r[p+6>>0],r[l+7>>0]=r[p+7>>0],f=+c[l>>3],s=t+187|0,r[l>>0]=r[s>>0],r[l+1>>0]=r[s+1>>0],r[l+2>>0]=r[s+2>>0],r[l+3>>0]=r[s+3>>0],r[l+4>>0]=r[s+4>>0],r[l+5>>0]=r[s+5>>0],r[l+6>>0]=r[s+6>>0],r[l+7>>0]=r[s+7>>0],m=+c[l>>3],e=t+195|0,r[l>>0]=r[e>>0],r[l+1>>0]=r[e+1>>0],r[l+2>>0]=r[e+2>>0],r[l+3>>0]=r[e+3>>0],r[l+4>>0]=r[e+4>>0],r[l+5>>0]=r[e+5>>0],r[l+6>>0]=r[e+6>>0],r[l+7>>0]=r[e+7>>0],o=+c[l>>3],d=t+203|0,r[l>>0]=r[d>>0],r[l+1>>0]=r[d+1>>0],r[l+2>>0]=r[d+2>>0],r[l+3>>0]=r[d+3>>0],r[l+4>>0]=r[d+4>>0],r[l+5>>0]=r[d+5>>0],r[l+6>>0]=r[d+6>>0],r[l+7>>0]=r[d+7>>0],u=+c[l>>3],a=t+211|0,r[l>>0]=r[a>>0],r[l+1>>0]=r[a+1>>0],r[l+2>>0]=r[a+2>>0],r[l+3>>0]=r[a+3>>0],r[l+4>>0]=r[a+4>>0],r[l+5>>0]=r[a+5>>0],r[l+6>>0]=r[a+6>>0],r[l+7>>0]=r[a+7>>0],n=+c[l>>3],t=t+219|0,r[l>>0]=r[t>>0],r[l+1>>0]=r[t+1>>0],r[l+2>>0]=r[t+2>>0],r[l+3>>0]=r[t+3>>0],r[l+4>>0]=r[t+4>>0],r[l+5>>0]=r[t+5>>0],r[l+6>>0]=r[t+6>>0],r[l+7>>0]=r[t+7>>0],i=+c[l>>3],c[l>>3]=m,r[p>>0]=r[l>>0],r[p+1>>0]=r[l+1>>0],r[p+2>>0]=r[l+2>>0],r[p+3>>0]=r[l+3>>0],r[p+4>>0]=r[l+4>>0],r[p+5>>0]=r[l+5>>0],r[p+6>>0]=r[l+6>>0],r[p+7>>0]=r[l+7>>0],c[l>>3]=f,r[d>>0]=r[l>>0],r[d+1>>0]=r[l+1>>0],r[d+2>>0]=r[l+2>>0],r[d+3>>0]=r[l+3>>0],r[d+4>>0]=r[l+4>>0],r[d+5>>0]=r[l+5>>0],r[d+6>>0]=r[l+6>>0],r[d+7>>0]=r[l+7>>0],c[l>>3]=u,r[s>>0]=r[l>>0],r[s+1>>0]=r[l+1>>0],r[s+2>>0]=r[l+2>>0],r[s+3>>0]=r[l+3>>0],r[s+4>>0]=r[l+4>>0],r[s+5>>0]=r[l+5>>0],r[s+6>>0]=r[l+6>>0],r[s+7>>0]=r[l+7>>0],c[l>>3]=o,r[a>>0]=r[l>>0],r[a+1>>0]=r[l+1>>0],r[a+2>>0]=r[l+2>>0],r[a+3>>0]=r[l+3>>0],r[a+4>>0]=r[l+4>>0],r[a+5>>0]=r[l+5>>0],r[a+6>>0]=r[l+6>>0],r[a+7>>0]=r[l+7>>0],c[l>>3]=i,r[e>>0]=r[l>>0],r[e+1>>0]=r[l+1>>0],r[e+2>>0]=r[l+2>>0],r[e+3>>0]=r[l+3>>0],r[e+4>>0]=r[l+4>>0],r[e+5>>0]=r[l+5>>0],r[e+6>>0]=r[l+6>>0],r[e+7>>0]=r[l+7>>0],c[l>>3]=n,r[t>>0]=r[l>>0],r[t+1>>0]=r[l+1>>0],r[t+2>>0]=r[l+2>>0],r[t+3>>0]=r[l+3>>0],r[t+4>>0]=r[l+4>>0],r[t+5>>0]=r[l+5>>0],r[t+6>>0]=r[l+6>>0],r[t+7>>0]=r[l+7>>0]}function Ue(){var e=0,t=0,n=0,i=0,o=0,s=0,c=0,l=0;if(o=P,P=P+48|0,n=o+24|0,i=o,e=o+44|0,!(r[21440]|0)&&yh(21440)|0&&(a[5374]=0,a[5375]=0,a[5376]=0,q(21440)),!(r[21448]|0)&&yh(21448)|0&&q(21448),(a[5374]|0)==(a[5375]|0)){if(Hh(21508),(a[5374]|0)==(a[5375]|0)){r[n>>0]=r[e>>0]|0,Qe(i,n),e=a[5375]|0;do if(e>>>0>=(a[5376]|0)>>>0)if(e=((e-(a[5374]|0)|0)/24|0)+1|0,t=at(21496)|0,t>>>0<e>>>0)Dg(21496);else{s=a[5374]|0,l=((a[5376]|0)-s|0)/24|0,c=l<<1,U(n,l>>>0<t>>>1>>>0?c>>>0<e>>>0?e:c:t,((a[5375]|0)-s|0)/24|0,21504),t=n+8|0,tt(a[t>>2]|0,i),a[t>>2]=(a[t>>2]|0)+24,rt(21496,n),it(n);break}else $e(n,21496,1),l=n+4|0,tt(a[l>>2]|0,i),a[l>>2]=(a[l>>2]|0)+24,et(n);while(0);B(i)}Uh(21508)}return P=o,21496}function We(e,t){e|=0,t|=0;var n=0,r=0;n=t+16|0,r=a[n>>2]|0;do if(r)if((t|0)==(r|0)){r=nt(e)|0,a[e+16>>2]=r,n=a[n>>2]|0,w_[a[(a[n>>2]|0)+12>>2]&15](n,r);break}else{a[e+16>>2]=v_[a[(a[r>>2]|0)+8>>2]&15](r)|0;break}else a[e+16>>2]=0;while(0)}function Ge(e,t){if(e|=0,t|=0,e=a[e+16>>2]|0,!e)t=h(4)|0,a[t>>2]=0,xt(t),g(t|0,4168,131);else{w_[a[(a[e>>2]|0)+24>>2]&15](e,t);return}}function B(e){e|=0;var t=0;t=a[e+16>>2]|0,(e|0)==(t|0)?C_[a[(a[t>>2]|0)+16>>2]&255](t):t|0&&C_[a[(a[t>>2]|0)+20>>2]&255](t)}function Ke(e){e|=0;var t=0,n=0,i=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,_=0,v=0;v=P,P=P+96|0,c=v+16|0,m=v,d=v+72|0,l=a[e>>2]|0,f=s[e+114>>1]|0,p=m,a[p>>2]=0,a[p+4>>2]=0,p=m+8|0,a[p>>2]=f,a[p+4>>2]=0,a[c>>2]=a[m>>2],a[c+4>>2]=a[m+4>>2],a[c+8>>2]=a[m+8>>2],a[c+12>>2]=a[m+12>>2],Ve(l,c),l=e+120|0;a:do if(a[l>>2]|0){for(u=c+2|0,f=c+16|0,p=c+20|0,m=c+18|0,n=0;;){if(!(St(a[e>>2]|0)|0)||Ct(a[e>>2]|0)|0)break a;for(ze(a[e>>2]|0,c,54),t=7277,i=u;(r[i>>0]|0)==(r[t>>0]|0);)if(i=i+1|0,(i|0)==(f|0)){_=8;break}else t=t+1|0;if((_|0)==8&&(_=0,(o[m>>0]|o[m+1>>0]<<8)<<16>>16==22204))break;if(Tt(a[e>>2]|0,(o[p>>0]|o[p+1>>0]<<8)&65535,0,1),n=n+1|0,n>>>0>=(a[l>>2]|0)>>>0)break a}m=(o[p>>0]|o[p+1>>0]<<8)&65535,_=Ah(m)|0,ze(a[e>>2]|0,_,m),wt(e,_),G(_),_=e+125|0,Dt(d,e+247|0,(o[_>>0]|o[_+1>>0]<<8)&65535),Ot(e+300|0,d)|0,Oe(d),P=v;return}while(0);v=h(8)|0,Et(v),g(v|0,2672,8)}function qe(e){e|=0;var t=0,n=0,r=0,i=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,_=0;if(p=P,P=P+176|0,i=p+40|0,s=p+24|0,t=p+16|0,r=p,u=p+152|0,d=p+136|0,f=p+56|0,l=a[e>>2]|0,c=e+116|0,_=a[c>>2]|0,n=s,a[n>>2]=0,a[n+4>>2]=0,n=s+8|0,a[n>>2]=_,a[n+4>>2]=0,a[i>>2]=a[s>>2],a[i+4>>2]=a[s+4>>2],a[i+8>>2]=a[s+8>>2],a[i+12>>2]=a[s+12>>2],Ve(l,i),l=t,a[l>>2]=0,a[l+4>>2]=0,ze(a[e>>2]|0,t,8),St(a[e>>2]|0)|0||(_=h(8)|0,Ut(_),g(_|0,2704,8)),n=t,t=a[n>>2]|0,n=a[n+4>>2]|0,(t|0)==-1&(n|0)==-1&&(_=h(8)|0,Wt(_,7488),g(_|0,2720,8)),_=a[e>>2]|0,l=r,a[l>>2]=0,a[l+4>>2]=0,l=r+8|0,a[l>>2]=t,a[l+4>>2]=n,a[i>>2]=a[r>>2],a[i+4>>2]=a[r+4>>2],a[i+8>>2]=a[r+8>>2],a[i+12>>2]=a[r+12>>2],Ve(_,i),St(a[e>>2]|0)|0||(_=h(8)|0,Ut(_),g(_|0,2704,8)),ze(a[e>>2]|0,i,8),St(a[e>>2]|0)|0||(_=h(8)|0,Ut(_),g(_|0,2704,8)),a[i>>2]|0&&(_=h(8)|0,Gt(_),g(_|0,2736,8)),s=e+288|0,l=e+292|0,a[l>>2]=a[s>>2],_=e+259|0,(o[_>>0]|o[_+1>>0]<<8|o[_+2>>0]<<16|o[_+3>>0]<<24|0)==-1&&(_=h(8)|0,Wt(_,7606),g(_|0,2720,8)),r=i+4|0,Kt(s,(a[r>>2]|0)+1|0),_=a[s>>2]|0,a[_>>2]=(a[c>>2]|0)+8,a[_+4>>2]=0,(a[r>>2]|0)>>>0>1){if(Pe(u,a[e>>2]|0),qt(d,u),Jt(f,32,2,8,0),Yt(d),Xt(f),!(a[r>>2]|0))s=a[s>>2]|0,n=s;else{n=1;do t=n>>>0>1?a[(a[s>>2]|0)+(n+-1<<3)>>2]|0:0,c=Zt(f,d,t,1)|0,t=a[s>>2]|0,_=t+(n<<3)|0,a[_>>2]=c,a[_+4>>2]=((c|0)<0)<<31>>31,n=n+1|0;while(n>>>0<=(a[r>>2]|0)>>>0);n=t,s=t}if(t=a[l>>2]|0,t-n>>3>>>0>1){i=t-s>>3,r=s,t=1,n=a[r>>2]|0,r=a[r+4>>2]|0;do _=s+(t<<3)|0,l=_,n=Ig(a[l>>2]|0,a[l+4>>2]|0,n|0,r|0)|0,r=m()|0,a[_>>2]=n,a[_+4>>2]=r,t=t+1|0;while(t>>>0<i>>>0)}Qt(f),$t(d),Ae(u)}P=p}function Je(e){e|=0,r[e+12>>0]=0,r[e+13>>0]=0}function Ye(e){e|=0,a[e+8>>2]=0,a[e+4>>2]=0}function V(e){return e|=0,Rp(e)|0}function Xe(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0,l=0,u=0;if(c=P,P=P+16|0,o=t,s=c,i=n-o|0,i>>>0>4294967279&&Yh(e),i>>>0<11?r[e+11>>0]=i:(u=i+16&-16,l=J(u)|0,a[e>>2]=l,a[e+8>>2]=u|-2147483648,a[e+4>>2]=i,e=l),(t|0)!=(n|0)){for(o=n-o|0,i=e;Ze(i,t),t=t+1|0,(t|0)!=(n|0);)i=i+1|0;e=e+o|0}r[s>>0]=0,Ze(e,s),P=c}function Ze(e,t){e|=0,t|=0,r[e>>0]=r[t>>0]|0}function H(e){e|=0,Qm(e),G(e)}function Qe(e,t){e|=0,t|=0,a[e>>2]=4372,a[e+16>>2]=e}function $e(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,t=a[t+4>>2]|0,a[e+4>>2]=t,a[e+8>>2]=t+(n*24|0)}function et(e){e|=0,a[(a[e>>2]|0)+4>>2]=a[e+4>>2]}function tt(e,t){e|=0,t|=0;var n=0,r=0;n=t+16|0,r=a[n>>2]|0;do if(r)if((t|0)==(r|0)){r=nt(e)|0,a[e+16>>2]=r,n=a[n>>2]|0,w_[a[(a[n>>2]|0)+12>>2]&15](n,r);break}else{a[e+16>>2]=r,a[n>>2]=0;break}else a[e+16>>2]=0;while(0)}function nt(e){return e|=0,e|0}function U(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0;i=e+12|0,a[i>>2]=0,a[e+16>>2]=r;do if(t)if(t>>>0>178956970)i=h(8)|0,Kh(i,6723),a[i>>2]=5956,g(i|0,3928,123);else{r=J(t*24|0)|0;break}else r=0;while(0);a[e>>2]=r,n=r+(n*24|0)|0,a[e+8>>2]=n,a[e+4>>2]=n,a[i>>2]=r+(t*24|0)}function rt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0;if(c=a[e>>2]|0,l=e+4|0,n=a[l>>2]|0,s=t+4|0,(n|0)==(c|0))i=s,o=e,r=a[s>>2]|0,n=c;else{r=a[s>>2]|0;do n=n+-24|0,tt(r+-24|0,n),r=(a[s>>2]|0)+-24|0,a[s>>2]=r;while((n|0)!=(c|0));i=s,o=e,n=a[e>>2]|0}a[o>>2]=r,a[i>>2]=n,c=t+8|0,s=a[l>>2]|0,a[l>>2]=a[c>>2],a[c>>2]=s,c=e+8|0,l=t+12|0,e=a[c>>2]|0,a[c>>2]=a[l>>2],a[l>>2]=e,a[t>>2]=a[i>>2]}function it(e){e|=0;var t=0,n=0,r=0,i=0;if(n=a[e+4>>2]|0,r=e+8|0,t=a[r>>2]|0,(t|0)!=(n|0))do i=t+-24|0,a[r>>2]=i,B(i),t=a[r>>2]|0;while((t|0)!=(n|0));t=a[e>>2]|0,t|0&&ge(t,(a[e+12>>2]|0)-t|0)}function at(e){return e|=0,178956970}function ot(e){e|=0,G(e)}function st(e){return e|=0,e=J(8)|0,a[e>>2]=4372,e|0}function ct(e,t){e|=0,t|=0,a[t>>2]=4372}function lt(e){e|=0}function ut(e){e|=0,ge(e,8)}function dt(e,t){e|=0,t|=0,ht(e+4|0,t)}function ft(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==7183?e+4|0:0)|0}function pt(e){return e|=0,2664}function mt(e){e|=0}function ht(e,t){e|=0,t|=0,gt(e,t)}function gt(e,t){e|=0,t|=0;var n=0,i=0;if(e=t+104|0,t=o[e>>0]|0,n=t>>>7,i=t>>>6&1,(n|0)==1&(i|0)!=0&&(i=h(8)|0,_t(i),g(i|0,2632,8)),(n|0)==(i|0))i=h(8)|0,vt(i),g(i|0,2648,8);else{r[e>>0]=t&63;return}}function _t(e){e|=0,Jh(e,7076),a[e>>2]=4416}function vt(e){e|=0,Jh(e,7144),a[e>>2]=4436}function yt(e){e|=0,Qm(e),G(e)}function bt(e){e|=0,Qm(e),G(e)}function xt(e){e|=0,a[e>>2]=6092}function St(e){e|=0;var t=0;return t=e+12|0,e=(r[t>>0]|0)==0,r[t>>0]=0,e|0}function Ct(e){return e|=0,(r[e+13>>0]|0)!=0|0}function wt(e,t){e|=0,t|=0,e=e+247|0,kt(e,t),(o[e>>0]|o[e+1>>0]<<8)<<16>>16!=2&&(t=h(8)|0,At(t),g(t|0,2688,8))}function Tt(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var o=0,s=0;switch(i|0){case 0:break;case 2:i=a[e+4>>2]|0,t=Ig(Ig(t|0,n|0,-1,-1)|0,m()|0,i|0,((i|0)<0)<<31>>31|0)|0,n=m()|0;break;case 1:i=a[e+8>>2]|0,t=Ig(i|0,((i|0)<0)<<31>>31|0,t|0,n|0)|0,n=m()|0;break;default:n=0,t=0}o=a[e+4>>2]|0,s=((o|0)<0)<<31>>31,i=e+12|0,(n|0)<0|((n|0)>(s|0)|(n|0)==(s|0)&t>>>0>=o>>>0)?r[i>>0]=1:(r[i>>0]=0,a[e+8>>2]=t)}function Et(e){e|=0,Jh(e,7410),a[e>>2]=4476}function Dt(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,a=0,s=0,c=0,l=0,u=0;if(s=P,P=P+16|0,a=s,Fe(e),i=t+32|0,(o[i>>0]|o[i+1>>0]<<8)<<16>>16){r=t+34|0,t=0;do l=o[r>>0]|o[r+1>>0]<<8|o[r+2>>0]<<16|o[r+3>>0]<<24,u=l+(t*6|0)|0,c=l+(t*6|0)+2|0,l=l+(t*6|0)+4|0,Pt(a,(o[u>>0]|o[u+1>>0]<<8)&65535,(o[c>>0]|o[c+1>>0]<<8)&65535,(o[l>>0]|o[l+1>>0]<<8)&65535),Nt(e,a),n=n-((o[c>>0]|o[c+1>>0]<<8)&65535)|0,t=t+1|0;while(t>>>0<((o[i>>0]|o[i+1>>0]<<8)&65535)>>>0)}(n|0)<0&&(u=h(8)|0,At(u),g(u|0,2688,8)),n|0&&(Pt(a,0,n,2),Nt(e,a)),P=s}function Ot(e,t){e|=0,t|=0;var n=0,i=0;return n=P,P=P+16|0,i=n+1|0,r[i>>0]=r[n>>0]|0,Vt(e,t,i),P=n,e|0}function kt(e,t){e|=0,t|=0;var n=0,i=0,a=0,s=0,c=0,l=0,u=0;if(i=t+2|0,s=o[t>>0]|o[t+1>>0]<<8,r[e>>0]=s,r[e+1>>0]=s>>8,s=e+2|0,i=o[i>>0]|o[i+1>>0]<<8,r[s>>0]=i,r[s+1>>0]=i>>8,r[e+4>>0]=r[t+4>>0]|0,s=t+6|0,r[e+5>>0]=r[t+5>>0]|0,i=t+8|0,n=e+6|0,s=o[s>>0]|o[s+1>>0]<<8,r[n>>0]=s,r[n+1>>0]=s>>8,n=t+12|0,s=e+8|0,i=o[i>>0]|o[i+1>>0]<<8|o[i+2>>0]<<16|o[i+3>>0]<<24,r[s>>0]=i,r[s+1>>0]=i>>8,r[s+2>>0]=i>>16,r[s+3>>0]=i>>24,s=e+12|0,n=o[n>>0]|o[n+1>>0]<<8|o[n+2>>0]<<16|o[n+3>>0]<<24,r[s>>0]=n,r[s+1>>0]=n>>8,r[s+2>>0]=n>>16,r[s+3>>0]=n>>24,s=t+16|0,n=s,n=o[n>>0]|o[n+1>>0]<<8|o[n+2>>0]<<16|o[n+3>>0]<<24,s=s+4|0,s=o[s>>0]|o[s+1>>0]<<8|o[s+2>>0]<<16|o[s+3>>0]<<24,i=e+16|0,c=i,r[c>>0]=n,r[c+1>>0]=n>>8,r[c+2>>0]=n>>16,r[c+3>>0]=n>>24,i=i+4|0,r[i>>0]=s,r[i+1>>0]=s>>8,r[i+2>>0]=s>>16,r[i+3>>0]=s>>24,i=t+32|0,s=t+24|0,c=s,c=o[c>>0]|o[c+1>>0]<<8|o[c+2>>0]<<16|o[c+3>>0]<<24,s=s+4|0,s=o[s>>0]|o[s+1>>0]<<8|o[s+2>>0]<<16|o[s+3>>0]<<24,n=e+24|0,a=n,r[a>>0]=c,r[a+1>>0]=c>>8,r[a+2>>0]=c>>16,r[a+3>>0]=c>>24,n=n+4|0,r[n>>0]=s,r[n+1>>0]=s>>8,r[n+2>>0]=s>>16,r[n+3>>0]=s>>24,n=t+34|0,s=e+32|0,i=o[i>>0]|o[i+1>>0]<<8,r[s>>0]=i,r[s+1>>0]=i>>8,a=e+34|0,e=o[a>>0]|o[a+1>>0]<<8|o[a+2>>0]<<16|o[a+3>>0]<<24,e?(jh(e),e=o[s>>0]|o[s+1>>0]<<8):e=i,i=Ah((e&65535)*6|0)|0,r[a>>0]=i,r[a+1>>0]=i>>8,r[a+2>>0]=i>>16,r[a+3>>0]=i>>24,e<<16>>16&&(e=t+36|0,c=o[n>>0]|o[n+1>>0]<<8,r[i>>0]=c,r[i+1>>0]=c>>8,t=t+38|0,c=i+2|0,e=o[e>>0]|o[e+1>>0]<<8,r[c>>0]=e,r[c+1>>0]=e>>8,c=i+4|0,t=o[t>>0]|o[t+1>>0]<<8,r[c>>0]=t,r[c+1>>0]=t>>8,((o[s>>0]|o[s+1>>0]<<8)&65535)>1)){e=1;do t=n,n=n+6|0,c=o[a>>0]|o[a+1>>0]<<8|o[a+2>>0]<<16|o[a+3>>0]<<24,l=t+8|0,i=c+(e*6|0)|0,u=o[n>>0]|o[n+1>>0]<<8,r[i>>0]=u,r[i+1>>0]=u>>8,t=t+10|0,i=c+(e*6|0)+2|0,l=o[l>>0]|o[l+1>>0]<<8,r[i>>0]=l,r[i+1>>0]=l>>8,c=c+(e*6|0)+4|0,t=o[t>>0]|o[t+1>>0]<<8,r[c>>0]=t,r[c+1>>0]=t>>8,e=e+1|0;while(e>>>0<((o[s>>0]|o[s+1>>0]<<8)&65535)>>>0)}}function At(e){e|=0,Jh(e,7354),a[e>>2]=4456}function jt(e){e|=0,Qm(e),G(e)}function Mt(e){e|=0,Qm(e),G(e)}function Nt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0;c=P,P=P+32|0,i=c,o=e+4|0,n=a[o>>2]|0,s=e+8|0;do if((n|0)==(a[s>>2]|0))if(n=((n-(a[e>>2]|0)|0)/12|0)+1|0,r=Bt(e)|0,r>>>0<n>>>0)Dg(e);else{l=a[e>>2]|0,u=((a[s>>2]|0)-l|0)/12|0,s=u<<1,Lt(i,u>>>0<r>>>1>>>0?s>>>0<n>>>0?n:s:r,((a[o>>2]|0)-l|0)/12|0,e+8|0),s=i+8|0,o=a[s>>2]|0,a[o>>2]=a[t>>2],a[o+4>>2]=a[t+4>>2],a[o+8>>2]=a[t+8>>2],a[s>>2]=(a[s>>2]|0)+12,Rt(e,i),zt(i);break}else Ft(i,e,1),u=i+4|0,l=a[u>>2]|0,a[l>>2]=a[t>>2],a[l+4>>2]=a[t+4>>2],a[l+8>>2]=a[t+8>>2],a[u>>2]=(a[u>>2]|0)+12,It(i);while(0);P=c}function Pt(e,t,n,r){e|=0,t|=0,n|=0,r|=0,a[e>>2]=t,a[e+4>>2]=n,a[e+8>>2]=r}function Ft(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,t=a[t+4>>2]|0,a[e+4>>2]=t,a[e+8>>2]=t+(n*12|0)}function It(e){e|=0,a[(a[e>>2]|0)+4>>2]=a[e+4>>2]}function Lt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0;i=e+12|0,a[i>>2]=0,a[e+16>>2]=r;do if(t)if(t>>>0>357913941)i=h(8)|0,Kh(i,6723),a[i>>2]=5956,g(i|0,3928,123);else{r=J(t*12|0)|0;break}else r=0;while(0);a[e>>2]=r,n=r+(n*12|0)|0,a[e+8>>2]=n,a[e+4>>2]=n,a[i>>2]=r+(t*12|0)}function Rt(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;r=a[e>>2]|0,s=e+4|0,o=t+4|0,i=(a[s>>2]|0)-r|0,n=(a[o>>2]|0)+(((i|0)/-12|0)*12|0)|0,a[o>>2]=n,(i|0)>0?(Gg(n|0,r|0,i|0)|0,r=o,n=a[o>>2]|0):r=o,o=a[e>>2]|0,a[e>>2]=n,a[r>>2]=o,o=t+8|0,i=a[s>>2]|0,a[s>>2]=a[o>>2],a[o>>2]=i,o=e+8|0,s=t+12|0,e=a[o>>2]|0,a[o>>2]=a[s>>2],a[s>>2]=e,a[t>>2]=a[r>>2]}function zt(e){e|=0;var t=0,n=0,r=0;t=a[e+4>>2]|0,n=e+8|0,r=a[n>>2]|0,(r|0)!=(t|0)&&(a[n>>2]=r+(~(((r+-12-t|0)>>>0)/12|0)*12|0)),t=a[e>>2]|0,t|0&&ge(t,(a[e+12>>2]|0)-t|0)}function Bt(e){return e|=0,357913941}function Vt(e,t,n){e|=0,t|=0,n|=0;var r=0;Ht(e),a[e>>2]=a[t>>2],n=t+4|0,a[e+4>>2]=a[n>>2],r=t+8|0,a[e+8>>2]=a[r>>2],a[r>>2]=0,a[n>>2]=0,a[t>>2]=0}function Ht(e){e|=0;var t=0,n=0,r=0,i=0;t=a[e>>2]|0,n=t,t|0&&(r=e+4|0,a[r>>2]=n,i=e+8|0,ge(t,(a[i>>2]|0)-n|0),a[i>>2]=0,a[r>>2]=0,a[e>>2]=0)}function Ut(e){e|=0,Jh(e,7660),a[e>>2]=4496}function Wt(e,t){e|=0,t|=0,Jh(e,t),a[e>>2]=4516}function Gt(e){e|=0,Jh(e,7704),a[e>>2]=4536}function Kt(e,t){e|=0,t|=0;var n=0,r=0,i=0;n=e+4|0,i=a[e>>2]|0,r=(a[n>>2]|0)-i>>3,r>>>0>=t>>>0?r>>>0>t>>>0&&(a[n>>2]=i+(t<<3)):rn(e,t-r|0)}function qt(e,t){e|=0,t|=0,a[e>>2]=t,a[e+4>>2]=0,a[e+8>>2]=-1}function Jt(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var o=0;a[e+4>>2]=t,a[e+8>>2]=n,a[e+12>>2]=r,a[e+16>>2]=i,a[e+36>>2]=0,a[e+40>>2]=0,a[e+44>>2]=0,hn(e+48|0),a[e+68>>2]=0,a[e+72>>2]=0,a[e+76>>2]=0;do if(i){for(r=e+20|0,a[r>>2]=0,a[e+24>>2]=i,n=i,o=0;n>>>=1,t=o+1|0,n;)o=t;a[r>>2]=(1<<o|0)==(i|0)?o:t,n=i>>>1,a[e+28>>2]=0-n,n=i+-1-n|0}else if(n=e+20|0,(t+-1|0)>>>0<31){a[n>>2]=t,i=1<<t,a[e+24>>2]=i,n=i>>>1,a[e+28>>2]=0-n,n=i+-1-n|0;break}else{a[n>>2]=32,a[e+24>>2]=0,a[e+28>>2]=-2147483648,n=2147483647;break}while(0);a[e+32>>2]=n,a[e>>2]=0}function Yt(e){e|=0;var t=0;t=((vn(a[e>>2]|0)|0)&255)<<24,t=((vn(a[e>>2]|0)|0)&255)<<16|t,t|=((vn(a[e>>2]|0)|0)&255)<<8,a[e+4>>2]=t|(vn(a[e>>2]|0)|0)&255}function Xt(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0;g=P,P=P+64|0,m=g+44|0,h=g,u=e+36|0,d=e+40|0;a:do if((a[u>>2]|0)==(a[d>>2]|0)){f=e+8|0;b:do if(!(a[f>>2]|0))p=e+20|0;else{for(i=e+20|0,o=e+44|0,s=m+4|0,c=e+44|0,l=m+8|0,r=0;;){if(Cn(h,(a[i>>2]|0)+1|0,0,0),t=a[d>>2]|0,t>>>0<(a[o>>2]|0)>>>0)wn(m,u,1),En(a[s>>2]|0,h),a[s>>2]=(a[s>>2]|0)+44,Tn(m);else{if(t=((t-(a[u>>2]|0)|0)/44|0)+1|0,n=An(u)|0,n>>>0<t>>>0)break;_=a[u>>2]|0,y=((a[o>>2]|0)-_|0)/44|0,v=y<<1,Dn(m,y>>>0<n>>>1>>>0?v>>>0<t>>>0?t:v:n,((a[d>>2]|0)-_|0)/44|0,c),En(a[l>>2]|0,h),a[l>>2]=(a[l>>2]|0)+44,On(u,m),kn(m)}if(_n(h),r=r+1|0,r>>>0>=(a[f>>2]|0)>>>0){p=i;break b}}Dg(u)}while(0);if(a[p>>2]|0){for(s=e+12|0,c=e+68|0,l=e+72|0,u=e+76|0,d=m+4|0,i=e+76|0,o=m+8|0,r=1;;){if(t=a[s>>2]|0,Cn(h,1<<(r>>>0>t>>>0?t:r),0,0),t=a[l>>2]|0,t>>>0<(a[u>>2]|0)>>>0)wn(m,c,1),En(a[d>>2]|0,h),a[d>>2]=(a[d>>2]|0)+44,Tn(m);else{if(t=((t-(a[c>>2]|0)|0)/44|0)+1|0,n=An(c)|0,n>>>0<t>>>0)break;y=a[c>>2]|0,_=((a[u>>2]|0)-y|0)/44|0,v=_<<1,Dn(m,_>>>0<n>>>1>>>0?v>>>0<t>>>0?t:v:n,((a[l>>2]|0)-y|0)/44|0,i),En(a[o>>2]|0,h),a[o>>2]=(a[o>>2]|0)+44,On(c,m),kn(m)}if(_n(h),r=r+1|0,r>>>0>(a[p>>2]|0)>>>0)break a}Dg(c)}}while(0);P=g}function Zt(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,n=(Nn(e,t,(a[e+36>>2]|0)+(r*44|0)|0)|0)+n|0,t=a[e+24>>2]|0,(n|0)<0?n+t|0:n-(n>>>0<t>>>0?0:t)|0}function Qt(e){e|=0,gn(e+68|0),gn(e+36|0)}function $t(e){e|=0}function en(e){e|=0,Qm(e),G(e)}function tn(e){e|=0,Qm(e),G(e)}function nn(e){e|=0,Qm(e),G(e)}function rn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0;c=P,P=P+32|0,i=c,o=e+8|0,s=e+4|0,n=a[s>>2]|0;do if((a[o>>2]|0)-n>>3>>>0<t>>>0)if(n=(n-(a[e>>2]|0)>>3)+t|0,r=fn(e)|0,r>>>0<n>>>0)Dg(e);else{l=a[e>>2]|0,u=(a[o>>2]|0)-l|0,o=u>>2,on(i,u>>3>>>0<r>>>1>>>0?o>>>0<n>>>0?n:o:r,(a[s>>2]|0)-l>>3,e+8|0),sn(i,t),cn(e,i),ln(i);break}else an(e,t);while(0);P=c}function an(e,t){e|=0,t|=0;var n=0,r=0,i=0;i=P,P=P+16|0,r=i,un(r,e,t),e=r+4|0,t=a[e>>2]|0,n=a[r+8>>2]|0,(t|0)!=(n|0)&&(n=n+-8-t|0,qg(t|0,0,n+8&-8|0)|0,a[e>>2]=t+((n>>>3)+1<<3)),dn(r),P=i}function on(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0;i=e+12|0,a[i>>2]=0,a[e+16>>2]=r;do if(t)if(t>>>0>536870911)i=h(8)|0,Kh(i,6723),a[i>>2]=5956,g(i|0,3928,123);else{r=J(t<<3)|0;break}else r=0;while(0);a[e>>2]=r,n=r+(n<<3)|0,a[e+8>>2]=n,a[e+4>>2]=n,a[i>>2]=r+(t<<3)}function sn(e,t){e|=0,t|=0;var n=0,r=0;r=P,P=P+16|0,n=r,pn(n,e+8|0,t),e=a[n>>2]|0,t=a[n+4>>2]|0,(e|0)!=(t|0)&&(t=t+-8-e|0,qg(e|0,0,t+8&-8|0)|0,a[n>>2]=e+((t>>>3)+1<<3)),mn(n),P=r}function cn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;r=a[e>>2]|0,s=e+4|0,o=t+4|0,i=(a[s>>2]|0)-r|0,n=(a[o>>2]|0)+(0-(i>>3)<<3)|0,a[o>>2]=n,(i|0)>0?(Gg(n|0,r|0,i|0)|0,r=o,n=a[o>>2]|0):r=o,o=a[e>>2]|0,a[e>>2]=n,a[r>>2]=o,o=t+8|0,i=a[s>>2]|0,a[s>>2]=a[o>>2],a[o>>2]=i,o=e+8|0,s=t+12|0,e=a[o>>2]|0,a[o>>2]=a[s>>2],a[s>>2]=e,a[t>>2]=a[r>>2]}function ln(e){e|=0;var t=0,n=0,r=0;t=a[e+4>>2]|0,n=e+8|0,r=a[n>>2]|0,(r|0)!=(t|0)&&(a[n>>2]=r+(~((r+-8-t|0)>>>3)<<3)),t=a[e>>2]|0,t|0&&ge(t,(a[e+12>>2]|0)-t|0)}function un(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,t=a[t+4>>2]|0,a[e+4>>2]=t,a[e+8>>2]=t+(n<<3)}function dn(e){e|=0,a[(a[e>>2]|0)+4>>2]=a[e+4>>2]}function fn(e){return e|=0,536870911}function pn(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=a[t>>2],a[e+4>>2]=(a[t>>2]|0)+(n<<3),a[e+8>>2]=t}function mn(e){e|=0,a[a[e+8>>2]>>2]=a[e>>2]}function hn(e){e|=0,a[e+12>>2]=1,a[e+16>>2]=2,a[e+8>>2]=4096,a[e+4>>2]=4,a[e>>2]=4}function gn(e){e|=0;var t=0,n=0,r=0;if(n=a[e>>2]|0,n|0){if(r=e+4|0,t=a[r>>2]|0,(t|0)==(n|0))t=n;else{do t=t+-44|0,_n(t);while((t|0)!=(n|0));t=a[e>>2]|0}a[r>>2]=n,ge(t,(a[e+8>>2]|0)-t|0)}}function _n(e){e|=0;var t=0;t=a[e+8>>2]|0,t|0&&Ne(t),t=a[e+12>>2]|0,t|0&&Ne(t),t=a[e+16>>2]|0,t|0&&Ne(t)}function vn(e){e|=0;var t=0,n=0;return n=e+4|0,t=a[n>>2]|0,(t|0)>=(a[e+8>>2]|0)&&(yn(e),t=a[n>>2]|0),e=a[e+12>>2]|0,a[n>>2]=t+1,r[e+t>>0]|0}function yn(e){e|=0;var t=0;if(a[e+4>>2]=0,ze(a[e>>2]|0,a[e+12>>2]|0,1048576),t=bn(a[e>>2]|0)|0,a[e+8>>2]=t,!t)t=h(8)|0,xn(t),g(t|0,2752,8);else return}function bn(e){return e|=0,a[e+16>>2]|0}function xn(e){e|=0,Jh(e,7769),a[e>>2]=4556}function Sn(e){e|=0,Qm(e),G(e)}function Cn(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var o=0,s=0,c=0;if(a[e>>2]=t,r[e+4>>0]=n&1,s=e+8|0,a[s>>2]=0,c=e+12|0,a[c>>2]=0,o=e+16|0,a[o>>2]=0,(t+-2|0)>>>0>2046&&(e=h(8)|0,Jh(e,7789),g(e|0,3912,8)),a[e+32>>2]=t+-1,t>>>0>16&(n^1)){for(n=3;1<<n+2>>>0<t>>>0;)n=n+1|0;t=1<<n,a[e+36>>2]=t,a[e+40>>2]=15-n,a[o>>2]=Re((t<<2)+8|0)|0,t=a[e>>2]|0}else a[o>>2]=0,a[e+40>>2]=0,a[e+36>>2]=0;if(a[s>>2]=Re(t<<2)|0,o=Re(a[e>>2]<<2)|0,a[c>>2]=o,a[e+20>>2]=0,t=a[e>>2]|0,n=e+24|0,a[n>>2]=t,t=(t|0)!=0,!i){if(t){t=0;do a[o+(t<<2)>>2]=1,t=t+1|0;while(t>>>0<(a[e>>2]|0)>>>0)}}else if(t){t=0;do a[o+(t<<2)>>2]=a[i+(t<<2)>>2],t=t+1|0;while(t>>>0<(a[e>>2]|0)>>>0)}Mn(e),i=((a[e>>2]|0)+6|0)>>>1,a[n>>2]=i,a[e+28>>2]=i}function wn(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,t=a[t+4>>2]|0,a[e+4>>2]=t,a[e+8>>2]=t+(n*44|0)}function Tn(e){e|=0,a[(a[e>>2]|0)+4>>2]=a[e+4>>2]}function En(e,t){e|=0,t|=0;var n=0;a[e>>2]=a[t>>2],r[e+4>>0]=r[t+4>>0]|0,n=t+8|0,a[e+8>>2]=a[n>>2],a[e+12>>2]=a[t+12>>2],a[e+16>>2]=a[t+16>>2],a[e+20>>2]=a[t+20>>2],a[e+24>>2]=a[t+24>>2],a[e+28>>2]=a[t+28>>2],a[e+32>>2]=a[t+32>>2],a[e+36>>2]=a[t+36>>2],a[e+40>>2]=a[t+40>>2],a[n>>2]=0,a[n+4>>2]=0,a[n+8>>2]=0}function Dn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0;i=e+12|0,a[i>>2]=0,a[e+16>>2]=r;do if(t)if(t>>>0>97612893)i=h(8)|0,Kh(i,6723),a[i>>2]=5956,g(i|0,3928,123);else{r=J(t*44|0)|0;break}else r=0;while(0);a[e>>2]=r,n=r+(n*44|0)|0,a[e+8>>2]=n,a[e+4>>2]=n,a[i>>2]=r+(t*44|0)}function On(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0;if(c=a[e>>2]|0,l=e+4|0,n=a[l>>2]|0,s=t+4|0,(n|0)==(c|0))i=s,o=e,r=a[s>>2]|0,n=c;else{r=a[s>>2]|0;do n=n+-44|0,jn(r+-44|0,n),r=(a[s>>2]|0)+-44|0,a[s>>2]=r;while((n|0)!=(c|0));i=s,o=e,n=a[e>>2]|0}a[o>>2]=r,a[i>>2]=n,c=t+8|0,s=a[l>>2]|0,a[l>>2]=a[c>>2],a[c>>2]=s,c=e+8|0,l=t+12|0,e=a[c>>2]|0,a[c>>2]=a[l>>2],a[l>>2]=e,a[t>>2]=a[i>>2]}function kn(e){e|=0;var t=0,n=0,r=0,i=0;if(n=a[e+4>>2]|0,r=e+8|0,t=a[r>>2]|0,(t|0)!=(n|0))do i=t+-44|0,a[r>>2]=i,_n(i),t=a[r>>2]|0;while((t|0)!=(n|0));t=a[e>>2]|0,t|0&&ge(t,(a[e+12>>2]|0)-t|0)}function An(e){return e|=0,97612893}function jn(e,t){e|=0,t|=0;var n=0,i=0,o=0,s=0;n=a[t>>2]|0,a[e>>2]=n,r[e+4>>0]=r[t+4>>0]|0,a[e+20>>2]=a[t+20>>2],a[e+24>>2]=a[t+24>>2],a[e+28>>2]=a[t+28>>2],a[e+32>>2]=a[t+32>>2],s=e+36|0,a[s>>2]=a[t+36>>2],a[e+40>>2]=a[t+40>>2],n<<=2,i=Re(n)|0,a[e+8>>2]=i,o=a[e>>2]|0,o|0&&Kg(i|0,a[t+8>>2]|0,o<<2|0)|0,n=Re(n)|0,a[e+12>>2]=n,i=a[e>>2]|0,i|0&&Kg(n|0,a[t+12>>2]|0,i<<2|0)|0,n=a[s>>2]|0,n?(i=Re((n<<2)+8|0)|0,a[e+16>>2]=i,n=(a[s>>2]<<2)+8|0,n|0&&Kg(i|0,a[t+16>>2]|0,n|0)|0):a[e+16>>2]=0}function Mn(e){e|=0;var t=0,n=0,i=0,o=0,s=0,c=0,l=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0;if(_=e+24|0,o=e+20|0,t=(a[o>>2]|0)+(a[_>>2]|0)|0,a[o>>2]=t,t>>>0>32768)if(a[o>>2]=0,!(a[e>>2]|0))t=0;else{i=a[e+12>>2]|0,n=0;do m=i+(n<<2)|0,t=((a[m>>2]|0)+1|0)>>>1,a[m>>2]=t,t=(a[o>>2]|0)+t|0,a[o>>2]=t,n=n+1|0;while(n>>>0<(a[e>>2]|0)>>>0)}m=2147483648/(t>>>0)|0;do if(!(r[e+4>>0]|0)&&(h=e+36|0,a[h>>2]|0)){if(a[e>>2]|0){l=a[e+8>>2]|0,d=a[e+12>>2]|0,f=e+40|0,p=e+16|0,t=0,s=0,c=0;do{if(n=(u(s,m)|0)>>>16,a[l+(c<<2)>>2]=n,s=(a[d+(c<<2)>>2]|0)+s|0,n>>>=a[f>>2]|0,t>>>0<n>>>0){i=c+-1|0,o=a[p>>2]|0;do t=t+1|0,a[o+(t<<2)>>2]=i;while((t|0)!=(n|0));t=n}c=c+1|0}while(c>>>0<(a[e>>2]|0)>>>0);if(n=a[p>>2]|0,a[n>>2]=0,t>>>0>(a[h>>2]|0)>>>0){t=e;break}}else n=a[e+16>>2]|0,a[n>>2]=0,t=0;do t=t+1|0,a[n+(t<<2)>>2]=(a[e>>2]|0)+-1;while(t>>>0<=(a[h>>2]|0)>>>0);t=e}else g=7;while(0);if((g|0)==7)if(!(a[e>>2]|0))t=e;else{i=a[e+8>>2]|0,o=a[e+12>>2]|0,t=0,n=0;do a[i+(t<<2)>>2]=(u(n,m)|0)>>>16,n=(a[o+(t<<2)>>2]|0)+n|0,t=t+1|0;while(t>>>0<(a[e>>2]|0)>>>0);t=e}g=((a[_>>2]|0)*5|0)>>>2,h=(a[t>>2]<<3)+48|0,g=g>>>0>h>>>0?h:g,a[_>>2]=g,a[e+28>>2]=g}function Nn(e,t,n){e|=0,t|=0,n|=0;var r=0;n=Pn(t,n)|0,a[e>>2]=n;do if(n){if(n>>>0>=32){n=a[e+28>>2]|0;break}if(r=a[e+12>>2]|0,n>>>0>r>>>0?(r=n-r|0,n=Pn(t,(a[e+68>>2]|0)+((n+-1|0)*44|0)|0)|0,r=n<<r|Fn(t,r)|0):r=Pn(t,(a[e+68>>2]|0)+((n+-1|0)*44|0)|0)|0,n=a[e>>2]|0,(r|0)<(1<<n+-1|0)){n=r+1+(-1<<n)|0;break}else{n=r+1|0;break}}else n=In(t,e+48|0)|0;while(0);return n|0}function Pn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,d=0,f=0,p=0,m=0,h=0;if(m=e+8|0,p=a[m>>2]|0,i=a[t+16>>2]|0,i){if(r=e+4|0,n=a[r>>2]|0,f=p>>>15,a[m>>2]=f,l=(n>>>0)/(f>>>0)|0,c=l>>>(a[t+40>>2]|0),o=a[i+(c<<2)>>2]|0,c=(a[i+(c+1<<2)>>2]|0)+1|0,s=o+1|0,d=a[t+8>>2]|0,c>>>0>s>>>0){i=o,o=c;do s=(o+i|0)>>>1,c=(a[d+(s<<2)>>2]|0)>>>0>l>>>0,i=c?i:s,o=c?s:o,s=i+1|0;while(o>>>0>s>>>0);o=i}i=u(a[d+(o<<2)>>2]|0,f)|0,s=(o|0)==(a[t+32>>2]|0)?p:u(a[d+(s<<2)>>2]|0,f)|0}else{d=p>>>15,a[m>>2]=d,c=a[t>>2]|0,f=a[t+8>>2]|0,r=e+4|0,n=a[r>>2]|0,l=c>>>1,i=0,s=p,o=0;do h=u(a[f+(l<<2)>>2]|0,d)|0,p=h>>>0>n>>>0,s=p?h:s,i=p?i:h,o=p?o:l,c=p?l:c,l=(o+c|0)>>>1;while((l|0)!=(o|0))}return a[r>>2]=n-i,h=s-i|0,a[m>>2]=h,h>>>0<16777216&&Ln(e),m=(a[t+12>>2]|0)+(o<<2)|0,a[m>>2]=(a[m>>2]|0)+1,m=t+28|0,h=(a[m>>2]|0)+-1|0,a[m>>2]=h,h||Mn(t),o|0}function Fn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return t>>>0>19?(n=(Rn(e)|0)&65535,(Fn(e,t+-16|0)|0)<<16|n|0):(r=e+4|0,i=a[r>>2]|0,o=e+8|0,n=(a[o>>2]|0)>>>t,a[o>>2]=n,t=(i>>>0)/(n>>>0)|0,a[r>>2]=i-(u(t,n)|0),n>>>0<16777216&&Ln(e),t|0)}function In(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0;return r=e+8|0,i=a[r>>2]|0,n=u(i>>>13,a[t+8>>2]|0)|0,o=e+4|0,s=a[o>>2]|0,c=s>>>0>=n>>>0,c?(a[o>>2]=s-n,n=i-n|0,a[r>>2]=n):(a[r>>2]=n,s=t+12|0,a[s>>2]=(a[s>>2]|0)+1),n>>>0<16777216&&Ln(e),s=t+4|0,e=(a[s>>2]|0)+-1|0,a[s>>2]=e,e||zn(t),c&1|0}function Ln(e){e|=0;var t=0,n=0,r=0,i=0;t=e+4|0,n=e+8|0,r=a[t>>2]|0;do r=r<<8|(vn(a[e>>2]|0)|0)&255,a[t>>2]=r,i=a[n>>2]<<8,a[n>>2]=i;while(i>>>0<16777216)}function Rn(e){e|=0;var t=0,n=0,r=0,i=0;return n=e+4|0,i=a[n>>2]|0,t=e+8|0,r=(a[t>>2]|0)>>>16,a[t>>2]=r,t=(i>>>0)/(r>>>0)|0,a[n>>2]=i-(u(t,r)|0),Ln(e),t&65535|0}function zn(e){e|=0;var t=0,n=0,r=0,i=0,o=0;i=a[e>>2]|0,n=e+16|0,t=(a[n>>2]|0)+i|0,a[n>>2]=t,t>>>0>8192?(r=(t+1|0)>>>1,a[n>>2]=r,o=e+12|0,t=((a[o>>2]|0)+1|0)>>>1,a[o>>2]=t,(t|0)==(r|0)?(t=r+1|0,a[n>>2]=t,n=t,t=r):n=r):(n=t,t=a[e+12>>2]|0),a[e+8>>2]=(u(t,2147483648/(n>>>0)|0)|0)>>>18,o=i*5|0,o=o>>>0>259?64:o>>>2,a[e>>2]=o,a[e+4>>2]=o}function Bn(e,t){e|=0,t|=0;var n=0,r=0,i=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,h=0;f=P,P=P+32|0,s=f+16|0,c=f+8|0,l=f,u=e+336|0,r=u,i=e+259|0,!(a[r+4>>2]|0)&&(a[r>>2]|0)==(o[i>>0]|o[i+1>>0]<<8|o[i+2>>0]<<16|o[i+3>>0]<<24|0)?(r=e+320|0,n=a[e+320>>2]|0,d=5):(r=e+320|0,n=a[r>>2]|0,i=n,n|0&&a[e+312>>2]|0||(n=i,d=5)),(d|0)==5&&(d=e+320|0,a[s>>2]=n,a[d>>2]=0,n=e+324|0,a[s+4>>2]=a[n>>2],a[n>>2]=0,Ee(s),i=e+312|0,a[s>>2]=a[i>>2],a[i>>2]=0,p=e+316|0,a[s+4>>2]=a[p>>2],a[p>>2]=0,De(s),h=J(12)|0,qt(h,e+4|0),a[l>>2]=0,a[s>>2]=a[l>>2],Hn(c,h,s),h=a[c>>2]|0,a[c>>2]=a[i>>2],a[i>>2]=h,h=c+4|0,l=a[h>>2]|0,a[h>>2]=a[p>>2],a[p>>2]=l,De(c),Vn(c,a[i>>2]|0,e+300|0),i=a[c>>2]|0,p=c+4|0,l=a[p>>2]|0,a[c>>2]=0,a[p>>2]=0,a[s>>2]=a[d>>2],a[d>>2]=i,a[s+4>>2]=a[n>>2],a[n>>2]=l,Ee(s),Ee(c),n=e+328|0,l=n,l=Ig(a[l>>2]|0,a[l+4>>2]|0,1,0)|0,d=m()|0,a[n>>2]=l,a[n+4>>2]=d,n=u,a[n>>2]=0,a[n+4>>2]=0,n=a[r>>2]|0),b_[a[a[n>>2]>>2]&63](n,t)|0,d=u,d=Ig(a[d>>2]|0,a[d+4>>2]|0,1,0)|0,p=m()|0,h=u,a[h>>2]=d,a[h+4>>2]=p,P=f}function Vn(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0;s=P,P=P+64|0,r=s+56|0,i=s,o=Jn(n)|0,(o|0)==-1&&(s=h(8)|0,Yn(s),g(s|0,2784,8)),n=Xn(n)|0;a:do if(n)Zn(r,t),Qn(a[r>>2]|0),(o|2)==3&&$n(a[r>>2]|0),(o|1)==3&&er(a[r>>2]|0),o=a[r>>2]|0,nr(i,n),tr(o,i),rr(i),a[e>>2]=a[r>>2],o=r+4|0,a[e+4>>2]=a[o>>2],a[r>>2]=0,a[o>>2]=0,ir(r);else switch(o|0){case 0:o=J(4788)|0,or(o),ar(e,t,o);break a;case 1:o=J(5116)|0,cr(o),sr(e,t,o);break a;case 2:o=J(5104)|0,ur(o),lr(e,t,o);break a;case 3:o=J(5432)|0,fr(o),dr(e,t,o);break a;default:a[e>>2]=0,a[e+4>>2]=0;break a}while(0);P=s}function Hn(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4576,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Un(e,r),P=n}function Un(e,t){e|=0,t|=0}function Wn(e){e|=0,Bh(e),G(e)}function Gn(e){e|=0,e=a[e+12>>2]|0,e|0&&($t(e),G(e))}function Kn(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==7983?e+12|0:0)|0}function qn(e){e|=0,ge(e,16)}function Jn(e){e|=0;var t=0,n=0;t=(a[e+4>>2]|0)-(a[e>>2]|0)|0;a:do if(t|0&&(n=((t|0)/12|0)+(((Xn(e)|0)!=0)<<31>>31)|0,n|0)&&(t=a[e>>2]|0,!(pr(t,mr()|0)|0))){switch(n|0){case 1:e=0;break a;case 2:if(hr((a[e>>2]|0)+12|0,gr()|0)|0){e=1;break a}if(hr((a[e>>2]|0)+12|0,_r()|0)|0){e=2;break a}break;case 3:if(hr((a[e>>2]|0)+12|0,gr()|0)|0&&(n=(a[e>>2]|0)+24|0,hr(n,_r()|0)|0)){e=3;break a}break;default:}e=-1}else e=-1;while(0);return e|0}function Yn(e){e|=0,Jh(e,8131),a[e>>2]=4604}function Xn(e){e|=0;var t=0,n=0;return t=a[e+4>>2]|0,e=(t|0)!=(a[e>>2]|0)&&(n=t,!(a[n+-12>>2]|0))&&(a[n+-4>>2]|0)==2?a[n+-8>>2]|0:0,e|0}function Zn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;n=P,P=P+16|0,r=n+4|0,o=n,i=J(24)|0,yr(i,t),a[o>>2]=0,a[r>>2]=a[o>>2],br(e,i,r),P=n}function Qn(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(4792)|0,Pr(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],Fr(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function $n(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(336)|0,Li(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],Ri(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function er(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(324)|0,ca(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],la(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function tr(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,s=l+12|0,c=l,r=l+8|0,o=J(64)|0,Ca(o,a[e+4>>2]|0,t),i=e+8|0,a[r>>2]=0,a[s>>2]=a[r>>2],wa(c,o,s),o=e+12|0,t=a[o>>2]|0,r=e+16|0;do if(t>>>0>=(a[r>>2]|0)>>>0)if(t=(t-(a[i>>2]|0)>>3)+1|0,n=Vr(i)|0,n>>>0<t>>>0)Dg(i);else{u=a[i>>2]|0,d=(a[r>>2]|0)-u|0,r=d>>2,Rr(s,d>>3>>>0<n>>>1>>>0?r>>>0<t>>>0?t:r:n,(a[o>>2]|0)-u>>3,e+16|0),e=s+8|0,o=a[e>>2]|0,a[o>>2]=a[c>>2],r=c+4|0,a[o+4>>2]=a[r>>2],a[c>>2]=0,a[r>>2]=0,a[e>>2]=o+8,zr(i,s),Br(s);break}else Ir(s,i,1),d=s+4|0,u=a[d>>2]|0,a[u>>2]=a[c>>2],e=c+4|0,a[u+4>>2]=a[e>>2],a[c>>2]=0,a[e>>2]=0,a[d>>2]=u+8,Lr(s);while(0);Dr(c),P=l}function nr(e,t){e|=0,t|=0;var n=0,i=0;n=P,P=P+48|0,i=n,a[e>>2]=t,r[e+4>>0]=0,_o(e+8|0,t),_o(e+20|0,t),Cn(i,256,0,0),vo(e+32|0,t,i),_n(i),P=n}function rr(e){e|=0,xo(e+32|0),Na(e+20|0),Na(e+8|0)}function ir(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function ar(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0;r=P,P=P+16|0,i=r+4|0,s=r,o=J(12)|0,So(o,t,n),a[s>>2]=0,a[i>>2]=a[s>>2],Co(e,o,i),P=r}function or(e){e|=0,Ur(e),Fo(e+4784|0)}function sr(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0;r=P,P=P+16|0,i=r+4|0,s=r,o=J(12)|0,Io(o,t,n),a[s>>2]=0,a[i>>2]=a[s>>2],Lo(e,o,i),P=r}function cr(e){e|=0,Ur(e),Yo(e+4784|0)}function lr(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0;r=P,P=P+16|0,i=r+4|0,s=r,o=J(12)|0,Xo(o,t,n),a[s>>2]=0,a[i>>2]=a[s>>2],Zo(e,o,i),P=r}function ur(e){e|=0,Ur(e),ls(e+4784|0)}function dr(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0;r=P,P=P+16|0,i=r+4|0,s=r,o=J(12)|0,us(o,t,n),a[s>>2]=0,a[i>>2]=a[s>>2],ds(e,o,i),P=r}function fr(e){e|=0,Ur(e),Cs(e+4784|0)}function pr(e,t){return e|=0,t|=0,(hr(e,t)|0)^1|0}function mr(){return!(r[21456]|0)&&yh(21456)|0&&(Pt(21536,6,20,2),q(21456)),21536}function hr(e,t){return e|=0,t|=0,e=(a[e>>2]|0)==(a[t>>2]|0)&&(a[e+8>>2]|0)==(a[t+8>>2]|0)?(a[e+4>>2]|0)==(a[t+4>>2]|0):0,e|0}function gr(){return!(r[21464]|0)&&yh(21464)|0&&(Pt(21548,7,8,2),q(21464)),21548}function _r(){return!(r[21472]|0)&&yh(21472)|0&&(Pt(21560,8,6,2),q(21472)),21560}function vr(e){e|=0,Qm(e),G(e)}function yr(e,t){e|=0,t|=0,xr(e),a[e>>2]=4624,a[e+4>>2]=t,a[e+8>>2]=0,a[e+12>>2]=0,a[e+16>>2]=0,r[e+20>>0]=1}function br(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4664,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,kr(e,r),P=n}function xr(e){e|=0,a[e>>2]=4644}function Sr(e,t){e|=0,t|=0;var n=0,i=0,o=0,s=0,c=0,l=0,u=0;if(u=P,P=P+16|0,s=u,n=a[e+8>>2]|0,c=a[e+12>>2]|0,(n|0)!=(c|0)){l=s+4|0;do i=a[n>>2]|0,a[s>>2]=i,o=a[n+4>>2]|0,a[l>>2]=o,o|0&&(o=o+4|0,a[o>>2]=(a[o>>2]|0)+1),t=b_[a[(a[i>>2]|0)+12>>2]&63](i,t)|0,Dr(s),n=n+8|0;while((n|0)!=(c|0))}return n=e+20|0,r[n>>0]|0&&(r[n>>0]=0,Yt(a[e+4>>2]|0)),P=u,t|0}function Cr(e){e|=0,a[e>>2]=4624,Or(e+8|0),Tr(e)}function wr(e){e|=0,Cr(e),G(e)}function Tr(e){e|=0}function Er(e){e|=0,N()}function Dr(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function Or(e){e|=0;var t=0,n=0,r=0;if(n=a[e>>2]|0,n|0){if(r=e+4|0,t=a[r>>2]|0,(t|0)==(n|0))t=n;else{do t=t+-8|0,Dr(t);while((t|0)!=(n|0));t=a[e>>2]|0}a[r>>2]=n,ge(t,(a[e+8>>2]|0)-t|0)}}function kr(e,t){e|=0,t|=0}function Ar(e){e|=0,Bh(e),G(e)}function jr(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+8>>2]&255](e)}function Mr(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==8546?e+12|0:0)|0}function Nr(e){e|=0,ge(e,16)}function Pr(e,t){e|=0,t|=0,Hr(e),a[e>>2]=4692,a[e+4>>2]=t,Ur(e+8|0)}function Fr(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4740,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function Ir(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,t=a[t+4>>2]|0,a[e+4>>2]=t,a[e+8>>2]=t+(n<<3)}function Lr(e){e|=0,a[(a[e>>2]|0)+4>>2]=a[e+4>>2]}function Rr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0;i=e+12|0,a[i>>2]=0,a[e+16>>2]=r;do if(t)if(t>>>0>536870911)i=h(8)|0,Kh(i,6723),a[i>>2]=5956,g(i|0,3928,123);else{r=J(t<<3)|0;break}else r=0;while(0);a[e>>2]=r,n=r+(n<<3)|0,a[e+8>>2]=n,a[e+4>>2]=n,a[i>>2]=r+(t<<3)}function zr(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0;if(c=a[e>>2]|0,l=e+4|0,n=a[l>>2]|0,s=t+4|0,(n|0)==(c|0))i=s,o=e,r=a[s>>2]|0,n=c;else{r=a[s>>2]|0;do o=n,n=n+-8|0,a[r+-8>>2]=a[n>>2],o=o+-4|0,a[r+-4>>2]=a[o>>2],a[n>>2]=0,a[o>>2]=0,r=(a[s>>2]|0)+-8|0,a[s>>2]=r;while((n|0)!=(c|0));i=s,o=e,n=a[e>>2]|0}a[o>>2]=r,a[i>>2]=n,c=t+8|0,s=a[l>>2]|0,a[l>>2]=a[c>>2],a[c>>2]=s,c=e+8|0,l=t+12|0,e=a[c>>2]|0,a[c>>2]=a[l>>2],a[l>>2]=e,a[t>>2]=a[i>>2]}function Br(e){e|=0;var t=0,n=0,r=0,i=0;if(n=a[e+4>>2]|0,r=e+8|0,t=a[r>>2]|0,(t|0)!=(n|0))do i=t+-8|0,a[r>>2]=i,Dr(i),t=a[r>>2]|0;while((t|0)!=(n|0));t=a[e>>2]|0,t|0&&ge(t,(a[e+12>>2]|0)-t|0)}function Vr(e){return e|=0,536870911}function Hr(e){e|=0,a[e>>2]=4716}function Ur(e){e|=0,Zr(e),Qr(e+3980|0),$r(e+4380|0),r[e+4780>>0]=0,r[e+4781>>0]=0}function Wr(e){e|=0,a[e>>2]=4692,ci(e+8|0),Jr(e)}function Gr(e){e|=0,Wr(e),G(e)}function Kr(e,t){return e|=0,t|=0,t|0}function qr(e,t){return e|=0,t|=0,ui(e+8|0,a[e+4>>2]|0,t)|0}function Jr(e){e|=0}function Yr(e){e|=0,Jr(e),G(e)}function Xr(e,t){return e|=0,t|=0,t|0}function Zr(e){e|=0;var t=0,n=0;ni(e),ri(e+52|0),ri(e+436|0),Cn(e+852|0,64,0,0),r[e+3976>>0]=0,t=e+20|0,n=t+32|0;do i[t>>1]=0,t=t+2|0;while((t|0)<(n|0));t=J(44)|0,Cn(t,256,0,0),a[e+896>>2]=t,t=J(44)|0,Cn(t,256,0,0),a[e+900>>2]=t,t=e+820|0,a[t>>2]=0,a[t+4>>2]=0,a[t+8>>2]=0,a[t+12>>2]=0,a[t+16>>2]=0,a[t+20>>2]=0,a[t+24>>2]=0,a[t+28>>2]=0,t=0;do n=J(44)|0,Cn(n,256,0,0),a[e+904+(t<<2)>>2]=n,n=J(44)|0,Cn(n,256,0,0),a[e+1928+(t<<2)>>2]=n,n=J(44)|0,Cn(n,256,0,0),a[e+2952+(t<<2)>>2]=n,t=t+1|0;while(t>>>0<256)}function Qr(e){e|=0,oi(e,16,4,8,0),oi(e+80|0,16,1,8,0),oi(e+160|0,32,2,8,0),oi(e+240|0,32,22,8,0),oi(e+320|0,32,20,8,0)}function $r(e){e|=0,Jt(e,16,4,8,0),Jt(e+80|0,16,1,8,0),Jt(e+160|0,32,2,8,0),Jt(e+240|0,32,22,8,0),Jt(e+320|0,32,20,8,0)}function ei(e){e|=0,si(e+320|0),si(e+240|0),si(e+160|0),si(e+80|0),si(e)}function ti(e){e|=0;var t=0,n=0;t=a[e+896>>2]|0,t|0&&(_n(t),G(t)),t=a[e+900>>2]|0,t|0&&(_n(t),G(t)),n=0;do t=a[e+904+(n<<2)>>2]|0,t|0&&(_n(t),G(t)),t=a[e+1928+(n<<2)>>2]|0,t|0&&(_n(t),G(t)),t=a[e+2952+(n<<2)>>2]|0,t|0&&(_n(t),G(t)),n=n+1|0;while((n|0)!=256);_n(e+852|0)}function ni(e){e|=0;var t=0;r[e>>0]=0,r[e+1>>0]=0,r[e+2>>0]=0,r[e+3>>0]=0,t=e+4|0,r[t>>0]=0,r[t+1>>0]=0,r[t+2>>0]=0,r[t+3>>0]=0,e=e+12|0,t=e,r[t>>0]=0,r[t+1>>0]=0,r[t+2>>0]=0,r[t+3>>0]=0,e=e+4|0,r[e>>0]=0,r[e+1>>0]=0,r[e+2>>0]=0,r[e+3>>0]=0}function ri(e){e|=0;var t=0;t=e+384|0;do ii(e),e=e+24|0;while((e|0)!=(t|0))}function ii(e){e|=0,ai(e)}function ai(e){e|=0,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,a[e+12>>2]=0,a[e+16>>2]=0,r[e+20>>0]=1}function oi(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var o=0;a[e+4>>2]=t,a[e+8>>2]=n,a[e+12>>2]=r,a[e+16>>2]=i,a[e+36>>2]=0,a[e+40>>2]=0,a[e+44>>2]=0,hn(e+48|0),a[e+68>>2]=0,a[e+72>>2]=0,a[e+76>>2]=0;do if(i){for(r=e+20|0,a[r>>2]=0,a[e+24>>2]=i,n=i,o=0;n>>>=1,t=o+1|0,n;)o=t;a[r>>2]=(1<<o|0)==(i|0)?o:t,n=i>>>1,a[e+28>>2]=0-n,n=i+-1-n|0}else if(n=e+20|0,(t+-1|0)>>>0<31){a[n>>2]=t,i=1<<t,a[e+24>>2]=i,n=i>>>1,a[e+28>>2]=0-n,n=i+-1-n|0;break}else{a[n>>2]=32,a[e+24>>2]=0,a[e+28>>2]=-2147483648,n=2147483647;break}while(0);a[e+32>>2]=n,a[e>>2]=0}function si(e){e|=0;var t=0,n=0,r=0,i=0,o=0;if(o=e+36|0,n=a[o>>2]|0,r=e+40|0,t=a[r>>2]|0,(t|0)!=(n|0))do t=t+-44|0,_n(t);while((t|0)!=(n|0));if(a[r>>2]=n,r=e+68|0,i=a[r>>2]|0,n=e+72|0,t=a[n>>2]|0,(t|0)!=(i|0))do t=t+-44|0,_n(t);while((t|0)!=(i|0));a[n>>2]=i,gn(r),gn(o)}function ci(e){e|=0,li(e+4380|0),ei(e+3980|0),ti(e)}function li(e){e|=0,Qt(e+320|0),Qt(e+240|0),Qt(e+160|0),Qt(e+80|0),Qt(e)}function ui(e,t,n){e|=0,t|=0,n|=0;var c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(h=P,P=P+32|0,m=h,c=e+4781|0,r[c>>0]|0||(di(e+4380|0),r[c>>0]=1),c=e+3976|0,r[c>>0]|0)f=Pn(t,e+852|0)|0,f?(f&32|0&&gi((Pn(t,a[e+904+(((hi(e)|0)&255)<<2)>>2]|0)|0)&255,e),p=e+14|0,u=r[p>>0]|0,c=u&7,u=(u&255)>>>3&7,l=o[16+(u<<3)+c>>0]|0,c=o[80+(u<<3)+c>>0]|0,f&16?(g=e+20+(l<<1)|0,d=(Zt(e+4380|0,t,s[g>>1]|0,l>>>0<3?l:3)|0)&65535,i[g>>1]=d):d=i[e+20+(l<<1)>>1]|0,i[e+12>>1]=d,f&8|0&&(g=e+15|0,r[g>>0]=Pn(t,a[e+1928+(o[g>>0]<<2)>>2]|0)|0),f&4|0&&(p=Pn(t,a[e+896+(((o[p>>0]|0)>>>6&1)<<2)>>2]|0)|0,g=e+16|0,r[g>>0]=_i(p+(r[g>>0]|0)|0)|0),f&2|0&&(g=e+17|0,r[g>>0]=Pn(t,a[e+2952+(o[g>>0]<<2)>>2]|0)|0),f&1&&(g=e+18|0,i[g>>1]=Zt(e+4460|0,t,s[g>>1]|0,0)|0)):(g=r[e+14>>0]|0,c=g&7,g=(g&255)>>>3&7,u=g,l=o[16+(g<<3)+c>>0]|0,c=o[80+(g<<3)+c>>0]|0),d=e+52+(l*24|0)|0,f=e+4540|0,p=(u|0)==1&1,u=Zt(f,t,vi(d)|0,p)|0,a[m>>2]=u,a[e>>2]=(a[e>>2]|0)+u,yi(d,m),d=e+436+(l*24|0)|0,u=vi(d)|0,l=bi(f)|0,g=e+4620|0,l=Zt(g,t,u,(l>>>0<20?l&-2:20)|p)|0,a[m>>2]=l,u=e+4|0,a[u>>2]=(a[u>>2]|0)+l,yi(d,m),m=bi(f)|0,m=(bi(g)|0)+m|0,g=e+820+(c<<2)|0,m=Zt(e+4700|0,t,a[g>>2]|0,(m>>>0<36?m>>>1&2147483646:18)|p)|0,a[e+8>>2]=m,a[g>>2]=m,xi(e,n);else{r[c>>0]=1,pi(fi(t)|0,n,20),mi(m,n),u=e,c=m,l=u+20|0;do r[u>>0]=r[c>>0]|0,u=u+1|0,c=c+1|0;while((u|0)<(l|0));i[e+12>>1]=0}return P=h,n+20|0}function di(e){e|=0,Xt(e),Xt(e+80|0),Xt(e+160|0),Xt(e+240|0),Xt(e+320|0)}function fi(e){return e|=0,a[e>>2]|0}function pi(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0,l=0,u=0;if(u=e+4|0,i=a[u>>2]|0,l=(a[e+8>>2]|0)-i|0,l=l>>>0>n>>>0?n:l,c=e+12|0,o=(a[c>>2]|0)+i|0,s=o+l|0,l){for(i=o,o=t;r[o>>0]=r[i>>0]|0,i=i+1|0,(i|0)!=(s|0);)o=o+1|0;i=a[u>>2]|0}if(a[u>>2]=i+l,n=n-l|0,n|0){for(yn(e),o=(a[c>>2]|0)+(a[u>>2]|0)|0,s=o+n|0,i=t+l|0;r[i>>0]=r[o>>0]|0,o=o+1|0,(o|0)!=(s|0);)i=i+1|0;a[u>>2]=(a[u>>2]|0)+n}}function mi(e,t){e|=0,t|=0,ni(e),a[e>>2]=Si(t)|0,a[e+4>>2]=Si(t+4|0)|0,a[e+8>>2]=Si(t+8|0)|0,i[e+12>>1]=Ci(t+12|0)|0,gi(wi(t+14|0)|0,e),r[e+15>>0]=wi(t+15|0)|0,r[e+16>>0]=Ti(t+16|0)|0,r[e+17>>0]=Ti(t+17|0)|0,i[e+18>>1]=Ci(t+18|0)|0}function hi(e){return e|=0,r[e+14>>0]|0}function gi(e,t){e|=0,t|=0,r[t+14>>0]=e}function _i(e){return e|=0,e&255|0}function vi(e){return e|=0,a[e+8>>2]|0}function yi(e,t){e|=0,t|=0;var n=0,i=0,o=0,s=0,c=0,l=0,u=0;u=e+20|0;do if(r[u>>0]|0){if(o=a[t>>2]|0,c=e+8|0,n=a[c>>2]|0,s=e+12|0,i=a[s>>2]|0,(o|0)>=(n|0)){n=e+16|0,(o|0)<(i|0)?(a[n>>2]=i,a[s>>2]=a[t>>2]):a[n>>2]=o,r[u>>0]=0;break}if(a[e+16>>2]=i,a[s>>2]=n,n=a[t>>2]|0,i=a[e>>2]|0,o=e+4|0,s=a[o>>2]|0,(n|0)<(i|0)){a[c>>2]=s,a[o>>2]=i,a[e>>2]=a[t>>2];break}if((n|0)<(s|0)){a[c>>2]=s,a[o>>2]=a[t>>2];break}else{a[c>>2]=n;break}}else{if(l=e+8|0,n=a[l>>2]|0,i=a[t>>2]|0,o=e+4|0,s=a[o>>2]|0,(n|0)>=(i|0)){(s|0)<(i|0)?(a[e>>2]=s,a[o>>2]=a[t>>2]):a[e>>2]=i,r[u>>0]=1;break}if(a[e>>2]=s,a[o>>2]=n,o=e+16|0,s=a[o>>2]|0,c=a[t>>2]|0,n=e+12|0,i=a[n>>2]|0,(s|0)<(c|0)){a[l>>2]=i,a[n>>2]=s,a[o>>2]=a[t>>2];break}if((i|0)<(c|0)){a[l>>2]=i,a[n>>2]=a[t>>2];break}else{a[l>>2]=c;break}}while(0)}function bi(e){return e|=0,a[e>>2]|0}function xi(e,t){e|=0,t|=0;var n=0;Di(o[e>>0]|o[e+1>>0]<<8|o[e+2>>0]<<16|o[e+3>>0]<<24,t),n=e+4|0,Di(o[n>>0]|o[n+1>>0]<<8|o[n+2>>0]<<16|o[n+3>>0]<<24,t+4|0),n=e+8|0,Di(o[n>>0]|o[n+1>>0]<<8|o[n+2>>0]<<16|o[n+3>>0]<<24,t+8|0),n=e+12|0,Oi(o[n>>0]|o[n+1>>0]<<8,t+12|0),ki(hi(e)|0,t+14|0),ki(r[e+15>>0]|0,t+15|0),Ai(r[e+16>>0]|0,t+16|0),Ai(r[e+17>>0]|0,t+17|0),e=e+18|0,Oi(o[e>>0]|o[e+1>>0]<<8,t+18|0)}function Si(e){return e|=0,Ei(e)|0}function Ci(e){return e|=0,(r[e+1>>0]<<8|o[e>>0])&65535|0}function wi(e){return e|=0,r[e>>0]|0}function Ti(e){return e|=0,r[e>>0]|0}function Ei(e){return e|=0,(o[e+1>>0]|0)<<8|o[e>>0]|0|(o[e+2>>0]|0)<<16|(o[e+3>>0]|0)<<24|0}function Di(e,t){e|=0,t|=0,ji(e,t)}function Oi(e,t){e|=0,t|=0,r[t+1>>0]=(e&65535)>>>8,r[t>>0]=e}function ki(e,t){e|=0,t|=0,r[t>>0]=e}function Ai(e,t){e|=0,t|=0,r[t>>0]=e}function ji(e,t){e|=0,t|=0,r[t+3>>0]=e>>>24,r[t+2>>0]=e>>>16,r[t+1>>0]=e>>>8,r[t>>0]=e}function Mi(e,t){e|=0,t|=0}function Ni(e){e|=0,Bh(e),G(e)}function Pi(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function Fi(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==9202?e+12|0:0)|0}function Ii(e){e|=0,ge(e,16)}function Li(e,t){e|=0,t|=0,Hr(e),a[e>>2]=4768,a[e+4>>2]=t,zi(e+8|0)}function Ri(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4792,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function zi(e){e|=0,Ui(e),Wi(e+164|0),Gi(e+244|0),r[e+324>>0]=0,r[e+325>>0]=0}function Bi(e){e|=0,a[e>>2]=4768,Xi(e+8|0),Jr(e)}function Vi(e){e|=0,Bi(e),G(e)}function Hi(e,t){return e|=0,t|=0,Qi(e+8|0,a[e+4>>2]|0,t)|0}function Ui(e){e|=0;var t=0,n=0,i=0,o=0,s=0,c=0,l=0;for(s=P,P=P+16|0,i=s,r[e>>0]=0,Cn(e+4|0,516,0,0),Cn(e+48|0,6,0,0),a[e+92>>2]=0,a[e+96>>2]=0,n=e+100|0,Ji(n),Yi(i),o=a[i>>2]|0,i=a[i+4>>2]|0,t=4;c=n,l=c,r[l>>0]=o,r[l+1>>0]=o>>8,r[l+2>>0]=o>>16,r[l+3>>0]=o>>24,c=c+4|0,r[c>>0]=i,r[c+1>>0]=i>>8,r[c+2>>0]=i>>16,r[c+3>>0]=i>>24,t=t+-1|0,t;)n=n+8|0;l=e+132|0,a[l>>2]=0,a[l+4>>2]=0,a[l+8>>2]=0,a[l+12>>2]=0,a[l+16>>2]=0,a[l+20>>2]=0,a[l+24>>2]=0,a[l+28>>2]=0,P=s}function Wi(e){e|=0,oi(e,32,9,8,0)}function Gi(e){e|=0,Jt(e,32,9,8,0)}function Ki(e){e|=0,si(e)}function qi(e){e|=0,_n(e+48|0),_n(e+4|0)}function Ji(e){e|=0;var t=0;t=e+32|0;do Yi(e),e=e+8|0;while((e|0)!=(t|0))}function Yi(e){e|=0;var t=0;t=e,r[t>>0]=0,r[t+1>>0]=0,r[t+2>>0]=0,r[t+3>>0]=0,e=e+4|0,r[e>>0]=0,r[e+1>>0]=0,r[e+2>>0]=0,r[e+3>>0]=0}function Xi(e){e|=0,Zi(e+244|0),Ki(e+164|0),qi(e)}function Zi(e){e|=0,Qt(e)}function Qi(e,t,n){e|=0,t|=0,n|=0;var i=0,s=0,c=0,l=0,d=0;if(i=e+325|0,r[i>>0]|0||($i(e+244|0),r[i>>0]=1),!(r[e>>0]|0))r[e>>0]=1,pi(fi(t)|0,n,8),c=ea(n)|0,l=m()|0,e=e+100|0,t=e,r[t>>0]=c,r[t+1>>0]=c>>8,r[t+2>>0]=c>>16,r[t+3>>0]=c>>24,e=e+4|0,r[e>>0]=l,r[e+1>>0]=l>>8,r[e+2>>0]=l>>16,r[e+3>>0]=l>>24;else{l=e+92|0;a:do if(a[e+132+(a[l>>2]<<2)>>2]|0){if(c=Pn(t,e+4|0)|0,(c|0)==1){i=Zt(e+244|0,t,a[e+132+(a[l>>2]<<2)>>2]|0,1)|0,d=a[l>>2]|0,t=e+100+(d<<3)|0,c=t,s=c,c=c+4|0,i=Ig(o[s>>0]|o[s+1>>0]<<8|o[s+2>>0]<<16|o[s+3>>0]<<24|0,o[c>>0]|o[c+1>>0]<<8|o[c+2>>0]<<16|o[c+3>>0]<<24|0,i|0,((i|0)<0)<<31>>31|0)|0,c=m()|0,s=t,r[s>>0]=i,r[s+1>>0]=i>>8,r[s+2>>0]=i>>16,r[s+3>>0]=i>>24,t=t+4|0,r[t>>0]=c,r[t+1>>0]=c>>8,r[t+2>>0]=c>>16,r[t+3>>0]=c>>24,a[e+148+(d<<2)>>2]=0;break}if((c|0)>=511){if((c|0)==512){d=e+96|0,a[d>>2]=(a[d>>2]|0)+1&3,c=e+100+(a[l>>2]<<3)+4|0,c=Zt(e+244|0,t,o[c>>0]|o[c+1>>0]<<8|o[c+2>>0]<<16|o[c+3>>0]<<24,8)|0,i=e+100+(a[d>>2]<<3)|0,s=i,r[s>>0]=0,r[s+1>>0]=0,r[s+2>>0]=0,r[s+3>>0]=0,i=i+4|0,r[i>>0]=c,r[i+1>>0]=c>>8,r[i+2>>0]=c>>16,r[i+3>>0]=c>>24,i=ta(t)|0,d=a[d>>2]|0,t=e+100+(d<<3)|0,c=t,s=c,c=c+4|0,c=o[c>>0]|o[c+1>>0]<<8|o[c+2>>0]<<16|o[c+3>>0]<<24,i=o[s>>0]|o[s+1>>0]<<8|o[s+2>>0]<<16|o[s+3>>0]<<24|i,s=t,r[s>>0]=i,r[s+1>>0]=i>>8,r[s+2>>0]=i>>16,r[s+3>>0]=i>>24,t=t+4|0,r[t>>0]=c,r[t+1>>0]=c>>8,r[t+2>>0]=c>>16,r[t+3>>0]=c>>24,a[l>>2]=d,a[e+132+(d<<2)>>2]=0,a[e+148+(a[l>>2]<<2)>>2]=0;break}if((c|0)<=511)break;a[l>>2]=(a[l>>2]|0)+c&3,Qi(e,t,n)|0;break}do if(!c)i=Zt(e+244|0,t,0,7)|0,s=e+148+(a[l>>2]<<2)|0,a[s>>2]=(a[s>>2]|0)+1,s=a[l>>2]|0,(a[e+148+(s<<2)>>2]|0)>3&&(a[e+132+(s<<2)>>2]=i,a[e+148+(a[l>>2]<<2)>>2]=0);else{if((c|0)<500)if(i=e+244|0,s=u(a[e+132+(a[l>>2]<<2)>>2]|0,c)|0,(c|0)<10){i=Zt(i,t,s,2)|0;break}else{i=Zt(i,t,s,3)|0;break}if((c|0)==500){if(i=Zt(e+244|0,t,(a[e+132+(a[l>>2]<<2)>>2]|0)*500|0,4)|0,s=e+148+(a[l>>2]<<2)|0,a[s>>2]=(a[s>>2]|0)+1,s=a[l>>2]|0,(a[e+148+(s<<2)>>2]|0)<=3)break;a[e+132+(s<<2)>>2]=i,a[e+148+(a[l>>2]<<2)>>2]=0;break}if(i=500-c|0,s=e+244|0,c=a[e+132+(a[l>>2]<<2)>>2]|0,(i|0)>-10){i=Zt(s,t,u(c,i)|0,5)|0;break}i=Zt(s,t,u(c,-10)|0,6)|0,s=e+148+(a[l>>2]<<2)|0,a[s>>2]=(a[s>>2]|0)+1,s=a[l>>2]|0,(a[e+148+(s<<2)>>2]|0)>3&&(a[e+132+(s<<2)>>2]=i,a[e+148+(a[l>>2]<<2)>>2]=0)}while(0);d=e+100+(a[l>>2]<<3)|0,s=d,t=s,s=s+4|0,s=Ig(o[t>>0]|o[t+1>>0]<<8|o[t+2>>0]<<16|o[t+3>>0]<<24|0,o[s>>0]|o[s+1>>0]<<8|o[s+2>>0]<<16|o[s+3>>0]<<24|0,i|0,((i|0)<0)<<31>>31|0)|0,t=m()|0,c=d,r[c>>0]=s,r[c+1>>0]=s>>8,r[c+2>>0]=s>>16,r[c+3>>0]=s>>24,d=d+4|0,r[d>>0]=t,r[d+1>>0]=t>>8,r[d+2>>0]=t>>16,r[d+3>>0]=t>>24}else switch(i=Pn(t,e+48|0)|0,i|0){case 1:t=Zt(e+244|0,t,0,0)|0,a[e+132+(a[l>>2]<<2)>>2]=t,t=a[l>>2]|0,d=a[e+132+(t<<2)>>2]|0,c=e+100+(t<<3)|0,s=c,i=s,s=s+4|0,d=Ig(o[i>>0]|o[i+1>>0]<<8|o[i+2>>0]<<16|o[i+3>>0]<<24|0,o[s>>0]|o[s+1>>0]<<8|o[s+2>>0]<<16|o[s+3>>0]<<24|0,d|0,((d|0)<0)<<31>>31|0)|0,s=m()|0,i=c,r[i>>0]=d,r[i+1>>0]=d>>8,r[i+2>>0]=d>>16,r[i+3>>0]=d>>24,c=c+4|0,r[c>>0]=s,r[c+1>>0]=s>>8,r[c+2>>0]=s>>16,r[c+3>>0]=s>>24,a[e+148+(t<<2)>>2]=0;break a;case 2:d=e+96|0,a[d>>2]=(a[d>>2]|0)+1&3,c=e+100+(a[l>>2]<<3)+4|0,c=Zt(e+244|0,t,o[c>>0]|o[c+1>>0]<<8|o[c+2>>0]<<16|o[c+3>>0]<<24,8)|0,i=e+100+(a[d>>2]<<3)|0,s=i,r[s>>0]=0,r[s+1>>0]=0,r[s+2>>0]=0,r[s+3>>0]=0,i=i+4|0,r[i>>0]=c,r[i+1>>0]=c>>8,r[i+2>>0]=c>>16,r[i+3>>0]=c>>24,i=ta(t)|0,d=a[d>>2]|0,t=e+100+(d<<3)|0,c=t,s=c,c=c+4|0,c=o[c>>0]|o[c+1>>0]<<8|o[c+2>>0]<<16|o[c+3>>0]<<24,i=o[s>>0]|o[s+1>>0]<<8|o[s+2>>0]<<16|o[s+3>>0]<<24|i,s=t,r[s>>0]=i,r[s+1>>0]=i>>8,r[s+2>>0]=i>>16,r[s+3>>0]=i>>24,t=t+4|0,r[t>>0]=c,r[t+1>>0]=c>>8,r[t+2>>0]=c>>16,r[t+3>>0]=c>>24,a[l>>2]=d,a[e+132+(d<<2)>>2]=0,a[e+148+(a[l>>2]<<2)>>2]=0;break a;default:if((i|0)<=2)break a;a[l>>2]=i+2+(a[l>>2]|0)&3,Qi(e,t,n)|0;break a}while(0);na(e+100+(a[l>>2]<<3)|0,n)}return n+8|0}function $i(e){e|=0,Xt(e)}function ea(e){e|=0;var t=0,n=0,r=0;return t=P,P=P+16|0,n=t,r=Ei(e)|0,ra(n,r,Ei(e+4|0)|0),e=a[n>>2]|0,p(a[n+4>>2]|0),P=t,e|0}function ta(e){e|=0;var t=0;return t=(Rn(e)|0)&65535,((Rn(e)|0)&65535)<<16|t|0}function na(e,t){e|=0,t|=0;var n=0;n=e,ji(o[n>>0]|o[n+1>>0]<<8|o[n+2>>0]<<16|o[n+3>>0]<<24,t),e=e+4|0,ji(o[e>>0]|o[e+1>>0]<<8|o[e+2>>0]<<16|o[e+3>>0]<<24,t+4|0)}function ra(e,t,n){e|=0,t|=0,n|=0;var i=0;i=e,r[i>>0]=t,r[i+1>>0]=t>>8,r[i+2>>0]=t>>16,r[i+3>>0]=t>>24,t=e+4|0,r[t>>0]=n,r[t+1>>0]=n>>8,r[t+2>>0]=n>>16,r[t+3>>0]=n>>24}function ia(e){e|=0,Bh(e),G(e)}function aa(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function oa(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==9890?e+12|0:0)|0}function sa(e){e|=0,ge(e,16)}function ca(e,t){e|=0,t|=0,Hr(e),a[e>>2]=4820,a[e+4>>2]=t,ua(e+8|0)}function la(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4844,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function ua(e){e|=0,r[e>>0]=0,ma(e+1|0),Cn(e+8|0,128,0,0),Cn(e+52|0,256,0,0),Cn(e+96|0,256,0,0),Cn(e+140|0,256,0,0),Cn(e+184|0,256,0,0),Cn(e+228|0,256,0,0),Cn(e+272|0,256,0,0)}function da(e){e|=0,a[e>>2]=4820,ha(e+8|0),Jr(e)}function fa(e){e|=0,da(e),G(e)}function pa(e,t){return e|=0,t|=0,ga(e+8|0,a[e+4>>2]|0,t)|0}function ma(e){e|=0;var t=0;r[e>>0]=0,r[e+1>>0]=0,t=e+2|0,r[t>>0]=0,r[t+1>>0]=0,e=e+4|0,r[e>>0]=0,r[e+1>>0]=0}function ha(e){e|=0,_n(e+272|0),_n(e+228|0),_n(e+184|0),_n(e+140|0),_n(e+96|0),_n(e+52|0),_n(e+8|0)}function ga(e,t,n){e|=0,t|=0,n|=0;var a=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(m=P,P=P+16|0,f=m,!(r[e>>0]|0))r[e>>0]=1,pi(fi(t)|0,n,6),_a(f,n),p=e+1|0,r[p>>0]=r[f>>0]|0,r[p+1>>0]=r[f+1>>0]|0,r[p+2>>0]=r[f+2>>0]|0,r[p+3>>0]=r[f+3>>0]|0,r[p+4>>0]=r[f+4>>0]|0,r[p+5>>0]=r[f+5>>0]|0;else{p=Pn(t,e+8|0)|0,ma(f),p&1?(d=(Pn(t,e+52|0)|0)&255,a=e+1|0,a=(_i(d+((o[a>>0]|o[a+1>>0]<<8)&255)|0)|0)&255):(a=e+1|0,a=(o[a>>0]|o[a+1>>0]<<8)&255),i[f>>1]=a,p&2?(a=(Pn(t,e+96|0)|0)&255,d=e+1|0,a=((_i((((o[d>>0]|o[d+1>>0]<<8)&65535)>>>8)+a|0)|0)&255)<<8,a=(a|s[f>>1])&65535):(d=e+1|0,a|=(o[d>>0]|o[d+1>>0]<<8)&-256),i[f>>1]=a;do if(p&64)if(u=e+1|0,c=(a&255)-((o[u>>0]|o[u+1>>0]<<8)&255)|0,p&4?(a=(Pn(t,e+140|0)|0)&255,d=e+3|0,d=c+((o[d>>0]|o[d+1>>0]<<8)&255)|0,a=(_i(((d|0)<1?0:(d|0)>254?255:d&255)+a|0)|0)&255):(a=e+3|0,a=(o[a>>0]|o[a+1>>0]<<8)&255),d=f+2|0,i[d>>1]=a,p&16?(a=Pn(t,e+228|0)|0,h=e+3|0,l=e+5|0,l=((c+(i[d>>1]&255)-((o[h>>0]|o[h+1>>0]<<8)&255)|0)/2|0)+((o[l>>0]|o[l+1>>0]<<8)&255)|0,a=(_i(((l|0)<1?0:(l|0)>254?255:l&255)+(a&255)|0)|0)&255):(a=e+5|0,a=(o[a>>0]|o[a+1>>0]<<8)&255),l=f+4|0,i[l>>1]=a,a=((s[f>>1]|0)>>>8)-(((o[u>>0]|o[u+1>>0]<<8)&65535)>>>8)|0,p&8?(c=(Pn(t,e+184|0)|0)&255,h=e+3|0,h=(((o[h>>0]|o[h+1>>0]<<8)&65535)>>>8)+a|0,c=((_i(((h|0)<1?0:(h|0)>254?255:h&255)+c|0)|0)&255)<<8,c=(c|s[d>>1])&65535):(c=e+3|0,c=i[d>>1]|(o[c>>0]|o[c+1>>0]<<8)&-256),i[d>>1]=c,p&32){h=Pn(t,e+272|0)|0,t=e+3|0,p=e+5|0,p=((((s[d>>1]|0)>>>8)+a-(((o[t>>0]|o[t+1>>0]<<8)&65535)>>>8)|0)/2|0)+(((o[p>>0]|o[p+1>>0]<<8)&65535)>>>8)|0,h=((_i(((p|0)<1?0:(p|0)>254?255:p&255)+(h&255)|0)|0)&255)<<8,i[l>>1]=h|s[l>>1];break}else{h=e+5|0,i[l>>1]=i[l>>1]|(o[h>>0]|o[h+1>>0]<<8)&-256;break}else i[f+2>>1]=a,i[f+4>>1]=a;while(0);h=e+1|0,r[h>>0]=r[f>>0]|0,r[h+1>>0]=r[f+1>>0]|0,r[h+2>>0]=r[f+2>>0]|0,r[h+3>>0]=r[f+3>>0]|0,r[h+4>>0]=r[f+4>>0]|0,r[h+5>>0]=r[f+5>>0]|0,va(h,n)}return P=m,n+6|0}function _a(e,t){e|=0,t|=0;var n=0,r=0;r=Ci(t)|0,n=Ci(t+2|0)|0,ya(e,r,n,Ci(t+4|0)|0)}function va(e,t){e|=0,t|=0;var n=0;Oi(o[e>>0]|o[e+1>>0]<<8,t),n=e+2|0,Oi(o[n>>0]|o[n+1>>0]<<8,t+2|0),e=e+4|0,Oi(o[e>>0]|o[e+1>>0]<<8,t+4|0)}function ya(e,t,n,i){e|=0,t|=0,n|=0,i|=0,r[e>>0]=t,r[e+1>>0]=t>>8,t=e+2|0,r[t>>0]=n,r[t+1>>0]=n>>8,n=e+4|0,r[n>>0]=i,r[n+1>>0]=i>>8}function ba(e){e|=0,Bh(e),G(e)}function W(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function xa(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==10570?e+12|0:0)|0}function Sa(e){e|=0,ge(e,16)}function Ca(e,t,n){e|=0,t|=0,n|=0,Hr(e),a[e>>2]=4872,a[e+4>>2]=t,Ta(e+8|0,n)}function wa(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4896,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function Ta(e,t){e|=0,t|=0,a[e>>2]=a[t>>2],r[e+4>>0]=r[t+4>>0]|0,ka(e+8|0,t+8|0),ka(e+20|0,t+20|0),Aa(e+32|0,t+32|0)}function Ea(e){e|=0,a[e>>2]=4872,rr(e+8|0),Jr(e)}function Da(e){e|=0,Ea(e),G(e)}function Oa(e,t){return e|=0,t|=0,uo(e+8|0,a[e+4>>2]|0,t)|0}function ka(e,t){e|=0,t|=0;var n=0,r=0;a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,n=t+4|0,r=(a[n>>2]|0)-(a[t>>2]|0)|0,r|0&&(ja(e,r),Ma(e,a[t>>2]|0,a[n>>2]|0,r))}function Aa(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;n=P,P=P+32|0,r=n+24|0,i=n+16|0,s=n+8|0,o=n,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,a[e+12>>2]=0,a[e+16>>2]=0,a[e+20>>2]=0,oo(s,t),so(o,t),a[i>>2]=a[s>>2],a[i+4>>2]=a[s+4>>2],a[r>>2]=a[o>>2],a[r+4>>2]=a[o+4>>2],La(e,i,r,0),P=n}function ja(e,t){e|=0,t|=0;var n=0;if((Pa(e)|0)>>>0<t>>>0)Dg(e);else{n=J(t)|0,a[e+4>>2]=n,a[e>>2]=n,a[e+8>>2]=n+t;return}}function Ma(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,o=0;o=P,P=P+16|0,i=o,Fa(i,e,r),r=i+4|0,e=n-t|0,(e|0)>0&&(Gg(a[r>>2]|0,t|0,e|0)|0,a[r>>2]=(a[r>>2]|0)+e),Ia(i),P=o}function Na(e){e|=0;var t=0,n=0;t=a[e>>2]|0,n=t,t|0&&(a[e+4>>2]=n,ge(t,(a[e+8>>2]|0)-n|0))}function Pa(e){return e|=0,2147483647}function Fa(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,t=a[t+4>>2]|0,a[e+4>>2]=t,a[e+8>>2]=t+n}function Ia(e){e|=0,a[(a[e>>2]|0)+4>>2]=a[e+4>>2]}function La(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(g=P,P=P+96|0,h=g+80|0,f=g+64|0,l=g+48|0,u=g+40|0,d=g+8|0,c=g,p=g+32|0,m=g+16|0,s=t,o=a[s>>2]|0,s=a[s+4>>2]|0,i=n,n=a[i>>2]|0,i=a[i+4>>2]|0,r=o,s=(i|0)==(s|0)?0:((i-(a[n>>2]|0)|0)/44|0)+((n-o>>2)*93|0)+((s-(a[o>>2]|0)|0)/-44|0)|0,n=(a[e+8>>2]|0)-(a[e+4>>2]|0)|0,n=(n|0?((n>>2)*93|0)+-1|0:0)-((a[e+20>>2]|0)+(a[e+16>>2]|0))|0,s>>>0>n>>>0&&za(e,s-n|0),Ba(u,e),Ba(c,e),i=c,n=a[i>>2]|0,i=a[i+4>>2]|0,o=d,a[o>>2]=n,a[o+4>>2]=i,o=n,s|0&&(n=((i-(a[n>>2]|0)|0)/44|0)+s|0,(n|0)>0?(c=(n>>>0)/93|0,s=o+(c<<2)|0,a[d>>2]=s,n=(a[s>>2]|0)+((n-(c*93|0)|0)*44|0)|0):(n=92-n|0,c=o+(((n|0)/-93|0)<<2)|0,a[d>>2]=c,n=(a[c>>2]|0)+((92-((n|0)%93|0)|0)*44|0)|0),a[d+4>>2]=n),a[f>>2]=a[u>>2],a[f+4>>2]=a[u+4>>2],a[h>>2]=a[d>>2],a[h+4>>2]=a[d+4>>2],Va(l,f,h),Ha(h,l),Ua(f,l),Wa(h,f)|0){o=m+4|0,s=t+4|0;do{if(Ga(p,h),Ka(m,e,p),n=a[m>>2]|0,(n|0)!=(a[o>>2]|0)){i=a[s>>2]|0;do jn(n,i),n=(a[m>>2]|0)+44|0,a[m>>2]=n,i=i+44|0,a[s>>2]=i,(i-(a[r>>2]|0)|0)==4092&&(r=r+4|0,a[t>>2]=r,i=a[r>>2]|0,a[s>>2]=i);while((n|0)!=(a[o>>2]|0))}qa(m),Ja(h)|0}while(Wa(h,f)|0)}P=g}function Ra(e){e|=0;var t=0,n=0,r=0;t=a[e+4>>2]|0,n=e+8|0,r=a[n>>2]|0,(r|0)!=(t|0)&&(a[n>>2]=r+(~((r+-4-t|0)>>>2)<<2)),t=a[e>>2]|0,t|0&&ge(t,(a[e+12>>2]|0)-t|0)}function za(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0;D=P,P=P+64|0,x=D+52|0,b=D+48|0,S=D+28|0,C=D+24|0,w=D+20|0,g=D,T=e+8|0,n=a[T>>2]|0,E=e+4|0,l=a[E>>2]|0,v=((n|0)==(l|0)&1)+t|0,s=(v>>>0)/93|0,s=s+((v-(s*93|0)|0)!=0&1)|0,v=e+16|0,r=a[v>>2]|0,c=(r>>>0)/93|0,_=s>>>0<c>>>0?s:c,t=s-_|0,o=n;a:do if(!t){if(a[v>>2]=(u(_,-93)|0)+r,_|0)for(c=e+12|0,d=e+12|0,f=S+4|0,p=S+8|0,m=S+12|0,t=_,r=l;;){s=a[r>>2]|0,o=r+4|0,a[E>>2]=o,y=a[c>>2]|0,r=y;do if((n|0)==(y|0)){if(y=a[e>>2]|0,n=y,o>>>0<=y>>>0){n=r-n|0,n=n|0?n>>1:1,Za(S,n,n>>>2,d),a[C>>2]=a[E>>2],a[w>>2]=a[T>>2],a[b>>2]=a[C>>2],a[x>>2]=a[w>>2],to(S,b,x),n=a[e>>2]|0,a[e>>2]=a[S>>2],a[S>>2]=n,n=a[E>>2]|0,a[E>>2]=a[f>>2],a[f>>2]=n,n=a[T>>2]|0,a[T>>2]=a[p>>2],a[p>>2]=n,n=a[c>>2]|0,a[c>>2]=a[m>>2],a[m>>2]=n,eo(S),n=a[T>>2]|0;break}y=o,n=((y-n>>2)+1|0)/-2|0,i=o+(n<<2)|0,r=r-y|0,r?(Kg(i|0,o|0,r|0)|0,n=(a[E>>2]|0)+(n<<2)|0):n=i,y=i+(r>>2<<2)|0,a[T>>2]=y,a[E>>2]=n,n=y}while(0);if(a[n>>2]=s,n=(a[T>>2]|0)+4|0,a[T>>2]=n,t=t+-1|0,!t)break a;r=a[E>>2]|0}}else if(y=e+12|0,r=a[y>>2]|0,i=r-(a[e>>2]|0)|0,n=o-l>>2,t>>>0>((i>>2)-n|0)>>>0){h=i>>1,m=n+t|0,Za(g,h>>>0<m>>>0?m:h,n-_|0,e+12|0);do a[x>>2]=J(4092)|0,Qa(g,x),t=t+-1|0;while(t|0);if(!_)n=a[E>>2]|0;else{c=g+8|0,l=g+12|0,d=g+4|0,f=g+16|0,p=S+4|0,m=S+8|0,h=S+12|0,s=_,t=a[c>>2]|0,n=a[E>>2]|0;do{o=a[l>>2]|0,r=o;do if((t|0)==(o|0)){if(i=a[d>>2]|0,o=a[g>>2]|0,t=o,i>>>0<=o>>>0){t=r-t|0,t=t|0?t>>1:1,Za(S,t,t>>>2,a[f>>2]|0),a[C>>2]=a[d>>2],a[w>>2]=a[c>>2],a[b>>2]=a[C>>2],a[x>>2]=a[w>>2],to(S,b,x),t=a[g>>2]|0,a[g>>2]=a[S>>2],a[S>>2]=t,t=a[d>>2]|0,a[d>>2]=a[p>>2],a[p>>2]=t,t=a[c>>2]|0,a[c>>2]=a[m>>2],a[m>>2]=t,t=a[l>>2]|0,a[l>>2]=a[h>>2],a[h>>2]=t,eo(S),t=a[c>>2]|0;break}O=i,t=((O-t>>2)+1|0)/-2|0,o=i+(t<<2)|0,r=r-O|0,r?(Kg(o|0,i|0,r|0)|0,t=(a[d>>2]|0)+(t<<2)|0):t=o,O=o+(r>>2<<2)|0,a[c>>2]=O,a[d>>2]=t,t=O}while(0);a[t>>2]=a[n>>2],t=(a[c>>2]|0)+4|0,a[c>>2]=t,n=(a[E>>2]|0)+4|0,a[E>>2]=n,s=s+-1|0}while(s|0)}if(t=a[T>>2]|0,(t|0)!=(n|0)){do t=t+-4|0,$a(g,t),n=a[E>>2]|0;while((t|0)!=(n|0));t=a[T>>2]|0}O=a[e>>2]|0,a[e>>2]=a[g>>2],a[g>>2]=O,O=g+4|0,a[E>>2]=a[O>>2],a[O>>2]=n,O=g+8|0,a[T>>2]=a[O>>2],a[O>>2]=t,O=g+12|0,E=a[y>>2]|0,a[y>>2]=a[O>>2],a[O>>2]=E,a[v>>2]=(a[v>>2]|0)+(u(_,-93)|0),eo(g);break}else{b:do if((r|0)==(o|0))d=18;else{for(;a[x>>2]=J(4092)|0,Ya(e,x),t=t+-1|0,t;)if((a[y>>2]|0)==(a[T>>2]|0)){d=18;break b}n=_,t=a[v>>2]|0}while(0);if((d|0)==18){r=~(s>>>0>c>>>0?c:s),n=t;do a[x>>2]=J(4092)|0,Xa(e,x),n=n+-1|0,i=(((a[T>>2]|0)-(a[E>>2]|0)|0)==4?92:93)+(a[v>>2]|0)|0,a[v>>2]=i;while(n|0);n=t+-1-r|0,t=i}if(a[v>>2]=t+(u(n,-93)|0),!n)break;c=e+12|0,l=S+4|0,d=S+8|0,f=S+12|0,t=a[T>>2]|0;do{o=a[E>>2]|0,s=a[o>>2]|0,o=o+4|0,a[E>>2]=o,O=a[y>>2]|0,r=O;do if((t|0)==(O|0)){if(O=a[e>>2]|0,t=O,o>>>0<=O>>>0){t=r-t|0,t=t|0?t>>1:1,Za(S,t,t>>>2,c),a[C>>2]=a[E>>2],a[w>>2]=a[T>>2],a[b>>2]=a[C>>2],a[x>>2]=a[w>>2],to(S,b,x),t=a[e>>2]|0,a[e>>2]=a[S>>2],a[S>>2]=t,t=a[E>>2]|0,a[E>>2]=a[l>>2],a[l>>2]=t,t=a[T>>2]|0,a[T>>2]=a[d>>2],a[d>>2]=t,t=a[y>>2]|0,a[y>>2]=a[f>>2],a[f>>2]=t,eo(S),t=a[T>>2]|0;break}O=o,t=((O-t>>2)+1|0)/-2|0,i=o+(t<<2)|0,r=r-O|0,r?(Kg(i|0,o|0,r|0)|0,t=(a[E>>2]|0)+(t<<2)|0):t=i,O=i+(r>>2<<2)|0,a[T>>2]=O,a[E>>2]=t,t=O}while(0);a[t>>2]=s,t=(a[T>>2]|0)+4|0,a[T>>2]=t,n=n+-1|0}while(n|0)}while(0);P=D}function Ba(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;n=(a[t+16>>2]|0)+(a[t+20>>2]|0)|0,o=a[t+4>>2]|0,r=(n>>>0)/93|0,i=o+(r<<2)|0,t=(a[t+8>>2]|0)==(o|0)?0:(a[i>>2]|0)+((n-(r*93|0)|0)*44|0)|0,a[e>>2]=i,a[e+4>>2]=t}function Va(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;i=t,t=a[i+4>>2]|0,r=e,a[r>>2]=a[i>>2],a[r+4>>2]=t,r=n,t=a[r+4>>2]|0,n=e+8|0,a[n>>2]=a[r>>2],a[n+4>>2]=t}function Ha(e,t){e|=0,t|=0,a[e>>2]=a[t>>2],a[e+4>>2]=a[t+4>>2],a[e+8>>2]=a[t+8>>2],a[e+12>>2]=a[t+12>>2]}function Ua(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0;n=P,P=P+32|0,r=n+24|0,i=n+16|0,s=n+8|0,o=n,c=t+8|0,l=a[c>>2]|0,c=a[c+4>>2]|0,t=s,a[t>>2]=l,a[t+4>>2]=c,t=o,a[t>>2]=l,a[t+4>>2]=c,a[i>>2]=a[s>>2],a[i+4>>2]=a[s+4>>2],a[r>>2]=a[o>>2],a[r+4>>2]=a[o+4>>2],Va(e,i,r),P=n}function Wa(e,t){return e|=0,t|=0,(io(e,t)|0)^1|0}function Ga(e,t){e|=0,t|=0;var n=0,r=0;n=a[t>>2]|0,r=a[t+4>>2]|0,(n|0)==(a[t+8>>2]|0)?ao(e,r,a[t+12>>2]|0):ao(e,r,(a[n>>2]|0)+4092|0)}function Ka(e,t,n){e|=0,t|=0,n|=0;var r=0;r=a[n>>2]|0,a[e>>2]=r,a[e+4>>2]=a[n+4>>2],a[e+8>>2]=r,a[e+12>>2]=t}function qa(e){e|=0;var t=0;t=(a[e+12>>2]|0)+20|0,a[t>>2]=(a[t>>2]|0)+(((a[e>>2]|0)-(a[e+8>>2]|0)|0)/44|0)}function Ja(e){e|=0;var t=0,n=0,r=0;return t=a[e>>2]|0,n=e+8|0,(t|0)==(a[n>>2]|0)?(r=n,t=a[r+4>>2]|0,n=e,a[n>>2]=a[r>>2],a[n+4>>2]=t):(r=t+4|0,a[e>>2]=r,a[e+4>>2]=a[r>>2]),e|0}function Ya(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;h=P,P=P+48|0,i=h+32|0,r=h+28|0,c=h+8|0,l=h+4|0,u=h,m=e+8|0,n=a[m>>2]|0,d=e+12|0,p=a[d>>2]|0,o=p;do if((n|0)==(p|0)){if(p=e+4|0,f=a[p>>2]|0,g=a[e>>2]|0,s=g,f>>>0<=g>>>0){n=o-s|0,n=n|0?n>>1:1,Za(c,n,n>>>2,e+12|0),a[l>>2]=a[p>>2],a[u>>2]=a[m>>2],a[r>>2]=a[l>>2],a[i>>2]=a[u>>2],to(c,r,i),n=a[e>>2]|0,a[e>>2]=a[c>>2],a[c>>2]=n,n=c+4|0,g=a[p>>2]|0,a[p>>2]=a[n>>2],a[n>>2]=g,n=c+8|0,g=a[m>>2]|0,a[m>>2]=a[n>>2],a[n>>2]=g,n=c+12|0,g=a[d>>2]|0,a[d>>2]=a[n>>2],a[n>>2]=g,eo(c),n=a[m>>2]|0;break}i=f,r=((i-s>>2)+1|0)/-2|0,e=f+(r<<2)|0,i=n-i|0,i?(Kg(e|0,f|0,i|0)|0,n=(a[p>>2]|0)+(r<<2)|0):n=e,g=e+(i>>2<<2)|0,a[m>>2]=g,a[p>>2]=n,n=g}while(0);a[n>>2]=a[t>>2],a[m>>2]=(a[m>>2]|0)+4,P=h}function Xa(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;h=P,P=P+48|0,r=h+32|0,n=h+28|0,s=h+8|0,c=h+4|0,l=h,m=e+4|0,f=a[m>>2]|0,p=a[e>>2]|0,u=p;do if((f|0)==(p|0)){if(p=e+8|0,d=a[p>>2]|0,o=e+12|0,g=a[o>>2]|0,i=g,d>>>0>=g>>>0){g=i-u|0,g=g|0?g>>1:1,Za(s,g,(g+3|0)>>>2,e+12|0),a[c>>2]=a[m>>2],a[l>>2]=a[p>>2],a[n>>2]=a[c>>2],a[r>>2]=a[l>>2],to(s,n,r),n=a[e>>2]|0,a[e>>2]=a[s>>2],a[s>>2]=n,n=s+4|0,g=a[m>>2]|0,a[m>>2]=a[n>>2],a[n>>2]=g,n=s+8|0,g=a[p>>2]|0,a[p>>2]=a[n>>2],a[n>>2]=g,n=s+12|0,g=a[o>>2]|0,a[o>>2]=a[n>>2],a[n>>2]=g,eo(s),n=a[m>>2]|0;break}r=d,e=((i-r>>2)+1|0)/2|0,i=d+(e<<2)|0,r=r-f|0,n=i+(0-(r>>2)<<2)|0,r?(Kg(n|0,f|0,r|0)|0,r=(a[p>>2]|0)+(e<<2)|0):(n=i,r=i),a[m>>2]=n,a[p>>2]=r}else n=f;while(0);a[n+-4>>2]=a[t>>2],a[m>>2]=(a[m>>2]|0)+-4,P=h}function Za(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0;i=e+12|0,a[i>>2]=0,a[e+16>>2]=r;do if(t)if(t>>>0>1073741823)i=h(8)|0,Kh(i,6723),a[i>>2]=5956,g(i|0,3928,123);else{r=J(t<<2)|0;break}else r=0;while(0);a[e>>2]=r,n=r+(n<<2)|0,a[e+8>>2]=n,a[e+4>>2]=n,a[i>>2]=r+(t<<2)}function Qa(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;h=P,P=P+48|0,i=h+32|0,r=h+28|0,c=h+8|0,l=h+4|0,u=h,m=e+8|0,n=a[m>>2]|0,d=e+12|0,p=a[d>>2]|0,o=p;do if((n|0)==(p|0)){if(p=e+4|0,f=a[p>>2]|0,g=a[e>>2]|0,s=g,f>>>0<=g>>>0){n=o-s|0,n=n|0?n>>1:1,Za(c,n,n>>>2,a[e+16>>2]|0),a[l>>2]=a[p>>2],a[u>>2]=a[m>>2],a[r>>2]=a[l>>2],a[i>>2]=a[u>>2],to(c,r,i),n=a[e>>2]|0,a[e>>2]=a[c>>2],a[c>>2]=n,n=c+4|0,g=a[p>>2]|0,a[p>>2]=a[n>>2],a[n>>2]=g,n=c+8|0,g=a[m>>2]|0,a[m>>2]=a[n>>2],a[n>>2]=g,n=c+12|0,g=a[d>>2]|0,a[d>>2]=a[n>>2],a[n>>2]=g,eo(c),n=a[m>>2]|0;break}i=f,r=((i-s>>2)+1|0)/-2|0,e=f+(r<<2)|0,i=n-i|0,i?(Kg(e|0,f|0,i|0)|0,n=(a[p>>2]|0)+(r<<2)|0):n=e,g=e+(i>>2<<2)|0,a[m>>2]=g,a[p>>2]=n,n=g}while(0);a[n>>2]=a[t>>2],a[m>>2]=(a[m>>2]|0)+4,P=h}function $a(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;h=P,P=P+48|0,r=h+32|0,n=h+28|0,s=h+8|0,c=h+4|0,l=h,m=e+4|0,f=a[m>>2]|0,p=a[e>>2]|0,u=p;do if((f|0)==(p|0)){if(p=e+8|0,d=a[p>>2]|0,o=e+12|0,g=a[o>>2]|0,i=g,d>>>0>=g>>>0){g=i-u|0,g=g|0?g>>1:1,Za(s,g,(g+3|0)>>>2,a[e+16>>2]|0),a[c>>2]=a[m>>2],a[l>>2]=a[p>>2],a[n>>2]=a[c>>2],a[r>>2]=a[l>>2],to(s,n,r),n=a[e>>2]|0,a[e>>2]=a[s>>2],a[s>>2]=n,n=s+4|0,g=a[m>>2]|0,a[m>>2]=a[n>>2],a[n>>2]=g,n=s+8|0,g=a[p>>2]|0,a[p>>2]=a[n>>2],a[n>>2]=g,n=s+12|0,g=a[o>>2]|0,a[o>>2]=a[n>>2],a[n>>2]=g,eo(s),n=a[m>>2]|0;break}r=d,e=((i-r>>2)+1|0)/2|0,i=d+(e<<2)|0,r=r-f|0,n=i+(0-(r>>2)<<2)|0,r?(Kg(n|0,f|0,r|0)|0,r=(a[p>>2]|0)+(e<<2)|0):(n=i,r=i),a[m>>2]=n,a[p>>2]=r}else n=f;while(0);a[n+-4>>2]=a[t>>2],a[m>>2]=(a[m>>2]|0)+-4,P=h}function eo(e){e|=0;var t=0,n=0,r=0;t=a[e+4>>2]|0,n=e+8|0,r=a[n>>2]|0,(r|0)!=(t|0)&&(a[n>>2]=r+(~((r+-4-t|0)>>>2)<<2)),t=a[e>>2]|0,t|0&&ge(t,(a[e+12>>2]|0)-t|0)}function to(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0;if(s=P,P=P+16|0,o=s,i=a[t>>2]|0,no(o,e+8|0,(a[n>>2]|0)-i>>2),e=a[o>>2]|0,r=o+4|0,(e|0)!=(a[r>>2]|0)){n=i;do a[e>>2]=a[n>>2],e=(a[o>>2]|0)+4|0,a[o>>2]=e,n=n+4|0;while((e|0)!=(a[r>>2]|0));a[t>>2]=n}ro(o),P=s}function no(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=a[t>>2],a[e+4>>2]=(a[t>>2]|0)+(n<<2),a[e+8>>2]=t}function ro(e){e|=0,a[a[e+8>>2]>>2]=a[e>>2]}function io(e,t){return e|=0,t|=0,(a[e+4>>2]|0)==(a[t+4>>2]|0)|0}function ao(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,a[e+4>>2]=n}function oo(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;o=a[t+4>>2]|0,n=a[t+16>>2]|0,r=(n>>>0)/93|0,i=o+(r<<2)|0,t=(a[t+8>>2]|0)==(o|0)?0:(a[i>>2]|0)+((n-(r*93|0)|0)*44|0)|0,a[e>>2]=i,a[e+4>>2]=t}function so(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;n=(a[t+16>>2]|0)+(a[t+20>>2]|0)|0,o=a[t+4>>2]|0,r=(n>>>0)/93|0,i=o+(r<<2)|0,t=(a[t+8>>2]|0)==(o|0)?0:(a[i>>2]|0)+((n-(r*93|0)|0)*44|0)|0,a[e>>2]=i,a[e+4>>2]=t}function co(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0;if(c=P,P=P+16|0,r=c+8|0,o=c,lo(r,e),Ba(o,e),i=r+4|0,t=a[i>>2]|0,o=o+4|0,(t|0)!=(a[o>>2]|0))do _n(t),t=(a[i>>2]|0)+44|0,a[i>>2]=t,n=a[r>>2]|0,(t-(a[n>>2]|0)|0)==4092&&(t=n+4|0,a[r>>2]=t,t=a[t>>2]|0,a[i>>2]=t);while((t|0)!=(a[o>>2]|0));if(a[e+20>>2]=0,i=e+8|0,r=e+4|0,n=a[r>>2]|0,t=(a[i>>2]|0)-n>>2,t>>>0>2)do ge(a[n>>2]|0,4092),n=(a[r>>2]|0)+4|0,a[r>>2]=n,t=(a[i>>2]|0)-n>>2;while(t>>>0>2);switch(t|0){case 1:t=46,s=11;break;case 2:t=93,s=11;break;default:}(s|0)==11&&(a[e+16>>2]=t),P=c}function lo(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;o=a[t+4>>2]|0,n=a[t+16>>2]|0,r=(n>>>0)/93|0,i=o+(r<<2)|0,t=(a[t+8>>2]|0)==(o|0)?0:(a[i>>2]|0)+((n-(r*93|0)|0)*44|0)|0,a[e>>2]=i,a[e+4>>2]=t}function uo(e,t,n){e|=0,t|=0,n|=0;var i=0,s=0,c=0,l=0,u=0,d=0,f=0;if(f=P,P=P+16|0,d=f,l=e+4|0,!(r[l>>0]|0)){if(d=fi(t)|0,pi(d,n,a[e>>2]|0),d=a[e>>2]|0,c=n+d|0,!d)i=0;else{for(i=n,s=a[e+8>>2]|0;r[s>>0]=r[i>>0]|0,i=i+1|0,(i|0)!=(c|0);)s=s+1|0;i=a[e>>2]|0}r[l>>0]=1,n=n+i|0}else if(s=a[e+20>>2]|0,i=a[e+8>>2]|0,lo(d,e+32|0),e=e+12|0,(i|0)!=(a[e>>2]|0))for(u=d+4|0,l=i,c=s,i=a[u>>2]|0;s=o[l>>0]|0,s=fo((Pn(t,i)|0)+s|0)|0,r[c>>0]=s,r[n>>0]=s,r[l>>0]=s,l=l+1|0,n=n+1|0,s=a[d>>2]|0,i=(a[u>>2]|0)+44|0,a[u>>2]=i,(i-(a[s>>2]|0)|0)==4092&&(i=s+4|0,a[d>>2]=i,i=a[i>>2]|0,a[u>>2]=i),(l|0)!=(a[e>>2]|0);)c=c+1|0;return P=f,n|0}function fo(e){return e|=0,e&255|0}function po(e){e|=0,Bh(e),G(e)}function mo(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function ho(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==11262?e+12|0:0)|0}function go(e){e|=0,ge(e,16)}function _o(e,t){e|=0,t|=0,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,t|0&&(ja(e,t),yo(e,t))}function vo(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,a[e+12>>2]=0,a[e+16>>2]=0,a[e+20>>2]=0,t|0&&bo(e,t,n)}function yo(e,t){e|=0,t|=0;var n=0,i=0,o=0;if(o=P,P=P+16|0,i=o,Fa(i,e,t),t=i+4|0,e=a[t>>2]|0,n=i+8|0,(e|0)!=(a[n>>2]|0))do r[e>>0]=0,e=(a[t>>2]|0)+1|0,a[t>>2]=e;while((e|0)!=(a[n>>2]|0));Ia(i),P=o}function bo(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;if(m=P,P=P+96|0,p=m+80|0,u=m+64|0,s=m+48|0,c=m+40|0,l=m+8|0,i=m,d=m+32|0,f=m+16|0,r=(a[e+8>>2]|0)-(a[e+4>>2]|0)|0,r=(r|0?((r>>2)*93|0)+-1|0:0)-((a[e+20>>2]|0)+(a[e+16>>2]|0))|0,r>>>0<t>>>0&&za(e,t-r|0),Ba(c,e),Ba(i,e),r=a[i>>2]|0,i=a[i+4>>2]|0,o=l,a[o>>2]=r,a[o+4>>2]=i,o=r,t|0&&(r=((i-(a[r>>2]|0)|0)/44|0)+t|0,(r|0)>0?(t=(r>>>0)/93|0,o=o+(t<<2)|0,a[l>>2]=o,r=(a[o>>2]|0)+((r-(t*93|0)|0)*44|0)|0):(r=92-r|0,t=o+(((r|0)/-93|0)<<2)|0,a[l>>2]=t,r=(a[t>>2]|0)+((92-((r|0)%93|0)|0)*44|0)|0),a[l+4>>2]=r),a[u>>2]=a[c>>2],a[u+4>>2]=a[c+4>>2],a[p>>2]=a[l>>2],a[p+4>>2]=a[l+4>>2],Va(s,u,p),Ha(p,s),Ua(u,s),Wa(p,u)|0){i=f+4|0;do{if(Ga(d,p),Ka(f,e,d),r=a[f>>2]|0,(r|0)!=(a[i>>2]|0))do jn(r,n),r=(a[f>>2]|0)+44|0,a[f>>2]=r;while((r|0)!=(a[i>>2]|0));qa(f),Ja(p)|0}while(Wa(p,u)|0)}P=m}function xo(e){e|=0;var t=0,n=0;if(co(e),t=a[e+4>>2]|0,n=a[e+8>>2]|0,(t|0)!=(n|0))do ge(a[t>>2]|0,4092),t=t+4|0;while((t|0)!=(n|0));Ra(e)}function So(e,t,n){e|=0,t|=0,n|=0,xr(e),a[e>>2]=4924,a[e+4>>2]=t,a[e+8>>2]=n}function Co(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4944,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Ao(e,r),P=n}function wo(e,t){return e|=0,t|=0,Do(a[e+8>>2]|0,a[e+4>>2]|0,t)|0}function To(e){e|=0;var t=0,n=0;a[e>>2]=4924,n=e+8|0,t=a[n>>2]|0,a[n>>2]=0,t|0&&(ko(t),G(t)),Tr(e)}function Eo(e){e|=0,To(e),G(e)}function Do(e,t,n){return e|=0,t|=0,n|=0,Oo(e+4784|0,t,ui(e,t,n)|0)|0}function Oo(e,t,n){return e|=0,t|=0,n|=0,r[e>>0]|0&&(Yt(t),r[e>>0]=0),n|0}function ko(e){e|=0,ci(e)}function Ao(e,t){e|=0,t|=0}function jo(e){e|=0,Bh(e),G(e)}function Mo(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+8>>2]&255](e)}function No(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==12004?e+12|0:0)|0}function Po(e){e|=0,ge(e,16)}function Fo(e){e|=0,r[e>>0]=1}function Io(e,t,n){e|=0,t|=0,n|=0,xr(e),a[e>>2]=4972,a[e+4>>2]=t,a[e+8>>2]=n}function Lo(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=4992,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Ao(e,r),P=n}function Ro(e,t){return e|=0,t|=0,Vo(a[e+8>>2]|0,a[e+4>>2]|0,t)|0}function zo(e){e|=0;var t=0,n=0;a[e>>2]=4972,n=e+8|0,t=a[n>>2]|0,a[n>>2]=0,t|0&&(Uo(t),G(t)),Tr(e)}function Bo(e){e|=0,zo(e),G(e)}function Vo(e,t,n){return e|=0,t|=0,n|=0,Ho(e+4784|0,t,ui(e,t,n)|0)|0}function Ho(e,t,n){return e|=0,t|=0,n|=0,Oo(e+328|0,t,Qi(e,t,n)|0)|0}function Uo(e){e|=0,Wo(e+4784|0),ci(e)}function Wo(e){e|=0,Xi(e)}function Go(e){e|=0,Bh(e),G(e)}function Ko(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+8>>2]&255](e)}function qo(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==12827?e+12|0:0)|0}function Jo(e){e|=0,ge(e,16)}function Yo(e){e|=0,zi(e),Fo(e+328|0)}function Xo(e,t,n){e|=0,t|=0,n|=0,xr(e),a[e>>2]=5020,a[e+4>>2]=t,a[e+8>>2]=n}function Zo(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5040,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Ao(e,r),P=n}function Qo(e,t){return e|=0,t|=0,ts(a[e+8>>2]|0,a[e+4>>2]|0,t)|0}function $o(e){e|=0;var t=0,n=0;a[e>>2]=5020,n=e+8|0,t=a[n>>2]|0,a[n>>2]=0,t|0&&(rs(t),G(t)),Tr(e)}function es(e){e|=0,$o(e),G(e)}function ts(e,t,n){return e|=0,t|=0,n|=0,ns(e+4784|0,t,ui(e,t,n)|0)|0}function ns(e,t,n){return e|=0,t|=0,n|=0,Oo(e+316|0,t,ga(e,t,n)|0)|0}function rs(e){e|=0,is(e+4784|0),ci(e)}function is(e){e|=0,ha(e)}function as(e){e|=0,Bh(e),G(e)}function os(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+8>>2]&255](e)}function ss(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==13672?e+12|0:0)|0}function cs(e){e|=0,ge(e,16)}function ls(e){e|=0,ua(e),Fo(e+316|0)}function us(e,t,n){e|=0,t|=0,n|=0,xr(e),a[e>>2]=5068,a[e+4>>2]=t,a[e+8>>2]=n}function ds(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5088,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Ao(e,r),P=n}function fs(e,t){return e|=0,t|=0,hs(a[e+8>>2]|0,a[e+4>>2]|0,t)|0}function ps(e){e|=0;var t=0,n=0;a[e>>2]=5068,n=e+8|0,t=a[n>>2]|0,a[n>>2]=0,t|0&&(_s(t),G(t)),Tr(e)}function ms(e){e|=0,ps(e),G(e)}function hs(e,t,n){return e|=0,t|=0,n|=0,gs(e+4784|0,t,ui(e,t,n)|0)|0}function gs(e,t,n){return e|=0,t|=0,n|=0,ns(e+328|0,t,Qi(e,t,n)|0)|0}function _s(e){e|=0,vs(e+4784|0),ci(e)}function vs(e){e|=0,is(e+328|0),Xi(e)}function ys(e){e|=0,Bh(e),G(e)}function bs(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+8>>2]&255](e)}function xs(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==14573?e+12|0:0)|0}function Ss(e){e|=0,ge(e,16)}function Cs(e){e|=0,zi(e),ls(e+328|0)}function ws(e){return e|=0,e+20|0}function Ts(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=t,a[e+4>>2]=n,a[e+8>>2]=0}function Es(e,t){e|=0,t|=0,a[e>>2]=t,a[e+4>>2]=0,a[e+8>>2]=-1}function Ds(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;n=P,P=P+16|0,r=n+4|0,o=n,i=J(24)|0,Ws(i,t),a[o>>2]=0,a[r>>2]=a[o>>2],Gs(e,i,r),P=n}function Os(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function ks(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5116,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,js(e,r),P=n}function As(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function js(e,t){e|=0,t|=0}function Ms(e){e|=0,Bh(e),G(e)}function Ns(e){e|=0,e=a[e+12>>2]|0,e|0&&G(e)}function Ps(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==14966?e+12|0:0)|0}function Fs(e){e|=0,ge(e,16)}function Is(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5144,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Rs(e,r),P=n}function Ls(e){e|=0;var t=0,n=0;e=a[e+4>>2]|0,e|0&&(n=e+4|0,t=a[n>>2]|0,a[n>>2]=t+-1,!(t|0))&&(C_[a[(a[e>>2]|0)+8>>2]&255](e),Vh(e))}function Rs(e,t){e|=0,t|=0}function zs(e){e|=0,Bh(e),G(e)}function Bs(e){e|=0,e=a[e+12>>2]|0,e|0&&(Us(e),G(e))}function Vs(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==15127?e+12|0:0)|0}function Hs(e){e|=0,ge(e,16)}function Us(e){e|=0}function Ws(e,t){e|=0,t|=0,xr(e),a[e>>2]=5172,a[e+4>>2]=t,a[e+8>>2]=0,a[e+12>>2]=0,a[e+16>>2]=0,r[e+20>>0]=1}function Gs(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5192,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Zs(e,r),P=n}function Ks(e,t){e|=0,t|=0;var n=0,i=0,o=0,s=0,c=0,l=0,u=0;if(u=P,P=P+16|0,s=u,n=a[e+8>>2]|0,c=a[e+12>>2]|0,(n|0)!=(c|0)){l=s+4|0;do i=a[n>>2]|0,a[s>>2]=i,o=a[n+4>>2]|0,a[l>>2]=o,o|0&&(o=o+4|0,a[o>>2]=(a[o>>2]|0)+1),t=b_[a[(a[i>>2]|0)+12>>2]&63](i,t)|0,Dr(s),n=n+8|0;while((n|0)!=(c|0))}return n=e+20|0,r[n>>0]|0&&(r[n>>0]=0,Ys(a[e+4>>2]|0)),P=u,t|0}function qs(e){e|=0,a[e>>2]=5172,Or(e+8|0),Tr(e)}function Js(e){e|=0,qs(e),G(e)}function Ys(e){e|=0;var t=0;t=((Xs(a[e>>2]|0)|0)&255)<<24,t=((Xs(a[e>>2]|0)|0)&255)<<16|t,t|=((Xs(a[e>>2]|0)|0)&255)<<8,a[e+4>>2]=t|(Xs(a[e>>2]|0)|0)&255}function Xs(e){e|=0;var t=0,n=0;return t=a[e>>2]|0,n=e+8|0,e=a[n>>2]|0,a[n>>2]=e+1,r[t+e>>0]|0}function Zs(e,t){e|=0,t|=0}function Qs(e){e|=0,Bh(e),G(e)}function $s(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+8>>2]&255](e)}function ec(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==15450?e+12|0:0)|0}function tc(e){e|=0,ge(e,16)}function nc(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(180)|0,ic(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],ac(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function rc(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(180)|0,Oc(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],kc(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function ic(e,t){e|=0,t|=0,Hr(e),a[e>>2]=5220,a[e+4>>2]=t,oc(e+8|0)}function ac(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5244,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function oc(e){e|=0,oi(e,32,1,8,0),Jt(e+80|0,32,1,8,0),r[e+160>>0]=0,r[e+161>>0]=0,uc(e+164|0)}function sc(e){e|=0,a[e>>2]=5220,dc(e+8|0),Jr(e)}function cc(e){e|=0,sc(e),G(e)}function lc(e,t){return e|=0,t|=0,fc(e+8|0,a[e+4>>2]|0,t)|0}function uc(e){e|=0,r[e+4>>0]=0}function dc(e){e|=0,Qt(e+80|0),si(e)}function fc(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0;return s=P,P=P+16|0,i=s,r[e+161>>0]|0||Xt(e+80|0),o=e+164|0,pc(o)|0?(t=mc(e+80|0,t,a[o>>2]|0,0)|0,a[i>>2]=t,Di(t,n)):(gc(hc(t)|0,n,4),a[i>>2]=Si(n)|0),_c(o,i),P=s,n+4|0}function pc(e){return e|=0,(r[e+4>>0]|0)!=0|0}function mc(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,n=(vc(e,t,(a[e+36>>2]|0)+(r*44|0)|0)|0)+n|0,t=a[e+24>>2]|0,(n|0)<0?n+t|0:n-(n>>>0<t>>>0?0:t)|0}function hc(e){return e|=0,a[e>>2]|0}function gc(e,t,n){e|=0,t|=0,n|=0;var i=0;if((n|0)>0){i=0;do r[t+i>>0]=Xs(e)|0,i=i+1|0;while((i|0)!=(n|0))}}function _c(e,t){e|=0,t|=0;var n=0;n=e+4|0,r[n>>0]|0||(r[n>>0]=1),a[e>>2]=a[t>>2]}function vc(e,t,n){e|=0,t|=0,n|=0;var r=0;n=yc(t,n)|0,a[e>>2]=n;do if(n){if(n>>>0>=32){n=a[e+28>>2]|0;break}if(r=a[e+12>>2]|0,n>>>0>r>>>0?(r=n-r|0,n=yc(t,(a[e+68>>2]|0)+((n+-1|0)*44|0)|0)|0,r=n<<r|bc(t,r)|0):r=yc(t,(a[e+68>>2]|0)+((n+-1|0)*44|0)|0)|0,n=a[e>>2]|0,(r|0)<(1<<n+-1|0)){n=r+1+(-1<<n)|0;break}else{n=r+1|0;break}}else n=xc(t,e+48|0)|0;while(0);return n|0}function yc(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,d=0,f=0,p=0,m=0,h=0;if(m=e+8|0,p=a[m>>2]|0,i=a[t+16>>2]|0,i){if(r=e+4|0,n=a[r>>2]|0,f=p>>>15,a[m>>2]=f,l=(n>>>0)/(f>>>0)|0,c=l>>>(a[t+40>>2]|0),o=a[i+(c<<2)>>2]|0,c=(a[i+(c+1<<2)>>2]|0)+1|0,s=o+1|0,d=a[t+8>>2]|0,c>>>0>s>>>0){i=o,o=c;do s=(o+i|0)>>>1,c=(a[d+(s<<2)>>2]|0)>>>0>l>>>0,i=c?i:s,o=c?s:o,s=i+1|0;while(o>>>0>s>>>0);o=i}i=u(a[d+(o<<2)>>2]|0,f)|0,s=(o|0)==(a[t+32>>2]|0)?p:u(a[d+(s<<2)>>2]|0,f)|0}else{d=p>>>15,a[m>>2]=d,c=a[t>>2]|0,f=a[t+8>>2]|0,r=e+4|0,n=a[r>>2]|0,l=c>>>1,i=0,s=p,o=0;do h=u(a[f+(l<<2)>>2]|0,d)|0,p=h>>>0>n>>>0,s=p?h:s,i=p?i:h,o=p?o:l,c=p?l:c,l=(o+c|0)>>>1;while((l|0)!=(o|0))}return a[r>>2]=n-i,h=s-i|0,a[m>>2]=h,h>>>0<16777216&&Sc(e),m=(a[t+12>>2]|0)+(o<<2)|0,a[m>>2]=(a[m>>2]|0)+1,m=t+28|0,h=(a[m>>2]|0)+-1|0,a[m>>2]=h,h||Mn(t),o|0}function bc(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return t>>>0>19?(n=(Cc(e)|0)&65535,(bc(e,t+-16|0)|0)<<16|n|0):(r=e+4|0,i=a[r>>2]|0,o=e+8|0,n=(a[o>>2]|0)>>>t,a[o>>2]=n,t=(i>>>0)/(n>>>0)|0,a[r>>2]=i-(u(t,n)|0),n>>>0<16777216&&Sc(e),t|0)}function xc(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0;return r=e+8|0,i=a[r>>2]|0,n=u(i>>>13,a[t+8>>2]|0)|0,o=e+4|0,s=a[o>>2]|0,c=s>>>0>=n>>>0,c?(a[o>>2]=s-n,n=i-n|0,a[r>>2]=n):(a[r>>2]=n,s=t+12|0,a[s>>2]=(a[s>>2]|0)+1),n>>>0<16777216&&Sc(e),s=t+4|0,e=(a[s>>2]|0)+-1|0,a[s>>2]=e,e||zn(t),c&1|0}function Sc(e){e|=0;var t=0,n=0,r=0,i=0;t=e+4|0,n=e+8|0,r=a[t>>2]|0;do r=r<<8|(Xs(a[e>>2]|0)|0)&255,a[t>>2]=r,i=a[n>>2]<<8,a[n>>2]=i;while(i>>>0<16777216)}function Cc(e){e|=0;var t=0,n=0,r=0,i=0;return n=e+4|0,i=a[n>>2]|0,t=e+8|0,r=(a[t>>2]|0)>>>16,a[t>>2]=r,t=(i>>>0)/(r>>>0)|0,a[n>>2]=i-(u(t,r)|0),Sc(e),t&65535|0}function wc(e){e|=0,Bh(e),G(e)}function Tc(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function Ec(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==15904?e+12|0:0)|0}function Dc(e){e|=0,ge(e,16)}function Oc(e,t){e|=0,t|=0,Hr(e),a[e>>2]=5272,a[e+4>>2]=t,Ac(e+8|0)}function kc(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5296,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function Ac(e){e|=0,oi(e,32,1,8,0),Jt(e+80|0,32,1,8,0),r[e+160>>0]=0,r[e+161>>0]=0,Pc(e+164|0)}function jc(e){e|=0,a[e>>2]=5272,Fc(e+8|0),Jr(e)}function Mc(e){e|=0,jc(e),G(e)}function Nc(e,t){return e|=0,t|=0,Ic(e+8|0,a[e+4>>2]|0,t)|0}function Pc(e){e|=0,r[e+4>>0]=0}function Fc(e){e|=0,Qt(e+80|0),si(e)}function Ic(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0;return s=P,P=P+16|0,i=s,r[e+161>>0]|0||Xt(e+80|0),o=e+164|0,Lc(o)|0?(t=mc(e+80|0,t,a[o>>2]|0,0)|0,a[i>>2]=t,ji(t,n)):(gc(hc(t)|0,n,4),a[i>>2]=Ei(n)|0),Rc(o,i),P=s,n+4|0}function Lc(e){return e|=0,(r[e+4>>0]|0)!=0|0}function Rc(e,t){e|=0,t|=0;var n=0;n=e+4|0,r[n>>0]|0||(r[n>>0]=1),a[e>>2]=a[t>>2]}function zc(e){e|=0,Bh(e),G(e)}function Bc(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function Vc(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==16402?e+12|0:0)|0}function Hc(e){e|=0,ge(e,16)}function Uc(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(172)|0,Gc(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],Kc(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function Wc(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(176)|0,cl(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],ll(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function Gc(e,t){e|=0,t|=0,Hr(e),a[e>>2]=5324,a[e+4>>2]=t,qc(e+8|0)}function Kc(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5348,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function qc(e){e|=0,oi(e,8,1,8,0),Jt(e+80|0,8,1,8,0),r[e+160>>0]=0,r[e+161>>0]=0,Zc(e+162|0)}function Jc(e){e|=0,a[e>>2]=5324,Qc(e+8|0),Jr(e)}function Yc(e){e|=0,Jc(e),G(e)}function Xc(e,t){return e|=0,t|=0,$c(e+8|0,a[e+4>>2]|0,t)|0}function Zc(e){e|=0,r[e+1>>0]=0}function Qc(e){e|=0,Qt(e+80|0),si(e)}function $c(e,t,n){e|=0,t|=0,n|=0;var i=0,a=0,o=0;return o=P,P=P+16|0,i=o,r[e+161>>0]|0||Xt(e+80|0),a=e+162|0,el(a)|0?(t=(mc(e+80|0,t,r[a>>0]|0,0)|0)&255,r[i>>0]=t,tl(t,n)):(gc(hc(t)|0,n,1),r[i>>0]=nl(n)|0),rl(a,i),P=o,n+1|0}function el(e){return e|=0,(r[e+1>>0]|0)!=0|0}function tl(e,t){e|=0,t|=0,r[t>>0]=e}function nl(e){return e|=0,r[e>>0]|0}function rl(e,t){e|=0,t|=0;var n=0;n=e+1|0,r[n>>0]|0||(r[n>>0]=1),r[e>>0]=r[t>>0]|0}function il(e){e|=0,Bh(e),G(e)}function al(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function ol(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==16900?e+12|0:0)|0}function sl(e){e|=0,ge(e,16)}function cl(e,t){e|=0,t|=0,Hr(e),a[e>>2]=5376,a[e+4>>2]=t,ul(e+8|0)}function ll(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5400,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function ul(e){e|=0,oi(e,16,1,8,0),Jt(e+80|0,16,1,8,0),r[e+160>>0]=0,r[e+161>>0]=0,ml(e+162|0)}function dl(e){e|=0,a[e>>2]=5376,hl(e+8|0),Jr(e)}function fl(e){e|=0,dl(e),G(e)}function pl(e,t){return e|=0,t|=0,gl(e+8|0,a[e+4>>2]|0,t)|0}function ml(e){e|=0,r[e+2>>0]=0}function hl(e){e|=0,Qt(e+80|0),si(e)}function gl(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,s=0;return s=P,P=P+16|0,a=s,r[e+161>>0]|0||Xt(e+80|0),o=e+162|0,_l(o)|0?(t=(mc(e+80|0,t,i[o>>1]|0,0)|0)&65535,i[a>>1]=t,vl(t,n)):(gc(hc(t)|0,n,2),i[a>>1]=yl(n)|0),bl(o,a),P=s,n+2|0}function _l(e){return e|=0,(r[e+2>>0]|0)!=0|0}function vl(e,t){e|=0,t|=0,Oi(e,t)}function yl(e){return e|=0,Ci(e)|0}function bl(e,t){e|=0,t|=0;var n=0;n=e+2|0,r[n>>0]|0||(r[n>>0]=1),i[e>>1]=i[t>>1]|0}function xl(e){e|=0,Bh(e),G(e)}function Sl(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function Cl(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==17398?e+12|0:0)|0}function wl(e){e|=0,ge(e,16)}function Tl(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(172)|0,Dl(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],Ol(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function El(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;l=P,P=P+32|0,r=l+12|0,i=l,t=l+8|0,s=J(176)|0,Hl(s,a[e+4>>2]|0),o=e+8|0,a[t>>2]=0,a[r>>2]=a[t>>2],Ul(i,s,r),s=e+12|0,t=a[s>>2]|0,c=e+16|0;do if(t>>>0>=(a[c>>2]|0)>>>0)if(t=(t-(a[o>>2]|0)>>3)+1|0,n=Vr(o)|0,n>>>0<t>>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0<n>>>1>>>0?c>>>0<t>>>0?t:c:n,(a[s>>2]|0)-u>>3,e+16|0),c=r+8|0,s=a[c>>2]|0,a[s>>2]=a[i>>2],e=i+4|0,a[s+4>>2]=a[e>>2],a[i>>2]=0,a[e>>2]=0,a[c>>2]=s+8,zr(o,r),Br(r);break}else Ir(r,o,1),d=r+4|0,u=a[d>>2]|0,a[u>>2]=a[i>>2],c=i+4|0,a[u+4>>2]=a[c>>2],a[i>>2]=0,a[c>>2]=0,a[d>>2]=u+8,Lr(r);while(0);Dr(i),P=l}function Dl(e,t){e|=0,t|=0,Hr(e),a[e>>2]=5428,a[e+4>>2]=t,kl(e+8|0)}function Ol(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5452,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function kl(e){e|=0,oi(e,8,1,8,0),Jt(e+80|0,8,1,8,0),r[e+160>>0]=0,r[e+161>>0]=0,Nl(e+162|0)}function Al(e){e|=0,a[e>>2]=5428,Pl(e+8|0),Jr(e)}function jl(e){e|=0,Al(e),G(e)}function Ml(e,t){return e|=0,t|=0,Fl(e+8|0,a[e+4>>2]|0,t)|0}function Nl(e){e|=0,r[e+1>>0]=0}function Pl(e){e|=0,Qt(e+80|0),si(e)}function Fl(e,t,n){e|=0,t|=0,n|=0;var i=0,a=0,s=0;return s=P,P=P+16|0,i=s,r[e+161>>0]|0||Xt(e+80|0),a=e+162|0,Il(a)|0?(t=(mc(e+80|0,t,o[a>>0]|0,0)|0)&255,r[i>>0]=t,ki(t,n)):(gc(hc(t)|0,n,1),r[i>>0]=wi(n)|0),Ll(a,i),P=s,n+1|0}function Il(e){return e|=0,(r[e+1>>0]|0)!=0|0}function Ll(e,t){e|=0,t|=0;var n=0;n=e+1|0,r[n>>0]|0||(r[n>>0]=1),r[e>>0]=r[t>>0]|0}function Rl(e){e|=0,Bh(e),G(e)}function zl(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function Bl(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==17896?e+12|0:0)|0}function Vl(e){e|=0,ge(e,16)}function Hl(e,t){e|=0,t|=0,Hr(e),a[e>>2]=5480,a[e+4>>2]=t,Wl(e+8|0)}function Ul(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;n=P,P=P+16|0,r=n,a[e>>2]=t,i=J(16)|0,a[i+4>>2]=0,a[i+8>>2]=0,a[i>>2]=5504,a[i+12>>2]=t,a[e+4>>2]=i,a[r>>2]=t,a[r+4>>2]=t,Mi(e,r),P=n}function Wl(e){e|=0,oi(e,16,1,8,0),Jt(e+80|0,16,1,8,0),r[e+160>>0]=0,r[e+161>>0]=0,Jl(e+162|0)}function Gl(e){e|=0,a[e>>2]=5480,Yl(e+8|0),Jr(e)}function Kl(e){e|=0,Gl(e),G(e)}function ql(e,t){return e|=0,t|=0,Xl(e+8|0,a[e+4>>2]|0,t)|0}function Jl(e){e|=0,r[e+2>>0]=0}function Yl(e){e|=0,Qt(e+80|0),si(e)}function Xl(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,c=0;return c=P,P=P+16|0,a=c,r[e+161>>0]|0||Xt(e+80|0),o=e+162|0,Zl(o)|0?(t=(mc(e+80|0,t,s[o>>1]|0,0)|0)&65535,i[a>>1]=t,Oi(t,n)):(gc(hc(t)|0,n,2),i[a>>1]=Ci(n)|0),Ql(o,a),P=c,n+2|0}function Zl(e){return e|=0,(r[e+2>>0]|0)!=0|0}function Ql(e,t){e|=0,t|=0;var n=0;n=e+2|0,r[n>>0]|0||(r[n>>0]=1),i[e>>1]=i[t>>1]|0}function $l(e){e|=0,Bh(e),G(e)}function eu(e){e|=0,e=a[e+12>>2]|0,e|0&&C_[a[(a[e>>2]|0)+4>>2]&255](e)}function tu(e,t){return e|=0,t|=0,((a[t+4>>2]|0)==18394?e+12|0:0)|0}function nu(e){e|=0,ge(e,16)}function ru(e){return e|=0,du(e)|0}function iu(){return 0}function au(){return 0}function ou(e){e|=0,e|0&&(fu(e),G(e))}function su(){return pu()|0}function cu(){return mu()|0}function lu(){return hu()|0}function uu(){return 0}function du(e){return e|=0,3360}function fu(e){e|=0;var t=0,n=0,r=0,i=0;t=P,P=P+16|0,r=t,a[r>>2]=a[e>>2],a[e>>2]=0,n=e+4|0,a[r+4>>2]=a[n>>2],a[n>>2]=0,ue(r),n=e+8|0,a[r>>2]=a[n>>2],a[n>>2]=0,i=e+12|0,a[r+4>>2]=a[i>>2],a[i>>2]=0,ye(r),ye(n),ue(e),P=t}function pu(){return 3360}function mu(){return 3368}function hu(){return 3384}function gu(){return 18579}function _u(){return 18582}function vu(){return 18584}function yu(){var e=0;return e=J(16)|0,Eu(e),e|0}function bu(e){e|=0;var t=0,n=0,r=0,i=0;t=P,P=P+16|0,n=t,i=su()|0,r=Su(n)|0,n=Cu(n)|0,b(i|0,r|0,n|0,gu()|0,12,e|0),P=t}function xu(e){return e|=0,wu(__[e&3]()|0)|0}function Su(e){return e|=0,1}function Cu(e){return e|=0,Tu()|0}function wu(e){return e|=0,e|0}function Tu(){return 5524}function Eu(e){e|=0,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,a[e+12>>2]=0}function Du(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;n=P,P=P+16|0,r=n,i=n+8|0,s=a[t+4>>2]|0,a[r>>2]=a[t>>2],a[r+4>>2]=s,s=su()|0,o=ku(i)|0,i=Au(i)|0,t=Iu()|0,x(s|0,e|0,o|0,i|0,t|0,4,ju(r)|0,0),P=n}function Ou(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,o=0;o=Mu(t)|0,t=a[e>>2]|0,i=a[e+4>>2]|0,e=o+(i>>1)|0,i&1&&(t=a[(a[e>>2]|0)+t>>2]|0),i=Nu(n)|0,o=Pu(r)|0,T_[t&15](e,i,o)}function ku(e){return e|=0,4}function Au(e){return e|=0,Fu()|0}function ju(e){e|=0;var t=0,n=0;return t=J(8)|0,n=a[e+4>>2]|0,a[t>>2]=a[e>>2],a[t+4>>2]=n,t|0}function Mu(e){return e|=0,e|0}function Nu(e){return e|=0,e|0}function Pu(e){return e|=0,e|0}function Fu(){return 144}function Iu(){return 18587}function Lu(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;n=P,P=P+16|0,r=n,i=n+8|0,s=a[t+4>>2]|0,a[r>>2]=a[t>>2],a[r+4>>2]=s,s=su()|0,o=zu(i)|0,i=Bu(i)|0,t=Wu()|0,x(s|0,e|0,o|0,i|0,t|0,7,Vu(r)|0,0),P=n}function Ru(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;i=Mu(t)|0,t=a[e>>2]|0,r=a[e+4>>2]|0,e=i+(r>>1)|0,r&1&&(t=a[(a[e>>2]|0)+t>>2]|0),i=Hu(n)|0,w_[t&15](e,i)}function zu(e){return e|=0,3}function Bu(e){return e|=0,Uu()|0}function Vu(e){e|=0;var t=0,n=0;return t=J(8)|0,n=a[e+4>>2]|0,a[t>>2]=a[e>>2],a[t+4>>2]=n,t|0}function Hu(e){return e|=0,e|0}function Uu(){return 5528}function Wu(){return 18593}function Gu(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;n=P,P=P+16|0,r=n,i=n+8|0,s=a[t+4>>2]|0,a[r>>2]=a[t>>2],a[r+4>>2]=s,s=su()|0,o=qu(i)|0,i=Ju(i)|0,t=Qu()|0,x(s|0,e|0,o|0,i|0,t|0,41,Yu(r)|0,0),P=n}function Ku(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return r=P,P=P+16|0,n=r,o=Mu(t)|0,t=a[e>>2]|0,i=a[e+4>>2]|0,e=o+(i>>1)|0,i&1&&(t=a[(a[e>>2]|0)+t>>2]|0),a[n>>2]=v_[t&15](e)|0,o=Xu(n)|0,P=r,o|0}function qu(e){return e|=0,2}function Ju(e){return e|=0,Zu()|0}function Yu(e){e|=0;var t=0,n=0;return t=J(8)|0,n=a[e+4>>2]|0,a[t>>2]=a[e>>2],a[t+4>>2]=n,t|0}function Xu(e){return e|=0,a[e>>2]|0}function Zu(){return 5540}function Qu(){return 18598}function $u(e){return e|=0,od(e)|0}function ed(){return 0}function td(){return 0}function nd(e){e|=0,e|0&&(sd(e),G(e))}function rd(){return cd()|0}function id(){return ld()|0}function ad(){return ud()|0}function od(e){return e|=0,3400}function sd(e){e|=0;var t=0,n=0,r=0,i=0;t=P,P=P+16|0,r=t,a[r>>2]=a[e>>2],a[e>>2]=0,n=e+4|0,a[r+4>>2]=a[n>>2],a[n>>2]=0,As(r),n=e+16|0,a[r>>2]=a[n>>2],a[n>>2]=0,i=e+20|0,a[r+4>>2]=a[i>>2],a[i>>2]=0,Os(r),a[r>>2]=a[n>>2],a[n>>2]=0,a[r+4>>2]=a[i>>2],a[i>>2]=0,Os(r),Os(n),Ls(e+8|0),As(e),P=t}function cd(){return 3400}function ld(){return 3408}function ud(){return 3424}function dd(){var e=0;return e=J(24)|0,vd(e),e|0}function fd(e){e|=0;var t=0,n=0,r=0,i=0;t=P,P=P+16|0,n=t,i=rd()|0,r=md(n)|0,n=hd(n)|0,b(i|0,r|0,n|0,gu()|0,13,e|0),P=t}function pd(e){return e|=0,gd(__[e&3]()|0)|0}function md(e){return e|=0,1}function hd(e){return e|=0,_d()|0}function gd(e){return e|=0,e|0}function _d(){return 5548}function vd(e){e|=0,a[e>>2]=0,a[e+4>>2]=0,a[e+8>>2]=0,a[e+12>>2]=0,a[e+16>>2]=0,a[e+20>>2]=0}function yd(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;n=P,P=P+16|0,r=n,i=n+8|0,s=a[t+4>>2]|0,a[r>>2]=a[t>>2],a[r+4>>2]=s,s=rd()|0,o=xd(i)|0,i=Sd(i)|0,t=Iu()|0,x(s|0,e|0,o|0,i|0,t|0,5,Cd(r)|0,0),P=n}function bd(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,o=0;o=wd(t)|0,t=a[e>>2]|0,i=a[e+4>>2]|0,e=o+(i>>1)|0,i&1&&(t=a[(a[e>>2]|0)+t>>2]|0),i=Nu(n)|0,o=Pu(r)|0,T_[t&15](e,i,o)}function xd(e){return e|=0,4}function Sd(e){return e|=0,Td()|0}function Cd(e){e|=0;var t=0,n=0;return t=J(8)|0,n=a[e+4>>2]|0,a[t>>2]=a[e>>2],a[t+4>>2]=n,t|0}function wd(e){return e|=0,e|0}function Td(){return 160}function Ed(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;n=P,P=P+16|0,r=n,i=n+8|0,s=a[t+4>>2]|0,a[r>>2]=a[t>>2],a[r+4>>2]=s,s=rd()|0,o=Od(i)|0,i=kd(i)|0,t=Wu()|0,x(s|0,e|0,o|0,i|0,t|0,8,Ad(r)|0,0),P=n}function Dd(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;i=wd(t)|0,t=a[e>>2]|0,r=a[e+4>>2]|0,e=i+(r>>1)|0,r&1&&(t=a[(a[e>>2]|0)+t>>2]|0),i=Pu(n)|0,w_[t&15](e,i)}function Od(e){return e|=0,3}function kd(e){return e|=0,jd()|0}function Ad(e){e|=0;var t=0,n=0;return t=J(8)|0,n=a[e+4>>2]|0,a[t>>2]=a[e>>2],a[t+4>>2]=n,t|0}function jd(){return 5552}function Md(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;n=P,P=P+16|0,r=n,i=n+8|0,s=a[t+4>>2]|0,a[r>>2]=a[t>>2],a[r+4>>2]=s,s=rd()|0,o=Pd(i)|0,i=Fd(i)|0,t=Wu()|0,x(s|0,e|0,o|0,i|0,t|0,9,Id(r)|0,0),P=n}function Nd(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;i=wd(t)|0,t=a[e>>2]|0,r=a[e+4>>2]|0,e=i+(r>>1)|0,r&1&&(t=a[(a[e>>2]|0)+t>>2]|0),i=Hu(n)|0,w_[t&15](e,i)}function Pd(e){return e|=0,3}function Fd(e){return e|=0,Ld()|0}function Id(e){e|=0;var t=0,n=0;return t=J(8)|0,n=a[e+4>>2]|0,a[t>>2]=a[e>>2],a[t+4>>2]=n,t|0}function Ld(){return 5564}function Rd(){ee()}function zd(){Bd()}function Bd(){Vd(22144)}function Vd(e){e|=0;var t=0;t=P,P=P+16|0,a[t>>2]=e,Hd(),P=t}function Hd(){O(Ud()|0,18653),v(Wd()|0,18658,1,1,0),Gd(18663),Kd(18668),qd(18680),Jd(18694),Yd(18700),Xd(18715),Zd(18719),Qd(18732),$d(18737),ef(18751),tf(18757),E(nf()|0,18764),E(rf()|0,18776),D(af()|0,4,18809),D(of()|0,2,18822),D(sf()|0,4,18837),S(cf()|0,18852),lf(18868),uf(18898),df(18935),ff(18974),pf(19005),mf(19045),hf(19074),gf(19112),_f(19142),uf(19181),df(19213),ff(19246),pf(19279),mf(19313),hf(19346),vf(19380),yf(19411),bf(19443)}function Ud(){return Mp()|0}function Wd(){return jp()|0}function Gd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=kp()|0,w(e|0,a[n>>2]|0,1,-128,127),P=t}function Kd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=Dp()|0,w(e|0,a[n>>2]|0,1,-128,127),P=t}function qd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=Tp()|0,w(e|0,a[n>>2]|0,1,0,255),P=t}function Jd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=Cp()|0,w(e|0,a[n>>2]|0,2,-32768,32767),P=t}function Yd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=xp()|0,w(e|0,a[n>>2]|0,2,0,65535),P=t}function Xd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=yp()|0,w(e|0,a[n>>2]|0,4,-2147483648,2147483647),P=t}function Zd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=_p()|0,w(e|0,a[n>>2]|0,4,0,-1),P=t}function Qd(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=hp()|0,w(e|0,a[n>>2]|0,4,-2147483648,2147483647),P=t}function $d(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=pp()|0,w(e|0,a[n>>2]|0,4,0,-1),P=t}function ef(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=dp()|0,C(e|0,a[n>>2]|0,4),P=t}function tf(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,a[n>>2]=e,e=lp()|0,C(e|0,a[n>>2]|0,8),P=t}function nf(){return cp()|0}function rf(){return sp()|0}function af(){return op()|0}function of(){return ap()|0}function sf(){return ip()|0}function cf(){return rp()|0}function lf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=ep()|0,e=tp()|0,T(r|0,e|0,a[n>>2]|0),P=t}function uf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=Zf()|0,e=Qf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function df(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=Jf()|0,e=Yf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function ff(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=Gf()|0,e=Kf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function pf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=Hf()|0,e=Uf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function mf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=zf()|0,e=Bf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function hf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=If()|0,e=Lf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function gf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=Nf()|0,e=Pf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function _f(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=Af()|0,e=jf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function vf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=Df()|0,e=Of()|0,T(r|0,e|0,a[n>>2]|0),P=t}function yf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=wf()|0,e=Tf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function bf(e){e|=0;var t=0,n=0,r=0;t=P,P=P+16|0,n=t,a[n>>2]=e,r=xf()|0,e=Sf()|0,T(r|0,e|0,a[n>>2]|0),P=t}function xf(){return Cf()|0}function Sf(){return 7}function Cf(){return 3440}function wf(){return Ef()|0}function Tf(){return 7}function Ef(){return 3448}function Df(){return kf()|0}function Of(){return 6}function kf(){return 3456}function Af(){return Mf()|0}function jf(){return 5}function Mf(){return 3464}function Nf(){return Ff()|0}function Pf(){return 4}function Ff(){return 3472}function If(){return Rf()|0}function Lf(){return 5}function Rf(){return 3480}function zf(){return Vf()|0}function Bf(){return 4}function Vf(){return 3488}function Hf(){return Wf()|0}function Uf(){return 3}function Wf(){return 3496}function Gf(){return qf()|0}function Kf(){return 2}function qf(){return 3504}function Jf(){return Xf()|0}function Yf(){return 1}function Xf(){return 3512}function Zf(){return $f()|0}function Qf(){return 0}function $f(){return 3520}function ep(){return np()|0}function tp(){return 0}function np(){return 3528}function rp(){return 3536}function ip(){return 3544}function ap(){return 3576}function op(){return 3600}function sp(){return 3624}function cp(){return 3648}function lp(){return up()|0}function up(){return 4144}function dp(){return fp()|0}function fp(){return 4136}function pp(){return mp()|0}function mp(){return 4128}function hp(){return gp()|0}function gp(){return 4120}function _p(){return vp()|0}function vp(){return 4112}function yp(){return bp()|0}function bp(){return 4104}function xp(){return Sp()|0}function Sp(){return 4096}function Cp(){return wp()|0}function wp(){return 4088}function Tp(){return Ep()|0}function Ep(){return 4072}function Dp(){return Op()|0}function Op(){return 4080}function kp(){return Ap()|0}function Ap(){return 4064}function jp(){return 4056}function Mp(){return 4040}function Np(e){e|=0;var t=0,n=0,r=0,i=0;return t=P,P=P+16|0,n=t+8|0,r=t+4|0,i=t,a[i>>2]=e,a[r>>2]=a[i>>2],a[n>>2]=a[(a[r>>2]|0)+4>>2],e=mm(a[n>>2]|0)|0,P=t,e|0}function Pp(){return 21636}function Fp(e){return e|=0,(e+-48|0)>>>0<10|0}function Ip(){return 5576}function Lp(e,t){e|=0,t|=0;var n=0,i=0;if(n=r[e>>0]|0,i=r[t>>0]|0,!(n<<24>>24)||n<<24>>24!=i<<24>>24)e=i;else{do e=e+1|0,t=t+1|0,n=r[e>>0]|0,i=r[t>>0]|0;while(!(!(n<<24>>24)||n<<24>>24!=i<<24>>24));e=i}return(n&255)-(e&255)|0}function Rp(e){e|=0;var t=0,n=0,i=0;i=e;a:do if(!(i&3))n=5;else for(t=i;;){if(!(r[e>>0]|0)){e=t;break a}if(e=e+1|0,t=e,!(t&3)){n=5;break}}while(0);if((n|0)==5){for(;t=a[e>>2]|0,!((t&-2139062144^-2139062144)&t+-16843009);)e=e+4|0;if((t&255)<<24>>24)do e=e+1|0;while(r[e>>0]|0)}return e-i|0}function zp(e){e|=0}function Bp(e){return e|=0,1}function Vp(e){e|=0;var t=0,n=0;return t=e+74|0,n=r[t>>0]|0,r[t>>0]=n+255|n,t=a[e>>2]|0,t&8?(a[e>>2]=t|32,e=-1):(a[e+8>>2]=0,a[e+4>>2]=0,n=a[e+44>>2]|0,a[e+28>>2]=n,a[e+20>>2]=n,a[e+16>>2]=n+(a[e+48>>2]|0),e=0),e|0}function Hp(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0,l=0;i=n+16|0,o=a[i>>2]|0,o?s=5:Vp(n)|0?i=0:(o=a[i>>2]|0,s=5);a:do if((s|0)==5){if(l=n+20|0,c=a[l>>2]|0,i=c,(o-c|0)>>>0<t>>>0){i=x_[a[n+36>>2]&7](n,e,t)|0;break}b:do if((r[n+75>>0]|0)<0|(t|0)==0)s=0,o=e;else{for(c=t;o=c+-1|0,(r[e+o>>0]|0)!=10;)if(o)c=o;else{s=0,o=e;break b}if(i=x_[a[n+36>>2]&7](n,e,c)|0,i>>>0<c>>>0)break a;s=c,o=e+c|0,t=t-c|0,i=a[l>>2]|0}while(0);Gg(i|0,o|0,t|0)|0,a[l>>2]=(a[l>>2]|0)+t,i=s+t|0}while(0);return i|0}function Up(e,t){return e|=0,t|=0,t=t?Wp(a[t>>2]|0,a[t+4>>2]|0,e)|0:0,(t|0?t:e)|0}function Wp(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;m=(a[e>>2]|0)+1794895138|0,s=Gp(a[e+8>>2]|0,m)|0,i=Gp(a[e+12>>2]|0,m)|0,o=Gp(a[e+16>>2]|0,m)|0;a:do if(s>>>0<t>>>2>>>0&&(p=t-(s<<2)|0,i>>>0<p>>>0&o>>>0<p>>>0)&&!((o|i)&3|0)){for(p=i>>>2,f=o>>>2,d=0;;){if(l=s>>>1,u=d+l|0,c=u<<1,o=c+p|0,i=Gp(a[e+(o<<2)>>2]|0,m)|0,o=Gp(a[e+(o+1<<2)>>2]|0,m)|0,!(o>>>0<t>>>0&i>>>0<(t-o|0)>>>0)){i=0;break a}if(r[e+(o+i)>>0]|0){i=0;break a}if(i=Lp(n,e+o|0)|0,!i)break;if(i=(i|0)<0,(s|0)==1){i=0;break a}d=i?d:u,s=i?l:s-l|0}i=c+f|0,o=Gp(a[e+(i<<2)>>2]|0,m)|0,i=Gp(a[e+(i+1<<2)>>2]|0,m)|0,i=i>>>0<t>>>0&o>>>0<(t-i|0)>>>0?r[e+(i+o)>>0]|0?0:e+i|0:0}else i=0;while(0);return i|0}function Gp(e,t){e|=0,t|=0;var n=0;return n=Wg(e|0)|0,(t|0?n:e)|0}function Kp(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0;s=t&255,i=(n|0)!=0;a:do if(i&(e&3|0)!=0)for(o=t&255;;){if((r[e>>0]|0)==o<<24>>24){o=6;break a}if(e=e+1|0,n=n+-1|0,i=(n|0)!=0,!(i&(e&3|0)!=0)){o=5;break}}else o=5;while(0);(o|0)==5&&(i?o=6:e=0);b:do if((o|0)==6){if((r[e>>0]|0)!=(t&255)<<24>>24){i=u(s,16843009)|0;c:do if(n>>>0>3)do{if(s=a[e>>2]^i,(s&-2139062144^-2139062144)&s+-16843009|0)break c;e=e+4|0,n=n+-4|0}while(n>>>0>3);while(0)}if(!n)e=0;else for(i=t&255;;){if((r[e>>0]|0)==i<<24>>24)break b;if(n=n+-1|0,n)e=e+1|0;else{e=0;break}}}while(0);return e|0}function qp(e,t,n){return e|=0,t|=0,n|=0,Xp(e,t,n,1,8)|0}function Jp(e,t,n,i,s,c){e|=0,t=+t,n|=0,i|=0,s|=0,c|=0;var l=0,d=0,f=0,p=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=0,M=0,N=0;N=P,P=P+560|0,f=N+32|0,S=N+536|0,M=N,j=M,p=N+540|0,a[S>>2]=0,A=p+12|0,cm(t)|0,l=m()|0,(l|0)<0?(t=-t,cm(t)|0,k=1,O=20247,l=m()|0):(k=(s&2049|0)!=0&1,O=s&2048|0?20250:s&1|0?20253:20248);do if(!0&(l&2146435072|0)==2146435072)M=(c&32|0)!=0,l=k+3|0,im(e,32,n,l,s&-65537),Qp(e,O,k),Qp(e,t!=t|!1?M?20274:20278:M?20266:20270,3),im(e,32,n,l,s^8192);else{if(v=lm(t,S)*2,l=v!=0,l&&(a[S>>2]=(a[S>>2]|0)+-1),x=c|32,(x|0)==97){g=c&32,y=g|0?O+9|0:O,_=k|2,l=12-i|0;do if(i>>>0>11|(l|0)==0)t=v;else{t=8;do l=l+-1|0,t*=16;while(l|0);if((r[y>>0]|0)==45){t=-(t+(-v-t));break}else{t=v+t-t;break}}while(0);d=a[S>>2]|0,l=(d|0)<0?0-d|0:d,l=rm(l,((l|0)<0)<<31>>31,A)|0,(l|0)==(A|0)&&(l=p+11|0,r[l>>0]=48),r[l+-1>>0]=(d>>31&2)+43,h=l+-2|0,r[h>>0]=c+15,d=(i|0)<1,f=(s&8|0)==0,p=M;do k=~~t,l=p+1|0,r[p>>0]=g|o[640+k>>0],t=(t-+(k|0))*16,(l-j|0)==1&&!(f&d&t==0)?(r[l>>0]=46,p=p+2|0):p=l;while(t!=0);i|0&&(-2-j+p|0)<(i|0)?(d=A,f=h,l=i+2+d-f|0):(d=A,f=h,l=d-j-f+p|0),A=l+_|0,im(e,32,n,A,s),Qp(e,y,_),im(e,48,n,A,s^65536),j=p-j|0,Qp(e,M,j),M=d-f|0,im(e,48,l-(j+M)|0,0,0),Qp(e,h,M),im(e,32,n,A,s^8192),l=A;break}d=(i|0)<0?6:i,l?(l=(a[S>>2]|0)+-28|0,a[S>>2]=l,t=v*268435456):(t=v,l=a[S>>2]|0),D=(l|0)<0?f:f+288|0,f=D;do T=~~t>>>0,a[f>>2]=T,f=f+4|0,t=(t-+(T>>>0))*1e9;while(t!=0);if(T=D,(l|0)>0)for(g=D;;){if(h=(l|0)<29?l:29,l=f+-4|0,l>>>0>=g>>>0){p=0;do b=Hg(a[l>>2]|0,0,h|0)|0,b=Ig(b|0,m()|0,p|0,0)|0,C=m()|0,p=Bg(b|0,C|0,1e9,0)|0,w=Fg(p|0,m()|0,1e9,0)|0,w=Lg(b|0,C|0,w|0,m()|0)|0,m()|0,a[l>>2]=w,l=l+-4|0;while(l>>>0>=g>>>0);p?(w=g+-4|0,a[w>>2]=p,p=w):p=g}else p=g;a:do if(f>>>0>p>>>0)for(l=f;;){if(f=l+-4|0,a[f>>2]|0){f=l;break a}if(f>>>0>p>>>0)l=f;else break}while(0);if(l=(a[S>>2]|0)-h|0,a[S>>2]=l,(l|0)>0)g=p;else break}else p=D;if((l|0)<0){i=((d+25|0)/9|0)+1|0,b=(x|0)==102;do{if(y=0-l|0,y=(y|0)<9?y:9,p>>>0<f>>>0){h=(1<<y)+-1|0,g=1e9>>>y,_=0,l=p;do w=a[l>>2]|0,a[l>>2]=(w>>>y)+_,_=u(w&h,g)|0,l=l+4|0;while(l>>>0<f>>>0);p=a[p>>2]|0?p:p+4|0,_&&(a[f>>2]=_,f=f+4|0)}else p=a[p>>2]|0?p:p+4|0;l=b?D:p,f=(f-l>>2|0)>(i|0)?l+(i<<2)|0:f,l=(a[S>>2]|0)+y|0,a[S>>2]=l}while((l|0)<0);b=p}else b=p;if(b>>>0<f>>>0){if(l=(T-b>>2)*9|0,h=a[b>>2]|0,h>>>0>=10){p=10;do p=p*10|0,l=l+1|0;while(h>>>0>=p>>>0)}}else l=0;if(C=(x|0)==103,w=(d|0)!=0,p=d-((x|0)==102?0:l)+((w&C)<<31>>31)|0,(p|0)<(((f-T>>2)*9|0)+-9|0)){if(S=p+9216|0,p=(S|0)/9|0,i=D+4+(p+-1024<<2)|0,p=S-(p*9|0)|0,(p|0)<8)for(h=10;h=h*10|0,(p|0)<7;)p=p+1|0;else h=10;if(_=a[i>>2]|0,p=(_>>>0)/(h>>>0)|0,y=_-(u(p,h)|0)|0,g=(i+4|0)==(f|0),g&(y|0)==0)p=i,h=b;else if(v=p&1|0?9007199254740994:9007199254740992,S=h>>>1,t=y>>>0<S>>>0?.5:g&(y|0)==(S|0)?1:1.5,k&&(S=(r[O>>0]|0)==45,t=S?-t:t,v=S?-v:v),p=_-y|0,a[i>>2]=p,v+t!=v){if(S=p+h|0,a[i>>2]=S,S>>>0>999999999)for(h=i,l=b;;)if(p=h+-4|0,a[h>>2]=0,p>>>0<l>>>0&&(l=l+-4|0,a[l>>2]=0),S=(a[p>>2]|0)+1|0,a[p>>2]=S,S>>>0>999999999)h=p;else{h=l;break}else p=i,h=b;if(l=(T-h>>2)*9|0,_=a[h>>2]|0,_>>>0>=10){g=10;do g=g*10|0,l=l+1|0;while(_>>>0>=g>>>0)}}else p=i,h=b;S=p+4|0,f=f>>>0>S>>>0?S:f}else h=b;i=0-l|0;b:do if(f>>>0>h>>>0)for(;;){if(p=f+-4|0,a[p>>2]|0){S=f,x=1;break b}if(p>>>0>h>>>0)f=p;else{S=p,x=0;break}}else S=f,x=0;while(0);do if(C){if(d=d+((w^1)&1)|0,(d|0)>(l|0)&(l|0)>-5?(g=c+-1|0,d=d+-1-l|0):(g=c+-2|0,d=d+-1|0),!(s&8)){if(x&&(E=a[S+-4>>2]|0,E|0))if((E>>>0)%10|0)p=0;else{p=0,f=10;do f=f*10|0,p=p+1|0;while(!((E>>>0)%(f>>>0)|0))}else p=9;if(f=((S-T>>2)*9|0)+-9|0,(g|32)==102){c=f-p|0,c=(c|0)>0?c:0,d=(d|0)<(c|0)?d:c;break}else{c=f+l-p|0,c=(c|0)>0?c:0,d=(d|0)<(c|0)?d:c;break}}}else g=c;while(0);if(b=(d|0)!=0,_=b?1:s>>>3&1,y=(g|32)==102,y)C=0,l=(l|0)>0?l:0;else{if(f=(l|0)<0?i:l,f=rm(f,((f|0)<0)<<31>>31,A)|0,p=A,(p-f|0)<2)do f=f+-1|0,r[f>>0]=48;while((p-f|0)<2);r[f+-1>>0]=(l>>31&2)+43,l=f+-2|0,r[l>>0]=g,C=l,l=p-l|0}if(l=k+1+d+_+l|0,im(e,32,n,l,s),Qp(e,O,k),im(e,48,n,l,s^65536),y){_=h>>>0>D>>>0?D:h,y=M+9|0,h=y,g=M+8|0,p=_;do{if(f=rm(a[p>>2]|0,0,y)|0,(p|0)==(_|0))(f|0)==(y|0)&&(r[g>>0]=48,f=g);else if(f>>>0>M>>>0){qg(M|0,48,f-j|0)|0;do f=f+-1|0;while(f>>>0>M>>>0)}Qp(e,f,h-f|0),p=p+4|0}while(p>>>0<=D>>>0);if((s&8|0)==0&(b^1)||Qp(e,20282,1),p>>>0<S>>>0&(d|0)>0)for(;;){if(f=rm(a[p>>2]|0,0,y)|0,f>>>0>M>>>0){qg(M|0,48,f-j|0)|0;do f=f+-1|0;while(f>>>0>M>>>0)}if(Qp(e,f,(d|0)<9?d:9),p=p+4|0,f=d+-9|0,p>>>0<S>>>0&(d|0)>9)d=f;else{d=f;break}}im(e,48,d+9|0,9,0)}else{if(S=x?S:h+4|0,h>>>0<S>>>0&(d|0)>-1){i=M+9|0,b=(s&8|0)==0,x=i,_=0-j|0,y=M+8|0,g=h;do{f=rm(a[g>>2]|0,0,i)|0,(f|0)==(i|0)&&(r[y>>0]=48,f=y);do if((g|0)==(h|0)){if(p=f+1|0,Qp(e,f,1),b&(d|0)<1){f=p;break}Qp(e,20282,1),f=p}else{if(f>>>0<=M>>>0)break;qg(M|0,48,f+_|0)|0;do f=f+-1|0;while(f>>>0>M>>>0)}while(0);j=x-f|0,Qp(e,f,(d|0)>(j|0)?j:d),d=d-j|0,g=g+4|0}while(g>>>0<S>>>0&(d|0)>-1)}im(e,48,d+18|0,18,0),Qp(e,C,A-C|0)}im(e,32,n,l,s^8192)}while(0);return P=N,((l|0)<(n|0)?n:l)|0}function Yp(e,t){e|=0,t|=0;var n=0,r=0;r=(a[t>>2]|0)+7&-8,n=+c[r>>3],a[t>>2]=r+8,c[e>>3]=n}function Xp(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0;y=P,P=P+224|0,h=y+208|0,g=y+160|0,_=y+80|0,v=y,s=g,c=s+40|0;do a[s>>2]=0,s=s+4|0;while((s|0)<(c|0));return a[h>>2]=a[n>>2],(Zp(0,t,h,_,g,i,o)|0)<0?n=-1:(m=(a[e+76>>2]|0)>-1?Bp(e)|0:0,n=a[e>>2]|0,p=n&32,(r[e+74>>0]|0)<1&&(a[e>>2]=n&-33),s=e+48|0,a[s>>2]|0?n=Zp(e,t,h,_,g,i,o)|0:(c=e+44|0,l=a[c>>2]|0,a[c>>2]=v,u=e+28|0,a[u>>2]=v,d=e+20|0,a[d>>2]=v,a[s>>2]=80,f=e+16|0,a[f>>2]=v+80,n=Zp(e,t,h,_,g,i,o)|0,l&&(x_[a[e+36>>2]&7](e,0,0)|0,n=a[d>>2]|0?n:-1,a[c>>2]=l,a[s>>2]=0,a[f>>2]=0,a[u>>2]=0,a[d>>2]=0)),s=a[e>>2]|0,a[e>>2]=s|p,m|0&&zp(e),n=s&32|0?-1:n),P=y,n|0}function Zp(e,t,n,o,s,l,u){e|=0,t|=0,n|=0,o|=0,s|=0,l|=0,u|=0;var d=0,f=0,p=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=0,M=0,N=0,F=0,ee=0,I=0;ee=P,P=P+64|0,M=ee+56|0,F=ee+40|0,D=ee,k=ee+48|0,A=ee+60|0,a[M>>2]=t,w=(e|0)!=0,T=D+40|0,E=T,D=D+39|0,O=k+4|0,d=0,t=0,p=0;a:for(;;){do{do if((t|0)>-1)if((d|0)>(2147483647-t|0)){a[(Pp()|0)>>2]=61,t=-1;break}else{t=d+t|0;break}while(0);if(v=a[M>>2]|0,d=r[v>>0]|0,!(d<<24>>24)){C=92;break a}f=v;b:for(;;){switch(d<<24>>24){case 37:C=10;break b;case 0:d=f;break b;default:}S=f+1|0,a[M>>2]=S,d=r[S>>0]|0,f=S}c:do if((C|0)==10){C=0,d=f;do{if((r[f+1>>0]|0)!=37)break c;d=d+1|0,f=f+2|0,a[M>>2]=f}while((r[f>>0]|0)==37)}while(0);d=d-v|0,w&&Qp(e,v,d)}while(d|0);if(S=(Fp(r[(a[M>>2]|0)+1>>0]|0)|0)==0,f=a[M>>2]|0,!S&&(r[f+2>>0]|0)==36?(b=(r[f+1>>0]|0)+-48|0,g=1,d=3):(b=-1,g=p,d=1),d=f+d|0,a[M>>2]=d,f=r[d>>0]|0,p=(f<<24>>24)+-32|0,p>>>0>31|(1<<p&75913|0)==0)h=0;else{h=0;do h=1<<p|h,d=d+1|0,a[M>>2]=d,f=r[d>>0]|0,p=(f<<24>>24)+-32|0;while(!(p>>>0>31|(1<<p&75913|0)==0))}if(f<<24>>24==42){if(Fp(r[d+1>>0]|0)|0&&(N=a[M>>2]|0,(r[N+2>>0]|0)==36))d=N+1|0,a[s+((r[d>>0]|0)+-48<<2)>>2]=10,d=a[o+((r[d>>0]|0)+-48<<3)>>2]|0,p=1,f=N+3|0;else{if(g|0){t=-1;break}w?(S=(a[n>>2]|0)+3&-4,d=a[S>>2]|0,a[n>>2]=S+4):d=0,p=0,f=(a[M>>2]|0)+1|0}a[M>>2]=f,S=(d|0)<0,x=S?0-d|0:d,h=S?h|8192:h,S=p}else{if(d=$p(M)|0,(d|0)<0){t=-1;break}x=d,S=g,f=a[M>>2]|0}do if((r[f>>0]|0)==46){if(d=f+1|0,(r[d>>0]|0)!=42){a[M>>2]=d,d=$p(M)|0,f=a[M>>2]|0;break}if(Fp(r[f+2>>0]|0)|0&&(j=a[M>>2]|0,(r[j+3>>0]|0)==36)){d=j+2|0,a[s+((r[d>>0]|0)+-48<<2)>>2]=10,d=a[o+((r[d>>0]|0)+-48<<3)>>2]|0,f=j+4|0,a[M>>2]=f;break}if(S|0){t=-1;break a}w?(y=(a[n>>2]|0)+3&-4,d=a[y>>2]|0,a[n>>2]=y+4):d=0,f=(a[M>>2]|0)+2|0,a[M>>2]=f}else d=-1;while(0);for(y=0;;){if(((r[f>>0]|0)+-65|0)>>>0>57){t=-1;break a}if(p=f,f=f+1|0,a[M>>2]=f,p=r[(r[p>>0]|0)+-65+(176+(y*58|0))>>0]|0,g=p&255,(g+-1|0)>>>0>=8)break;y=g}if(!(p<<24>>24)){t=-1;break}_=(b|0)>-1;do if(p<<24>>24==19)if(_){t=-1;break a}else C=54;else{if(_){a[s+(b<<2)>>2]=g,_=o+(b<<3)|0,b=a[_+4>>2]|0,C=F,a[C>>2]=a[_>>2],a[C+4>>2]=b,C=54;break}if(!w){t=0;break a}em(F,g,n,u),f=a[M>>2]|0,C=55}while(0);(C|0)==54&&(C=0,w?C=55:d=0);d:do if((C|0)==55){C=0,f=r[f+-1>>0]|0,f=(y|0)!=0&(f&15|0)==3?f&-33:f,p=h&-65537,b=h&8192|0?p:h;e:do switch(f|0){case 110:switch((y&255)<<24>>24){case 0:a[a[F>>2]>>2]=t,d=0;break d;case 1:a[a[F>>2]>>2]=t,d=0;break d;case 2:d=a[F>>2]|0,a[d>>2]=t,a[d+4>>2]=((t|0)<0)<<31>>31,d=0;break d;case 3:i[a[F>>2]>>1]=t,d=0;break d;case 4:r[a[F>>2]>>0]=t,d=0;break d;case 6:a[a[F>>2]>>2]=t,d=0;break d;case 7:d=a[F>>2]|0,a[d>>2]=t,a[d+4>>2]=((t|0)<0)<<31>>31,d=0;break d;default:d=0;break d}case 112:f=120,d=d>>>0>8?d:8,p=b|8,C=67;break;case 88:case 120:p=b,C=67;break;case 111:_=F,_=nm(a[_>>2]|0,a[_+4>>2]|0,T)|0,p=E-_|0,h=0,g=20230,d=(b&8|0)==0|(d|0)>(p|0)?d:p+1|0,p=b,C=73;break;case 105:case 100:if(p=F,f=a[p>>2]|0,p=a[p+4>>2]|0,(p|0)<0){f=Lg(0,0,f|0,p|0)|0,p=m()|0,h=F,a[h>>2]=f,a[h+4>>2]=p,h=1,g=20230,C=72;break e}else{h=(b&2049|0)!=0&1,g=b&2048|0?20231:b&1|0?20232:20230,C=72;break e}case 117:p=F,h=0,g=20230,f=a[p>>2]|0,p=a[p+4>>2]|0,C=72;break;case 99:r[D>>0]=a[F>>2],v=D,h=0,g=20230,_=1,f=p,d=E;break;case 115:y=a[F>>2]|0,y=y|0?y:20240,b=Kp(y,0,d)|0,I=(b|0)==0,v=y,h=0,g=20230,_=I?d:b-y|0,f=p,d=I?y+d|0:b;break;case 67:a[k>>2]=a[F>>2],a[O>>2]=0,a[F>>2]=k,g=-1,C=79;break;case 83:d?(g=d,C=79):(im(e,32,x,0,b),d=0,C=89);break;case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:d=y_[l&1](e,+c[F>>3],x,d,b,f)|0;break d;default:h=0,g=20230,_=d,f=b,d=E}while(0);f:do if((C|0)==67)_=F,_=tm(a[_>>2]|0,a[_+4>>2]|0,T,f&32)|0,g=F,g=(p&8|0)==0|(a[g>>2]|0)==0&(a[g+4>>2]|0)==0,h=g?0:2,g=g?20230:20230+(f>>>4)|0,C=73;else if((C|0)==72)_=rm(f,p,T)|0,p=b,C=73;else if((C|0)==79){for(C=0,h=a[F>>2]|0,d=0;f=a[h>>2]|0,f;){if(f=am(A,f)|0,p=(f|0)<0,p|f>>>0>(g-d|0)>>>0){C=83;break}if(d=f+d|0,g>>>0>d>>>0)h=h+4|0;else break}if((C|0)==83&&(C=0,p)){t=-1;break a}if(im(e,32,x,d,b),!d)d=0,C=89;else for(p=a[F>>2]|0,h=0;;){if(f=a[p>>2]|0,!f){C=89;break f}if(f=am(A,f)|0,h=f+h|0,(h|0)>(d|0)){C=89;break f}if(Qp(e,A,f),h>>>0>=d>>>0){C=89;break}else p=p+4|0}}while(0);if((C|0)==73)C=0,f=F,f=(a[f>>2]|0)!=0|(a[f+4>>2]|0)!=0,I=(d|0)!=0|f,f=E-_+((f^1)&1)|0,v=I?_:T,_=I?(d|0)>(f|0)?d:f:0,f=(d|0)>-1?p&-65537:p,d=E;else if((C|0)==89){C=0,im(e,32,x,d,b^8192),d=(x|0)>(d|0)?x:d;break}b=d-v|0,y=(_|0)<(b|0)?b:_,I=y+h|0,d=(x|0)<(I|0)?I:x,im(e,32,d,I,f),Qp(e,g,h),im(e,48,d,I,f^65536),im(e,48,y,b,0),Qp(e,v,b),im(e,32,d,I,f^8192)}while(0);p=S}g:do if((C|0)==92&&!e)if(!p)t=0;else{for(t=1;d=a[s+(t<<2)>>2]|0,d;)if(em(o+(t<<3)|0,d,n,u),t=t+1|0,t>>>0>=10){t=1;break g}for(;;){if(a[s+(t<<2)>>2]|0){t=-1;break g}if(t=t+1|0,t>>>0>=10){t=1;break}}}while(0);return P=ee,t|0}function Qp(e,t,n){e|=0,t|=0,n|=0,a[e>>2]&32||Hp(t,n,e)|0}function $p(e){e|=0;var t=0,n=0;if(!(Fp(r[a[e>>2]>>0]|0)|0))t=0;else{t=0;do n=a[e>>2]|0,t=(t*10|0)+-48+(r[n>>0]|0)|0,n=n+1|0,a[e>>2]=n;while(Fp(r[n>>0]|0)|0)}return t|0}function em(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,o=0;a:do if(t>>>0<=20)do switch(t|0){case 9:t=(a[n>>2]|0)+3&-4,r=a[t>>2]|0,a[n>>2]=t+4,a[e>>2]=r;break a;case 10:r=(a[n>>2]|0)+3&-4,t=a[r>>2]|0,a[n>>2]=r+4,r=e,a[r>>2]=t,a[r+4>>2]=((t|0)<0)<<31>>31;break a;case 11:r=(a[n>>2]|0)+3&-4,t=a[r>>2]|0,a[n>>2]=r+4,r=e,a[r>>2]=t,a[r+4>>2]=0;break a;case 12:r=(a[n>>2]|0)+7&-8,t=r,i=a[t>>2]|0,t=a[t+4>>2]|0,a[n>>2]=r+8,r=e,a[r>>2]=i,a[r+4>>2]=t;break a;case 13:i=(a[n>>2]|0)+3&-4,r=a[i>>2]|0,a[n>>2]=i+4,r=(r&65535)<<16>>16,i=e,a[i>>2]=r,a[i+4>>2]=((r|0)<0)<<31>>31;break a;case 14:i=(a[n>>2]|0)+3&-4,r=a[i>>2]|0,a[n>>2]=i+4,i=e,a[i>>2]=r&65535,a[i+4>>2]=0;break a;case 15:i=(a[n>>2]|0)+3&-4,r=a[i>>2]|0,a[n>>2]=i+4,r=(r&255)<<24>>24,i=e,a[i>>2]=r,a[i+4>>2]=((r|0)<0)<<31>>31;break a;case 16:i=(a[n>>2]|0)+3&-4,r=a[i>>2]|0,a[n>>2]=i+4,i=e,a[i>>2]=r&255,a[i+4>>2]=0;break a;case 17:i=(a[n>>2]|0)+7&-8,o=+c[i>>3],a[n>>2]=i+8,c[e>>3]=o;break a;case 18:w_[r&15](e,n);break a;default:break a}while(0);while(0)}function tm(e,t,n,i){if(e|=0,t|=0,n|=0,i|=0,!((e|0)==0&(t|0)==0))do n=n+-1|0,r[n>>0]=o[640+(e&15)>>0]|0|i,e=Vg(e|0,t|0,4)|0,t=m()|0;while(!((e|0)==0&(t|0)==0));return n|0}function nm(e,t,n){if(e|=0,t|=0,n|=0,!((e|0)==0&(t|0)==0))do n=n+-1|0,r[n>>0]=e&7|48,e=Vg(e|0,t|0,3)|0,t=m()|0;while(!((e|0)==0&(t|0)==0));return n|0}function rm(e,t,n){e|=0,t|=0,n|=0;var i=0,a=0,o=0;if(t>>>0>0|(t|0)==0&e>>>0>4294967295){do i=e,e=Bg(e|0,t|0,10,0)|0,a=t,t=m()|0,o=Fg(e|0,t|0,10,0)|0,o=Lg(i|0,a|0,o|0,m()|0)|0,m()|0,n=n+-1|0,r[n>>0]=o&255|48;while(a>>>0>9|(a|0)==9&i>>>0>4294967295);t=e}else t=e;if(t)do o=t,t=(t>>>0)/10|0,n=n+-1|0,r[n>>0]=o-(t*10|0)|48;while(o>>>0>=10);return n|0}function im(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var a=0,o=0;if(o=P,P=P+256|0,a=o,(n|0)>(r|0)&(i&73728|0)==0){if(i=n-r|0,qg(a|0,t<<24>>24|0,(i>>>0<256?i:256)|0)|0,i>>>0>255){t=n-r|0;do Qp(e,a,256),i=i+-256|0;while(i>>>0>255);i=t&255}Qp(e,a,i)}P=o}function am(e,t){return e|=0,t|=0,e=e?om(e,t,0)|0:0,e|0}function om(e,t,n){e|=0,t|=0,n|=0;do if(e){if(t>>>0<128){r[e>>0]=t,e=1;break}if(!(a[a[(sm()|0)+176>>2]>>2]|0))if((t&-128|0)==57216){r[e>>0]=t,e=1;break}else{a[(Pp()|0)>>2]=25,e=-1;break}if(t>>>0<2048){r[e>>0]=t>>>6|192,r[e+1>>0]=t&63|128,e=2;break}if(t>>>0<55296|(t&-8192|0)==57344){r[e>>0]=t>>>12|224,r[e+1>>0]=t>>>6&63|128,r[e+2>>0]=t&63|128,e=3;break}if((t+-65536|0)>>>0<1048576){r[e>>0]=t>>>18|240,r[e+1>>0]=t>>>12&63|128,r[e+2>>0]=t>>>6&63|128,r[e+3>>0]=t&63|128,e=4;break}else{a[(Pp()|0)>>2]=25,e=-1;break}}else e=1;while(0);return e|0}function sm(){return Ip()|0}function cm(e){e=+e;var t=0;return c[l>>3]=e,t=a[l>>2]|0,p(a[l+4>>2]|0),t|0}function lm(e,t){e=+e,t|=0;var n=0,r=0,i=0;switch(c[l>>3]=e,n=a[l>>2]|0,r=a[l+4>>2]|0,i=Vg(n|0,r|0,52)|0,m()|0,i&2047){case 0:e==0?n=0:(e=+lm(e*0x10000000000000000,t),n=(a[t>>2]|0)+-64|0),a[t>>2]=n;break;case 2047:break;default:a[t>>2]=(i&2047)+-1022,a[l>>2]=n,a[l+4>>2]=r&-2146435073|1071644672,e=+c[l>>3]}return+e}function um(e,t,n){e|=0,t|=0,n|=0;var i=0,a=0;a:do if(!n)e=0;else{for(;i=r[e>>0]|0,a=r[t>>0]|0,i<<24>>24==a<<24>>24;)if(n=n+-1|0,n)e=e+1|0,t=t+1|0;else{e=0;break a}e=(i&255)-(a&255)|0}while(0);return e|0}function dm(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,o=0;return i=P,P=P+16|0,o=i,a[o>>2]=r,r=fm(e,t,n,o)|0,P=i,r|0}function fm(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var o=0,s=0,c=0,l=0;return l=P,P=P+160|0,o=l+144|0,c=l,Gg(c|0,3672,144)|0,(t+-1|0)>>>0>2147483646?t?(a[(Pp()|0)>>2]=61,t=-1):(e=o,t=1,s=4):s=4,(s|0)==4&&(s=-2-e|0,s=t>>>0>s>>>0?s:t,a[c+48>>2]=s,o=c+20|0,a[o>>2]=e,a[c+44>>2]=e,t=e+s|0,e=c+16|0,a[e>>2]=t,a[c+28>>2]=t,t=qp(c,n,i)|0,s&&(c=a[o>>2]|0,r[c+(((c|0)==(a[e>>2]|0))<<31>>31)>>0]=0)),P=l,t|0}function pm(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;return r=e+20|0,i=a[r>>2]|0,e=(a[e+16>>2]|0)-i|0,e=e>>>0>n>>>0?n:e,Gg(i|0,t|0,e|0)|0,a[r>>2]=(a[r>>2]|0)+e,n|0}function mm(e){e|=0;var t=0,n=0;return t=(Rp(e)|0)+1|0,n=Og(t)|0,e=n?Gg(n|0,e|0,t|0)|0:0,e|0}function hm(e,t){e|=0,t|=0;var n=0,i=0;for(n=0;;){if((o[656+n>>0]|0)==(e|0)){i=4;break}if(n=n+1|0,(n|0)==87){e=87,i=5;break}}if((i|0)==4&&(n?(e=n,i=5):n=752),(i|0)==5){n=752;do{do i=n,n=n+1|0;while(r[i>>0]|0);e=e+-1|0}while(e|0)}return gm(n,a[t+20>>2]|0)|0}function gm(e,t){return e|=0,t|=0,Up(e,t)|0}function _m(e){return e|=0,hm(e,a[(vm()|0)+176>>2]|0)|0}function vm(){return Ip()|0}function ym(e,t,n){e|=0,t|=0,n|=0;var i=0;return i=_m(e)|0,e=Rp(i)|0,e>>>0>=n>>>0?(e=n+-1|0,n?(Gg(t|0,i|0,e|0)|0,r[t+e>>0]=0,e=68):e=68):(Gg(t|0,i|0,e+1|0)|0,e=0),e|0}function bm(){var e=0,t=0,n=0,r=0,i=0,o=0,s=0;r=P,P=P+48|0,o=r+32|0,t=r+24|0,s=r+16|0,i=r,r=r+36|0,e=xm()|0,e|0&&(n=a[e>>2]|0,n|0)&&(e=n+48|0,Sm(e)|0||(a[t>>2]=20420,wm(20370,t)),t=Cm(e)|0,e=(t|0)==1126902529&(m()|0)==1129074247?a[n+44>>2]|0:n+80|0,a[r>>2]=e,n=a[n>>2]|0,e=a[n+4>>2]|0,x_[a[(a[954]|0)+16>>2]&7](3816,n,r)|0?(s=a[r>>2]|0,s=v_[a[(a[s>>2]|0)+8>>2]&15](s)|0,a[i>>2]=20420,a[i+4>>2]=e,a[i+8>>2]=s,wm(20284,i)):(a[s>>2]=20420,a[s+4>>2]=e,wm(20329,s))),wm(20408,o)}function xm(){return 21640}function Sm(e){return e|=0,e=Cm(e)|0,(e&-256|0)==1126902528&(m()|0)==1129074247|0}function Cm(e){e|=0;var t=0;return t=e,e=a[t>>2]|0,p(a[t+4>>2]|0),e|0}function wm(e,t){e|=0,t|=0,N()}function Tm(e){e|=0}function Em(e){e|=0,Tm(e),G(e)}function Dm(e){e|=0}function Om(e){e|=0}function km(e,t,n){e|=0,t|=0,n|=0;var o=0,s=0,c=0,l=0,u=0,d=0;if(d=P,P=P+64|0,l=d,Nm(e,t,0)|0)e=1;else if(t|0&&(u=Lm(t,3840,3824,0)|0,u|0)){a[l>>2]=u,a[l+4>>2]=0,a[l+8>>2]=e,a[l+12>>2]=-1,e=l+16|0,t=l+24|0,o=l+48|0,s=e,c=s+36|0;do a[s>>2]=0,s=s+4|0;while((s|0)<(c|0));i[e+36>>1]=0,r[e+38>>0]=0,a[o>>2]=1,E_[a[(a[u>>2]|0)+28>>2]&7](u,l,a[n>>2]|0,1),(a[t>>2]|0)==1?(a[n>>2]=a[e>>2],e=1):e=0}else e=0;return P=d,e|0}function Am(e,t,n,r,i,o){e|=0,t|=0,n|=0,r|=0,i|=0,o|=0,Nm(e,a[t+8>>2]|0,o)|0&&Im(0,t,n,r,i)}function jm(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var s=0;do if(Nm(e,a[t+8>>2]|0,o)|0)Fm(0,t,n,i);else if(Nm(e,a[t>>2]|0,o)|0){if((a[t+16>>2]|0)!=(n|0)&&(s=t+20|0,(a[s>>2]|0)!=(n|0))){a[t+32>>2]=i,a[s>>2]=n,o=t+40|0,a[o>>2]=(a[o>>2]|0)+1,(a[t+36>>2]|0)==1&&(a[t+24>>2]|0)==2&&(r[t+54>>0]=1),a[t+44>>2]=4;break}(i|0)==1&&(a[t+32>>2]=1)}while(0)}function Mm(e,t,n,r){e|=0,t|=0,n|=0,r|=0,Nm(e,a[t+8>>2]|0,0)|0&&Pm(0,t,n,r)}function Nm(e,t,n){return e|=0,t|=0,n|=0,e=n?(e|0)==(t|0)?1:(Lp(a[e+4>>2]|0,a[t+4>>2]|0)|0)==0:(a[e+4>>2]|0)==(a[t+4>>2]|0),e|0}function Pm(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var o=0;e=t+16|0,o=a[e>>2]|0;do if(o){if((o|0)!=(n|0)){i=t+36|0,a[i>>2]=(a[i>>2]|0)+1,a[t+24>>2]=2,r[t+54>>0]=1;break}e=t+24|0,(a[e>>2]|0)==2&&(a[e>>2]=i)}else a[e>>2]=n,a[t+24>>2]=i,a[t+36>>2]=1;while(0)}function Fm(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0;(a[t+4>>2]|0)==(n|0)&&(i=t+28|0,(a[i>>2]|0)!=1)&&(a[i>>2]=r)}function Im(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0,r[t+53>>0]=1;do if((a[t+4>>2]|0)==(i|0)){if(r[t+52>>0]=1,e=t+16|0,i=a[e>>2]|0,!i){if(a[e>>2]=n,a[t+24>>2]=o,a[t+36>>2]=1,!((o|0)==1&&(a[t+48>>2]|0)==1))break;r[t+54>>0]=1;break}if((i|0)!=(n|0)){o=t+36|0,a[o>>2]=(a[o>>2]|0)+1,r[t+54>>0]=1;break}i=t+24|0,e=a[i>>2]|0,(e|0)==2&&(a[i>>2]=o,e=o),(e|0)==1&&(a[t+48>>2]|0)==1&&(r[t+54>>0]=1)}while(0)}function Lm(e,t,n,o){e|=0,t|=0,n|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;h=P,P=P+64|0,p=h,f=a[e>>2]|0,m=e+(a[f+-8>>2]|0)|0,f=a[f+-4>>2]|0,a[p>>2]=n,a[p+4>>2]=e,a[p+8>>2]=t,a[p+12>>2]=o,e=p+16|0,t=p+20|0,o=p+24|0,s=p+28|0,c=p+32|0,l=p+40|0,u=e,d=u+36|0;do a[u>>2]=0,u=u+4|0;while((u|0)<(d|0));i[e+36>>1]=0,r[e+38>>0]=0;a:do if(Nm(f,n,0)|0)a[p+48>>2]=1,D_[a[(a[f>>2]|0)+20>>2]&3](f,p,m,m,1,0),e=(a[o>>2]|0)==1?m:0;else{switch(X[a[(a[f>>2]|0)+24>>2]&3](f,p,m,1,0),a[p+36>>2]|0){case 0:e=(a[l>>2]|0)==1&(a[s>>2]|0)==1&(a[c>>2]|0)==1?a[t>>2]|0:0;break a;case 1:break;default:e=0;break a}if((a[o>>2]|0)!=1&&!((a[l>>2]|0)==0&(a[s>>2]|0)==1&(a[c>>2]|0)==1)){e=0;break}e=a[e>>2]|0}while(0);return P=h,e|0}function Rm(e){e|=0,Tm(e),G(e)}function zm(e,t,n,r,i,o){e|=0,t|=0,n|=0,r|=0,i|=0,o|=0,Nm(e,a[t+8>>2]|0,o)|0?Im(0,t,n,r,i):(e=a[e+8>>2]|0,D_[a[(a[e>>2]|0)+20>>2]&3](e,t,n,r,i,o))}function Bm(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var s=0,c=0,l=0;a:do if(Nm(e,a[t+8>>2]|0,o)|0)Fm(0,t,n,i);else{if(!(Nm(e,a[t>>2]|0,o)|0)){c=a[e+8>>2]|0,X[a[(a[c>>2]|0)+24>>2]&3](c,t,n,i,o);break}if((a[t+16>>2]|0)!=(n|0)&&(c=t+20|0,(a[c>>2]|0)!=(n|0))){a[t+32>>2]=i,i=t+44|0;do if((a[i>>2]|0)!=4)if(s=t+52|0,r[s>>0]=0,l=t+53|0,r[l>>0]=0,e=a[e+8>>2]|0,D_[a[(a[e>>2]|0)+20>>2]&3](e,t,n,n,1,o),r[l>>0]|0){if(l=(r[s>>0]|0)==0,a[i>>2]=3,l)break;break a}else{a[i>>2]=4;break}while(0);if(a[c>>2]=n,l=t+40|0,a[l>>2]=(a[l>>2]|0)+1,(a[t+36>>2]|0)!=1||(a[t+24>>2]|0)!=2)break;r[t+54>>0]=1;break}(i|0)==1&&(a[t+32>>2]=1)}while(0)}function Vm(e,t,n,r){e|=0,t|=0,n|=0,r|=0,Nm(e,a[t+8>>2]|0,0)|0?Pm(0,t,n,r):(e=a[e+8>>2]|0,E_[a[(a[e>>2]|0)+28>>2]&7](e,t,n,r))}function G(e){e|=0,kg(e)}function Hm(e){e|=0}function Um(e){e|=0,G(e)}function Wm(e){return e|=0,20599}function Gm(e){e|=0,a[e>>2]=5916,Ym(e+4|0)}function Km(e){e|=0,Gm(e),G(e)}function qm(e){return e|=0,Jm(e+4|0)|0}function Jm(e){return e|=0,a[e>>2]|0}function Ym(e){e|=0;var t=0,n=0;Xm(e)|0&&(t=Zm(a[e>>2]|0)|0,n=t+8|0,e=a[n>>2]|0,a[n>>2]=e+-1,(e|0)<1)&&G(t)}function Xm(e){return e|=0,1}function Zm(e){return e|=0,e+-12|0}function Qm(e){e|=0,a[e>>2]=5936,Ym(e+4|0)}function $m(e){e|=0,Qm(e),G(e)}function eh(e){return e|=0,Jm(e+4|0)|0}function th(e){e|=0,Gm(e),G(e)}function nh(e){e|=0,Gm(e),G(e)}function rh(){var e=0;e=P,P=P+16|0,wm(20848,e)}function ih(e){e|=0,Tm(e),G(e)}function ah(e,t,n){return e|=0,t|=0,n|=0,Nm(e,t,0)|0}function oh(e){e|=0,Tm(e),G(e)}function sh(e,t,n){e|=0,t|=0,n|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;p=P,P=P+64|0,d=p;do if(Nm(t,4048,0)|0)a[n>>2]=0,t=1;else{if(ch(e,t,0)|0){if(t=a[n>>2]|0,!t){t=1;break}a[n>>2]=a[t>>2],t=1;break}if(t|0&&(o=Lm(t,3840,3976,0)|0,o|0))if(t=a[n>>2]|0,t|0&&(a[n>>2]=a[t>>2]),t=a[o+8>>2]|0,c=e+8|0,s=a[c>>2]|0,!(t&7&(s^7)|0)&&!((t&96^96)&s|0))if(s=e+12|0,e=a[s>>2]|0,o=o+12|0,t=a[o>>2]|0,Nm(e,t,0)|0)t=1;else{if(Nm(e,4040,0)|0){if(!t){t=1;break}t=(Lm(t,3840,3992,0)|0)==0;break}if(e){if(t=Lm(e,3840,3976,0)|0,t|0){if(!(a[c>>2]&1)){t=0;break}t=lh(t,a[o>>2]|0)|0;break}if(t=a[s>>2]|0,t){if(t=Lm(t,3840,4008,0)|0,t|0){if(!(a[c>>2]&1)){t=0;break}t=uh(t,a[o>>2]|0)|0;break}if(t=a[s>>2]|0,t|0&&(l=Lm(t,3840,3824,0)|0,l|0)&&(u=a[o>>2]|0,u|0)&&(f=Lm(u,3840,3824,0)|0,f|0)){a[d>>2]=f,a[d+4>>2]=0,a[d+8>>2]=l,a[d+12>>2]=-1,t=d+16|0,e=d+24|0,o=d+48|0,s=t,c=s+36|0;do a[s>>2]=0,s=s+4|0;while((s|0)<(c|0));i[t+36>>1]=0,r[t+38>>0]=0,a[o>>2]=1,E_[a[(a[f>>2]|0)+28>>2]&7](f,d,a[n>>2]|0,1);do if((a[e>>2]|0)==1){if(!(a[n>>2]|0)){t=1;break}a[n>>2]=a[t>>2],t=1}else t=0;while(0)}else t=0}else t=0}else t=0}else t=0;else t=0}while(0);return P=p,t|0}function ch(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;return a[e+8>>2]&24?(n=1,i=5):t|0&&(r=Lm(t,3840,3960,0)|0,r|0)?(n=(a[r+8>>2]&24|0)!=0,i=5):n=0,(i|0)==5&&(n=Nm(e,t,n)|0),n|0}function lh(e,t){e|=0,t|=0;for(var n=0,r=0,i=0,o=0,s=0;;){if(!t){t=0;break}if(n=Lm(t,3840,3976,0)|0,!n){t=0;break}if(i=a[e+8>>2]|0,a[n+8>>2]&~i|0){t=0;break}if(r=e+12|0,t=a[r>>2]|0,n=n+12|0,Nm(t,a[n>>2]|0,0)|0){t=1;break}if((i&1|0)==0|(t|0)==0){t=0;break}if(e=Lm(t,3840,3976,0)|0,!e){s=9;break}t=a[n>>2]|0}return(s|0)==9&&(t=a[r>>2]|0,t=t|0&&(o=Lm(t,3840,4008,0)|0,o|0)?uh(o,a[n>>2]|0)|0:0),t|0}function uh(e,t){e|=0,t|=0;var n=0;return e=t|0&&(n=Lm(t,3840,4008,0)|0,n|0)&&!(a[n+8>>2]&~a[e+8>>2]|0)&&Nm(a[e+12>>2]|0,a[n+12>>2]|0,0)|0?Nm(a[e+16>>2]|0,a[n+16>>2]|0,0)|0:0,e|0}function dh(e){e|=0,Tm(e),G(e)}function fh(e,t,n,i,o,s){e|=0,t|=0,n|=0,i|=0,o|=0,s|=0;var c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0;if(Nm(e,a[t+8>>2]|0,s)|0)Im(0,t,n,i,o);else{_=t+52|0,l=r[_>>0]|0,g=t+53|0,c=r[g>>0]|0,h=a[e+12>>2]|0,f=e+16+(h<<3)|0,r[_>>0]=0,r[g>>0]=0,gh(e+16|0,t,n,i,o,s),u=r[_>>0]|0,l=u|l,d=r[g>>0]|0,c=d|c;a:do if((h|0)>1){p=t+24|0,m=e+8|0,h=t+54|0,e=e+24|0;do{if(c&=1,l&=1,r[h>>0]|0)break a;if(!(u<<24>>24)){if(d<<24>>24&&!(a[m>>2]&1|0))break a}else if((a[p>>2]|0)==1||!(a[m>>2]&2))break a;r[_>>0]=0,r[g>>0]=0,gh(e,t,n,i,o,s),u=r[_>>0]|0,l=u|l,d=r[g>>0]|0,c=d|c,e=e+8|0}while(e>>>0<f>>>0)}while(0);r[_>>0]=l<<24>>24!=0&1,r[g>>0]=c<<24>>24!=0&1}}function ph(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;a:do if(Nm(e,a[t+8>>2]|0,o)|0)Fm(0,t,n,i);else{if(!(Nm(e,a[t>>2]|0,o)|0)){if(h=a[e+12>>2]|0,u=e+16+(h<<3)|0,_h(e+16|0,t,n,i,o),s=e+24|0,(h|0)<=1)break;if(e=a[e+8>>2]|0,!(e&2|0)&&(l=t+36|0,(a[l>>2]|0)!=1)){if(!(e&1)){for(e=t+54|0;;)if(r[e>>0]|0||(a[l>>2]|0)==1||(_h(s,t,n,i,o),s=s+8|0,s>>>0>=u>>>0))break a}for(e=t+24|0,c=t+54|0;;)if(r[c>>0]|0||(a[l>>2]|0)==1&&(a[e>>2]|0)==1||(_h(s,t,n,i,o),s=s+8|0,s>>>0>=u>>>0))break a}for(e=t+54|0;;)if(r[e>>0]|0||(_h(s,t,n,i,o),s=s+8|0,s>>>0>=u>>>0))break a}if((a[t+16>>2]|0)!=(n|0)&&(h=t+20|0,(a[h>>2]|0)!=(n|0))){if(a[t+32>>2]=i,m=t+44|0,(a[m>>2]|0)!=4){l=e+16+(a[e+12>>2]<<3)|0,u=t+52|0,i=t+53|0,d=t+54|0,f=e+8|0,p=t+24|0,s=0,c=e+16|0,e=0;b:for(;;){if(c>>>0>=l>>>0){c=18;break}if(r[u>>0]=0,r[i>>0]=0,gh(c,t,n,n,1,o),r[d>>0]|0){c=18;break}do if(r[i>>0]|0){if(!(r[u>>0]|0))if(a[f>>2]&1){e=1;break}else{c=19;break b}if((a[p>>2]|0)==1){s=1,c=19;break b}if(a[f>>2]&2)s=1,e=1;else{s=1,c=19;break b}}while(0);c=c+8|0}if((c|0)==18&&(e?c=19:e=4),(c|0)==19&&(e=3),a[m>>2]=e,s&1)break}if(a[h>>2]=n,n=t+40|0,a[n>>2]=(a[n>>2]|0)+1,(a[t+36>>2]|0)!=1||(a[t+24>>2]|0)!=2)break;r[t+54>>0]=1;break}(i|0)==1&&(a[t+32>>2]=1)}while(0)}function mh(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var o=0,s=0;a:do if(Nm(e,a[t+8>>2]|0,0)|0)Pm(0,t,n,i);else if(s=a[e+12>>2]|0,o=e+16+(s<<3)|0,hh(e+16|0,t,n,i),(s|0)>1){s=t+54|0,e=e+24|0;do{if(hh(e,t,n,i),r[s>>0]|0)break a;e=e+8|0}while(e>>>0<o>>>0)}while(0)}function hh(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,o=0;o=a[e+4>>2]|0,n?(i=o>>8,o&1&&(i=a[(a[n>>2]|0)+i>>2]|0)):i=0,e=a[e>>2]|0,E_[a[(a[e>>2]|0)+28>>2]&7](e,t,n+i|0,o&2|0?r:2)}function gh(e,t,n,r,i,o){e|=0,t|=0,n|=0,r|=0,i|=0,o|=0;var s=0,c=0;c=a[e+4>>2]|0,s=c>>8,c&1&&(s=a[(a[r>>2]|0)+s>>2]|0),e=a[e>>2]|0,D_[a[(a[e>>2]|0)+20>>2]&3](e,t,n,r+s|0,c&2|0?i:2,o)}function _h(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var o=0,s=0;s=a[e+4>>2]|0,o=s>>8,s&1&&(o=a[(a[n>>2]|0)+o>>2]|0),e=a[e>>2]|0,X[a[(a[e>>2]|0)+24>>2]&3](e,t,n+o|0,s&2|0?r:2,i)}function vh(e){e|=0,a[e>>2]=5896}function yh(e){e|=0;var t=0,n=0;return t=P,P=P+16|0,n=t,K(n,e),e=bh(n)|0,P=t,e|0}function K(e,t){e|=0,t|=0,Th(e,t)}function bh(e){e|=0;var t=0,n=0;return t=P,P=P+16|0,n=t,xh(n,a[e+4>>2]|0),e=(Sh(n)|0)<<24>>24?0:wh(Ch(e)|0)|0,P=t,e|0}function xh(e,t){e|=0,t|=0,a[e>>2]=t}function Sh(e){return e|=0,r[a[e>>2]>>0]|0}function Ch(e){return e|=0,e|0}function wh(e){e|=0;var t=0,n=0,i=0,o=0;o=P,P=P+16|0,i=o,e=a[e+8>>2]|0,t=r[e>>0]|0;do if(t<<24>>24!=1)if(t&2)wm(20985,i);else{r[e>>0]=2,n=1;break}else n=0;while(0);return P=o,n|0}function Th(e,t){e|=0,t|=0,a[e>>2]=t,a[e+4>>2]=t,a[e+8>>2]=t+1,a[e+12>>2]=0}function q(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,K(n,e),Eh(n),P=t}function Eh(e){e|=0;var t=0,n=0;t=P,P=P+16|0,n=t,xh(n,a[e+4>>2]|0),Dh(n),Oh(Ch(e)|0),P=t}function Dh(e){e|=0,r[a[e>>2]>>0]=1}function Oh(e){e|=0,r[a[e+8>>2]>>0]=1}function kh(){return 0}function J(e){e|=0;var t=0,n=0;for(n=e|0?e:1;;){if(t=Og(n)|0,t|0){e=6;break}if(e=kh()|0,!e){e=5;break}S_[e&3]()}if((e|0)==5)n=h(4)|0,vh(n),g(n|0,3880,121);else if((e|0)==6)return t|0;return 0}function Ah(e){return e|=0,J(e)|0}function jh(e){e|=0,G(e)}function Mh(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;return i=P,P=P+16|0,r=i,a[r>>2]=a[n>>2],e=x_[a[(a[e>>2]|0)+16>>2]&7](e,t,r)|0,e&&(a[n>>2]=a[r>>2]),P=i,e&1|0}function Nh(e){return e|=0,e=e?(Lm(e,3840,3976,0)|0)!=0&1:0,e|0}function Ph(e){return e|=0,0}function Fh(){return(Ih()|0)>0|0}function Ih(){return _()|0}function Lh(e){e|=0}function Rh(e){e|=0,Lh(e),G(e)}function zh(e){return e|=0,21039}function Bh(e){e|=0}function Vh(e){e|=0;var t=0,n=0;t=e+8|0,a[t>>2]|0&&(n=a[t>>2]|0,a[t>>2]=n+-1,n|0)||C_[a[(a[e>>2]|0)+16>>2]&255](e)}function Hh(e){if(e|=0,e=Ph(e)|0,e)Eg(e,21145);else return}function Uh(e){e|=0}function Wh(e,t){e|=0,t|=0;var n=0,r=0;r=Rp(t)|0,n=J(r+13|0)|0,a[n>>2]=r,a[n+4>>2]=r,a[n+8>>2]=0,n=Gh(n)|0,Gg(n|0,t|0,r+1|0)|0,a[e>>2]=n}function Gh(e){return e|=0,e+12|0}function Kh(e,t){e|=0,t|=0,a[e>>2]=5916,Wh(e+4|0,t)}function qh(e,t){e|=0,t|=0,a[e>>2]=5936,Wh(e+4|0,(r[t+11>>0]|0)<0?a[t>>2]|0:t)}function Jh(e,t){e|=0,t|=0,a[e>>2]=5936,Wh(e+4|0,t)}function Yh(e){e|=0,e=h(8)|0,Kh(e,21163),a[e>>2]=5956,g(e|0,3928,123)}function Xh(e){e|=0,e=h(8)|0,Kh(e,21163),a[e>>2]=5976,g(e|0,3944,123)}function Zh(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0;o=P,P=P+16|0,i=o,n>>>0>4294967279&&Yh(e),n>>>0<11?r[e+11>>0]=n:(c=n+16&-16,s=J(c)|0,a[e>>2]=s,a[e+8>>2]=c|-2147483648,a[e+4>>2]=n,e=s),Qh(e,t,n)|0,r[i>>0]=0,Ze(e+n|0,i),P=o}function Qh(e,t,n){return e|=0,t|=0,n|=0,n|0&&Gg(e|0,t|0,n|0)|0,e|0}function $h(e){e|=0,(r[e+11>>0]|0)<0&&ge(a[e>>2]|0,a[e+8>>2]&2147483647)}function eg(e,t,n,i,o,s,c,l){e|=0,t|=0,n|=0,i|=0,o|=0,s|=0,c|=0,l|=0;var u=0,d=0,f=0,p=0,m=0;m=P,P=P+16|0,p=m,(-18-t|0)>>>0<n>>>0&&Yh(e),f=(r[e+11>>0]|0)<0?a[e>>2]|0:e,t>>>0<2147483623?(u=n+t|0,d=t<<1,u=u>>>0<d>>>0?d:u,u=u>>>0<11?11:u+16&-16):u=-17,d=J(u)|0,o|0&&Qh(d,f,o)|0,c|0&&Qh(d+o|0,l,c)|0,i=i-s|0,n=i-o|0,n|0&&Qh(d+o+c|0,f+o+s|0,n)|0,n=t+1|0,(n|0)!=11&&ge(f,n),a[e>>2]=d,a[e+8>>2]=u|-2147483648,c=i+c|0,a[e+4>>2]=c,r[p>>0]=0,Ze(d+c|0,p),P=m}function tg(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0,l=0,u=0;return u=P,P=P+16|0,c=u,l=e+11|0,i=r[l>>0]|0,s=i<<24>>24<0,s?(o=(a[e+8>>2]&2147483647)+-1|0,i=a[e+4>>2]|0):(o=10,i&=255),(o-i|0)>>>0>=n>>>0?n|0&&(o=s?a[e>>2]|0:e,Qh(o+i|0,t,n)|0,i=i+n|0,(r[l>>0]|0)<0?a[e+4>>2]=i:r[l>>0]=i,r[c>>0]=0,Ze(o+i|0,c)):eg(e,o,i+n-o|0,i,i,0,n,t),P=u,e|0}function ng(e,t){return e|=0,t|=0,tg(e,t,V(t)|0)|0}function rg(e,t,n){return e|=0,t|=0,n|=0,e=n?um(e,t,n)|0:0,e|0}function ig(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var s=0,c=0;return s=r[e+11>>0]|0,c=s<<24>>24<0,c?s=a[e+4>>2]|0:s&=255,(o|0)==-1|s>>>0<t>>>0&&Xh(e),s=s-t|0,n=s>>>0<n>>>0?s:n,c&&(e=a[e>>2]|0),s=n>>>0>o>>>0,e=rg(e+t|0,i,s?o:n)|0,e?e|0:(n>>>0<o>>>0?-1:s&1)|0}function ag(e){e|=0}function og(e){e|=0,G(e)}function sg(e){return e|=0,21228}function cg(e,t,n){e|=0,t|=0,n|=0,a[e>>2]=n,a[e+4>>2]=t}function lg(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;return i=P,P=P+16|0,r=i,T_[a[(a[e>>2]|0)+12>>2]&15](r,e,t),e=(a[r+4>>2]|0)==(a[n+4>>2]|0)?(a[r>>2]|0)==(a[n>>2]|0):0,P=i,e|0}function ug(e,t,n){return e|=0,t|=0,n|=0,((a[t>>2]|0)==(n|0)?(a[t+4>>2]|0)==(e|0):0)|0}function dg(e,t,n){e|=0,t|=0,n|=0,(n|0)>256?Zh(e,21176,V(21176)|0):fg(e,0,n)}function fg(e,t,n){e|=0,t|=0,n|=0,pg(e,n)}function pg(e,t){e|=0,t|=0;var n=0,i=0,o=0,s=0,c=0;c=P,P=P+1040|0,o=c+1024|0,n=c,s=a[(Pp()|0)>>2]|0,i=mg(ym(t,n,1024)|0,n)|0,r[i>>0]|0?n=i:(a[o>>2]=t,dm(n,1024,21211,o)|0),a[(Pp()|0)>>2]=s,Zh(e,n,V(n)|0),P=c}function mg(e,t){e|=0,t|=0;var n=0,r=0;switch(e|0){case 0:n=t;break;case-1:e=a[(Pp()|0)>>2]|0,r=3;break;default:r=3}return(r|0)==3&&((e|0)==28?n=22145:k()),n|0}function hg(e){e|=0,G(e)}function gg(e){return e|=0,21353}function _g(e,t,n){e|=0,t|=0,n|=0,(n|0)>256?(yg()|0,t=6180):(bg()|0,t=6176),a[e>>2]=n,a[e+4>>2]=t}function vg(e,t,n){e|=0,t|=0,n|=0,(n|0)>256?Zh(e,21319,V(21319)|0):fg(e,0,n)}function yg(){return!(r[21488]|0)&&yh(21488)|0&&q(21488),6180}function bg(){return!(r[21480]|0)&&yh(21480)|0&&q(21480),6176}function xg(e){e|=0,Qm(e)}function Sg(e){e|=0,xg(e),G(e)}function Cg(e,t){e|=0,t|=0;var n=0;n=a[t+4>>2]|0,T_[a[(a[n>>2]|0)+24>>2]&15](e,n,a[t>>2]|0)}function wg(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0;for(s=P,P=P+16|0,o=s,a[t>>2]|0&&(i=r[n+11>>0]|0,i<<24>>24<0?i=a[n+4>>2]|0:i&=255,i|0&&ng(n,21417)|0,Cg(o,t),t=r[o+11>>0]|0,i=t<<24>>24<0,tg(n,i?a[o>>2]|0:o,i?a[o+4>>2]|0:t&255)|0,$h(o)),a[e>>2]=a[n>>2],a[e+4>>2]=a[n+4>>2],a[e+8>>2]=a[n+8>>2],i=0;(i|0)!=3;)a[n+(i<<2)>>2]=0,i=i+1|0;P=s}function Tg(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0;r=P,P=P+32|0,o=r+12|0,i=r,Zh(i,n,V(n)|0),wg(o,t,i),qh(e,o),$h(o),$h(i),a[e>>2]=6192,i=t,t=a[i+4>>2]|0,n=e+8|0,a[n>>2]=a[i>>2],a[n+4>>2]=t,P=r}function Eg(e,t){e|=0,t|=0;var n=0,r=0,i=0;i=P,P=P+16|0,r=i+8|0,n=h(16)|0,yg()|0,a[i>>2]=e,a[i+4>>2]=6180,a[r>>2]=a[i>>2],a[r+4>>2]=a[i+4>>2],Tg(n,r,t),g(n|0,4272,136)}function Dg(e){e|=0,e=h(8)|0,Kh(e,21420),a[e>>2]=5956,g(e|0,3928,123)}function Og(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0;S=P,P=P+16|0,p=S;do if(e>>>0<245){if(u=e>>>0<11?16:e+11&-8,e=u>>>3,f=a[5412]|0,n=f>>>e,n&3|0)return t=(n&1^1)+e|0,e=21688+(t<<1<<2)|0,n=e+8|0,r=a[n>>2]|0,i=r+8|0,o=a[i>>2]|0,(o|0)==(e|0)?a[5412]=f&~(1<<t):(a[o+12>>2]=e,a[n>>2]=o),x=t<<3,a[r+4>>2]=x|3,x=r+x+4|0,a[x>>2]=a[x>>2]|1,x=i,P=S,x|0;if(d=a[5414]|0,u>>>0>d>>>0){if(n|0)return t=2<<e,t=n<<e&(t|0-t),t=(t&0-t)+-1|0,c=t>>>12&16,t>>>=c,n=t>>>5&8,t>>>=n,o=t>>>2&4,t>>>=o,e=t>>>1&2,t>>>=e,r=t>>>1&1,r=(n|c|o|e|r)+(t>>>r)|0,t=21688+(r<<1<<2)|0,e=t+8|0,o=a[e>>2]|0,c=o+8|0,n=a[c>>2]|0,(n|0)==(t|0)?(e=f&~(1<<r),a[5412]=e):(a[n+12>>2]=t,a[e>>2]=n,e=f),x=r<<3,s=x-u|0,a[o+4>>2]=u|3,i=o+u|0,a[i+4>>2]=s|1,a[o+x>>2]=s,d|0&&(r=a[5417]|0,t=d>>>3,n=21688+(t<<1<<2)|0,t=1<<t,e&t?(e=n+8|0,t=a[e>>2]|0):(a[5412]=e|t,t=n,e=n+8|0),a[e>>2]=r,a[t+12>>2]=r,a[r+8>>2]=t,a[r+12>>2]=n),a[5414]=s,a[5417]=i,x=c,P=S,x|0;if(o=a[5413]|0,o){for(n=(o&0-o)+-1|0,i=n>>>12&16,n>>>=i,r=n>>>5&8,n>>>=r,s=n>>>2&4,n>>>=s,c=n>>>1&2,n>>>=c,l=n>>>1&1,l=a[21952+((r|i|s|c|l)+(n>>>l)<<2)>>2]|0,n=l,c=l,l=(a[l+4>>2]&-8)-u|0;e=a[n+16>>2]|0,!(!e&&(e=a[n+20>>2]|0,!e));)s=(a[e+4>>2]&-8)-u|0,i=s>>>0<l>>>0,n=e,c=i?e:c,l=i?s:l;if(s=c+u|0,s>>>0>c>>>0){i=a[c+24>>2]|0,t=a[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=a[e>>2]|0,!t&&(e=c+16|0,t=a[e>>2]|0,!t)){n=0;break}for(;;)if(r=t+20|0,n=a[r>>2]|0,n)t=n,e=r;else if(r=t+16|0,n=a[r>>2]|0,n)t=n,e=r;else break;a[e>>2]=0,n=t}else n=a[c+8>>2]|0,a[n+12>>2]=t,a[t+8>>2]=n,n=t;while(0);do if(i|0){if(t=a[c+28>>2]|0,e=21952+(t<<2)|0,(c|0)==(a[e>>2]|0)){if(a[e>>2]=n,!n){a[5413]=o&~(1<<t);break}}else if(x=i+16|0,a[((a[x>>2]|0)==(c|0)?x:i+20|0)>>2]=n,!n)break;a[n+24>>2]=i,t=a[c+16>>2]|0,t|0&&(a[n+16>>2]=t,a[t+24>>2]=n),t=a[c+20>>2]|0,t|0&&(a[n+20>>2]=t,a[t+24>>2]=n)}while(0);return l>>>0<16?(x=l+u|0,a[c+4>>2]=x|3,x=c+x+4|0,a[x>>2]=a[x>>2]|1):(a[c+4>>2]=u|3,a[s+4>>2]=l|1,a[s+l>>2]=l,d|0&&(r=a[5417]|0,t=d>>>3,n=21688+(t<<1<<2)|0,t=1<<t,t&f?(e=n+8|0,t=a[e>>2]|0):(a[5412]=t|f,t=n,e=n+8|0),a[e>>2]=r,a[t+12>>2]=r,a[r+8>>2]=t,a[r+12>>2]=n),a[5414]=l,a[5417]=s),x=c+8|0,P=S,x|0}else f=u}else f=u}else f=u}else if(e>>>0<=4294967231)if(e=e+11|0,u=e&-8,r=a[5413]|0,r){i=0-u|0,e>>>=8,e?u>>>0>16777215?l=31:(f=(e+1048320|0)>>>16&8,g=e<<f,c=(g+520192|0)>>>16&4,g<<=c,l=(g+245760|0)>>>16&2,l=14-(c|f|l)+(g<<l>>>15)|0,l=u>>>(l+7|0)&1|l<<1):l=0,n=a[21952+(l<<2)>>2]|0;a:do if(!n)n=0,e=0,g=61;else for(e=0,c=u<<((l|0)==31?0:25-(l>>>1)|0),o=0;;){if(s=(a[n+4>>2]&-8)-u|0,s>>>0<i>>>0)if(s)e=n,i=s;else{e=n,i=0,g=65;break a}if(g=a[n+20>>2]|0,n=a[n+16+(c>>>31<<2)>>2]|0,o=(g|0)==0|(g|0)==(n|0)?o:g,n)c<<=1;else{n=o,g=61;break}}while(0);if((g|0)==61){if((n|0)==0&(e|0)==0){if(e=2<<l,e=(e|0-e)&r,!e){f=u;break}f=(e&0-e)+-1|0,s=f>>>12&16,f>>>=s,o=f>>>5&8,f>>>=o,c=f>>>2&4,f>>>=c,l=f>>>1&2,f>>>=l,n=f>>>1&1,e=0,n=a[21952+((o|s|c|l|n)+(f>>>n)<<2)>>2]|0}n?g=65:(c=e,s=i)}if((g|0)==65)for(o=n;;)if(f=(a[o+4>>2]&-8)-u|0,n=f>>>0<i>>>0,i=n?f:i,e=n?o:e,n=a[o+16>>2]|0,n||=a[o+20>>2]|0,n)o=n;else{c=e,s=i;break}if(c|0&&s>>>0<((a[5414]|0)-u|0)>>>0&&(d=c+u|0,d>>>0>c>>>0)){o=a[c+24>>2]|0,t=a[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=a[e>>2]|0,!t&&(e=c+16|0,t=a[e>>2]|0,!t)){t=0;break}for(;;)if(i=t+20|0,n=a[i>>2]|0,n)t=n,e=i;else if(i=t+16|0,n=a[i>>2]|0,n)t=n,e=i;else break;a[e>>2]=0}else x=a[c+8>>2]|0,a[x+12>>2]=t,a[t+8>>2]=x;while(0);do if(o){if(e=a[c+28>>2]|0,n=21952+(e<<2)|0,(c|0)==(a[n>>2]|0)){if(a[n>>2]=t,!t){r&=~(1<<e),a[5413]=r;break}}else if(x=o+16|0,a[((a[x>>2]|0)==(c|0)?x:o+20|0)>>2]=t,!t)break;a[t+24>>2]=o,e=a[c+16>>2]|0,e|0&&(a[t+16>>2]=e,a[e+24>>2]=t),e=a[c+20>>2]|0,e&&(a[t+20>>2]=e,a[e+24>>2]=t)}while(0);b:do if(s>>>0<16)x=s+u|0,a[c+4>>2]=x|3,x=c+x+4|0,a[x>>2]=a[x>>2]|1;else{if(a[c+4>>2]=u|3,a[d+4>>2]=s|1,a[d+s>>2]=s,t=s>>>3,s>>>0<256){n=21688+(t<<1<<2)|0,e=a[5412]|0,t=1<<t,e&t?(e=n+8|0,t=a[e>>2]|0):(a[5412]=e|t,t=n,e=n+8|0),a[e>>2]=d,a[t+12>>2]=d,a[d+8>>2]=t,a[d+12>>2]=n;break}if(t=s>>>8,t?s>>>0>16777215?n=31:(b=(t+1048320|0)>>>16&8,x=t<<b,y=(x+520192|0)>>>16&4,x<<=y,n=(x+245760|0)>>>16&2,n=14-(y|b|n)+(x<<n>>>15)|0,n=s>>>(n+7|0)&1|n<<1):n=0,t=21952+(n<<2)|0,a[d+28>>2]=n,e=d+16|0,a[e+4>>2]=0,a[e>>2]=0,e=1<<n,!(r&e)){a[5413]=r|e,a[t>>2]=d,a[d+24>>2]=t,a[d+12>>2]=d,a[d+8>>2]=d;break}t=a[t>>2]|0;c:do if((a[t+4>>2]&-8|0)!=(s|0)){for(r=s<<((n|0)==31?0:25-(n>>>1)|0);n=t+16+(r>>>31<<2)|0,e=a[n>>2]|0,e;)if((a[e+4>>2]&-8|0)==(s|0)){t=e;break c}else r<<=1,t=e;a[n>>2]=d,a[d+24>>2]=t,a[d+12>>2]=d,a[d+8>>2]=d;break b}while(0);b=t+8|0,x=a[b>>2]|0,a[x+12>>2]=d,a[b>>2]=d,a[d+8>>2]=x,a[d+12>>2]=t,a[d+24>>2]=0}while(0);return x=c+8|0,P=S,x|0}else f=u}else f=u;else f=-1;while(0);if(n=a[5414]|0,n>>>0>=f>>>0)return t=n-f|0,e=a[5417]|0,t>>>0>15?(x=e+f|0,a[5417]=x,a[5414]=t,a[x+4>>2]=t|1,a[e+n>>2]=t,a[e+4>>2]=f|3):(a[5414]=0,a[5417]=0,a[e+4>>2]=n|3,x=e+n+4|0,a[x>>2]=a[x>>2]|1),x=e+8|0,P=S,x|0;if(s=a[5415]|0,s>>>0>f>>>0)return y=s-f|0,a[5415]=y,x=a[5418]|0,b=x+f|0,a[5418]=b,a[b+4>>2]=y|1,a[x+4>>2]=f|3,x=x+8|0,P=S,x|0;if(a[5530]|0?e=a[5532]|0:(a[5532]=4096,a[5531]=4096,a[5533]=-1,a[5534]=-1,a[5535]=0,a[5523]=0,a[5530]=p&-16^1431655768,e=4096),c=f+48|0,l=f+47|0,o=e+l|0,i=0-e|0,u=o&i,u>>>0<=f>>>0||(e=a[5522]|0,e|0&&(d=a[5520]|0,p=d+u|0,p>>>0<=d>>>0|p>>>0>e>>>0)))return x=0,P=S,x|0;d:do if(a[5523]&4)t=0,g=143;else{n=a[5418]|0;e:do if(n){for(r=22096;p=a[r>>2]|0,!(p>>>0<=n>>>0&&(p+(a[r+4>>2]|0)|0)>>>0>n>>>0);)if(e=a[r+8>>2]|0,e)r=e;else{g=128;break e}if(t=o-s&i,t>>>0<2147483647)if(e=Ag(t)|0,(e|0)==((a[r>>2]|0)+(a[r+4>>2]|0)|0)){if((e|0)!=-1){s=t,o=e,g=145;break d}}else r=e,g=136;else t=0}else g=128;while(0);do if((g|0)==128)if(n=Ag(0)|0,(n|0)!=-1&&(t=n,m=a[5531]|0,h=m+-1|0,t=(h&t|0?(h+t&0-m)-t|0:0)+u|0,m=a[5520]|0,h=t+m|0,t>>>0>f>>>0&t>>>0<2147483647)){if(p=a[5522]|0,p|0&&h>>>0<=m>>>0|h>>>0>p>>>0){t=0;break}if(e=Ag(t)|0,(e|0)==(n|0)){s=t,o=n,g=145;break d}else r=e,g=136}else t=0;while(0);do if((g|0)==136){if(n=0-t|0,!(c>>>0>t>>>0&(t>>>0<2147483647&(r|0)!=-1)))if((r|0)==-1){t=0;break}else{s=t,o=r,g=145;break d}if(e=a[5532]|0,e=l-t+e&0-e,e>>>0>=2147483647){s=t,o=r,g=145;break d}if((Ag(e)|0)==-1){Ag(n)|0,t=0;break}else{s=e+t|0,o=r,g=145;break d}}while(0);a[5523]|=4,g=143}while(0);if((g|0)==143&&u>>>0<2147483647&&(y=Ag(u)|0,h=Ag(0)|0,_=h-y|0,v=_>>>0>(f+40|0)>>>0,!((y|0)==-1|v^1|y>>>0<h>>>0&((y|0)!=-1&(h|0)!=-1)^1))&&(s=v?_:t,o=y,g=145),(g|0)==145){t=(a[5520]|0)+s|0,a[5520]=t,t>>>0>(a[5521]|0)>>>0&&(a[5521]=t),l=a[5418]|0;f:do if(l){for(t=22096;;){if(e=a[t>>2]|0,n=a[t+4>>2]|0,(o|0)==(e+n|0)){g=154;break}if(r=a[t+8>>2]|0,r)t=r;else break}if((g|0)==154&&(b=t+4|0,!(a[t+12>>2]&8|0))&&o>>>0>l>>>0&e>>>0<=l>>>0){a[b>>2]=n+s,x=(a[5415]|0)+s|0,y=l+8|0,y=y&7|0?0-y&7:0,b=l+y|0,y=x-y|0,a[5418]=b,a[5415]=y,a[b+4>>2]=y|1,a[l+x+4>>2]=40,a[5419]=a[5534];break}for(o>>>0<(a[5416]|0)>>>0&&(a[5416]=o),n=o+s|0,t=22096;;){if((a[t>>2]|0)==(n|0)){g=162;break}if(e=a[t+8>>2]|0,e)t=e;else break}if((g|0)==162&&!(a[t+12>>2]&8|0)){a[t>>2]=o,d=t+4|0,a[d>>2]=(a[d>>2]|0)+s,d=o+8|0,d=o+(d&7|0?0-d&7:0)|0,t=n+8|0,t=n+(t&7|0?0-t&7:0)|0,u=d+f|0,c=t-d-f|0,a[d+4>>2]=f|3;g:do if((l|0)==(t|0))x=(a[5415]|0)+c|0,a[5415]=x,a[5418]=u,a[u+4>>2]=x|1;else{if((a[5417]|0)==(t|0)){x=(a[5414]|0)+c|0,a[5414]=x,a[5417]=u,a[u+4>>2]=x|1,a[u+x>>2]=x;break}if(e=a[t+4>>2]|0,(e&3|0)==1){s=e&-8,r=e>>>3;h:do if(e>>>0<256)if(e=a[t+8>>2]|0,n=a[t+12>>2]|0,(n|0)==(e|0)){a[5412]&=~(1<<r);break}else{a[e+12>>2]=n,a[n+8>>2]=e;break}else{o=a[t+24>>2]|0,e=a[t+12>>2]|0;do if((e|0)==(t|0)){if(n=t+16|0,r=n+4|0,e=a[r>>2]|0,e)n=r;else if(e=a[n>>2]|0,!e){e=0;break}for(;;)if(i=e+20|0,r=a[i>>2]|0,r)e=r,n=i;else if(i=e+16|0,r=a[i>>2]|0,r)e=r,n=i;else break;a[n>>2]=0}else x=a[t+8>>2]|0,a[x+12>>2]=e,a[e+8>>2]=x;while(0);if(!o)break;n=a[t+28>>2]|0,r=21952+(n<<2)|0;do if((a[r>>2]|0)!=(t|0)){if(x=o+16|0,a[((a[x>>2]|0)==(t|0)?x:o+20|0)>>2]=e,!e)break h}else{if(a[r>>2]=e,e|0)break;a[5413]&=~(1<<n);break h}while(0);if(a[e+24>>2]=o,n=t+16|0,r=a[n>>2]|0,r|0&&(a[e+16>>2]=r,a[r+24>>2]=e),n=a[n+4>>2]|0,!n)break;a[e+20>>2]=n,a[n+24>>2]=e}while(0);t=t+s|0,i=s+c|0}else i=c;if(t=t+4|0,a[t>>2]=a[t>>2]&-2,a[u+4>>2]=i|1,a[u+i>>2]=i,t=i>>>3,i>>>0<256){n=21688+(t<<1<<2)|0,e=a[5412]|0,t=1<<t,e&t?(e=n+8|0,t=a[e>>2]|0):(a[5412]=e|t,t=n,e=n+8|0),a[e>>2]=u,a[t+12>>2]=u,a[u+8>>2]=t,a[u+12>>2]=n;break}t=i>>>8;do if(!t)r=0;else{if(i>>>0>16777215){r=31;break}b=(t+1048320|0)>>>16&8,x=t<<b,y=(x+520192|0)>>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<<r>>>15)|0,r=i>>>(r+7|0)&1|r<<1}while(0);if(t=21952+(r<<2)|0,a[u+28>>2]=r,e=u+16|0,a[e+4>>2]=0,a[e>>2]=0,e=a[5413]|0,n=1<<r,!(e&n)){a[5413]=e|n,a[t>>2]=u,a[u+24>>2]=t,a[u+12>>2]=u,a[u+8>>2]=u;break}t=a[t>>2]|0;i:do if((a[t+4>>2]&-8|0)!=(i|0)){for(r=i<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=a[n>>2]|0,e;)if((a[e+4>>2]&-8|0)==(i|0)){t=e;break i}else r<<=1,t=e;a[n>>2]=u,a[u+24>>2]=t,a[u+12>>2]=u,a[u+8>>2]=u;break g}while(0);b=t+8|0,x=a[b>>2]|0,a[x+12>>2]=u,a[b>>2]=u,a[u+8>>2]=x,a[u+12>>2]=t,a[u+24>>2]=0}while(0);return x=d+8|0,P=S,x|0}for(t=22096;e=a[t>>2]|0,!(e>>>0<=l>>>0&&(x=e+(a[t+4>>2]|0)|0,x>>>0>l>>>0));)t=a[t+8>>2]|0;i=x+-47|0,e=i+8|0,e=i+(e&7|0?0-e&7:0)|0,i=l+16|0,e=e>>>0<i>>>0?l:e,t=e+8|0,n=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=n-y|0,a[5418]=b,a[5415]=y,a[b+4>>2]=y|1,a[o+n+4>>2]=40,a[5419]=a[5534],n=e+4|0,a[n>>2]=27,a[t>>2]=a[5524],a[t+4>>2]=a[5525],a[t+8>>2]=a[5526],a[t+12>>2]=a[5527],a[5524]=o,a[5525]=s,a[5527]=0,a[5526]=t,t=e+24|0;do b=t,t=t+4|0,a[t>>2]=7;while((b+8|0)>>>0<x>>>0);if((e|0)!=(l|0)){if(o=e-l|0,a[n>>2]=a[n>>2]&-2,a[l+4>>2]=o|1,a[e>>2]=o,t=o>>>3,o>>>0<256){n=21688+(t<<1<<2)|0,e=a[5412]|0,t=1<<t,e&t?(e=n+8|0,t=a[e>>2]|0):(a[5412]=e|t,t=n,e=n+8|0),a[e>>2]=l,a[t+12>>2]=l,a[l+8>>2]=t,a[l+12>>2]=n;break}if(t=o>>>8,t?o>>>0>16777215?r=31:(b=(t+1048320|0)>>>16&8,x=t<<b,y=(x+520192|0)>>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<<r>>>15)|0,r=o>>>(r+7|0)&1|r<<1):r=0,n=21952+(r<<2)|0,a[l+28>>2]=r,a[l+20>>2]=0,a[i>>2]=0,t=a[5413]|0,e=1<<r,!(t&e)){a[5413]=t|e,a[n>>2]=l,a[l+24>>2]=n,a[l+12>>2]=l,a[l+8>>2]=l;break}t=a[n>>2]|0;j:do if((a[t+4>>2]&-8|0)!=(o|0)){for(r=o<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=a[n>>2]|0,e;)if((a[e+4>>2]&-8|0)==(o|0)){t=e;break j}else r<<=1,t=e;a[n>>2]=l,a[l+24>>2]=t,a[l+12>>2]=l,a[l+8>>2]=l;break f}while(0);b=t+8|0,x=a[b>>2]|0,a[x+12>>2]=l,a[b>>2]=l,a[l+8>>2]=x,a[l+12>>2]=t,a[l+24>>2]=0}}else x=a[5416]|0,(x|0)==0|o>>>0<x>>>0&&(a[5416]=o),a[5524]=o,a[5525]=s,a[5527]=0,a[5421]=a[5530],a[5420]=-1,a[5425]=21688,a[5424]=21688,a[5427]=21696,a[5426]=21696,a[5429]=21704,a[5428]=21704,a[5431]=21712,a[5430]=21712,a[5433]=21720,a[5432]=21720,a[5435]=21728,a[5434]=21728,a[5437]=21736,a[5436]=21736,a[5439]=21744,a[5438]=21744,a[5441]=21752,a[5440]=21752,a[5443]=21760,a[5442]=21760,a[5445]=21768,a[5444]=21768,a[5447]=21776,a[5446]=21776,a[5449]=21784,a[5448]=21784,a[5451]=21792,a[5450]=21792,a[5453]=21800,a[5452]=21800,a[5455]=21808,a[5454]=21808,a[5457]=21816,a[5456]=21816,a[5459]=21824,a[5458]=21824,a[5461]=21832,a[5460]=21832,a[5463]=21840,a[5462]=21840,a[5465]=21848,a[5464]=21848,a[5467]=21856,a[5466]=21856,a[5469]=21864,a[5468]=21864,a[5471]=21872,a[5470]=21872,a[5473]=21880,a[5472]=21880,a[5475]=21888,a[5474]=21888,a[5477]=21896,a[5476]=21896,a[5479]=21904,a[5478]=21904,a[5481]=21912,a[5480]=21912,a[5483]=21920,a[5482]=21920,a[5485]=21928,a[5484]=21928,a[5487]=21936,a[5486]=21936,x=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=x-y|0,a[5418]=b,a[5415]=y,a[b+4>>2]=y|1,a[o+x+4>>2]=40,a[5419]=a[5534];while(0);if(t=a[5415]|0,t>>>0>f>>>0)return y=t-f|0,a[5415]=y,x=a[5418]|0,b=x+f|0,a[5418]=b,a[b+4>>2]=y|1,a[x+4>>2]=f|3,x=x+8|0,P=S,x|0}return a[(Pp()|0)>>2]=48,x=0,P=S,x|0}function kg(e){e|=0;var t=0,n=0,r=0,i=0,o=0,s=0,c=0,l=0;if(e){n=e+-8|0,i=a[5416]|0,e=a[e+-4>>2]|0,t=e&-8,l=n+t|0;do if(e&1)c=n,s=n;else{if(r=a[n>>2]|0,!(e&3)||(s=n+(0-r)|0,o=r+t|0,s>>>0<i>>>0))return;if((a[5417]|0)==(s|0)){if(e=l+4|0,t=a[e>>2]|0,(t&3|0)!=3){c=s,t=o;break}a[5414]=o,a[e>>2]=t&-2,a[s+4>>2]=o|1,a[s+o>>2]=o;return}if(n=r>>>3,r>>>0<256)if(e=a[s+8>>2]|0,t=a[s+12>>2]|0,(t|0)==(e|0)){a[5412]&=~(1<<n),c=s,t=o;break}else{a[e+12>>2]=t,a[t+8>>2]=e,c=s,t=o;break}i=a[s+24>>2]|0,e=a[s+12>>2]|0;do if((e|0)==(s|0)){if(t=s+16|0,n=t+4|0,e=a[n>>2]|0,e)t=n;else if(e=a[t>>2]|0,!e){e=0;break}for(;;)if(r=e+20|0,n=a[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=a[r>>2]|0,n)e=n,t=r;else break;a[t>>2]=0}else c=a[s+8>>2]|0,a[c+12>>2]=e,a[e+8>>2]=c;while(0);if(i){if(t=a[s+28>>2]|0,n=21952+(t<<2)|0,(a[n>>2]|0)==(s|0)){if(a[n>>2]=e,!e){a[5413]&=~(1<<t),c=s,t=o;break}}else if(c=i+16|0,a[((a[c>>2]|0)==(s|0)?c:i+20|0)>>2]=e,!e){c=s,t=o;break}a[e+24>>2]=i,t=s+16|0,n=a[t>>2]|0,n|0&&(a[e+16>>2]=n,a[n+24>>2]=e),t=a[t+4>>2]|0,t?(a[e+20>>2]=t,a[t+24>>2]=e,c=s,t=o):(c=s,t=o)}else c=s,t=o}while(0);if(!(s>>>0>=l>>>0)&&(e=l+4|0,r=a[e>>2]|0,r&1)){if(r&2)a[e>>2]=r&-2,a[c+4>>2]=t|1,a[s+t>>2]=t,i=t;else{if((a[5418]|0)==(l|0)){if(l=(a[5415]|0)+t|0,a[5415]=l,a[5418]=c,a[c+4>>2]=l|1,(c|0)!=(a[5417]|0))return;a[5417]=0,a[5414]=0;return}if((a[5417]|0)==(l|0)){l=(a[5414]|0)+t|0,a[5414]=l,a[5417]=s,a[c+4>>2]=l|1,a[s+l>>2]=l;return}i=(r&-8)+t|0,n=r>>>3;do if(r>>>0<256)if(t=a[l+8>>2]|0,e=a[l+12>>2]|0,(e|0)==(t|0)){a[5412]&=~(1<<n);break}else{a[t+12>>2]=e,a[e+8>>2]=t;break}else{o=a[l+24>>2]|0,e=a[l+12>>2]|0;do if((e|0)==(l|0)){if(t=l+16|0,n=t+4|0,e=a[n>>2]|0,e)t=n;else if(e=a[t>>2]|0,!e){n=0;break}for(;;)if(r=e+20|0,n=a[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=a[r>>2]|0,n)e=n,t=r;else break;a[t>>2]=0,n=e}else n=a[l+8>>2]|0,a[n+12>>2]=e,a[e+8>>2]=n,n=e;while(0);if(o|0){if(e=a[l+28>>2]|0,t=21952+(e<<2)|0,(a[t>>2]|0)==(l|0)){if(a[t>>2]=n,!n){a[5413]&=~(1<<e);break}}else if(r=o+16|0,a[((a[r>>2]|0)==(l|0)?r:o+20|0)>>2]=n,!n)break;a[n+24>>2]=o,e=l+16|0,t=a[e>>2]|0,t|0&&(a[n+16>>2]=t,a[t+24>>2]=n),e=a[e+4>>2]|0,e|0&&(a[n+20>>2]=e,a[e+24>>2]=n)}}while(0);if(a[c+4>>2]=i|1,a[s+i>>2]=i,(c|0)==(a[5417]|0)){a[5414]=i;return}}if(e=i>>>3,i>>>0<256){n=21688+(e<<1<<2)|0,t=a[5412]|0,e=1<<e,t&e?(t=n+8|0,e=a[t>>2]|0):(a[5412]=t|e,e=n,t=n+8|0),a[t>>2]=c,a[e+12>>2]=c,a[c+8>>2]=e,a[c+12>>2]=n;return}e=i>>>8,e?i>>>0>16777215?r=31:(s=(e+1048320|0)>>>16&8,l=e<<s,o=(l+520192|0)>>>16&4,l<<=o,r=(l+245760|0)>>>16&2,r=14-(o|s|r)+(l<<r>>>15)|0,r=i>>>(r+7|0)&1|r<<1):r=0,e=21952+(r<<2)|0,a[c+28>>2]=r,a[c+20>>2]=0,a[c+16>>2]=0,t=a[5413]|0,n=1<<r;a:do if(!(t&n))a[5413]=t|n,a[e>>2]=c,a[c+24>>2]=e,a[c+12>>2]=c,a[c+8>>2]=c;else{e=a[e>>2]|0;b:do if((a[e+4>>2]&-8|0)!=(i|0)){for(r=i<<((r|0)==31?0:25-(r>>>1)|0);n=e+16+(r>>>31<<2)|0,t=a[n>>2]|0,t;)if((a[t+4>>2]&-8|0)==(i|0)){e=t;break b}else r<<=1,e=t;a[n>>2]=c,a[c+24>>2]=e,a[c+12>>2]=c,a[c+8>>2]=c;break a}while(0);s=e+8|0,l=a[s>>2]|0,a[l+12>>2]=c,a[s>>2]=c,a[c+8>>2]=l,a[c+12>>2]=e,a[c+24>>2]=0}while(0);if(l=(a[5420]|0)+-1|0,a[5420]=l,!(l|0)){for(e=22104;e=a[e>>2]|0,e;)e=e+8|0;a[5420]=-1}}}}function Ag(e){e|=0;var t=0,n=0,r=0;r=e+3&-4,e=Ug()|0,t=a[e>>2]|0,n=t+r|0;do if((r|0)<1|n>>>0>t>>>0){if(n>>>0>(A()|0)>>>0&&!(M(n|0)|0))break;return a[e>>2]=n,r=t,r|0}while(0);return a[(Pp()|0)>>2]=48,r=-1,r|0}function jg(e){e|=0;var t=0;return t=P,P=P+e|0,P=P+15&-16,t|0}function Mg(e){e|=0,P=e}function Ng(){return P|0}function Pg(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0;return a=e&65535,i=t&65535,n=u(i,a)|0,r=e>>>16,e=(n>>>16)+(u(i,r)|0)|0,i=t>>>16,t=u(i,a)|0,(p((e>>>16)+(u(i,r)|0)+(((e&65535)+t|0)>>>16)|0),e+t<<16|n&65535|0)|0}function Fg(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0;return i=e,a=n,n=Pg(i,a)|0,e=m()|0,(p((u(t,a)|0)+(u(r,i)|0)+e|e&0|0),n|0)|0}function Ig(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,n=e+n>>>0,(p(t+r+(n>>>0<e>>>0|0)>>>0|0),n|0)|0}function Lg(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,r=t-r-(n>>>0>e>>>0|0)>>>0,(p(r|0),e-n>>>0|0)|0}function Rg(e){return e|=0,(e?31-(d(e^e-1)|0)|0:32)|0}function zg(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var o=0,s=0,c=0,l=0,u=0,f=0,h=0,g=0,_=0,v=0;if(f=e,l=t,u=l,s=n,g=r,c=g,!u)return o=(i|0)!=0,c?o?(a[i>>2]=e|0,a[i+4>>2]=t&0,g=0,i=0,(p(g|0),i)|0):(g=0,i=0,(p(g|0),i)|0):(o&&(a[i>>2]=(f>>>0)%(s>>>0),a[i+4>>2]=0),g=0,i=(f>>>0)/(s>>>0)>>>0,(p(g|0),i)|0);o=(c|0)==0;do if(s){if(!o){if(o=(d(c|0)|0)-(d(u|0)|0)|0,o>>>0<=31){h=o+1|0,c=31-o|0,t=o-31>>31,s=h,e=f>>>(h>>>0)&t|u<<c,t=u>>>(h>>>0)&t,o=0,c=f<<c;break}return i?(a[i>>2]=e|0,a[i+4>>2]=l|t&0,g=0,i=0,(p(g|0),i)|0):(g=0,i=0,(p(g|0),i)|0)}if(o=s-1|0,o&s|0){c=(d(s|0)|0)+33-(d(u|0)|0)|0,v=64-c|0,h=32-c|0,l=h>>31,_=c-32|0,t=_>>31,s=c,e=h-1>>31&u>>>(_>>>0)|(u<<h|f>>>(c>>>0))&t,t&=u>>>(c>>>0),o=f<<v&l,c=(u<<v|f>>>(_>>>0))&l|f<<h&c-33>>31;break}return i|0&&(a[i>>2]=o&f,a[i+4>>2]=0),(s|0)==1?(_=l|t&0,v=e|0,(p(_|0),v)|0):(v=Rg(s|0)|0,_=u>>>(v>>>0)|0,v=u<<32-v|f>>>(v>>>0)|0,(p(_|0),v)|0)}else{if(o)return i|0&&(a[i>>2]=(u>>>0)%(s>>>0),a[i+4>>2]=0),_=0,v=(u>>>0)/(s>>>0)>>>0,(p(_|0),v)|0;if(!f)return i|0&&(a[i>>2]=0,a[i+4>>2]=(u>>>0)%(c>>>0)),_=0,v=(u>>>0)/(c>>>0)>>>0,(p(_|0),v)|0;if(o=c-1|0,!(o&c))return i|0&&(a[i>>2]=e|0,a[i+4>>2]=o&u|t&0),_=0,v=u>>>((Rg(c|0)|0)>>>0),(p(_|0),v)|0;if(o=(d(c|0)|0)-(d(u|0)|0)|0,o>>>0<=30){t=o+1|0,c=31-o|0,s=t,e=u<<c|f>>>(t>>>0),t=u>>>(t>>>0),o=0,c=f<<c;break}return i?(a[i>>2]=e|0,a[i+4>>2]=l|t&0,_=0,v=0,(p(_|0),v)|0):(_=0,v=0,(p(_|0),v)|0)}while(0);if(!s)u=c,l=0,c=0;else{h=n|0,f=g|r&0,u=Ig(h|0,f|0,-1,-1)|0,n=m()|0,l=c,c=0;do r=l,l=o>>>31|l<<1,o=c|o<<1,r=e<<1|r>>>31|0,g=e>>>31|t<<1|0,Lg(u|0,n|0,r|0,g|0)|0,v=m()|0,_=v>>31|((v|0)<0?-1:0)<<1,c=_&1,e=Lg(r|0,g|0,_&h|0,(((v|0)<0?-1:0)>>31|((v|0)<0?-1:0)<<1)&f|0)|0,t=m()|0,s=s-1|0;while(s|0);u=l,l=0}return s=0,i|0&&(a[i>>2]=e,a[i+4>>2]=t),_=(o|0)>>>31|(u|s)<<1|(s<<1|o>>>31)&0|l,v=(o<<1|0)&-2|c,(p(_|0),v)|0}function Bg(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,zg(e,t,n,r,0)|0}function Vg(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(p(t>>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(p(0),t>>>n-32|0)}function Hg(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(p(t<<n|(e&(1<<n)-1<<32-n)>>>32-n|0),e<<n):(p(e<<n-32|0),0)}function Ug(){return 22176}function Wg(e){return e|=0,(e&255)<<24|(e>>8&255)<<16|(e>>16&255)<<8|e>>>24|0}function Gg(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0;if((n|0)>=512)return j(e|0,t|0,n|0)|0,e|0;if(s=e|0,o=e+n|0,(e&3)==(t&3)){for(;e&3;){if(!n)return s|0;r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0,n=n-1|0}for(n=o&-4|0,i=n-64|0;(e|0)<=(i|0);)a[e>>2]=a[t>>2],a[e+4>>2]=a[t+4>>2],a[e+8>>2]=a[t+8>>2],a[e+12>>2]=a[t+12>>2],a[e+16>>2]=a[t+16>>2],a[e+20>>2]=a[t+20>>2],a[e+24>>2]=a[t+24>>2],a[e+28>>2]=a[t+28>>2],a[e+32>>2]=a[t+32>>2],a[e+36>>2]=a[t+36>>2],a[e+40>>2]=a[t+40>>2],a[e+44>>2]=a[t+44>>2],a[e+48>>2]=a[t+48>>2],a[e+52>>2]=a[t+52>>2],a[e+56>>2]=a[t+56>>2],a[e+60>>2]=a[t+60>>2],e=e+64|0,t=t+64|0;for(;(e|0)<(n|0);)a[e>>2]=a[t>>2],e=e+4|0,t=t+4|0}else for(n=o-4|0;(e|0)<(n|0);)r[e>>0]=r[t>>0]|0,r[e+1>>0]=r[t+1>>0]|0,r[e+2>>0]=r[t+2>>0]|0,r[e+3>>0]=r[t+3>>0]|0,e=e+4|0,t=t+4|0;for(;(e|0)<(o|0);)r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0;return s|0}function Kg(e,t,n){e|=0,t|=0,n|=0;var i=0;if((t|0)<(e|0)&(e|0)<(t+n|0)){for(i=e,t=t+n|0,e=e+n|0;(n|0)>0;)e=e-1|0,t=t-1|0,n=n-1|0,r[e>>0]=r[t>>0]|0;e=i}else Gg(e,t,n)|0;return e|0}function qg(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0,c=0;if(s=e+n|0,t&=255,(n|0)>=67){for(;e&3;)r[e>>0]=t,e=e+1|0;for(i=s&-4|0,c=t|t<<8|t<<16|t<<24,o=i-64|0;(e|0)<=(o|0);)a[e>>2]=c,a[e+4>>2]=c,a[e+8>>2]=c,a[e+12>>2]=c,a[e+16>>2]=c,a[e+20>>2]=c,a[e+24>>2]=c,a[e+28>>2]=c,a[e+32>>2]=c,a[e+36>>2]=c,a[e+40>>2]=c,a[e+44>>2]=c,a[e+48>>2]=c,a[e+52>>2]=c,a[e+56>>2]=c,a[e+60>>2]=c,e=e+64|0;for(;(e|0)<(i|0);)a[e>>2]=c,e=e+4|0}for(;(e|0)<(s|0);)r[e>>0]=t,e=e+1|0;return s-n|0}function Jg(e){return e|=0,__[e&3]()|0}function Yg(e,t){return e|=0,t|=0,v_[e&15](t|0)|0}function Xg(e,t,n,r,i,a,o){return e|=0,t|=0,n=+n,r|=0,i|=0,a|=0,o|=0,y_[e&1](t|0,+n,r|0,i|0,a|0,o|0)|0}function Zg(e,t,n){return e|=0,t|=0,n|=0,b_[e&63](t|0,n|0)|0}function Qg(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,x_[e&7](t|0,n|0,r|0)|0}function $g(e){e|=0,S_[e&3]()}function e_(e,t){e|=0,t|=0,C_[e&255](t|0)}function t_(e,t,n){e|=0,t|=0,n|=0,w_[e&15](t|0,n|0)}function n_(e,t,n,r){e|=0,t|=0,n|=0,r|=0,T_[e&15](t|0,n|0,r|0)}function r_(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0,E_[e&7](t|0,n|0,r|0,i|0)}function i_(e,t,n,r,i,a){e|=0,t|=0,n|=0,r|=0,i|=0,a|=0,X[e&3](t|0,n|0,r|0,i|0,a|0)}function a_(e,t,n,r,i,a,o){e|=0,t|=0,n|=0,r|=0,i|=0,a|=0,o|=0,D_[e&3](t|0,n|0,r|0,i|0,a|0,o|0)}function o_(){return f(0),0}function s_(e){return e|=0,f(1),0}function c_(e,t,n,r,i,a){return e|=0,t=+t,n|=0,r|=0,i|=0,a|=0,f(2),0}function l_(e,t){return e|=0,t|=0,f(3),0}function u_(e,t,n){return e|=0,t|=0,n|=0,f(4),0}function d_(){f(5)}function Y(e){e|=0,f(6)}function f_(e,t){e|=0,t|=0,f(7)}function p_(e,t,n){e|=0,t|=0,n|=0,f(8)}function m_(e,t,n,r){e|=0,t|=0,n|=0,r|=0,f(9)}function h_(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0,f(10)}function g_(e,t,n,r,i,a){e|=0,t|=0,n|=0,r|=0,i|=0,a|=0,f(11)}var __=[o_,yu,dd,o_],v_=[s_,eh,st,pt,Wm,qm,zh,sg,gg,ru,ne,$u,xu,pd,s_,s_],y_=[c_,Jp],b_=[l_,me,Ce,ft,Kn,Sr,Mr,Kr,qr,Xr,Fi,Hi,oa,pa,xa,Oa,ho,wo,No,Ro,qo,Qo,ss,fs,xs,Ps,Vs,Ks,ec,lc,Ec,Nc,Vc,Xc,ol,pl,Cl,Ml,Bl,ql,tu,Ku,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_,l_],x_=[u_,pm,km,ah,sh,lg,ug,u_],S_=[d_,rh,bm,d_],C_=[Y,Bh,fe,pe,he,xe,Se,we,Qm,H,mt,ot,lt,ut,yt,bt,jt,Mt,en,tn,nn,Sn,Wn,Gn,qn,vr,Cr,wr,Tr,Er,Ar,jr,Nr,Wr,Gr,Jr,Yr,Ni,Pi,Ii,Bi,Vi,ia,aa,sa,da,fa,ba,W,Sa,Ea,Da,po,mo,go,To,Eo,jo,Mo,Po,zo,Bo,Go,Ko,Jo,$o,es,as,os,cs,ps,ms,ys,bs,Ss,Ms,Ns,Fs,zs,Bs,Hs,qs,Js,Qs,$s,tc,sc,cc,wc,Tc,Dc,jc,Mc,zc,Bc,Hc,Jc,Yc,il,al,sl,dl,fl,xl,Sl,wl,Al,jl,Rl,zl,Vl,Gl,Kl,$l,eu,nu,Tm,Em,Dm,Om,Rm,Hm,Um,Gm,Km,$m,th,nh,ih,oh,dh,Lh,Rh,ag,og,hg,xg,Sg,ou,nd,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y],w_=[f_,ct,dt,te,re,ie,ae,oe,Yp,f_,f_,f_,f_,f_,f_,f_],T_=[p_,cg,dg,_g,vg,L,R,Ru,Dd,Nd,p_,p_,p_,p_,p_,p_],E_=[m_,Mm,Vm,mh,Ou,bd,m_,m_],X=[h_,jm,Bm,ph],D_=[g_,Am,zm,fh];return{__ZSt18uncaught_exceptionv:Fh,___cxa_can_catch:Mh,___cxa_is_pointer_type:Nh,___embind_register_native_and_builtin_types:Hd,___errno_location:Pp,___getTypeName:Np,___muldi3:Fg,___udivdi3:Bg,_bitshift64Lshr:Vg,_bitshift64Shl:Hg,_emscripten_get_sbrk_ptr:Ug,_free:kg,_i64Add:Ig,_i64Subtract:Lg,_llvm_bswap_i32:Wg,_malloc:Og,_memcpy:Gg,_memmove:Kg,_memset:qg,dynCall_i:Jg,dynCall_ii:Yg,dynCall_iidiiii:Xg,dynCall_iii:Zg,dynCall_iiii:Qg,dynCall_v:$g,dynCall_vi:e_,dynCall_vii:t_,dynCall_viii:n_,dynCall_viiii:r_,dynCall_viiiii:i_,dynCall_viiiiii:a_,globalCtors:F,stackAlloc:jg,stackRestore:Mg,stackSave:Ng}})({Math,Int8Array,Int16Array,Int32Array,Uint8Array,Uint16Array,Float32Array,Float64Array},{A:wn,B:Sn,C:Cn,D:Me,a:De,b:y,c:b,d:Ne,e:Le,f:Re,g:ze,h:Fe,i:Ie,j:Be,k:nt,l:Jt,m:Zt,n:en,o:ln,p:fn,q:mn,r:hn,s:gn,t:_n,u:vn,v:rn,w:cn,x:yn,y:un,z:bn},I),jn=e.__ZSt18uncaught_exceptionv=An.__ZSt18uncaught_exceptionv;e.___cxa_can_catch=An.___cxa_can_catch,e.___cxa_is_pointer_type=An.___cxa_is_pointer_type,e.___embind_register_native_and_builtin_types=An.___embind_register_native_and_builtin_types,e.___errno_location=An.___errno_location;var Mn=e.___getTypeName=An.___getTypeName;e.___muldi3=An.___muldi3,e.___udivdi3=An.___udivdi3,e._bitshift64Lshr=An._bitshift64Lshr,e._bitshift64Shl=An._bitshift64Shl,e._emscripten_get_sbrk_ptr=An._emscripten_get_sbrk_ptr;var Nn=e._free=An._free;e._i64Add=An._i64Add,e._i64Subtract=An._i64Subtract,e._llvm_bswap_i32=An._llvm_bswap_i32;var Pn=e._malloc=An._malloc;e._memcpy=An._memcpy,e._memmove=An._memmove,e._memset=An._memset;var Fn=e.globalCtors=An.globalCtors;if(e.stackAlloc=An.stackAlloc,e.stackRestore=An.stackRestore,e.stackSave=An.stackSave,e.dynCall_i=An.dynCall_i,e.dynCall_ii=An.dynCall_ii,e.dynCall_iidiiii=An.dynCall_iidiiii,e.dynCall_iii=An.dynCall_iii,e.dynCall_iiii=An.dynCall_iiii,e.dynCall_v=An.dynCall_v,e.dynCall_vi=An.dynCall_vi,e.dynCall_vii=An.dynCall_vii,e.dynCall_viii=An.dynCall_viii,e.dynCall_viiii=An.dynCall_viiii,e.dynCall_viiiii=An.dynCall_viiiii,e.dynCall_viiiiii=An.dynCall_viiiiii,e.asm=An,Oe)if(je(Oe)||(Oe=l(Oe)),o||s){var In=f(Oe);te.set(In,x)}else{Te(`memory initializer`);var Ln=function(t){t.byteLength&&(t=new Uint8Array(t)),te.set(t,x),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,Ee(`memory initializer`)},Rn=function(){d(Oe,Ln,function(){throw Error(`could not load memory initializer `+Oe)})},zn=kn(Oe);if(zn)Ln(zn.buffer);else if(e.memoryInitializerRequest){var Bn=function(){var t=e.memoryInitializerRequest,n=t.response;if(t.status!==200&&t.status!==0){var r=kn(e.memoryInitializerRequestURL);if(r)n=r.buffer;else{console.warn(`a problem seems to have happened with Module.memoryInitializerRequest, status: `+t.status+`, retrying `+Oe),Rn();return}}Ln(n)};e.memoryInitializerRequest.response?setTimeout(Bn,0):e.memoryInitializerRequest.addEventListener(`load`,Bn)}else Rn()}var Vn;function Hn(e){this.name=`ExitStatus`,this.message=`Program terminated with exit(`+e+`)`,this.status=e}we=function e(){Vn||Un(),Vn||(we=e)};function Un(t){if(t||=r,Se>0||(ge(),Se>0))return;function n(){Vn||(Vn=!0,e.calledRun=!0,!S&&(_e(),ve(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),ye()))}e.setStatus?(e.setStatus(`Running...`),setTimeout(function(){setTimeout(function(){e.setStatus(``)},1),n()},1)):n()}if(e.run=Un,e.preInit)for(typeof e.preInit==`function`&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return Un(),e}function F$(e,t={},n,r){r=r===void 0||r===0?1:r;let i=new t(e.slice(n,n+t.BYTES_PER_ELEMENT*r));if(r===1)return i[0];let a=[];for(let e=0;e<r;e++)a.push(i[e]);return a}function I$(e){let t=131,n={pointsOffset:F$(e,Uint32Array,96),pointsFormatId:F$(e,Uint8Array,104),pointsStructSize:F$(e,Uint16Array,105),pointsCount:F$(e,Uint32Array,107),scale:F$(e,Float64Array,t,3)};t+=24,n.offset=F$(e,Float64Array,t,3),t+=24;let r=F$(e,Float64Array,t,6);return t+=48,n.maxs=[r[0],r[2],r[4]],n.mins=[r[1],r[3],r[5]],n.hasColor=new Set([2,3]).has(n.pointsFormatId&63),n}function L$(e,t){return R$(e,t)}function R$(e,t={}){let n=0,r,i,a,o,s,c={loader:`las`,loaderData:{},schema:{fields:[],metadata:{}},header:{vertexCount:0,boundingBox:[[0,0,0],[0,0,0]]},attributes:{},topology:`point-list`,mode:0};return z$(e,t.las?.skip,(e={},l)=>{if(!s){s=l;let e=l.totalToRead;r=new(t.las?.fp64?Float64Array:Float32Array)(e*3),i=l.hasColor?new Uint8Array(e*4):null,a=new Uint16Array(e),o=new Uint8Array(e),c.loaderData=l,c.attributes={POSITION:{value:r,size:3},intensity:{value:a,size:1},classification:{value:o,size:1}},i&&(c.attributes.COLOR_0={value:i,size:4})}let u=e.pointsCount,{scale:[d,f,p],offset:[m,h,g]}=l,_=B$(e,u,t.las?.colorDepth);for(let t=0;t<u;t++){let{position:s,color:c,intensity:l,classification:u}=e.getPoint(t);r[n*3]=s[0]*d+m,r[n*3+1]=s[1]*f+h,r[n*3+2]=s[2]*p+g,c&&i&&(_?(i[n*4]=c[0]/256,i[n*4+1]=c[1]/256,i[n*4+2]=c[2]/256):(i[n*4]=c[0],i[n*4+1]=c[1],i[n*4+2]=c[2]),i[n*4+3]=255),a[n]=l,o[n]=u,n++}let v={...c,header:{vertexCount:l.totalRead},progress:l.totalRead/l.totalToRead};t?.onProgress?.(v)}),c.header={vertexCount:s.totalToRead,boundingBox:E$(c?.attributes||{})},c&&(c.schema=M$(c.loaderData,c.attributes)),c}function z$(e,t,n={}){let r=new z8(e);try{r.open();let e=r.getHeader(),i=r.getUnpacker(),a=Math.ceil(e.pointsCount/Math.max(1,t));e.totalToRead=a;let o=0;for(;;){let s=r.readData(1e3*100,t);if(o+=s.count,e.totalRead=o,n(new i(s.buffer,s.count,e),e),!s.hasMoreData||o>=a)break}}catch(e){throw e}finally{r.close()}}function B$(e={},t,n){let r=!1;switch(n){case 8:r=!1;break;case 16:r=!0;break;case`auto`:if(e.getPoint(0).color)for(let n=0;n<t;n++){let{color:t}=e.getPoint(n);(t[0]>255||t[1]>255||t[2]>255)&&(r=!0)}break;default:console.warn(`las: illegal value for options.las.colorDepth`);break}return r}function V$(e){e(`EPSG:4326`,`+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees`),e(`EPSG:4269`,`+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees`),e(`EPSG:3857`,`+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs`);for(var t=1;t<=60;++t)e(`EPSG:`+(32600+t),`+proj=utm +zone=`+t+` +datum=WGS84 +units=m`),e(`EPSG:`+(32700+t),`+proj=utm +zone=`+t+` +south +datum=WGS84 +units=m`);e(`EPSG:5041`,`+title=WGS 84 / UPS North (E,N) +proj=stere +lat_0=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m`),e(`EPSG:5042`,`+title=WGS 84 / UPS South (E,N) +proj=stere +lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m`),e.WGS84=e[`EPSG:4326`],e[`EPSG:3785`]=e[`EPSG:3857`],e.GOOGLE=e[`EPSG:3857`],e[`EPSG:900913`]=e[`EPSG:3857`],e[`EPSG:102113`]=e[`EPSG:3857`]}function H$(e,t){if(e[t])return e[t];for(var n=Object.keys(e),r=t.toLowerCase().replace(i5,``),i=-1,a,o;++i<n.length;)if(a=n[i],o=a.toLowerCase().replace(i5,``),o===r)return e[a]}function U$(e){var t={},n=e.split(`+`).map(function(e){return e.trim()}).filter(function(e){return e}).reduce(function(e,t){var n=t.split(`=`);return n.push(!0),e[n[0].toLowerCase()]=n[1],e},{}),r,i,a,o={proj:`projName`,datum:`datumCode`,rf:function(e){t.rf=parseFloat(e)},lat_0:function(e){t.lat0=e*Z8},lat_1:function(e){t.lat1=e*Z8},lat_2:function(e){t.lat2=e*Z8},lat_ts:function(e){t.lat_ts=e*Z8},lon_0:function(e){t.long0=e*Z8},lon_1:function(e){t.long1=e*Z8},lon_2:function(e){t.long2=e*Z8},alpha:function(e){t.alpha=parseFloat(e)*Z8},gamma:function(e){t.rectified_grid_angle=parseFloat(e)*Z8},lonc:function(e){t.longc=e*Z8},x_0:function(e){t.x0=parseFloat(e)},y_0:function(e){t.y0=parseFloat(e)},k_0:function(e){t.k0=parseFloat(e)},k:function(e){t.k0=parseFloat(e)},a:function(e){t.a=parseFloat(e)},b:function(e){t.b=parseFloat(e)},r:function(e){t.a=t.b=parseFloat(e)},r_a:function(){t.R_A=!0},zone:function(e){t.zone=parseInt(e,10)},south:function(){t.utmSouth=!0},towgs84:function(e){t.datum_params=e.split(`,`).map(function(e){return parseFloat(e)})},to_meter:function(e){t.to_meter=parseFloat(e)},units:function(e){t.units=e;var n=H$(r5,e);n&&(t.to_meter=n.to_meter)},from_greenwich:function(e){t.from_greenwich=e*Z8},pm:function(e){t.from_greenwich=(H$(n5,e)||parseFloat(e))*Z8},nadgrids:function(e){e===`@null`?t.datumCode=`none`:t.nadgrids=e},axis:function(e){var n=`ewnsud`;e.length===3&&n.indexOf(e.substr(0,1))!==-1&&n.indexOf(e.substr(1,1))!==-1&&n.indexOf(e.substr(2,1))!==-1&&(t.axis=e)},approx:function(){t.approx=!0},over:function(){t.over=!0}};for(r in n)i=n[r],r in o?(a=o[r],typeof a==`function`?a(i):t[a]=i):t[r]=i;return typeof t.datumCode==`string`&&t.datumCode!==`WGS84`&&(t.datumCode=t.datumCode.toLowerCase()),t.projStr=e,t}function W$(e){return e.find(e=>Array.isArray(e)&&e[0]===`USAGE`)?`2019`:(e.find(e=>Array.isArray(e)&&e[0]===`CS`)||e[0]===`BOUNDCRS`||e[0]===`PROJCRS`||e[0],`2015`)}function G$(e){return(W$(e)===`2019`?s5:o5).convert(e)}function K$(e){let t=e.toUpperCase();return t.includes(`PROJCRS`)||t.includes(`GEOGCRS`)||t.includes(`BOUNDCRS`)||t.includes(`VERTCRS`)||t.includes(`LENGTHUNIT`)||t.includes(`ANGLEUNIT`)||t.includes(`SCALEUNIT`)?`WKT2`:(t.includes(`PROJCS`)||t.includes(`GEOGCS`)||t.includes(`LOCAL_CS`)||t.includes(`VERT_CS`)||t.includes(`UNIT`),`WKT1`)}function q$(e){if(typeof e!=`string`)throw Error(`not a string`);this.text=e.trim(),this.level=0,this.place=0,this.root=null,this.stack=[],this.currentObject=null,this.state=l5}function J$(e){return new q$(e).output()}function Y$(e,t,n){Array.isArray(t)&&(n.unshift(t),t=null);var r=t?{}:e,i=n.reduce(function(e,t){return X$(t,e),e},r);t&&(e[t]=i)}function X$(e,t){if(!Array.isArray(e)){t[e]=!0;return}var n=e.shift();if(n===`PARAMETER`&&(n=e.shift()),e.length===1){if(Array.isArray(e[0])){t[n]={},X$(e[0],t[n]);return}t[n]=e[0];return}if(!e.length){t[n]=!0;return}if(n===`TOWGS84`){t[n]=e;return}if(n===`AXIS`){n in t||(t[n]=[]),t[n].push(e);return}Array.isArray(n)||(t[n]={});var r;switch(n){case`UNIT`:case`PRIMEM`:case`VERT_DATUM`:t[n]={name:e[0].toLowerCase(),convert:e[1]},e.length===3&&X$(e[2],t[n]);return;case`SPHEROID`:case`ELLIPSOID`:t[n]={name:e[0],a:e[1],rf:e[2]},e.length===4&&X$(e[3],t[n]);return;case`EDATUM`:case`ENGINEERINGDATUM`:case`LOCAL_DATUM`:case`DATUM`:case`VERT_CS`:case`VERTCRS`:case`VERTICALCRS`:e[0]=[`name`,e[0]],Y$(t,n,e);return;case`COMPD_CS`:case`COMPOUNDCRS`:case`FITTED_CS`:case`PROJECTEDCRS`:case`PROJCRS`:case`GEOGCS`:case`GEOCCS`:case`PROJCS`:case`LOCAL_CS`:case`GEODCRS`:case`GEODETICCRS`:case`GEODETICDATUM`:case`ENGCRS`:case`ENGINEERINGCRS`:e[0]=[`name`,e[0]],Y$(t,n,e),t[n].type=n;return;default:for(r=-1;++r<e.length;)if(!Array.isArray(e[r]))return X$(e,t[n]);return Y$(t,n,e)}}function Z$(e){return e*b5}function Q$(e){let t=(e.projName||``).toLowerCase().replace(/_/g,` `);e.long0===void 0&&e.longc!==void 0&&(e.long0=e.longc),!e.lat_ts&&e.lat1&&(t===`stereographic south pole`||t===`polar stereographic (variant b)`)?(e.lat0=Z$(e.lat1>0?90:-90),e.lat_ts=e.lat1,delete e.lat1):!e.lat_ts&&e.lat0&&(t===`polar stereographic`||t===`polar stereographic (variant a)`)&&(e.lat_ts=e.lat0,e.lat0=Z$(e.lat0>0?90:-90),delete e.lat1)}function $$(e){let t={units:null,to_meter:void 0};return typeof e==`string`?(t.units=e.toLowerCase(),t.units===`metre`&&(t.units=`meter`),t.units===`meter`&&(t.to_meter=1)):e&&e.name&&(t.units=e.name.toLowerCase(),t.units===`metre`&&(t.units=`meter`),t.to_meter=e.conversion_factor),t}function e1(e){return typeof e==`object`?e.value*e.unit.conversion_factor:e}function t1(e,t){e.ellipsoid.radius?(t.a=e.ellipsoid.radius,t.rf=0):(t.a=e1(e.ellipsoid.semi_major_axis),e.ellipsoid.inverse_flattening===void 0?e.ellipsoid.semi_major_axis!==void 0&&e.ellipsoid.semi_minor_axis!==void 0&&(t.rf=t.a/(t.a-e1(e.ellipsoid.semi_minor_axis))):t.rf=e.ellipsoid.inverse_flattening)}function n1(e,t={}){return!e||typeof e!=`object`?e:e.type===`BoundCRS`?(n1(e.source_crs,t),e.transformation&&(e.transformation.method&&e.transformation.method.name===`NTv2`?t.nadgrids=e.transformation.parameters[0].value:t.datum_params=e.transformation.parameters.map(e=>e.value)),t):(Object.keys(e).forEach(n=>{let r=e[n];if(r!==null)switch(n){case`name`:if(t.srsCode)break;t.name=r,t.srsCode=r;break;case`type`:r===`GeographicCRS`?t.projName=`longlat`:r===`GeodeticCRS`?e.coordinate_system&&e.coordinate_system.subtype===`Cartesian`?t.projName=`geocent`:t.projName=`longlat`:r===`ProjectedCRS`&&e.conversion&&e.conversion.method&&(t.projName=e.conversion.method.name);break;case`datum`:case`datum_ensemble`:r.ellipsoid&&(t.ellps=r.ellipsoid.name,t1(r,t)),r.prime_meridian&&(t.from_greenwich=r.prime_meridian.longitude*Math.PI/180);break;case`ellipsoid`:t.ellps=r.name,t1(r,t);break;case`prime_meridian`:t.long0=(r.longitude||0)*Math.PI/180;break;case`coordinate_system`:if(r.axis){let e={east:`e`,north:`n`,west:`w`,south:`s`,up:`u`,down:`d`,geocentricx:`e`,geocentricy:`n`,geocentricz:`u`},n=r.axis.map(t=>e[t.direction.toLowerCase()]);if(n.every(Boolean)&&(t.axis=n.join(``),t.axis.length===2&&(t.axis+=`u`)),r.unit){let{units:e,to_meter:n}=$$(r.unit);t.units=e,t.to_meter=n}else if(r.axis[0]&&r.axis[0].unit){let{units:e,to_meter:n}=$$(r.axis[0].unit);t.units=e,t.to_meter=n}}break;case`id`:r.authority&&r.code&&(t.title=r.authority+`:`+r.code);break;case`conversion`:r.method&&r.method.name&&(t.projName=r.method.name),r.parameters&&r.parameters.forEach(e=>{let n=e.name.toLowerCase().replace(/\s+/g,`_`),r=e.value;e.unit&&e.unit.conversion_factor?t[n]=r*e.unit.conversion_factor:e.unit===`degree`?t[n]=r*Math.PI/180:t[n]=r});break;case`unit`:r.name&&(t.units=r.name.toLowerCase(),t.units===`metre`&&(t.units=`meter`)),r.conversion_factor&&(t.to_meter=r.conversion_factor);break;case`base_crs`:n1(r,t),t.datumCode=r.id?r.id.authority+`_`+r.id.code:r.name;break;default:break}}),t.latitude_of_false_origin!==void 0&&(t.lat0=t.latitude_of_false_origin),t.longitude_of_false_origin!==void 0&&(t.long0=t.longitude_of_false_origin),t.latitude_of_standard_parallel!==void 0&&(t.lat0=t.latitude_of_standard_parallel,t.lat1=t.latitude_of_standard_parallel),t.latitude_of_1st_standard_parallel!==void 0&&(t.lat1=t.latitude_of_1st_standard_parallel),t.latitude_of_2nd_standard_parallel!==void 0&&(t.lat2=t.latitude_of_2nd_standard_parallel),t.latitude_of_projection_centre!==void 0&&(t.lat0=t.latitude_of_projection_centre),t.longitude_of_projection_centre!==void 0&&(t.longc=t.longitude_of_projection_centre),t.easting_at_false_origin!==void 0&&(t.x0=t.easting_at_false_origin),t.northing_at_false_origin!==void 0&&(t.y0=t.northing_at_false_origin),t.latitude_of_natural_origin!==void 0&&(t.lat0=t.latitude_of_natural_origin),t.longitude_of_natural_origin!==void 0&&(t.long0=t.longitude_of_natural_origin),t.longitude_of_origin!==void 0&&(t.long0=t.longitude_of_origin),t.false_easting!==void 0&&(t.x0=t.false_easting),t.easting_at_projection_centre&&(t.x0=t.easting_at_projection_centre),t.false_northing!==void 0&&(t.y0=t.false_northing),t.northing_at_projection_centre&&(t.y0=t.northing_at_projection_centre),t.standard_parallel_1!==void 0&&(t.lat1=t.standard_parallel_1),t.standard_parallel_2!==void 0&&(t.lat2=t.standard_parallel_2),t.scale_factor_at_natural_origin!==void 0&&(t.k0=t.scale_factor_at_natural_origin),t.scale_factor_at_projection_centre!==void 0&&(t.k0=t.scale_factor_at_projection_centre),t.scale_factor_on_pseudo_standard_parallel!==void 0&&(t.k0=t.scale_factor_on_pseudo_standard_parallel),t.azimuth!==void 0&&(t.alpha=t.azimuth),t.azimuth_at_projection_centre!==void 0&&(t.alpha=t.azimuth_at_projection_centre),t.angle_from_rectified_to_skew_grid&&(t.rectified_grid_angle=t.angle_from_rectified_to_skew_grid),Q$(t),t)}function r1(e,t){var n=t[0],r=t[1];!(n in e)&&r in e&&(e[n]=e[r],t.length===3&&(e[n]=t[2](e[n])))}function i1(e){for(var t=Object.keys(e),n=0,r=t.length;n<r;++n){var i=t[n];x5.indexOf(i)!==-1&&a1(e[i]),typeof e[i]==`object`&&i1(e[i])}}function a1(e){if(e.AUTHORITY){var t=Object.keys(e.AUTHORITY)[0];t&&t in e.AUTHORITY&&(e.title=t+`:`+e.AUTHORITY[t])}if(e.type===`GEOGCS`?e.projName=`longlat`:e.type===`LOCAL_CS`?(e.projName=`identity`,e.local=!0):typeof e.PROJECTION==`object`?e.projName=Object.keys(e.PROJECTION)[0]:e.projName=e.PROJECTION,e.AXIS){for(var n=``,r=0,i=e.AXIS.length;r<i;++r){var a=[e.AXIS[r][0].toLowerCase(),e.AXIS[r][1].toLowerCase()];a[0].indexOf(`north`)!==-1||(a[0]===`y`||a[0]===`lat`)&&a[1]===`north`?n+=`n`:a[0].indexOf(`south`)!==-1||(a[0]===`y`||a[0]===`lat`)&&a[1]===`south`?n+=`s`:a[0].indexOf(`east`)!==-1||(a[0]===`x`||a[0]===`lon`)&&a[1]===`east`?n+=`e`:(a[0].indexOf(`west`)!==-1||(a[0]===`x`||a[0]===`lon`)&&a[1]===`west`)&&(n+=`w`)}n.length===2&&(n+=`u`),n.length===3&&(e.axis=n)}e.UNIT&&(e.units=e.UNIT.name.toLowerCase(),e.units===`metre`&&(e.units=`meter`),e.UNIT.convert&&(e.type===`GEOGCS`?e.DATUM&&e.DATUM.SPHEROID&&(e.to_meter=e.UNIT.convert*e.DATUM.SPHEROID.a):e.to_meter=e.UNIT.convert));var o=e.GEOGCS;e.type===`GEOGCS`&&(o=e),o&&(o.PRIMEM&&o.PRIMEM.convert&&(e.from_greenwich=Z$(o.PRIMEM.convert)),o.DATUM?e.datumCode=o.DATUM.name.toLowerCase():e.datumCode=o.name.toLowerCase(),e.datumCode.slice(0,2)===`d_`&&(e.datumCode=e.datumCode.slice(2)),e.datumCode===`new_zealand_1949`&&(e.datumCode=`nzgd49`),(e.datumCode===`wgs_1984`||e.datumCode===`world_geodetic_system_1984`)&&(e.PROJECTION===`Mercator_Auxiliary_Sphere`&&(e.sphere=!0),e.datumCode=`wgs84`),e.datumCode===`belge_1972`&&(e.datumCode=`rnb72`),o.DATUM&&o.DATUM.SPHEROID&&(e.ellps=o.DATUM.SPHEROID.name.replace(`_19`,``).replace(/[Cc]larke\_18/,`clrk`),e.ellps.toLowerCase().slice(0,13)===`international`&&(e.ellps=`intl`),e.a=o.DATUM.SPHEROID.a,e.rf=parseFloat(o.DATUM.SPHEROID.rf)),o.DATUM&&o.DATUM.TOWGS84&&(e.datum_params=o.DATUM.TOWGS84),~e.datumCode.indexOf(`osgb_1936`)&&(e.datumCode=`osgb36`),~e.datumCode.indexOf(`osni_1952`)&&(e.datumCode=`osni52`),(~e.datumCode.indexOf(`tm65`)||~e.datumCode.indexOf(`geodetic_datum_of_1965`))&&(e.datumCode=`ire65`),e.datumCode===`ch1903+`&&(e.datumCode=`ch1903`),~e.datumCode.indexOf(`israel`)&&(e.datumCode=`isr93`)),e.b&&!isFinite(e.b)&&(e.b=e.a),e.rectified_grid_angle&&=Z$(e.rectified_grid_angle);function s(t){return t*(e.to_meter||1)}[[`standard_parallel_1`,`Standard_Parallel_1`],[`standard_parallel_1`,`Latitude of 1st standard parallel`],[`standard_parallel_2`,`Standard_Parallel_2`],[`standard_parallel_2`,`Latitude of 2nd standard parallel`],[`false_easting`,`False_Easting`],[`false_easting`,`False easting`],[`false-easting`,`Easting at false origin`],[`false_northing`,`False_Northing`],[`false_northing`,`False northing`],[`false_northing`,`Northing at false origin`],[`central_meridian`,`Central_Meridian`],[`central_meridian`,`Longitude of natural origin`],[`central_meridian`,`Longitude of false origin`],[`latitude_of_origin`,`Latitude_Of_Origin`],[`latitude_of_origin`,`Central_Parallel`],[`latitude_of_origin`,`Latitude of natural origin`],[`latitude_of_origin`,`Latitude of false origin`],[`scale_factor`,`Scale_Factor`],[`k0`,`scale_factor`],[`latitude_of_center`,`Latitude_Of_Center`],[`latitude_of_center`,`Latitude_of_center`],[`lat0`,`latitude_of_center`,Z$],[`longitude_of_center`,`Longitude_Of_Center`],[`longitude_of_center`,`Longitude_of_center`],[`longc`,`longitude_of_center`,Z$],[`x0`,`false_easting`,s],[`y0`,`false_northing`,s],[`long0`,`central_meridian`,Z$],[`lat0`,`latitude_of_origin`,Z$],[`lat0`,`standard_parallel_1`,Z$],[`lat1`,`standard_parallel_1`,Z$],[`lat2`,`standard_parallel_2`,Z$],[`azimuth`,`Azimuth`],[`alpha`,`azimuth`,Z$],[`srsCode`,`name`]].forEach(function(t){return r1(e,t)}),Q$(e)}function o1(e){if(typeof e==`object`)return n1(e);let t=K$(e);var n=c5(e);if(t===`WKT2`)return n1(G$(n));var r=n[0],i={};return X$(n,i),i1(i),i[r]}function s1(e){var t=this;if(arguments.length===2){var n=arguments[1];typeof n==`string`?n.charAt(0)===`+`?s1[e]=U$(arguments[1]):s1[e]=o1(arguments[1]):n&&typeof n==`object`&&!(`projName`in n)?s1[e]=o1(arguments[1]):(s1[e]=n,n||delete s1[e])}else if(arguments.length===1){if(Array.isArray(e))return e.map(function(e){return Array.isArray(e)?s1.apply(t,e):s1(e)});if(typeof e==`string`){if(e in s1)return s1[e]}else `EPSG`in e?s1[`EPSG:`+e.EPSG]=e:`ESRI`in e?s1[`ESRI:`+e.ESRI]=e:`IAU2000`in e?s1[`IAU2000:`+e.IAU2000]=e:console.log(e);return}}function c1(e){return typeof e==`string`}function l1(e){return e in s1}function u1(e){return e.indexOf(`+`)!==0&&e.indexOf(`[`)!==-1||typeof e==`object`&&!(`srsCode`in e)}function d1(e){if(e.title)return e.title.toLowerCase().indexOf(`epsg:`)===0&&S5.indexOf(e.title.substr(5))>-1;var t=H$(e,`authority`);if(t){var n=H$(t,`epsg`);return n&&S5.indexOf(n)>-1}}function f1(e){var t=H$(e,`extension`);if(t)return H$(t,`proj4`)}function p1(e){return e[0]===`+`}function m1(e){let t;if(c1(e))if(l1(e))t=s1[e];else if(u1(e)){t=o1(e);var n=f1(t);n&&(t=U$(n))}else p1(e)&&(t=U$(e));else t=`projName`in e?e:o1(e);return t&&d1(t)?s1[`EPSG:3857`]:t}function h1(e,t){e||={};var n,r;if(!t)return e;for(r in t)n=t[r],n!==void 0&&(e[r]=n);return e}function g1(e,t,n){var r=e*t;return n/Math.sqrt(1-r*r)}function _1(e){return e<0?-1:1}function Q(e,t){return t||Math.abs(e)<=3.14159265359?e:e-_1(e)*e5}function v1(e,t,n){var r=e*n,i=.5*e;return r=((1-r)/(1+r))**i,Math.tan(.5*($-t))/r}function y1(e,t){for(var n=.5*e,r,i,a=$-2*Math.atan(t),o=0;o<=15;o++)if(r=e*Math.sin(a),i=$-2*Math.atan(t*((1-r)/(1+r))**n)-a,a+=i,Math.abs(i)<=1e-10)return a;return-9999}function b1(){var e=this.b/this.a;this.es=1-e*e,`x0`in this||(this.x0=0),`y0`in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=g1(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function x1(e){var t=e.x,n=e.y;if(n*57.29577951308232>90&&n*57.29577951308232<-90&&t*57.29577951308232>180&&t*57.29577951308232<-180)return null;var r,i;if(Math.abs(Math.abs(n)-$)<=1e-10)return null;if(this.sphere)r=this.x0+this.a*this.k0*Q(t-this.long0,this.over),i=this.y0+this.a*this.k0*Math.log(Math.tan($8+.5*n));else{var a=Math.sin(n),o=v1(this.e,n,a);r=this.x0+this.a*this.k0*Q(t-this.long0,this.over),i=this.y0-this.a*this.k0*Math.log(o)}return e.x=r,e.y=i,e}function S1(e){var t=e.x-this.x0,n=e.y-this.y0,r,i;if(this.sphere)i=$-2*Math.atan(Math.exp(-n/(this.a*this.k0)));else{var a=Math.exp(-n/(this.a*this.k0));if(i=y1(this.e,a),i===-9999)return null}return r=Q(this.long0+t/(this.a*this.k0),this.over),e.x=r,e.y=i,e}function C1(){}function w1(e){return e}function T1(e,t){var n=D5.length;return e.names?(D5[n]=e,e.names.forEach(function(e){E5[e.toLowerCase()]=n}),this):(console.log(t),!0)}function E1(e){return e.replace(/[-\(\)\s]+/g,` `).trim().replace(/ /g,`_`)}function D1(e){if(!e)return!1;var t=e.toLowerCase();if(E5[t]!==void 0&&D5[E5[t]]||(t=E1(t),t in E5&&D5[E5[t]]))return D5[E5[t]]}function O1(){T5.forEach(T1)}function k1(e,t,n,r){var i=e*e,a=t*t,o=(i-a)/i,s=0;r?(e*=1-o*(q8+o*(J8+o*Y8)),i=e*e,o=0):s=Math.sqrt(o);var c=(i-a)/a;return{es:o,e:s,ep2:c}}function A1(e,t,n,r,i){if(!e){var a=H$(k5,r);a||=A5,e=a.a,t=a.b,n=a.rf}return n&&!t&&(t=(1-1/n)*e),(n===0||Math.abs(e-t)<1e-10)&&(i=!0,t=e),{a:e,b:t,rf:n,sphere:i}}function j1(e,t,n,r,i,a,o){var s={};return e===void 0||e===`none`?s.datum_type=5:s.datum_type=4,t&&(s.datum_params=t.map(parseFloat),(s.datum_params[0]!==0||s.datum_params[1]!==0||s.datum_params[2]!==0)&&(s.datum_type=1),s.datum_params.length>3&&(s.datum_params[3]!==0||s.datum_params[4]!==0||s.datum_params[5]!==0||s.datum_params[6]!==0)&&(s.datum_type=2,s.datum_params[3]*=K8,s.datum_params[4]*=K8,s.datum_params[5]*=K8,s.datum_params[6]=s.datum_params[6]/1e6+1)),o&&(s.datum_type=3,s.grids=o),s.a=n,s.b=r,s.es=i,s.ep2=a,s}function M1(e,t,n){return t instanceof ArrayBuffer?N1(e,t,n):{ready:P1(e,t)}}function N1(e,t,n){var r=!0;n!==void 0&&n.includeErrorFields===!1&&(r=!1);var i=new DataView(t),a=z1(i),o=B1(i,a),s={header:o,subgrids:H1(i,o,a,r)};return N5[e]=s,s}async function P1(e,t){for(var n=[],r=await t.getImageCount(),i=r-1;i>=0;i--){var a=await t.getImage(i),o=await a.readRasters(),s=[a.getWidth(),a.getHeight()],c=a.getBoundingBox().map(L1),l=[a.fileDirectory.ModelPixelScale[0],a.fileDirectory.ModelPixelScale[1]].map(L1),u=c[0]+(s[0]-1)*l[0],d=c[3]-(s[1]-1)*l[1],f=o[0],p=o[1],m=[];for(let e=s[1]-1;e>=0;e--)for(let t=s[0]-1;t>=0;t--){var h=e*s[0]+t;m.push([-R1(p[h]),R1(f[h])])}n.push({del:l,lim:s,ll:[-u,d],cvs:m})}var g={header:{nSubgrids:r},subgrids:n};return N5[e]=g,g}function F1(e){return e===void 0?null:e.split(`,`).map(I1)}function I1(e){if(e.length===0)return null;var t=e[0]===`@`;return t&&(e=e.slice(1)),e===`null`?{name:`null`,mandatory:!t,grid:null,isNull:!0}:{name:e,mandatory:!t,grid:N5[e]||null,isNull:!1}}function L1(e){return e*Math.PI/180}function R1(e){return e/3600*Math.PI/180}function z1(e){var t=e.getInt32(8,!1);return t===11?!1:(t=e.getInt32(8,!0),t!==11&&console.warn(`Failed to detect nadgrid endian-ness, defaulting to little-endian`),!0)}function B1(e,t){return{nFields:e.getInt32(8,t),nSubgridFields:e.getInt32(24,t),nSubgrids:e.getInt32(40,t),shiftType:V1(e,56,64).trim(),fromSemiMajorAxis:e.getFloat64(120,t),fromSemiMinorAxis:e.getFloat64(136,t),toSemiMajorAxis:e.getFloat64(152,t),toSemiMinorAxis:e.getFloat64(168,t)}}function V1(e,t,n){return String.fromCharCode.apply(null,new Uint8Array(e.buffer.slice(t,n)))}function H1(e,t,n,r){for(var i=176,a=[],o=0;o<t.nSubgrids;o++){var s=W1(e,i,n),c=G1(e,i,s,n,r),l=Math.round(1+(s.upperLongitude-s.lowerLongitude)/s.longitudeInterval),u=Math.round(1+(s.upperLatitude-s.lowerLatitude)/s.latitudeInterval);a.push({ll:[R1(s.lowerLongitude),R1(s.lowerLatitude)],del:[R1(s.longitudeInterval),R1(s.latitudeInterval)],lim:[l,u],count:s.gridNodeCount,cvs:U1(c)});var d=16;r===!1&&(d=8),i+=176+s.gridNodeCount*d}return a}function U1(e){return e.map(function(e){return[R1(e.longitudeShift),R1(e.latitudeShift)]})}function W1(e,t,n){return{name:V1(e,t+8,t+16).trim(),parent:V1(e,t+24,t+24+8).trim(),lowerLatitude:e.getFloat64(t+72,n),upperLatitude:e.getFloat64(t+88,n),lowerLongitude:e.getFloat64(t+104,n),upperLongitude:e.getFloat64(t+120,n),latitudeInterval:e.getFloat64(t+136,n),longitudeInterval:e.getFloat64(t+152,n),gridNodeCount:e.getInt32(t+168,n)}}function G1(e,t,n,r,i){var a=t+176,o=16;i===!1&&(o=8);for(var s=[],c=0;c<n.gridNodeCount;c++){var l={latitudeShift:e.getFloat32(a+c*o,r),longitudeShift:e.getFloat32(a+c*o+4,r)};i!==!1&&(l.latitudeAccuracy=e.getFloat32(a+c*o+8,r),l.longitudeAccuracy=e.getFloat32(a+c*o+12,r)),s.push(l)}return s}function K1(e,t){if(!(this instanceof K1))return new K1(e);this.forward=null,this.inverse=null,this.init=null,this.name,this.names=null,this.title,t||=function(e){if(e)throw e};var n=m1(e);if(typeof n!=`object`){t(`Could not parse to valid json: `+e);return}var r=K1.projections.get(n.projName);if(!r){t(`Could not get projection name from: `+e);return}if(n.datumCode&&n.datumCode!==`none`){var i=H$(j5,n.datumCode);i&&(n.datum_params=n.datum_params||(i.towgs84?i.towgs84.split(`,`):null),n.ellps=i.ellipse,n.datumName=i.datumName?i.datumName:n.datumCode)}n.k0=n.k0||1,n.axis=n.axis||`enu`,n.ellps=n.ellps||`wgs84`,n.lat1=n.lat1||n.lat0;var a=A1(n.a,n.b,n.rf,n.ellps,n.sphere),o=k1(a.a,a.b,a.rf,n.R_A),s=F1(n.nadgrids),c=n.datum||j1(n.datumCode,n.datum_params,a.a,a.b,o.es,o.ep2,s);h1(this,n),h1(this,r),this.a=a.a,this.b=a.b,this.rf=a.rf,this.sphere=a.sphere,this.es=o.es,this.e=o.e,this.ep2=o.ep2,this.datum=c,`init`in this&&typeof this.init==`function`&&this.init(),t(null,this)}function q1(e,t){return e.datum_type===t.datum_type?e.a!==t.a||Math.abs(e.es-t.es)>5e-11?!1:e.datum_type===1?e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]:e.datum_type===2?e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]&&e.datum_params[3]===t.datum_params[3]&&e.datum_params[4]===t.datum_params[4]&&e.datum_params[5]===t.datum_params[5]&&e.datum_params[6]===t.datum_params[6]:!0:!1}function J1(e,t,n){var r=e.x,i=e.y,a=e.z?e.z:0,o,s,c,l;if(i<-$&&i>-1.001*$)i=-$;else if(i>$&&i<1.001*$)i=$;else if(i<-$)return{x:-1/0,y:-1/0,z:e.z};else if(i>$)return{x:1/0,y:1/0,z:e.z};return r>Math.PI&&(r-=2*Math.PI),s=Math.sin(i),l=Math.cos(i),c=s*s,o=n/Math.sqrt(1-t*c),{x:(o+a)*l*Math.cos(r),y:(o+a)*l*Math.sin(r),z:(o*(1-t)+a)*s}}function Y1(e,t,n,r){var i=1e-12,a=i*i,o=30,s,c,l,u,d,f,p,m,h,g,_,v,y,b=e.x,x=e.y,S=e.z?e.z:0,C,w,T;if(s=Math.sqrt(b*b+x*x),c=Math.sqrt(b*b+x*x+S*S),s/n<i){if(C=0,c/n<i)return w=$,T=-r,{x:e.x,y:e.y,z:e.z}}else C=Math.atan2(x,b);l=S/c,u=s/c,d=1/Math.sqrt(1-t*(2-t)*u*u),m=u*(1-t)*d,h=l*d,y=0;do y++,p=n/Math.sqrt(1-t*h*h),T=s*m+S*h-p*(1-t*h*h),f=t*p/(p+T),d=1/Math.sqrt(1-f*(2-f)*u*u),g=u*(1-f)*d,_=l*d,v=_*m-g*h,m=g,h=_;while(v*v>a&&y<o);return w=Math.atan(_/Math.abs(g)),{x:C,y:w,z:T}}function X1(e,t,n){if(t===1)return{x:e.x+n[0],y:e.y+n[1],z:e.z+n[2]};if(t===2){var r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6];return{x:l*(e.x-c*e.y+s*e.z)+r,y:l*(c*e.x+e.y-o*e.z)+i,z:l*(-s*e.x+o*e.y+e.z)+a}}}function Z1(e,t,n){if(t===1)return{x:e.x-n[0],y:e.y-n[1],z:e.z-n[2]};if(t===2){var r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=(e.x-r)/l,d=(e.y-i)/l,f=(e.z-a)/l;return{x:u+c*d-s*f,y:-c*u+d+o*f,z:s*u-o*d+f}}}function Q1(e){return e===1||e===2}function $1(e,t,n){if(q1(e,t)||e.datum_type===5||t.datum_type===5)return n;var r=e.a,i=e.es;if(e.datum_type===3){if(e0(e,!1,n)!==0)return;r=U8,i=G8}var a=t.a,o=t.b,s=t.es;if(t.datum_type===3&&(a=U8,o=W8,s=G8),i===s&&r===a&&!Q1(e.datum_type)&&!Q1(t.datum_type)||(n=J1(n,i,r),Q1(e.datum_type)&&(n=X1(n,e.datum_type,e.datum_params)),Q1(t.datum_type)&&(n=Z1(n,t.datum_type,t.datum_params)),n=Y1(n,s,a,o),!(t.datum_type===3&&e0(t,!0,n)!==0)))return n}function e0(e,t,n){if(e.grids===null||e.grids.length===0)return console.log(`Grid shift grids not found`),-1;var r={x:-n.x,y:n.y},i={x:NaN,y:NaN},a=[];outer:for(var o=0;o<e.grids.length;o++){var s=e.grids[o];if(a.push(s.name),s.isNull){i=r;break}if(s.grid===null){if(s.mandatory)return console.log(`Unable to find mandatory grid '`+s.name+`'`),-1;continue}for(var c=s.grid.subgrids,l=0,u=c.length;l<u;l++){var d=c[l],f=(Math.abs(d.del[1])+Math.abs(d.del[0]))/1e4,p=d.ll[0]-f,m=d.ll[1]-f,h=d.ll[0]+(d.lim[0]-1)*d.del[0]+f,g=d.ll[1]+(d.lim[1]-1)*d.del[1]+f;if(!(m>r.y||p>r.x||g<r.y||h<r.x)&&(i=t0(r,t,d),!isNaN(i.x)))break outer}}return isNaN(i.x)?(console.log(`Failed to find a grid shift table for location '`+-r.x*Q8+` `+r.y*Q8+` tried: '`+a+`'`),-1):(n.x=-i.x,n.y=i.y,0)}function t0(e,t,n){var r={x:NaN,y:NaN};if(isNaN(e.x))return r;var i={x:e.x,y:e.y};i.x-=n.ll[0],i.y-=n.ll[1],i.x=Q(i.x-Math.PI)+Math.PI;var a=n0(i,n);if(t){if(isNaN(a.x))return r;a.x=i.x-a.x,a.y=i.y-a.y;var o=9,s=1e-12,c,l;do{if(l=n0(a,n),isNaN(l.x)){console.log(`Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.`);break}c={x:i.x-(l.x+a.x),y:i.y-(l.y+a.y)},a.x+=c.x,a.y+=c.y}while(o--&&Math.abs(c.x)>s&&Math.abs(c.y)>s);if(o<0)return console.log(`Inverse grid shift iterator failed to converge.`),r;r.x=Q(a.x+n.ll[0]),r.y=a.y+n.ll[1]}else isNaN(a.x)||(r.x=e.x+a.x,r.y=e.y+a.y);return r}function n0(e,t){var n={x:e.x/t.del[0],y:e.y/t.del[1]},r={x:Math.floor(n.x),y:Math.floor(n.y)},i={x:n.x-1*r.x,y:n.y-1*r.y},a={x:NaN,y:NaN},o;if(r.x<0||r.x>=t.lim[0]||r.y<0||r.y>=t.lim[1])return a;o=r.y*t.lim[0]+r.x;var s={x:t.cvs[o][0],y:t.cvs[o][1]};o++;var c={x:t.cvs[o][0],y:t.cvs[o][1]};o+=t.lim[0];var l={x:t.cvs[o][0],y:t.cvs[o][1]};o--;var u={x:t.cvs[o][0],y:t.cvs[o][1]},d=i.x*i.y,f=i.x*(1-i.y),p=(1-i.x)*(1-i.y),m=(1-i.x)*i.y;return a.x=p*s.x+f*c.x+m*u.x+d*l.x,a.y=p*s.y+f*c.y+m*u.y+d*l.y,a}function r0(e,t,n){var r=n.x,i=n.y,a=n.z||0,o,s,c,l={};for(c=0;c<3;c++)if(!(t&&c===2&&n.z===void 0))switch(c===0?(o=r,s=`ew`.indexOf(e.axis[c])===-1?`y`:`x`):c===1?(o=i,s=`ns`.indexOf(e.axis[c])===-1?`x`:`y`):(o=a,s=`z`),e.axis[c]){case`e`:l[s]=o;break;case`w`:l[s]=-o;break;case`n`:l[s]=o;break;case`s`:l[s]=-o;break;case`u`:n[s]!==void 0&&(l.z=o);break;case`d`:n[s]!==void 0&&(l.z=-o);break;default:return null}return l}function i0(e){var t={x:e[0],y:e[1]};return e.length>2&&(t.z=e[2]),e.length>3&&(t.m=e[3]),t}function a0(e){o0(e.x),o0(e.y)}function o0(e){if(typeof Number.isFinite==`function`){if(Number.isFinite(e))return;throw TypeError(`coordinates must be finite numbers`)}if(typeof e!=`number`||e!==e||!isFinite(e))throw TypeError(`coordinates must be finite numbers`)}function s0(e,t){return(e.datum.datum_type===1||e.datum.datum_type===2||e.datum.datum_type===3)&&t.datumCode!==`WGS84`||(t.datum.datum_type===1||t.datum.datum_type===2||t.datum.datum_type===3)&&e.datumCode!==`WGS84`}function c0(e,t,n,r){var i;n=Array.isArray(n)?i0(n):{x:n.x,y:n.y,z:n.z,m:n.m};var a=n.z!==void 0;if(a0(n),e.datum&&t.datum&&s0(e,t)&&(i=new K1(`WGS84`),n=c0(e,i,n,r),e=i),r&&e.axis!==`enu`&&(n=r0(e,!1,n)),e.projName===`longlat`)n={x:n.x*Z8,y:n.y*Z8,z:n.z||0};else if(e.to_meter&&(n={x:n.x*e.to_meter,y:n.y*e.to_meter,z:n.z||0}),n=e.inverse(n),!n)return;if(e.from_greenwich&&(n.x+=e.from_greenwich),n=$1(e.datum,t.datum,n),n)return n=n,t.from_greenwich&&(n={x:n.x-t.from_greenwich,y:n.y,z:n.z||0}),t.projName===`longlat`?n={x:n.x*Q8,y:n.y*Q8,z:n.z||0}:(n=t.forward(n),t.to_meter&&(n={x:n.x/t.to_meter,y:n.y/t.to_meter,z:n.z||0})),r&&t.axis!==`enu`?r0(t,!0,n):(n&&!a&&t.projName!==`geocent`&&delete n.z,n)}function l0(e,t,n,r){var i,a,o;return Array.isArray(n)?(i=c0(e,t,n,r)||{x:NaN,y:NaN},n.length>2?e.name!==void 0&&e.name===`geocent`||t.name!==void 0&&t.name===`geocent`?typeof i.z==`number`?[i.x,i.y,i.z].concat(n.slice(3)):[i.x,i.y,n[2]].concat(n.slice(3)):[i.x,i.y].concat(n.slice(2)):[i.x,i.y]):(a=c0(e,t,n,r),o=Object.keys(n),o.length===2||o.forEach(function(r){if(e.name!==void 0&&e.name===`geocent`||t.name!==void 0&&t.name===`geocent`){if(r===`x`||r===`y`||r===`z`)return}else if(r===`x`||r===`y`)return;a[r]=n[r]}),a)}function u0(e){return e instanceof K1?e:typeof e==`object`&&`oProj`in e?e.oProj:K1(e)}function d0(e,t,n){var r,i,a=!1,o;return t===void 0?(i=u0(e),r=P5,a=!0):(t.x!==void 0||Array.isArray(t))&&(n=t,i=u0(e),r=P5,a=!0),r||=u0(e),i||=u0(t),n?l0(r,i,n):(o={forward:function(e,t){return l0(r,i,e,t)},inverse:function(e,t){return l0(i,r,e,t)}},a&&(o.oProj=i),o)}function f0(e,t){return t||=5,b0(_0({lat:e[1],lon:e[0]}),t)}function p0(e){var t=v0(w0(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat,t.lon,t.lat]:[t.left,t.bottom,t.right,t.top]}function m0(e){var t=v0(w0(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}function h0(e){return Math.PI/180*e}function g0(e){return e/Math.PI*180}function _0(e){var t=e.lat,n=e.lon,r=6378137,i=.00669438,a=.9996,o,s,c,l,u,d,f,p=h0(t),m=h0(n),h,g=Math.floor((n+180)/6)+1;n===180&&(g=60),t>=56&&t<64&&n>=3&&n<12&&(g=32),t>=72&&t<84&&(n>=0&&n<9?g=31:n>=9&&n<21?g=33:n>=21&&n<33?g=35:n>=33&&n<42&&(g=37)),o=(g-1)*6-180+3,h=h0(o),s=i/(1-i),c=r/Math.sqrt(1-i*Math.sin(p)*Math.sin(p)),l=Math.tan(p)*Math.tan(p),u=s*Math.cos(p)*Math.cos(p),d=Math.cos(p)*(m-h),f=r*((1-i/4-3*i*i/64-5*i*i*i/256)*p-(3*i/8+3*i*i/32+45*i*i*i/1024)*Math.sin(2*p)+(15*i*i/256+45*i*i*i/1024)*Math.sin(4*p)-35*i*i*i/3072*Math.sin(6*p));var _=a*c*(d+(1-l+u)*d*d*d/6+(5-18*l+l*l+72*u-58*s)*d*d*d*d*d/120)+5e5,v=a*(f+c*Math.tan(p)*(d*d/2+(5-l+9*u+4*u*u)*d*d*d*d/24+(61-58*l+l*l+600*u-330*s)*d*d*d*d*d*d/720));return t<0&&(v+=1e7),{northing:Math.round(v),easting:Math.round(_),zoneNumber:g,zoneLetter:y0(t)}}function v0(e){var t=e.northing,n=e.easting,r=e.zoneLetter,i=e.zoneNumber;if(i<0||i>60)return null;var a=.9996,o=6378137,s=.00669438,c,l=(1-Math.sqrt(1-s))/(1+Math.sqrt(1-s)),u,d,f,p,m,h,g,_,v,y=n-5e5,b=t;r<`N`&&(b-=1e7),g=(i-1)*6-180+3,c=s/(1-s),h=b/a,_=h/(o*(1-s/4-3*s*s/64-5*s*s*s/256)),v=_+(3*l/2-27*l*l*l/32)*Math.sin(2*_)+(21*l*l/16-55*l*l*l*l/32)*Math.sin(4*_)+151*l*l*l/96*Math.sin(6*_),u=o/Math.sqrt(1-s*Math.sin(v)*Math.sin(v)),d=Math.tan(v)*Math.tan(v),f=c*Math.cos(v)*Math.cos(v),p=o*(1-s)/(1-s*Math.sin(v)*Math.sin(v))**1.5,m=y/(u*a);var x=v-u*Math.tan(v)/p*(m*m/2-(5+3*d+10*f-4*f*f-9*c)*m*m*m*m/24+(61+90*d+298*f+45*d*d-252*c-3*f*f)*m*m*m*m*m*m/720);x=g0(x);var S=(m-(1+2*d+f)*m*m*m/6+(5-2*f+28*d-3*f*f+8*c+24*d*d)*m*m*m*m*m/120)/Math.cos(v);S=g+g0(S);var C;if(e.accuracy){var w=v0({northing:e.northing+e.accuracy,easting:e.easting+e.accuracy,zoneLetter:e.zoneLetter,zoneNumber:e.zoneNumber});C={top:w.lat,right:w.lon,bottom:x,left:S}}else C={lat:x,lon:S};return C}function y0(e){var t=`Z`;return 84>=e&&e>=72?t=`X`:72>e&&e>=64?t=`W`:64>e&&e>=56?t=`V`:56>e&&e>=48?t=`U`:48>e&&e>=40?t=`T`:40>e&&e>=32?t=`S`:32>e&&e>=24?t=`R`:24>e&&e>=16?t=`Q`:16>e&&e>=8?t=`P`:8>e&&e>=0?t=`N`:0>e&&e>=-8?t=`M`:-8>e&&e>=-16?t=`L`:-16>e&&e>=-24?t=`K`:-24>e&&e>=-32?t=`J`:-32>e&&e>=-40?t=`H`:-40>e&&e>=-48?t=`G`:-48>e&&e>=-56?t=`F`:-56>e&&e>=-64?t=`E`:-64>e&&e>=-72?t=`D`:-72>e&&e>=-80&&(t=`C`),t}function b0(e,t){var n=`00000`+e.easting,r=`00000`+e.northing;return e.zoneNumber+e.zoneLetter+x0(e.easting,e.northing,e.zoneNumber)+n.substr(n.length-5,t)+r.substr(r.length-5,t)}function x0(e,t,n){var r=S0(n);return C0(Math.floor(e/1e5),Math.floor(t/1e5)%20,r)}function S0(e){var t=e%F5;return t===0&&(t=F5),t}function C0(e,t,n){var r=n-1,i=I5.charCodeAt(r),a=L5.charCodeAt(r),o=i+e-1,s=a+t,c=!1;return o>H5&&(o=o-H5+R5-1,c=!0),(o===z5||i<z5&&o>z5||(o>z5||i<z5)&&c)&&o++,(o===B5||i<B5&&o>B5||(o>B5||i<B5)&&c)&&(o++,o===z5&&o++),o>H5&&(o=o-H5+R5-1),s>V5?(s=s-V5+R5-1,c=!0):c=!1,(s===z5||a<z5&&s>z5||(s>z5||a<z5)&&c)&&s++,(s===B5||a<B5&&s>B5||(s>B5||a<B5)&&c)&&(s++,s===z5&&s++),s>V5&&(s=s-V5+R5-1),String.fromCharCode(o)+String.fromCharCode(s)}function w0(e){if(e&&e.length===0)throw`MGRSPoint coverting from nothing`;for(var t=e.length,n=null,r=``,i,a=0;!/[A-Z]/.test(i=e.charAt(a));){if(a>=2)throw`MGRSPoint bad conversion from: `+e;r+=i,a++}var o=parseInt(r,10);if(a===0||a+3>t)throw`MGRSPoint bad conversion from: `+e;var s=e.charAt(a++);if(s<=`A`||s===`B`||s===`Y`||s>=`Z`||s===`I`||s===`O`)throw`MGRSPoint zone letter `+s+` not handled: `+e;n=e.substring(a,a+=2);for(var c=S0(o),l=T0(n.charAt(0),c),u=E0(n.charAt(1),c);u<D0(s);)u+=2e6;var d=t-a;if(d%2!=0)throw`MGRSPoint has to have an even number
|
||
of digits after the zone letter and two 100km letters - front
|
||
half for easting meters, second half for
|
||
northing meters`+e;var f=d/2,p=0,m=0,h,g,_,v,y;return f>0&&(h=1e5/10**f,g=e.substring(a,a+f),p=parseFloat(g)*h,_=e.substring(a+f),m=parseFloat(_)*h),v=p+l,y=m+u,{easting:v,northing:y,zoneLetter:s,zoneNumber:o,accuracy:h}}function T0(e,t){for(var n=I5.charCodeAt(t-1),r=1e5,i=!1;n!==e.charCodeAt(0);){if(n++,n===z5&&n++,n===B5&&n++,n>H5){if(i)throw`Bad character: `+e;n=R5,i=!0}r+=1e5}return r}function E0(e,t){if(e>`V`)throw`MGRSPoint given invalid Northing `+e;for(var n=L5.charCodeAt(t-1),r=0,i=!1;n!==e.charCodeAt(0);){if(n++,n===z5&&n++,n===B5&&n++,n>V5){if(i)throw`Bad character: `+e;n=R5,i=!0}r+=1e5}return r}function D0(e){var t;switch(e){case`C`:t=11e5;break;case`D`:t=2e6;break;case`E`:t=28e5;break;case`F`:t=37e5;break;case`G`:t=46e5;break;case`H`:t=55e5;break;case`J`:t=64e5;break;case`K`:t=73e5;break;case`L`:t=82e5;break;case`M`:t=91e5;break;case`N`:t=0;break;case`P`:t=8e5;break;case`Q`:t=17e5;break;case`R`:t=26e5;break;case`S`:t=35e5;break;case`T`:t=44e5;break;case`U`:t=53e5;break;case`V`:t=62e5;break;case`W`:t=7e6;break;case`X`:t=79e5;break;default:t=-1}if(t>=0)return t;throw`Invalid zone letter: `+e}function O0(e,t,n){if(!(this instanceof O0))return new O0(e,t,n);if(Array.isArray(e))this.x=e[0],this.y=e[1],this.z=e[2]||0;else if(typeof e==`object`)this.x=e.x,this.y=e.y,this.z=e.z||0;else if(typeof e==`string`&&t===void 0){var r=e.split(`,`);this.x=parseFloat(r[0]),this.y=parseFloat(r[1]),this.z=parseFloat(r[2])||0}else this.x=e,this.y=t,this.z=n||0;console.warn(`proj4.Point will be removed in version 3, use proj4.toPoint`)}function k0(e){var t=[];t[0]=W5-e*(G5+e*(K5+e*(q5+e*J5))),t[1]=e*(Y5-e*(K5+e*(q5+e*J5)));var n=e*e;return t[2]=n*(X5-e*(Z5+e*Q5)),n*=e,t[3]=n*($5-e*e7),t[4]=n*e*t7,t}function A0(e,t,n,r){return n*=t,t*=t,r[0]*e-n*(r[1]+t*(r[2]+t*(r[3]+t*r[4])))}function j0(e,t,n){for(var r=1/(1-t),i=e,a=n7;a;--a){var o=Math.sin(i),s=1-t*o*o;if(s=(A0(i,o,Math.cos(i),n)-e)*(s*Math.sqrt(s))*r,i-=s,Math.abs(s)<1e-10)return i}return i}function M0(){this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0,this.long0=this.long0===void 0?0:this.long0,this.lat0=this.lat0===void 0?0:this.lat0,this.es&&(this.en=k0(this.es),this.ml0=A0(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function N0(e){var t=e.x,n=e.y,r=Q(t-this.long0,this.over),i,a,o,s=Math.sin(n),c=Math.cos(n);if(this.es){var l=c*r,u=l**2,d=this.ep2*c**2,f=d**2,p=(Math.abs(c)>1e-10?Math.tan(n):0)**2,m=p**2;i=1-this.es*s**2,l/=Math.sqrt(i);var h=A0(n,s,c,this.en);a=this.a*(this.k0*l*(1+u/6*(1-p+d+u/20*(5-18*p+m+14*d-58*p*d+u/42*(61+179*m-m*p-479*p)))))+this.x0,o=this.a*(this.k0*(h-this.ml0+s*r*l/2*(1+u/12*(5-p+9*d+4*f+u/30*(61+m-58*p+270*d-330*p*d+u/56*(1385+543*m-m*p-3111*p))))))+this.y0}else{var g=c*Math.sin(r);if(Math.abs(Math.abs(g)-1)<1e-10)return 93;if(a=.5*this.a*this.k0*Math.log((1+g)/(1-g))+this.x0,o=c*Math.cos(r)/Math.sqrt(1-g**2),g=Math.abs(o),g>=1){if(g-1>1e-10)return 93;o=0}else o=Math.acos(o);n<0&&(o=-o),o=this.a*this.k0*(o-this.lat0)+this.y0}return e.x=a,e.y=o,e}function P0(e){var t,n,r,i,a=(e.x-this.x0)*(1/this.a),o=(e.y-this.y0)*(1/this.a);if(!this.es){var s=Math.exp(a/this.k0),c=.5*(s-1/s),l=this.lat0+o/this.k0,u=Math.cos(l);t=Math.sqrt((1-u**2)/(1+c**2)),r=Math.asin(t),o<0&&(r=-r),i=c===0&&u===0?0:Q(Math.atan2(c,u)+this.long0,this.over)}else if(t=this.ml0+o/this.k0,n=j0(t,this.es,this.en),Math.abs(n)<$){var d=Math.sin(n),f=Math.cos(n),p=Math.abs(f)>1e-10?Math.tan(n):0,m=this.ep2*f**2,h=m**2,g=p**2,_=g**2;t=1-this.es*d**2;var v=a*Math.sqrt(t)/this.k0,y=v**2;t*=p,r=n-t*y/(1-this.es)*.5*(1-y/12*(5+3*g-9*m*g+m-4*h-y/30*(61+90*g-252*m*g+45*_+46*m-y/56*(1385+3633*g+4095*_+1574*_*g)))),i=Q(this.long0+v*(1-y/6*(1+2*g+m-y/20*(5+28*g+24*_+8*m*g+6*m-y/42*(61+662*g+1320*_+720*_*g))))/f,this.over)}else r=$*_1(o),i=0;return e.x=i,e.y=r,e}function F0(e){var t=Math.exp(e);return t=(t-1/t)/2,t}function I0(e,t){e=Math.abs(e),t=Math.abs(t);var n=Math.max(e,t),r=Math.min(e,t)/(n||1);return n*Math.sqrt(1+r**2)}function L0(e){var t=1+e,n=t-1;return n===0?e:e*Math.log(t)/n}function R0(e){var t=Math.abs(e);return t=L0(t*(1+t/(I0(1,t)+1))),e<0?-t:t}function z0(e,t){for(var n=2*Math.cos(2*t),r=e.length-1,i=e[r],a=0,o;--r>=0;)o=-a+n*i+e[r],a=i,i=o;return t+o*Math.sin(2*t)}function B0(e,t){for(var n=2*Math.cos(t),r=e.length-1,i=e[r],a=0,o;--r>=0;)o=-a+n*i+e[r],a=i,i=o;return Math.sin(t)*o}function V0(e){var t=Math.exp(e);return t=(t+1/t)/2,t}function H0(e,t,n){for(var r=Math.sin(t),i=Math.cos(t),a=F0(n),o=V0(n),s=2*i*o,c=-2*r*a,l=e.length-1,u=e[l],d=0,f=0,p=0,m,h;--l>=0;)m=f,h=d,f=u,d=p,u=-m+s*f-c*d+e[l],p=-h+c*f+s*d;return s=r*o,c=i*a,[s*u-c*p,s*p+c*u]}function U0(){if(!this.approx&&(isNaN(this.es)||this.es<=0))throw Error(`Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.`);this.approx&&(r7.init.apply(this),this.forward=r7.forward,this.inverse=r7.inverse),this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0,this.long0=this.long0===void 0?0:this.long0,this.lat0=this.lat0===void 0?0:this.lat0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var e=this.es/(1+Math.sqrt(1-this.es)),t=e/(2-e),n=t;this.cgb[0]=t*(2+t*(-2/3+t*(-2+t*(116/45+t*(26/45+-2854/675*t))))),this.cbg[0]=t*(-2+t*(2/3+t*(4/3+t*(-82/45+t*(32/45+4642/4725*t))))),n*=t,this.cgb[1]=n*(7/3+t*(-8/5+t*(-227/45+t*(2704/315+2323/945*t)))),this.cbg[1]=n*(5/3+t*(-16/15+t*(-13/9+t*(904/315+-1522/945*t)))),n*=t,this.cgb[2]=n*(56/15+t*(-136/35+t*(-1262/105+73814/2835*t))),this.cbg[2]=n*(-26/15+t*(34/21+t*(8/5+-12686/2835*t))),n*=t,this.cgb[3]=n*(4279/630+t*(-332/35+-399572/14175*t)),this.cbg[3]=n*(1237/630+t*(-12/5+-24832/14175*t)),n*=t,this.cgb[4]=n*(4174/315+-144838/6237*t),this.cbg[4]=n*(-734/315+109598/31185*t),n*=t,this.cgb[5]=601676/22275*n,this.cbg[5]=444337/155925*n,n=t**2,this.Qn=this.k0/(1+t)*(1+n*(1/4+n*(1/64+n/256))),this.utg[0]=t*(-.5+t*(2/3+t*(-37/96+t*(1/360+t*(81/512+-96199/604800*t))))),this.gtu[0]=t*(.5+t*(-2/3+t*(5/16+t*(41/180+t*(-127/288+7891/37800*t))))),this.utg[1]=n*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+1118711/3870720*t)))),this.gtu[1]=n*(13/48+t*(-3/5+t*(557/1440+t*(281/630+-1983433/1935360*t)))),n*=t,this.utg[2]=n*(-17/480+t*(37/840+t*(209/4480+-5569/90720*t))),this.gtu[2]=n*(61/240+t*(-103/140+t*(15061/26880+167603/181440*t))),n*=t,this.utg[3]=n*(-4397/161280+t*(11/504+830251/7257600*t)),this.gtu[3]=n*(49561/161280+t*(-179/168+6601661/7257600*t)),n*=t,this.utg[4]=n*(-4583/161280+108847/3991680*t),this.gtu[4]=n*(34729/80640+-3418889/1995840*t),n*=t,this.utg[5]=-20648693/638668800*n,this.gtu[5]=212378941/319334400*n;var r=z0(this.cbg,this.lat0);this.Zb=-this.Qn*(r+B0(this.gtu,2*r))}function W0(e){var t=Q(e.x-this.long0,this.over),n=e.y;n=z0(this.cbg,n);var r=Math.sin(n),i=Math.cos(n),a=Math.sin(t),o=Math.cos(t);n=Math.atan2(r,o*i),t=Math.atan2(a*i,I0(r,i*o)),t=R0(Math.tan(t));var s=H0(this.gtu,2*n,2*t);n+=s[0],t+=s[1];var c,l;return Math.abs(t)<=2.623395162778?(c=this.a*(this.Qn*t)+this.x0,l=this.a*(this.Qn*n+this.Zb)+this.y0):(c=1/0,l=1/0),e.x=c,e.y=l,e}function G0(e){var t=(e.x-this.x0)*(1/this.a),n=(e.y-this.y0)*(1/this.a);n=(n-this.Zb)/this.Qn,t/=this.Qn;var r,i;if(Math.abs(t)<=2.623395162778){var a=H0(this.utg,2*n,2*t);n+=a[0],t+=a[1],t=Math.atan(F0(t));var o=Math.sin(n),s=Math.cos(n),c=Math.sin(t),l=Math.cos(t);n=Math.atan2(o*l,I0(c,l*s)),t=Math.atan2(c,l*s),r=Q(t+this.long0,this.over),i=z0(this.cgb,n)}else r=1/0,i=1/0;return e.x=r,e.y=i,e}function K0(e,t){if(e===void 0){if(e=Math.floor((Q(t)+Math.PI)*30/Math.PI)+1,e<0)return 0;if(e>60)return 60}return e}function q0(){var e=K0(this.zone,this.long0);if(e===void 0)throw Error(`unknown utm zone`);this.lat0=0,this.long0=(6*Math.abs(e)-183)*Z8,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,i7.init.apply(this),this.forward=i7.forward,this.inverse=i7.inverse}function J0(e,t){return((1-e)/(1+e))**t}function Y0(){var e=Math.sin(this.lat0),t=Math.cos(this.lat0);t*=t,this.rc=Math.sqrt(1-this.es)/(1-this.es*e*e),this.C=Math.sqrt(1+this.es*t*t/(1-this.es)),this.phic0=Math.asin(e/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+$8)/(Math.tan(.5*this.lat0+$8)**+this.C*J0(this.e*e,this.ratexp))}function X0(e){var t=e.x,n=e.y;return e.y=2*Math.atan(this.K*Math.tan(.5*n+$8)**+this.C*J0(this.e*Math.sin(n),this.ratexp))-$,e.x=this.C*t,e}function Z0(e){for(var t=1e-14,n=e.x/this.C,r=e.y,i=(Math.tan(.5*r+$8)/this.K)**(1/this.C),a=s7;a>0&&(r=2*Math.atan(i*J0(this.e*Math.sin(e.y),-.5*this.e))-$,!(Math.abs(r-e.y)<t));--a)e.y=r;return a?(e.x=n,e.y=r,e):null}function Q0(){c7.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||=`Oblique Stereographic Alternative`)}function $0(e){var t,n,r,i;return e.x=Q(e.x-this.long0,this.over),c7.forward.apply(this,[e]),t=Math.sin(e.y),n=Math.cos(e.y),r=Math.cos(e.x),i=this.k0*this.R2/(1+this.sinc0*t+this.cosc0*n*r),e.x=i*n*Math.sin(e.x),e.y=i*(this.cosc0*t-this.sinc0*n*r),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function e2(e){var t,n,r,i,a;if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,a=I0(e.x,e.y)){var o=2*Math.atan2(a,this.R2);t=Math.sin(o),n=Math.cos(o),i=Math.asin(n*this.sinc0+e.y*t*this.cosc0/a),r=Math.atan2(e.x*t,a*this.cosc0*n-e.y*this.sinc0*t)}else i=this.phic0,r=0;return e.x=r,e.y=i,c7.inverse.apply(this,[e]),e.x=Q(e.x+this.long0,this.over),e}function t2(e,t,n){return t*=n,Math.tan(.5*($+e))*((1-t)/(1+t))**(.5*n)}function n2(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=1e-10&&(this.k0=.5*(1+_1(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=1e-10&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt((1+this.e)**+(1+this.e)*(1-this.e)**(1-this.e)),this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=1e-10&&Math.abs(Math.cos(this.lat_ts))>1e-10&&(this.k0=.5*this.cons*g1(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/v1(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=g1(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(t2(this.lat0,this.sinlat0,this.e))-$,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function r2(e){var t=e.x,n=e.y,r=Math.sin(n),i=Math.cos(n),a,o,s,c,l,u,d=Q(t-this.long0,this.over);return Math.abs(Math.abs(t-this.long0)-Math.PI)<=1e-10&&Math.abs(n+this.lat0)<=1e-10?(e.x=NaN,e.y=NaN,e):this.sphere?(a=2*this.k0/(1+this.sinlat0*r+this.coslat0*i*Math.cos(d)),e.x=this.a*a*i*Math.sin(d)+this.x0,e.y=this.a*a*(this.coslat0*r-this.sinlat0*i*Math.cos(d))+this.y0,e):(o=2*Math.atan(t2(n,r,this.e))-$,c=Math.cos(o),s=Math.sin(o),Math.abs(this.coslat0)<=1e-10?(l=v1(this.e,n*this.con,this.con*r),u=2*this.a*this.k0*l/this.cons,e.x=this.x0+u*Math.sin(t-this.long0),e.y=this.y0-this.con*u*Math.cos(t-this.long0),e):(Math.abs(this.sinlat0)<1e-10?(a=2*this.a*this.k0/(1+c*Math.cos(d)),e.y=a*s):(a=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*s+this.cosX0*c*Math.cos(d))),e.y=a*(this.cosX0*s-this.sinX0*c*Math.cos(d))+this.y0),e.x=a*c*Math.sin(d)+this.x0,e))}function i2(e){e.x-=this.x0,e.y-=this.y0;var t,n,r,i,a,o=Math.sqrt(e.x*e.x+e.y*e.y);if(this.sphere){var s=2*Math.atan(o/(2*this.a*this.k0));return t=this.long0,n=this.lat0,o<=1e-10?(e.x=t,e.y=n,e):(n=Math.asin(Math.cos(s)*this.sinlat0+e.y*Math.sin(s)*this.coslat0/o),t=Math.abs(this.coslat0)<1e-10?this.lat0>0?Q(this.long0+Math.atan2(e.x,-1*e.y),this.over):Q(this.long0+Math.atan2(e.x,e.y),this.over):Q(this.long0+Math.atan2(e.x*Math.sin(s),o*this.coslat0*Math.cos(s)-e.y*this.sinlat0*Math.sin(s)),this.over),e.x=t,e.y=n,e)}else if(Math.abs(this.coslat0)<=1e-10){if(o<=1e-10)return n=this.lat0,t=this.long0,e.x=t,e.y=n,e;e.x*=this.con,e.y*=this.con,r=o*this.cons/(2*this.a*this.k0),n=this.con*y1(this.e,r),t=this.con*Q(this.con*this.long0+Math.atan2(e.x,-1*e.y),this.over)}else i=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),t=this.long0,o<=1e-10?a=this.X0:(a=Math.asin(Math.cos(i)*this.sinX0+e.y*Math.sin(i)*this.cosX0/o),t=Q(this.long0+Math.atan2(e.x*Math.sin(i),o*this.cosX0*Math.cos(i)-e.y*this.sinX0*Math.sin(i)),this.over)),n=-1*y1(this.e,Math.tan(.5*($+a)));return e.x=t,e.y=n,e}function a2(){var e=this.lat0;this.lambda0=this.long0;var t=Math.sin(e),n=this.a,r=1/this.rf,i=2*r-r**2,a=this.e=Math.sqrt(i);this.R=this.k0*n*Math.sqrt(1-i)/(1-i*t**2),this.alpha=Math.sqrt(1+i/(1-i)*Math.cos(e)**4),this.b0=Math.asin(t/this.alpha);var o=Math.log(Math.tan(Math.PI/4+this.b0/2)),s=Math.log(Math.tan(Math.PI/4+e/2)),c=Math.log((1+a*t)/(1-a*t));this.K=o-this.alpha*s+this.alpha*a/2*c}function o2(e){var t=Math.log(Math.tan(Math.PI/4-e.y/2)),n=this.e/2*Math.log((1+this.e*Math.sin(e.y))/(1-this.e*Math.sin(e.y))),r=-this.alpha*(t+n)+this.K,i=2*(Math.atan(Math.exp(r))-Math.PI/4),a=this.alpha*(e.x-this.lambda0),o=Math.atan(Math.sin(a)/(Math.sin(this.b0)*Math.tan(i)+Math.cos(this.b0)*Math.cos(a))),s=Math.asin(Math.cos(this.b0)*Math.sin(i)-Math.sin(this.b0)*Math.cos(i)*Math.cos(a));return e.y=this.R/2*Math.log((1+Math.sin(s))/(1-Math.sin(s)))+this.y0,e.x=this.R*o+this.x0,e}function s2(e){for(var t=e.x-this.x0,n=e.y-this.y0,r=t/this.R,i=2*(Math.atan(Math.exp(n/this.R))-Math.PI/4),a=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(r)),o=Math.atan(Math.sin(r)/(Math.cos(this.b0)*Math.cos(r)-Math.sin(this.b0)*Math.tan(i))),s=this.lambda0+o/this.alpha,c=0,l=a,u=-1e3,d=0;Math.abs(l-u)>1e-7;){if(++d>20)return;c=1/this.alpha*(Math.log(Math.tan(Math.PI/4+a/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(l))/2)),u=l,l=2*Math.atan(Math.exp(c))-Math.PI/2}return e.x=s,e.y=l,e}function c2(e){var t=[`Hotine_Oblique_Mercator`,`Hotine_Oblique_Mercator_variant_A`,`Hotine_Oblique_Mercator_Azimuth_Natural_Origin`],n=typeof e.projName==`object`?Object.keys(e.projName)[0]:e.projName;return`no_uoff`in e||`no_off`in e||t.indexOf(n)!==-1||t.indexOf(E1(n))!==-1}function l2(){var e,t,n,r,i,a,o,s,c,l,u=0,d,f=0,p=0,m=0,h=0,g=0,_=0;this.no_off=c2(this),this.no_rot=`no_rot`in this;var v=!1;`alpha`in this&&(v=!0);var y=!1;if(`rectified_grid_angle`in this&&(y=!0),v&&(_=this.alpha),y&&(u=this.rectified_grid_angle),v||y)f=this.longc;else if(p=this.long1,h=this.lat1,m=this.long2,g=this.lat2,Math.abs(h-g)<=f7||(e=Math.abs(h))<=f7||Math.abs(e-$)<=f7||Math.abs(Math.abs(this.lat0)-$)<=f7||Math.abs(Math.abs(g)-$)<=f7)throw Error();var b=1-this.es;t=Math.sqrt(b),Math.abs(this.lat0)>1e-10?(s=Math.sin(this.lat0),n=Math.cos(this.lat0),e=1-this.es*s*s,this.B=n*n,this.B=Math.sqrt(1+this.es*this.B*this.B/b),this.A=this.B*this.k0*t/e,r=this.B*t/(n*Math.sqrt(e)),i=r*r-1,i<=0?i=0:(i=Math.sqrt(i),this.lat0<0&&(i=-i)),this.E=i+=r,this.E*=v1(this.e,this.lat0,s)**+this.B):(this.B=1/t,this.A=this.k0,this.E=r=i=1),v||y?(v?(d=Math.asin(Math.sin(_)/r),y||(u=_)):(d=u,_=Math.asin(r*Math.sin(d))),this.lam0=f-Math.asin(.5*(i-1/i)*Math.tan(d))/this.B):(a=v1(this.e,h,Math.sin(h))**+this.B,o=v1(this.e,g,Math.sin(g))**+this.B,i=this.E/a,c=(o-a)/(o+a),l=this.E*this.E,l=(l-o*a)/(l+o*a),e=p-m,e<-Math.PI?m-=e5:e>Math.PI&&(m+=e5),this.lam0=Q(.5*(p+m)-Math.atan(l*Math.tan(.5*this.B*(p-m))/c)/this.B,this.over),d=Math.atan(2*Math.sin(this.B*Q(p-this.lam0,this.over))/(i-1/i)),u=_=Math.asin(r*Math.sin(d))),this.singam=Math.sin(d),this.cosgam=Math.cos(d),this.sinrot=Math.sin(u),this.cosrot=Math.cos(u),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.no_off?this.u_0=0:(this.u_0=Math.abs(this.ArB*Math.atan(Math.sqrt(r*r-1)/Math.cos(_))),this.lat0<0&&(this.u_0=-this.u_0)),i=.5*d,this.v_pole_n=this.ArB*Math.log(Math.tan($8-i)),this.v_pole_s=this.ArB*Math.log(Math.tan($8+i))}function u2(e){var t={},n,r,i,a,o,s,c,l;if(e.x-=this.lam0,Math.abs(Math.abs(e.y)-$)>1e-10){if(o=this.E/v1(this.e,e.y,Math.sin(e.y))**+this.B,s=1/o,n=.5*(o-s),r=.5*(o+s),a=Math.sin(this.B*e.x),i=(n*this.singam-a*this.cosgam)/r,Math.abs(Math.abs(i)-1)<1e-10)throw Error();l=.5*this.ArB*Math.log((1-i)/(1+i)),s=Math.cos(this.B*e.x),c=Math.abs(s)<f7?this.A*e.x:this.ArB*Math.atan2(n*this.cosgam+a*this.singam,s)}else l=e.y>0?this.v_pole_n:this.v_pole_s,c=this.ArB*e.y;return this.no_rot?(t.x=c,t.y=l):(c-=this.u_0,t.x=l*this.cosrot+c*this.sinrot,t.y=c*this.cosrot-l*this.sinrot),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function d2(e){var t,n,r,i,a,o,s,c={};if(e.x=(e.x-this.x0)*(1/this.a),e.y=(e.y-this.y0)*(1/this.a),this.no_rot?(n=e.y,t=e.x):(n=e.x*this.cosrot-e.y*this.sinrot,t=e.y*this.cosrot+e.x*this.sinrot+this.u_0),r=Math.exp(-this.BrA*n),i=.5*(r-1/r),a=.5*(r+1/r),o=Math.sin(this.BrA*t),s=(o*this.cosgam+i*this.singam)/a,Math.abs(Math.abs(s)-1)<1e-10)c.x=0,c.y=s<0?-$:$;else{if(c.y=this.E/Math.sqrt((1+s)/(1-s)),c.y=y1(this.e,c.y**(1/this.B)),c.y===1/0)throw Error();c.x=-this.rB*Math.atan2(i*this.cosgam-o*this.singam,Math.cos(this.BrA*t))}return c.x+=this.lam0,c}function f2(){if(this.lat2||=this.lat1,this.k0||=1,this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<1e-10)){var e=this.b/this.a;this.e=Math.sqrt(1-e*e);var t=Math.sin(this.lat1),n=Math.cos(this.lat1),r=g1(this.e,t,n),i=v1(this.e,this.lat1,t),a=Math.sin(this.lat2),o=Math.cos(this.lat2),s=g1(this.e,a,o),c=v1(this.e,this.lat2,a),l=Math.abs(Math.abs(this.lat0)-$)<1e-10?0:v1(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>1e-10?this.ns=Math.log(r/s)/Math.log(i/c):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=r/(this.ns*i**+this.ns),this.rh=this.a*this.f0*l**+this.ns,this.title||=`Lambert Conformal Conic`}}function p2(e){var t=e.x,n=e.y;Math.abs(2*Math.abs(n)-Math.PI)<=1e-10&&(n=_1(n)*($-2*X8));var r=Math.abs(Math.abs(n)-$),i,a;if(r>1e-10)i=v1(this.e,n,Math.sin(n)),a=this.a*this.f0*i**+this.ns;else{if(r=n*this.ns,r<=0)return null;a=0}var o=this.ns*Q(t-this.long0,this.over);return e.x=this.k0*(a*Math.sin(o))+this.x0,e.y=this.k0*(this.rh-a*Math.cos(o))+this.y0,e}function m2(e){var t,n,r,i,a,o=(e.x-this.x0)/this.k0,s=this.rh-(e.y-this.y0)/this.k0;this.ns>0?(t=Math.sqrt(o*o+s*s),n=1):(t=-Math.sqrt(o*o+s*s),n=-1);var c=0;if(t!==0&&(c=Math.atan2(n*o,n*s)),t!==0||this.ns>0){if(n=1/this.ns,r=(t/(this.a*this.f0))**+n,i=y1(this.e,r),i===-9999)return null}else i=-$;return a=Q(c/this.ns+this.long0,this.over),e.x=a,e.y=i,e}function h2(){this.a=6377397.155,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||=.863937979737193,this.long0||=.4334234309119251,this.k0||=.9999,this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.cos(this.fi0)**4/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)))**(this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.tan(this.fi0/2+this.s45)**+this.alfa*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.sin(this.fi0)**2),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq}function g2(e){var t,n,r,i,a,o,s,c=e.x,l=e.y,u=Q(c-this.long0,this.over);return t=((1+this.e*Math.sin(l))/(1-this.e*Math.sin(l)))**(this.alfa*this.e/2),n=2*(Math.atan(this.k*Math.tan(l/2+this.s45)**+this.alfa/t)-this.s45),r=-u*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(n)+Math.sin(this.ad)*Math.cos(n)*Math.cos(r)),a=Math.asin(Math.cos(n)*Math.sin(r)/Math.cos(i)),o=this.n*a,s=this.ro0*Math.tan(this.s0/2+this.s45)**+this.n/Math.tan(i/2+this.s45)**+this.n,e.y=s*Math.cos(o)/1,e.x=s*Math.sin(o)/1,this.czech||(e.y*=-1,e.x*=-1),e}function _2(e){var t,n,r,i,a,o,s,c,l=e.x;e.x=e.y,e.y=l,this.czech||(e.y*=-1,e.x*=-1),o=Math.sqrt(e.x*e.x+e.y*e.y),a=Math.atan2(e.y,e.x),i=a/Math.sin(this.s0),r=2*(Math.atan((this.ro0/o)**(1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),t=Math.asin(Math.cos(this.ad)*Math.sin(r)-Math.sin(this.ad)*Math.cos(r)*Math.cos(i)),n=Math.asin(Math.cos(r)*Math.sin(i)/Math.cos(t)),e.x=this.long0-n/this.alfa,s=t,c=0;var u=0;do e.y=2*(Math.atan(this.k**(-1/this.alfa)*Math.tan(t/2+this.s45)**(1/this.alfa)*((1+this.e*Math.sin(s))/(1-this.e*Math.sin(s)))**(this.e/2))-this.s45),Math.abs(s-e.y)<1e-10&&(c=1),s=e.y,u+=1;while(c===0&&u<15);return u>=15?null:e}function v2(e,t,n,r,i){return e*i-t*Math.sin(2*i)+n*Math.sin(4*i)-r*Math.sin(6*i)}function y2(e){return 1-.25*e*(1+e/16*(3+1.25*e))}function b2(e){return .375*e*(1+.25*e*(1+.46875*e))}function x2(e){return .05859375*e*e*(1+.75*e)}function S2(e){return e*e*e*(35/3072)}function C2(e,t,n){var r=t*n;return e/Math.sqrt(1-r*r)}function w2(e){return Math.abs(e)<$?e:e-_1(e)*Math.PI}function T2(e,t,n,r,i){for(var a=e/t,o,s=0;s<15;s++)if(o=(e-(t*a-n*Math.sin(2*a)+r*Math.sin(4*a)-i*Math.sin(6*a)))/(t-2*n*Math.cos(2*a)+4*r*Math.cos(4*a)-6*i*Math.cos(6*a)),a+=o,Math.abs(o)<=1e-10)return a;return NaN}function E2(){this.sphere||(this.e0=y2(this.es),this.e1=b2(this.es),this.e2=x2(this.es),this.e3=S2(this.es),this.ml0=this.a*v2(this.e0,this.e1,this.e2,this.e3,this.lat0))}function D2(e){var t,n,r=e.x,i=e.y;if(r=Q(r-this.long0,this.over),this.sphere)t=this.a*Math.asin(Math.cos(i)*Math.sin(r)),n=this.a*(Math.atan2(Math.tan(i),Math.cos(r))-this.lat0);else{var a=Math.sin(i),o=Math.cos(i),s=C2(this.a,this.e,a),c=Math.tan(i)*Math.tan(i),l=r*Math.cos(i),u=l*l,d=this.es*o*o/(1-this.es),f=this.a*v2(this.e0,this.e1,this.e2,this.e3,i);t=s*l*(1-u*c*(1/6-(8-c+8*d)*u/120)),n=f-this.ml0+s*a/o*u*(.5+(5-c+6*d)*u/24)}return e.x=t+this.x0,e.y=n+this.y0,e}function O2(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,n=e.y/this.a,r,i;if(this.sphere){var a=n+this.lat0;r=Math.asin(Math.sin(a)*Math.cos(t)),i=Math.atan2(Math.tan(t),Math.cos(a))}else{var o=T2(this.ml0/this.a+n,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(o)-$)<=1e-10)return e.x=this.long0,e.y=$,n<0&&(e.y*=-1),e;var s=C2(this.a,this.e,Math.sin(o)),c=s*s*s/this.a/this.a*(1-this.es),l=Math.tan(o)**2,u=t*this.a/s,d=u*u;r=o-s*Math.tan(o)/c*u*u*(.5-(1+3*l)*u*u/24),i=u*(1-d*(l/3+(1+3*l)*l*d/15))/Math.cos(o)}return e.x=Q(i+this.long0,this.over),e.y=w2(r),e}function k2(e,t){var n;return e>1e-7?(n=e*t,(1-e*e)*(t/(1-n*n)-.5/e*Math.log((1-n)/(1+n)))):2*t}function A2(){var e=Math.abs(this.lat0);if(Math.abs(e-$)<1e-10?this.mode=this.lat0<0?1:2:Math.abs(e)<1e-10?this.mode=3:this.mode=4,this.es>0){var t;switch(this.qp=k2(this.e,1),this.mmf=.5/(1-this.es),this.apa=N2(this.es),this.mode){case 2:this.dd=1;break;case 1:this.dd=1;break;case 3:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case 4:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=k2(this.e,t)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*t*t)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd;break}}else this.mode===4&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function j2(e){var t,n,r,i,a,o,s,c,l,u,d=e.x,f=e.y;if(d=Q(d-this.long0,this.over),this.sphere){if(a=Math.sin(f),u=Math.cos(f),r=Math.cos(d),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(n=this.mode===this.EQUIT?1+u*r:1+this.sinph0*a+this.cosph0*u*r,n<=1e-10)return null;n=Math.sqrt(2/n),t=n*u*Math.sin(d),n*=this.mode===this.EQUIT?a:this.cosph0*a-this.sinph0*u*r}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(r=-r),Math.abs(f+this.lat0)<1e-10)return null;n=$8-f*.5,n=2*(this.mode===this.S_POLE?Math.cos(n):Math.sin(n)),t=n*Math.sin(d),n*=r}}else{switch(s=0,c=0,l=0,r=Math.cos(d),i=Math.sin(d),a=Math.sin(f),o=k2(this.e,a),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(s=o/this.qp,c=Math.sqrt(1-s*s)),this.mode){case this.OBLIQ:l=1+this.sinb1*s+this.cosb1*c*r;break;case this.EQUIT:l=1+c*r;break;case this.N_POLE:l=$+f,o=this.qp-o;break;case this.S_POLE:l=f-$,o=this.qp+o;break}if(Math.abs(l)<1e-10)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:l=Math.sqrt(2/l),n=this.mode===this.OBLIQ?this.ymf*l*(this.cosb1*s-this.sinb1*c*r):(l=Math.sqrt(2/(1+c*r)))*s*this.ymf,t=this.xmf*l*c*i;break;case this.N_POLE:case this.S_POLE:o>=0?(t=(l=Math.sqrt(o))*i,n=r*(this.mode===this.S_POLE?l:-l)):t=n=0;break}}return e.x=this.a*t+this.x0,e.y=this.a*n+this.y0,e}function M2(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,n=e.y/this.a,r,i,a,o,s,c,l;if(this.sphere){var u=0,d,f=0;if(d=Math.sqrt(t*t+n*n),i=d*.5,i>1)return null;switch(i=2*Math.asin(i),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(f=Math.sin(i),u=Math.cos(i)),this.mode){case this.EQUIT:i=Math.abs(d)<=1e-10?0:Math.asin(n*f/d),t*=f,n=u*d;break;case this.OBLIQ:i=Math.abs(d)<=1e-10?this.lat0:Math.asin(u*this.sinph0+n*f*this.cosph0/d),t*=f*this.cosph0,n=(u-Math.sin(i)*this.sinph0)*d;break;case this.N_POLE:n=-n,i=$-i;break;case this.S_POLE:i-=$;break}r=n===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(t,n)}else{if(l=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(t/=this.dd,n*=this.dd,c=Math.sqrt(t*t+n*n),c<1e-10)return e.x=this.long0,e.y=this.lat0,e;o=2*Math.asin(.5*c/this.rq),a=Math.cos(o),t*=o=Math.sin(o),this.mode===this.OBLIQ?(l=a*this.sinb1+n*o*this.cosb1/c,s=this.qp*l,n=c*this.cosb1*a-n*this.sinb1*o):(l=n*o/c,s=this.qp*l,n=c*a)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(n=-n),s=t*t+n*n,!s)return e.x=this.long0,e.y=this.lat0,e;l=1-s/this.qp,this.mode===this.S_POLE&&(l=-l)}r=Math.atan2(t,n),i=P2(Math.asin(l),this.apa)}return e.x=Q(this.long0+r,this.over),e.y=i,e}function N2(e){var t,n=[];return n[0]=e*_7,t=e*e,n[0]+=t*v7,n[1]=t*b7,t*=e,n[0]+=t*y7,n[1]+=t*x7,n[2]=t*S7,n}function P2(e,t){var n=e+e;return e+t[0]*Math.sin(n)+t[1]*Math.sin(n+n)+t[2]*Math.sin(n+n+n)}function F2(e){return Math.abs(e)>1&&(e=e>1?1:-1),Math.asin(e)}function I2(){Math.abs(this.lat1+this.lat2)<1e-10||(this.temp=this.b/this.a,this.es=1-this.temp**2,this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=g1(this.e3,this.sin_po,this.cos_po),this.qs1=k2(this.e3,this.sin_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=g1(this.e3,this.sin_po,this.cos_po),this.qs2=k2(this.e3,this.sin_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=k2(this.e3,this.sin_po),Math.abs(this.lat1-this.lat2)>1e-10?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)}function L2(e){var t=e.x,n=e.y;this.sin_phi=Math.sin(n),this.cos_phi=Math.cos(n);var r=k2(this.e3,this.sin_phi),i=this.a*Math.sqrt(this.c-this.ns0*r)/this.ns0,a=this.ns0*Q(t-this.long0,this.over),o=i*Math.sin(a)+this.x0,s=this.rh-i*Math.cos(a)+this.y0;return e.x=o,e.y=s,e}function R2(e){var t,n,r,i,a,o;return e.x-=this.x0,e.y=this.rh-e.y+this.y0,this.ns0>=0?(t=Math.sqrt(e.x*e.x+e.y*e.y),r=1):(t=-Math.sqrt(e.x*e.x+e.y*e.y),r=-1),i=0,t!==0&&(i=Math.atan2(r*e.x,r*e.y)),r=t*this.ns0/this.a,this.sphere?o=Math.asin((this.c-r*r)/(2*this.ns0)):(n=(this.c-r*r)/this.ns0,o=this.phi1z(this.e3,n)),a=Q(i/this.ns0+this.long0,this.over),e.x=a,e.y=o,e}function z2(e,t){var n,r,i,a,o,s=F2(.5*t);if(e<1e-10)return s;for(var c=e*e,l=1;l<=25;l++)if(n=Math.sin(s),r=Math.cos(s),i=e*n,a=1-i*i,o=.5*a*a/r*(t/(1-c)-n/a+.5/e*Math.log((1-i)/(1+i))),s+=o,Math.abs(o)<=1e-7)return s;return null}function B2(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function V2(e){var t,n,r,i,a,o,s,c,l=e.x,u=e.y;return r=Q(l-this.long0,this.over),t=Math.sin(u),n=Math.cos(u),i=Math.cos(r),o=this.sin_p14*t+this.cos_p14*n*i,a=1,o>0||Math.abs(o)<=1e-10?(s=this.x0+this.a*a*n*Math.sin(r)/o,c=this.y0+this.a*a*(this.cos_p14*t-this.sin_p14*n*i)/o):(s=this.x0+this.infinity_dist*n*Math.sin(r),c=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*n*i)),e.x=s,e.y=c,e}function H2(e){var t,n,r,i,a,o;return e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,(t=Math.sqrt(e.x*e.x+e.y*e.y))?(i=Math.atan2(t,this.rc),n=Math.sin(i),r=Math.cos(i),o=F2(r*this.sin_p14+e.y*n*this.cos_p14/t),a=Math.atan2(e.x*n,t*this.cos_p14*r-e.y*this.sin_p14*n),a=Q(this.long0+a,this.over)):(o=this.phic0,a=0),e.x=a,e.y=o,e}function U2(e,t){var n=1-(1-e*e)/(2*e)*Math.log((1-e)/(1+e));if(Math.abs(Math.abs(t)-n)<1e-6)return t<0?-1*$:$;for(var r=Math.asin(.5*t),i,a,o,s,c=0;c<30;c++)if(a=Math.sin(r),o=Math.cos(r),s=e*a,i=(1-s*s)**2/(2*o)*(t/(1-e*e)-a/(1-s*s)+.5/e*Math.log((1-s)/(1+s))),r+=i,Math.abs(i)<=1e-10)return r;return NaN}function W2(){this.sphere||(this.k0=g1(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function G2(e){var t=e.x,n=e.y,r,i,a=Q(t-this.long0,this.over);if(this.sphere)r=this.x0+this.a*a*Math.cos(this.lat_ts),i=this.y0+this.a*Math.sin(n)/Math.cos(this.lat_ts);else{var o=k2(this.e,Math.sin(n));r=this.x0+this.a*this.k0*a,i=this.y0+this.a*o*.5/this.k0}return e.x=r,e.y=i,e}function K2(e){e.x-=this.x0,e.y-=this.y0;var t,n;return this.sphere?(t=Q(this.long0+e.x/this.a/Math.cos(this.lat_ts),this.over),n=Math.asin(e.y/this.a*Math.cos(this.lat_ts))):(n=U2(this.e,2*e.y*this.k0/this.a),t=Q(this.long0+e.x/(this.a*this.k0),this.over)),e.x=t,e.y=n,e}function q2(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||`Equidistant Cylindrical (Plate Carre)`,this.rc=Math.cos(this.lat_ts)}function J2(e){var t=e.x,n=e.y,r=Q(t-this.long0,this.over),i=w2(n-this.lat0);return e.x=this.x0+this.a*r*this.rc,e.y=this.y0+this.a*i,e}function Y2(e){var t=e.x,n=e.y;return e.x=Q(this.long0+(t-this.x0)/(this.a*this.rc),this.over),e.y=w2(this.lat0+(n-this.y0)/this.a),e}function X2(){this.temp=this.b/this.a,this.es=1-this.temp**2,this.e=Math.sqrt(this.es),this.e0=y2(this.es),this.e1=b2(this.es),this.e2=x2(this.es),this.e3=S2(this.es),this.ml0=this.a*v2(this.e0,this.e1,this.e2,this.e3,this.lat0)}function Z2(e){var t=e.x,n=e.y,r,i,a,o=Q(t-this.long0,this.over);if(a=o*Math.sin(n),this.sphere)Math.abs(n)<=1e-10?(r=this.a*o,i=-1*this.a*this.lat0):(r=this.a*Math.sin(a)/Math.tan(n),i=this.a*(w2(n-this.lat0)+(1-Math.cos(a))/Math.tan(n)));else if(Math.abs(n)<=1e-10)r=this.a*o,i=-1*this.ml0;else{var s=C2(this.a,this.e,Math.sin(n))/Math.tan(n);r=s*Math.sin(a),i=this.a*v2(this.e0,this.e1,this.e2,this.e3,n)-this.ml0+s*(1-Math.cos(a))}return e.x=r+this.x0,e.y=i+this.y0,e}function Q2(e){var t,n,r=e.x-this.x0,i=e.y-this.y0,a,o,s,c,l;if(this.sphere)if(Math.abs(i+this.a*this.lat0)<=1e-10)t=Q(r/this.a+this.long0,this.over),n=0;else{o=this.lat0+i/this.a,s=r*r/this.a/this.a+o*o,c=o;var u;for(a=O7;a;--a)if(u=Math.tan(c),l=-1*(o*(c*u+1)-c-.5*(c*c+s)*u)/((c-o)/u-1),c+=l,Math.abs(l)<=1e-10){n=c;break}t=Q(this.long0+Math.asin(r*Math.tan(c)/this.a)/Math.sin(n),this.over)}else if(Math.abs(i+this.ml0)<=1e-10)n=0,t=Q(this.long0+r/this.a,this.over);else{o=(this.ml0+i)/this.a,s=r*r/this.a/this.a+o*o,c=o;var d,f,p,m,h;for(a=O7;a;--a)if(h=this.e*Math.sin(c),d=Math.sqrt(1-h*h)*Math.tan(c),f=this.a*v2(this.e0,this.e1,this.e2,this.e3,c),p=this.e0-2*this.e1*Math.cos(2*c)+4*this.e2*Math.cos(4*c)-6*this.e3*Math.cos(6*c),m=f/this.a,l=(o*(d*m+1)-m-.5*d*(m*m+s))/(this.es*Math.sin(2*c)*(m*m+s-2*o*m)/(4*d)+(o-m)*(d*p-2/Math.sin(2*c))-p),c-=l,Math.abs(l)<=1e-10){n=c;break}d=Math.sqrt(1-this.es*Math.sin(n)**2)*Math.tan(n),t=Q(this.long0+Math.asin(r*d/this.a)/Math.sin(n),this.over)}return e.x=t,e.y=n,e}function $2(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013}function e4(e){var t,n=e.x,r=e.y-this.lat0,i=n-this.long0,a=r/K8*1e-5,o=i,s=1,c=0;for(t=1;t<=10;t++)s*=a,c+=this.A[t]*s;var l=c,u=o,d=1,f=0,p,m,h=0,g=0;for(t=1;t<=6;t++)p=d*l-f*u,m=f*l+d*u,d=p,f=m,h=h+this.B_re[t]*d-this.B_im[t]*f,g=g+this.B_im[t]*d+this.B_re[t]*f;return e.x=g*this.a+this.x0,e.y=h*this.a+this.y0,e}function t4(e){var t,n=e.x,r=e.y,i=n-this.x0,a=(r-this.y0)/this.a,o=i/this.a,s=1,c=0,l,u,d=0,f=0;for(t=1;t<=6;t++)l=s*a-c*o,u=c*a+s*o,s=l,c=u,d=d+this.C_re[t]*s-this.C_im[t]*c,f=f+this.C_im[t]*s+this.C_re[t]*c;for(var p=0;p<this.iterations;p++){var m=d,h=f,g,_,v=a,y=o;for(t=2;t<=6;t++)g=m*d-h*f,_=h*d+m*f,m=g,h=_,v+=(t-1)*(this.B_re[t]*m-this.B_im[t]*h),y+=(t-1)*(this.B_im[t]*m+this.B_re[t]*h);m=1,h=0;var b=this.B_re[1],x=this.B_im[1];for(t=2;t<=6;t++)g=m*d-h*f,_=h*d+m*f,m=g,h=_,b+=t*(this.B_re[t]*m-this.B_im[t]*h),x+=t*(this.B_im[t]*m+this.B_re[t]*h);var S=b*b+x*x;d=(v*b+y*x)/S,f=(y*b-v*x)/S}var C=d,w=f,T=1,E=0;for(t=1;t<=9;t++)T*=C,E+=this.D[t]*T;var D=this.lat0+E*K8*1e5;return e.x=this.long0+w,e.y=D,e}function n4(){}function r4(e){var t=e.x,n=e.y,r=Q(t-this.long0,this.over),i=this.x0+this.a*r,a=this.y0+this.a*Math.log(Math.tan(Math.PI/4+n/2.5))*1.25;return e.x=i,e.y=a,e}function i4(e){e.x-=this.x0,e.y-=this.y0;var t=Q(this.long0+e.x/this.a,this.over),n=2.5*(Math.atan(Math.exp(.8*e.y/this.a))-Math.PI/4);return e.x=t,e.y=n,e}function a4(){this.long0=this.long0||0,this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=k0(this.es)}function o4(e){var t,n,r=e.x,i=e.y;if(r=Q(r-this.long0,this.over),this.sphere){if(!this.m)i=this.n===1?i:Math.asin(this.n*Math.sin(i));else for(var a=this.n*Math.sin(i),o=M7;o;--o){var s=(this.m*i+Math.sin(i)-a)/(this.m+Math.cos(i));if(i-=s,Math.abs(s)<1e-10)break}t=this.a*this.C_x*r*(this.m+Math.cos(i)),n=this.a*this.C_y*i}else{var c=Math.sin(i),l=Math.cos(i);n=this.a*A0(i,c,l,this.en),t=this.a*r*l/Math.sqrt(1-this.es*c*c)}return e.x=t,e.y=n,e}function s4(e){var t,n,r,i;return e.x-=this.x0,r=e.x/this.a,e.y-=this.y0,t=e.y/this.a,this.sphere?(t/=this.C_y,r/=this.C_x*(this.m+Math.cos(t)),this.m?t=F2((this.m*t+Math.sin(t))/this.n):this.n!==1&&(t=F2(Math.sin(t)/this.n)),r=Q(r+this.long0,this.over),t=w2(t)):(t=j0(e.y/this.a,this.es,this.en),i=Math.abs(t),i<$?(i=Math.sin(t),n=this.long0+e.x*Math.sqrt(1-this.es*i*i)/(this.a*Math.cos(t)),r=Q(n,this.over)):i-1e-10<$&&(r=this.long0)),e.x=r,e.y=t,e}function c4(){this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0,this.long0=this.long0===void 0?0:this.long0}function l4(e){for(var t=e.x,n=e.y,r=Q(t-this.long0,this.over),i=n,a=Math.PI*Math.sin(n);;){var o=-(i+Math.sin(i)-a)/(1+Math.cos(i));if(i+=o,Math.abs(o)<1e-10)break}i/=2,Math.PI/2-Math.abs(n)<1e-10&&(r=0);var s=.900316316158*this.a*r*Math.cos(i)+this.x0,c=1.4142135623731*this.a*Math.sin(i)+this.y0;return e.x=s,e.y=c,e}function u4(e){var t,n;e.x-=this.x0,e.y-=this.y0,n=e.y/(1.4142135623731*this.a),Math.abs(n)>.999999999999&&(n=.999999999999),t=Math.asin(n);var r=Q(this.long0+e.x/(.900316316158*this.a*Math.cos(t)),this.over);r<-Math.PI&&(r=-Math.PI),r>Math.PI&&(r=Math.PI),n=(2*t+Math.sin(2*t))/Math.PI,Math.abs(n)>1&&(n=1);var i=Math.asin(n);return e.x=r,e.y=i,e}function d4(){Math.abs(this.lat1+this.lat2)<1e-10||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-this.temp**2,this.e=Math.sqrt(this.es),this.e0=y2(this.es),this.e1=b2(this.es),this.e2=x2(this.es),this.e3=S2(this.es),this.sin_phi=Math.sin(this.lat1),this.cos_phi=Math.cos(this.lat1),this.ms1=g1(this.e,this.sin_phi,this.cos_phi),this.ml1=v2(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<1e-10?this.ns=this.sin_phi:(this.sin_phi=Math.sin(this.lat2),this.cos_phi=Math.cos(this.lat2),this.ms2=g1(this.e,this.sin_phi,this.cos_phi),this.ml2=v2(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=v2(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))}function f4(e){var t=e.x,n=e.y,r;if(this.sphere)r=this.a*(this.g-n);else{var i=v2(this.e0,this.e1,this.e2,this.e3,n);r=this.a*(this.g-i)}var a=this.ns*Q(t-this.long0,this.over),o=this.x0+r*Math.sin(a),s=this.y0+this.rh-r*Math.cos(a);return e.x=o,e.y=s,e}function p4(e){e.x-=this.x0,e.y=this.rh-e.y+this.y0;var t,n,r,i;this.ns>=0?(n=Math.sqrt(e.x*e.x+e.y*e.y),t=1):(n=-Math.sqrt(e.x*e.x+e.y*e.y),t=-1);var a=0;return n!==0&&(a=Math.atan2(t*e.x,t*e.y)),this.sphere?(i=Q(this.long0+a/this.ns,this.over),r=w2(this.g-n/this.a),e.x=i,e.y=r,e):(r=T2(this.g-n/this.a,this.e0,this.e1,this.e2,this.e3),i=Q(this.long0+a/this.ns,this.over),e.x=i,e.y=r,e)}function m4(){this.R=this.a}function h4(e){var t=e.x,n=e.y,r=Q(t-this.long0,this.over),i,a;Math.abs(n)<=1e-10&&(i=this.x0+this.R*r,a=this.y0);var o=F2(2*Math.abs(n/Math.PI));(Math.abs(r)<=1e-10||Math.abs(Math.abs(n)-$)<=1e-10)&&(i=this.x0,a=n>=0?this.y0+Math.PI*this.R*Math.tan(.5*o):this.y0+Math.PI*this.R*-Math.tan(.5*o));var s=.5*Math.abs(Math.PI/r-r/Math.PI),c=s*s,l=Math.sin(o),u=Math.cos(o),d=u/(l+u-1),f=d*d,p=d*(2/l-1),m=p*p,h=Math.PI*this.R*(s*(d-m)+Math.sqrt(c*(d-m)*(d-m)-(m+c)*(f-m)))/(m+c);r<0&&(h=-h),i=this.x0+h;var g=c+d;return h=Math.PI*this.R*(p*g-s*Math.sqrt((m+c)*(c+1)-g*g))/(m+c),a=n>=0?this.y0+h:this.y0-h,e.x=i,e.y=a,e}function g4(e){var t,n,r,i,a,o,s,c,l,u,d,f,p;return e.x-=this.x0,e.y-=this.y0,d=Math.PI*this.R,r=e.x/d,i=e.y/d,a=r*r+i*i,o=-Math.abs(i)*(1+a),s=o-2*i*i+r*r,c=-2*o+1+2*i*i+a*a,p=i*i/c+(2*s*s*s/c/c/c-9*o*s/c/c)/27,l=(o-s*s/3/c)/c,u=2*Math.sqrt(-l/3),d=3*p/l/u,Math.abs(d)>1&&(d=d>=0?1:-1),f=Math.acos(d)/3,n=e.y>=0?(-u*Math.cos(f+Math.PI/3)-s/3/c)*Math.PI:-(-u*Math.cos(f+Math.PI/3)-s/3/c)*Math.PI,t=Math.abs(r)<1e-10?this.long0:Q(this.long0+Math.PI*(a-1+Math.sqrt(1+2*(r*r-i*i)+a*a))/2/r,this.over),e.x=t,e.y=n,e}function _4(e,t,n,r,i,a){let o=r-t,s=Math.atan((1-a)*Math.tan(e)),c=Math.atan((1-a)*Math.tan(n)),l=Math.sin(s),u=Math.cos(s),d=Math.sin(c),f=Math.cos(c),p=o,m,h=100,g,_,v,y,b,x,S,C,w,T,E,D,O,k;do{if(g=Math.sin(p),_=Math.cos(p),v=Math.sqrt(f*g*(f*g)+(u*d-l*f*_)*(u*d-l*f*_)),v===0)return{azi1:0,s12:0};y=l*d+u*f*_,b=Math.atan2(v,y),x=u*f*g/v,S=1-x*x,C=S===0?0:y-2*l*d/S,w=a/16*S*(4+a*(4-3*S)),m=p,p=o+(1-w)*a*x*(b+w*v*(C+w*y*(-1+2*C*C)))}while(Math.abs(p-m)>1e-12&&--h>0);return h===0?{azi1:NaN,s12:NaN}:(T=S*(i*i-i*(1-a)*(i*(1-a)))/(i*(1-a)*(i*(1-a))),E=1+T/16384*(4096+T*(-768+T*(320-175*T))),D=T/1024*(256+T*(-128+T*(74-47*T))),O=D*v*(C+D/4*(y*(-1+2*C*C)-D/6*C*(-3+4*v*v)*(-3+4*C*C))),k=i*(1-a)*E*(b-O),{azi1:Math.atan2(f*g,u*d-l*f*_),s12:k})}function v4(e,t,n,r,i,a){let o=Math.atan((1-a)*Math.tan(e)),s=Math.sin(o),c=Math.cos(o),l=Math.sin(n),u=Math.cos(n),d=Math.atan2(s,c*u),f=c*l,p=1-f*f,m=p*(i*i-i*(1-a)*(i*(1-a)))/(i*(1-a)*(i*(1-a))),h=1+m/16384*(4096+m*(-768+m*(320-175*m))),g=m/1024*(256+m*(-128+m*(74-47*m))),_=r/(i*(1-a)*h),v,y=100,b,x,S,C;do b=Math.cos(2*d+_),x=Math.sin(_),S=Math.cos(_),C=g*x*(b+g/4*(S*(-1+2*b*b)-g/6*b*(-3+4*x*x)*(-3+4*b*b))),v=_,_=r/(i*(1-a)*h)+C;while(Math.abs(_-v)>1e-12&&--y>0);if(y===0)return{lat2:NaN,lon2:NaN};let w=s*x-c*S*u,T=Math.atan2(s*S+c*x*u,(1-a)*Math.sqrt(f*f+w*w)),E=Math.atan2(x*l,c*S-s*x*u),D=a/16*p*(4+a*(4-3*p));return{lat2:T,lon2:t+(E-(1-D)*a*f*(_+D*x*(b+D*S*(-1+2*b*b))))}}function y4(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0),this.f=this.es/(1+Math.sqrt(1-this.es))}function b4(e){var t=e.x,n=e.y,r=Math.sin(e.y),i=Math.cos(e.y),a=Q(t-this.long0,this.over),o,s,c,l,u,d,f,p,m,h,g;return this.sphere?Math.abs(this.sin_p12-1)<=1e-10?(e.x=this.x0+this.a*($-n)*Math.sin(a),e.y=this.y0-this.a*($-n)*Math.cos(a),e):Math.abs(this.sin_p12+1)<=1e-10?(e.x=this.x0+this.a*($+n)*Math.sin(a),e.y=this.y0+this.a*($+n)*Math.cos(a),e):(m=this.sin_p12*r+this.cos_p12*i*Math.cos(a),f=Math.acos(m),p=f?f/Math.sin(f):1,e.x=this.x0+this.a*p*i*Math.sin(a),e.y=this.y0+this.a*p*(this.cos_p12*r-this.sin_p12*i*Math.cos(a)),e):(o=y2(this.es),s=b2(this.es),c=x2(this.es),l=S2(this.es),Math.abs(this.sin_p12-1)<=1e-10?(u=this.a*v2(o,s,c,l,$),d=this.a*v2(o,s,c,l,n),e.x=this.x0+(u-d)*Math.sin(a),e.y=this.y0-(u-d)*Math.cos(a),e):Math.abs(this.sin_p12+1)<=1e-10?(u=this.a*v2(o,s,c,l,$),d=this.a*v2(o,s,c,l,n),e.x=this.x0+(u+d)*Math.sin(a),e.y=this.y0+(u+d)*Math.cos(a),e):Math.abs(t)<1e-10&&Math.abs(n-this.lat0)<1e-10?(e.x=e.y=0,e):(h=_4(this.lat0,this.long0,n,t,this.a,this.f),g=h.azi1,e.x=h.s12*Math.sin(g),e.y=h.s12*Math.cos(g),e))}function x4(e){e.x-=this.x0,e.y-=this.y0;var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;return this.sphere?(t=Math.sqrt(e.x*e.x+e.y*e.y),t>2*$*this.a?void 0:(n=t/this.a,r=Math.sin(n),i=Math.cos(n),a=this.long0,Math.abs(t)<=1e-10?o=this.lat0:(o=F2(i*this.sin_p12+e.y*r*this.cos_p12/t),s=Math.abs(this.lat0)-$,a=Math.abs(s)<=1e-10?this.lat0>=0?Q(this.long0+Math.atan2(e.x,-e.y),this.over):Q(this.long0-Math.atan2(-e.x,e.y),this.over):Q(this.long0+Math.atan2(e.x*r,t*this.cos_p12*i-e.y*this.sin_p12*r),this.over)),e.x=a,e.y=o,e)):(c=y2(this.es),l=b2(this.es),u=x2(this.es),d=S2(this.es),Math.abs(this.sin_p12-1)<=1e-10?(f=this.a*v2(c,l,u,d,$),t=Math.sqrt(e.x*e.x+e.y*e.y),p=f-t,o=T2(p/this.a,c,l,u,d),a=Q(this.long0+Math.atan2(e.x,-1*e.y),this.over),e.x=a,e.y=o,e):Math.abs(this.sin_p12+1)<=1e-10?(f=this.a*v2(c,l,u,d,$),t=Math.sqrt(e.x*e.x+e.y*e.y),p=t-f,o=T2(p/this.a,c,l,u,d),a=Q(this.long0+Math.atan2(e.x,e.y),this.over),e.x=a,e.y=o,e):(m=Math.atan2(e.x,e.y),h=Math.sqrt(e.x*e.x+e.y*e.y),g=v4(this.lat0,this.long0,m,h,this.a,this.f),e.x=g.lon2,e.y=g.lat2,e))}function S4(){this.sin_p14=Math.sin(this.lat0||0),this.cos_p14=Math.cos(this.lat0||0)}function C4(e){var t,n,r,i,a,o,s,c,l=e.x,u=e.y;return r=Q(l-(this.long0||0),this.over),t=Math.sin(u),n=Math.cos(u),i=Math.cos(r),o=this.sin_p14*t+this.cos_p14*n*i,a=1,(o>0||Math.abs(o)<=1e-10)&&(s=this.a*a*n*Math.sin(r),c=(this.y0||0)+this.a*a*(this.cos_p14*t-this.sin_p14*n*i)),e.x=s,e.y=c,e}function w4(e){var t,n,r,i,a,o,s,c,l;return e.x-=this.x0||0,e.y-=this.y0||0,t=Math.sqrt(e.x*e.x+e.y*e.y),n=F2(t/this.a),r=Math.sin(n),i=Math.cos(n),c=this.long0||0,l=this.lat0||0,o=c,Math.abs(t)<=1e-10?(s=l,e.x=o,e.y=s,e):(s=F2(i*this.sin_p14+e.y*r*this.cos_p14/t),a=Math.abs(l)-$,Math.abs(a)<=1e-10?(o=Q(l>=0?c+Math.atan2(e.x,-e.y):c-Math.atan2(-e.x,e.y),this.over),e.x=o,e.y=s,e):(o=Q(c+Math.atan2(e.x*r,t*this.cos_p14*i-e.y*this.sin_p14*r),this.over),e.x=o,e.y=s,e))}function T4(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||`Quadrilateralized Spherical Cube`,this.lat0>=$-$8/2?this.face=z7.TOP:this.lat0<=-($-$8/2)?this.face=z7.BOTTOM:Math.abs(this.long0)<=$8?this.face=z7.FRONT:Math.abs(this.long0)<=$+$8?this.face=this.long0>0?z7.RIGHT:z7.LEFT:this.face=z7.BACK,this.es!==0&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)}function E4(e){var t={x:0,y:0},n,r,i,a,o,s,c={value:0};if(e.x-=this.long0,n=this.es===0?e.y:Math.atan(this.one_minus_f_squared*Math.tan(e.y)),r=e.x,this.face===z7.TOP)a=$-n,r>=$8&&r<=$+$8?(c.value=B7.AREA_0,i=r-$):r>$+$8||r<=-($+$8)?(c.value=B7.AREA_1,i=r>0?r-t5:r+t5):r>-($+$8)&&r<=-$8?(c.value=B7.AREA_2,i=r+$):(c.value=B7.AREA_3,i=r);else if(this.face===z7.BOTTOM)a=$+n,r>=$8&&r<=$+$8?(c.value=B7.AREA_0,i=-r+$):r<$8&&r>=-$8?(c.value=B7.AREA_1,i=-r):r<-$8&&r>=-($+$8)?(c.value=B7.AREA_2,i=-r-$):(c.value=B7.AREA_3,i=r>0?-r+t5:-r-t5);else{var l,u,d,f,p,m,h;this.face===z7.RIGHT?r=k4(r,+$):this.face===z7.BACK?r=k4(r,+t5):this.face===z7.LEFT&&(r=k4(r,-$)),f=Math.sin(n),p=Math.cos(n),m=Math.sin(r),h=Math.cos(r),l=p*h,u=p*m,d=f,this.face===z7.FRONT?(a=Math.acos(l),i=O4(a,d,u,c)):this.face===z7.RIGHT?(a=Math.acos(u),i=O4(a,d,-l,c)):this.face===z7.BACK?(a=Math.acos(-l),i=O4(a,d,-u,c)):this.face===z7.LEFT?(a=Math.acos(-u),i=O4(a,d,l,c)):(a=i=0,c.value=B7.AREA_0)}return s=Math.atan(12/t5*(i+Math.acos(Math.sin(i)*Math.cos($8))-$)),o=Math.sqrt((1-Math.cos(a))/(Math.cos(s)*Math.cos(s))/(1-Math.cos(Math.atan(1/Math.cos(i))))),c.value===B7.AREA_1?s+=$:c.value===B7.AREA_2?s+=t5:c.value===B7.AREA_3&&(s+=1.5*t5),t.x=o*Math.cos(s),t.y=o*Math.sin(s),t.x=t.x*this.a+this.x0,t.y=t.y*this.a+this.y0,e.x=t.x,e.y=t.y,e}function D4(e){var t={lam:0,phi:0},n,r,i,a,o,s,c,l,u,d={value:0};if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,r=Math.atan(Math.sqrt(e.x*e.x+e.y*e.y)),n=Math.atan2(e.y,e.x),e.x>=0&&e.x>=Math.abs(e.y)?d.value=B7.AREA_0:e.y>=0&&e.y>=Math.abs(e.x)?(d.value=B7.AREA_1,n-=$):e.x<0&&-e.x>=Math.abs(e.y)?(d.value=B7.AREA_2,n=n<0?n+t5:n-t5):(d.value=B7.AREA_3,n+=$),u=t5/12*Math.tan(n),o=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),s=Math.atan(o),i=Math.cos(n),a=Math.tan(r),c=1-i*i*a*a*(1-Math.cos(Math.atan(1/Math.cos(s)))),c<-1?c=-1:c>1&&(c=1),this.face===z7.TOP)l=Math.acos(c),t.phi=$-l,d.value===B7.AREA_0?t.lam=s+$:d.value===B7.AREA_1?t.lam=s<0?s+t5:s-t5:d.value===B7.AREA_2?t.lam=s-$:t.lam=s;else if(this.face===z7.BOTTOM)l=Math.acos(c),t.phi=l-$,d.value===B7.AREA_0?t.lam=-s+$:d.value===B7.AREA_1?t.lam=-s:d.value===B7.AREA_2?t.lam=-s-$:t.lam=s<0?-s-t5:-s+t5;else{var f=c,p,m;u=f*f,m=u>=1?0:Math.sqrt(1-u)*Math.sin(s),u+=m*m,p=u>=1?0:Math.sqrt(1-u),d.value===B7.AREA_1?(u=p,p=-m,m=u):d.value===B7.AREA_2?(p=-p,m=-m):d.value===B7.AREA_3&&(u=p,p=m,m=-u),this.face===z7.RIGHT?(u=f,f=-p,p=u):this.face===z7.BACK?(f=-f,p=-p):this.face===z7.LEFT&&(u=f,f=p,p=-u),t.phi=Math.acos(-m)-$,t.lam=Math.atan2(p,f),this.face===z7.RIGHT?t.lam=k4(t.lam,-$):this.face===z7.BACK?t.lam=k4(t.lam,-t5):this.face===z7.LEFT&&(t.lam=k4(t.lam,+$))}if(this.es!==0){var h=+(t.phi<0),g=Math.tan(t.phi),_=this.b/Math.sqrt(g*g+this.one_minus_f_squared);t.phi=Math.atan(Math.sqrt(this.a*this.a-_*_)/(this.one_minus_f*_)),h&&(t.phi=-t.phi)}return t.lam+=this.long0,e.x=t.lam,e.y=t.phi,e}function O4(e,t,n,r){var i;return e<1e-10?(r.value=B7.AREA_0,i=0):(i=Math.atan2(t,n),Math.abs(i)<=$8?r.value=B7.AREA_0:i>$8&&i<=$+$8?(r.value=B7.AREA_1,i-=$):i>$+$8||i<=-($+$8)?(r.value=B7.AREA_2,i=i>=0?i-t5:i+t5):(r.value=B7.AREA_3,i+=$)),i}function k4(e,t){var n=e+t;return n<-3.14159265359?n+=e5:n>3.14159265359&&(n-=e5),n}function A4(e,t,n,r){for(var i=t;r;--r){var a=e(i);if(i-=a,Math.abs(a)<n)break}return i}function j4(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||`Robinson`}function M4(e){var t=Q(e.x-this.long0,this.over),n=Math.abs(e.y),r=Math.floor(n*K7);r<0?r=0:r>=J7&&(r=J7-1),n=Q8*(n-q7*r);var i={x:Y7(H7[r],n)*t,y:Y7(U7[r],n)};return e.y<0&&(i.y=-i.y),i.x=i.x*this.a*W7+this.x0,i.y=i.y*this.a*G7+this.y0,i}function N4(e){var t={x:(e.x-this.x0)/(this.a*W7),y:Math.abs(e.y-this.y0)/(this.a*G7)};if(t.y>=1)t.x/=H7[J7][0],t.y=e.y<0?-$:$;else{var n=Math.floor(t.y*J7);for(n<0?n=0:n>=J7&&(n=J7-1);;)if(U7[n][0]>t.y)--n;else if(U7[n+1][0]<=t.y)++n;else break;var r=U7[n],i=5*(t.y-r[0])/(U7[n+1][0]-r[0]);i=A4(function(e){return(Y7(r,e)-t.y)/X7(r,e)},i,X8,100),t.x/=Y7(H7[n],i),t.y=(5*n+i)*Z8,e.y<0&&(t.y=-t.y)}return t.x=Q(t.x+this.long0,this.over),t}function P4(){this.name=`geocent`}function F4(e){return J1(e,this.es,this.a)}function I4(e){return Y1(e,this.es,this.a,this.b)}function L4(){if(Object.keys(e9).forEach(function(e){if(this[e]===void 0)this[e]=e9[e].def;else if(e9[e].num&&isNaN(this[e]))throw Error(`Invalid parameter value, must be numeric `+e+` = `+this[e]);else e9[e].num&&(this[e]=parseFloat(this[e]));e9[e].degrees&&(this[e]=this[e]*Z8)}.bind(this)),Math.abs(Math.abs(this.lat0)-$)<1e-10?this.mode=this.lat0<0?$7.S_POLE:$7.N_POLE:Math.abs(this.lat0)<1e-10?this.mode=$7.EQUIT:(this.mode=$7.OBLIQ,this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0)),this.pn1=this.h/this.a,this.pn1<=0||this.pn1>1e10)throw Error(`Invalid height`);this.p=1+this.pn1,this.rp=1/this.p,this.h1=1/this.pn1,this.pfact=(this.p+1)*this.h1,this.es=0;var e=this.tilt,t=this.azi;this.cg=Math.cos(t),this.sg=Math.sin(t),this.cw=Math.cos(e),this.sw=Math.sin(e)}function R4(e){e.x-=this.long0;var t=Math.sin(e.y),n=Math.cos(e.y),r=Math.cos(e.x),i,a;switch(this.mode){case $7.OBLIQ:a=this.sinph0*t+this.cosph0*n*r;break;case $7.EQUIT:a=n*r;break;case $7.S_POLE:a=-t;break;case $7.N_POLE:a=t;break}switch(a=this.pn1/(this.p-a),i=a*n*Math.sin(e.x),this.mode){case $7.OBLIQ:a*=this.cosph0*t-this.sinph0*n*r;break;case $7.EQUIT:a*=t;break;case $7.N_POLE:a*=-(n*r);break;case $7.S_POLE:a*=n*r;break}var o=a*this.cg+i*this.sg,s=1/(o*this.sw*this.h1+this.cw);return i=(i*this.cg-a*this.sg)*this.cw*s,a=o*s,e.x=i*this.a,e.y=a*this.a,e}function z4(e){e.x/=this.a,e.y/=this.a;var t={x:e.x,y:e.y},n,r,i=1/(this.pn1-e.y*this.sw);n=this.pn1*e.x*i,r=this.pn1*e.y*this.cw*i,e.x=n*this.cg+r*this.sg,e.y=r*this.cg-n*this.sg;var a=I0(e.x,e.y);if(Math.abs(a)<1e-10)t.x=0,t.y=e.y;else{var o,s=1-a*a*this.pfact;switch(s=(this.p-Math.sqrt(s))/(this.pn1/a+a/this.pn1),o=Math.sqrt(1-s*s),this.mode){case $7.OBLIQ:t.y=Math.asin(o*this.sinph0+e.y*s*this.cosph0/a),e.y=(o-this.sinph0*Math.sin(t.y))*a,e.x*=s*this.cosph0;break;case $7.EQUIT:t.y=Math.asin(e.y*s/a),e.y=o*a,e.x*=s;break;case $7.N_POLE:t.y=Math.asin(o),e.y=-e.y;break;case $7.S_POLE:t.y=-Math.asin(o);break}t.x=Math.atan2(e.x,e.y)}return e.x=t.x+this.long0,e.y=t.y,e}function B4(){if(this.flip_axis=+(this.sweep===`x`),this.h=Number(this.h),this.radius_g_1=this.h/this.a,this.radius_g_1<=0||this.radius_g_1>1e10)throw Error();if(this.radius_g=1+this.radius_g_1,this.C=this.radius_g*this.radius_g-1,this.es!==0){var e=1-this.es,t=1/e;this.radius_p=Math.sqrt(e),this.radius_p2=e,this.radius_p_inv2=t,this.shape=`ellipse`}else this.radius_p=1,this.radius_p2=1,this.radius_p_inv2=1,this.shape=`sphere`;this.title||=`Geostationary Satellite View`}function V4(e){var t=e.x,n=e.y,r,i,a,o;if(t-=this.long0,this.shape===`ellipse`){n=Math.atan(this.radius_p2*Math.tan(n));var s=this.radius_p/I0(this.radius_p*Math.cos(n),Math.sin(n));if(i=s*Math.cos(t)*Math.cos(n),a=s*Math.sin(t)*Math.cos(n),o=s*Math.sin(n),(this.radius_g-i)*i-a*a-o*o*this.radius_p_inv2<0)return e.x=NaN,e.y=NaN,e;r=this.radius_g-i,this.flip_axis?(e.x=this.radius_g_1*Math.atan(a/I0(o,r)),e.y=this.radius_g_1*Math.atan(o/r)):(e.x=this.radius_g_1*Math.atan(a/r),e.y=this.radius_g_1*Math.atan(o/I0(a,r)))}else this.shape===`sphere`&&(r=Math.cos(n),i=Math.cos(t)*r,a=Math.sin(t)*r,o=Math.sin(n),r=this.radius_g-i,this.flip_axis?(e.x=this.radius_g_1*Math.atan(a/I0(o,r)),e.y=this.radius_g_1*Math.atan(o/r)):(e.x=this.radius_g_1*Math.atan(a/r),e.y=this.radius_g_1*Math.atan(o/I0(a,r))));return e.x*=this.a,e.y*=this.a,e}function H4(e){var t=-1,n=0,r=0,i,a,o,s;if(e.x/=this.a,e.y/=this.a,this.shape===`ellipse`){this.flip_axis?(r=Math.tan(e.y/this.radius_g_1),n=Math.tan(e.x/this.radius_g_1)*I0(1,r)):(n=Math.tan(e.x/this.radius_g_1),r=Math.tan(e.y/this.radius_g_1)*I0(1,n));var c=r/this.radius_p;if(i=n*n+c*c+t*t,a=2*this.radius_g*t,o=a*a-4*i*this.C,o<0)return e.x=NaN,e.y=NaN,e;s=(-a-Math.sqrt(o))/(2*i),t=this.radius_g+s*t,n*=s,r*=s,e.x=Math.atan2(n,t),e.y=Math.atan(r*Math.cos(e.x)/t),e.y=Math.atan(this.radius_p_inv2*Math.tan(e.y))}else if(this.shape===`sphere`){if(this.flip_axis?(r=Math.tan(e.y/this.radius_g_1),n=Math.tan(e.x/this.radius_g_1)*Math.sqrt(1+r*r)):(n=Math.tan(e.x/this.radius_g_1),r=Math.tan(e.y/this.radius_g_1)*Math.sqrt(1+n*n)),i=n*n+r*r+t*t,a=2*this.radius_g*t,o=a*a-4*i*this.C,o<0)return e.x=NaN,e.y=NaN,e;s=(-a-Math.sqrt(o))/(2*i),t=this.radius_g+s*t,n*=s,r*=s,e.x=Math.atan2(n,t),e.y=Math.atan(r*Math.cos(e.x)/t)}return e.x+=this.long0,e}function U4(){this.es=0,this.long0=this.long0===void 0?0:this.long0,this.x0=this.x0===void 0?0:this.x0,this.y0=this.y0===void 0?0:this.y0}function W4(e){var t=Q(e.x-this.long0,this.over),n=e.y,r=Math.asin(s9*Math.sin(n)),i=r*r,a=i*i*i;return e.x=t*Math.cos(r)/(s9*(r9+3*i9*i+a*(7*a9+9*o9*i))),e.y=r*(r9+i9*i+a*(a9+o9*i)),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function G4(e){e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a;var t=1e-9,n=12,r=e.y,i,a,o,s,c,l;for(l=0;l<n&&(i=r*r,a=i*i*i,o=r*(r9+i9*i+a*(a9+o9*i))-e.y,s=r9+3*i9*i+a*(7*a9+9*o9*i),r-=c=o/s,!(Math.abs(c)<t));++l);return i=r*r,a=i*i*i,e.x=s9*e.x*(r9+3*i9*i+a*(7*a9+9*o9*i))/Math.cos(r),e.y=Math.asin(Math.sin(r)/s9),e.x=Q(e.x+this.long0,this.over),e}function K4(){var e;if(this.phi1=this.lat1,Math.abs(this.phi1)<l9)throw Error();this.es?(this.en=k0(this.es),this.m1=A0(this.phi1,this.am1=Math.sin(this.phi1),e=Math.cos(this.phi1),this.en),this.am1=e/(Math.sqrt(1-this.es*this.am1*this.am1)*this.am1),this.inverse=J4,this.forward=q4):(Math.abs(this.phi1)+l9>=$?this.cphi1=0:this.cphi1=1/Math.tan(this.phi1),this.inverse=X4,this.forward=Y4)}function q4(e){var t=Q(e.x-(this.long0||0),this.over),n=e.y,r=this.am1+this.m1-A0(n,i=Math.sin(n),a=Math.cos(n),this.en),i=a*t/(r*Math.sqrt(1-this.es*i*i)),a;return e.x=r*Math.sin(i),e.y=this.am1-r*Math.cos(i),e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function J4(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,n=I0(e.x,e.y=this.am1-e.y),r,i=j0(this.am1+this.m1-n,this.es,this.en);if((t=Math.abs(i))<$)t=Math.sin(i),r=n*Math.atan2(e.x,e.y)*Math.sqrt(1-this.es*t*t)/Math.cos(i);else if(Math.abs(t-$)<=l9)r=0;else throw Error();return e.x=Q(r+(this.long0||0),this.over),e.y=w2(i),e}function Y4(e){var t=Q(e.x-(this.long0||0),this.over),n=e.y,r,i=this.cphi1+this.phi1-n;return Math.abs(i)>l9?(e.x=i*Math.sin(r=t*Math.cos(n)/i),e.y=this.cphi1-i*Math.cos(r)):e.x=e.y=0,e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function X4(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,n,r=I0(e.x,e.y=this.cphi1-e.y);if(n=this.cphi1+this.phi1-r,Math.abs(n)>$)throw Error();return t=Math.abs(Math.abs(n)-$)<=l9?0:r*Math.atan2(e.x,e.y)/Math.cos(n),e.x=Q(t+(this.long0||0),this.over),e.y=w2(n),e}function Z4(){if(this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.title=this.title||`General Oblique Transformation`,this.isIdentity=w5.includes(this.o_proj),!this.o_proj)throw Error(`Missing parameter: o_proj`);if(this.o_proj===`ob_tran`)throw Error(`Invalid value for o_proj: `+this.o_proj);let e=K1(this.projStr.replace(`+proj=ob_tran`,``).replace(`+o_proj=`,`+proj=`).trim());if(!e)throw Error(`Invalid parameter: o_proj. Unknown projection `+this.o_proj);e.long0=0,this.obliqueProjection=e;let t,n=Object.keys(f9),r=e=>{if(this[e]===void 0)return;let t=parseFloat(this[e])*Z8;if(isNaN(t))throw Error(`Invalid value for `+e+`: `+this[e]);return t};for(let e=0;e<n.length;e++){let i=f9[n[e]],a=Object.entries(i);if(a.some(([e])=>this[e]!==void 0)){t=i;for(let e=0;e<a.length;e++){let[t,n]=a[e],i=r(t);if(i===void 0)throw Error(`Missing parameter: `+t+`.`);this[n]=i}break}}if(!t)throw Error(`No valid parameters provided for ob_tran projection.`);let{lamp:i,phip:a}=e3(this,t);this.lamp=i,Math.abs(a)>1e-10?(this.cphip=Math.cos(a),this.sphip=Math.sin(a),this.projectionType=d9.OBLIQUE):this.projectionType=d9.TRANSVERSE}function Q4(e){return this.projectionType.forward(this,e)}function $4(e){return this.projectionType.inverse(this,e)}function e3(e,t){let n,r;if(t===f9.ROTATE){let t=e.oLongC,i=e.oLatC,a=e.oAlpha;if(Math.abs(Math.abs(i)-$)<=1e-10)throw Error(`Invalid value for o_lat_c: `+e.o_lat_c+` should be < 90°`);r=t+Math.atan2(-1*Math.cos(a),-1*Math.sin(a)*Math.sin(i)),n=Math.asin(Math.cos(i)*Math.sin(a))}else if(t===f9.NEW_POLE)r=e.oLongP,n=e.oLatP;else{let t=e.oLong1,i=e.oLat1,a=e.oLong2,o=e.oLat2,s=Math.abs(i);if(Math.abs(i)>$-1e-10)throw Error(`Invalid value for o_lat_1: `+e.o_lat_1+` should be < 90°`);if(Math.abs(o)>$-1e-10)throw Error(`Invalid value for o_lat_2: `+e.o_lat_2+` should be < 90°`);if(Math.abs(i-o)<1e-10)throw Error(`Invalid value for o_lat_1 and o_lat_2: o_lat_1 should be different from o_lat_2`);if(s<1e-10)throw Error(`Invalid value for o_lat_1: o_lat_1 should be different from zero`);r=Math.atan2(Math.cos(i)*Math.sin(o)*Math.cos(t)-Math.sin(i)*Math.cos(o)*Math.cos(a),Math.sin(i)*Math.cos(o)*Math.sin(a)-Math.cos(i)*Math.sin(o)*Math.sin(t)),n=Math.atan(-1*Math.cos(r-t)/Math.tan(i))}return{lamp:r,phip:n}}function t3(e,t){let{x:n,y:r}=t;n+=e.long0;let i=Math.cos(n),a=Math.sin(r),o=Math.cos(r);t.x=Q(Math.atan2(o*Math.sin(n),e.sphip*o*i+e.cphip*a)+e.lamp),t.y=Math.asin(e.sphip*a-e.cphip*o*i);let s=e.obliqueProjection.forward(t);return e.isIdentity&&(s.x*=Q8,s.y*=Q8),s}function n3(e,t){let{x:n,y:r}=t;n+=e.long0;let i=Math.cos(r),a=Math.cos(n);t.x=Q(Math.atan2(i*Math.sin(n),Math.sin(r))+e.lamp),t.y=Math.asin(-1*i*a);let o=e.obliqueProjection.forward(t);return e.isIdentity&&(o.x*=Q8,o.y*=Q8),o}function r3(e,t){e.isIdentity&&(t.x*=Z8,t.y*=Z8);let{x:n,y:r}=e.obliqueProjection.inverse(t);if(n<Number.MAX_VALUE){n-=e.lamp;let i=Math.cos(n),a=Math.sin(r),o=Math.cos(r);t.x=Math.atan2(o*Math.sin(n),e.sphip*o*i-e.cphip*a),t.y=Math.asin(e.sphip*a+e.cphip*o*i)}return t.x=Q(t.x+e.long0),t}function i3(e,t){e.isIdentity&&(t.x*=Z8,t.y*=Z8);let{x:n,y:r}=e.obliqueProjection.inverse(t);if(n<Number.MAX_VALUE){let i=Math.cos(r);n-=e.lamp,t.x=Math.atan2(i*Math.sin(n),-1*Math.sin(r)),t.y=Math.asin(i*Math.cos(n))}return t.x=Q(t.x+e.long0),t}function a3(e){e.Proj.projections.add(r7),e.Proj.projections.add(i7),e.Proj.projections.add(o7),e.Proj.projections.add(l7),e.Proj.projections.add(u7),e.Proj.projections.add(d7),e.Proj.projections.add(p7),e.Proj.projections.add(m7),e.Proj.projections.add(h7),e.Proj.projections.add(g7),e.Proj.projections.add(C7),e.Proj.projections.add(w7),e.Proj.projections.add(T7),e.Proj.projections.add(E7),e.Proj.projections.add(D7),e.Proj.projections.add(k7),e.Proj.projections.add(A7),e.Proj.projections.add(j7),e.Proj.projections.add(N7),e.Proj.projections.add(P7),e.Proj.projections.add(F7),e.Proj.projections.add(I7),e.Proj.projections.add(L7),e.Proj.projections.add(R7),e.Proj.projections.add(V7),e.Proj.projections.add(Z7),e.Proj.projections.add(Q7),e.Proj.projections.add(t9),e.Proj.projections.add(n9),e.Proj.projections.add(c9),e.Proj.projections.add(u9),e.Proj.projections.add(p9)}function o3(e,t){switch(e){case`float64`:return new Float64Array(t);case`float32`:return new Float32Array(t);case`uint32`:return new Uint32Array(t);case`uint16`:return new Uint16Array(t);case`uint8`:return new Uint8Array(t);case`int32`:return new Int32Array(t);case`int16`:return new Int16Array(t);case`int8`:return new Int8Array(t);default:return new Float32Array(t)}}async function s3(){return _9||=await(0,V8.createLazPerf)({locateFile:e=>e.endsWith(`.wasm`)?`https://unpkg.com/laz-perf@0.0.7/lib/web/laz-perf.wasm`:e}),_9}function c3(e){let t=new Uint8Array(e);return async(e,n)=>t.slice(e,n)}function l3(e){if(e.startsWith(`COMPD_CS[`)){let t=e.indexOf(`PROJCS[`);if(t===-1)return e;let n=0,r=t;for(let i=t;i<e.length;i++)if(e[i]===`[`&&n++,e[i]===`]`&&(n--,n===0)){r=i+1;break}return e.substring(t,r)}return e}function u3(e){let t=e.toLowerCase();if(t.includes(`us survey foot`)||t.includes(`us_survey_foot`)||t.includes(`foot_us`))return .3048006096012192;for(let t of[/unit\s*\[\s*"foot/i,/unit\s*\[\s*"international foot/i,/,\s*foot\s*\]/i,/"ft"/i])if(t.test(e))return .3048;return 1}function d3(e){let t=new Uint8Array(e);return async(e,n)=>new Uint8Array(t.subarray(e,n))}function f3(e,t){switch(e){case`float64`:return new Float64Array(t);case`float32`:return new Float32Array(t);case`uint32`:return new Uint32Array(t);case`uint16`:return new Uint16Array(t);case`uint8`:return new Uint8Array(t);case`int32`:return new Int32Array(t);case`int16`:return new Int16Array(t);case`int8`:return new Int8Array(t);default:return new Float32Array(t)}}async function p3(){return x9||=await(0,V8.createLazPerf)({locateFile:e=>e.endsWith(`.wasm`)?`https://unpkg.com/laz-perf@0.0.7/lib/web/laz-perf.wasm`:e}),x9}function m3(e){if(e.startsWith(`COMPD_CS[`)){let t=e.indexOf(`PROJCS[`);if(t===-1)return e;let n=0,r=t;for(let i=t;i<e.length;i++)if(e[i]===`[`&&n++,e[i]===`]`&&(n--,n===0)){r=i+1;break}return e.substring(t,r)}return e}function h3(e){let t=e.toLowerCase();if(t.includes(`us survey foot`)||t.includes(`us_survey_foot`)||t.includes(`foot_us`))return .3048006096012192;for(let t of[/unit\s*\[\s*"foot/i,/unit\s*\[\s*"international foot/i,/,\s*foot\s*\]/i,/"ft"/i])if(t.test(e))return .3048;return 1}function g3(e,t,n=``){let r=e,i=t,a=!1;return t>90?(i=90,a=!0):t<-90&&(i=-90,a=!0),e>180?(r=180,a=!0):e<-180&&(r=-180,a=!0),a&&console.warn(`COPC: Clamped transformed coordinates to valid WGS84 range${n?` (${n})`:``}:`,`[${e.toFixed(6)}, ${t.toFixed(6)}] -> [${r.toFixed(6)}, ${i.toFixed(6)}]`),[r,i]}function _3(e,t){switch(e){case`float64`:return new Float64Array(t);case`float32`:return new Float32Array(t);case`uint32`:return new Uint32Array(t);case`uint16`:return new Uint16Array(t);case`uint8`:return new Uint8Array(t);case`int32`:return new Int32Array(t);case`int16`:return new Int16Array(t);case`int8`:return new Int8Array(t);default:return new Float32Array(t)}}function v3(e,t,n=``){let r=e,i=t,a=!1;return t>90?(i=90,a=!0):t<-90&&(i=-90,a=!0),e>180?(r=180,a=!0):e<-180&&(r=-180,a=!0),a&&n&&console.warn(`EPT: Clamped transformed coordinates to valid WGS84 range${n?` (${n})`:``}:`,`[${e.toFixed(6)}, ${t.toFixed(6)}] -> [${r.toFixed(6)}, ${i.toFixed(6)}]`),[r,i]}function y3(e){if(e.startsWith(`COMPD_CS[`)){let t=e.indexOf(`PROJCS[`);if(t===-1)return e;let n=0,r=t;for(let i=t;i<e.length;i++)if(e[i]===`[`&&n++,e[i]===`]`&&(n--,n===0)){r=i+1;break}return e.substring(t,r)}return e}function b3(e){let t=e.toLowerCase();if(t.includes(`us survey foot`)||t.includes(`us_survey_foot`)||t.includes(`foot_us`))return .3048006096012192;for(let t of[/unit\s*\[\s*"foot/i,/unit\s*\[\s*"international foot/i,/,\s*foot\s*\]/i,/"ft"/i])if(t.test(e))return .3048;return 1}function x3(e,t){if(t===0)return e.toString();let n=Math.max(0,-Math.floor(Math.log10(t)));return e.toFixed(n)}function S3(e){let t=Math.random().toString(36).substring(2,9);return e?`${e}-${t}`:t}function C3(e,t){let n=null;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)}}function w3(e){return e.toLocaleString()}function T3(e){return e.replace(/\\/g,`/`).split(`/`).pop()?.split(`?`)[0]||`unknown`}function E3(e,t,n=1e5){if(e.length===0)return 0;if(e.length===1)return e[0];let r;if(e.length>n){let t=e.length/n;r=[];for(let i=0;i<n;i++){let n=Math.floor(i*t);r.push(e[n])}}else r=Array.from(e);r.sort((e,t)=>e-t);let i=t/100*(r.length-1),a=Math.floor(i),o=Math.ceil(i);if(a===o)return r[a];let s=i-a;return r[a]*(1-s)+r[o]*s}function D3(e,t=2,n=98){if(e.length===0)return{min:0,max:1};let r=E3(e,t),i=E3(e,n);return r===i?{min:r-.5,max:i+.5}:{min:r,max:i}}function O3(e){return O9[e]||O9.viridis}function k3(e){return{0:`Never Classified`,1:`Unclassified`,2:`Ground`,3:`Low Vegetation`,4:`Medium Vegetation`,5:`High Vegetation`,6:`Building`,7:`Low Point (Noise)`,8:`Reserved`,9:`Water`,10:`Rail`,11:`Road Surface`,12:`Reserved`,13:`Wire - Guard`,14:`Wire - Conductor`,15:`Transmission Tower`,16:`Wire-Structure Connector`,17:`Bridge Deck`,18:`High Noise`}[e]||`Class ${e}`}function A3(e){let t=new Set;if(e.hasClassification&&e.classifications)for(let n=0;n<e.pointCount;n++)t.add(e.classifications[n]);return t}function j3(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);if(typeof atob==`function`){let e=atob(n),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return new TextDecoder().decode(t)}return Buffer.from(n,`base64`).toString(`utf-8`)}function M3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N3(e){return typeof e==`number`&&Number.isFinite(e)}function P3(e){if(!M3(e))return!1;let t=e.center;return Array.isArray(t)&&t.length===2&&t.every(N3)&&N3(e.zoom)&&N3(e.bearing)&&N3(e.pitch)}function F3(e){return e===null||Array.isArray(e)&&e.length===2&&N3(e[0])&&N3(e[1])}function I3(e){return!(!M3(e)||e.mode!==`percentile`&&e.mode!==`absolute`||!N3(e.percentileLow)||!N3(e.percentileHigh)||e.absoluteMin!==void 0&&!N3(e.absoluteMin)||e.absoluteMax!==void 0&&!N3(e.absoluteMax))}function L3(e){return M3(e)?N3(e.pointSize)&&N3(e.opacity)&&e.colorScheme!==void 0&&typeof e.colormap==`string`&&I3(e.colorRange)&&F3(e.elevationRange)&&typeof e.pickable==`boolean`&&typeof e.zOffsetEnabled==`boolean`&&N3(e.zOffset)&&typeof e.terrainEnabled==`boolean`&&Array.isArray(e.hiddenClassifications)&&e.hiddenClassifications.every(N3):!1}function R3(e,t){if(!e||e===`file`)return null;if(!t)return e;try{return new URL(e,t).toString()}catch{return e}}function z3(e,t,n){let r=new Set;for(let t of e.pointClouds){let e=R3(t.source,n);e&&r.add(e)}return{v:1,map:t,pointClouds:Array.from(r),visualization:{pointSize:e.pointSize,opacity:e.opacity,colorScheme:e.colorScheme,colormap:e.colormap,colorRange:e.colorRange,elevationRange:e.elevationRange,pickable:e.pickable,zOffsetEnabled:e.zOffsetEnabled,zOffset:e.zOffset,terrainEnabled:e.terrainEnabled,hiddenClassifications:Array.from(e.hiddenClassifications).sort((e,t)=>e-t)}}}function gae(e){try{let t=JSON.parse(j3(e));return!M3(t)||t.v!==1||!Array.isArray(t.pointClouds)||!t.pointClouds.every(e=>typeof e==`string`)||!L3(t.visualization)||t.map!==void 0&&!P3(t.map)?null:{v:1,map:t.map,pointClouds:[...t.pointClouds],visualization:{...t.visualization,hiddenClassifications:[...t.visualization.hiddenClassifications]}}}catch{return null}}function _ae(e,t){let n=new URL(e);for(let e of Z9)n.searchParams.delete(e);n.searchParams.delete(Y9);for(let e of t.pointClouds)n.searchParams.append(X9,e);t.map&&(n.searchParams.set(`lon`,B3(t.map.center[0])),n.searchParams.set(`lat`,B3(t.map.center[1])),n.searchParams.set(`zoom`,B3(t.map.zoom)),n.searchParams.set(`bearing`,B3(t.map.bearing)),n.searchParams.set(`pitch`,B3(t.map.pitch)));let r=t.visualization;return n.searchParams.set(`size`,B3(r.pointSize)),n.searchParams.set(`opacity`,B3(r.opacity)),n.searchParams.set(`color`,typeof r.colorScheme==`string`?r.colorScheme:JSON.stringify(r.colorScheme)),n.searchParams.set(`cmap`,r.colormap),n.searchParams.set(`range`,r.colorRange.mode),n.searchParams.set(`plow`,B3(r.colorRange.percentileLow)),n.searchParams.set(`phigh`,B3(r.colorRange.percentileHigh)),r.colorRange.absoluteMin!==void 0&&n.searchParams.set(`amin`,B3(r.colorRange.absoluteMin)),r.colorRange.absoluteMax!==void 0&&n.searchParams.set(`amax`,B3(r.colorRange.absoluteMax)),r.elevationRange&&(n.searchParams.set(`emin`,B3(r.elevationRange[0])),n.searchParams.set(`emax`,B3(r.elevationRange[1]))),n.searchParams.set(`pick`,V3(r.pickable)),n.searchParams.set(`zoffEnabled`,V3(r.zOffsetEnabled)),n.searchParams.set(`zoff`,B3(r.zOffset)),n.searchParams.set(`terrain`,V3(r.terrainEnabled)),r.hiddenClassifications.length>0&&n.searchParams.set(`hidden`,r.hiddenClassifications.join(`,`)),n.hash=``,n.toString()}function vae(e){try{let t=new URL(e),n=xae(t.searchParams);if(n)return n;let r=t.searchParams.get(Y9);return r?gae(r):null}catch{return null}}function B3(e){return Number.isInteger(e)?String(e):Number(e.toFixed(8)).toString()}function V3(e){return e?`1`:`0`}function H3(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function U3(e,t){return e===null?t:e===`1`||e.toLowerCase()===`true`}function yae(e){if(!e)return`elevation`;if(e.trim().startsWith(`{`))try{let t=JSON.parse(e);if(M3(t)&&(t.type===`gradient`||t.type===`categorical`)&&typeof t.attribute==`string`)return t}catch{return`elevation`}return e}function bae(e){return Z9.some(t=>t!==X9&&e.has(t))}function xae(e){if(!bae(e))return null;let t=H3(e.get(`lon`)),n=H3(e.get(`lat`)),r=H3(e.get(`zoom`)),i=H3(e.get(`bearing`))??0,a=H3(e.get(`pitch`))??0,o=H3(e.get(`size`))??2,s=H3(e.get(`opacity`))??1,c=H3(e.get(`plow`))??2,l=H3(e.get(`phigh`))??98,u=H3(e.get(`amin`)),d=H3(e.get(`amax`)),f=H3(e.get(`emin`)),p=H3(e.get(`emax`)),m=H3(e.get(`zoff`))??0,h=(e.get(`hidden`)??``).split(`,`).map(e=>Number(e)).filter(e=>Number.isFinite(e));return{v:1,map:t!==void 0&&n!==void 0&&r!==void 0?{center:[t,n],zoom:r,bearing:i,pitch:a}:void 0,pointClouds:e.getAll(X9).filter(e=>e.trim()!==``),visualization:{pointSize:o,opacity:s,colorScheme:yae(e.get(`color`)),colormap:e.get(`cmap`)??`viridis`,colorRange:{mode:e.get(`range`)===`absolute`?`absolute`:`percentile`,percentileLow:c,percentileHigh:l,...u===void 0?{}:{absoluteMin:u},...d===void 0?{}:{absoluteMax:d}},elevationRange:f!==void 0&&p!==void 0?[f,p]:null,pickable:U3(e.get(`pick`),!1),zOffsetEnabled:U3(e.get(`zoffEnabled`),!1),zOffset:m,terrainEnabled:U3(e.get(`terrain`),!1),hiddenClassifications:h}}}var W3,G3,K3,q3,J3,Y3,X3,Z3,Q3,$3,e6,t6,n6,r6,i6,a6,o6,s6,c6,l6,u6,d6,f6,p6,m6,h6,g6,_6,v6,y6,b6,x6,S6,C6,w6,T6,E6,D6,O6,k6,A6,j6,M6,N6,P6,F6,I6,L6,R6,z6,B6,V6,H6,U6,W6,G6,K6,q6,J6,Y6,X6,Z6,Q6,$6,e8,t8,n8,r8,i8,a8,o8,s8,c8,l8,u8,d8,f8,p8,m8,h8,g8,_8,v8,y8,b8,x8,S8,C8,w8,T8,E8,D8,O8,k8,A8,j8,M8,N8,P8,F8,I8,L8,R8,z8,B8,V8,H8,U8,W8,G8,K8,$,q8,J8,Y8,X8,Z8,Q8,$8,e5,t5,n5,r5,i5,a5,o5,s5,c5,l5,u5,d5,f5,p5,m5,h5,g5,_5,v5,y5,b5,x5,S5,C5,w5,T5,E5,D5,O5,k5,A5,j5,M5,N5,P5,F5,I5,L5,R5,z5,B5,V5,H5,U5,W5,G5,K5,q5,J5,Y5,X5,Z5,Q5,$5,e7,t7,n7,r7,i7,a7,o7,s7,c7,l7,u7,d7,f7,p7,m7,h7,g7,_7,v7,y7,b7,x7,S7,C7,w7,T7,E7,D7,O7,k7,A7,j7,M7,N7,P7,F7,I7,L7,R7,z7,B7,V7,H7,U7,W7,G7,K7,q7,J7,Y7,X7,Z7,Q7,$7,e9,t9,n9,r9,i9,a9,o9,s9,c9,l9,u9,d9,f9,p9,m9,h9,g9,_9,v9,y9,b9,x9,S9,C9,w9,T9,E9,D9,O9,k9,A9,j9,M9,N9,P9,F9,I9,L9,R9,z9,B9,V9,H9,U9,W9,G9,K9,q9,J9,Y9,X9,Z9,Q9,$9,Sae=o((()=>{for(var e in ZK(),SZ(),EK(),W3=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),G3=(e=>d===void 0?typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(d===void 0?e:d)[t]}):e:d)(function(e){if(d!==void 0)return d.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")}),K3=class{_map;_overlay;_layers;constructor(e){this._map=e,this._layers=new Map,this._overlay=new YK({interleaved:!1,layers:[]}),this._map.addControl(this._overlay)}addLayer(e,t){this._layers.set(e,t),this._updateOverlay()}removeLayer(e){this._layers.delete(e),this._updateOverlay()}updateLayer(e,t){this._layers.has(e)&&(this._layers.set(e,t),this._updateOverlay())}getLayers(){return Array.from(this._layers.values())}hasLayer(e){return this._layers.has(e)}clearLayers(){this._layers.clear(),this._updateOverlay()}getMap(){return this._map}destroy(){this._layers.clear();try{this._map.removeControl(this._overlay)}catch{}}_updateOverlay(){let e=Array.from(this._layers.entries()).sort(([e],[t])=>{let n=e.includes(`cross-section`),r=t.includes(`cross-section`);return n&&!r?1:!n&&r?-1:0}).map(([,e])=>e);this._overlay.setProps({layers:e}),this._map.triggerRepaint()}},q3=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),J3=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Hierarchy=void 0,e.Hierarchy={parse:t};function t(e){return Object.entries(e).reduce((e,[t,n])=>(n===-1?e.pages[t]={}:n&&(e.nodes[t]={pointCount:n}),e),{nodes:{},pages:{}})}})),Y3=W3((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(q3(),e),n(J3(),e)})),X3=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hierarchyItemLength=e.infoLength=void 0,e.infoLength=160,e.hierarchyItemLength=32})),Z3=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.evlrHeaderLength=e.vlrHeaderLength=e.minHeaderLength=void 0,e.minHeaderLength=375,e.vlrHeaderLength=54,e.evlrHeaderLength=60})),Q3=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getBigUint64=e.parseBigInt=void 0;function t(e){if(e>BigInt(2**53-1)||e<BigInt(-(2**53-1)))throw Error(`Cannot convert bigint to number: ${e}`);return Number(e)}e.parseBigInt=t;function n(e,t,n){if(e.getBigUint64)return e.getBigUint64(t,n);let[r,i]=n?[4,0]:[0,4],a=BigInt(e.getUint32(t+r,n)),o=BigInt(e.getUint32(t+i,n));return(a<<BigInt(32))+o}e.getBigUint64=n})),$3=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.toCString=e.toDataView=e.Binary=void 0,e.Binary={toDataView:t,toCString:n};function t(e){return new DataView(e.buffer,e.byteOffset,e.length)}e.toDataView=t;function n(e){let n=t(e),r=``;for(let e=0;e<n.byteLength;++e){let t=n.getInt8(e);if(t===0)return r;r+=String.fromCharCode(t)}return r}e.toCString=n})),e6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Bounds=void 0,e.Bounds={min:t,max:n,mid:r,width:i,depth:a,height:o,cube:s,step:c,stepTo:l,intersection:u};function t(e){return[e[0],e[1],e[2]]}function n(e){return[e[3],e[4],e[5]]}function r([e,t,n,r,i,a]){return[e+(r-e)/2,t+(i-t)/2,n+(a-n)/2]}function i(e){return e[3]-e[0]}function a(e){return e[4]-e[1]}function o(e){return e[5]-e[2]}function s(e){let t=r(e),n=Math.max(i(e),a(e),o(e))/2;return[t[0]-n,t[1]-n,t[2]-n,t[0]+n,t[1]+n,t[2]+n]}function c(e,[t,n,i]){let[a,o,s,c,l,u]=e,[d,f,p]=r(e);return[t?d:a,n?f:o,i?p:s,t?c:d,n?l:f,i?u:p]}function l(e,[t,n,r,i]){for(let a=t-1;a>=0;--a)e=c(e,[n>>a&1,r>>a&1,i>>a&1]);return e}function u(e,t){return[Math.max(e[0],t[0]),Math.max(e[1],t[1]),Math.max(e[2],t[2]),Math.min(e[3],t[3]),Math.min(e[4],t[4]),Math.min(e[5],t[5])]}})),t6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Dimension=void 0,e.Dimension={Type:{int8:{type:`signed`,size:1},int16:{type:`signed`,size:2},int32:{type:`signed`,size:4},int64:{type:`signed`,size:8},uint8:{type:`unsigned`,size:1},uint16:{type:`unsigned`,size:2},uint32:{type:`unsigned`,size:4},uint64:{type:`unsigned`,size:8},float32:{type:`float`,size:4},float64:{type:`float`,size:8},float:{type:`float`,size:4},double:{type:`float`,size:8},bool:{type:`unsigned`,size:1},boolean:{type:`unsigned`,size:1}},ctype:t};function t({type:e,size:t}){switch(e){case`signed`:switch(t){case 1:return`int8`;case 2:return`int16`;case 4:return`int32`;case 8:return`int64`}case`unsigned`:switch(t){case 1:return`uint8`;case 2:return`uint16`;case 4:return`uint32`;case 8:return`uint64`}case`float`:switch(t){case 4:return`float`;case 8:return`double`}}throw Error(`Invalid dimension type/size: ${e}/${t}`)}})),n6=W3(((e,t)=>{var n=typeof globalThis<`u`&&globalThis||typeof self<`u`&&self||typeof global<`u`&&global,r=(function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e})();(function(e){(function(t){var n=e!==void 0&&e||typeof self<`u`&&self||typeof global<`u`&&global||{},r={searchParams:`URLSearchParams`in n,iterable:`Symbol`in n&&`iterator`in Symbol,blob:`FileReader`in n&&`Blob`in n&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:`FormData`in n,arrayBuffer:`ArrayBuffer`in n};function i(e){return e&&DataView.prototype.isPrototypeOf(e)}if(r.arrayBuffer)var a=[`[object Int8Array]`,`[object Uint8Array]`,`[object Uint8ClampedArray]`,`[object Int16Array]`,`[object Uint16Array]`,`[object Int32Array]`,`[object Uint32Array]`,`[object Float32Array]`,`[object Float64Array]`],o=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if(typeof e!=`string`&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e===``)throw TypeError(`Invalid character in header field name: "`+e+`"`);return e.toLowerCase()}function c(e){return typeof e!=`string`&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:t===void 0,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){if(e.length!=2)throw TypeError(`Headers constructor: expected name/value pair to be length 2, found`+e.length);this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}u.prototype.append=function(e,t){e=s(e),t=c(t);var n=this.map[e];this.map[e]=n?n+`, `+t:t},u.prototype.delete=function(e){delete this.map[s(e)]},u.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},u.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},u.prototype.set=function(e,t){this.map[s(e)]=c(t)},u.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},u.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),l(e)},u.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),l(e)},u.prototype.entries=function(){var e=[];return this.forEach(function(t,n){e.push([n,t])}),l(e)},r.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);function d(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(TypeError(`Already read`));e.bodyUsed=!0}}function f(e){return new Promise(function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}})}function p(e){var t=new FileReader,n=f(t);return t.readAsArrayBuffer(e),n}function m(e){var t=new FileReader,n=f(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=r?r[1]:`utf-8`;return t.readAsText(e,i),n}function h(e){for(var t=new Uint8Array(e),n=Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join(``)}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e==`string`?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&i(e)?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=``),this.headers.get(`content-type`)||(typeof e==`string`?this.headers.set(`content-type`,`text/plain;charset=UTF-8`):this._bodyBlob&&this._bodyBlob.type?this.headers.set(`content-type`,this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set(`content-type`,`application/x-www-form-urlencoded;charset=UTF-8`))},r.blob&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw Error(`could not read FormData body as blob`);return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer)return d(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer));if(r.blob)return this.blob().then(p);throw Error(`could not read as ArrayBuffer`)},this.text=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return m(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(h(this._bodyArrayBuffer));if(this._bodyFormData)throw Error(`could not read FormData body as text`);return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(x)}),this.json=function(){return this.text().then(JSON.parse)},this}var v=[`CONNECT`,`DELETE`,`GET`,`HEAD`,`OPTIONS`,`PATCH`,`POST`,`PUT`,`TRACE`];function y(e){var t=e.toUpperCase();return v.indexOf(t)>-1?t:e}function b(e,t){if(!(this instanceof b))throw TypeError(`Please use the "new" operator, this DOM object constructor cannot be called as a function.`);t||={};var r=t.body;if(e instanceof b){if(e.bodyUsed)throw TypeError(`Already read`);this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new u(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||`same-origin`,(t.headers||!this.headers)&&(this.headers=new u(t.headers)),this.method=y(t.method||this.method||`GET`),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if(`AbortController`in n)return new AbortController().signal}(),this.referrer=null,(this.method===`GET`||this.method===`HEAD`)&&r)throw TypeError(`Body not allowed for GET or HEAD requests`);if(this._initBody(r),(this.method===`GET`||this.method===`HEAD`)&&(t.cache===`no-store`||t.cache===`no-cache`)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,`$1_=`+new Date().getTime());else{var a=/\?/;this.url+=(a.test(this.url)?`&`:`?`)+`_=`+new Date().getTime()}}}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})};function x(e){var t=new FormData;return e.trim().split(`&`).forEach(function(e){if(e){var n=e.split(`=`),r=n.shift().replace(/\+/g,` `),i=n.join(`=`).replace(/\+/g,` `);t.append(decodeURIComponent(r),decodeURIComponent(i))}}),t}function S(e){var t=new u;return e.replace(/\r?\n[\t ]+/g,` `).split(`\r`).map(function(e){return e.indexOf(`
|
||
`)===0?e.substr(1,e.length):e}).forEach(function(e){var n=e.split(`:`),r=n.shift().trim();if(r){var i=n.join(`:`).trim();try{t.append(r,i)}catch(e){console.warn(`Response `+e.message)}}}),t}_.call(b.prototype);function C(e,t){if(!(this instanceof C))throw TypeError(`Please use the "new" operator, this DOM object constructor cannot be called as a function.`);if(t||={},this.type=`default`,this.status=t.status===void 0?200:t.status,this.status<200||this.status>599)throw RangeError(`Failed to construct 'Response': The status provided (0) is outside the range [200, 599].`);this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?``:``+t.statusText,this.headers=new u(t.headers),this.url=t.url||``,this._initBody(e)}_.call(C.prototype),C.prototype.clone=function(){return new C(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},C.error=function(){var e=new C(null,{status:200,statusText:``});return e.ok=!1,e.status=0,e.type=`error`,e};var w=[301,302,303,307,308];C.redirect=function(e,t){if(w.indexOf(t)===-1)throw RangeError(`Invalid status code`);return new C(null,{status:t,headers:{location:e}})},t.DOMException=n.DOMException;try{new t.DOMException}catch{t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function T(e,i){return new Promise(function(a,o){var l=new b(e,i);if(l.signal&&l.signal.aborted)return o(new t.DOMException(`Aborted`,`AbortError`));var d=new XMLHttpRequest;function f(){d.abort()}d.onload=function(){var e={statusText:d.statusText,headers:S(d.getAllResponseHeaders()||``)};l.url.indexOf(`file://`)===0&&(d.status<200||d.status>599)?e.status=200:e.status=d.status,e.url=`responseURL`in d?d.responseURL:e.headers.get(`X-Request-URL`);var t=`response`in d?d.response:d.responseText;setTimeout(function(){a(new C(t,e))},0)},d.onerror=function(){setTimeout(function(){o(TypeError(`Network request failed`))},0)},d.ontimeout=function(){setTimeout(function(){o(TypeError(`Network request timed out`))},0)},d.onabort=function(){setTimeout(function(){o(new t.DOMException(`Aborted`,`AbortError`))},0)};function p(e){try{return e===``&&n.location.href?n.location.href:e}catch{return e}}if(d.open(l.method,p(l.url),!0),l.credentials===`include`?d.withCredentials=!0:l.credentials===`omit`&&(d.withCredentials=!1),`responseType`in d&&(r.blob?d.responseType=`blob`:r.arrayBuffer&&(d.responseType=`arraybuffer`)),i&&typeof i.headers==`object`&&!(i.headers instanceof u||n.Headers&&i.headers instanceof n.Headers)){var m=[];Object.getOwnPropertyNames(i.headers).forEach(function(e){m.push(s(e)),d.setRequestHeader(e,c(i.headers[e]))}),l.headers.forEach(function(e,t){m.indexOf(t)===-1&&d.setRequestHeader(t,e)})}else l.headers.forEach(function(e,t){d.setRequestHeader(t,e)});l.signal&&(l.signal.addEventListener(`abort`,f),d.onreadystatechange=function(){d.readyState===4&&l.signal.removeEventListener(`abort`,f)}),d.send(l._bodyInit===void 0?null:l._bodyInit)})}return T.polyfill=!0,n.fetch||(n.fetch=T,n.Headers=u,n.Request=b,n.Response=C),t.Headers=u,t.Request=b,t.Response=C,t.fetch=T,Object.defineProperty(t,"__esModule",{value:!0}),t})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=n.fetch?n:r;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})),r6=W3((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.Getter=void 0;var a=i(n6());e.Getter={create:o,http:s,file:c};function o(e){return typeof e==`function`?e:e.startsWith(`http://`)||e.startsWith(`https://`)?s(e):c(e)}function s(e){return async function(t,n){if(t<0||n<0||t>n)throw Error(`Invalid range`);let r=await(await(0,a.default)(e,{headers:{Range:`bytes=${t}-${n-1}`}})).arrayBuffer();return new Uint8Array(r)}}function c(e){return async function(t,n){let i=await Promise.resolve().then(()=>r({}));async function a(t=0,n=1/0){if(t<0||n<0||t>n)throw Error(`Invalid range`);return await i.promises.access(e),l(i.createReadStream(e,{start:t,end:n-1,autoClose:!0}))}return a(t,n)}}async function l(e){return await new Promise((t,n)=>{let r=[];e.on(`data`,e=>r.push(e)),e.on(`error`,n),e.on(`end`,()=>t(Buffer.concat(r)))})}})),i6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Key=void 0,e.Key={create:t,parse:n,toString:r,step:i,up:a,compare:o,depth:s};function t(e,t=0,r=0,i=0){return typeof e==`number`?[e,t,r,i]:n(e)}function n(e){if(typeof e!=`string`)return e;let[t,n,r,i,...a]=e.split(`-`).map(e=>parseInt(e,10)),o=[t,n,r,i];if(a.length!==0||o.some(e=>typeof e!=`number`||Number.isNaN(e)))throw Error(`Invalid key: ${e}`);return o}function r(e){return typeof e==`string`?e:e.join(`-`)}function i(t,[n,r,i]){let[a,o,s,c]=e.Key.create(t);return[a+1,o*2+n,s*2+r,c*2+i]}function a(t,n=1){let[r,i,a,o]=e.Key.create(t);return[r-n,i>>n,a>>n,o>>n]}function o(e,t){for(let n=0;n<e.length;++n){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return 0}function s(e){return e[0]}})),a6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Scale=void 0,e.Scale={apply:(e,t=1,n=0)=>(e-n)/t,unapply:(e,t=1,n=0)=>e*t+n}})),o6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Step=void 0,e.Step={fromIndex:t,list:n};function t(e){if(e<0||e>=8)throw Error(`Invalid step index: ${e}`);return[e>>0&1?1:0,e>>1&1?1:0,e>>2&1?1:0]}function n(){return[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]}})),s6=W3((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.Step=e.Scale=e.Key=e.Getter=e.Dimension=e.Bounds=e.Binary=void 0,n(Q3(),e);var r=$3();Object.defineProperty(e,"Binary",{enumerable:!0,get:function(){return r.Binary}});var i=e6();Object.defineProperty(e,"Bounds",{enumerable:!0,get:function(){return i.Bounds}});var a=t6();Object.defineProperty(e,"Dimension",{enumerable:!0,get:function(){return a.Dimension}});var o=r6();Object.defineProperty(e,"Getter",{enumerable:!0,get:function(){return o.Getter}});var s=i6();Object.defineProperty(e,"Key",{enumerable:!0,get:function(){return s.Key}});var c=a6();Object.defineProperty(e,"Scale",{enumerable:!0,get:function(){return c.Scale}});var l=o6();Object.defineProperty(e,"Step",{enumerable:!0,get:function(){return l.Step}})})),c6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExtraBytes=void 0;var t=s6();e.ExtraBytes={getDimension:r,parse:i,parseOne:a};var n=192;function r({type:e,length:t}){switch(e){case`signed`:case`unsigned`:switch(t){case 1:case 2:case 4:case 8:return{type:e,size:t}}case`float`:switch(t){case 4:case 8:return{type:e,size:t}}}}function i(e){if(e.byteLength%n!==0)throw Error(`Invalid extra bytes VLR length: ${e.byteLength}`);let t=[];for(let r=0;r<e.byteLength;r+=n)t.push(a(e.slice(r,r+n)));return t}function a(e){if(e.byteLength!==n)throw Error(`Invalid extra bytes entry length: ${e.byteLength}`);let r=t.Binary.toDataView(e),i=t.Binary.toCString(e.slice(4,36)),a=t.Binary.toCString(e.slice(60,192)),c=r.getUint8(2),l=r.getUint8(3);if(c>=11)throw Error(`Invalid extra bytes "type" value: ${c}`);if(c===0)return{name:i,description:a,length:l};let u=s(l),d=o(c);if(!d)throw Error(`Failed to extract dimension type: ${c}`);let{type:f,size:p}=d;function m(e){switch(f){case`signed`:return(0,t.parseBigInt)(r.getBigInt64(e,!0));case`unsigned`:return(0,t.parseBigInt)((0,t.getBigUint64)(r,e,!0));case`float`:return r.getFloat64(e,!0)}}let h={name:i,description:a,type:f,length:p};return u.hasNodata&&(h.nodata=m(40)),u.hasMin&&(h.min=m(64)),u.hasMax&&(h.max=m(88)),u.hasScale&&(h.scale=r.getFloat64(112)),u.hasOffset&&(h.offset=r.getFloat64(136)),h}function o(e){switch(e){case 1:return t.Dimension.Type.uint8;case 2:return t.Dimension.Type.int8;case 3:return t.Dimension.Type.uint16;case 4:return t.Dimension.Type.int16;case 5:return t.Dimension.Type.uint32;case 6:return t.Dimension.Type.int32;case 7:return t.Dimension.Type.uint64;case 8:return t.Dimension.Type.int64;case 9:return t.Dimension.Type.float32;case 10:return t.Dimension.Type.float64}}function s(e){return{hasNodata:!!(e&1),hasMin:!!(e>>1&1),hasMax:!!(e>>2&1),hasScale:!!(e>>3&1),hasOffset:!!(e>>4&1)}}})),l6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Dimensions=void 0;var t=s6(),n=c6();e.Dimensions={create:a};var{Type:r}=t.Dimension,i={X:r.float64,Y:r.float64,Z:r.float64,Intensity:r.uint16,ReturnNumber:r.uint8,NumberOfReturns:r.uint8,ScanDirectionFlag:r.boolean,EdgeOfFlightLine:r.boolean,Classification:r.uint8,Synthetic:r.boolean,KeyPoint:r.boolean,Withheld:r.boolean,Overlap:r.boolean,ScanAngle:r.float32,UserData:r.uint8,PointSourceId:r.uint16,GpsTime:r.float64,Red:r.uint16,Green:r.uint16,Blue:r.uint16,ScannerChannel:r.uint8,Infrared:r.uint16};function a(e,t=[]){return Object.keys(e).reduce((e,r)=>{let a=i[r];if(a)return{...e,[r]:a};let o=t.find(e=>e.name===r),s=o&&n.ExtraBytes.getDimension(o);if(s)return{...e,[r]:s};throw Error(`Failed to look up LAS type: ${r}`)},{})}})),u6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Extractor=void 0;var t=s6();e.Extractor={create:a};function n(e){switch(e){case 0:return 20;case 1:return 28;case 2:return 26;case 3:return 34;case 6:return 30;case 7:return 36;case 8:return 38;default:throw Error(`Unsupported point data record format: ${e}`)}}function r(e,n,{type:r,length:i}){let a=p(e);switch(r){case`signed`:switch(i){case 1:return(e,t)=>e.getInt8(a(t)+n);case 2:return(e,t)=>e.getInt16(a(t)+n,!0);case 4:return(e,t)=>e.getInt32(a(t)+n,!0);case 8:return(e,r)=>(0,t.parseBigInt)(e.getBigInt64(a(r)+n,!0))}case`unsigned`:switch(i){case 1:return(e,t)=>e.getUint8(a(t)+n);case 2:return(e,t)=>e.getUint16(a(t)+n,!0);case 4:return(e,t)=>e.getUint32(a(t)+n,!0);case 8:return(e,r)=>(0,t.parseBigInt)((0,t.getBigUint64)(e,a(r)+n,!0))}case`float`:switch(i){case 4:return(e,t)=>e.getFloat32(a(t)+n,!0);case 8:return(e,t)=>e.getFloat64(a(t)+n,!0)}}}function i(e,i){let a=n(e.pointDataRecordFormat);return i.reduce((n,i)=>{let o=a;a+=i.length;let s=r(e,o,i);if(!s)return n;let c=(e,n)=>t.Scale.unapply(s(e,n),i.scale,i.offset);return{...n,[i.name]:c}},{})}function a(e,t=[]){let n=i(e,t);return{...(()=>{let{pointDataRecordFormat:t}=e;switch(t){case 0:return o(e);case 1:return s(e);case 2:return c(e);case 3:return l(e);case 6:return u(e);case 7:return d(e);case 8:return f(e);default:throw Error(`Unsupported point data record format: ${t}`)}})(),...n}}function o(e){let{scale:n,offset:r}=e,i=p(e);function a(e,t){return e.getUint8(i(t)+14)}function o(e,t){return e.getUint8(i(t)+15)}function s(e,t){return o(e,t)&31}return{X:(e,a)=>t.Scale.unapply(e.getInt32(i(a),!0),n[0],r[0]),Y:(e,a)=>t.Scale.unapply(e.getInt32(i(a)+4,!0),n[1],r[1]),Z:(e,a)=>t.Scale.unapply(e.getInt32(i(a)+8,!0),n[2],r[2]),Intensity:(e,t)=>e.getUint16(i(t)+12,!0),ReturnNumber:(e,t)=>a(e,t)&7,NumberOfReturns:(e,t)=>(a(e,t)&56)>>3,ScanDirectionFlag:(e,t)=>(a(e,t)&64)>>6,EdgeOfFlightLine:(e,t)=>(a(e,t)&128)>>7,Classification:(e,t)=>{let n=s(e,t);return n===12?0:n},Synthetic:(e,t)=>(o(e,t)&32)>>5,KeyPoint:(e,t)=>(o(e,t)&64)>>6,Withheld:(e,t)=>(o(e,t)&128)>>7,Overlap:(e,t)=>+(s(e,t)===12),ScanAngle:(e,t)=>e.getInt8(i(t)+16),UserData:(e,t)=>e.getUint8(i(t)+17),PointSourceId:(e,t)=>e.getUint16(i(t)+18,!0)}}function s(e){let t=p(e);return{...o(e),GpsTime:(e,n)=>e.getFloat64(t(n)+20,!0)}}function c(e){let t=p(e);return{...o(e),Red:(e,n)=>e.getUint16(t(n)+20,!0),Green:(e,n)=>e.getUint16(t(n)+22,!0),Blue:(e,n)=>e.getUint16(t(n)+24,!0)}}function l(e){let t=p(e);return{...o(e),GpsTime:(e,n)=>e.getFloat64(t(n)+20,!0),Red:(e,n)=>e.getUint16(t(n)+28,!0),Green:(e,n)=>e.getUint16(t(n)+30,!0),Blue:(e,n)=>e.getUint16(t(n)+32,!0)}}function u(e){let{scale:n,offset:r}=e,i=p(e);function a(e,t){return e.getUint8(i(t)+15)}return{X:(e,a)=>t.Scale.unapply(e.getInt32(i(a),!0),n[0],r[0]),Y:(e,a)=>t.Scale.unapply(e.getInt32(i(a)+4,!0),n[1],r[1]),Z:(e,a)=>t.Scale.unapply(e.getInt32(i(a)+8,!0),n[2],r[2]),Intensity:(e,t)=>e.getUint16(i(t)+12,!0),ReturnNumber:(e,t)=>e.getUint16(i(t)+14,!0)&15,NumberOfReturns:(e,t)=>(e.getUint16(i(t)+14,!0)&240)>>4,Synthetic:(e,t)=>a(e,t)&1,KeyPoint:(e,t)=>(a(e,t)&2)>>1,Withheld:(e,t)=>(a(e,t)&4)>>2,Overlap:(e,t)=>(a(e,t)&8)>>3,ScannerChannel:(e,t)=>(a(e,t)&48)>>4,ScanDirectionFlag:(e,t)=>(a(e,t)&64)>>6,EdgeOfFlightLine:(e,t)=>(a(e,t)&128)>>7,Classification:(e,t)=>e.getUint8(i(t)+16),UserData:(e,t)=>e.getUint8(i(t)+17),ScanAngle:(e,t)=>e.getInt16(i(t)+18,!0)*.006,PointSourceId:(e,t)=>e.getUint16(i(t)+20,!0),GpsTime:(e,t)=>e.getFloat64(i(t)+22,!0)}}function d(e){let t=p(e);return{...u(e),Red:(e,n)=>e.getUint16(t(n)+30,!0),Green:(e,n)=>e.getUint16(t(n)+32,!0),Blue:(e,n)=>e.getUint16(t(n)+34,!0)}}function f(e){let t=p(e);return{...d(e),Infrared:(e,n)=>e.getUint16(t(n)+36,!0)}}function p(e){let{pointDataRecordLength:t}=e;return function(e){return e*t}}})),d6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatGuid=e.parsePoint=void 0;var t=s6();function n(e){let n=t.Binary.toDataView(e);if(n.byteLength!==24)throw Error(`Invalid tuple buffer length: ${n.byteLength}`);return[n.getFloat64(0,!0),n.getFloat64(8,!0),n.getFloat64(16,!0)]}e.parsePoint=n;function r(e){let n=t.Binary.toDataView(e);if(n.byteLength!==16)throw Error(`Invalid GUID buffer length: ${n.byteLength}`);let r=``;for(let e=0;e<n.byteLength;e+=4){let t=n.getUint32(e,!0);r+=t.toString(16).padStart(8,`0`)}return[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,32)].join(`-`)}e.formatGuid=r})),f6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Header=void 0;var t=s6(),n=Z3(),r=d6();e.Header={parse:i};function i(e){if(e.byteLength<n.minHeaderLength)throw Error(`Invalid header: must be at least ${n.minHeaderLength} bytes`);let i=t.Binary.toDataView(e),s=t.Binary.toCString(e.slice(0,4));if(s!==`LASF`)throw Error(`Invalid file signature: ${s}`);let c=i.getUint8(24),l=i.getUint8(25);if(c!==1||l!==2&&l!==4)throw Error(`Invalid version (only 1.2 and 1.4 supported): ${c}.${l}`);let u={fileSignature:s,fileSourceId:i.getUint16(4,!0),globalEncoding:i.getUint16(6,!0),projectId:(0,r.formatGuid)(e.slice(8,24)),majorVersion:c,minorVersion:l,systemIdentifier:t.Binary.toCString(e.slice(26,58)),generatingSoftware:t.Binary.toCString(e.slice(58,90)),fileCreationDayOfYear:i.getUint16(90,!0),fileCreationYear:i.getUint16(92,!0),headerLength:i.getUint16(94,!0),pointDataOffset:i.getUint32(96,!0),vlrCount:i.getUint32(100,!0),pointDataRecordFormat:i.getUint8(104)&15,pointDataRecordLength:i.getUint16(105,!0),pointCount:i.getUint32(107,!0),pointCountByReturn:o(e.slice(111,131)),scale:(0,r.parsePoint)(e.slice(131,155)),offset:(0,r.parsePoint)(e.slice(155,179)),min:[i.getFloat64(187,!0),i.getFloat64(203,!0),i.getFloat64(219,!0)],max:[i.getFloat64(179,!0),i.getFloat64(195,!0),i.getFloat64(211,!0)],waveformDataOffset:0,evlrOffset:0,evlrCount:0};return l==2?u:{...u,pointCount:(0,t.parseBigInt)((0,t.getBigUint64)(i,247,!0)),pointCountByReturn:a(e.slice(255,375)),waveformDataOffset:(0,t.parseBigInt)((0,t.getBigUint64)(i,227,!0)),evlrOffset:(0,t.parseBigInt)((0,t.getBigUint64)(i,235,!0)),evlrCount:i.getUint32(243,!0)}}function a(e){let n=t.Binary.toDataView(e),r=[];for(let e=0;e<120;e+=8)r.push((0,t.getBigUint64)(n,e,!0));return r.map(e=>(0,t.parseBigInt)(e))}function o(e){let n=t.Binary.toDataView(e),r=[];for(let e=0;e<20;e+=4)r.push(n.getUint32(e,!0));return r}})),p6=W3(((e,t)=>{var n=(()=>{var e=typeof document<`u`&&document.currentScript?document.currentScript.src:void 0;return(function(t){t||={};var n=t===void 0?{}:t,r,i;n.ready=new Promise(function(e,t){r=e,i=t}),[`_main`,`___getTypeName`,`__embind_initialize_bindings`,`_fflush`,`onRuntimeInitialized`].forEach(e=>{Object.getOwnPropertyDescriptor(n.ready,e)||Object.defineProperty(n.ready,e,{get:()=>we(`You are getting `+e+` on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js`),set:()=>we(`You are setting `+e+` on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js`)})});var a=Object.assign({},n),o=[],s=`./this.program`,c=!0,l=!1,u=!1,d=!1;if(n.ENVIRONMENT)throw Error(`Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)`);var f=``;function p(e){return n.locateFile?n.locateFile(e,f):f+e}var m;if(d){if(typeof process==`object`&&typeof G3==`function`||typeof window==`object`||typeof importScripts==`function`)throw Error(`not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)`);m=function(e){let t;return typeof readbuffer==`function`?new Uint8Array(readbuffer(e)):(t=read(e,`binary`),T(typeof t==`object`),t)},typeof scriptArgs<`u`?o=scriptArgs:typeof arguments<`u`&&(o=arguments),typeof print<`u`&&(typeof console>`u`&&(console={}),console.log=print,console.warn=console.error=typeof printErr<`u`?printErr:print)}else if(c||l){if(l?f=self.location.href:typeof document<`u`&&document.currentScript&&(f=document.currentScript.src),e&&(f=e),f=f.indexOf(`blob:`)===0?``:f.substr(0,f.replace(/[?#].*/,``).lastIndexOf(`/`)+1),!(typeof window==`object`||typeof importScripts==`function`))throw Error(`not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)`);l&&(m=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)})}else throw Error(`environment detection error`);var h=n.print||console.log.bind(console),g=n.printErr||console.warn.bind(console);Object.assign(n,a),a=null,nr(),n.arguments&&(o=n.arguments),_(`arguments`,`arguments_`),n.thisProgram&&(s=n.thisProgram),_(`thisProgram`,`thisProgram`),n.quit&&n.quit,_(`quit`,`quit_`),T(n.memoryInitializerPrefixURL===void 0,`Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead`),T(n.pthreadMainPrefixURL===void 0,`Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead`),T(n.cdInitializerPrefixURL===void 0,`Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead`),T(n.filePackagePrefixURL===void 0,`Module.filePackagePrefixURL option was removed, use Module.locateFile instead`),T(n.read===void 0,`Module.read option was removed (modify read_ in JS)`),T(n.readAsync===void 0,`Module.readAsync option was removed (modify readAsync in JS)`),T(n.readBinary===void 0,`Module.readBinary option was removed (modify readBinary in JS)`),T(n.setWindowTitle===void 0,`Module.setWindowTitle option was removed (modify setWindowTitle in JS)`),T(n.TOTAL_MEMORY===void 0,`Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY`),_(`read`,`read_`),_(`readAsync`,`readAsync`),_(`readBinary`,`readBinary`),_(`setWindowTitle`,`setWindowTitle`),T(!l,"worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable."),T(!u,"node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable."),T(!d,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");function _(e,t){Object.getOwnPropertyDescriptor(n,e)||Object.defineProperty(n,e,{configurable:!0,get:function(){we(`Module.`+e+` has been replaced with plain `+t+` (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)`)}})}function v(e){Object.getOwnPropertyDescriptor(n,e)&&we("`Module."+e+"` was supplied but `"+e+"` not included in INCOMING_MODULE_JS_API")}function y(e){return e===`FS_createPath`||e===`FS_createDataFile`||e===`FS_createPreloadedFile`||e===`FS_unlink`||e===`addRunDependency`||e===`FS_createLazyFile`||e===`FS_createDevice`||e===`removeRunDependency`}function b(e){typeof globalThis<`u`&&!Object.getOwnPropertyDescriptor(globalThis,e)&&Object.defineProperty(globalThis,e,{configurable:!0,get:function(){var t="`"+e+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line";y(e)&&(t+=`. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you`),z(t)}})}function x(e){Object.getOwnPropertyDescriptor(n,e)||Object.defineProperty(n,e,{configurable:!0,get:function(){var t=`'`+e+`' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)`;y(e)&&(t+=`. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you`),we(t)}})}var S;n.wasmBinary&&(S=n.wasmBinary),_(`wasmBinary`,`wasmBinary`),n.noExitRuntime,_(`noExitRuntime`,`noExitRuntime`),typeof WebAssembly!=`object`&&we(`no native wasm support detected`);var C,w=!1;function T(e,t){e||we(`Assertion failed`+(t?`: `+t:``))}var E=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function D(e,t,n){for(var r=t+n,i=t;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&E)return E.decode(e.subarray(t,i));for(var a=``;t<i;){var o=e[t++];if(!(o&128)){a+=String.fromCharCode(o);continue}var s=e[t++]&63;if((o&224)==192){a+=String.fromCharCode((o&31)<<6|s);continue}var c=e[t++]&63;if((o&240)==224?o=(o&15)<<12|s<<6|c:((o&248)!=240&&z(`Invalid UTF-8 leading byte 0x`+o.toString(16)+` encountered when deserializing a UTF-8 string in wasm memory to a JS string!`),o=(o&7)<<18|s<<12|c<<6|e[t++]&63),o<65536)a+=String.fromCharCode(o);else{var l=o-65536;a+=String.fromCharCode(55296|l>>10,56320|l&1023)}}return a}function O(e,t){return e?D(P,e,t):``}function k(e,t,n,r){if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343){var c=e.charCodeAt(++o);s=65536+((s&1023)<<10)|c&1023}if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|s&63}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|s&63}else{if(n+3>=a)break;s>1114111&&z(`Invalid Unicode code point 0x`+s.toString(16)+` encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).`),t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|s&63}}return t[n]=0,n-i}function A(e,t,n){return T(typeof n==`number`,`stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!`),k(e,P,t,n)}function j(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++n):t+=3}return t}var M,N,P,F,ee,I,L,te,ne;function R(e){M=e,n.HEAP8=N=new Int8Array(e),n.HEAP16=F=new Int16Array(e),n.HEAP32=I=new Int32Array(e),n.HEAPU8=P=new Uint8Array(e),n.HEAPU16=ee=new Uint16Array(e),n.HEAPU32=L=new Uint32Array(e),n.HEAPF32=te=new Float32Array(e),n.HEAPF64=ne=new Float64Array(e)}var re=65536;n.TOTAL_STACK&&T(re===n.TOTAL_STACK,`the stack size can no longer be determined at runtime`);var ie=n.INITIAL_MEMORY||262144;_(`INITIAL_MEMORY`,`INITIAL_MEMORY`),T(ie>=re,`INITIAL_MEMORY should be larger than TOTAL_STACK, was `+ie+`! (TOTAL_STACK=`+re+`)`),T(typeof Int32Array<`u`&&typeof Float64Array<`u`&&Int32Array.prototype.subarray!=null&&Int32Array.prototype.set!=null,`JS engine does not provide full typed array support`),T(!n.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),T(ie==262144,`Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically`);var ae;function oe(){var e=ur();T((e&3)==0),L[e>>2]=34821223,L[e+4>>2]=2310721022,L[0]=1668509029}function se(){if(!w){var e=ur(),t=L[e>>2],n=L[e+4>>2];(t!=34821223||n!=2310721022)&&we(`Stack overflow! Stack cookie has been overwritten at 0x`+e.toString(16)+`, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x`+n.toString(16)+` 0x`+t.toString(16)),L[0]!==1668509029&&we(`Runtime error: The application has corrupted its heap memory area (address zero)!`)}}(function(){var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,t[0]!==115||t[1]!==99)throw`Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)`})();var ce=[],le=[],ue=[],de=!1;function fe(){if(n.preRun)for(typeof n.preRun==`function`&&(n.preRun=[n.preRun]);n.preRun.length;)he(n.preRun.shift());Pe(ce)}function pe(){T(!de),de=!0,se(),Pe(le)}function me(){if(se(),n.postRun)for(typeof n.postRun==`function`&&(n.postRun=[n.postRun]);n.postRun.length;)_e(n.postRun.shift());Pe(ue)}function he(e){ce.unshift(e)}function ge(e){le.unshift(e)}function _e(e){ue.unshift(e)}T(Math.imul,`This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill`),T(Math.fround,`This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill`),T(Math.clz32,`This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill`),T(Math.trunc,`This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill`);var ve=0,ye=null,be=null,xe={};function Se(e){ve++,n.monitorRunDependencies&&n.monitorRunDependencies(ve),e?(T(!xe[e]),xe[e]=1,ye===null&&typeof setInterval<`u`&&(ye=setInterval(function(){if(w){clearInterval(ye),ye=null;return}var e=!1;for(var t in xe)e||(e=!0,g(`still waiting on run dependencies:`)),g(`dependency: `+t);e&&g(`(end of list)`)},1e4))):g(`warning: run dependency added without ID`)}function Ce(e){if(ve--,n.monitorRunDependencies&&n.monitorRunDependencies(ve),e?(T(xe[e]),delete xe[e]):g(`warning: run dependency removed without ID`),ve==0&&(ye!==null&&(clearInterval(ye),ye=null),be)){var t=be;be=null,t()}}function we(e){n.onAbort&&n.onAbort(e),e=`Aborted(`+e+`)`,g(e),w=!0;var t=new WebAssembly.RuntimeError(e);throw i(t),t}var Te={error:function(){we(`Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM`)},init:function(){Te.error()},createDataFile:function(){Te.error()},createPreloadedFile:function(){Te.error()},createLazyFile:function(){Te.error()},open:function(){Te.error()},mkdev:function(){Te.error()},registerDevice:function(){Te.error()},analyzePath:function(){Te.error()},loadFilesFromDB:function(){Te.error()},ErrnoError:function(){Te.error()}};n.FS_createDataFile=Te.createDataFile,n.FS_createPreloadedFile=Te.createPreloadedFile;var Ee=`data:application/octet-stream;base64,`;function De(e){return e.startsWith(Ee)}function Oe(e){return e.startsWith(`file://`)}function ke(e,t){return function(){var r=e,i=t;return t||(i=n.asm),T(de,"native function `"+r+"` called before runtime initialization"),i[e]||T(i[e],"exported native function `"+r+"` not found"),i[e].apply(null,arguments)}}var Ae=`laz-perf.wasm`;De(Ae)||(Ae=p(Ae));function je(e){try{if(e==Ae&&S)return new Uint8Array(S);if(m)return m(e);throw`both async and sync fetching of the wasm failed`}catch(e){we(e)}}function Me(){return!S&&(c||l)&&typeof fetch==`function`?fetch(Ae,{credentials:`same-origin`}).then(function(e){if(!e.ok)throw`failed to load wasm binary file at '`+Ae+`'`;return e.arrayBuffer()}).catch(function(){return je(Ae)}):Promise.resolve().then(function(){return je(Ae)})}function Ne(){var e={env:rr,wasi_snapshot_preview1:rr};function t(e,t){n.asm=e.exports,C=n.asm.memory,T(C,`memory not found in wasm exports`),R(C.buffer),ae=n.asm.__indirect_function_table,T(ae,`table not found in wasm exports`),ge(n.asm.__wasm_call_ctors),Ce(`wasm-instantiate`)}Se(`wasm-instantiate`);var r=n;function a(e){T(n===r,`the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?`),r=null,t(e.instance)}function o(t){return Me().then(function(t){return WebAssembly.instantiate(t,e)}).then(function(e){return e}).then(t,function(e){g(`failed to asynchronously prepare wasm: `+e),Oe(Ae)&&g(`warning: Loading from a file URI (`+Ae+`) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),we(e)})}function s(){return!S&&typeof WebAssembly.instantiateStreaming==`function`&&!De(Ae)&&typeof fetch==`function`?fetch(Ae,{credentials:`same-origin`}).then(function(t){return WebAssembly.instantiateStreaming(t,e).then(a,function(e){return g(`wasm streaming compile failed: `+e),g(`falling back to ArrayBuffer instantiation`),o(a)})}):o(a)}if(n.instantiateWasm)try{return n.instantiateWasm(e,t)}catch(e){return g(`Module.instantiateWasm callback failed with error: `+e),!1}return s().catch(i),{}}function Pe(e){for(;e.length>0;)e.shift()(n)}function z(e){z.shown||={},z.shown[e]||(z.shown[e]=1,g(e))}function Fe(e,t){T(e.length>=0,`writeArrayToMemory array must have a length (should be an array or typed array)`),N.set(e,t)}function Ie(e){return ir(e+24)+24}function Le(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){L[this.ptr+4>>2]=e},this.get_type=function(){return L[this.ptr+4>>2]},this.set_destructor=function(e){L[this.ptr+8>>2]=e},this.get_destructor=function(){return L[this.ptr+8>>2]},this.set_refcount=function(e){I[this.ptr>>2]=e},this.set_caught=function(e){e=+!!e,N[this.ptr+12>>0]=e},this.get_caught=function(){return N[this.ptr+12>>0]!=0},this.set_rethrown=function(e){e=+!!e,N[this.ptr+13>>0]=e},this.get_rethrown=function(){return N[this.ptr+13>>0]!=0},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var e=I[this.ptr>>2];I[this.ptr>>2]=e+1},this.release_ref=function(){var e=I[this.ptr>>2];return I[this.ptr>>2]=e-1,T(e>0),e===1},this.set_adjusted_ptr=function(e){L[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return L[this.ptr+16>>2]},this.get_exception_ptr=function(){if(dr(this.get_type()))return L[this.excPtr>>2];var e=this.get_adjusted_ptr();return e===0?this.excPtr:e}}var Re=0;function ze(e,t,n){throw new Le(e).init(t,n),Re++,e+` - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.`}function Be(e,t,n,r,i){}function Ve(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw TypeError(`Unknown type size: `+e)}}function He(){for(var e=Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);Ue=e}var Ue=void 0;function We(e){for(var t=``,n=e;P[n];)t+=Ue[P[n++]];return t}var Ge={},B={},Ke={},qe=48,Je=57;function Ye(e){if(e===void 0)return`_unknown`;e=e.replace(/[^a-zA-Z0-9_]/g,`$`);var t=e.charCodeAt(0);return t>=qe&&t<=Je?`_`+e:e}function V(e,t){return e=Ye(e),Function(`body`,`return function `+e+`() {
|
||
"use strict"; return body.apply(this, arguments);
|
||
};
|
||
`)(t)}function Xe(e,t){var n=V(t,function(e){this.name=t,this.message=e;var n=Error(e).stack;n!==void 0&&(this.stack=this.toString()+`
|
||
`+n.replace(/^Error(:[^\n]*)?\n/,``))});return n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return this.message===void 0?this.name:this.name+`: `+this.message},n}var Ze=void 0;function H(e){throw new Ze(e)}var Qe=void 0;function $e(e){throw new Qe(e)}function et(e,t,n){e.forEach(function(e){Ke[e]=t});function r(t){var r=n(t);r.length!==e.length&&$e(`Mismatched type converter count`);for(var i=0;i<e.length;++i)tt(e[i],r[i])}var i=Array(t.length),a=[],o=0;t.forEach((e,t)=>{B.hasOwnProperty(e)?i[t]=B[e]:(a.push(e),Ge.hasOwnProperty(e)||(Ge[e]=[]),Ge[e].push(()=>{i[t]=B[e],++o,o===a.length&&r(i)}))}),a.length===0&&r(i)}function tt(e,t,n={}){if(!(`argPackAdvance`in t))throw TypeError(`registerType registeredInstance requires argPackAdvance`);var r=t.name;if(e||H(`type "`+r+`" must have a positive integer typeid pointer`),B.hasOwnProperty(e)){if(n.ignoreDuplicateRegistrations)return;H(`Cannot register type '`+r+`' twice`)}if(B[e]=t,delete Ke[e],Ge.hasOwnProperty(e)){var i=Ge[e];delete Ge[e],i.forEach(e=>e())}}function nt(e,t,n,r,i){var a=Ve(n);t=We(t),tt(e,{name:t,fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:i},argPackAdvance:8,readValueFromPointer:function(e){var r;if(n===1)r=N;else if(n===2)r=F;else if(n===4)r=I;else throw TypeError(`Unknown boolean type size: `+t);return this.fromWireType(r[e>>a])},destructorFunction:null})}function U(e){if(!(this instanceof kt)||!(e instanceof kt))return!1;for(var t=this.$$.ptrType.registeredClass,n=this.$$.ptr,r=e.$$.ptrType.registeredClass,i=e.$$.ptr;t.baseClass;)n=t.upcast(n),t=t.baseClass;for(;r.baseClass;)i=r.upcast(i),r=r.baseClass;return t===r&&n===i}function rt(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function it(e){function t(e){return e.$$.ptrType.registeredClass.name}H(t(e)+` instance already deleted`)}var at=!1;function ot(e){}function st(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function ct(e){--e.count.value,e.count.value===0&&st(e)}function lt(e,t,n){if(t===n)return e;if(n.baseClass===void 0)return null;var r=lt(e,t,n.baseClass);return r===null?null:n.downcast(r)}var ut={};function dt(){return Object.keys(vt).length}function ft(){var e=[];for(var t in vt)vt.hasOwnProperty(t)&&e.push(vt[t]);return e}var pt=[];function mt(){for(;pt.length;){var e=pt.pop();e.$$.deleteScheduled=!1,e.delete()}}var ht=void 0;function gt(e){ht=e,pt.length&&ht&&ht(mt)}function _t(){n.getInheritedInstanceCount=dt,n.getLiveInheritedInstances=ft,n.flushPendingDeletes=mt,n.setDelayFunction=gt}var vt={};function yt(e,t){for(t===void 0&&H(`ptr should not be undefined`);e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}function bt(e,t){return t=yt(e,t),vt[t]}function xt(e,t){return(!t.ptrType||!t.ptr)&&$e(`makeClassHandle requires ptr and ptrType`),!!t.smartPtrType!=!!t.smartPtr&&$e(`Both smartPtrType and smartPtr must be specified`),t.count={value:1},Ct(Object.create(e,{$$:{value:t}}))}function St(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var n=bt(this.registeredClass,t);if(n!==void 0){if(n.$$.count.value===0)return n.$$.ptr=t,n.$$.smartPtr=e,n.clone();var r=n.clone();return this.destructor(e),r}function i(){return this.isSmartPointer?xt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):xt(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=ut[this.registeredClass.getActualType(t)];if(!a)return i.call(this);var o=this.isConst?a.constPointerType:a.pointerType,s=lt(t,this.registeredClass,o.registeredClass);return s===null?i.call(this):this.isSmartPointer?xt(o.registeredClass.instancePrototype,{ptrType:o,ptr:s,smartPtrType:this,smartPtr:e}):xt(o.registeredClass.instancePrototype,{ptrType:o,ptr:s})}function Ct(e){return typeof FinalizationRegistry>`u`?(Ct=e=>e,e):(at=new FinalizationRegistry(e=>{console.warn(e.leakWarning.stack.replace(/^Error: /,``)),ct(e.$$)}),Ct=e=>{var t=e.$$;if(t.smartPtr){var n={$$:t},r=t.ptrType.registeredClass;n.leakWarning=Error(`Embind found a leaked C++ instance `+r.name+` <0x`+t.ptr.toString(16)+`>.
|
||
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
||
Make sure to invoke .delete() manually once you're done with the instance instead.
|
||
Originally allocated`),`captureStackTrace`in Error&&Error.captureStackTrace(n.leakWarning,St),at.register(e,n,e)}return e},ot=e=>at.unregister(e),Ct(e))}function wt(){if(this.$$.ptr||it(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=Ct(Object.create(Object.getPrototypeOf(this),{$$:{value:rt(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function Tt(){this.$$.ptr||it(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&H(`Object already scheduled for deletion`),ot(this),ct(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Et(){return!this.$$.ptr}function Dt(){return this.$$.ptr||it(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&H(`Object already scheduled for deletion`),pt.push(this),pt.length===1&&ht&&ht(mt),this.$$.deleteScheduled=!0,this}function Ot(){kt.prototype.isAliasOf=U,kt.prototype.clone=wt,kt.prototype.delete=Tt,kt.prototype.isDeleted=Et,kt.prototype.deleteLater=Dt}function kt(){}function At(e,t,n){if(e[t].overloadTable===void 0){var r=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||H(`Function '`+n+`' called with an invalid number of arguments (`+arguments.length+`) - expects one of (`+e[t].overloadTable+`)!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[r.argCount]=r}}function jt(e,t,r){n.hasOwnProperty(e)?((r===void 0||n[e].overloadTable!==void 0&&n[e].overloadTable[r]!==void 0)&&H(`Cannot register public name '`+e+`' twice`),At(n,e,e),n.hasOwnProperty(r)&&H(`Cannot register multiple overloads of a function with the same number of arguments (`+r+`)!`),n[e].overloadTable[r]=t):(n[e]=t,r!==void 0&&(n[e].numArguments=r))}function Mt(e,t,n,r,i,a,o,s){this.name=e,this.constructor=t,this.instancePrototype=n,this.rawDestructor=r,this.baseClass=i,this.getActualType=a,this.upcast=o,this.downcast=s,this.pureVirtualFunctions=[]}function Nt(e,t,n){for(;t!==n;)t.upcast||H(`Expected null or instance of `+n.name+`, got an instance of `+t.name),e=t.upcast(e),t=t.baseClass;return e}function Pt(e,t){if(t===null)return this.isReference&&H(`null is not a valid `+this.name),0;t.$$||H(`Cannot pass "`+hn(t)+`" as a `+this.name),t.$$.ptr||H(`Cannot pass deleted object as a pointer of type `+this.name);var n=t.$$.ptrType.registeredClass;return Nt(t.$$.ptr,n,this.registeredClass)}function Ft(e,t){var n;if(t===null)return this.isReference&&H(`null is not a valid `+this.name),this.isSmartPointer?(n=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,n),n):0;t.$$||H(`Cannot pass "`+hn(t)+`" as a `+this.name),t.$$.ptr||H(`Cannot pass deleted object as a pointer of type `+this.name),!this.isConst&&t.$$.ptrType.isConst&&H(`Cannot convert argument of type `+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+` to parameter type `+this.name);var r=t.$$.ptrType.registeredClass;if(n=Nt(t.$$.ptr,r,this.registeredClass),this.isSmartPointer)switch(t.$$.smartPtr===void 0&&H(`Passing raw pointer to smart pointer is illegal`),this.sharingPolicy){case 0:t.$$.smartPtrType===this?n=t.$$.smartPtr:H(`Cannot convert argument of type `+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+` to parameter type `+this.name);break;case 1:n=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)n=t.$$.smartPtr;else{var i=t.clone();n=this.rawShare(n,pn.toHandle(function(){i.delete()})),e!==null&&e.push(this.rawDestructor,n)}break;default:H(`Unsupporting sharing policy`)}return n}function It(e,t){if(t===null)return this.isReference&&H(`null is not a valid `+this.name),0;t.$$||H(`Cannot pass "`+hn(t)+`" as a `+this.name),t.$$.ptr||H(`Cannot pass deleted object as a pointer of type `+this.name),t.$$.ptrType.isConst&&H(`Cannot convert argument of type `+t.$$.ptrType.name+` to parameter type `+this.name);var n=t.$$.ptrType.registeredClass;return Nt(t.$$.ptr,n,this.registeredClass)}function Lt(e){return this.fromWireType(I[e>>2])}function Rt(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function zt(e){this.rawDestructor&&this.rawDestructor(e)}function Bt(e){e!==null&&e.delete()}function Vt(){Ht.prototype.getPointee=Rt,Ht.prototype.destructor=zt,Ht.prototype.argPackAdvance=8,Ht.prototype.readValueFromPointer=Lt,Ht.prototype.deleteObject=Bt,Ht.prototype.fromWireType=St}function Ht(e,t,n,r,i,a,o,s,c,l,u){this.name=e,this.registeredClass=t,this.isReference=n,this.isConst=r,this.isSmartPointer=i,this.pointeeType=a,this.sharingPolicy=o,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=l,this.rawDestructor=u,!i&&t.baseClass===void 0?r?(this.toWireType=Pt,this.destructorFunction=null):(this.toWireType=It,this.destructorFunction=null):this.toWireType=Ft}function Ut(e,t,r){n.hasOwnProperty(e)||$e(`Replacing nonexistant public symbol`),n[e].overloadTable!==void 0&&r!==void 0?n[e].overloadTable[r]=t:(n[e]=t,n[e].argCount=r)}function Wt(e,t,r){T(`dynCall_`+e in n,`bad function pointer type - no table for sig '`+e+`'`),r&&r.length?T(r.length===e.substring(1).replace(/j/g,`--`).length):T(e.length==1);var i=n[`dynCall_`+e];return r&&r.length?i.apply(null,[t].concat(r)):i.call(null,t)}var Gt=[];function Kt(e){var t=Gt[e];return t||(e>=Gt.length&&(Gt.length=e+1),Gt[e]=t=ae.get(e)),T(ae.get(e)==t,`JavaScript-side Wasm function table mirror is out of date!`),t}function qt(e,t,n){return e.includes(`j`)?Wt(e,t,n):(T(Kt(t),`missing table entry in dynCall: `+t),Kt(t).apply(null,n))}function Jt(e,t){T(e.includes(`j`)||e.includes(`p`),`getDynCaller should only be called with i64 sigs`);var n=[];return function(){return n.length=0,Object.assign(n,arguments),qt(e,t,n)}}function Yt(e,t){e=We(e);function n(){return e.includes(`j`)?Jt(e,t):Kt(t)}var r=n();return typeof r!=`function`&&H(`unknown function pointer with signature `+e+`: `+t),r}var Xt=void 0;function Zt(e){var t=or(e),n=We(t);return ar(t),n}function Qt(e,t){var n=[],r={};function i(e){if(!r[e]&&!B[e]){if(Ke[e]){Ke[e].forEach(i);return}n.push(e),r[e]=!0}}throw t.forEach(i),new Xt(e+`: `+n.map(Zt).join([`, `]))}function $t(e,t,n,r,i,a,o,s,c,l,u,d,f){u=We(u),a=Yt(i,a),s&&=Yt(o,s),l&&=Yt(c,l),f=Yt(d,f);var p=Ye(u);jt(p,function(){Qt(`Cannot construct `+u+` due to unbound types`,[r])}),et([e,t,n],r?[r]:[],function(t){t=t[0];var n,i;r?(n=t.registeredClass,i=n.instancePrototype):i=kt.prototype;var o=V(p,function(){if(Object.getPrototypeOf(this)!==c)throw new Ze(`Use 'new' to construct `+u);if(d.constructor_body===void 0)throw new Ze(u+` has no accessible constructor`);var e=d.constructor_body[arguments.length];if(e===void 0)throw new Ze(`Tried to invoke ctor of `+u+` with invalid number of parameters (`+arguments.length+`) - expected (`+Object.keys(d.constructor_body).toString()+`) parameters instead!`);return e.apply(this,arguments)}),c=Object.create(i,{constructor:{value:o}});o.prototype=c;var d=new Mt(u,o,c,f,n,a,s,l),m=new Ht(u,d,!0,!1,!1),h=new Ht(u+`*`,d,!1,!1,!1),g=new Ht(u+` const*`,d,!1,!0,!1);return ut[e]={pointerType:h,constPointerType:g},Ut(p,o),[m,h,g]})}function en(e,t){for(var n=[],r=0;r<e;r++)n.push(L[t+r*4>>2]);return n}function tn(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function nn(e,t){if(!(e instanceof Function))throw TypeError(`new_ called with constructor type `+typeof e+` which is not a function`);var n=V(e.name||`unknownFunctionName`,function(){});n.prototype=e.prototype;var r=new n,i=e.apply(r,t);return i instanceof Object?i:r}function rn(e,t,n,r,i){var a=t.length;a<2&&H(`argTypes array size mismatch! Must at least get return value and 'this' types!`);for(var o=t[1]!==null&&n!==null,s=!1,c=1;c<t.length;++c)if(t[c]!==null&&t[c].destructorFunction===void 0){s=!0;break}for(var l=t[0].name!==`void`,u=``,d=``,c=0;c<a-2;++c)u+=(c===0?``:`, `)+`arg`+c,d+=(c===0?``:`, `)+`arg`+c+`Wired`;var f=`return function `+Ye(e)+`(`+u+`) {
|
||
if (arguments.length !== `+(a-2)+`) {
|
||
throwBindingError('function `+e+` called with ' + arguments.length + ' arguments, expected `+(a-2)+` args!');
|
||
}
|
||
`;s&&(f+=`var destructors = [];
|
||
`);var p=s?`destructors`:`null`,m=[`throwBindingError`,`invoker`,`fn`,`runDestructors`,`retType`,`classParam`],h=[H,r,i,tn,t[0],t[1]];o&&(f+=`var thisWired = classParam.toWireType(`+p+`, this);
|
||
`);for(var c=0;c<a-2;++c)f+=`var arg`+c+`Wired = argType`+c+`.toWireType(`+p+`, arg`+c+`); // `+t[c+2].name+`
|
||
`,m.push(`argType`+c),h.push(t[c+2]);if(o&&(d=`thisWired`+(d.length>0?`, `:``)+d),f+=(l?`var rv = `:``)+`invoker(fn`+(d.length>0?`, `:``)+d+`);
|
||
`,s)f+=`runDestructors(destructors);
|
||
`;else for(var c=o?1:2;c<t.length;++c){var g=c===1?`thisWired`:`arg`+(c-2)+`Wired`;t[c].destructorFunction!==null&&(f+=g+`_dtor(`+g+`); // `+t[c].name+`
|
||
`,m.push(g+`_dtor`),h.push(t[c].destructorFunction))}return l&&(f+=`var ret = retType.fromWireType(rv);
|
||
return ret;
|
||
`),f+=`}
|
||
`,m.push(f),nn(Function,m).apply(null,h)}function an(e,t,n,r,i,a){T(t>0);var o=en(t,n);i=Yt(r,i),et([],[e],function(e){e=e[0];var n=`constructor `+e.name;if(e.registeredClass.constructor_body===void 0&&(e.registeredClass.constructor_body=[]),e.registeredClass.constructor_body[t-1]!==void 0)throw new Ze(`Cannot register multiple constructors with identical number of parameters (`+(t-1)+`) for class '`+e.name+`'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{Qt(`Cannot construct `+e.name+` due to unbound types`,o)},et([],o,function(r){return r.splice(1,0,null),e.registeredClass.constructor_body[t-1]=rn(n,r,null,i,a),[]}),[]})}function on(e,t,n,r,i,a,o,s){var c=en(n,r);t=We(t),a=Yt(i,a),et([],[e],function(e){e=e[0];var r=e.name+`.`+t;t.startsWith(`@@`)&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);function i(){Qt(`Cannot call `+r+` due to unbound types`,c)}var l=e.registeredClass.instancePrototype,u=l[t];return u===void 0||u.overloadTable===void 0&&u.className!==e.name&&u.argCount===n-2?(i.argCount=n-2,i.className=e.name,l[t]=i):(At(l,t,r),l[t].overloadTable[n-2]=i),et([],c,function(i){var s=rn(r,i,e,a,o);return l[t].overloadTable===void 0?(s.argCount=n-2,l[t]=s):l[t].overloadTable[n-2]=s,[]}),[]})}var sn=[],cn=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function ln(e){e>4&&--cn[e].refcount===0&&(cn[e]=void 0,sn.push(e))}function un(){for(var e=0,t=5;t<cn.length;++t)cn[t]!==void 0&&++e;return e}function dn(){for(var e=5;e<cn.length;++e)if(cn[e]!==void 0)return cn[e];return null}function fn(){n.count_emval_handles=un,n.get_first_emval=dn}var pn={toValue:e=>(e||H(`Cannot use deleted val. handle = `+e),cn[e].value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=sn.length?sn.pop():cn.length;return cn[t]={refcount:1,value:e},t}}};function mn(e,t){t=We(t),tt(e,{name:t,fromWireType:function(e){var t=pn.toValue(e);return ln(e),t},toWireType:function(e,t){return pn.toHandle(t)},argPackAdvance:8,readValueFromPointer:Lt,destructorFunction:null})}function hn(e){if(e===null)return`null`;var t=typeof e;return t===`object`||t===`array`||t===`function`?e.toString():``+e}function gn(e,t){switch(t){case 2:return function(e){return this.fromWireType(te[e>>2])};case 3:return function(e){return this.fromWireType(ne[e>>3])};default:throw TypeError(`Unknown float type: `+e)}}function _n(e,t,n){var r=Ve(n);t=We(t),tt(e,{name:t,fromWireType:function(e){return e},toWireType:function(e,t){if(typeof t!=`number`&&typeof t!=`boolean`)throw TypeError(`Cannot convert "`+hn(t)+`" to `+this.name);return t},argPackAdvance:8,readValueFromPointer:gn(t,r),destructorFunction:null})}function vn(e,t,n){switch(t){case 0:return n?function(e){return N[e]}:function(e){return P[e]};case 1:return n?function(e){return F[e>>1]}:function(e){return ee[e>>1]};case 2:return n?function(e){return I[e>>2]}:function(e){return L[e>>2]};default:throw TypeError(`Unknown integer type: `+e)}}function yn(e,t,n,r,i){t=We(t),i===-1&&(i=4294967295);var a=Ve(n),o=e=>e;if(r===0){var s=32-8*n;o=e=>e<<s>>>s}var c=t.includes(`unsigned`),l=(e,n)=>{if(typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Cannot convert "`+hn(e)+`" to `+n);if(e<r||e>i)throw TypeError(`Passing a number "`+hn(e)+`" from JS side to C/C++ side to an argument of type "`+t+`", which is outside the valid range [`+r+`, `+i+`]!`)};tt(e,{name:t,fromWireType:o,toWireType:c?function(e,t){return l(t,this.name),t>>>0}:function(e,t){return l(t,this.name),t},argPackAdvance:8,readValueFromPointer:vn(t,a,r!==0),destructorFunction:null})}function bn(e,t,n){var r=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function i(e){e>>=2;var t=L,n=t[e],i=t[e+1];return new r(M,i,n)}n=We(n),tt(e,{name:n,fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{ignoreDuplicateRegistrations:!0})}function xn(e,t){t=We(t);var n=t===`std::string`;tt(e,{name:t,fromWireType:function(e){var t=L[e>>2],r=e+4,i;if(n)for(var a=r,o=0;o<=t;++o){var s=r+o;if(o==t||P[s]==0){var c=s-a,l=O(a,c);i===void 0?i=l:(i+=`\0`,i+=l),a=s+1}}else{for(var u=Array(t),o=0;o<t;++o)u[o]=String.fromCharCode(P[r+o]);i=u.join(``)}return ar(e),i},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r,i=typeof t==`string`;i||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||H(`Cannot pass non-string to std::string`),r=n&&i?j(t):t.length;var a=ir(4+r+1),o=a+4;if(L[a>>2]=r,n&&i)A(t,o,r+1);else if(i)for(var s=0;s<r;++s){var c=t.charCodeAt(s);c>255&&(ar(o),H(`String has UTF-16 code units that do not fit in 8 bits`)),P[o+s]=c}else for(var s=0;s<r;++s)P[o+s]=t[s];return e!==null&&e.push(ar,a),a},argPackAdvance:8,readValueFromPointer:Lt,destructorFunction:function(e){ar(e)}})}var Sn=typeof TextDecoder<`u`?new TextDecoder(`utf-16le`):void 0;function Cn(e,t){T(e%2==0,`Pointer passed to UTF16ToString must be aligned to two bytes!`);for(var n=e,r=n>>1,i=r+t/2;!(r>=i)&&ee[r];)++r;if(n=r<<1,n-e>32&&Sn)return Sn.decode(P.subarray(e,n));for(var a=``,o=0;!(o>=t/2);++o){var s=F[e+o*2>>1];if(s==0)break;a+=String.fromCharCode(s)}return a}function wn(e,t,n){if(T(t%2==0,`Pointer passed to stringToUTF16 must be aligned to two bytes!`),T(typeof n==`number`,`stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!`),n===void 0&&(n=2147483647),n<2)return 0;n-=2;for(var r=t,i=n<e.length*2?n/2:e.length,a=0;a<i;++a){var o=e.charCodeAt(a);F[t>>1]=o,t+=2}return F[t>>1]=0,t-r}function Tn(e){return e.length*2}function En(e,t){T(e%4==0,`Pointer passed to UTF32ToString must be aligned to four bytes!`);for(var n=0,r=``;!(n>=t/4);){var i=I[e+n*4>>2];if(i==0)break;if(++n,i>=65536){var a=i-65536;r+=String.fromCharCode(55296|a>>10,56320|a&1023)}else r+=String.fromCharCode(i)}return r}function Dn(e,t,n){if(T(t%4==0,`Pointer passed to stringToUTF32 must be aligned to four bytes!`),T(typeof n==`number`,`stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!`),n===void 0&&(n=2147483647),n<4)return 0;for(var r=t,i=r+n-4,a=0;a<e.length;++a){var o=e.charCodeAt(a);if(o>=55296&&o<=57343){var s=e.charCodeAt(++a);o=65536+((o&1023)<<10)|s&1023}if(I[t>>2]=o,t+=4,t+4>i)break}return I[t>>2]=0,t-r}function On(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r>=55296&&r<=57343&&++n,t+=4}return t}function kn(e,t,n){n=We(n);var r,i,a,o,s;t===2?(r=Cn,i=wn,o=Tn,a=()=>ee,s=1):t===4&&(r=En,i=Dn,o=On,a=()=>L,s=2),tt(e,{name:n,fromWireType:function(e){for(var n=L[e>>2],i=a(),o,c=e+4,l=0;l<=n;++l){var u=e+4+l*t;if(l==n||i[u>>s]==0){var d=u-c,f=r(c,d);o===void 0?o=f:(o+=`\0`,o+=f),c=u+t}}return ar(e),o},toWireType:function(e,r){typeof r!=`string`&&H(`Cannot pass non-string to C++ string type `+n);var a=o(r),c=ir(4+a+t);return L[c>>2]=a>>s,i(r,c+4,a+t),e!==null&&e.push(ar,c),c},argPackAdvance:8,readValueFromPointer:Lt,destructorFunction:function(e){ar(e)}})}function An(e,t){t=We(t),tt(e,{isVoid:!0,name:t,argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})}function jn(){we(`native code called abort()`)}function Mn(e,t,n){P.copyWithin(e,t,t+n)}function Nn(){return 2147483648}function Pn(e){try{return C.grow(e-M.byteLength+65535>>>16),R(C.buffer),1}catch(t){g(`emscripten_realloc_buffer: Attempted to grow heap from `+M.byteLength+` bytes to `+e+` bytes, but got error: `+t)}}function Fn(e){var t=P.length;e>>>=0,T(e>t);var n=Nn();if(e>n)return g(`Cannot enlarge memory, asked to go up to `+e+` bytes, but the limit is `+n+` bytes!`),!1;let r=(e,t)=>e+(t-e%t)%t;for(var i=1;i<=4;i*=2){var a=t*(1+.2/i);a=Math.min(a,e+100663296);var o=Math.min(n,r(Math.max(e,a),65536));if(Pn(o))return!0}return g(`Failed to grow the heap from `+t+` bytes to `+o+` bytes, not enough memory!`),!1}var In={};function Ln(){return s||`./this.program`}function Rn(){if(!Rn.strings){var e={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(typeof navigator==`object`&&navigator.languages&&navigator.languages[0]||`C`).replace(`-`,`_`)+`.UTF-8`,_:Ln()};for(var t in In)In[t]===void 0?delete e[t]:e[t]=In[t];var n=[];for(var t in e)n.push(t+`=`+e[t]);Rn.strings=n}return Rn.strings}function zn(e,t,n){for(var r=0;r<e.length;++r)T(e.charCodeAt(r)===(e.charCodeAt(r)&255)),N[t++>>0]=e.charCodeAt(r);n||(N[t>>0]=0)}var Bn={varargs:void 0,get:function(){return T(Bn.varargs!=null),Bn.varargs+=4,I[Bn.varargs-4>>2]},getStr:function(e){return O(e)}};function Vn(e,t){var n=0;return Rn().forEach(function(r,i){var a=t+n;L[e+i*4>>2]=a,zn(r,a),n+=r.length+1}),0}function Hn(e,t){var n=Rn();L[e>>2]=n.length;var r=0;return n.forEach(function(e){r+=e.length+1}),L[t>>2]=r,0}function Un(e){we(`fd_close called without SYSCALLS_REQUIRE_FILESYSTEM`)}function Wn(e,t,n,r,i){return 70}var Gn=[null,[],[]];function Kn(e,t){var n=Gn[e];T(n),t===0||t===10?((e===1?h:g)(D(n,0)),n.length=0):n.push(t)}function qn(e,t,n,r){for(var i=0,a=0;a<n;a++){var o=L[t>>2],s=L[t+4>>2];t+=8;for(var c=0;c<s;c++)Kn(e,P[o+c]);i+=s}return L[r>>2]=i,0}function Jn(e){return e%4==0&&(e%100!=0||e%400==0)}function Yn(e,t){for(var n=0,r=0;r<=t;n+=e[r++]);return n}var Xn=[31,29,31,30,31,30,31,31,30,31,30,31],Zn=[31,28,31,30,31,30,31,31,30,31,30,31];function Qn(e,t){for(var n=new Date(e.getTime());t>0;){var r=Jn(n.getFullYear()),i=n.getMonth(),a=(r?Xn:Zn)[i];if(t>a-n.getDate())t-=a-n.getDate()+1,n.setDate(1),i<11?n.setMonth(i+1):(n.setMonth(0),n.setFullYear(n.getFullYear()+1));else return n.setDate(n.getDate()+t),n}return n}function $n(e,t,n){var r=n>0?n:j(e)+1,i=Array(r),a=k(e,i,0,i.length);return t&&(i.length=a),i}function er(e,t,n,r){var i=I[r+40>>2],a={tm_sec:I[r>>2],tm_min:I[r+4>>2],tm_hour:I[r+8>>2],tm_mday:I[r+12>>2],tm_mon:I[r+16>>2],tm_year:I[r+20>>2],tm_wday:I[r+24>>2],tm_yday:I[r+28>>2],tm_isdst:I[r+32>>2],tm_gmtoff:I[r+36>>2],tm_zone:i?O(i):``},o=O(n),s={"%c":`%a %b %d %H:%M:%S %Y`,"%D":`%m/%d/%y`,"%F":`%Y-%m-%d`,"%h":`%b`,"%r":`%I:%M:%S %p`,"%R":`%H:%M`,"%T":`%H:%M:%S`,"%x":`%m/%d/%y`,"%X":`%H:%M:%S`,"%Ec":`%c`,"%EC":`%C`,"%Ex":`%m/%d/%y`,"%EX":`%H:%M:%S`,"%Ey":`%y`,"%EY":`%Y`,"%Od":`%d`,"%Oe":`%e`,"%OH":`%H`,"%OI":`%I`,"%Om":`%m`,"%OM":`%M`,"%OS":`%S`,"%Ou":`%u`,"%OU":`%U`,"%OV":`%V`,"%Ow":`%w`,"%OW":`%W`,"%Oy":`%y`};for(var c in s)o=o.replace(new RegExp(c,`g`),s[c]);var l=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],u=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function d(e,t,n){for(var r=typeof e==`number`?e.toString():e||``;r.length<t;)r=n[0]+r;return r}function f(e,t){return d(e,t,`0`)}function p(e,t){function n(e){return e<0?-1:+(e>0)}var r;return(r=n(e.getFullYear()-t.getFullYear()))===0&&(r=n(e.getMonth()-t.getMonth()))===0&&(r=n(e.getDate()-t.getDate())),r}function m(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function h(e){var t=Qn(new Date(e.tm_year+1900,0,1),e.tm_yday),n=new Date(t.getFullYear(),0,4),r=new Date(t.getFullYear()+1,0,4),i=m(n),a=m(r);return p(i,t)<=0?p(a,t)<=0?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var g={"%a":function(e){return l[e.tm_wday].substring(0,3)},"%A":function(e){return l[e.tm_wday]},"%b":function(e){return u[e.tm_mon].substring(0,3)},"%B":function(e){return u[e.tm_mon]},"%C":function(e){return f((e.tm_year+1900)/100|0,2)},"%d":function(e){return f(e.tm_mday,2)},"%e":function(e){return d(e.tm_mday,2,` `)},"%g":function(e){return h(e).toString().substring(2)},"%G":function(e){return h(e)},"%H":function(e){return f(e.tm_hour,2)},"%I":function(e){var t=e.tm_hour;return t==0?t=12:t>12&&(t-=12),f(t,2)},"%j":function(e){return f(e.tm_mday+Yn(Jn(e.tm_year+1900)?Xn:Zn,e.tm_mon-1),3)},"%m":function(e){return f(e.tm_mon+1,2)},"%M":function(e){return f(e.tm_min,2)},"%n":function(){return`
|
||
`},"%p":function(e){return e.tm_hour>=0&&e.tm_hour<12?`AM`:`PM`},"%S":function(e){return f(e.tm_sec,2)},"%t":function(){return` `},"%u":function(e){return e.tm_wday||7},"%U":function(e){var t=e.tm_yday+7-e.tm_wday;return f(Math.floor(t/7),2)},"%V":function(e){var t=Math.floor((e.tm_yday+7-(e.tm_wday+6)%7)/7);if((e.tm_wday+371-e.tm_yday-2)%7<=2&&t++,!t){t=52;var n=(e.tm_wday+7-e.tm_yday-1)%7;(n==4||n==5&&Jn(e.tm_year%400-1))&&t++}else if(t==53){var r=(e.tm_wday+371-e.tm_yday)%7;r!=4&&(r!=3||!Jn(e.tm_year))&&(t=1)}return f(t,2)},"%w":function(e){return e.tm_wday},"%W":function(e){var t=e.tm_yday+7-(e.tm_wday+6)%7;return f(Math.floor(t/7),2)},"%y":function(e){return(e.tm_year+1900).toString().substring(2)},"%Y":function(e){return e.tm_year+1900},"%z":function(e){var t=e.tm_gmtoff,n=t>=0;return t=Math.abs(t)/60,t=t/60*100+t%60,(n?`+`:`-`)+String(`0000`+t).slice(-4)},"%Z":function(e){return e.tm_zone},"%%":function(){return`%`}};for(var c in o=o.replace(/%%/g,`\0\0`),g)o.includes(c)&&(o=o.replace(new RegExp(c,`g`),g[c](a)));o=o.replace(/\0\0/g,`%`);var _=$n(o,!1);return _.length>t?0:(Fe(_,e),_.length-1)}function tr(e,t,n,r){return er(e,t,n,r)}He(),Ze=n.BindingError=Xe(Error,`BindingError`),Qe=n.InternalError=Xe(Error,`InternalError`),Ot(),_t(),Vt(),Xt=n.UnboundTypeError=Xe(Error,`UnboundTypeError`),fn();function nr(){v(`fetchSettings`)}var rr={__cxa_allocate_exception:Ie,__cxa_throw:ze,_embind_register_bigint:Be,_embind_register_bool:nt,_embind_register_class:$t,_embind_register_class_constructor:an,_embind_register_class_function:on,_embind_register_emval:mn,_embind_register_float:_n,_embind_register_integer:yn,_embind_register_memory_view:bn,_embind_register_std_string:xn,_embind_register_std_wstring:kn,_embind_register_void:An,abort:jn,emscripten_memcpy_big:Mn,emscripten_resize_heap:Fn,environ_get:Vn,environ_sizes_get:Hn,fd_close:Un,fd_seek:Wn,fd_write:qn,strftime_l:tr};Ne(),n.___wasm_call_ctors=ke(`__wasm_call_ctors`);var ir=n._malloc=ke(`malloc`),ar=n._free=ke(`free`),or=n.___getTypeName=ke(`__getTypeName`);n.__embind_initialize_bindings=ke(`_embind_initialize_bindings`),n.___errno_location=ke(`__errno_location`),n._fflush=ke(`fflush`);var sr=n._emscripten_stack_init=function(){return(sr=n._emscripten_stack_init=n.asm.emscripten_stack_init).apply(null,arguments)},cr=n._emscripten_stack_get_free=function(){return(cr=n._emscripten_stack_get_free=n.asm.emscripten_stack_get_free).apply(null,arguments)},lr=n._emscripten_stack_get_base=function(){return(lr=n._emscripten_stack_get_base=n.asm.emscripten_stack_get_base).apply(null,arguments)},ur=n._emscripten_stack_get_end=function(){return(ur=n._emscripten_stack_get_end=n.asm.emscripten_stack_get_end).apply(null,arguments)};n.stackSave=ke(`stackSave`),n.stackRestore=ke(`stackRestore`),n.stackAlloc=ke(`stackAlloc`);var dr=n.___cxa_is_pointer_type=ke(`__cxa_is_pointer_type`);n.dynCall_viijii=ke(`dynCall_viijii`),n.dynCall_ji=ke(`dynCall_ji`),n.dynCall_jiji=ke(`dynCall_jiji`),n.dynCall_iiiiij=ke(`dynCall_iiiiij`),n.dynCall_iiiiijj=ke(`dynCall_iiiiijj`),n.dynCall_iiiiiijj=ke(`dynCall_iiiiiijj`),`run.UTF8ArrayToString.UTF8ToString.stringToUTF8Array.stringToUTF8.lengthBytesUTF8.addOnPreRun.addOnInit.addOnPreMain.addOnExit.addOnPostRun.addRunDependency.removeRunDependency.FS_createFolder.FS_createPath.FS_createDataFile.FS_createPreloadedFile.FS_createLazyFile.FS_createLink.FS_createDevice.FS_unlink.getLEB.getFunctionTables.alignFunctionTables.registerFunctions.prettyPrint.getCompilerSetting.print.printErr.callMain.abort.keepRuntimeAlive.wasmMemory.stackAlloc.stackSave.stackRestore.getTempRet0.setTempRet0.writeStackCookie.checkStackCookie.ptrToString.zeroMemory.stringToNewUTF8.exitJS.getHeapMax.emscripten_realloc_buffer.ENV.ERRNO_CODES.ERRNO_MESSAGES.setErrNo.inetPton4.inetNtop4.inetPton6.inetNtop6.readSockaddr.writeSockaddr.DNS.getHostByName.Protocols.Sockets.getRandomDevice.warnOnce.traverseStack.UNWIND_CACHE.convertPCtoSourceLocation.readAsmConstArgsArray.readAsmConstArgs.mainThreadEM_ASM.jstoi_q.jstoi_s.getExecutableName.listenOnce.autoResumeAudioContext.dynCallLegacy.getDynCaller.dynCall.handleException.runtimeKeepalivePush.runtimeKeepalivePop.callUserCallback.maybeExit.safeSetTimeout.asmjsMangle.asyncLoad.alignMemory.mmapAlloc.writeI53ToI64.writeI53ToI64Clamped.writeI53ToI64Signaling.writeI53ToU64Clamped.writeI53ToU64Signaling.readI53FromI64.readI53FromU64.convertI32PairToI53.convertI32PairToI53Checked.convertU32PairToI53.getCFunc.ccall.cwrap.uleb128Encode.sigToWasmTypes.convertJsFunctionToWasm.freeTableIndexes.functionsInTableMap.getEmptyTableSlot.updateTableMap.addFunction.removeFunction.reallyNegative.unSign.strLen.reSign.formatString.setValue.getValue.PATH.PATH_FS.intArrayFromString.intArrayToString.AsciiToString.stringToAscii.UTF16Decoder.UTF16ToString.stringToUTF16.lengthBytesUTF16.UTF32ToString.stringToUTF32.lengthBytesUTF32.allocateUTF8.allocateUTF8OnStack.writeStringToMemory.writeArrayToMemory.writeAsciiToMemory.SYSCALLS.getSocketFromFD.getSocketAddress.JSEvents.registerKeyEventCallback.specialHTMLTargets.maybeCStringToJsString.findEventTarget.findCanvasEventTarget.getBoundingClientRect.fillMouseEventData.registerMouseEventCallback.registerWheelEventCallback.registerUiEventCallback.registerFocusEventCallback.fillDeviceOrientationEventData.registerDeviceOrientationEventCallback.fillDeviceMotionEventData.registerDeviceMotionEventCallback.screenOrientation.fillOrientationChangeEventData.registerOrientationChangeEventCallback.fillFullscreenChangeEventData.registerFullscreenChangeEventCallback.JSEvents_requestFullscreen.JSEvents_resizeCanvasForFullscreen.registerRestoreOldStyle.hideEverythingExceptGivenElement.restoreHiddenElements.setLetterbox.currentFullscreenStrategy.restoreOldWindowedStyle.softFullscreenResizeWebGLRenderTarget.doRequestFullscreen.fillPointerlockChangeEventData.registerPointerlockChangeEventCallback.registerPointerlockErrorEventCallback.requestPointerLock.fillVisibilityChangeEventData.registerVisibilityChangeEventCallback.registerTouchEventCallback.fillGamepadEventData.registerGamepadEventCallback.registerBeforeUnloadEventCallback.fillBatteryEventData.battery.registerBatteryEventCallback.setCanvasElementSize.getCanvasElementSize.demangle.demangleAll.jsStackTrace.stackTrace.ExitStatus.getEnvStrings.checkWasiClock.flush_NO_FILESYSTEM.dlopenMissingError.setImmediateWrapped.clearImmediateWrapped.polyfillSetImmediate.uncaughtExceptionCount.exceptionLast.exceptionCaught.ExceptionInfo.exception_addRef.exception_decRef.Browser.setMainLoop.wget.FS.MEMFS.TTY.PIPEFS.SOCKFS._setNetworkCallback.tempFixedLengthArray.miniTempWebGLFloatBuffers.heapObjectForWebGLType.heapAccessShiftForWebGLHeap.GL.emscriptenWebGLGet.computeUnpackAlignedImageSize.emscriptenWebGLGetTexPixelData.emscriptenWebGLGetUniform.webglGetUniformLocation.webglPrepareUniformLocationsBeforeFirstUse.webglGetLeftBracePos.emscriptenWebGLGetVertexAttrib.writeGLArray.AL.SDL_unicode.SDL_ttfContext.SDL_audio.SDL.SDL_gfx.GLUT.EGL.GLFW_Window.GLFW.GLEW.IDBStore.runAndAbortIfError.ALLOC_NORMAL.ALLOC_STACK.allocate.InternalError.BindingError.UnboundTypeError.PureVirtualError.init_embind.throwInternalError.throwBindingError.throwUnboundTypeError.ensureOverloadTable.exposePublicSymbol.replacePublicSymbol.extendError.createNamedFunction.embindRepr.registeredInstances.getBasestPointer.registerInheritedInstance.unregisterInheritedInstance.getInheritedInstance.getInheritedInstanceCount.getLiveInheritedInstances.registeredTypes.awaitingDependencies.typeDependencies.registeredPointers.registerType.whenDependentTypesAreResolved.embind_charCodes.embind_init_charCodes.readLatin1String.getTypeName.heap32VectorToArray.requireRegisteredType.getShiftFromSize.integerReadValueFromPointer.enumReadValueFromPointer.floatReadValueFromPointer.simpleReadValueFromPointer.runDestructors.new_.craftInvokerFunction.embind__requireFunction.tupleRegistrations.structRegistrations.genericPointerToWireType.constNoSmartPtrRawPointerToWireType.nonConstNoSmartPtrRawPointerToWireType.init_RegisteredPointer.RegisteredPointer.RegisteredPointer_getPointee.RegisteredPointer_destructor.RegisteredPointer_deleteObject.RegisteredPointer_fromWireType.runDestructor.releaseClassHandle.finalizationRegistry.detachFinalizer_deps.detachFinalizer.attachFinalizer.makeClassHandle.init_ClassHandle.ClassHandle.ClassHandle_isAliasOf.throwInstanceAlreadyDeleted.ClassHandle_clone.ClassHandle_delete.deletionQueue.ClassHandle_isDeleted.ClassHandle_deleteLater.flushPendingDeletes.delayFunction.setDelayFunction.RegisteredClass.shallowCopyInternalPointer.downcastPointer.upcastPointer.validateThis.char_0.char_9.makeLegalFunctionName.emval_handle_array.emval_free_list.emval_symbols.init_emval.count_emval_handles.get_first_emval.getStringOrSymbol.Emval.emval_newers.craftEmvalAllocator.emval_get_global.emval_lookupTypes.emval_allocateDestructors.emval_methodCallers.emval_addMethodCaller.emval_registeredMethods`.split(`.`).forEach(x),`ptrToString.zeroMemory.stringToNewUTF8.exitJS.setErrNo.inetPton4.inetNtop4.inetPton6.inetNtop6.readSockaddr.writeSockaddr.getHostByName.getRandomDevice.traverseStack.convertPCtoSourceLocation.readAsmConstArgs.mainThreadEM_ASM.jstoi_q.jstoi_s.listenOnce.autoResumeAudioContext.runtimeKeepalivePush.runtimeKeepalivePop.callUserCallback.maybeExit.safeSetTimeout.asmjsMangle.asyncLoad.alignMemory.mmapAlloc.writeI53ToI64.writeI53ToI64Clamped.writeI53ToI64Signaling.writeI53ToU64Clamped.writeI53ToU64Signaling.readI53FromI64.readI53FromU64.convertI32PairToI53.convertU32PairToI53.reallyNegative.unSign.strLen.reSign.formatString.getSocketFromFD.getSocketAddress.registerKeyEventCallback.maybeCStringToJsString.findEventTarget.findCanvasEventTarget.getBoundingClientRect.fillMouseEventData.registerMouseEventCallback.registerWheelEventCallback.registerUiEventCallback.registerFocusEventCallback.fillDeviceOrientationEventData.registerDeviceOrientationEventCallback.fillDeviceMotionEventData.registerDeviceMotionEventCallback.screenOrientation.fillOrientationChangeEventData.registerOrientationChangeEventCallback.fillFullscreenChangeEventData.registerFullscreenChangeEventCallback.JSEvents_requestFullscreen.JSEvents_resizeCanvasForFullscreen.registerRestoreOldStyle.hideEverythingExceptGivenElement.restoreHiddenElements.setLetterbox.softFullscreenResizeWebGLRenderTarget.doRequestFullscreen.fillPointerlockChangeEventData.registerPointerlockChangeEventCallback.registerPointerlockErrorEventCallback.requestPointerLock.fillVisibilityChangeEventData.registerVisibilityChangeEventCallback.registerTouchEventCallback.fillGamepadEventData.registerGamepadEventCallback.registerBeforeUnloadEventCallback.fillBatteryEventData.battery.registerBatteryEventCallback.setCanvasElementSize.getCanvasElementSize.checkWasiClock.setImmediateWrapped.clearImmediateWrapped.polyfillSetImmediate.exception_addRef.exception_decRef.setMainLoop._setNetworkCallback.heapObjectForWebGLType.heapAccessShiftForWebGLHeap.emscriptenWebGLGet.computeUnpackAlignedImageSize.emscriptenWebGLGetTexPixelData.emscriptenWebGLGetUniform.webglGetUniformLocation.webglPrepareUniformLocationsBeforeFirstUse.webglGetLeftBracePos.emscriptenWebGLGetVertexAttrib.writeGLArray.SDL_unicode.SDL_ttfContext.SDL_audio.GLFW_Window.runAndAbortIfError.registerInheritedInstance.unregisterInheritedInstance.requireRegisteredType.enumReadValueFromPointer.validateThis.getStringOrSymbol.craftEmvalAllocator.emval_get_global.emval_lookupTypes.emval_allocateDestructors.emval_addMethodCaller`.split(`.`).forEach(b);var fr;be=function e(){fr||mr(),fr||(be=e)};function pr(){sr(),oe()}function mr(e){if(e||=o,ve>0||(pr(),fe(),ve>0))return;function t(){fr||(fr=!0,n.calledRun=!0,!w&&(pe(),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),T(!n._main,`compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]`),me()))}n.setStatus?(n.setStatus(`Running...`),setTimeout(function(){setTimeout(function(){n.setStatus(``)},1),t()},1)):t(),se()}if(n.preInit)for(typeof n.preInit==`function`&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return mr(),t.ready})})();typeof e==`object`&&typeof t==`object`?t.exports=n:typeof define==`function`&&define.amd?define([],function(){return n}):typeof e==`object`&&(e.createLazPerf=n)})),m6=W3((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.LazPerf=e.create=e.createLazPerf=void 0;var n=t(p6());e.createLazPerf=n.default,e.create=n.default,e.LazPerf={create:n.default}})),h6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decompressFile=e.decompressChunk=e.PointData=void 0;var t=m6(),n=f6();e.PointData={createLazPerf:t.createLazPerf,decompressChunk:a,decompressFile:o};var r=void 0;async function i(e){return e||(r||=(0,t.createLazPerf)(),r)}async function a(e,{pointCount:t,pointDataRecordFormat:n,pointDataRecordLength:r},a){let o=await i(a),s=new Uint8Array(t*r),c=o._malloc(e.byteLength),l=o._malloc(r),u=new o.ChunkDecoder;try{o.HEAPU8.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),c),u.open(n,r,c);for(let e=0;e<t;++e)u.getPoint(l),s.set(new Uint8Array(o.HEAPU8.buffer,l,r),e*r)}finally{o._free(c),o._free(l),u.delete()}return s}e.decompressChunk=a;async function o(e,t){let r=await i(t),{pointCount:a,pointDataRecordLength:o}=n.Header.parse(e),s=new Uint8Array(a*o),c=r._malloc(e.byteLength),l=r._malloc(o),u=new r.LASZip;try{r.HEAPU8.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),c),u.open(c,e.byteLength);for(let e=0;e<a;++e)u.getPoint(l),s.set(new Uint8Array(r.HEAPU8.buffer,l,o),e*o)}finally{u.delete()}return s}e.decompressFile=o})),g6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.View=void 0;var t=s6(),n=l6(),r=u6();e.View={create:i};function i(e,i,a=[],o){let s=r.Extractor.create(i,a);if(o){let e=new Set([...o]);s=Object.entries(s).reduce((t,[n,r])=>(e.has(n)&&(t[n]=r),t),{})}let c=n.Dimensions.create(s,a),l=t.Binary.toDataView(e),u=i.pointDataRecordLength;if(l.byteLength%u!==0)throw Error(`Invalid buffer length (${l.byteLength}) for point length ${u}`);let d=l.byteLength/i.pointDataRecordLength;function f(e){let t=s[e];if(!t)throw Error(`No extractor for dimension: ${e}`);return function(e){if(e>=d)throw RangeError(`View index (${e}) out of range: ${d}`);return t(l,e)}}return{pointCount:d,dimensions:c,getter:f}}})),_6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Vlr=void 0;var t=s6(),n=Z3();e.Vlr={walk:o,parse:s,find:r,at:i,fetch:a};function r(e,t,n){return e.find(e=>e.userId===t&&e.recordId===n)}function i(e,t,n){let i=r(e,t,n);if(!i)throw Error(`VLR not found: ${t}/${n}`);return i}function a(e,{contentOffset:n,contentLength:r}){return r===0?new Uint8Array:t.Getter.create(e)(n,n+r)}async function o(e,n){let r=t.Getter.create(e),i=await u({get:r,startOffset:n.headerLength,count:n.vlrCount,isExtended:!1}),a=await u({get:r,startOffset:n.evlrOffset,count:n.evlrCount,isExtended:!0});return[...i,...a]}function s(e,t){return(t?l:c)(e)}function c(e){let r=t.Binary.toDataView(e);if(r.byteLength!==n.vlrHeaderLength)throw Error(`Invalid VLR header length (must be ${n.vlrHeaderLength}): ${r.byteLength}`);return{userId:t.Binary.toCString(e.slice(2,18)),recordId:r.getUint16(18,!0),contentLength:r.getUint16(20,!0),description:t.Binary.toCString(e.slice(22,54)),isExtended:!1}}function l(e){let r=t.Binary.toDataView(e);if(r.byteLength!==n.evlrHeaderLength)throw Error(`Invalid EVLR header length (must be ${n.evlrHeaderLength}): ${r.byteLength}`);return{userId:t.Binary.toCString(e.slice(2,18)),recordId:r.getUint16(18,!0),contentLength:(0,t.parseBigInt)((0,t.getBigUint64)(r,20,!0)),description:t.Binary.toCString(e.slice(28,60)),isExtended:!0}}async function u({get:e,startOffset:t,count:r,isExtended:i}){let a=[],o=t,c=i?n.evlrHeaderLength:n.vlrHeaderLength;for(let t=0;t<r;++t){let{userId:t,recordId:n,contentLength:r,description:l}=s(c?await e(o,o+c):new Uint8Array,i);a.push({userId:t,recordId:n,contentOffset:o+c,contentLength:r,description:l,isExtended:i}),o+=c+r}return a}})),v6=W3((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Vlr=e.View=e.PointData=e.Header=e.Extractor=e.ExtraBytes=e.Dimensions=e.Constants=void 0,e.Constants=r(Z3());var i=l6();Object.defineProperty(e,"Dimensions",{enumerable:!0,get:function(){return i.Dimensions}});var a=c6();Object.defineProperty(e,"ExtraBytes",{enumerable:!0,get:function(){return a.ExtraBytes}});var o=u6();Object.defineProperty(e,"Extractor",{enumerable:!0,get:function(){return o.Extractor}});var s=f6();Object.defineProperty(e,"Header",{enumerable:!0,get:function(){return s.Header}});var c=h6();Object.defineProperty(e,"PointData",{enumerable:!0,get:function(){return c.PointData}});var l=g6();Object.defineProperty(e,"View",{enumerable:!0,get:function(){return l.View}});var u=_6();Object.defineProperty(e,"Vlr",{enumerable:!0,get:function(){return u.Vlr}})})),y6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Hierarchy=void 0;var t=s6(),n=X3();e.Hierarchy={parse:r,load:i};function r(e){let r=t.Binary.toDataView(e);if(r.byteLength%n.hierarchyItemLength!==0)throw Error(`Invalid hierarchy page length: ${r.byteLength}`);let i={},a={};for(let e=0;e<r.byteLength;e+=n.hierarchyItemLength){let n=r.getInt32(e+0,!0),o=r.getInt32(e+4,!0),s=r.getInt32(e+8,!0),c=r.getInt32(e+12,!0),l=(0,t.parseBigInt)((0,t.getBigUint64)(r,e+16,!0)),u=r.getInt32(e+24,!0),d=r.getInt32(e+28,!0),f=t.Key.toString([n,o,s,c]);if(d<-1)throw Error(`Invalid hierarchy point count at key: ${f}`);d===-1?a[f]={pageOffset:l,pageLength:u}:i[f]={pointCount:d,pointDataOffset:l,pointDataLength:u}}return{nodes:i,pages:a}}async function i(e,n){return r(await t.Getter.create(e)(n.pageOffset,n.pageOffset+n.pageLength))}})),b6=W3((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Info=void 0;var t=s6(),n=X3();e.Info={parse:r};function r(e){let r=t.Binary.toDataView(e);if(r.byteLength!==n.infoLength)throw Error(`Invalid COPC info VLR length (should be ${n.infoLength}): ${r.byteLength}`);let i=[r.getFloat64(0,!0),r.getFloat64(8,!0),r.getFloat64(16,!0)],a=r.getFloat64(24,!0);return{cube:[i[0]-a,i[1]-a,i[2]-a,i[0]+a,i[1]+a,i[2]+a],spacing:r.getFloat64(32,!0),rootHierarchyPage:{pageOffset:(0,t.parseBigInt)((0,t.getBigUint64)(r,40,!0)),pageLength:(0,t.parseBigInt)((0,t.getBigUint64)(r,48,!0))},gpsTimeRange:[r.getFloat64(56,!0),r.getFloat64(64,!0)]}}})),x6=W3((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Copc=void 0;var i=r(v6()),a=s6(),o=y6(),s=b6();e.Copc={create:c,loadHierarchyPage:l,loadCompressedPointDataBuffer:u,loadPointDataBuffer:d,loadPointDataView:f};async function c(e){let t=a.Getter.create(e),n=65536,r=t(0,n);async function o(e,i){return i>=n?t(e,i):(await r).slice(e,i)}let c=i.Header.parse(await o(0,i.Constants.minHeaderLength)),l=await i.Vlr.walk(o,c),u=i.Vlr.find(l,`copc`,1);if(!u)throw Error(`COPC info VLR is required`);let d=s.Info.parse(await i.Vlr.fetch(o,u)),f,p=i.Vlr.find(l,`LASF_Projection`,2112);p&&p.contentLength&&(f=a.Binary.toCString(await i.Vlr.fetch(o,p)),f===``&&(f=void 0));let m=[],h=i.Vlr.find(l,`LASF_Spec`,4);return h&&(m=i.ExtraBytes.parse(await i.Vlr.fetch(o,h))),{header:c,vlrs:l,info:d,wkt:f,eb:m}}async function l(e,t){let n=a.Getter.create(e);return o.Hierarchy.load(n,t)}async function u(e,{pointDataOffset:t,pointDataLength:n}){return a.Getter.create(e)(t,t+n)}async function d(e,{pointDataRecordFormat:t,pointDataRecordLength:n},r,a){let o=await u(e,r),{pointCount:s}=r;return i.PointData.decompressChunk(o,{pointCount:s,pointDataRecordFormat:t,pointDataRecordLength:n},a)}async function f(e,t,n,{lazPerf:r,include:a}={}){let o=await d(e,t.header,n,r);return i.View.create(o,t.header,t.eb,a)}})),S6=W3((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Info=e.Hierarchy=e.Copc=e.Constants=void 0,e.Constants=r(X3());var i=x6();Object.defineProperty(e,"Copc",{enumerable:!0,get:function(){return i.Copc}});var a=y6();Object.defineProperty(e,"Hierarchy",{enumerable:!0,get:function(){return a.Hierarchy}});var o=b6();Object.defineProperty(e,"Info",{enumerable:!0,get:function(){return o.Info}})})),C6=W3((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.Las=e.Ept=void 0,e.Ept=r(Y3()),i(S6(),e),e.Las=r(v6()),i(s6(),e)})),w6={self:typeof self<`u`&&self,window:typeof window<`u`&&window,global:typeof global<`u`&&global,document:typeof document<`u`&&document},w6.self||w6.window||w6.global,w6.window||w6.self||w6.global,w6.global||w6.self||w6.window,w6.document,T6=!!(typeof process!=`object`||String(process)!==`[object process]`||process.browser),E6=typeof process<`u`&&process.version&&/v([0-9]*)/.exec(process.version),E6&&parseFloat(E6[1]),D6=globalThis,globalThis.document,O6=globalThis.process||{},globalThis.console,globalThis.navigator,k6=`4.1.1`,A6=()=>{},j6=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log(`warn`,0,e,t,{once:!0})}error(e,...t){return this._log(`error`,0,e,t)}log(e,t,...n){return this._log(`log`,e,t,n)}info(e,t,...n){return this._log(`info`,e,t,n)}once(e,t,...n){return this._log(`once`,e,t,n,{once:!0})}_log(e,t,n,r,i={}){let a=OZ({logLevel:t,message:n,args:this._buildArgs(t,n,r),opts:i});return this._createLogFunction(e,a,i)}_buildArgs(e,t,n){return[e,t,...n]}_createLogFunction(e,t,n){if(!this._shouldLog(t.logLevel))return A6;let r=this._getOnceTag(n.tag??t.tag??t.message);if((n.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return A6;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=DZ(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e==`string`?e:String(e)}catch{return}}},M6=class{constructor(e,t,n=`sessionStorage`){this.storage=kZ(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}},(function(e){e[e.BLACK=30]=`BLACK`,e[e.RED=31]=`RED`,e[e.GREEN=32]=`GREEN`,e[e.YELLOW=33]=`YELLOW`,e[e.BLUE=34]=`BLUE`,e[e.MAGENTA=35]=`MAGENTA`,e[e.CYAN=36]=`CYAN`,e[e.WHITE=37]=`WHITE`,e[e.BRIGHT_BLACK=90]=`BRIGHT_BLACK`,e[e.BRIGHT_RED=91]=`BRIGHT_RED`,e[e.BRIGHT_GREEN=92]=`BRIGHT_GREEN`,e[e.BRIGHT_YELLOW=93]=`BRIGHT_YELLOW`,e[e.BRIGHT_BLUE=94]=`BRIGHT_BLUE`,e[e.BRIGHT_MAGENTA=95]=`BRIGHT_MAGENTA`,e[e.BRIGHT_CYAN=96]=`BRIGHT_CYAN`,e[e.BRIGHT_WHITE=97]=`BRIGHT_WHITE`})(N6||={}),P6=10,F6={debug:TZ()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},I6={enabled:!0,level:0},L6=class extends j6{constructor({id:e}={id:``}){super({level:0}),this.VERSION=k6,this._startTs=FZ(),this._deltaTs=FZ(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new M6(`__probe-${this.id}__`,{[this.id]:I6}),this.timeStamp(`${this.id} started`),PZ(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((FZ()-this._startTs).toPrecision(10))}getDelta(){return Number((FZ()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw Error(t||`Assertion failed`)}warn(e,...t){return this._log(`warn`,0,e,t,{method:F6.warn,once:!0})}error(e,...t){return this._log(`error`,0,e,t,{method:F6.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed \
|
||
in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...n){return this._log(`log`,e,t,n,{method:F6.log,time:!0,once:!0})}log(e,t,...n){return this._log(`log`,e,t,n,{method:F6.debug})}info(e,t,...n){return this._log(`info`,e,t,n,{method:console.info})}once(e,t,...n){return this._log(`once`,e,t,n,{method:F6.debug||F6.info,once:!0})}table(e,t,n){return t?this._log(`table`,e,t,n&&[n]||[],{method:console.table||A6,tag:LZ(t)}):A6}time(e,t){return this._log(`time`,e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log(`time`,e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log(`time`,e,t,[],{method:console.timeStamp||A6})}group(e,t,n={collapsed:!1}){let r=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log(`group`,e,t,[],{method:r})}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log(`groupEnd`,e,``,[],{method:console.groupEnd||A6})}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let n=t.method;EZ(n),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=FZ();let r=IZ(this.id,t.message,t);return n.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(I6),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...I6};this._storage.setConfiguration({[this.id]:{...t,...e}})}},L6.VERSION=k6,R6=`v4.4.2`,z6=RZ(),B6=e=>typeof e==`boolean`,V6=e=>typeof e==`function`,H6=e=>typeof e==`object`&&!!e,U6=e=>H6(e)&&e.constructor==={}.constructor,W6=e=>typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,G6=e=>H6(e)&&typeof e.byteLength==`number`&&typeof e.slice==`function`,K6=e=>!!e&&V6(e[Symbol.iterator]),q6=e=>!!e&&V6(e[Symbol.asyncIterator]),J6=e=>typeof Response<`u`&&e instanceof Response||H6(e)&&V6(e.arrayBuffer)&&V6(e.text)&&V6(e.json),Y6=e=>typeof Blob<`u`&&e instanceof Blob,X6=e=>typeof ReadableStream<`u`&&e instanceof ReadableStream||H6(e)&&V6(e.tee)&&V6(e.cancel)&&V6(e.getReader),Z6=e=>H6(e)&&V6(e.read)&&V6(e.pipe)&&B6(e.readable),Q6=e=>X6(e)||Z6(e),$6=`latest`,e8=VZ(),t8={self:typeof self<`u`&&self,window:typeof window<`u`&&window,global:typeof global<`u`&&global,document:typeof document<`u`&&document},t8.self||t8.window||t8.global,t8.window||t8.self||t8.global,t8.global||t8.self||t8.window,t8.document,n8=typeof process!=`object`||String(process)!==`[object process]`||process.browser,r8=typeof window<`u`&&window.orientation!==void 0,i8=typeof process<`u`&&process.version&&/v([0-9]*)/.exec(process.version),i8&&parseFloat(i8[1]),a8=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:`loaders.gl`,type:e,payload:t})}done(e){HZ(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){HZ(this.isRunning),this.isRunning=!1,this._reject(e)}},o8=class{terminate(){}},s8=new Map,c8=()=>{},l8=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL=``;static isSupported(){return typeof Worker<`u`&&n8||o8!==void 0&&!n8}constructor(e){let{name:t,source:n,url:r}=e;HZ(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=c8,this.onError=e=>console.log(e),this.worker=n8?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=c8,this.onError=c8,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t||=qZ(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t=`Failed to load `;return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),Error(t)}_createBrowserWorker(){this._loadableURL=UZ({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(Error(`No data received`))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url)e=new o8(this.url.includes(`:/`)||this.url.startsWith(`/`)?this.url:`./${this.url}`,{eval:!1,type:this.url.endsWith(`.ts`)||this.url.endsWith(`.mjs`)?`module`:`commonjs`});else if(this.source)e=new o8(this.source,{eval:!0});else throw Error(`no worker`);return e.on(`message`,e=>{this.onMessage(e)}),e.on(`error`,e=>{this.onError(e)}),e.on(`exit`,e=>{}),e}},u8=class{name=`unnamed`;source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return l8.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){let r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:`Starting job`,name:t.name,workerThread:e,backlog:this.jobQueue.length});let n=new a8(t.name,e);e.onMessage=e=>t.onMessage(n,e.type,e.payload),e.onError=e=>t.onError(n,e),t.onStart(n);try{await n.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!n8||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){return this.idleQueue.length>0?this.idleQueue.shift()||null:this.count<this._getMaxConcurrency()?(this.count++,new l8({name:`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`,source:this.source,url:this.url})):null}_getMaxConcurrency(){return r8?this.maxMobileConcurrency:this.maxConcurrency}},d8={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},f8=class e{props;workerPools=new Map;static _workerFarm;static isSupported(){return l8.isSupported()}static getWorkerFarm(t={}){return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}constructor(e){this.props={...d8},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:n,url:r}=e,i=this.workerPools.get(t);return i||(i=new u8({name:t,source:n,url:r}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},p8=``,m8={},h8=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response},g8=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,_8=/^([-\w.]+\/[-\w.+]+)/,v8=/\?.*/,y8=new L6({id:`loaders.gl`}),b8=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},x8=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},S8={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new x8,useLocalLibraries:!1,CDN:`https://unpkg.com/@loaders.gl`,worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:T6,_nodeWorkers:!1,_workerType:``,limit:0,_limitMB:0,batchSize:`auto`,batchDebounceMs:0,metadata:!1,transforms:[]}},C8={baseUri:`core.baseUrl`,fetch:`core.fetch`,mimeType:`core.mimeType`,fallbackMimeType:`core.fallbackMimeType`,ignoreRegisteredLoaders:`core.ignoreRegisteredLoaders`,nothrow:`core.nothrow`,log:`core.log`,useLocalLibraries:`core.useLocalLibraries`,CDN:`core.CDN`,worker:`core.worker`,maxConcurrency:`core.maxConcurrency`,maxMobileConcurrency:`core.maxMobileConcurrency`,reuseWorkers:`core.reuseWorkers`,_nodeWorkers:`core.nodeWorkers`,_workerType:`core._workerType`,_worker:`core._workerType`,limit:`core.limit`,_limitMB:`core._limitMB`,batchSize:`core.batchSize`,batchDebounceMs:`core.batchDebounceMs`,metadata:`core.metadata`,transforms:`core.transforms`,throws:`nothrow`,dataType:`(no longer used)`,uri:`core.baseUrl`,method:`core.fetch.method`,headers:`core.fetch.headers`,body:`core.fetch.body`,mode:`core.fetch.mode`,credentials:`core.fetch.credentials`,cache:`core.fetch.cache`,redirect:`core.fetch.redirect`,referrer:`core.fetch.referrer`,referrerPolicy:`core.fetch.referrerPolicy`,integrity:`core.fetch.integrity`,keepalive:`core.fetch.keepalive`,signal:`core.fetch.signal`},w8=[`baseUrl`,`fetch`,`mimeType`,`fallbackMimeType`,`ignoreRegisteredLoaders`,`nothrow`,`log`,`useLocalLibraries`,`CDN`,`worker`,`maxConcurrency`,`maxMobileConcurrency`,`reuseWorkers`,`_nodeWorkers`,`_workerType`,`limit`,`_limitMB`,`batchSize`,`batchDebounceMs`,`metadata`,`transforms`],T8=()=>{let e=NQ();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry},E8=/\.([^.]+)$/,D8=256*1024,O8=256*1024,k8=1024*1024,A8=`Cannot convert supplied data type`,j8={name:`LAS`,id:`las`,module:`las`,extensions:[`las`,`laz`],mimeTypes:[`application/octet-stream`],text:!1,binary:!0,tests:[`LASF`]},M8=`4.4.2`,N8={...j8,dataType:null,batchType:null,version:M8,worker:!0,options:{las:{shape:`mesh`,fp64:!1,skip:1,colorDepth:8}}},P8=null,F8={0:e=>({position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(15)}),1:e=>({position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(15)}),2:e=>({position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(15),color:[e.getUint16(20,!0),e.getUint16(22,!0),e.getUint16(24,!0)]}),3:e=>({position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(15),color:[e.getUint16(28,!0),e.getUint16(30,!0),e.getUint16(32,!0)]})},I8=class{arraybuffer;readOffset=0;header={pointsOffset:0,pointsFormatId:0,pointsStructSize:0,pointsCount:0,scale:[0,0,0],offset:[0,0,0],maxs:[0],mins:[0],totalToRead:0,totalRead:0,versionAsString:``,isCompressed:!0,hasColor:!1};constructor(e){this.arraybuffer=e}open(){return!0}getHeader(){return this.header=I$(this.arraybuffer),this.header}readData(e,t){let{header:n,arraybuffer:r}=this;if(!n)throw Error(`Cannot start reading data till a header request is issued`);let{readOffset:i}=this,a;if(t<=1){e=Math.min(e,n.pointsCount-i),a=n.pointsOffset+i*n.pointsStructSize;let t=a+e*n.pointsStructSize;return i+=e,this.readOffset=i,{buffer:r.slice(a,t),count:e,hasMoreData:i<n.pointsCount}}let o=Math.min(e*t,n.pointsCount-i),s=Math.ceil(o/t),c=0,l=new Uint8Array(s*n.pointsStructSize);for(let e=0;e<o;e++){if(e%t===0){a=n.pointsOffset+i*n.pointsStructSize;let e=new Uint8Array(r,a,n.pointsStructSize);l.set(e,c*n.pointsStructSize),c++}i++}return this.readOffset=i,{buffer:l.buffer,count:c,hasMoreData:i<n.pointsCount}}close(){return this.arraybuffer=null,!0}},L8=class{arraybuffer;instance=null;header=null;constructor(e){this.arraybuffer=e,P8||=P$()}open(){try{let{arraybuffer:e}=this;this.instance=new P8.LASZip;let t=new Uint8Array(e),n=P8._malloc(e.byteLength);return this.instance.arraybuffer=e,this.instance.buf=n,P8.HEAPU8.set(t,n),this.instance.open(n,e.byteLength),this.instance.readOffset=0,!0}catch(e){throw Error(`Failed to open file: ${e.message}`)}}getHeader(){if(!this.instance)throw Error(`You need to open the file before trying to read header`);try{let e=I$(this.instance.arraybuffer);return e.pointsFormatId&=63,this.header=e,e}catch(e){throw Error(`Failed to get header: ${e.message}`)}}readData(e,t){if(!this.instance)throw Error(`You need to open the file before trying to read stuff`);let{header:n,instance:r}=this;if(!n)throw Error(`You need to query header before reading, I maintain state that way, sorry :(`);try{let i=Math.min(e*t,n.pointsCount-r.readOffset),a=Math.ceil(i/t),o=0,s=new Uint8Array(a*n.pointsStructSize),c=P8._malloc(n.pointsStructSize);for(let e=0;e<i;e++){if(r.getPoint(c),e%t===0){let e=new Uint8Array(P8.HEAPU8.buffer,c,n.pointsStructSize);s.set(e,o*n.pointsStructSize),o++}r.readOffset++}return P8._free(c),{buffer:s.buffer,count:o,hasMoreData:r.readOffset<n.pointsCount}}catch(e){throw Error(`Failed to read data: ${e.message}`)}}close(){try{return this.instance!==null&&(P8._free(this.instance.buf),this.instance.delete(),this.instance=null),!0}catch(e){throw Error(`Failed to close file: ${e.message}`)}}},R8=class{arrayb;decoder;pointsCount;pointSize;scale;offset;mins;maxs;constructor(e,t,n){this.arrayb=e,this.decoder=F8[n.pointsFormatId],this.pointsCount=t,this.pointSize=n.pointsStructSize,this.scale=n.scale,this.offset=n.offset,this.mins=n.mins,this.maxs=n.maxs}getPoint(e){if(e<0||e>=this.pointsCount)throw Error(`Point index out of range`);let t=new DataView(this.arrayb,e*this.pointSize,this.pointSize);return this.decoder(t)}},z8=class{arraybuffer;formatId=0;loader;isCompressed=!0;isOpen=!1;version=0;versionAsString=``;constructor(e){if(this.arraybuffer=e,this.determineVersion()>13)throw Error(`Only file versions <= 1.3 are supported at this time`);if(this.determineFormat(),F8[this.formatId]===void 0)throw Error(`The point format ID is not supported`);this.loader=this.isCompressed?new L8(this.arraybuffer):new I8(this.arraybuffer)}determineFormat(){let e=F$(this.arraybuffer,Uint8Array,104),t=(e&128)>>7,n=(e&64)>>6;if(t===1&&n===1)throw Error(`Old style compression not supported`);this.formatId=e&63,this.isCompressed=t===1||n===1}determineVersion(){let e=new Int8Array(this.arraybuffer,24,2);return this.version=e[0]*10+e[1],this.versionAsString=`${e[0]}.${e[1]}`,this.version}open(){this.loader.open()&&(this.isOpen=!0)}getHeader(){return this.loader.getHeader()}readData(e,t){return this.loader.readData(e,t)}close(){this.loader.close()&&(this.isOpen=!1)}getUnpacker(){return R8}},B8={...N8,parse:async(e,t)=>L$(e,t),parseSync:(e,t)=>L$(e,t)},V8=m6(),H8=C6(),U8=6378137,W8=6356752.314,G8=.0066943799901413165,K8=484813681109536e-20,$=Math.PI/2,q8=.16666666666666666,J8=.04722222222222222,Y8=.022156084656084655,X8=1e-10,Z8=.017453292519943295,Q8=57.29577951308232,$8=Math.PI/4,e5=Math.PI*2,t5=3.14159265359,n5={},n5.greenwich=0,n5.lisbon=-9.131906111111,n5.paris=2.337229166667,n5.bogota=-74.080916666667,n5.madrid=-3.687938888889,n5.rome=12.452333333333,n5.bern=7.439583333333,n5.jakarta=106.807719444444,n5.ferro=-17.666666666667,n5.brussels=4.367975,n5.stockholm=18.058277777778,n5.athens=23.7163375,n5.oslo=10.722916666667,r5={mm:{to_meter:.001},cm:{to_meter:.01},ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937},fath:{to_meter:1.8288},kmi:{to_meter:1852},"us-ch":{to_meter:20.1168402336805},"us-mi":{to_meter:1609.34721869444},km:{to_meter:1e3},"ind-ft":{to_meter:.30479841},"ind-yd":{to_meter:.91439523},mi:{to_meter:1609.344},yd:{to_meter:.9144},ch:{to_meter:20.1168},link:{to_meter:.201168},dm:{to_meter:.1},in:{to_meter:.0254},"ind-ch":{to_meter:20.11669506},"us-in":{to_meter:.025400050800101},"us-yd":{to_meter:.914401828803658}},i5=/[\s_\-\/\(\)]/g,a5=class{static getId(e){let t=e.find(e=>Array.isArray(e)&&e[0]===`ID`);return t&&t.length>=3?{authority:t[1],code:parseInt(t[2],10)}:null}static convertUnit(e,t=`unit`){if(!e||e.length<3)return{type:t,name:`unknown`,conversion_factor:null};let n=e[1],r=parseFloat(e[2])||null,i=e.find(e=>Array.isArray(e)&&e[0]===`ID`);return{type:t,name:n,conversion_factor:r,id:i?{authority:i[1],code:parseInt(i[2],10)}:null}}static convertAxis(e){let t=e[1]||`Unknown`,n,r=t.match(/^\((.)\)$/);if(r){let t=r[1].toUpperCase();if(t===`E`)n=`east`;else if(t===`N`)n=`north`;else if(t===`U`)n=`up`;else if(e[2])n=e[2];else throw Error(`Unknown axis abbreviation: ${t}`)}else n=e[2]||`unknown`;let i=e.find(e=>Array.isArray(e)&&e[0]===`ORDER`),a=i?parseInt(i[1],10):null,o=e.find(e=>Array.isArray(e)&&(e[0]===`LENGTHUNIT`||e[0]===`ANGLEUNIT`||e[0]===`SCALEUNIT`)),s=this.convertUnit(o);return{name:t,direction:n,unit:s,order:a}}static extractAxes(e){return e.filter(e=>Array.isArray(e)&&e[0]===`AXIS`).map(e=>this.convertAxis(e)).sort((e,t)=>(e.order||0)-(t.order||0))}static convert(e,t={}){switch(e[0]){case`PROJCRS`:t.type=`ProjectedCRS`,t.name=e[1],t.base_crs=e.find(e=>Array.isArray(e)&&e[0]===`BASEGEOGCRS`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`BASEGEOGCRS`)):null,t.conversion=e.find(e=>Array.isArray(e)&&e[0]===`CONVERSION`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`CONVERSION`)):null;let n=e.find(e=>Array.isArray(e)&&e[0]===`CS`);n&&(t.coordinate_system={type:n[1],axis:this.extractAxes(e)});let r=e.find(e=>Array.isArray(e)&&e[0]===`LENGTHUNIT`);if(r){let e=this.convertUnit(r);t.coordinate_system.unit=e}t.id=this.getId(e);break;case`BASEGEOGCRS`:case`GEOGCRS`:case`GEODCRS`:t.type=e[0]===`GEODCRS`?`GeodeticCRS`:`GeographicCRS`,t.name=e[1];let i=e.find(e=>Array.isArray(e)&&(e[0]===`DATUM`||e[0]===`ENSEMBLE`));if(i){let n=this.convert(i);i[0]===`ENSEMBLE`?t.datum_ensemble=n:t.datum=n;let r=e.find(e=>Array.isArray(e)&&e[0]===`PRIMEM`);r&&r[1]!==`Greenwich`&&(n.prime_meridian={name:r[1],longitude:parseFloat(r[2])})}t.coordinate_system={type:`ellipsoidal`,axis:this.extractAxes(e)},t.id=this.getId(e);break;case`DATUM`:t.type=`GeodeticReferenceFrame`,t.name=e[1],t.ellipsoid=e.find(e=>Array.isArray(e)&&e[0]===`ELLIPSOID`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`ELLIPSOID`)):null;break;case`ENSEMBLE`:t.type=`DatumEnsemble`,t.name=e[1],t.members=e.filter(e=>Array.isArray(e)&&e[0]===`MEMBER`).map(e=>({type:`DatumEnsembleMember`,name:e[1],id:this.getId(e)}));let a=e.find(e=>Array.isArray(e)&&e[0]===`ENSEMBLEACCURACY`);a&&(t.accuracy=parseFloat(a[1]));let o=e.find(e=>Array.isArray(e)&&e[0]===`ELLIPSOID`);o&&(t.ellipsoid=this.convert(o)),t.id=this.getId(e);break;case`ELLIPSOID`:t.type=`Ellipsoid`,t.name=e[1],t.semi_major_axis=parseFloat(e[2]),t.inverse_flattening=parseFloat(e[3]),e.find(e=>Array.isArray(e)&&e[0]===`LENGTHUNIT`)&&this.convert(e.find(e=>Array.isArray(e)&&e[0]===`LENGTHUNIT`),t);break;case`CONVERSION`:t.type=`Conversion`,t.name=e[1],t.method=e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)):null,t.parameters=e.filter(e=>Array.isArray(e)&&e[0]===`PARAMETER`).map(e=>this.convert(e));break;case`METHOD`:t.type=`Method`,t.name=e[1],t.id=this.getId(e);break;case`PARAMETER`:t.type=`Parameter`,t.name=e[1],t.value=parseFloat(e[2]),t.unit=this.convertUnit(e.find(e=>Array.isArray(e)&&(e[0]===`LENGTHUNIT`||e[0]===`ANGLEUNIT`||e[0]===`SCALEUNIT`))),t.id=this.getId(e);break;case`BOUNDCRS`:t.type=`BoundCRS`;let s=e.find(e=>Array.isArray(e)&&e[0]===`SOURCECRS`);if(s){let e=s.find(e=>Array.isArray(e));t.source_crs=e?this.convert(e):null}let c=e.find(e=>Array.isArray(e)&&e[0]===`TARGETCRS`);if(c){let e=c.find(e=>Array.isArray(e));t.target_crs=e?this.convert(e):null}let l=e.find(e=>Array.isArray(e)&&e[0]===`ABRIDGEDTRANSFORMATION`);l?t.transformation=this.convert(l):t.transformation=null;break;case`ABRIDGEDTRANSFORMATION`:if(t.type=`Transformation`,t.name=e[1],t.method=e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)?this.convert(e.find(e=>Array.isArray(e)&&e[0]===`METHOD`)):null,t.parameters=e.filter(e=>Array.isArray(e)&&(e[0]===`PARAMETER`||e[0]===`PARAMETERFILE`)).map(e=>{if(e[0]===`PARAMETER`)return this.convert(e);if(e[0]===`PARAMETERFILE`)return{name:e[1],value:e[2],id:{authority:`EPSG`,code:8656}}}),t.parameters.length===7){let e=t.parameters[6];e.name===`Scale difference`&&(e.value=Math.round((e.value-1)*0xe8d4a51000)/1e6)}t.id=this.getId(e);break;case`AXIS`:t.coordinate_system||={type:`unspecified`,axis:[]},t.coordinate_system.axis.push(this.convertAxis(e));break;case`LENGTHUNIT`:let u=this.convertUnit(e,`LinearUnit`);t.coordinate_system&&t.coordinate_system.axis&&t.coordinate_system.axis.forEach(e=>{e.unit||=u}),u.conversion_factor&&u.conversion_factor!==1&&(t.semi_major_axis&&={value:t.semi_major_axis,unit:u});break;default:t.keyword=e[0];break}return t}},o5=class extends a5{static convert(e,t={}){return super.convert(e,t),t.coordinate_system&&t.coordinate_system.subtype===`Cartesian`&&delete t.coordinate_system,t.usage&&delete t.usage,t}},s5=class extends a5{static convert(e,t={}){super.convert(e,t);let n=e.find(e=>Array.isArray(e)&&e[0]===`CS`);n&&(t.coordinate_system={subtype:n[1],axis:this.extractAxes(e)});let r=e.find(e=>Array.isArray(e)&&e[0]===`USAGE`);if(r){let e=r.find(e=>Array.isArray(e)&&e[0]===`SCOPE`),n=r.find(e=>Array.isArray(e)&&e[0]===`AREA`),i=r.find(e=>Array.isArray(e)&&e[0]===`BBOX`);t.usage={},e&&(t.usage.scope=e[1]),n&&(t.usage.area=n[1]),i&&(t.usage.bbox=i.slice(1))}return t}},c5=J$,l5=1,u5=2,d5=3,f5=4,p5=5,m5=-1,h5=/\s/,g5=/[A-Za-z]/,_5=/[A-Za-z84_]/,v5=/[,\]]/,y5=/[\d\.E\-\+]/,q$.prototype.readCharicter=function(){var e=this.text[this.place++];if(this.state!==f5)for(;h5.test(e);){if(this.place>=this.text.length)return;e=this.text[this.place++]}switch(this.state){case l5:return this.neutral(e);case u5:return this.keyword(e);case f5:return this.quoted(e);case p5:return this.afterquote(e);case d5:return this.number(e);case m5:return}},q$.prototype.afterquote=function(e){if(e===`"`){this.word+=`"`,this.state=f5;return}if(v5.test(e)){this.word=this.word.trim(),this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in afterquote yet, index `+this.place)},q$.prototype.afterItem=function(e){if(e===`,`){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=l5;return}if(e===`]`){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=l5,this.currentObject=this.stack.pop(),this.currentObject||(this.state=m5);return}},q$.prototype.number=function(e){if(y5.test(e)){this.word+=e;return}if(v5.test(e)){this.word=parseFloat(this.word),this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in number yet, index `+this.place)},q$.prototype.quoted=function(e){if(e===`"`){this.state=p5;return}this.word+=e},q$.prototype.keyword=function(e){if(_5.test(e)){this.word+=e;return}if(e===`[`){var t=[];t.push(this.word),this.level++,this.root===null?this.root=t:this.currentObject.push(t),this.stack.push(this.currentObject),this.currentObject=t,this.state=l5;return}if(v5.test(e)){this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in keyword yet, index `+this.place)},q$.prototype.neutral=function(e){if(g5.test(e)){this.word=e,this.state=u5;return}if(e===`"`){this.word=``,this.state=f5;return}if(y5.test(e)){this.word=e,this.state=d5;return}if(v5.test(e)){this.afterItem(e);return}throw Error(`havn't handled "`+e+`" in neutral yet, index `+this.place)},q$.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===m5)return this.root;throw Error(`unable to parse string "`+this.text+`". State is `+this.state)},b5=.017453292519943295,x5=[`PROJECTEDCRS`,`PROJCRS`,`GEOGCS`,`GEOCCS`,`PROJCS`,`LOCAL_CS`,`GEODCRS`,`GEODETICCRS`,`GEODETICDATUM`,`ENGCRS`,`ENGINEERINGCRS`],V$(s1),S5=[`3857`,`900913`,`3785`,`102113`],C5={init:b1,forward:x1,inverse:S1,names:[`Mercator`,`Popular Visualisation Pseudo Mercator`,`Mercator_1SP`,`Mercator_Auxiliary_Sphere`,`Mercator_Variant_A`,`merc`]},w5=[`longlat`,`identity`],T5=[C5,{init:C1,forward:w1,inverse:w1,names:w5}],E5={},D5=[],O5={start:O1,add:T1,get:D1},k5={MERIT:{a:6378137,rf:298.257,ellipseName:`MERIT 1983`},SGS85:{a:6378136,rf:298.257,ellipseName:`Soviet Geodetic System 85`},GRS80:{a:6378137,rf:298.257222101,ellipseName:`GRS 1980(IUGG, 1980)`},IAU76:{a:6378140,rf:298.257,ellipseName:`IAU 1976`},airy:{a:6377563.396,b:6356256.91,ellipseName:`Airy 1830`},APL4:{a:6378137,rf:298.25,ellipseName:`Appl. Physics. 1965`},NWL9D:{a:6378145,rf:298.25,ellipseName:`Naval Weapons Lab., 1965`},mod_airy:{a:6377340.189,b:6356034.446,ellipseName:`Modified Airy`},andrae:{a:6377104.43,rf:300,ellipseName:`Andrae 1876 (Den., Iclnd.)`},aust_SA:{a:6378160,rf:298.25,ellipseName:`Australian Natl & S. Amer. 1969`},GRS67:{a:6378160,rf:298.247167427,ellipseName:`GRS 67(IUGG 1967)`},bessel:{a:6377397.155,rf:299.1528128,ellipseName:`Bessel 1841`},bess_nam:{a:6377483.865,rf:299.1528128,ellipseName:`Bessel 1841 (Namibia)`},clrk66:{a:6378206.4,b:6356583.8,ellipseName:`Clarke 1866`},clrk80:{a:6378249.145,rf:293.4663,ellipseName:`Clarke 1880 mod.`},clrk80ign:{a:6378249.2,b:6356515,rf:293.4660213,ellipseName:`Clarke 1880 (IGN)`},clrk58:{a:6378293.645208759,rf:294.2606763692654,ellipseName:`Clarke 1858`},CPM:{a:6375738.7,rf:334.29,ellipseName:`Comm. des Poids et Mesures 1799`},delmbr:{a:6376428,rf:311.5,ellipseName:`Delambre 1810 (Belgium)`},engelis:{a:6378136.05,rf:298.2566,ellipseName:`Engelis 1985`},evrst30:{a:6377276.345,rf:300.8017,ellipseName:`Everest 1830`},evrst48:{a:6377304.063,rf:300.8017,ellipseName:`Everest 1948`},evrst56:{a:6377301.243,rf:300.8017,ellipseName:`Everest 1956`},evrst69:{a:6377295.664,rf:300.8017,ellipseName:`Everest 1969`},evrstSS:{a:6377298.556,rf:300.8017,ellipseName:`Everest (Sabah & Sarawak)`},fschr60:{a:6378166,rf:298.3,ellipseName:`Fischer (Mercury Datum) 1960`},fschr60m:{a:6378155,rf:298.3,ellipseName:`Fischer 1960`},fschr68:{a:6378150,rf:298.3,ellipseName:`Fischer 1968`},helmert:{a:6378200,rf:298.3,ellipseName:`Helmert 1906`},hough:{a:6378270,rf:297,ellipseName:`Hough`},intl:{a:6378388,rf:297,ellipseName:`International 1909 (Hayford)`},kaula:{a:6378163,rf:298.24,ellipseName:`Kaula 1961`},lerch:{a:6378139,rf:298.257,ellipseName:`Lerch 1979`},mprts:{a:6397300,rf:191,ellipseName:`Maupertius 1738`},new_intl:{a:6378157.5,b:6356772.2,ellipseName:`New International 1967`},plessis:{a:6376523,rf:6355863,ellipseName:`Plessis 1817 (France)`},krass:{a:6378245,rf:298.3,ellipseName:`Krassovsky, 1942`},SEasia:{a:6378155,b:6356773.3205,ellipseName:`Southeast Asia`},walbeck:{a:6376896,b:6355834.8467,ellipseName:`Walbeck`},WGS60:{a:6378165,rf:298.3,ellipseName:`WGS 60`},WGS66:{a:6378145,rf:298.25,ellipseName:`WGS 66`},WGS7:{a:6378135,rf:298.26,ellipseName:`WGS 72`},WGS84:{a:6378137,rf:298.257223563,ellipseName:`WGS 84`},sphere:{a:6370997,b:6370997,ellipseName:`Normal Sphere (r=6370997)`}},A5=k5.WGS84,j5={wgs84:{towgs84:`0,0,0`,ellipse:`WGS84`,datumName:`WGS84`},ch1903:{towgs84:`674.374,15.056,405.346`,ellipse:`bessel`,datumName:`swiss`},ggrs87:{towgs84:`-199.87,74.79,246.62`,ellipse:`GRS80`,datumName:`Greek_Geodetic_Reference_System_1987`},nad83:{towgs84:`0,0,0`,ellipse:`GRS80`,datumName:`North_American_Datum_1983`},nad27:{nadgrids:`@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat`,ellipse:`clrk66`,datumName:`North_American_Datum_1927`},potsdam:{towgs84:`598.1,73.7,418.2,0.202,0.045,-2.455,6.7`,ellipse:`bessel`,datumName:`Potsdam Rauenberg 1950 DHDN`},carthage:{towgs84:`-263.0,6.0,431.0`,ellipse:`clark80`,datumName:`Carthage 1934 Tunisia`},hermannskogel:{towgs84:`577.326,90.129,463.919,5.137,1.474,5.297,2.4232`,ellipse:`bessel`,datumName:`Hermannskogel`},mgi:{towgs84:`577.326,90.129,463.919,5.137,1.474,5.297,2.4232`,ellipse:`bessel`,datumName:`Militar-Geographische Institut`},osni52:{towgs84:`482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15`,ellipse:`airy`,datumName:`Irish National`},ire65:{towgs84:`482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15`,ellipse:`mod_airy`,datumName:`Ireland 1965`},rassadiran:{towgs84:`-133.63,-157.5,-158.62`,ellipse:`intl`,datumName:`Rassadiran`},nzgd49:{towgs84:`59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993`,ellipse:`intl`,datumName:`New Zealand Geodetic Datum 1949`},osgb36:{towgs84:`446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894`,ellipse:`airy`,datumName:`Ordnance Survey of Great Britain 1936`},s_jtsk:{towgs84:`589,76,480`,ellipse:`bessel`,datumName:`S-JTSK (Ferro)`},beduaram:{towgs84:`-106,-87,188`,ellipse:`clrk80`,datumName:`Beduaram`},gunung_segara:{towgs84:`-403,684,41`,ellipse:`bessel`,datumName:`Gunung Segara Jakarta`},rnb72:{towgs84:`106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1`,ellipse:`intl`,datumName:`Reseau National Belge 1972`},EPSG_5451:{towgs84:`6.41,-49.05,-11.28,1.5657,0.5242,6.9718,-5.7649`},IGNF_LURESG:{towgs84:`-192.986,13.673,-39.309,-0.4099,-2.9332,2.6881,0.43`},EPSG_4614:{towgs84:`-119.4248,-303.65872,-11.00061,1.164298,0.174458,1.096259,3.657065`},EPSG_4615:{towgs84:`-494.088,-312.129,279.877,-1.423,-1.013,1.59,-0.748`},ESRI_37241:{towgs84:`-76.822,257.457,-12.817,2.136,-0.033,-2.392,-0.031`},ESRI_37249:{towgs84:`-440.296,58.548,296.265,1.128,10.202,4.559,-0.438`},ESRI_37245:{towgs84:`-511.151,-181.269,139.609,1.05,2.703,1.798,3.071`},EPSG_4178:{towgs84:`24.9,-126.4,-93.2,-0.063,-0.247,-0.041,1.01`},EPSG_4622:{towgs84:`-472.29,-5.63,-304.12,0.4362,-0.8374,0.2563,1.8984`},EPSG_4625:{towgs84:`126.93,547.94,130.41,-2.7867,5.1612,-0.8584,13.8227`},EPSG_5252:{towgs84:`0.023,0.036,-0.068,0.00176,0.00912,-0.01136,0.00439`},EPSG_4314:{towgs84:`597.1,71.4,412.1,0.894,0.068,-1.563,7.58`},EPSG_4282:{towgs84:`-178.3,-316.7,-131.5,5.278,6.077,10.979,19.166`},EPSG_4231:{towgs84:`-83.11,-97.38,-117.22,0.005693,-0.044698,0.044285,0.1218`},EPSG_4274:{towgs84:`-230.994,102.591,25.199,0.633,-0.239,0.9,1.95`},EPSG_4134:{towgs84:`-180.624,-225.516,173.919,-0.81,-1.898,8.336,16.71006`},EPSG_4254:{towgs84:`18.38,192.45,96.82,0.056,-0.142,-0.2,-0.0013`},EPSG_4159:{towgs84:`-194.513,-63.978,-25.759,-3.4027,3.756,-3.352,-0.9175`},EPSG_4687:{towgs84:`0.072,-0.507,-0.245,0.0183,-0.0003,0.007,-0.0093`},EPSG_4227:{towgs84:`-83.58,-397.54,458.78,-17.595,-2.847,4.256,3.225`},EPSG_4746:{towgs84:`599.4,72.4,419.2,-0.062,-0.022,-2.723,6.46`},EPSG_4745:{towgs84:`612.4,77,440.2,-0.054,0.057,-2.797,2.55`},EPSG_6311:{towgs84:`8.846,-4.394,-1.122,-0.00237,-0.146528,0.130428,0.783926`},EPSG_4289:{towgs84:`565.7381,50.4018,465.2904,-0.395026,0.330772,-1.876073,4.07244`},EPSG_4230:{towgs84:`-68.863,-134.888,-111.49,-0.53,-0.14,0.57,-3.4`},EPSG_4154:{towgs84:`-123.02,-158.95,-168.47`},EPSG_4156:{towgs84:`570.8,85.7,462.8,4.998,1.587,5.261,3.56`},EPSG_4299:{towgs84:`482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15`},EPSG_4179:{towgs84:`33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84`},EPSG_4313:{towgs84:`-106.8686,52.2978,-103.7239,0.3366,-0.457,1.8422,-1.2747`},EPSG_4194:{towgs84:`163.511,127.533,-159.789`},EPSG_4195:{towgs84:`105,326,-102.5`},EPSG_4196:{towgs84:`-45,417,-3.5`},EPSG_4611:{towgs84:`-162.619,-276.959,-161.764,0.067753,-2.243648,-1.158828,-1.094246`},EPSG_4633:{towgs84:`137.092,131.66,91.475,-1.9436,-11.5993,-4.3321,-7.4824`},EPSG_4641:{towgs84:`-408.809,366.856,-412.987,1.8842,-0.5308,2.1655,-121.0993`},EPSG_4643:{towgs84:`-480.26,-438.32,-643.429,16.3119,20.1721,-4.0349,-111.7002`},EPSG_4300:{towgs84:`482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15`},EPSG_4188:{towgs84:`482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15`},EPSG_4660:{towgs84:`982.6087,552.753,-540.873,6.681627,-31.611492,-19.848161,16.805`},EPSG_4662:{towgs84:`97.295,-263.247,310.882,-1.5999,0.8386,3.1409,13.3259`},EPSG_3906:{towgs84:`577.88891,165.22205,391.18289,4.9145,-0.94729,-13.05098,7.78664`},EPSG_4307:{towgs84:`-209.3622,-87.8162,404.6198,0.0046,3.4784,0.5805,-1.4547`},EPSG_6892:{towgs84:`-76.269,-16.683,68.562,-6.275,10.536,-4.286,-13.686`},EPSG_4690:{towgs84:`221.597,152.441,176.523,2.403,1.3893,0.884,11.4648`},EPSG_4691:{towgs84:`218.769,150.75,176.75,3.5231,2.0037,1.288,10.9817`},EPSG_4629:{towgs84:`72.51,345.411,79.241,-1.5862,-0.8826,-0.5495,1.3653`},EPSG_4630:{towgs84:`165.804,216.213,180.26,-0.6251,-0.4515,-0.0721,7.4111`},EPSG_4692:{towgs84:`217.109,86.452,23.711,0.0183,-0.0003,0.007,-0.0093`},EPSG_9333:{towgs84:`0,0,0,-0.008393,0.000749,-0.010276,0`},EPSG_9059:{towgs84:`0,0,0`},EPSG_4312:{towgs84:`601.705,84.263,485.227,4.7354,1.3145,5.393,-2.3887`},EPSG_4123:{towgs84:`-96.062,-82.428,-121.753,4.801,0.345,-1.376,1.496`},EPSG_4309:{towgs84:`-124.45,183.74,44.64,-0.4384,0.5446,-0.9706,-2.1365`},ESRI_104106:{towgs84:`-283.088,-70.693,117.445,-1.157,0.059,-0.652,-4.058`},EPSG_4281:{towgs84:`-219.247,-73.802,269.529`},EPSG_4322:{towgs84:`0,0,4.5`},EPSG_4324:{towgs84:`0,0,1.9`},EPSG_4284:{towgs84:`43.822,-108.842,-119.585,1.455,-0.761,0.737,0.549`},EPSG_4277:{towgs84:`446.448,-125.157,542.06,0.15,0.247,0.842,-20.489`},EPSG_4207:{towgs84:`-282.1,-72.2,120,-1.529,0.145,-0.89,-4.46`},EPSG_4688:{towgs84:`347.175,1077.618,2623.677,33.9058,-70.6776,9.4013,186.0647`},EPSG_4689:{towgs84:`410.793,54.542,80.501,-2.5596,-2.3517,-0.6594,17.3218`},EPSG_4720:{towgs84:`0,0,4.5`},EPSG_4273:{towgs84:`278.3,93,474.5,7.889,0.05,-6.61,6.21`},EPSG_4240:{towgs84:`204.64,834.74,293.8`},EPSG_4817:{towgs84:`278.3,93,474.5,7.889,0.05,-6.61,6.21`},ESRI_104131:{towgs84:`426.62,142.62,460.09,4.98,4.49,-12.42,-17.1`},EPSG_4265:{towgs84:`-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68`},EPSG_4263:{towgs84:`-111.92,-87.85,114.5,1.875,0.202,0.219,0.032`},EPSG_4298:{towgs84:`-689.5937,623.84046,-65.93566,-0.02331,1.17094,-0.80054,5.88536`},EPSG_4270:{towgs84:`-253.4392,-148.452,386.5267,0.15605,0.43,-0.1013,-0.0424`},EPSG_4229:{towgs84:`-121.8,98.1,-10.7`},EPSG_4220:{towgs84:`-55.5,-348,-229.2`},EPSG_4214:{towgs84:`12.646,-155.176,-80.863`},EPSG_4232:{towgs84:`-345,3,223`},EPSG_4238:{towgs84:`-1.977,-13.06,-9.993,0.364,0.254,0.689,-1.037`},EPSG_4168:{towgs84:`-170,33,326`},EPSG_4131:{towgs84:`199,931,318.9`},EPSG_4152:{towgs84:`-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0`},EPSG_5228:{towgs84:`572.213,85.334,461.94,4.9732,1.529,5.2484,3.5378`},EPSG_8351:{towgs84:`485.021,169.465,483.839,7.786342,4.397554,4.102655,0`},EPSG_4683:{towgs84:`-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06`},EPSG_4133:{towgs84:`0,0,0`},EPSG_7373:{towgs84:`0.819,-0.5762,-1.6446,-0.00378,-0.03317,0.00318,0.0693`},EPSG_9075:{towgs84:`-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0`},EPSG_9072:{towgs84:`-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0`},EPSG_9294:{towgs84:`1.16835,-1.42001,-2.24431,-0.00822,-0.05508,0.01818,0.23388`},EPSG_4212:{towgs84:`-267.434,173.496,181.814,-13.4704,8.7154,7.3926,14.7492`},EPSG_4191:{towgs84:`-44.183,-0.58,-38.489,2.3867,2.7072,-3.5196,-8.2703`},EPSG_4237:{towgs84:`52.684,-71.194,-13.975,-0.312,-0.1063,-0.3729,1.0191`},EPSG_4740:{towgs84:`-1.08,-0.27,-0.9`},EPSG_4124:{towgs84:`419.3836,99.3335,591.3451,0.850389,1.817277,-7.862238,-0.99496`},EPSG_5681:{towgs84:`584.9636,107.7175,413.8067,1.1155,0.2824,-3.1384,7.9922`},EPSG_4141:{towgs84:`23.772,17.49,17.859,-0.3132,-1.85274,1.67299,-5.4262`},EPSG_4204:{towgs84:`-85.645,-273.077,-79.708,2.289,-1.421,2.532,3.194`},EPSG_4319:{towgs84:`226.702,-193.337,-35.371,-2.229,-4.391,9.238,0.9798`},EPSG_4200:{towgs84:`24.82,-131.21,-82.66`},EPSG_4130:{towgs84:`0,0,0`},EPSG_4127:{towgs84:`-82.875,-57.097,-156.768,-2.158,1.524,-0.982,-0.359`},EPSG_4149:{towgs84:`674.374,15.056,405.346`},EPSG_4617:{towgs84:`-0.991,1.9072,0.5129,0.02579,0.00965,0.01166,0`},EPSG_4663:{towgs84:`-210.502,-66.902,-48.476,2.094,-15.067,-5.817,0.485`},EPSG_4664:{towgs84:`-211.939,137.626,58.3,-0.089,0.251,0.079,0.384`},EPSG_4665:{towgs84:`-105.854,165.589,-38.312,-0.003,-0.026,0.024,-0.048`},EPSG_4666:{towgs84:`631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43`},EPSG_4756:{towgs84:`-192.873,-39.382,-111.202,-0.00205,-0.0005,0.00335,0.0188`},EPSG_4723:{towgs84:`-179.483,-69.379,-27.584,-7.862,8.163,6.042,-13.925`},EPSG_4726:{towgs84:`8.853,-52.644,180.304,-0.393,-2.323,2.96,-24.081`},EPSG_4267:{towgs84:`-8.0,160.0,176.0`},EPSG_5365:{towgs84:`-0.16959,0.35312,0.51846,0.03385,-0.16325,0.03446,0.03693`},EPSG_4218:{towgs84:`304.5,306.5,-318.1`},EPSG_4242:{towgs84:`-33.722,153.789,94.959,-8.581,-4.478,4.54,8.95`},EPSG_4216:{towgs84:`-292.295,248.758,429.447,4.9971,2.99,6.6906,1.0289`},ESRI_104105:{towgs84:`631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43`},ESRI_104129:{towgs84:`0,0,0`},EPSG_4673:{towgs84:`174.05,-25.49,112.57`},EPSG_4202:{towgs84:`-124,-60,154`},EPSG_4203:{towgs84:`-117.763,-51.51,139.061,0.292,0.443,0.277,-0.191`},EPSG_3819:{towgs84:`595.48,121.69,515.35,4.115,-2.9383,0.853,-3.408`},EPSG_8694:{towgs84:`-93.799,-132.737,-219.073,-1.844,0.648,-6.37,-0.169`},EPSG_4145:{towgs84:`275.57,676.78,229.6`},EPSG_4283:{towgs84:`0.06155,-0.01087,-0.04019,0.039492,0.032722,0.032898,-0.009994`},EPSG_4317:{towgs84:`2.3287,-147.0425,-92.0802,-0.309248,0.324822,0.497299,5.689063`},EPSG_4272:{towgs84:`59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993`},EPSG_4248:{towgs84:`-307.7,265.3,-363.5`},EPSG_5561:{towgs84:`24,-121,-76`},EPSG_5233:{towgs84:`-0.293,766.95,87.713,0.195704,1.695068,3.473016,-0.039338`},ESRI_104130:{towgs84:`-86,-98,-119`},ESRI_104102:{towgs84:`682,-203,480`},ESRI_37207:{towgs84:`7,-10,-26`},EPSG_4675:{towgs84:`59.935,118.4,-10.871`},ESRI_104109:{towgs84:`-89.121,-348.182,260.871`},ESRI_104112:{towgs84:`-185.583,-230.096,281.361`},ESRI_104113:{towgs84:`25.1,-275.6,222.6`},IGNF_WGS72G:{towgs84:`0,12,6`},IGNF_NTFG:{towgs84:`-168,-60,320`},IGNF_EFATE57G:{towgs84:`-127,-769,472`},IGNF_PGP50G:{towgs84:`324.8,153.6,172.1`},IGNF_REUN47G:{towgs84:`94,-948,-1262`},IGNF_CSG67G:{towgs84:`-186,230,110`},IGNF_GUAD48G:{towgs84:`-467,-16,-300`},IGNF_TAHI51G:{towgs84:`162,117,154`},IGNF_TAHAAG:{towgs84:`65,342,77`},IGNF_NUKU72G:{towgs84:`84,274,65`},IGNF_PETRELS72G:{towgs84:`365,194,166`},IGNF_WALL78G:{towgs84:`253,-133,-127`},IGNF_MAYO50G:{towgs84:`-382,-59,-262`},IGNF_TANNAG:{towgs84:`-139,-967,436`},IGNF_IGN72G:{towgs84:`-13,-348,292`},IGNF_ATIGG:{towgs84:`1118,23,66`},IGNF_FANGA84G:{towgs84:`150.57,158.33,118.32`},IGNF_RUSAT84G:{towgs84:`202.13,174.6,-15.74`},IGNF_KAUE70G:{towgs84:`126.74,300.1,-75.49`},IGNF_MOP90G:{towgs84:`-10.8,-1.8,12.77`},IGNF_MHPF67G:{towgs84:`338.08,212.58,-296.17`},IGNF_TAHI79G:{towgs84:`160.61,116.05,153.69`},IGNF_ANAA92G:{towgs84:`1.5,3.84,4.81`},IGNF_MARQUI72G:{towgs84:`330.91,-13.92,58.56`},IGNF_APAT86G:{towgs84:`143.6,197.82,74.05`},IGNF_TUBU69G:{towgs84:`237.17,171.61,-77.84`},IGNF_STPM50G:{towgs84:`11.363,424.148,373.13`},EPSG_4150:{towgs84:`674.374,15.056,405.346`},EPSG_4754:{towgs84:`-208.4058,-109.8777,-2.5764`},ESRI_104101:{towgs84:`372.87,149.23,585.29`},EPSG_4693:{towgs84:`0,-0.15,0.68`},EPSG_6207:{towgs84:`293.17,726.18,245.36`},EPSG_4153:{towgs84:`-133.63,-157.5,-158.62`},EPSG_4132:{towgs84:`-241.54,-163.64,396.06`},EPSG_4221:{towgs84:`-154.5,150.7,100.4`},EPSG_4266:{towgs84:`-80.7,-132.5,41.1`},EPSG_4193:{towgs84:`-70.9,-151.8,-41.4`},EPSG_5340:{towgs84:`-0.41,0.46,-0.35`},EPSG_4246:{towgs84:`-294.7,-200.1,525.5`},EPSG_4318:{towgs84:`-3.2,-5.7,2.8`},EPSG_4121:{towgs84:`-199.87,74.79,246.62`},EPSG_4223:{towgs84:`-260.1,5.5,432.2`},EPSG_4158:{towgs84:`-0.465,372.095,171.736`},EPSG_4285:{towgs84:`-128.16,-282.42,21.93`},EPSG_4613:{towgs84:`-404.78,685.68,45.47`},EPSG_4607:{towgs84:`195.671,332.517,274.607`},EPSG_4475:{towgs84:`-381.788,-57.501,-256.673`},EPSG_4208:{towgs84:`-157.84,308.54,-146.6`},EPSG_4743:{towgs84:`70.995,-335.916,262.898`},EPSG_4710:{towgs84:`-323.65,551.39,-491.22`},EPSG_7881:{towgs84:`-0.077,0.079,0.086`},EPSG_4682:{towgs84:`283.729,735.942,261.143`},EPSG_4739:{towgs84:`-156,-271,-189`},EPSG_4679:{towgs84:`-80.01,253.26,291.19`},EPSG_4750:{towgs84:`-56.263,16.136,-22.856`},EPSG_4644:{towgs84:`-10.18,-350.43,291.37`},EPSG_4695:{towgs84:`-103.746,-9.614,-255.95`},EPSG_4292:{towgs84:`-355,21,72`},EPSG_4302:{towgs84:`-61.702,284.488,472.052`},EPSG_4143:{towgs84:`-124.76,53,466.79`},EPSG_4606:{towgs84:`-153,153,307`},EPSG_4699:{towgs84:`-770.1,158.4,-498.2`},EPSG_4247:{towgs84:`-273.5,110.6,-357.9`},EPSG_4160:{towgs84:`8.88,184.86,106.69`},EPSG_4161:{towgs84:`-233.43,6.65,173.64`},EPSG_9251:{towgs84:`-9.5,122.9,138.2`},EPSG_9253:{towgs84:`-78.1,101.6,133.3`},EPSG_4297:{towgs84:`-198.383,-240.517,-107.909`},EPSG_4269:{towgs84:`0,0,0`},EPSG_4301:{towgs84:`-147,506,687`},EPSG_4618:{towgs84:`-59,-11,-52`},EPSG_4612:{towgs84:`0,0,0`},EPSG_4678:{towgs84:`44.585,-131.212,-39.544`},EPSG_4250:{towgs84:`-130,29,364`},EPSG_4144:{towgs84:`214,804,268`},EPSG_4147:{towgs84:`-17.51,-108.32,-62.39`},EPSG_4259:{towgs84:`-254.1,-5.36,-100.29`},EPSG_4164:{towgs84:`-76,-138,67`},EPSG_4211:{towgs84:`-378.873,676.002,-46.255`},EPSG_4182:{towgs84:`-422.651,-172.995,84.02`},EPSG_4224:{towgs84:`-143.87,243.37,-33.52`},EPSG_4225:{towgs84:`-205.57,168.77,-4.12`},EPSG_5527:{towgs84:`-67.35,3.88,-38.22`},EPSG_4752:{towgs84:`98,390,-22`},EPSG_4310:{towgs84:`-30,190,89`},EPSG_9248:{towgs84:`-192.26,65.72,132.08`},EPSG_4680:{towgs84:`124.5,-63.5,-281`},EPSG_4701:{towgs84:`-79.9,-158,-168.9`},EPSG_4706:{towgs84:`-146.21,112.63,4.05`},EPSG_4805:{towgs84:`682,-203,480`},EPSG_4201:{towgs84:`-165,-11,206`},EPSG_4210:{towgs84:`-157,-2,-299`},EPSG_4183:{towgs84:`-104,167,-38`},EPSG_4139:{towgs84:`11,72,-101`},EPSG_4668:{towgs84:`-86,-98,-119`},EPSG_4717:{towgs84:`-2,151,181`},EPSG_4732:{towgs84:`102,52,-38`},EPSG_4280:{towgs84:`-377,681,-50`},EPSG_4209:{towgs84:`-138,-105,-289`},EPSG_4261:{towgs84:`31,146,47`},EPSG_4658:{towgs84:`-73,46,-86`},EPSG_4721:{towgs84:`265.025,384.929,-194.046`},EPSG_4222:{towgs84:`-136,-108,-292`},EPSG_4601:{towgs84:`-255,-15,71`},EPSG_4602:{towgs84:`725,685,536`},EPSG_4603:{towgs84:`72,213.7,93`},EPSG_4605:{towgs84:`9,183,236`},EPSG_4621:{towgs84:`137,248,-430`},EPSG_4657:{towgs84:`-28,199,5`},EPSG_4316:{towgs84:`103.25,-100.4,-307.19`},EPSG_4642:{towgs84:`-13,-348,292`},EPSG_4698:{towgs84:`145,-187,103`},EPSG_4192:{towgs84:`-206.1,-174.7,-87.7`},EPSG_4311:{towgs84:`-265,120,-358`},EPSG_4135:{towgs84:`58,-283,-182`},ESRI_104138:{towgs84:`198,-226,-347`},EPSG_4245:{towgs84:`-11,851,5`},EPSG_4142:{towgs84:`-125,53,467`},EPSG_4213:{towgs84:`-106,-87,188`},EPSG_4253:{towgs84:`-133,-77,-51`},EPSG_4129:{towgs84:`-132,-110,-335`},EPSG_4713:{towgs84:`-77,-128,142`},EPSG_4239:{towgs84:`217,823,299`},EPSG_4146:{towgs84:`295,736,257`},EPSG_4155:{towgs84:`-83,37,124`},EPSG_4165:{towgs84:`-173,253,27`},EPSG_4672:{towgs84:`175,-38,113`},EPSG_4236:{towgs84:`-637,-549,-203`},EPSG_4251:{towgs84:`-90,40,88`},EPSG_4271:{towgs84:`-2,374,172`},EPSG_4175:{towgs84:`-88,4,101`},EPSG_4716:{towgs84:`298,-304,-375`},EPSG_4315:{towgs84:`-23,259,-9`},EPSG_4744:{towgs84:`-242.2,-144.9,370.3`},EPSG_4244:{towgs84:`-97,787,86`},EPSG_4293:{towgs84:`616,97,-251`},EPSG_4714:{towgs84:`-127,-769,472`},EPSG_4736:{towgs84:`260,12,-147`},EPSG_6883:{towgs84:`-235,-110,393`},EPSG_6894:{towgs84:`-63,176,185`},EPSG_4205:{towgs84:`-43,-163,45`},EPSG_4256:{towgs84:`41,-220,-134`},EPSG_4262:{towgs84:`639,405,60`},EPSG_4604:{towgs84:`174,359,365`},EPSG_4169:{towgs84:`-115,118,426`},EPSG_4620:{towgs84:`-106,-129,165`},EPSG_4184:{towgs84:`-203,141,53`},EPSG_4616:{towgs84:`-289,-124,60`},EPSG_9403:{towgs84:`-307,-92,127`},EPSG_4684:{towgs84:`-133,-321,50`},EPSG_4708:{towgs84:`-491,-22,435`},EPSG_4707:{towgs84:`114,-116,-333`},EPSG_4709:{towgs84:`145,75,-272`},EPSG_4712:{towgs84:`-205,107,53`},EPSG_4711:{towgs84:`124,-234,-25`},EPSG_4718:{towgs84:`230,-199,-752`},EPSG_4719:{towgs84:`211,147,111`},EPSG_4724:{towgs84:`208,-435,-229`},EPSG_4725:{towgs84:`189,-79,-202`},EPSG_4735:{towgs84:`647,1777,-1124`},EPSG_4722:{towgs84:`-794,119,-298`},EPSG_4728:{towgs84:`-307,-92,127`},EPSG_4734:{towgs84:`-632,438,-609`},EPSG_4727:{towgs84:`912,-58,1227`},EPSG_4729:{towgs84:`185,165,42`},EPSG_4730:{towgs84:`170,42,84`},EPSG_4733:{towgs84:`276,-57,149`},ESRI_37218:{towgs84:`230,-199,-752`},ESRI_37240:{towgs84:`-7,215,225`},ESRI_37221:{towgs84:`252,-209,-751`},ESRI_4305:{towgs84:`-123,-206,219`},ESRI_104139:{towgs84:`-73,-247,227`},EPSG_4748:{towgs84:`51,391,-36`},EPSG_4219:{towgs84:`-384,664,-48`},EPSG_4255:{towgs84:`-333,-222,114`},EPSG_4257:{towgs84:`-587.8,519.75,145.76`},EPSG_4646:{towgs84:`-963,510,-359`},EPSG_6881:{towgs84:`-24,-203,268`},EPSG_6882:{towgs84:`-183,-15,273`},EPSG_4715:{towgs84:`-104,-129,239`},IGNF_RGF93GDD:{towgs84:`0,0,0`},IGNF_RGM04GDD:{towgs84:`0,0,0`},IGNF_RGSPM06GDD:{towgs84:`0,0,0`},IGNF_RGTAAF07GDD:{towgs84:`0,0,0`},IGNF_RGFG95GDD:{towgs84:`0,0,0`},IGNF_RGNCG:{towgs84:`0,0,0`},IGNF_RGPFGDD:{towgs84:`0,0,0`},IGNF_ETRS89G:{towgs84:`0,0,0`},IGNF_RGR92GDD:{towgs84:`0,0,0`},EPSG_4173:{towgs84:`0,0,0`},EPSG_4180:{towgs84:`0,0,0`},EPSG_4619:{towgs84:`0,0,0`},EPSG_4667:{towgs84:`0,0,0`},EPSG_4075:{towgs84:`0,0,0`},EPSG_6706:{towgs84:`0,0,0`},EPSG_7798:{towgs84:`0,0,0`},EPSG_4661:{towgs84:`0,0,0`},EPSG_4669:{towgs84:`0,0,0`},EPSG_8685:{towgs84:`0,0,0`},EPSG_4151:{towgs84:`0,0,0`},EPSG_9702:{towgs84:`0,0,0`},EPSG_4758:{towgs84:`0,0,0`},EPSG_4761:{towgs84:`0,0,0`},EPSG_4765:{towgs84:`0,0,0`},EPSG_8997:{towgs84:`0,0,0`},EPSG_4023:{towgs84:`0,0,0`},EPSG_4670:{towgs84:`0,0,0`},EPSG_4694:{towgs84:`0,0,0`},EPSG_4148:{towgs84:`0,0,0`},EPSG_4163:{towgs84:`0,0,0`},EPSG_4167:{towgs84:`0,0,0`},EPSG_4189:{towgs84:`0,0,0`},EPSG_4190:{towgs84:`0,0,0`},EPSG_4176:{towgs84:`0,0,0`},EPSG_4659:{towgs84:`0,0,0`},EPSG_3824:{towgs84:`0,0,0`},EPSG_3889:{towgs84:`0,0,0`},EPSG_4046:{towgs84:`0,0,0`},EPSG_4081:{towgs84:`0,0,0`},EPSG_4558:{towgs84:`0,0,0`},EPSG_4483:{towgs84:`0,0,0`},EPSG_5013:{towgs84:`0,0,0`},EPSG_5264:{towgs84:`0,0,0`},EPSG_5324:{towgs84:`0,0,0`},EPSG_5354:{towgs84:`0,0,0`},EPSG_5371:{towgs84:`0,0,0`},EPSG_5373:{towgs84:`0,0,0`},EPSG_5381:{towgs84:`0,0,0`},EPSG_5393:{towgs84:`0,0,0`},EPSG_5489:{towgs84:`0,0,0`},EPSG_5593:{towgs84:`0,0,0`},EPSG_6135:{towgs84:`0,0,0`},EPSG_6365:{towgs84:`0,0,0`},EPSG_5246:{towgs84:`0,0,0`},EPSG_7886:{towgs84:`0,0,0`},EPSG_8431:{towgs84:`0,0,0`},EPSG_8427:{towgs84:`0,0,0`},EPSG_8699:{towgs84:`0,0,0`},EPSG_8818:{towgs84:`0,0,0`},EPSG_4757:{towgs84:`0,0,0`},EPSG_9140:{towgs84:`0,0,0`},EPSG_8086:{towgs84:`0,0,0`},EPSG_4686:{towgs84:`0,0,0`},EPSG_4737:{towgs84:`0,0,0`},EPSG_4702:{towgs84:`0,0,0`},EPSG_4747:{towgs84:`0,0,0`},EPSG_4749:{towgs84:`0,0,0`},EPSG_4674:{towgs84:`0,0,0`},EPSG_4755:{towgs84:`0,0,0`},EPSG_4759:{towgs84:`0,0,0`},EPSG_4762:{towgs84:`0,0,0`},EPSG_4763:{towgs84:`0,0,0`},EPSG_4764:{towgs84:`0,0,0`},EPSG_4166:{towgs84:`0,0,0`},EPSG_4170:{towgs84:`0,0,0`},EPSG_5546:{towgs84:`0,0,0`},EPSG_7844:{towgs84:`0,0,0`},EPSG_4818:{towgs84:`589,76,480`},EPSG_10328:{towgs84:`0,0,0`},EPSG_9782:{towgs84:`0,0,0`},EPSG_9777:{towgs84:`0,0,0`},EPSG_10690:{towgs84:`0,0,0`},EPSG_10639:{towgs84:`0,0,0`},EPSG_10739:{towgs84:`0,0,0`},EPSG_7686:{towgs84:`0,0,0`},EPSG_8900:{towgs84:`0,0,0`},EPSG_5886:{towgs84:`0,0,0`},EPSG_7683:{towgs84:`0,0,0`},EPSG_6668:{towgs84:`0,0,0`},EPSG_20046:{towgs84:`0,0,0`},EPSG_10299:{towgs84:`0,0,0`},EPSG_10310:{towgs84:`0,0,0`},EPSG_10475:{towgs84:`0,0,0`},EPSG_4742:{towgs84:`0,0,0`},EPSG_10671:{towgs84:`0,0,0`},EPSG_10762:{towgs84:`0,0,0`},EPSG_10725:{towgs84:`0,0,0`},EPSG_10791:{towgs84:`0,0,0`},EPSG_10800:{towgs84:`0,0,0`},EPSG_10305:{towgs84:`0,0,0`},EPSG_10941:{towgs84:`0,0,0`},EPSG_10968:{towgs84:`0,0,0`},EPSG_10875:{towgs84:`0,0,0`},EPSG_6318:{towgs84:`0,0,0`},EPSG_10910:{towgs84:`0,0,0`}},j5)M5=j5[e],M5.datumName&&(j5[M5.datumName]=M5);N5={},K1.projections=O5,K1.projections.start(),P5=K1(`WGS84`),F5=6,I5=`AJSAJS`,L5=`AFAFAF`,R5=65,z5=73,B5=79,V5=86,H5=90,U5={forward:f0,inverse:p0,toPoint:m0},O0.fromMGRS=function(e){return new O0(m0(e))},O0.prototype.toMGRS=function(e){return f0([this.x,this.y],e)},W5=1,G5=.25,K5=.046875,q5=.01953125,J5=.01068115234375,Y5=.75,X5=.46875,Z5=.013020833333333334,Q5=.007120768229166667,$5=.3645833333333333,e7=.005696614583333333,t7=.3076171875,n7=20,r7={init:M0,forward:N0,inverse:P0,names:[`Fast_Transverse_Mercator`,`Fast Transverse Mercator`]},i7={init:U0,forward:W0,inverse:G0,names:[`Extended_Transverse_Mercator`,`Extended Transverse Mercator`,`etmerc`,`Transverse_Mercator`,`Transverse Mercator`,`Gauss Kruger`,`Gauss_Kruger`,`tmerc`]},a7=`etmerc`,o7={init:q0,names:[`Universal Transverse Mercator System`,`utm`],dependsOn:a7},s7=20,c7={init:Y0,forward:X0,inverse:Z0,names:[`gauss`]},l7={init:Q0,forward:$0,inverse:e2,names:[`Stereographic_North_Pole`,`Oblique_Stereographic`,`sterea`,`Oblique Stereographic Alternative`,`Double_Stereographic`]},u7={init:n2,forward:r2,inverse:i2,names:[`stere`,`Stereographic_South_Pole`,`Polar_Stereographic_variant_A`,`Polar_Stereographic_variant_B`,`Polar_Stereographic`],ssfn_:t2},d7={init:a2,forward:o2,inverse:s2,names:[`somerc`]},f7=1e-7,p7={init:l2,forward:u2,inverse:d2,names:[`Hotine_Oblique_Mercator`,`Hotine Oblique Mercator`,`Hotine_Oblique_Mercator_variant_A`,`Hotine_Oblique_Mercator_Variant_B`,`Hotine_Oblique_Mercator_Azimuth_Natural_Origin`,`Hotine_Oblique_Mercator_Two_Point_Natural_Origin`,`Hotine_Oblique_Mercator_Azimuth_Center`,`Oblique_Mercator`,`omerc`]},m7={init:f2,forward:p2,inverse:m2,names:[`Lambert Tangential Conformal Conic Projection`,`Lambert_Conformal_Conic`,`Lambert_Conformal_Conic_1SP`,`Lambert_Conformal_Conic_2SP`,`lcc`,`Lambert Conic Conformal (1SP)`,`Lambert Conic Conformal (2SP)`]},h7={init:h2,forward:g2,inverse:_2,names:[`Krovak`,`Krovak Modified`,`Krovak (North Orientated)`,`Krovak Modified (North Orientated)`,`krovak`]},g7={init:E2,forward:D2,inverse:O2,names:[`Cassini`,`Cassini_Soldner`,`cass`]},_7=.3333333333333333,v7=.17222222222222222,y7=.10257936507936508,b7=.06388888888888888,x7=.0664021164021164,S7=.016415012942191543,C7={init:A2,forward:j2,inverse:M2,names:[`Lambert Azimuthal Equal Area`,`Lambert_Azimuthal_Equal_Area`,`laea`],S_POLE:1,N_POLE:2,EQUIT:3,OBLIQ:4},w7={init:I2,forward:L2,inverse:R2,names:[`Albers_Conic_Equal_Area`,`Albers_Equal_Area`,`Albers`,`aea`],phi1z:z2},T7={init:B2,forward:V2,inverse:H2,names:[`gnom`]},E7={init:W2,forward:G2,inverse:K2,names:[`cea`]},D7={init:q2,forward:J2,inverse:Y2,names:[`Equirectangular`,`Equidistant_Cylindrical`,`Equidistant_Cylindrical_Spherical`,`eqc`]},O7=20,k7={init:X2,forward:Z2,inverse:Q2,names:[`Polyconic`,`American_Polyconic`,`poly`]},A7={init:$2,forward:e4,inverse:t4,names:[`New_Zealand_Map_Grid`,`nzmg`]},j7={init:n4,forward:r4,inverse:i4,names:[`Miller_Cylindrical`,`mill`]},M7=20,N7={init:a4,forward:o4,inverse:s4,names:[`Sinusoidal`,`sinu`]},P7={init:c4,forward:l4,inverse:u4,names:[`Mollweide`,`moll`]},F7={init:d4,forward:f4,inverse:p4,names:[`Equidistant_Conic`,`eqdc`]},I7={init:m4,forward:h4,inverse:g4,names:[`Van_der_Grinten_I`,`VanDerGrinten`,`Van_der_Grinten`,`vandg`]},L7={init:y4,forward:b4,inverse:x4,names:[`Azimuthal_Equidistant`,`aeqd`]},R7={init:S4,forward:C4,inverse:w4,names:[`ortho`]},z7={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},B7={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4},V7={init:T4,forward:E4,inverse:D4,names:[`Quadrilateralized Spherical Cube`,`Quadrilateralized_Spherical_Cube`,`qsc`]},H7=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-9.86701e-7],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,1.8736e-8],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,9.34959e-7],[.7986,-.00755338,-500009e-10,9.35324e-7],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],U7=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,422642e-15],[.124,.0124,5.07171e-9,-1.60604e-9],[.186,.0123999,-1.90189e-8,6.00152e-9],[.248,.0124002,7.10039e-8,-2.24e-8],[.31,.0123992,-2.64997e-7,8.35986e-8],[.372,.0124029,9.88983e-7,-3.11994e-7],[.434,.0123893,-369093e-11,-4.35621e-7],[.4958,.0123198,-102252e-10,-3.45523e-7],[.5571,.0121916,-154081e-10,-5.82288e-7],[.6176,.0119938,-241424e-10,-5.25327e-7],[.6769,.011713,-320223e-10,-5.16405e-7],[.7346,.0113541,-397684e-10,-6.09052e-7],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-1.40374e-9],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],W7=.8487,G7=1.3523,K7=Q8/5,q7=1/K7,J7=18,Y7=function(e,t){return e[0]+t*(e[1]+t*(e[2]+t*e[3]))},X7=function(e,t){return e[1]+t*(2*e[2]+t*3*e[3])},Z7={init:j4,forward:M4,inverse:N4,names:[`Robinson`,`robin`]},Q7={init:P4,forward:F4,inverse:I4,names:[`Geocentric`,`geocentric`,`geocent`,`Geocent`]},$7={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3},e9={h:{def:1e5,num:!0},azi:{def:0,num:!0,degrees:!0},tilt:{def:0,num:!0,degrees:!0},long0:{def:0,num:!0},lat0:{def:0,num:!0}},t9={init:L4,forward:R4,inverse:z4,names:[`Tilted_Perspective`,`tpers`]},n9={init:B4,forward:V4,inverse:H4,names:[`Geostationary Satellite View`,`Geostationary_Satellite`,`geos`]},r9=1.340264,i9=-.081106,a9=893e-6,o9=.003796,s9=Math.sqrt(3)/2,c9={init:U4,forward:W4,inverse:G4,names:[`eqearth`,`Equal Earth`,`Equal_Earth`]},l9=1e-10,u9={init:K4,names:[`bonne`,`Bonne (Werner lat_1=90)`]},d9={OBLIQUE:{forward:t3,inverse:r3},TRANSVERSE:{forward:n3,inverse:i3}},f9={ROTATE:{o_alpha:`oAlpha`,o_lon_c:`oLongC`,o_lat_c:`oLatC`},NEW_POLE:{o_lat_p:`oLatP`,o_lon_p:`oLongP`},NEW_EQUATOR:{o_lon_1:`oLong1`,o_lat_1:`oLat1`,o_lon_2:`oLong2`,o_lat_2:`oLat2`}},p9={init:Z4,forward:Q4,inverse:$4,names:[`General Oblique Transformation`,`General_Oblique_Transformation`,`ob_tran`]},m9=Object.assign(d0,{defaultDatum:`WGS84`,Proj:K1,WGS84:new K1(`WGS84`),Point:O0,toPoint:i0,defs:s1,nadgrid:M1,transform:c0,mgrs:U5,version:`__VERSION__`}),a3(m9),h9={GpsTime:{arrayType:`float64`},ReturnNumber:{arrayType:`uint8`},NumberOfReturns:{arrayType:`uint8`},ScanDirectionFlag:{arrayType:`uint8`},EdgeOfFlightLine:{arrayType:`uint8`},ScanAngleRank:{arrayType:`int8`},ScanAngle:{arrayType:`float32`},UserData:{arrayType:`uint8`},PointSourceId:{arrayType:`uint16`},ScannerChannel:{arrayType:`uint8`},Synthetic:{arrayType:`uint8`},KeyPoint:{arrayType:`uint8`},Withheld:{arrayType:`uint8`},Overlap:{arrayType:`uint8`},ClassFlags:{arrayType:`uint8`},Nir:{arrayType:`uint16`},NearInfrared:{arrayType:`uint16`}},g9=new Set([`X`,`Y`,`Z`,`Intensity`,`Classification`,`Red`,`Green`,`Blue`]),_9=null,v9=class{constructor(){}_onProgress;async load(e,t){if(this._onProgress=t,typeof e==`string`){if(e.startsWith(`http://`)||e.startsWith(`https://`))return await this._loadCopcFromUrl(e);{this._reportProgress(5,`Fetching file...`);let t=await(await fetch(e)).arrayBuffer();return await this._loadCopcFromBuffer(t)}}else if(e instanceof File){this._reportProgress(5,`Reading file...`);let t=await e.arrayBuffer();return await this._loadCopcFromBuffer(t)}else return await this._loadCopcFromBuffer(e)}_reportProgress(e,t){this._onProgress&&this._onProgress(e,t)}async _yieldToUI(){return new Promise(e=>setTimeout(e,0))}async _loadCopcFromUrl(e){this._reportProgress(5,`Initializing decoder...`),await this._yieldToUI();let t=await s3();this._reportProgress(10,`Reading file header...`),await this._yieldToUI();let n;try{n=await H8.Copc.create(e)}catch(t){if(t instanceof TypeError&&t.message===`Failed to fetch`)throw Error(`Failed to fetch from URL. This is likely a CORS (Cross-Origin Resource Sharing) error. The server at "${new URL(e).hostname}" doesn't allow requests from this origin. Solutions: (1) Download the file locally and load it as a file, (2) Use a CORS proxy, or (3) Host the file on a CORS-enabled server.`);if(t instanceof Error&&(t.message.includes(`Invalid version`)||t.message.includes(`COPC info VLR is required`)))return console.warn(`copc.js cannot load this file, falling back to loaders.gl:`,t.message),this._reportProgress(10,`Using alternative decoder...`),await this._loadUrlWithLoadersGL(e);throw t}this._reportProgress(15,`Loading hierarchy...`),await this._yieldToUI();let r=await this._loadFullHierarchy(e,n.info);return await this._processCopcData(e,n,r,t)}async _loadCopcFromBuffer(e){this._reportProgress(10,`Initializing decoder...`),await this._yieldToUI();let t=await s3(),n=c3(e);this._reportProgress(15,`Reading file header...`),await this._yieldToUI();try{let e=await H8.Copc.create(n);this._reportProgress(20,`Loading hierarchy...`),await this._yieldToUI();let r=await this._loadFullHierarchy(n,e.info);return await this._processCopcData(n,e,r,t)}catch(n){if(n instanceof Error){if(n.message.includes(`COPC info VLR is required`)){console.warn(`Not a COPC file, trying to load as regular LAS:`,n.message),this._reportProgress(15,`Loading as regular LAS file...`);try{return await this._loadRegularLasFromBuffer(e,t)}catch(t){return console.warn(`Las module failed, falling back to loaders.gl:`,t),await this._loadWithLoadersGL(e)}}if(n.message.includes(`Invalid version`))return console.warn(`copc.js does not support this LAS version, falling back to loaders.gl:`,n.message),this._reportProgress(15,`Using alternative decoder...`),await this._loadWithLoadersGL(e)}throw n}}async _loadRegularLasFromBuffer(e,t){this._reportProgress(20,`Parsing LAS header...`),await this._yieldToUI();let n=new Uint8Array(e),r=H8.Las.Header.parse(n),i=(r.pointDataRecordFormat&128)!=0||r.generatingSoftware.toLowerCase().includes(`laszip`),a;i?(this._reportProgress(30,`Decompressing LAZ data...`),await this._yieldToUI(),a=await H8.Las.PointData.decompressFile(n,t)):a=n.slice(r.pointDataOffset),this._reportProgress(50,`Processing points...`),await this._yieldToUI();let o=null,s=!1,c=1,l,u=c3(e);try{let e=await H8.Las.Vlr.walk(u,r);for(let t of e)if(t.userId===`LASF_Projection`&&t.recordId===2112){let e=await H8.Las.Vlr.fetch(u,t);l=new TextDecoder().decode(e).replace(/\0/g,``);break}}catch(e){console.warn(`Failed to read VLRs:`,e)}if(l)try{let e=m9(l3(l),`EPSG:4326`);o=t=>e.forward(t),s=!0,c=u3(l)}catch(e){console.warn(`Failed to setup coordinate transformation:`,e)}let d=r.pointDataRecordFormat&127,f=H8.Las.View.create(a,r),p,m;if(s&&o){let[e,t]=o([r.min[0],r.min[1]]),[n,i]=o([r.max[0],r.max[1]]);p={minX:Math.min(e,n),minY:Math.min(t,i),minZ:r.min[2]*c,maxX:Math.max(e,n),maxY:Math.max(t,i),maxZ:r.max[2]*c}}else p={minX:r.min[0],minY:r.min[1],minZ:r.min[2],maxX:r.max[0],maxY:r.max[1],maxZ:r.max[2]};m=[(p.minX+p.maxX)/2,(p.minY+p.maxY)/2,0];let h=r.pointCount;this._reportProgress(60,`Allocating memory for ${h.toLocaleString()} points...`),await this._yieldToUI();let g=new Float32Array(h*3),_=new Float32Array(h),v=new Uint8Array(h),y=[2,3,5,7,8,10].includes(d),b;y&&(b=new Uint8Array(h*4));let x=f.getter(`X`),S=f.getter(`Y`),C=f.getter(`Z`),w=f.getter(`Intensity`),T=f.getter(`Classification`),E=y?f.getter(`Red`):null,D=y?f.getter(`Green`):null,O=y?f.getter(`Blue`):null;this._reportProgress(70,`Processing point coordinates...`),await this._yieldToUI();for(let e=0;e<h;e++){let t=x(e),n=S(e),r=C(e)*c;if(s&&o){let[i,a]=o([t,n]);g[e*3]=i-m[0],g[e*3+1]=a-m[1],g[e*3+2]=r}else g[e*3]=t-m[0],g[e*3+1]=n-m[1],g[e*3+2]=r;if(_[e]=w(e)/65535,v[e]=T(e),y&&b&&E&&D&&O&&(b[e*4]=E(e)>>8,b[e*4+1]=D(e)>>8,b[e*4+2]=O(e)>>8,b[e*4+3]=255),e%1e5==0&&e>0){let t=70+e/h*25;this._reportProgress(t,`Processing points... ${e.toLocaleString()} / ${h.toLocaleString()}`),await this._yieldToUI()}}return this._reportProgress(95,`Finalizing...`),{positions:g,intensities:_,classifications:v,colors:b,pointCount:h,bounds:p,hasRGB:y,hasIntensity:!0,hasClassification:!0,coordinateOrigin:m,wkt:l}}async _loadWithLoadersGL(e){this._reportProgress(20,`Parsing point cloud data...`),await this._yieldToUI();let t=await j$(e,B8,{las:{shape:`mesh`,fp64:!1},worker:!1});this._reportProgress(50,`Processing points...`),await this._yieldToUI();let n=t.loaderData||{},r=n.header||{},i=r.pointsCount||r.vertexCount||(t.attributes?.POSITION?.value?.length?t.attributes.POSITION.value.length/3:0),a=(t.attributes?.POSITION||t.attributes?.positions)?.value;if(!a||i===0)throw Error(`No point data found in file`);let o=null,s=!1,c=1,l;if(n.vlrs)for(let e of n.vlrs)e.userId===`LASF_Projection`&&e.recordId===2112&&(l=new TextDecoder().decode(e.data));if(l=l||r.wkt||r.projection?.wkt,l)try{let e=m9(l3(l),`EPSG:4326`);o=t=>e.forward(t),s=!0,c=u3(l)}catch(e){console.warn(`Failed to setup coordinate transformation:`,e)}let u=a[0],d=a[1];(Math.abs(u)>180||Math.abs(d)>90)&&!s&&console.warn(`Point cloud appears to be in a projected coordinate system but no WKT/projection info was found. Coordinates may not display correctly on the map.`);let f=1/0,p=1/0,m=1/0,h=-1/0,g=-1/0,_=-1/0;for(let e=0;e<i;e++){let t=a[e*3],n=a[e*3+1],r=a[e*3+2];if(s&&o){let[e,r]=o([t,n]);f=Math.min(f,e),h=Math.max(h,e),p=Math.min(p,r),g=Math.max(g,r)}else f=Math.min(f,t),h=Math.max(h,t),p=Math.min(p,n),g=Math.max(g,n);let i=r*c;m=Math.min(m,i),_=Math.max(_,i)}if(Math.abs(p)>90||Math.abs(g)>90||Math.abs(f)>180||Math.abs(h)>180)throw Error(`Point cloud coordinates are not in WGS84 (latitude/longitude) format. The file appears to use a projected coordinate system but no valid projection information was found. Please ensure the LAS file contains proper CRS metadata (WKT in VLR records).`);let v={minX:f,minY:p,minZ:m,maxX:h,maxY:g,maxZ:_},y=[(v.minX+v.maxX)/2,(v.minY+v.maxY)/2,0];this._reportProgress(70,`Allocating arrays...`),await this._yieldToUI();let b=new Float32Array(i*3),x=new Float32Array(i),S=new Uint8Array(i),C=t.attributes?.COLOR_0||t.attributes?.colors,w=C?.value,T=w&&w.length>=i*3,E;T&&(E=new Uint8Array(i*4));let D=t.attributes?.intensity?.value,O=D&&D.length>=i,k=t.attributes?.classification?.value,A=k&&k.length>=i;this._reportProgress(80,`Transforming coordinates...`),await this._yieldToUI();for(let e=0;e<i;e++){let t=a[e*3],n=a[e*3+1],r=a[e*3+2]*c;if(s&&o){let[i,a]=o([t,n]);b[e*3]=i-y[0],b[e*3+1]=a-y[1],b[e*3+2]=r}else b[e*3]=t-y[0],b[e*3+1]=n-y[1],b[e*3+2]=r;O&&(x[e]=D[e]/65535),A&&(S[e]=k[e]),T&&E&&((C.size||3)===4?(E[e*4]=w[e*4],E[e*4+1]=w[e*4+1],E[e*4+2]=w[e*4+2],E[e*4+3]=w[e*4+3]):(E[e*4]=w[e*3],E[e*4+1]=w[e*3+1],E[e*4+2]=w[e*3+2],E[e*4+3]=255))}return this._reportProgress(95,`Finalizing...`),{positions:b,intensities:x,classifications:S,colors:E,pointCount:i,bounds:v,hasRGB:T,hasIntensity:O,hasClassification:A,coordinateOrigin:y,wkt:l}}async _loadUrlWithLoadersGL(e){this._reportProgress(15,`Downloading file...`),await this._yieldToUI();let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch: ${t.status} ${t.statusText}`);let n=await t.arrayBuffer();return await this._loadWithLoadersGL(n)}async _loadFullHierarchy(e,t){let n={},r=async t=>{let i=await H8.Hierarchy.load(e,t);for(let[e,t]of Object.entries(i.nodes))t&&(n[e]=t);for(let[,e]of Object.entries(i.pages))e&&await r(e)};return await r(t.rootHierarchyPage),{nodes:n,pages:{}}}async _processCopcData(e,t,n,r){let{header:i}=t,a=null,o=!1,s=1;if(t.wkt)try{let e=m9(l3(t.wkt),`EPSG:4326`);a=t=>e.forward(t),o=!0,s=u3(t.wkt)}catch(e){console.warn(`Failed to setup coordinate transformation:`,e)}let c=[];for(let[e,t]of Object.entries(n.nodes))t&&c.push({key:e,node:t});let l=c.reduce((e,{node:t})=>e+t.pointCount,0),u,d;if(o&&a){let[e,t]=a([i.min[0],i.min[1]]),[n,r]=a([i.max[0],i.max[1]]);u={minX:Math.min(e,n),minY:Math.min(t,r),minZ:i.min[2]*s,maxX:Math.max(e,n),maxY:Math.max(t,r),maxZ:i.max[2]*s},d=[(u.minX+u.maxX)/2,(u.minY+u.maxY)/2,0]}else u={minX:i.min[0],minY:i.min[1],minZ:i.min[2],maxX:i.max[0],maxY:i.max[1],maxZ:i.max[2]},d=[(u.minX+u.maxX)/2,(u.minY+u.maxY)/2,0];this._reportProgress(25,`Allocating memory for ${l.toLocaleString()} points...`),await this._yieldToUI();let f=new Float32Array(l*3),p=new Float32Array(l),m=new Uint8Array(l),h,g=[2,3,5,7,8,10].includes(i.pointDataRecordFormat);g&&(h=new Uint8Array(l*4));let _={},v=new Set,y=!1,b=0,x=Date.now();for(let n=0;n<c.length;n++){let{node:i}=c[n],u=25+n/c.length*65,S=b.toLocaleString();this._reportProgress(u,`Loading points... ${S} / ${l.toLocaleString()}`);try{let n=await H8.Copc.loadPointDataView(e,t,i,{lazPerf:r});if(!y){let e=Object.keys(n.dimensions||{});for(let t of e)g9.has(t)||(v.add(t),_[t]=o3((h9[t]||{arrayType:`float32`}).arrayType,l));y=!0}let c=n.getter(`X`),u=n.getter(`Y`),S=n.getter(`Z`),C=n.getter(`Intensity`),w=n.getter(`Classification`),T=g?n.getter(`Red`):null,E=g?n.getter(`Green`):null,D=g?n.getter(`Blue`):null,O=new Map;for(let e of v)try{let t=n.getter(e);t&&O.set(e,t)}catch{}for(let e=0;e<i.pointCount;e++){let t=c(e),n=u(e),r=S(e);if(o&&a){let[e,i]=a([t,n]);f[b*3]=e-d[0],f[b*3+1]=i-d[1],f[b*3+2]=r*s}else f[b*3]=t-d[0],f[b*3+1]=n-d[1],f[b*3+2]=r;p[b]=C(e)/65535,m[b]=w(e),h&&T&&E&&D&&(h[b*4]=T(e)>>8,h[b*4+1]=E(e)>>8,h[b*4+2]=D(e)>>8,h[b*4+3]=255);for(let[t,n]of O){let r=_[t];r&&(r[b]=n(e))}if(b++,e%5e4==0){let e=Date.now();e-x>50&&(await this._yieldToUI(),x=e)}}}catch(e){console.warn(`Failed to load node: ${e}`)}}this._reportProgress(92,`Processing complete, preparing visualization...`);let S={};for(let[e,t]of Object.entries(_))S[e]=t.subarray(0,b);return{positions:f.subarray(0,b*3),coordinateOrigin:d,colors:h?.subarray(0,b*4),intensities:p.subarray(0,b),classifications:m.subarray(0,b),extraAttributes:Object.keys(S).length>0?S:void 0,pointCount:b,bounds:u,hasRGB:!!h,hasIntensity:!0,hasClassification:!0,wkt:t.wkt}}},m9.defs(`EPSG:2180`,`+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs`),y9={GpsTime:{arrayType:`float64`},ReturnNumber:{arrayType:`uint8`},NumberOfReturns:{arrayType:`uint8`},ScanDirectionFlag:{arrayType:`uint8`},EdgeOfFlightLine:{arrayType:`uint8`},ScanAngleRank:{arrayType:`int8`},ScanAngle:{arrayType:`float32`},UserData:{arrayType:`uint8`},PointSourceId:{arrayType:`uint16`},ScannerChannel:{arrayType:`uint8`},Synthetic:{arrayType:`uint8`},KeyPoint:{arrayType:`uint8`},Withheld:{arrayType:`uint8`},Overlap:{arrayType:`uint8`},ClassFlags:{arrayType:`uint8`},Nir:{arrayType:`uint16`},NearInfrared:{arrayType:`uint16`}},b9=new Set([`X`,`Y`,`Z`,`Intensity`,`Classification`,`Red`,`Green`,`Blue`]),x9=null,S9={pointBudget:5e6,maxConcurrentRequests:8,viewportDebounceMs:100,minDetailZoom:10,maxOctreeDepth:20,maxSubtreesPerViewport:60},C9=class{_originalSource;_source=null;_copc=null;_lazPerf=null;_options;_hierarchyPages=new Map;_loadedHierarchyKeys=new Set;_rootHierarchyPage=null;_nodeCache=new Map;_positions=null;_colors=null;_intensities=null;_classifications=null;_extraAttributes={};_coordinateOrigin=[0,0,0];_bounds=null;_loadingQueue=[];_activeRequests=0;_totalLoadedPoints=0;_totalLoadedNodes=0;_isInitialized=!1;_transformer=null;_verticalUnitFactor=1;_needsTransform=!1;_hasColor=!1;_totalPointsInFile=0;_octreeCube=[];_spacing=0;_spacingInMeters=0;_availableDimensions=new Set;_dimensionsDetected=!1;_eventHandlers=new Map;_pendingLayerUpdate=!1;_updateBatchTimeout=null;_onPointsLoaded;constructor(e,t){this._originalSource=e,this._options={...S9,...t}}async initialize(){if(this._lazPerf=await p3(),typeof this._originalSource==`string`){this._source=this._originalSource;try{this._copc=await H8.Copc.create(this._source)}catch(e){throw e instanceof TypeError&&e.message===`Failed to fetch`?Error(`Failed to fetch from URL. This is likely a CORS (Cross-Origin Resource Sharing) error. The server at "${new URL(this._source).hostname}" doesn't allow requests from this origin. Solutions: (1) Download the file locally and load it as a file, (2) Use a CORS proxy, or (3) Host the file on a CORS-enabled server.`):e}}else if(this._originalSource instanceof File){let e=await this._originalSource.arrayBuffer();this._source=d3(e),this._copc=await H8.Copc.create(this._source)}else this._source=d3(this._originalSource),this._copc=await H8.Copc.create(this._source);let{header:e,info:t}=this._copc;this._rootHierarchyPage=t.rootHierarchyPage,this._octreeCube=t.cube,this._spacing=t.spacing,this._totalPointsInFile=e.pointCount;let n=[2,3,5,7,8,10];if(this._hasColor=n.includes(e.pointDataRecordFormat),this._copc.wkt)try{let e=m9(m3(this._copc.wkt),`EPSG:4326`);this._transformer=t=>e.forward(t),this._needsTransform=!0,this._verticalUnitFactor=h3(this._copc.wkt)}catch(e){console.warn(`Failed to setup coordinate transformation:`,e)}else{let t=e.min[0],n=e.min[1],r=e.max[0],i=e.max[1],a=null;if(t>=1e5&&r<=9e5&&n>=1e5&&i<=8e5&&(a=`EPSG:2180`),a)try{let e=m9(a,`EPSG:4326`);this._transformer=t=>e.forward(t),this._needsTransform=!0}catch(e){console.warn(`Failed to setup coordinate transformation from ${a}:`,e)}}if(this._needsTransform&&this._transformer){let[t,n]=this._transformer([e.min[0],e.min[1]]),[r,i]=this._transformer([e.max[0],e.max[1]]),[a,o]=g3(t,n,`header bounds min`),[s,c]=g3(r,i,`header bounds max`);this._bounds={minX:Math.min(a,s),minY:Math.min(o,c),minZ:e.min[2]*this._verticalUnitFactor,maxX:Math.max(a,s),maxY:Math.max(o,c),maxZ:e.max[2]*this._verticalUnitFactor}}else this._bounds={minX:e.min[0],minY:e.min[1],minZ:e.min[2],maxX:e.max[0],maxY:e.max[1],maxZ:e.max[2]};if(this._coordinateOrigin=[(this._bounds.minX+this._bounds.maxX)/2,(this._bounds.minY+this._bounds.maxY)/2,0],!this._needsTransform&&Math.abs(e.min[0])<=180&&Math.abs(e.max[0])<=180&&Math.abs(e.min[1])<=90&&Math.abs(e.max[1])<=90){let e=(this._bounds.minY+this._bounds.maxY)/2,t=111320*Math.cos(e*Math.PI/180);this._spacingInMeters=this._spacing*Math.max(t,1)}else this._spacingInMeters=this._spacing;return this._allocateBuffers(),this._isInitialized=!0,{bounds:this._bounds,totalPoints:this._totalPointsInFile,hasRGB:this._hasColor,spacing:this._spacingInMeters}}_allocateBuffers(){let e=this._options.pointBudget;this._positions=new Float32Array(e*3),this._intensities=new Float32Array(e),this._classifications=new Uint8Array(e),this._hasColor&&(this._colors=new Uint8Array(e*4))}getSpacing(){return this._spacingInMeters}_parseNodeKey(e){let t=e.split(`-`).map(Number);return[t[0],t[1],t[2],t[3]]}_calculateNodeBounds(e){let[t,n,r,i]=e,a=this._octreeCube,o=a[0],s=a[1],c=a[2],l=(a[3]-o)*(1/2**t),u=o+n*l,d=s+r*l,f=c+i*l,p={minX:u,minY:d,minZ:f,maxX:u+l,maxY:d+l,maxZ:f+l},m=p;if(this._needsTransform&&this._transformer){let[e,t]=this._transformer([u,d]),[n,r]=this._transformer([u+l,d+l]),[i,a]=g3(e,t,`node bounds SW`),[o,s]=g3(n,r,`node bounds NE`);m={minX:Math.min(i,o),minY:Math.min(a,s),minZ:f*this._verticalUnitFactor,maxX:Math.max(i,o),maxY:Math.max(a,s),maxZ:(f+l)*this._verticalUnitFactor}}return{bounds:p,boundsWgs84:m}}_boundsIntersectsViewport(e,t){let[n,r,i,a]=t.bounds,o=i-n,s=a-r,c=o*.2,l=s*.2,u=n-c,d=i+c,f=r-l,p=a+l;return!(e.maxX<u||e.minX>d||e.maxY<f||e.minY>p)}_calculateNodePriority(e,t){let n=(e.minX+e.maxX)/2,r=(e.minY+e.maxY)/2,i=n-t.center[0],a=r-t.center[1];return Math.sqrt(i*i+a*a)}async _ensureHierarchyLoaded(e){this._loadedHierarchyKeys.has(e)||this._rootHierarchyPage&&this._hierarchyPages.size===0&&await this._loadHierarchyRecursive(this._rootHierarchyPage)}async _loadHierarchyRecursive(e){let t=await H8.Hierarchy.load(this._source,e);for(let[e,n]of Object.entries(t.nodes))if(n&&(this._loadedHierarchyKeys.add(e),!this._nodeCache.has(e))){let t=this._parseNodeKey(e),{bounds:r,boundsWgs84:i}=this._calculateNodeBounds(t);this._nodeCache.set(e,{key:e,keyArray:t,state:`pending`,pointCount:n.pointCount,pointDataOffset:n.pointDataOffset,pointDataLength:n.pointDataLength,bounds:r,boundsWgs84:i})}for(let[,e]of Object.entries(t.pages))e&&await this._loadHierarchyRecursive(e)}async selectNodesForViewport(e){if(!this._isInitialized)throw Error(`CopcStreamingLoader not initialized. Call initialize() first.`);await this._ensureHierarchyLoaded(`0-0-0-0`);let t=[],n=e.targetDepth;for(let[,r]of this._nodeCache){let i=r.keyArray[0];i>n+1||this._boundsIntersectsViewport(r.boundsWgs84,e)&&r.state!==`loaded`&&r.state!==`loading`&&(r.priority=this._calculateNodePriority(r.boundsWgs84,e)-i*1e-4,t.push(r))}return t.sort((e,t)=>(e.priority||1/0)-(t.priority||1/0)),t}queueNode(e){e.state===`pending`&&(this._loadingQueue.find(t=>t.key===e.key)||(this._loadingQueue.push(e),this._loadingQueue.sort((e,t)=>(e.priority||1/0)-(t.priority||1/0))))}async loadQueuedNodes(){for(;this._loadingQueue.length>0&&this._activeRequests<this._options.maxConcurrentRequests&&this._totalLoadedPoints<this._options.pointBudget;){let e=this._loadingQueue.shift();if(this._totalLoadedPoints+e.pointCount>this._options.pointBudget){this._emit(`budgetreached`,this._getProgressEvent());break}this._loadNode(e)}}pruneQueueForViewport(e){if(this._loadingQueue.length!==0){this._loadingQueue=this._loadingQueue.filter(t=>this._boundsIntersectsViewport(t.boundsWgs84,e));for(let t of this._loadingQueue)t.priority=this._calculateNodePriority(t.boundsWgs84,e)-t.keyArray[0]*1e-4;this._loadingQueue.sort((e,t)=>(e.priority||1/0)-(t.priority||1/0))}}evictLoadedNodesOutsideViewport(e){if(this._activeRequests>0)return!1;let t=Array.from(this._nodeCache.values()).filter(e=>e.state===`loaded`&&e.bufferStartIndex!==void 0);if(t.length===0)return!0;let n=t.filter(t=>this._boundsIntersectsViewport(t.boundsWgs84,e)).sort((e,t)=>e.bufferStartIndex-t.bufferStartIndex),r=new Set(n.map(e=>e.key)),i=0;for(let e of n){let t=e.bufferStartIndex;t!==i&&this._copyNodeBufferRange(t,i,e.pointCount),e.bufferStartIndex=i,i+=e.pointCount}let a=0;for(let e of this._nodeCache.values())e.state===`loaded`&&r.has(e.key)||e.state!==`loaded`&&e.state!==`error`||(e.state=`pending`,e.bufferStartIndex=void 0,e.error=void 0,e.priority=void 0,a++);let o=i!==this._totalLoadedPoints;return(a>0||o)&&(this._totalLoadedPoints=i,this._totalLoadedNodes=n.length,this._emit(`progress`,this._getProgressEvent()),this._scheduleLayerUpdate()),!0}resetLoadedData(){if(this._activeRequests>0)return!1;this._loadingQueue=[],this._totalLoadedPoints=0,this._totalLoadedNodes=0;for(let e of this._nodeCache.values())(e.state===`loaded`||e.state===`loading`||e.state===`error`)&&(e.state=`pending`,e.bufferStartIndex=void 0,e.error=void 0,e.priority=void 0);return this._emit(`progress`,this._getProgressEvent()),this._scheduleLayerUpdate(),!0}_copyNodeBufferRange(e,t,n){this._positions.copyWithin(t*3,e*3,(e+n)*3),this._intensities.copyWithin(t,e,e+n),this._classifications.copyWithin(t,e,e+n),this._colors&&this._colors.copyWithin(t*4,e*4,(e+n)*4);for(let r of Object.values(this._extraAttributes))r.copyWithin(t,e,e+n)}async _loadNode(e){if(e.state===`loaded`||e.state===`loading`)return;e.state=`loading`,this._activeRequests++;let t=this._totalLoadedPoints;e.bufferStartIndex=t,this._totalLoadedPoints+=e.pointCount;try{let n={pointCount:e.pointCount,pointDataOffset:e.pointDataOffset,pointDataLength:e.pointDataLength},r=await H8.Copc.loadPointDataView(this._source,this._copc,n,{lazPerf:this._lazPerf});if(!this._dimensionsDetected){let e=Object.keys(r.dimensions||{});for(let t of e)if(!b9.has(t)){this._availableDimensions.add(t);let e=y9[t]||{arrayType:`float32`};this._extraAttributes[t]=f3(e.arrayType,this._options.pointBudget)}this._dimensionsDetected=!0}await this._extractPointData(r,e,t),e.state=`loaded`,this._totalLoadedNodes++,this._emit(`nodeloaded`,e),this._emit(`progress`,this._getProgressEvent()),this._scheduleLayerUpdate()}catch(t){e.state=`error`,e.error=t instanceof Error?t.message:String(t),console.warn(`Failed to load node ${e.key}:`,t),this._emit(`error`,t)}finally{this._activeRequests--,this.loadQueuedNodes()}}async _extractPointData(e,t,n){let r=e.getter(`X`),i=e.getter(`Y`),a=e.getter(`Z`),o=e.getter(`Intensity`),s=e.getter(`Classification`),c=this._hasColor?e.getter(`Red`):null,l=this._hasColor?e.getter(`Green`):null,u=this._hasColor?e.getter(`Blue`):null,d=new Map;for(let t of this._availableDimensions)try{let n=e.getter(t);n&&d.set(t,n)}catch{}for(let e=0;e<t.pointCount;e++){let t=n+e,f=r(e),p=i(e),m=a(e);if(this._needsTransform&&this._transformer){let[e,n]=this._transformer([f,p]),[r,i]=g3(e,n,``);this._positions[t*3]=r-this._coordinateOrigin[0],this._positions[t*3+1]=i-this._coordinateOrigin[1],this._positions[t*3+2]=m*this._verticalUnitFactor}else this._positions[t*3]=f-this._coordinateOrigin[0],this._positions[t*3+1]=p-this._coordinateOrigin[1],this._positions[t*3+2]=m;this._intensities[t]=o(e)/65535,this._classifications[t]=s(e),this._colors&&c&&l&&u&&(this._colors[t*4]=c(e)>>8,this._colors[t*4+1]=l(e)>>8,this._colors[t*4+2]=u(e)>>8,this._colors[t*4+3]=255);for(let[n,r]of d){let i=this._extraAttributes[n];i&&(i[t]=r(e))}}}_scheduleLayerUpdate(){this._pendingLayerUpdate||(this._pendingLayerUpdate=!0,this._updateBatchTimeout=setTimeout(()=>{this._performLayerUpdate(),this._pendingLayerUpdate=!1,this._updateBatchTimeout=null},100))}_performLayerUpdate(){if(this._onPointsLoaded){let e=this.getLoadedPointCloudData();this._onPointsLoaded(e)}}setOnPointsLoaded(e){this._onPointsLoaded=e}getLoadedPointCloudData(){let e=this._totalLoadedPoints,t={};for(let[n,r]of Object.entries(this._extraAttributes))t[n]=r.subarray(0,e);return{positions:this._positions.subarray(0,e*3),coordinateOrigin:this._coordinateOrigin,colors:this._colors?.subarray(0,e*4),intensities:this._intensities.subarray(0,e),classifications:this._classifications.subarray(0,e),extraAttributes:Object.keys(t).length>0?t:void 0,pointCount:e,bounds:this._bounds,hasRGB:this._hasColor,hasIntensity:!0,hasClassification:!0,wkt:this._copc?.wkt}}_getProgressEvent(){return{totalNodesInView:this._nodeCache.size,loadedNodes:this._totalLoadedNodes,loadedPoints:this._totalLoadedPoints,pointBudget:this._options.pointBudget,isLoading:this._activeRequests>0||this._loadingQueue.length>0,queueSize:this._loadingQueue.length}}on(e,t){this._eventHandlers.has(e)||this._eventHandlers.set(e,new Set),this._eventHandlers.get(e).add(t)}off(e,t){this._eventHandlers.get(e)?.delete(t)}_emit(e,t){let n=this._eventHandlers.get(e);if(n)for(let r of n)r(e,t)}getLoadedPointCount(){return this._totalLoadedPoints}getPointBudget(){return this._options.pointBudget}getViewportCoverageRatio(e,t=0){let[n,r,i,a]=e.bounds,o=(i-n)*(a-r);if(o<=0)return 0;let s=0;for(let e of this._nodeCache.values()){if(e.state!==`loaded`||e.keyArray[0]<t)continue;let o=Math.max(n,e.boundsWgs84.minX),c=Math.min(i,e.boundsWgs84.maxX),l=Math.max(r,e.boundsWgs84.minY),u=Math.min(a,e.boundsWgs84.maxY);o<c&&l<u&&(s+=(c-o)*(u-l))}return Math.min(1,s/o)}getLoadedNodeCount(){return this._totalLoadedNodes}isLoading(){return this._activeRequests>0||this._loadingQueue.length>0}getCopcMetadata(){if(!this._copc)return;let{header:e,info:t}=this._copc,n=[];if(e.pointDataRecordFormat!==void 0){for(let t of[`X`,`Y`,`Z`,`Intensity`,`ReturnNumber`,`NumberOfReturns`,`ScanDirectionFlag`,`EdgeOfFlightLine`,`Classification`,`ScanAngleRank`,`UserData`,`PointSourceId`])n.push({name:t,type:t===`X`||t===`Y`||t===`Z`?`float`:t===`Intensity`?`uint16`:`uint8`,size:t===`X`||t===`Y`||t===`Z`?8:t===`Intensity`?2:1,scale:t===`X`?e.scale[0]:t===`Y`?e.scale[1]:t===`Z`?e.scale[2]:void 0,offset:t===`X`?e.offset[0]:t===`Y`?e.offset[1]:t===`Z`?e.offset[2]:void 0});[2,3,5,7,8,10].includes(e.pointDataRecordFormat)&&(n.push({name:`Red`,type:`uint16`,size:2}),n.push({name:`Green`,type:`uint16`,size:2}),n.push({name:`Blue`,type:`uint16`,size:2}))}return{lasVersion:`${e.majorVersion}.${e.minorVersion}`,pointDataRecordFormat:e.pointDataRecordFormat,generatingSoftware:e.generatingSoftware||`Unknown`,creationDate:e.fileCreationYear?{year:e.fileCreationYear,dayOfYear:e.fileCreationDayOfYear||1}:void 0,scale:e.scale,offset:e.offset,nativeBounds:{min:e.min,max:e.max},copcInfo:{spacing:t.spacing,rootHierarchyOffset:t.rootHierarchyPage?.pageOffset||0,pointSpacing:this._calculateNominalSpacing(e)},dimensions:n}}_calculateNominalSpacing(e){let t=(e.max[0]-e.min[0])*(e.max[1]-e.min[1]);return t<=0||e.pointCount<=0?0:Math.sqrt(t/e.pointCount)*this._verticalUnitFactor}getWkt(){return this._copc?.wkt}destroy(){this._updateBatchTimeout&&clearTimeout(this._updateBatchTimeout),this._loadingQueue=[],this._nodeCache.clear(),this._hierarchyPages.clear(),this._loadedHierarchyKeys.clear(),this._eventHandlers.clear(),this._positions=null,this._colors=null,this._intensities=null,this._classifications=null,this._extraAttributes={}}},w9={GpsTime:{arrayType:`float64`},ReturnNumber:{arrayType:`uint8`},NumberOfReturns:{arrayType:`uint8`},ScanDirectionFlag:{arrayType:`uint8`},EdgeOfFlightLine:{arrayType:`uint8`},ScanAngleRank:{arrayType:`int8`},ScanAngle:{arrayType:`float32`},UserData:{arrayType:`uint8`},PointSourceId:{arrayType:`uint16`},ScannerChannel:{arrayType:`uint8`},Synthetic:{arrayType:`uint8`},KeyPoint:{arrayType:`uint8`},Withheld:{arrayType:`uint8`},Overlap:{arrayType:`uint8`},ClassFlags:{arrayType:`uint8`},Nir:{arrayType:`uint16`},NearInfrared:{arrayType:`uint16`},OriginId:{arrayType:`uint32`}},T9=new Set([`X`,`Y`,`Z`,`Intensity`,`Classification`,`Red`,`Green`,`Blue`]),E9={pointBudget:5e6,maxConcurrentRequests:8,viewportDebounceMs:100,minDetailZoom:10,maxOctreeDepth:20,maxSubtreesPerViewport:60},D9=class{_baseUrl;_options;_metadata=null;_hierarchyCache=new Map;_hierarchyLoading=new Set;_hierarchyFailures=new Map;_subtreeRoots=new Set;_rootHierarchyLoaded=!1;_nodeCache=new Map;_positions=null;_colors=null;_intensities=null;_classifications=null;_extraAttributes={};_coordinateOrigin=[0,0,0];_bounds=null;_loadingQueue=[];_activeRequests=0;_totalLoadedPoints=0;_totalLoadedNodes=0;_isInitialized=!1;_transformer=null;_verticalUnitFactor=1;_needsTransform=!1;_hasColor=!1;_hasIntensity=!1;_totalPointsInFile=0;_pointByteLength=0;_parsedSchema=[];_availableDimensions=new Set;_dimensionsDetected=!1;_eventHandlers=new Map;_pendingLayerUpdate=!1;_updateBatchTimeout=null;_onPointsLoaded;_isResetting=!1;constructor(e,t){this._baseUrl=e.endsWith(`/ept.json`)?e.slice(0,-9):e.replace(/\/$/,``),this._options={...E9,...t}}async initialize(){try{let e=await fetch(`${this._baseUrl}/ept.json`);if(!e.ok)throw Error(`Failed to fetch ept.json: ${e.status} ${e.statusText}`);this._metadata=await e.json()}catch(e){throw e instanceof TypeError&&e.message===`Failed to fetch`?Error(`Failed to fetch from URL. This is likely a CORS (Cross-Origin Resource Sharing) error. The server doesn't allow requests from this origin. Solutions: (1) Use a CORS proxy, or (2) Host the EPT data on a CORS-enabled server.`):e}if(this._totalPointsInFile=this._metadata.numPoints??this._metadata.points??0,this._parseSchema(),this._hasColor=this._parsedSchema.some(e=>e.dimension.name===`Red`),this._hasIntensity=this._parsedSchema.some(e=>e.dimension.name===`Intensity`),this._metadata.srs?.wkt)try{let e=m9(y3(this._metadata.srs.wkt),`EPSG:4326`);this._transformer=t=>e.forward(t),this._needsTransform=!0,this._verticalUnitFactor=b3(this._metadata.srs.wkt)}catch(e){console.warn(`Failed to setup EPT coordinate transformation:`,e)}let[e,t,n,r,i,a]=this._metadata.boundsConforming;if(this._needsTransform&&this._transformer){let[o,s]=this._transformer([e,t]),[c,l]=this._transformer([r,i]);if(isNaN(o)||isNaN(s)||isNaN(c)||isNaN(l)||!isFinite(o)||!isFinite(s)||!isFinite(c)||!isFinite(l))console.error(`EPT coordinate transformation produced invalid bounds:`,{input:{minX:e,minY:t,maxX:r,maxY:i},output:{rawMinLng:o,rawMinLat:s,rawMaxLng:c,rawMaxLat:l}}),this._bounds={minX:e,minY:t,minZ:n,maxX:r,maxY:i,maxZ:a},this._needsTransform=!1,this._transformer=null;else{let[e,t]=v3(o,s,`header bounds min`),[r,i]=v3(c,l,`header bounds max`);this._bounds={minX:Math.min(e,r),minY:Math.min(t,i),minZ:n*this._verticalUnitFactor,maxX:Math.max(e,r),maxY:Math.max(t,i),maxZ:a*this._verticalUnitFactor}}}else this._bounds={minX:e,minY:t,minZ:n,maxX:r,maxY:i,maxZ:a};this._coordinateOrigin=[(this._bounds.minX+this._bounds.maxX)/2,(this._bounds.minY+this._bounds.maxY)/2,0],this._allocateBuffers(),this._isInitialized=!0;let o=(this._metadata.bounds[3]-this._metadata.bounds[0])/this._metadata.span;return{bounds:this._bounds,totalPoints:this._totalPointsInFile,hasRGB:this._hasColor,spacing:o}}_parseSchema(){if(!this._metadata)return;let e=0;this._parsedSchema=[];for(let t of this._metadata.schema){let n=this._createDimensionGetter(t,e);this._parsedSchema.push({dimension:t,byteOffset:e,getter:n}),e+=t.size}this._pointByteLength=e}_createDimensionGetter(e,t){let n=e.scale??1,r=e.offset??0;if(e.type===`float`){if(e.size===4)return(e,i)=>e.getFloat32(i+t,!0)*n+r;if(e.size===8)return(e,i)=>e.getFloat64(i+t,!0)*n+r}else if(e.type===`signed`){if(e.size===1)return(e,i)=>e.getInt8(i+t)*n+r;if(e.size===2)return(e,i)=>e.getInt16(i+t,!0)*n+r;if(e.size===4)return(e,i)=>e.getInt32(i+t,!0)*n+r;if(e.size===8)return(e,i)=>Number(e.getBigInt64(i+t,!0))*n+r}else{if(e.size===1)return(e,i)=>e.getUint8(i+t)*n+r;if(e.size===2)return(e,i)=>e.getUint16(i+t,!0)*n+r;if(e.size===4)return(e,i)=>e.getUint32(i+t,!0)*n+r;if(e.size===8)return(e,i)=>Number(e.getBigUint64(i+t,!0))*n+r}return()=>0}_allocateBuffers(){let e=this._options.pointBudget;this._positions=new Float32Array(e*3),this._intensities=new Float32Array(e),this._classifications=new Uint8Array(e),this._hasColor&&(this._colors=new Uint8Array(e*4))}getSpacing(){return this._metadata?(this._metadata.bounds[3]-this._metadata.bounds[0])/this._metadata.span:1}_parseNodeKey(e){let t=e.split(`-`).map(Number);return[t[0],t[1],t[2],t[3]]}_calculateNodeBounds(e){if(!this._metadata)throw Error(`Metadata not loaded`);let[t,n,r,i]=e,[a,o,s,c]=this._metadata.bounds,l=(c-a)*(1/2**t),u=a+n*l,d=o+r*l,f=s+i*l,p={minX:u,minY:d,minZ:f,maxX:u+l,maxY:d+l,maxZ:f+l},m=p;if(this._needsTransform&&this._transformer){let[e,t]=this._transformer([u,d]),[n,r]=this._transformer([u+l,d+l]),[i,a]=v3(e,t,`node bounds SW`),[o,s]=v3(n,r,`node bounds NE`);m={minX:Math.min(i,o),minY:Math.min(a,s),minZ:f*this._verticalUnitFactor,maxX:Math.max(i,o),maxY:Math.max(a,s),maxZ:(f+l)*this._verticalUnitFactor}}return{bounds:p,boundsWgs84:m}}_boundsIntersectsViewport(e,t){let[n,r,i,a]=t.bounds,o=i-n,s=a-r,c=o*.2,l=s*.2,u=n-c,d=i+c,f=r-l,p=a+l;return!(e.maxX<u||e.minX>d||e.maxY<f||e.minY>p)}_calculateNodePriority(e,t){let n=(e.minX+e.maxX)/2,r=(e.minY+e.maxY)/2,i=n-t.center[0],a=r-t.center[1];return Math.sqrt(i*i+a*a)}async _loadHierarchy(e){if(this._hierarchyCache.has(e)||this._hierarchyLoading.has(e))return;let t=`${this._baseUrl}/ept-hierarchy/${e}.json`;this._hierarchyLoading.add(e);try{let n=await fetch(t);if(!n.ok){this._hierarchyFailures.set(e,Date.now()),console.warn(`Failed to load hierarchy ${e}: ${n.status}`);return}let r=await n.json();this._hierarchyCache.set(e,r),this._hierarchyFailures.delete(e);for(let[e,t]of Object.entries(r)){let n=this._parseNodeKey(e),{bounds:r,boundsWgs84:i}=this._calculateNodeBounds(n),a=this._nodeCache.get(e);t===-1?(this._subtreeRoots.add(e),a||this._nodeCache.set(e,{key:e,keyArray:n,state:`subtree`,pointCount:0,bounds:r,boundsWgs84:i})):t>0&&(a?.state===`subtree`?(a.state=`pending`,a.pointCount=t,a.bounds=r,a.boundsWgs84=i):a||this._nodeCache.set(e,{key:e,keyArray:n,state:`pending`,pointCount:t,bounds:r,boundsWgs84:i}))}}catch(t){this._hierarchyFailures.set(e,Date.now()),console.warn(`Error loading hierarchy ${e}:`,t)}finally{this._hierarchyLoading.delete(e)}}async _ensureHierarchyLoaded(){this._rootHierarchyLoaded||=(await this._loadHierarchy(`0-0-0-0`),!0)}async selectNodesForViewport(e){if(!this._isInitialized)throw Error(`EptStreamingLoader not initialized. Call initialize() first.`);await this._ensureHierarchyLoaded();let t=e.targetDepth,n=Math.max(1,this._options.maxSubtreesPerViewport),r=new Set,i=Date.now();for(let a=0;a<3;a++){let a=[];for(let[,n]of this._nodeCache){if(n.keyArray[0]>t+3)continue;let o=this._hierarchyFailures.get(n.key);if(n.state===`subtree`&&!this._hierarchyCache.has(n.key)&&!this._hierarchyLoading.has(n.key)&&!r.has(n.key)&&(!o||i-o>=5e3)&&this._boundsIntersectsViewport(n.boundsWgs84,e)){let t=this._calculateNodePriority(n.boundsWgs84,e);a.push({key:n.key,priority:t})}}if(a.length===0)break;a.sort((e,t)=>e.priority-t.priority);let o=Math.ceil(n/3),s=a.slice(0,o).map(e=>e.key);if(await Promise.all(s.map(e=>this._loadHierarchy(e))),s.forEach(e=>r.add(e)),r.size>=n)break}let a=[];for(let[,n]of this._nodeCache){let r=n.keyArray[0];n.state!==`subtree`&&n.state!==`error`&&(n.lastFailedAt&&i-n.lastFailedAt<5e3||r>t+2||this._boundsIntersectsViewport(n.boundsWgs84,e)&&n.state!==`loaded`&&n.state!==`loading`&&(n.priority=this._calculateNodePriority(n.boundsWgs84,e)-r*1e-4,a.push(n)))}return a.sort((e,t)=>(e.priority||1/0)-(t.priority||1/0)),a}queueNode(e){e.state===`pending`&&(this._loadingQueue.find(t=>t.key===e.key)||(this._loadingQueue.push(e),this._loadingQueue.sort((e,t)=>(e.priority||1/0)-(t.priority||1/0))))}async loadQueuedNodes(){for(;this._loadingQueue.length>0&&this._activeRequests<this._options.maxConcurrentRequests&&this._totalLoadedPoints<this._options.pointBudget;){let e=this._loadingQueue.shift();if(this._totalLoadedPoints+e.pointCount>this._options.pointBudget){this._emit(`budgetreached`,this._getProgressEvent());break}this._loadNode(e)}}_getDataUrl(e){let t=this._metadata?.dataType===`binary`?`bin`:`laz`;return`${this._baseUrl}/ept-data/${e}.${t}`}async _loadNode(e){if(e.state===`loaded`||e.state===`loading`)return;e.state=`loading`,this._activeRequests++;let t=this._totalLoadedPoints;e.bufferStartIndex=t;let n=e.pointCount;this._totalLoadedPoints+=n;try{let n=this._getDataUrl(e.key);this._metadata?.dataType===`laszip`?await this._loadLazNode(n,e,t):await this._loadBinaryNode(n,e,t),e.state=`loaded`,this._totalLoadedNodes++,this._emit(`nodeloaded`,e),this._emit(`progress`,this._getProgressEvent()),this._scheduleLayerUpdate()}catch(t){this._totalLoadedPoints-=n,e.bufferStartIndex=void 0,e.retryCount=(e.retryCount||0)+1,e.lastFailedAt=Date.now(),e.retryCount<3?(e.state=`pending`,e.error=t instanceof Error?t.message:String(t),e.retryCount===1&&console.warn(`Failed to load EPT node ${e.key} (will retry): ${e.error}`)):(e.state=`error`,e.error=t instanceof Error?t.message:String(t),console.warn(`Failed to load EPT node ${e.key} after 3 attempts: ${e.error}`))}finally{this._activeRequests--,this.loadQueuedNodes()}}async _loadLazNode(e,t,n){let r=await j$(e,B8,{las:{shape:`mesh`,fp64:!1},worker:!1}),i=(r.attributes?.POSITION||r.attributes?.positions)?.value,a=(r.attributes?.COLOR_0||r.attributes?.colors)?.value,o=r.loaderData||{};if(!i)throw Error(`No position data in LAZ file`);let s=i.length/3;if(!this._dimensionsDetected){let e=Object.keys(r.attributes||{});for(let t of e)if(!T9.has(t)&&t!==`POSITION`&&t!==`COLOR_0`&&t!==`positions`&&t!==`colors`){this._availableDimensions.add(t);let e=w9[t]||{arrayType:`float32`};this._extraAttributes[t]=_3(e.arrayType,this._options.pointBudget)}this._dimensionsDetected=!0}let c=(r.attributes?.intensity||o.intensity)?.value,l=(r.attributes?.classification||o.classification)?.value;for(let e=0;e<s;e++){let t=n+e;if(t>=this._options.pointBudget)break;let r=i[e*3],o=i[e*3+1],u=i[e*3+2];if(this._needsTransform&&this._transformer){let[e,n]=this._transformer([r,o]),[i,a]=v3(e,n,``);this._positions[t*3]=i-this._coordinateOrigin[0],this._positions[t*3+1]=a-this._coordinateOrigin[1],this._positions[t*3+2]=u*this._verticalUnitFactor}else this._positions[t*3]=r-this._coordinateOrigin[0],this._positions[t*3+1]=o-this._coordinateOrigin[1],this._positions[t*3+2]=u;if(c&&(this._intensities[t]=c[e]/65535),l&&(this._classifications[t]=l[e]),this._colors&&a){let n=a.length/s,r=e*n;this._colors[t*4]=a[r],this._colors[t*4+1]=a[r+1],this._colors[t*4+2]=a[r+2],this._colors[t*4+3]=255}}}async _loadBinaryNode(e,t,n){let r=await fetch(e);if(!r.ok)throw Error(`Failed to fetch binary data: ${r.status}`);let i=await r.arrayBuffer(),a=new DataView(i),o=this._parsedSchema.find(e=>e.dimension.name===`X`)?.getter,s=this._parsedSchema.find(e=>e.dimension.name===`Y`)?.getter,c=this._parsedSchema.find(e=>e.dimension.name===`Z`)?.getter,l=this._parsedSchema.find(e=>e.dimension.name===`Intensity`)?.getter,u=this._parsedSchema.find(e=>e.dimension.name===`Classification`)?.getter,d=this._hasColor?this._parsedSchema.find(e=>e.dimension.name===`Red`)?.getter:null,f=this._hasColor?this._parsedSchema.find(e=>e.dimension.name===`Green`)?.getter:null,p=this._hasColor?this._parsedSchema.find(e=>e.dimension.name===`Blue`)?.getter:null;if(!o||!s||!c)throw Error(`Missing required X, Y, Z dimensions in EPT schema`);if(!this._dimensionsDetected){for(let e of this._parsedSchema){let t=e.dimension.name;if(!T9.has(t)){this._availableDimensions.add(t);let e=w9[t]||{arrayType:`float32`};this._extraAttributes[t]=_3(e.arrayType,this._options.pointBudget)}}this._dimensionsDetected=!0}let m=new Map;for(let e of this._availableDimensions){let t=this._parsedSchema.find(t=>t.dimension.name===e);t&&m.set(e,t)}for(let e=0;e<t.pointCount;e++){let t=n+e;if(t>=this._options.pointBudget)break;let r=e*this._pointByteLength,i=o(a,r),h=s(a,r),g=c(a,r);if(this._needsTransform&&this._transformer){let[e,n]=this._transformer([i,h]),[r,a]=v3(e,n,``);this._positions[t*3]=r-this._coordinateOrigin[0],this._positions[t*3+1]=a-this._coordinateOrigin[1],this._positions[t*3+2]=g*this._verticalUnitFactor}else this._positions[t*3]=i-this._coordinateOrigin[0],this._positions[t*3+1]=h-this._coordinateOrigin[1],this._positions[t*3+2]=g;l&&(this._intensities[t]=l(a,r)/65535),u&&(this._classifications[t]=u(a,r)),this._colors&&d&&f&&p&&(this._parsedSchema.find(e=>e.dimension.name===`Red`)?.dimension?.size===2?(this._colors[t*4]=d(a,r)>>8,this._colors[t*4+1]=f(a,r)>>8,this._colors[t*4+2]=p(a,r)>>8):(this._colors[t*4]=d(a,r),this._colors[t*4+1]=f(a,r),this._colors[t*4+2]=p(a,r)),this._colors[t*4+3]=255);for(let[e,n]of m){let i=this._extraAttributes[e];i&&(i[t]=n.getter(a,r))}}}_scheduleLayerUpdate(){this._pendingLayerUpdate||(this._pendingLayerUpdate=!0,this._updateBatchTimeout=setTimeout(()=>{this._performLayerUpdate(),this._pendingLayerUpdate=!1,this._updateBatchTimeout=null},100))}_performLayerUpdate(){if(this._onPointsLoaded){let e=this.getLoadedPointCloudData();this._onPointsLoaded(e)}}setOnPointsLoaded(e){this._onPointsLoaded=e}getLoadedPointCloudData(){let e=this._totalLoadedPoints,t={};for(let[n,r]of Object.entries(this._extraAttributes))t[n]=r.subarray(0,e);return{positions:this._positions.subarray(0,e*3),coordinateOrigin:this._coordinateOrigin,colors:this._colors?.subarray(0,e*4),intensities:this._intensities.subarray(0,e),classifications:this._classifications.subarray(0,e),extraAttributes:Object.keys(t).length>0?t:void 0,pointCount:e,bounds:this._bounds,hasRGB:this._hasColor,hasIntensity:this._hasIntensity,hasClassification:!0,wkt:this._metadata?.srs?.wkt}}hasPendingSubtrees(e){if(!this._isInitialized)return!1;let t=e.targetDepth,n=Date.now();for(let[,r]of this._nodeCache){if(r.keyArray[0]>t+3)continue;let i=this._hierarchyFailures.get(r.key);if(r.state===`subtree`&&!this._hierarchyCache.has(r.key)&&!this._hierarchyLoading.has(r.key)&&(!i||n-i>=5e3)&&this._boundsIntersectsViewport(r.boundsWgs84,e))return!0}return!1}_getProgressEvent(){return{totalNodesInView:this._nodeCache.size,loadedNodes:this._totalLoadedNodes,loadedPoints:this._totalLoadedPoints,pointBudget:this._options.pointBudget,isLoading:this._activeRequests>0||this._loadingQueue.length>0,queueSize:this._loadingQueue.length}}on(e,t){this._eventHandlers.has(e)||this._eventHandlers.set(e,new Set),this._eventHandlers.get(e).add(t)}off(e,t){this._eventHandlers.get(e)?.delete(t)}_emit(e,t){let n=this._eventHandlers.get(e);if(n)for(let r of n)r(e,t)}getLoadedPointCount(){return this._totalLoadedPoints}getPointBudget(){return this._options.pointBudget}hasLoadedNodesInViewport(e,t=0){for(let[,n]of this._nodeCache)if(n.state===`loaded`&&!(n.keyArray[0]<t)&&this._boundsIntersectsViewport(n.boundsWgs84,e))return!0;return!1}getViewportCoverageRatio(e,t=0){let[n,r,i,a]=e.bounds,o=(i-n)*(a-r);if(o<=0)return 0;let s=0;for(let[,e]of this._nodeCache){if(e.state!==`loaded`||e.keyArray[0]<t)continue;let o=e.boundsWgs84.minX,c=e.boundsWgs84.minY,l=e.boundsWgs84.maxX,u=e.boundsWgs84.maxY,d=Math.max(n,o),f=Math.min(i,l),p=Math.max(r,c),m=Math.min(a,u);if(d<f&&p<m){let e=(f-d)*(m-p);s+=e}}return Math.min(1,s/o)}getLoadedNodeCount(){return this._totalLoadedNodes}isLoading(){return this._activeRequests>0||this._loadingQueue.length>0}pruneQueueForViewport(e){if(this._loadingQueue.length!==0){this._loadingQueue=this._loadingQueue.filter(t=>this._boundsIntersectsViewport(t.boundsWgs84,e));for(let t of this._loadingQueue)t.priority=this._calculateNodePriority(t.boundsWgs84,e)-t.keyArray[0]*1e-4;this._loadingQueue.sort((e,t)=>(e.priority||1/0)-(t.priority||1/0))}}resetLoadedData(){if(this._activeRequests>0||this._isResetting)return!1;this._isResetting=!0,this._loadingQueue=[],this._totalLoadedPoints=0,this._totalLoadedNodes=0;for(let[,e]of this._nodeCache)(e.state===`loaded`||e.state===`loading`||e.state===`error`)&&(e.state=`pending`,e.bufferStartIndex=void 0,e.error=void 0,e.retryCount=void 0,e.lastFailedAt=void 0);return this._scheduleLayerUpdate(),this._isResetting=!1,!0}getMetadata(){return this._metadata}getExtendedMetadata(){if(!this._metadata)return;let e=this._metadata,t=[];if(e.schema)for(let n of e.schema)t.push({name:n.name,type:n.type,size:n.size,scale:n.scale,offset:n.offset});let n;if(e.bounds&&e.bounds.length>=6&&this._totalPointsInFile>0){let t=(e.bounds[3]-e.bounds[0])*(e.bounds[4]-e.bounds[1]);t>0&&(n=Math.sqrt(t/this._totalPointsInFile)*this._verticalUnitFactor)}return{version:e.version||`1.0`,dataType:e.dataType||`laszip`,hierarchyType:e.hierarchyType||`json`,span:e.span||128,nativeBounds:e.bounds||[],srs:e.srs?{authority:e.srs.authority,horizontal:e.srs.horizontal,vertical:e.srs.vertical,wkt:e.srs.wkt}:void 0,dimensions:t,pointSpacing:n}}destroy(){this._updateBatchTimeout&&clearTimeout(this._updateBatchTimeout),this._loadingQueue=[],this._nodeCache.clear(),this._hierarchyCache.clear(),this._hierarchyLoading.clear(),this._hierarchyFailures.clear(),this._subtreeRoots.clear(),this._eventHandlers.clear(),this._positions=null,this._colors=null,this._intensities=null,this._classifications=null,this._extraAttributes={}}},O9={viridis:[[68,1,84],[72,40,120],[62,74,137],[49,104,142],[38,130,142],[31,158,137],[53,183,121],[109,205,89],[180,222,44],[253,231,37]],plasma:[[13,8,135],[75,3,161],[125,3,168],[168,34,150],[203,70,121],[229,107,93],[248,148,65],[253,195,40],[240,249,33],[240,249,33]],inferno:[[0,0,4],[40,11,84],[89,13,115],[137,31,107],[179,55,79],[213,87,49],[240,130,24],[253,184,43],[249,251,146],[252,255,164]],magma:[[0,0,4],[28,16,68],[79,18,123],[129,37,129],[181,54,122],[229,80,100],[251,135,97],[254,194,135],[254,247,187],[252,253,191]],cividis:[[0,32,77],[0,58,103],[52,77,105],[87,95,108],[115,113,112],[143,132,108],[171,152,97],[200,173,79],[231,196,55],[253,231,37]],turbo:[[48,18,59],[70,107,227],[40,170,225],[35,221,162],[122,249,85],[194,241,45],[241,206,51],[250,144,42],[229,68,25],[122,4,3]],jet:[[0,0,127],[0,0,255],[0,127,255],[0,255,255],[127,255,127],[255,255,0],[255,127,0],[255,0,0],[127,0,0],[127,0,0]],rainbow:[[150,0,90],[0,0,200],[0,125,255],[0,200,255],[0,255,125],[125,255,0],[255,255,0],[255,125,0],[255,0,0],[128,0,0]],terrain:[[51,51,153],[51,102,153],[51,153,153],[102,178,102],[153,204,102],[204,229,102],[204,204,153],[178,153,102],[153,102,51],[255,255,255]],coolwarm:[[59,76,192],[98,130,234],[141,176,254],[184,208,249],[221,221,221],[245,196,173],[244,154,123],[222,96,77],[180,4,38],[180,4,38]],gray:[[0,0,0],[28,28,28],[57,57,57],[85,85,85],[113,113,113],[142,142,142],[170,170,170],[198,198,198],[227,227,227],[255,255,255]]},k9=[`viridis`,`plasma`,`inferno`,`magma`,`cividis`,`turbo`,`jet`,`rainbow`,`terrain`,`coolwarm`,`gray`],A9={viridis:`Viridis`,plasma:`Plasma`,inferno:`Inferno`,magma:`Magma`,cividis:`Cividis`,turbo:`Turbo`,jet:`Jet`,rainbow:`Rainbow`,terrain:`Terrain`,coolwarm:`Cool-Warm`,gray:`Grayscale`},j9={0:[128,128,128],1:[128,128,128],2:[165,113,78],3:[144,238,144],4:[34,139,34],5:[0,100,0],6:[255,165,0],7:[255,0,0],8:[128,128,128],9:[0,0,255],10:[139,90,43],11:[128,128,128],12:[128,128,128],13:[255,255,0],14:[255,200,0],15:[200,200,0],16:[100,100,100],17:[0,128,255],18:[255,0,255]},M9=class{_lastComputedBounds;getColors(e,t,n={}){return this.getColorsWithBounds(e,t,n).colors}getColorsWithBounds(e,t,n={}){let r=new Uint8Array(e.pointCount*4),i=n.colormap??`viridis`,a=n.colorRange,o=n.usePercentile??!0;if(typeof t==`string`)switch(t){case`elevation`:return this._colorByElevation(e,r,i,a,o);case`intensity`:return this._colorByIntensity(e,r,i,a,o);case`classification`:return{colors:this._colorByClassification(e,r,n.hiddenClassifications)};case`rgb`:return{colors:this._colorByRGB(e,r)};default:return this._colorByElevation(e,r,i,a,o)}else return{colors:this._colorByCustom(e,r,t,i,a,o)}}getLastComputedBounds(){return this._lastComputedBounds}_computeBounds(e,t,n,r){return n?n.mode===`absolute`?{min:n.absoluteMin??t.min,max:n.absoluteMax??t.max}:D3(e,n.percentileLow??2,n.percentileHigh??98):r?D3(e,2,98):t}_colorByElevation(e,t,n,r,i){if(!e.positions||e.positions.length===0)return{colors:t};let a=new Float32Array(e.pointCount);for(let t=0;t<e.pointCount;t++)a[t]=e.positions[t*3+2]??0;let o={min:e.bounds?.minZ??0,max:e.bounds?.maxZ??1},s=this._computeBounds(a,o,r,i);this._lastComputedBounds=s;let{min:c,max:l}=s,u=l-c||1,d=O9[n]||O9.viridis;for(let n=0;n<e.pointCount;n++){let e=(a[n]-c)/u,r=this._interpolateRamp(d,e);t[n*4]=r[0],t[n*4+1]=r[1],t[n*4+2]=r[2],t[n*4+3]=255}return{colors:t,bounds:s}}_colorByIntensity(e,t,n,r,i){if(!e.hasIntensity||!e.intensities)return this._colorByElevation(e,t,n,r,i);let a=1/0,o=-1/0;for(let t=0;t<e.pointCount;t++){let n=e.intensities[t];n<a&&(a=n),n>o&&(o=n)}let s={min:a,max:o},c=this._computeBounds(e.intensities,s,r,i);this._lastComputedBounds=c;let{min:l,max:u}=c,d=u-l||1,f=O9[n]||O9.gray;for(let n=0;n<e.pointCount;n++){let r=(e.intensities[n]-l)/d,i=this._interpolateRamp(f,r);t[n*4]=i[0],t[n*4+1]=i[1],t[n*4+2]=i[2],t[n*4+3]=255}return{colors:t,bounds:c}}_colorByClassification(e,t,n){if(!e.hasClassification||!e.classifications)return this._colorByElevation(e,t,`viridis`,void 0,!0).colors;for(let r=0;r<e.pointCount;r++){let i=e.classifications[r],a=j9[i]||[128,128,128];t[r*4]=a[0],t[r*4+1]=a[1],t[r*4+2]=a[2],t[r*4+3]=n?.has(i)?0:255}return t}_colorByRGB(e,t){if(!e.hasRGB||!e.colors)return this._colorByElevation(e,t,`viridis`,void 0,!0).colors;for(let n=0;n<e.pointCount;n++)t[n*4]=e.colors[n*4],t[n*4+1]=e.colors[n*4+1],t[n*4+2]=e.colors[n*4+2],t[n*4+3]=255;return t}_colorByCustom(e,t,n,r,i,a){return this._colorByElevation(e,t,r,i,a).colors}_interpolateRamp(e,t){if(!Number.isFinite(t))return e[0];let n=Math.max(0,Math.min(1,t)),r=Math.min(Math.floor(n*(e.length-1)),e.length-2),i=n*(e.length-1)-r;return[Math.round(e[r][0]+(e[r+1][0]-e[r][0])*i),Math.round(e[r][1]+(e[r+1][1]-e[r][1])*i),Math.round(e[r][2]+(e[r+1][2]-e[r][2])*i)]}},N9=class{_deckOverlay;_pointClouds;_options;_colorProcessor;_lastComputedBounds;constructor(e,t={}){this._deckOverlay=e,this._pointClouds=new Map,this._colorProcessor=new M9,this._options={pointSize:t.pointSize??2,opacity:t.opacity??1,colorScheme:t.colorScheme??`elevation`,usePercentile:t.usePercentile??!0,colormap:t.colormap??`viridis`,colorRange:t.colorRange,elevationRange:t.elevationRange??null,pickable:t.pickable??!1,zOffset:t.zOffset??0,onHover:t.onHover}}setOnHover(e){this._options.onHover=e}addPointCloud(e,t){let n=this._colorProcessor.getColorsWithBounds(t,this._options.colorScheme,{usePercentile:this._options.usePercentile,colormap:this._options.colormap,colorRange:this._options.colorRange,hiddenClassifications:this._options.hiddenClassifications});n.bounds&&(this._lastComputedBounds=n.bounds);let r=t.coordinateOrigin;this._pointClouds.set(e,{id:e,data:t,colors:n.colors,coordinateOrigin:r,visible:!0,opacityOverride:null,chunkCount:0}),this._createLayer(e)}updatePointCloud(e,t){let n=this._pointClouds.get(e);if(!t.positions||t.pointCount===0){n&&(this._pointClouds.set(e,{id:e,data:t,colors:new Uint8Array,coordinateOrigin:t.coordinateOrigin,visible:n.visible,opacityOverride:n.opacityOverride,chunkCount:n.chunkCount}),this._createLayer(e));return}if(n){let r=this._colorProcessor.getColorsWithBounds(t,this._options.colorScheme,{usePercentile:this._options.usePercentile,colormap:this._options.colormap,colorRange:this._options.colorRange,hiddenClassifications:this._options.hiddenClassifications});r.bounds&&(this._lastComputedBounds=r.bounds),this._pointClouds.set(e,{id:e,data:t,colors:r.colors,coordinateOrigin:t.coordinateOrigin,visible:n.visible,opacityOverride:n.opacityOverride,chunkCount:n.chunkCount}),this._createLayer(e)}else this.addPointCloud(e,t)}getPointCount(e){return this._pointClouds.get(e)?.data.pointCount||0}removePointCloud(e){let t=this._pointClouds.get(e);if(t)for(let n=0;n<t.chunkCount;n++)this._deckOverlay.removeLayer(`pointcloud-${e}-chunk${n}`);this._pointClouds.delete(e)}hasPointCloud(e){return this._pointClouds.has(e)}getPointCloudIds(){return Array.from(this._pointClouds.keys())}getPointCloudBounds(e){return this._pointClouds.get(e)?.data.bounds}updateStyle(e){let t=e.colorScheme!==void 0&&e.colorScheme!==this._options.colorScheme,n=e.usePercentile!==void 0&&e.usePercentile!==this._options.usePercentile,r=e.colormap!==void 0&&e.colormap!==this._options.colormap,i=e.colorRange!==void 0,a=e.hiddenClassifications!==void 0;if(this._options={...this._options,...e},t||n||r||i||a)for(let[e,t]of this._pointClouds){let n=this._colorProcessor.getColorsWithBounds(t.data,this._options.colorScheme,{usePercentile:this._options.usePercentile,colormap:this._options.colormap,colorRange:this._options.colorRange,hiddenClassifications:this._options.hiddenClassifications});n.bounds&&(this._lastComputedBounds=n.bounds),this._pointClouds.set(e,{...t,colors:n.colors,coordinateOrigin:t.coordinateOrigin,visible:t.visible,opacityOverride:t.opacityOverride})}this._updateAllLayers()}setPointSize(e){this.updateStyle({pointSize:e})}setOpacity(e){for(let[e,t]of this._pointClouds)t.opacityOverride!==null&&this._pointClouds.set(e,{...t,opacityOverride:null});this.updateStyle({opacity:e})}setColorScheme(e){this.updateStyle({colorScheme:e})}setUsePercentile(e){this.updateStyle({usePercentile:e})}setColormap(e){this.updateStyle({colormap:e})}setColorRange(e){this.updateStyle({colorRange:e})}setElevationRange(e){this.updateStyle({elevationRange:e})}setPickable(e){this.updateStyle({pickable:e})}setZOffset(e){this.updateStyle({zOffset:e})}setHiddenClassifications(e){this.updateStyle({hiddenClassifications:e})}setPointCloudVisibility(e,t){let n=this._pointClouds.get(e);n&&(this._pointClouds.set(e,{...n,visible:t}),this._createLayer(e))}getPointCloudVisibility(e){return this._pointClouds.get(e)?.visible}setPointCloudOpacity(e,t){let n=this._pointClouds.get(e);n&&(this._pointClouds.set(e,{...n,opacityOverride:t}),this._createLayer(e))}getPointCloudOpacity(e){let t=this._pointClouds.get(e);if(t)return t.opacityOverride??this._options.opacity}clear(){for(let[e,t]of this._pointClouds)for(let n=0;n<t.chunkCount;n++)this._deckOverlay.removeLayer(`pointcloud-${e}-chunk${n}`);this._pointClouds.clear()}getOptions(){return{...this._options}}getLastComputedBounds(){return this._lastComputedBounds}getMergedPointCloudData(){if(this._pointClouds.size===0)return null;if(this._pointClouds.size===1){let[e]=this._pointClouds.values();return e.data}let e=0;for(let t of this._pointClouds.values())e+=t.data.pointCount;if(e===0)return null;let[t]=this._pointClouds.values(),n=t.coordinateOrigin[0],r=t.coordinateOrigin[1],i=new Float32Array(e*3),a=new Float32Array(e),o=new Uint8Array(e),s=0;for(let e of this._pointClouds.values()){let t=e.data,c=t.pointCount,l=e.coordinateOrigin[0]-n,u=e.coordinateOrigin[1]-r;for(let e=0;e<c;e++)i[(s+e)*3]=t.positions[e*3]+l,i[(s+e)*3+1]=t.positions[e*3+1]+u,i[(s+e)*3+2]=t.positions[e*3+2];t.intensities&&a.set(t.intensities.subarray(0,c),s),t.classifications&&o.set(t.classifications.subarray(0,c),s),s+=c}return{positions:i,coordinateOrigin:[n,r,0],intensities:a,classifications:o,pointCount:e,bounds:t.data.bounds,hasRGB:t.data.hasRGB,hasIntensity:!0,hasClassification:!0}}_createLayer(e){let t=this._pointClouds.get(e);if(!t)return;let{data:n,colors:r,coordinateOrigin:i,visible:a,opacityOverride:o}=t,s=this._options.elevationRange,c=this._options.zOffset??0,l=o??this._options.opacity;for(let n=0;n<t.chunkCount;n++)this._deckOverlay.removeLayer(`pointcloud-${e}-chunk${n}`);if(!a){this._pointClouds.set(e,{...t,chunkCount:0});return}let u=[];for(let e=0;e<n.pointCount;e++){let t=n.positions[e*3+2];(s===null||t>=s[0]&&t<=s[1])&&u.push(e)}if(u.length===0){this._pointClouds.set(e,{...t,chunkCount:0});return}let d=1e6,f=Math.ceil(u.length/d);for(let t=0;t<f;t++){let a=t*d,o=Math.min(a+d,u.length)-a,f=new Float32Array(o*3),p=new Uint8Array(o*4),m=[];for(let e=0;e<o;e++){let t=u[a+e];m.push(t),f[e*3]=n.positions[t*3],f[e*3+1]=n.positions[t*3+1],f[e*3+2]=n.positions[t*3+2]+c,p[e*4]=r[t*4],p[e*4+1]=r[t*4+1],p[e*4+2]=r[t*4+2],p[e*4+3]=r[t*4+3]}let h=e=>{if(this._options.onHover)if(e.index>=0&&e.picked&&e.index<m.length){let t=m[e.index],r={index:t,longitude:i[0]+f[e.index*3],latitude:i[1]+f[e.index*3+1],elevation:f[e.index*3+2],x:e.x,y:e.y};if(n.intensities&&(r.intensity=n.intensities[t]),n.classifications&&(r.classification=n.classifications[t]),n.colors&&n.hasRGB&&(r.red=n.colors[t*4],r.green=n.colors[t*4+1],r.blue=n.colors[t*4+2]),n.extraAttributes){let e={};for(let[r,i]of Object.entries(n.extraAttributes))i&&t<i.length&&(e[r]=i[t]);Object.keys(e).length>0&&(r.attributes=e)}this._options.onHover(r)}else this._options.onHover(null)},g=s?`${s[0]}-${s[1]}`:`none`,_=c,v=new zq({id:`pointcloud-${e}-chunk${t}`,coordinateSystem:PP.LNGLAT_OFFSETS,coordinateOrigin:i,data:{length:o,attributes:{getPosition:{value:f,size:3},getColor:{value:p,size:4}}},pointSize:this._options.pointSize,sizeUnits:`pixels`,opacity:l,getNormal:[0,0,1],pickable:this._options.pickable,onHover:this._options.pickable?h:void 0,autoHighlight:this._options.pickable,highlightColor:[255,255,0,200],updateTriggers:{getPosition:[g,_,o],getColor:[g,o]}});this._deckOverlay.addLayer(`pointcloud-${e}-chunk${t}`,v)}this._pointClouds.set(e,{...t,chunkCount:f})}_updateAllLayers(){for(let e of this._pointClouds.keys())this._createLayer(e)}},P9=class{_map;_debounceMs;_onViewportChange;_debouncedHandler;_isActive=!1;_minDetailZoom;_maxOctreeDepth;_spacing;constructor(e,t,n){this._map=e,this._onViewportChange=t,this._debounceMs=n?.debounceMs??150,this._minDetailZoom=n?.minDetailZoom??10,this._maxOctreeDepth=n?.maxOctreeDepth??20,this._spacing=n?.spacing??null,this._debouncedHandler=C3(()=>this._handleViewportChange(),this._debounceMs)}start(){this._isActive||(this._isActive=!0,this._map.on(`moveend`,this._debouncedHandler),this._map.on(`zoomend`,this._debouncedHandler),this._map.on(`pitchend`,this._debouncedHandler),this._handleViewportChange())}stop(){this._isActive&&(this._isActive=!1,this._map.off(`moveend`,this._debouncedHandler),this._map.off(`zoomend`,this._debouncedHandler),this._map.off(`pitchend`,this._debouncedHandler))}getCurrentViewport(){let e=this._map.getBounds(),t=this._map.getCenter(),n=this._map.getZoom(),r=this._map.getPitch();return{bounds:[e.getWest(),e.getSouth(),e.getEast(),e.getNorth()],center:[t.lng,t.lat],zoom:n,pitch:r,targetDepth:this._calculateTargetDepth(n,r)}}_calculateTargetDepth(e,t){let n;if(this._spacing!==null){let t=156543.03/2**e*2;n=Math.floor(Math.log2(this._spacing/t)),n=Math.max(0,n)}else n=e<this._minDetailZoom?Math.floor(e/5):Math.floor(2+(e-this._minDetailZoom)*1);let r=t*Math.PI/180,i=Math.floor((1-Math.cos(r))*3);return n=Math.max(0,n-i),Math.min(n,this._maxOctreeDepth)}_handleViewportChange(){if(!this._isActive)return;let e=this.getCurrentViewport();this._onViewportChange(e)}forceUpdate(){this._handleViewportChange()}setSpacing(e){this._spacing=e}isActive(){return this._isActive}destroy(){this.stop()}},F9=class{_options;_input;_label;constructor(e){this._options={accept:`.las,.laz`,label:`Drop LAS/LAZ file here or click to browse`,...e}}render(){let e=document.createElement(`div`);e.className=`lidar-file-input-wrapper`;let t=document.createElement(`div`);t.className=`lidar-file-input-label`,t.innerHTML=`
|
||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
||
<polyline points="17 8 12 3 7 8"/>
|
||
<line x1="12" y1="3" x2="12" y2="15"/>
|
||
</svg>
|
||
<span>${this._options.label}</span>
|
||
`,this._label=t;let n=document.createElement(`input`);return n.type=`file`,n.className=`lidar-file-input`,n.accept=this._options.accept||``,this._input=n,n.addEventListener(`change`,()=>{let e=n.files?.[0];e&&(this._options.onChange(e),n.value=``)}),t.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation(),t.classList.add(`drag-over`)}),t.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),t.classList.remove(`drag-over`)}),t.addEventListener(`drop`,e=>{e.preventDefault(),e.stopPropagation(),t.classList.remove(`drag-over`);let n=e.dataTransfer?.files?.[0];n&&this._isValidFile(n)&&this._options.onChange(n)}),e.appendChild(n),e.appendChild(t),e}setLabel(e){if(this._label){let t=this._label.querySelector(`span`);t&&(t.textContent=e)}}resetLabel(){this.setLabel(this._options.label||`Drop LAS/LAZ file here or click to browse`)}setEnabled(e){this._input&&(this._input.disabled=!e),this._label&&(this._label.style.pointerEvents=e?`auto`:`none`,this._label.style.opacity=e?`1`:`0.5`)}_isValidFile(e){let t=(this._options.accept||``).split(`,`).map(e=>e.trim().toLowerCase()),n=e.name.toLowerCase();return t.some(e=>n.endsWith(e.replace(`*`,``)))}},I9=class{_options;_slider;_valueDisplay;constructor(e){this._options=e}render(){let e=document.createElement(`div`);e.className=`lidar-control-group`;let t=document.createElement(`div`);t.className=`lidar-control-label-row`;let n=document.createElement(`label`);n.className=`lidar-control-label`,n.textContent=this._options.label;let r=document.createElement(`span`);r.className=`lidar-control-value`,r.textContent=this._formatValue(this._options.value),this._valueDisplay=r,t.appendChild(n),t.appendChild(r);let i=document.createElement(`input`);return i.type=`range`,i.className=`lidar-control-slider`,i.min=String(this._options.min),i.max=String(this._options.max),i.step=String(this._options.step),i.value=String(this._options.value),this._slider=i,i.addEventListener(`input`,()=>{let e=parseFloat(i.value);this._valueDisplay.textContent=this._formatValue(e),this._options.onChange(e)}),e.appendChild(t),e.appendChild(i),e}setValue(e){this._slider&&(this._slider.value=String(e)),this._valueDisplay&&(this._valueDisplay.textContent=this._formatValue(e))}getValue(){return this._slider?parseFloat(this._slider.value):this._options.value}setEnabled(e){this._slider&&(this._slider.disabled=!e)}setBounds(e,t){this._options.min=e,this._options.max=t,this._slider&&(this._slider.min=String(e),this._slider.max=String(t))}_formatValue(e){return this._options.formatValue?this._options.formatValue(e):x3(e,this._options.step)}},L9=class{_options;_sliderLow;_sliderHigh;_valueDisplay;_rangeHighlight;constructor(e){this._options=e}render(){let e=document.createElement(`div`);e.className=`lidar-control-group`;let t=document.createElement(`div`);t.className=`lidar-control-label-row`;let n=document.createElement(`label`);n.className=`lidar-control-label`,n.textContent=this._options.label;let r=document.createElement(`span`);r.className=`lidar-control-value`,r.textContent=this._formatRange(this._options.valueLow,this._options.valueHigh),this._valueDisplay=r,t.appendChild(n),t.appendChild(r),e.appendChild(t);let i=document.createElement(`div`);i.style.cssText=`
|
||
position: relative;
|
||
height: 20px;
|
||
margin-top: 8px;
|
||
`;let a=document.createElement(`div`);a.style.cssText=`
|
||
position: absolute;
|
||
top: 8px;
|
||
left: 0;
|
||
right: 0;
|
||
height: 4px;
|
||
background: #e0e0e0;
|
||
border-radius: 2px;
|
||
`,i.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`
|
||
position: absolute;
|
||
top: 8px;
|
||
height: 4px;
|
||
background: #159895;
|
||
border-radius: 2px;
|
||
`,this._rangeHighlight=o,i.appendChild(o);let s=document.createElement(`input`);s.type=`range`,s.min=String(this._options.min),s.max=String(this._options.max),s.step=String(this._options.step),s.value=String(this._options.valueLow),s.style.cssText=`
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 20px;
|
||
-webkit-appearance: none;
|
||
appearance: none;
|
||
background: transparent;
|
||
pointer-events: none;
|
||
z-index: 2;
|
||
`,this._sliderLow=s;let c=document.createElement(`input`);c.type=`range`,c.min=String(this._options.min),c.max=String(this._options.max),c.step=String(this._options.step),c.value=String(this._options.valueHigh),c.style.cssText=`
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 20px;
|
||
-webkit-appearance: none;
|
||
appearance: none;
|
||
background: transparent;
|
||
pointer-events: none;
|
||
z-index: 2;
|
||
`,this._sliderHigh=c;let l=document.createElement(`style`);l.textContent=`
|
||
.dual-range-slider input[type="range"]::-webkit-slider-thumb {
|
||
-webkit-appearance: none;
|
||
appearance: none;
|
||
width: 16px;
|
||
height: 16px;
|
||
border-radius: 50%;
|
||
background: #159895;
|
||
cursor: pointer;
|
||
pointer-events: auto;
|
||
border: 2px solid #fff;
|
||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
||
}
|
||
.dual-range-slider input[type="range"]::-moz-range-thumb {
|
||
width: 16px;
|
||
height: 16px;
|
||
border-radius: 50%;
|
||
background: #159895;
|
||
cursor: pointer;
|
||
pointer-events: auto;
|
||
border: 2px solid #fff;
|
||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
||
}
|
||
`,e.appendChild(l),i.classList.add(`dual-range-slider`),i.appendChild(s),i.appendChild(c),e.appendChild(i);let u=()=>{let e=parseFloat(s.value),t=parseFloat(c.value),n=this._options.min,r=this._options.max,i=(e-n)/(r-n)*100,a=(t-n)/(r-n)*100;o.style.left=`${i}%`,o.style.width=`${a-i}%`};return u(),s.addEventListener(`input`,()=>{let e=parseFloat(s.value),t=parseFloat(c.value);e>t&&(e=t,s.value=String(e)),this._valueDisplay.textContent=this._formatRange(e,t),u(),this._options.onChange(e,t)}),c.addEventListener(`input`,()=>{let e=parseFloat(s.value),t=parseFloat(c.value);t<e&&(t=e,c.value=String(t)),this._valueDisplay.textContent=this._formatRange(e,t),u(),this._options.onChange(e,t)}),e}setRange(e,t){this._sliderLow&&(this._sliderLow.value=String(e)),this._sliderHigh&&(this._sliderHigh.value=String(t)),this._valueDisplay&&(this._valueDisplay.textContent=this._formatRange(e,t)),this._updateRangeHighlight()}setBounds(e,t){this._options.min=e,this._options.max=t,this._sliderLow&&(this._sliderLow.min=String(e),this._sliderLow.max=String(t)),this._sliderHigh&&(this._sliderHigh.min=String(e),this._sliderHigh.max=String(t)),this._updateRangeHighlight()}setStep(e){this._options.step=e,this._sliderLow&&(this._sliderLow.step=String(e)),this._sliderHigh&&(this._sliderHigh.step=String(e))}_updateRangeHighlight(){if(!this._rangeHighlight||!this._sliderLow||!this._sliderHigh)return;let e=parseFloat(this._sliderLow.value),t=parseFloat(this._sliderHigh.value),n=this._options.min,r=this._options.max,i=(e-n)/(r-n)*100,a=(t-n)/(r-n)*100;this._rangeHighlight.style.left=`${i}%`,this._rangeHighlight.style.width=`${a-i}%`}getRange(){return[this._sliderLow?parseFloat(this._sliderLow.value):this._options.valueLow,this._sliderHigh?parseFloat(this._sliderHigh.value):this._options.valueHigh]}_formatRange(e,t){let n=this._options.formatValue||(e=>e.toFixed(1));return`${n(e)} - ${n(t)}`}},R9=class{_options;_container;_listContainer;_checkboxes=new Map;constructor(e){this._options=e}render(){let e=document.createElement(`div`);e.className=`lidar-classification-legend`,this._container=e;let t=document.createElement(`div`);t.className=`lidar-classification-legend-header`;let n=document.createElement(`button`);n.type=`button`,n.className=`lidar-legend-action-btn`,n.textContent=`Show All`,n.addEventListener(`click`,()=>this._options.onShowAll());let r=document.createElement(`button`);r.type=`button`,r.className=`lidar-legend-action-btn`,r.textContent=`Hide All`,r.addEventListener(`click`,()=>this._options.onHideAll()),t.appendChild(n),t.appendChild(r),e.appendChild(t);let i=document.createElement(`div`);i.className=`lidar-classification-legend-list`,this._listContainer=i;let a=[...this._options.classifications].sort((e,t)=>e-t);if(a.length===0){let e=document.createElement(`div`);e.className=`lidar-classification-empty`,e.textContent=`Loading classifications...`,i.appendChild(e)}else for(let e of a)i.appendChild(this._buildLegendItem(e));return e.appendChild(i),e}_buildLegendItem(e){let t=document.createElement(`div`);t.className=`lidar-classification-legend-item`;let n=document.createElement(`input`);n.type=`checkbox`,n.checked=!this._options.hiddenClassifications.has(e),n.id=`lidar-class-${e}`,n.addEventListener(`change`,()=>{this._options.onToggle(e,n.checked)}),this._checkboxes.set(e,n);let r=document.createElement(`span`);r.className=`lidar-classification-swatch`;let i=j9[e]||[128,128,128];r.style.backgroundColor=`rgb(${i[0]}, ${i[1]}, ${i[2]})`;let a=document.createElement(`label`);return a.htmlFor=`lidar-class-${e}`,a.className=`lidar-classification-label`,a.textContent=k3(e),t.appendChild(n),t.appendChild(r),t.appendChild(a),t}updateClassification(e,t){let n=this._checkboxes.get(e);n&&(n.checked=t)}updateAll(e){for(let[t,n]of this._checkboxes)n.checked=!e.has(t)}setClassifications(e,t){if(this._options.classifications=e,this._options.hiddenClassifications=t,this._listContainer)if(this._listContainer.innerHTML=``,this._checkboxes.clear(),e.length===0){let e=document.createElement(`div`);e.className=`lidar-classification-empty`,e.textContent=`No classifications found`,this._listContainer.appendChild(e)}else{let t=[...e].sort((e,t)=>e-t);for(let e of t)this._listContainer.appendChild(this._buildLegendItem(e))}}getContainer(){return this._container}},z9=class{_options;_canvas;_minLabel;_maxLabel;constructor(e){this._options={...e}}render(){let e=document.createElement(`div`);if(e.className=`lidar-colorbar`,this._options.label){let t=document.createElement(`div`);t.className=`lidar-colorbar-label`,t.textContent=this._options.label,e.appendChild(t)}let t=document.createElement(`canvas`);t.className=`lidar-colorbar-gradient`,t.width=200,t.height=14,this._canvas=t,e.appendChild(t);let n=document.createElement(`div`);n.className=`lidar-colorbar-labels`;let r=document.createElement(`span`);r.className=`lidar-colorbar-min`,this._minLabel=r;let i=document.createElement(`span`);return i.className=`lidar-colorbar-max`,this._maxLabel=i,n.appendChild(r),n.appendChild(i),e.appendChild(n),this._drawGradient(),this._updateLabels(),e}update(e){e.colormap!==void 0&&(this._options.colormap=e.colormap),e.minValue!==void 0&&(this._options.minValue=e.minValue),e.maxValue!==void 0&&(this._options.maxValue=e.maxValue),e.label!==void 0&&(this._options.label=e.label),this._drawGradient(),this._updateLabels()}setColormap(e){this._options.colormap=e,this._drawGradient()}setRange(e,t){this._options.minValue=e,this._options.maxValue=t,this._updateLabels()}getColormap(){return this._options.colormap}getRange(){return{min:this._options.minValue,max:this._options.maxValue}}_drawGradient(){if(!this._canvas)return;let e=this._canvas.getContext(`2d`);if(!e)return;let t=this._canvas.width,n=this._canvas.height,r=O9[this._options.colormap]||O9.viridis,i=e.createLinearGradient(0,0,t,0);for(let e=0;e<r.length;e++){let t=e/(r.length-1),[n,a,o]=r[e];i.addColorStop(t,`rgb(${n}, ${a}, ${o})`)}e.fillStyle=i,e.fillRect(0,0,t,n)}_updateLabels(){this._minLabel&&(this._minLabel.textContent=this._formatValue(this._options.minValue)),this._maxLabel&&(this._maxLabel.textContent=this._formatValue(this._options.maxValue))}_formatValue(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(this._options.maxValue-this._options.minValue);return t<1?e.toFixed(3):t<10?e.toFixed(2):t<100?e.toFixed(1):e.toFixed(0)}},B9=2,V9=98,H9=class{_options;_percentileRadio;_absoluteRadio;_percentileSliderContainer;_absoluteSliderContainer;_percentileSlider;_absoluteSlider;_computedBounds;constructor(e){this._options={...e},this._computedBounds=e.computedBounds}render(){let e=document.createElement(`div`);e.className=`lidar-color-range`;let t=document.createElement(`div`);t.className=`lidar-color-range-header`;let n=document.createElement(`div`);n.className=`lidar-control-label`,n.textContent=`Color Range`,t.appendChild(n);let r=document.createElement(`button`);r.className=`lidar-range-reset-btn`,r.textContent=`Reset`,r.title=`Reset to default (2-98% percentile)`,r.addEventListener(`click`,()=>this._onReset()),t.appendChild(r),e.appendChild(t);let i=document.createElement(`div`);i.className=`lidar-range-mode`;let a=document.createElement(`label`),o=document.createElement(`input`);o.type=`radio`,o.name=`lidar-range-mode`,o.value=`percentile`,o.checked=this._options.config.mode===`percentile`,this._percentileRadio=o,a.appendChild(o),a.appendChild(document.createTextNode(` Percentile`)),i.appendChild(a);let s=document.createElement(`label`),c=document.createElement(`input`);c.type=`radio`,c.name=`lidar-range-mode`,c.value=`absolute`,c.checked=this._options.config.mode===`absolute`,this._absoluteRadio=c,s.appendChild(c),s.appendChild(document.createTextNode(` Absolute`)),i.appendChild(s),e.appendChild(i);let l=document.createElement(`div`);l.style.display=this._options.config.mode===`percentile`?`block`:`none`,this._percentileSliderContainer=l,this._percentileSlider=new L9({label:``,min:0,max:100,step:1,valueLow:this._options.config.percentileLow??B9,valueHigh:this._options.config.percentileHigh??V9,onChange:(e,t)=>this._onPercentileChange(e,t),formatValue:e=>`${e.toFixed(0)}%`}),l.appendChild(this._percentileSlider.render()),e.appendChild(l);let u=document.createElement(`div`);u.style.display=this._options.config.mode===`absolute`?`block`:`none`,this._absoluteSliderContainer=u;let d=this._options.dataBounds||{min:0,max:100},f=this._options.config.absoluteMin??d.min,p=this._options.config.absoluteMax??d.max;return this._absoluteSlider=new L9({label:``,min:d.min,max:d.max,step:this._getAbsoluteStep(d),valueLow:f,valueHigh:p,onChange:(e,t)=>this._onAbsoluteChange(e,t),formatValue:e=>this._formatAbsoluteValue(e)}),u.appendChild(this._absoluteSlider.render()),e.appendChild(u),o.addEventListener(`change`,()=>this._onModeChange()),c.addEventListener(`change`,()=>this._onModeChange()),e}setConfig(e){if(this._options.config={...e},this._percentileRadio&&this._absoluteRadio&&(this._percentileRadio.checked=e.mode===`percentile`,this._absoluteRadio.checked=e.mode===`absolute`),this._percentileSlider&&this._percentileSlider.setRange(e.percentileLow??B9,e.percentileHigh??V9),this._absoluteSlider){let t=this._options.dataBounds||{min:0,max:100};this._absoluteSlider.setRange(e.absoluteMin??t.min,e.absoluteMax??t.max)}this._updateSlidersVisibility()}setDataBounds(e){if(this._options.dataBounds=e,this._absoluteSlider){this._absoluteSlider.setBounds(e.min,e.max),this._absoluteSlider.setStep(this._getAbsoluteStep(e)),this._options.config.absoluteMin===void 0&&(this._options.config.absoluteMin=e.min),this._options.config.absoluteMax===void 0&&(this._options.config.absoluteMax=e.max);let t=this._options.config.absoluteMin??e.min,n=this._options.config.absoluteMax??e.max,r=Math.max(e.min,Math.min(e.max,t)),i=Math.max(e.min,Math.min(e.max,n));this._absoluteSlider.setRange(r,i)}}setComputedBounds(e){this._computedBounds=e}getConfig(){return{...this._options.config}}_onPercentileChange(e,t){this._options.config.percentileLow=e,this._options.config.percentileHigh=t,this._emitChange()}_onAbsoluteChange(e,t){this._options.config.absoluteMin=e,this._options.config.absoluteMax=t,this._emitChange()}_onModeChange(){let e=this._percentileRadio?.checked?`percentile`:`absolute`;if(e!==this._options.config.mode&&e===`absolute`){if(this._computedBounds)this._options.config.absoluteMin=this._computedBounds.min,this._options.config.absoluteMax=this._computedBounds.max;else if(this._options.dataBounds){let{min:e,max:t}=this._options.dataBounds,n=t-e,r=this._options.config.percentileLow??B9,i=this._options.config.percentileHigh??V9;this._options.config.absoluteMin=parseFloat((e+r/100*n).toFixed(2)),this._options.config.absoluteMax=parseFloat((e+i/100*n).toFixed(2))}this._absoluteSlider&&this._options.config.absoluteMin!==void 0&&this._options.config.absoluteMax!==void 0&&this._absoluteSlider.setRange(this._options.config.absoluteMin,this._options.config.absoluteMax)}this._options.config.mode=e,this._updateSlidersVisibility(),this._emitChange()}_onReset(){if(this._options.config.mode=`percentile`,this._options.config.percentileLow=B9,this._options.config.percentileHigh=V9,this._options.dataBounds){let{min:e,max:t}=this._options.dataBounds,n=t-e;this._options.config.absoluteMin=parseFloat((e+B9/100*n).toFixed(2)),this._options.config.absoluteMax=parseFloat((e+V9/100*n).toFixed(2))}this._percentileRadio&&(this._percentileRadio.checked=!0),this._absoluteRadio&&(this._absoluteRadio.checked=!1),this._percentileSlider&&this._percentileSlider.setRange(B9,V9),this._absoluteSlider&&this._options.config.absoluteMin!==void 0&&this._options.config.absoluteMax!==void 0&&this._absoluteSlider.setRange(this._options.config.absoluteMin,this._options.config.absoluteMax),this._updateSlidersVisibility(),this._emitChange()}_updateSlidersVisibility(){this._percentileSliderContainer&&(this._percentileSliderContainer.style.display=this._options.config.mode===`percentile`?`block`:`none`),this._absoluteSliderContainer&&(this._absoluteSliderContainer.style.display=this._options.config.mode===`absolute`?`block`:`none`)}_getAbsoluteStep(e){let t=e.max-e.min;return t<=1?.01:t<=10?.1:t<=100||t<=1e3?1:Math.round(t/100)}_formatAbsoluteValue(e){let t=this._options.dataBounds||{min:0,max:100},n=t.max-t.min;return n<=1?e.toFixed(2):n<=10?e.toFixed(1):e.toFixed(0)}_emitChange(){this._options.onChange({...this._options.config})}},U9=class{_callbacks;_state;_contentElement;_fileInput;_urlInput;_loadButton;_colorSelect;_colormapSelect;_colormapGroup;_colorbar;_colorbarContainer;_colorRangeControl;_colorRangeContainer;_percentileCheckbox;_percentileGroup;_pointSizeSlider;_opacitySlider;_pointCloudsList;_pickableCheckbox;_elevationSlider;_elevationCheckbox;_zOffsetCheckbox;_zOffsetSlider;_zOffsetSliderContainer;_terrainCheckbox;_loadingIndicator;_errorMessage;_classificationLegend;_classificationLegendContainer;_shareFeedbackTimeout;constructor(e,t){this._callbacks=e,this._state=t}build(){let e=document.createElement(`div`);e.className=`lidar-control-content`,this._state.maxHeight&&(e.style.maxHeight=`${this._state.maxHeight}px`),this._contentElement=e,e.appendChild(this._buildFileSection()),e.appendChild(this._buildStylingSection()),e.appendChild(this._buildPointCloudsList());let t=this._buildCrossSectionSection();t&&e.appendChild(t),e.appendChild(this._buildLoadingIndicator()),e.appendChild(this._buildErrorMessage());let n=this._buildShareSection();return n&&e.appendChild(n),e}updateState(e){if(this._state=e,this._contentElement&&e.maxHeight&&(this._contentElement.style.maxHeight=`${e.maxHeight}px`),this._loadingIndicator&&(e.loading?this._loadingIndicator.classList.add(`active`):this._loadingIndicator.classList.remove(`active`)),this._errorMessage&&(e.error?(this._errorMessage.textContent=e.error,this._errorMessage.style.display=`block`):this._errorMessage.style.display=`none`),this._updatePointCloudsList(),this._pointSizeSlider&&this._pointSizeSlider.setValue(e.pointSize),this._opacitySlider&&this._opacitySlider.setValue(e.opacity),this._colorSelect&&typeof e.colorScheme==`string`&&(this._colorSelect.value=e.colorScheme,this._updatePercentileVisibility(e.colorScheme)),this._colormapSelect&&e.colormap&&(this._colormapSelect.value=e.colormap),this._colorbar&&(e.colormap&&this._colorbar.setColormap(e.colormap),e.computedColorBounds&&this._colorbar.setRange(e.computedColorBounds.min,e.computedColorBounds.max)),this._colorRangeControl&&e.colorRange){this._colorRangeControl.setConfig(e.colorRange);let t=this._getDataBoundsForCurrentScheme();this._colorRangeControl.setDataBounds(t),e.computedColorBounds&&this._colorRangeControl.setComputedBounds(e.computedColorBounds)}if(this._percentileCheckbox&&(this._percentileCheckbox.checked=e.usePercentile??!0),this._pickableCheckbox&&(this._pickableCheckbox.checked=e.pickable??!1),this._zOffsetCheckbox&&(this._zOffsetCheckbox.checked=e.zOffsetEnabled??!1),this._zOffsetSliderContainer&&(this._zOffsetSliderContainer.style.display=e.zOffsetEnabled?`block`:`none`),this._zOffsetSlider){if(e.zOffsetBase!==void 0){let t=-e.zOffsetBase,n=t-100,r=t+100;this._zOffsetSlider.setBounds(n,r)}this._zOffsetSlider.setValue(e.zOffset??0)}if(this._terrainCheckbox&&(this._terrainCheckbox.checked=e.terrainEnabled??!1),this._elevationSlider&&e.pointClouds.length>0){let e=this._getElevationBounds();this._elevationSlider.setBounds(e.min,e.max),this._elevationCheckbox?.checked||this._elevationSlider.setRange(e.min,e.max)}this._classificationLegend&&e.availableClassifications&&this._classificationLegend.setClassifications(Array.from(e.availableClassifications),e.hiddenClassifications||new Set);let t=!e.loading;this._fileInput?.setEnabled(t),this._urlInput&&(this._urlInput.disabled=!t),this._loadButton&&(this._loadButton.disabled=!t)}updateLoadingProgress(e,t){if(!this._loadingIndicator)return;let n=this._loadingIndicator.querySelector(`.lidar-loading-bar-fill`),r=this._loadingIndicator.querySelector(`.lidar-loading-progress`);n&&(n.style.width=`${e}%`),r&&t&&(r.textContent=t)}_buildFileSection(){let e=document.createElement(`div`);e.className=`lidar-control-section`,this._fileInput=new F9({accept:`.las,.laz`,onChange:e=>this._callbacks.onFileSelect(e)}),e.appendChild(this._fileInput.render());let t=document.createElement(`div`);t.className=`lidar-control-group`,t.style.marginTop=`12px`;let n=document.createElement(`label`);n.className=`lidar-control-label`,n.textContent=`Load COPC or EPT from URL`,t.appendChild(n);let r=document.createElement(`div`);r.className=`lidar-control-flex`;let i=document.createElement(`input`);i.type=`text`,i.className=`lidar-control-input`,i.placeholder=`https://example.com/pointcloud.laz`,i.style.flex=`1`,this._urlInput=i;let a=document.createElement(`button`);return a.type=`button`,a.className=`lidar-control-button`,a.textContent=`Load`,a.addEventListener(`click`,()=>{let e=i.value.trim();e&&(this._callbacks.onUrlSubmit(e),i.value=``)}),this._loadButton=a,i.addEventListener(`keypress`,e=>{e.key===`Enter`&&a.click()}),r.appendChild(i),r.appendChild(a),t.appendChild(r),e.appendChild(t),e}_buildStylingSection(){let e=document.createElement(`div`);e.className=`lidar-control-section`;let t=document.createElement(`div`);t.className=`lidar-control-section-header`,t.textContent=`Styling`,e.appendChild(t);let n=document.createElement(`div`);n.className=`lidar-control-group`;let r=document.createElement(`label`);r.className=`lidar-control-label`,r.textContent=`Color By`,n.appendChild(r);let i=document.createElement(`select`);return i.className=`lidar-control-select`,i.innerHTML=`
|
||
<option value="elevation">Elevation</option>
|
||
<option value="intensity">Intensity</option>
|
||
<option value="classification">Classification</option>
|
||
<option value="rgb">RGB (if available)</option>
|
||
`,i.value=typeof this._state.colorScheme==`string`?this._state.colorScheme:`elevation`,i.addEventListener(`change`,()=>{this._callbacks.onColorSchemeChange(i.value),this._updatePercentileVisibility(i.value)}),this._colorSelect=i,n.appendChild(i),e.appendChild(n),e.appendChild(this._buildColormapSelector()),e.appendChild(this._buildColorbar()),e.appendChild(this._buildClassificationLegend()),e.appendChild(this._buildColorRangeControl()),this._pointSizeSlider=new I9({label:`Point Size`,min:1,max:10,step:.5,value:this._state.pointSize,onChange:e=>this._callbacks.onPointSizeChange(e)}),e.appendChild(this._pointSizeSlider.render()),this._opacitySlider=new I9({label:`Opacity`,min:0,max:1,step:.05,value:this._state.opacity,onChange:e=>this._callbacks.onOpacityChange(e)}),e.appendChild(this._opacitySlider.render()),e.appendChild(this._buildTerrainCheckbox()),e.appendChild(this._buildPickableCheckbox()),e.appendChild(this._buildElevationFilter()),e.appendChild(this._buildZOffsetControl()),e}_buildElevationFilter(){let e=document.createElement(`div`);e.className=`lidar-control-group`;let t=document.createElement(`div`);t.className=`lidar-control-label-row`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`checkbox`,n.id=`lidar-elevation-filter-checkbox`,n.style.marginRight=`6px`,this._elevationCheckbox=n;let r=document.createElement(`label`);r.className=`lidar-control-label`,r.htmlFor=`lidar-elevation-filter-checkbox`,r.style.display=`inline`,r.style.cursor=`pointer`,r.textContent=`Elevation Filter`,t.appendChild(n),t.appendChild(r),e.appendChild(t);let i=document.createElement(`div`);i.style.display=`none`,i.style.marginTop=`8px`;let a=this._getElevationBounds();return this._elevationSlider=new L9({label:`Range (m)`,min:a.min,max:a.max,step:1,valueLow:a.min,valueHigh:a.max,onChange:(e,t)=>{n.checked&&this._callbacks.onElevationRangeChange([e,t])},formatValue:e=>e.toFixed(0)}),i.appendChild(this._elevationSlider.render()),e.appendChild(i),n.addEventListener(`change`,()=>{if(i.style.display=n.checked?`block`:`none`,n.checked){let e=this._getElevationBounds();this._elevationSlider?.setBounds(e.min,e.max),this._elevationSlider?.setRange(e.min,e.max);let t=this._elevationSlider?.getRange();t&&this._callbacks.onElevationRangeChange(t)}else this._callbacks.onElevationRangeChange(null)}),e}_buildZOffsetControl(){let e=document.createElement(`div`);e.className=`lidar-control-group`;let t=document.createElement(`div`);t.className=`lidar-control-label-row`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`checkbox`,n.id=`lidar-zoffset-checkbox`,n.checked=this._state.zOffsetEnabled??!1,n.style.marginRight=`6px`,this._zOffsetCheckbox=n;let r=document.createElement(`label`);r.className=`lidar-control-label`,r.htmlFor=`lidar-zoffset-checkbox`,r.style.display=`inline`,r.style.cursor=`pointer`,r.textContent=`Z Offset`,t.appendChild(n),t.appendChild(r),e.appendChild(t);let i=document.createElement(`div`);i.style.display=this._state.zOffsetEnabled?`block`:`none`,i.style.marginTop=`8px`,this._zOffsetSliderContainer=i;let a=-(this._state.zOffsetBase??0),o=a-100,s=a+100;return this._zOffsetSlider=new I9({label:`Offset (m)`,min:o,max:s,step:1,value:this._state.zOffset??a,onChange:e=>this._callbacks.onZOffsetChange(e)}),i.appendChild(this._zOffsetSlider.render()),e.appendChild(i),n.addEventListener(`change`,()=>{i.style.display=n.checked?`block`:`none`,this._callbacks.onZOffsetEnabledChange(n.checked),n.checked||(this._zOffsetSlider?.setValue(0),this._callbacks.onZOffsetChange(0))}),e}_buildTerrainCheckbox(){let e=document.createElement(`div`);e.className=`lidar-control-group`;let t=document.createElement(`div`);t.className=`lidar-control-label-row`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`checkbox`,n.id=`lidar-terrain-checkbox`,n.checked=this._state.terrainEnabled??!1,n.style.marginRight=`6px`,this._terrainCheckbox=n;let r=document.createElement(`label`);return r.className=`lidar-control-label`,r.htmlFor=`lidar-terrain-checkbox`,r.style.display=`inline`,r.style.cursor=`pointer`,r.textContent=`3D Terrain`,t.appendChild(n),t.appendChild(r),e.appendChild(t),n.addEventListener(`change`,()=>{this._callbacks.onTerrainChange(n.checked)}),e}_getElevationBounds(){if(this._state.pointClouds.length===0)return{min:0,max:100};let e=1/0,t=-1/0;for(let n of this._state.pointClouds)e=Math.min(e,n.bounds.minZ),t=Math.max(t,n.bounds.maxZ);return e=Math.floor(e),t=Math.ceil(t),{min:e,max:t}}_getIntensityBounds(){return{min:0,max:1}}_getDataBoundsForCurrentScheme(){return(typeof this._state.colorScheme==`string`?this._state.colorScheme:`elevation`)===`intensity`?this._getIntensityBounds():this._getElevationBounds()}_buildColormapSelector(){let e=document.createElement(`div`);e.className=`lidar-colormap-group`,this._colormapGroup=e;let t=typeof this._state.colorScheme==`string`?this._state.colorScheme:`elevation`,n=t===`elevation`||t===`intensity`;e.style.display=n?`block`:`none`;let r=document.createElement(`label`);r.className=`lidar-control-label`,r.textContent=`Colormap`,e.appendChild(r);let i=document.createElement(`select`);i.className=`lidar-colormap-select`;for(let e of k9){let t=document.createElement(`option`);t.value=e,t.textContent=A9[e],i.appendChild(t)}return i.value=this._state.colormap||`viridis`,this._colormapSelect=i,i.addEventListener(`change`,()=>{let e=i.value;this._callbacks.onColormapChange(e)}),e.appendChild(i),e}_buildColorbar(){let e=document.createElement(`div`);e.className=`lidar-control-group`,this._colorbarContainer=e;let t=typeof this._state.colorScheme==`string`?this._state.colorScheme:`elevation`,n=(t===`elevation`||t===`intensity`)&&this._state.showColorbar;return e.style.display=n?`block`:`none`,this._colorbar=new z9({colormap:this._state.colormap||`viridis`,minValue:this._state.computedColorBounds?.min??0,maxValue:this._state.computedColorBounds?.max??100}),e.appendChild(this._colorbar.render()),e}_buildColorRangeControl(){let e=document.createElement(`div`);e.className=`lidar-control-group`,this._colorRangeContainer=e;let t=typeof this._state.colorScheme==`string`?this._state.colorScheme:`elevation`,n=t===`elevation`||t===`intensity`;e.style.display=n?`block`:`none`;let r=this._getDataBoundsForCurrentScheme();return this._colorRangeControl=new H9({config:this._state.colorRange||{mode:`percentile`,percentileLow:2,percentileHigh:98},dataBounds:r,computedBounds:this._state.computedColorBounds,onChange:e=>{this._callbacks.onColorRangeChange(e)}}),e.appendChild(this._colorRangeControl.render()),e}_updatePercentileVisibility(e){let t=e===`elevation`||e===`intensity`;if(this._colormapGroup&&(this._colormapGroup.style.display=t?`block`:`none`),this._colorbarContainer&&(this._colorbarContainer.style.display=t&&this._state.showColorbar?`block`:`none`),this._colorRangeContainer&&(this._colorRangeContainer.style.display=t?`block`:`none`),this._colorRangeControl&&t){let e=this._getDataBoundsForCurrentScheme();this._colorRangeControl.setDataBounds(e)}this._percentileGroup&&(this._percentileGroup.style.display=`none`),this._classificationLegendContainer&&(this._classificationLegendContainer.style.display=e===`classification`?`block`:`none`)}_buildClassificationLegend(){let e=document.createElement(`div`);e.className=`lidar-control-group`,this._classificationLegendContainer=e;let t=typeof this._state.colorScheme==`string`?this._state.colorScheme:`elevation`;return e.style.display=t===`classification`?`block`:`none`,this._classificationLegend=new R9({classifications:Array.from(this._state.availableClassifications||new Set),hiddenClassifications:this._state.hiddenClassifications||new Set,onToggle:(e,t)=>this._callbacks.onClassificationToggle(e,t),onShowAll:()=>this._callbacks.onClassificationShowAll(),onHideAll:()=>this._callbacks.onClassificationHideAll()}),e.appendChild(this._classificationLegend.render()),e}_buildPickableCheckbox(){let e=document.createElement(`div`);e.className=`lidar-control-group`;let t=document.createElement(`div`);t.className=`lidar-control-label-row`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`checkbox`,n.id=`lidar-pickable-checkbox`,n.checked=this._state.pickable??!1,n.style.marginRight=`6px`,this._pickableCheckbox=n;let r=document.createElement(`label`);return r.className=`lidar-control-label`,r.htmlFor=`lidar-pickable-checkbox`,r.style.display=`inline`,r.style.cursor=`pointer`,r.textContent=`Enable point picking`,n.addEventListener(`change`,()=>{this._callbacks.onPickableChange(n.checked)}),t.appendChild(n),t.appendChild(r),e.appendChild(t),e}_buildPointCloudsList(){let e=document.createElement(`div`);e.className=`lidar-control-section lidar-pointclouds-section`;let t=document.createElement(`div`);t.className=`lidar-control-section-header`,t.textContent=`Loaded Point Clouds`,e.appendChild(t);let n=document.createElement(`div`);return n.className=`lidar-pointclouds-list`,this._pointCloudsList=n,e.appendChild(n),this._updatePointCloudsList(),e}_updatePointCloudsList(){if(this._pointCloudsList){if(this._pointCloudsList.innerHTML=``,this._state.pointClouds.length===0){let e=document.createElement(`div`);e.className=`lidar-pointclouds-empty`,e.textContent=`No point clouds loaded`,this._pointCloudsList.appendChild(e);return}for(let e of this._state.pointClouds)this._pointCloudsList.appendChild(this._buildPointCloudItem(e))}}_buildPointCloudItem(e){let t=document.createElement(`div`);t.className=`lidar-pointcloud-item`;let n=document.createElement(`div`);n.className=`lidar-pointcloud-info`;let r=document.createElement(`div`);r.className=`lidar-pointcloud-name`,r.textContent=e.name,r.title=e.name;let i=document.createElement(`div`);i.className=`lidar-pointcloud-details`,i.textContent=`${w3(e.pointCount)} points`,n.appendChild(r),n.appendChild(i);let a=document.createElement(`div`);if(a.className=`lidar-pointcloud-actions`,this._callbacks.onShowMetadata){let t=document.createElement(`button`);t.type=`button`,t.className=`lidar-pointcloud-action info`,t.textContent=`Info`,t.title=`Show metadata`,t.addEventListener(`click`,t=>{t.stopPropagation(),this._callbacks.onShowMetadata(e.id)}),a.appendChild(t)}let o=document.createElement(`button`);o.type=`button`,o.className=`lidar-pointcloud-action`,o.textContent=`Zoom`,o.title=`Zoom to point cloud`,o.addEventListener(`click`,()=>this._callbacks.onZoomTo(e.id));let s=document.createElement(`button`);return s.type=`button`,s.className=`lidar-pointcloud-action remove`,s.textContent=`Remove`,s.title=`Remove point cloud`,s.addEventListener(`click`,t=>{t.stopPropagation(),this._callbacks.onUnload(e.id)}),a.appendChild(o),a.appendChild(s),t.appendChild(n),t.appendChild(a),t}_buildLoadingIndicator(){let e=document.createElement(`div`);return e.className=`lidar-loading`,e.innerHTML=`
|
||
<div class="lidar-loading-spinner"></div>
|
||
<div class="lidar-loading-text">Loading point cloud...</div>
|
||
<div class="lidar-loading-progress">Preparing...</div>
|
||
<div class="lidar-loading-bar">
|
||
<div class="lidar-loading-bar-fill"></div>
|
||
</div>
|
||
`,this._loadingIndicator=e,e}_buildErrorMessage(){let e=document.createElement(`div`);return e.className=`lidar-error`,e.style.display=`none`,this._errorMessage=e,e}_buildShareSection(){if(!this._callbacks.onShareUrl)return null;let e=document.createElement(`div`);e.className=`lidar-control-section lidar-share-section`;let t=document.createElement(`button`);t.type=`button`,t.className=`lidar-control-button lidar-share-button`,t.textContent=`Share URL`;let n=document.createElement(`div`);return n.className=`lidar-share-status`,n.setAttribute(`aria-live`,`polite`),t.addEventListener(`click`,async()=>{try{let e=this._callbacks.onShareUrl?.();if(!e)throw Error(`No share URL available`);await this._copyToClipboard(e),this._setShareStatus(n,`Copied`)}catch{this._setShareStatus(n,`Copy failed`)}}),e.appendChild(t),e.appendChild(n),e}async _copyToClipboard(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);if(t.remove(),!n)throw Error(`Clipboard copy failed`)}_setShareStatus(e,t){e.textContent=t,this._shareFeedbackTimeout&&clearTimeout(this._shareFeedbackTimeout),this._shareFeedbackTimeout=setTimeout(()=>{e.textContent=``},2e3)}_buildCrossSectionSection(){if(!this._callbacks.onCrossSectionPanel)return null;let e=this._callbacks.onCrossSectionPanel();if(!e)return null;let t=document.createElement(`div`);t.className=`lidar-control-section lidar-crosssection-section`;let n=document.createElement(`div`);n.className=`lidar-control-section-header lidar-section-collapsible`,n.innerHTML=`<span class="lidar-section-toggle">▶</span> Cross-Section`,n.style.cursor=`pointer`;let r=document.createElement(`div`);return r.className=`lidar-section-body`,r.style.display=`none`,r.appendChild(e),n.addEventListener(`click`,()=>{let e=n.querySelector(`.lidar-section-toggle`);r.style.display===`none`?(r.style.display=`block`,e&&(e.textContent=`▼`)):(r.style.display=`none`,e&&(e.textContent=`▶`))}),t.appendChild(n),t.appendChild(r),t}},W9=class{_container=null;_backdrop=null;_options;_metadata=null;constructor(e){this._options=e}show(e){this._metadata=e,this._render()}hide(){this._backdrop?.remove(),this._container?.remove(),this._backdrop=null,this._container=null}_render(){if(!this._metadata)return;this._backdrop=document.createElement(`div`),this._backdrop.className=`lidar-metadata-backdrop`,this._backdrop.addEventListener(`click`,()=>this._close()),document.body.appendChild(this._backdrop),this._container=document.createElement(`div`),this._container.className=`lidar-metadata-panel`,this._container.addEventListener(`click`,e=>e.stopPropagation());let e=document.createElement(`div`);e.className=`lidar-metadata-header`,e.innerHTML=`
|
||
<span class="lidar-metadata-title">Point Cloud Metadata</span>
|
||
<button type="button" class="lidar-metadata-close" title="Close">×</button>
|
||
`,e.querySelector(`.lidar-metadata-close`)?.addEventListener(`click`,()=>this._close()),this._container.appendChild(e);let t=document.createElement(`div`);t.className=`lidar-metadata-content`,t.appendChild(this._buildBasicInfoSection()),t.appendChild(this._buildBoundsSection()),t.appendChild(this._buildCrsSection()),t.appendChild(this._buildPointFormatSection()),t.appendChild(this._buildDimensionsSection()),this._container.appendChild(t),document.body.appendChild(this._container)}_close(){this.hide(),this._options.onClose()}_buildBasicInfoSection(){let e=this._createSection(`Basic Info`,!0),t=e.querySelector(`.lidar-metadata-section-body`),n=this._metadata,r=n.basic,i=[{label:`Name`,value:r.name},{label:`Type`,value:n.type.toUpperCase()},{label:`Point Count`,value:this._formatNumber(r.pointCount)},{label:`Has RGB`,value:r.hasRGB?`Yes`:`No`},{label:`Has Intensity`,value:r.hasIntensity?`Yes`:`No`},{label:`Has Classification`,value:r.hasClassification?`Yes`:`No`},{label:`Source`,value:r.source}];n.type===`copc`&&n.copc&&(i.push({label:`LAS Version`,value:n.copc.lasVersion}),i.push({label:`Point Format`,value:String(n.copc.pointDataRecordFormat)}),i.push({label:`Generating Software`,value:n.copc.generatingSoftware}),n.copc.creationDate&&i.push({label:`Creation Date`,value:`${n.copc.creationDate.year}, Day ${n.copc.creationDate.dayOfYear}`}),n.copc.copcInfo?.pointSpacing!==void 0&&n.copc.copcInfo.pointSpacing>0&&i.push({label:`Point Spacing (est.)`,value:`~`+n.copc.copcInfo.pointSpacing.toFixed(2)+` m`})),n.type===`ept`&&n.ept&&(i.push({label:`EPT Version`,value:n.ept.version}),i.push({label:`Data Type`,value:n.ept.dataType}),n.ept.pointSpacing!==void 0&&n.ept.pointSpacing>0&&i.push({label:`Point Spacing (est.)`,value:`~`+n.ept.pointSpacing.toFixed(2)+` m`}));for(let e of i)t.appendChild(this._createRow(e.label,e.value));return e}_buildBoundsSection(){let e=this._createSection(`Bounds`,!1),t=e.querySelector(`.lidar-metadata-section-body`),n=this._metadata,r=n.basic;if(t.appendChild(this._createSubheader(`Geographic (WGS84)`)),t.appendChild(this._createRow(`Min X (Lng)`,r.bounds.minX.toFixed(6)+`°`)),t.appendChild(this._createRow(`Max X (Lng)`,r.bounds.maxX.toFixed(6)+`°`)),t.appendChild(this._createRow(`Min Y (Lat)`,r.bounds.minY.toFixed(6)+`°`)),t.appendChild(this._createRow(`Max Y (Lat)`,r.bounds.maxY.toFixed(6)+`°`)),t.appendChild(this._createRow(`Min Z`,r.bounds.minZ.toFixed(2)+` m`)),t.appendChild(this._createRow(`Max Z`,r.bounds.maxZ.toFixed(2)+` m`)),n.type===`copc`&&n.copc?.nativeBounds){t.appendChild(this._createSubheader(`Native CRS`));let e=n.copc.nativeBounds;t.appendChild(this._createRow(`Min X`,e.min[0].toFixed(3))),t.appendChild(this._createRow(`Max X`,e.max[0].toFixed(3))),t.appendChild(this._createRow(`Min Y`,e.min[1].toFixed(3))),t.appendChild(this._createRow(`Max Y`,e.max[1].toFixed(3))),t.appendChild(this._createRow(`Min Z`,e.min[2].toFixed(3))),t.appendChild(this._createRow(`Max Z`,e.max[2].toFixed(3)))}if(n.type===`ept`&&n.ept?.nativeBounds&&n.ept.nativeBounds.length>=6){t.appendChild(this._createSubheader(`Native CRS`));let e=n.ept.nativeBounds;t.appendChild(this._createRow(`Min X`,e[0].toFixed(3))),t.appendChild(this._createRow(`Max X`,e[3].toFixed(3))),t.appendChild(this._createRow(`Min Y`,e[1].toFixed(3))),t.appendChild(this._createRow(`Max Y`,e[4].toFixed(3))),t.appendChild(this._createRow(`Min Z`,e[2].toFixed(3))),t.appendChild(this._createRow(`Max Z`,e[5].toFixed(3)))}return e}_buildCrsSection(){let e=this._createSection(`Coordinate Reference System`,!1),t=e.querySelector(`.lidar-metadata-section-body`),n=this._metadata,r=n.basic.wkt;if(r){let e=document.createElement(`div`);e.className=`lidar-metadata-wkt`;let n=document.createElement(`button`);n.type=`button`,n.className=`lidar-metadata-copy-btn`,n.textContent=`Copy WKT`,n.addEventListener(`click`,()=>{navigator.clipboard.writeText(r).then(()=>{n.textContent=`Copied!`,setTimeout(()=>{n.textContent=`Copy WKT`},2e3)})}),e.appendChild(n);let i=document.createElement(`pre`);i.className=`lidar-metadata-code`,i.textContent=this._formatWkt(r),e.appendChild(i),t.appendChild(e)}else t.appendChild(this._createRow(`WKT`,`Not available`));if(n.type===`ept`&&n.ept?.srs){let e=n.ept.srs;e.authority&&t.appendChild(this._createRow(`Authority`,e.authority)),e.horizontal&&t.appendChild(this._createRow(`Horizontal`,e.horizontal)),e.vertical&&t.appendChild(this._createRow(`Vertical`,e.vertical))}return n.type===`copc`&&n.copc&&(t.appendChild(this._createSubheader(`Scale & Offset`)),t.appendChild(this._createRow(`Scale X`,n.copc.scale[0].toExponential(4))),t.appendChild(this._createRow(`Scale Y`,n.copc.scale[1].toExponential(4))),t.appendChild(this._createRow(`Scale Z`,n.copc.scale[2].toExponential(4))),t.appendChild(this._createRow(`Offset X`,n.copc.offset[0].toFixed(3))),t.appendChild(this._createRow(`Offset Y`,n.copc.offset[1].toFixed(3))),t.appendChild(this._createRow(`Offset Z`,n.copc.offset[2].toFixed(3)))),e}_buildPointFormatSection(){let e=this._createSection(`Point Format`,!1),t=e.querySelector(`.lidar-metadata-section-body`),n=this._metadata;if(n.type===`copc`&&n.copc){t.appendChild(this._createRow(`Point Data Record Format`,String(n.copc.pointDataRecordFormat))),t.appendChild(this._createRow(`LAS Version`,n.copc.lasVersion));let e=n.copc.pointDataRecordFormat,r={0:`Core (XYZ, Intensity, Return, Classification)`,1:`Format 0 + GPS Time`,2:`Format 0 + RGB`,3:`Format 0 + GPS Time + RGB`,6:`Extended (14-bit Classification, NIR)`,7:`Format 6 + RGB`,8:`Format 6 + RGB + NIR`};r[e]&&t.appendChild(this._createRow(`Description`,r[e]))}return n.type===`ept`&&n.ept&&t.appendChild(this._createRow(`Data Encoding`,n.ept.dataType)),e}_buildDimensionsSection(){let e=this._createSection(`Dimensions`,!1),t=e.querySelector(`.lidar-metadata-section-body`),n=this._metadata,r=[];if(n.type===`copc`&&n.copc?.dimensions?r=n.copc.dimensions:n.type===`ept`&&n.ept?.dimensions&&(r=n.ept.dimensions),r.length>0){let e=document.createElement(`table`);e.className=`lidar-metadata-table`,e.innerHTML=`
|
||
<thead>
|
||
<tr>
|
||
<th>Name</th>
|
||
<th>Type</th>
|
||
<th>Size</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody></tbody>
|
||
`;let n=e.querySelector(`tbody`);for(let e of r){let t=document.createElement(`tr`);t.innerHTML=`
|
||
<td>${e.name}</td>
|
||
<td>${e.type}</td>
|
||
<td>${e.size} bytes</td>
|
||
`,n.appendChild(t)}t.appendChild(e)}else t.appendChild(this._createRow(`Dimensions`,`Not available`));return e}_createSection(e,t){let n=document.createElement(`div`);n.className=`lidar-metadata-section`;let r=document.createElement(`div`);r.className=`lidar-metadata-section-header`,r.innerHTML=`
|
||
<span class="lidar-metadata-section-toggle">${t?`▼`:`▶`}</span>
|
||
<span class="lidar-metadata-section-title">${e}</span>
|
||
`;let i=document.createElement(`div`);return i.className=`lidar-metadata-section-body`,i.style.display=t?`block`:`none`,r.addEventListener(`click`,()=>{let e=r.querySelector(`.lidar-metadata-section-toggle`);i.style.display===`none`?(i.style.display=`block`,e.textContent=`▼`):(i.style.display=`none`,e.textContent=`▶`)}),n.appendChild(r),n.appendChild(i),n}_createRow(e,t){let n=document.createElement(`div`);return n.className=`lidar-metadata-row`,n.innerHTML=`
|
||
<span class="lidar-metadata-label">${e}:</span>
|
||
<span class="lidar-metadata-value">${t}</span>
|
||
`,n}_createSubheader(e){let t=document.createElement(`div`);return t.className=`lidar-metadata-subheader`,t.textContent=e,t}_formatNumber(e){return e.toLocaleString()}_formatWkt(e){let t=``,n=0;for(let r=0;r<e.length;r++){let i=e[r];i===`[`?t+=`[
|
||
`+` `.repeat(++n):i===`]`?t+=`
|
||
`+` `.repeat(--n)+`]`:i===`,`?t+=`,
|
||
`+` `.repeat(n):t+=i}return t}},G9=class{_container;_canvas;_ctx;_tooltip;_options;_profile=null;_hoveredPointIndex=-1;MARGIN={top:20,right:20,bottom:40,left:60};constructor(e){this._options={width:e?.width??300,height:e?.height??150,colormap:e?.colormap??`viridis`,onPointHover:e?.onPointHover??(()=>{})},this._container=document.createElement(`div`),this._container.className=`lidar-profile-chart-container`,this._canvas=document.createElement(`canvas`),this._canvas.className=`lidar-profile-chart`,this._canvas.width=this._options.width,this._canvas.height=this._options.height,this._container.appendChild(this._canvas),this._ctx=this._canvas.getContext(`2d`),this._tooltip=document.createElement(`div`),this._tooltip.className=`lidar-profile-tooltip`,this._tooltip.style.display=`none`,this._container.appendChild(this._tooltip),this._canvas.addEventListener(`mousemove`,this._handleMouseMove.bind(this)),this._canvas.addEventListener(`mouseleave`,this._handleMouseLeave.bind(this))}render(){return this._container}setProfile(e){this._profile=e,this._draw()}setColormap(e){this._options.colormap=e,this._draw()}resize(e,t){let n=Math.max(100,Math.round(e)),r=Math.max(80,Math.round(t));this._options.width=n,this._options.height=r,this._canvas.width=n,this._canvas.height=r;let i=this._canvas.getContext(`2d`);i&&(this._ctx=i),this._draw()}_draw(){let{width:e,height:t}=this._options,n=this._ctx;if(n.clearRect(0,0,e,t),n.fillStyle=`#f8f8f8`,n.fillRect(0,0,e,t),!this._profile||this._profile.points.length===0){this._drawNoData();return}let r=e-this.MARGIN.left-this.MARGIN.right,i=t-this.MARGIN.top-this.MARGIN.bottom;this._drawGrid(r,i),this._drawPoints(r,i),this._drawAxes(r,i)}_drawNoData(){let{width:e,height:t}=this._options,n=this._ctx;n.fillStyle=`#888`,n.font=`12px sans-serif`,n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(`Draw a cross-section line to view elevation profile`,e/2,t/2)}_drawGrid(e,t){let n=this._ctx,{left:r,top:i}=this.MARGIN;n.strokeStyle=`#ddd`,n.lineWidth=1;for(let a=0;a<=4;a++){let o=i+t*a/4;n.beginPath(),n.moveTo(r,o),n.lineTo(r+e,o),n.stroke()}for(let a=0;a<=4;a++){let o=r+e*a/4;n.beginPath(),n.moveTo(o,i),n.lineTo(o,i+t),n.stroke()}}_drawPoints(e,t){if(!this._profile)return;let n=this._ctx,{left:r,top:i}=this.MARGIN,{points:a,stats:o}=this._profile,s=O3(this._options.colormap),c=e/o.totalDistance,l=o.maxElevation-o.minElevation,u=l>0?t/l:1,d=Math.max(1,Math.min(3,500/a.length));for(let e=0;e<a.length;e++){let f=a[e],p=r+f.distance*c,m=i+t-(f.elevation-o.minElevation)*u,h=l>0?(f.elevation-o.minElevation)/l:.5,g=Math.floor(h*(s.length-1)),_=s[Math.max(0,Math.min(s.length-1,g))];n.fillStyle=`rgb(${_[0]}, ${_[1]}, ${_[2]})`,n.beginPath(),n.arc(p,m,d,0,Math.PI*2),n.fill(),e===this._hoveredPointIndex&&(n.strokeStyle=`#000`,n.lineWidth=2,n.beginPath(),n.arc(p,m,d+2,0,Math.PI*2),n.stroke())}}_drawAxes(e,t){if(!this._profile)return;let n=this._ctx,{left:r,top:i}=this.MARGIN,{width:a,height:o}=this._options,{stats:s}=this._profile;n.strokeStyle=`#333`,n.lineWidth=1,n.beginPath(),n.moveTo(r,i),n.lineTo(r,i+t),n.stroke(),n.beginPath(),n.moveTo(r,i+t),n.lineTo(r+e,i+t),n.stroke(),n.fillStyle=`#333`,n.font=`10px sans-serif`,n.textAlign=`center`,n.textBaseline=`top`;for(let a=0;a<=4;a++){let o=r+e*a/4,c=s.totalDistance*a/4;n.fillText(this._formatDistance(c),o,i+t+5)}n.textBaseline=`bottom`,n.fillText(`Distance (m)`,a/2,o-6),n.textAlign=`right`,n.textBaseline=`middle`;let c=s.maxElevation-s.minElevation;for(let e=0;e<=4;e++){let a=i+t-t*e/4,o=s.minElevation+c*e/4;n.fillText(o.toFixed(1),r-5,a)}n.save(),n.translate(12,o/2),n.rotate(-Math.PI/2),n.textAlign=`center`,n.fillText(`Elevation (m)`,0,0),n.restore()}_formatDistance(e){return e>=1e3?(e/1e3).toFixed(1)+`km`:Math.round(e)+``}_handleMouseMove(e){if(!this._profile||this._profile.points.length===0){this._hideTooltip();return}let t=this._canvas.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,{left:i,top:a}=this.MARGIN,o=this._options.width-this.MARGIN.left-this.MARGIN.right,s=this._options.height-this.MARGIN.top-this.MARGIN.bottom,{points:c,stats:l}=this._profile,u=o/l.totalDistance,d=l.maxElevation-l.minElevation,f=d>0?s/d:1,p=-1,m=1/0;for(let e=0;e<c.length;e++){let t=c[e],o=i+t.distance*u,d=a+s-(t.elevation-l.minElevation)*f,h=Math.sqrt((n-o)**2+(r-d)**2);h<m&&h<15&&(m=h,p=e)}if(p!==this._hoveredPointIndex)if(this._hoveredPointIndex=p,this._draw(),p>=0){let t=c[p];this._showTooltip(t,e.clientX,e.clientY),this._options.onPointHover(t,e.clientX,e.clientY)}else this._hideTooltip(),this._options.onPointHover(null,0,0)}_handleMouseLeave(){this._hoveredPointIndex=-1,this._draw(),this._hideTooltip(),this._options.onPointHover(null,0,0)}_showTooltip(e,t,n){let r=[`Distance: ${e.distance.toFixed(1)} m`,`Elevation: ${e.elevation.toFixed(2)} m`,`Offset: ${e.offsetFromLine.toFixed(2)} m`];e.classification!==void 0&&r.push(`Class: ${e.classification}`),this._tooltip.innerHTML=r.join(`<br>`),this._tooltip.style.display=`block`;let i=this._container.getBoundingClientRect();this._tooltip.style.left=`${t-i.left+10}px`,this._tooltip.style.top=`${n-i.top-40}px`}_hideTooltip(){this._tooltip.style.display=`none`}destroy(){this._canvas.removeEventListener(`mousemove`,this._handleMouseMove.bind(this)),this._canvas.removeEventListener(`mouseleave`,this._handleMouseLeave.bind(this)),this._container.remove()}},K9=class{_container;_callbacks;_options;_drawButton;_clearButton;_downloadButton;_expandButton;_bufferSlider;_bufferValue;_statsContainer;_chartContainer;_chart;_popupBackdrop;_popupContainer;_popupChartContainer;_popupChart;_popupResizeObserver;_isDrawing=!1;_profile=null;_isResizing=!1;_ignoreBackdropClick=!1;_resizeStartX=0;_resizeStartY=0;_resizeStartWidth=0;_resizeStartHeight=0;_resizeObserver;_handlePopupResizeMouseMove;_handlePopupResizeMouseUp;constructor(e,t){this._callbacks=e,this._options={bufferDistance:t?.bufferDistance??10,colormap:t?.colormap??`viridis`,chartHeight:t?.chartHeight??180},this._container=document.createElement(`div`),this._container.className=`lidar-crosssection-panel`,this._chart=new G9({width:320,height:this._options.chartHeight,colormap:this._options.colormap}),this._handlePopupResizeMouseMove=this._onPopupResizeMouseMove.bind(this),this._handlePopupResizeMouseUp=this._onPopupResizeMouseUp.bind(this),this._build(),this._setupResizeObserver()}render(){return this._container}setProfile(e){this._profile=e,this._chart.setProfile(e),this._popupChart?.setProfile(e),this._updateStats();let t=e&&e.points.length>0;this._downloadButton&&(this._downloadButton.disabled=!t),this._expandButton&&(this._expandButton.disabled=!t)}setDrawing(e){this._isDrawing=e,this._drawButton&&(this._drawButton.textContent=e?`Cancel`:`Draw Line`,this._drawButton.classList.toggle(`active`,e))}setColormap(e){this._options.colormap=e,this._chart.setColormap(e),this._popupChart?.setColormap(e)}setBufferDistance(e){this._options.bufferDistance=e,this._bufferSlider&&(this._bufferSlider.value=String(e)),this._bufferValue&&(this._bufferValue.textContent=`${e} m`)}_build(){let e=document.createElement(`div`);e.className=`lidar-crosssection-controls`,this._drawButton=document.createElement(`button`),this._drawButton.type=`button`,this._drawButton.className=`lidar-control-button lidar-crosssection-draw`,this._drawButton.textContent=`Draw Line`,this._drawButton.addEventListener(`click`,e=>{e.stopPropagation(),this._isDrawing=!this._isDrawing,this.setDrawing(this._isDrawing),this._callbacks.onDrawToggle(this._isDrawing)}),e.appendChild(this._drawButton),this._clearButton=document.createElement(`button`),this._clearButton.type=`button`,this._clearButton.className=`lidar-control-button lidar-crosssection-clear`,this._clearButton.textContent=`Clear`,this._clearButton.addEventListener(`click`,e=>{e.stopPropagation(),this._callbacks.onClear(),this.setDrawing(!1)}),e.appendChild(this._clearButton),this._downloadButton=document.createElement(`button`),this._downloadButton.type=`button`,this._downloadButton.className=`lidar-control-button secondary`,this._downloadButton.textContent=`CSV`,this._downloadButton.title=`Download profile data as CSV`,this._downloadButton.disabled=!0,this._downloadButton.addEventListener(`click`,e=>{e.stopPropagation(),this._downloadCSV()}),e.appendChild(this._downloadButton),this._expandButton=document.createElement(`button`),this._expandButton.type=`button`,this._expandButton.className=`lidar-control-button secondary`,this._expandButton.innerHTML=`⤢`,this._expandButton.title=`Expand chart in popup`,this._expandButton.disabled=!0,this._expandButton.addEventListener(`click`,e=>{e.stopPropagation(),this._openPopup()}),e.appendChild(this._expandButton),this._container.appendChild(e);let t=document.createElement(`div`);t.className=`lidar-control-group`;let n=document.createElement(`label`);n.className=`lidar-control-label`,n.textContent=`Buffer Distance: `,this._bufferValue=document.createElement(`span`),this._bufferValue.textContent=`${this._options.bufferDistance} m`,n.appendChild(this._bufferValue),t.appendChild(n),this._bufferSlider=document.createElement(`input`),this._bufferSlider.type=`range`,this._bufferSlider.className=`lidar-control-slider`,this._bufferSlider.min=`1`,this._bufferSlider.max=`100`,this._bufferSlider.step=`1`,this._bufferSlider.value=String(this._options.bufferDistance),this._bufferSlider.addEventListener(`input`,e=>{e.stopPropagation();let t=parseInt(this._bufferSlider.value,10);this._bufferValue.textContent=`${t} m`,this._callbacks.onBufferDistanceChange(t)}),t.appendChild(this._bufferSlider),this._container.appendChild(t),this._chartContainer=document.createElement(`div`),this._chartContainer.className=`lidar-crosssection-chart`,this._chartContainer.appendChild(this._chart.render()),this._container.appendChild(this._chartContainer),this._statsContainer=document.createElement(`div`),this._statsContainer.className=`lidar-crosssection-stats`,this._container.appendChild(this._statsContainer),this._updateStats()}_updateStats(){if(!this._statsContainer)return;if(!this._profile||this._profile.points.length===0){this._statsContainer.innerHTML=`<div class="lidar-crosssection-stat">No profile data</div>`;return}let{stats:e}=this._profile;this._statsContainer.innerHTML=`
|
||
<div class="lidar-crosssection-stat">
|
||
<span class="lidar-crosssection-stat-label">Points:</span>
|
||
<span class="lidar-crosssection-stat-value">${e.pointCount.toLocaleString()}</span>
|
||
</div>
|
||
<div class="lidar-crosssection-stat">
|
||
<span class="lidar-crosssection-stat-label">Distance:</span>
|
||
<span class="lidar-crosssection-stat-value">${e.totalDistance.toFixed(1)} m</span>
|
||
</div>
|
||
<div class="lidar-crosssection-stat">
|
||
<span class="lidar-crosssection-stat-label">Elevation:</span>
|
||
<span class="lidar-crosssection-stat-value">${e.minElevation.toFixed(1)} - ${e.maxElevation.toFixed(1)} m</span>
|
||
</div>
|
||
<div class="lidar-crosssection-stat">
|
||
<span class="lidar-crosssection-stat-label">Mean:</span>
|
||
<span class="lidar-crosssection-stat-value">${e.meanElevation.toFixed(1)} m</span>
|
||
</div>
|
||
`}_setupResizeObserver(){this._resizeObserver=new ResizeObserver(e=>{for(let t of e)if(t.target===this._container){let e=t.contentRect.width,n=Math.max(200,e-4);this._chart.resize(n,this._options.chartHeight)}}),this._resizeObserver.observe(this._container)}_openPopup(){if(!this._profile)return;this._popupBackdrop=document.createElement(`div`),this._popupBackdrop.className=`lidar-chart-popup-backdrop`,this._popupBackdrop.addEventListener(`click`,e=>{if(this._ignoreBackdropClick){this._ignoreBackdropClick=!1;return}e.target===this._popupBackdrop&&this._closePopup()}),this._popupContainer=document.createElement(`div`),this._popupContainer.className=`lidar-chart-popup`;let e=document.createElement(`div`);e.className=`lidar-chart-popup-header`;let t=document.createElement(`span`);t.className=`lidar-chart-popup-title`,t.textContent=`Cross-Section Elevation Profile`,e.appendChild(t);let n=document.createElement(`button`);n.className=`lidar-chart-popup-close`,n.innerHTML=`×`,n.title=`Close`,n.addEventListener(`click`,()=>this._closePopup()),e.appendChild(n),this._popupContainer.appendChild(e);let r=document.createElement(`div`);r.className=`lidar-chart-popup-content`,this._popupChartContainer=r,this._popupChart=new G9({width:700,height:400,colormap:this._options.colormap}),this._popupChart.setProfile(this._profile),r.appendChild(this._popupChart.render()),this._popupContainer.appendChild(r);let i=document.createElement(`div`);i.className=`lidar-chart-popup-stats`;let{stats:a}=this._profile;i.innerHTML=`
|
||
<span><strong>Points:</strong> ${a.pointCount.toLocaleString()}</span>
|
||
<span><strong>Distance:</strong> ${a.totalDistance.toFixed(1)} m</span>
|
||
<span><strong>Elevation:</strong> ${a.minElevation.toFixed(1)} - ${a.maxElevation.toFixed(1)} m</span>
|
||
<span><strong>Mean:</strong> ${a.meanElevation.toFixed(1)} m</span>
|
||
`,this._popupContainer.appendChild(i);let o=document.createElement(`div`);o.className=`lidar-chart-popup-resize`,o.title=`Drag to resize`,o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),this._startPopupResize(e)}),this._popupContainer.appendChild(o),this._popupBackdrop.appendChild(this._popupContainer),document.body.appendChild(this._popupBackdrop),document.body.style.overflow=`hidden`,this._popupResizeObserver=new ResizeObserver(()=>{this._syncPopupChartSize()}),this._popupResizeObserver.observe(r),this._syncPopupChartSize()}_closePopup(){this._popupBackdrop&&=(this._popupBackdrop.remove(),void 0),this._popupChart&&=(this._popupChart.destroy(),void 0),this._popupResizeObserver&&=(this._popupResizeObserver.disconnect(),void 0),this._popupContainer=void 0,this._popupChartContainer=void 0,this._ignoreBackdropClick=!1,document.body.style.overflow=``}_startPopupResize(e){if(!this._popupContainer)return;this._isResizing=!0,this._ignoreBackdropClick=!0,this._resizeStartX=e.clientX,this._resizeStartY=e.clientY;let t=this._popupContainer.getBoundingClientRect();this._resizeStartWidth=t.width,this._resizeStartHeight=t.height,document.addEventListener(`mousemove`,this._handlePopupResizeMouseMove),document.addEventListener(`mouseup`,this._handlePopupResizeMouseUp),document.body.style.cursor=`nwse-resize`,document.body.style.userSelect=`none`}_onPopupResizeMouseMove(e){if(!this._isResizing||!this._popupContainer)return;let t=e.clientX-this._resizeStartX,n=e.clientY-this._resizeStartY,r=Math.max(400,Math.min(window.innerWidth-40,this._resizeStartWidth+t)),i=Math.max(300,Math.min(window.innerHeight-40,this._resizeStartHeight+n));this._popupContainer.style.width=`${r}px`,this._popupContainer.style.height=`${i}px`,this._syncPopupChartSize()}_onPopupResizeMouseUp(){this._isResizing=!1,document.removeEventListener(`mousemove`,this._handlePopupResizeMouseMove),document.removeEventListener(`mouseup`,this._handlePopupResizeMouseUp),document.body.style.cursor=``,document.body.style.userSelect=``,this._syncPopupChartSize(),window.setTimeout(()=>{this._ignoreBackdropClick=!1},0),this._popupChart&&this._profile&&this._popupChart.setProfile(this._profile)}_syncPopupChartSize(){if(!this._popupChart||!this._popupChartContainer)return;let e=this._popupChartContainer.getBoundingClientRect(),t=window.getComputedStyle(this._popupChartContainer),n=(Number.parseFloat(t.paddingLeft)||0)+(Number.parseFloat(t.paddingRight)||0),r=(Number.parseFloat(t.paddingTop)||0)+(Number.parseFloat(t.paddingBottom)||0),i=Math.max(200,e.width-n),a=Math.max(150,e.height-r);this._popupChart.resize(i,a)}_downloadCSV(){if(!this._profile||this._profile.points.length===0)return;let e=[[`distance`,`elevation`,`offsetFromLine`,`longitude`,`latitude`,`intensity`,`classification`].join(`,`)];for(let t of this._profile.points){let n=[t.distance.toFixed(3),t.elevation.toFixed(3),t.offsetFromLine.toFixed(3),t.longitude.toFixed(8),t.latitude.toFixed(8),t.intensity===void 0?``:t.intensity.toFixed(4),t.classification===void 0?``:String(t.classification)];e.push(n.join(`,`))}let t=e.join(`
|
||
`),n=new Blob([t],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`cross-section-profile-${Date.now()}.csv`,i.style.display=`none`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}destroy(){this._closePopup(),this._resizeObserver&&=(this._resizeObserver.disconnect(),void 0),this._isResizing&&(document.removeEventListener(`mousemove`,this._handlePopupResizeMouseMove),document.removeEventListener(`mouseup`,this._handlePopupResizeMouseUp),document.body.style.cursor=``,document.body.style.userSelect=``),this._chart.destroy(),this._container.remove()}},q9=class{static EARTH_RADIUS_M=6371e3;static extract(e,t,n){let r=[],{positions:i,intensities:a,classifications:o,pointCount:s}=t,c=e.start,l=e.end,u=this.haversineDistance(c,l),d=l[0]-c[0],f=l[1]-c[1],p=d*d+f*f;for(let t=0;t<s;t++){let s=i[t*3]+n[0],d=i[t*3+1]+n[1],f=i[t*3+2],{distance:m,offset:h}=this.pointToLineDistance([s,d],c,l,p,u);if(h<=e.bufferDistance&&m>=0&&m<=u){let e={distance:m,elevation:f,offsetFromLine:h,longitude:s,latitude:d,intensity:a?a[t]:void 0,classification:o?o[t]:void 0};r.push(e)}}return r.sort((e,t)=>e.distance-t.distance),{line:e,points:r,stats:this.calculateStats(r,u)}}static haversineDistance(e,t){let n=this.toRadians(e[1]),r=this.toRadians(t[1]),i=this.toRadians(t[1]-e[1]),a=this.toRadians(t[0]-e[0]),o=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n)*Math.cos(r)*Math.sin(a/2)*Math.sin(a/2),s=2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o));return this.EARTH_RADIUS_M*s}static pointToLineDistance(e,t,n,r,i){let a=n[0]-t[0],o=n[1]-t[1],s=e[0]-t[0],c=e[1]-t[1],l=(s*a+c*o)/r;l=Math.max(0,Math.min(1,l));let u=t[0]+l*a,d=t[1]+l*o;return{distance:l*i,offset:this.haversineDistance(e,[u,d])}}static calculateStats(e,t){if(e.length===0)return{minElevation:0,maxElevation:0,meanElevation:0,totalDistance:t,pointCount:0};let n=1/0,r=-1/0,i=0;for(let t of e)n=Math.min(n,t.elevation),r=Math.max(r,t.elevation),i+=t.elevation;return{minElevation:n,maxElevation:r,meanElevation:i/e.length,totalDistance:t,pointCount:e.length}}static toRadians(e){return Math.PI/180*e}static createBufferPolygon(e,t=8){let[n,r]=e.start,[i,a]=e.end,o=this.metersToDegrees(e.bufferDistance,(r+a)/2),s=i-n,c=a-r,l=Math.sqrt(s*s+c*c),u=-c/l,d=s/l,f=[];f.push([n+u*o,r+d*o]),f.push([i+u*o,a+d*o]);for(let e=0;e<=t;e++){let n=Math.atan2(d,u)-Math.PI+Math.PI*e/t;f.push([i+Math.cos(n)*o,a+Math.sin(n)*o])}f.push([i-u*o,a-d*o]),f.push([n-u*o,r-d*o]);for(let e=0;e<=t;e++){let i=Math.atan2(d,u)+Math.PI*e/t;f.push([n+Math.cos(i)*o,r+Math.sin(i)*o])}return f.push(f[0]),f}static metersToDegrees(e,t){let n=this.toRadians(t);return e/(this.EARTH_RADIUS_M*Math.cos(n)*(Math.PI/180))}},J9=class{_map;_deckOverlay;_enabled=!1;_isDrawing=!1;_startPoint=null;_endPoint=null;_bufferDistance=10;LAYER_ID=`lidar-cross-section-layer`;_onLineChange;_handleClickBound;_handleMouseMoveBound;constructor(e,t){this._map=e,this._deckOverlay=t,this._handleClickBound=this._handleClick.bind(this),this._handleMouseMoveBound=this._handleMouseMove.bind(this)}enable(){this._enabled||(this._enabled=!0,this._addEventListeners(),this._map.getCanvas().style.cursor=`crosshair`)}disable(){this._enabled&&(this._enabled=!1,this._removeEventListeners(),this._map.getCanvas().style.cursor=``,this._isDrawing=!1)}isEnabled(){return this._enabled}getLine(){return!this._startPoint||!this._endPoint?null:{start:this._startPoint,end:this._endPoint,bufferDistance:this._bufferDistance}}setBufferDistance(e){this._bufferDistance=e,this._updateVisualization(),this._notifyLineChange()}getBufferDistance(){return this._bufferDistance}clearLine(){this._startPoint=null,this._endPoint=null,this._isDrawing=!1,this._removeDeckLayers(),this._notifyLineChange()}setOnLineChange(e){this._onLineChange=e}destroy(){this.disable(),this._removeDeckLayers()}_removeDeckLayers(){this._deckOverlay.hasLayer(this.LAYER_ID)&&this._deckOverlay.removeLayer(this.LAYER_ID)}_addEventListeners(){this._map.on(`click`,this._handleClickBound),this._map.on(`mousemove`,this._handleMouseMoveBound)}_removeEventListeners(){this._map.off(`click`,this._handleClickBound),this._map.off(`mousemove`,this._handleMouseMoveBound)}_handleClick(e){let t=e.lngLat;this._isDrawing?(this._endPoint=[t.lng,t.lat],this._isDrawing=!1,this._notifyLineChange()):(this._startPoint=[t.lng,t.lat],this._endPoint=null,this._isDrawing=!0),this._updateVisualization()}_handleMouseMove(e){!this._isDrawing||!this._startPoint||(this._endPoint=[e.lngLat.lng,e.lngLat.lat],this._updateVisualization())}_updateVisualization(){let e=[];if(this._startPoint&&e.push({type:`Feature`,properties:{type:`point`,position:`start`},geometry:{type:`Point`,coordinates:this._startPoint}}),this._startPoint&&this._endPoint){e.push({type:`Feature`,properties:{type:`point`,position:`end`},geometry:{type:`Point`,coordinates:this._endPoint}}),e.push({type:`Feature`,properties:{type:`line`},geometry:{type:`LineString`,coordinates:[this._startPoint,this._endPoint]}});let t=q9.createBufferPolygon({start:this._startPoint,end:this._endPoint,bufferDistance:this._bufferDistance});e.push({type:`Feature`,properties:{type:`buffer`},geometry:{type:`Polygon`,coordinates:[t]}})}let t={type:`FeatureCollection`,features:e},n=new bZ({id:this.LAYER_ID,data:t,pickable:!1,stroked:!0,filled:!0,parameters:{depthTest:!1,depthMask:!1},getFillColor:e=>e.properties?.type===`point`?[255,51,51,255]:e.properties?.type===`buffer`?[51,136,255,50]:[0,0,0,0],getLineColor:e=>e.properties?.type===`line`?[51,136,255,255]:e.properties?.type===`buffer`?[51,136,255,100]:e.properties?.type===`point`?[255,255,255,255]:[0,0,0,0],getLineWidth:e=>e.properties?.type===`line`?3:e.properties?.type===`point`?2:1,lineWidthUnits:`pixels`,pointType:`circle`,getPointRadius:8,pointRadiusUnits:`pixels`});this._deckOverlay.hasLayer(this.LAYER_ID)?this._deckOverlay.updateLayer(this.LAYER_ID,n):this._deckOverlay.addLayer(this.LAYER_ID,n)}_notifyLineChange(){this._onLineChange&&this._onLineChange(this.getLine())}},Y9=`lidar`,X9=`url`,Z9=[`url`,`lon`,`lat`,`zoom`,`bearing`,`pitch`,`size`,`opacity`,`color`,`cmap`,`range`,`plow`,`phigh`,`amin`,`amax`,`emin`,`emax`,`pick`,`zoff`,`zoffEnabled`,`terrain`,`hidden`],Q9={collapsed:!0,position:`top-right`,title:`LiDAR Viewer`,panelWidth:365,maxHeight:500,className:``,pointSize:2,opacity:1,colorScheme:`elevation`,usePercentile:!0,colormap:`viridis`,colorRange:{mode:`percentile`,percentileLow:2,percentileHigh:98},showColorbar:!0,pointBudget:1e6,elevationRange:null,pickable:!1,autoZoom:!0,pickInfoFields:void 0,zOffsetEnabled:!1,zOffset:0,autoZOffset:!0,copcLoadingMode:void 0,streamingPointBudget:5e6,streamingMaxConcurrentRequests:4,streamingViewportDebounceMs:150,terrainEnabled:!1,terrainExaggeration:1,shareUrl:!0,restoreFromUrl:!0},$9=class{_map;_mapContainer;_container;_panel;_options;_state;_eventHandlers=new globalThis.Map;_resizeHandler=null;_mapResizeHandler=null;_clickOutsideHandler=null;_deckOverlay;_pointCloudManager;_loader;_panelBuilder;_tooltip;_streamingLoaders=new Map;_eptStreamingLoaders=new Map;_viewportManagers=new Map;_copcViewportRequestIds=new Map;_eptViewportRequestIds=new Map;_eptLastViewport=new Map;_manualZOffset=!1;_metadataPanel;_fullMetadata=new Map;_crossSectionTool;_crossSectionPanel;_currentProfile=null;constructor(e){this._options={...Q9,...e};let t=this._options.colorRange??{mode:`percentile`,percentileLow:2,percentileHigh:98};this._state={collapsed:this._options.collapsed,panelWidth:this._options.panelWidth,maxHeight:this._options.maxHeight,pointClouds:[],activePointCloudId:null,pointSize:this._options.pointSize,opacity:this._options.opacity,colorScheme:this._options.colorScheme,colormap:this._options.colormap??`viridis`,colorRange:t,showColorbar:this._options.showColorbar??!0,usePercentile:this._options.usePercentile,elevationRange:this._options.elevationRange,pointBudget:this._options.pointBudget,pickable:this._options.pickable,loading:!1,error:null,pickInfoFields:this._options.pickInfoFields,zOffsetEnabled:this._options.zOffsetEnabled??!1,zOffset:this._options.zOffset??0,hiddenClassifications:new Set,availableClassifications:new Set,terrainEnabled:this._options.terrainEnabled??!1},this._loader=new v9,(e?.zOffset!==void 0||e?.zOffsetEnabled!==void 0)&&(this._manualZOffset=!0)}onAdd(e){return this._map=e,this._mapContainer=e.getContainer(),this._deckOverlay=new K3(e),this._pointCloudManager=new N9(this._deckOverlay,{pointSize:this._state.pointSize,opacity:this._state.opacity,colorScheme:this._state.colorScheme,usePercentile:this._state.usePercentile,elevationRange:this._state.elevationRange,pickable:this._state.pickable,zOffset:this._state.zOffset,onHover:e=>this._handlePointHover(e)}),this._tooltip=this._createTooltip(),document.body.appendChild(this._tooltip),this._container=this._createContainer(),this._panel=this._createPanel(),this._mapContainer.appendChild(this._panel),this._setupEventListeners(),this._state.collapsed||(this._panel.classList.add(`expanded`),requestAnimationFrame(()=>{this._updatePanelPosition()})),this._state.terrainEnabled&&this.setTerrain(!0),this._options.restoreFromUrl&&this.restoreFromUrl().catch(e=>{console.warn(`Failed to restore LiDAR state from URL:`,e)}),this._container}onRemove(){this.stopStreaming(),this._deckOverlay?.destroy(),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null),this._mapResizeHandler&&this._map&&(this._map.off(`resize`,this._mapResizeHandler),this._mapResizeHandler=null),this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler),null),this._tooltip?.parentNode?.removeChild(this._tooltip),this._panel?.parentNode?.removeChild(this._panel),this._container?.parentNode?.removeChild(this._container),this._map=void 0,this._mapContainer=void 0,this._container=void 0,this._panel=void 0,this._deckOverlay=void 0,this._pointCloudManager=void 0,this._panelBuilder=void 0,this._tooltip=void 0,this._eventHandlers.clear()}getState(){return{...this._state}}getShareUrl(){let e=typeof window<`u`?window.location.href:`http://localhost/`;return _ae(e,z3(this._state,this._getShareMapState(),e))}async restoreFromUrl(e){let t=e??(typeof window<`u`?window.location.href:void 0);if(!t)return[];let n=vae(t);if(!n)return[];let r=n.visualization;this.setPointSize(r.pointSize),this.setOpacity(r.opacity),this.setColorScheme(r.colorScheme),this.setColormap(r.colormap),this.setColorRange(r.colorRange),r.elevationRange?this.setElevationRange(r.elevationRange[0],r.elevationRange[1]):this.clearElevationRange(),this.setPickable(r.pickable),this.setZOffsetEnabled(r.zOffsetEnabled),r.zOffsetEnabled&&this.setZOffset(r.zOffset),this.setTerrain(r.terrainEnabled),this._panelBuilder?.updateState(this._state),n.map&&this._applyShareMapState(n.map);let i=[],a=this._options.autoZoom;this._options.autoZoom=!1;try{for(let e of n.pointClouds)i.push(await this.loadPointCloud(e))}finally{this._options.autoZoom=a}let o=new Set(r.hiddenClassifications);return this._pointCloudManager?.setHiddenClassifications(o),this.setState({hiddenClassifications:o}),this._emit(`stylechange`),n.map&&(this._applyShareMapState(n.map),typeof requestAnimationFrame==`function`&&requestAnimationFrame(()=>this._applyShareMapState(n.map)),globalThis.setTimeout(()=>this._applyShareMapState(n.map),250),globalThis.setTimeout(()=>this._applyShareMapState(n.map),1250)),i}setState(e){this._state={...this._state,...e},this._panelBuilder?.updateState(this._state),this._state.collapsed||this._updatePanelPosition(),this._emit(`statechange`)}toggle(){this._state.collapsed=!this._state.collapsed,this._panel&&(this._state.collapsed?(this._panel.classList.remove(`expanded`),this._emit(`collapse`)):(this._panel.classList.add(`expanded`),this._updatePanelPosition(),this._emit(`expand`))),this._emit(`statechange`)}expand(){this._state.collapsed&&this.toggle()}collapse(){this._state.collapsed||this.toggle()}on(e,t){this._eventHandlers.has(e)||this._eventHandlers.set(e,new Set),this._eventHandlers.get(e).add(t)}off(e,t){this._eventHandlers.get(e)?.delete(t)}getMap(){return this._map}getContainer(){return this._container}getDeckOverlay(){return this._deckOverlay}async loadPointCloud(e,t){if(typeof e==`string`&&(e.endsWith(`/ept.json`)||e.includes(`/ept.json?`)))return this.loadPointCloudEptStreaming(e);let n=typeof e==`string`&&(e.startsWith(`http://`)||e.startsWith(`https://`))&&/\.copc\./i.test(e),r=e instanceof File&&/\.copc\./i.test(e.name),i=n||r;if((t?.loadingMode??this._options.copcLoadingMode??(i?`dynamic`:`full`))===`dynamic`&&i)return this.loadPointCloudStreaming(e);let a=S3(`pc`),o;o=typeof e==`string`?T3(e):e instanceof File?e.name:`PointCloud ${a}`,this.setState({loading:!0,error:null}),this._emit(`loadstart`);let s=(e,t)=>{this._panelBuilder?.updateLoadingProgress(e,t)};try{let t=await this._loader.load(e,s);s(95,`Creating visualization layers...`),this._pointCloudManager?.addPointCloud(a,t);let n,r,i=this._state.zOffsetEnabled;if(this._options.autoZOffset&&!this._manualZOffset&&t.positions&&t.pointCount>0){let e=new Float32Array(t.pointCount);for(let n=0;n<t.pointCount;n++)e[n]=t.positions[n*3+2]??0;n=D3(e,2,98).min,r=-n,i=!0,this._pointCloudManager?.setZOffset(r),console.log(`Auto Z offset applied: zOffsetBase=${n.toFixed(1)}, zOffset=${r.toFixed(1)}, enabled=${i}`)}else this._manualZOffset?(this._pointCloudManager?.setZOffset(this._state.zOffset),r=this._state.zOffset,i=this._state.zOffsetEnabled,console.log(`Manual Z offset applied: zOffset=${r}, enabled=${i}`)):console.log(`Auto Z offset skipped - conditions not met`);s(100,`Complete!`);let c={id:a,name:o,pointCount:t.pointCount,bounds:t.bounds,hasRGB:t.hasRGB,hasIntensity:t.hasIntensity,hasClassification:t.hasClassification,source:typeof e==`string`?e:`file`,wkt:t.wkt},l=A3(t),u=new Set([...this._state.availableClassifications,...l]),d=[...this._state.pointClouds,c];return this.setState({loading:!1,pointClouds:d,activePointCloudId:a,availableClassifications:u,zOffsetBase:n,zOffset:r??this._state.zOffset,zOffsetEnabled:i}),this._updateComputedColorBounds(),this._panelBuilder?.updateState(this._state),this._emitWithData(`load`,{pointCloud:c}),this._options.autoZoom&&this.flyToPointCloud(a),c}catch(t){let n=t instanceof Error?t:Error(String(t)),r=n.message.includes(`CORS`)||n.message===`Failed to fetch`||t instanceof TypeError&&n.message===`Failed to fetch`,i=typeof e==`string`&&(e.startsWith(`http://`)||e.startsWith(`https://`));if(r&&i)return console.warn(`CORS error detected for ${e}. Falling back to download mode...`),this._panelBuilder?.updateLoadingProgress(5,`CORS blocked - downloading file...`),this._loadPointCloudFullDownload(e);throw this.setState({loading:!1,error:`Failed to load: ${n.message}`}),this._emitWithData(`loaderror`,{error:n}),n}}unloadPointCloud(e){if(e){if(this._streamingLoaders.has(e)||this._eptStreamingLoaders.has(e)){this.stopStreaming(e);return}this._pointCloudManager?.removePointCloud(e);let t=this._state.pointClouds.filter(t=>t.id!==e),n={pointClouds:t,activePointCloudId:this._state.activePointCloudId===e?t[0]?.id||null:this._state.activePointCloudId,availableClassifications:new Set,hiddenClassifications:new Set};this.setState(n),this._emitWithData(`unload`,{pointCloud:{id:e}})}else{let e=this._state.pointClouds.map(e=>e.id);this.stopStreaming(),this._pointCloudManager?.clear(),this.setState({pointClouds:[],activePointCloudId:null,availableClassifications:new Set,hiddenClassifications:new Set});for(let t of e)this._emitWithData(`unload`,{pointCloud:{id:t}})}}async loadPointCloudStreaming(e,t){let n=S3(`pc-stream`),r;r=typeof e==`string`?T3(e):e instanceof File?e.name:`PointCloud ${n}`,this.setState({loading:!0,error:null,streamingActive:!0}),this._emit(`loadstart`),this._emit(`streamingstart`);try{let i=new C9(e,{pointBudget:t?.pointBudget??this._options.streamingPointBudget,maxConcurrentRequests:t?.maxConcurrentRequests??this._options.streamingMaxConcurrentRequests,viewportDebounceMs:t?.viewportDebounceMs??this._options.streamingViewportDebounceMs,minDetailZoom:t?.minDetailZoom??10,maxOctreeDepth:t?.maxOctreeDepth??20});this._panelBuilder?.updateLoadingProgress(10,`Initializing COPC file...`);let{bounds:a,totalPoints:o,hasRGB:s,spacing:c}=await i.initialize();this._panelBuilder?.updateLoadingProgress(20,`Setting up streaming...`);let l=!1;i.setOnPointsLoaded(e=>{if(this._pointCloudManager?.updatePointCloud(n,e),this._options.autoZOffset&&!this._manualZOffset&&!l&&e.bounds){let t=e.bounds.minZ,n=-t;this._pointCloudManager?.setZOffset(n),console.log(`Auto Z offset applied (streaming): ${n.toFixed(1)}m (ground level from bounds: ${t.toFixed(1)}m)`),this.setState({zOffsetBase:t,zOffset:n,zOffsetEnabled:!0}),l=!0}else this._manualZOffset&&!l&&(this._pointCloudManager?.setZOffset(this._state.zOffset),l=!0);let t=A3(e);if(t.size>0){let e=new Set([...this._state.availableClassifications,...t]);e.size>this._state.availableClassifications.size&&this.setState({availableClassifications:e})}}),i.on(`progress`,(e,t)=>{let n=t;this.setState({streamingProgress:{loadedNodes:n.loadedNodes,loadedPoints:n.loadedPoints,queueSize:n.queueSize,isLoading:n.isLoading}});let r=Math.min(99,20+Math.round(n.loadedPoints/n.pointBudget*70));this._panelBuilder?.updateLoadingProgress(r,`Streaming: ${n.loadedPoints.toLocaleString()} points loaded`),this._emit(`streamingprogress`)}),i.on(`budgetreached`,()=>{this._emit(`budgetreached`)}),this._streamingLoaders.set(n,i);let u=new P9(this._map,e=>this._handleViewportChangeForStreaming(e,n),{debounceMs:t?.viewportDebounceMs??this._options.streamingViewportDebounceMs,minDetailZoom:t?.minDetailZoom??10,maxOctreeDepth:t?.maxOctreeDepth??20,spacing:c});this._viewportManagers.set(n,u);let d={id:n,name:`${r}`,pointCount:o,bounds:a,hasRGB:s,hasIntensity:!0,hasClassification:!0,source:typeof e==`string`?e:r,wkt:void 0},f=[...this._state.pointClouds,d];if(this.setState({loading:!1,pointClouds:f,activePointCloudId:n}),this._updateComputedColorBounds(),this._panelBuilder?.updateState(this._state),u.start(),this._options.autoZoom){let e=Math.max(-90,Math.min(90,a.minY)),t=Math.max(-90,Math.min(90,a.maxY)),n=Math.max(-180,Math.min(180,a.minX)),r=Math.max(-180,Math.min(180,a.maxX));this._map?.fitBounds([[n,e],[r,t]],{padding:50,duration:1e3}),setTimeout(()=>{u.forceUpdate()},1100)}return this._emitWithData(`load`,{pointCloud:d}),d}catch(t){let r=t instanceof Error?t:Error(String(t));if((r.message.includes(`CORS`)||r.message===`Failed to fetch`||t instanceof TypeError&&r.message===`Failed to fetch`)&&typeof e==`string`){console.warn(`CORS error detected for ${e}. Falling back to download mode...`);let t=this._streamingLoaders.get(n);t&&(t.destroy(),this._streamingLoaders.delete(n)),this._copcViewportRequestIds.delete(n);let r=this._viewportManagers.get(n);r&&(r.destroy(),this._viewportManagers.delete(n));let i=this._streamingLoaders.size>0;return this.setState({loading:!0,streamingActive:i,error:null}),this._panelBuilder?.updateLoadingProgress(5,`CORS blocked - downloading file...`),this._loadPointCloudFullDownload(e)}this.setState({loading:!1,streamingActive:!1,error:`Failed to load: ${r.message}`});let i=this._streamingLoaders.get(n);throw i&&(i.destroy(),this._streamingLoaders.delete(n)),this._copcViewportRequestIds.delete(n),this._emitWithData(`loaderror`,{error:r}),r}}async loadPointCloudEptStreaming(e,t){let n=S3(`ept-stream`),r=T3(e.replace(`/ept.json`,``));this.setState({loading:!0,error:null,streamingActive:!0}),this._emit(`loadstart`),this._emit(`streamingstart`);try{let i=new D9(e,{pointBudget:t?.pointBudget??this._options.streamingPointBudget,maxConcurrentRequests:t?.maxConcurrentRequests??this._options.streamingMaxConcurrentRequests,viewportDebounceMs:t?.viewportDebounceMs??this._options.streamingViewportDebounceMs,minDetailZoom:t?.minDetailZoom??10,maxOctreeDepth:t?.maxOctreeDepth??20});this._panelBuilder?.updateLoadingProgress(10,`Initializing EPT dataset...`);let{bounds:a,totalPoints:o,hasRGB:s,spacing:c}=await i.initialize();this._panelBuilder?.updateLoadingProgress(20,`Setting up streaming...`);let l=!1;i.setOnPointsLoaded(e=>{if(this._pointCloudManager?.updatePointCloud(n,e),this._options.autoZOffset&&!this._manualZOffset&&!l&&e.bounds){let t=e.bounds.minZ,n=-t;this._pointCloudManager?.setZOffset(n),console.log(`Auto Z offset applied (EPT streaming): ${n.toFixed(1)}m`),this.setState({zOffsetBase:t,zOffset:n,zOffsetEnabled:!0}),l=!0}else this._manualZOffset&&!l&&(this._pointCloudManager?.setZOffset(this._state.zOffset),l=!0);let t=A3(e);if(t.size>0){let e=new Set([...this._state.availableClassifications,...t]);e.size>this._state.availableClassifications.size&&this.setState({availableClassifications:e})}}),i.on(`progress`,(e,t)=>{let n=t;this.setState({streamingProgress:{loadedNodes:n.loadedNodes,loadedPoints:n.loadedPoints,queueSize:n.queueSize,isLoading:n.isLoading}});let r=Math.min(99,20+Math.round(n.loadedPoints/n.pointBudget*70));this._panelBuilder?.updateLoadingProgress(r,`Streaming EPT: ${n.loadedPoints.toLocaleString()} points loaded`),this._emit(`streamingprogress`)}),i.on(`budgetreached`,()=>{this._emit(`budgetreached`)}),this._eptStreamingLoaders.set(n,i);let u=new P9(this._map,e=>this._handleViewportChangeForEptStreaming(e,n),{debounceMs:t?.viewportDebounceMs??this._options.streamingViewportDebounceMs,minDetailZoom:t?.minDetailZoom??10,maxOctreeDepth:t?.maxOctreeDepth??20,spacing:c});this._viewportManagers.set(n,u);let d=i.getMetadata(),f={id:n,name:`${r} (EPT)`,pointCount:o,bounds:a,hasRGB:s,hasIntensity:!0,hasClassification:!0,source:e,wkt:d?.srs?.wkt},p=[...this._state.pointClouds,f];if(this.setState({loading:!1,pointClouds:p,activePointCloudId:n}),this._updateComputedColorBounds(),this._panelBuilder?.updateState(this._state),u.start(),this._options.autoZoom){let e=Math.max(-90,Math.min(90,a.minY)),t=Math.max(-90,Math.min(90,a.maxY)),n=Math.max(-180,Math.min(180,a.minX)),r=Math.max(-180,Math.min(180,a.maxX));this._map?.fitBounds([[n,e],[r,t]],{padding:50,duration:1e3}),setTimeout(()=>{u.forceUpdate()},1100)}return this._emitWithData(`load`,{pointCloud:f}),f}catch(e){let t=e instanceof Error?e:Error(String(e)),r=this._eptStreamingLoaders.get(n);r&&(r.destroy(),this._eptStreamingLoaders.delete(n)),this._eptViewportRequestIds.delete(n),this._eptLastViewport.delete(n);let i=this._viewportManagers.get(n);i&&(i.destroy(),this._viewportManagers.delete(n));let a=this._streamingLoaders.size>0||this._eptStreamingLoaders.size>0;throw this.setState({loading:!1,streamingActive:a,error:`Failed to load EPT: ${t.message}`}),this._emitWithData(`loaderror`,{error:t}),t}}_shouldResetEptForViewportChange(e,t){if(!e)return!1;let[n,r,i,a]=e.bounds,[o,s,c,l]=t.bounds;if(c<n||o>i||l<r||s>a)return!0;let u=i-n,d=a-r,f=t.center[0]-e.center[0],p=t.center[1]-e.center[1];return Math.sqrt(f*f+p*p)>Math.max(u,d)*.3}async _handleViewportChangeForEptStreaming(e,t,n){let r=this._eptStreamingLoaders.get(t);if(r)try{let i=n??(this._eptViewportRequestIds.get(t)??0)+1;if(n===void 0&&this._eptViewportRequestIds.set(t,i),this._eptViewportRequestIds.get(t)!==i)return;let a=this._eptLastViewport.get(t),o=this._shouldResetEptForViewportChange(a,e);if(this._eptLastViewport.set(t,e),r.pruneQueueForViewport(e),o&&!r.resetLoadedData()){setTimeout(()=>{this._handleViewportChangeForEptStreaming(e,t,i)},200);return}let s=await r.selectNodesForViewport(e),c=!1,l=r.getLoadedPointCount()>=r.getPointBudget()*.8,u=Math.max(0,e.targetDepth-2),d=r.getViewportCoverageRatio(e,u),f=d<.5,p=r.hasPendingSubtrees(e),m=s.length>0||p;l&&f&&m&&(c=r.resetLoadedData(),c&&(s=await r.selectNodesForViewport(e))),!l&&d<.1&&s.length===0&&(s=await r.selectNodesForViewport(e));for(let e of s)r.queueNode(e);if(await r.loadQueuedNodes(),this._eptViewportRequestIds.get(t)!==i)return;if(l&&f&&s.length>0&&!c){setTimeout(()=>{this._handleViewportChangeForEptStreaming(e,t,i)},200);return}p&&setTimeout(()=>{this._handleViewportChangeForEptStreaming(e,t,i)},100)}catch(e){console.warn(`Failed to load EPT nodes for viewport:`,e)}}async _loadPointCloudFullDownload(e){let t=S3(`pc`),n=T3(e);try{this._panelBuilder?.updateLoadingProgress(10,`Downloading file...`);let r=await fetch(e);if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);let i=r.headers.get(`content-length`),a=i?parseInt(i,10):0,o=r.body?.getReader();if(!o)throw Error(`Failed to get response reader`);let s=[],c=0;for(;;){let{done:e,value:t}=await o.read();if(e)break;if(s.push(t),c+=t.length,a>0){let e=Math.round(c/a*50);this._panelBuilder?.updateLoadingProgress(10+e,`Downloading: ${(c/1024/1024).toFixed(1)} MB`)}}let l=new Uint8Array(c),u=0;for(let e of s)l.set(e,u),u+=e.length;this._panelBuilder?.updateLoadingProgress(60,`Processing point cloud...`);let d=await this._loader.load(l.buffer,(e,t)=>{let n=60+e*.4;this._panelBuilder?.updateLoadingProgress(n,t)});this._panelBuilder?.updateLoadingProgress(95,`Creating visualization layers...`),this._pointCloudManager?.addPointCloud(t,d);let f,p,m=this._state.zOffsetEnabled;if(this._options.autoZOffset&&!this._manualZOffset&&d.positions&&d.pointCount>0){let e=new Float32Array(d.pointCount);for(let t=0;t<d.pointCount;t++)e[t]=d.positions[t*3+2]??0;f=D3(e,2,98).min,p=-f,m=!0,this._pointCloudManager?.setZOffset(p),console.log(`Auto Z offset applied (download): ${p.toFixed(1)}m (ground level: ${f.toFixed(1)}m)`)}else this._manualZOffset&&(this._pointCloudManager?.setZOffset(this._state.zOffset),p=this._state.zOffset,m=this._state.zOffsetEnabled);this._panelBuilder?.updateLoadingProgress(100,`Complete!`);let h={id:t,name:n,pointCount:d.pointCount,bounds:d.bounds,hasRGB:d.hasRGB,hasIntensity:d.hasIntensity,hasClassification:d.hasClassification,source:e,wkt:d.wkt},g=A3(d),_=new Set([...this._state.availableClassifications,...g]),v=[...this._state.pointClouds,h];return this.setState({loading:!1,pointClouds:v,activePointCloudId:t,availableClassifications:_,zOffsetBase:f,zOffset:p??this._state.zOffset,zOffsetEnabled:m}),this._updateComputedColorBounds(),this._panelBuilder?.updateState(this._state),this._emitWithData(`load`,{pointCloud:h}),this._options.autoZoom&&this.flyToPointCloud(t),h}catch(t){let n=t instanceof Error?t:Error(String(t)),r=n.message.includes(`CORS`)||n.message===`Failed to fetch`||t instanceof TypeError&&n.message===`Failed to fetch`,i;throw i=r?`Cannot load from "${new URL(e).hostname}" - server blocks cross-origin requests (CORS). Please download the file manually and load it using the file picker above.`:`Failed to download: ${n.message}`,this.setState({loading:!1,error:i}),this._emitWithData(`loaderror`,{error:Error(i)}),Error(i)}}async _handleViewportChangeForStreaming(e,t,n){let r=this._streamingLoaders.get(t);if(r)try{let i=n??(this._copcViewportRequestIds.get(t)??0)+1;if(n===void 0&&this._copcViewportRequestIds.set(t,i),this._copcViewportRequestIds.get(t)!==i)return;if(r.pruneQueueForViewport(e),!r.evictLoadedNodesOutsideViewport(e)){setTimeout(()=>{this._handleViewportChangeForStreaming(e,t,i)},200);return}let a=await r.selectNodesForViewport(e);if(this._copcViewportRequestIds.get(t)!==i)return;let o=!1,s=r.getLoadedPointCount()>=r.getPointBudget()*.8,c=Math.max(0,e.targetDepth-2),l=r.getViewportCoverageRatio(e,c)<.5,u=a.length>0;if(s&&l&&u){if(o=r.resetLoadedData(),!o){setTimeout(()=>{this._handleViewportChangeForStreaming(e,t,i)},200);return}a=await r.selectNodesForViewport(e)}for(let e of a)r.queueNode(e);await r.loadQueuedNodes()}catch(e){console.warn(`Failed to load nodes for viewport:`,e)}}stopStreaming(e){if(e){let t=this._viewportManagers.get(e);t&&(t.destroy(),this._viewportManagers.delete(e));let n=this._streamingLoaders.get(e);n&&(n.destroy(),this._streamingLoaders.delete(e)),this._copcViewportRequestIds.delete(e);let r=this._eptStreamingLoaders.get(e);r&&(r.destroy(),this._eptStreamingLoaders.delete(e)),this._pointCloudManager?.removePointCloud(e);let i=this._state.pointClouds.filter(t=>t.id!==e),a=this._streamingLoaders.size>0||this._eptStreamingLoaders.size>0;this.setState({pointClouds:i,activePointCloudId:this._state.activePointCloudId===e?i[0]?.id||null:this._state.activePointCloudId,streamingActive:a,streamingProgress:a?this._state.streamingProgress:void 0,availableClassifications:new Set,hiddenClassifications:new Set}),this._emit(`streamingstop`),this._emitWithData(`unload`,{pointCloud:{id:e}})}else{let e=[...Array.from(this._streamingLoaders.keys()),...Array.from(this._eptStreamingLoaders.keys())];for(let e of this._viewportManagers.values())e.destroy();this._viewportManagers.clear();for(let e of this._streamingLoaders.values())e.destroy();this._streamingLoaders.clear(),this._copcViewportRequestIds.clear();for(let e of this._eptStreamingLoaders.values())e.destroy();this._eptStreamingLoaders.clear(),this._eptViewportRequestIds.clear(),this._eptLastViewport.clear();for(let t of e)this._pointCloudManager?.removePointCloud(t);let t=this._state.pointClouds.filter(t=>!e.includes(t.id));if(this.setState({pointClouds:t,activePointCloudId:e.includes(this._state.activePointCloudId||``)?t[0]?.id||null:this._state.activePointCloudId,streamingActive:!1,streamingProgress:void 0,availableClassifications:new Set,hiddenClassifications:new Set}),e.length>0){this._emit(`streamingstop`);for(let t of e)this._emitWithData(`unload`,{pointCloud:{id:t}})}}}isStreaming(e){return e?this._streamingLoaders.has(e)||this._eptStreamingLoaders.has(e):this._streamingLoaders.size>0||this._eptStreamingLoaders.size>0}getStreamingProgress(){return this._state.streamingProgress}setPointSize(e){this._state.pointSize=e,this._pointCloudManager?.setPointSize(e),this._emit(`stylechange`),this._emit(`statechange`)}setOpacity(e){this._state.opacity=e,this._pointCloudManager?.setOpacity(e),this._emit(`stylechange`),this._emit(`statechange`)}setColorScheme(e){let t=this._state.colorScheme;this._state.colorScheme=e,this._pointCloudManager?.setColorScheme(e),typeof e==`string`&&typeof t==`string`&&((e===`elevation`||e===`intensity`)&&(t===`elevation`||t===`intensity`)&&e!==t&&(this._state.colorRange={mode:`percentile`,percentileLow:2,percentileHigh:98},this._pointCloudManager?.setColorRange(this._state.colorRange)),e===`intensity`&&t!==`intensity`?(this._state.colormap=`gray`,this._pointCloudManager?.setColormap(`gray`)):e===`elevation`&&t===`intensity`&&(this._state.colormap=`viridis`,this._pointCloudManager?.setColormap(`viridis`))),this._updateComputedColorBounds(),this._panelBuilder?.updateState(this._state),this._emit(`stylechange`),this._emit(`statechange`)}setColormap(e){this._state.colormap=e,this._pointCloudManager?.setColormap(e),this._updateComputedColorBounds(),this._panelBuilder?.updateState(this._state),this._emit(`stylechange`),this._emit(`statechange`)}getColormap(){return this._state.colormap}setColorRange(e){this._state.colorRange=e,this._pointCloudManager?.setColorRange(e),this._updateComputedColorBounds(),this._panelBuilder?.updateState(this._state),this._emit(`stylechange`),this._emit(`statechange`)}getColorRange(){return this._state.colorRange}setUsePercentile(e){this._state.usePercentile=e,this._pointCloudManager?.setUsePercentile(e),this._emit(`stylechange`),this._emit(`statechange`)}getUsePercentile(){return this._state.usePercentile}setElevationRange(e,t){this._state.elevationRange=[e,t],this._pointCloudManager?.setElevationRange([e,t]),this._emit(`stylechange`),this._emit(`statechange`)}clearElevationRange(){this._state.elevationRange=null,this._pointCloudManager?.setElevationRange(null),this._emit(`stylechange`),this._emit(`statechange`)}setPointBudget(e){this._state.pointBudget=e,this._emit(`statechange`)}setPickable(e){this._state.pickable=e,this._pointCloudManager?.setPickable(e),!e&&this._tooltip&&(this._tooltip.style.display=`none`),this._emit(`stylechange`),this._emit(`statechange`)}setZOffsetEnabled(e){this._state.zOffsetEnabled=e,e||(this._state.zOffset=0,this._pointCloudManager?.setZOffset(0)),this._emit(`stylechange`),this._emit(`statechange`)}setZOffset(e){this._manualZOffset=!0,this._state.zOffset=e,this._pointCloudManager?.setZOffset(e),this._emit(`stylechange`),this._emit(`statechange`)}getZOffset(){return this._state.zOffset}setTerrain(e){this._map&&(this._state.terrainEnabled=e,e?(this._map.getSource(`terrain-dem`)||this._map.addSource(`terrain-dem`,{type:`raster-dem`,tiles:[`https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png`],encoding:`terrarium`,tileSize:256,maxzoom:15}),this._map.setTerrain({source:`terrain-dem`,exaggeration:this._options.terrainExaggeration??1})):this._map.setTerrain(null),this._emit(`stylechange`),this._emit(`statechange`))}getTerrain(){return this._state.terrainEnabled}getPointClouds(){return[...this._state.pointClouds]}flyToPointCloud(e){let t=e||this._state.activePointCloudId||this._state.pointClouds[0]?.id;if(!t||!this._map)return;let n=this._pointCloudManager?.getPointCloudBounds(t);if(n||=this._state.pointClouds.find(e=>e.id===t)?.bounds,!n){console.warn(`Cannot fly to point cloud: no bounds available`);return}if(Math.abs(n.minY)>90||Math.abs(n.maxY)>90||Math.abs(n.minX)>180||Math.abs(n.maxX)>180){console.error(`Cannot fly to point cloud: coordinates are not in WGS84 range`,n);return}if(isNaN(n.minX)||isNaN(n.minY)||isNaN(n.maxX)||isNaN(n.maxY)){console.error(`Cannot fly to point cloud: bounds contain NaN values`,n);return}this._map.fitBounds([[n.minX,n.minY],[n.maxX,n.maxY]],{padding:50,duration:1e3})}_getShareMapState(){if(!this._map)return;let e=this._map.getCenter();return{center:[e.lng,e.lat],zoom:this._map.getZoom(),bearing:this._map.getBearing(),pitch:this._map.getPitch()}}_applyShareMapState(e){this._map&&this._map.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch})}_emit(e){let t=this._eventHandlers.get(e);if(t){let n={type:e,state:this.getState()};t.forEach(e=>e(n))}}_emitWithData(e,t){let n=this._eventHandlers.get(e);if(n){let r={type:e,state:this.getState(),...t};n.forEach(e=>e(r))}}_updateComputedColorBounds(){if(this._state.pointClouds.length===0){this._state.computedColorBounds=void 0;return}let e=this._pointCloudManager?.getLastComputedBounds();e?this._state.computedColorBounds=e:(typeof this._state.colorScheme==`string`?this._state.colorScheme:`elevation`)===`intensity`?this._state.computedColorBounds=this._getIntensityBounds():this._state.computedColorBounds=this._getElevationBounds()}_getElevationBounds(){if(this._state.pointClouds.length===0)return{min:0,max:100};let e=1/0,t=-1/0;for(let n of this._state.pointClouds)e=Math.min(e,n.bounds.minZ),t=Math.max(t,n.bounds.maxZ);return{min:e,max:t}}_getIntensityBounds(){return{min:0,max:1}}_createContainer(){let e=document.createElement(`div`);e.className=`maplibregl-ctrl maplibregl-ctrl-group lidar-control${this._options.className?` ${this._options.className}`:``}`;let t=document.createElement(`button`);return t.className=`lidar-control-toggle`,t.type=`button`,t.setAttribute(`aria-label`,this._options.title),t.innerHTML=`
|
||
<span class="lidar-control-icon">
|
||
<svg viewBox="0 0 24 24" width="22" height="22" stroke="currentColor" stroke-width="1.5" fill="none">
|
||
<circle cx="12" cy="12" r="2"/>
|
||
<circle cx="12" cy="5" r="1.5"/>
|
||
<circle cx="12" cy="19" r="1.5"/>
|
||
<circle cx="5" cy="12" r="1.5"/>
|
||
<circle cx="19" cy="12" r="1.5"/>
|
||
<circle cx="7" cy="7" r="1"/>
|
||
<circle cx="17" cy="7" r="1"/>
|
||
<circle cx="7" cy="17" r="1"/>
|
||
<circle cx="17" cy="17" r="1"/>
|
||
</svg>
|
||
</span>
|
||
`,t.addEventListener(`click`,()=>this.toggle()),e.appendChild(t),e}_createPanel(){let e=document.createElement(`div`);e.className=`lidar-control-panel`,e.style.width=`${this._options.panelWidth}px`;let t=document.createElement(`div`);t.className=`lidar-control-header`;let n=document.createElement(`span`);n.className=`lidar-control-title`,n.textContent=this._options.title;let r=document.createElement(`button`);r.className=`lidar-control-close`,r.type=`button`,r.setAttribute(`aria-label`,`Close panel`),r.innerHTML=`×`,r.addEventListener(`click`,()=>this.collapse()),t.appendChild(n),t.appendChild(r),this._panelBuilder=new U9({onFileSelect:e=>this.loadPointCloud(e),onUrlSubmit:e=>this.loadPointCloud(e),onPointSizeChange:e=>this.setPointSize(e),onOpacityChange:e=>this.setOpacity(e),onColorSchemeChange:e=>this.setColorScheme(e),onColormapChange:e=>this.setColormap(e),onColorRangeChange:e=>this.setColorRange(e),onUsePercentileChange:e=>this.setUsePercentile(e),onElevationRangeChange:e=>{e?this.setElevationRange(e[0],e[1]):this.clearElevationRange()},onPickableChange:e=>this.setPickable(e),onZOffsetEnabledChange:e=>this.setZOffsetEnabled(e),onZOffsetChange:e=>this.setZOffset(e),onUnload:e=>this.unloadPointCloud(e),onZoomTo:e=>this.flyToPointCloud(e),onClassificationToggle:(e,t)=>this._toggleClassification(e,t),onClassificationShowAll:()=>this._showAllClassifications(),onClassificationHideAll:()=>this._hideAllClassifications(),onTerrainChange:e=>this.setTerrain(e),onShowMetadata:e=>this.showMetadataPanel(e),onCrossSectionPanel:()=>this.getCrossSectionPanel().render(),onShareUrl:this._options.shareUrl?()=>this.getShareUrl():void 0},this._state);let i=this._panelBuilder.build();return e.appendChild(t),e.appendChild(i),e}_createTooltip(){let e=document.createElement(`div`);return e.className=`lidar-tooltip`,e.style.cssText=`
|
||
position: fixed;
|
||
pointer-events: none;
|
||
background: rgba(0, 0, 0, 0.85);
|
||
color: white;
|
||
padding: 8px 12px;
|
||
border-radius: 4px;
|
||
font-size: 12px;
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||
z-index: 10000;
|
||
display: none;
|
||
white-space: nowrap;
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||
`,e}_formatGpsTime(e){if(e>1e9){let t=Date.UTC(1980,0,6,0,0,0)+(e-18)*1e3;return new Date(t).toISOString().replace(`T`,` `).slice(0,19)}return e.toFixed(6)}_formatAttributeValue(e,t){let n=e.toLowerCase();return n===`gpstime`?this._formatGpsTime(t):n===`intensity`?`${(t*100).toFixed(1)}%`:n===`classification`?this._getClassificationName(t):n.includes(`angle`)?`${t.toFixed(1)}°`:[`synthetic`,`keypoint`,`withheld`,`overlap`,`edgeofflightline`,`scandirectionflag`].includes(n)?t===0?`0`:`1`:Number.isInteger(t)||[`returnnumber`,`numberofreturns`,`pointsourceid`,`userdata`,`scannerchannel`].includes(n)?Math.round(t).toString():Math.abs(t)<.01||Math.abs(t)>1e5?t.toExponential(4):t.toFixed(2)}_getClassificationName(e){return{0:`Never Classified`,1:`Unassigned`,2:`Ground`,3:`Low Vegetation`,4:`Medium Vegetation`,5:`High Vegetation`,6:`Building`,7:`Low Point`,8:`Reserved`,9:`Water`,10:`Rail`,11:`Road Surface`,12:`Reserved`,13:`Wire - Guard`,14:`Wire - Conductor`,15:`Transmission Tower`,16:`Wire - Connector`,17:`Bridge Deck`,18:`High Noise`}[e]||`Class ${e}`}_shouldShowAttribute(e){let t=this._state.pickInfoFields;return!t||t.length===0?!0:t.some(t=>t.toLowerCase()===e.toLowerCase())}_handlePointHover(e){if(this._tooltip)if(e&&this._state.pickable){let t=`
|
||
<div style="margin-bottom: 4px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.3); padding-bottom: 4px;">Point Info</div>
|
||
`;if((this._shouldShowAttribute(`X`)||this._shouldShowAttribute(`Longitude`))&&(t+=`<div>X: ${e.longitude.toFixed(6)}</div>`),(this._shouldShowAttribute(`Y`)||this._shouldShowAttribute(`Latitude`))&&(t+=`<div>Y: ${e.latitude.toFixed(6)}</div>`),(this._shouldShowAttribute(`Z`)||this._shouldShowAttribute(`Elevation`))&&(t+=`<div>Z: ${e.elevation.toFixed(2)}</div>`),e.intensity!==void 0&&this._shouldShowAttribute(`Intensity`)&&(t+=`<div>Intensity: ${this._formatAttributeValue(`Intensity`,e.intensity)}</div>`),e.classification!==void 0&&this._shouldShowAttribute(`Classification`)&&(t+=`<div>Classification: ${this._getClassificationName(e.classification)}</div>`),e.red!==void 0&&this._shouldShowAttribute(`Red`)&&(t+=`<div>Red: ${e.red}</div>`),e.green!==void 0&&this._shouldShowAttribute(`Green`)&&(t+=`<div>Green: ${e.green}</div>`),e.blue!==void 0&&this._shouldShowAttribute(`Blue`)&&(t+=`<div>Blue: ${e.blue}</div>`),e.attributes){for(let[n,r]of Object.entries(e.attributes))if(this._shouldShowAttribute(n)){let e=this._formatAttributeValue(n,r);t+=`<div>${n}: ${e}</div>`}}this._tooltip.innerHTML=t,this._tooltip.style.display=`block`;let n=this._mapContainer?.getBoundingClientRect(),r=n?.left??0,i=n?.top??0;this._tooltip.style.left=`${e.x+r+15}px`,this._tooltip.style.top=`${e.y+i+15}px`}else this._tooltip.style.display=`none`}setPickInfoFields(e){this._state.pickInfoFields=e,this._emit(`statechange`)}getPickInfoFields(){return this._state.pickInfoFields}_toggleClassification(e,t){let n=new Set(this._state.hiddenClassifications);t?n.delete(e):n.add(e),this._pointCloudManager?.setHiddenClassifications(n),this.setState({hiddenClassifications:n}),this._emit(`stylechange`)}_showAllClassifications(){let e=new Set;this._pointCloudManager?.setHiddenClassifications(e),this.setState({hiddenClassifications:e}),this._emit(`stylechange`)}_hideAllClassifications(){let e=new Set(this._state.availableClassifications);this._pointCloudManager?.setHiddenClassifications(e),this.setState({hiddenClassifications:e}),this._emit(`stylechange`)}setClassificationVisibility(e,t){this._toggleClassification(e,t)}getHiddenClassifications(){return Array.from(this._state.hiddenClassifications)}getAvailableClassifications(){return Array.from(this._state.availableClassifications)}showAllClassifications(){this._showAllClassifications()}hideAllClassifications(){this._hideAllClassifications()}_setupEventListeners(){this._clickOutsideHandler=e=>{if(this._crossSectionTool?.isEnabled()||this._crossSectionTool?.getLine())return;let t=e.target;this._container&&this._panel&&!this._container.contains(t)&&!this._panel.contains(t)&&this.collapse()},document.addEventListener(`click`,this._clickOutsideHandler),this._resizeHandler=()=>{this._state.collapsed||this._updatePanelPosition()},window.addEventListener(`resize`,this._resizeHandler),this._mapResizeHandler=()=>{this._state.collapsed||this._updatePanelPosition()},this._map?.on(`resize`,this._mapResizeHandler)}_getControlPosition(){let e=this._container?.parentElement;return e?e.classList.contains(`maplibregl-ctrl-top-left`)?`top-left`:e.classList.contains(`maplibregl-ctrl-top-right`)?`top-right`:e.classList.contains(`maplibregl-ctrl-bottom-left`)?`bottom-left`:e.classList.contains(`maplibregl-ctrl-bottom-right`)?`bottom-right`:`top-right`:`top-right`}_updatePanelPosition(){if(!this._container||!this._panel||!this._mapContainer)return;let e=this._container.querySelector(`.lidar-control-toggle`);if(!e)return;let t=e.getBoundingClientRect(),n=this._mapContainer.getBoundingClientRect(),r=this._getControlPosition(),i=t.top-n.top,a=n.bottom-t.bottom,o=t.left-n.left,s=n.right-t.right,c=n.height-10;switch(this._panel.style.top=``,this._panel.style.bottom=``,this._panel.style.left=``,this._panel.style.right=``,r){case`top-left`:this._panel.style.top=`${i+t.height+5}px`,this._panel.style.left=`${o}px`,c=n.height-(i+t.height+5)-5;break;case`top-right`:this._panel.style.top=`${i+t.height+5}px`,this._panel.style.right=`${s}px`,c=n.height-(i+t.height+5)-5;break;case`bottom-left`:this._panel.style.bottom=`${a+t.height+5}px`,this._panel.style.left=`${o}px`,c=n.height-(a+t.height+5)-5;break;case`bottom-right`:this._panel.style.bottom=`${a+t.height+5}px`,this._panel.style.right=`${s}px`,c=n.height-(a+t.height+5)-5;break}let l=Math.max(220,c);this._panel.style.maxHeight=`${l}px`;let u=this._panel.querySelector(`.lidar-control-header`),d=this._panel.querySelector(`.lidar-control-content`);if(d){let e=u?.offsetHeight??0,t=Math.max(180,Math.min(this._state.maxHeight,l-e-16));d.style.maxHeight=`${t}px`}}getFullMetadata(e){let t=e??this._state.activePointCloudId;if(t)return this._fullMetadata.get(t)}showMetadataPanel(e){let t=e??this._state.activePointCloudId;if(!t)return;let n=this._fullMetadata.get(t);n||(n=this._buildFullMetadata(t),n&&this._fullMetadata.set(t,n)),n&&(this._metadataPanel||=new W9({onClose:()=>{}}),this._metadataPanel.show(n))}hideMetadataPanel(){this._metadataPanel?.hide()}_buildFullMetadata(e){let t=this._state.pointClouds.find(t=>t.id===e);if(!t)return;let n=this._streamingLoaders.get(e);if(n)return{type:`copc`,copc:n.getCopcMetadata(),basic:{...t,wkt:n.getWkt()??t.wkt}};let r=this._eptStreamingLoaders.get(e);return r?{type:`ept`,ept:r.getExtendedMetadata(),basic:t}:{type:`las`,basic:t}}enableCrossSection(){this._map&&(!this._crossSectionTool&&this._deckOverlay&&(this._crossSectionTool=new J9(this._map,this._deckOverlay),this._crossSectionTool.setOnLineChange(e=>{this._handleCrossSectionLineChange(e)})),this._crossSectionTool?.enable(),this._crossSectionPanel?.setDrawing(!0))}disableCrossSection(){this._crossSectionTool?.disable(),this._crossSectionPanel?.setDrawing(!1)}isCrossSectionEnabled(){return this._crossSectionTool?.isEnabled()??!1}getCrossSectionProfile(){return this._currentProfile}setCrossSectionBufferDistance(e){this._crossSectionTool?.setBufferDistance(e),this._crossSectionPanel?.setBufferDistance(e);let t=this._crossSectionTool?.getLine();t&&this._extractElevationProfile(t)}getCrossSectionBufferDistance(){return this._crossSectionTool?.getBufferDistance()??10}clearCrossSection(){this._crossSectionTool?.clearLine(),this._currentProfile=null,this._crossSectionPanel?.setProfile(null)}getCrossSectionLine(){return this._crossSectionTool?.getLine()??null}_handleCrossSectionLineChange(e){e?(this._extractElevationProfile(e),this._crossSectionTool?.disable(),this._crossSectionPanel?.setDrawing(!1)):(this._currentProfile=null,this._crossSectionPanel?.setProfile(null))}_extractElevationProfile(e){let t=this._pointCloudManager?.getMergedPointCloudData();if(!t||t.pointCount===0){this._currentProfile=null,this._crossSectionPanel?.setProfile(null);return}this._currentProfile=q9.extract(e,t,t.coordinateOrigin),this._crossSectionPanel?.setProfile(this._currentProfile)}getCrossSectionPanel(){return this._crossSectionPanel||=new K9({onDrawToggle:e=>{e?this.enableCrossSection():this.disableCrossSection()},onClear:()=>this.clearCrossSection(),onBufferDistanceChange:e=>this.setCrossSectionBufferDistance(e)},{colormap:this._state.colormap}),this._crossSectionPanel}getPanelElement(){return this._panel??null}}})),Cae=o((()=>{Sae()})),wae=o((()=>{})),Tae=o((()=>{}));s((()=>{var e=u(f());Gc(),Iy(),Cae(),wae(),Tae(),Wc.defs(`EPSG:25832`,`+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs`);var t=[9.20911684275724,52.26520546238239],n=new e.default.Map({container:`map`,style:`https://tiles.openfreemap.org/styles/bright`,center:t,zoom:17,maxZoom:24});n.addControl(new e.default.NavigationControl({visualizePitch:!0,showZoom:!0,showCompass:!0}));var r=null,i=!0,a=`deckgl`,o=`rgb`,s=Number(document.getElementById(`pointSizeSlider`).value),c=null,l=null,d=`medium`;n.on(`load`,()=>{l=new $9({title:`Mein LiDAR-Viewer`,collapsed:!1,pointSize:2,colorScheme:`rgb`,pointBudget:3e6,maxRequests:32,pickable:!1});let e=document.querySelector(`select[name="pointcloud"]`);e&&e.value&&(c=e.value,y()),E()});var p=document.getElementById(`pointSizeSlider`).value,m=document.getElementById(`potree_render_area`),h=new Potree.Viewer(m,{noDragAndDrop:!0});h.setEDLEnabled(!1),h.setFOV(60),h.setMinNodeSize(p),h.setBackground(`none`),h.orbitControls.enabled=!1,h.fpControls.enabled=!1,h.deviceControls.enabled=!1,m.style.display=`none`,h.setPointBudget(3e6);function g(){if(l){try{n.removeControl(l)}catch{}l=null,l=new $9({title:`Mein LiDAR-Viewer`,collapsed:!1,pointSize:s>0?s:2,colorScheme:o===`rgb`?`rgb`:`elevation`,pointBudget:3e6,maxRequests:32,pickable:!1}),n.addControl(l,`top-right`)}}function _(){return{first:`http://ar2350.web-01.fbbgg.hs-woe.de/Punktwolken%20konvertiert%20potree%20Format/sp1_${d}/metadata.json`,second:`http://ar2350.web-01.fbbgg.hs-woe.de/Punktwolken%20konvertiert%20potree%20Format/sp2_${d}/metadata.json`,third:`http://ar2350.web-01.fbbgg.hs-woe.de/Punktwolken%20konvertiert%20potree%20Format/sp3_${d}/metadata.json`}}function v(){return{first:`http://ar2350.web-01.fbbgg.hs-woe.de/copc%20Daten/sp1_${d}.copc.laz`,second:`http://ar2350.web-01.fbbgg.hs-woe.de/copc%20Daten/sp2_${d}.copc.laz`,third:`http://ar2350.web-01.fbbgg.hs-woe.de/copc%20Daten/sp3_${d}.copc.laz`}}function y(){c&&(a===`deckgl`?b(v()[c]):D(_()[c]))}function b(e){!l||!e||(g(),l.loadPointCloudStreaming(e),setTimeout(()=>x(),500))}function x(){if(l)try{l.setPointSize(s>0?s:2),l.setColorScheme(o===`rgb`?`rgb`:`elevation`),l.setColormap(`jet`)}catch(e){console.warn(`LidarControl API:`,e)}}function S(e){a=e;let t=document.getElementById(`pointSizeSlider`);e===`deckgl`?(m.style.display=`none`,r&&(r.visible=!1),s=2,t.min=1,t.max=10,t.value=2,l&&c&&b(v()[c]),document.getElementById(`rendererToggle`).dataset.active=`deckgl`,document.getElementById(`rendererLabel`).textContent=`Renderer: Deck.gl`):(g(),m.style.display=`block`,s=0,t.min=0,t.max=1e3,t.value=0,c&&D(_()[c]),document.getElementById(`rendererToggle`).dataset.active=`potree`,document.getElementById(`rendererLabel`).textContent=`Renderer: Potree`),C()}function C(){a===`potree`&&r&&(r.visible=i),a===`deckgl`&&l.setPointSize(i?2:0)}function w(){if(!r)return;let e=r.material;e.activeAttributeName=o===`rgb`?`rgba`:`elevation`,h.renderer.resetState(),h.render(),n.triggerRepaint()}function T(){a===`potree`?w():x()}function E(){fetch(`info.json`).then(e=>e.json()).then(e=>{F=e}).catch(e=>console.error(`Fehler beim Laden der JSON:`,e))}function D(e){if(h.scene.view.yaw=0,h.scene.view.pitch=0,r){let e=h.scene.pointclouds.indexOf(r);e!==-1&&h.scene.pointclouds.splice(e,1),r.parent&&r.parent.remove(r),r=null,h.render()}!e||!i||Potree.loadPointCloud(e,`punktwolke`,function(e){r=e.pointcloud,h.scene.addPointCloud(r);let t=r.material;t.size=1,t.pointSizeType=Potree.PointSizeType.ADAPTIVE,r.updateMatrixWorld(!0),h.update(h.clock.getDelta(),Number.MAX_VALUE),T(),k(),requestAnimationFrame(()=>{k()})})}var O=!1;function k(){if(!r||O||a!==`potree`)return;O=!0;let e=n.transform;h.renderer&&h.renderer.setSize(n.getCanvas().clientWidth,n.getCanvas().clientHeight);let t=e.pitch*Math.PI/180,i=e.bearing*Math.PI/180,o=n.getCenter(),[s,c]=Wc(`EPSG:4326`,`EPSG:25832`,[o.lng,o.lat]),l=e.cameraToCenterDistance/e.pixelsPerMeter,u=new q(s,c,0),d=new q(0,-l*Math.sin(t),l*Math.cos(t));d.applyAxisAngle(new q(0,0,1),-i);let f=u.clone().add(d);h.scene.view.position.copy(f),h.scene.view.lookAt(u),h.setFOV(e.fov),h.renderer.resetState(),h.render(),O=!1}window.requestAnimationFrame,n.on(`movestart`,()=>{n.getCanvasContainer().style.cursor=`grabbing`}),n.on(`zoom`,k),n.on(`move`,k),n.on(`rotate`,k),n.on(`pitch`,k),n.on(`draw`,k),m.style.pointerEvents=`none`,n.getCanvas().style.pointerEvents=`auto`;function A(e){var t;switch(e){case`openfree_dark`:t=`https://tiles.openfreemap.org/styles/dark`;break;case`openfree_bright`:t=`https://tiles.openfreemap.org/styles/bright`;break;case`openfree_liberty`:t=`https://tiles.openfreemap.org/styles/liberty`;break;case`satellite`:t={version:8,sources:{"raster-tiles":{type:`raster`,tiles:[`https://api.maptiler.com/tiles/satellite-v2/{z}/{x}/{y}.jpg?key=6mG881AthmTTWyLvFyjH`],tileSize:256,attribution:`© MapTiler`}},layers:[{id:`satellite-layer`,type:`raster`,source:`raster-tiles`}]};break;case`terrain`:t={version:8,sources:{topo:{type:`raster`,url:`https://api.maptiler.com/maps/topo-v4/tiles.json?key=6mG881AthmTTWyLvFyjH`,tileSize:256},terrainSource:{type:`raster-dem`,url:`https://tiles.mapterhorn.com/tilejson.json`},hillshadeSource:{type:`raster-dem`,url:`https://tiles.mapterhorn.com/tilejson.json`}},layers:[{id:`topo`,type:`raster`,source:`topo`},{id:`hills`,type:`hillshade`,source:`hillshadeSource`,layout:{visibility:`visible`},paint:{"hillshade-shadow-color":`#473B24`}}],terrain:{source:`terrainSource`,exaggeration:1},sky:{}};break;case`satellite_terrain`:t={version:8,sources:{"raster-tiles":{type:`raster`,tiles:[`https://api.maptiler.com/tiles/satellite-v2/{z}/{x}/{y}.jpg?key=6mG881AthmTTWyLvFyjH`],tileSize:256,attribution:`© MapTiler`},terrainSource:{type:`raster-dem`,url:`https://tiles.mapterhorn.com/tilejson.json`},hillshadeSource:{type:`raster-dem`,url:`https://tiles.mapterhorn.com/tilejson.json`}},layers:[{id:`raster-tiles`,type:`raster`,source:`raster-tiles`},{id:`hills`,type:`hillshade`,source:`hillshadeSource`,layout:{visibility:`visible`},paint:{"hillshade-shadow-color":`#473B24`}}],terrain:{source:`terrainSource`,exaggeration:1},sky:{}};break}n.setStyle(t)}document.querySelector(`#disable`).addEventListener(`click`,function(){i=!i,C(),i?(this.textContent=`Punktwolke ausblenden`,this.classList.add(`active-state`),this.classList.remove(`inactive-state`)):(this.textContent=`Punktwolke anzeigen`,this.classList.add(`inactive-state`),this.classList.remove(`active-state`))});var j=document.getElementById(`coordinates`);n.on(`mousemove`,e=>{j.innerHTML=`Lon: ${e.lngLat.lng.toFixed(5)}° | Lat: ${e.lngLat.lat.toFixed(5)}°`}),document.querySelector(`select[name="basemap"]`).addEventListener(`change`,e=>A(e.target.value)),document.querySelector(`select[name="pointcloud"]`).addEventListener(`change`,e=>{c=e.target.value,y()}),document.getElementById(`location`).addEventListener(`click`,()=>n.flyTo({center:t,zoom:17})),document.getElementById(`pointSizeSlider`).oninput=function(){if(s=Number(this.value),a===`potree`)h.setMinNodeSize(s);else if(l)try{l.setPointSize(s)}catch{}};var M=document.getElementById(`closeSideBarButton`),N=document.getElementById(`sidebar`),P=document.getElementById(`openButtonOuter`);M&&M.addEventListener(`click`,()=>{let e=M.getBoundingClientRect();N.style.display=`none`,P.innerHTML=`<button class='sideBarButtons' id='openSideBarButton' title='Menü ausklappen'>>></button>`;let t=document.getElementById(`openSideBarButton`);t.style.top=`${e.top+window.scrollY-2}px`,t.addEventListener(`click`,()=>{N.style.display=`flex`,P.innerHTML=``})}),document.querySelectorAll(`.qualityButtons`).forEach(e=>{e.addEventListener(`click`,()=>{d=e.id,c&&y(),document.querySelectorAll(`.qualityButtons`).forEach(e=>e.classList.remove(`active`)),e.classList.add(`active`)})}),document.querySelectorAll(`.colorButtons`).forEach(e=>{e.addEventListener(`click`,()=>{document.querySelectorAll(`.colorButtons`).forEach(e=>e.classList.remove(`active`)),e.classList.add(`active`),o=e.id,T()})}),n.once(`idle`,()=>{k()});var F={},ee=document.getElementById(`info-panel`),I=document.getElementById(`info-panel-title`),L=document.getElementById(`info-panel-text`),te=document.getElementById(`openInfoPanel`),ne=document.getElementById(`closeInfoPanel`),R=0;function re(){let e=document.querySelector(`select[name="pointcloud"]`).value,t=F[e];R=0,t?(I.textContent=t.title,L.textContent=t.text,ie(t)):(I.textContent=`Info`,L.textContent=`Bitte wählen Sie eine Punktwolke aus.`,document.getElementById(`info-panel-image`).style.display=`none`,document.getElementById(`info-image-nav`).style.display=`none`)}function ie(e){let t=document.getElementById(`info-panel-image`),n=document.getElementById(`info-image-nav`),r=document.getElementById(`info-image-counter`);t.src=e.images[R],t.style.display=`block`,e.images.length>1?(n.style.display=`flex`,r.textContent=`${R+1} / ${e.images.length}`):n.style.display=`none`}document.getElementById(`info-img-prev`).addEventListener(`click`,()=>{let e=document.querySelector(`select[name="pointcloud"]`).value,t=F[e];t&&(R=(R-1+t.images.length)%t.images.length,ie(t))}),document.getElementById(`info-img-next`).addEventListener(`click`,()=>{let e=document.querySelector(`select[name="pointcloud"]`).value,t=F[e];t&&(R=(R+1)%t.images.length,ie(t))}),te.addEventListener(`click`,()=>{ee.classList.add(`open`)}),ne.addEventListener(`click`,()=>{ee.classList.remove(`open`),te.style.display=`flex`}),document.querySelector(`select[name="pointcloud"]`).addEventListener(`change`,()=>{re()}),document.getElementById(`rendererToggle`).addEventListener(`click`,function(){S(a===`deckgl`?`potree`:`deckgl`)})}))(); |