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;li[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)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{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.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:s180&&(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=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(;re.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;n4?`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=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;o2**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;it.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||tt))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=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)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=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`,(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(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;n0&&s<0||o<0&&s>0}function er(e,t,n){let r=[];for(let i=0;in[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)=>et)){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=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);o0;)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 et)}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;e1?(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;p180;)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]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[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]=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;e0;){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{return t=e,Array.isArray(t)?`(${t.map(ct).join(`, `)})`:`(${ct(t.type)}...)`;var t})).join(` | `),r=[];for(let n=1;n{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;te[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{let n=e.id(),r=t.value;return typeof n==typeof r&&n":[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 et)}function wi(e){if(!Array.isArray(e))return!1;if(e[0]===`within`||e[0]===`distance`)return!0;for(let t=1;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;tr.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&&cnew 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{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[]}})),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=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;tn?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=t):this.lastFloorZoom{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(rr.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>>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>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>1],a=n-1,o=r+1;for(;;){do a++;while(e[a]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`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`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`#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),(en.x+1||rn.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;e1){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;n1?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;et.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;rt.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.xi.x&&t.x>i.x||e.yi.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;nyc(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{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;tthis.max&&(this.max=n),n=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;t0)for(let i=t;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;e0||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.x&&n.x>=c&&r!==n.x&&sl(ia.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=(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<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;r0?(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=1||y<=0)||h&&(si)){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=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=s0?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;ei==(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;o80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(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;t0?(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=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(cl)p=!1;else{let n=f-d,a=-(e[2*t[s]]-u),o=d((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(lms.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;ems.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>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>3}if(r--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),is&&(s=i),al&&(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=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>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{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;rms.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;nO)||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>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);so;)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;ri)o=r,i=t;else if(t===i){let e=Math.abs(r-a);er&&(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;n0&&(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;i1?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=(n/=t)&&o=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))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=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;fn&&(u=c(s,p,m,g,_,n),o&&(s.start=d+l*u)):v>r?y=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;r0||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=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):i1,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;nt&&(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;e1)for(let e of d){let n=e*l;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e>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<0&&t.size<(i?o:r))return void(n.numPoints+=t.points.length/3);let s=[];for(let e=0;eo)&&(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;t0===t)for(let t=0,n=e.length;t1&&(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<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<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<=f||o=m)continue;let h=!1;for(let t of e)if(t.maxX>=d&&t.minX=p&&t.minY1&&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.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=2&&e[l-1].equals(e[l-2]);)l--;let u=0;for(;u0;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`&&(yi&&(w=`bevel`),w===`bevel`&&(y>2&&(w=`flipbevel`),y100)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;t2*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=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?eMath.max(e,this.sections[t].scale)),0)}getMaxImageSize(e){let t=0,n=0;for(let r=0;rn)))}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>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(;i239?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.pos127;);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(;t268435455||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;a55295&&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=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;nt.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&&eg.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 rs){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(;ie.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;le.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=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;e0}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;tr[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=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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}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<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= 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.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y=0&&e=0&&t=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<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=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>>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)<>>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(o32)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<h)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${m}, need ${r}, size=${h}) at block ${c}`);for(let a=0;ae.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>>2;if(3&i.byteOffset)for(let n=0;n>>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>>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>>(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>>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;t0&&(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)<=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=4)for(;r=4)for(;r=4)for(let r=e[0];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&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=4)for(;r>>0;for(let n=1;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>>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>>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.length0){let n=e.byteOffset+t;if(3&n)for(let n=0;n0){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>>o&255;if(o+=8,s+=o>>>5,o&=31,f|=(127&t)<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>1,t)-n}}function um(e,t){let n=0;for(let r=0;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[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;e0&&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;e0&&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;rn?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=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=12?Om.decode(e.subarray(t,n)):function(e,t,n){let r=``,i=t;for(;i239?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=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>>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>>0,a=Dp(e,t,1)[0]>>>0;r.columns=Array(a);for(let n=0;n=4)for(;n>>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>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=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(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=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;nt&&s.push(o(l,u,t)):d>r?f=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(;sr;)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;nl){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=0&&_=0&&v=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;n0&&(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)=>et)){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=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;tf.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;te.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;ne*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=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])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:``,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===``){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===``){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:``,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}),dr&&(r=d),fa&&(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)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;re.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;ed?(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;n25||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;re*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;ee.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;n0&&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;t0;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]=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-1);c++,a[c]=s,o[c]=l,o[c+1]=_}for(let s=0,c=0;s/[-\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;e1&&(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;t1&&(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.lengtht.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=i&&e.y{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+1e.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;en.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;ne)t=!1;else if(n)if(this.expirationTime({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>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;e0?(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;ethis.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;e0}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;rMath.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.ax.vertical?n.yr.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;r0?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=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=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=1;e--)p.push(o.path[e]);for(let e=1;ee.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=r.x&&n.x<=i.x&&e.y>=r.y&&n.y<=i.y?[p]:n.xi.x||n.yi.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;tn&&(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=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e=0&&tthis.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;nh(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=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;r0,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.lastPlacementChangeTimee}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._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!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({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.ze))}}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;ee.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 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<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]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<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-os&&(_=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-rl&&(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;e0}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<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=0&&a++}if(a===0)return 0;a=0&&r++}if(r===0)return 0}return 1}intersectsPlane(e){let t=this.points.length,n=0;for(let r=0;r=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<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<=(1<{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<a&&(a=n),rs&&(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=-_&&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)=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&&tt.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]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({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({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{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=0&&(g[_.associatedIconIndex]={shiftedAnchor:O,angle:k})}else ht(_.numGlyphs,m)}if(l){h.clear();let n=e.icon.placedSymbolArray;for(let e=0;ee.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.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;nt.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;n0};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;ethis.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.currentLayern.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().maxzoom0?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.durationn.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)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;rthis.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)!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()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.ye.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.ye.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{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()){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(nthis._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=y0,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)MapLibre`};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{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<>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<>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){let n=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>n<>n<>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<>n)-a.canonical.x,c=(e.canonical.y>>n)-a.canonical.y,l=t.a6<i.maxzoom&&(a=i.maxzoom),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.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<>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<0,r=n&&e.canonical.y===0,i=n&&e.canonical.y===(1<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!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;et.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._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)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.longitudet.getEast()||n.latitudet.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.ythis._map.transform.height-t-a.bottom?[`bottom`]:[],n.xthis._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{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{}));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{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={}}));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/na&&b{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;or.y||p>r.x||gs&&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||iZn||(o>Zn||iQn||(o>Qn||ier&&(o=o-er+Xn-1),s>$n?(s=s-$n+Xn-1,c=!0):c=!1,(s===Zn||aZn||(s>Zn||aQn||(s>Qn||a$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);u0&&(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)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){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)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){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{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{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?(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)=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{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)=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))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;ethis[e]!==void 0)){t=i;for(let e=0;e1e-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{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;nt&&(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 ln.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=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.length0){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;e65535?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.version0)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`);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);e0?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 n0,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;e1&&r.sort(e||sd),i.length>1&&i.sort(t||cd)}function d(){for(let e=n,r=t.length;e0&&(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=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;ln||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;e0);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=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;tr||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;e0&&d){for(let e=0,t=S.length;e0&&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=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(si.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=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.xa.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=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.x&&n.x>=c&&r!==n.x&&gf(io.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;t0||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=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;a2&&e[t-1].equals(e[0])&&e.pop()}function Mf(e,t){for(let n=0;n=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`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;eky-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>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;e1)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)s&&e>_?e_?s=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;si&&(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;si&&(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;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.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;tthis.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=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=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<1){for(let e=0;e1){for(let e=0;e0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(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;t1))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+(n0&&(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;r0,a=r[1]&&r[1].length>0,o=e.morphTargets,s=o.length,c;if(s>0){c=[];for(let e=0;e0){d=[];for(let e=0;e0&&t.length===0&&console.error(`THREE.DirectGeometry: Faceless geometries are not supported.`);for(let e=0;e65535?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;n0){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;e0){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;e0&&(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;t0&&(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;e0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&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;n0&&(c=l);for(let n=0,l=s.length;n0?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;e0&&(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 #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include 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)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 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 #include }`,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 uniform float opacity; varying vec3 vWorldDirection; #include void main() { vec3 vReflect = vWorldDirection; #include gl_FragColor = envColor; gl_FragColor.a *= opacity; #include #include }`,cube_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,depth_frag:`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include 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 #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,distanceRGBA_frag:`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include 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 #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,equirect_frag:`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); vec4 texColor = texture2D( tEquirect, sampleUV ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,equirect_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,linedashed_frag:`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,linedashed_vert:`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include }`,meshbasic_frag:`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include 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 reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,meshbasic_vert:`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_ENVMAP #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #ifdef DOUBLE_SIDED reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; #else reflectedLight.indirectDiffuse += vIndirectFront; #endif #include 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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,meshlambert_vert:`#define LAMBERT varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,meshmatcap_frag:`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include 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 #include #include #include #include }`,meshmatcap_vert:`#define MATCAP varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,meshtoon_frag:`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,meshtoon_vert:`#define TOON varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,meshphong_frag:`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,meshphong_vert:`#define PHONG varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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 #include #include #include #include }`,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 #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,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 #include #include #include #include #include void main() { #include #include #include #include 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 #include #include #include #include #include #include void main() { #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,points_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,points_vert:`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,shadow_frag:`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,shadow_vert:`#include #include #include void main() { #include #include #include #include #include #include #include #include #include #include }`,sprite_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include }`,sprite_vert:`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`},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 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;re.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;e0){let n,r;for(n=1,r=t.length;n0){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=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;ro)continue;u.applyMatrix4(this.matrixWorld);let f=e.ray.origin.distanceTo(u);fe.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;no)continue;u.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(u);re.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;no)continue;u.applyMatrix4(this.matrixWorld);let i=e.ray.origin.distanceTo(u);ie.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;t0&&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;e0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&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;t0)for(let e=0;e0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,t=this.faces.length;e=0;e--){let t=a[e];this.faces.splice(t,1);for(let e=0,n=this.faceVertexUvs.length;e0,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<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;e80*n){s=l=e[0],c=u=e[1];for(let t=n;tl&&(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;i2**-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=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=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e=r)){c.push(t.times[e]);for(let n=0;na.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e=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=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--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;o0){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;e1){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;e0||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+2r.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=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;n1&&!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;t0){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;n0: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;n2**-52){if(c<0&&(n=t[a],s=-s,o=t[i],c=-c),e.yo.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;t1){let e=!1,t=[];for(let e=0,t=f.length;e0&&(e||(p=d))}let g;for(let e=0,t=f.length;e0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&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=.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=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],c0&&(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=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;ethis.max.x||e.ythis.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.xthis.max.x||e.max.ythis.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{})),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{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.byteLengthe 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{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{dS(),sC(),iC(),TS(),vS(),dC(),xS(),OC=/\.([^.]+)$/}));function*AC(e,t){let n=t?.chunkSize||jC,r=0,i=new TextEncoder;for(;r{dS(),jC=256*1024}));function*NC(e,t={}){let{chunkSize:n=PC}=t,r=0;for(;r{PC=256*1024}));async function*IC(e,t){let n=t?.chunkSize||LC,r=0;for(;r{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{}));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{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;ee+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]{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;te.blockName===t)?.body||null}function _T(e,t){if(e.length!==t.length)return!1;for(let n=0;n!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;rt.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(;n0){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(``))return`sint`;if(e.includes(``))return`uint`;if(e.includes(``))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&&n0?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{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{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;n0?`, `:``)+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{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=0&&e=0&&e{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{}));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{$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{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;sMath.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 fp64arithmetic : Fp64ArithmeticUniforms; fn fp64_nan(seed: f32) -> f32 { let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0); return bitcast(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 floatColors : floatColorsUniforms; fn floatColors_normalize(inputColor: vec3) -> vec3 { return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); } fn floatColors_normalize4(inputColor: vec4) -> vec4 { return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); } fn floatColors_premultiplyAlpha(inputColor: vec4) -> vec4 { return vec4(inputColor.rgb * inputColor.a, inputColor.a); } fn floatColors_unpremultiplyAlpha(inputColor: vec4) -> vec4 { return select( vec4(0.0), vec4(inputColor.rgb / inputColor.a, inputColor.a), inputColor.a > 0.0 ); } fn floatColors_premultiply_alpha(inputColor: vec4) -> vec4 { return floatColors_premultiplyAlpha(inputColor); } fn floatColors_unpremultiply_alpha(inputColor: vec4) -> vec4 { 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`,highlightColor:`vec4`},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>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;te!==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?`
${e.type.toUpperCase()}: ${e.message}
`:`${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?`
`:` `}`}function sne(e,t){let n=``;for(let r=e.length;r`,`>`).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=`\

Compilation error in ${r}


${i}
`,a&&(o.innerHTML+=`

Translated Source



${a}
`),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=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`,2],"vec3":[`f32`,3],"vec4":[`f32`,4],f16:[`f16`,1],"vec2":[`f16`,2],"vec3":[`f16`,3],"vec4":[`f16`,4],i32:[`i32`,1],"vec2":[`i32`,2],"vec3":[`i32`,3],"vec4":[`i32`,4],u32:[`u32`,1],"vec2":[`u32`,2],"vec3":[`u32`,3],"vec4":[`u32`,4]},aj={f32:{type:`f32`,components:1},f16:{type:`f16`,components:1},i32:{type:`i32`,components:1},u32:{type:`u32`,components:1},"vec2":{type:`f32`,components:2},"vec3":{type:`f32`,components:3},"vec4":{type:`f32`,components:4},"vec2":{type:`f16`,components:2},"vec3":{type:`f16`,components:3},"vec4":{type:`f16`,components:4},"vec2":{type:`i32`,components:2},"vec3":{type:`i32`,components:3},"vec4":{type:`i32`,components:4},"vec2":{type:`u32`,components:2},"vec3":{type:`u32`,components:3},"vec4":{type:`u32`,components:4},"mat2x2":{type:`f32`,components:4},"mat2x3":{type:`f32`,components:6},"mat2x4":{type:`f32`,components:8},"mat3x2":{type:`f32`,components:6},"mat3x3":{type:`f32`,components:9},"mat3x4":{type:`f32`,components:12},"mat4x2":{type:`f32`,components:8},"mat4x3":{type:`f32`,components:12},"mat4x4":{type:`f32`,components:16},"mat2x2":{type:`f16`,components:4},"mat2x3":{type:`f16`,components:6},"mat2x4":{type:`f16`,components:8},"mat3x2":{type:`f16`,components:6},"mat3x3":{type:`f16`,components:9},"mat3x4":{type:`f16`,components:12},"mat4x2":{type:`f16`,components:8},"mat4x3":{type:`f16`,components:12},"mat4x4":{type:`f16`,components:16},"mat2x2":{type:`i32`,components:4},"mat2x3":{type:`i32`,components:6},"mat2x4":{type:`i32`,components:8},"mat3x2":{type:`i32`,components:6},"mat3x3":{type:`i32`,components:9},"mat3x4":{type:`i32`,components:12},"mat4x2":{type:`i32`,components:8},"mat4x3":{type:`i32`,components:12},"mat4x4":{type:`i32`,components:16},"mat2x2":{type:`u32`,components:4},"mat2x3":{type:`u32`,components:6},"mat2x4":{type:`u32`,components:8},"mat3x2":{type:`u32`,components:6},"mat3x3":{type:`u32`,components:9},"mat3x4":{type:`u32`,components:12},"mat4x2":{type:`u32`,components:8},"mat4x3":{type:`u32`,components:12},"mat4x4":{type:`u32`,components:16}},oj={vec2i:`vec2`,vec3i:`vec3`,vec4i:`vec4`,vec2u:`vec2`,vec3u:`vec3`,vec4u:`vec4`,vec2f:`vec2`,vec3f:`vec3`,vec4f:`vec4`,vec2h:`vec2`,vec3h:`vec3`,vec4h:`vec4`},sj={vec2i:`vec2`,vec3i:`vec3`,vec4i:`vec4`,vec2u:`vec2`,vec3u:`vec3`,vec4u:`vec4`,vec2f:`vec2`,vec3f:`vec3`,vec4f:`vec4`,vec2h:`vec2`,vec3h:`vec3`,vec4h:`vec4`,mat2x2f:`mat2x2`,mat2x3f:`mat2x3`,mat2x4f:`mat2x4`,mat3x2f:`mat3x2`,mat3x3f:`mat3x3`,mat3x4f:`mat3x4`,mat4x2f:`mat4x2`,mat4x3f:`mat4x3`,mat4x4f:`mat4x4`,mat2x2i:`mat2x2`,mat2x3i:`mat2x3`,mat2x4i:`mat2x4`,mat3x2i:`mat3x2`,mat3x3i:`mat3x3`,mat3x4i:`mat3x4`,mat4x2i:`mat4x2`,mat4x3i:`mat4x3`,mat4x4i:`mat4x4`,mat2x2u:`mat2x2`,mat2x3u:`mat2x3`,mat2x4u:`mat2x4`,mat3x2u:`mat3x2`,mat3x3u:`mat3x3`,mat3x4u:`mat3x4`,mat4x2u:`mat4x2`,mat4x3u:`mat4x3`,mat4x4u:`mat4x4`,mat2x2h:`mat2x2`,mat2x3h:`mat2x3`,mat2x4h:`mat2x4`,mat3x2h:`mat3x2`,mat3x3h:`mat3x3`,mat3x4h:`mat3x4`,mat4x2h:`mat4x2`,mat4x3h:`mat4x3`,mat4x4h:`mat4x4`}}));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{wj(),cj()}));function Lj(e){return(!zj||zj.byteLength{}));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=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;ea)return!1;for(let e=0;e{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, }; struct PointLight { color: vec3, position: vec3, attenuation: vec3, // 2nd order x:Constant-y:Linear-z:Exponential }; struct SpotLight { color: vec3, position: vec3, direction: vec3, attenuation: vec3, coneCos: vec2, }; struct DirectionalLight { color: vec3, direction: vec3, }; struct UniformLight { color: vec3, position: vec3, direction: vec3, attenuation: vec3, coneCos: vec2, }; struct lightingUniforms { enabled: i32, directionalLightCount: i32, pointLightCount: i32, spotLightCount: i32, ambientColor: vec3, lights: array, }; @group(2) @binding(auto) var 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 { 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`,position:`vec3`,direction:`vec3`,attenuation:`vec3`,coneCos:`vec2`},uM={props:{},uniforms:{},name:`lighting`,defines:{},uniformTypes:{enabled:`i32`,directionalLightCount:`i32`,pointLightCount:`i32`,spotLightCount:`i32`,ambientColor:`vec3`,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, }; @group(3) @binding(auto) var phongMaterial : phongMaterialUniforms; fn lighting_getLightColor(surfaceColor: vec3, light_direction: vec3, view_direction: vec3, normal_worldspace: vec3, color: vec3) -> vec3 { let halfway_direction: vec3 = 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, cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3 { var lightColor: vec3 = surfaceColor; if (phongMaterial.unlit != 0u) { return surfaceColor; } if (lighting.enabled == 0) { return lightColor; } let view_direction: vec3 = 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 = pointLight.position; let light_direction: vec3 = 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 = spotLight.position; let light_direction: vec3 = 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, position_worldspace: vec3, normal_worldspace: vec3) -> vec3{ var lightColor = vec3(0, 0, 0); let surfaceColor = vec3(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 = pointLight.position; let light_direction: vec3 = 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 = spotLight.position; let light_direction: vec3 = 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`},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 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) -> vec4 { 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, worldPosition: vec3, worldPositionAlt: vec3, normal: vec3, uv: vec2, pickingColor: vec3, }; var geometry_: VertexGeometry = VertexGeometry( vec4(0.0, 0.0, 1.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec2(0.0, 0.0), vec3(0.0, 0.0, 0.0) ); struct FragmentGeometry { uv: vec2, }; var 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{}));function nN(e){let t=[],n=0;for(;n{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{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)}tryEmit(e){this.canEmit()?this.emit(e):this.state=LM.Failed}canEmit(){let e=0;for(;e{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{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{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{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 = vec3(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, projectionMode: i32, scale: f32, commonUnitsPerWorldUnit: vec3, commonUnitsPerWorldUnit2: vec3, center: vec4, modelMatrix: mat4x4, viewProjectionMatrix: mat4x4, viewportSize: vec2, devicePixelRatio: f32, focalDistance: f32, cameraPosition: vec3, coordinateOrigin: vec3, commonOrigin: vec3, pseudoMeters: i32, }; @group(0) @binding(auto) var 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, worldPositionAlt: vec3, position: vec4, normal: vec3, uv: vec2, pickingColor: vec3, }; var 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) -> vec2 { return meters * project.commonUnitsPerMeter.xy * project_size(); } fn project_size_vec3(meters: vec3) -> vec3 { return meters * project.commonUnitsPerMeter * project_size(); } fn project_size_vec4(meters: vec4) -> vec4 { return vec4(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) -> mat3x3 { let uz = normalize(up); let ux = select( vec3(1.0, 0.0, 0.0), normalize(vec3(uz.y, -uz.x, 0.0)), abs(uz.z) == 1.0 ); let uy = cross(uz, ux); return mat3x3(ux, uy, uz); } // Since WGSL does not support "out" parameters, we return a struct. struct RotationResult { needsRotation: bool, transform: mat3x3, }; fn project_needs_rotation(commonPosition: vec3) -> RotationResult { if (project.projectionMode == PROJECTION_MODE_GLOBE) { return RotationResult(true, project_get_orientation_matrix(commonPosition)); } else { return RotationResult(false, mat3x3()); // identity alternative if needed }; } // Projects a normal vector from the current coordinate system to world space. fn project_normal(vector: vec3) -> vec3 { let normal_modelspace = project.modelMatrix * vec4(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) -> vec4 { let dy: f32 = offset.y; let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); } // Projects lng/lat coordinates to a unit tile [0,1] fn project_mercator_(lnglat: vec2) -> vec2 { 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( 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) -> vec3 { 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( 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, position64Low: vec3) -> vec4 { 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( 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( 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_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(position64Low, 0.0)); } // Overloaded versions for different input types. fn project_position_vec4_f32(position: vec4) -> vec4 { return project_position_vec4_f64(position, ZERO_64_LOW); } fn project_position_vec3_f64(position: vec3, position64Low: vec3) -> vec3 { let projected_position = project_position_vec4_f64(vec4(position, 1.0), position64Low); return projected_position.xyz; } fn project_position_vec3_f32(position: vec3) -> vec3 { let projected_position = project_position_vec4_f64(vec4(position, 1.0), ZERO_64_LOW); return projected_position.xyz; } fn project_position_vec2_f32(position: vec2) -> vec2 { let projected_position = project_position_vec4_f64(vec4(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, viewProjectionMatrix: mat4x4, center: vec4) -> vec4 { return viewProjectionMatrix * position + center; } // Uses the project viewProjectionMatrix and center. fn project_common_position_to_clipspace(position: vec4) -> vec4 { 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) -> vec2 { 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) -> vec2 { 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`,projectionMode:`i32`,scale:`f32`,commonUnitsPerWorldUnit:`vec3`,commonUnitsPerWorldUnit2:`vec3`,center:`vec4`,modelMatrix:`mat4x4`,viewProjectionMatrix:`mat4x4`,viewportSize:`vec2`,devicePixelRatio:`f32`,focalDistance:`f32`,cameraPosition:`vec3`,coordinateOrigin:`vec3`,commonOrigin:`vec3`,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, commonPosition: vec4, }; // This function mimics the GLSL version with the 'out' parameter by returning both values. fn project_position_to_clipspace_and_commonspace( position: vec3, position64Low: vec3, offset: vec3 ) -> ProjectResult { // Compute the projected position. let projectedPosition: vec3 = project_position_vec3_f64(position, position64Low); // Start with the provided offset. var finalOffset: vec3 = 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 = vec4(projectedPosition + finalOffset, 1.0); // Convert to clip-space. let clipPosition: vec4 = 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, position64Low: vec3, offset: vec3 ) -> vec4 { 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 en?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;t0:!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{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`,lightId:`i32`,lightCount:`f32`,viewProjectionMatrix0:`mat4x4`,viewProjectionMatrix1:`mat4x4`,projectCenter0:`vec4`,projectCenter1:`vec4`}}})),fI,pI,mI=o((()=>{bM(),fI=`struct pickingUniforms { isActive: f32, isAttribute: f32, isHighlightActive: f32, useByteColors: f32, highlightedObjectColor: vec3, highlightColor: vec4, }; @group(0) @binding(auto) var picking: pickingUniforms; fn picking_normalizeColor(color: vec3) -> vec3 { return select(color, color / 255.0, picking.useByteColors > 0.5); } fn picking_normalizeColor4(color: vec4) -> vec4 { return select(color, color / 255.0, picking.useByteColors > 0.5); } fn picking_isColorZero(color: vec3) -> bool { return dot(color, vec3(1.0)) < 0.00001; } fn picking_isColorValid(color: vec3) -> bool { return dot(color, vec3(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;re/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{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;ae.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{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.lengththis.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{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{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{})),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;ee===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>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{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=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>e),s=Math.max(1,n>>e);if(r{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>> 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{})),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{})),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=`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{})),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&&(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;tu)f+=4*c;else for(let t=0;t=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=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;e0){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+10){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=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=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;t0&&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(de.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{}));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{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{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{}));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`,35665:`vec3`,35666:`vec4`,5124:`i32`,35667:`vec2`,35668:`vec3`,35669:`vec4`,5125:`u32`,36294:`vec2`,36295:`vec3`,36296:`vec4`,35670:`f32`,35671:`vec2`,35672:`vec3`,35673:`vec4`,35674:`mat2x2`,35685:`mat2x3`,35686:`mat2x4`,35687:`mat3x2`,35675:`mat3x3`,35688:`mat3x4`,35689:`mat4x2`,35690:`mat4x3`,35676:`mat4x4`},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=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;ie.location-t.location),n}function Yre(e,t){let n=[],r=e.getProgramParameter(t,35718);for(let i=0;i1)for(let r=0;re.getActiveUniformBlockParameter(t,n,r),r=[],i=e.getProgramParameter(t,35382);for(let a=0;ae.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;r1){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{}));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{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{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&&o=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{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;ea[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(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;r0&&(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{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;at[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.byteLengthl?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(;lr(e+s,t)),l=Math.min(i.length,a.length);for(let r=1;r{}));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.byteLengthe}){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{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{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{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{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{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{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{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,niK&&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(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{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`,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, sizeBasis: f32, sizeMinPixels: f32, sizeMaxPixels: f32, billboard: i32, sizeUnits: i32, alphaCutoff: f32 }; @group(0) @binding(auto) var icon: IconUniforms; @group(0) @binding(auto) var iconsTexture : texture_2d; @group(0) @binding(auto) var iconsTextureSampler : sampler; fn rotate_by_angle(vertex: vec2, angle_deg: f32) -> vec2 { let angle_radian = angle_deg * PI / 180.0; let c = cos(angle_radian); let s = sin(angle_radian); let rotation = mat2x2(vec2(c, s), vec2(-s, c)); return rotation * vertex; } struct Attributes { @location(0) positions: vec2, @location(1) instancePositions: vec3, @location(2) instancePositions64Low: vec3, @location(3) instanceSizes: f32, @location(4) instanceAngles: f32, @location(5) instanceColors: vec4, @location(6) instancePickingColors: vec3, @location(7) instanceIconFrames: vec4, @location(8) instanceColorModes: f32, @location(9) instanceOffsets: vec2, @location(10) instancePixelOffset: vec2, }; struct Varyings { @builtin(position) position: vec4, @location(0) vColorMode: f32, @location(1) vColor: vec4, @location(2) vTextureCoords: vec2, @location(3) uv: vec2, @location(4) pickingColor: vec3, }; @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(0.0)); // TODO, &geometry.position); // DECKGL_FILTER_GL_POSITION(pos, geometry); var offset = vec3(pixelOffset, 0.0); // DECKGL_FILTER_SIZE(offset, geometry); let clipOffset = project_pixel_size_to_clipspace(offset.xy); pos = vec4(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w); outp.position = pos; } else { var offset_common = vec3(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(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 { // 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(inp.pickingColor, 1.0); } var fragColor = deckgl_premultiplied_alpha(vec4(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( mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), blendedAlpha ); } else { fragColor = vec4(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;ro&&(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 pointCloudUniforms: PointCloudUniforms; struct ConstantAttributes { instanceNormals: vec3, instanceColors: vec4, instancePositions: vec3, instancePositions64Low: vec3, instancePickingColors: vec3 }; const constants = ConstantAttributes( vec3(1.0, 0.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0), vec3(0.0), vec3(0.0), vec3(0.0) ); struct Attributes { @builtin(instance_index) instanceIndex : u32, @builtin(vertex_index) vertexIndex : u32, @location(0) positions: vec3, @location(1) instancePositions: vec3, @location(2) instancePositions64Low: vec3, @location(3) instanceNormals: vec3, @location(4) instanceColors: vec4, @location(5) instancePickingColors: vec3 }; struct Varyings { @builtin(position) position: vec4, @location(0) vColor: vec4, @location(1) unitPosition: vec2, @location(2) pickingColor: vec3, }; @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(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( 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 { // var geometry: Geometry; // geometry.uv = unitPosition.xy; let distToCenter = length(varyings.unitPosition); if (distToCenter > 1.0) { discard; } var fragColor: vec4; fragColor = varyings.vColor; if (picking.isActive > 0.5) { if (!picking_isColorValid(varyings.pickingColor)) { discard; } return vec4(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( mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), blendedAlpha ); } else { fragColor = vec4(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, instancePositions64Low: vec3, instanceRadius: f32, instanceLineWidths: f32, instanceFillColors: vec4, instanceLineColors: vec4, instancePickingColors: vec3, instancePixelOffset: vec2, instancePositionsConstant: i32, instancePositions64LowConstant: i32, instanceRadiusConstant: i32, instanceLineWidthsConstant: i32, instanceFillColorsConstant: i32, instanceLineColorsConstant: i32, instancePickingColorsConstant: i32, instancePixelOffsetConstant: i32 }; @group(0) @binding(0) var scatterplot: ScatterplotUniforms; struct ConstantAttributes { instancePositions: vec3, instancePositions64Low: vec3, instanceRadius: f32, instanceLineWidths: f32, instanceFillColors: vec4, instanceLineColors: vec4, instancePickingColors: vec3, instancePixelOffset: vec2 }; const constants = ConstantAttributes( vec3(0.0), vec3(0.0), 0.0, 0.0, vec4(0.0, 0.0, 0.0, 1.0), vec4(0.0, 0.0, 0.0, 1.0), vec3(0.0), vec2(0.0) ); struct Attributes { @builtin(instance_index) instanceIndex : u32, @builtin(vertex_index) vertexIndex : u32, @location(0) positions: vec3, @location(1) instancePositions: vec3, @location(2) instancePositions64Low: vec3, @location(3) instanceRadius: f32, @location(4) instanceLineWidths: f32, @location(5) instanceFillColors: vec4, @location(6) instanceLineColors: vec4, @location(7) instancePickingColors: vec3, @location(8) instancePixelOffset: vec2 }; struct Varyings { @builtin(position) position: vec4, @location(0) vFillColor: vec4, @location(1) vLineColor: vec4, @location(2) unitPosition: vec2, @location(3) innerUnitRadius: f32, @location(4) outerRadiusPixels: f32, @location(5) pickingColor: vec3, }; @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, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5)); // if (attributes.instanceIndex == 0) { // varyings.position = vec4(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(0.0)); // TODO , geometry.position); // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels; offset = vec3(offset.xy + attributes.instancePixelOffset, offset.z); // DECKGL_FILTER_SIZE(offset, geometry); let clipPixels = project_pixel_size_to_clipspace(offset.xy); varyings.position = vec4(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(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(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity); // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry); varyings.vLineColor = vec4(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 { // 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; 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(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(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( mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), blendedAlpha ); } else { fragColor = vec4(fragColor.rgb, 0.0); } } } // Apply premultiplied alpha as required by transparent canvas fragColor = deckgl_premultiplied_alpha(fragColor); return fragColor; // return vec4(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{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{}));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;nt[2]&&(n|=2),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;tn&&(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=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;ra?t:a,o=ns?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{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;ti&&(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;o180||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{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{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=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.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;_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=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=ia?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=sc?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=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.x&&n.x>=l&&r!==n.x&&y(io.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;t0||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=(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;s0&&(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;ie/t);let a=tY(e),o=r&&t===3;if(n){let e=a.length;a=a.slice();let r=[];for(let i=0;it&&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;e2?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{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;ne.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;nn&&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{}));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{})),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`}}})),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`,align:`vec2`,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-1);c++,a[c]=s,o[c]=l,o[c+1]=oX}for(let s=0,c=0;s{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;er&&(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;ar&&(os){let t=fX(e,s,c,i);l+t>r&&(or&&(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;i0,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=t1||c>0){let t=e.constructor;f=new t(l);for(let t=0;t{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=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`,padding:`vec4`,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;e0&&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{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.byteLengthe 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;e0&&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.byteLengthMQ(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;ei?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>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=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=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>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=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=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=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>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>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;e0?`, `:``)+d),f+=(l?`var rv = `:``)+`invoker(fn`+(d.length>0?`, `:``)+d+`); `,s)f+=`runDestructors(destructors); `;else for(var c=o?1:2;c4&&--nn[e].refcount===0&&(nn[e]=void 0,tn.push(e))}function an(){for(var e=0,t=5;t>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}}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(ni)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>2]=a,n&&i)O(t,o+4,a+1);else if(i)for(var s=0;s255&&(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>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;n255&&(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>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>>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>>0)Dg(21496);else{s=a[5374]|0,l=((a[5376]|0)-s|0)/24|0,c=l<<1,U(n,l>>>0>>1>>>0?c>>>0>>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>>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>>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>>1>>>0?s>>>0>>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<>>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<>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>>0)break;_=a[u>>2]|0,y=((a[o>>2]|0)-_|0)/44|0,v=y<<1,Dn(m,y>>>0>>1>>>0?v>>>0>>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>>0)break;y=a[c>>2]|0,_=((a[u>>2]|0)-y|0)/44|0,v=_<<1,Dn(m,_>>>0>>1>>>0?v>>>0>>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>>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>>0)if(n=(n-(a[e>>2]|0)>>3)+t|0,r=fn(e)|0,r>>>0>>0)Dg(e);else{l=a[e>>2]|0,u=(a[o>>2]|0)-l|0,o=u>>2,on(i,u>>3>>>0>>1>>>0?o>>>0>>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<>>0>>0;)n=n+1|0;t=1<>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>>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<>2]|0)+((n+-1|0)*44|0)|0)|0,n=a[e>>2]|0,(r|0)<(1<>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>0)Dg(i);else{u=a[i>>2]|0,d=(a[r>>2]|0)-u|0,r=d>>2,Rr(s,d>>3>>>0>>1>>>0?r>>>0>>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<>>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<>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>>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>>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>>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>>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>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<>2]|0)+((n+-1|0)*44|0)|0)|0,n=a[e>>2]|0,(r|0)<(1<>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>0)Dg(o);else{u=a[o>>2]|0,d=(a[c>>2]|0)-u|0,c=d>>2,Rr(r,d>>3>>>0>>1>>>0?c>>>0>>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>>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>>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>>2>>>0&&(p=t-(s<<2)|0,i>>>0

>>0&o>>>0

>>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>>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>>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>>0){h=(1<>>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>>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>>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>>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>>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>>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>>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>>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>>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<>2]=d,f=r[d>>0]|0,p=(f<<24>>24)+-32|0;while(!(p>>>0>31|(1<>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>>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>>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>>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>>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>>0&&Xh(e),s=s-t|0,n=s>>>0>>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>>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<>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<>>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<>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<>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>>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<>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<>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<>>16&4,g<<=c,l=(g+245760|0)>>>16&2,l=14-(c|f|l)+(g<>>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>>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<>>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>>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<>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<>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<>>16&4,x<<=y,n=(x+245760|0)>>>16&2,n=14-(y|b|n)+(x<>>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<>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>>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<>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<>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<>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<>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<>>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<>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>>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>>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<>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<>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<>>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<>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>>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>>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<>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<>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<>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<>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<>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<>>16&4,l<<=o,r=(l+245760|0)>>>16&2,r=14-(o|s|r)+(l<>>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<>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>>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<>>(h>>>0)&t,o=0,c=f<>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<>>(c>>>0))&t,t&=u>>>(c>>>0),o=f<>>(_>>>0))&l|f<>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<>>(t>>>0),t=u>>>(t>>>0),o=0,c=f<>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-32|0)}function Hg(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(p(t<>>32-n|0),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{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=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;n255||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;++iArray.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;++r0?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-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;o5e-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/na&&yr.y||p>r.x||gs&&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||iz5||(o>z5||iB5||(o>B5||iH5&&(o=o-H5+R5-1),s>V5?(s=s-V5+R5-1,c=!0):c=!1,(s===z5||az5||(s>z5||aB5||(s>B5||aV5&&(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);u0&&(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)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)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.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)=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=$?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;ethis[e]!==void 0)){t=i;for(let e=0;e1e-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(ne.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;inew 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;i90?(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{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;ie-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;ne-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{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{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-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;nt[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=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{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(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>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=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=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{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>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;c0?`, `:``)+d),f+=(l?`var rv = `:``)+`invoker(fn`+(d.length>0?`, `:``)+d+`); `,s)f+=`runDestructors(destructors); `;else for(var c=o?1:2;c0);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(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}var c=t.includes(`unsigned`),l=(e,n)=>{if(typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Cannot convert "`+hn(e)+`" to `+n);if(ei)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>2]=r,n&&i)A(t,o,r+1);else if(i)for(var s=0;s255&&(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>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>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=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=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>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>2],s=L[t+4>>2];t+=8;for(var c=0;c>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.length0)}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{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{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{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{}},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=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.placesetTimeout(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>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;e90||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{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>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.maxXd||e.maxYp)}_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._activeRequeststhis._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>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]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.maxXd||e.maxYp)}_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._activeRequeststhis._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=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=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]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;to&&(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=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{if(this._options.onHover)if(e.index>=0&&e.picked&&e.index0&&(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._options.label} `,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);te.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;ethis._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=` `,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=`

Loading point cloud...
Preparing...
`,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=` 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=` `,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=` Name Type Size `;let n=e.querySelector(`tbody`);for(let e of r){let t=document.createElement(`tr`);t.innerHTML=` ${e.name} ${e.type} ${e.size} bytes `,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=` `;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=` `,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{})},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;e0?(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=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(`
`),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=`
No profile data
`;return}let{stats:e}=this._profile;this._statsContainer.innerHTML=`
Points: ${e.pointCount.toLocaleString()}
Distance: ${e.totalDistance.toFixed(1)} m
Elevation: ${e.minElevation.toFixed(1)} - ${e.maxElevation.toFixed(1)} m
Mean: ${e.meanElevation.toFixed(1)} m
`}_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=` Points: ${a.pointCount.toLocaleString()} Distance: ${a.totalDistance.toFixed(1)} m Elevation: ${a.minElevation.toFixed(1)} - ${a.maxElevation.toFixed(1)} m Mean: ${a.meanElevation.toFixed(1)} m `,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=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;nt.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(ci||la)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{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=` `,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=`
Point Info
`;if((this._shouldShowAttribute(`X`)||this._shouldShowAttribute(`Longitude`))&&(t+=`
X: ${e.longitude.toFixed(6)}
`),(this._shouldShowAttribute(`Y`)||this._shouldShowAttribute(`Latitude`))&&(t+=`
Y: ${e.latitude.toFixed(6)}
`),(this._shouldShowAttribute(`Z`)||this._shouldShowAttribute(`Elevation`))&&(t+=`
Z: ${e.elevation.toFixed(2)}
`),e.intensity!==void 0&&this._shouldShowAttribute(`Intensity`)&&(t+=`
Intensity: ${this._formatAttributeValue(`Intensity`,e.intensity)}
`),e.classification!==void 0&&this._shouldShowAttribute(`Classification`)&&(t+=`
Classification: ${this._getClassificationName(e.classification)}
`),e.red!==void 0&&this._shouldShowAttribute(`Red`)&&(t+=`
Red: ${e.red}
`),e.green!==void 0&&this._shouldShowAttribute(`Green`)&&(t+=`
Green: ${e.green}
`),e.blue!==void 0&&this._shouldShowAttribute(`Blue`)&&(t+=`
Blue: ${e.blue}
`),e.attributes){for(let[n,r]of Object.entries(e.attributes))if(this._shouldShowAttribute(n)){let e=this._formatAttributeValue(n,r);t+=`
${n}: ${e}
`}}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=``;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`)})}))();