diff --git a/package-lock.json b/package-lock.json index 46d512b0..b9ab0901 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5913,7 +5913,7 @@ }, "src/plugins/giro3d": { "name": "@bimdata/giro3d-viewer-plugin", - "version": "2.0.1", + "version": "2.0.5", "devDependencies": { "@bimdata/design-system": "^1.4.0-rc.89", "@giro3d/giro3d": "^0.4.0", diff --git a/src/plugins/giro3d/dist/giro3d.plugin.js b/src/plugins/giro3d/dist/giro3d.plugin.js index a02c2a48..0071b4df 100644 --- a/src/plugins/giro3d/dist/giro3d.plugin.js +++ b/src/plugins/giro3d/dist/giro3d.plugin.js @@ -1,11 +1,9 @@ -!function(){try{if("undefined"!=typeof document){var t=document.createElement("style");t.appendChild(document.createTextNode(".bimdata-giro3d[data-v-fd5ecc76]{width:100%;height:100%;position:relative;overflow:hidden}.bimdata-giro3d__viewer[data-v-fd5ecc76]{width:100%;height:100%;display:block;touch-action:none}")),document.head.appendChild(t)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}(); +!function(){try{if("undefined"!=typeof document){var t=document.createElement("style");t.appendChild(document.createTextNode(".bimdata-giro3d[data-v-e734460a]{width:100%;height:100%;position:relative;overflow:hidden}.bimdata-giro3d__viewer[data-v-e734460a]{width:100%;height:100%;display:block;touch-action:none}")),document.head.appendChild(t)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}(); /** * @license * Copyright 2010-2021 Three.js Authors * SPDX-License-Identifier: MIT */ -const t="135",e={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},r={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},n=0,i=1,a=2,o=1,s=2,l=3,u=0,c=1,h=2,d=0,f=1,p=2,m=3,g=4,v=5,y=100,x=101,_=102,w=103,b=104,M=200,S=201,T=202,E=203,A=204,R=205,P=206,C=207,I=208,L=209,O=210,D=0,k=1,F=2,N=3,U=4,B=5,z=6,G=7,j=0,V=1,H=2,W=0,q=1,X=2,Y=3,Z=4,K=5,J=300,Q=301,$=302,tt=303,et=304,rt=306,nt=307,it=1e3,at=1001,ot=1002,st=1003,lt=1004,ut=1005,ct=1006,ht=1007,dt=1008,ft=1009,pt=1010,mt=1011,gt=1012,vt=1013,yt=1014,xt=1015,_t=1016,wt=1017,bt=1018,Mt=1019,St=1020,Tt=1021,Et=1022,At=1023,Rt=1024,Pt=1025,Ct=At,It=1026,Lt=1027,Ot=1028,Dt=1029,kt=1030,Ft=1031,Nt=1032,Ut=1033,Bt=33776,zt=33777,Gt=33778,jt=33779,Vt=35840,Ht=35841,Wt=35842,qt=35843,Xt=36196,Yt=37492,Zt=37496,Kt=37808,Jt=37809,Qt=37810,$t=37811,te=37812,ee=37813,re=37814,ne=37815,ie=37816,ae=37817,oe=37818,se=37819,le=37820,ue=37821,ce=36492,he=37840,de=37841,fe=37842,pe=37843,me=37844,ge=37845,ve=37846,ye=37847,xe=37848,_e=37849,we=37850,be=37851,Me=37852,Se=37853,Te=2300,Ee=2301,Ae=2302,Re=2400,Pe=2401,Ce=2402,Ie=2500,Le=2501,Oe=2,De=3e3,ke=3001,Fe=3007,Ne=3002,Ue=3004,Be=3005,ze=3006,Ge=3201,je=0,Ve=1,He=7680,We=35044,qe=35048,Xe="300 es";class Ye{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const r=this._listeners;void 0===r[t]&&(r[t]=[]),-1===r[t].indexOf(e)&&r[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const r=this._listeners;return void 0!==r[t]&&-1!==r[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const r=this._listeners[t];if(void 0!==r){const t=r.indexOf(e);-1!==t&&r.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const r=e.slice(0);for(let e=0,n=r.length;e>8&255]+Ze[t>>16&255]+Ze[t>>24&255]+"-"+Ze[255&e]+Ze[e>>8&255]+"-"+Ze[e>>16&15|64]+Ze[e>>24&255]+"-"+Ze[63&r|128]+Ze[r>>8&255]+"-"+Ze[r>>16&255]+Ze[r>>24&255]+Ze[255&n]+Ze[n>>8&255]+Ze[n>>16&255]+Ze[n>>24&255]).toUpperCase()}function tr(t,e,r){return Math.max(e,Math.min(r,t))}function er(t,e){return(t%e+e)%e}function rr(t,e,r){return(1-r)*t+r*e}function nr(t){return 0==(t&t-1)&&0!==t}function ir(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ar(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var or=Object.freeze({__proto__:null,DEG2RAD:Je,RAD2DEG:Qe,generateUUID:$e,clamp:tr,euclideanModulo:er,mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},inverseLerp:function(t,e,r){return t!==e?(r-t)/(e-t):0},lerp:rr,damp:function(t,e,r,n){return rr(t,e,1-Math.exp(-r*n))},pingpong:function(t,e=1){return e-Math.abs(er(t,2*e)-e)},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(Ke=t%2147483647),Ke=16807*Ke%2147483647,(Ke-1)/2147483646},degToRad:function(t){return t*Je},radToDeg:function(t){return t*Qe},isPowerOfTwo:nr,ceilPowerOfTwo:ir,floorPowerOfTwo:ar,setQuaternionFromProperEuler:function(t,e,r,n,i){const a=Math.cos,o=Math.sin,s=a(r/2),l=o(r/2),u=a((e+n)/2),c=o((e+n)/2),h=a((e-n)/2),d=o((e-n)/2),f=a((n-e)/2),p=o((n-e)/2);switch(i){case"XYX":t.set(s*c,l*h,l*d,s*u);break;case"YZY":t.set(l*d,s*c,l*h,s*u);break;case"ZXZ":t.set(l*h,l*d,s*c,s*u);break;case"XZX":t.set(s*c,l*p,l*f,s*u);break;case"YXY":t.set(l*f,s*c,l*p,s*u);break;case"ZYZ":t.set(l*p,l*f,s*c,s*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}});class sr{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*r-a*n+t.x,this.y=i*n+a*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}sr.prototype.isVector2=!0;class lr{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,r,n,i,a,o,s,l){const u=this.elements;return u[0]=t,u[1]=n,u[2]=o,u[3]=e,u[4]=i,u[5]=s,u[6]=r,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,a=r[0],o=r[3],s=r[6],l=r[1],u=r[4],c=r[7],h=r[2],d=r[5],f=r[8],p=n[0],m=n[3],g=n[6],v=n[1],y=n[4],x=n[7],_=n[2],w=n[5],b=n[8];return i[0]=a*p+o*v+s*_,i[3]=a*m+o*y+s*w,i[6]=a*g+o*x+s*b,i[1]=l*p+u*v+c*_,i[4]=l*m+u*y+c*w,i[7]=l*g+u*x+c*b,i[2]=h*p+d*v+f*_,i[5]=h*m+d*y+f*w,i[8]=h*g+d*x+f*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],u=t[8];return e*a*u-e*o*l-r*i*u+r*o*s+n*i*l-n*a*s}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],u=t[8],c=u*a-o*l,h=o*s-u*i,d=l*i-a*s,f=e*c+r*h+n*d;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const p=1/f;return t[0]=c*p,t[1]=(n*l-u*r)*p,t[2]=(o*r-n*a)*p,t[3]=h*p,t[4]=(u*e-n*s)*p,t[5]=(n*i-o*e)*p,t[6]=d*p,t[7]=(r*s-l*e)*p,t[8]=(a*e-r*i)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,n,i,a,o){const s=Math.cos(i),l=Math.sin(i);return this.set(r*s,r*l,-r*(s*a+l*o)+a+t,-n*l,n*s,-n*(-l*a+s*o)+o+e,0,0,1),this}scale(t,e){const r=this.elements;return r[0]*=t,r[3]*=t,r[6]*=t,r[1]*=e,r[4]*=e,r[7]*=e,this}rotate(t){const e=Math.cos(t),r=Math.sin(t),n=this.elements,i=n[0],a=n[3],o=n[6],s=n[1],l=n[4],u=n[7];return n[0]=e*i+r*s,n[3]=e*a+r*l,n[6]=e*o+r*u,n[1]=-r*i+e*s,n[4]=-r*a+e*l,n[7]=-r*o+e*u,this}translate(t,e){const r=this.elements;return r[0]+=t*r[2],r[3]+=t*r[5],r[6]+=t*r[8],r[1]+=e*r[2],r[4]+=e*r[5],r[7]+=e*r[8],this}equals(t){const e=this.elements,r=t.elements;for(let t=0;t<9;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}function ur(t){if(0===t.length)return-1/0;let e=t[0];for(let r=1,n=t.length;re&&(e=t[r]);return e}lr.prototype.isMatrix3=!0;const cr={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function hr(t,e){return new cr[t](e)}function dr(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function fr(t,e=0){let r=3735928559^e,n=1103547991^e;for(let e,i=0;i>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&n)+(r>>>0)}let pr;class mr{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===pr&&(pr=dr("canvas")),pr.width=t.width,pr.height=t.height;const r=pr.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),e=pr}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}}let gr=0;class vr extends Ye{constructor(t=vr.DEFAULT_IMAGE,e=vr.DEFAULT_MAPPING,r=at,n=at,i=ct,a=dt,o=At,s=ft,l=1,u=De){super(),Object.defineProperty(this,"id",{value:gr++}),this.uuid=$e(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=r,this.wrapT=n,this.magFilter=i,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=s,this.offset=new sr(0,0),this.repeat=new sr(1,1),this.center=new sr(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new lr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this.userData=JSON.parse(JSON.stringify(t.userData)),this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=$e()),!e&&void 0===t.images[n.uuid]){let e;if(Array.isArray(n)){e=[];for(let t=0,r=n.length;t1)switch(this.wrapS){case it:t.x=t.x-Math.floor(t.x);break;case at:t.x=t.x<0?0:1;break;case ot:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case it:t.y=t.y-Math.floor(t.y);break;case at:t.y=t.y<0?0:1;break;case ot:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function yr(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?mr.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}vr.DEFAULT_IMAGE=void 0,vr.DEFAULT_MAPPING=J,vr.prototype.isTexture=!0;class xr{constructor(t=0,e=0,r=0,n=1){this.x=t,this.y=e,this.z=r,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*r+a[8]*n+a[12]*i,this.y=a[1]*e+a[5]*r+a[9]*n+a[13]*i,this.z=a[2]*e+a[6]*r+a[10]*n+a[14]*i,this.w=a[3]*e+a[7]*r+a[11]*n+a[15]*i,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,n,i;const a=.01,o=.1,s=t.elements,l=s[0],u=s[4],c=s[8],h=s[1],d=s[5],f=s[9],p=s[2],m=s[6],g=s[10];if(Math.abs(u-h)s&&t>v?tv?s=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const i=Math.sqrt(n),a=Math.atan2(i,e*r);t=Math.sin(t*a)/i,o=Math.sin(o*a)/i}const i=o*r;if(s=s*t+h*i,l=l*t+d*i,u=u*t+f*i,c=c*t+p*i,t===1-o){const t=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=t,l*=t,u*=t,c*=t}}t[e]=s,t[e+1]=l,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,r,n,i,a){const o=r[n],s=r[n+1],l=r[n+2],u=r[n+3],c=i[a],h=i[a+1],d=i[a+2],f=i[a+3];return t[e]=o*f+u*c+s*d-l*h,t[e+1]=s*f+u*h+l*c-o*d,t[e+2]=l*f+u*d+o*h-s*c,t[e+3]=u*f-o*c-s*h-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const r=t._x,n=t._y,i=t._z,a=t._order,o=Math.cos,s=Math.sin,l=o(r/2),u=o(n/2),c=o(i/2),h=s(r/2),d=s(n/2),f=s(i/2);switch(a){case"XYZ":this._x=h*u*c+l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c-h*d*f;break;case"YXZ":this._x=h*u*c+l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c+h*d*f;break;case"ZXY":this._x=h*u*c-l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c-h*d*f;break;case"ZYX":this._x=h*u*c-l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c+h*d*f;break;case"YZX":this._x=h*u*c+l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c-h*d*f;break;case"XZY":this._x=h*u*c-l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c+h*d*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],n=e[4],i=e[8],a=e[1],o=e[5],s=e[9],l=e[2],u=e[6],c=e[10],h=r+o+c;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(u-s)*t,this._y=(i-l)*t,this._z=(a-n)*t}else if(r>o&&r>c){const t=2*Math.sqrt(1+r-o-c);this._w=(u-s)/t,this._x=.25*t,this._y=(n+a)/t,this._z=(i+l)/t}else if(o>c){const t=2*Math.sqrt(1+o-r-c);this._w=(i-l)/t,this._x=(n+a)/t,this._y=.25*t,this._z=(s+u)/t}else{const t=2*Math.sqrt(1+c-r-o);this._w=(a-n)/t,this._x=(i+l)/t,this._y=(s+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return rMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(tr(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(0===r)return this;const n=Math.min(1,e/r);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const r=t._x,n=t._y,i=t._z,a=t._w,o=e._x,s=e._y,l=e._z,u=e._w;return this._x=r*u+a*o+n*l-i*s,this._y=n*u+a*s+i*o-r*l,this._z=i*u+a*l+r*s-n*o,this._w=a*u-r*o-n*s-i*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const r=this._x,n=this._y,i=this._z,a=this._w;let o=a*t._w+r*t._x+n*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=r,this._y=n,this._z=i,this;const s=1-o*o;if(s<=Number.EPSILON){const t=1-e;return this._w=t*a+e*this._w,this._x=t*r+e*this._x,this._y=t*n+e*this._y,this._z=t*i+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),u=Math.atan2(l,o),c=Math.sin((1-e)*u)/l,h=Math.sin(e*u)/l;return this._w=a*c+this._w*h,this._x=r*c+this._x*h,this._y=n*c+this._y*h,this._z=i*c+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,r){this.copy(t).slerp(e,r)}random(){const t=Math.random(),e=Math.sqrt(1-t),r=Math.sqrt(t),n=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(e*Math.cos(n),r*Math.sin(i),r*Math.cos(i),e*Math.sin(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Mr.prototype.isQuaternion=!0;class Sr{constructor(t=0,e=0,r=0){this.x=t,this.y=e,this.z=r}set(t,e,r){return void 0===r&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Er.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Er.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=t.elements,a=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*a,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*a,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*a,this}applyQuaternion(t){const e=this.x,r=this.y,n=this.z,i=t.x,a=t.y,o=t.z,s=t.w,l=s*e+a*n-o*r,u=s*r+o*e-i*n,c=s*n+i*r-a*e,h=-i*e-a*r-o*n;return this.x=l*s+h*-i+u*-o-c*-a,this.y=u*s+h*-a+c*-i-l*-o,this.z=c*s+h*-o+l*-a-u*-i,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,n=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=n*s-i*o,this.y=i*a-r*s,this.z=r*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Tr.copy(this).projectOnVector(t),this.sub(Tr)}reflect(t){return this.sub(Tr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(tr(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){const n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,r=Math.sqrt(1-t**2);return this.x=r*Math.cos(e),this.y=r*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Sr.prototype.isVector3=!0;const Tr=new Sr,Er=new Mr;class Ar{constructor(t=new Sr(1/0,1/0,1/0),e=new Sr(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,l=t.length;si&&(i=l),u>a&&(a=u),c>o&&(o=c)}return this.min.set(e,r,n),this.max.set(i,a,o),this}setFromBufferAttribute(t){let e=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,l=t.count;si&&(i=l),u>a&&(a=u),c>o&&(o=c)}return this.min.set(e,r,n),this.max.set(i,a,o),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Pr),Pr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Nr),Ur.subVectors(this.max,Nr),Ir.subVectors(t.a,Nr),Lr.subVectors(t.b,Nr),Or.subVectors(t.c,Nr),Dr.subVectors(Lr,Ir),kr.subVectors(Or,Lr),Fr.subVectors(Ir,Or);let e=[0,-Dr.z,Dr.y,0,-kr.z,kr.y,0,-Fr.z,Fr.y,Dr.z,0,-Dr.x,kr.z,0,-kr.x,Fr.z,0,-Fr.x,-Dr.y,Dr.x,0,-kr.y,kr.x,0,-Fr.y,Fr.x,0];return!!Gr(e,Ir,Lr,Or,Ur)&&(e=[1,0,0,0,1,0,0,0,1],!!Gr(e,Ir,Lr,Or,Ur)&&(Br.crossVectors(Dr,kr),e=[Br.x,Br.y,Br.z],Gr(e,Ir,Lr,Or,Ur)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Pr.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(Pr).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Rr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Rr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Rr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Rr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Rr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Rr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Rr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Rr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Rr)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Ar.prototype.isBox3=!0;const Rr=[new Sr,new Sr,new Sr,new Sr,new Sr,new Sr,new Sr,new Sr],Pr=new Sr,Cr=new Ar,Ir=new Sr,Lr=new Sr,Or=new Sr,Dr=new Sr,kr=new Sr,Fr=new Sr,Nr=new Sr,Ur=new Sr,Br=new Sr,zr=new Sr;function Gr(t,e,r,n,i){for(let a=0,o=t.length-3;a<=o;a+=3){zr.fromArray(t,a);const o=i.x*Math.abs(zr.x)+i.y*Math.abs(zr.y)+i.z*Math.abs(zr.z),s=e.dot(zr),l=r.dot(zr),u=n.dot(zr);if(Math.max(-Math.max(s,l,u),Math.min(s,l,u))>o)return!1}return!0}const jr=new Ar,Vr=new Sr,Hr=new Sr,Wr=new Sr;class qr{constructor(t=new Sr,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const r=this.center;void 0!==e?r.copy(e):jr.setFromPoints(t).getCenter(r);let n=0;for(let e=0,i=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){Wr.subVectors(t,this.center);const e=Wr.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),r=.5*(t-this.radius);this.center.add(Wr.multiplyScalar(r/t)),this.radius+=r}return this}union(t){return Hr.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(Vr.copy(t.center).add(Hr)),this.expandByPoint(Vr.copy(t.center).sub(Hr)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Xr=new Sr,Yr=new Sr,Zr=new Sr,Kr=new Sr,Jr=new Sr,Qr=new Sr,$r=new Sr;class tn{constructor(t=new Sr,e=new Sr(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Xr)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Xr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Xr.copy(this.direction).multiplyScalar(e).add(this.origin),Xr.distanceToSquared(t))}distanceSqToSegment(t,e,r,n){Yr.copy(t).add(e).multiplyScalar(.5),Zr.copy(e).sub(t).normalize(),Kr.copy(this.origin).sub(Yr);const i=.5*t.distanceTo(e),a=-this.direction.dot(Zr),o=Kr.dot(this.direction),s=-Kr.dot(Zr),l=Kr.lengthSq(),u=Math.abs(1-a*a);let c,h,d,f;if(u>0)if(c=a*s-o,h=a*o-s,f=i*u,c>=0)if(h>=-f)if(h<=f){const t=1/u;c*=t,h*=t,d=c*(c+a*h+2*o)+h*(a*c+h+2*s)+l}else h=i,c=Math.max(0,-(a*h+o)),d=-c*c+h*(h+2*s)+l;else h=-i,c=Math.max(0,-(a*h+o)),d=-c*c+h*(h+2*s)+l;else h<=-f?(c=Math.max(0,-(-a*i+o)),h=c>0?-i:Math.min(Math.max(-i,-s),i),d=-c*c+h*(h+2*s)+l):h<=f?(c=0,h=Math.min(Math.max(-i,-s),i),d=h*(h+2*s)+l):(c=Math.max(0,-(a*i+o)),h=c>0?i:Math.min(Math.max(-i,-s),i),d=-c*c+h*(h+2*s)+l);else h=a>0?-i:i,c=Math.max(0,-(a*h+o)),d=-c*c+h*(h+2*s)+l;return r&&r.copy(this.direction).multiplyScalar(c).add(this.origin),n&&n.copy(Zr).multiplyScalar(h).add(Yr),d}intersectSphere(t,e){Xr.subVectors(t.center,this.origin);const r=Xr.dot(this.direction),n=Xr.dot(Xr)-r*r,i=t.radius*t.radius;if(n>i)return null;const a=Math.sqrt(i-n),o=r-a,s=r+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){const r=this.distanceToPlane(t);return null===r?null:this.at(r,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,n,i,a,o,s;const l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(r=(t.min.x-h.x)*l,n=(t.max.x-h.x)*l):(r=(t.max.x-h.x)*l,n=(t.min.x-h.x)*l),u>=0?(i=(t.min.y-h.y)*u,a=(t.max.y-h.y)*u):(i=(t.max.y-h.y)*u,a=(t.min.y-h.y)*u),r>a||i>n?null:((i>r||r!=r)&&(r=i),(a=0?(o=(t.min.z-h.z)*c,s=(t.max.z-h.z)*c):(o=(t.max.z-h.z)*c,s=(t.min.z-h.z)*c),r>s||o>n?null:((o>r||r!=r)&&(r=o),(s=0?r:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Xr)}intersectTriangle(t,e,r,n,i){Jr.subVectors(e,t),Qr.subVectors(r,t),$r.crossVectors(Jr,Qr);let a,o=this.direction.dot($r);if(o>0){if(n)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Kr.subVectors(this.origin,t);const s=a*this.direction.dot(Qr.crossVectors(Kr,Qr));if(s<0)return null;const l=a*this.direction.dot(Jr.cross(Kr));if(l<0)return null;if(s+l>o)return null;const u=-a*Kr.dot($r);return u<0?null:this.at(u/o,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class en{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,r,n,i,a,o,s,l,u,c,h,d,f,p,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=d,g[7]=f,g[11]=p,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new en).fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,r=t.elements,n=1/rn.setFromMatrixColumn(t,0).length(),i=1/rn.setFromMatrixColumn(t,1).length(),a=1/rn.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=0,e[8]=r[8]*a,e[9]=r[9]*a,e[10]=r[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,r=t.x,n=t.y,i=t.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(n),l=Math.sin(n),u=Math.cos(i),c=Math.sin(i);if("XYZ"===t.order){const t=a*u,r=a*c,n=o*u,i=o*c;e[0]=s*u,e[4]=-s*c,e[8]=l,e[1]=r+n*l,e[5]=t-i*l,e[9]=-o*s,e[2]=i-t*l,e[6]=n+r*l,e[10]=a*s}else if("YXZ"===t.order){const t=s*u,r=s*c,n=l*u,i=l*c;e[0]=t+i*o,e[4]=n*o-r,e[8]=a*l,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=r*o-n,e[6]=i+t*o,e[10]=a*s}else if("ZXY"===t.order){const t=s*u,r=s*c,n=l*u,i=l*c;e[0]=t-i*o,e[4]=-a*c,e[8]=n+r*o,e[1]=r+n*o,e[5]=a*u,e[9]=i-t*o,e[2]=-a*l,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){const t=a*u,r=a*c,n=o*u,i=o*c;e[0]=s*u,e[4]=n*l-r,e[8]=t*l+i,e[1]=s*c,e[5]=i*l+t,e[9]=r*l-n,e[2]=-l,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){const t=a*s,r=a*l,n=o*s,i=o*l;e[0]=s*u,e[4]=i-t*c,e[8]=n*c+r,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-l*u,e[6]=r*c+n,e[10]=t-i*c}else if("XZY"===t.order){const t=a*s,r=a*l,n=o*s,i=o*l;e[0]=s*u,e[4]=-c,e[8]=l*u,e[1]=t*c+i,e[5]=a*u,e[9]=r*c-n,e[2]=n*c-r,e[6]=o*u,e[10]=i*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(an,t,on)}lookAt(t,e,r){const n=this.elements;return un.subVectors(t,e),0===un.lengthSq()&&(un.z=1),un.normalize(),sn.crossVectors(r,un),0===sn.lengthSq()&&(1===Math.abs(r.z)?un.x+=1e-4:un.z+=1e-4,un.normalize(),sn.crossVectors(r,un)),sn.normalize(),ln.crossVectors(un,sn),n[0]=sn.x,n[4]=ln.x,n[8]=un.x,n[1]=sn.y,n[5]=ln.y,n[9]=un.y,n[2]=sn.z,n[6]=ln.z,n[10]=un.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,a=r[0],o=r[4],s=r[8],l=r[12],u=r[1],c=r[5],h=r[9],d=r[13],f=r[2],p=r[6],m=r[10],g=r[14],v=r[3],y=r[7],x=r[11],_=r[15],w=n[0],b=n[4],M=n[8],S=n[12],T=n[1],E=n[5],A=n[9],R=n[13],P=n[2],C=n[6],I=n[10],L=n[14],O=n[3],D=n[7],k=n[11],F=n[15];return i[0]=a*w+o*T+s*P+l*O,i[4]=a*b+o*E+s*C+l*D,i[8]=a*M+o*A+s*I+l*k,i[12]=a*S+o*R+s*L+l*F,i[1]=u*w+c*T+h*P+d*O,i[5]=u*b+c*E+h*C+d*D,i[9]=u*M+c*A+h*I+d*k,i[13]=u*S+c*R+h*L+d*F,i[2]=f*w+p*T+m*P+g*O,i[6]=f*b+p*E+m*C+g*D,i[10]=f*M+p*A+m*I+g*k,i[14]=f*S+p*R+m*L+g*F,i[3]=v*w+y*T+x*P+_*O,i[7]=v*b+y*E+x*C+_*D,i[11]=v*M+y*A+x*I+_*k,i[15]=v*S+y*R+x*L+_*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[4],n=t[8],i=t[12],a=t[1],o=t[5],s=t[9],l=t[13],u=t[2],c=t[6],h=t[10],d=t[14];return t[3]*(+i*s*c-n*l*c-i*o*h+r*l*h+n*o*d-r*s*d)+t[7]*(+e*s*d-e*l*h+i*a*h-n*a*d+n*l*u-i*s*u)+t[11]*(+e*l*c-e*o*d-i*a*c+r*a*d+i*o*u-r*l*u)+t[15]*(-n*o*u-e*s*c+e*o*h+n*a*c-r*a*h+r*s*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11],f=t[12],p=t[13],m=t[14],g=t[15],v=c*m*l-p*h*l+p*s*d-o*m*d-c*s*g+o*h*g,y=f*h*l-u*m*l-f*s*d+a*m*d+u*s*g-a*h*g,x=u*p*l-f*c*l+f*o*d-a*p*d-u*o*g+a*c*g,_=f*c*s-u*p*s-f*o*h+a*p*h+u*o*m-a*c*m,w=e*v+r*y+n*x+i*_;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/w;return t[0]=v*b,t[1]=(p*h*i-c*m*i-p*n*d+r*m*d+c*n*g-r*h*g)*b,t[2]=(o*m*i-p*s*i+p*n*l-r*m*l-o*n*g+r*s*g)*b,t[3]=(c*s*i-o*h*i-c*n*l+r*h*l+o*n*d-r*s*d)*b,t[4]=y*b,t[5]=(u*m*i-f*h*i+f*n*d-e*m*d-u*n*g+e*h*g)*b,t[6]=(f*s*i-a*m*i-f*n*l+e*m*l+a*n*g-e*s*g)*b,t[7]=(a*h*i-u*s*i+u*n*l-e*h*l-a*n*d+e*s*d)*b,t[8]=x*b,t[9]=(f*c*i-u*p*i-f*r*d+e*p*d+u*r*g-e*c*g)*b,t[10]=(a*p*i-f*o*i+f*r*l-e*p*l-a*r*g+e*o*g)*b,t[11]=(u*o*i-a*c*i-u*r*l+e*c*l+a*r*d-e*o*d)*b,t[12]=_*b,t[13]=(u*p*n-f*c*n+f*r*h-e*p*h-u*r*m+e*c*m)*b,t[14]=(f*o*n-a*p*n-f*r*s+e*p*s+a*r*m-e*o*m)*b,t[15]=(a*c*n-u*o*n+u*r*s-e*c*s-a*r*h+e*o*h)*b,this}scale(t){const e=this.elements,r=t.x,n=t.y,i=t.z;return e[0]*=r,e[4]*=n,e[8]*=i,e[1]*=r,e[5]*=n,e[9]*=i,e[2]*=r,e[6]*=n,e[10]*=i,e[3]*=r,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}makeTranslation(t,e,r){return this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),n=Math.sin(e),i=1-r,a=t.x,o=t.y,s=t.z,l=i*a,u=i*o;return this.set(l*a+r,l*o-n*s,l*s+n*o,0,l*o+n*s,u*o+r,u*s-n*a,0,l*s-n*o,u*s+n*a,i*s*s+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,n,i,a){return this.set(1,r,i,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){const n=this.elements,i=e._x,a=e._y,o=e._z,s=e._w,l=i+i,u=a+a,c=o+o,h=i*l,d=i*u,f=i*c,p=a*u,m=a*c,g=o*c,v=s*l,y=s*u,x=s*c,_=r.x,w=r.y,b=r.z;return n[0]=(1-(p+g))*_,n[1]=(d+x)*_,n[2]=(f-y)*_,n[3]=0,n[4]=(d-x)*w,n[5]=(1-(h+g))*w,n[6]=(m+v)*w,n[7]=0,n[8]=(f+y)*b,n[9]=(m-v)*b,n[10]=(1-(h+p))*b,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){const n=this.elements;let i=rn.set(n[0],n[1],n[2]).length();const a=rn.set(n[4],n[5],n[6]).length(),o=rn.set(n[8],n[9],n[10]).length();this.determinant()<0&&(i=-i),t.x=n[12],t.y=n[13],t.z=n[14],nn.copy(this);const s=1/i,l=1/a,u=1/o;return nn.elements[0]*=s,nn.elements[1]*=s,nn.elements[2]*=s,nn.elements[4]*=l,nn.elements[5]*=l,nn.elements[6]*=l,nn.elements[8]*=u,nn.elements[9]*=u,nn.elements[10]*=u,e.setFromRotationMatrix(nn),r.x=i,r.y=a,r.z=o,this}makePerspective(t,e,r,n,i,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,s=2*i/(e-t),l=2*i/(r-n),u=(e+t)/(e-t),c=(r+n)/(r-n),h=-(a+i)/(a-i),d=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=l,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,r,n,i,a){const o=this.elements,s=1/(e-t),l=1/(r-n),u=1/(a-i),c=(e+t)*s,h=(r+n)*l,d=(a+i)*u;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-c,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,r=t.elements;for(let t=0;t<16;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}en.prototype.isMatrix4=!0;const rn=new Sr,nn=new en,an=new Sr(0,0,0),on=new Sr(1,1,1),sn=new Sr,ln=new Sr,un=new Sr,cn=new en,hn=new Mr;class dn{constructor(t=0,e=0,r=0,n=dn.DefaultOrder){this._x=t,this._y=e,this._z=r,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){const n=t.elements,i=n[0],a=n[4],o=n[8],s=n[1],l=n[5],u=n[9],c=n[2],h=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(tr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-tr(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin(tr(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-tr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(tr(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-tr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===r&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return cn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(cn,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return hn.setFromEuler(this),this.setFromQuaternion(hn,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new Sr(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}dn.prototype.isEuler=!0,dn.DefaultOrder="XYZ",dn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class fn{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0){n.children=[];for(let e=0;e0){n.animations=[];for(let e=0;e0&&(r.geometries=e),n.length>0&&(r.materials=n),i.length>0&&(r.textures=i),o.length>0&&(r.images=o),s.length>0&&(r.shapes=s),l.length>0&&(r.skeletons=l),u.length>0&&(r.animations=u)}return r.object=n,r;function a(t){const e=[];for(const r in t){const n=t[r];delete n.metadata,e.push(n)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?n.multiplyScalar(1/Math.sqrt(i)):n.set(0,0,0)}static getBarycoord(t,e,r,n,i){Rn.subVectors(n,e),Pn.subVectors(r,e),Cn.subVectors(t,e);const a=Rn.dot(Rn),o=Rn.dot(Pn),s=Rn.dot(Cn),l=Pn.dot(Pn),u=Pn.dot(Cn),c=a*l-o*o;if(0===c)return i.set(-2,-1,-1);const h=1/c,d=(l*s-o*u)*h,f=(a*u-o*s)*h;return i.set(1-d-f,f,d)}static containsPoint(t,e,r,n){return this.getBarycoord(t,e,r,n,In),In.x>=0&&In.y>=0&&In.x+In.y<=1}static getUV(t,e,r,n,i,a,o,s){return this.getBarycoord(t,e,r,n,In),s.set(0,0),s.addScaledVector(i,In.x),s.addScaledVector(a,In.y),s.addScaledVector(o,In.z),s}static isFrontFacing(t,e,r,n){return Rn.subVectors(r,e),Pn.subVectors(t,e),Rn.cross(Pn).dot(n)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,r,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Rn.subVectors(this.c,this.b),Pn.subVectors(this.a,this.b),.5*Rn.cross(Pn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Un.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Un.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,r,n,i){return Un.getUV(t,this.a,this.b,this.c,e,r,n,i)}containsPoint(t){return Un.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Un.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const r=this.a,n=this.b,i=this.c;let a,o;Ln.subVectors(n,r),On.subVectors(i,r),kn.subVectors(t,r);const s=Ln.dot(kn),l=On.dot(kn);if(s<=0&&l<=0)return e.copy(r);Fn.subVectors(t,n);const u=Ln.dot(Fn),c=On.dot(Fn);if(u>=0&&c<=u)return e.copy(n);const h=s*c-u*l;if(h<=0&&s>=0&&u<=0)return a=s/(s-u),e.copy(r).addScaledVector(Ln,a);Nn.subVectors(t,i);const d=Ln.dot(Nn),f=On.dot(Nn);if(f>=0&&d<=f)return e.copy(i);const p=d*l-s*f;if(p<=0&&l>=0&&f<=0)return o=l/(l-f),e.copy(r).addScaledVector(On,o);const m=u*f-d*c;if(m<=0&&c-u>=0&&d-f>=0)return Dn.subVectors(i,n),o=(c-u)/(c-u+(d-f)),e.copy(n).addScaledVector(Dn,o);const g=1/(m+p+h);return a=p*g,o=h*g,e.copy(r).addScaledVector(Ln,a).addScaledVector(On,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Bn=0;class zn extends Ye{constructor(){super(),Object.defineProperty(this,"id",{value:Bn++}),this.uuid=$e(),this.name="",this.type="Material",this.fog=!0,this.blending=f,this.side=u,this.vertexColors=!1,this.opacity=1,this.format=At,this.transparent=!1,this.blendSrc=A,this.blendDst=R,this.blendEquation=y,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=N,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=He,this.stencilZFail=He,this.stencilZPass=He,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const r=t[e];if(void 0===r){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===r;continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]=r:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const r in t){const n=t[r];delete n.metadata,e.push(n)}return e}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(r.combine=this.combine)),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==f&&(r.blending=this.blending),this.side!==u&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.format!==At&&(r.format=this.format),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(r.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=this.flatShading),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),e){const e=n(t.textures),i=n(t.images);e.length>0&&(r.textures=e),i.length>0&&(r.images=i)}return r}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.format=t.format,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let r=null;if(null!==e){const t=e.length;r=new Array(t);for(let n=0;n!==t;++n)r[n]=e[n].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}zn.prototype.isMaterial=!0;const Gn={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},jn={h:0,s:0,l:0},Vn={h:0,s:0,l:0};function Hn(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}function Wn(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function qn(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Xn{constructor(t,e,r){return void 0===e&&void 0===r?this.set(t):this.setRGB(t,e,r)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,r){return this.r=t,this.g=e,this.b=r,this}setHSL(t,e,r){if(t=er(t,1),e=tr(e,0,1),r=tr(r,0,1),0===e)this.r=this.g=this.b=r;else{const n=r<=.5?r*(1+e):r+e-r*e,i=2*r-n;this.r=Hn(i,n,t+1/3),this.g=Hn(i,n,t),this.b=Hn(i,n,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const n=r[1],i=r[2];switch(n){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const r=parseFloat(t[1])/360,n=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(r,n,i)}}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=r[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=Gn[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Wn(t.r),this.g=Wn(t.g),this.b=Wn(t.b),this}copyLinearToSRGB(t){return this.r=qn(t.r),this.g=qn(t.g),this.b=qn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){const e=this.r,r=this.g,n=this.b,i=Math.max(e,r,n),a=Math.min(e,r,n);let o,s;const l=(a+i)/2;if(a===i)o=0,s=0;else{const t=i-a;switch(s=l<=.5?t/(i+a):t/(2-i-a),i){case e:o=(r-n)/t+(r65535?ii:ri)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const r=this.attributes.normal;if(void 0!==r){const e=(new lr).getNormalMatrix(t);r.applyNormalMatrix(e),r.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return ui.makeRotationFromQuaternion(t),this.applyMatrix4(ui),this}rotateX(t){return ui.makeRotationX(t),this.applyMatrix4(ui),this}rotateY(t){return ui.makeRotationY(t),this.applyMatrix4(ui),this}rotateZ(t){return ui.makeRotationZ(t),this.applyMatrix4(ui),this}translate(t,e,r){return ui.makeTranslation(t,e,r),this.applyMatrix4(ui),this}scale(t,e,r){return ui.makeScale(t,e,r),this.applyMatrix4(ui),this}lookAt(t){return ci.lookAt(t),ci.updateMatrix(),this.applyMatrix4(ci.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hi).negate(),this.translate(hi.x,hi.y,hi.z),this}setFromPoints(t){const e=[];for(let r=0,n=t.length;r0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const r in e)void 0!==e[r]&&(t[r]=e[r]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const r=this.attributes;for(const e in r){const n=r[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let i=!1;for(const e in this.morphAttributes){const r=this.morphAttributes[e],a=[];for(let e=0,n=r.length;e0&&(n[e]=a,i=!0)}i&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const r=t.index;null!==r&&this.setIndex(r.clone(e));const n=t.attributes;for(const t in n){const r=n[t];this.setAttribute(t,r.clone(e))}const i=t.morphAttributes;for(const t in i){const r=[],n=i[t];for(let t=0,i=n.length;t0){const t=e[r[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,r=t.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const r=this.geometry,n=this.material,i=this.matrixWorld;if(void 0===n)return;if(null===r.boundingSphere&&r.computeBoundingSphere(),yi.copy(r.boundingSphere),yi.applyMatrix4(i),!1===t.ray.intersectsSphere(yi))return;if(gi.copy(i).invert(),vi.copy(t.ray).applyMatrix4(gi),null!==r.boundingBox&&!1===vi.intersectsBox(r.boundingBox))return;let a;if(r.isBufferGeometry){const i=r.index,o=r.attributes.position,s=r.morphAttributes.position,l=r.morphTargetsRelative,u=r.attributes.uv,c=r.attributes.uv2,h=r.groups,d=r.drawRange;if(null!==i)if(Array.isArray(n))for(let r=0,f=h.length;rr.far?null:{distance:u,point:Li.clone(),object:t}}(t,e,r,n,xi,_i,wi,Ii);if(m){s&&(Ri.fromBufferAttribute(s,u),Pi.fromBufferAttribute(s,d),Ci.fromBufferAttribute(s,f),m.uv=Un.getUV(Ii,xi,_i,wi,Ri,Pi,Ci,new sr)),l&&(Ri.fromBufferAttribute(l,u),Pi.fromBufferAttribute(l,d),Ci.fromBufferAttribute(l,f),m.uv2=Un.getUV(Ii,xi,_i,wi,Ri,Pi,Ci,new sr));const t={a:u,b:d,c:f,normal:new Sr,materialIndex:0};Un.getNormal(xi,_i,wi,t.normal),m.face=t}return m}Oi.prototype.isMesh=!0;class ki extends mi{constructor(t=1,e=1,r=1,n=1,i=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:a};const o=this;n=Math.floor(n),i=Math.floor(i),a=Math.floor(a);const s=[],l=[],u=[],c=[];let h=0,d=0;function f(t,e,r,n,i,a,f,p,m,g,v){const y=a/m,x=f/g,_=a/2,w=f/2,b=p/2,M=m+1,S=g+1;let T=0,E=0;const A=new Sr;for(let a=0;a0?1:-1,u.push(A.x,A.y,A.z),c.push(s/m),c.push(1-a/g),T+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const r={};for(const t in this.extensions)!0===this.extensions[t]&&(r[t]=!0);return Object.keys(r).length>0&&(e.extensions=r),e}}Bi.prototype.isShaderMaterial=!0;let zi=class extends An{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new en,this.projectionMatrix=new en,this.projectionMatrixInverse=new en}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}};zi.prototype.isCamera=!0;class Gi extends zi{constructor(t=50,e=1,r=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=r,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Qe*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Je*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Qe*Math.atan(Math.tan(.5*Je*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,r,n,i,a){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=n,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Je*this.fov)/this.zoom,r=2*e,n=this.aspect*r,i=-.5*n;const a=this.view;if(null!==this.view&&this.view.enabled){const t=a.fullWidth,o=a.fullHeight;i+=a.offsetX*n/t,e-=a.offsetY*r/o,n*=a.width/t,r*=a.height/o}const o=this.filmOffset;0!==o&&(i+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+n,e,e-r,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}Gi.prototype.isPerspectiveCamera=!0;const ji=90;class Vi extends An{constructor(t,e,r){if(super(),this.type="CubeCamera",!0!==r.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=r;const n=new Gi(ji,1,t,e);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new Sr(1,0,0)),this.add(n);const i=new Gi(ji,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Sr(-1,0,0)),this.add(i);const a=new Gi(ji,1,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new Sr(0,1,0)),this.add(a);const o=new Gi(ji,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new Sr(0,-1,0)),this.add(o);const s=new Gi(ji,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new Sr(0,0,1)),this.add(s);const l=new Gi(ji,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Sr(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const r=this.renderTarget,[n,i,a,o,s,l]=this.children,u=t.xr.enabled,c=t.getRenderTarget();t.xr.enabled=!1;const h=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,n),t.setRenderTarget(r,1),t.render(e,i),t.setRenderTarget(r,2),t.render(e,a),t.setRenderTarget(r,3),t.render(e,o),t.setRenderTarget(r,4),t.render(e,s),r.texture.generateMipmaps=h,t.setRenderTarget(r,5),t.render(e,l),t.setRenderTarget(c),t.xr.enabled=u}}class Hi extends vr{constructor(t,e,r,n,i,a,o,s,l,u){super(t=void 0!==t?t:[],e=void 0!==e?e:Q,r,n,i,a,o,s,l,u),this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}Hi.prototype.isCubeTexture=!0;class Wi extends _r{constructor(t,e,r){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=r),super(t,t,e),e=e||{},this.texture=new Hi(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:ct,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=At,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new ki(5,5,5),i=new Bi({name:"CubemapFromEquirect",uniforms:Fi(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:c,blending:d});i.uniforms.tEquirect.value=e;const a=new Oi(n,i),o=e.minFilter;e.minFilter===dt&&(e.minFilter=ct);return new Vi(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,r,n){const i=t.getRenderTarget();for(let i=0;i<6;i++)t.setRenderTarget(this,i),t.clear(e,r,n);t.setRenderTarget(i)}}Wi.prototype.isWebGLCubeRenderTarget=!0;const qi=new Sr,Xi=new Sr,Yi=new lr;class Zi{constructor(t=new Sr(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,r,n){return this.normal.set(t,e,r),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,r){const n=qi.subVectors(r,e).cross(Xi.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const r=t.delta(qi),n=this.normal.dot(r);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/n;return i<0||i>1?null:e.copy(r).multiplyScalar(i).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const r=e||Yi.getNormalMatrix(t),n=this.coplanarPoint(qi).applyMatrix4(t),i=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}Zi.prototype.isPlane=!0;const Ki=new qr,Ji=new Sr;class Qi{constructor(t=new Zi,e=new Zi,r=new Zi,n=new Zi,i=new Zi,a=new Zi){this.planes=[t,e,r,n,i,a]}set(t,e,r,n,i,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(r),o[3].copy(n),o[4].copy(i),o[5].copy(a),this}copy(t){const e=this.planes;for(let r=0;r<6;r++)e[r].copy(t.planes[r]);return this}setFromProjectionMatrix(t){const e=this.planes,r=t.elements,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],u=r[6],c=r[7],h=r[8],d=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(o-n,c-s,p-h,y-m).normalize(),e[1].setComponents(o+n,c+s,p+h,y+m).normalize(),e[2].setComponents(o+i,c+l,p+d,y+g).normalize(),e[3].setComponents(o-i,c-l,p-d,y-g).normalize(),e[4].setComponents(o-a,c-u,p-f,y-v).normalize(),e[5].setComponents(o+a,c+u,p+f,y+v).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Ki)}intersectsSprite(t){return Ki.center.set(0,0,0),Ki.radius=.7071067811865476,Ki.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(t){const e=this.planes,r=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(r)0?t.max.x:t.min.x,Ji.y=n.normal.y>0?t.max.y:t.min.y,Ji.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Ji)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function $i(){let t=null,e=!1,r=null,n=null;function i(e,a){r(e,a),n=t.requestAnimationFrame(i)}return{start:function(){!0!==e&&null!==r&&(n=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){r=t},setContext:function(e){t=e}}}function ta(t,e){const r=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const r=n.get(e);r&&(t.deleteBuffer(r.buffer),n.delete(e))},update:function(e,i){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},na={common:{diffuse:{value:new Xn(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new lr},uv2Transform:{value:new lr},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},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 sr(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 Xn(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 Xn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new lr}},sprite:{diffuse:{value:new Xn(16777215)},opacity:{value:1},center:{value:new sr(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new lr}}},ia={basic:{uniforms:Ni([na.common,na.specularmap,na.envmap,na.aomap,na.lightmap,na.fog]),vertexShader:ra.meshbasic_vert,fragmentShader:ra.meshbasic_frag},lambert:{uniforms:Ni([na.common,na.specularmap,na.envmap,na.aomap,na.lightmap,na.emissivemap,na.fog,na.lights,{emissive:{value:new Xn(0)}}]),vertexShader:ra.meshlambert_vert,fragmentShader:ra.meshlambert_frag},phong:{uniforms:Ni([na.common,na.specularmap,na.envmap,na.aomap,na.lightmap,na.emissivemap,na.bumpmap,na.normalmap,na.displacementmap,na.fog,na.lights,{emissive:{value:new Xn(0)},specular:{value:new Xn(1118481)},shininess:{value:30}}]),vertexShader:ra.meshphong_vert,fragmentShader:ra.meshphong_frag},standard:{uniforms:Ni([na.common,na.envmap,na.aomap,na.lightmap,na.emissivemap,na.bumpmap,na.normalmap,na.displacementmap,na.roughnessmap,na.metalnessmap,na.fog,na.lights,{emissive:{value:new Xn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ra.meshphysical_vert,fragmentShader:ra.meshphysical_frag},toon:{uniforms:Ni([na.common,na.aomap,na.lightmap,na.emissivemap,na.bumpmap,na.normalmap,na.displacementmap,na.gradientmap,na.fog,na.lights,{emissive:{value:new Xn(0)}}]),vertexShader:ra.meshtoon_vert,fragmentShader:ra.meshtoon_frag},matcap:{uniforms:Ni([na.common,na.bumpmap,na.normalmap,na.displacementmap,na.fog,{matcap:{value:null}}]),vertexShader:ra.meshmatcap_vert,fragmentShader:ra.meshmatcap_frag},points:{uniforms:Ni([na.points,na.fog]),vertexShader:ra.points_vert,fragmentShader:ra.points_frag},dashed:{uniforms:Ni([na.common,na.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ra.linedashed_vert,fragmentShader:ra.linedashed_frag},depth:{uniforms:Ni([na.common,na.displacementmap]),vertexShader:ra.depth_vert,fragmentShader:ra.depth_frag},normal:{uniforms:Ni([na.common,na.bumpmap,na.normalmap,na.displacementmap,{opacity:{value:1}}]),vertexShader:ra.meshnormal_vert,fragmentShader:ra.meshnormal_frag},sprite:{uniforms:Ni([na.sprite,na.fog]),vertexShader:ra.sprite_vert,fragmentShader:ra.sprite_frag},background:{uniforms:{uvTransform:{value:new lr},t2D:{value:null}},vertexShader:ra.background_vert,fragmentShader:ra.background_frag},cube:{uniforms:Ni([na.envmap,{opacity:{value:1}}]),vertexShader:ra.cube_vert,fragmentShader:ra.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ra.equirect_vert,fragmentShader:ra.equirect_frag},distanceRGBA:{uniforms:Ni([na.common,na.displacementmap,{referencePosition:{value:new Sr},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ra.distanceRGBA_vert,fragmentShader:ra.distanceRGBA_frag},shadow:{uniforms:Ni([na.lights,na.fog,{color:{value:new Xn(0)},opacity:{value:1}}]),vertexShader:ra.shadow_vert,fragmentShader:ra.shadow_frag}};function aa(t,e,r,n,i){const a=new Xn(0);let o,s,l=0,h=null,d=0,f=null;function p(t,e){r.buffers.color.setClear(t.r,t.g,t.b,e,i)}return{getClearColor:function(){return a},setClearColor:function(t,e=1){a.set(t),l=e,p(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(t){l=t,p(a,l)},render:function(r,i){let m=!1,g=!0===i.isScene?i.background:null;g&&g.isTexture&&(g=e.get(g));const v=t.xr,y=v.getSession&&v.getSession();y&&"additive"===y.environmentBlendMode&&(g=null),null===g?p(a,l):g&&g.isColor&&(p(g,1),m=!0),(t.autoClear||m)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),g&&(g.isCubeTexture||g.mapping===rt)?(void 0===s&&(s=new Oi(new ki(1,1,1),new Bi({name:"BackgroundCubeMaterial",uniforms:Fi(ia.cube.uniforms),vertexShader:ia.cube.vertexShader,fragmentShader:ia.cube.fragmentShader,side:c,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(t,e,r){this.matrixWorld.copyPosition(r.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(s)),s.material.uniforms.envMap.value=g,s.material.uniforms.flipEnvMap.value=g.isCubeTexture&&!1===g.isRenderTargetTexture?-1:1,h===g&&d===g.version&&f===t.toneMapping||(s.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),r.unshift(s,s.geometry,s.material,0,0,null)):g&&g.isTexture&&(void 0===o&&(o=new Oi(new ea(2,2),new Bi({name:"BackgroundMaterial",uniforms:Fi(ia.background.uniforms),vertexShader:ia.background.vertexShader,fragmentShader:ia.background.fragmentShader,side:u,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(o)),o.material.uniforms.t2D.value=g,!0===g.matrixAutoUpdate&&g.updateMatrix(),o.material.uniforms.uvTransform.value.copy(g.matrix),h===g&&d===g.version&&f===t.toneMapping||(o.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),r.unshift(o,o.geometry,o.material,0,0,null))}}}function oa(t,e,r,n){const i=t.getParameter(34921),a=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||null!==a,s={},l=d(null);let u=l;function c(e){return n.isWebGL2?t.bindVertexArray(e):a.bindVertexArrayOES(e)}function h(e){return n.isWebGL2?t.deleteVertexArray(e):a.deleteVertexArrayOES(e)}function d(t){const e=[],r=[],n=[];for(let t=0;t=0){let a=l[e];if(void 0===a&&("instanceMatrix"===e&&i.instanceMatrix&&(a=i.instanceMatrix),"instanceColor"===e&&i.instanceColor&&(a=i.instanceColor)),void 0!==a){const e=a.normalized,o=a.itemSize,l=r.get(a);if(void 0===l)continue;const u=l.buffer,c=l.type,h=l.bytesPerElement;if(a.isInterleavedBufferAttribute){const r=a.data,l=r.stride,d=a.offset;if(r&&r.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let o=void 0!==r.precision?r.precision:"highp";const s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const l=a||e.has("WEBGL_draw_buffers"),u=!0===r.logarithmicDepthBuffer,c=t.getParameter(34930),h=t.getParameter(35660),d=t.getParameter(3379),f=t.getParameter(34076),p=t.getParameter(34921),m=t.getParameter(36347),g=t.getParameter(36348),v=t.getParameter(36349),y=h>0,x=a||e.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const r=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:u,maxTextures:c,maxVertexTextures:h,maxTextureSize:d,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:a?t.getParameter(36183):0}}function ua(t){const e=this;let r=null,n=0,i=!1,a=!1;const o=new Zi,s=new lr,l={value:null,needsUpdate:!1};function u(){l.value!==r&&(l.value=r,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function c(t,r,n,i){const a=null!==t?t.length:0;let u=null;if(0!==a){if(u=l.value,!0!==i||null===u){const e=n+4*a,i=r.matrixWorldInverse;s.getNormalMatrix(i),(null===u||u.length0){const o=t.getRenderTarget(),s=new Wi(a.height/2);return s.fromEquirectangularTexture(t,i),e.set(i,s),t.setRenderTarget(o),i.addEventListener("dispose",n),r(s.texture,i.mapping)}return null}}}return i},dispose:function(){e=new WeakMap}}}ia.physical={uniforms:Ni([ia.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new sr(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new Xn(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new sr},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Xn(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new Xn(1,1,1)},specularColorMap:{value:null}}]),vertexShader:ra.meshphysical_vert,fragmentShader:ra.meshphysical_frag};class ha extends zi{constructor(t=-1,e=1,r=1,n=-1,i=.1,a=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=r,this.bottom=n,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,r,n,i,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=n,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let i=r-t,a=r+t,o=n+e,s=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=t*this.view.offsetX,a=i+t*this.view.width,o-=e*this.view.offsetY,s=o-e*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}ha.prototype.isOrthographicCamera=!0;class da extends Bi{constructor(t){super(t),this.type="RawShaderMaterial"}}da.prototype.isRawShaderMaterial=!0;const fa=4,pa=8,ma=Math.pow(2,pa),ga=[.125,.215,.35,.446,.526,.582],va=pa-fa+1+ga.length,ya=20,xa={[De]:0,[ke]:1,[Ne]:2,[Ue]:3,[Be]:4,[ze]:5,[Fe]:6},_a=new ha,{_lodPlanes:wa,_sizeLods:ba,_sigmas:Ma}=Ia(),Sa=new Xn;let Ta=null;const Ea=(1+Math.sqrt(5))/2,Aa=1/Ea,Ra=[new Sr(1,1,1),new Sr(-1,1,1),new Sr(1,1,-1),new Sr(-1,1,-1),new Sr(0,Ea,Aa),new Sr(0,Ea,-Aa),new Sr(Aa,0,Ea),new Sr(-Aa,0,Ea),new Sr(Ea,Aa,0),new Sr(-Ea,Aa,0)];class Pa{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(t),r=new Sr(0,1,0);return new da({name:"SphericalGaussianBlur",defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r},inputEncoding:{value:xa[De]},outputEncoding:{value:xa[De]}},vertexShader:Fa(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t${Na()}\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:d,depthTest:!1,depthWrite:!1})}(ya),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,r=.1,n=100){Ta=this._renderer.getRenderTarget();const i=this._allocateTargets();return this._sceneToCubeUV(t,r,n,i),e>0&&this._blur(i,0,0,e),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=ka(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Da(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let t=0;t2?ma:0,ma,ma),s.setRenderTarget(n),p&&s.render(f,i),s.render(t,i)}f.geometry.dispose(),f.material.dispose(),s.toneMapping=h,s.outputEncoding=u,s.autoClear=l,t.background=m}_setEncoding(t,e){t.value=xa[e.encoding]}_textureToCubeUV(t,e){const r=this._renderer,n=t.mapping===Q||t.mapping===$;n?null==this._cubemapShader&&(this._cubemapShader=ka()):null==this._equirectShader&&(this._equirectShader=Da());const i=n?this._cubemapShader:this._equirectShader,a=new Oi(wa[0],i),o=i.uniforms;o.envMap.value=t,n||o.texelSize.value.set(1/t.image.width,1/t.image.height),this._setEncoding(o.inputEncoding,t),this._setEncoding(o.outputEncoding,e.texture),Oa(e,0,0,3*ma,2*ma),r.setRenderTarget(e),r.render(a,_a)}_applyPMREM(t){const e=this._renderer,r=e.autoClear;e.autoClear=!1;for(let e=1;eya&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;tpa-fa?n-pa+fa:0),3*v,2*v),s.setRenderTarget(e),s.render(u,_a)}}function Ca(t){return void 0!==t&&t.type===ft&&(t.encoding===De||t.encoding===ke||t.encoding===Fe)}function Ia(){const t=[],e=[],r=[];let n=pa;for(let i=0;ipa-fa?o=ga[i-pa+fa-1]:0==i&&(o=0),r.push(o);const s=1/(a-1),l=-s/2,u=1+s/2,c=[l,l,u,l,u,u,l,l,u,u,l,u],h=6,d=6,f=3,p=2,m=1,g=new Float32Array(f*d*h),v=new Float32Array(p*d*h),y=new Float32Array(m*d*h);for(let t=0;t2?0:-1,n=[e,r,0,e+2/3,r,0,e+2/3,r+1,0,e,r,0,e+2/3,r+1,0,e,r+1,0];g.set(n,f*d*t),v.set(c,p*d*t);const i=[t,t,t,t,t,t];y.set(i,m*d*t)}const x=new mi;x.setAttribute("position",new Jn(g,f)),x.setAttribute("uv",new Jn(v,p)),x.setAttribute("faceIndex",new Jn(y,m)),t.push(x),n>fa&&n--}return{_lodPlanes:t,_sizeLods:e,_sigmas:r}}function La(t){const e=new _r(3*ma,3*ma,t);return e.texture.mapping=rt,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Oa(t,e,r,n,i){t.viewport.set(e,r,n,i),t.scissor.set(e,r,n,i)}function Da(){const t=new sr(1,1);return new da({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:xa[De]},outputEncoding:{value:xa[De]}},vertexShader:Fa(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t${Na()}\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:d,depthTest:!1,depthWrite:!1})}function ka(){return new da({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:xa[De]},outputEncoding:{value:xa[De]}},vertexShader:Fa(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t${Na()}\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:d,depthTest:!1,depthWrite:!1})}function Fa(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Na(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}function Ua(t){let e=new WeakMap,r=null;function n(t){const r=t.target;r.removeEventListener("dispose",n);const i=e.get(r);void 0!==i&&(e.delete(r),i.dispose())}return{get:function(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const a=i.mapping,o=a===tt||a===et,s=a===Q||a===$;if(o||s){if(e.has(i))return e.get(i).texture;{const a=i.image;if(o&&a&&a.height>0||s&&a&&function(t){let e=0;const r=6;for(let n=0;n65535?ii:ri)(r,1);s.version=o;const l=a.get(t);l&&e.remove(l),a.set(t,s)}return{get:function(t,e){return!0===i[e.id]||(e.addEventListener("dispose",o),i[e.id]=!0,r.memory.geometries++),e},update:function(t){const r=t.attributes;for(const t in r)e.update(r[t],34962);const n=t.morphAttributes;for(const t in n){const r=n[t];for(let t=0,n=r.length;te.maxTextureSize&&(h=Math.ceil(c/e.maxTextureSize),c=e.maxTextureSize);const d=new Float32Array(c*h*4*n),f=new Va(d,c,h,n);f.format=At,f.type=xt;const p=4*l;for(let e=0;e0)return t;const i=e*r;let a=to[i];if(void 0===a&&(a=new Float32Array(i),to[i]=a),0!==e){n.toArray(a,0);for(let n=1,i=0;n!==e;++n)i+=r,t[n].toArray(a,i)}return a}function oo(t,e){if(t.length!==e.length)return!1;for(let r=0,n=t.length;r/gm;function ds(t){return t.replace(hs,fs)}function fs(t,e){const r=ra[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return ds(r)}const ps=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,ms=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function gs(t){return t.replace(ms,ys).replace(ps,vs)}function vs(t,e,r,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),ys(t,e,r,n)}function ys(t,e,r,n){let i="";for(let t=parseInt(e);t0?t.gammaFactor:1,g=r.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ls).join("\n")}(r),v=function(t){const e=[];for(const r in t){const n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}(a),y=i.createProgram();let x,_,w=r.glslVersion?"#version "+r.glslVersion+"\n":"";r.isRawShaderMaterial?(x=[v].filter(ls).join("\n"),x.length>0&&(x+="\n"),_=[g,v].filter(ls).join("\n"),_.length>0&&(_+="\n")):(x=[xs(r),"#define SHADER_NAME "+r.shaderName,v,r.instancing?"#define USE_INSTANCING":"",r.instancingColor?"#define USE_INSTANCING_COLOR":"",r.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+r.maxBones,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+f:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMap&&r.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",r.normalMap&&r.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.displacementMap&&r.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",r.specularColorMap?"#define USE_SPECULARCOLORMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.sheenColorMap?"#define USE_SHEENCOLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",r.vertexTangents?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUvs?"#define USE_UV":"",r.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.useVertexTexture?"#define BONE_TEXTURE":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&!1===r.flatShading?"#define USE_MORPHNORMALS":"",r.morphTargets&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",r.morphTargets&&r.isWebGL2?"#define MORPHTARGETS_COUNT "+r.morphTargetsCount:"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+h:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ls).join("\n"),_=[g,xs(r),"#define SHADER_NAME "+r.shaderName,v,"#define GAMMA_FACTOR "+m,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+d:"",r.envMap?"#define "+f:"",r.envMap?"#define "+p:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMap&&r.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",r.normalMap&&r.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",r.clearcoat?"#define USE_CLEARCOAT":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",r.specularColorMap?"#define USE_SPECULARCOLORMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaTest?"#define USE_ALPHATEST":"",r.sheen?"#define USE_SHEEN":"",r.sheenColorMap?"#define USE_SHEENCOLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.vertexTangents?"#define USE_TANGENT":"",r.vertexColors||r.instancingColor?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUvs?"#define USE_UV":"",r.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+h:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensionShaderTextureLOD||r.envMap)&&r.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",r.toneMapping!==W?"#define TONE_MAPPING":"",r.toneMapping!==W?ra.tonemapping_pars_fragment:"",r.toneMapping!==W?ss("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",r.format===Et?"#define OPAQUE":"",ra.encodings_pars_fragment,r.map?as("mapTexelToLinear",r.mapEncoding):"",r.matcap?as("matcapTexelToLinear",r.matcapEncoding):"",r.envMap?as("envMapTexelToLinear",r.envMapEncoding):"",r.emissiveMap?as("emissiveMapTexelToLinear",r.emissiveMapEncoding):"",r.specularColorMap?as("specularColorMapTexelToLinear",r.specularColorMapEncoding):"",r.sheenColorMap?as("sheenColorMapTexelToLinear",r.sheenColorMapEncoding):"",r.lightMap?as("lightMapTexelToLinear",r.lightMapEncoding):"",os("linearToOutputTexel",r.outputEncoding),r.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(ls).join("\n")),u=ds(u),u=us(u,r),u=cs(u,r),c=ds(c),c=us(c,r),c=cs(c,r),u=gs(u),c=gs(c),r.isWebGL2&&!0!==r.isRawShaderMaterial&&(w="#version 300 es\n",x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,_=["#define varying in",r.glslVersion===Xe?"":"out highp vec4 pc_fragColor;",r.glslVersion===Xe?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+_);const b=w+_+c,M=es(i,35633,w+x+u),S=es(i,35632,b);if(i.attachShader(y,M),i.attachShader(y,S),void 0!==r.index0AttributeName?i.bindAttribLocation(y,0,r.index0AttributeName):!0===r.morphTargets&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y),t.debug.checkShaderErrors){const t=i.getProgramInfoLog(y).trim(),e=i.getShaderInfoLog(M).trim(),r=i.getShaderInfoLog(S).trim();let n=!0,a=!0;if(!1===i.getProgramParameter(y,35714)){n=!1;const e=is(i,M,"vertex"),r=is(i,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+r)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==r||(a=!1);a&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:x},fragmentShader:{log:r,prefix:_}})}let T,E;return i.deleteShader(M),i.deleteShader(S),this.getUniforms=function(){return void 0===T&&(T=new ts(i,y)),T},this.getAttributes=function(){return void 0===E&&(E=function(t,e){const r={},n=t.getProgramParameter(e,35721);for(let i=0;i0,C=a.clearcoat>0;return{isWebGL2:l,shaderID:S,shaderName:a.type,vertexShader:E,fragmentShader:A,defines:a.defines,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:m,instancing:!0===_.isInstancedMesh,instancingColor:!0===_.isInstancedMesh&&null!==_.instanceColor,supportsVertexTextures:p,outputEncoding:null!==R?y(R.texture):t.outputEncoding,map:!!a.map,mapEncoding:y(a.map),matcap:!!a.matcap,matcapEncoding:y(a.matcap),envMap:!!M,envMapMode:M&&M.mapping,envMapEncoding:y(M),envMapCubeUV:!!M&&(M.mapping===rt||M.mapping===nt),lightMap:!!a.lightMap,lightMapEncoding:y(a.lightMap),aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,emissiveMapEncoding:y(a.emissiveMap),bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,objectSpaceNormalMap:a.normalMapType===Ve,tangentSpaceNormalMap:a.normalMapType===je,clearcoat:C,clearcoatMap:C&&!!a.clearcoatMap,clearcoatRoughnessMap:C&&!!a.clearcoatRoughnessMap,clearcoatNormalMap:C&&!!a.clearcoatNormalMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,specularIntensityMap:!!a.specularIntensityMap,specularColorMap:!!a.specularColorMap,specularColorMapEncoding:y(a.specularColorMap),alphaMap:!!a.alphaMap,alphaTest:P,gradientMap:!!a.gradientMap,sheen:a.sheen>0,sheenColorMap:!!a.sheenColorMap,sheenColorMapEncoding:y(a.sheenColorMap),sheenRoughnessMap:!!a.sheenRoughnessMap,transmission:a.transmission>0,transmissionMap:!!a.transmissionMap,thicknessMap:!!a.thicknessMap,combine:a.combine,vertexTangents:!!a.normalMap&&!!_.geometry&&!!_.geometry.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!_.geometry&&!!_.geometry.attributes.color&&4===_.geometry.attributes.color.itemSize,vertexUvs:!!a.map||!!a.bumpMap||!!a.normalMap||!!a.specularMap||!!a.alphaMap||!!a.emissiveMap||!!a.roughnessMap||!!a.metalnessMap||!!a.clearcoatMap||!!a.clearcoatRoughnessMap||!!a.clearcoatNormalMap||!!a.displacementMap||!!a.transmissionMap||!!a.thicknessMap||!!a.specularIntensityMap||!!a.specularColorMap||!!a.sheenColorMap||a.sheenRoughnessMap,uvsVertexOnly:!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatNormalMap||a.transmission>0||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheen>0||a.sheenColorMap||a.sheenRoughnessMap||!a.displacementMap),fog:!!w,useFog:a.fog,fogExp2:w&&w.isFogExp2,flatShading:!!a.flatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh&&T>0,maxBones:T,useVertexTexture:d,morphTargets:!!_.geometry&&!!_.geometry.morphAttributes.position,morphNormals:!!_.geometry&&!!_.geometry.morphAttributes.normal,morphTargetsCount:_.geometry&&_.geometry.morphAttributes.position?_.geometry.morphAttributes.position.length:0,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,format:a.format,dithering:a.dithering,shadowMapEnabled:t.shadowMap.enabled&&v.length>0,shadowMapType:t.shadowMap.type,toneMapping:a.toneMapped?t.toneMapping:W,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===h,flipSided:a.side===c,depthPacking:void 0!==a.depthPacking&&a.depthPacking,index0AttributeName:a.index0AttributeName,extensionDerivatives:a.extensions&&a.extensions.derivatives,extensionFragDepth:a.extensions&&a.extensions.fragDepth,extensionDrawBuffers:a.extensions&&a.extensions.drawBuffers,extensionShaderTextureLOD:a.extensions&&a.extensions.shaderTextureLOD,rendererExtensionFragDepth:l||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:l||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:l||n.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(e){const r=[];if(e.shaderID?r.push(e.shaderID):(r.push(fr(e.fragmentShader)),r.push(fr(e.vertexShader))),void 0!==e.defines)for(const t in e.defines)r.push(t),r.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t0?i.push(c):!0===r.transparent?a.push(c):n.push(c)},unshift:function(t,e,r,o,l,u){const c=s(t,e,r,o,l,u);r.transmission>0?i.unshift(c):!0===r.transparent?a.unshift(c):n.unshift(c)},finish:function(){for(let t=r,n=e.length;t1&&n.sort(t||Ms),i.length>1&&i.sort(e||Ss),a.length>1&&a.sort(e||Ss)}}}function Es(t){let e=new WeakMap;return{get:function(r,n){let i;return!1===e.has(r)?(i=new Ts(t),e.set(r,[i])):n>=e.get(r).length?(i=new Ts(t),e.get(r).push(i)):i=e.get(r)[n],i},dispose:function(){e=new WeakMap}}}function As(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let r;switch(e.type){case"DirectionalLight":r={direction:new Sr,color:new Xn};break;case"SpotLight":r={position:new Sr,direction:new Sr,color:new Xn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new Sr,color:new Xn,distance:0,decay:0};break;case"HemisphereLight":r={direction:new Sr,skyColor:new Xn,groundColor:new Xn};break;case"RectAreaLight":r={color:new Xn,position:new Sr,halfWidth:new Sr,halfHeight:new Sr}}return t[e.id]=r,r}}}let Rs=0;function Ps(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function Cs(t,e){const r=new As,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let r;switch(e.type){case"DirectionalLight":case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sr};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sr,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=r,r}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)i.probe.push(new Sr);const a=new Sr,o=new en,s=new en;return{setup:function(a,o){let s=0,l=0,u=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let c=0,h=0,d=0,f=0,p=0,m=0,g=0,v=0;a.sort(Ps);const y=!0!==o?Math.PI:1;for(let t=0,e=a.length;t0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=na.LTC_FLOAT_1,i.rectAreaLTC2=na.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=na.LTC_HALF_1,i.rectAreaLTC2=na.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=u;const x=i.hash;x.directionalLength===c&&x.pointLength===h&&x.spotLength===d&&x.rectAreaLength===f&&x.hemiLength===p&&x.numDirectionalShadows===m&&x.numPointShadows===g&&x.numSpotShadows===v||(i.directional.length=c,i.spot.length=d,i.rectArea.length=f,i.point.length=h,i.hemi.length=p,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=v,i.spotShadowMap.length=v,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotShadowMatrix.length=v,x.directionalLength=c,x.pointLength=h,x.spotLength=d,x.rectAreaLength=f,x.hemiLength=p,x.numDirectionalShadows=m,x.numPointShadows=g,x.numSpotShadows=v,i.version=Rs++)},setupView:function(t,e){let r=0,n=0,l=0,u=0,c=0;const h=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.get(n).length?(a=new Is(t,e),r.get(n).push(a)):a=r.get(n)[i],a},dispose:function(){r=new WeakMap}}}class Os extends zn{constructor(t){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}Os.prototype.isMeshDepthMaterial=!0;class Ds extends zn{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Sr,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}Ds.prototype.isMeshDistanceMaterial=!0;const ks="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",Fs="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function Ns(t,e,r){let n=new Qi;const i=new sr,a=new sr,s=new xr,f=new Os({depthPacking:Ge}),p=new Ds,m={},g=r.maxTextureSize,v={0:c,1:u,2:h},y=new Bi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new sr},radius:{value:4}},vertexShader:ks,fragmentShader:Fs}),x=y.clone();x.defines.HORIZONTAL_PASS=1;const _=new mi;_.setAttribute("position",new Jn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const w=new Oi(_,y),b=this;function M(r,n){const i=e.update(w);y.defines.VSM_SAMPLES!==r.blurSamples&&(y.defines.VSM_SAMPLES=r.blurSamples,x.defines.VSM_SAMPLES=r.blurSamples,y.needsUpdate=!0,x.needsUpdate=!0),y.uniforms.shadow_pass.value=r.map.texture,y.uniforms.resolution.value=r.mapSize,y.uniforms.radius.value=r.radius,t.setRenderTarget(r.mapPass),t.clear(),t.renderBufferDirect(n,null,i,y,w,null),x.uniforms.shadow_pass.value=r.mapPass.texture,x.uniforms.resolution.value=r.mapSize,x.uniforms.radius.value=r.radius,t.setRenderTarget(r.map),t.clear(),t.renderBufferDirect(n,null,i,x,w,null)}function S(e,r,n,i,a,o,s){let u=null;const c=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(u=void 0!==c?c:!0===i.isPointLight?p:f,t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const t=u.uuid,e=n.uuid;let r=m[t];void 0===r&&(r={},m[t]=r);let i=r[e];void 0===i&&(i=u.clone(),r[e]=i),u=i}return u.visible=n.visible,u.wireframe=n.wireframe,u.side=s===l?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:v[n.side],u.alphaMap=n.alphaMap,u.alphaTest=n.alphaTest,u.clipShadows=n.clipShadows,u.clippingPlanes=n.clippingPlanes,u.clipIntersection=n.clipIntersection,u.displacementMap=n.displacementMap,u.displacementScale=n.displacementScale,u.displacementBias=n.displacementBias,u.wireframeLinewidth=n.wireframeLinewidth,u.linewidth=n.linewidth,!0===i.isPointLight&&!0===u.isMeshDistanceMaterial&&(u.referencePosition.setFromMatrixPosition(i.matrixWorld),u.nearDistance=a,u.farDistance=o),u}function T(r,i,a,o,s){if(!1===r.visible)return;if(r.layers.test(i.layers)&&(r.isMesh||r.isLine||r.isPoints)&&(r.castShadow||r.receiveShadow&&s===l)&&(!r.frustumCulled||n.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,r.matrixWorld);const n=e.update(r),i=r.material;if(Array.isArray(i)){const e=n.groups;for(let l=0,u=e.length;lg||i.y>g)&&(i.x>g&&(a.x=Math.floor(g/d.x),i.x=a.x*d.x,h.mapSize.x=a.x),i.y>g&&(a.y=Math.floor(g/d.y),i.y=a.y*d.y,h.mapSize.y=a.y)),null===h.map&&!h.isPointLightShadow&&this.type===l){const t={minFilter:ct,magFilter:ct,format:At};h.map=new _r(i.x,i.y,t),h.map.texture.name=c.name+".shadowMap",h.mapPass=new _r(i.x,i.y,t),h.camera.updateProjectionMatrix()}if(null===h.map){const t={minFilter:st,magFilter:st,format:At};h.map=new _r(i.x,i.y,t),h.map.texture.name=c.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const p=h.getViewportCount();for(let t=0;t=1):-1!==lt.indexOf("OpenGL ES")&&(st=parseFloat(/^OpenGL ES (\d)/.exec(lt)[1]),ot=st>=2);let ut=null,ct={};const ht=t.getParameter(3088),dt=t.getParameter(2978),ft=(new xr).fromArray(ht),pt=(new xr).fromArray(dt);function mt(e,r,n){const i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;en||t.height>n)&&(i=n/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?ar:Math.floor,a=n(i*t.width),o=n(i*t.height);void 0===p&&(p=g(a,o));const s=r?g(a,o):p;s.width=a,s.height=o;return s.getContext("2d").drawImage(t,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+a+"x"+o+")."),s}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function y(t){return nr(t.width)&&nr(t.height)}function x(t,e){return t.generateMipmaps&&e&&t.minFilter!==st&&t.minFilter!==ct}function _(e){t.generateMipmap(e)}function w(r,n,i){if(!1===s)return n;if(null!==r){if(void 0!==t[r])return t[r];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+r+"'")}let a=n;return 6403===n&&(5126===i&&(a=33326),5131===i&&(a=33325),5121===i&&(a=33321)),6407===n&&(5126===i&&(a=34837),5131===i&&(a=34843),5121===i&&(a=32849)),6408===n&&(5126===i&&(a=34836),5131===i&&(a=34842),5121===i&&(a=32856)),33325!==a&&33326!==a&&34842!==a&&34836!==a||e.get("EXT_color_buffer_float"),a}function b(t){return t===st||t===lt||t===ut?9728:9729}function M(e){const r=e.target;r.removeEventListener("dispose",M),function(e){const r=n.get(e);if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture),n.remove(e)}(r),r.isVideoTexture&&f.delete(r),o.memory.textures--}function S(e){const r=e.target;r.removeEventListener("dispose",S),function(e){const r=e.texture,i=n.get(e),a=n.get(r);if(!e)return;void 0!==a.__webglTexture&&(t.deleteTexture(a.__webglTexture),o.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&t.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,i=r.length;e0&&i.__version!==t.version){const r=t.image;if(void 0===r)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==r.complete)return void L(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}r.activeTexture(33984+e),r.bindTexture(3553,i.__webglTexture)}function A(e,i){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,n,i){if(6!==n.image.length)return;I(e,n),r.activeTexture(33984+i),r.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const o=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),l=n.image[0]&&n.image[0].isDataTexture,c=[];for(let t=0;t<6;t++)c[t]=o||l?l?n.image[t].image:n.image[t]:v(n.image[t],!1,!0,u);const h=y(c[0])||s,d=a.convert(n.format),f=a.convert(n.type),p=w(n.internalFormat,d,f,n.encoding);let m;if(C(34067,n,h),o)for(let t=0;t<6;t++){m=c[t].mipmaps;for(let e=0;e1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function I(e,r){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",M),e.__webglTexture=t.createTexture(),o.memory.textures++)}function L(e,n,i){let o=3553;n.isDataTexture2DArray&&(o=35866),n.isDataTexture3D&&(o=32879),I(e,n),r.activeTexture(33984+i),r.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const l=function(t){return!s&&(t.wrapS!==at||t.wrapT!==at||t.minFilter!==st&&t.minFilter!==ct)}(n)&&!1===y(n.image),u=v(n.image,l,!1,c),h=y(u)||s,d=a.convert(n.format);let f,p=a.convert(n.type),m=w(n.internalFormat,d,p,n.encoding);C(o,n,h);const g=n.mipmaps;if(n.isDepthTexture)m=6402,s?m=n.type===xt?36012:n.type===yt?33190:n.type===St?35056:33189:n.type===xt&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===It&&6402===m&&n.type!==gt&&n.type!==yt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=gt,p=a.convert(n.type)),n.format===Lt&&6402===m&&(m=34041,n.type!==St&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=St,p=a.convert(n.type))),r.texImage2D(3553,0,m,u.width,u.height,0,d,p,null);else if(n.isDataTexture)if(g.length>0&&h){for(let t=0,e=g.length;t0?t.mipmaps.length:1}(n,u,h),i=s&&!0!==n.isVideoTexture,a=void 0===e.__version;if(g.length>0&&h){i&&a&&r.texStorage2D(3553,t,m,g[0].width,g[0].height);for(let t=0,e=g.length;t=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(t,e){const i=n.get(t);t.version>0&&i.__version!==t.version?L(i,t,e):(r.activeTexture(33984+e),r.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){const i=n.get(t);t.version>0&&i.__version!==t.version?L(i,t,e):(r.activeTexture(33984+e),r.bindTexture(32879,i.__webglTexture))},this.setTextureCube=A,this.rebindTextures=function(t,e,r){const i=n.get(t);void 0!==e&&O(i.__webglFramebuffer,t,t.texture,36064,3553),void 0!==r&&k(t)},this.setupRenderTarget=function(e){const l=e.texture,u=n.get(e),c=n.get(l);e.addEventListener("dispose",S),!0!==e.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=t.createTexture()),c.__version=l.version,o.memory.textures++);const h=!0===e.isWebGLCubeRenderTarget,d=!0===e.isWebGLMultipleRenderTargets,f=l.isDataTexture3D||l.isDataTexture2DArray,p=y(e)||s;if(!s||l.format!==Et||l.type!==xt&&l.type!==_t||(l.format=At,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){u.__webglFramebuffer=[];for(let e=0;e<6;e++)u.__webglFramebuffer[e]=t.createFramebuffer()}else if(u.__webglFramebuffer=t.createFramebuffer(),d)if(i.drawBuffers){const r=e.texture;for(let e=0,i=r.length;es+u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&o<=s-u&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==s&&t.gripSpace&&(i=e.getPose(t.gripSpace,r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));return null!==o&&(o.visible=null!==n),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==a),this}}class Ws extends vr{constructor(t,e,r,n,i,a,o,s,l,u){if((u=void 0!==u?u:It)!==It&&u!==Lt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===It&&(r=gt),void 0===r&&u===Lt&&(r=St),super(null,n,i,a,o,s,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==o?o:st,this.minFilter=void 0!==s?s:st,this.flipY=!1,this.generateMipmaps=!1}}Ws.prototype.isDepthTexture=!0;class qs extends Ye{constructor(t,e){super();const r=this;let n=null,i=1,a=null,o="local-floor";const s=t.extensions.has("WEBGL_multisampled_render_to_texture");let l=null,u=null,c=null,h=null,d=!1,f=null;const p=e.getContextAttributes();let m=null,g=null;const v=[],y=new Map,x=new Gi;x.layers.enable(1),x.viewport=new xr;const _=new Gi;_.layers.enable(2),_.viewport=new xr;const w=[x,_],b=new Gs;b.layers.enable(1),b.layers.enable(2);let M=null,S=null;function T(t){const e=y.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function E(){y.forEach((function(t,e){t.disconnect(e)})),y.clear(),M=null,S=null,t.setRenderTarget(m),h=null,c=null,u=null,n=null,g=null,L.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}function A(t){const e=n.inputSources;for(let t=0;t0&&(e.alphaTest.value=r.alphaTest);const n=t.get(r).envMap;let i,a;n&&(e.envMap.value=n,e.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity),r.map?i=r.map:r.specularMap?i=r.specularMap:r.displacementMap?i=r.displacementMap:r.normalMap?i=r.normalMap:r.bumpMap?i=r.bumpMap:r.roughnessMap?i=r.roughnessMap:r.metalnessMap?i=r.metalnessMap:r.alphaMap?i=r.alphaMap:r.emissiveMap?i=r.emissiveMap:r.clearcoatMap?i=r.clearcoatMap:r.clearcoatNormalMap?i=r.clearcoatNormalMap:r.clearcoatRoughnessMap?i=r.clearcoatRoughnessMap:r.specularIntensityMap?i=r.specularIntensityMap:r.specularColorMap?i=r.specularColorMap:r.transmissionMap?i=r.transmissionMap:r.thicknessMap?i=r.thicknessMap:r.sheenColorMap?i=r.sheenColorMap:r.sheenRoughnessMap&&(i=r.sheenRoughnessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix)),r.aoMap?a=r.aoMap:r.lightMap&&(a=r.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),e.uv2Transform.value.copy(a.matrix))}function r(e,r){e.roughness.value=r.roughness,e.metalness.value=r.metalness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap),r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap),r.bumpMap&&(e.bumpMap.value=r.bumpMap,e.bumpScale.value=r.bumpScale,r.side===c&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,e.normalScale.value.copy(r.normalScale),r.side===c&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias);t.get(r).envMap&&(e.envMapIntensity.value=r.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,n,i,a,o){n.isMeshBasicMaterial?e(t,n):n.isMeshLambertMaterial?(e(t,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,n)):n.isMeshToonMaterial?(e(t,n),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshPhongMaterial?(e(t,n),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshStandardMaterial?(e(t,n),n.isMeshPhysicalMaterial?function(t,e,n){r(t,e),t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===c&&t.clearcoatNormalScale.value.negate()));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap);e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap)}(t,n,o):r(t,n)):n.isMeshMatcapMaterial?(e(t,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDepthMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDistanceMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,n)):n.isMeshNormalMaterial?(e(t,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,r,n){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*r,t.scale.value=.5*n,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n,i,a):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let r;e.map?r=e.map:e.alphaMap&&(r=e.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Ys(e={}){const r=void 0!==e.canvas?e.canvas:function(){const t=dr("canvas");return t.style.display="block",t}(),n=void 0!==e.context?e.context:null,i=void 0!==e.alpha&&e.alpha,a=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,s=void 0!==e.antialias&&e.antialias,l=void 0===e.premultipliedAlpha||e.premultipliedAlpha,d=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,f=void 0!==e.powerPreference?e.powerPreference:"default",p=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let m=null,g=null;const v=[],y=[];this.domElement=r,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=De,this.physicallyCorrectLights=!1,this.toneMapping=W,this.toneMappingExposure=1;const x=this;let _=!1,w=0,b=0,M=null,S=-1,T=null;const E=new xr,A=new xr;let R=null,P=r.width,C=r.height,I=1,L=null,O=null;const D=new xr(0,0,P,C),k=new xr(0,0,P,C);let F=!1;const N=[],U=new Qi;let B=!1,z=!1,G=null;const j=new en,V=new Sr,H={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return null===M?I:1}let X,Y,Z,K,J,Q,$,tt,et,rt,nt,it,ot,lt,ut,ct,ht,pt,mt,gt,vt,yt,wt,bt=n;function Mt(t,e){for(let n=0;n0&&function(t,e,r){if(null===G){const t=!0===s&&!0===Y.isWebGL2;G=new(t?br:_r)(1024,1024,{generateMipmaps:!0,type:null!==yt.convert(_t)?_t:ft,minFilter:dt,magFilter:st,wrapS:at,wrapT:at,useRenderToTexture:X.has("WEBGL_multisampled_render_to_texture")})}const n=x.getRenderTarget();x.setRenderTarget(G),x.clear();const i=x.toneMapping;x.toneMapping=W,Ft(t,e,r),x.toneMapping=i,Q.updateMultisampleRenderTarget(G),Q.updateRenderTargetMipmap(G),x.setRenderTarget(n)}(i,e,r),n&&Z.viewport(E.copy(n)),i.length>0&&Ft(i,e,r),a.length>0&&Ft(a,e,r),o.length>0&&Ft(o,e,r)}function Ft(t,e,r){const n=!0===e.isScene?e.overrideMaterial:null;for(let i=0,a=t.length;i0?y[y.length-1]:null,v.pop(),m=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,r){J.get(t.texture).__webglTexture=e,J.get(t.depthTexture).__webglTexture=r;const n=J.get(t);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===r,n.__autoAllocateDepthBuffer||t.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),t.useRenderToTexture=!1,t.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(t,e){const r=J.get(t);r.__webglFramebuffer=e,r.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,r=0){M=t,w=e,b=r;let n=!0;if(t){const e=J.get(t);void 0!==e.__useDefaultFramebuffer?(Z.bindFramebuffer(36160,null),n=!1):void 0===e.__webglFramebuffer?Q.setupRenderTarget(t):e.__hasExternalTextures&&Q.rebindTextures(t,J.get(t.texture).__webglTexture,J.get(t.depthTexture).__webglTexture)}let i=null,a=!1,o=!1;if(t){const r=t.texture;(r.isDataTexture3D||r.isDataTexture2DArray)&&(o=!0);const n=J.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=n[e],a=!0):i=t.useRenderbuffer?J.get(t).__webglMultisampledFramebuffer:n,E.copy(t.viewport),A.copy(t.scissor),R=t.scissorTest}else E.copy(D).multiplyScalar(I).floor(),A.copy(k).multiplyScalar(I).floor(),R=F;if(Z.bindFramebuffer(36160,i)&&Y.drawBuffers&&n){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const r=t.texture;if(N.length!==r.length||36064!==N[0]){for(let t=0,e=r.length;t=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&bt.readPixels(e,r,n,i,yt.convert(s),yt.convert(l),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==M?J.get(M).__webglFramebuffer:null;Z.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,r=0){const n=Math.pow(2,-r),i=Math.floor(e.image.width*n),a=Math.floor(e.image.height*n);let o=yt.convert(e.format);Y.isWebGL2&&(6407===o&&(o=32849),6408===o&&(o=32856)),Q.setTexture2D(e,0),bt.copyTexImage2D(3553,r,o,t.x,t.y,i,a,0),Z.unbindTexture()},this.copyTextureToTexture=function(t,e,r,n=0){const i=e.image.width,a=e.image.height,o=yt.convert(r.format),s=yt.convert(r.type);Q.setTexture2D(r,0),bt.pixelStorei(37440,r.flipY),bt.pixelStorei(37441,r.premultiplyAlpha),bt.pixelStorei(3317,r.unpackAlignment),e.isDataTexture?bt.texSubImage2D(3553,n,t.x,t.y,i,a,o,s,e.image.data):e.isCompressedTexture?bt.compressedTexSubImage2D(3553,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):bt.texSubImage2D(3553,n,t.x,t.y,o,s,e.image),0===n&&r.generateMipmaps&&bt.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(t,e,r,n,i=0){if(x.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=t.max.x-t.min.x+1,o=t.max.y-t.min.y+1,s=t.max.z-t.min.z+1,l=yt.convert(n.format),u=yt.convert(n.type);let c;if(n.isDataTexture3D)Q.setTexture3D(n,0),c=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(n,0),c=35866}bt.pixelStorei(37440,n.flipY),bt.pixelStorei(37441,n.premultiplyAlpha),bt.pixelStorei(3317,n.unpackAlignment);const h=bt.getParameter(3314),d=bt.getParameter(32878),f=bt.getParameter(3316),p=bt.getParameter(3315),m=bt.getParameter(32877),g=r.isCompressedTexture?r.mipmaps[0]:r.image;bt.pixelStorei(3314,g.width),bt.pixelStorei(32878,g.height),bt.pixelStorei(3316,t.min.x),bt.pixelStorei(3315,t.min.y),bt.pixelStorei(32877,t.min.z),r.isDataTexture||r.isDataTexture3D?bt.texSubImage3D(c,i,e.x,e.y,e.z,a,o,s,l,u,g.data):r.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),bt.compressedTexSubImage3D(c,i,e.x,e.y,e.z,a,o,s,l,g.data)):bt.texSubImage3D(c,i,e.x,e.y,e.z,a,o,s,l,u,g),bt.pixelStorei(3314,h),bt.pixelStorei(32878,d),bt.pixelStorei(3316,f),bt.pixelStorei(3315,p),bt.pixelStorei(32877,m),0===i&&n.generateMipmaps&&bt.generateMipmap(c),Z.unbindTexture()},this.initTexture=function(t){Q.setTexture2D(t,0),Z.unbindTexture()},this.resetState=function(){w=0,b=0,M=null,Z.reset(),wt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Ys.prototype.isWebGLRenderer=!0;class Zs extends Ys{}Zs.prototype.isWebGL1Renderer=!0;class Ks{constructor(t,e=25e-5){this.name="",this.color=new Xn(t),this.density=e}clone(){return new Ks(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Ks.prototype.isFogExp2=!0;class Js{constructor(t,e=1,r=1e3){this.name="",this.color=new Xn(t),this.near=e,this.far=r}clone(){return new Js(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Js.prototype.isFog=!0;class Qs extends An{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}Qs.prototype.isScene=!0;class $s{constructor(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=We,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=$e()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let n=0,i=this.stride;nt.far||e.push({distance:s,point:il.clone(),uv:Un.getUV(il,cl,hl,dl,fl,pl,ml,new sr),face:null,object:this})}copy(t){return super.copy(t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function vl(t,e,r,n,i,a){sl.subVectors(t,r).addScalar(.5).multiply(n),void 0!==i?(ll.x=a*sl.x-i*sl.y,ll.y=i*sl.x+a*sl.y):ll.copy(sl),t.copy(e),t.x+=ll.x,t.y+=ll.y,t.applyMatrix4(ul)}gl.prototype.isSprite=!0;const yl=new Sr,xl=new Sr;class _l extends An{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,r=e.length;t0){let r,n;for(r=1,n=e.length;r0){yl.setFromMatrixPosition(this.matrixWorld);const r=t.ray.origin.distanceTo(yl);this.getObjectForDistance(r).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){yl.setFromMatrixPosition(t.matrixWorld),xl.setFromMatrixPosition(this.matrixWorld);const r=yl.distanceTo(xl)/t.zoom;let n,i;for(e[0].object.visible=!0,n=1,i=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;ns)continue;h.applyMatrix4(this.matrixWorld);const d=t.ray.origin.distanceTo(h);dt.far||e.push({distance:d,point:c.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}else{for(let r=Math.max(0,a.start),n=Math.min(i.count,a.start+a.count)-1;rs)continue;h.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(h);nt.far||e.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}}else r.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,r=Object.keys(e);if(r.length>0){const t=e[r[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,r=t.length;e0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Hl.prototype.isLine=!0;const Wl=new Sr,ql=new Sr;class Xl extends Hl{constructor(t,e){super(t,e),this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,r=[];for(let t=0,n=e.count;t0){const t=e[r[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,r=t.length;e0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};function eu(t,e,r,n,i,a,o){const s=Jl.distanceSqToPoint(t);if(si.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:r,index:e,face:null,object:o})}}tu.prototype.isPoints=!0;class ru extends vr{constructor(t,e,r,n,i,a,o,s,l){super(t,e,r,n,i,a,o,s,l),this.format=void 0!==o?o:Et,this.minFilter=void 0!==a?a:ct,this.magFilter=void 0!==i?i:ct,this.generateMipmaps=!1;const u=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){u.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}ru.prototype.isVideoTexture=!0;class nu extends vr{constructor(t,e,r,n,i,a,o,s,l,u,c,h){super(null,a,o,s,l,u,n,i,c,h),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}nu.prototype.isCompressedTexture=!0;class iu extends vr{constructor(t,e,r,n,i,a,o,s,l){super(t,e,r,n,i,a,o,s,l),this.needsUpdate=!0}}iu.prototype.isCanvasTexture=!0;class au extends mi{constructor(t=1,e=8,r=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},e=Math.max(3,e);const i=[],a=[],o=[],s=[],l=new Sr,u=new sr;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,c=3;i<=e;i++,c+=3){const h=r+i/e*n;l.x=t*Math.cos(h),l.y=t*Math.sin(h),a.push(l.x,l.y,l.z),o.push(0,0,1),u.x=(a[c]/t+1)/2,u.y=(a[c+1]/t+1)/2,s.push(u.x,u.y)}for(let t=1;t<=e;t++)i.push(t,t+1,0);this.setIndex(i),this.setAttribute("position",new oi(a,3)),this.setAttribute("normal",new oi(o,3)),this.setAttribute("uv",new oi(s,2))}static fromJSON(t){return new au(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class ou extends mi{constructor(t=1,e=1,r=1,n=8,i=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};const l=this;n=Math.floor(n),i=Math.floor(i);const u=[],c=[],h=[],d=[];let f=0;const p=[],m=r/2;let g=0;function v(r){const i=f,a=new sr,p=new Sr;let v=0;const y=!0===r?t:e,x=!0===r?1:-1;for(let t=1;t<=n;t++)c.push(0,m*x,0),h.push(0,x,0),d.push(.5,.5),f++;const _=f;for(let t=0;t<=n;t++){const e=t/n*s+o,r=Math.cos(e),i=Math.sin(e);p.x=y*i,p.y=m*x,p.z=y*r,c.push(p.x,p.y,p.z),h.push(0,x,0),a.x=.5*r+.5,a.y=.5*i*x+.5,d.push(a.x,a.y),f++}for(let t=0;t0&&v(!0),e>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new oi(c,3)),this.setAttribute("normal",new oi(h,3)),this.setAttribute("uv",new oi(d,2))}static fromJSON(t){return new ou(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class su extends ou{constructor(t=1,e=1,r=8,n=1,i=!1,a=0,o=2*Math.PI){super(0,t,e,r,n,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new su(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class lu extends mi{constructor(t=[],e=[],r=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n};const i=[],a=[];function o(t,e,r,n){const i=n+1,a=[];for(let n=0;n<=i;n++){a[n]=[];const o=t.clone().lerp(r,n/i),s=e.clone().lerp(r,n/i),l=i-n;for(let t=0;t<=l;t++)a[n][t]=0===t&&n===i?o:o.clone().lerp(s,t/l)}for(let t=0;t.9&&o<.1&&(e<.2&&(a[t+0]+=1),r<.2&&(a[t+2]+=1),n<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new oi(i,3)),this.setAttribute("normal",new oi(i.slice(),3)),this.setAttribute("uv",new oi(a,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(t){return new lu(t.vertices,t.indices,t.radius,t.details)}}class uu extends lu{constructor(t=1,e=0){const r=(1+Math.sqrt(5))/2,n=1/r;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new uu(t.radius,t.detail)}}const cu=new Sr,hu=new Sr,du=new Sr,fu=new Un;class pu extends mi{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const r=4,n=Math.pow(10,r),i=Math.cos(Je*e),a=t.getIndex(),o=t.getAttribute("position"),s=a?a.count:o.count,l=[0,0,0],u=["a","b","c"],c=new Array(3),h={},d=[];for(let t=0;t0)){l=n;break}l=n-1}if(n=l,r[n]===a)return n/(i-1);const u=r[n];return(n+(a-u)/(r[n+1]-u))/(i-1)}getTangent(t,e){const r=1e-4;let n=t-r,i=t+r;n<0&&(n=0),i>1&&(i=1);const a=this.getPoint(n),o=this.getPoint(i),s=e||(a.isVector2?new sr:new Sr);return s.copy(o).sub(a).normalize(),s}getTangentAt(t,e){const r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){const r=new Sr,n=[],i=[],a=[],o=new Sr,s=new en;for(let e=0;e<=t;e++){const r=e/t;n[e]=this.getTangentAt(r,new Sr)}i[0]=new Sr,a[0]=new Sr;let l=Number.MAX_VALUE;const u=Math.abs(n[0].x),c=Math.abs(n[0].y),h=Math.abs(n[0].z);u<=l&&(l=u,r.set(1,0,0)),c<=l&&(l=c,r.set(0,1,0)),h<=l&&r.set(0,0,1),o.crossVectors(n[0],r).normalize(),i[0].crossVectors(n[0],o),a[0].crossVectors(n[0],i[0]);for(let e=1;e<=t;e++){if(i[e]=i[e-1].clone(),a[e]=a[e-1].clone(),o.crossVectors(n[e-1],n[e]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos(tr(n[e-1].dot(n[e]),-1,1));i[e].applyMatrix4(s.makeRotationAxis(o,t))}a[e].crossVectors(n[e],i[e])}if(!0===e){let e=Math.acos(tr(i[0].dot(i[t]),-1,1));e/=t,n[0].dot(o.crossVectors(i[0],i[t]))>0&&(e=-e);for(let r=1;r<=t;r++)i[r].applyMatrix4(s.makeRotationAxis(n[r],e*r)),a[r].crossVectors(n[r],i[r])}return{tangents:n,normals:i,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class gu extends mu{constructor(t=0,e=0,r=1,n=1,i=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(t,e){const r=e||new sr,n=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const a=Math.abs(i)n;)i-=n;i0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===u&&l===i-1&&(l=i-2,u=1),this.closed||l>0?o=n[(l-1)%i]:(xu.subVectors(n[0],n[1]).add(n[0]),o=xu);const c=n[l%i],h=n[(l+1)%i];if(this.closed||l+2n.length-2?n.length-1:a+1],c=n[a>n.length-3?n.length-1:a+2];return r.set(Su(o,s.x,l.x,u.x,c.x),Su(o,s.y,l.y,u.y,c.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e=r){const t=n[i]-r,a=this.curves[i],o=a.getLength(),s=0===o?0:1-t/o;return a.getPointAt(s,e)}i++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,n=this.curves.length;r1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Nu extends Fu{constructor(t){super(t),this.uuid=$e(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let r=0,n=this.holes.length;r80*r){s=u=t[0],l=c=t[1];for(let e=r;eu&&(u=h),d>c&&(c=d);f=Math.max(u-s,c-l),f=0!==f?1/f:0}return Gu(a,o,r,s,l,f),o};function Bu(t,e,r,n,i){let a,o;if(i===function(t,e,r,n){let i=0;for(let a=e,o=r-n;a0)for(a=e;a=e;a-=n)o=oc(a,t[a],t[a+1],o);return o&&tc(o,o.next)&&(sc(o),o=o.next),o}function zu(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!tc(n,n.next)&&0!==$u(n.prev,n,n.next))n=n.next;else{if(sc(n),n=e=n.prev,n===n.next)break;r=!0}}while(r||n!==e);return e}function Gu(t,e,r,n,i,a,o){if(!t)return;!o&&a&&function(t,e,r,n){let i=t;do{null===i.z&&(i.z=Zu(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r,n,i,a,o,s,l,u=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,u*=2}while(o>1)}(i)}(t,n,i,a);let s,l,u=t;for(;t.prev!==t.next;)if(s=t.prev,l=t.next,a?Vu(t,n,i,a):ju(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),sc(t),t=l.next,u=l.next;else if((t=l)===u){o?1===o?Gu(t=Hu(zu(t),e,r),e,r,n,i,a,2):2===o&&Wu(t,e,r,n,i,a):Gu(zu(t),e,r,n,i,a,1);break}}function ju(t){const e=t.prev,r=t,n=t.next;if($u(e,r,n)>=0)return!1;let i=t.next.next;for(;i!==t.prev;){if(Ju(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&$u(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vu(t,e,r,n){const i=t.prev,a=t,o=t.next;if($u(i,a,o)>=0)return!1;const s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,c=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Zu(s,l,e,r,n),d=Zu(u,c,e,r,n);let f=t.prevZ,p=t.nextZ;for(;f&&f.z>=h&&p&&p.z<=d;){if(f!==t.prev&&f!==t.next&&Ju(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&$u(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,p!==t.prev&&p!==t.next&&Ju(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&$u(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&Ju(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&$u(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&Ju(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&$u(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Hu(t,e,r){let n=t;do{const i=n.prev,a=n.next.next;!tc(i,a)&&ec(i,n,n.next,a)&&ic(i,a)&&ic(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),sc(n),sc(n.next),n=t=a),n=n.next}while(n!==t);return zu(n)}function Wu(t,e,r,n,i,a){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Qu(o,t)){let s=ac(o,t);return o=zu(o,o.next),s=zu(s,s.next),Gu(o,e,r,n,i,a),void Gu(s,e,r,n,i,a)}t=t.next}o=o.next}while(o!==t)}function qu(t,e){return t.x-e.x}function Xu(t,e){if(e=function(t,e){let r=e;const n=t.x,i=t.y;let a,o=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>o){if(o=t,t===n){if(i===r.y)return r;if(i===r.next.y)return r.next}a=r.x=r.x&&r.x>=l&&n!==r.x&&Ju(ia.x||r.x===a.x&&Yu(a,r)))&&(a=r,h=c)),r=r.next}while(r!==s);return a}(t,e),e){const r=ac(e,t);zu(e,e.next),zu(r,r.next)}}function Yu(t,e){return $u(t.prev,t,e.prev)<0&&$u(e.next,t,t.next)<0}function Zu(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ku(t){let e=t,r=t;do{(e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function Qu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&ec(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(ic(t,e)&&ic(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&($u(t.prev,t,e.prev)||$u(t,e.prev,e))||tc(t,e)&&$u(t.prev,t,t.next)>0&&$u(e.prev,e,e.next)>0)}function $u(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function tc(t,e){return t.x===e.x&&t.y===e.y}function ec(t,e,r,n){const i=nc($u(t,e,r)),a=nc($u(t,e,n)),o=nc($u(r,n,t)),s=nc($u(r,n,e));return i!==a&&o!==s||(!(0!==i||!rc(t,r,e))||(!(0!==a||!rc(t,n,e))||(!(0!==o||!rc(r,t,n))||!(0!==s||!rc(r,e,n)))))}function rc(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function nc(t){return t>0?1:t<0?-1:0}function ic(t,e){return $u(t.prev,t,t.next)<0?$u(t,e,t.next)>=0&&$u(t,t.prev,e)>=0:$u(t,e,t.prev)<0||$u(t,t.next,e)<0}function ac(t,e){const r=new lc(t.i,t.x,t.y),n=new lc(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function oc(t,e,r,n){const i=new lc(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function sc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function lc(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class uc{static area(t){const e=t.length;let r=0;for(let n=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function hc(t,e){for(let r=0;rNumber.EPSILON){const h=Math.sqrt(c),d=Math.sqrt(l*l+u*u),f=e.x-s/h,p=e.y+o/h,m=((r.x-u/d-f)*u-(r.y+l/d-p)*l)/(o*u-s*l);n=f+o*m-t.x,i=p+s*m-t.y;const g=n*n+i*i;if(g<=2)return new sr(n,i);a=Math.sqrt(g/2)}else{let t=!1;o>Number.EPSILON?l>Number.EPSILON&&(t=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(s)===Math.sign(u)&&(t=!0),t?(n=-s,i=o,a=Math.sqrt(c)):(n=o,i=s,a=Math.sqrt(c/2))}return new sr(n/a,i/a)}const I=[];for(let t=0,e=E.length,r=e-1,n=t+1;t=0;t--){const e=t/f,r=c*Math.cos(e*Math.PI/2),n=h*Math.sin(e*Math.PI/2)+d;for(let t=0,e=E.length;t=0;){const n=r;let i=r-1;i<0&&(i=t.length-1);for(let t=0,r=s+2*f;t0)&&d.push(e,i,l),(t!==r-1||s0!=t>0&&this.version++,this._sheen=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}Pc.prototype.isMeshPhysicalMaterial=!0;class Cc extends zn{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new Xn(16777215),this.specular=new Xn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=je,this.normalScale=new sr(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=j,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this}}Cc.prototype.isMeshPhongMaterial=!0;class Ic extends zn{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Xn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=je,this.normalScale=new sr(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Ic.prototype.isMeshToonMaterial=!0;class Lc extends zn{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=je,this.normalScale=new sr(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}Lc.prototype.isMeshNormalMaterial=!0;class Oc extends zn{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new Xn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=j,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Oc.prototype.isMeshLambertMaterial=!0;class Dc extends zn{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Xn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=je,this.normalScale=new sr(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this}}Dc.prototype.isMeshMatcapMaterial=!0;class kc extends Ul{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}kc.prototype.isLineDashedMaterial=!0;var Fc=Object.freeze({__proto__:null,ShadowMaterial:Ac,SpriteMaterial:rl,RawShaderMaterial:da,ShaderMaterial:Bi,PointsMaterial:Zl,MeshPhysicalMaterial:Pc,MeshStandardMaterial:Rc,MeshPhongMaterial:Cc,MeshToonMaterial:Ic,MeshNormalMaterial:Lc,MeshLambertMaterial:Oc,MeshDepthMaterial:Os,MeshDistanceMaterial:Ds,MeshBasicMaterial:Yn,MeshMatcapMaterial:Dc,LineDashedMaterial:kc,LineBasicMaterial:Ul,Material:zn});const Nc={arraySlice:function(t,e,r){return Nc.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,r=new Array(e);for(let t=0;t!==e;++t)r[t]=t;return r.sort((function(e,r){return t[e]-t[r]})),r},sortedArray:function(t,e,r){const n=t.length,i=new t.constructor(n);for(let a=0,o=0;o!==n;++a){const n=r[a]*e;for(let r=0;r!==e;++r)i[o++]=t[n+r]}return i},flattenJSON:function(t,e,r,n){let i=1,a=t[0];for(;void 0!==a&&void 0===a[n];)a=t[i++];if(void 0===a)return;let o=a[n];if(void 0!==o)if(Array.isArray(o))do{o=a[n],void 0!==o&&(e.push(a.time),r.push.apply(r,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{o=a[n],void 0!==o&&(e.push(a.time),o.toArray(r,r.length)),a=t[i++]}while(void 0!==a);else do{o=a[n],void 0!==o&&(e.push(a.time),r.push(o)),a=t[i++]}while(void 0!==a)},subclip:function(t,e,r,n,i=30){const a=t.clone();a.name=e;const o=[];for(let t=0;t=n)){l.push(e.times[t]);for(let r=0;ra.tracks[t].times[0]&&(s=a.tracks[t].times[0]);for(let t=0;t=n.times[h]){const t=h*l+s,e=t+l-s;d=Nc.arraySlice(n.values,t,e)}else{const t=n.createInterpolant(),e=s,r=l-s;t.evaluate(a),d=Nc.arraySlice(t.resultBuffer,e,r)}if("quaternion"===i){(new Mr).fromArray(d).normalize().conjugate().toArray(d)}const f=o.times.length;for(let t=0;t=i)break t;{const o=e[1];t=i)break e}a=r,r=0}}for(;r>>1;te;)--a;if(++a,0!==i||a!==n){i>=a&&(a=Math.max(a,1),i=a-1);const t=this.getValueSize();this.times=Nc.arraySlice(r,i,a),this.values=Nc.arraySlice(this.values,i*t,a*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const r=this.times,n=this.values,i=r.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let e=0;e!==i;e++){const n=r[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==a&&a>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,a),t=!1;break}a=n}if(void 0!==n&&Nc.isTypedArray(n))for(let e=0,r=n.length;e!==r;++e){const r=n[e];if(isNaN(r)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,r),t=!1;break}}return t}optimize(){const t=Nc.arraySlice(this.times),e=Nc.arraySlice(this.values),r=this.getValueSize(),n=this.getInterpolation()===Ae,i=t.length-1;let a=1;for(let o=1;o0){t[a]=t[i];for(let t=i*r,n=a*r,o=0;o!==r;++o)e[n+o]=e[t+o];++a}return a!==t.length?(this.times=Nc.arraySlice(t,0,a),this.values=Nc.arraySlice(e,0,a*r)):(this.times=t,this.values=e),this}clone(){const t=Nc.arraySlice(this.times,0),e=Nc.arraySlice(this.values,0),r=new(0,this.constructor)(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}}jc.prototype.TimeBufferType=Float32Array,jc.prototype.ValueBufferType=Float32Array,jc.prototype.DefaultInterpolation=Ee;class Vc extends jc{}Vc.prototype.ValueTypeName="bool",Vc.prototype.ValueBufferType=Array,Vc.prototype.DefaultInterpolation=Te,Vc.prototype.InterpolantFactoryMethodLinear=void 0,Vc.prototype.InterpolantFactoryMethodSmooth=void 0;class Hc extends jc{}Hc.prototype.ValueTypeName="color";class Wc extends jc{}Wc.prototype.ValueTypeName="number";class qc extends Uc{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(r-e)/(n-e);let l=t*o;for(let t=l+o;l!==t;l+=4)Mr.slerpFlat(i,0,a,l-o,a,l,s);return i}}class Xc extends jc{InterpolantFactoryMethodLinear(t){return new qc(this.times,this.values,this.getValueSize(),t)}}Xc.prototype.ValueTypeName="quaternion",Xc.prototype.DefaultInterpolation=Ee,Xc.prototype.InterpolantFactoryMethodSmooth=void 0;class Yc extends jc{}Yc.prototype.ValueTypeName="string",Yc.prototype.ValueBufferType=Array,Yc.prototype.DefaultInterpolation=Te,Yc.prototype.InterpolantFactoryMethodLinear=void 0,Yc.prototype.InterpolantFactoryMethodSmooth=void 0;class Zc extends jc{}Zc.prototype.ValueTypeName="vector";class Kc{constructor(t,e=-1,r,n=2500){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=$e(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],r=t.tracks,n=1/(t.fps||1);for(let t=0,i=r.length;t!==i;++t)e.push(Jc(r[t]).scale(n));const i=new this(t.name,t.duration,e,t.blendMode);return i.uuid=t.uuid,i}static toJSON(t){const e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=r.length;t!==n;++t)e.push(jc.toJSON(r[t]));return n}static CreateFromMorphTargetSequence(t,e,r,n){const i=e.length,a=[];for(let t=0;t1){const t=a[1];let e=n[t];e||(n[t]=e=[]),e.push(r)}}const a=[];for(const t in n)a.push(this.CreateFromMorphTargetSequence(t,n[t],e,r));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const r=function(t,e,r,n,i){if(0!==r.length){const a=[],o=[];Nc.flattenJSON(r,a,o,n),0!==a.length&&i.push(new t(e,a,o))}},n=[],i=t.name||"default",a=t.fps||30,o=t.blendMode;let s=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(i),this.manager.itemEnd(t)}),0),i;if(void 0!==rh[t])return void rh[t].push({onLoad:e,onProgress:r,onError:n});rh[t]=[],rh[t].push({onLoad:e,onProgress:r,onError:n});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});fetch(a).then((e=>{if(200===e.status||0===e.status){0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");const r=rh[t],n=e.body.getReader(),i=e.headers.get("Content-Length"),a=i?parseInt(i):0,o=0!==a;let s=0;return new ReadableStream({start(t){!function e(){n.read().then((({done:n,value:i})=>{if(n)t.close();else{s+=i.byteLength;const n=new ProgressEvent("progress",{lengthComputable:o,loaded:s,total:a});for(let t=0,e=r.length;t{const e=new Response(t);switch(this.responseType){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((t=>(new DOMParser).parseFromString(t,this.mimeType)));case"json":return e.json();default:return e.text()}})).then((e=>{Qc.add(t,e);const r=rh[t];delete rh[t];for(let t=0,n=r.length;t{const r=rh[t];delete rh[t];for(let t=0,n=r.length;t0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const i=t.uniforms[e];switch(n.uniforms[e]={},i.type){case"t":n.uniforms[e].value=r(i.value);break;case"c":n.uniforms[e].value=(new Xn).setHex(i.value);break;case"v2":n.uniforms[e].value=(new sr).fromArray(i.value);break;case"v3":n.uniforms[e].value=(new Sr).fromArray(i.value);break;case"v4":n.uniforms[e].value=(new xr).fromArray(i.value);break;case"m3":n.uniforms[e].value=(new lr).fromArray(i.value);break;case"m4":n.uniforms[e].value=(new en).fromArray(i.value);break;default:n.uniforms[e].value=i.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(n.flatShading=1===t.shading),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=r(t.map)),void 0!==t.matcap&&(n.matcap=r(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=r(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=r(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=r(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new sr).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=r(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=r(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=r(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=r(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=r(t.specularMap)),void 0!==t.specularIntensityMap&&(n.specularIntensityMap=r(t.specularIntensityMap)),void 0!==t.specularColorMap&&(n.specularColorMap=r(t.specularColorMap)),void 0!==t.envMap&&(n.envMap=r(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=r(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=r(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=r(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=r(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=r(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=r(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new sr).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(n.transmissionMap=r(t.transmissionMap)),void 0!==t.thicknessMap&&(n.thicknessMap=r(t.thicknessMap)),void 0!==t.sheenColorMap&&(n.sheenColorMap=r(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(n.sheenRoughnessMap=r(t.sheenRoughnessMap)),n}setTextures(t){return this.textures=t,this}}class Rh{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let r=0,n=t.length;r0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let t=e,i=e+e;t!==i;++t)if(r[t]!==r[t+e]){o.setValue(r,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let t=r,i=n;t!==i;++t)e[t]=e[n+t%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r=.5)for(let n=0;n!==i;++n)t[e+n]=t[r+n]}_slerp(t,e,r,n){Mr.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,i){const a=this._workIndex*i;Mr.multiplyQuaternionsFlat(t,a,t,e,t,r),Mr.slerpFlat(t,e,t,e,t,a,n)}_lerp(t,e,r,n,i){const a=1-n;for(let o=0;o!==i;++o){const i=e+o;t[i]=t[i]*a+t[r+o]*n}}_lerpAdditive(t,e,r,n,i){for(let a=0;a!==i;++a){const i=e+a;t[i]=t[i]+t[r+a]*n}}}const rd="\\[\\]\\.:\\/",nd=new RegExp("["+rd+"]","g"),id="[^"+rd+"]",ad="[^"+rd.replace("\\.","")+"]",od=/((?:WC+[\/:])*)/.source.replace("WC",id),sd=/(WCOD+)?/.source.replace("WCOD",ad),ld=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",id),ud=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",id),cd=new RegExp("^"+od+sd+ld+ud+"$"),hd=["material","materials","bones"];class dd{constructor(t,e,r){this.path=e,this.parsedPath=r||dd.parseTrackName(e),this.node=dd.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new dd.Composite(t,e,r):new dd(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(nd,"")}static parseTrackName(t){const e=cd.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=r.nodeName.substring(n+1);-1!==hd.indexOf(t)&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=t)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const r=t.skeleton.getBoneByName(e);if(void 0!==r)return r}if(t.children){const r=function(t){for(let n=0;n=i){const a=i++,u=t[a];e[u.uuid]=l,t[l]=u,e[s]=a,t[a]=o;for(let t=0,e=n;t!==e;++t){const e=r[t],n=e[a],i=e[l];e[l]=n,e[a]=i}}}this.nCachedObjects_=i}uncache(){const t=this._objects,e=this._indicesByUUID,r=this._bindings,n=r.length;let i=this.nCachedObjects_,a=t.length;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o].uuid,l=e[s];if(void 0!==l)if(delete e[s],l0&&(e[o.uuid]=l),t[l]=o,t.pop();for(let t=0,e=n;t!==e;++t){const e=r[t];e[l]=e[i],e.pop()}}}this.nCachedObjects_=i}subscribe_(t,e){const r=this._bindingsIndicesByPath;let n=r[t];const i=this._bindings;if(void 0!==n)return i[n];const a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,u=this.nCachedObjects_,c=new Array(l);n=i.length,r[t]=n,a.push(t),o.push(e),i.push(c);for(let r=u,n=s.length;r!==n;++r){const n=s[r];c[r]=new dd(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,r=e[t];if(void 0!==r){const n=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];e[t[o]]=r,a[r]=s,a.pop(),i[r]=i[o],i.pop(),n[r]=n[o],n.pop()}}}fd.prototype.isAnimationObjectGroup=!0;class pd{constructor(t,e,r=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=n;const i=e.tracks,a=i.length,o=new Array(a),s={endingStart:Re,endingEnd:Re};for(let t=0;t!==a;++t){const e=i[t].createInterpolant(null);o[t]=e,e.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){const r=this._clip.duration,n=t._clip.duration,i=n/r,a=r/n;t.warp(1,i,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){const n=this._mixer,i=n.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const s=o.parameterPositions,l=o.sampleValues;return s[0]=i,s[1]=i+r,l[0]=t/a,l[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,n){if(!this.enabled)return void this._updateWeight(t);const i=this._startTime;if(null!==i){const n=(t-i)*r;if(n<0||0===r)return;this._startTime=null,e=r*n}e*=this._updateTimeScale(t);const a=this._updateTime(e),o=this._updateWeight(t);if(o>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Le)for(let r=0,n=t.length;r!==n;++r)t[r].evaluate(a),e[r].accumulateAdditive(o);else for(let r=0,i=t.length;r!==i;++r)t[r].evaluate(a),e[r].accumulate(n,o)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const r=this._weightInterpolant;if(null!==r){const n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const r=this._timeScaleInterpolant;if(null!==r){e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,r=this.loop;let n=this.time+t,i=this._loopCount;const a=2202===r;if(0===t)return-1===i?n:a&&1==(1&i)?e-n:n;if(2200===r){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),n>=e||n<0){const r=Math.floor(n/e);n-=e*r,i+=Math.abs(r);const o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===o){const e=t<0;this._setEndings(e,!e,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})}}else this.time=n;if(a&&1==(1&i))return e-n}return n}_setEndings(t,e,r){const n=this._interpolantSettings;r?(n.endingStart=Pe,n.endingEnd=Pe):(n.endingStart=t?this.zeroSlopeAtStart?Pe:Re:Ce,n.endingEnd=e?this.zeroSlopeAtEnd?Pe:Re:Ce)}_scheduleFading(t,e,r){const n=this._mixer,i=n.time;let a=this._weightInterpolant;null===a&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=r,this}}class md extends Ye{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,a=t._propertyBindings,o=t._interpolants,s=r.uuid,l=this._bindingsByRootAndName;let u=l[s];void 0===u&&(u={},l[s]=u);for(let t=0;t!==i;++t){const i=n[t],l=i.name;let c=u[l];if(void 0!==c)a[t]=c;else{if(c=a[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,s,l));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new ed(dd.create(r,l,n),i.ValueTypeName,i.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,s,l),a[t]=c}o[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}const e=t._propertyBindings;for(let t=0,r=e.length;t!==r;++t){const r=e[t];0==r.useCount++&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,r=e.length;t!==r;++t){const r=e[t];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,r=this._nActiveActions,n=this.time+=t,i=Math.sign(t),a=this._accuIndex^=1;for(let o=0;o!==r;++o){e[o]._update(n,t,i,a)}const o=this._bindings,s=this._nActiveBindings;for(let t=0;t!==s;++t)o[t].apply(a);return this}setTime(t){this.time=0;for(let t=0;tthis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return bd.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Md.prototype.isBox2=!0;const Sd=new Sr,Td=new Sr;class Ed{constructor(t=new Sr,e=new Sr){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Sd.subVectors(t,this.start),Td.subVectors(this.end,this.start);const r=Td.dot(Td);let n=Td.dot(Sd)/r;return e&&(n=tr(n,0,1)),n}closestPointToPoint(t,e,r){const n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Ad=new Sr;const Rd=new Sr,Pd=new en,Cd=new en;class Id extends Xl{constructor(t){const e=Ld(t),r=new mi,n=[],i=[],a=new Xn(0,0,1),o=new Xn(0,1,0);for(let t=0;t.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Wd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Wd,e)}}setLength(t,e=.2*t,r=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}},Audio:Zh,AudioAnalyser:td,AudioContext:Fh,AudioListener:class extends An{constructor(){super(),this.type="AudioListener",this.context=Fh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Vh}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,r=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Wh,qh,Xh),Yh.set(0,0,-1).applyQuaternion(qh),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Wh.x,t),e.positionY.linearRampToValueAtTime(Wh.y,t),e.positionZ.linearRampToValueAtTime(Wh.z,t),e.forwardX.linearRampToValueAtTime(Yh.x,t),e.forwardY.linearRampToValueAtTime(Yh.y,t),e.forwardZ.linearRampToValueAtTime(Yh.z,t),e.upX.linearRampToValueAtTime(r.x,t),e.upY.linearRampToValueAtTime(r.y,t),e.upZ.linearRampToValueAtTime(r.z,t)}else e.setPosition(Wh.x,Wh.y,Wh.z),e.setOrientation(Yh.x,Yh.y,Yh.z,r.x,r.y,r.z)}},AudioLoader:Nh,AxesHelper:Yd,AxisHelper:function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Yd(t)},BackSide:c,BasicDepthPacking:3200,BasicShadowMap:0,BinaryTextureLoader:function(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new oh(t)},Bone:Al,BooleanKeyframeTrack:Vc,BoundingBoxHelper:function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Hd(t,e)},Box2:Md,Box3:Ar,Box3Helper:class extends Xl{constructor(t,e=16776960){const r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new mi;n.setIndex(new Jn(r,1)),n.setAttribute("position",new oi([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new Ul({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}},BoxBufferGeometry:ki,BoxGeometry:ki,BoxHelper:Hd,BufferAttribute:Jn,BufferGeometry:mi,BufferGeometryLoader:Ch,ByteType:pt,Cache:Qc,Camera:zi,CameraHelper:class extends Xl{constructor(t){const e=new mi,r=new Ul({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],i=[],a={},o=new Xn(16755200),s=new Xn(16711680),l=new Xn(43775),u=new Xn(16777215),c=new Xn(3355443);function h(t,e,r){d(t,r),d(e,r)}function d(t,e){n.push(0,0,0),i.push(e.r,e.g,e.b),void 0===a[t]&&(a[t]=[]),a[t].push(n.length/3-1)}h("n1","n2",o),h("n2","n4",o),h("n4","n3",o),h("n3","n1",o),h("f1","f2",o),h("f2","f4",o),h("f4","f3",o),h("f3","f1",o),h("n1","f1",o),h("n2","f2",o),h("n3","f3",o),h("n4","f4",o),h("p","n1",s),h("p","n2",s),h("p","n3",s),h("p","n4",s),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",u),h("p","c",c),h("cn1","cn2",c),h("cn3","cn4",c),h("cf1","cf2",c),h("cf3","cf4",c),e.setAttribute("position",new oi(n,3)),e.setAttribute("color",new oi(i,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){const t=this.geometry,e=this.pointMap;Gd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),jd("c",e,t,Gd,0,0,-1),jd("t",e,t,Gd,0,0,1),jd("n1",e,t,Gd,-1,-1,-1),jd("n2",e,t,Gd,1,-1,-1),jd("n3",e,t,Gd,-1,1,-1),jd("n4",e,t,Gd,1,1,-1),jd("f1",e,t,Gd,-1,-1,1),jd("f2",e,t,Gd,1,-1,1),jd("f3",e,t,Gd,-1,1,1),jd("f4",e,t,Gd,1,1,1),jd("u1",e,t,Gd,.7,1.1,-1),jd("u2",e,t,Gd,-.7,1.1,-1),jd("u3",e,t,Gd,0,2,-1),jd("cf1",e,t,Gd,-1,0,1),jd("cf2",e,t,Gd,1,0,1),jd("cf3",e,t,Gd,0,-1,1),jd("cf4",e,t,Gd,0,1,1),jd("cn1",e,t,Gd,-1,0,-1),jd("cn2",e,t,Gd,1,0,-1),jd("cn3",e,t,Gd,0,-1,-1),jd("cn4",e,t,Gd,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasRenderer:function(){console.error("THREE.CanvasRenderer has been removed")},CanvasTexture:iu,CatmullRomCurve3:Mu,CineonToneMapping:Y,CircleBufferGeometry:au,CircleGeometry:au,ClampToEdgeWrapping:at,Clock:Vh,Color:Xn,ColorKeyframeTrack:Hc,CompressedTexture:nu,CompressedTextureLoader:class extends eh{constructor(t){super(t)}load(t,e,r,n){const i=this,a=[],o=new nu,s=new nh(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let l=0;function u(u){s.load(t[u],(function(t){const r=i.parse(t,!0);a[u]={width:r.width,height:r.height,format:r.format,mipmaps:r.mipmaps},l+=1,6===l&&(1===r.mipmapCount&&(o.minFilter=ct),o.image=a,o.format=r.format,o.needsUpdate=!0,e&&e(o))}),r,n)}if(Array.isArray(t))for(let e=0,r=t.length;e65504&&(console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."),t=65504),Zd[0]=t;const e=Kd[0];let r=e>>16&32768,n=e>>12&2047;const i=e>>23&255;return i<103?r:i>142?(r|=31744,r|=(255==i?0:1)&&8388607&e,r):i<113?(n|=2048,r|=(n>>114-i)+(n>>113-i&1),r):(r|=i-112<<10|n>>1,r+=1&n,r)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:th,DepthFormat:It,DepthStencilFormat:Lt,DepthTexture:Ws,DirectionalLight:bh,DirectionalLightHelper:class extends An{constructor(t,e,r){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,void 0===e&&(e=1);let n=new mi;n.setAttribute("position",new oi([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const i=new Ul({fog:!1,toneMapped:!1});this.lightPlane=new Hl(n,i),this.add(this.lightPlane),n=new mi,n.setAttribute("position",new oi([0,0,0,0,0,1],3)),this.targetLine=new Hl(n,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){Nd.setFromMatrixPosition(this.light.matrixWorld),Ud.setFromMatrixPosition(this.light.target.matrixWorld),Bd.subVectors(Ud,Nd),this.lightPlane.lookAt(Ud),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Ud),this.targetLine.scale.z=Bd.length()}},DiscreteInterpolant:Gc,DodecahedronBufferGeometry:uu,DodecahedronGeometry:uu,DoubleSide:h,DstAlphaFactor:P,DstColorFactor:I,DynamicBufferAttribute:function(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new Jn(t,e).setUsage(qe)},DynamicCopyUsage:35050,DynamicDrawUsage:qe,DynamicReadUsage:35049,EdgesGeometry:pu,EdgesHelper:function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Xl(new pu(t.geometry),new Ul({color:void 0!==e?e:16777215}))},EllipseCurve:gu,EqualDepth:U,EqualStencilFunc:514,EquirectangularReflectionMapping:tt,EquirectangularRefractionMapping:et,Euler:dn,EventDispatcher:Ye,ExtrudeBufferGeometry:dc,ExtrudeGeometry:dc,FaceColors:1,FileLoader:nh,FlatShading:1,Float16BufferAttribute:ai,Float32Attribute:function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new oi(t,e)},Float32BufferAttribute:oi,Float64Attribute:function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new si(t,e)},Float64BufferAttribute:si,FloatType:xt,Fog:Js,FogExp2:Ks,Font:function(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")},FontLoader:function(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")},FrontSide:u,Frustum:Qi,GLBufferAttribute:yd,GLSL1:"100",GLSL3:Xe,GammaEncoding:Fe,GreaterDepth:z,GreaterEqualDepth:B,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:Fd,Group:js,HalfFloatType:_t,HemisphereLight:uh,HemisphereLightHelper:class extends An{constructor(t,e,r){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r;const n=new gc(e);n.rotateY(.5*Math.PI),this.material=new Yn({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=n.getAttribute("position"),a=new Float32Array(3*i.count);n.setAttribute("color",new Jn(a,3)),this.add(new Oi(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Dd.copy(this.light.color),kd.copy(this.light.groundColor);for(let t=0,r=e.count;t0){const r=new $c(e);i=new ih(r),i.setCrossOrigin(this.crossOrigin);for(let e=0,r=t.length;e0){n=new ih(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;eNumber.EPSILON){if(l<0&&(r=e[a],s=-s,o=e[i],l=-l),t.yo.y)continue;if(t.y===r.y){if(t.x===r.x)return!0}else{const e=l*(t.x-r.x)-s*(t.y-r.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==r.y)continue;if(o.x<=t.x&&t.x<=r.x||r.x<=t.x&&t.x<=o.x)return!0}}return n}const i=uc.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return r(a);let o,s,l;const u=[];if(1===a.length)return s=a[0],l=new Nu,l.curves=s.curves,u.push(l),u;let c=!i(a[0].getPoints());c=t?!c:c;const h=[],d=[];let f,p,m=[],g=0;d[g]=void 0,m[g]=[];for(let e=0,r=a.length;e1){let t=!1;const e=[];for(let t=0,e=d.length;t0&&(t||(m=h))}for(let t=0,e=d.length;tMath.PI&&(g-=m),v<-Math.PI?v+=m:v>Math.PI&&(v-=m),l.theta=g<=v?Math.max(g,Math.min(v,l.theta)):l.theta>(g+v)/2?Math.max(g,l.theta):Math.min(v,l.theta)),l.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,l.phi)),l.makeSafe(),l.radius*=c,l.radius=Math.max(i.minDistance,Math.min(i.maxDistance,l.radius)),!0===i.enableDamping?i.target.addScaledVector(h,i.dampingFactor):i.target.add(h),e.setFromSpherical(l),e.applyQuaternion(n),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(u.theta*=1-i.dampingFactor,u.phi*=1-i.dampingFactor,h.multiplyScalar(1-i.dampingFactor)):(u.set(0,0,0),h.set(0,0,0)),c=1,!!(d||f.distanceToSquared(i.object.position)>s||8*(1-p.dot(i.object.quaternion))>s)&&(i.dispatchEvent($d),f.copy(i.object.position),p.copy(i.object.quaternion),d=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",q),i.domElement.removeEventListener("pointerdown",z),i.domElement.removeEventListener("pointercancel",V),i.domElement.removeEventListener("wheel",H),i.domElement.removeEventListener("pointermove",G),i.domElement.removeEventListener("pointerup",j),null!==i._domElementKeyEvents&&i._domElementKeyEvents.removeEventListener("keydown",W)};const i=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let o=a.NONE;const s=1e-6,l=new wd,u=new wd;let c=1;const h=new Sr;let d=!1;const f=new sr,p=new sr,m=new sr,g=new sr,v=new sr,y=new sr,x=new sr,_=new sr,w=new sr,b=[],M={};function S(){return Math.pow(.95,i.zoomSpeed)}function T(t){u.theta-=t}function E(t){u.phi-=t}const A=function(){const t=new Sr;return function(e,r){t.setFromMatrixColumn(r,0),t.multiplyScalar(-e),h.add(t)}}(),R=function(){const t=new Sr;return function(e,r){!0===i.screenSpacePanning?t.setFromMatrixColumn(r,1):(t.setFromMatrixColumn(r,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),h.add(t)}}(),P=function(){const t=new Sr;return function(e,r){const n=i.domElement;if(i.object.isPerspectiveCamera){const a=i.object.position;t.copy(a).sub(i.target);let o=t.length();o*=Math.tan(i.object.fov/2*Math.PI/180),A(2*e*o/n.clientHeight,i.object.matrix),R(2*r*o/n.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(A(e*(i.object.right-i.object.left)/i.object.zoom/n.clientWidth,i.object.matrix),R(r*(i.object.top-i.object.bottom)/i.object.zoom/n.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function C(t){i.object.isPerspectiveCamera?c/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),d=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function I(t){i.object.isPerspectiveCamera?c*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),d=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function L(t){f.set(t.clientX,t.clientY)}function O(t){g.set(t.clientX,t.clientY)}function D(){if(1===b.length)f.set(b[0].pageX,b[0].pageY);else{const t=.5*(b[0].pageX+b[1].pageX),e=.5*(b[0].pageY+b[1].pageY);f.set(t,e)}}function k(){if(1===b.length)g.set(b[0].pageX,b[0].pageY);else{const t=.5*(b[0].pageX+b[1].pageX),e=.5*(b[0].pageY+b[1].pageY);g.set(t,e)}}function F(){const t=b[0].pageX-b[1].pageX,e=b[0].pageY-b[1].pageY,r=Math.sqrt(t*t+e*e);x.set(0,r)}function N(t){if(1==b.length)p.set(t.pageX,t.pageY);else{const e=Z(t),r=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);p.set(r,n)}m.subVectors(p,f).multiplyScalar(i.rotateSpeed);const e=i.domElement;T(2*Math.PI*m.x/e.clientHeight),E(2*Math.PI*m.y/e.clientHeight),f.copy(p)}function U(t){if(1===b.length)v.set(t.pageX,t.pageY);else{const e=Z(t),r=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);v.set(r,n)}y.subVectors(v,g).multiplyScalar(i.panSpeed),P(y.x,y.y),g.copy(v)}function B(t){const e=Z(t),r=t.pageX-e.x,n=t.pageY-e.y,a=Math.sqrt(r*r+n*n);_.set(0,a),w.set(0,Math.pow(_.y/x.y,i.zoomSpeed)),C(w.y),x.copy(_)}function z(t){!1!==i.enabled&&(0===b.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",G),i.domElement.addEventListener("pointerup",j)),function(t){b.push(t)}(t),"touch"===t.pointerType?function(t){switch(Y(t),b.length){case 1:switch(i.touches.ONE){case r.ROTATE:if(!1===i.enableRotate)return;D(),o=a.TOUCH_ROTATE;break;case r.PAN:if(!1===i.enablePan)return;k(),o=a.TOUCH_PAN;break;default:o=a.NONE}break;case 2:switch(i.touches.TWO){case r.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&F(),i.enablePan&&k(),o=a.TOUCH_DOLLY_PAN;break;case r.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&F(),i.enableRotate&&D(),o=a.TOUCH_DOLLY_ROTATE;break;default:o=a.NONE}break;default:o=a.NONE}o!==a.NONE&&i.dispatchEvent(tf)}(t):function(t){let r;switch(t.button){case 0:r=i.mouseButtons.LEFT;break;case 1:r=i.mouseButtons.MIDDLE;break;case 2:r=i.mouseButtons.RIGHT;break;default:r=-1}switch(r){case e.DOLLY:if(!1===i.enableZoom)return;!function(t){x.set(t.clientX,t.clientY)}(t),o=a.DOLLY;break;case e.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;O(t),o=a.PAN}else{if(!1===i.enableRotate)return;L(t),o=a.ROTATE}break;case e.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;L(t),o=a.ROTATE}else{if(!1===i.enablePan)return;O(t),o=a.PAN}break;default:o=a.NONE}o!==a.NONE&&i.dispatchEvent(tf)}(t))}function G(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(Y(t),o){case a.TOUCH_ROTATE:if(!1===i.enableRotate)return;N(t),i.update();break;case a.TOUCH_PAN:if(!1===i.enablePan)return;U(t),i.update();break;case a.TOUCH_DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&B(t),i.enablePan&&U(t)}(t),i.update();break;case a.TOUCH_DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&B(t),i.enableRotate&&N(t)}(t),i.update();break;default:o=a.NONE}}(t):function(t){if(!1===i.enabled)return;switch(o){case a.ROTATE:if(!1===i.enableRotate)return;!function(t){p.set(t.clientX,t.clientY),m.subVectors(p,f).multiplyScalar(i.rotateSpeed);const e=i.domElement;T(2*Math.PI*m.x/e.clientHeight),E(2*Math.PI*m.y/e.clientHeight),f.copy(p),i.update()}(t);break;case a.DOLLY:if(!1===i.enableZoom)return;!function(t){_.set(t.clientX,t.clientY),w.subVectors(_,x),w.y>0?C(S()):w.y<0&&I(S()),x.copy(_),i.update()}(t);break;case a.PAN:if(!1===i.enablePan)return;!function(t){v.set(t.clientX,t.clientY),y.subVectors(v,g).multiplyScalar(i.panSpeed),P(y.x,y.y),g.copy(v),i.update()}(t)}}(t))}function j(t){X(t),0===b.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",G),i.domElement.removeEventListener("pointerup",j)),i.dispatchEvent(ef),o=a.NONE}function V(t){X(t)}function H(t){!1!==i.enabled&&!1!==i.enableZoom&&o===a.NONE&&(t.preventDefault(),i.dispatchEvent(tf),function(t){t.deltaY<0?I(S()):t.deltaY>0&&C(S()),i.update()}(t),i.dispatchEvent(ef))}function W(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:P(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:P(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:P(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:P(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function q(t){!1!==i.enabled&&t.preventDefault()}function X(t){delete M[t.pointerId];for(let e=0;e=this.text.length)return;t=this.text[this.place++]}switch(this.state){case cp:return this.neutral(t);case 2:return this.keyword(t);case 4:return this.quoted(t);case 5:return this.afterquote(t);case 3:return this.number(t);case-1:return}},gp.prototype.afterquote=function(t){if('"'===t)return this.word+='"',void(this.state=4);if(pp.test(t))return this.word=this.word.trim(),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in afterquote yet, index '+this.place)},gp.prototype.afterItem=function(t){return","===t?(null!==this.word&&this.currentObject.push(this.word),this.word=null,void(this.state=cp)):"]"===t?(this.level--,null!==this.word&&(this.currentObject.push(this.word),this.word=null),this.state=cp,this.currentObject=this.stack.pop(),void(this.currentObject||(this.state=-1))):void 0},gp.prototype.number=function(t){if(!mp.test(t)){if(pp.test(t))return this.word=parseFloat(this.word),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in number yet, index '+this.place)}this.word+=t},gp.prototype.quoted=function(t){'"'!==t?this.word+=t:this.state=5},gp.prototype.keyword=function(t){if(fp.test(t))this.word+=t;else{if("["===t){var e=[];return e.push(this.word),this.level++,null===this.root?this.root=e:this.currentObject.push(e),this.stack.push(this.currentObject),this.currentObject=e,void(this.state=cp)}if(!pp.test(t))throw new Error("havn't handled \""+t+'" in keyword yet, index '+this.place);this.afterItem(t)}},gp.prototype.neutral=function(t){if(dp.test(t))return this.word=t,void(this.state=2);if('"'===t)return this.word="",void(this.state=4);if(mp.test(t))return this.word=t,void(this.state=3);if(!pp.test(t))throw new Error("havn't handled \""+t+'" in neutral yet, index '+this.place);this.afterItem(t)},gp.prototype.output=function(){for(;this.place0?90:-90),t.lat_ts=t.lat1)}(i),i}function Mp(t){var e=this;if(2===arguments.length){var r=arguments[1];"string"==typeof r?"+"===r.charAt(0)?Mp[t]=up(arguments[1]):Mp[t]=bp(arguments[1]):Mp[t]=r}else if(1===arguments.length){if(Array.isArray(t))return t.map((function(t){Array.isArray(t)?Mp.apply(e,t):Mp(t)}));if("string"==typeof t){if(t in Mp)return Mp[t]}else"EPSG"in t?Mp["EPSG:"+t.EPSG]=t:"ESRI"in t?Mp["ESRI:"+t.ESRI]=t:"IAU2000"in t?Mp["IAU2000:"+t.IAU2000]=t:console.log(t);return}}(xp=Mp)("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),xp("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),xp("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"),xp.WGS84=xp["EPSG:4326"],xp["EPSG:3785"]=xp["EPSG:3857"],xp.GOOGLE=xp["EPSG:3857"],xp["EPSG:900913"]=xp["EPSG:3857"],xp["EPSG:102113"]=xp["EPSG:3857"];var Sp=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];var Tp=["3857","900913","3785","102113"];function Ep(t){if(!function(t){return"string"==typeof t}(t))return t;if(function(t){return t in Mp}(t))return Mp[t];if(function(t){return Sp.some((function(e){return t.indexOf(e)>-1}))}(t)){var e=bp(t);if(function(t){var e=lp(t,"authority");if(e){var r=lp(e,"epsg");return r&&Tp.indexOf(r)>-1}}(e))return Mp["EPSG:3857"];var r=function(t){var e=lp(t,"extension");if(e)return lp(e,"proj4")}(e);return r?up(r):e}return function(t){return"+"===t[0]}(t)?up(t):void 0}function Ap(t,e){var r,n;if(t=t||{},!e)return t;for(n in e)void 0!==(r=e[n])&&(t[n]=r);return t}function Rp(t,e,r){var n=t*e;return r/Math.sqrt(1-n*n)}function Pp(t){return t<0?-1:1}function Cp(t){return Math.abs(t)<=ip?t:t-Pp(t)*np}function Ip(t,e,r){var n=t*r,i=.5*t;return n=Math.pow((1-n)/(1+n),i),Math.tan(.5*(Zf-e))/n}function Lp(t,e){for(var r,n,i=.5*t,a=Zf-2*Math.atan(e),o=0;o<=15;o++)if(r=t*Math.sin(a),a+=n=Zf-2*Math.atan(e*Math.pow((1-r)/(1+r),i))-a,Math.abs(n)<=1e-10)return a;return-9999}function Op(t){return t}var Dp=[{init:function(){var t=this.b/this.a;this.es=1-t*t,"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=Rp(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)},forward:function(t){var e,r,n=t.x,i=t.y;if(i*ep>90&&i*ep<-90&&n*ep>180&&n*ep<-180)return null;if(Math.abs(Math.abs(i)-Zf)<=$f)return null;if(this.sphere)e=this.x0+this.a*this.k0*Cp(n-this.long0),r=this.y0+this.a*this.k0*Math.log(Math.tan(rp+.5*i));else{var a=Math.sin(i),o=Ip(this.e,i,a);e=this.x0+this.a*this.k0*Cp(n-this.long0),r=this.y0-this.a*this.k0*Math.log(o)}return t.x=e,t.y=r,t},inverse:function(t){var e,r,n=t.x-this.x0,i=t.y-this.y0;if(this.sphere)r=Zf-2*Math.atan(Math.exp(-i/(this.a*this.k0)));else{var a=Math.exp(-i/(this.a*this.k0));if(-9999===(r=Lp(this.e,a)))return null}return e=Cp(this.long0+n/(this.a*this.k0)),t.x=e,t.y=r,t},names:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"]},{init:function(){},forward:Op,inverse:Op,names:["longlat","identity"]}],kp={},Fp=[];function Np(t,e){var r=Fp.length;return t.names?(Fp[r]=t,t.names.forEach((function(t){kp[t.toLowerCase()]=r})),this):(console.log(e),!0)}const Up={start:function(){Dp.forEach(Np)},add:Np,get:function(t){if(!t)return!1;var e=t.toLowerCase();return void 0!==kp[e]&&Fp[kp[e]]?Fp[kp[e]]:void 0}};var Bp={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."},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"}},zp=Bp.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};Bp.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};var Gp={};Gp.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},Gp.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},Gp.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},Gp.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},Gp.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},Gp.potsdam={towgs84:"598.1,73.7,418.2,0.202,0.045,-2.455,6.7",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},Gp.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},Gp.hermannskogel={towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Hermannskogel"},Gp.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},Gp.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},Gp.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},Gp.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},Gp.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"},Gp.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},Gp.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},Gp.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},Gp.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};var jp={};function Vp(t){if(0===t.length)return null;var e="@"===t[0];return e&&(t=t.slice(1)),"null"===t?{name:"null",mandatory:!e,grid:null,isNull:!0}:{name:t,mandatory:!e,grid:jp[t]||null,isNull:!1}}function Hp(t){return t/3600*Math.PI/180}function Wp(t,e,r){return String.fromCharCode.apply(null,new Uint8Array(t.buffer.slice(e,r)))}function qp(t){return t.map((function(t){return[Hp(t.longitudeShift),Hp(t.latitudeShift)]}))}function Xp(t,e,r){return{name:Wp(t,e+8,e+16).trim(),parent:Wp(t,e+24,e+24+8).trim(),lowerLatitude:t.getFloat64(e+72,r),upperLatitude:t.getFloat64(e+88,r),lowerLongitude:t.getFloat64(e+104,r),upperLongitude:t.getFloat64(e+120,r),latitudeInterval:t.getFloat64(e+136,r),longitudeInterval:t.getFloat64(e+152,r),gridNodeCount:t.getInt32(e+168,r)}}function Yp(t,e,r,n){for(var i=e+176,a=[],o=0;o3&&(0===s.datum_params[3]&&0===s.datum_params[4]&&0===s.datum_params[5]&&0===s.datum_params[6]||(s.datum_type=Gf,s.datum_params[3]*=Yf,s.datum_params[4]*=Yf,s.datum_params[5]*=Yf,s.datum_params[6]=s.datum_params[6]/1e6+1))),o&&(s.datum_type=jf,s.grids=o),s.a=r,s.b=n,s.es=i,s.ep2=a,s}(r.datumCode,r.datum_params,d.a,d.b,f.es,f.ep2,p);Ap(this,r),Ap(this,n),this.a=d.a,this.b=d.b,this.rf=d.rf,this.sphere=d.sphere,this.es=f.es,this.e=f.e,this.ep2=f.ep2,this.datum=m,this.init(),e(null,this)}else e(t)}else e(t)}function Kp(t,e,r){var n,i,a,o,s=t.x,l=t.y,u=t.z?t.z:0;if(l<-Zf&&l>-1.001*Zf)l=-Zf;else if(l>Zf&&l<1.001*Zf)l=Zf;else{if(l<-Zf)return{x:-1/0,y:-1/0,z:t.z};if(l>Zf)return{x:1/0,y:1/0,z:t.z}}return s>Math.PI&&(s-=2*Math.PI),i=Math.sin(l),o=Math.cos(l),a=i*i,{x:((n=r/Math.sqrt(1-e*a))+u)*o*Math.cos(s),y:(n+u)*o*Math.sin(s),z:(n*(1-e)+u)*i}}function Jp(t,e,r,n){var i,a,o,s,l,u,c,h,d,f,p,m,g,v,y,x=1e-12,_=t.x,w=t.y,b=t.z?t.z:0;if(i=Math.sqrt(_*_+w*w),a=Math.sqrt(_*_+w*w+b*b),i/r1e-24&&g<30);return{x:v,y:Math.atan(p/Math.abs(f)),z:y}}function Qp(t){return t===zf||t===Gf}function $p(t,e,r){if(function(t,e){return t.datum_type===e.datum_type&&!(t.a!==e.a||Math.abs(t.es-e.es)>5e-11)&&(t.datum_type===zf?t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]:t.datum_type!==Gf||t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]&&t.datum_params[3]===e.datum_params[3]&&t.datum_params[4]===e.datum_params[4]&&t.datum_params[5]===e.datum_params[5]&&t.datum_params[6]===e.datum_params[6])}(t,e))return r;if(t.datum_type===Hf||e.datum_type===Hf)return r;var n=t.a,i=t.es;if(t.datum_type===jf){if(0!==tm(t,!1,r))return;n=Wf,i=Xf}var a=e.a,o=e.b,s=e.es;if(e.datum_type===jf&&(a=Wf,o=qf,s=Xf),i===s&&n===a&&!Qp(t.datum_type)&&!Qp(e.datum_type))return r;if((r=Kp(r,i,n),Qp(t.datum_type)&&(r=function(t,e,r){if(e===zf)return{x:t.x+r[0],y:t.y+r[1],z:t.z+r[2]};if(e===Gf){var n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],u=r[6];return{x:u*(t.x-l*t.y+s*t.z)+n,y:u*(l*t.x+t.y-o*t.z)+i,z:u*(-s*t.x+o*t.y+t.z)+a}}}(r,t.datum_type,t.datum_params)),Qp(e.datum_type)&&(r=function(t,e,r){if(e===zf)return{x:t.x-r[0],y:t.y-r[1],z:t.z-r[2]};if(e===Gf){var n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],u=r[6],c=(t.x-n)/u,h=(t.y-i)/u,d=(t.z-a)/u;return{x:c+l*h-s*d,y:-l*c+h+o*d,z:s*c-o*h+d}}}(r,e.datum_type,e.datum_params)),r=Jp(r,s,a,o),e.datum_type===jf)&&0!==tm(e,!0,r))return;return r}function tm(t,e,r){if(null===t.grids||0===t.grids.length)return console.log("Grid shift grids not found"),-1;for(var n={x:-r.x,y:r.y},i={x:Number.NaN,y:Number.NaN},a=[],o=0;on.y||c>n.x||f1e-12&&Math.abs(o.y)>1e-12);if(l<0)return console.log("Inverse grid shift iterator failed to converge."),n;n.x=Cp(a.x+r.ll[0]),n.y=a.y+r.ll[1]}else isNaN(a.x)||(n.x=t.x+a.x,n.y=t.y+a.y);return n}function rm(t,e){var r,n={x:t.x/e.del[0],y:t.y/e.del[1]},i=Math.floor(n.x),a=Math.floor(n.y),o=n.x-1*i,s=n.y-1*a,l={x:Number.NaN,y:Number.NaN};if(i<0||i>=e.lim[0])return l;if(a<0||a>=e.lim[1])return l;r=a*e.lim[0]+i;var u=e.cvs[r][0],c=e.cvs[r][1];r++;var h=e.cvs[r][0],d=e.cvs[r][1];r+=e.lim[0];var f=e.cvs[r][0],p=e.cvs[r][1];r--;var m=e.cvs[r][0],g=e.cvs[r][1],v=o*s,y=o*(1-s),x=(1-o)*(1-s),_=(1-o)*s;return l.x=x*u+y*h+_*m+v*f,l.y=x*c+y*d+_*g+v*p,l}function nm(t,e,r){var n,i,a,o=r.x,s=r.y,l=r.z||0,u={};for(a=0;a<3;a++)if(!e||2!==a||void 0!==r.z)switch(0===a?(n=o,i=-1!=="ew".indexOf(t.axis[a])?"x":"y"):1===a?(n=s,i=-1!=="ns".indexOf(t.axis[a])?"y":"x"):(n=l,i="z"),t.axis[a]){case"e":case"n":u[i]=n;break;case"w":case"s":u[i]=-n;break;case"u":void 0!==r[i]&&(u.z=n);break;case"d":void 0!==r[i]&&(u.z=-n);break;default:return null}return u}function im(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e}function am(t){if("function"==typeof Number.isFinite){if(Number.isFinite(t))return;throw new TypeError("coordinates must be finite numbers")}if("number"!=typeof t||t!=t||!isFinite(t))throw new TypeError("coordinates must be finite numbers")}function om(t,e,r,n){var i;if(Array.isArray(r)&&(r=im(r)),function(t){am(t.x),am(t.y)}(r),t.datum&&e.datum&&function(t,e){return(t.datum.datum_type===zf||t.datum.datum_type===Gf)&&"WGS84"!==e.datumCode||(e.datum.datum_type===zf||e.datum.datum_type===Gf)&&"WGS84"!==t.datumCode}(t,e)&&(r=om(t,i=new Zp("WGS84"),r,n),t=i),n&&"enu"!==t.axis&&(r=nm(t,!1,r)),"longlat"===t.projName)r={x:r.x*tp,y:r.y*tp,z:r.z||0};else if(t.to_meter&&(r={x:r.x*t.to_meter,y:r.y*t.to_meter,z:r.z||0}),!(r=t.inverse(r)))return;if(t.from_greenwich&&(r.x+=t.from_greenwich),r=$p(t.datum,e.datum,r))return e.from_greenwich&&(r={x:r.x-e.from_greenwich,y:r.y,z:r.z||0}),"longlat"===e.projName?r={x:r.x*ep,y:r.y*ep,z:r.z||0}:(r=e.forward(r),e.to_meter&&(r={x:r.x/e.to_meter,y:r.y/e.to_meter,z:r.z||0})),n&&"enu"!==e.axis?nm(e,!0,r):r}Zp.projections=Up,Zp.projections.start();var sm=Zp("WGS84");function lm(t,e,r,n){var i,a,o;return Array.isArray(r)?(i=om(t,e,r,n)||{x:NaN,y:NaN},r.length>2?void 0!==t.name&&"geocent"===t.name||void 0!==e.name&&"geocent"===e.name?"number"==typeof i.z?[i.x,i.y,i.z].concat(r.splice(3)):[i.x,i.y,r[2]].concat(r.splice(3)):[i.x,i.y].concat(r.splice(2)):[i.x,i.y]):(a=om(t,e,r,n),2===(o=Object.keys(r)).length||o.forEach((function(n){if(void 0!==t.name&&"geocent"===t.name||void 0!==e.name&&"geocent"===e.name){if("x"===n||"y"===n||"z"===n)return}else if("x"===n||"y"===n)return;a[n]=r[n]})),a)}function um(t){return t instanceof Zp?t:t.oProj?t.oProj:Zp(t)}function cm(t,e,r){t=um(t);var n,i=!1;return void 0===e?(e=t,t=sm,i=!0):(void 0!==e.x||Array.isArray(e))&&(r=e,e=t,t=sm,i=!0),e=um(e),r?lm(t,e,r):(n={forward:function(r,n){return lm(t,e,r,n)},inverse:function(r,n){return lm(e,t,r,n)}},i&&(n.oProj=e),n)}var hm=6,dm="AJSAJS",fm="AFAFAF",pm=65,mm=73,gm=79,vm=86,ym=90;const xm={forward:_m,inverse:function(t){var e=Sm(Am(t.toUpperCase()));if(e.lat&&e.lon)return[e.lon,e.lat,e.lon,e.lat];return[e.left,e.bottom,e.right,e.top]},toPoint:wm};function _m(t,e){return e=e||5,function(t,e){var r="00000"+t.easting,n="00000"+t.northing;return t.zoneNumber+t.zoneLetter+(f=t.easting,p=t.northing,m=t.zoneNumber,g=Em(m),v=Math.floor(f/1e5),y=Math.floor(p/1e5)%20,i=v,a=y,o=g,s=o-1,l=dm.charCodeAt(s),u=fm.charCodeAt(s),c=l+i-1,h=u+a,d=!1,c>ym&&(c=c-ym+pm-1,d=!0),(c===mm||lmm||(c>mm||lgm||(c>gm||lym&&(c=c-ym+pm-1),h>vm?(h=h-vm+pm-1,d=!0):d=!1,(h===mm||umm||(h>mm||ugm||(h>gm||uvm&&(h=h-vm+pm-1),String.fromCharCode(c)+String.fromCharCode(h))+r.substr(r.length-5,e)+n.substr(n.length-5,e);var i,a,o,s,l,u,c,h,d;var f,p,m,g,v,y}(function(t){var e,r,n,i,a,o,s,l,u=t.lat,c=t.lon,h=6378137,d=.00669438,f=.9996,p=bm(u),m=bm(c);l=Math.floor((c+180)/6)+1,180===c&&(l=60);u>=56&&u<64&&c>=3&&c<12&&(l=32);u>=72&&u<84&&(c>=0&&c<9?l=31:c>=9&&c<21?l=33:c>=21&&c<33?l=35:c>=33&&c<42&&(l=37));s=bm(6*(l-1)-180+3),e=d/(1-d),r=h/Math.sqrt(1-d*Math.sin(p)*Math.sin(p)),n=Math.tan(p)*Math.tan(p),i=e*Math.cos(p)*Math.cos(p),a=Math.cos(p)*(m-s),o=h*((1-d/4-3*d*d/64-5*d*d*d/256)*p-(3*d/8+3*d*d/32+45*d*d*d/1024)*Math.sin(2*p)+(15*d*d/256+45*d*d*d/1024)*Math.sin(4*p)-35*d*d*d/3072*Math.sin(6*p));var g=f*r*(a+(1-n+i)*a*a*a/6+(5-18*n+n*n+72*i-58*e)*a*a*a*a*a/120)+5e5,v=f*(o+r*Math.tan(p)*(a*a/2+(5-n+9*i+4*i*i)*a*a*a*a/24+(61-58*n+n*n+600*i-330*e)*a*a*a*a*a*a/720));u<0&&(v+=1e7);return{northing:Math.round(v),easting:Math.round(g),zoneNumber:l,zoneLetter:Tm(u)}}({lat:t[1],lon:t[0]}),e)}function wm(t){var e=Sm(Am(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function bm(t){return t*(Math.PI/180)}function Mm(t){return t/Math.PI*180}function Sm(t){var e=t.northing,r=t.easting,n=t.zoneLetter,i=t.zoneNumber;if(i<0||i>60)return null;var a,o,s,l,u,c,h,d,f,p=.9996,m=6378137,g=.00669438,v=(1-Math.sqrt(.99330562))/(1+Math.sqrt(.99330562)),y=r-5e5,x=e;n<"N"&&(x-=1e7),h=6*(i-1)-180+3,a=.006739496752268451,f=(d=x/p/6367449.145945056)+(3*v/2-27*v*v*v/32)*Math.sin(2*d)+(21*v*v/16-55*v*v*v*v/32)*Math.sin(4*d)+151*v*v*v/96*Math.sin(6*d),o=m/Math.sqrt(1-g*Math.sin(f)*Math.sin(f)),s=Math.tan(f)*Math.tan(f),l=a*Math.cos(f)*Math.cos(f),u=.99330562*m/Math.pow(1-g*Math.sin(f)*Math.sin(f),1.5),c=y/(o*p);var _=f-o*Math.tan(f)/u*(c*c/2-(5+3*s+10*l-4*l*l-9*a)*c*c*c*c/24+(61+90*s+298*l+45*s*s-1.6983531815716497-3*l*l)*c*c*c*c*c*c/720);_=Mm(_);var w,b=(c-(1+2*s+l)*c*c*c/6+(5-2*l+28*s-3*l*l+8*a+24*s*s)*c*c*c*c*c/120)/Math.cos(f);if(b=h+Mm(b),t.accuracy){var M=Sm({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});w={top:M.lat,right:M.lon,bottom:_,left:b}}else w={lat:_,lon:b};return w}function Tm(t){var e="Z";return 84>=t&&t>=72?e="X":72>t&&t>=64?e="W":64>t&&t>=56?e="V":56>t&&t>=48?e="U":48>t&&t>=40?e="T":40>t&&t>=32?e="S":32>t&&t>=24?e="R":24>t&&t>=16?e="Q":16>t&&t>=8?e="P":8>t&&t>=0?e="N":0>t&&t>=-8?e="M":-8>t&&t>=-16?e="L":-16>t&&t>=-24?e="K":-24>t&&t>=-32?e="J":-32>t&&t>=-40?e="H":-40>t&&t>=-48?e="G":-48>t&&t>=-56?e="F":-56>t&&t>=-64?e="E":-64>t&&t>=-72?e="D":-72>t&&t>=-80&&(e="C"),e}function Em(t){var e=t%hm;return 0===e&&(e=hm),e}function Am(t){if(t&&0===t.length)throw"MGRSPoint coverting from nothing";for(var e,r=t.length,n=null,i="",a=0;!/[A-Z]/.test(e=t.charAt(a));){if(a>=2)throw"MGRSPoint bad conversion from: "+t;i+=e,a++}var o=parseInt(i,10);if(0===a||a+3>r)throw"MGRSPoint bad conversion from: "+t;var s=t.charAt(a++);if(s<="A"||"B"===s||"Y"===s||s>="Z"||"I"===s||"O"===s)throw"MGRSPoint zone letter "+s+" not handled: "+t;n=t.substring(a,a+=2);for(var l=Em(o),u=function(t,e){var r=dm.charCodeAt(e-1),n=1e5,i=!1;for(;r!==t.charCodeAt(0);){if(++r===mm&&r++,r===gm&&r++,r>ym){if(i)throw"Bad character: "+t;r=pm,i=!0}n+=1e5}return n}(n.charAt(0),l),c=function(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;var r=fm.charCodeAt(e-1),n=0,i=!1;for(;r!==t.charCodeAt(0);){if(++r===mm&&r++,r===gm&&r++,r>vm){if(i)throw"Bad character: "+t;r=pm,i=!0}n+=1e5}return n}(n.charAt(1),l);c0&&(d=1e5/Math.pow(10,m),f=t.substring(a,a+m),g=parseFloat(f)*d,p=t.substring(a+m),v=parseFloat(p)*d),{easting:g+u,northing:v+c,zoneLetter:s,zoneNumber:o,accuracy:d}}function Rm(t){var e;switch(t){case"C":e=11e5;break;case"D":e=2e6;break;case"E":e=28e5;break;case"F":e=37e5;break;case"G":e=46e5;break;case"H":e=55e5;break;case"J":e=64e5;break;case"K":e=73e5;break;case"L":e=82e5;break;case"M":e=91e5;break;case"N":e=0;break;case"P":e=8e5;break;case"Q":e=17e5;break;case"R":e=26e5;break;case"S":e=35e5;break;case"T":e=44e5;break;case"U":e=53e5;break;case"V":e=62e5;break;case"W":e=7e6;break;case"X":e=79e5;break;default:e=-1}if(e>=0)return e;throw"Invalid zone letter: "+t}function Pm(t,e,r){if(!(this instanceof Pm))return new Pm(t,e,r);if(Array.isArray(t))this.x=t[0],this.y=t[1],this.z=t[2]||0;else if("object"==typeof t)this.x=t.x,this.y=t.y,this.z=t.z||0;else if("string"==typeof t&&void 0===e){var n=t.split(",");this.x=parseFloat(n[0],10),this.y=parseFloat(n[1],10),this.z=parseFloat(n[2],10)||0}else this.x=t,this.y=e,this.z=r||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}Pm.fromMGRS=function(t){return new Pm(wm(t))},Pm.prototype.toMGRS=function(t){return _m([this.x,this.y],t)};var Cm=1,Im=.25,Lm=.046875,Om=.01953125,Dm=.01068115234375,km=.75,Fm=.46875,Nm=.013020833333333334,Um=.007120768229166667,Bm=.3645833333333333,zm=.005696614583333333,Gm=.3076171875;function jm(t){var e=[];e[0]=Cm-t*(Im+t*(Lm+t*(Om+t*Dm))),e[1]=t*(km-t*(Lm+t*(Om+t*Dm)));var r=t*t;return e[2]=r*(Fm-t*(Nm+t*Um)),r*=t,e[3]=r*(Bm-t*zm),e[4]=r*t*Gm,e}function Vm(t,e,r,n){return r*=e,e*=e,n[0]*t-r*(n[1]+e*(n[2]+e*(n[3]+e*n[4])))}var Hm=20;function Wm(t,e,r){for(var n=1/(1-e),i=t,a=Hm;a;--a){var o=Math.sin(i),s=1-e*o*o;if(i-=s=(Vm(i,o,Math.cos(i),r)-t)*(s*Math.sqrt(s))*n,Math.abs(s)<$f)return i}return i}const qm={init:function(){this.x0=void 0!==this.x0?this.x0:0,this.y0=void 0!==this.y0?this.y0:0,this.long0=void 0!==this.long0?this.long0:0,this.lat0=void 0!==this.lat0?this.lat0:0,this.es&&(this.en=jm(this.es),this.ml0=Vm(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))},forward:function(t){var e,r,n,i=t.x,a=t.y,o=Cp(i-this.long0),s=Math.sin(a),l=Math.cos(a);if(this.es){var u=l*o,c=Math.pow(u,2),h=this.ep2*Math.pow(l,2),d=Math.pow(h,2),f=Math.abs(l)>$f?Math.tan(a):0,p=Math.pow(f,2),m=Math.pow(p,2);e=1-this.es*Math.pow(s,2),u/=Math.sqrt(e);var g=Vm(a,s,l,this.en);r=this.a*(this.k0*u*(1+c/6*(1-p+h+c/20*(5-18*p+m+14*h-58*p*h+c/42*(61+179*m-m*p-479*p)))))+this.x0,n=this.a*(this.k0*(g-this.ml0+s*o*u/2*(1+c/12*(5-p+9*h+4*d+c/30*(61+m-58*p+270*h-330*p*h+c/56*(1385+543*m-m*p-3111*p))))))+this.y0}else{var v=l*Math.sin(o);if(Math.abs(Math.abs(v)-1)<$f)return 93;if(r=.5*this.a*this.k0*Math.log((1+v)/(1-v))+this.x0,n=l*Math.cos(o)/Math.sqrt(1-Math.pow(v,2)),(v=Math.abs(n))>=1){if(v-1>$f)return 93;n=0}else n=Math.acos(n);a<0&&(n=-n),n=this.a*this.k0*(n-this.lat0)+this.y0}return t.x=r,t.y=n,t},inverse:function(t){var e,r,n,i,a=(t.x-this.x0)*(1/this.a),o=(t.y-this.y0)*(1/this.a);if(this.es)if(r=Wm(e=this.ml0+o/this.k0,this.es,this.en),Math.abs(r)$f?Math.tan(r):0,c=this.ep2*Math.pow(l,2),h=Math.pow(c,2),d=Math.pow(u,2),f=Math.pow(d,2);e=1-this.es*Math.pow(s,2);var p=a*Math.sqrt(e)/this.k0,m=Math.pow(p,2);n=r-(e*=u)*m/(1-this.es)*.5*(1-m/12*(5+3*d-9*c*d+c-4*h-m/30*(61+90*d-252*c*d+45*f+46*c-m/56*(1385+3633*d+4095*f+1574*f*d)))),i=Cp(this.long0+p*(1-m/6*(1+2*d+c-m/20*(5+28*d+24*f+8*c*d+6*c-m/42*(61+662*d+1320*f+720*f*d))))/l)}else n=Zf*Pp(o),i=0;else{var g=Math.exp(a/this.k0),v=.5*(g-1/g),y=this.lat0+o/this.k0,x=Math.cos(y);e=Math.sqrt((1-Math.pow(x,2))/(1+Math.pow(v,2))),n=Math.asin(e),o<0&&(n=-n),i=0===v&&0===x?0:Cp(Math.atan2(v,x)+this.long0)}return t.x=i,t.y=n,t},names:["Fast_Transverse_Mercator","Fast Transverse Mercator"]};function Xm(t){var e=Math.exp(t);return e=(e-1/e)/2}function Ym(t,e){t=Math.abs(t),e=Math.abs(e);var r=Math.max(t,e),n=Math.min(t,e)/(r||1);return r*Math.sqrt(1+Math.pow(n,2))}function Zm(t){var e=Math.abs(t);return e=function(t){var e=1+t,r=e-1;return 0===r?t:t*Math.log(e)/r}(e*(1+e/(Ym(1,e)+1))),t<0?-e:e}function Km(t,e){for(var r,n=2*Math.cos(2*e),i=t.length-1,a=t[i],o=0;--i>=0;)r=n*a-o+t[i],o=a,a=r;return e+r*Math.sin(2*e)}function Jm(t,e,r){for(var n,i,a=Math.sin(e),o=Math.cos(e),s=Xm(r),l=function(t){var e=Math.exp(t);return(e+1/e)/2}(r),u=2*o*l,c=-2*a*s,h=t.length-1,d=t[h],f=0,p=0,m=0;--h>=0;)n=p,i=f,d=u*(p=d)-n-c*(f=m)+t[h],m=c*p-i+u*f;return[(u=a*l)*d-(c=o*s)*m,u*m+c*d]}const Qm={init:function(){if(!this.approx&&(isNaN(this.es)||this.es<=0))throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');this.approx&&(qm.init.apply(this),this.forward=qm.forward,this.inverse=qm.inverse),this.x0=void 0!==this.x0?this.x0:0,this.y0=void 0!==this.y0?this.y0:0,this.long0=void 0!==this.long0?this.long0:0,this.lat0=void 0!==this.lat0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var t=this.es/(1+Math.sqrt(1-this.es)),e=t/(2-t),r=e;this.cgb[0]=e*(2+e*(-2/3+e*(e*(116/45+e*(26/45+e*(-2854/675)))-2))),this.cbg[0]=e*(e*(2/3+e*(4/3+e*(-82/45+e*(32/45+e*(4642/4725)))))-2),r*=e,this.cgb[1]=r*(7/3+e*(e*(-227/45+e*(2704/315+e*(2323/945)))-1.6)),this.cbg[1]=r*(5/3+e*(-16/15+e*(-13/9+e*(904/315+e*(-1522/945))))),r*=e,this.cgb[2]=r*(56/15+e*(-136/35+e*(-1262/105+e*(73814/2835)))),this.cbg[2]=r*(-26/15+e*(34/21+e*(1.6+e*(-12686/2835)))),r*=e,this.cgb[3]=r*(4279/630+e*(-332/35+e*(-399572/14175))),this.cbg[3]=r*(1237/630+e*(e*(-24832/14175)-2.4)),r*=e,this.cgb[4]=r*(4174/315+e*(-144838/6237)),this.cbg[4]=r*(-734/315+e*(109598/31185)),r*=e,this.cgb[5]=r*(601676/22275),this.cbg[5]=r*(444337/155925),r=Math.pow(e,2),this.Qn=this.k0/(1+e)*(1+r*(1/4+r*(1/64+r/256))),this.utg[0]=e*(e*(2/3+e*(-37/96+e*(1/360+e*(81/512+e*(-96199/604800)))))-.5),this.gtu[0]=e*(.5+e*(-2/3+e*(5/16+e*(41/180+e*(-127/288+e*(7891/37800)))))),this.utg[1]=r*(-1/48+e*(-1/15+e*(437/1440+e*(-46/105+e*(1118711/3870720))))),this.gtu[1]=r*(13/48+e*(e*(557/1440+e*(281/630+e*(-1983433/1935360)))-.6)),r*=e,this.utg[2]=r*(-17/480+e*(37/840+e*(209/4480+e*(-5569/90720)))),this.gtu[2]=r*(61/240+e*(-103/140+e*(15061/26880+e*(167603/181440)))),r*=e,this.utg[3]=r*(-4397/161280+e*(11/504+e*(830251/7257600))),this.gtu[3]=r*(49561/161280+e*(-179/168+e*(6601661/7257600))),r*=e,this.utg[4]=r*(-4583/161280+e*(108847/3991680)),this.gtu[4]=r*(34729/80640+e*(-3418889/1995840)),r*=e,this.utg[5]=r*(-20648693/638668800),this.gtu[5]=.6650675310896665*r;var n=Km(this.cbg,this.lat0);this.Zb=-this.Qn*(n+function(t,e){for(var r,n=2*Math.cos(e),i=t.length-1,a=t[i],o=0;--i>=0;)r=n*a-o+t[i],o=a,a=r;return Math.sin(e)*r}(this.gtu,2*n))},forward:function(t){var e=Cp(t.x-this.long0),r=t.y;r=Km(this.cbg,r);var n=Math.sin(r),i=Math.cos(r),a=Math.sin(e),o=Math.cos(e);r=Math.atan2(n,o*i),e=Math.atan2(a*i,Ym(n,i*o)),e=Zm(Math.tan(e));var s,l,u=Jm(this.gtu,2*r,2*e);return r+=u[0],e+=u[1],Math.abs(e)<=2.623395162778?(s=this.a*(this.Qn*e)+this.x0,l=this.a*(this.Qn*r+this.Zb)+this.y0):(s=1/0,l=1/0),t.x=s,t.y=l,t},inverse:function(t){var e,r,n=(t.x-this.x0)*(1/this.a),i=(t.y-this.y0)*(1/this.a);if(i=(i-this.Zb)/this.Qn,n/=this.Qn,Math.abs(n)<=2.623395162778){var a=Jm(this.utg,2*i,2*n);i+=a[0],n+=a[1],n=Math.atan(Xm(n));var o=Math.sin(i),s=Math.cos(i),l=Math.sin(n),u=Math.cos(n);i=Math.atan2(o*u,Ym(l,u*s)),e=Cp((n=Math.atan2(l,u*s))+this.long0),r=Km(this.cgb,i)}else e=1/0,r=1/0;return t.x=e,t.y=r,t},names:["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","tmerc"]};const $m={init:function(){var t=function(t,e){if(void 0===t){if((t=Math.floor(30*(Cp(e)+Math.PI)/Math.PI)+1)<0)return 0;if(t>60)return 60}return t}(this.zone,this.long0);if(void 0===t)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(t)-183)*tp,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,Qm.init.apply(this),this.forward=Qm.forward,this.inverse=Qm.inverse},names:["Universal Transverse Mercator System","utm"],dependsOn:"etmerc"};function tg(t,e){return Math.pow((1-t)/(1+t),e)}const eg={init:function(){var t=Math.sin(this.lat0),e=Math.cos(this.lat0);e*=e,this.rc=Math.sqrt(1-this.es)/(1-this.es*t*t),this.C=Math.sqrt(1+this.es*e*e/(1-this.es)),this.phic0=Math.asin(t/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+rp)/(Math.pow(Math.tan(.5*this.lat0+rp),this.C)*tg(this.e*t,this.ratexp))},forward:function(t){var e=t.x,r=t.y;return t.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*r+rp),this.C)*tg(this.e*Math.sin(r),this.ratexp))-Zf,t.x=this.C*e,t},inverse:function(t){for(var e=t.x/this.C,r=t.y,n=Math.pow(Math.tan(.5*r+rp)/this.K,1/this.C),i=20;i>0&&(r=2*Math.atan(n*tg(this.e*Math.sin(t.y),-.5*this.e))-Zf,!(Math.abs(r-t.y)<1e-14));--i)t.y=r;return i?(t.x=e,t.y=r,t):null},names:["gauss"]};const rg={init:function(){eg.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))},forward:function(t){var e,r,n,i;return t.x=Cp(t.x-this.long0),eg.forward.apply(this,[t]),e=Math.sin(t.y),r=Math.cos(t.y),n=Math.cos(t.x),i=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*r*n),t.x=i*r*Math.sin(t.x),t.y=i*(this.cosc0*e-this.sinc0*r*n),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t},inverse:function(t){var e,r,n,i,a;if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,a=Math.sqrt(t.x*t.x+t.y*t.y)){var o=2*Math.atan2(a,this.R2);e=Math.sin(o),r=Math.cos(o),i=Math.asin(r*this.sinc0+t.y*e*this.cosc0/a),n=Math.atan2(t.x*e,a*this.cosc0*r-t.y*this.sinc0*e)}else i=this.phic0,n=0;return t.x=n,t.y=i,eg.inverse.apply(this,[t]),t.x=Cp(t.x+this.long0),t},names:["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"]};const ng={init:function(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=$f&&(this.k0=.5*(1+Pp(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=$f&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=$f&&(this.k0=.5*this.cons*Rp(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/Ip(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=Rp(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-Zf,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))},forward:function(t){var e,r,n,i,a,o,s=t.x,l=t.y,u=Math.sin(l),c=Math.cos(l),h=Cp(s-this.long0);return Math.abs(Math.abs(s-this.long0)-Math.PI)<=$f&&Math.abs(l+this.lat0)<=$f?(t.x=NaN,t.y=NaN,t):this.sphere?(e=2*this.k0/(1+this.sinlat0*u+this.coslat0*c*Math.cos(h)),t.x=this.a*e*c*Math.sin(h)+this.x0,t.y=this.a*e*(this.coslat0*u-this.sinlat0*c*Math.cos(h))+this.y0,t):(r=2*Math.atan(this.ssfn_(l,u,this.e))-Zf,i=Math.cos(r),n=Math.sin(r),Math.abs(this.coslat0)<=$f?(a=Ip(this.e,l*this.con,this.con*u),o=2*this.a*this.k0*a/this.cons,t.x=this.x0+o*Math.sin(s-this.long0),t.y=this.y0-this.con*o*Math.cos(s-this.long0),t):(Math.abs(this.sinlat0)<$f?(e=2*this.a*this.k0/(1+i*Math.cos(h)),t.y=e*n):(e=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*n+this.cosX0*i*Math.cos(h))),t.y=e*(this.cosX0*n-this.sinX0*i*Math.cos(h))+this.y0),t.x=e*i*Math.sin(h)+this.x0,t))},inverse:function(t){var e,r,n,i,a;t.x-=this.x0,t.y-=this.y0;var o=Math.sqrt(t.x*t.x+t.y*t.y);if(this.sphere){var s=2*Math.atan(o/(2*this.a*this.k0));return e=this.long0,r=this.lat0,o<=$f?(t.x=e,t.y=r,t):(r=Math.asin(Math.cos(s)*this.sinlat0+t.y*Math.sin(s)*this.coslat0/o),e=Math.abs(this.coslat0)<$f?this.lat0>0?Cp(this.long0+Math.atan2(t.x,-1*t.y)):Cp(this.long0+Math.atan2(t.x,t.y)):Cp(this.long0+Math.atan2(t.x*Math.sin(s),o*this.coslat0*Math.cos(s)-t.y*this.sinlat0*Math.sin(s))),t.x=e,t.y=r,t)}if(Math.abs(this.coslat0)<=$f){if(o<=$f)return r=this.lat0,e=this.long0,t.x=e,t.y=r,t;t.x*=this.con,t.y*=this.con,n=o*this.cons/(2*this.a*this.k0),r=this.con*Lp(this.e,n),e=this.con*Cp(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else i=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),e=this.long0,o<=$f?a=this.X0:(a=Math.asin(Math.cos(i)*this.sinX0+t.y*Math.sin(i)*this.cosX0/o),e=Cp(this.long0+Math.atan2(t.x*Math.sin(i),o*this.cosX0*Math.cos(i)-t.y*this.sinX0*Math.sin(i)))),r=-1*Lp(this.e,Math.tan(.5*(Zf+a)));return t.x=e,t.y=r,t},names:["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],ssfn_:function(t,e,r){return e*=r,Math.tan(.5*(Zf+t))*Math.pow((1-e)/(1+e),.5*r)}};const ig={init:function(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),r=this.a,n=1/this.rf,i=2*n-Math.pow(n,2),a=this.e=Math.sqrt(i);this.R=this.k0*r*Math.sqrt(1-i)/(1-i*Math.pow(e,2)),this.alpha=Math.sqrt(1+i/(1-i)*Math.pow(Math.cos(t),4)),this.b0=Math.asin(e/this.alpha);var o=Math.log(Math.tan(Math.PI/4+this.b0/2)),s=Math.log(Math.tan(Math.PI/4+t/2)),l=Math.log((1+a*e)/(1-a*e));this.K=o-this.alpha*s+this.alpha*a/2*l},forward:function(t){var e=Math.log(Math.tan(Math.PI/4-t.y/2)),r=this.e/2*Math.log((1+this.e*Math.sin(t.y))/(1-this.e*Math.sin(t.y))),n=-this.alpha*(e+r)+this.K,i=2*(Math.atan(Math.exp(n))-Math.PI/4),a=this.alpha*(t.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 t.y=this.R/2*Math.log((1+Math.sin(s))/(1-Math.sin(s)))+this.y0,t.x=this.R*o+this.x0,t},inverse:function(t){for(var e=t.x-this.x0,r=t.y-this.y0,n=e/this.R,i=2*(Math.atan(Math.exp(r/this.R))-Math.PI/4),a=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(n)),o=Math.atan(Math.sin(n)/(Math.cos(this.b0)*Math.cos(n)-Math.sin(this.b0)*Math.tan(i))),s=this.lambda0+o/this.alpha,l=0,u=a,c=-1e3,h=0;Math.abs(u-c)>1e-7;){if(++h>20)return;l=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(u))/2)),c=u,u=2*Math.atan(Math.exp(l))-Math.PI/2}return t.x=s,t.y=u,t},names:["somerc"]};var ag=1e-7;const og={init:function(){var t,e,r,n,i,a,o,s,l,u,c,h,d,f=0,p=0,m=0,g=0,v=0,y=0,x=0;this.no_off=(d="object"==typeof(h=this).PROJECTION?Object.keys(h.PROJECTION)[0]:h.PROJECTION,"no_uoff"in h||"no_off"in h||-1!==["Hotine_Oblique_Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin"].indexOf(d)),this.no_rot="no_rot"in this;var _=!1;"alpha"in this&&(_=!0);var w=!1;if("rectified_grid_angle"in this&&(w=!0),_&&(x=this.alpha),w&&(f=this.rectified_grid_angle*tp),_||w)p=this.longc;else if(m=this.long1,v=this.lat1,g=this.long2,y=this.lat2,Math.abs(v-y)<=ag||(t=Math.abs(v))<=ag||Math.abs(t-Zf)<=ag||Math.abs(Math.abs(this.lat0)-Zf)<=ag||Math.abs(Math.abs(y)-Zf)<=ag)throw new Error;var b=1-this.es;e=Math.sqrt(b),Math.abs(this.lat0)>$f?(s=Math.sin(this.lat0),r=Math.cos(this.lat0),t=1-this.es*s*s,this.B=r*r,this.B=Math.sqrt(1+this.es*this.B*this.B/b),this.A=this.B*this.k0*e/t,(i=(n=this.B*e/(r*Math.sqrt(t)))*n-1)<=0?i=0:(i=Math.sqrt(i),this.lat0<0&&(i=-i)),this.E=i+=n,this.E*=Math.pow(Ip(this.e,this.lat0,s),this.B)):(this.B=1/e,this.A=this.k0,this.E=n=i=1),_||w?(_?(c=Math.asin(Math.sin(x)/n),w||(f=x)):(c=f,x=Math.asin(n*Math.sin(c))),this.lam0=p-Math.asin(.5*(i-1/i)*Math.tan(c))/this.B):(a=Math.pow(Ip(this.e,v,Math.sin(v)),this.B),o=Math.pow(Ip(this.e,y,Math.sin(y)),this.B),i=this.E/a,l=(o-a)/(o+a),u=((u=this.E*this.E)-o*a)/(u+o*a),(t=m-g)<-Math.pi?g-=np:t>Math.pi&&(g+=np),this.lam0=Cp(.5*(m+g)-Math.atan(u*Math.tan(.5*this.B*(m-g))/l)/this.B),c=Math.atan(2*Math.sin(this.B*Cp(m-this.lam0))/(i-1/i)),f=x=Math.asin(n*Math.sin(c))),this.singam=Math.sin(c),this.cosgam=Math.cos(c),this.sinrot=Math.sin(f),this.cosrot=Math.cos(f),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.A,this.B,this.no_off?this.u_0=0:(this.u_0=Math.abs(this.ArB*Math.atan(Math.sqrt(n*n-1)/Math.cos(x))),this.lat0<0&&(this.u_0=-this.u_0)),i=.5*c,this.v_pole_n=this.ArB*Math.log(Math.tan(rp-i)),this.v_pole_s=this.ArB*Math.log(Math.tan(rp+i))},forward:function(t){var e,r,n,i,a,o,s,l,u={};if(t.x=t.x-this.lam0,Math.abs(Math.abs(t.y)-Zf)>$f){if(e=.5*((a=this.E/Math.pow(Ip(this.e,t.y,Math.sin(t.y)),this.B))-(o=1/a)),r=.5*(a+o),i=Math.sin(this.B*t.x),n=(e*this.singam-i*this.cosgam)/r,Math.abs(Math.abs(n)-1)<$f)throw new Error;l=.5*this.ArB*Math.log((1-n)/(1+n)),o=Math.cos(this.B*t.x),s=Math.abs(o)0?this.v_pole_n:this.v_pole_s,s=this.ArB*t.y;return this.no_rot?(u.x=s,u.y=l):(s-=this.u_0,u.x=l*this.cosrot+s*this.sinrot,u.y=s*this.cosrot-l*this.sinrot),u.x=this.a*u.x+this.x0,u.y=this.a*u.y+this.y0,u},inverse:function(t){var e,r,n,i,a,o,s,l={};if(t.x=(t.x-this.x0)*(1/this.a),t.y=(t.y-this.y0)*(1/this.a),this.no_rot?(r=t.y,e=t.x):(r=t.x*this.cosrot-t.y*this.sinrot,e=t.y*this.cosrot+t.x*this.sinrot+this.u_0),i=.5*((n=Math.exp(-this.BrA*r))-1/n),a=.5*(n+1/n),s=((o=Math.sin(this.BrA*e))*this.cosgam+i*this.singam)/a,Math.abs(Math.abs(s)-1)<$f)l.x=0,l.y=s<0?-Zf:Zf;else{if(l.y=this.E/Math.sqrt((1+s)/(1-s)),l.y=Lp(this.e,Math.pow(l.y,1/this.B)),l.y===1/0)throw new Error;l.x=-this.rB*Math.atan2(i*this.cosgam-o*this.singam,Math.cos(this.BrA*e))}return l.x+=this.lam0,l},names:["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Two_Point_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","Oblique_Mercator","omerc"]};const sg={init:function(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<$f)){var t=this.b/this.a;this.e=Math.sqrt(1-t*t);var e=Math.sin(this.lat1),r=Math.cos(this.lat1),n=Rp(this.e,e,r),i=Ip(this.e,this.lat1,e),a=Math.sin(this.lat2),o=Math.cos(this.lat2),s=Rp(this.e,a,o),l=Ip(this.e,this.lat2,a),u=Ip(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>$f?this.ns=Math.log(n/s)/Math.log(i/l):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=n/(this.ns*Math.pow(i,this.ns)),this.rh=this.a*this.f0*Math.pow(u,this.ns),this.title||(this.title="Lambert Conformal Conic")}},forward:function(t){var e=t.x,r=t.y;Math.abs(2*Math.abs(r)-Math.PI)<=$f&&(r=Pp(r)*(Zf-2*$f));var n,i,a=Math.abs(Math.abs(r)-Zf);if(a>$f)n=Ip(this.e,r,Math.sin(r)),i=this.a*this.f0*Math.pow(n,this.ns);else{if((a=r*this.ns)<=0)return null;i=0}var o=this.ns*Cp(e-this.long0);return t.x=this.k0*(i*Math.sin(o))+this.x0,t.y=this.k0*(this.rh-i*Math.cos(o))+this.y0,t},inverse:function(t){var e,r,n,i,a,o=(t.x-this.x0)/this.k0,s=this.rh-(t.y-this.y0)/this.k0;this.ns>0?(e=Math.sqrt(o*o+s*s),r=1):(e=-Math.sqrt(o*o+s*s),r=-1);var l=0;if(0!==e&&(l=Math.atan2(r*o,r*s)),0!==e||this.ns>0){if(r=1/this.ns,n=Math.pow(e/(this.a*this.f0),r),-9999===(i=Lp(this.e,n)))return null}else i=-Zf;return a=Cp(l/this.ns+this.long0),t.x=a,t.y=i,t},names:["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_1SP","Lambert_Conformal_Conic_2SP","lcc","Lambert Conic Conformal (1SP)","Lambert Conic Conformal (2SP)"]};const lg={init:function(){this.a=6377397.155,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.4334234309119251),this.k0||(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.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((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.pow(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.pow(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},forward:function(t){var e,r,n,i,a,o,s,l=t.x,u=t.y,c=Cp(l-this.long0);return e=Math.pow((1+this.e*Math.sin(u))/(1-this.e*Math.sin(u)),this.alfa*this.e/2),r=2*(Math.atan(this.k*Math.pow(Math.tan(u/2+this.s45),this.alfa)/e)-this.s45),n=-c*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(r)+Math.sin(this.ad)*Math.cos(r)*Math.cos(n)),a=Math.asin(Math.cos(r)*Math.sin(n)/Math.cos(i)),o=this.n*a,s=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(i/2+this.s45),this.n),t.y=s*Math.cos(o)/1,t.x=s*Math.sin(o)/1,this.czech||(t.y*=-1,t.x*=-1),t},inverse:function(t){var e,r,n,i,a,o,s,l=t.x;t.x=t.y,t.y=l,this.czech||(t.y*=-1,t.x*=-1),a=Math.sqrt(t.x*t.x+t.y*t.y),i=Math.atan2(t.y,t.x)/Math.sin(this.s0),n=2*(Math.atan(Math.pow(this.ro0/a,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),e=Math.asin(Math.cos(this.ad)*Math.sin(n)-Math.sin(this.ad)*Math.cos(n)*Math.cos(i)),r=Math.asin(Math.cos(n)*Math.sin(i)/Math.cos(e)),t.x=this.long0-r/this.alfa,o=e,s=0;var u=0;do{t.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(e/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(o))/(1-this.e*Math.sin(o)),this.e/2))-this.s45),Math.abs(o-t.y)<1e-10&&(s=1),o=t.y,u+=1}while(0===s&&u<15);return u>=15?null:t},names:["Krovak","krovak"]};function ug(t,e,r,n,i){return t*i-e*Math.sin(2*i)+r*Math.sin(4*i)-n*Math.sin(6*i)}function cg(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function hg(t){return.375*t*(1+.25*t*(1+.46875*t))}function dg(t){return.05859375*t*t*(1+.75*t)}function fg(t){return t*t*t*(35/3072)}function pg(t,e,r){var n=e*r;return t/Math.sqrt(1-n*n)}function mg(t){return Math.abs(t)1e-7?(1-t*t)*(e/(1-(r=t*e)*r)-.5/t*Math.log((1-r)/(1+r))):2*e}var xg=.3333333333333333,_g=.17222222222222222,wg=.10257936507936508,bg=.06388888888888888,Mg=.0664021164021164,Sg=.016415012942191543;const Tg={init:function(){var t,e=Math.abs(this.lat0);if(Math.abs(e-Zf)<$f?this.mode=this.lat0<0?this.S_POLE:this.N_POLE:Math.abs(e)<$f?this.mode=this.EQUIT:this.mode=this.OBLIQ,this.es>0)switch(this.qp=yg(this.e,1),this.mmf=.5/(1-this.es),this.apa=function(t){var e,r=[];return r[0]=t*xg,e=t*t,r[0]+=e*_g,r[1]=e*bg,e*=t,r[0]+=e*wg,r[1]+=e*Mg,r[2]=e*Sg,r}(this.es),this.mode){case this.N_POLE:case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=yg(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}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))},forward:function(t){var e,r,n,i,a,o,s,l,u,c,h=t.x,d=t.y;if(h=Cp(h-this.long0),this.sphere){if(a=Math.sin(d),c=Math.cos(d),n=Math.cos(h),this.mode===this.OBLIQ||this.mode===this.EQUIT){if((r=this.mode===this.EQUIT?1+c*n:1+this.sinph0*a+this.cosph0*c*n)<=$f)return null;e=(r=Math.sqrt(2/r))*c*Math.sin(h),r*=this.mode===this.EQUIT?a:this.cosph0*a-this.sinph0*c*n}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(n=-n),Math.abs(d+this.lat0)<$f)return null;r=rp-.5*d,e=(r=2*(this.mode===this.S_POLE?Math.cos(r):Math.sin(r)))*Math.sin(h),r*=n}}else{switch(s=0,l=0,u=0,n=Math.cos(h),i=Math.sin(h),a=Math.sin(d),o=yg(this.e,a),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(s=o/this.qp,l=Math.sqrt(1-s*s)),this.mode){case this.OBLIQ:u=1+this.sinb1*s+this.cosb1*l*n;break;case this.EQUIT:u=1+l*n;break;case this.N_POLE:u=Zf+d,o=this.qp-o;break;case this.S_POLE:u=d-Zf,o=this.qp+o}if(Math.abs(u)<$f)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:u=Math.sqrt(2/u),r=this.mode===this.OBLIQ?this.ymf*u*(this.cosb1*s-this.sinb1*l*n):(u=Math.sqrt(2/(1+l*n)))*s*this.ymf,e=this.xmf*u*l*i;break;case this.N_POLE:case this.S_POLE:o>=0?(e=(u=Math.sqrt(o))*i,r=n*(this.mode===this.S_POLE?u:-u)):e=r=0}}return t.x=this.a*e+this.x0,t.y=this.a*r+this.y0,t},inverse:function(t){t.x-=this.x0,t.y-=this.y0;var e,r,n,i,a,o,s,l,u,c,h=t.x/this.a,d=t.y/this.a;if(this.sphere){var f,p=0,m=0;if((r=.5*(f=Math.sqrt(h*h+d*d)))>1)return null;switch(r=2*Math.asin(r),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(m=Math.sin(r),p=Math.cos(r)),this.mode){case this.EQUIT:r=Math.abs(f)<=$f?0:Math.asin(d*m/f),h*=m,d=p*f;break;case this.OBLIQ:r=Math.abs(f)<=$f?this.lat0:Math.asin(p*this.sinph0+d*m*this.cosph0/f),h*=m*this.cosph0,d=(p-Math.sin(r)*this.sinph0)*f;break;case this.N_POLE:d=-d,r=Zf-r;break;case this.S_POLE:r-=Zf}e=0!==d||this.mode!==this.EQUIT&&this.mode!==this.OBLIQ?Math.atan2(h,d):0}else{if(s=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(h/=this.dd,d*=this.dd,(o=Math.sqrt(h*h+d*d))<$f)return t.x=this.long0,t.y=this.lat0,t;i=2*Math.asin(.5*o/this.rq),n=Math.cos(i),h*=i=Math.sin(i),this.mode===this.OBLIQ?(s=n*this.sinb1+d*i*this.cosb1/o,a=this.qp*s,d=o*this.cosb1*n-d*this.sinb1*i):(s=d*i/o,a=this.qp*s,d=o*n)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(d=-d),!(a=h*h+d*d))return t.x=this.long0,t.y=this.lat0,t;s=1-a/this.qp,this.mode===this.S_POLE&&(s=-s)}e=Math.atan2(h,d),l=Math.asin(s),u=this.apa,c=l+l,r=l+u[0]*Math.sin(c)+u[1]*Math.sin(c+c)+u[2]*Math.sin(c+c+c)}return t.x=Cp(this.long0+e),t.y=r,t},names:["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],S_POLE:1,N_POLE:2,EQUIT:3,OBLIQ:4};function Eg(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}const Ag={init:function(){Math.abs(this.lat1+this.lat2)<$f||(this.temp=this.b/this.a,this.es=1-Math.pow(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=Rp(this.e3,this.sin_po,this.cos_po),this.qs1=yg(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=Rp(this.e3,this.sin_po,this.cos_po),this.qs2=yg(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=yg(this.e3,this.sin_po,this.cos_po),Math.abs(this.lat1-this.lat2)>$f?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)},forward:function(t){var e=t.x,r=t.y;this.sin_phi=Math.sin(r),this.cos_phi=Math.cos(r);var n=yg(this.e3,this.sin_phi,this.cos_phi),i=this.a*Math.sqrt(this.c-this.ns0*n)/this.ns0,a=this.ns0*Cp(e-this.long0),o=i*Math.sin(a)+this.x0,s=this.rh-i*Math.cos(a)+this.y0;return t.x=o,t.y=s,t},inverse:function(t){var e,r,n,i,a,o;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns0>=0?(e=Math.sqrt(t.x*t.x+t.y*t.y),n=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),n=-1),i=0,0!==e&&(i=Math.atan2(n*t.x,n*t.y)),n=e*this.ns0/this.a,this.sphere?o=Math.asin((this.c-n*n)/(2*this.ns0)):(r=(this.c-n*n)/this.ns0,o=this.phi1z(this.e3,r)),a=Cp(i/this.ns0+this.long0),t.x=a,t.y=o,t},names:["Albers_Conic_Equal_Area","Albers","aea"],phi1z:function(t,e){var r,n,i,a,o=Eg(.5*e);if(t<$f)return o;for(var s=t*t,l=1;l<=25;l++)if(o+=a=.5*(i=1-(n=t*(r=Math.sin(o)))*n)*i/Math.cos(o)*(e/(1-s)-r/i+.5/t*Math.log((1-n)/(1+n))),Math.abs(a)<=1e-7)return o;return null}};const Rg={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1},forward:function(t){var e,r,n,i,a,o,s,l=t.x,u=t.y;return n=Cp(l-this.long0),e=Math.sin(u),r=Math.cos(u),i=Math.cos(n),1,(a=this.sin_p14*e+this.cos_p14*r*i)>0||Math.abs(a)<=$f?(o=this.x0+1*this.a*r*Math.sin(n)/a,s=this.y0+1*this.a*(this.cos_p14*e-this.sin_p14*r*i)/a):(o=this.x0+this.infinity_dist*r*Math.sin(n),s=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*r*i)),t.x=o,t.y=s,t},inverse:function(t){var e,r,n,i,a,o;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,(e=Math.sqrt(t.x*t.x+t.y*t.y))?(i=Math.atan2(e,this.rc),r=Math.sin(i),o=Eg((n=Math.cos(i))*this.sin_p14+t.y*r*this.cos_p14/e),a=Math.atan2(t.x*r,e*this.cos_p14*n-t.y*this.sin_p14*r),a=Cp(this.long0+a)):(o=this.phic0,a=0),t.x=a,t.y=o,t},names:["gnom"]};const Pg={init:function(){this.sphere||(this.k0=Rp(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))},forward:function(t){var e,r,n=t.x,i=t.y,a=Cp(n-this.long0);if(this.sphere)e=this.x0+this.a*a*Math.cos(this.lat_ts),r=this.y0+this.a*Math.sin(i)/Math.cos(this.lat_ts);else{var o=yg(this.e,Math.sin(i));e=this.x0+this.a*this.k0*a,r=this.y0+this.a*o*.5/this.k0}return t.x=e,t.y=r,t},inverse:function(t){var e,r;return t.x-=this.x0,t.y-=this.y0,this.sphere?(e=Cp(this.long0+t.x/this.a/Math.cos(this.lat_ts)),r=Math.asin(t.y/this.a*Math.cos(this.lat_ts))):(r=function(t,e){var r=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));if(Math.abs(Math.abs(e)-r)<1e-6)return e<0?-1*Zf:Zf;for(var n,i,a,o,s=Math.asin(.5*e),l=0;l<30;l++)if(i=Math.sin(s),a=Math.cos(s),o=t*i,s+=n=Math.pow(1-o*o,2)/(2*a)*(e/(1-t*t)-i/(1-o*o)+.5/t*Math.log((1-o)/(1+o))),Math.abs(n)<=1e-10)return s;return NaN}(this.e,2*t.y*this.k0/this.a),e=Cp(this.long0+t.x/(this.a*this.k0))),t.x=e,t.y=r,t},names:["cea"]};const Cg={init:function(){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)},forward:function(t){var e=t.x,r=t.y,n=Cp(e-this.long0),i=mg(r-this.lat0);return t.x=this.x0+this.a*n*this.rc,t.y=this.y0+this.a*i,t},inverse:function(t){var e=t.x,r=t.y;return t.x=Cp(this.long0+(e-this.x0)/(this.a*this.rc)),t.y=mg(this.lat0+(r-this.y0)/this.a),t},names:["Equirectangular","Equidistant_Cylindrical","eqc"]};const Ig={init:function(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=cg(this.es),this.e1=hg(this.es),this.e2=dg(this.es),this.e3=fg(this.es),this.ml0=this.a*ug(this.e0,this.e1,this.e2,this.e3,this.lat0)},forward:function(t){var e,r,n,i=t.x,a=t.y,o=Cp(i-this.long0);if(n=o*Math.sin(a),this.sphere)Math.abs(a)<=$f?(e=this.a*o,r=-1*this.a*this.lat0):(e=this.a*Math.sin(n)/Math.tan(a),r=this.a*(mg(a-this.lat0)+(1-Math.cos(n))/Math.tan(a)));else if(Math.abs(a)<=$f)e=this.a*o,r=-1*this.ml0;else{var s=pg(this.a,this.e,Math.sin(a))/Math.tan(a);e=s*Math.sin(n),r=this.a*ug(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+s*(1-Math.cos(n))}return t.x=e+this.x0,t.y=r+this.y0,t},inverse:function(t){var e,r,n,i,a,o,s,l,u;if(n=t.x-this.x0,i=t.y-this.y0,this.sphere)if(Math.abs(i+this.a*this.lat0)<=$f)e=Cp(n/this.a+this.long0),r=0;else{var c;for(o=this.lat0+i/this.a,s=n*n/this.a/this.a+o*o,l=o,a=20;a;--a)if(l+=u=-1*(o*(l*(c=Math.tan(l))+1)-l-.5*(l*l+s)*c)/((l-o)/c-1),Math.abs(u)<=$f){r=l;break}e=Cp(this.long0+Math.asin(n*Math.tan(l)/this.a)/Math.sin(r))}else if(Math.abs(i+this.ml0)<=$f)r=0,e=Cp(this.long0+n/this.a);else{var h,d,f,p,m;for(o=(this.ml0+i)/this.a,s=n*n/this.a/this.a+o*o,l=o,a=20;a;--a)if(m=this.e*Math.sin(l),h=Math.sqrt(1-m*m)*Math.tan(l),d=this.a*ug(this.e0,this.e1,this.e2,this.e3,l),f=this.e0-2*this.e1*Math.cos(2*l)+4*this.e2*Math.cos(4*l)-6*this.e3*Math.cos(6*l),l-=u=(o*(h*(p=d/this.a)+1)-p-.5*h*(p*p+s))/(this.es*Math.sin(2*l)*(p*p+s-2*o*p)/(4*h)+(o-p)*(h*f-2/Math.sin(2*l))-f),Math.abs(u)<=$f){r=l;break}h=Math.sqrt(1-this.es*Math.pow(Math.sin(r),2))*Math.tan(r),e=Cp(this.long0+Math.asin(n*h/this.a)/Math.sin(r))}return t.x=e,t.y=r,t},names:["Polyconic","poly"]};const Lg={init:function(){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},forward:function(t){var e,r=t.x,n=t.y-this.lat0,i=r-this.long0,a=n/Yf*1e-5,o=i,s=1,l=0;for(e=1;e<=10;e++)s*=a,l+=this.A[e]*s;var u,c=l,h=o,d=1,f=0,p=0,m=0;for(e=1;e<=6;e++)u=f*c+d*h,d=d*c-f*h,f=u,p=p+this.B_re[e]*d-this.B_im[e]*f,m=m+this.B_im[e]*d+this.B_re[e]*f;return t.x=m*this.a+this.x0,t.y=p*this.a+this.y0,t},inverse:function(t){var e,r,n=t.x,i=t.y,a=n-this.x0,o=(i-this.y0)/this.a,s=a/this.a,l=1,u=0,c=0,h=0;for(e=1;e<=6;e++)r=u*o+l*s,l=l*o-u*s,u=r,c=c+this.C_re[e]*l-this.C_im[e]*u,h=h+this.C_im[e]*l+this.C_re[e]*u;for(var d=0;d.999999999999&&(r=.999999999999),e=Math.asin(r);var n=Cp(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));n<-Math.PI&&(n=-Math.PI),n>Math.PI&&(n=Math.PI),r=(2*e+Math.sin(2*e))/Math.PI,Math.abs(r)>1&&(r=1);var i=Math.asin(r);return t.x=n,t.y=i,t},names:["Mollweide","moll"]};const Fg={init:function(){Math.abs(this.lat1+this.lat2)<$f||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=cg(this.es),this.e1=hg(this.es),this.e2=dg(this.es),this.e3=fg(this.es),this.sinphi=Math.sin(this.lat1),this.cosphi=Math.cos(this.lat1),this.ms1=Rp(this.e,this.sinphi,this.cosphi),this.ml1=ug(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<$f?this.ns=this.sinphi:(this.sinphi=Math.sin(this.lat2),this.cosphi=Math.cos(this.lat2),this.ms2=Rp(this.e,this.sinphi,this.cosphi),this.ml2=ug(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=ug(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))},forward:function(t){var e,r=t.x,n=t.y;if(this.sphere)e=this.a*(this.g-n);else{var i=ug(this.e0,this.e1,this.e2,this.e3,n);e=this.a*(this.g-i)}var a=this.ns*Cp(r-this.long0),o=this.x0+e*Math.sin(a),s=this.y0+this.rh-e*Math.cos(a);return t.x=o,t.y=s,t},inverse:function(t){var e,r,n,i;t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns>=0?(r=Math.sqrt(t.x*t.x+t.y*t.y),e=1):(r=-Math.sqrt(t.x*t.x+t.y*t.y),e=-1);var a=0;return 0!==r&&(a=Math.atan2(e*t.x,e*t.y)),this.sphere?(i=Cp(this.long0+a/this.ns),n=mg(this.g-r/this.a),t.x=i,t.y=n,t):(n=gg(this.g-r/this.a,this.e0,this.e1,this.e2,this.e3),i=Cp(this.long0+a/this.ns),t.x=i,t.y=n,t)},names:["Equidistant_Conic","eqdc"]};const Ng={init:function(){this.R=this.a},forward:function(t){var e,r,n=t.x,i=t.y,a=Cp(n-this.long0);Math.abs(i)<=$f&&(e=this.x0+this.R*a,r=this.y0);var o=Eg(2*Math.abs(i/Math.PI));(Math.abs(a)<=$f||Math.abs(Math.abs(i)-Zf)<=$f)&&(e=this.x0,r=i>=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/a-a/Math.PI),l=s*s,u=Math.sin(o),c=Math.cos(o),h=c/(u+c-1),d=h*h,f=h*(2/u-1),p=f*f,m=Math.PI*this.R*(s*(h-p)+Math.sqrt(l*(h-p)*(h-p)-(p+l)*(d-p)))/(p+l);a<0&&(m=-m),e=this.x0+m;var g=l+h;return m=Math.PI*this.R*(f*g-s*Math.sqrt((p+l)*(l+1)-g*g))/(p+l),r=i>=0?this.y0+m:this.y0-m,t.x=e,t.y=r,t},inverse:function(t){var e,r,n,i,a,o,s,l,u,c,h,d;return t.x-=this.x0,t.y-=this.y0,h=Math.PI*this.R,a=(n=t.x/h)*n+(i=t.y/h)*i,h=3*(i*i/(l=-2*(o=-Math.abs(i)*(1+a))+1+2*i*i+a*a)+(2*(s=o-2*i*i+n*n)*s*s/l/l/l-9*o*s/l/l)/27)/(u=(o-s*s/3/l)/l)/(c=2*Math.sqrt(-u/3)),Math.abs(h)>1&&(h=h>=0?1:-1),d=Math.acos(h)/3,r=t.y>=0?(-c*Math.cos(d+Math.PI/3)-s/3/l)*Math.PI:-(-c*Math.cos(d+Math.PI/3)-s/3/l)*Math.PI,e=Math.abs(n)<$f?this.long0:Cp(this.long0+Math.PI*(a-1+Math.sqrt(1+2*(n*n-i*i)+a*a))/2/n),t.x=e,t.y=r,t},names:["Van_der_Grinten_I","VanDerGrinten","vandg"]};const Ug={init:function(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)},forward:function(t){var e,r,n,i,a,o,s,l,u,c,h,d,f,p,m,g,v,y,x,_,w,b,M=t.x,S=t.y,T=Math.sin(t.y),E=Math.cos(t.y),A=Cp(M-this.long0);return this.sphere?Math.abs(this.sin_p12-1)<=$f?(t.x=this.x0+this.a*(Zf-S)*Math.sin(A),t.y=this.y0-this.a*(Zf-S)*Math.cos(A),t):Math.abs(this.sin_p12+1)<=$f?(t.x=this.x0+this.a*(Zf+S)*Math.sin(A),t.y=this.y0+this.a*(Zf+S)*Math.cos(A),t):(y=this.sin_p12*T+this.cos_p12*E*Math.cos(A),v=(g=Math.acos(y))?g/Math.sin(g):1,t.x=this.x0+this.a*v*E*Math.sin(A),t.y=this.y0+this.a*v*(this.cos_p12*T-this.sin_p12*E*Math.cos(A)),t):(e=cg(this.es),r=hg(this.es),n=dg(this.es),i=fg(this.es),Math.abs(this.sin_p12-1)<=$f?(a=this.a*ug(e,r,n,i,Zf),o=this.a*ug(e,r,n,i,S),t.x=this.x0+(a-o)*Math.sin(A),t.y=this.y0-(a-o)*Math.cos(A),t):Math.abs(this.sin_p12+1)<=$f?(a=this.a*ug(e,r,n,i,Zf),o=this.a*ug(e,r,n,i,S),t.x=this.x0+(a+o)*Math.sin(A),t.y=this.y0+(a+o)*Math.cos(A),t):(s=T/E,l=pg(this.a,this.e,this.sin_p12),u=pg(this.a,this.e,T),c=Math.atan((1-this.es)*s+this.es*l*this.sin_p12/(u*E)),x=0===(h=Math.atan2(Math.sin(A),this.cos_p12*Math.tan(c)-this.sin_p12*Math.cos(A)))?Math.asin(this.cos_p12*Math.sin(c)-this.sin_p12*Math.cos(c)):Math.abs(Math.abs(h)-Math.PI)<=$f?-Math.asin(this.cos_p12*Math.sin(c)-this.sin_p12*Math.cos(c)):Math.asin(Math.sin(A)*Math.cos(c)/Math.sin(h)),d=this.e*this.sin_p12/Math.sqrt(1-this.es),g=l*x*(1-(_=x*x)*(m=(f=this.e*this.cos_p12*Math.cos(h)/Math.sqrt(1-this.es))*f)*(1-m)/6+(w=_*x)/8*(p=d*f)*(1-2*m)+(b=w*x)/120*(m*(4-7*m)-3*d*d*(1-7*m))-b*x/48*p),t.x=this.x0+g*Math.sin(h),t.y=this.y0+g*Math.cos(h),t))},inverse:function(t){var e,r,n,i,a,o,s,l,u,c,h,d,f,p,m,g,v,y,x,_,w,b,M;if(t.x-=this.x0,t.y-=this.y0,this.sphere){if((e=Math.sqrt(t.x*t.x+t.y*t.y))>2*Zf*this.a)return;return r=e/this.a,n=Math.sin(r),i=Math.cos(r),a=this.long0,Math.abs(e)<=$f?o=this.lat0:(o=Eg(i*this.sin_p12+t.y*n*this.cos_p12/e),s=Math.abs(this.lat0)-Zf,a=Math.abs(s)<=$f?this.lat0>=0?Cp(this.long0+Math.atan2(t.x,-t.y)):Cp(this.long0-Math.atan2(-t.x,t.y)):Cp(this.long0+Math.atan2(t.x*n,e*this.cos_p12*i-t.y*this.sin_p12*n))),t.x=a,t.y=o,t}return l=cg(this.es),u=hg(this.es),c=dg(this.es),h=fg(this.es),Math.abs(this.sin_p12-1)<=$f?(o=gg(((d=this.a*ug(l,u,c,h,Zf))-(e=Math.sqrt(t.x*t.x+t.y*t.y)))/this.a,l,u,c,h),a=Cp(this.long0+Math.atan2(t.x,-1*t.y)),t.x=a,t.y=o,t):Math.abs(this.sin_p12+1)<=$f?(d=this.a*ug(l,u,c,h,Zf),o=gg(((e=Math.sqrt(t.x*t.x+t.y*t.y))-d)/this.a,l,u,c,h),a=Cp(this.long0+Math.atan2(t.x,t.y)),t.x=a,t.y=o,t):(e=Math.sqrt(t.x*t.x+t.y*t.y),m=Math.atan2(t.x,t.y),f=pg(this.a,this.e,this.sin_p12),g=Math.cos(m),y=-(v=this.e*this.cos_p12*g)*v/(1-this.es),x=3*this.es*(1-y)*this.sin_p12*this.cos_p12*g/(1-this.es),b=1-y*(w=(_=e/f)-y*(1+y)*Math.pow(_,3)/6-x*(1+3*y)*Math.pow(_,4)/24)*w/2-_*w*w*w/6,p=Math.asin(this.sin_p12*Math.cos(w)+this.cos_p12*Math.sin(w)*g),a=Cp(this.long0+Math.asin(Math.sin(m)*Math.sin(w)/Math.cos(p))),M=Math.sin(p),o=Math.atan2((M-this.es*b*this.sin_p12)*Math.tan(p),M*(1-this.es)),t.x=a,t.y=o,t)},names:["Azimuthal_Equidistant","aeqd"]};const Bg={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)},forward:function(t){var e,r,n,i,a,o,s,l=t.x,u=t.y;return n=Cp(l-this.long0),e=Math.sin(u),r=Math.cos(u),i=Math.cos(n),1,((a=this.sin_p14*e+this.cos_p14*r*i)>0||Math.abs(a)<=$f)&&(o=1*this.a*r*Math.sin(n),s=this.y0+1*this.a*(this.cos_p14*e-this.sin_p14*r*i)),t.x=o,t.y=s,t},inverse:function(t){var e,r,n,i,a,o,s;return t.x-=this.x0,t.y-=this.y0,r=Eg((e=Math.sqrt(t.x*t.x+t.y*t.y))/this.a),n=Math.sin(r),i=Math.cos(r),o=this.long0,Math.abs(e)<=$f?(s=this.lat0,t.x=o,t.y=s,t):(s=Eg(i*this.sin_p14+t.y*n*this.cos_p14/e),a=Math.abs(this.lat0)-Zf,Math.abs(a)<=$f?(o=this.lat0>=0?Cp(this.long0+Math.atan2(t.x,-t.y)):Cp(this.long0-Math.atan2(-t.x,t.y)),t.x=o,t.y=s,t):(o=Cp(this.long0+Math.atan2(t.x*n,e*this.cos_p14*i-t.y*this.sin_p14*n)),t.x=o,t.y=s,t))},names:["ortho"]};var zg=1,Gg=2,jg=3,Vg=4,Hg=5,Wg=6,qg={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function Xg(t,e,r,n){var i;return t<$f?(n.value=qg.AREA_0,i=0):(i=Math.atan2(e,r),Math.abs(i)<=rp?n.value=qg.AREA_0:i>rp&&i<=Zf+rp?(n.value=qg.AREA_1,i-=Zf):i>Zf+rp||i<=-(Zf+rp)?(n.value=qg.AREA_2,i=i>=0?i-ip:i+ip):(n.value=qg.AREA_3,i+=Zf)),i}function Yg(t,e){var r=t+e;return r<-ip?r+=np:r>+ip&&(r-=np),r}const Zg={init:function(){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>=Zf-rp/2?this.face=Hg:this.lat0<=-(Zf-rp/2)?this.face=Wg:Math.abs(this.long0)<=rp?this.face=zg:Math.abs(this.long0)<=Zf+rp?this.face=this.long0>0?Gg:Vg:this.face=jg,0!==this.es&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)},forward:function(t){var e,r,n,i,a,o,s={x:0,y:0},l={value:0};if(t.x-=this.long0,e=0!==this.es?Math.atan(this.one_minus_f_squared*Math.tan(t.y)):t.y,r=t.x,this.face===Hg)i=Zf-e,r>=rp&&r<=Zf+rp?(l.value=qg.AREA_0,n=r-Zf):r>Zf+rp||r<=-(Zf+rp)?(l.value=qg.AREA_1,n=r>0?r-ip:r+ip):r>-(Zf+rp)&&r<=-rp?(l.value=qg.AREA_2,n=r+Zf):(l.value=qg.AREA_3,n=r);else if(this.face===Wg)i=Zf+e,r>=rp&&r<=Zf+rp?(l.value=qg.AREA_0,n=-r+Zf):r=-rp?(l.value=qg.AREA_1,n=-r):r<-rp&&r>=-(Zf+rp)?(l.value=qg.AREA_2,n=-r-Zf):(l.value=qg.AREA_3,n=r>0?-r+ip:-r-ip);else{var u,c,h,d,f,p;this.face===Gg?r=Yg(r,+Zf):this.face===jg?r=Yg(r,+ip):this.face===Vg&&(r=Yg(r,-Zf)),d=Math.sin(e),f=Math.cos(e),p=Math.sin(r),u=f*Math.cos(r),c=f*p,h=d,this.face===zg?n=Xg(i=Math.acos(u),h,c,l):this.face===Gg?n=Xg(i=Math.acos(c),h,-u,l):this.face===jg?n=Xg(i=Math.acos(-u),h,-c,l):this.face===Vg?n=Xg(i=Math.acos(-c),h,u,l):(i=n=0,l.value=qg.AREA_0)}return o=Math.atan(12/ip*(n+Math.acos(Math.sin(n)*Math.cos(rp))-Zf)),a=Math.sqrt((1-Math.cos(i))/(Math.cos(o)*Math.cos(o))/(1-Math.cos(Math.atan(1/Math.cos(n))))),l.value===qg.AREA_1?o+=Zf:l.value===qg.AREA_2?o+=ip:l.value===qg.AREA_3&&(o+=1.5*ip),s.x=a*Math.cos(o),s.y=a*Math.sin(o),s.x=s.x*this.a+this.x0,s.y=s.y*this.a+this.y0,t.x=s.x,t.y=s.y,t},inverse:function(t){var e,r,n,i,a,o,s,l,u,c,h,d,f={lam:0,phi:0},p={value:0};if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,r=Math.atan(Math.sqrt(t.x*t.x+t.y*t.y)),e=Math.atan2(t.y,t.x),t.x>=0&&t.x>=Math.abs(t.y)?p.value=qg.AREA_0:t.y>=0&&t.y>=Math.abs(t.x)?(p.value=qg.AREA_1,e-=Zf):t.x<0&&-t.x>=Math.abs(t.y)?(p.value=qg.AREA_2,e=e<0?e+ip:e-ip):(p.value=qg.AREA_3,e+=Zf),u=ip/12*Math.tan(e),a=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),o=Math.atan(a),(s=1-(n=Math.cos(e))*n*(i=Math.tan(r))*i*(1-Math.cos(Math.atan(1/Math.cos(o)))))<-1?s=-1:s>1&&(s=1),this.face===Hg)l=Math.acos(s),f.phi=Zf-l,p.value===qg.AREA_0?f.lam=o+Zf:p.value===qg.AREA_1?f.lam=o<0?o+ip:o-ip:p.value===qg.AREA_2?f.lam=o-Zf:f.lam=o;else if(this.face===Wg)l=Math.acos(s),f.phi=l-Zf,p.value===qg.AREA_0?f.lam=-o+Zf:p.value===qg.AREA_1?f.lam=-o:p.value===qg.AREA_2?f.lam=-o-Zf:f.lam=o<0?-o-ip:-o+ip;else{var m,g,v;u=(m=s)*m,g=(u+=(v=u>=1?0:Math.sqrt(1-u)*Math.sin(o))*v)>=1?0:Math.sqrt(1-u),p.value===qg.AREA_1?(u=g,g=-v,v=u):p.value===qg.AREA_2?(g=-g,v=-v):p.value===qg.AREA_3&&(u=g,g=v,v=-u),this.face===Gg?(u=m,m=-g,g=u):this.face===jg?(m=-m,g=-g):this.face===Vg&&(u=m,m=g,g=-u),f.phi=Math.acos(-v)-Zf,f.lam=Math.atan2(g,m),this.face===Gg?f.lam=Yg(f.lam,-Zf):this.face===jg?f.lam=Yg(f.lam,-ip):this.face===Vg&&(f.lam=Yg(f.lam,+Zf))}return 0!==this.es&&(c=f.phi<0?1:0,h=Math.tan(f.phi),d=this.b/Math.sqrt(h*h+this.one_minus_f_squared),f.phi=Math.atan(Math.sqrt(this.a*this.a-d*d)/(this.one_minus_f*d)),c&&(f.phi=-f.phi)),f.lam+=this.long0,t.x=f.lam,t.y=f.phi,t},names:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"]};var Kg=[[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]],Jg=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,4.22642e-10],[.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]],Qg=.8487,$g=1.3523,tv=ep/5,ev=1/tv,rv=18,nv=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))};const iv={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"},forward:function(t){var e=Cp(t.x-this.long0),r=Math.abs(t.y),n=Math.floor(r*tv);n<0?n=0:n>=rv&&(n=17);var i={x:nv(Kg[n],r=ep*(r-ev*n))*e,y:nv(Jg[n],r)};return t.y<0&&(i.y=-i.y),i.x=i.x*this.a*Qg+this.x0,i.y=i.y*this.a*$g+this.y0,i},inverse:function(t){var e={x:(t.x-this.x0)/(this.a*Qg),y:Math.abs(t.y-this.y0)/(this.a*$g)};if(e.y>=1)e.x/=Kg[18][0],e.y=t.y<0?-Zf:Zf;else{var r=Math.floor(e.y*rv);for(r<0?r=0:r>=rv&&(r=17);;)if(Jg[r][0]>e.y)--r;else{if(!(Jg[r+1][0]<=e.y))break;++r}var n=Jg[r],i=5*(e.y-n[0])/(Jg[r+1][0]-n[0]);i=function(t,e,r,n){for(var i=e;n;--n){var a=t(i);if(i-=a,Math.abs(a)1e10)throw new Error;if(this.radius_g=1+this.radius_g_1,this.C=this.radius_g*this.radius_g-1,0!==this.es){var t=1-this.es,e=1/t;this.radius_p=Math.sqrt(t),this.radius_p2=t,this.radius_p_inv2=e,this.shape="ellipse"}else this.radius_p=1,this.radius_p2=1,this.radius_p_inv2=1,this.shape="sphere";this.title||(this.title="Geostationary Satellite View")},forward:function(t){var e,r,n,i,a=t.x,o=t.y;if(a-=this.long0,"ellipse"===this.shape){o=Math.atan(this.radius_p2*Math.tan(o));var s=this.radius_p/Ym(this.radius_p*Math.cos(o),Math.sin(o));if(r=s*Math.cos(a)*Math.cos(o),n=s*Math.sin(a)*Math.cos(o),i=s*Math.sin(o),(this.radius_g-r)*r-n*n-i*i*this.radius_p_inv2<0)return t.x=Number.NaN,t.y=Number.NaN,t;e=this.radius_g-r,this.flip_axis?(t.x=this.radius_g_1*Math.atan(n/Ym(i,e)),t.y=this.radius_g_1*Math.atan(i/e)):(t.x=this.radius_g_1*Math.atan(n/e),t.y=this.radius_g_1*Math.atan(i/Ym(n,e)))}else"sphere"===this.shape&&(e=Math.cos(o),r=Math.cos(a)*e,n=Math.sin(a)*e,i=Math.sin(o),e=this.radius_g-r,this.flip_axis?(t.x=this.radius_g_1*Math.atan(n/Ym(i,e)),t.y=this.radius_g_1*Math.atan(i/e)):(t.x=this.radius_g_1*Math.atan(n/e),t.y=this.radius_g_1*Math.atan(i/Ym(n,e))));return t.x=t.x*this.a,t.y=t.y*this.a,t},inverse:function(t){var e,r,n,i,a=-1,o=0,s=0;if(t.x=t.x/this.a,t.y=t.y/this.a,"ellipse"===this.shape){this.flip_axis?(s=Math.tan(t.y/this.radius_g_1),o=Math.tan(t.x/this.radius_g_1)*Ym(1,s)):(o=Math.tan(t.x/this.radius_g_1),s=Math.tan(t.y/this.radius_g_1)*Ym(1,o));var l=s/this.radius_p;if(e=o*o+l*l+a*a,(n=(r=2*this.radius_g*a)*r-4*e*this.C)<0)return t.x=Number.NaN,t.y=Number.NaN,t;i=(-r-Math.sqrt(n))/(2*e),a=this.radius_g+i*a,o*=i,s*=i,t.x=Math.atan2(o,a),t.y=Math.atan(s*Math.cos(t.x)/a),t.y=Math.atan(this.radius_p_inv2*Math.tan(t.y))}else if("sphere"===this.shape){if(this.flip_axis?(s=Math.tan(t.y/this.radius_g_1),o=Math.tan(t.x/this.radius_g_1)*Math.sqrt(1+s*s)):(o=Math.tan(t.x/this.radius_g_1),s=Math.tan(t.y/this.radius_g_1)*Math.sqrt(1+o*o)),e=o*o+s*s+a*a,(n=(r=2*this.radius_g*a)*r-4*e*this.C)<0)return t.x=Number.NaN,t.y=Number.NaN,t;i=(-r-Math.sqrt(n))/(2*e),a=this.radius_g+i*a,o*=i,s*=i,t.x=Math.atan2(o,a),t.y=Math.atan(s*Math.cos(t.x)/a)}return t.x=t.x+this.long0,t},names:["Geostationary Satellite View","Geostationary_Satellite","geos"]};var fv;cm.defaultDatum="WGS84",cm.Proj=Zp,cm.WGS84=new cm.Proj("WGS84"),cm.Point=Pm,cm.toPoint=im,cm.defs=Mp,cm.nadgrid=function(t,e){var r=new DataView(e),n=function(t){var e=t.getInt32(8,!1);if(11===e)return!1;e=t.getInt32(8,!0),11!==e&&console.warn("Failed to detect nadgrid endian-ness, defaulting to little-endian");return!0}(r),i=function(t,e){return{nFields:t.getInt32(8,e),nSubgridFields:t.getInt32(24,e),nSubgrids:t.getInt32(40,e),shiftType:Wp(t,56,64).trim(),fromSemiMajorAxis:t.getFloat64(120,e),fromSemiMinorAxis:t.getFloat64(136,e),toSemiMajorAxis:t.getFloat64(152,e),toSemiMinorAxis:t.getFloat64(168,e)}}(r,n);i.nSubgrids>1&&console.log("Only single NTv2 subgrids are currently supported, subsequent sub grids are ignored");var a=function(t,e,r){for(var n=176,i=[],a=0;a1?r:2,a=e;void 0===a&&(a=i>2?t.slice():new Array(n));for(var o=0;oDv?s=Dv:s<-Dv&&(s=-Dv),a[o+1]=s}return a}function Uv(t,e,r){var n=t.length,i=r>1?r:2,a=e;void 0===a&&(a=i>2?t.slice():new Array(n));for(var o=0;oi&&(l|=Qv.RIGHT),sa&&(l|=Qv.ABOVE),l===Qv.UNKNOWN&&(l=Qv.INTERSECTING),l}function dy(){return[1/0,1/0,-1/0,-1/0]}function fy(t,e,r,n,i){return i?(i[0]=t,i[1]=e,i[2]=r,i[3]=n,i):[t,e,r,n]}function py(t){return fy(1/0,1/0,-1/0,-1/0,t)}function my(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function gy(t,e){return e[0]t[2]&&(t[2]=e[2]),e[1]t[3]&&(t[3]=e[3]),t}function vy(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function yy(t,e){for(var r=0,n=e.length;re[0]?n[0]=t[0]:n[0]=e[0],t[1]>e[1]?n[1]=t[1]:n[1]=e[1],t[2]=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function ky(t){return t[2]=o&&m<=l),n||!(a&Qv.RIGHT)||i&Qv.RIGHT||(n=(g=f-(d-l)*p)>=s&&g<=u),n||!(a&Qv.BELOW)||i&Qv.BELOW||(n=(m=d-(f-s)/p)>=o&&m<=l),n||!(a&Qv.LEFT)||i&Qv.LEFT||(n=(g=f-(d-o)*p)>=s&&g<=u)}return n}function Ny(t,e,r,n){var i=[];if(n>1)for(var a=t[2]-t[0],o=t[3]-t[1],s=0;s=r[2])){var i=Oy(r),a=Math.floor((n[0]-r[0])/i)*i;t[0]-=a,t[2]-=a}return t}function By(t,e){if(e.canWrapX()){var r=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[r[0],t[1],r[2],t[3]]];Uy(t,e);var n=Oy(r);if(Oy(t)>n)return[[r[0],t[1],r[2],t[3]]];if(t[0]r[2])return[[t[0],t[1],r[2],t[3]],[r[0],t[1],t[2]-n,t[3]]]}return[t]}const zy=Object.freeze(Object.defineProperty({__proto__:null,applyTransform:Ny,approximatelyEquals:function(t,e,r){return Math.abs(t[0]-e[0])=u?e[s+c]:l[c];return o}}function $y(t,e){if(t===e)return!0;var r=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||tx(t,e)===qy)&&r}function tx(t,e){var r=Jv(t.getCode(),e.getCode());return r||(r=Xy),r}function ex(t,e){return tx(Zy(t),Zy(e))}function rx(t,e,r){return ex(e,r)(t,void 0,t.length)}function nx(t,e,r){return function(n){var i,a;if(t.canWrapX()){var o=t.getExtent(),s=Oy(o);a=function(t,e,r){var n=e.getExtent(),i=0;if(e.canWrapX()&&(t[0]n[2])){var a=r||Oy(n);i=Math.floor((t[0]-n[0])/a)}return i}(n=n.slice(0),t,s),a&&(n[0]=n[0]-a*s),n[0]=xv(n[0],o[0],o[2]),n[1]=xv(n[1],o[1],o[3]),i=r(n)}else i=r(n);return a&&e.canWrapX()&&(i[0]+=a*Oy(e.getExtent())),i}}Jy(Fv),Jy(Vv),Gy=Fv,jy=Nv,Vy=Uv,Vv.forEach((function(t){Gy.forEach((function(e){Kv(t,e,jy),Kv(e,t,Vy)}))}));const ix=Object.freeze(Object.defineProperty({__proto__:null,register:function(t){var e,r,n,i,a,o,s,l,u=Object.keys(t.defs),c=u.length;for(e=0;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r1?r-1:0),a=1;a1?e-1:0),n=1;ne?1:t0)},e.prototype.removeEventListener=function(t,e){var r=this.listeners_&&this.listeners_[t];if(r){var n=r.indexOf(e);-1!==n&&(this.pendingRemovals_&&t in this.pendingRemovals_?(r[n]=Yx,++this.pendingRemovals_[t]):(r.splice(n,1),0===r.length&&delete this.listeners_[t]))}},e}(jx),Jx={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},Qx=Object.freeze(Object.defineProperty({__proto__:null,default:Jx},Symbol.toStringTag,{value:"Module"}));var $x=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const t_=function(t){function e(e,r,n){var i=t.call(this)||this,a=n||{};return i.tileCoord=e,i.state=r,i.interimTile=null,i.key="",i.transition_=void 0===a.transition?250:a.transition,i.transitionStarts_={},i.interpolate=!!a.interpolate,i}return $x(e,t),e.prototype.changed=function(){this.dispatchEvent(Gx.CHANGE)},e.prototype.release=function(){},e.prototype.getKey=function(){return this.key+"/"+this.tileCoord},e.prototype.getInterimTile=function(){if(!this.interimTile)return this;var t=this.interimTile;do{if(t.getState()==Jx.LOADED)return this.transition_=0,t;t=t.interimTile}while(t);return this},e.prototype.refreshInterimChain=function(){if(this.interimTile){var t=this.interimTile,e=this;do{if(t.getState()==Jx.LOADED){t.interimTile=null;break}t.getState()==Jx.LOADING?e=t:t.getState()==Jx.IDLE?e.interimTile=t.interimTile:e=t,t=e.interimTile}while(t)}},e.prototype.getTileCoord=function(){return this.tileCoord},e.prototype.getState=function(){return this.state},e.prototype.setState=function(t){if(this.state!==Jx.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()},e.prototype.load=function(){$v()},e.prototype.getAlpha=function(t,e){if(!this.transition_)return 1;var r=this.transitionStarts_[t];if(r){if(-1===r)return 1}else r=e,this.transitionStarts_[t]=r;var n,i=e-r+1e3/60;return i>=this.transition_?1:(n=i/this.transition_,Math.pow(n,3))},e.prototype.inTransition=function(t){return!!this.transition_&&-1!==this.transitionStarts_[t]},e.prototype.endTransition=function(t){this.transition_&&(this.transitionStarts_[t]=-1)},e}(Kx);var e_="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"";e_.indexOf("firefox"),-1!==e_.indexOf("safari")&&-1==e_.indexOf("chrom")&&(e_.indexOf("version/15.4")>=0||e_.match(/cpu (os|iphone os) 15_4 like mac os x/)),-1!==e_.indexOf("webkit")&&e_.indexOf("edge"),e_.indexOf("macintosh");var r_="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,n_="undefined"!=typeof Image&&Image.prototype.decode;function i_(t,e,r,n){var i;return i=r&&r.length?r.shift():r_?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(i.width=t),e&&(i.height=e),i.getContext("2d",n)}function a_(t){var e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}!function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch(t){}}();var o_=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const s_=function(t){function e(e,r,n,i){var a=t.call(this)||this;return a.extent=e,a.pixelRatio_=n,a.resolution=r,a.state=i,a}return o_(e,t),e.prototype.changed=function(){this.dispatchEvent(Gx.CHANGE)},e.prototype.getExtent=function(){return this.extent},e.prototype.getImage=function(){return $v()},e.prototype.getPixelRatio=function(){return this.pixelRatio_},e.prototype.getResolution=function(){return this.resolution},e.prototype.getState=function(){return this.state},e.prototype.load=function(){$v()},e}(Kx),l_={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function u_(t,e,r,n,i){if(n&&n!==t&&(r=r.bind(n)),i){var a=r;r=function(){t.removeEventListener(e,r),a.apply(this,arguments)}}var o={target:t,type:e,listener:r};return t.addEventListener(e,r),o}function c_(t,e,r,n){return u_(t,e,r,n,!0)}function h_(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),qv(t))}const d_=Object.freeze(Object.defineProperty({__proto__:null,listen:u_,listenOnce:c_,unlistenByKey:h_},Symbol.toStringTag,{value:"Module"}));var f_=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();function p_(t,e,r){var n=t,i=!0,a=!1,o=!1,s=[c_(n,Gx.LOAD,(function(){o=!0,a||e()}))];return n.src&&n_?(a=!0,n.decode().then((function(){i&&e()})).catch((function(t){i&&(o?e():r())}))):s.push(c_(n,Gx.ERROR,r)),function(){i=!1,s.forEach(h_)}}!function(t){function e(e,r,n,i,a,o){var s=t.call(this,e,r,n,l_.IDLE)||this;return s.src_=i,s.image_=new Image,null!==a&&(s.image_.crossOrigin=a),s.unlisten_=null,s.state=l_.IDLE,s.imageLoadFunction_=o,s}f_(e,t),e.prototype.getImage=function(){return this.image_},e.prototype.handleImageError_=function(){this.state=l_.ERROR,this.unlistenImage_(),this.changed()},e.prototype.handleImageLoad_=function(){void 0===this.resolution&&(this.resolution=Py(this.extent)/this.image_.height),this.state=l_.LOADED,this.unlistenImage_(),this.changed()},e.prototype.load=function(){this.state!=l_.IDLE&&this.state!=l_.ERROR||(this.state=l_.LOADING,this.changed(),this.imageLoadFunction_(this,this.src_),this.unlisten_=p_(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))},e.prototype.setImage=function(t){this.image_=t,this.resolution=Py(this.extent)/this.image_.height},e.prototype.unlistenImage_=function(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}(s_);var m_=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const g_=function(t){function e(e,r,n,i,a,o){var s=t.call(this,e,r,o)||this;return s.crossOrigin_=i,s.src_=n,s.key=n,s.image_=new Image,null!==i&&(s.image_.crossOrigin=i),s.unlisten_=null,s.tileLoadFunction_=a,s}return m_(e,t),e.prototype.getImage=function(){return this.image_},e.prototype.setImage=function(t){this.image_=t,this.state=Jx.LOADED,this.unlistenImage_(),this.changed()},e.prototype.handleImageError_=function(){var t;this.state=Jx.ERROR,this.unlistenImage_(),this.image_=((t=i_(1,1)).fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas),this.changed()},e.prototype.handleImageLoad_=function(){var t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=Jx.LOADED:this.state=Jx.EMPTY,this.unlistenImage_(),this.changed()},e.prototype.load=function(){this.state==Jx.ERROR&&(this.state=Jx.IDLE,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==Jx.IDLE&&(this.state=Jx.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=p_(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))},e.prototype.unlistenImage_=function(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)},e}(t_);const v_=function(){function t(t,e,r,n,i,a){this.sourceProj_=t,this.targetProj_=e;var o={},s=ex(this.targetProj_,this.sourceProj_);this.transformInv_=function(t){var e=t[0]+"/"+t[1];return o[e]||(o[e]=s(t)),o[e]},this.maxSourceExtent_=n,this.errorThresholdSquared_=i*i,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&Oy(n)==Oy(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Oy(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Oy(this.targetProj_.getExtent()):null;var l=Iy(r),u=Ly(r),c=Ty(r),h=Sy(r),d=this.transformInv_(l),f=this.transformInv_(u),p=this.transformInv_(c),m=this.transformInv_(h),g=10+(a?Math.max(0,Math.ceil(wv(My(r)/(a*a*256*256)))):0);if(this.addQuad_(l,u,c,h,d,f,p,m,g),this.wrapsXInSource_){var v=1/0;this.triangles_.forEach((function(t,e,r){v=Math.min(v,t.source[0][0],t.source[1][0],t.source[2][0])})),this.triangles_.forEach(function(t){if(Math.max(t.source[0][0],t.source[1][0],t.source[2][0])-v>this.sourceWorldWidth_/2){var e=[[t.source[0][0],t.source[0][1]],[t.source[1][0],t.source[1][1]],[t.source[2][0],t.source[2][1]]];e[0][0]-v>this.sourceWorldWidth_/2&&(e[0][0]-=this.sourceWorldWidth_),e[1][0]-v>this.sourceWorldWidth_/2&&(e[1][0]-=this.sourceWorldWidth_),e[2][0]-v>this.sourceWorldWidth_/2&&(e[2][0]-=this.sourceWorldWidth_);var r=Math.min(e[0][0],e[1][0],e[2][0]);Math.max(e[0][0],e[1][0],e[2][0])-r.5&&c<1,f=!1;if(l>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_)f=Oy(ay([t,e,r,n]))/this.targetWorldWidth_>.25||f;!d&&this.sourceProj_.isGlobal()&&c&&(f=c>.25||f)}if(!(!f&&this.maxSourceExtent_&&isFinite(u[0])&&isFinite(u[1])&&isFinite(u[2])&&isFinite(u[3]))||Dy(u,this.maxSourceExtent_)){var p=0;if(!(f||isFinite(i[0])&&isFinite(i[1])&&isFinite(a[0])&&isFinite(a[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(s[0])&&isFinite(s[1])))if(l>0)f=!0;else if(1!=(p=(isFinite(i[0])&&isFinite(i[1])?0:8)+(isFinite(a[0])&&isFinite(a[1])?0:4)+(isFinite(o[0])&&isFinite(o[1])?0:2)+(isFinite(s[0])&&isFinite(s[1])?0:1))&&2!=p&&4!=p&&8!=p)return;if(l>0){if(!f){var m=[(t[0]+r[0])/2,(t[1]+r[1])/2],g=this.transformInv_(m),v=void 0;if(d)v=(Mv(i[0],h)+Mv(o[0],h))/2-Mv(g[0],h);else v=(i[0]+o[0])/2-g[0];var y=(i[1]+o[1])/2-g[1];f=v*v+y*y>this.errorThresholdSquared_}if(f){if(Math.abs(t[0]-r[0])<=Math.abs(t[1]-r[1])){var x=[(e[0]+r[0])/2,(e[1]+r[1])/2],_=this.transformInv_(x),w=[(n[0]+t[0])/2,(n[1]+t[1])/2],b=this.transformInv_(w);this.addQuad_(t,e,x,w,i,a,_,b,l-1),this.addQuad_(w,x,r,n,b,_,o,s,l-1)}else{var M=[(t[0]+e[0])/2,(t[1]+e[1])/2],S=this.transformInv_(M),T=[(r[0]+n[0])/2,(r[1]+n[1])/2],E=this.transformInv_(T);this.addQuad_(t,M,T,n,i,S,E,s,l-1),this.addQuad_(M,e,r,T,S,a,o,E,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}0==(11&p)&&this.addTriangle_(t,r,n,i,o,s),0==(14&p)&&this.addTriangle_(t,r,e,i,o,a),p&&(0==(13&p)&&this.addTriangle_(e,n,t,a,s,i),0==(7&p)&&this.addTriangle_(e,n,r,a,s,o))}},t.prototype.calculateSourceExtent=function(){var t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach((function(e,r,n){var i=e.source;vy(t,i[0]),vy(t,i[1]),vy(t,i[2])})),t},t.prototype.getTriangles=function(){return this.triangles_},t}();var y_,x_={imageSmoothingEnabled:!1,msImageSmoothingEnabled:!1},__=[];function w_(t,e,r,n,i){t.beginPath(),t.moveTo(0,0),t.lineTo(e,r),t.lineTo(n,i),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,n)+1,Math.max(r,i)),t.restore()}function b_(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function M_(t,e,r,n){var i=rx(r,e,t),a=Ky(e,n,r),o=e.getMetersPerUnit();void 0!==o&&(a*=o);var s=t.getMetersPerUnit();void 0!==s&&(a/=s);var l=t.getExtent();if(!l||ly(l,i)){var u=Ky(t,a,i)/a;isFinite(u)&&u>0&&(a/=u)}return a}function S_(t,e,r,n,i,a,o,s,l,u,c,h){var d=i_(Math.round(r*t),Math.round(r*e),__);if(h||Wv(d,x_),0===l.length)return d.canvas;function f(t){return Math.round(t*r)/r}d.scale(r,r),d.globalCompositeOperation="lighter";var p=[1/0,1/0,-1/0,-1/0];l.forEach((function(t,e,r){gy(p,t.extent)}));var m=Oy(p),g=Py(p),v=i_(Math.round(r*m/n),Math.round(r*g/n));h||Wv(v,x_);var y=r/n;l.forEach((function(t,e,r){var n=t.extent[0]-p[0],i=-(t.extent[3]-p[3]),a=Oy(t.extent),o=Py(t.extent);t.image.width>0&&t.image.height>0&&v.drawImage(t.image,u,u,t.image.width-2*u,t.image.height-2*u,n*y,i*y,a*y,o*y)}));var x=Iy(o);return s.getTriangles().forEach((function(t,e,i){var o=t.source,s=t.target,l=o[0][0],u=o[0][1],c=o[1][0],m=o[1][1],g=o[2][0],y=o[2][1],_=f((s[0][0]-x[0])/a),w=f(-(s[0][1]-x[1])/a),b=f((s[1][0]-x[0])/a),M=f(-(s[1][1]-x[1])/a),S=f((s[2][0]-x[0])/a),T=f(-(s[2][1]-x[1])/a),E=l,A=u;l=0,u=0;var R=function(t){for(var e=t.length,r=0;ri&&(i=o,n=a)}if(0===i)return null;var s=t[n];t[n]=t[r],t[r]=s;for(var l=r+1;l=0;d--){h[d]=t[d][e]/t[d][d];for(var f=d-1;f>=0;f--)t[f][e]-=t[f][d]*h[d]}return h}([[c-=E,m-=A,0,0,b-_],[g-=E,y-=A,0,0,S-_],[0,0,c,m,M-w],[0,0,g,y,T-w]]);if(R){if(d.save(),d.beginPath(),function(){if(void 0===y_){var t=document.createElement("canvas").getContext("2d");t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",w_(t,4,5,4,0),w_(t,4,5,0,5);var e=t.getImageData(0,0,3,3).data;y_=b_(e,0)||b_(e,4)||b_(e,8)}return y_}()||!h){d.moveTo(b,M);for(var P=_-b,C=w-M,I=0;I<4;I++)d.lineTo(b+f((I+1)*P/4),M+f(I*C/3)),3!=I&&d.lineTo(b+f((I+1)*P/4),M+f((I+1)*C/3));d.lineTo(S,T)}else d.moveTo(b,M),d.lineTo(_,w),d.lineTo(S,T);d.clip(),d.transform(R[0],R[2],R[1],R[3],_,w),d.translate(p[0]-E,p[3]-A),d.scale(n/r,-n/r),d.drawImage(v.canvas,0,0),d.restore()}})),c&&(d.save(),d.globalCompositeOperation="source-over",d.strokeStyle="black",d.lineWidth=1,s.getTriangles().forEach((function(t,e,r){var n=t.target,i=(n[0][0]-x[0])/a,o=-(n[0][1]-x[1])/a,s=(n[1][0]-x[0])/a,l=-(n[1][1]-x[1])/a,u=(n[2][0]-x[0])/a,c=-(n[2][1]-x[1])/a;d.beginPath(),d.moveTo(s,l),d.lineTo(i,o),d.lineTo(u,c),d.closePath(),d.stroke()})),d.restore()),d.canvas}var T_=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const E_=function(t){function e(e,r,n,i,a,o,s,l,u,c,h,d){var f=t.call(this,a,Jx.IDLE,{interpolate:!!d})||this;f.renderEdges_=void 0!==h&&h,f.pixelRatio_=s,f.gutter_=l,f.canvas_=null,f.sourceTileGrid_=r,f.targetTileGrid_=i,f.wrappedTileCoord_=o||a,f.sourceTiles_=[],f.sourcesListenerKeys_=null,f.sourceZ_=0;var p=i.getTileCoordExtent(f.wrappedTileCoord_),m=f.targetTileGrid_.getExtent(),g=f.sourceTileGrid_.getExtent(),v=m?Cy(p,m):p;if(0===My(v))return f.state=Jx.EMPTY,f;var y=e.getExtent();y&&(g=g?Cy(g,y):y);var x=i.getResolution(f.wrappedTileCoord_[0]),_=function(t,e,r,n){var i=Ey(r),a=M_(t,e,i,n);return(!isFinite(a)||a<=0)&&by(r,(function(r){return a=M_(t,e,r,n),isFinite(a)&&a>0})),a}(e,n,v,x);if(!isFinite(_)||_<=0)return f.state=Jx.EMPTY,f;var w=void 0!==c?c:.5;if(f.triangulation_=new v_(e,n,v,g,_*w,x),0===f.triangulation_.getTriangles().length)return f.state=Jx.EMPTY,f;f.sourceZ_=r.getZForResolution(_);var b=f.triangulation_.calculateSourceExtent();if(g&&(e.canWrapX()?(b[1]=xv(b[1],g[1],g[3]),b[3]=xv(b[3],g[1],g[3])):b=Cy(b,g)),My(b)){for(var M=r.getTileRangeForExtentAndZ(b,f.sourceZ_),S=M.minX;S<=M.maxX;S++)for(var T=M.minY;T<=M.maxY;T++){var E=u(f.sourceZ_,S,T,s);E&&f.sourceTiles_.push(E)}0===f.sourceTiles_.length&&(f.state=Jx.EMPTY)}else f.state=Jx.EMPTY;return f}return T_(e,t),e.prototype.getImage=function(){return this.canvas_},e.prototype.reproject_=function(){var t=[];if(this.sourceTiles_.forEach(function(e,r,n){e&&e.getState()==Jx.LOADED&&t.push({extent:this.sourceTileGrid_.getTileCoordExtent(e.tileCoord),image:e.getImage()})}.bind(this)),this.sourceTiles_.length=0,0===t.length)this.state=Jx.ERROR;else{var e=this.wrappedTileCoord_[0],r=this.targetTileGrid_.getTileSize(e),n="number"==typeof r?r:r[0],i="number"==typeof r?r:r[1],a=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),s=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=S_(n,i,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),a,s,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=Jx.LOADED}this.changed()},e.prototype.load=function(){if(this.state==Jx.IDLE){this.state=Jx.LOADING,this.changed();var t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(function(e,r,n){var i=e.getState();if(i==Jx.IDLE||i==Jx.LOADING){t++;var a=u_(e,Gx.CHANGE,(function(r){var n=e.getState();n!=Jx.LOADED&&n!=Jx.ERROR&&n!=Jx.EMPTY||(h_(a),0===--t&&(this.unlistenSources_(),this.reproject_()))}),this);this.sourcesListenerKeys_.push(a)}}.bind(this)),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function(t,e,r){t.getState()==Jx.IDLE&&t.load()}))}},e.prototype.unlistenSources_=function(){this.sourcesListenerKeys_.forEach(h_),this.sourcesListenerKeys_=null},e.prototype.release=function(){this.canvas_&&(a_(this.canvas_.getContext("2d")),__.push(this.canvas_),this.canvas_=null),t.prototype.release.call(this)},e}(t_);const A_=function(){function t(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}return t.prototype.canExpireCache=function(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark},t.prototype.expireCache=function(t){for(;this.canExpireCache();)this.pop()},t.prototype.clear=function(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null},t.prototype.containsKey=function(t){return this.entries_.hasOwnProperty(t)},t.prototype.forEach=function(t){for(var e=this.oldest_;e;)t(e.value_,e.key_,this),e=e.newer},t.prototype.get=function(t,e){var r=this.entries_[t];return iy(void 0!==r,15),r===this.newest_||(r===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(r.newer.older=r.older,r.older.newer=r.newer),r.newer=null,r.older=this.newest_,this.newest_.newer=r,this.newest_=r),r.value_},t.prototype.remove=function(t){var e=this.entries_[t];return iy(void 0!==e,15),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_},t.prototype.getCount=function(){return this.count_},t.prototype.getKeys=function(){var t,e=new Array(this.count_),r=0;for(t=this.newest_;t;t=t.older)e[r++]=t.key_;return e},t.prototype.getValues=function(){var t,e=new Array(this.count_),r=0;for(t=this.newest_;t;t=t.older)e[r++]=t.value_;return e},t.prototype.peekLast=function(){return this.oldest_.value_},t.prototype.peekLastKey=function(){return this.oldest_.key_},t.prototype.peekFirstKey=function(){return this.newest_.key_},t.prototype.peek=function(t){if(this.containsKey(t))return this.entries_[t].value_},t.prototype.pop=function(){var t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_},t.prototype.replace=function(t,e){this.get(t),this.entries_[t].value_=e},t.prototype.set=function(t,e){iy(!(t in this.entries_),16);var r={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=r:this.oldest_=r,this.newest_=r,this.entries_[t]=r,++this.count_},t.prototype.setSize=function(t){this.highWaterMark=t},t}();function R_(t,e,r,n){return void 0!==n?(n[0]=t,n[1]=e,n[2]=r,n):[t,e,r]}function P_(t,e,r){return t+"/"+e+"/"+r}function C_(t){return P_(t[0],t[1],t[2])}function I_(t){return t.split("/").map(Number)}function L_(t){return(t[1]<this.maxX&&(this.maxX=t.maxX),t.minYthis.maxY&&(this.maxY=t.maxY)},t.prototype.getHeight=function(){return this.maxY-this.minY+1},t.prototype.getSize=function(){return[this.getWidth(),this.getHeight()]},t.prototype.getWidth=function(){return this.maxX-this.minX+1},t.prototype.intersects=function(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY},t}();function Z_(t,e,r,n,i){return void 0!==i?(i.minX=t,i.maxX=e,i.minY=r,i.maxY=n,i):new Y_(t,e,r,n)}const K_=Y_;var J_=42,Q_=256;function $_(t,e,r,n,i,a){for(var o=0,s=t[r-n],l=t[r-n+1];ea&&(u-s)*(a-l)-(i-s)*(c-l)>0&&o++:c<=a&&(u-s)*(a-l)-(i-s)*(c-l)<0&&o--,s=u,l=c}return 0!==o}function tw(t,e,r,n,i){return!!function(t,e,r,n,i){var a=xy([1/0,1/0,-1/0,-1/0],t,e,r,n);return!!Dy(i,a)&&(!!uy(i,a)||a[0]>=i[0]&&a[2]<=i[2]||a[1]>=i[1]&&a[3]<=i[3]||function(t,e,r,n,i){var a;for(e+=n;e0||r&&0===a)}))),17),!t.origins)for(var a=0,o=this.resolutions_.length-1;a=this.minZoom;){if(e(s,2===this.zoomFactor_?Z_(i=Math.floor(i/2),i,a=Math.floor(a/2),a,r):this.getTileRangeForExtentAndZ(o,s,r)))return!0;--s}return!1},t.prototype.getExtent=function(){return this.extent_},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.getMinZoom=function(){return this.minZoom},t.prototype.getOrigin=function(t){return this.origin_?this.origin_:this.origins_[t]},t.prototype.getResolution=function(t){return this.resolutions_[t]},t.prototype.getResolutions=function(){return this.resolutions_},t.prototype.getTileCoordChildTileRange=function(t,e,r){if(t[0]this.maxZoom||e0){for(i=1;i0?i-1:i:t[i-1]-e0?n:Math.max(o/s[0],a/s[1]),u=i+1,c=new Array(u),h=0;hr||r>e.getMaxZoom())return!1;var a=e.getFullTileRange(r);return!a||a.containsXY(n,i)}(t,n)?t:null},e.prototype.clear=function(){this.tileCache.clear()},e.prototype.refresh=function(){this.clear(),t.prototype.refresh.call(this)},e.prototype.updateCacheSize=function(t,e){var r=this.getTileCacheForProjection(e);t>r.highWaterMark&&(r.highWaterMark=t)},e.prototype.useTile=function(t,e,r,n){},e}(X_),dw=function(t){function e(e,r){var n=t.call(this,e)||this;return n.tile=r,n}return cw(e,t),e}(Vx);const fw=hw;function pw(t,e){var r=/\{z\}/g,n=/\{x\}/g,i=/\{y\}/g,a=/\{-y\}/g;return function(o,s,l){return o?t.replace(r,o[0].toString()).replace(n,o[1].toString()).replace(i,o[2].toString()).replace(a,(function(){var t=o[0],r=e.getFullTileRange(t);return iy(r,55),(r.getHeight()-o[2]-1).toString()})):void 0}}function mw(t,e){for(var r=t.length,n=new Array(r),i=0;io)return 1;if(o>a)return-1}return 0}(t,"1.3")>=0},e.prototype.tileUrlFunction=function(t,e,r){var n=this.getTileGrid();if(n||(n=this.getTileGridForProjection(r)),!(n.getResolutions().length<=t[0])){1==e||this.hidpi_&&void 0!==this.serverType_||(e=1);var i=n.getResolution(t[0]),a=n.getTileCoordExtent(t,this.tmpExtent_),o=nw(n.getTileSize(t[0]),this.tmpSize),s=this.gutter_;0!==s&&(o=ew(o,s,this.tmpSize),a=oy(a,i*s,a)),1!=e&&(o=rw(o,e,this.tmpSize));var l={SERVICE:"WMS",VERSION:bw,REQUEST:"GetMap",FORMAT:"image/png",TRANSPARENT:!0};return Wv(l,this.params_),this.getRequestUrl_(t,o,a,e,r,l)}},e}(ww);const Ew=of(Object.freeze(Object.defineProperty({__proto__:null,default:Tw},Symbol.toStringTag,{value:"Module"}))),Aw="add",Rw="remove";var Pw=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Cw="length",Iw=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.element=r,i.index=n,i}return Pw(e,t),e}(Vx);const Lw=function(t){function e(e,r){var n=t.call(this)||this;n.on,n.once,n.un;var i=r||{};if(n.unique_=!!i.unique,n.array_=e||[],n.unique_)for(var a=0,o=n.array_.length;a0;)this.pop()},e.prototype.extend=function(t){for(var e=0,r=t.length;er;){if(n-r>600){var a=n-r+1,o=e-r+1,s=Math.log(a),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(a-l)/a)*(o-a/2<0?-1:1);Dw(t,e,Math.max(r,Math.floor(e-o*l/a+u)),Math.min(n,Math.floor(e+(a-o)*l/a+u)),i)}var c=t[e],h=r,d=n;for(kw(t,r,e),i(t[n],c)>0&&kw(t,r,n);h0;)d--}0===i(t[r],c)?kw(t,r,d):kw(t,++d,n),d<=e&&(r=d+1),e<=d&&(n=d-1)}}function kw(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Fw(t,e){return te?1:0}function Nw(t,e,r){if(!r)return e.indexOf(t);for(let n=0;n=t.minX&&e.maxY>=t.minY}function Yw(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Zw(t,e,r,n,i){const a=[e,r];for(;a.length;){if((r=a.pop())-(e=a.pop())<=n)continue;const o=e+Math.ceil((r-e)/n/2)*n;Ow(t,o,e,r,i),a.push(e,o,o,r)}}const Kw=function(){function t(t){this.rbush_=new class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const r=[];if(!Xw(t,e))return r;const n=this.toBBox,i=[];for(;e;){for(let a=0;a=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(n,i,e)}_split(t,e){const r=t[e],n=r.children.length,i=this._minEntries;this._chooseSplitAxis(r,i,n);const a=this._chooseSplitIndex(r,i,n),o=Yw(r.children.splice(a,r.children.length-a));o.height=r.height,o.leaf=r.leaf,Uw(r,this.toBBox),Uw(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(r,o)}_splitRoot(t,e){this.data=Yw([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Uw(this.data,this.toBBox)}_chooseSplitIndex(t,e,r){let n,i=1/0,a=1/0;for(let o=e;o<=r-e;o++){const e=Bw(t,0,o,this.toBBox),s=Bw(t,o,r,this.toBBox),l=Ww(e,s),u=Vw(e)+Vw(s);l=e;n--){const e=t.children[n];zw(o,t.leaf?i(e):e),s+=Hw(o)}return s}_adjustParentBBoxes(t,e,r){for(let n=r;n>=0;n--)zw(e[n],t)}_condense(t){for(let e,r=t.length-1;r>=0;r--)0===t[r].children.length?r>0?(e=t[r-1].children,e.splice(e.indexOf(t[r]),1)):this.clear():Uw(t[r],this.toBBox)}}(t),this.items_={}}return t.prototype.insert=function(t,e){var r={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(r),this.items_[ey(e)]=r},t.prototype.load=function(t,e){for(var r=new Array(e.length),n=0,i=e.length;n=200&&s.status<300){var n=e.getType(),l=void 0;"json"==n||"text"==n?l=s.responseText:"xml"==n?(l=s.responseXML)||(l=(new DOMParser).parseFromString(s.responseText,"application/xml")):"arraybuffer"==n&&(l=s.response),l?a(e.readFeatures(l,{extent:r,featureProjection:i}),e.readProjection(l)):o()}else o()},s.onerror=o,s.send()}function sb(t,e){return function(r,n,i,a,o){var s=this;ob(t,e,r,n,i,(function(t,e){s.addFeatures(t),void 0!==a&&a(t)}),o||Yx)}}var lb=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ub=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.feature=r,i.features=n,i}return lb(e,t),e}(Vx),cb=function(t){function e(e){var r=this,n=e||{};(r=t.call(this,{attributions:n.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===n.wrapX||n.wrapX})||this).on,r.once,r.un,r.loader_=Yx,r.format_=n.format,r.overlaps_=void 0===n.overlaps||n.overlaps,r.url_=n.url,void 0!==n.loader?r.loader_=n.loader:void 0!==r.url_&&(iy(r.format_,7),r.loader_=sb(r.url_,r.format_)),r.strategy_=void 0!==n.strategy?n.strategy:ib;var i,a,o=void 0===n.useSpatialIndex||n.useSpatialIndex;return r.featuresRtree_=o?new Kw:null,r.loadedExtentsRtree_=new Kw,r.loadingExtentsCount_=0,r.nullGeometryFeatures_={},r.idIndex_={},r.uidIndex_={},r.featureChangeKeys_={},r.featuresCollection_=null,Array.isArray(n.features)?a=n.features:n.features&&(a=(i=n.features).getArray()),o||void 0!==i||(i=new Lw(a)),void 0!==a&&r.addFeaturesInternal(a),void 0!==i&&r.bindFeaturesCollection_(i),r}return lb(e,t),e.prototype.addFeature=function(t){this.addFeatureInternal(t),this.changed()},e.prototype.addFeatureInternal=function(t){var e=ey(t);if(this.addToIndex_(e,t)){this.setupChangeEvents_(e,t);var r=t.getGeometry();if(r){var n=r.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new ub(Jw,t))}else this.featuresCollection_&&this.featuresCollection_.remove(t)},e.prototype.setupChangeEvents_=function(t,e){this.featureChangeKeys_[t]=[u_(e,Gx.CHANGE,this.handleFeatureChange_,this),u_(e,U_,this.handleFeatureChange_,this)]},e.prototype.addToIndex_=function(t,e){var r=!0,n=e.getId();return void 0!==n&&(n.toString()in this.idIndex_?r=!1:this.idIndex_[n.toString()]=e),r&&(iy(!(t in this.uidIndex_),30),this.uidIndex_[t]=e),r},e.prototype.addFeatures=function(t){this.addFeaturesInternal(t),this.changed()},e.prototype.addFeaturesInternal=function(t){for(var e=[],r=[],n=[],i=0,a=t.length;i0},e.prototype.refresh=function(){this.clear(!0),this.loadedExtentsRtree_.clear(),t.prototype.refresh.call(this)},e.prototype.removeLoadedExtent=function(t){var e,r=this.loadedExtentsRtree_;r.forEachInExtent(t,(function(r){if(my(r.extent,t))return e=r,!0})),e&&r.remove(e)},e.prototype.removeFeature=function(t){if(t){var e=ey(t);e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.removeFeatureInternal(t)&&this.changed()}},e.prototype.removeFeatureInternal=function(t){var e=ey(t),r=this.featureChangeKeys_[e];if(r){r.forEach(h_),delete this.featureChangeKeys_[e];var n=t.getId();return void 0!==n&&delete this.idIndex_[n.toString()],delete this.uidIndex_[e],this.dispatchEvent(new ub(tb,t)),t}},e.prototype.removeFromIdIndex_=function(t){var e=!1;for(var r in this.idIndex_)if(this.idIndex_[r]===t){delete this.idIndex_[r],e=!0;break}return e},e.prototype.setLoader=function(t){this.loader_=t},e.prototype.setUrl=function(t){iy(this.format_,7),this.url_=t,this.setLoader(sb(t,this.format_))},e}(X_);const hb=of(Object.freeze(Object.defineProperty({__proto__:null,VectorSourceEvent:ub,default:cb},Symbol.toStringTag,{value:"Module"})));var db=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const fb=function(t){function e(e,r,n,i,a,o){var s=t.call(this,e,r,o)||this;return s.extent=null,s.format_=i,s.features_=null,s.loader_,s.projection=null,s.resolution,s.tileLoadFunction_=a,s.url_=n,s.key=n,s}return db(e,t),e.prototype.getFormat=function(){return this.format_},e.prototype.getFeatures=function(){return this.features_},e.prototype.load=function(){this.state==Jx.IDLE&&(this.setState(Jx.LOADING),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))},e.prototype.onLoad=function(t,e){this.setFeatures(t)},e.prototype.onError=function(){this.setState(Jx.ERROR)},e.prototype.setFeatures=function(t){this.features_=t,this.setState(Jx.LOADED)},e.prototype.setLoader=function(t){this.loader_=t},e}(t_);var pb=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),mb=[];const gb=function(t){function e(e,r,n,i){var a=t.call(this,e,r,{transition:0})||this;return a.context_={},a.executorGroups={},a.declutterExecutorGroups={},a.loadingSourceTiles=0,a.hitDetectionImageData={},a.replayState_={},a.sourceTiles=[],a.errorTileKeys={},a.wantedResolution,a.getSourceTiles=i.bind(void 0,a),a.wrappedTileCoord=n,a}return pb(e,t),e.prototype.getContext=function(t){var e=ey(t);return e in this.context_||(this.context_[e]=i_(1,1,mb)),this.context_[e]},e.prototype.hasContext=function(t){return ey(t)in this.context_},e.prototype.getImage=function(t){return this.hasContext(t)?this.getContext(t).canvas:null},e.prototype.getReplayState=function(t){var e=ey(t);return e in this.replayState_||(this.replayState_[e]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[e]},e.prototype.load=function(){this.getSourceTiles()},e.prototype.release=function(){for(var e in this.context_){var r=this.context_[e];a_(r),mb.push(r.canvas),delete this.context_[e]}t.prototype.release.call(this)},e}(t_);var vb=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),yb=function(t){function e(e){var r=this,n=e.projection||"EPSG:3857",i=e.extent||uw(n),a=e.tileGrid||sw({extent:i,maxResolution:e.maxResolution,maxZoom:void 0!==e.maxZoom?e.maxZoom:22,minZoom:e.minZoom,tileSize:e.tileSize||512});return(r=t.call(this,{attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,interpolate:!0,opaque:!1,projection:n,state:e.state,tileGrid:a,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:xb,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:void 0===e.wrapX||e.wrapX,transition:e.transition,zDirection:void 0===e.zDirection?1:e.zDirection})||this).format_=e.format?e.format:null,r.sourceTileCache=new D_(r.tileCache.highWaterMark),r.overlaps_=null==e.overlaps||e.overlaps,r.tileClass=e.tileClass?e.tileClass:fb,r.tileGrids_={},r}return vb(e,t),e.prototype.getFeaturesInExtent=function(t){var e=[],r=this.tileCache;if(0===r.getCount())return e;var n=I_(r.peekFirstKey())[0],i=this.tileGrid;return r.forEach((function(r){if(r.tileCoord[0]===n&&r.getState()===Jx.LOADED)for(var a=r.getSourceTiles(),o=0,s=a.length;oStamen Design, under CC BY 3.0.',Sb],Ab={terrain:{extension:"jpg",opaque:!0},"terrain-background":{extension:"jpg",opaque:!0},"terrain-labels":{extension:"png",opaque:!1},"terrain-lines":{extension:"png",opaque:!1},"toner-background":{extension:"png",opaque:!0},toner:{extension:"png",opaque:!0},"toner-hybrid":{extension:"png",opaque:!1},"toner-labels":{extension:"png",opaque:!1},"toner-lines":{extension:"png",opaque:!1},"toner-lite":{extension:"png",opaque:!0},watercolor:{extension:"jpg",opaque:!0}},Rb={terrain:{minZoom:0,maxZoom:18},toner:{minZoom:0,maxZoom:20},watercolor:{minZoom:0,maxZoom:18}},Pb=function(t){function e(e){var r=void 0===e.imageSmoothing||e.imageSmoothing;void 0!==e.interpolate&&(r=e.interpolate);var n=e.layer.indexOf("-"),i=-1==n?e.layer:e.layer.slice(0,n),a=Rb[i],o=Ab[e.layer],s=void 0!==e.url?e.url:"https://stamen-tiles-{a-d}.a.ssl.fastly.net/"+e.layer+"/{z}/{x}/{y}."+o.extension;return t.call(this,{attributions:Eb,cacheSize:e.cacheSize,crossOrigin:"anonymous",interpolate:r,maxZoom:null!=e.maxZoom?e.maxZoom:a.maxZoom,minZoom:null!=e.minZoom?e.minZoom:a.minZoom,opaque:o.opaque,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:e.tileLoadFunction,transition:e.transition,url:s,wrapX:e.wrapX,zDirection:e.zDirection})||this}return Tb(e,t),e}(bb);const Cb=of(Object.freeze(Object.defineProperty({__proto__:null,default:Pb},Symbol.toStringTag,{value:"Module"})));var Ib,Lb={};function Ob(){if(Ib)return Lb;Ib=1,Object.defineProperty(Lb,"__esModule",{value:!0}),Lb.STRATEGY_PROGRESSIVE=Lb.STRATEGY_MIN_NETWORK_TRAFFIC=Lb.STRATEGY_GROUP=Lb.STRATEGY_DICHOTOMY=void 0;Lb.STRATEGY_MIN_NETWORK_TRAFFIC=0;Lb.STRATEGY_GROUP=1;Lb.STRATEGY_PROGRESSIVE=2;return Lb.STRATEGY_DICHOTOMY=3,Lb}var Db,kb={};var Fb,Nb,Ub,Bb={},zb={};function Gb(){if(Fb)return zb;Fb=1,Object.defineProperty(zb,"__esModule",{value:!0}),zb.default=void 0;var t=new Bf.TextureLoader;function e(t){if(!t.ok){var e=new Error("Error loading ".concat(t.url,": status ").concat(t.status));throw e.response=t,e}}var r={text:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.text()}))},json:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.json()}))},xml:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.text()})).then((function(t){return(new window.DOMParser).parseFromString(t,"text/xml")}))},texture:function(e){var r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.crossOrigin=i.crossOrigin;var a=new Promise((function(t,e){r=t,n=e}));return t.load(e,r,(function(){}),n),a},arrayBuffer:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.arrayBuffer()}))}};return zb.default=r,zb}function jb(){if(Ub)return zx;Ub=1;var t=uf;Object.defineProperty(zx,"__esModule",{value:!0}),zx.defineLayerProperty=zx.default=zx.MAX_RETRY=zx.ImageryLayers=void 0,zx.nodeCommandQueuePriorityFunction=function(t){var e=t.extent.dimensions();return e.x*e.y},zx.refinementCommandCancellationFn=function(t){if(!t.requester.parent||!t.requester.material)return!0;if(t.force)return!1;return!t.requester.material.visible};var e=t(pf()),r=t(yf()),n=t(bf()),i=t(Cf()),a=t(Df()),o=t(Uf()),s=Bf,l=t(Ew),u=t(hb),c=t(_b),h=t(Cb),d=Ob(),f=t(function(){if(Db)return kb;Db=1;var t=uf;Object.defineProperty(kb,"__esModule",{value:!0}),kb.default=void 0;var e=t(yf()),r=t(pf()),n=(0,e.default)((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,r.default)(this,t),this.url=e.url})),i=n;return kb.default=i,kb}()),p=t(function(){if(Nb)return Bb;Nb=1;var t=uf;Object.defineProperty(Bb,"__esModule",{value:!0}),Bb.default=void 0;var e=t(pf()),r=t(yf()),n=t(Gb()),i=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,e.default)(this,t),this.url=new URL(r.url,window.location),this.networkOptions=r.networkOptions}return(0,r.default)(t,[{key:"buildUrl",value:function(t){return this.url.href.substr(0,this.url.href.lastIndexOf("/")+1)+t}},{key:"fetchMetadata",value:function(){return n.default.json(this.url.href,this.networkOptions)}}]),t}(),a=i;return Bb.default=a,Bb}());function m(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return g(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);ri&&o.sequence<=e?o.sequence--:o.sequence>=e&&o.sequence0&&this.moveLayerToIndex(t,t.sequence-1,e)}},{key:"moveLayerUp",value:function(t,e){var r=e.length-1;t.sequence1&&void 0!==arguments[1]?arguments[1]:{};return(0,r.default)(this,o),n=e.call(this,t,a),(0,c.defineLayerProperty)((0,i.default)(n),"frozen",!1),(0,c.defineLayerProperty)((0,i.default)(n),"visible",!0),(0,c.defineLayerProperty)((0,i.default)(n),"opacity",1),(0,c.defineLayerProperty)((0,i.default)(n),"sequence",0),n}return(0,n.default)(o,[{key:"clean",value:function(t){var e=this;t.object3d.traverse((function(r){r.layer===t&&(delete r.layerUpdateState[e.id],r.material&&-1!==r.material.indexOfColorLayer(e)&&r.material.removeLayer(e))}))}},{key:"initColorTexturesFromParent",value:function(t,e,r){if(!r.material||!r.material.getColorTexture)return!1;for(var n=e.getExtentForLayer(this);r&&r.material&&r.material.uniforms.colorTexture&&r.material.uniforms.colorTexture.value!==r.material.texturesInfo.color.atlasTexture;)r=r.parent;if(!r||!r.material)return!1;var i=r.material.getColorTexture(this);return!!i&&(!(!i||!i.extent)&&(e.material.uniforms.colorTexture.value=r.material.uniforms.colorTexture.value,e.material.setColorTextures(this,{texture:i,pitch:n.offsetToParent(i.extent)},!0,t.instance),!0))}},{key:"update",value:function(t,e,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.material;if(!e.parent||!a)return null;if(void 0===e.layerUpdateState[this.id]){if(e.layerUpdateState[this.id]=new l.default,!this.tileInsideLimit(e,this)&&(this.noTextureParentOutsideLimit||!r||!r.material||!r.material.getColorTexture(this)))return e.layerUpdateState[this.id].noMoreUpdatePossible(),null;if(a.pushLayer(this,e.getExtentForLayer(this)),r&&this.initColorTexturesFromParent(t,e,r,this))return t.instance.notifyChange(e,!1),null}if(!e.material.visible||i)return null;a.setLayerVisibility(this,this.visible),a.setLayerOpacity(this,this.opacity);var o=Date.now();if(this.frozen||!this.visible||!e.layerUpdateState[this.id].canTryUpdate(o))return null;var s=this.getPossibleTextureImprovements(this,e.getExtentForLayer(this),e.material.getColorTexture(this),e.layerUpdateState[this.id].failureParams);if(void 0===s)return e.layerUpdateState[this.id].noMoreUpdatePossible(),null;if(null===s||!1===s)return null;e.layerUpdateState[this.id].newTry();var h={view:t.instance,layer:this,requester:e,priority:(0,c.nodeCommandQueuePriorityFunction)(e),earlyDropFunction:c.refinementCommandCancellationFn,toDownload:s};return t.scheduler.execute(h).then((function(r){return null===e.material?null:e.material.setColorTextures(n,r,!1,t.instance).then((function(){e.layerUpdateState[n.id].success()}))}),(function(r){if(r instanceof u.default)e.layerUpdateState[n.id].success();else{console.warn("Imagery texture update error for",e,r);var i=e.layerUpdateState[n.id].errorCount>c.MAX_RETRY;e.layerUpdateState[n.id].failure(Date.now(),i,r),i||window.setTimeout((function(){t.instance.notifyChange(e,!1)}),1e3*e.layerUpdateState[n.id].secondsUntilNextTry())}}))}}]),o}(c.default),p=f;return Wb.default=p,Wb}var $b,tM,eM={},rM={},nM={},iM={get exports(){return nM},set exports(t){nM=t}},aM={},oM={get exports(){return aM},set exports(t){aM=t}};function sM(){return tM||(tM=1,function(t){var e=($b||($b=1,function(t){var e=Uf();t.exports=function(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=e(t)););return t},t.exports.__esModule=!0,t.exports.default=t.exports}(oM)),aM);function r(){return"undefined"!=typeof Reflect&&Reflect.get?(t.exports=r=Reflect.get.bind(),t.exports.__esModule=!0,t.exports.default=t.exports):(t.exports=r=function(t,r,n){var i=e(t,r);if(i){var a=Object.getOwnPropertyDescriptor(i,r);return a.get?a.get.call(arguments.length<3?t:n):a.value}},t.exports.__esModule=!0,t.exports.default=t.exports),r.apply(this,arguments)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(iM)),nM}var lM,uM={};function cM(){if(lM)return uM;lM=1,Object.defineProperty(uM,"__esModule",{value:!0}),uM.default=void 0;return uM.default={FINAL:0,DEPTH:1,ID:2,UV:3},uM}var hM,dM={},fM={};function pM(){if(hM)return fM;function t(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,r){if(!t)return;if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:1/0,i={value:e,lastTimeUsed:Date.now(),lifetime:n};return r.set(t,i),e},deletePrefix:function(e){var n,i=t(r.keys());try{for(i.s();!(n=i.n()).done;){var a=n.value;a.startsWith&&a.startsWith(e)&&r.delete(a)}}catch(t){i.e(t)}finally{i.f()}},delete:function(t){return r.delete(t)},clear:r.clear(),flush:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),e=r.size;r.forEach((function(e,n){e.lifetime1?n-1:0),s=1;s1&&void 0!==arguments[1]?arguments[1]:new s.Vector4;if(this.crs()!==t.crs())throw new Error("unsupported mix");if(d(this.crs())){var r=this.zoom-t.zoom,n=Math.pow(2,r),i=1/n,a=(this.row-this.row%n)*i,o=(this.col-this.col%n)*i;return e.set(this.col*i-o,this.row*i-a,i,i)}var l=t.dimensions(),u=this.dimensions(),c=.001*Math.round(1e3*(this.west()-t.west())/l.x),h=.001*Math.round(1e3*(t.north()-this.north())/l.y),f=.001*Math.round(1e3*u.x/l.x),p=.001*Math.round(1e3*u.y/l.y);return e.set(c,h,f,p)}},{key:"west",value:function(){return this._values[h.WEST]}},{key:"east",value:function(){return this._values[h.EAST]}},{key:"north",value:function(){return this._values[h.NORTH]}},{key:"south",value:function(){return this._values[h.SOUTH]}},{key:"crs",value:function(){return this._crs}},{key:"center",value:function(t){if(d(this._crs))throw new Error("Invalid operation for WMTS bbox");var e;t?(l.default.call(t,this._crs,this._values[0],this._values[2]),e=t):e=new l.default(this._crs,this._values[0],this._values[2]);var r=this.dimensions();return e._values[0]+=.5*r.x,e._values[1]+=.5*r.y,e}},{key:"dimensions",value:function(t){return(t=t||{x:0,y:0}).x=Math.abs(this.east()-this.west()),t.y=Math.abs(this.north()-this.south()),t}},{key:"isPointInside",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.crs()===t.crs?t:t.as(this.crs());return(0,l.crsIsGeographic)(this.crs())?r.longitude()<=this.east()+e&&r.longitude()>=this.west()-e&&r.latitude()<=this.north()+e&&r.latitude()>=this.south()-e:r.x()<=this.east()+e&&r.x()>=this.west()-e&&r.y()<=this.north()+e&&r.y()>=this.south()-e}},{key:"isInside",value:function(t,e){if(d(this.crs())){if(this.zoom===t.zoom)return this.row===t.row&&this.col===t.col;if(this.zoom=e.east()||this.east()<=e.west()||this.south()>=e.north()||this.north()<=e.south())}},{key:"intersect",value:function(t){return this.intersectsExtent(t)?(t.crs()!==this.crs()&&(t=t.as(this.crs())),this.set(this.crs(),Math.max(this.west(),t.west()),Math.min(this.east(),t.east()),Math.max(this.south(),t.south()),Math.min(this.north(),t.north())),this):(this.set(this.crs(),0,0,0,0),this)}},{key:"set",value:function(t){for(var e=this,r=arguments.length,n=new Array(r>1?r-1:0),i=1;ithis.east()&&(this._values[h.EAST]=r);var n=t.south();nthis.north()&&(this._values[h.NORTH]=i)}},{key:"expandByPoint",value:function(t){var e=t.as(this.crs()),r=e._values[0];rthis.east()&&(this._values[h.EAST]=r);var n=e._values[1];nthis.north()&&(this._values[h.NORTH]=n)}},{key:"shift",value:function(t,e){return this._values[h.WEST]+=t,this._values[h.EAST]+=t,this._values[h.SOUTH]+=e,this._values[h.NORTH]+=e,this}},{key:"quadtreeSplit",value:function(){return this.center(f),[new t(this.crs(),this.west(),f._values[0],f._values[1],this.north()),new t(this.crs(),f._values[0],this.east(),f._values[1],this.north()),new t(this.crs(),this.west(),f._values[0],this.south(),f._values[1]),new t(this.crs(),f._values[0],this.east(),this.south(),f._values[1])]}},{key:"externalBorders",value:function(t){var e=[this.clone(),this.clone(),this.clone(),this.clone()],r=this.dimensions();return e[0]._values[h.SOUTH]=e[0]._values[h.NORTH],e[0]._values[h.NORTH]+=r.y*t,e[1]._values[h.WEST]=e[1]._values[h.EAST],e[1]._values[h.EAST]+=r.x*t,e[2]._values[h.NORTH]=e[2]._values[h.SOUTH],e[2]._values[h.SOUTH]-=r.y*t,e[3]._values[h.EAST]=e[3]._values[h.WEST],e[3]._values[h.WEST]-=r.x*t,e}}],[{key:"fromBox3",value:function(t,e){return new this(t,{west:e.min.x,east:e.max.x,south:e.min.y,north:e.max.y})}}]),t}(),m=p;return vM.default=m,vM}function kM(){if(RM)return gM;RM=1;var t=uf;Object.defineProperty(gM,"__esModule",{value:!0}),gM.default=void 0;var e=Bf,r=t(Ux()),n=t(DM()),i=Math.PI/4,a=Math.PI/2,o=1/(2*Math.PI),s=Math.log(2);function l(t){return Math.min(84,Math.max(-86,t))}var u={x:0,y:0},c=new r.default("EPSG:4326",0,0,0),h={WGS84ToY:function(t){return.5-Math.log(Math.tan(i+.5*e.Math.degToRad(t)))*o},YToWGS84:function(t){return e.Math.radToDeg(2*(Math.atan(Math.exp(-(t-.5)/o))-i))},getCoordWMTS_WGS84:function(t,e,r){if("PM"===r)return function(t,e){var r,i=[],a=t.zoom+1,o=Math.pow(2,a),s=1/o,u=h.WGS84ToY(l(e.north())),c=h.WGS84ToY(l(e.south())),d=Math.floor(u/s);r=Math.ceil(c/s)-1,r=Math.min(r,o-1);for(var f=t.col,p=r;p>=d;p--)for(var m=f;m<=f;m++)i.push(new n.default("WMTS:PM",a,p,m));return i}(t,e);if("WGS84G"===r)return[t.clone()];throw new Error("Unsupported TileMatrixSet '".concat(r,"'"))},WGS84toWMTS:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new n.default("WMTS:WGS84G",0,0,0);t.dimensions(u);var i=Math.floor(Math.log(Math.PI/e.Math.degToRad(u.y))/s+.5),o=Math.pow(2,i),l=2*Math.PI/(2*o),h=Math.PI/o;t.center(c);var d=Math.floor((Math.PI+e.Math.degToRad(c.longitude()))/l),f=Math.floor(o-(a+e.Math.degToRad(c.latitude()))/h);return r.set("WMTS:WGS84G",i,f,d)},UnitaryToLongitudeWGS84:function(t,e){return e.dimensions(u),e.west()+t*u.x},UnitaryToLatitudeWGS84:function(t,e){return e.dimensions(u),e.south()+t*u.y}};var d=h;return gM.default=d,gM}function FM(){if(PM)return dM;PM=1;var t=uf;Object.defineProperty(dM,"__esModule",{value:!0}),dM.default=dM.SIZE_TEXTURE_TILE=void 0;var e=Bf,r=t(Gb()),n=t(pM()),i=t(kM()),a=t(DM());dM.SIZE_TEXTURE_TILE=256;var o=new a.default("WMTS:WGS84G",0,0,0),s={getColorTextureByUrl:function(t,i){return n.default.get(t)||n.default.set(t,r.default.texture(t,i).then((function(t){return t.generateMipmaps=!1,t.magFilter=e.LinearFilter,t.minFilter=e.LinearFilter,t.anisotropy=16,t})),n.default.POLICIES.TEXTURE)},getXBilTextureByUrl:function(t,i){return n.default.get(t)||n.default.set(t,r.default.arrayBuffer(t,i).then((function(t){var r=function(t){var r=new e.DataTexture(t,256,256,e.AlphaFormat,e.FloatType);return r.needsUpdate=!0,r}(t);return r.generateMipmaps=!1,r.magFilter=e.LinearFilter,r.minFilter=e.LinearFilter,r})),n.default.POLICIES.TEXTURE)},computeTileMatrixSetCoordinates:function(t,e){if(!((e=e||"WGS84G")in t.wmtsCoords)){if(t.wmtsCoords.WGS84G){var r=t.wmtsCoords.WGS84G[0];o.zoom=r.zoom,o.col=r.col,o.row=r.row}else i.default.WGS84toWMTS(t.extent,o),t.wmtsCoords.WGS84G=[o.clone()];t.wmtsCoords[e]=i.default.getCoordWMTS_WGS84(o,t.extent,e)}},computeTMSCoordinates:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"bottom";if(t.crs()!==e.crs())throw new Error("Unsupported configuration. TMS is only supported when geometry has the same crs than TMS layer");var n,i=t.center(),o=e.dimensions(),s=Math.round(o.x/t.dimensions().x),l=Math.floor(Math.log2(s)),u=(i.x()-e.west())/o.x;return n="top"===r?(e.north()-i.y())/o.y:(i.y()-e.south())/o.y,[new a.default("TMS",l,Math.floor(n*s),Math.floor(u*s))]},WMTS_WGS84Parent:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new a.default(t.crs(),0,0,0),i=t.zoom-e,o=Math.pow(2,i),s=1/o,l=(t.row-t.row%o)*s,u=(t.col-t.col%o)*s;return r&&(r.x=t.col*s-u,r.y=t.row*s-l,r.z=s,r.w=s),n.set(n.crs(),e,l,u)}};return dM.default=s,dM}function NM(){if(CM)return rM;CM=1;var t=uf;Object.defineProperty(rM,"__esModule",{value:!0}),rM.default=void 0;var e=t(pf()),r=t(yf()),n=t(sM()),i=t(Cf()),a=t(Df()),o=t(Uf()),s=Bf,l=t(cM()),u=t(FM());function c(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return h(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rl.default.FINAL?this.material.transparent=!1:this.material.transparent=1!==this.material.opacity||1!==this.material.uniforms.noTextureOpacity.value,this.material.needsUpdate=!0)}},{key:"pushRenderState",value:function(t){var e=this;if(this.material.uniforms.renderingState.value===t)return function(){};var r=this.material.uniforms.renderingState.value;return this.traverse((function(e){return f(e,t)})),function(){e.traverse((function(t){return f(t,r)}))}}},{key:"setFog",value:function(t){this.material.setFogDistance(t)}},{key:"setSelected",value:function(t){this.material.setSelected(t)}},{key:"setTextureElevation",value:function(t,e){null!==this.material&&(this.setBBoxZ(e.min,e.max),this.material.setElevationTexture(t,e))}},{key:"setBBoxZ",value:function(t,e){null==t&&null==e||Math.floor(t)===Math.floor(this.obb.z.min)&&Math.floor(e)===Math.floor(this.obb.z.max)||this.OBB().updateZ(t,e)}},{key:"OBB",value:function(){return this.obb}},{key:"removeColorLayer",value:function(t){this.layerUpdateState&&this.layerUpdateState[t]&&delete this.layerUpdateState[t],this.material.removeColorLayer(t)}},{key:"changeSequenceLayers",value:function(t){this.material.getColorLayersCount()<2||this.material.setSequence(t)}},{key:"getExtentForLayer",value:function(t){if(t.extent.crs()!==this.extent.crs())throw new Error("Layer should be in the same CRS of their supporting tile geometry, but layer crs is ".concat(t.extent.crs()," and tile crs is ").concat(this.extent.crs()));return"tms"===t.protocol||"xyz"===t.protocol?u.default.computeTMSCoordinates(this.extent,t.extent,t.origin)[0]:this.extent}},{key:"findCommonAncestor",value:function(t){if(t)return t.level===this.level?t.id===this.id?t:0!==t.level?this.parent.findCommonAncestor(t.parent):void 0:t.level1?o-1:0),c=1;c=1?new i.Vector3(u,h):new i.Vector3(l,c));g.getBarycoord(new i.Vector3(e.x,e.y),m);var v=f(t,g.a.x,g.a.y),y=f(t,g.b.x,g.b.y),x=f(t,g.c.x,g.c.y);return v*m.x+y*m.y+x*m.z}(h,v,l.extent.dimensions(),h.texture.extent.dimensions()):p(h,v),{coord:o,texture:d,tile:l}}function y(t,e,r,n,i,o){var s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},l=arguments.length>8?arguments[8]:void 0,u=(arguments.length>7?arguments[7]:void 0)||new a.default(n);s.worldFromLocal?u.set(n,g.v.copy(i).applyMatrix4(s.worldFromLocal)):u.set(n,i);var c=v(t,e,u,r,l);return c?(c.coord._values[2]+=o,c.coord.as(n,g.coord2).xyz(i),s.localFromWorld&&i.applyMatrix4(s.localFromWorld),{id:c.texture.id,version:c.texture.version,tile:c.tile}):null}var x={getElevationValueAt:function(t,e){var r=v(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,e,(arguments.length>3?arguments[3]:void 0)||t.level0Nodes);return r?{z:r.coord._values[2],texture:r.texture,tile:r.tile}:null},placeObjectOnGround:function(t,e,r){var n,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},l=arguments.length>4?arguments[4]:void 0;if(n=l?l.concat(t.level0Nodes):t.level0Nodes,!s.modifyGeometry){s.cache&&(s.cache.length=1);var u={worldFromLocal:r.parent?r.parent.matrixWorld:void 0,localFromWorld:r.parent?(new i.Matrix4).copy(r.parent.matrixWorld).invert():void 0};return!!(g=y(t,s.method||o,n,e,r.position,s.offset||0,u,void 0,s.cache?s.cache[0]:void 0))&&(s.cache&&(s.cache[0]=g),r.updateMatrix(),r.updateMatrixWorld(),!0)}var c={worldFromLocal:r.matrixWorld,localFromWorld:(new i.Matrix4).copy(r.matrixWorld).invert()},h=r.geometry;if(h.vertices){s.cache&&(s.cache.length=h.vertices.length);for(var d=!0,f=new a.default(e),p=0;p=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,l=arguments.length>2?arguments[2]:void 0;return(0,e.default)(this,a),(t=i.call(this)).atlasInfo=l,t.defines.STITCHING=1,t.uniforms.segments=new o.Uniform(n),r.side&&(t.side=r.side),t.uniforms.renderingState=new o.Uniform(s.default.FINAL),t.defines.TEX_UNITS=0,t.fragmentShader="#include \n\nuniform int renderingState;\nuniform sampler2D colorTexture;\n\n#if TEX_UNITS\nuniform vec4 colorOffsetScale[TEX_UNITS];\nuniform float colorOpacity[TEX_UNITS];\nuniform bool colorVisible[TEX_UNITS];\nuniform vec3 colors[TEX_UNITS];\n#endif\n\n// backgroundColor\nuniform float noTextureOpacity;\nuniform vec3 noTextureColor;\n// tile opacity\nuniform float opacity;\n\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying vec4 vPosition;\n\n#if defined(HILLSHADE)\n// hillshade support\nuniform sampler2D elevationTexture;\nuniform vec4 elevationOffsetScale;\nuniform vec2 tileDimensions;\n\n#include \n\nfloat ZENITH = 0.7857142857;\nfloat AZIMUTH = 2.3571428571;\n\n#define M_PI 3.1415926535897932384626433832795\n\n// from https://github.com/PropellerAero/cesium-elevation-gradient/blob/master/lib/shaders/elevationGradientFrag.glsl\nfloat calcHillshade(float a, float b, float c, float d, float e, float f, float g, float h, float i, vec2 onePixel){\n vec2 cellsize = tileDimensions / onePixel;\n // http://edndoc.esri.com/arcobjects/9.2/net/shared/geoprocessing/spatial_analyst_tools/how_hillshade_works.htm\n\n float dzdx = ((c + 2.0 * f + i) - (a + 2.0 * d + g)) / (8.0 * cellsize.x);\n float dzdy = ((g + 2.0 * h + i) - (a + 2.0 * b + c)) / (8.0 * cellsize.y);\n float slope = atan(1.0 * sqrt(dzdx * dzdx + dzdy * dzdy));\n\n float aspect = atan(dzdy, -dzdx);\n\n if(aspect < 0.0){\n aspect = aspect + 2.0 * M_PI;\n }\n\n float hillshade = ((cos(ZENITH) * cos(slope)) + (sin(ZENITH) * sin(slope) * cos(AZIMUTH - aspect)));\n return clamp(hillshade, 0., 1.);\n}\n#endif\n\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\n\n#if defined(DEBUG)\nuniform bool showOutline;\nconst float sLine = 0.003;\n#endif\n\n#include \n\n#include \nuniform int uuid;\n\nvoid main() {\n if (renderingState == 2) {\n gl_FragColor = packDepthToRGBA(float(uuid) / (256.0 * 256.0 * 256.0));\n } else if (renderingState == 1) {\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n } else if (renderingState == 3) {\n gl_FragColor = encodeHalfRGBA(vUv);\n } else {\n\n vec4 diffuseColor = vec4(noTextureColor, 0.0);\n\n bool hasTexture = false;\n\n #if TEX_UNITS\n #pragma unroll_loop_start\n for (int i = 0; i < TEX_UNITS; i++) {\n if (colorVisible[i] && colorOpacity[i] > 0.0 && colorOffsetScale[i].zw != vec2(0.0)) {\n vec2 uv = computeUv(vUv, colorOffsetScale[i].xy, colorOffsetScale[i].zw);\n vec4 layerColor = texture2D(colorTexture, uv);\n if (layerColor.a > 0.0) {\n hasTexture = true;\n }\n layerColor.rgb *= colors[i];\n diffuseColor = diffuseColor * (1.0 - layerColor.a * colorOpacity[i]) + layerColor * colorOpacity[i];\n }\n }\n #pragma unroll_loop_end\n #endif\n\n\n gl_FragColor = diffuseColor;\n\n#if defined(HILLSHADE)\n vec2 onePixel = vec2(1.0) / 256.0;\n\n vec2 vVv = vec2(\n vUv.x * elevationOffsetScale.z + elevationOffsetScale.x,\n (1.0 - vUv.y) * elevationOffsetScale.w + elevationOffsetScale.y);\n\n float a = getElevation(elevationTexture, vVv + onePixel * vec2(-1.0, 1.0));\n float b = getElevation(elevationTexture, vVv + onePixel * vec2( 0.0, 1.0));\n float c = getElevation(elevationTexture, vVv + onePixel * vec2( 1.0, 1.0));\n float d = getElevation(elevationTexture, vVv + onePixel * vec2(-1.0, 0.0));\n float e = getElevation(elevationTexture, vVv + onePixel * vec2( 0.0, 0.0));\n float f = getElevation(elevationTexture, vVv + onePixel * vec2( 1.0, 0.0));\n float g = getElevation(elevationTexture, vVv + onePixel * vec2(-1.0, -1.0));\n float h = getElevation(elevationTexture, vVv + onePixel * vec2( 0.0, -1.0));\n float i = getElevation(elevationTexture, vVv + onePixel * vec2( 1.0, -1.0));\n\n float hillshade = calcHillshade(a, b, c, d, e, f, g, h, i, elevationOffsetScale.zw * 256.0);\n\n gl_FragColor.rgb *= hillshade;\n#endif\n\n // gl_FragColor.rgb = mix(gl_FragColor.rgb, vColor.rgb, vColor.a);\n if (hasTexture) {\n gl_FragColor.a = max(gl_FragColor.a, noTextureOpacity);\n } else {\n gl_FragColor = vec4(noTextureColor, noTextureOpacity);\n }\n\n#if defined(DEBUG)\n if (showOutline && (vUv.x < sLine || vUv.x > 1.0 - sLine || vUv.y < sLine || vUv.y > 1.0 - sLine)) {\n gl_FragColor.rgb = mix(vec3(1.0, 0.0, 0.0), gl_FragColor.rgb, 0.2);\n }\n#endif\n\n }\n\n}\n",t.vertexShader="#include \n\nattribute vec3 position;\nattribute vec2 uv;\n\nuniform sampler2D elevationTexture;\nuniform vec4 elevationOffsetScale;\n#if defined(STITCHING)\nuniform sampler2D nTex[4];\nuniform vec4 nOff[4];\nuniform float segments;\n#endif\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 modelViewMatrix;\n\nuniform vec4 neighbourdiffLevel;\nuniform vec2 tileDimensions;\n\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying vec4 vPosition;\n\nuniform vec4 validityExtent;\n\n#include \n#include \n\n#if defined(STITCHING)\nfloat readNeighbourElevation(vec2 uv, int neighbour, sampler2D texture) {\n vec2 vv = uv;\n // top\n if (neighbour == 1 || neighbour == 3) {\n vv.x = 1.0 - vv.x;\n } else {\n vv.y = 1.0 - vv.y;\n }\n vec2 vVv = computeUv(\n vv,\n nOff[neighbour].xy, nOff[neighbour].zw);\n return getElevation(texture, vVv);\n}\n#endif\n\n\nvoid main() {\n vUv = uv;\n vPosition = vec4(position, 1.0);\n vColor = vec4(0., 0., 0., 0.);\n\n if(elevationOffsetScale.z > 0.) {\n vec2 vVv = computeUv(vUv, elevationOffsetScale.xy, elevationOffsetScale.zw);\n int weight = 1;\n\n float elevation = getElevation(elevationTexture, vVv);\n\n#if defined(STITCHING)\n // We process the 4 borders separatly. The logic is:\n // - identify if the current vertex is on the border\n // - then, if the neighbour tile is:\n // - at the same level (= precision): we average\n // both elevations\n // - at a lower level (less precise): we use its\n // elevation. And if this vertex has no direct\n // v-neighbour, it is shifted along the other\n // (x when processing north/south border, else\n // y) to be at the same position than the vertex\n // on the other tile. Eg, for vertex 'o' below:\n //\n // ---xx--x-- ---xx--x--\n // || | ||⋱|\n // |o--x-- => || x--\n // || | || |\n // ---xx--x-- ---xx--x--\n // || | || |\n //\n // factor: num_vert_in_tile / num_vert_in_neighbour_tile\n // = 2^(level_difference)\n vec4 neighbourFactor = pow(vec4(2.0), abs(neighbourdiffLevel));\n // Interval in current tile is: 1.0 / segments. If a neighbour\n // has less vertices on our shared edges, its interval size is\n // going to be:\n vec4 modulo = neighbourFactor / segments;\n // West border\n if (vUv.x < 0.01) {\n if (neighbourdiffLevel.w < 0.0) {\n float offset = fract(vUv.y / modulo.w) * modulo.w;\n vPosition.y -= tileDimensions.y * offset;\n vUv.y -= offset;\n\n elevation = readNeighbourElevation(vUv, 3, nTex[3]);\n weight = 1;\n // vColor = vec4(0.0, 1.0, 0.0, 0.5);\n } else if (neighbourdiffLevel.w == 0.0) {\n elevation += readNeighbourElevation(uv, 3, nTex[3]);\n weight += 1;\n }\n }\n // East border\n else if (vUv.x > 0.99) {\n if (neighbourdiffLevel.y < 0.0) {\n float offset = fract(vUv.y / modulo.y) * modulo.y;\n vPosition.y -= tileDimensions.y * offset;\n vUv.y -= offset;\n elevation = readNeighbourElevation(vUv, 1, nTex[1]);\n weight = 1;\n // vColor = vec4(1.0, 1.0, 0.0, 0.5);\n } else if (neighbourdiffLevel.y == 0.0) {\n elevation += readNeighbourElevation(uv, 1, nTex[1]);\n weight += 1;\n }\n }\n // South border\n else if (vUv.y < 0.01) {\n if (neighbourdiffLevel.z < 0.0) {\n float offset = fract(vUv.x / modulo.z) * modulo.z;\n // move to the left\n vPosition.x -= tileDimensions.x * offset;\n vUv.x -= offset;\n\n elevation = readNeighbourElevation(vUv, 2, nTex[2]);\n weight = 1;\n // vColor = vec4(0.0, 1.0, 1.0, 0.5);\n } else if (neighbourdiffLevel.z == 0.0) {\n elevation += readNeighbourElevation(uv, 2, nTex[2]);\n weight += 1;\n }\n }\n // North border\n else if (vUv.y > 0.99) {\n if (neighbourdiffLevel.x < 0.0) {\n float offset = fract(vUv.x / modulo.x) * modulo.x;\n vPosition.x -= tileDimensions.x * offset;\n vUv.x -= offset;\n\n elevation = readNeighbourElevation(vUv, 0, nTex[0]);\n weight = 1;\n // vColor = vec4(0.0, 0.0, 1.0, 0.5);\n } else if (neighbourdiffLevel.x == 0.0) {\n elevation += readNeighbourElevation(uv, 0, nTex[0]);\n weight += 1;\n }\n }\n\n if (weight > 1) {\n elevation /= float(weight);\n }\n#endif\n vPosition.z = elevation;\n }\n\n // colors from OGC EL.GridCoverage.Default style\n // float z = vPosition.z;\n // if (z < -100.0) {\n // vColor = vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0);\n // } else if (z <= 0.0) {\n // vColor = mix(\n // vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n // vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n // -z / 100.0);\n // } else if (z <= 50.0) {\n // vColor = mix(\n // vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n // vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n // -z / 100.0);\n // } else if (z <= 50.0) {\n // vColor = mix(\n // vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n // vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n // z / 50.0);\n // } else if (z <= 100.0) {\n // vColor = mix(\n // vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n // vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n // (z - 50.0)/ 50.0);\n // } else {\n // vColor = mix(\n // vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n // vec4(float(0x7B) / 255.0, float(0xF2) / 255.0, float(0x3A) / 255.0, 1.0),\n // (z - 100.0)/ 50.0);\n // }\n gl_Position = projectionMatrix * modelViewMatrix * vPosition;\n}\n",t.canvas=document.createElement("canvas"),t.canvas.width=l.maxX,t.canvas.height=l.maxY,t.pendingUpdates=[],t.texturesInfo={color:{offsetScale:[],originalOffsetScale:[],atlasTexture:new o.CanvasTexture(t.canvas),parentAtlasTexture:null,textures:[],opacity:[],visible:[],colors:[]},elevation:{offsetScale:new o.Vector4(0,0,0,0),texture:d,neighbours:{offsetScale:Array(4),texture:Array(4)},format:null}},m(t.texturesInfo.elevation.neighbours.texture,d),m(t.texturesInfo.elevation.neighbours.offsetScale,f),t.canvasRevision=0,t.uniforms.tileDimensions=new o.Uniform(new o.Vector2),t.uniforms.neighbourdiffLevel=new o.Uniform(new o.Vector4),t.uniforms.elevationTexture=new o.Uniform(t.texturesInfo.elevation.texture),t.uniforms.elevationOffsetScale=new o.Uniform(t.texturesInfo.elevation.offsetScale),t.uniforms.nTex=new o.Uniform(t.texturesInfo.elevation.neighbours.texture),t.uniforms.nOff=new o.Uniform(t.texturesInfo.elevation.neighbours.offsetScale),t.uniforms.colorTexture=new o.Uniform(t.texturesInfo.color.atlasTexture),t.uniforms.colorOffsetScale=new o.Uniform,t.uniforms.colorOpacity=new o.Uniform,t.uniforms.colorVisible=new o.Uniform,t.uniforms.colors=new o.Uniform(t.texturesInfo.color.colors),t.uniforms.uuid=new o.Uniform(0),t.uniforms.noTextureColor=new o.Uniform(new o.Color),t.uniforms.noTextureOpacity=new o.Uniform(1),t.uniforms.opacity=new o.Uniform(1),t.colorLayers=[],t.texturesInfo.color.atlasTexture.generateMipmaps=!1,t.texturesInfo.color.atlasTexture.magFilter=o.LinearFilter,t.texturesInfo.color.atlasTexture.minFilter=o.LinearFilter,t.texturesInfo.color.atlasTexture.anisotropy=1,t.texturesInfo.color.atlasTexture.premultiplyAlpha=!0,t.texturesInfo.color.atlasTexture.needsUpdate=!1,t}return(0,r.default)(a,[{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"}),this.disposed=!0,this.texturesInfo.color.atlasTexture.dispose(),this.texturesInfo.elevation.texture.dispose()}},{key:"getColorTexture",value:function(t){var e=this.indexOfColorLayer(t);return-1===e?null:this.texturesInfo.color.textures[e]}},{key:"setColorTextures",value:function(t,e,r,n){var i=this;Array.isArray(e)&&(e=e[0]);var a=this.indexOfColorLayer(t);return this.texturesInfo.color.originalOffsetScale[a].copy(e.pitch),this.texturesInfo.color.textures[a]=e.texture,r?(y(t.imageSize,this.atlasInfo.atlas[t.id],this.texturesInfo.color.originalOffsetScale[a],this.uniforms.colorTexture.value.image,this.texturesInfo.color.offsetScale[a]),Promise.resolve()):(this.pendingUpdates.push(t),null!==this.setTimeoutId&&clearTimeout(this.setTimeoutId),this.setTimeoutId=setTimeout((function(){if(i.uniforms.colorTexture.value!==i.texturesInfo.color.atlasTexture){i.uniforms.colorTexture.value=i.texturesInfo.color.atlasTexture;var t,e=u(i.colorLayers);try{for(e.s();!(t=e.n()).done;){var r=t.value;-1===i.pendingUpdates.indexOf(r)&&(console.warn("no new texture for ",r.id,". Redrawing the old one"),i.pendingUpdates.push(r))}}catch(t){e.e(t)}finally{e.f()}}var a,o=u(i.pendingUpdates);try{for(o.s();!(a=o.n()).done;){var s=a.value,l=i.indexOfColorLayer(s),c=i.atlasInfo.atlas[s.id];y(s.imageSize,i.atlasInfo.atlas[s.id],i.texturesInfo.color.originalOffsetScale[l],i.uniforms.colorTexture.value.image,i.texturesInfo.color.offsetScale[l]);var h=i.texturesInfo.color.textures[l].image;i.canvasRevision=v(s,i.texturesInfo.color.atlasTexture,c,h===i.canvas?null:h,i.texturesInfo.color.offsetScale[l],i.canvasRevision)}}catch(t){o.e(t)}finally{o.f()}i.pendingUpdates.length=0,i.texturesInfo.color.atlasTexture.needsUpdate=!0,i.visible&&n.notifyChange(),i.setTimeoutId=null}),1),Promise.resolve())}},{key:"getElevationTextureInfo",value:function(){return this.isElevationLayerTextureLoaded()?{texture:this.texturesInfo.elevation.texture,offsetScale:this.texturesInfo.elevation.offsetScale,elevationFormat:this.texturesInfo.elevation.format,heightFieldScale:this.texturesInfo.elevation.heightFieldScale,heightFieldOffset:this.texturesInfo.elevation.heightFieldOffset}:null}},{key:"setElevationTexture",value:function(t,e){if(t.elevationFormat===l.ELEVATION_FORMAT.MAPBOX_RGB)this.defines.MAPBOX_RGB_ELEVATION||(this.defines.MAPBOX_RGB_ELEVATION=1,this.needsUpdate=!0);else if(t.elevationFormat===l.ELEVATION_FORMAT.HEIGHFIELD){if(!this.defines.HEIGHTFIELD_ELEVATION){this.defines.HEIGHTFIELD_ELEVATION=1;var r=t.heightFieldOffset||0;this.texturesInfo.elevation.heightFieldOffset=r,this.uniforms.heightFieldOffset=new o.Uniform(r);var n=t.heightFieldScale||255;this.texturesInfo.elevation.heightFieldScale=n,this.uniforms.heightFieldScale=new o.Uniform(n),this.needsUpdate=!0}}else{if(t.elevationFormat!==l.ELEVATION_FORMAT.RATP_GEOL)throw new Error("Missing layer.elevationFormat handling",t.elevationFormat);this.defines.RATP_GEOL_ELEVATION||(this.defines.RATP_GEOL_ELEVATION=1)}return this.uniforms.elevationTexture.value=e.texture,this.texturesInfo.elevation.texture=e.texture,this.texturesInfo.elevation.offsetScale.copy(e.pitch),this.texturesInfo.elevation.format=t.elevationFormat,Promise.resolve(!0)}},{key:"pushLayer",value:function(t){this.texturesInfo.color.opacity.push(t.opacity),this.texturesInfo.color.visible.push(t.visible),this.texturesInfo.color.offsetScale.push(new o.Vector4(0,0,0,0)),this.texturesInfo.color.originalOffsetScale.push(new o.Vector4(0,0,0,0)),this.texturesInfo.color.textures.push(d),this.texturesInfo.color.colors.push(t.color||new o.Color(1,1,1)),this.colorLayers.push(t),1===this.colorLayers.length&&(this.uniforms.colorOffsetScale=new o.Uniform(this.texturesInfo.color.offsetScale),this.uniforms.colorOpacity=new o.Uniform(this.texturesInfo.color.opacity),this.uniforms.colorVisible=new o.Uniform(this.texturesInfo.color.visible)),this.defines.TEX_UNITS=this.colorLayers.length,this.needsUpdate=!0}},{key:"removeLayer",value:function(t){var e=this.indexOfColorLayer(t);-1!==e?(this.texturesInfo.color.opacity.splice(e,1),this.texturesInfo.color.visible.splice(e,1),this.texturesInfo.color.offsetScale.splice(e,1),this.texturesInfo.color.originalOffsetScale.splice(e,1),this.texturesInfo.color.textures.splice(e,1),this.texturesInfo.color.colors.splice(e,1),this.colorLayers.splice(e,1),this.defines.TEX_UNITS=this.colorLayers.length,this.needsUpdate=!0):console.warn("Layer ".concat(t.id," not found, so not removed..."))}},{key:"update",value:function(){if(0===this.colorLayers.length)return!0;if(this.atlasInfo.maxX>this.canvas.width||this.atlasInfo.maxY>this.canvas.height){var t=document.createElement("canvas");if(t.width=this.atlasInfo.maxX,t.height=this.atlasInfo.maxY,this.canvas.width>0)t.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height);this.texturesInfo.color.atlasTexture.dispose(),this.texturesInfo.color.atlasTexture=new o.CanvasTexture(t),this.texturesInfo.color.atlasTexture.magFilter=o.LinearFilter,this.texturesInfo.color.atlasTexture.minFilter=o.LinearFilter,this.texturesInfo.color.atlasTexture.anisotropy=1,this.texturesInfo.color.atlasTexture.premultiplyAlpha=!0,this.texturesInfo.color.atlasTexture.needsUpdate=!0;for(var e=0;e0}},{key:"indexOfColorLayer",value:function(t){return this.colorLayers.indexOf(t)}},{key:"setLayerOpacity",value:function(t,e){var r=Number.isInteger(t)?t:this.indexOfColorLayer(t);this.texturesInfo.color.opacity[r]=e}},{key:"setLayerVisibility",value:function(t,e){var r=Number.isInteger(t)?t:this.indexOfColorLayer(t);this.texturesInfo.color.visible[r]=e}},{key:"isElevationLayerTextureLoaded",value:function(){return this.texturesInfo.elevation.texture!==d}},{key:"isColorLayerTextureLoaded",value:function(t){var e=this.indexOfColorLayer(t);return e<0?null:this.texturesInfo.color.textures[e]!==d}},{key:"setUuid",value:function(t){this.uniforms.uuid.value=t}}]),a}(o.RawShaderMaterial);function v(t,e,r,n,i,a){var o=e.image.getContext("2d");return void 0!==n&&t.transparent&&o.clearRect(r.x,r.y,t.imageSize.w,t.imageSize.h+2*r.offset),n&&(o.drawImage(n,r.x,r.y+r.offset,t.imageSize.w,t.imageSize.h),r.offset&&(o.drawImage(n,0,0,t.imageSize.w,r.offset,r.x,r.y,t.imageSize.w,r.offset),o.drawImage(n,0,t.imageSize.h-1-r.offset,t.imageSize.w,r.offset,r.x,r.y+t.imageSize.h+r.offset,t.imageSize.w,r.offset))),e.needsUpdate=!0,a+1}function y(t,e,r,n,i){if(0!==r.z&&0!==r.w){var a=t.w/n.width,o=t.h/n.height;i.set(e.x/n.width+r.x*a,(e.y+e.offset)/n.height+r.y*o,r.z*a,r.w*o)}else i.set(0,0,0,0)}var x=g;return GM.default=x,GM}function WM(){if(zM)return eM;zM=1;var t=uf;Object.defineProperty(eM,"__esModule",{value:!0}),eM.default=void 0;var e=Bf,r=t(NM()),n=t(cM()),i=HM(),a=t(Ux()),o=t(VM());function s(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return l(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:0,r=t.camera.camera3D.layers.mask;return t.camera.camera3D.layers.mask=1<i)&&!(l<=r)){var u=t+a,c=t+s;if(!1===e(u,c,c*(2*t)+u))return}}r=i}}function d(t){return t.layer?t.layer:t.parent?d(t.parent):null}var f=new e.Raycaster,p=new a.default("EPSG:3857",0,0,0),m=new e.Color,g={pickTilesAt:function(t,l,d,f){var m,g=[],v=function(t,r,a,o){var s=t.mainLoop.gfxEngine.getWindowSize();a=a||new e.Vector2(Math.floor(s.x/2),Math.floor(s.y/2));var l=r.level0Nodes.map((function(t){return t.pushRenderState(n.default.ID)})),d=u(t,r.object3d,r.threejsLayer),f=t.mainLoop.gfxEngine.renderViewToBuffer({camera:t.camera,scene:r.object3d},{x:a.x-o,y:a.y-o,width:1+2*o,height:1+2*o});d(),l.forEach((function(t){return t()}));var p=[];return h(o,(function(t,e,r){var n=f.slice(4*r,4*r+4);c.fromArray(n).divideScalar(255);var a=(0,i.unpack1K)(c,Math.pow(256,3)),o=Math.round(a);p.indexOf(o)<0&&p.push(o)})),p}(t,f,l,d),y=function(i){if(v.indexOf(i.id)>=0&&i instanceof r.default){var s=i.pushRenderState(n.default.UV),u=t.mainLoop.gfxEngine.renderViewToBuffer({camera:t.camera,scene:i},{x:Math.max(0,l.x-d),y:Math.max(0,l.y-d),width:1+2*d,height:1+2*d}),m=[];h(d,(function(t,r,n){var i,a,o=u.slice(4*n,4*n+4);c.fromArray(o).divideScalar(255),m.push((i=c,a&&a.isVector2||(a=new e.Vector2),a.set(i.x+i.y/255,i.z+i.w/255)))}));for(var y=0,x=m;yl.length)&&console.error("azadaz");var s=l.slice(4*n,4*n+4);if(255!==s[0]||255!==s[1]){var u=s[0]+((240&s[1])<<4);u>o&&console.warn("weird: pickingId (".concat(u,") > visibleId (").concat(o,")"));for(var h={pickingId:u,index:((15&s[1])<<16)+(s[2]<<8)+s[3],coord:i},d=0;d4&&void 0!==arguments[4]?arguments[4]:[],a={x:e.x-r,y:e.y-r,width:1+2*r,height:1+2*r},o=t.mainLoop.gfxEngine.renderViewToBuffer({scene:n,camera:t.camera},a),l=t.mainLoop.gfxEngine.renderer.getClearColor(m),u=Math.round(255*l.r),c=Math.round(255*l.g),p=Math.round(255*l.b),g=t.viewToNormalizedCoords(e),v=g.clone();return h(r,(function(e,a){var l=4*((a+r)*(2*r+1)+(e+r)),h=o[l],m=o[l+1],y=o[l+2];if(Math.abs(u-h)<=1&&Math.abs(c-m)<=1&&Math.abs(p-y)<=1)return null;v.setX(g.x+e/t.camera.width).setY(g.y+a/t.camera.height),f.setFromCamera(v,t.camera.camera3D);var x,_=s(f.intersectObject(n,!0));try{for(_.s();!(x=_.n()).done;){var w=x.value;w.layer=d(w.object),i.push(w)}}catch(t){_.e(t)}finally{_.f()}return 0===i.length})),i},preparePointGeometryForPicking:function(t){var r=t.attributes.position.count;r>=1<<20&&console.warn("picking issue: only ".concat(1<<20," points per Points object supported"));for(var n=new Uint8Array(4*r),i=0;i>16,n[4*i+2]=(65280&i)>>8,n[4*i+3]=(255&i)>>0;t.setAttribute("unique_id",new e.BufferAttribute(n,4,!0))}};return eM.default=g,eM}var qM,XM,YM={},ZM={};function KM(){if(qM)return ZM;qM=1,Object.defineProperty(ZM,"__esModule",{value:!0}),ZM.default=void 0;var t=Bf;function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r-1}var a={isLogDepthBufferSupported:function(){return e},isFirefox:i,isInternetExplorer:function(){return!!document.documentMode},getMaxTextureUnitsCount:function(){return r},getMaxTextureSize:function(){return t},updateCapabilities:function(a){var o=a.getContext();r=o.getParameter(o.MAX_TEXTURE_IMAGE_UNITS),t=o.getParameter(o.MAX_TEXTURE_SIZE);var s=o.createProgram(),l=n(a,o.VERTEX_SHADER,"void main() {\n gl_Position = vec4( 0.0, 0.0, 0.0, 1.0 );\n}"),u="#define SAMPLE ".concat(r,"\n");u+="uniform sampler2D uni[SAMPLE];\nvoid main() {\n gl_FragColor += texture2D(uni[SAMPLE-1], vec2(0));\n}";var c=n(a,o.FRAGMENT_SHADER,u);if(o.attachShader(s,l),o.attachShader(s,c),o.linkProgram(s),!1===o.getProgramParameter(s,o.LINK_STATUS)){if(!(r>16))throw new Error("The GPU capabilities could not be determined accurately.\n Impossible to link a shader with the Maximum texture units ".concat(r));var h=o.getProgramInfoLog(s);console.warn("".concat(h,": using a maximum of 16 texture units instead of the reported value (").concat(r,")")),i()&&console.warn("It can come from a Mesa/Firefox bug;\n the shader compiles to an error when using more than 16 sampler uniforms,\n see https://bugzilla.mozilla.org/show_bug.cgi?id=777028"),r=16}o.deleteProgram(s),o.deleteShader(l),o.deleteShader(c),e=a.capabilities.logarithmicDepthBuffer}};return QM.default=a,QM}var tS,eS={};function rS(){if(tS)return eS;tS=1;var t=uf;Object.defineProperty(eS,"__esModule",{value:!0}),eS.default=void 0;var e=t(pf()),r=t(yf()),n=function(){function t(r){if((0,e.default)(this,t),!r)throw new Error("Missing id parameter (Entity must have a unique id defined)");Object.defineProperty(this,"id",{value:r,writable:!1})}return(0,r.default)(t,[{key:"preUpdate",value:function(){return null}},{key:"update",value:function(){}},{key:"postUpdate",value:function(){}}]),t}();return eS.default=n,eS}var nS,iS,aS={};function oS(){if(iS)return Hb;iS=1;var t=uf;Object.defineProperty(Hb,"__esModule",{value:!0}),Hb.default=void 0;var e=t(pf()),r=t(yf()),n=t(bf()),i=t(Cf()),a=t(Df()),o=t(Uf()),s=Bf,l=jb(),u=t(Qb()),c=t(WM()),h=t(function(){if(XM)return YM;XM=1;var t=uf;Object.defineProperty(YM,"__esModule",{value:!0}),YM.default=void 0;var e=t(KM()),r={pack:function(t,r,n,i){t=2048;for(var a,o=[],s=0;s=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r can't attach layer ".concat(t.id));if(t=t._preprocessLayer(this,this._instance),this._attachedLayers.push(t),t instanceof u.default){var e=this._attachedLayers.filter((function(t){return t instanceof u.default})),r=h.default.pack(d.default.getMaxTextureSize(),e.map((function(t){return t.id})),e.map((function(t){return t.imageSize})),this.atlasInfo.atlas),n=r.atlas,i=r.maxX,a=r.maxY;this.atlasInfo.atlas=n,this.atlasInfo.maxX=Math.max(this.atlasInfo.maxX,i),this.atlasInfo.maxY=Math.max(this.atlasInfo.maxY,a)}}},{key:"detach",value:function(t){var e=this._attachedLayers.length;return this._attachedLayers=this._attachedLayers.filter((function(e){return e.id!==t.id})),this._attachedLayers.length=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw a}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{};(0,e.default)(this,t),void 0===a.antialias&&(a.antialias=!0),void 0===a.alpha&&(a.alpha=!0),void 0===a.logarithmicDepthBuffer&&(a.logarithmicDepthBuffer=!1),void 0===a.clearColor&&(a.clearColor=197896);var o=r.domElement?r:void 0,s=o?void 0:r;this.width=(o?o.domElement:s).clientWidth,this.height=(o?o.domElement:s).clientHeight,this.positionBuffer=null,this._nextThreejsLayer=1,this.fullSizeRenderTarget=new n.WebGLRenderTarget(this.width,this.height),this.fullSizeRenderTarget.texture.minFilter=n.LinearFilter,this.fullSizeRenderTarget.texture.magFilter=n.NearestFilter,this.fullSizeRenderTarget.texture.generateMipmaps=!1,this.fullSizeRenderTarget.depthBuffer=!0,this.fullSizeRenderTarget.depthTexture=new n.DepthTexture,this.fullSizeRenderTarget.depthTexture.type=n.UnsignedShortType;try{this.renderer=o||new n.WebGLRenderer({canvas:document.createElement("canvas"),antialias:a.antialias,alpha:a.alpha,logarithmicDepthBuffer:a.logarithmicDepthBuffer})}catch(t){console.error("Failed to create WebGLRenderer",t),this.renderer=null}if(!this.renderer){var l=document.createElement("div");throw l.id="webgl-error-message",l.style.fontFamily="monospace",l.style.fontSize="13px",l.style.fontWeight="normal",l.style.textAlign="center",l.style.background="#fff",l.style.color="#000",l.style.padding="1.5em",l.style.width="400px",l.style.margin="5em auto 0",l.innerHTML=window.WebGLRenderingContext?['Your graphics card does not seem to support WebGL.
','Find out how to get it here.
','See also graphics card blacklisting'].join("\n"):['Your browser does not seem to support WebGL.
','Find out how to get it here.
',"You can also try another browser like Firefox or Chrome."].join("\n"),s.appendChild(l),new Error("WebGL unsupported")}if(!o&&a.logarithmicDepthBuffer&&!this.renderer.extensions.get("EXT_frag_depth")){var u=this.renderer.domElement;this.renderer.dispose(),this.renderer=new n.WebGLRenderer({canvas:u,antialias:a.antialias,alpha:a.alpha,logarithmicDepthBuffer:!1})}-1===this.renderer.domElement.tabIndex&&(this.renderer.domElement.tabIndex=-1),i.default.updateCapabilities(this.renderer),!1!==a.clearColor&&this.renderer.setClearColor(a.clearColor),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,o||(this.renderer.setPixelRatio(s.devicePixelRatio),this.renderer.setSize(s.clientWidth,s.clientHeight),s.appendChild(this.renderer.domElement))}return(0,r.default)(t,[{key:"renderView",value:function(t,e){this.renderer.setViewport(0,0,this.width,this.height),this.renderer.clear(),this.renderer.render(t.scene,t.camera.camera3D),!1!==e&&(this.renderer.clearDepth(),this.renderer.render(t.scene2D,t.camera.camera2D))}},{key:"onWindowResize",value:function(t,e){this.width=t,this.height=e,this.fullSizeRenderTarget.setSize(this.width,this.height),this.renderer.setSize(this.width,this.height)}},{key:"getWindowSize",value:function(){return new n.Vector2(this.width,this.height)}},{key:"getRenderer",value:function(){return this.renderer}},{key:"renderViewToBuffer",value:function(t,e){e||(e={x:0,y:0,width:this.width,height:this.height}),this.renderViewToRenderTarget(t,this.fullSizeRenderTarget,e),e.x=Math.max(0,Math.min(e.x,this.width)),e.y=Math.max(0,Math.min(e.y,this.height));var r=new Uint8Array(4*e.width*e.height);return this.renderer.readRenderTargetPixels(this.fullSizeRenderTarget,e.x,this.height-(e.y+e.height),e.width,e.height,r),r}},{key:"renderViewToRenderTarget",value:function(t,e,r){e||(e=this.fullSizeRenderTarget);var n=this.renderer.getRenderTarget();return e.viewport.set(0,0,e.width,e.height),r&&(e.scissor.set(Math.max(0,r.x),Math.max(e.height-(r.y+r.height)),r.width,r.height),e.scissorTest=!0),this.renderer.setRenderTarget(e),this.renderer.clear(),this.renderer.render(t.scene,t.camera.camera3D),this.renderer.setRenderTarget(n),e.scissorTest=!1,e}},{key:"renderLayerTobuffer",value:function(t,e,r,n,i,o,s){var l,u=t._objects.map((function(t){return t.visible})),c=a(t._objects);try{for(c.s();!(l=c.n()).done;){l.value.visible=!1}}catch(t){c.e(t)}finally{c.f()}e.visible=!0;var h=this.renderer.getRenderTarget();this.renderer.setRenderTarget(r),this.renderer.setViewport(0,0,r.width,r.height),this.renderer.setScissor(n,i,o,s),this.renderer.setScissorTest(!0),this.renderer.clear(),this.renderer.render(e.object3d,t.camera.camera3D),this.renderer.setScissorTest(!1);var d=new Uint8Array(4*o*s);this.renderer.readRenderTargetPixels(r,n,i,o,s,d),this.renderer.setRenderTarget(h);for(var f=0;f31&&(console.warn("Too much js layers. Starting from now all of them will use layerMask = 31"),this._nextThreejsLayer=31),this._nextThreejsLayer++}}],[{key:"bufferToImage",value:function(t,e,r){var n=document.createElement("canvas"),i=n.getContext("2d");n.width=e,n.height=r;var a=i.getImageData(0,0,e,r);a.data.set(t),i.putImageData(a,0,0);var o=new Image;return o.src=n.toDataURL(),o}}]),t}(),l=s;return hS.default=l,hS}var fS={};function pS(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var mS,gS={},vS={get exports(){return gS},set exports(t){gS=t}};function yS(){return mS||(mS=1,vS.exports=function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){if(!s&&pS)return pS(o);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[o]={exports:{}};e[o][0].call(u.exports,(function(t){var r=e[o][1][t];return i(r||t)}),u,u.exports,t,e,r,n)}return r[o].exports}for(var a=pS,o=0;o>>1],e)>=0?i=a+1:n=a;return i},e.exports=function(){function t(t){var e;this.options=t,this.comparator=this.options.comparator,this.data=(null!=(e=this.options.initialValues)?e.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return t.prototype.queue=function(t){var e;e=n(this.data,t,this.comparator),this.data.splice(e,0,t)},t.prototype.dequeue=function(){return this.data.pop()},t.prototype.peek=function(){return this.data[this.data.length-1]},t.prototype.clear=function(){this.data.length=0},t}()},{}],4:[function(t,e,r){e.exports=function(){function t(t){var e,r,n,i,a,o,s,l;for(this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.pageSize=(null!=t?t.pageSize:void 0)||512,this.length=0,s=0;1<a;0<=a?++r:--r)e.push(null);if(this._memory=[],this._mask=this.pageSize-1,t.initialValues)for(n=0,i=(o=t.initialValues).length;n0&&(this._write(1,e),this._bubbleDown(1,e)),t},t.prototype.peek=function(){return this._read(1)},t.prototype.clear=function(){this.length=0,this._memory.length=0},t.prototype._write=function(t,e){var r;for(r=t>>this._shift;r>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[r][t&this._mask]=e},t.prototype._read=function(t){return this._memory[t>>this._shift][t&this._mask]},t.prototype._bubbleUp=function(t,e){var r,n,i,a;for(r=this.comparator;t>1&&(n=t&this._mask,t3?i=t&~this._mask|n>>1:n<2?(i=t-this.pageSize>>this._shift,i+=i&~(this._mask>>1),i|=this.pageSize>>1):i=t-2,!(r(a=this._read(i),e)<0));)this._write(i,e),this._write(t,a),t=i},t.prototype._bubbleDown=function(t,e){var r,n,i,a,o;for(o=this.comparator;tthis._mask&&!(t&this._mask-1)?r=n=t+2:t&this.pageSize>>1?(r=(t&~this._mask)>>1,n=1+(r=1+(r|=t&this._mask>>1)<0)for(t=e=1,r=this.data.length;1<=r?er;t=1<=r?++e:--e)this._bubbleUp(t)},t.prototype.queue=function(t){this.data.push(t),this._bubbleUp(this.data.length-1)},t.prototype.dequeue=function(){var t,e;return e=this.data[0],t=this.data.pop(),this.data.length>0&&(this.data[0]=t,this._bubbleDown(0)),e},t.prototype.peek=function(){return this.data[0]},t.prototype.clear=function(){this.length=0,this.data.length=0},t.prototype._bubbleUp=function(t){for(var e,r;t>0&&(e=t-1>>>1,this.comparator(this.data[t],this.data[e])<0);)r=this.data[e],this.data[e]=this.data[t],this.data[t]=r,t=e},t.prototype._bubbleDown=function(t){var e,r,n,i,a;for(e=this.data.length-1;i=1+(r=1+(t<<1)),n=t,r<=e&&this.comparator(this.data[r],this.data[n])<0&&(n=r),i<=e&&this.comparator(this.data[i],this.data[n])<0&&(n=i),n!==t;)a=this.data[n],this.data[n]=this.data[t],this.data[t]=a,t=n},t}()},{}]},{},[1])(1)),gS}const xS=of(Qx);var _S,wS={},bS={},MS={};function SS(){if(_S)return MS;_S=1;var t=uf,e=cf;Object.defineProperty(MS,"__esModule",{value:!0}),MS.default=void 0;var r,n=t(pf()),i=t(yf()),a=t(bf()),o=t(sM()),s=t(Cf()),l=t(Df()),u=t(Uf()),c=m(VM()),h=t(Xb()),d=t(Jb()),f=m(jb());function p(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return(p=function(t){return t?r:e})(t)}function m(t,r){if(!r&&t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var n=p(r);if(n&&n.has(t))return n.get(t);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=t[o]}return i.default=t,n&&n.set(t,i),i}function g(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return v(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{};return(0,n.default)(this,l),(r=e.call(this,t,i)).elevationFormat=i.elevationFormat,r.elevationFormat===c.ELEVATION_FORMAT.HEIGHFIELD&&(r.heightFieldOffset=i.heightFieldOffset||0,r.heightFieldScale=i.heightFieldScale||255),(0,f.defineLayerProperty)((0,a.default)(r),"frozen",!1),r}return(0,i.default)(l,[{key:"minMaxFromTexture",value:function(t){if(null!=t.min&&null!=t.max)return{min:t.min,max:t.max};var e=1/0,r=-1/0;if(this.elevationFormat===c.ELEVATION_FORMAT.MAPBOX_RGB)for(var n=l.colorImageSetup(t),i=n.data,a=n.stride,o=n.h,s=0;sr&&(r=h)}else if(this.elevationFormat===c.ELEVATION_FORMAT.HEIGHFIELD){for(var d=l.colorImageSetup(t),f=d.data,p=d.stride,m=d.h,g=0;g-1e3&&(e=Math.min(e,x),r=Math.max(r,x))}else{if(this.elevationFormat!==c.ELEVATION_FORMAT.RATP_GEOL)throw new Error('Unsupported layer.elevationFormat "'.concat(this.elevationFormat,"'"));e=-1e3,r=1e3}return t.min=e,t.max=r,{min:e,max:r}}},{key:"initNodeElevationTextureFromParent",value:function(t,e){var r=e.material.getElevationTextureInfo();if(r&&r.texture.extent){var n=r.texture,i=t.getExtentForLayer(this).offsetToParent(n.extent),a={texture:n,pitch:i},o=n.min,s=n.max;if(!o||!s){var l=this.minMaxFromTexture(n,i);o=l.min,s=l.max}a.min=o,a.max=s,t.setTextureElevation(this,a)}}},{key:"_preprocessLayer",value:function(t,e){var r=this;return(0,o.default)((0,u.default)(l.prototype),"_preprocessLayer",this).call(this,t,e),this.whenReady=this.whenReady.then((function(){var t=r.provider.getPossibleTextureImprovements(r,r.extent);return r.provider.executeCommand({layer:r,toDownload:t}).then((function(t){var e=r.minMaxFromTexture(t.texture,t.pitch);t.texture.min=e.min,t.texture.max=e.max,r.minmax=e}))})),this.whenReady=this.whenReady.then((function(){if(!r.minmax)throw new Error("At this point the whole min/max should be known");t.object3d.traverse((function(t){t.setBBoxZ&&t.setBBoxZ(r.minmax.min,r.minmax.max)})),t.minMaxFromElevationLayer={min:r.minmax.min,max:r.minmax.max};var e,n=g(t.level0Nodes);try{for(n.s();!(e=n.n()).done;){e.value.traverse((function(e){e.setBBoxZ&&e.setBBoxZ(t.minMaxFromElevationLayer.min,t.minMaxFromElevationLayer.max)}))}}catch(t){n.e(t)}finally{n.f()}return r})),this}},{key:"update",value:function(t,e,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.material;if(!e.parent||!a)return null;if(void 0===e.layerUpdateState[this.id]&&(e.layerUpdateState[this.id]=new h.default,r&&r.material&&this.initNodeElevationTextureFromParent(e,r)))return t.instance.notifyChange(e,!1),null;var o=Date.now();if(i||this.frozen||!e.material.visible||!e.layerUpdateState[this.id].canTryUpdate(o))return null;var s=e.material.getElevationTextureInfo(),l=this.getPossibleTextureImprovements(this,e.getExtentForLayer(this),s&&s.texture,e.layerUpdateState[this.id].failureParams);if(!l)return e.layerUpdateState[this.id].noMoreUpdatePossible(),null;e.layerUpdateState[this.id].newTry();var u={view:t.instance,layer:this,requester:e,priority:(0,f.nodeCommandQueuePriorityFunction)(e),earlyDropFunction:f.refinementCommandCancellationFn,toDownload:l};return t.scheduler.execute(u).then((function(t){return null===e.material?null:(Array.isArray(t)&&(t=t[0]),t)}),(function(r){if(r instanceof d.default)e.layerUpdateState[n.id].success();else{console.warn("Elevation texture update error for",e,r);var i=e.layerUpdateState[n.id].errorCount>f.MAX_RETRY;e.layerUpdateState[n.id].failure(Date.now(),i,r),i||window.setTimeout((function(){t.instance.notifyChange(e,!1)}),1e3*e.layerUpdateState[n.id].secondsUntilNextTry())}})).then((function(t){if(t){var r=n.minMaxFromTexture(t.texture,t.pitch),i=r.min,a=r.max;t.min=i,t.max=a,e.setTextureElevation(n,t),e.layerUpdateState[n.id].success()}}))}}],[{key:"colorImageSetup",value:function(t){r||((r=document.createElement("canvas")).width=256,r.height=256);var e=t.image.width,n=t.image.height,i=r.getContext("2d");return r.width=e,r.height=n,i.drawImage(t.image,0,0),{data:i.getImageData(0,0,e,n).data,stride:4*e,h:n}}}]),l}(f.default),_=x;return MS.default=_,MS}var TS,ES,AS={},RS={};function PS(){if(TS)return RS;TS=1;var t=uf;Object.defineProperty(RS,"__esModule",{value:!0}),RS.default=void 0;var e=t(pf()),r=t(yf()),n=t(Cf()),i=t(Df()),a=t(Uf()),o=Bf;function s(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,a.default)(t);if(e){var o=(0,a.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,i.default)(this,r)}}var l=function(t){(0,n.default)(a,t);var i=s(a);function a(t,r){var n;return(0,e.default)(this,a),(n=i.call(this)).box3D=new o.Box3(t.clone(),r.clone()),n.natBox=n.box3D.clone(),n.z={min:0,max:0},n.topPointsWorld=[new o.Vector3,new o.Vector3,new o.Vector3,new o.Vector3],n.update(),n}return(0,r.default)(a,[{key:"clone",value:function(){var t=new a(this.natBox.min,this.natBox.max);return t.position.copy(this.position),t.quaternion.copy(this.quaternion),t}},{key:"updateMinMax",value:function(t,e){this.box3D.min.copy(t),this.box3D.max.copy(e),this.natBox.copy(this.box3D),this.update(),this.oPosition.copy(this.position)}},{key:"update",value:function(){this.updateMatrixWorld(!0),this._cPointsWorld(this._points(this.topPointsWorld))}},{key:"updateZ",value:function(t,e){this.z={min:t,max:e},this.box3D.min.z=this.natBox.min.z+t,this.box3D.max.z=this.natBox.max.z+e,this.update()}},{key:"_points",value:function(t){return t[0].set(this.box3D.max.x,this.box3D.max.y,this.box3D.max.z),t[1].set(this.box3D.min.x,this.box3D.max.y,this.box3D.max.z),t[2].set(this.box3D.min.x,this.box3D.min.y,this.box3D.max.z),t[3].set(this.box3D.max.x,this.box3D.min.y,this.box3D.max.z),t.length>4&&(t[4].set(this.box3D.max.x,this.box3D.max.y,this.box3D.min.z),t[5].set(this.box3D.min.x,this.box3D.max.y,this.box3D.min.z),t[6].set(this.box3D.min.x,this.box3D.min.y,this.box3D.min.z),t[7].set(this.box3D.max.x,this.box3D.min.y,this.box3D.min.z)),t}},{key:"_cPointsWorld",value:function(t){for(var e=this.matrixWorld,r=0,n=t.length;r=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&(b[0].minmax||console.error("fix the provider"),g.setBBoxZ(b[0].minmax.min,b[0].minmax.max))}return g.add(g.OBB()),t.onTileCreated(t,r,g),g}var E=new o.Vector3,A=function(t){(0,n.default)(a,t);var i=w(a);function a(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,e.default)(this,a),r=i.call(this,t,n.object3d||new o.Group);var u=n.extent,c=Array.isArray(u)?u[0].crs():u.crs();if(r.validityExtent=u,"EPSG:3857"===c){var h=function(t){for(var e=new l.default("EPSG:3857",-20037508.342789244,20037508.342789244,-20037508.342789244,20037508.342789244),r=e.dimensions(),n=Math.min(Math.floor(r.x/t.dimensions().x),Math.floor(r.y/t.dimensions().y)),i=Math.floor(Math.max(0,Math.log2(n))),a=new s.default("EPSG:3857",t.west(),t.north()),o=new s.default("EPSG:3857",t.east(),t.south()),u=Math.pow(2,i),c=S(a.x()-e.west(),e.north()-a.y(),r,u),h=S(o.x()-e.west(),e.north()-o.y(),r,u),d=r.x/u,f=r.y/u,p=[],m=c.x;m<=h.x;m++)for(var g=c.y;g<=h.y;g++){var v=e.west()+m*d,y=e.north()-g*f;p.push(new l.default("EPSG:3857",v,v+d,y-f,y))}return p}(u);r.schemeTile=h}else Array.isArray(u)?r.schemeTile=u:r.schemeTile=[u];r.extent=r.schemeTile[0].clone();for(var d=1;d0){var u,c=b(e.getColorLayers());try{for(c.s();!(u=c.n()).done;)u.value.update(t,o,r,!0)}catch(t){c.e(t)}finally{c.f()}}o.updateMatrixWorld(!0)}}catch(t){i.e(t)}finally{i.f()}t.instance.notifyChange(r)}}(t,this,e),e.setDisplayed(!1),i=!0):e.setDisplayed(!0)}return e.material.visible&&(e.material.update(),this.updateMinMaxDistance(t,e),!i)?p.default.removeChildren(this,e):i?e.children.filter((function(t){return t.layer===r})):void 0}return e.setDisplayed(!1),p.default.removeChildren(this,e)}},{key:"postUpdate",value:function(){var t,e=this,r=b(this.level0Nodes);try{for(r.s();!(t=r.n()).done;){t.value.traverse((function(t){if(t.layer===e&&t.material.visible){t.material.uniforms.neighbourdiffLevel.value.set(0,0,0,1);var r=t.findNeighbours();if(r)for(var n=t.extent.dimensions(),i=t.material.texturesInfo.elevation.neighbours,a=0;a<4;a++)if(r[a]&&r[a][0].material.visible){var o=r[a][0],s=r[a][1],l=Math.log2(a%2?Math.round(o.extent.dimensions().y/n.y):Math.round(o.extent.dimensions().x/n.x));t.material.uniforms.neighbourdiffLevel.value.setComponent(a,-l),i.texture[a]=o.material.texturesInfo.elevation.texture;var u=s.offsetToParent(o.extent);i.offsetScale[a]=o.material.texturesInfo.elevation.offsetScale.clone(),i.offsetScale[a].x+=u.x*i.offsetScale[a].z,i.offsetScale[a].y+=u.y*i.offsetScale[a].w,i.offsetScale[a].z*=u.z,i.offsetScale[a].w*=u.w}else t.material.uniforms.neighbourdiffLevel.value.setComponent(a,1)}}))}}catch(t){r.e(t)}finally{r.f()}}},{key:"addLayer",value:function(t){var e=this;return new Promise((function(r,n){e._instance?t instanceof u.default?e.getLayers((function(e){return e.id===t.id})).length>0||e.currentAddedLayerIds.includes(t.id)?n(new Error("Invalid id '".concat(t.id,"': id already used"))):(e.currentAddedLayerIds.push(t.id),t.extent||(t.extent=e.extent),t.projection||(t.projection=e.projection),(t=t._preprocessLayer(e,e._instance)).whenReady.then((function(t){e.attach(t),e._instance.notifyChange(e,!1),r(t)})).catch((function(t){n(t)})).then((function(){e.currentAddedLayerIds=e.currentAddedLayerIds.filter((function(e){return e!==t.id}))}))):n(new Error("layer is not an instance of Layer")):n(new Error("map is not attached to an instance"))}))}},{key:"removeLayer",value:function(t){t.object3d&&(p.default.removeChildrenAndCleanupRecursively(t,t.object3d),this.scene.remove(t.object3d));var e=this.getLayers((function(e){return e._attachedLayers&&e._attachedLayers.includes(t)}))[0];e&&e.detach(t),this._cleanLayer(t),this.notifyChange(e||this._instance.camera.camera3D,!0)}},{key:"getLayers",value:function(t){var e,r=[],n=b(this._attachedLayers);try{for(n.s();!(e=n.n()).done;){var i=e.value;t&&!t(i)||r.push(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"getColorLayers",value:function(){return this.getLayers((function(t){return t instanceof c.default}))}},{key:"getElevationLayers",value:function(){return this.getLayers((function(t){return t instanceof h.default}))}},{key:"clean",value:function(){var t,e=b(this.getLayers());try{for(e.s();!(t=e.n()).done;){t.value.clean(this)}}catch(t){e.e(t)}finally{e.f()}}},{key:"hasEnoughTexturesToSubdivide",value:function(t,e){var r,n=this,i=b(t.elevationLayers);try{for(i.s();!(r=i.n()).done;){var a=r.value;if(!a.frozen&&a.ready&&a.tileInsideLimit(e,a)&&!e.material.isElevationLayerTextureLoaded(a)){if(e.layerUpdateState[a.id]&&e.layerUpdateState[a.id].inError())continue;return!1}}}catch(t){i.e(t)}finally{i.f()}return e.children.some((function(t){return t.layer===n})),!0}},{key:"testTileSSE",value:function(t,e){if(this.maxSubdivisionLevel>0&&this.maxSubdivisionLevel<=t.level)return!1;if(t.extent.dimensions().x<5)return!1;if(!e)return!0;var r=[e.lengths.x*e.ratio,e.lengths.y*e.ratio];return!(r.filter((function(e){return e<100*t.layer.sseScale})).length>=1)&&r.filter((function(e){return e>=384*t.layer.sseScale})).length>=2}},{key:"updateMinMaxDistance",value:function(t,e){var r=e.OBB().box3D.clone().applyMatrix4(e.OBB().matrixWorld),n=t.distance.plane.distanceToPoint(r.getCenter(E)),i=.5*r.getSize(E).length();this._distance.min=Math.min(this._distance.min,n-i),this._distance.max=Math.max(this._distance.max,n+i)}}]),a}(d.default);return bS.Map=A,bS}function jS(){if(US)return wS;US=1,Object.defineProperty(wS,"__esModule",{value:!0}),wS.default=void 0;var t=GS();function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,a,o)}}class rT{constructor(t){this.parser=t,this.name=qS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const a=i.extensions[e],o=n.images[a.source];let s=r.textureLoader;if(o.uri){const t=r.options.manager.getHandler(o.uri);null!==t&&(s=t)}return this.detectSupport().then((function(i){if(i)return r.loadTextureImage(t,o,s);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class nT{constructor(t){this.name=qS.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,r=e.bufferViews[t];if(r.extensions&&r.extensions[this.name]){const t=r.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([n,i.ready]).then((function(e){const r=t.byteOffset||0,n=t.byteLength||0,a=t.count,o=t.byteStride,s=new ArrayBuffer(a*o),l=new Uint8Array(e[0],r,n);return i.decodeGltfBuffer(new Uint8Array(s),a,o,l,t.mode,t.filter),s}))}return null}}const iT="glTF",aT=1313821514,oT=5130562;class sT{constructor(t){this.name=qS.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:Rh.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==iT)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,n=new DataView(t,12);let i=0;for(;i",e).replace("#include ",r).replace("#include ",n).replace("#include ",i).replace("#include ",a)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(t){o.specular.value=t}},specularMap:{get:function(){return o.specularMap.value},set:function(t){o.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(t){o.glossiness.value=t}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(t){o.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class hT{constructor(){this.name=qS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return cT}extendParams(t,e,r){const n=e.extensions[this.name];t.color=new Xn(1,1,1),t.opacity=1;const i=[];if(Array.isArray(n.diffuseFactor)){const e=n.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==n.diffuseTexture&&i.push(r.assignTexture(t,"map",n.diffuseTexture)),t.emissive=new Xn(0,0,0),t.glossiness=void 0!==n.glossinessFactor?n.glossinessFactor:1,t.specular=new Xn(1,1,1),Array.isArray(n.specularFactor)&&t.specular.fromArray(n.specularFactor),void 0!==n.specularGlossinessTexture){const e=n.specularGlossinessTexture;i.push(r.assignTexture(t,"glossinessMap",e)),i.push(r.assignTexture(t,"specularMap",e))}return Promise.all(i)}createMaterial(t){const e=new cT(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=je,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}class dT{constructor(){this.name=qS.KHR_MESH_QUANTIZATION}}class fT extends Uc{constructor(t,e,r,n){super(t,e,r,n)}copySampleValue_(t){const e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let t=0;t!==n;t++)e[t]=r[i+t];return e}}fT.prototype.beforeStart_=fT.prototype.copySampleValue_,fT.prototype.afterEnd_=fT.prototype.copySampleValue_,fT.prototype.interpolate_=function(t,e,r,n){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,u=n-e,c=(r-e)/u,h=c*c,d=h*c,f=t*l,p=f-l,m=-2*d+3*h,g=d-h,v=1-m,y=g-h+c;for(let t=0;t!==o;t++){const e=a[p+t+o],r=a[p+t+s]*u,n=a[f+t+o],l=a[f+t]*u;i[t]=v*e+y*r+m*n+g*l}return i};const pT=new Mr;class mT extends fT{interpolate_(t,e,r,n){const i=super.interpolate_(t,e,r,n);return pT.fromArray(i).normalize().toArray(i),i}}const gT=0,vT=1,yT=2,xT=3,_T=4,wT=5,bT=6,MT={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ST={9728:st,9729:ct,9984:lt,9985:ht,9986:ut,9987:dt},TT={33071:at,33648:ot,10497:it},ET={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},AT={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},RT={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},PT={CUBICSPLINE:void 0,LINEAR:Ee,STEP:Te},CT="OPAQUE",IT="MASK",LT="BLEND";function OT(t,e,r){for(const n in r.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=r.extensions[n])}function DT(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function kT(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let r=0,n=e.weights.length;r{const r=this.associations.get(t);null!=r&&this.associations.set(e,r);for(const[r,n]of t.children.entries())i(n,e.children[r])};return i(r,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let r=0;r=2&&f.setY(e,c[t*a+1]),a>=3&&f.setZ(e,c[t*a+2]),a>=4&&f.setW(e,c[t*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f}))}loadTexture(t){const e=this.json,r=this.options,n=e.textures[t],i=e.images[n.source];let a=this.textureLoader;if(i.uri){const t=r.manager.getHandler(i.uri);null!==t&&(a=t)}return this.loadTextureImage(t,i,a)}loadTextureImage(t,e,r){const n=this,i=this.json,a=this.options,o=i.textures[t],s=(e.uri||e.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];const l=self.URL||self.webkitURL;let u=e.uri||"",c=!1;if(void 0!==e.bufferView)u=n.getDependency("bufferView",e.bufferView).then((function(t){c=!0;const r=new Blob([t],{type:e.mimeType});return u=l.createObjectURL(r),u}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(u).then((function(t){return new Promise((function(e,n){let i=e;!0===r.isImageBitmapLoader&&(i=function(t){const r=new vr(t);r.needsUpdate=!0,e(r)}),r.load(Rh.resolveURL(t,a.path),i,void 0,n)}))})).then((function(e){!0===c&&l.revokeObjectURL(u),e.flipY=!1,o.name&&(e.name=o.name);const r=(i.samplers||{})[o.sampler]||{};return e.magFilter=ST[r.magFilter]||ct,e.minFilter=ST[r.minFilter]||dt,e.wrapS=TT[r.wrapS]||it,e.wrapT=TT[r.wrapT]||it,n.associations.set(e,{textures:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",u),null}));return this.textureCache[s]=h,h}assignTexture(t,e,r){const n=this;return this.getDependency("texture",r.index).then((function(i){if(void 0===r.texCoord||0==r.texCoord||"aoMap"===e&&1==r.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+r.texCoord+" for texture "+e+" not yet supported."),n.extensions[qS.KHR_TEXTURE_TRANSFORM]){const t=void 0!==r.extensions?r.extensions[qS.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=n.associations.get(i);i=n.extensions[qS.KHR_TEXTURE_TRANSFORM].extendTexture(i,t),n.associations.set(i,e)}}return t[e]=i,i}))}assignFinalMaterial(t){const e=t.geometry;let r=t.material;const n=void 0===e.attributes.tangent,i=void 0!==e.attributes.color,a=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+r.uuid;let e=this.cache.get(t);e||(e=new Zl,zn.prototype.copy.call(e,r),e.color.copy(r.color),e.map=r.map,e.sizeAttenuation=!1,this.cache.add(t,e)),r=e}else if(t.isLine){const t="LineBasicMaterial:"+r.uuid;let e=this.cache.get(t);e||(e=new Ul,zn.prototype.copy.call(e,r),e.color.copy(r.color),this.cache.add(t,e)),r=e}if(n||i||a){let t="ClonedMaterial:"+r.uuid+":";r.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),n&&(t+="derivative-tangents:"),i&&(t+="vertex-colors:"),a&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=r.clone(),i&&(e.vertexColors=!0),a&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(r))),r=e}r.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=r}getMaterialType(){return Rc}loadMaterial(t){const e=this,r=this.json,n=this.extensions,i=r.materials[t];let a;const o={},s=i.extensions||{},l=[];if(s[qS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=n[qS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];a=t.getMaterialType(),l.push(t.extendParams(o,i,e))}else if(s[qS.KHR_MATERIALS_UNLIT]){const t=n[qS.KHR_MATERIALS_UNLIT];a=t.getMaterialType(),l.push(t.extendParams(o,i,e))}else{const r=i.pbrMetallicRoughness||{};if(o.color=new Xn(1,1,1),o.opacity=1,Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;o.color.fromArray(t),o.opacity=t[3]}void 0!==r.baseColorTexture&&l.push(e.assignTexture(o,"map",r.baseColorTexture)),o.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,o.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(e.assignTexture(o,"metalnessMap",r.metallicRoughnessTexture)),l.push(e.assignTexture(o,"roughnessMap",r.metallicRoughnessTexture))),a=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),l.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,o)}))))}!0===i.doubleSided&&(o.side=h);const u=i.alphaMode||CT;if(u===LT?(o.transparent=!0,o.depthWrite=!1):(o.format=Et,o.transparent=!1,u===IT&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&a!==Yn&&(l.push(e.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new sr(1,1),void 0!==i.normalTexture.scale)){const t=i.normalTexture.scale;o.normalScale.set(t,t)}return void 0!==i.occlusionTexture&&a!==Yn&&(l.push(e.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&a!==Yn&&(o.emissive=(new Xn).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&a!==Yn&&l.push(e.assignTexture(o,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){let r;return r=a===cT?n[qS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new a(o),i.name&&(r.name=i.name),r.map&&(r.map.encoding=ke),r.emissiveMap&&(r.emissiveMap.encoding=ke),DT(r,i),e.associations.set(r,{materials:t}),i.extensions&&OT(n,r,i),r}))}createUniqueName(t){const e=dd.sanitizeNodeName(t||"");let r=e;for(let t=1;this.nodeNamesUsed[r];++t)r=e+"_"+t;return this.nodeNamesUsed[r]=!0,r}loadGeometries(t){const e=this,r=this.extensions,n=this.primitiveCache;function i(t){return r[qS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(r){return GT(r,t,e)}))}const a=[];for(let r=0,o=t.length;r0&&kT(h,i),h.name=e.createUniqueName(i.name||"mesh_"+t),DT(h,i),c.extensions&&OT(n,h,c),e.assignFinalMaterial(h),l.push(h)}for(let r=0,n=l.length;r1?new js:1===e.length?e[0]:new An,o!==e[0])for(let t=0,r=e.length;t{const e=new Map;for(const[t,r]of i.associations)(t instanceof zn||t instanceof vr)&&e.set(t,r);return t.traverse((t=>{const r=i.associations.get(t);null!=r&&e.set(t,r)})),e})(a),a}))}}function zT(t,e,r,n){const i=r.nodes[t];return n.getDependency("node",t).then((function(t){if(void 0===i.skin)return t;let e;return n.getDependency("skin",i.skin).then((function(t){e=t;const r=[];for(let t=0,i=e.joints.length;t=2.0 are supported.")));const l=new BT(s,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===o[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(r,n)}parseAsync(t,e){const r=this;return new Promise((function(n,i){r.parse(t,e,n,i)}))}}},Symbol.toStringTag,{value:"Module"})));var HT,WT={};function qT(){if(HT)return WT;HT=1,Object.defineProperty(WT,"__esModule",{value:!0}),WT.default=void 0;var t=Bf,e=function(){function e(e){this.manager=void 0!==e?e:t.DefaultLoadingManager}function r(){var t={};return{get:function(e){return t[e]},add:function(e,r){t[e]=r},remove:function(e){delete t[e]},removeAll:function(){t={}},update:function(e,r){for(var n in t){var i=t[n];i.update&&i.update(e,r)}}}}function n(e,r){var n={},i=e.material.uniforms;for(var a in i){var o=i[a];if(o.semantic){var s=o.node,l=e;s&&(l=r[s]),n[a]={semantic:o.semantic,sourceNode:l,targetNode:e,uniform:o}}}this.boundUniforms=n,this._m4=new t.Matrix4}e.prototype={constructor:e,crossOrigin:"Anonymous",load:function(e,r,n,i){var a=this,o=this.path&&"string"==typeof this.path?this.path:t.LoaderUtils.extractUrlBase(e),s=new t.FileLoader(a.manager);s.setResponseType("arraybuffer"),s.load(e,(function(t){a.parse(t,r,o)}),n,i)},setCrossOrigin:function(t){this.crossOrigin=t},setPath:function(t){this.path=t},parse:function(e,r,n){var s,u={};t.LoaderUtils.decodeText(new Uint8Array(e,0,4))===o.magic?(u[i.KHR_BINARY_GLTF]=new l(e),s=u[i.KHR_BINARY_GLTF].content):s=t.LoaderUtils.decodeText(new Uint8Array(e));var c=JSON.parse(s);c.extensionsUsed&&c.extensionsUsed.indexOf(i.KHR_MATERIALS_COMMON)>=0&&(u[i.KHR_MATERIALS_COMMON]=new a(c)),new A(c,u,{path:n||this.path,crossOrigin:this.crossOrigin}).parse((function(t,e,n,i){r({scene:t,scenes:e,cameras:n,animations:i})}))}},e.Shaders={update:function(){console.warn("LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.")}},n.prototype.update=function(t,e){var r=this.boundUniforms;for(var n in r){var i=r[n];switch(i.semantic){case"MODELVIEW":i.uniform.value.multiplyMatrices(e.matrixWorldInverse,i.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var a=i.uniform.value;this._m4.multiplyMatrices(e.matrixWorldInverse,i.sourceNode.matrixWorld),a.getNormalMatrix(this._m4);break;case"PROJECTION":i.uniform.value.copy(e.projectionMatrix);break;case"JOINTMATRIX":for(var o=i.uniform.value,s=0;s>6*r)+n];r>0;){var a=e>>6*(r-1);i.push(128|63&a),r-=1}return i}}rE.prototype={decode:function(t,e){var r;r="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=KT(e),this._streaming||(this._decoder=new iE({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,i=new QT(r),a=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==$T;)null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n));if(!this._streaming){do{if((n=this._decoder.handler(i,i.read()))===$T)break;null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n))}while(!i.endOfStream());this._decoder=null}return a.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===a[0]?(this._BOMseen=!0,a.shift()):this._BOMseen=!0)),function(t){for(var e="",r=0;r>10),56320+(1023&n)))}return e}(a)}},nE.prototype={encode:function(t,e){t=t?String(t):"",e=KT(e),this._streaming||(this._encoder=new aE(this._options)),this._streaming=Boolean(e.stream);for(var r,n=[],i=new QT(function(t){for(var e=String(t),r=e.length,n=0,i=[];n57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(n===r-1)i.push(65533);else{var o=t.charCodeAt(n+1);if(56320<=o&&o<=57343){var s=1023&a,l=1023&o;i.push(65536+(s<<10)+l),n+=1}else i.push(65533)}n+=1}return i}(t));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==$T;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==$T;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};const oE=of(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:rE,TextEncoder:nE},Symbol.toStringTag,{value:"Module"})));var sE,lE;function uE(){if(sE)return YT;sE=1,Object.defineProperty(YT,"__esModule",{value:!0}),YT.default=YT.TextDecoder=void 0;var t=oE,e="function"==typeof af.TextDecoder?af.TextDecoder:t.TextDecoder;YT.TextDecoder=e;var r=new e("utf-8");return YT.default=r,YT}function cE(){if(lE)return XT;lE=1;var t=uf;Object.defineProperty(XT,"__esModule",{value:!0}),XT.default=void 0;var e=t(uE()),r={parse:function(t){var r=e.default.decode(new Uint8Array(t)),n=JSON.parse(r);return Promise.resolve(n)}};return XT.default=r,XT}var hE,dE,fE={};function pE(){if(dE)return HS;dE=1;var t=uf;Object.defineProperty(HS,"__esModule",{value:!0}),HS.default=void 0;var e=t(cf),r=Bf,n=VT,i=t(qT()),a=t(cE()),o=t($M()),s=t(function(){if(hE)return fE;hE=1,Object.defineProperty(fE,"__esModule",{value:!0}),fE.default=void 0;var t=new RegExp("gl_Position.*(?![^]*gl_Position)"),e=new RegExp("[^\\w]*main[^\\w]*(void)?[^\\w]*{"),r={patchMaterialForLogDepthSupport:function(r){if(-1===r.vertexShader.indexOf("USE_LOGDEPTHBUF")&&-1===r.vertexShader.indexOf("logdepthbuf_pars_vertex")){r.vertexShader="#include \n#define EPSILON 1e-6\n".concat(r.vertexShader);var n=t.exec(r.vertexShader),i=n[0].length+n.index;r.vertexShader="".concat(r.vertexShader.slice(0,i),"\n#include \n").concat(r.vertexShader.slice(i)),r.fragmentShader="".concat("precision highp float;\nprecision highp int;\n","\n#include \n").concat(r.fragmentShader),i=(n=e.exec(r.fragmentShader))[0].length+n.index,r.fragmentShader="".concat(r.fragmentShader.slice(0,i),"\n#include \n").concat(r.fragmentShader.slice(i)),r.defines={USE_LOGDEPTHBUF:1,USE_LOGDEPTHBUF_EXT:1}}}};return fE.default=r,fE}()),l=t(uE());function u(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0){var _=28+y.FTJSONLength+y.FTBinaryLength;x.push(a.default.parse(t.slice(_,y.BTJSONLength+_)))}else x.push(Promise.resolve({}));return x.push(new Promise((function(a){var g=function(c){var f,p=u(c.scenes);try{for(p.s();!(f=p.n()).done;){f.value.traverse(m)}}catch(t){p.e(t)}finally{p.f()}void 0===i||"Y"===i?c.scene.applyMatrix4(h):"X"===i&&c.scene.applyMatrix4(d),function(t,e){var r=new DataView(t,0,20),n=new Uint8Array(t,20,r.getUint32(12,!0)),i=l.default.decode(new Uint8Array(n)),a=JSON.parse(i);a.extensions&&a.extensions.CESIUM_RTC&&(e.position.fromArray(a.extensions.CESIUM_RTC.center),e.updateMatrixWorld(!0))}(t.slice(28+y.FTJSONLength+y.FTBinaryLength+y.BTJSONLength+y.BTBinaryLength),c.scene),c.scene.traverse((function(t){t.frustumCulled=!1,t.material&&(n.overrideMaterials?(t.material.dispose(),"object"===(0,e.default)(n.overrideMaterials)&&n.overrideMaterials.isMaterial?t.material=n.overrideMaterials.clone():t.material=new r.MeshLambertMaterial({color:16777215})):o.default.isLogDepthBufferSupported()&&t.material.isRawShaderMaterial&&!n.doNotPatchMaterial&&(s.default.patchMaterialForLogDepthSupport(t.material),console.warn("b3dm shader has been patched to add log depth buffer support")),t.material.transparent=n.opacity<1,t.material.opacity=n.opacity)})),a(c)},v=t.slice(28+y.FTJSONLength+y.FTBinaryLength+y.BTJSONLength+y.BTBinaryLength);1===new DataView(v,0,20).getUint32(4,!0)?p.parse(v,g,c):f.parse(v,c,g,(function(t){return console.error(t)}))}))),Promise.all(x).then((function(t){return{gltf:t[1],batchTable:t[0]}}))}throw new Error("Invalid b3dm file.")}};return HS.default=g,HS}var mE,gE={};function vE(){if(mE)return gE;mE=1;var t=uf;Object.defineProperty(gE,"__esModule",{value:!0}),gE.default=void 0;var e=Bf,r=t(cE()),n=t(uE()),i={parse:function(t){if(!t)throw new Error("No array buffer provided.");var i=new DataView(t),a=0,o={},s={},l={};if(o.magic=n.default.decode(new Uint8Array(t,a,4)),a+=4,o.magic){if(o.version=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.byteLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.FTJSONLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.FTBinaryLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.BTJSONLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.BTBinaryLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.FTBinaryLength>0&&(l=function(t,r,i){var a,o=new e.BufferGeometry,s=n.default.decode(new Uint8Array(t,r,i)),l=JSON.parse(s);l.POINTS_LENGTH&&(a=l.POINTS_LENGTH);if(l.POSITION){var u=l.POSITION.byteOffset+s.length+r,c=new Float32Array(t,u,3*a);o.setAttribute("position",new e.BufferAttribute(c,3))}if(l.RGB){var h=l.RGB.byteOffset+s.length+r,d=new Uint8Array(t,h,3*a);o.setAttribute("color",new e.BufferAttribute(d,3,!0))}if(l.POSITION_QUANTIZED)throw new Error("For pnts loader, POSITION_QUANTIZED: not yet managed");if(l.RGBA)throw new Error("For pnts loader, RGBA: not yet managed");if(l.RGB565)throw new Error("For pnts loader, RGB565: not yet managed");if(l.NORMAL)throw new Error("For pnts loader, NORMAL: not yet managed");if(l.NORMAL_OCT16P)throw new Error("For pnts loader, NORMAL_OCT16P: not yet managed");if(l.BATCH_ID)throw new Error("For pnts loader, BATCH_ID: not yet managed");var f=l.RTC_CENTER?(new e.Vector3).fromArray(l.RTC_CENTER):void 0;return{geometry:o,offset:f}}(t,a,o.FTJSONLength)),o.BTJSONLength>0){var u=28+o.FTJSONLength+o.FTBinaryLength;s=r.default.parse(t.slice(u,o.BTJSONLength+u))}var c={point:l,batchTable:s};return Promise.resolve(c)}throw new Error("Invalid pnts file.")}};return gE.default=i,gE}var yE,xE,_E={},wE={};function bE(){if(yE)return wE;yE=1;var t=uf;Object.defineProperty(wE,"__esModule",{value:!0}),wE.default=wE.MODE=void 0;var e=t(pf()),r=t(yf()),n=t(sM()),i=t(Cf()),a=t(Df()),o=t(Uf()),s=Bf,l=t($M());function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,o.default)(t);if(e){var i=(0,o.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,a.default)(this,r)}}var c={COLOR:0,INTENSITY:1,CLASSIFICATION:2,NORMAL:3,TEXTURE:4,ELEVATION:5};wE.MODE=c;var h=16,d=function(t){(0,i.default)(d,t);var a=u(d);function d(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,e.default)(this,d),(t=a.call(this)).vertexShader="precision highp float;\nprecision highp int;\n\n#include \n#define EPSILON 1e-6\n\nattribute vec3 position;\nuniform mat4 modelMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\nuniform float size;\n\nuniform int pickingId;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\nattribute vec3 color;\nattribute vec4 unique_id;\nattribute float intensity;\n\n#if defined(NORMAL_OCT16)\nattribute vec2 oct16Normal;\n#elif defined(NORMAL_SPHEREMAPPED)\nattribute vec2 sphereMappedNormal;\n#else\nattribute vec3 normal;\n#endif\n\nuniform sampler2D overlayTexture;\nuniform vec4 offsetScale;\nuniform vec2 extentTopLeft;\nuniform vec2 extentSize;\n\nvarying vec4 vColor;\n\n// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602\n// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)\n#if defined(NORMAL_OCT16)\nvec3 decodeOct16Normal(vec2 encodedNormal) {\n vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;\n vec3 n;\n n.z = 1. - abs(nNorm.x) - abs(nNorm.y);\n if (n.z >= 0.) {\n n.x = nNorm.x;\n n.y = nNorm.y;\n } else {\n n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;\n n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;\n }\n return normalize(n);\n}\n#elif defined(NORMAL_SPHEREMAPPED)\n// see http://aras-p.info/texts/CompactNormalStorage.html method #4\n// or see potree's implementation in BINPointReader.cpp\nvec3 decodeSphereMappedNormal(vec2 encodedNormal) {\n vec2 fenc = 2. * encodedNormal / 255. - 1.;\n float f = dot(fenc,fenc);\n float g = 2. * sqrt(1. - f);\n vec3 n;\n n.xy = fenc * g;\n n.z = 1. - 2. * f;\n return n;\n}\n#endif\n\n#ifdef DEFORMATION_SUPPORT\nuniform int enableTransfo;\nuniform mat4 transformations[NUM_TRANSFO];\nuniform vec3 vec[NUM_TRANSFO];\nuniform vec2 origin[NUM_TRANSFO];\nuniform vec2 influence[NUM_TRANSFO];\nuniform vec4 tColors[NUM_TRANSFO];\n#endif\n\nvoid main() {\n\n#if defined(NORMAL_OCT16)\n vec3 normal = decodeOct16Normal(oct16Normal);\n#elif defined(NORMAL_SPHEREMAPPED)\n vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);\n#elif defined(NORMAL)\n // nothing to do\n#else\n // default to color\n vec3 normal = color;\n#endif\n\n if (pickingId > 0) {\n vColor = unique_id;\n\n int left4bitsShift = 16; // << 4 <=> * 2^4\n int left8bitsShift = left4bitsShift * left4bitsShift;\n // 20 bits for 'unique_id' (= the point index in the buffer)\n // 12 bits for 'pickingId' (= the point instance id)\n // (see Picking.js)\n // = |4bits|| 8 bits |\n // ^ left-most 4 bits of the green channel\n // ^ red channel\n int upperPart = pickingId / left8bitsShift;\n int lowerPart = pickingId - upperPart * left8bitsShift; // 8 bits\n vColor.r = float(lowerPart) / 255.0;\n vColor.g += float(upperPart * 8) / 255.0; // << 4\n // vColor.g += float(upperPart * left4bitsShift) / 255.0;\n } else if (mode == MODE_INTENSITY) {\n vColor = vec4(intensity, intensity, intensity, opacity);\n } else if (mode == MODE_NORMAL) {\n vColor = vec4(abs(normal), opacity);\n } else if (mode == MODE_TEXTURE) {\n vec2 pp = (modelMatrix * vec4(position, 1.0)).xy;\n // offsetScale is from topleft\n pp.x -= extentTopLeft.x;\n pp.y = extentTopLeft.y - pp.y;\n pp *= offsetScale.zw / extentSize;\n pp += offsetScale.xy;\n pp.y = 1.0 - pp.y;\n vec3 textureColor = texture2D(overlayTexture, pp).rgb;\n vColor = vec4(mix(textureColor, overlayColor.rgb, overlayColor.a), opacity);\n } else if (mode == MODE_ELEVATION) {\n float z = (modelMatrix * vec4(position, 1.0)).z;\n // colors from OGC EL.GridCoverage.Default style\n if (z < -100.0) {\n vColor = vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0);\n } else if (z <= 0.0) {\n vColor = mix(\n vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n -z / 100.0);\n } else if (z <= 50.0) {\n vColor = mix(\n vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n -z / 100.0);\n } else if (z <= 50.0) {\n vColor = mix(\n vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n z / 50.0);\n } else if (z <= 100.0) {\n vColor = mix(\n vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n (z - 50.0)/ 50.0);\n } else {\n vColor = mix(\n vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n vec4(float(0x7B) / 255.0, float(0xF2) / 255.0, float(0x3A) / 255.0, 1.0),\n (z - 100.0)/ 50.0);\n }\n vColor.a = opacity;\n } else {\n // default to color mode\n vColor = vec4(mix(color, overlayColor.rgb, overlayColor.a), opacity);\n }\n\n mat4 mvMatrix = modelViewMatrix;\n\n #ifdef DEFORMATION_SUPPORT\n if (!pickingMode) {\n vColor = enableTransfo > 0 ?\n vec4(0.0, 1.0, 1.0, 1.0):\n vec4(1.0, 0.0, 1.0, 1.0);\n }\n if (enableTransfo > 0) {\n vec4 mPosition = modelMatrix * vec4(position, 1.0);\n float minDistance = 1000.0;\n int bestChoice = -1;\n for (int i = 0; i < NUM_TRANSFO; i++) {\n if (i >= enableTransfo) {\n break;\n }\n vec2 v = vec[i].xy;\n float length = vec[i].z;\n float depassement_x =\n length * (influence[i].x - 1.0);\n\n vec2 diff = mPosition.xy - origin[i];\n float distance_x = dot(diff, v);\n\n if (-depassement_x <= distance_x &&\n distance_x <= (length + depassement_x)) {\n vec2 normal = vec2(-v.y, v.x);\n float d = abs(dot(diff, normal));\n if (d < minDistance && d <= influence[i].y) {\n minDistance = d;\n bestChoice = i;\n }\n }\n }\n\n if (bestChoice >= 0) {\n // override modelViewMatrix\n mvMatrix = transformations[bestChoice];\n vColor = mix(\n tColors[bestChoice],\n vec4(color, 1.0),\n 0.5);\n }\n }\n #endif\n\n vec4 mvPosition = mvMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n\n if (size > 0.) {\n gl_PointSize = size;\n } else {\n gl_PointSize = clamp(-size / gl_Position.w, 3.0, 10.0);\n }\n\n #include \n}\n",t.fragmentShader="precision highp float;\nprecision highp int;\n\n#include \n\nvarying vec4 vColor;\n\nvoid main() {\n // circular point rendering\n if(length(gl_PointCoord - 0.5) > 0.5){\n discard;\n }\n\n gl_FragColor = vColor;\n\n #include \n}\n",t.size=r.size||0,t.scale=r.scale||.025/Math.tan(.5),t.overlayColor=r.overlayColor||new s.Vector4(0,0,0,0),t.mode=r.mode||c.COLOR,t.pickingId=0;for(var n=0,i=Object.keys(c);n0?this.size:-this.scale*window.innerHeight,this.uniforms.mode.value=this.mode,this.uniforms.pickingId.value=this.pickingId,this.uniforms.opacity.value=this.opacity,this.uniforms.overlayColor.value=this.overlayColor}},{key:"update",value:function(t){return t&&(this.visible=t.visible,this.opacity=t.opacity,this.transparent=t.transparent,this.size=t.size,this.mode=t.mode,this.pickingId=t.pickingId,this.scale=t.scale,this.overlayColor.copy(t.overlayColor)),this.updateUniforms(),t&&Object.assign(this.defines,t.defines),this}},{key:"pushLayer",value:function(t,e){this.mode=c.TEXTURE,this.updateUniforms(),this.colorLayer=t,this.uniforms.overlayTexture=new s.Uniform,this.uniforms.offsetScale=new s.Uniform(new s.Vector4(0,0,1,1)),this.uniforms.extentTopLeft=new s.Uniform(new s.Vector2(e.west(),e.north()));var r=e.dimensions();this.uniforms.extentSize=new s.Uniform(new s.Vector2(r.x,r.y))}},{key:"getColorTexture",value:function(t){return t!==this.colorLayer?null:this.uniforms.overlayTexture.value}},{key:"setColorTextures",value:function(t,e){return Array.isArray(e)&&(e=e[0]),t===this.colorLayer&&(this.uniforms.overlayTexture.value=e.texture,this.uniforms.offsetScale.value.copy(e.pitch)),Promise.resolve()}},{key:"setSequence",value:function(){}},{key:"setLayerVisibility",value:function(){}},{key:"setLayerOpacity",value:function(){}},{key:"enableTransfo",value:function(t){t?(this.defines.DEFORMATION_SUPPORT=1,this.defines.NUM_TRANSFO=h):(delete this.defines.DEFORMATION_SUPPORT,delete this.defines.NUM_TRANSFO),this.needsUpdate=!0}}]),d}(s.RawShaderMaterial),f=d;return wE.default=f,wE}function ME(){if(xE)return _E;xE=1;var t=uf;Object.defineProperty(_E,"__esModule",{value:!0}),_E.default=void 0;var e=t(pf()),r=t(yf()),n=t(Cf()),i=t(Df()),a=t(Uf()),o=Bf,s=t(bE());function l(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,a.default)(t);if(e){var o=(0,a.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,i.default)(this,r)}}var u=function(t){(0,n.default)(a,t);var i=l(a);function a(t,r){var n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new s.default;return(0,e.default)(this,a),(n=i.call(this,r,o))._layer=t,n.extent=void 0,n.layerUpdateState={},n.wmtsCoords={},n}return(0,r.default)(a,[{key:"getExtentForLayer",value:function(t){if(t.extent.crs()!==this._layer.extent.crs())throw new Error("Unsupported reprojection");return this.extent}}]),a}(o.Points),c=u;return _E.default=c,_E}var SE={},TE=uf;Object.defineProperty(SE,"__esModule",{value:!0}),SE.calculateCameraDistance=JE;var EE=SE.default=void 0;SE.init3dTilesEntity=function(t,e,r){return GE(t,e,r,r.tileset.root,void 0,!0).then((function(e){delete r.tileset,r.object3d.add(e),e.updateMatrixWorld(),r.tileIndex.index[e.tileId].obj=e,r.root=e,r.extent=VE(r.projection||t.referenceCrs,e.boundingVolume,e.matrixWorld)}))};var AE=TE(Nx()),RE=TE(pf()),PE=TE(yf()),CE=TE(Cf()),IE=TE(Df()),LE=TE(Uf()),OE=Bf,DE=TE(DM()),kE=TE(kS());function FE(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return NE(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return NE(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function NE(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:{};if((0,RE.default)(this,r),i=e.call(this,t,a.object3d||new OE.Group),!n)throw new Error("missing source");if(!n.url)throw new Error("missing source.url");return i.protocol="3d-tiles",i.url=n.url,i.networkOptions=n.networkOptions,i.sseThreshold=a.sseThreshold||16,i.cleanupDelay=a.cleanupDelay||1e3,i.material=a.material||void 0,i._cleanableTiles=[],i}return(0,PE.default)(r,[{key:"preUpdate",value:function(){if(!this.visible)return[];var t=Date.now();if(this._cleanableTiles.length&&t-this._cleanableTiles[0].cleanableSince>this.cleanupDelay)for(;this._cleanableTiles.length;){var e=this._cleanableTiles[0];if(!(t-e.cleanableSince>this.cleanupDelay))break;qE(this,e)}return[this.root]}},{key:"update",value:function(t,e){var r=this;if(e.remove.apply(e,(0,AE.default)(e.children.filter((function(t){return t.deleted})))),!e.parent.pendingSubdivision||e.parent.additiveRefinement){var n,i=!WE(t.camera,e,e.matrixWorld);if(e.visible=i,i){if(KE(this,e),JE(t.camera.camera3D,e),e.pendingSubdivision||function(t,e,r){if(void 0===e.tileIndex.index[r.tileId].children)return!1;if(e.tileIndex.index[r.tileId].isTileset)return!0;var n=function(t,e){if(e.boundingVolume.region)throw new Error("boundingVolume.region is unsupported");if(e.boundingVolume.box){var r=kE.default.computeFromBox3(t.camera,e.boundingVolume.box,e.matrixWorld,e.geometricError,kE.default.MODE_3D);return r?Math.max(r.lengths.x,r.lengths.y):1/0}return e.boundingVolume.sphere?0===e.distance?1/0:t.camera._preSSE*(e.geometricError/e.distance):1/0}(t,r);return r.sse=n,n>e.sseThreshold}(t,this,e)){if(function(t,e,r,n){r.additiveRefinement?function(t,e,r,n){var i,a=FE(e.tileIndex.index[r.tileId].children);try{var o=function(){var a=i.value;if(a.promise||r.children.filter((function(t){return t.tileId===a.tileId})).length>0)return"continue";var o=r.matrixWorld;if(a.transform&&(o=HE.multiplyMatrices(r.matrixWorld,a.transform)),!(!n||!n(t.camera,a,o)))return"continue";a.promise=GE(t.instance,t.scheduler,e,a,r,!0).then((function(n){if(n&&r.parent){r.add(n),n.updateMatrixWorld();var i=VE(e.extent.crs(),n.boundingVolume,n.matrixWorld);n.traverse((function(t){t.extent=i})),t.instance.notifyChange(a)}delete a.promise}),(function(){delete a.promise}))};for(a.s();!(i=a.n()).done;)o()}catch(t){a.e(t)}finally{a.f()}}(t,e,r,n):function(t,e,r){if(r.pendingSubdivision)return;if(jE(r).length>0)return;var n=e.tileIndex.index[r.tileId].children;if(void 0===n||0===n.length)return;r.pendingSubdivision=!0;var i,a=[],o=FE(e.tileIndex.index[r.tileId].children);try{for(o.s();!(i=o.n()).done;){var s=i.value,l=GE(t.instance,t.scheduler,e,s,r,!1).then((function(t){r.add(t),t.updateMatrixWorld();var n=VE(e.extent.crs(),t.boundingVolume,t.matrixWorld);t.traverse((function(t){t.extent=n}))}));a.push(l)}}catch(t){o.e(t)}finally{o.f()}Promise.all(a).then((function(){r.pendingSubdivision=!1,t.instance.notifyChange(r)}),(function(){r.pendingSubdivision=!1;var t,n=FE(jE(r));try{for(n.s();!(t=n.n()).done;){var i=t.value;i.visible=!1,ZE(e,i)}}catch(t){n.e(t)}finally{n.f()}}))}(t,e,r)}(t,this,e,WE),e.additiveRefinement||e.pendingSubdivision)YE(e,!0);else{var a=this.tileIndex.index[e.tileId].children.filter((function(t){return t.isTileset}));if(a.length){var o,s=!0,l=FE(a);try{var u=function(){var t=o.value,r=e.children.filter((function(e){return e.tileId===t.tileId}))[0];if(!function(t,e){return t&&e&&1===e.children.length&&e.children[0].children.length>0}(t,r))return s=!1,"break"};for(l.s();!(o=l.n()).done;){if("break"===u())break}}catch(t){l.e(t)}finally{l.f()}YE(e,s)}else YE(e,!0)}n=jE(e)}else{YE(e,!0);var c,h=FE(jE(e));try{for(h.s();!(c=h.n()).done;){var d=c.value;d.visible=!1,ZE(this,d)}}catch(t){h.e(t)}finally{h.f()}}if(e.content&&e.content.visible){if(e.boundingVolume.region)throw new Error("boundingVolume.region is not yet supported");(e.boundingVolume.box||e.boundingVolume.sphere)&&(this._distance.min=Math.min(this._distance.min,e.distance.min),this._distance.max=Math.max(this._distance.max,e.distance.max)),e.content.traverse((function(t){t.layer===r&&t.material&&(t.material.wireframe=r.wireframe,t.isPoints&&(t.material.update?t.material.update(r.material):t.material.copy(r.material)))}))}}else e!==this.root&&e.parent&&e.parent.additiveRefinement&&ZE(this,e);return n}e.visible=!1}}]),r}(TE(oS()).default),zE={v:new OE.Vector3,b:new OE.Box3,s:new OE.Sphere};function GE(t,e,r,n,i,a){if(n.obj)return KE(r,n.obj),t.notifyChange(i),Promise.resolve(n.obj);var o;if(!i||i.additiveRefinement){var s=n.boundingVolume.box.clone().applyMatrix4(n._worldFromLocalTransform).getSize(zE.v);o=s.x*s.y}else{var l=i.boundingVolume.box.clone().applyMatrix4(i.matrixWorld).getSize(zE.v);o=l.x*l.y}var u={view:t,requester:i,layer:r,priority:o,metadata:n,redraw:a,earlyDropFunction:function(t){return t.requester&&(!t.requester.parent||!t.requester.visible||t.requester.sse2&&void 0!==arguments[2]?arguments[2]:0;KE(t,e),t.tileIndex.index[e.tileId].obj&&(t.tileIndex.index[e.tileId].obj.deleted=Date.now(),t.tileIndex.index[e.tileId].obj=void 0);var n,i=FE(jE(e));try{for(i.s();!(n=i.n()).done;){var a=n.value;qE(t,a,r+1),e.remove(a)}}catch(t){i.e(t)}finally{i.f()}e.content&&(e.content.traverse(XE),e.remove(e.content),delete e.content),e.dispose&&e.dispose()}function XE(t){var e,r=FE(t.children);try{for(r.s();!(e=r.n()).done;){XE(e.value)}}catch(t){r.e(t)}finally{r.f()}t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose(),t.remove.apply(t,(0,AE.default)(t.children))}function YE(t,e){t.content&&(t.content.visible=e)}function ZE(t,e){e.cleanableSince||(e.cleanableSince=Date.now(),t._cleanableTiles.push(e))}function KE(t,e){e.cleanableSince&&(t._cleanableTiles.splice(t._cleanableTiles.indexOf(e),1),e.cleanableSince=void 0)}function JE(t,e){if(e.distance.min=0,e.distance.max=0,e.boundingVolume.region)throw new Error("boundingVolume.region is unsupported");e.boundingVolume.box?(zE.b.copy(e.boundingVolume.box),zE.b.applyMatrix4(e.matrixWorld),e.distance.min=zE.b.distanceToPoint(t.position),e.distance.max=e.distance.min+zE.b.getSize(zE.v).length()):e.boundingVolume.sphere&&(zE.s.copy(e.boundingVolume.sphere),zE.s.applyMatrix4(e.matrixWorld),e.distance.min=Math.max(0,zE.s.distanceToPoint(t.position)),e.distance.max=e.distance.min+2*zE.s.radius)}var QE,$E=BE;function tA(){if(QE)return VS;QE=1;var t=uf;Object.defineProperty(VS,"__esModule",{value:!0}),VS.$3dTilesIndex=void 0,VS.configureTile=w,VS.default=void 0,VS.getObjectToUpdateForAttachedLayers=v;var e=t(pf()),r=t(yf()),n=Bf,i=t(pE()),a=t(vE()),o=t(Gb()),s=t(uE()),l=t(WM()),u=t(ME()),c=t(bE()),h=t(pM()),d=SE;function f(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r>1,c=-7,h=r?i-1:0,d=r?-1:1,f=t[e+h];for(h+=d,a=f&(1<<-c)-1,f>>=-c,c+=s;c>0;a=256*a+t[e+h],h+=d,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=n;c>0;o=256*o+t[e+h],h+=d,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),a-=u}return(f?-1:1)*o*Math.pow(2,a-n)},uA.write=function(t,e,r,n,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(s=0,o=c):o+h>=1?(s=(e*l-1)*Math.pow(2,i),o+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+f]=255&s,f+=p,s/=256,i-=8);for(o=o<0;t[r+f]=255&o,f+=p,o/=256,u-=8);t[r+f-p]|=128*m}),uA);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function a(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function o(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function s(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function x(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=x(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=v(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=v(this.buf,this.pos)+x(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(i=a[r.pos++],n=(112&i)>>4,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<3,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<10,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<17,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<24,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(1&i)<<31,i<128)return o(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){var n="",i=e;for(;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((u=(15&l)<<12|(63&a)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=a(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else{if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos]=127&t}(r,0,e),function(t,e){var r=(7&t)<<4;if(e.buf[e.pos++]|=r|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&s(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&s(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,g,e)},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r)},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r)},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r)},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r)},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r)},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r)},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},aA}var hA,dA,fA,pA,mA,gA,vA,yA,xA,_A={};function wA(){if(pA)return fA;pA=1;var t=function(){if(dA)return hA;function t(t,e){this.x=t,this.y=e}return dA=1,hA=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.x+r*(this.x-e.x)-n*(this.y-e.y),a=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},hA}();function e(t,e,n,i,a){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=a,t.readFields(r,this,e)}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){var r=t.readVarint()+t.pos;for(;t.pos>3}if(a--,1===i||2===i)o+=e.readSVarint(),s+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(o,s));else{if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone())}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,u=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())u&&(u=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,u]},e.prototype.toGeoJSON=function(t,r,i){var a,o,s=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}return mA=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},mA}function MA(){return xA||(xA=1,_A.VectorTile=function(){if(yA)return vA;yA=1;var t=bA();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i)}}return vA=function(t,r){this.layers=t.readFields(e,{},r)}}(),_A.VectorTileFeature=wA(),_A.VectorTileLayer=bA()),_A}var SA,TA,EA={};function AA(){if(SA)return EA;SA=1;var t=uf;Object.defineProperty(EA,"__esModule",{value:!0}),EA.default=void 0;var e=t(Ux()),r=t(DM());function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{},r=e.crsOut,n=e.filteringExtent;switch("string"==typeof t&&(t=JSON.parse(t)),e.crsIn=e.crsIn||function(t){if(t.crs){if("epsg"===t.crs.type.toLowerCase())return"EPSG:".concat(t.crs.properties.code);if("name"===t.crs.type.toLowerCase()){var e=t.crs.properties.name.toLowerCase().indexOf("epsg:");if(e>=0){var r=t.crs.properties.name.indexOf(":",e+5);if(r>0)return"EPSG:".concat(t.crs.properties.name.substr(r+1))}}throw new Error("Unsupported CRS type '".concat(t.crs,"'"))}return"EPSG:4326"}(t),t.type.toLowerCase()){case"featurecollection":return Promise.resolve(c(e.crsIn,r,t.features,n,e));case"feature":return Promise.resolve(c(e.crsIn,r,[t],n,e));default:throw new Error("Unsupported GeoJSON type: '".concat(t.type))}}};return EA.default=h,EA}function RA(){if(TA)return lA;TA=1;var t=uf;Object.defineProperty(lA,"__esModule",{value:!0}),lA.default=void 0;var e=t(cA()),r=MA(),n=t(AA());t(DM());var i={parse:function(t,i){return Promise.resolve(function(t,i){var a=new r.VectorTile(new e.default(t)),o=Object.keys(a.layers);if(o.length<1)return null;var s,l={type:"FeatureCollection",features:[],crs:{type:"EPSG",properties:{code:4326}},extent:i.extent};o.forEach((function(t){for(var e=a.layers[t],r=0;r1&&(n.properties.vt_layer=t),l.features.push(n)}})),s="WMTS:PM"===i.coords.crs()?"EPSG:3857":i.extent.crs();return n.default.parse(l,{crsOut:s,filteringExtent:i.filteringExtent,filter:i.filter,buildExtent:!0})}(t,i))}};return lA.default=i,lA}var PA,CA,IA,LA={};function OA(){if(PA)return LA;PA=1,Object.defineProperty(LA,"__esModule",{value:!0}),LA.default=void 0;var t=Bf;function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r6&&void 0!==arguments[6]?arguments[6]:{};if(0!==r.length)if(l.length){var u,c=e(l);try{for(c.s();!(u=c.n()).done;){s(t,r,n,i,a,o,u.value)}}catch(t){c.e(t)}finally{c.f()}}else s(t,r,n,i,a,o,l)}function s(t,r,n,o,s,l,u){t.beginPath();var c,h=e(n);try{for(h.s();!(c=h.n()).done;){var d=c.value;i(t,r[d.offset],s,o);for(var f=1;f4&&void 0!==arguments[4]?arguments[4]:{};n.x=e._values[0]-r.x,n.y=r.y-e._values[1],n.multiply(i),t.beginPath(),t.arc(n.x,n.y,a.radius||3,0,2*Math.PI,!1),t.fillStyle=a.fill||"white",t.fill(),t.lineWidth=a.lineWidth||1,t.strokeStyle=a.stroke||"red",t.stroke()}function u(t,r,n,i,a){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},u=r.properties;"function"==typeof s&&(s=s(u,r));var c,h=e(r.geometry);try{for(h.s();!(c=h.n()).done;){var d=c.value;"point"===r.type?l(t,r.vertices[0],n,i,s):d.extent.intersectsExtent(a)&&o(t,r.vertices,d.indices,n,i,u,s)}}catch(t){h.e(t)}finally{h.f()}}var c={createTextureFromFeature:function(r,n,i,a,o){var s;if(r){var l=new t.Vector2(n.west(),n.north()),c=n.dimensions(),h=document.createElement("canvas");h.width=i,h.height=i;var d=h.getContext("2d");o&&(d.fillStyle=o.getStyle(),d.fillRect(0,0,i,i)),d.globalCompositeOperation=a.globalCompositeOperation||"source-over";var f,p=new t.Vector2(d.canvas.width/c.x,d.canvas.width/c.y),m=e(r.features);try{for(m.s();!(f=m.n()).done;){u(d,f.value,l,p,n,a)}}catch(t){m.e(t)}finally{m.f()}(s=new t.Texture(h)).flipY=!1,s.generateMipmaps=!1,s.magFilter=t.LinearFilter,s.minFilter=t.LinearFilter,s.needsUpdate=!0}else if(o){var g=new Uint8Array(3);g[0]=255*o.r,g[1]=255*o.g,g[2]=255*o.b,(s=new t.DataTexture(g,1,1,t.RGBFormat)).needsUpdate=!0}else s=new t.Texture;return s},featuresAtPoint:function(r,n,i,a,o,s){if(!r)return[];var l=[],c=n.dimensions(),h=new t.Vector2(i/c.x,i/c.y),d=new t.Vector2(o.x-s/h.x,o.y+s/h.y),f=document.createElement("canvas");f.width=1+2*s,f.height=1+2*s;var p=f.getContext("2d");p.globalCompositeOperation="source-over";var m,g=e(r.features);try{for(g.s();!(m=g.n()).done;){var v=m.value;p.clearRect(0,0,f.width,f.height),u(p,v,d,h,n,a);for(var y=p.getImageData(0,0,f.width,f.height),x=y.data,_=!1,w=0;w0);w+=4);_&&l.push(v)}}catch(t){g.e(t)}finally{g.f()}return l}};return LA.default=c,LA}function DA(){if(IA)return rA;IA=1;var t=uf;Object.defineProperty(rA,"__esModule",{value:!0}),rA.default=void 0;var e=t(px()),r=t(Nx()),n=Bf,i=t(FM()),a=t(function(){if(eA)return nA;eA=1;var t=uf;return Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0,t(DM()),t(jb()),nA.default={xyz:function(t,e){return e.url.replace(/(\$\{z\}|%TILEMATRIX)/,t.zoom).replace(/(\$\{y\}|%ROW)/,t.row).replace(/(\$\{x\}|%COL)/,t.col)},bbox:function(t,e){var r="EPSG:4326"===e.projection?9:2,n=t.crs()===e.projection?t:t.as(e.projection),i=n.west().toFixed(r),a=n.south().toFixed(r),o=n.east().toFixed(r),s=n.north().toFixed(r),l=e.axisOrder||"wsen";return l=l.replace("w","".concat(i,",")).replace("s","".concat(a,",")).replace("e","".concat(o,",")).replace("n","".concat(s,",")).slice(0,-1),e.url.replace("%bbox",l)}},nA}()),o=t(DM()),s=t(function(){if(CA)return sA;CA=1;var t=uf;Object.defineProperty(sA,"__esModule",{value:!0}),sA.default=void 0;var e=Bf,r=t(Gb()),n=t(pM()),i=t(RA()),a=t(OA());t(DM()),t(NM()),t(jb());var o=t(Qb()),s=function(t,e,n,a){return r.default.arrayBuffer(t,n.networkOptions).then((function(t){return i.default.parse(t,{extent:e.extent,filteringExtent:n.extent,filter:n.filter,origin:n.origin,coords:a})}))},l={getVectorTileByUrl:s,getVectorTileTextureByUrl:function(t,r,i,l){return i instanceof o.default?null:n.default.get(t)||n.default.set(t,s(t,r,i,l).then((function(t){var n,o=i.backgroundLayer&&i.backgroundLayer.paint?new e.Color(i.backgroundLayer.paint["background-color"]):void 0;switch(l.crs()){case"TMS":n=r.extent;break;case"WMTS:PM":n=l.as("EPSG:3857");break;default:n=l.as(r.extent.crs())}var s=a.default.createTextureFromFeature(t,n,256,i.style,o);return s.extent=r.extent,s.coords=l,s})))}};return sA.default=l,sA}()),l=Ob();function u(t,e,r,o){var s=new n.Vector4(0,0,1,1),u=function(t,e,r,n,a){if(r.updateStrategy.type===l.STRATEGY_MIN_NETWORK_TRAFFIC)return t;var o,s,u,c=0;if(e){if(t.zoom<=e.zoom+1)return t;switch(r.updateStrategy.type){case l.STRATEGY_PROGRESSIVE:c+=1;break;case l.STRATEGY_GROUP:o=t.zoom,e.zoom,c=(u=(s=r.updateStrategy.options).groups.filter((function(t){return t<=o}))).length?u[u.length-1]:s.groups[0];break;default:case l.STRATEGY_DICHOTOMY:c=Math.ceil((e.zoom+t.zoom)/2)}}return a&&a.extent&&a.extent.zoom===c&&(c=Math.ceil((e.zoom+c)/2)),c=Math.min(Math.max(c,r.options.zoom.min),r.options.zoom.max),t.zoom<=c?t:i.default.WMTS_WGS84Parent(t,c,n)}(e,r&&r.extent?r.extent:null,t,s,o);return r&&r.extent&&r.extent.zoom===u.zoom?null:{extent:u,pitch:s,url:a.default.xyz(u,t)}}function c(t,e){return h(t.getExtentForLayer(e),e)}function h(t,e){return e.options.zoom.min<=t.zoom&&t.zoom<=e.options.zoom.max}var d={preprocessDataLayer:function(t){if(t.extent||(t.extent=new o.default("EPSG:3857",-20037508.342789244,20037508.342789244,-20037508.342789244,20037508.342789244)),!(t.extent instanceof o.default)){if(!t.projection)throw new Error("Missing projection property for layer '".concat(t.id,"'"));t.extent=(0,e.default)(o.default,[t.projection].concat((0,r.default)(t.extent)))}t.origin=t.origin||("xyz"===t.protocol?"top":"bottom"),t.options.zoom||(t.options.zoom={min:0,max:18}),t.fx=t.fx||0},executeCommand:function(t){var e=t.layer;return("application/x-protobuf;type=mapbox-vector"===e.format?s.default.getVectorTileTextureByUrl(t.toDownload,t.requester,e):i.default.getColorTextureByUrl(t.toDownload,e.networkOptions)).then((function(t){var r={};return r.texture=t,e.transparent&&(t.premultiplyAlpha=!0),r}))},tileTextureCount:function(t,e){return c(t,e)?1:0},tileInsideLimit:c,getPossibleTextureImprovements:function(t,e,r,n){return h(e,t)?e.zoom>t.options.zoom.max?null:r?(!r.extent||r.extent.zoom=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0&&t.octreeDepthLimit0)if(i.obj)i.obj.material.update?i.obj.material.update(t.material):i.obj.material.copy(t.material);else if(!i.promise){var c=o(e,t,i,u)/Math.max(.001,u);i.promise=e.scheduler.execute({layer:t,requester:i,view:e.instance,priority:c,redraw:!0,isLeaf:0===i.childrenBitField,earlyDropFunction:function(e){return!e.requester.visible||!t.visible}}).then((function(e){t.onPointsCreated&&t.onPointsCreated(t,e),i.obj=e,i.tightbbox=e.tightbbox,t.group.add(i.obj),i.obj.updateMatrixWorld(!0),i.promise=null}),(function(t){t instanceof r.default&&(i.promise=null)}))}i.children&&i.children.length&&(i.sse=o(e,t,i,u)/t.sseThreshold)}if(i.children&&i.children.length){if(i.sse>=1)return i.children;var h,d=n(i.children);try{for(d.s();!(h=d.n()).done;){s(h.value)}}catch(t){d.e(t)}finally{d.f()}}return null}},postUpdate:function(t){return function(){if(t.group){t.displayedCount=0;var e,r=n(t.group.children);try{for(r.s();!(e=r.n()).done;){var i=e.value;if(i.material.visible){var a=i.geometry.attributes.position.count;i.geometry.setDrawRange(0,a),t.displayedCount+=a}}}catch(t){r.e(t)}finally{r.f()}if(t.displayedCount>t.pointBudget)if(t.supportsProgressiveDisplay){var o,s=t.pointBudget/t.displayedCount,l=n(t.group.children);try{for(l.s();!(o=l.n()).done;){var u=o.value;if(u.material.visible){var c=Math.floor(u.geometry.drawRange.count*s);c>0?u.geometry.setDrawRange(0,c):u.material.visible=!1}}}catch(t){l.e(t)}finally{l.f()}t.displayedCount*=s}else{t.group.children.sort((function(t,e){return e.userData.metadata.sse-t.userData.metadata.sse}));var h=!1;t.displayedCount=0;var d,f=n(t.group.children);try{for(f.s();!(d=f.n()).done;){var p=d.value,m=p.geometry.attributes.position.count;h||t.displayedCount+m>t.pointBudget?(p.material.visible=!1,h=!0):t.displayedCount+=m}}catch(t){f.e(t)}finally{f.f()}}for(var g=Date.now(),v=t.group.children.length-1;v>=0;v--){var y=t.group.children[v],x=y.userData.metadata.notVisibleSince;!y.material.visible&&g-x>1e4&&(t.group.children.splice(v,1),y.material.dispose(),y.geometry.dispose(),y.material=null,y.geometry=null,y.userData.metadata.obj=null)}}}}};return NA.default=u,NA}var BA,zA={};function GA(){if(BA)return zA;BA=1,Object.defineProperty(zA,"__esModule",{value:!0}),zA.default=void 0;var t=Bf;function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r>4!=3)throw new Error(`Got v${r>>4} data when expected v3.`);const[n]=new Uint16Array(t,2,1),[i]=new Uint32Array(t,4,1);return new ZA(i,n,YA[15&r],t)}constructor(t,e=16,r=Float64Array,n){if(void 0===t)throw new Error("Missing required argument: numItems.");if(isNaN(t)||t<=0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535);let i=t,a=i;this._levelBounds=[4*i];do{i=Math.ceil(i/this.nodeSize),a+=i,this._levelBounds.push(4*a)}while(1!==i);this.ArrayType=r||Float64Array,this.IndexArrayType=a<16384?Uint16Array:Uint32Array;const o=YA.indexOf(this.ArrayType),s=4*a*this.ArrayType.BYTES_PER_ELEMENT;if(o<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this._boxes=new this.ArrayType(this.data,8,4*a),this._indices=new this.IndexArrayType(this.data,8+s,a),this._pos=4*a,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1]):(this.data=new ArrayBuffer(8+s+a*this.IndexArrayType.BYTES_PER_ELEMENT),this._boxes=new this.ArrayType(this.data,8,4*a),this._indices=new this.IndexArrayType(this.data,8+s,a),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(this.data,0,2).set([251,48+o]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t),this._queue=new XA}add(t,e,r,n){const i=this._pos>>2;return this._indices[i]=i,this._boxes[this._pos++]=t,this._boxes[this._pos++]=e,this._boxes[this._pos++]=r,this._boxes[this._pos++]=n,tthis.maxX&&(this.maxX=r),n>this.maxY&&(this.maxY=n),i}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);if(this.numItems<=this.nodeSize)return this._boxes[this._pos++]=this.minX,this._boxes[this._pos++]=this.minY,this._boxes[this._pos++]=this.maxX,void(this._boxes[this._pos++]=this.maxY);const t=this.maxX-this.minX||1,e=this.maxY-this.minY||1,r=new Uint32Array(this.numItems);for(let n=0;n>2]=t,this._boxes[this._pos++]=n,this._boxes[this._pos++]=i,this._boxes[this._pos++]=a,this._boxes[this._pos++]=o}}}search(t,e,r,n,i){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let a=this._boxes.length-4;const o=[],s=[];for(;void 0!==a;){const l=Math.min(a+4*this.nodeSize,JA(a,this._levelBounds));for(let u=a;u>2];rthis._boxes[u+2]||e>this._boxes[u+3]||(a<4*this.numItems?(void 0===i||i(l))&&s.push(l):o.push(l)))}a=o.pop()}return s}neighbors(t,e,r=1/0,n=1/0,i){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let a=this._boxes.length-4;const o=this._queue,s=[],l=n*n;for(;void 0!==a;){const n=Math.min(a+4*this.nodeSize,JA(a,this._levelBounds));for(let r=a;r>2],s=KA(t,this._boxes[r],this._boxes[r+2]),l=KA(e,this._boxes[r+1],this._boxes[r+3]),u=s*s+l*l;a<4*this.numItems?(void 0===i||i(n))&&o.push(1+(n<<1),u):o.push(n<<1,u)}for(;o.length&&1&o.peek();){if(o.peekValue()>l)return o.clear(),s;if(s.push(o.pop()>>1),s.length===r)return o.clear(),s}a=o.pop()>>1}return o.clear(),s}}function KA(t,e,r){return t>1;e[i]>t?n=i:r=i+1}return e[r]}function QA(t,e,r,n,i,a){if(Math.floor(n/a)>=Math.floor(i/a))return;const o=t[n+i>>1];let s=n-1,l=i+1;for(;;){do{s++}while(t[s]o);if(s>=l)break;$A(t,e,r,s,l)}QA(t,e,r,n,l,a),QA(t,e,r,l+1,i,a)}function $A(t,e,r,n,i){const a=t[n];t[n]=t[i],t[i]=a;const o=4*n,s=4*i,l=e[o],u=e[o+1],c=e[o+2],h=e[o+3];e[o]=e[s],e[o+1]=e[s+1],e[o+2]=e[s+2],e[o+3]=e[s+3],e[s]=l,e[s+1]=u,e[s+2]=c,e[s+3]=h;const d=r[n];r[n]=r[i],r[i]=d}function tR(t,e){let r=t^e,n=65535^r,i=65535^(t|e),a=t&(65535^e),o=r|n>>1,s=r>>1^r,l=i>>1^n&a>>1^i,u=r&i>>1^a>>1^a;r=o,n=s,i=l,a=u,o=r&r>>2^n&n>>2,s=r&n>>2^n&(r^n)>>2,l^=r&i>>2^n&a>>2,u^=n&i>>2^(r^n)&a>>2,r=o,n=s,i=l,a=u,o=r&r>>4^n&n>>4,s=r&n>>4^n&(r^n)>>4,l^=r&i>>4^n&a>>4,u^=n&i>>4^(r^n)&a>>4,r=o,n=s,i=l,a=u,l^=r&i>>8^n&a>>8,u^=n&i>>8^(r^n)&a>>8,r=l^l>>1,n=u^u>>1;let c=t^e,h=n|65535^(c|r);return c=16711935&(c|c<<8),c=252645135&(c|c<<4),c=858993459&(c|c<<2),c=1431655765&(c|c<<1),h=16711935&(h|h<<8),h=252645135&(h|h<<4),h=858993459&(h|h<<2),h=1431655765&(h|h<<1),(h<<1|c)>>>0}const eR=of(Object.freeze(Object.defineProperty({__proto__:null,default:ZA},Symbol.toStringTag,{value:"Module"})));var rR;function nR(){if(rR)return qA;rR=1;var t=uf;Object.defineProperty(qA,"__esModule",{value:!0}),qA.default=void 0;var e=t(px()),r=t(Nx()),n=t(eR),i=Bf,a=t(DM()),o=t(FM()),s=VM();function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=d)if(r)if(g===d){var v=p.extent.dimensions(),y=r.extent.dimensions();v.x=n;i--)if(1===(r=t.getTileRangeForExtentAndZ(e,i,r)).getWidth()&&1===r.getHeight())return[i,r.minX,r.minY];return null}(i,e);if(!o)return null;var s=r.getTile(o[0],o[1],o[2],1,n),l=a(i.getTileCoordExtent(o),n.getCode()),u=e.offsetToParent(l);return{extent:e,pitch:u,tile:s,tileExtent:l}}(t,n);return r&&r.extent&&r.extent.isInside(i.tileExtent)?null:i}};return iR.default=s,iR}var lR={};const uR=of(zy);var cR={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},hR=[cR.FILL],dR=[cR.STROKE],fR=[cR.BEGIN_PATH],pR=[cR.CLOSE_PATH];const mR=cR;const gR=function(){function t(){}return t.prototype.drawCustom=function(t,e,r,n){},t.prototype.drawGeometry=function(t){},t.prototype.setStyle=function(t){},t.prototype.drawCircle=function(t,e){},t.prototype.drawFeature=function(t,e){},t.prototype.drawGeometryCollection=function(t,e){},t.prototype.drawLineString=function(t,e){},t.prototype.drawMultiLineString=function(t,e){},t.prototype.drawMultiPoint=function(t,e){},t.prototype.drawMultiPolygon=function(t,e){},t.prototype.drawPoint=function(t,e){},t.prototype.drawPolygon=function(t,e){},t.prototype.drawText=function(t,e){},t.prototype.setFillStrokeStyle=function(t,e){},t.prototype.setImageStyle=function(t,e){},t.prototype.setTextStyle=function(t,e){},t}();var vR=/^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i,yR=/^([a-z]*)$|^hsla?\(.*\)$/i;function xR(t){return"string"==typeof t?t:TR(t)}var _R,wR,bR=(_R={},wR=0,function(t){var e;if(_R.hasOwnProperty(t))e=_R[t];else{if(wR>=1024){var r=0;for(var n in _R)0==(3&r++)&&(delete _R[n],--wR)}e=function(t){var e,r,n,i,a;if(yR.exec(t)&&(t=function(t){var e=document.createElement("div");if(e.style.color=t,""!==e.style.color){document.body.appendChild(e);var r=getComputedStyle(e).color;return document.body.removeChild(e),r}return""}(t)),vR.exec(t)){var o=t.length-1,s=void 0;s=o<=4?1:2;var l=4===o||8===o;e=parseInt(t.substr(1+0*s,s),16),r=parseInt(t.substr(1+1*s,s),16),n=parseInt(t.substr(1+2*s,s),16),i=l?parseInt(t.substr(1+3*s,s),16):255,1==s&&(e=(e<<4)+e,r=(r<<4)+r,n=(n<<4)+n,l&&(i=(i<<4)+i)),a=[e,r,n,i/255]}else 0==t.indexOf("rgba(")?SR(a=t.slice(5,-1).split(",").map(Number)):0==t.indexOf("rgb(")?((a=t.slice(4,-1).split(",").map(Number)).push(1),SR(a)):iy(!1,14);return a}(t),_R[t]=e,++wR}return e});function MR(t){return Array.isArray(t)?t:bR(t)}function SR(t){return t[0]=xv(t[0]+.5|0,0,255),t[1]=xv(t[1]+.5|0,0,255),t[2]=xv(t[2]+.5|0,0,255),t[3]=xv(t[3],0,1),t}function TR(t){var e=t[0];e!=(0|e)&&(e=e+.5|0);var r=t[1];r!=(0|r)&&(r=r+.5|0);var n=t[2];return n!=(0|n)&&(n=n+.5|0),"rgba("+e+","+r+","+n+","+(void 0===t[3]?1:Math.round(100*t[3])/100)+")"}function ER(t){return Array.isArray(t)?TR(t):t}var AR=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))","?\\s*([-,\\\"\\'\\sa-z]+?)\\s*$"].join(""),"i"),RR=["style","variant","weight","size","lineHeight","family"],PR=function(t){var e=t.match(AR);if(!e)return null;for(var r={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"},n=0,i=RR.length;nh&&(this.instructions.push([mR.CUSTOM,h,a,t,r,ZR]),this.hitDetectionInstructions.push([mR.CUSTOM,h,a,t,n||r,ZR]));break;case"Point":i=t.getFlatCoordinates(),this.coordinates.push(i[0],i[1]),a=this.coordinates.length,this.instructions.push([mR.CUSTOM,h,a,t,r]),this.hitDetectionInstructions.push([mR.CUSTOM,h,a,t,n||r])}this.endGeometry(e)},e.prototype.beginGeometry=function(t,e){this.beginGeometryInstruction1_=[mR.BEGIN_GEOMETRY,e,0,t],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[mR.BEGIN_GEOMETRY,e,0,t],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)},e.prototype.finish=function(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}},e.prototype.reverseHitDetectionInstructions=function(){var t,e=this.hitDetectionInstructions;e.reverse();var r,n,i=e.length,a=-1;for(t=0;tthis.maxLineWidth&&(this.maxLineWidth=r.lineWidth,this.bufferedMaxExtent_=null)}else r.strokeStyle=void 0,r.lineCap=void 0,r.lineDash=null,r.lineDashOffset=void 0,r.lineJoin=void 0,r.lineWidth=void 0,r.miterLimit=void 0},e.prototype.createFill=function(t){var e=t.fillStyle,r=[mR.SET_FILL_STYLE,e];return"string"!=typeof e&&r.push(!0),r},e.prototype.applyStroke=function(t){this.instructions.push(this.createStroke(t))},e.prototype.createStroke=function(t){return[mR.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]},e.prototype.updateFillStyle=function(t,e){var r=t.fillStyle;"string"==typeof r&&t.currentFillStyle==r||(void 0!==r&&this.instructions.push(e.call(this,t)),t.currentFillStyle=r)},e.prototype.updateStrokeStyle=function(t,e){var r=t.strokeStyle,n=t.lineCap,i=t.lineDash,a=t.lineDashOffset,o=t.lineJoin,s=t.lineWidth,l=t.miterLimit;(t.currentStrokeStyle!=r||t.currentLineCap!=n||i!=t.currentLineDash&&!qx(t.currentLineDash,i)||t.currentLineDashOffset!=a||t.currentLineJoin!=o||t.currentLineWidth!=s||t.currentMiterLimit!=l)&&(void 0!==r&&e.call(this,t),t.currentStrokeStyle=r,t.currentLineCap=n,t.currentLineDash=i,t.currentLineDashOffset=a,t.currentLineJoin=o,t.currentLineWidth=s,t.currentMiterLimit=l)},e.prototype.endGeometry=function(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;var e=[mR.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)},e.prototype.getBufferedMaxExtent=function(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=sy(this.maxExtent),this.maxLineWidth>0)){var t=this.resolution*(this.maxLineWidth+1)/2;oy(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_},e}(gR);var tP=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const eP=function(t){function e(e,r,n,i){var a=t.call(this,e,r,n,i)||this;return a.hitDetectionImage_=null,a.image_=null,a.imagePixelRatio_=void 0,a.anchorX_=void 0,a.anchorY_=void 0,a.height_=void 0,a.opacity_=void 0,a.originX_=void 0,a.originY_=void 0,a.rotateWithView_=void 0,a.rotation_=void 0,a.scale_=void 0,a.width_=void 0,a.declutterMode_=void 0,a.declutterImageWithText_=void 0,a}return tP(e,t),e.prototype.drawPoint=function(t,e){if(this.image_){this.beginGeometry(t,e);var r=t.getFlatCoordinates(),n=t.getStride(),i=this.coordinates.length,a=this.appendFlatPointCoordinates(r,n);this.instructions.push([mR.DRAW_IMAGE,i,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([mR.DRAW_IMAGE,i,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,this.opacity_,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}},e.prototype.drawMultiPoint=function(t,e){if(this.image_){this.beginGeometry(t,e);var r=t.getFlatCoordinates(),n=t.getStride(),i=this.coordinates.length,a=this.appendFlatPointCoordinates(r,n);this.instructions.push([mR.DRAW_IMAGE,i,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([mR.DRAW_IMAGE,i,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,this.opacity_,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}},e.prototype.finish=function(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,t.prototype.finish.call(this)},e.prototype.setImageStyle=function(t,e){var r=t.getAnchor(),n=t.getSize(),i=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=r[0],this.anchorY_=r[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=n[1],this.opacity_=t.getOpacity(),this.originX_=i[0],this.originY_=i[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=n[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e},e}($R);var rP=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const nP=function(t){function e(e,r,n,i){return t.call(this,e,r,n,i)||this}return rP(e,t),e.prototype.drawFlatCoordinates_=function(t,e,r,n){var i=this.coordinates.length,a=this.appendFlatLineCoordinates(t,e,r,n,!1,!1),o=[mR.MOVE_TO_LINE_TO,i,a];return this.instructions.push(o),this.hitDetectionInstructions.push(o),r},e.prototype.drawLineString=function(t,e){var r=this.state,n=r.strokeStyle,i=r.lineWidth;if(void 0!==n&&void 0!==i){this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([mR.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,LR,0],fR);var a=t.getFlatCoordinates(),o=t.getStride();this.drawFlatCoordinates_(a,0,a.length,o),this.hitDetectionInstructions.push(dR),this.endGeometry(e)}},e.prototype.drawMultiLineString=function(t,e){var r=this.state,n=r.strokeStyle,i=r.lineWidth;if(void 0!==n&&void 0!==i){this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([mR.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,r.lineDash,r.lineDashOffset],fR);for(var a=t.getEnds(),o=t.getFlatCoordinates(),s=t.getStride(),l=0,u=0,c=a.length;ut&&(v>g&&(g=v,p=y,m=a),v=0,y=a-i)),o=s,c=d,h=f),l=x,u=_}return(v+=s)>g?[y,a]:[p,m]}var cP=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),hP={left:0,end:0,center:.5,right:1,start:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};var dP={Circle:oP,Default:$R,Image:eP,LineString:nP,Polygon:oP,Text:function(t){function e(e,r,n,i){var a=t.call(this,e,r,n,i)||this;return a.labels_=null,a.text_="",a.textOffsetX_=0,a.textOffsetY_=0,a.textRotateWithView_=void 0,a.textRotation_=0,a.textFillState_=null,a.fillStates={},a.textStrokeState_=null,a.strokeStates={},a.textState_={},a.textStates={},a.textKey_="",a.fillKey_="",a.strokeKey_="",a.declutterImageWithText_=void 0,a}return cP(e,t),e.prototype.finish=function(){var e=t.prototype.finish.call(this);return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e},e.prototype.drawText=function(t,e){var r=this.textFillState_,n=this.textStrokeState_,i=this.textState_;if(""!==this.text_&&i&&(r||n)){var a=this.coordinates,o=a.length,s=t.getType(),l=null,u=t.getStride();if(i.placement!==lP||"LineString"!=s&&"MultiLineString"!=s&&"Polygon"!=s&&"MultiPolygon"!=s){var c=i.overflow?null:[];switch(s){case"Point":case"MultiPoint":l=t.getFlatCoordinates();break;case"LineString":l=t.getFlatMidpoint();break;case"Circle":l=t.getCenter();break;case"MultiLineString":l=t.getFlatMidpoints(),u=2;break;case"Polygon":l=t.getFlatInteriorPoint(),i.overflow||c.push(l[2]/this.resolution),u=3;break;case"MultiPolygon":var h=t.getFlatInteriorPoints();l=[];for(b=0,M=h.length;bR[2]}else T=_>E;var P,C=Math.PI,I=[],L=b+n===e;if(g=0,v=M,d=t[e=b],f=t[e+1],L){y(),P=Math.atan2(f-m,d-p),T&&(P+=P>0?-C:C);var O=(E+_)/2,D=(A+w)/2;return I[0]=[O,D,(S-a)/2,P,i],I}for(var k=0,F=(i=i.replace(/\n/g," ")).length;k0?-C:C),void 0!==P){var U=N-P;if(U+=U>C?-2*C:U<-C?2*C:0,Math.abs(U)>o)return null}P=N;for(var B=k,z=0;k0&&t.push("\n",""),t.push(e,""),t}const BP=function(){function t(t,e,r,n){this.overlaps=r,this.pixelRatio=e,this.resolution=t,this.alignFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=[1,0,0,1,0,0],this.hitDetectionInstructions=n.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=n.fillStates||{},this.strokeStates=n.strokeStates||{},this.textStates=n.textStates||{},this.widths_={},this.labels_={}}return t.prototype.createLabel=function(t,e,r,n){var i=t+e+r+n;if(this.labels_[i])return this.labels_[i];var a=n?this.strokeStates[n]:null,o=r?this.fillStates[r]:null,s=this.textStates[e],l=this.pixelRatio,u=[s.scale[0]*l,s.scale[1]*l],c=Array.isArray(t),h=s.justify?hP[s.justify]:NP(Array.isArray(t)?t[0]:t,s.textAlign||kR),d=n&&a.lineWidth?a.lineWidth:0,f=c?t:t.split("\n").reduce(UP,[]),p=function(t,e){for(var r=[],n=[],i=[],a=0,o=0,s=0,l=0,u=0,c=e.length;u<=c;u+=2){var h=e[u];if("\n"!==h&&u!==c){var d=e[u+1]||t.font,f=qR(d,h);r.push(f),o+=f;var p=HR(d);n.push(p),l=Math.max(l,p)}else a=Math.max(a,o),i.push(o),o=0,s+=l}return{width:a,height:s,widths:r,heights:n,lineWidths:i}}(s,f),m=p.width,g=p.height,v=p.widths,y=p.heights,x=p.lineWidths,_=m+d,w=[],b=(_+2)*u[0],M=(g+d)*u[1],S={width:b<0?Math.floor(b):Math.ceil(b),height:M<0?Math.floor(M):Math.ceil(M),contextInstructions:w};(1==u[0]&&1==u[1]||w.push("scale",u),n)&&(w.push("strokeStyle",a.strokeStyle),w.push("lineWidth",d),w.push("lineCap",a.lineCap),w.push("lineJoin",a.lineJoin),w.push("miterLimit",a.miterLimit),(r_?OffscreenCanvasRenderingContext2D:CanvasRenderingContext2D).prototype.setLineDash&&(w.push("setLineDash",[a.lineDash]),w.push("lineDashOffset",a.lineDashOffset)));r&&w.push("fillStyle",o.fillStyle),w.push("textBaseline","middle"),w.push("textAlign","center");for(var T,E=.5-h,A=h*_+E*d,R=[],P=[],C=0,I=0,L=0,O=0,D=0,k=f.length;Dt?t-l:i,_=a+u>e?e-u:a,w=f[3]+x*h[0]+f[1],b=f[0]+_*h[1]+f[2],M=v-f[3],S=y-f[0];return(p||0!==c)&&(IP[0]=M,DP[0]=M,IP[1]=S,LP[1]=S,LP[0]=M+w,OP[0]=LP[0],OP[1]=S+b,DP[1]=OP[1]),0!==c?(wP(g=bP([1,0,0,1,0,0],r,n,1,1,c,-r,-n),IP),wP(g,LP),wP(g,OP),wP(g,DP),fy(Math.min(IP[0],LP[0],OP[0],DP[0]),Math.min(IP[1],LP[1],OP[1],DP[1]),Math.max(IP[0],LP[0],OP[0],DP[0]),Math.max(IP[1],LP[1],OP[1],DP[1]),CP)):fy(Math.min(M,M+w),Math.min(S,S+b),Math.max(M,M+w),Math.max(S,S+b),CP),d&&(v=Math.round(v),y=Math.round(y)),{drawImageX:v,drawImageY:y,drawImageW:x,drawImageH:_,originX:l,originY:u,declutterBox:{minX:CP[0],minY:CP[1],maxX:CP[2],maxY:CP[3],value:m},canvasTransform:g,scale:h}},t.prototype.replayImageOrLabel_=function(t,e,r,n,i,a,o){var s=!(!a&&!o),l=n.declutterBox,u=t.canvas,c=o?o[2]*n.scale[0]/2:0;return l.minX-c<=u.width/e&&l.maxX+c>=0&&l.minY-c<=u.height/e&&l.maxY+c>=0&&(s&&this.replayTextBackground_(t,IP,LP,OP,DP,a,o),YR(t,n.canvasTransform,i,r,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0},t.prototype.fill_=function(t){if(this.alignFill_){var e=wP(this.renderedTransform_,[0,0]),r=512*this.pixelRatio;t.save(),t.translate(e[0]%r,e[1]%r),t.rotate(this.viewRotation_)}t.fill(),this.alignFill_&&t.restore()},t.prototype.setStrokeStyle_=function(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.setLineDash&&(t.lineDashOffset=e[7],t.setLineDash(e[6]))},t.prototype.drawLabelWithPointPlacement_=function(t,e,r,n){var i=this.textStates[e],a=this.createLabel(t,e,n,r),o=this.strokeStates[r],s=this.pixelRatio,l=NP(Array.isArray(t)?t[0]:t,i.textAlign||kR),u=hP[i.textBaseline||FR],c=o&&o.lineWidth?o.lineWidth:0;return{label:a,anchorX:l*(a.width/s-2*i.scale[0])+2*(.5-l)*c,anchorY:u*a.height/s+2*(.5-u)*c}},t.prototype.execute_=function(t,e,r,n,i,a,o,s){var l;this.pixelCoordinates_&&qx(r,this.renderedTransform_)?l=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),l=AP(this.coordinates,0,this.coordinates.length,2,r,this.pixelCoordinates_),_P(this.renderedTransform_,r));for(var u,c,h,d,f,p,m,g,v,y,x,_,w,b,M,S,T=0,E=n.length,A=0,R=0,P=0,C=null,I=null,L=this.coordinateCache_,O=this.viewRotation_,D=Math.round(1e12*Math.atan2(-r[1],r[0]))/1e12,k={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:O},F=this.instructions!=n||this.overlaps?0:200;TF&&(this.fill_(t),R=0),P>F&&(t.stroke(),P=0),R||P||(t.beginPath(),d=NaN,f=NaN),++T;break;case mR.CIRCLE:var U=l[A=N[1]],B=l[A+1],z=l[A+2]-U,G=l[A+3]-B,j=Math.sqrt(z*z+G*G);t.moveTo(U+j,B),t.arc(U,B,j,0,2*Math.PI,!0),++T;break;case mR.CLOSE_PATH:t.closePath(),++T;break;case mR.CUSTOM:A=N[1],u=N[2];var V=N[3],H=N[4],W=6==N.length?N[5]:void 0;k.geometry=V,k.feature=w,T in L||(L[T]=[]);var q=L[T];W?W(l,A,u,2,q):(q[0]=l[A],q[1]=l[A+1],q.length=2),H(q,k),++T;break;case mR.DRAW_IMAGE:A=N[1],u=N[2],g=N[3],c=N[4],h=N[5];var X=N[6],Y=N[7],Z=N[8],K=N[9],J=N[10],Q=N[11],$=N[12],tt=N[13],et=N[14],rt=N[15];if(!g&&N.length>=20){v=N[19],y=N[20],x=N[21],_=N[22];var nt=this.drawLabelWithPointPlacement_(v,y,x,_);g=nt.label,N[3]=g;var it=N[23];c=(nt.anchorX-it)*this.pixelRatio,N[4]=c;var at=N[24];h=(nt.anchorY-at)*this.pixelRatio,N[5]=h,X=g.height,N[6]=X,tt=g.width,N[13]=tt}var ot=void 0;N.length>25&&(ot=N[25]);var st=void 0,lt=void 0,ut=void 0;N.length>17?(st=N[16],lt=N[17],ut=N[18]):(st=NR,lt=!1,ut=!1),J&&D?Q+=O:J||D||(Q-=O);for(var ct=0;A0){if(!a||"Image"!==h&&"Text"!==h||-1!==a.indexOf(t)){var u=(d[s]-3)/4,f=n-u%o,p=n-(u/o|0),m=i(t,e,f*f+p*p);if(m)return m}c.clearRect(0,0,o,o);break}}var p,m,g,v,y,x=Object.keys(this.executorsByZIndex_).map(Number);for(x.sort(Hx),p=x.length-1;p>=0;--p){var _=x[p].toString();for(g=this.executorsByZIndex_[_],m=zP.length-1;m>=0;--m)if(void 0!==(v=g[h=zP[m]])&&(y=v.executeHitDetection(c,s,r,f,u)))return y}},t.prototype.getClipCoords=function(t){var e=this.maxExtent_;if(!e)return null;var r=e[0],n=e[1],i=e[2],a=e[3],o=[r,n,r,a,i,a,i,n];return AP(o,0,8,2,t,o),o},t.prototype.isEmpty=function(){return Yv(this.executorsByZIndex_)},t.prototype.execute=function(t,e,r,n,i,a,o){var s=Object.keys(this.executorsByZIndex_).map(Number);s.sort(Hx),this.maxExtent_&&(t.save(),this.clip(t,r));var l,u,c,h,d,f,p=a||zP;for(o&&s.reverse(),l=0,u=s.length;lr)break;var s=n[o];s||(s=[],n[o]=s),s.push(4*((t+i)*e+(t+a))+3),i>0&&s.push(4*((t-i)*e+(t+a))+3),a>0&&(s.push(4*((t+i)*e+(t-a))+3),i>0&&s.push(4*((t-i)*e+(t-a))+3))}for(var l=[],u=(i=0,n.length);ithis.maxCacheSize_},t.prototype.expire=function(){if(this.canExpireCache()){var t=0;for(var e in this.cache_){var r=this.cache_[e];0!=(3&t++)||r.hasListener()||(delete this.cache_[e],--this.cacheSize_)}}},t.prototype.get=function(t,e,r){var n=sC(t,e,r);return n in this.cache_?this.cache_[n]:null},t.prototype.set=function(t,e,r,n){var i=sC(t,e,r);this.cache_[i]=n,++this.cacheSize_},t.prototype.setSize=function(t){this.maxCacheSize_=t,this.expire()},t}()),uC=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),cC=null,hC=function(t){function e(e,r,n,i,a,o){var s=t.call(this)||this;return s.hitDetectionImage_=null,s.image_=e||new Image,null!==i&&(s.image_.crossOrigin=i),s.canvas_={},s.color_=o,s.unlisten_=null,s.imageState_=a,s.size_=n,s.src_=r,s.tainted_,s}return uC(e,t),e.prototype.isTainted_=function(){if(void 0===this.tainted_&&this.imageState_===l_.LOADED){cC||(cC=i_(1,1)),cC.drawImage(this.image_,0,0);try{cC.getImageData(0,0,1,1),this.tainted_=!1}catch(t){cC=null,this.tainted_=!0}}return!0===this.tainted_},e.prototype.dispatchChangeEvent_=function(){this.dispatchEvent(Gx.CHANGE)},e.prototype.handleImageError_=function(){this.imageState_=l_.ERROR,this.unlistenImage_(),this.dispatchChangeEvent_()},e.prototype.handleImageLoad_=function(){this.imageState_=l_.LOADED,this.size_?(this.image_.width=this.size_[0],this.image_.height=this.size_[1]):this.size_=[this.image_.width,this.image_.height],this.unlistenImage_(),this.dispatchChangeEvent_()},e.prototype.getImage=function(t){return this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_},e.prototype.getPixelRatio=function(t){return this.replaceColor_(t),this.canvas_[t]?t:1},e.prototype.getImageState=function(){return this.imageState_},e.prototype.getHitDetectionImage=function(){if(!this.hitDetectionImage_)if(this.isTainted_()){var t=this.size_[0],e=this.size_[1],r=i_(t,e);r.fillRect(0,0,t,e),this.hitDetectionImage_=r.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_},e.prototype.getSize=function(){return this.size_},e.prototype.getSrc=function(){return this.src_},e.prototype.load=function(){if(this.imageState_==l_.IDLE){this.imageState_=l_.LOADING;try{this.image_.src=this.src_}catch(t){this.handleImageError_()}this.unlisten_=p_(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this))}},e.prototype.replaceColor_=function(t){if(this.color_&&!this.canvas_[t]&&this.imageState_===l_.LOADED){var e=document.createElement("canvas");this.canvas_[t]=e,e.width=Math.ceil(this.image_.width*t),e.height=Math.ceil(this.image_.height*t);var r=e.getContext("2d");if(r.scale(t,t),r.drawImage(this.image_,0,0),r.globalCompositeOperation="multiply","multiply"===r.globalCompositeOperation||this.isTainted_())r.fillStyle=xR(this.color_),r.fillRect(0,0,e.width/t,e.height/t),r.globalCompositeOperation="destination-in",r.drawImage(this.image_,0,0);else{for(var n=r.getImageData(0,0,e.width,e.height),i=n.data,a=this.color_[0]/255,o=this.color_[1]/255,s=this.color_[2]/255,l=this.color_[3],u=0,c=i.length;u0,6);var c=void 0!==n.src?l_.IDLE:l_.LOADED;return r.color_=void 0!==n.color?MR(n.color):null,r.iconImage_=function(t,e,r,n,i,a){var o=lC.get(e,n,a);return o||(o=new hC(t,e,r,n,i,a),lC.set(e,n,a,o)),o}(l,u,void 0!==r.imgSize_?r.imgSize_:null,r.crossOrigin_,c,r.color_),r.offset_=void 0!==n.offset?n.offset:[0,0],r.offsetOrigin_=void 0!==n.offsetOrigin?n.offsetOrigin:aC,r.origin_=null,r.size_=void 0!==n.size?n.size:null,r}return fC(e,t),e.prototype.clone=function(){var t=this.getScale();return new e({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,imgSize:this.imgSize_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:Array.isArray(t)?t.slice():t,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})},e.prototype.getAnchor=function(){var t=this.normalizedAnchor_;if(!t){t=this.anchor_;var e=this.getSize();if(this.anchorXUnits_==rC||this.anchorYUnits_==rC){if(!e)return null;t=this.anchor_.slice(),this.anchorXUnits_==rC&&(t[0]*=e[0]),this.anchorYUnits_==rC&&(t[1]*=e[1])}if(this.anchorOrigin_!=aC){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),this.anchorOrigin_!=oC&&this.anchorOrigin_!=iC||(t[0]=-t[0]+e[0]),this.anchorOrigin_!=nC&&this.anchorOrigin_!=iC||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}var r=this.getDisplacement();return[t[0]-r[0],t[1]+r[1]]},e.prototype.setAnchor=function(t){this.anchor_=t,this.normalizedAnchor_=null},e.prototype.getColor=function(){return this.color_},e.prototype.getImage=function(t){return this.iconImage_.getImage(t)},e.prototype.getPixelRatio=function(t){return this.iconImage_.getPixelRatio(t)},e.prototype.getImageSize=function(){return this.iconImage_.getSize()},e.prototype.getImageState=function(){return this.iconImage_.getImageState()},e.prototype.getHitDetectionImage=function(){return this.iconImage_.getHitDetectionImage()},e.prototype.getOrigin=function(){if(this.origin_)return this.origin_;var t=this.offset_;if(this.offsetOrigin_!=aC){var e=this.getSize(),r=this.iconImage_.getSize();if(!e||!r)return null;t=t.slice(),this.offsetOrigin_!=oC&&this.offsetOrigin_!=iC||(t[0]=r[0]-e[0]-t[0]),this.offsetOrigin_!=nC&&this.offsetOrigin_!=iC||(t[1]=r[1]-e[1]-t[1])}return this.origin_=t,this.origin_},e.prototype.getSrc=function(){return this.iconImage_.getSrc()},e.prototype.getSize=function(){return this.size_?this.size_:this.iconImage_.getSize()},e.prototype.listenImageChange=function(t){this.iconImage_.addEventListener(Gx.CHANGE,t)},e.prototype.load=function(){this.iconImage_.load()},e.prototype.unlistenImageChange=function(t){this.iconImage_.removeEventListener(Gx.CHANGE,t)},e}(KP);const mC=function(){function t(t){var e=t||{};this.color_=void 0!==e.color?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=void 0!==e.lineDash?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}return t.prototype.clone=function(){var e=this.getColor();return new t({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})},t.prototype.getColor=function(){return this.color_},t.prototype.getLineCap=function(){return this.lineCap_},t.prototype.getLineDash=function(){return this.lineDash_},t.prototype.getLineDashOffset=function(){return this.lineDashOffset_},t.prototype.getLineJoin=function(){return this.lineJoin_},t.prototype.getMiterLimit=function(){return this.miterLimit_},t.prototype.getWidth=function(){return this.width_},t.prototype.setColor=function(t){this.color_=t},t.prototype.setLineCap=function(t){this.lineCap_=t},t.prototype.setLineDash=function(t){this.lineDash_=t},t.prototype.setLineDashOffset=function(t){this.lineDashOffset_=t},t.prototype.setLineJoin=function(t){this.lineJoin_=t},t.prototype.setMiterLimit=function(t){this.miterLimit_=t},t.prototype.setWidth=function(t){this.width_=t},t}();function gC(t){return t.getGeometry()}const vC=function(){function t(t){var e=t||{};this.geometry_=null,this.geometryFunction_=gC,void 0!==e.geometry&&this.setGeometry(e.geometry),this.fill_=void 0!==e.fill?e.fill:null,this.image_=void 0!==e.image?e.image:null,this.renderer_=void 0!==e.renderer?e.renderer:null,this.hitDetectionRenderer_=void 0!==e.hitDetectionRenderer?e.hitDetectionRenderer:null,this.stroke_=void 0!==e.stroke?e.stroke:null,this.text_=void 0!==e.text?e.text:null,this.zIndex_=e.zIndex}return t.prototype.clone=function(){var e=this.getGeometry();return e&&"object"==typeof e&&(e=e.clone()),new t({geometry:e,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer(),stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})},t.prototype.getRenderer=function(){return this.renderer_},t.prototype.setRenderer=function(t){this.renderer_=t},t.prototype.setHitDetectionRenderer=function(t){this.hitDetectionRenderer_=t},t.prototype.getHitDetectionRenderer=function(){return this.hitDetectionRenderer_},t.prototype.getGeometry=function(){return this.geometry_},t.prototype.getGeometryFunction=function(){return this.geometryFunction_},t.prototype.getFill=function(){return this.fill_},t.prototype.setFill=function(t){this.fill_=t},t.prototype.getImage=function(){return this.image_},t.prototype.setImage=function(t){this.image_=t},t.prototype.getStroke=function(){return this.stroke_},t.prototype.setStroke=function(t){this.stroke_=t},t.prototype.getText=function(){return this.text_},t.prototype.setText=function(t){this.text_=t},t.prototype.getZIndex=function(){return this.zIndex_},t.prototype.setGeometry=function(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=gC,this.geometry_=t},t.prototype.setZIndex=function(t){this.zIndex_=t},t}();const yC=function(){function t(t){var e=t||{};this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.scale_=e.scale,this.scaleArray_=nw(void 0!==e.scale?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.textBaseline_=e.textBaseline,this.fill_=void 0!==e.fill?e.fill:new eC({color:"#333"}),this.maxAngle_=void 0!==e.maxAngle?e.maxAngle:Math.PI/4,this.placement_=void 0!==e.placement?e.placement:sP,this.overflow_=!!e.overflow,this.stroke_=void 0!==e.stroke?e.stroke:null,this.offsetX_=void 0!==e.offsetX?e.offsetX:0,this.offsetY_=void 0!==e.offsetY?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=void 0===e.padding?null:e.padding}return t.prototype.clone=function(){var e=this.getScale();return new t({font:this.getFont(),placement:this.getPlacement(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0})},t.prototype.getOverflow=function(){return this.overflow_},t.prototype.getFont=function(){return this.font_},t.prototype.getMaxAngle=function(){return this.maxAngle_},t.prototype.getPlacement=function(){return this.placement_},t.prototype.getOffsetX=function(){return this.offsetX_},t.prototype.getOffsetY=function(){return this.offsetY_},t.prototype.getFill=function(){return this.fill_},t.prototype.getRotateWithView=function(){return this.rotateWithView_},t.prototype.getRotation=function(){return this.rotation_},t.prototype.getScale=function(){return this.scale_},t.prototype.getScaleArray=function(){return this.scaleArray_},t.prototype.getStroke=function(){return this.stroke_},t.prototype.getText=function(){return this.text_},t.prototype.getTextAlign=function(){return this.textAlign_},t.prototype.getJustify=function(){return this.justify_},t.prototype.getTextBaseline=function(){return this.textBaseline_},t.prototype.getBackgroundFill=function(){return this.backgroundFill_},t.prototype.getBackgroundStroke=function(){return this.backgroundStroke_},t.prototype.getPadding=function(){return this.padding_},t.prototype.setOverflow=function(t){this.overflow_=t},t.prototype.setFont=function(t){this.font_=t},t.prototype.setMaxAngle=function(t){this.maxAngle_=t},t.prototype.setOffsetX=function(t){this.offsetX_=t},t.prototype.setOffsetY=function(t){this.offsetY_=t},t.prototype.setPlacement=function(t){this.placement_=t},t.prototype.setRotateWithView=function(t){this.rotateWithView_=t},t.prototype.setFill=function(t){this.fill_=t},t.prototype.setRotation=function(t){this.rotation_=t},t.prototype.setScale=function(t){this.scale_=t,this.scaleArray_=nw(void 0!==t?t:1)},t.prototype.setStroke=function(t){this.stroke_=t},t.prototype.setText=function(t){this.text_=t},t.prototype.setTextAlign=function(t){this.textAlign_=t},t.prototype.setJustify=function(t){this.justify_=t},t.prototype.setTextBaseline=function(t){this.textBaseline_=t},t.prototype.setBackgroundFill=function(t){this.backgroundFill_=t},t.prototype.setBackgroundStroke=function(t){this.backgroundStroke_=t},t.prototype.setPadding=function(t){this.padding_=t},t}(),xC=of(Object.freeze(Object.defineProperty({__proto__:null,Circle:tC,Fill:eC,Icon:pC,IconImage:dC,Image:KP,RegularShape:QP,Stroke:mC,Style:vC,Text:yC},Symbol.toStringTag,{value:"Module"}))),_C=of(EP);var wC;function bC(){if(wC)return lR;wC=1;var t=uf;Object.defineProperty(lR,"__esModule",{value:!0}),lR.default=void 0;var e=Bf,r=t(xS),n=aR,i=uR,a=t(pP),o=t(HP),s=ZP,l=xC,u=_C,c=t(DM()),h=(0,u.create)(),d=new e.Texture;function f(){var t=this;this.storage={},this.contains=function(e){return e in t.storage}}function p(t,e){return new c.default(e,t[0],t[2],t[1],t[3])}function m(t,n,l){if(!t.material)return null;var c=t.material.canvas,d=new e.CanvasTexture(c);d.premultiplyAlpha=l.transparent,d.extent=n.tileExtent;var f=function(t,e){var n=this,l=t.getReplayState(e),u=e.source,c=u.getTileGrid(),h=u.getProjection(),d=u.getTileGridForProjection(h),f=d.getResolution(t.tileCoord[0]),p=d.getTileCoordExtent(t.wrappedTileCoord),m=1,v=(0,i.createEmpty)(),y=!0;t.executorGroups[e.ol_uid]=[];for(var x=u.getSourceTiles(m,h,t),_=function(h,d){var _=x[h];if(_.getState()!==r.default.LOADED)return console.warn("not loaded !!!",_),"continue";for(var w=_.tileCoord,b=c.getTileCoordExtent(w),M=(0,i.getIntersection)(p,b),S=100,T=(0,i.buffer)(M,S*f,v),E=(0,i.equals)(b,M)?null:T,A=new a.default(0,T,f,m),R=(0,s.getSquaredTolerance)(f,m),P=function(t){var r,n=t.getStyleFunction()||e.getStyleFunction();if(n&&(r=n(t,f)),r){var i=function(t,e,r,n){if(!r)return!1;var i=!1;if(Array.isArray(r))for(var a=0,o=r.length;a=n;i--)if(1===(r=t.getTileRangeForExtentAndZ(e,i,r)).getWidth()&&1===r.getHeight())return[i,r.minX,r.minY];return null}(i,e);if(!a)return null;var o=r.getTile(a[0],a[1],a[2],1,n),s=o.tileCoord[0].toString();s in t.usedTiles||(t.usedTiles[s]=new f);t.usedTiles[s].storage[o.tileCoord]=o;var l=p(i.getTileCoordExtent(a),n.getCode()),u=t.extent.dimensions(),c=u.y/u.x;l._values[3]=l._values[2]+l.dimensions().x*c;var h=e.offsetToParent(l);return{extent:e,pitch:h,tile:o,tileExtent:l}}(t,n);return r&&r.extent&&r.extent.isInside(i.tileExtent)||r===d?null:i}};return lR.default=v,lR}var MC,SC={};function TC(){if(MC)return SC;MC=1;var t=uf;Object.defineProperty(SC,"__esModule",{value:!0}),SC.default=void 0;var e=Bf,r=t(pP),n=t(HP),i=ZP,a=xC,o=_C,s=t(DM());function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(s&&l){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(IC)),CC}var OC,DC={},kC={get exports(){return DC},set exports(t){DC=t}};var FC,NC,UC,BC={},zC={},GC={},jC={},VC={},HC={},WC={};function qC(){if(FC)return WC;FC=1,Object.defineProperty(WC,"__esModule",{value:!0});WC.THIS_IS_NOT_AN_OBJECT="This is not an object";WC.THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT="This is not a Float16Array object";WC.THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY="This constructor is not a subclass of Float16Array";WC.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT="The constructor property value is not an object";WC.SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT="Species constructor didn't return TypedArray object";WC.DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH="Derived constructor created TypedArray object which was too small length";WC.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER="Attempting to access detached ArrayBuffer";WC.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT="Cannot convert undefined or null to object";WC.CANNOT_MIX_BIGINT_AND_OTHER_TYPES="Cannot mix BigInt and other types, use explicit conversions";WC.ITERATOR_PROPERTY_IS_NOT_CALLABLE="@@iterator property is not callable";WC.REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE="Reduce of empty array with no initial value";return WC.OFFSET_IS_OUT_OF_BOUNDS="Offset is out of bounds",WC}function XC(){if(NC)return HC;NC=1,Object.defineProperty(HC,"__esModule",{value:!0});var t=qC();function e(t){return(e,...r)=>n(t,e,r)}function r(t,r){return e(s(t,r).get)}const{apply:n,construct:i,defineProperty:a,get:o,getOwnPropertyDescriptor:s,getPrototypeOf:l,has:u,ownKeys:c,set:h,setPrototypeOf:d}=Reflect;HC.ReflectSetPrototypeOf=d,HC.ReflectSet=h,HC.ReflectOwnKeys=c,HC.ReflectHas=u,HC.ReflectGetPrototypeOf=l,HC.ReflectGetOwnPropertyDescriptor=s,HC.ReflectGet=o,HC.ReflectDefineProperty=a,HC.ReflectConstruct=i,HC.ReflectApply=n;const f=Proxy;HC.NativeProxy=f;const{MAX_SAFE_INTEGER:p,isFinite:m,isNaN:g}=Number;HC.NumberIsNaN=g,HC.NumberIsFinite=m,HC.MAX_SAFE_INTEGER=p;const{iterator:v,species:y,toStringTag:x,for:_}=Symbol;HC.SymbolFor=_,HC.SymbolToStringTag=x,HC.SymbolSpecies=y,HC.SymbolIterator=v;const w=Object;HC.NativeObject=w;const{create:b,defineProperty:M,freeze:S,is:T}=w;HC.ObjectIs=T,HC.ObjectFreeze=S,HC.ObjectDefineProperty=M,HC.ObjectCreate=b;const E=w.prototype,A=E.__lookupGetter__?e(E.__lookupGetter__):(e,r)=>{if(null==e)throw xt(t.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT);let n=w(e);do{const t=s(n,r);if(void 0!==t)return R(t,"get")?t.get:void 0}while(null!==(n=l(n)))};HC.ObjectPrototype__lookupGetter__=A;const R=w.hasOwn||e(E.hasOwnProperty);HC.ObjectHasOwn=R;const P=Array,C=P.isArray;HC.ArrayIsArray=C;const I=P.prototype,L=e(I.join);HC.ArrayPrototypeJoin=L;const O=e(I.push);HC.ArrayPrototypePush=O;const D=e(I.toLocaleString);HC.ArrayPrototypeToLocaleString=D;const k=I[v];HC.NativeArrayPrototypeSymbolIterator=k;const F=e(k);HC.ArrayPrototypeSymbolIterator=F;const N=Math.trunc;HC.MathTrunc=N;const U=ArrayBuffer;HC.NativeArrayBuffer=U;const B=U.isView;HC.ArrayBufferIsView=B;const z=U.prototype,G=e(z.slice);HC.ArrayBufferPrototypeSlice=G;const j=r(z,"byteLength");HC.ArrayBufferPrototypeGetByteLength=j;const V="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:null;HC.NativeSharedArrayBuffer=V;const H=V&&r(V.prototype,"byteLength");HC.SharedArrayBufferPrototypeGetByteLength=H;const W=l(Uint8Array);HC.TypedArray=W;const q=W.from,X=W.prototype;HC.TypedArrayPrototype=X;const Y=X[v];HC.NativeTypedArrayPrototypeSymbolIterator=Y;const Z=e(X.keys);HC.TypedArrayPrototypeKeys=Z;const K=e(X.values);HC.TypedArrayPrototypeValues=K;const J=e(X.entries);HC.TypedArrayPrototypeEntries=J;const Q=e(X.set);HC.TypedArrayPrototypeSet=Q;const $=e(X.reverse);HC.TypedArrayPrototypeReverse=$;const tt=e(X.fill);HC.TypedArrayPrototypeFill=tt;const et=e(X.copyWithin);HC.TypedArrayPrototypeCopyWithin=et;const rt=e(X.sort);HC.TypedArrayPrototypeSort=rt;const nt=e(X.slice);HC.TypedArrayPrototypeSlice=nt;const it=e(X.subarray);HC.TypedArrayPrototypeSubarray=it;const at=r(X,"buffer");HC.TypedArrayPrototypeGetBuffer=at;const ot=r(X,"byteOffset");HC.TypedArrayPrototypeGetByteOffset=ot;const st=r(X,"length");HC.TypedArrayPrototypeGetLength=st;const lt=r(X,x);HC.TypedArrayPrototypeGetSymbolToStringTag=lt;const ut=Uint16Array;HC.NativeUint16Array=ut;HC.Uint16ArrayFrom=(...t)=>n(q,ut,t);const ct=Uint32Array;HC.NativeUint32Array=ct;const ht=Float32Array;HC.NativeFloat32Array=ht;const dt=l([][v]());HC.ArrayIteratorPrototype=dt;const ft=e(dt.next);HC.ArrayIteratorPrototypeNext=ft;const pt=e(function*(){}().next);HC.GeneratorPrototypeNext=pt;const mt=l(dt);HC.IteratorPrototype=mt;const gt=DataView.prototype,vt=e(gt.getUint16);HC.DataViewPrototypeGetUint16=vt;const yt=e(gt.setUint16);HC.DataViewPrototypeSetUint16=yt;const xt=TypeError;HC.NativeTypeError=xt;const _t=RangeError;HC.NativeRangeError=_t;const wt=WeakSet;HC.NativeWeakSet=wt;const bt=wt.prototype,Mt=e(bt.add);HC.WeakSetPrototypeAdd=Mt;const St=e(bt.has);HC.WeakSetPrototypeHas=St;const Tt=WeakMap;HC.NativeWeakMap=Tt;const Et=Tt.prototype,At=e(Et.get);HC.WeakMapPrototypeGet=At;const Rt=e(Et.has);HC.WeakMapPrototypeHas=Rt;const Pt=e(Et.set);return HC.WeakMapPrototypeSet=Pt,HC}function YC(){if(UC)return VC;UC=1,Object.defineProperty(VC,"__esModule",{value:!0}),VC.safeIfNeeded=function(n){if(n[t.SymbolIterator]===t.NativeArrayPrototypeSymbolIterator)return n;const i=(0,t.ObjectCreate)(r);return(0,t.WeakMapPrototypeSet)(e,i,(0,t.ArrayPrototypeSymbolIterator)(n)),i},VC.wrap=function(e){const r=(0,t.ObjectCreate)(i);return(0,t.WeakMapPrototypeSet)(n,r,e),r};var t=XC();const e=new t.NativeWeakMap,r=(0,t.ObjectCreate)(null,{next:{value:function(){const r=(0,t.WeakMapPrototypeGet)(e,this);return(0,t.ArrayIteratorPrototypeNext)(r)}},[t.SymbolIterator]:{value:function(){return this}}});const n=new t.NativeWeakMap,i=(0,t.ObjectCreate)(t.IteratorPrototype,{next:{value:function(){const e=(0,t.WeakMapPrototypeGet)(n,this);return(0,t.GeneratorPrototypeNext)(e)},writable:!0,configurable:!0}});for(const e of(0,t.ReflectOwnKeys)(t.ArrayIteratorPrototype))"next"!==e&&(0,t.ObjectDefineProperty)(i,e,(0,t.ReflectGetOwnPropertyDescriptor)(t.ArrayIteratorPrototype,e));return VC}var ZC,KC,JC={},QC={};function $C(){if(ZC)return QC;ZC=1,Object.defineProperty(QC,"__esModule",{value:!0}),QC.isArrayBuffer=function(e){try{return(0,t.ArrayBufferPrototypeGetByteLength)(e),!0}catch(t){return!1}},QC.isCanonicalIntegerIndexString=function(e){if("string"!=typeof e)return!1;const r=+e;if(e!==r+"")return!1;if(!(0,t.NumberIsFinite)(r))return!1;return r===(0,t.MathTrunc)(r)},QC.isNativeBigIntTypedArray=function(e){const r=(0,t.TypedArrayPrototypeGetSymbolToStringTag)(e);return"BigInt64Array"===r||"BigUint64Array"===r},QC.isNativeTypedArray=e,QC.isObject=function(t){return null!==t&&"object"==typeof t||"function"==typeof t},QC.isObjectLike=function(t){return null!==t&&"object"==typeof t},QC.isOrdinaryArray=function(e){if(!(0,t.ArrayIsArray)(e))return!1;if(e[t.SymbolIterator]===t.NativeArrayPrototypeSymbolIterator)return!0;return"Array Iterator"===e[t.SymbolIterator]()[t.SymbolToStringTag]},QC.isOrdinaryNativeTypedArray=function(r){if(!e(r))return!1;if(r[t.SymbolIterator]===t.NativeTypedArrayPrototypeSymbolIterator)return!0;return"Array Iterator"===r[t.SymbolIterator]()[t.SymbolToStringTag]},QC.isSharedArrayBuffer=function(e){if(null===t.NativeSharedArrayBuffer)return!1;try{return(0,t.SharedArrayBufferPrototypeGetByteLength)(e),!0}catch(t){return!1}};var t=XC();function e(e){return void 0!==(0,t.TypedArrayPrototypeGetSymbolToStringTag)(e)}return QC}var tI,eI={};function rI(){if(tI)return eI;tI=1,Object.defineProperty(eI,"__esModule",{value:!0}),eI.convertToNumber=function(t){const e=t>>10;return n[0]=o[l[e]+(1023&t)]+s[e],r[0]},eI.roundToFloat16Bits=function(t){r[0]=t;const e=n[0],o=e>>23&511;return i[o]+((8388607&e)>>a[o])};var t=XC();const e=new t.NativeArrayBuffer(4),r=new t.NativeFloat32Array(e),n=new t.NativeUint32Array(e),i=new t.NativeUint32Array(512),a=new t.NativeUint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,a[t]=24,a[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,a[t]=-e-1,a[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,a[t]=13,a[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,a[t]=24,a[256|t]=24):(i[t]=31744,i[256|t]=64512,a[t]=13,a[256|t]=13)}const o=new t.NativeUint32Array(2048),s=new t.NativeUint32Array(64),l=new t.NativeUint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,r=0;for(;0==(8388608&e);)e<<=1,r-=8388608;e&=-8388609,r+=947912704,o[t]=e|r}for(let t=1024;t<2048;++t)o[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)s[t]=t<<23;s[31]=1199570944,s[32]=2147483648;for(let t=33;t<63;++t)s[t]=2147483648+(t-32<<23);s[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(l[t]=1024);return eI}var nI,iI,aI={};function oI(){if(iI)return jC;iI=1,Object.defineProperty(jC,"__esModule",{value:!0}),jC.isFloat16Array=l;var t=YC(),e=function(){if(KC)return JC;KC=1,Object.defineProperty(JC,"__esModule",{value:!0}),JC.hasFloat16ArrayBrand=function(i){if(!(0,t.isObjectLike)(i))return!1;const a=(0,r.ReflectGetPrototypeOf)(i);if(!(0,t.isObjectLike)(a))return!1;const o=a.constructor;if(void 0===o)return!1;if(!(0,t.isObject)(o))throw(0,r.NativeTypeError)(e.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);return(0,r.ReflectHas)(o,n)};var t=$C(),e=qC(),r=XC();const n=(0,r.SymbolFor)("__Float16Array__");return JC.brand=n,JC}(),r=rI(),n=$C(),i=qC(),a=XC(),o=function(){if(nI)return aI;nI=1,Object.defineProperty(aI,"__esModule",{value:!0}),aI.IsDetachedBuffer=function(e){if((0,t.isSharedArrayBuffer)(e))return!1;try{return(0,r.ArrayBufferPrototypeSlice)(e,0,0),!1}catch(t){}return!0},aI.SpeciesConstructor=function(n,i){if(!(0,t.isObject)(n))throw(0,r.NativeTypeError)(e.THIS_IS_NOT_AN_OBJECT);const a=n.constructor;if(void 0===a)return i;if(!(0,t.isObject)(a))throw(0,r.NativeTypeError)(e.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);const o=a[r.SymbolSpecies];return null==o?i:o},aI.ToIntegerOrInfinity=n,aI.ToLength=function(t){const e=n(t);return e<0?0:ee)return 1;if(0===t&&0===e){const n=(0,r.ObjectIs)(t,0),i=(0,r.ObjectIs)(e,0);if(!n&&i)return-1;if(n&&!i)return 1}return 0};var t=$C(),e=qC(),r=XC();function n(t){const e=+t;return(0,r.NumberIsNaN)(e)||0===e?0:(0,r.MathTrunc)(e)}return aI}();const s=new a.NativeWeakMap;function l(t){return(0,a.WeakMapPrototypeHas)(s,t)||!(0,a.ArrayBufferIsView)(t)&&(0,e.hasFloat16ArrayBrand)(t)}function u(t){if(!l(t))throw(0,a.NativeTypeError)(i.THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT)}function c(t,e){const r=l(t),o=(0,n.isNativeTypedArray)(t);if(!r&&!o)throw(0,a.NativeTypeError)(i.SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT);if("number"==typeof e){let n;if(r){const e=h(t);n=(0,a.TypedArrayPrototypeGetLength)(e)}else n=(0,a.TypedArrayPrototypeGetLength)(t);if(n(0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)?(0,r.convertToNumber)((0,a.ReflectGet)(t,e)):(0,a.WeakSetPrototypeHas)(f,(0,a.ObjectPrototype__lookupGetter__)(t,e))?(0,a.ReflectGet)(t,e):(0,a.ReflectGet)(t,e,i),set:(t,e,i,o)=>(0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)?(0,a.ReflectSet)(t,e,(0,r.roundToFloat16Bits)(i)):(0,a.ReflectSet)(t,e,i,o),getOwnPropertyDescriptor(t,e){if((0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)){const n=(0,a.ReflectGetOwnPropertyDescriptor)(t,e);return n.value=(0,r.convertToNumber)(n.value),n}return(0,a.ReflectGetOwnPropertyDescriptor)(t,e)},defineProperty:(t,e,i)=>(0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)&&(0,a.ObjectHasOwn)(i,"value")?(i.value=(0,r.roundToFloat16Bits)(i.value),(0,a.ReflectDefineProperty)(t,e,i)):(0,a.ReflectDefineProperty)(t,e,i)});let m=class f{constructor(t,e,u){let c;if(l(t))c=(0,a.ReflectConstruct)(a.NativeUint16Array,[h(t)],new.target);else if((0,n.isObject)(t)&&!(0,n.isArrayBuffer)(t)){let e,s;if((0,n.isNativeTypedArray)(t)){e=t,s=(0,a.TypedArrayPrototypeGetLength)(t);const r=(0,a.TypedArrayPrototypeGetBuffer)(t),l=(0,n.isSharedArrayBuffer)(r)?a.NativeArrayBuffer:(0,o.SpeciesConstructor)(r,a.NativeArrayBuffer);if((0,o.IsDetachedBuffer)(r))throw(0,a.NativeTypeError)(i.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);if((0,n.isNativeBigIntTypedArray)(t))throw(0,a.NativeTypeError)(i.CANNOT_MIX_BIGINT_AND_OTHER_TYPES);const u=new l(2*s);c=(0,a.ReflectConstruct)(a.NativeUint16Array,[u],new.target)}else{const r=t[a.SymbolIterator];if(null!=r&&"function"!=typeof r)throw(0,a.NativeTypeError)(i.ITERATOR_PROPERTY_IS_NOT_CALLABLE);null!=r?(0,n.isOrdinaryArray)(t)?(e=t,s=t.length):(e=[...t],s=e.length):(e=t,s=(0,o.ToLength)(e.length)),c=(0,a.ReflectConstruct)(a.NativeUint16Array,[s],new.target)}for(let t=0;t=0?i:n+i;if(!(s<0||s>=n))return(0,r.convertToNumber)(e[s])}map(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),s=e[0],l=(0,o.SpeciesConstructor)(n,f);if(l===f){const e=new f(i),o=h(e);for(let e=0;e=0;--e)s=t(s,(0,r.convertToNumber)(n[e]),e,this);return s}forEach(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),o=e[0];for(let e=0;e=0;--e){const i=(0,r.convertToNumber)(n[e]);if((0,a.ReflectApply)(t,o,[i,e,this]))return i}}findLastIndex(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),o=e[0];for(let e=i-1;e>=0;--e){const i=(0,r.convertToNumber)(n[e]);if((0,a.ReflectApply)(t,o,[i,e,this]))return e}return-1}every(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),o=e[0];for(let e=0;ed)throw(0,a.NativeRangeError)(i.OFFSET_IS_OUT_OF_BOUNDS);for(let t=0;tn((0,r.convertToNumber)(t),(0,r.convertToNumber)(e)))),this}slice(t,e){u(this);const n=h(this),s=(0,o.SpeciesConstructor)(n,f);if(s===f){const r=new a.NativeUint16Array((0,a.TypedArrayPrototypeGetBuffer)(n),(0,a.TypedArrayPrototypeGetByteOffset)(n),(0,a.TypedArrayPrototypeGetLength)(n));return new f((0,a.TypedArrayPrototypeGetBuffer)((0,a.TypedArrayPrototypeSlice)(r,t,e)))}const l=(0,a.TypedArrayPrototypeGetLength)(n),d=(0,o.ToIntegerOrInfinity)(t),p=void 0===e?l:(0,o.ToIntegerOrInfinity)(e);let m,g;m=d===-1/0?0:d<0?l+d>0?l+d:0:l0?l+p:0:l0?g-m:0,y=new s(v);if(c(y,v),0===v)return y;const x=(0,a.TypedArrayPrototypeGetBuffer)(n);if((0,o.IsDetachedBuffer)(x))throw(0,a.NativeTypeError)(i.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);let _=0;for(;m=1?(0,o.ToIntegerOrInfinity)(e[0]):i-1;if(s===-1/0)return-1;s>=0?s=s=0;--e)if((0,a.ObjectHasOwn)(n,e)&&(0,r.convertToNumber)(n[e])===t)return e;return-1}includes(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n);let s=(0,o.ToIntegerOrInfinity)(e[0]);if(s===1/0)return!1;s<0&&(s+=i,s<0&&(s=0));const l=(0,a.NumberIsNaN)(t);for(let e=s;e/]`,l);if(o&&console.log("[xml-utils] start:",u),-1===u)return;const c=n.slice(u+i.length);let h=e(c,"^[^<]*[ /]>",0);const d=-1!==h&&"/"===c[h-1];if(o&&console.log("[xml-utils] selfClosing:",d),!1===d)if(s){let t=0,n=1,a=0;for(;-1!==(h=e(c,"[ /]"+i+">",t));){const e=c.substring(t,h+1);if(n+=r(e,"<"+i),a+=r(e,"/"+i+">"),a>=n)break;t=h}}else h=e(c,"[ /]"+i+">",0);const f=u+i.length+h+1;if(o&&console.log("[xml-utils] end:",f),-1===f)return;const p=n.slice(u,f);let m;return m=d?null:p.slice(p.indexOf(">")+1,p.lastIndexOf("<")),{inner:m,outer:p,start:u,end:f}}return bI.exports=n,wI.default=n,wI}var DI,kI={};function FI(){return DI||(DI=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.geoKeys=t.geoKeyNames=t.LercAddCompression=t.LercParameters=t.ExtraSamplesValues=t.photometricInterpretations=t.fieldTypes=t.fieldTypeNames=t.arrayFields=t.fieldTagTypes=t.fieldTags=t.fieldTagNames=void 0,t.fieldTagNames={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},t.fieldTags={};for(const e in t.fieldTagNames)t.fieldTagNames.hasOwnProperty(e)&&(t.fieldTags[t.fieldTagNames[e]]=parseInt(e,10));t.fieldTagTypes={256:"SHORT",257:"SHORT",258:"SHORT",259:"SHORT",262:"SHORT",273:"LONG",274:"SHORT",277:"SHORT",278:"LONG",279:"LONG",282:"RATIONAL",283:"RATIONAL",284:"SHORT",286:"SHORT",287:"RATIONAL",296:"SHORT",297:"SHORT",305:"ASCII",306:"ASCII",338:"SHORT",339:"SHORT",513:"LONG",514:"LONG",1024:"SHORT",1025:"SHORT",2048:"SHORT",2049:"ASCII",3072:"SHORT",3073:"ASCII",33550:"DOUBLE",33922:"DOUBLE",34665:"LONG",34735:"SHORT",34737:"ASCII",42113:"ASCII"},t.arrayFields=[t.fieldTags.BitsPerSample,t.fieldTags.ExtraSamples,t.fieldTags.SampleFormat,t.fieldTags.StripByteCounts,t.fieldTags.StripOffsets,t.fieldTags.StripRowCounts,t.fieldTags.TileByteCounts,t.fieldTags.TileOffsets,t.fieldTags.SubIFDs],t.fieldTypeNames={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},t.fieldTypes={};for(const e in t.fieldTypeNames)t.fieldTypeNames.hasOwnProperty(e)&&(t.fieldTypes[t.fieldTypeNames[e]]=parseInt(e,10));t.photometricInterpretations={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},t.ExtraSamplesValues={Unspecified:0,Assocalpha:1,Unassalpha:2},t.LercParameters={Version:0,AddCompression:1},t.LercAddCompression={None:0,Deflate:1},t.geoKeyNames={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},t.geoKeys={};for(const e in t.geoKeyNames)t.geoKeyNames.hasOwnProperty(e)&&(t.geoKeys[t.geoKeyNames[e]]=parseInt(e,10))}(kI)),kI}var NI,UI={};function BI(){if(NI)return UI;NI=1,Object.defineProperty(UI,"__esModule",{value:!0}),UI.fromCIELab=UI.fromYCbCr=UI.fromCMYK=UI.fromPalette=UI.fromBlackIsZero=UI.fromWhiteIsZero=void 0,UI.fromWhiteIsZero=function(t,e){const{width:r,height:n}=t,i=new Uint8Array(r*n*3);let a;for(let r=0,n=0;r>24)/500+s,u=s-(t[e+2]<<24>>24)/200;l=.95047*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),s=1*(s*s*s>.008856?s*s*s:(s-16/116)/7.787),u=1.08883*(u*u*u>.008856?u*u*u:(u-16/116)/7.787),i=3.2406*l+-1.5372*s+-.4986*u,a=-.9689*l+1.8758*s+.0415*u,o=.0557*l+-.204*s+1.057*u,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,n[r]=255*Math.max(0,Math.min(1,i)),n[r+1]=255*Math.max(0,Math.min(1,a)),n[r+2]=255*Math.max(0,Math.min(1,o))}return n},UI}var zI,GI,jI,VI={},HI={},WI={},qI={};function XI(){if(GI)return WI;GI=1,Object.defineProperty(WI,"__esModule",{value:!0});const t=function(){if(zI)return qI;function t(t,e){let r=t.length-e,n=0;do{for(let r=e;r>0;r--)t[n+e]+=t[n],n++;r-=e}while(r>0)}function e(t,e,r){let n=0,i=t.length;const a=i/r;for(;i>e;){for(let r=e;r>0;--r)t[n+e]+=t[n],++n;i-=e}const o=t.slice();for(let e=0;e=r.byteLength);++s){let a;if(2===n){switch(o[0]){case 8:a=new Uint8Array(r,s*u*i*l,u*i*l);break;case 16:a=new Uint16Array(r,s*u*i*l,u*i*l/2);break;case 32:a=new Uint32Array(r,s*u*i*l,u*i*l/4);break;default:throw new Error(`Predictor 2 not allowed with ${o[0]} bits per sample.`)}t(a,u)}else 3===n&&(a=new Uint8Array(r,s*u*i*l,u*i*l),e(a,u,l))}return r},qI}();return WI.default=class{async decode(e,r){const n=await this.decodeBlock(r),i=e.Predictor||1;if(1!==i){const r=!e.StripOffsets,a=r?e.TileWidth:e.ImageWidth,o=r?e.TileLength:e.RowsPerStrip||e.ImageLength;return(0,t.applyPredictor)(n,i,a,o,e.BitsPerSample,e.PlanarConfiguration)}return n}},WI}var YI,ZI={};function KI(){if(YI)return ZI;YI=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ZI,"__esModule",{value:!0});const e=t(XI()),r=257;function n(t,e){for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t}function i(t){const e=new Uint16Array(4093),i=new Uint8Array(4093);for(let t=0;t<=257;t++)e[t]=4096,i[t]=t;let a=258,o=9,s=0;function l(){a=258,o=9}function u(t){const e=function(t,e,n){const i=e%8,a=Math.floor(e/8),o=8-i,s=e+n-8*(a+1);let l=8*(a+2)-(e+n);const u=8*(a+2)-e;if(l=Math.max(0,l),a>=t.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),r;let c=t[a]&2**(8-i)-1;c<<=n-o;let h=c;if(a+1>>l;e<<=Math.max(0,n-u),h+=e}if(s>8&&a+2>>r}return h}(t,s,o);return s+=o,e}function c(t,r){return i[a]=r,e[a]=t,a++,a-1}function h(t){const r=[];for(let n=t;4096!==n;n=e[n])r.push(i[n]);return r}const d=[];l();const f=new Uint8Array(t);let p,m=u(f);for(;m!==r;){if(256===m){for(l(),m=u(f);256===m;)m=u(f);if(m===r)break;if(m>256)throw new Error(`corrupted code at scanline ${m}`);n(d,h(m)),p=m}else if(m=2**o&&(12===o?p=void 0:o++),m=u(f)}return new Uint8Array(d)}class a extends e.default{decodeBlock(t){return i(t).buffer}}return ZI.default=a,ZI}var JI,QI={};var $I,tL,eL,rL,nL,iL,aL,oL,sL,lL,uL={},cL={},hL={},dL={},fL={};function pL(){if($I)return fL;$I=1;function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=256,r=286,n=30,i=15,a=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),o=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),s=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),l=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new Array(576);t(u);const c=new Array(60);t(c);const h=new Array(512);t(h);const d=new Array(256);t(d);const f=new Array(29);t(f);const p=new Array(n);function m(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let g,v,y;function x(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(p);const _=t=>t<256?h[t]:h[256+(t>>>7)],w=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},b=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<{b(t,r[2*e],r[2*e+1])},S=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},T=(t,e,r)=>{const n=new Array(16);let a,o,s=0;for(a=1;a<=i;a++)n[a]=s=s+r[a-1]<<1;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=S(n[e]++,e))}},E=t=>{let e;for(e=0;e{t.bi_valid>8?w(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},R=(t,e,r,n)=>{const i=2*e,a=2*r;return t[i]{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i{let i,s,l,u,c=0;if(0!==t.last_lit)do{i=t.pending_buf[t.d_buf+2*c]<<8|t.pending_buf[t.d_buf+2*c+1],s=t.pending_buf[t.l_buf+c],c++,0===i?M(t,s,r):(l=d[s],M(t,l+e+1,r),u=a[l],0!==u&&(s-=f[l],b(t,s,u)),i--,l=_(i),M(t,l,n),u=o[l],0!==u&&(i-=p[l],b(t,i,u)))}while(c{const r=e.dyn_tree,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,l,u,c=-1;for(t.heap_len=0,t.heap_max=573,s=0;s>1;s>=1;s--)P(t,r,s);u=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],P(t,r,1),l=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=l,r[2*u]=r[2*s]+r[2*l],t.depth[u]=(t.depth[s]>=t.depth[l]?t.depth[s]:t.depth[l])+1,r[2*s+1]=r[2*l+1]=u,t.heap[1]=u++,P(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,a=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,l=e.stat_desc.extra_base,u=e.stat_desc.max_length;let c,h,d,f,p,m,g=0;for(f=0;f<=i;f++)t.bl_count[f]=0;for(r[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)h=t.heap[c],f=r[2*r[2*h+1]+1]+1,f>u&&(f=u,g++),r[2*h+1]=f,h>n||(t.bl_count[f]++,p=0,h>=l&&(p=s[h-l]),m=r[2*h],t.opt_len+=m*(f+p),o&&(t.static_len+=m*(a[2*h+1]+p)));if(0!==g){do{for(f=u-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[u]--,g-=2}while(g>0);for(f=u;0!==f;f--)for(h=t.bl_count[f];0!==h;)d=t.heap[--c],d>n||(r[2*d+1]!==f&&(t.opt_len+=(f-r[2*d+1])*r[2*d],r[2*d+1]=f),h--)}})(t,e),T(r,c,t.bl_count)},L=(t,e,r)=>{let n,i,a=-1,o=e[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++s{let n,i,a=-1,o=e[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),n=0;n<=r;n++)if(i=o,o=e[2*(n+1)+1],!(++s{b(t,0+(n?1:0),3),((t,e,r,n)=>{A(t),n&&(w(t,r),w(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r})(t,e,r,!0)};return fL._tr_init=t=>{D||((()=>{let t,e,l,x,_;const w=new Array(16);for(l=0,x=0;x<28;x++)for(f[x]=l,t=0;t<1<>=7;x{let a,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let r,n=4093624447;for(r=0;r<=31;r++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*r])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(r=32;r{let e;for(L(t,t.dyn_ltree,t.l_desc.max_code),L(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*l[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),a=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=a&&(a=o)):a=o=n+5,n+4<=a&&-1!==r?k(t,r,n,i):4===t.strategy||o===a?(b(t,2+(i?1:0),3),C(t,u,c)):(b(t,4+(i?1:0),3),((t,e,r,n)=>{let i;for(b(t,e-257,5),b(t,r-1,5),b(t,n-4,4),i=0;i(t.pending_buf[t.d_buf+2*t.last_lit]=r>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&r,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===r?t.dyn_ltree[2*n]++:(t.matches++,r--,t.dyn_ltree[2*(d[n]+e+1)]++,t.dyn_dtree[2*_(r)]++),t.last_lit===t.lit_bufsize-1),fL._tr_align=t=>{b(t,2,3),M(t,256,u),(t=>{16===t.bi_valid?(w(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},fL}function mL(){if(eL)return tL;eL=1;return tL=(t,e,r,n)=>{let i=65535&t|0,a=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{i=i+e[n++]|0,a=a+i|0}while(--o);i%=65521,a%=65521}return i|a<<16|0}}function gL(){if(nL)return rL;nL=1;const t=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());return rL=(e,r,n,i)=>{const a=t,o=i+n;e^=-1;for(let t=i;t>>8^a[255&(e^r[t])];return-1^e}}function vL(){return aL?iL:(aL=1,iL={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"})}function yL(){return sL?oL:(sL=1,oL={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8})}function xL(){if(lL)return dL;lL=1;const{_tr_init:t,_tr_stored_block:e,_tr_flush_block:r,_tr_tally:n,_tr_align:i}=pL(),a=mL(),o=gL(),s=vL(),{Z_NO_FLUSH:l,Z_PARTIAL_FLUSH:u,Z_FULL_FLUSH:c,Z_FINISH:h,Z_BLOCK:d,Z_OK:f,Z_STREAM_END:p,Z_STREAM_ERROR:m,Z_DATA_ERROR:g,Z_BUF_ERROR:v,Z_DEFAULT_COMPRESSION:y,Z_FILTERED:x,Z_HUFFMAN_ONLY:_,Z_RLE:w,Z_FIXED:b,Z_DEFAULT_STRATEGY:M,Z_UNKNOWN:S,Z_DEFLATED:T}=yL(),E=258,A=262,R=103,P=113,C=666,I=(t,e)=>(t.msg=s[e],e),L=t=>(t<<1)-(t>4?9:0),O=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let D=(t,e,r)=>(e<{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},F=(t,e)=>{r(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,k(t.strm)},N=(t,e)=>{t.pending_buf[t.pending++]=e},U=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},B=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=a(t.adler,e,i,r):2===t.state.wrap&&(t.adler=o(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},z=(t,e)=>{let r,n,i=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match;const l=t.strstart>t.w_size-A?t.strstart-(t.w_size-A):0,u=t.window,c=t.w_mask,h=t.prev,d=t.strstart+E;let f=u[a+o-1],p=u[a+o];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(r=e,u[r+o]===p&&u[r+o-1]===f&&u[r]===u[a]&&u[++r]===u[a+1]){a+=2,r++;do{}while(u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&ao){if(t.match_start=e,o=n,n>=s)break;f=u[a+o-1],p=u[a+o]}}}while((e=h[e&c])>l&&0!=--i);return o<=t.lookahead?o:t.lookahead},G=t=>{const e=t.w_size;let r,n,i,a,o;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-A)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do{i=t.head[--r],t.head[r]=i>=e?i-e:0}while(--n);n=e,r=n;do{i=t.prev[--r],t.prev[r]=i>=e?i-e:0}while(--n);a+=e}if(0===t.strm.avail_in)break;if(n=B(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=n,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=D(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=D(t,t.ins_h,t.window[o+3-1]),t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead{let r,i;for(;;){if(t.lookahead=3&&(t.ins_h=D(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-A&&(t.match_length=z(t,r)),t.match_length>=3)if(i=n(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=D(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=D(t,t.ins_h,t.window[t.strstart+1]);else i=n(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(F(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===h?(F(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(F(t,!1),0===t.strm.avail_out)?1:2},V=(t,e)=>{let r,i,a;for(;;){if(t.lookahead=3&&(t.ins_h=D(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-3,i=n(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=a&&(t.ins_h=D(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(F(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=n(t,0,t.window[t.strstart-1]),i&&F(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=n(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===h?(F(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(F(t,!1),0===t.strm.avail_out)?1:2};function H(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const W=[new H(0,0,0,0,((t,e)=>{let r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(G(t),0===t.lookahead&&e===l)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,F(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-A&&(F(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===h?(F(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(F(t,!1),t.strm.avail_out),1)})),new H(4,4,8,4,j),new H(4,5,16,8,j),new H(4,6,32,32,j),new H(4,4,16,16,V),new H(8,16,32,32,V),new H(8,16,128,128,V),new H(8,32,128,256,V),new H(32,128,258,1024,V),new H(32,258,258,4096,V)];function q(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=T,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),O(this.dyn_ltree),O(this.dyn_dtree),O(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),O(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),O(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const X=e=>{if(!e||!e.state)return I(e,m);e.total_in=e.total_out=0,e.data_type=S;const r=e.state;return r.pending=0,r.pending_out=0,r.wrap<0&&(r.wrap=-r.wrap),r.status=r.wrap?42:P,e.adler=2===r.wrap?0:1,r.last_flush=l,t(r),f},Y=t=>{const e=X(t);var r;return e===f&&((r=t.state).window_size=2*r.w_size,O(r.head),r.max_lazy_match=W[r.level].max_lazy,r.good_match=W[r.level].good_length,r.nice_match=W[r.level].nice_length,r.max_chain_length=W[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),e},Z=(t,e,r,n,i,a)=>{if(!t)return m;let o=1;if(e===y&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==T||n<8||n>15||e<0||e>9||a<0||a>b)return I(t,m);8===n&&(n=9);const s=new q;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<Z(t,e,T,15,8,M),dL.deflateInit2=Z,dL.deflateReset=Y,dL.deflateResetKeep=X,dL.deflateSetHeader=(t,e)=>t&&t.state?2!==t.state.wrap?m:(t.state.gzhead=e,f):m,dL.deflate=(t,r)=>{let a,s;if(!t||!t.state||r>d||r<0)return t?I(t,m):m;const g=t.state;if(!t.output||!t.input&&0!==t.avail_in||g.status===C&&r!==h)return I(t,0===t.avail_out?v:m);g.strm=t;const y=g.last_flush;if(g.last_flush=r,42===g.status)if(2===g.wrap)t.adler=0,N(g,31),N(g,139),N(g,8),g.gzhead?(N(g,(g.gzhead.text?1:0)+(g.gzhead.hcrc?2:0)+(g.gzhead.extra?4:0)+(g.gzhead.name?8:0)+(g.gzhead.comment?16:0)),N(g,255&g.gzhead.time),N(g,g.gzhead.time>>8&255),N(g,g.gzhead.time>>16&255),N(g,g.gzhead.time>>24&255),N(g,9===g.level?2:g.strategy>=_||g.level<2?4:0),N(g,255&g.gzhead.os),g.gzhead.extra&&g.gzhead.extra.length&&(N(g,255&g.gzhead.extra.length),N(g,g.gzhead.extra.length>>8&255)),g.gzhead.hcrc&&(t.adler=o(t.adler,g.pending_buf,g.pending,0)),g.gzindex=0,g.status=69):(N(g,0),N(g,0),N(g,0),N(g,0),N(g,0),N(g,9===g.level?2:g.strategy>=_||g.level<2?4:0),N(g,3),g.status=P);else{let e=T+(g.w_bits-8<<4)<<8,r=-1;r=g.strategy>=_||g.level<2?0:g.level<6?1:6===g.level?2:3,e|=r<<6,0!==g.strstart&&(e|=32),e+=31-e%31,g.status=P,U(g,e),0!==g.strstart&&(U(g,t.adler>>>16),U(g,65535&t.adler)),t.adler=1}if(69===g.status)if(g.gzhead.extra){for(a=g.pending;g.gzindex<(65535&g.gzhead.extra.length)&&(g.pending!==g.pending_buf_size||(g.gzhead.hcrc&&g.pending>a&&(t.adler=o(t.adler,g.pending_buf,g.pending-a,a)),k(t),a=g.pending,g.pending!==g.pending_buf_size));)N(g,255&g.gzhead.extra[g.gzindex]),g.gzindex++;g.gzhead.hcrc&&g.pending>a&&(t.adler=o(t.adler,g.pending_buf,g.pending-a,a)),g.gzindex===g.gzhead.extra.length&&(g.gzindex=0,g.status=73)}else g.status=73;if(73===g.status)if(g.gzhead.name){a=g.pending;do{if(g.pending===g.pending_buf_size&&(g.gzhead.hcrc&&g.pending>a&&(t.adler=o(t.adler,g.pending_buf,g.pending-a,a)),k(t),a=g.pending,g.pending===g.pending_buf_size)){s=1;break}s=g.gzindexa&&(t.adler=o(t.adler,g.pending_buf,g.pending-a,a)),0===s&&(g.gzindex=0,g.status=91)}else g.status=91;if(91===g.status)if(g.gzhead.comment){a=g.pending;do{if(g.pending===g.pending_buf_size&&(g.gzhead.hcrc&&g.pending>a&&(t.adler=o(t.adler,g.pending_buf,g.pending-a,a)),k(t),a=g.pending,g.pending===g.pending_buf_size)){s=1;break}s=g.gzindexa&&(t.adler=o(t.adler,g.pending_buf,g.pending-a,a)),0===s&&(g.status=R)}else g.status=R;if(g.status===R&&(g.gzhead.hcrc?(g.pending+2>g.pending_buf_size&&k(t),g.pending+2<=g.pending_buf_size&&(N(g,255&t.adler),N(g,t.adler>>8&255),t.adler=0,g.status=P)):g.status=P),0!==g.pending){if(k(t),0===t.avail_out)return g.last_flush=-1,f}else if(0===t.avail_in&&L(r)<=L(y)&&r!==h)return I(t,v);if(g.status===C&&0!==t.avail_in)return I(t,v);if(0!==t.avail_in||0!==g.lookahead||r!==l&&g.status!==C){let a=g.strategy===_?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(G(t),0===t.lookahead)){if(e===l)return 1;break}if(t.match_length=0,r=n(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(F(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===h?(F(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(F(t,!1),0===t.strm.avail_out)?1:2})(g,r):g.strategy===w?((t,e)=>{let r,i,a,o;const s=t.window;for(;;){if(t.lookahead<=E){if(G(t),t.lookahead<=E&&e===l)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(a=t.strstart-1,i=s[a],i===s[++a]&&i===s[++a]&&i===s[++a])){o=t.strstart+E;do{}while(i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&at.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=n(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=n(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(F(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===h?(F(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(F(t,!1),0===t.strm.avail_out)?1:2})(g,r):W[g.level].func(g,r);if(3!==a&&4!==a||(g.status=C),1===a||3===a)return 0===t.avail_out&&(g.last_flush=-1),f;if(2===a&&(r===u?i(g):r!==d&&(e(g,0,0,!1),r===c&&(O(g.head),0===g.lookahead&&(g.strstart=0,g.block_start=0,g.insert=0))),k(t),0===t.avail_out))return g.last_flush=-1,f}return r!==h?f:g.wrap<=0?p:(2===g.wrap?(N(g,255&t.adler),N(g,t.adler>>8&255),N(g,t.adler>>16&255),N(g,t.adler>>24&255),N(g,255&t.total_in),N(g,t.total_in>>8&255),N(g,t.total_in>>16&255),N(g,t.total_in>>24&255)):(U(g,t.adler>>>16),U(g,65535&t.adler)),k(t),g.wrap>0&&(g.wrap=-g.wrap),0!==g.pending?f:p)},dL.deflateEnd=t=>{if(!t||!t.state)return m;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==R&&e!==P&&e!==C?I(t,m):(t.state=null,e===P?I(t,g):f)},dL.deflateSetDictionary=(t,e)=>{let r=e.length;if(!t||!t.state)return m;const n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return m;if(1===i&&(t.adler=a(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(O(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const o=t.avail_in,s=t.next_in,l=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,G(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=D(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,G(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=l,t.avail_in=o,n.wrap=i,f},dL.deflateInfo="pako deflate (from Nodeca project)",dL}var _L,wL={};function bL(){if(_L)return wL;_L=1;const t=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);return wL.assign=function(e){const r=Array.prototype.slice.call(arguments,1);for(;r.length;){const n=r.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const r in n)t(n,r)&&(e[r]=n[r])}}return e},wL.flattenChunks=t=>{let e=0;for(let r=0,n=t.length;r=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;e[254]=e[254]=1,AL.string2buf=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,a,o=t.length,s=0;for(i=0;i>>6,e[a++]=128|63&r):r<65536?(e[a++]=224|r>>>12,e[a++]=128|r>>>6&63,e[a++]=128|63&r):(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63,e[a++]=128|r>>>6&63,e[a++]=128|63&r);return e};return AL.buf2string=(r,n)=>{const i=n||r.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(r.subarray(0,n));let a,o;const s=new Array(2*i);for(o=0,a=0;a4)s[o++]=65533,a+=n-1;else{for(t&=2===n?31:3===n?15:7;n>1&&a1?s[o++]=65533:t<65536?s[o++]=t:(t-=65536,s[o++]=55296|t>>10&1023,s[o++]=56320|1023&t)}}return((e,r)=>{if(r<65534&&e.subarray&&t)return String.fromCharCode.apply(null,e.length===r?e:e.subarray(0,r));let n="";for(let t=0;t{(r=r||t.length)>t.length&&(r=t.length);let n=r-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?r:n+e[t[n]]>r?n:r},AL}function PL(){if(TL)return SL;return TL=1,SL=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}}var CL,IL,LL,OL,DL,kL,FL,NL,UL,BL,zL={},GL={};function jL(){if(DL)return GL;DL=1;const t=mL(),e=gL(),r=IL?CL:(IL=1,CL=function(t,e){let r,n,i,a,o,s,l,u,c,h,d,f,p,m,g,v,y,x,_,w,b,M,S,T;const E=t.state;r=t.next_in,S=t.input,n=r+(t.avail_in-5),i=t.next_out,T=t.output,a=i-(e-t.avail_out),o=i+(t.avail_out-257),s=E.dmax,l=E.wsize,u=E.whave,c=E.wnext,h=E.window,d=E.hold,f=E.bits,p=E.lencode,m=E.distcode,g=(1<>>24,d>>>=x,f-=x,x=y>>>16&255,0===x)T[i++]=65535&y;else{if(!(16&x)){if(0==(64&x)){y=p[(65535&y)+(d&(1<>>=x,f-=x),f<15&&(d+=S[r++]<>>24,d>>>=x,f-=x,x=y>>>16&255,!(16&x)){if(0==(64&x)){y=m[(65535&y)+(d&(1<s){t.msg="invalid distance too far back",E.mode=30;break t}if(d>>>=x,f-=x,x=i-a,w>x){if(x=w-x,x>u&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(b=0,M=h,0===c){if(b+=l-x,x<_){_-=x;do{T[i++]=h[b++]}while(--x);b=i-w,M=T}}else if(c2;)T[i++]=M[b++],T[i++]=M[b++],T[i++]=M[b++],_-=3;_&&(T[i++]=M[b++],_>1&&(T[i++]=M[b++]))}else{b=i-w;do{T[i++]=T[b++],T[i++]=T[b++],T[i++]=T[b++],_-=3}while(_>2);_&&(T[i++]=T[b++],_>1&&(T[i++]=T[b++]))}break}}break}}while(r>3,r-=_,f-=_<<3,d&=(1<{const f=d.bits;let p,m,g,v,y,x,_=0,w=0,b=0,M=0,S=0,T=0,E=0,A=0,R=0,P=0,C=null,I=0;const L=new Uint16Array(16),O=new Uint16Array(16);let D,k,F,N=null,U=0;for(_=0;_<=t;_++)L[_]=0;for(w=0;w=1&&0===L[M];M--);if(S>M&&(S=M),0===M)return u[c++]=20971520,u[c++]=20971520,d.bits=1,0;for(b=1;b0&&(0===a||1!==M))return-1;for(O[1]=0,_=1;_852||2===a&&R>592)return 1;for(;;){D=_-E,h[w]x?(k=N[U+h[w]],F=C[I+h[w]]):(k=96,F=0),p=1<<_-E,m=1<>E)+m]=D<<24|k<<16|F|0}while(0!==m);for(p=1<<_-1;P&p;)p>>=1;if(0!==p?(P&=p-1,P+=p):P=0,w++,0==--L[_]){if(_===M)break;_=o[s+h[w]]}if(_>S&&(P&v)!==g){for(0===E&&(E=S),y+=b,T=_-E,A=1<852||2===a&&R>592)return 1;g=P&v,u[g]=S<<24|T<<16|y-c|0}}return 0!==P&&(u[y+P]=_-E<<24|64<<16|0),d.bits=S,0}}(),{Z_FINISH:i,Z_BLOCK:a,Z_TREES:o,Z_OK:s,Z_STREAM_END:l,Z_NEED_DICT:u,Z_STREAM_ERROR:c,Z_DATA_ERROR:h,Z_MEM_ERROR:d,Z_BUF_ERROR:f,Z_DEFLATED:p}=yL(),m=12,g=30,v=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const x=t=>{if(!t||!t.state)return c;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,s},_=t=>{if(!t||!t.state)return c;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,x(t)},w=(t,e)=>{let r;if(!t||!t.state)return c;const n=t.state;return e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?c:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,_(t))},b=(t,e)=>{if(!t)return c;const r=new y;t.state=r,r.window=null;const n=w(t,e);return n!==s&&(t.state=null),n};let M,S,T=!0;const E=t=>{if(T){M=new Int32Array(512),S=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(n(1,t.lens,0,288,M,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;n(2,t.lens,0,32,S,0,t.work,{bits:5}),T=!1}t.lencode=M,t.lenbits=9,t.distcode=S,t.distbits=5},A=(t,e,r,n)=>{let i;const a=t.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(e.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),a.window.set(e.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(e.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whaveb(t,15),GL.inflateInit2=b,GL.inflate=(y,x)=>{let _,w,b,M,S,T,R,P,C,I,L,O,D,k,F,N,U,B,z,G,j,V,H=0;const W=new Uint8Array(4);let q,X;const Y=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!y||!y.state||!y.output||!y.input&&0!==y.avail_in)return c;_=y.state,_.mode===m&&(_.mode=13),S=y.next_out,b=y.output,R=y.avail_out,M=y.next_in,w=y.input,T=y.avail_in,P=_.hold,C=_.bits,I=T,L=R,V=s;t:for(;;)switch(_.mode){case 1:if(0===_.wrap){_.mode=13;break}for(;C<16;){if(0===T)break t;T--,P+=w[M++]<>>8&255,_.check=e(_.check,W,2,0),P=0,C=0,_.mode=2;break}if(_.flags=0,_.head&&(_.head.done=!1),!(1&_.wrap)||(((255&P)<<8)+(P>>8))%31){y.msg="incorrect header check",_.mode=g;break}if((15&P)!==p){y.msg="unknown compression method",_.mode=g;break}if(P>>>=4,C-=4,j=8+(15&P),0===_.wbits)_.wbits=j;else if(j>_.wbits){y.msg="invalid window size",_.mode=g;break}_.dmax=1<<_.wbits,y.adler=_.check=1,_.mode=512&P?10:m,P=0,C=0;break;case 2:for(;C<16;){if(0===T)break t;T--,P+=w[M++]<>8&1),512&_.flags&&(W[0]=255&P,W[1]=P>>>8&255,_.check=e(_.check,W,2,0)),P=0,C=0,_.mode=3;case 3:for(;C<32;){if(0===T)break t;T--,P+=w[M++]<>>8&255,W[2]=P>>>16&255,W[3]=P>>>24&255,_.check=e(_.check,W,4,0)),P=0,C=0,_.mode=4;case 4:for(;C<16;){if(0===T)break t;T--,P+=w[M++]<>8),512&_.flags&&(W[0]=255&P,W[1]=P>>>8&255,_.check=e(_.check,W,2,0)),P=0,C=0,_.mode=5;case 5:if(1024&_.flags){for(;C<16;){if(0===T)break t;T--,P+=w[M++]<>>8&255,_.check=e(_.check,W,2,0)),P=0,C=0}else _.head&&(_.head.extra=null);_.mode=6;case 6:if(1024&_.flags&&(O=_.length,O>T&&(O=T),O&&(_.head&&(j=_.head.extra_len-_.length,_.head.extra||(_.head.extra=new Uint8Array(_.head.extra_len)),_.head.extra.set(w.subarray(M,M+O),j)),512&_.flags&&(_.check=e(_.check,w,O,M)),T-=O,M+=O,_.length-=O),_.length))break t;_.length=0,_.mode=7;case 7:if(2048&_.flags){if(0===T)break t;O=0;do{j=w[M+O++],_.head&&j&&_.length<65536&&(_.head.name+=String.fromCharCode(j))}while(j&&O>9&1,_.head.done=!0),y.adler=_.check=0,_.mode=m;break;case 10:for(;C<32;){if(0===T)break t;T--,P+=w[M++]<>>=7&C,C-=7&C,_.mode=27;break}for(;C<3;){if(0===T)break t;T--,P+=w[M++]<>>=1,C-=1,3&P){case 0:_.mode=14;break;case 1:if(E(_),_.mode=20,x===o){P>>>=2,C-=2;break t}break;case 2:_.mode=17;break;case 3:y.msg="invalid block type",_.mode=g}P>>>=2,C-=2;break;case 14:for(P>>>=7&C,C-=7&C;C<32;){if(0===T)break t;T--,P+=w[M++]<>>16^65535)){y.msg="invalid stored block lengths",_.mode=g;break}if(_.length=65535&P,P=0,C=0,_.mode=15,x===o)break t;case 15:_.mode=16;case 16:if(O=_.length,O){if(O>T&&(O=T),O>R&&(O=R),0===O)break t;b.set(w.subarray(M,M+O),S),T-=O,M+=O,R-=O,S+=O,_.length-=O;break}_.mode=m;break;case 17:for(;C<14;){if(0===T)break t;T--,P+=w[M++]<>>=5,C-=5,_.ndist=1+(31&P),P>>>=5,C-=5,_.ncode=4+(15&P),P>>>=4,C-=4,_.nlen>286||_.ndist>30){y.msg="too many length or distance symbols",_.mode=g;break}_.have=0,_.mode=18;case 18:for(;_.have<_.ncode;){for(;C<3;){if(0===T)break t;T--,P+=w[M++]<>>=3,C-=3}for(;_.have<19;)_.lens[Y[_.have++]]=0;if(_.lencode=_.lendyn,_.lenbits=7,q={bits:_.lenbits},V=n(0,_.lens,0,19,_.lencode,0,_.work,q),_.lenbits=q.bits,V){y.msg="invalid code lengths set",_.mode=g;break}_.have=0,_.mode=19;case 19:for(;_.have<_.nlen+_.ndist;){for(;H=_.lencode[P&(1<<_.lenbits)-1],F=H>>>24,N=H>>>16&255,U=65535&H,!(F<=C);){if(0===T)break t;T--,P+=w[M++]<>>=F,C-=F,_.lens[_.have++]=U;else{if(16===U){for(X=F+2;C>>=F,C-=F,0===_.have){y.msg="invalid bit length repeat",_.mode=g;break}j=_.lens[_.have-1],O=3+(3&P),P>>>=2,C-=2}else if(17===U){for(X=F+3;C>>=F,C-=F,j=0,O=3+(7&P),P>>>=3,C-=3}else{for(X=F+7;C>>=F,C-=F,j=0,O=11+(127&P),P>>>=7,C-=7}if(_.have+O>_.nlen+_.ndist){y.msg="invalid bit length repeat",_.mode=g;break}for(;O--;)_.lens[_.have++]=j}}if(_.mode===g)break;if(0===_.lens[256]){y.msg="invalid code -- missing end-of-block",_.mode=g;break}if(_.lenbits=9,q={bits:_.lenbits},V=n(1,_.lens,0,_.nlen,_.lencode,0,_.work,q),_.lenbits=q.bits,V){y.msg="invalid literal/lengths set",_.mode=g;break}if(_.distbits=6,_.distcode=_.distdyn,q={bits:_.distbits},V=n(2,_.lens,_.nlen,_.ndist,_.distcode,0,_.work,q),_.distbits=q.bits,V){y.msg="invalid distances set",_.mode=g;break}if(_.mode=20,x===o)break t;case 20:_.mode=21;case 21:if(T>=6&&R>=258){y.next_out=S,y.avail_out=R,y.next_in=M,y.avail_in=T,_.hold=P,_.bits=C,r(y,L),S=y.next_out,b=y.output,R=y.avail_out,M=y.next_in,w=y.input,T=y.avail_in,P=_.hold,C=_.bits,_.mode===m&&(_.back=-1);break}for(_.back=0;H=_.lencode[P&(1<<_.lenbits)-1],F=H>>>24,N=H>>>16&255,U=65535&H,!(F<=C);){if(0===T)break t;T--,P+=w[M++]<>B)],F=H>>>24,N=H>>>16&255,U=65535&H,!(B+F<=C);){if(0===T)break t;T--,P+=w[M++]<>>=B,C-=B,_.back+=B}if(P>>>=F,C-=F,_.back+=F,_.length=U,0===N){_.mode=26;break}if(32&N){_.back=-1,_.mode=m;break}if(64&N){y.msg="invalid literal/length code",_.mode=g;break}_.extra=15&N,_.mode=22;case 22:if(_.extra){for(X=_.extra;C>>=_.extra,C-=_.extra,_.back+=_.extra}_.was=_.length,_.mode=23;case 23:for(;H=_.distcode[P&(1<<_.distbits)-1],F=H>>>24,N=H>>>16&255,U=65535&H,!(F<=C);){if(0===T)break t;T--,P+=w[M++]<>B)],F=H>>>24,N=H>>>16&255,U=65535&H,!(B+F<=C);){if(0===T)break t;T--,P+=w[M++]<>>=B,C-=B,_.back+=B}if(P>>>=F,C-=F,_.back+=F,64&N){y.msg="invalid distance code",_.mode=g;break}_.offset=U,_.extra=15&N,_.mode=24;case 24:if(_.extra){for(X=_.extra;C>>=_.extra,C-=_.extra,_.back+=_.extra}if(_.offset>_.dmax){y.msg="invalid distance too far back",_.mode=g;break}_.mode=25;case 25:if(0===R)break t;if(O=L-R,_.offset>O){if(O=_.offset-O,O>_.whave&&_.sane){y.msg="invalid distance too far back",_.mode=g;break}O>_.wnext?(O-=_.wnext,D=_.wsize-O):D=_.wnext-O,O>_.length&&(O=_.length),k=_.window}else k=b,D=S-_.offset,O=_.length;O>R&&(O=R),R-=O,_.length-=O;do{b[S++]=k[D++]}while(--O);0===_.length&&(_.mode=21);break;case 26:if(0===R)break t;b[S++]=_.length,R--,_.mode=21;break;case 27:if(_.wrap){for(;C<32;){if(0===T)break t;T--,P|=w[M++]<{if(!t||!t.state)return c;let e=t.state;return e.window&&(e.window=null),t.state=null,s},GL.inflateGetHeader=(t,e)=>{if(!t||!t.state)return c;const r=t.state;return 0==(2&r.wrap)?c:(r.head=e,e.done=!1,s)},GL.inflateSetDictionary=(e,r)=>{const n=r.length;let i,a,o;return e&&e.state?(i=e.state,0!==i.wrap&&11!==i.mode?c:11===i.mode&&(a=1,a=t(a,r,n,0),a!==i.check)?h:(o=A(e,r,n,n),o?(i.mode=31,d):(i.havedict=1,s))):c},GL.inflateInfo="pako inflate (from Nodeca project)",GL}function VL(){if(NL)return zL;NL=1;const t=jL(),e=bL(),r=RL(),n=vL(),i=PL(),a=FL?kL:(FL=1,kL=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}),o=Object.prototype.toString,{Z_NO_FLUSH:s,Z_FINISH:l,Z_OK:u,Z_STREAM_END:c,Z_NEED_DICT:h,Z_STREAM_ERROR:d,Z_DATA_ERROR:f,Z_MEM_ERROR:p}=yL();function m(s){this.options=e.assign({chunkSize:65536,windowBits:15,to:""},s||{});const l=this.options;l.raw&&l.windowBits>=0&&l.windowBits<16&&(l.windowBits=-l.windowBits,0===l.windowBits&&(l.windowBits=-15)),!(l.windowBits>=0&&l.windowBits<16)||s&&s.windowBits||(l.windowBits+=32),l.windowBits>15&&l.windowBits<48&&0==(15&l.windowBits)&&(l.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;let c=t.inflateInit2(this.strm,l.windowBits);if(c!==u)throw new Error(n[c]);if(this.header=new a,t.inflateGetHeader(this.strm,this.header),l.dictionary&&("string"==typeof l.dictionary?l.dictionary=r.string2buf(l.dictionary):"[object ArrayBuffer]"===o.call(l.dictionary)&&(l.dictionary=new Uint8Array(l.dictionary)),l.raw&&(c=t.inflateSetDictionary(this.strm,l.dictionary),c!==u)))throw new Error(n[c])}function g(t,e){const r=new m(e);if(r.push(t),r.err)throw r.msg||n[r.err];return r.result}return m.prototype.push=function(e,n){const i=this.strm,a=this.options.chunkSize,m=this.options.dictionary;let g,v,y;if(this.ended)return!1;for(v=n===~~n?n:!0===n?l:s,"[object ArrayBuffer]"===o.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),g=t.inflate(i,v),g===h&&m&&(g=t.inflateSetDictionary(i,m),g===u?g=t.inflate(i,v):g===f&&(g=h));i.avail_in>0&&g===c&&i.state.wrap>0&&0!==e[i.next_in];)t.inflateReset(i),g=t.inflate(i,v);switch(g){case d:case f:case h:case p:return this.onEnd(g),this.ended=!0,!1}if(y=i.avail_out,i.next_out&&(0===i.avail_out||g===c))if("string"===this.options.to){let t=r.utf8border(i.output,i.next_out),e=i.next_out-t,n=r.buf2string(i.output,t);i.next_out=e,i.avail_out=a-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(g!==u||0!==y){if(g===c)return g=t.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},m.prototype.onData=function(t){this.chunks.push(t)},m.prototype.onEnd=function(t){t===u&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},zL.Inflate=m,zL.inflate=g,zL.inflateRaw=function(t,e){return(e=e||{}).raw=!0,g(t,e)},zL.ungzip=g,zL.constants=yL(),zL}function HL(){if(UL)return cL;UL=1;const{Deflate:t,deflate:e,deflateRaw:r,gzip:n}=function(){if(EL)return hL;EL=1;const t=xL(),e=bL(),r=RL(),n=vL(),i=PL(),a=Object.prototype.toString,{Z_NO_FLUSH:o,Z_SYNC_FLUSH:s,Z_FULL_FLUSH:l,Z_FINISH:u,Z_OK:c,Z_STREAM_END:h,Z_DEFAULT_COMPRESSION:d,Z_DEFAULT_STRATEGY:f,Z_DEFLATED:p}=yL();function m(o){this.options=e.assign({level:d,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:f},o||{});let s=this.options;s.raw&&s.windowBits>0?s.windowBits=-s.windowBits:s.gzip&&s.windowBits>0&&s.windowBits<16&&(s.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;let l=t.deflateInit2(this.strm,s.level,s.method,s.windowBits,s.memLevel,s.strategy);if(l!==c)throw new Error(n[l]);if(s.header&&t.deflateSetHeader(this.strm,s.header),s.dictionary){let e;if(e="string"==typeof s.dictionary?r.string2buf(s.dictionary):"[object ArrayBuffer]"===a.call(s.dictionary)?new Uint8Array(s.dictionary):s.dictionary,l=t.deflateSetDictionary(this.strm,e),l!==c)throw new Error(n[l]);this._dict_set=!0}}function g(t,e){const r=new m(e);if(r.push(t,!0),r.err)throw r.msg||n[r.err];return r.result}return m.prototype.push=function(e,n){const i=this.strm,d=this.options.chunkSize;let f,p;if(this.ended)return!1;for(p=n===~~n?n:!0===n?u:o,"string"==typeof e?i.input=r.string2buf(e):"[object ArrayBuffer]"===a.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(d),i.next_out=0,i.avail_out=d),(p===s||p===l)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(f=t.deflate(i,p),f===h)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),f=t.deflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===c;if(0!==i.avail_out){if(p>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},m.prototype.onData=function(t){this.chunks.push(t)},m.prototype.onEnd=function(t){t===c&&(this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},hL.Deflate=m,hL.deflate=g,hL.deflateRaw=function(t,e){return(e=e||{}).raw=!0,g(t,e)},hL.gzip=function(t,e){return(e=e||{}).gzip=!0,g(t,e)},hL.constants=yL(),hL}(),{Inflate:i,inflate:a,inflateRaw:o,ungzip:s}=VL(),l=yL();return cL.Deflate=t,cL.deflate=e,cL.deflateRaw=r,cL.gzip=n,cL.Inflate=i,cL.inflate=a,cL.inflateRaw=o,cL.ungzip=s,cL.constants=l,cL}var WL,qL={};var XL,YL,ZL={},KL={},JL={get exports(){return KL},set exports(t){KL=t}};function QL(){if(YL)return ZL;YL=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ZL,"__esModule",{value:!0});const e=HL(),r=t((XL||(XL=1,function(t){ +const t="135",e={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},r={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},n=0,i=1,a=2,o=1,s=2,l=3,u=0,c=1,h=2,d=0,f=1,p=2,m=3,g=4,v=5,y=100,x=101,_=102,w=103,b=104,M=200,S=201,T=202,E=203,A=204,P=205,R=206,C=207,I=208,L=209,O=210,D=0,k=1,F=2,N=3,U=4,B=5,z=6,G=7,j=0,V=1,H=2,W=0,q=1,X=2,Y=3,Z=4,K=5,J=300,Q=301,$=302,tt=303,et=304,rt=306,nt=307,it=1e3,at=1001,ot=1002,st=1003,lt=1004,ut=1005,ct=1006,ht=1007,dt=1008,ft=1009,pt=1010,mt=1011,gt=1012,vt=1013,yt=1014,xt=1015,_t=1016,wt=1017,bt=1018,Mt=1019,St=1020,Tt=1021,Et=1022,At=1023,Pt=1024,Rt=1025,Ct=At,It=1026,Lt=1027,Ot=1028,Dt=1029,kt=1030,Ft=1031,Nt=1032,Ut=1033,Bt=33776,zt=33777,Gt=33778,jt=33779,Vt=35840,Ht=35841,Wt=35842,qt=35843,Xt=36196,Yt=37492,Zt=37496,Kt=37808,Jt=37809,Qt=37810,$t=37811,te=37812,ee=37813,re=37814,ne=37815,ie=37816,ae=37817,oe=37818,se=37819,le=37820,ue=37821,ce=36492,he=37840,de=37841,fe=37842,pe=37843,me=37844,ge=37845,ve=37846,ye=37847,xe=37848,_e=37849,we=37850,be=37851,Me=37852,Se=37853,Te=2300,Ee=2301,Ae=2302,Pe=2400,Re=2401,Ce=2402,Ie=2500,Le=2501,Oe=3e3,De=3001,ke=3007,Fe=3002,Ne=3004,Ue=3005,Be=3006,ze=3201,Ge=0,je=1,Ve=7680,He=35044,We=35048,qe="300 es";class Xe{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const r=this._listeners;void 0===r[t]&&(r[t]=[]),-1===r[t].indexOf(e)&&r[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const r=this._listeners;return void 0!==r[t]&&-1!==r[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const r=this._listeners[t];if(void 0!==r){const t=r.indexOf(e);-1!==t&&r.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const r=e.slice(0);for(let e=0,n=r.length;e>8&255]+Ye[t>>16&255]+Ye[t>>24&255]+"-"+Ye[255&e]+Ye[e>>8&255]+"-"+Ye[e>>16&15|64]+Ye[e>>24&255]+"-"+Ye[63&r|128]+Ye[r>>8&255]+"-"+Ye[r>>16&255]+Ye[r>>24&255]+Ye[255&n]+Ye[n>>8&255]+Ye[n>>16&255]+Ye[n>>24&255]).toUpperCase()}function $e(t,e,r){return Math.max(e,Math.min(r,t))}function tr(t,e){return(t%e+e)%e}function er(t,e,r){return(1-r)*t+r*e}function rr(t){return 0==(t&t-1)&&0!==t}function nr(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ir(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var ar=Object.freeze({__proto__:null,DEG2RAD:Ke,RAD2DEG:Je,generateUUID:Qe,clamp:$e,euclideanModulo:tr,mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},inverseLerp:function(t,e,r){return t!==e?(r-t)/(e-t):0},lerp:er,damp:function(t,e,r,n){return er(t,e,1-Math.exp(-r*n))},pingpong:function(t,e=1){return e-Math.abs(tr(t,2*e)-e)},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(Ze=t%2147483647),Ze=16807*Ze%2147483647,(Ze-1)/2147483646},degToRad:function(t){return t*Ke},radToDeg:function(t){return t*Je},isPowerOfTwo:rr,ceilPowerOfTwo:nr,floorPowerOfTwo:ir,setQuaternionFromProperEuler:function(t,e,r,n,i){const a=Math.cos,o=Math.sin,s=a(r/2),l=o(r/2),u=a((e+n)/2),c=o((e+n)/2),h=a((e-n)/2),d=o((e-n)/2),f=a((n-e)/2),p=o((n-e)/2);switch(i){case"XYX":t.set(s*c,l*h,l*d,s*u);break;case"YZY":t.set(l*d,s*c,l*h,s*u);break;case"ZXZ":t.set(l*h,l*d,s*c,s*u);break;case"XZX":t.set(s*c,l*p,l*f,s*u);break;case"YXY":t.set(l*f,s*c,l*p,s*u);break;case"ZYZ":t.set(l*p,l*f,s*c,s*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}});class or{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*r-a*n+t.x,this.y=i*n+a*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}or.prototype.isVector2=!0;class sr{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,r,n,i,a,o,s,l){const u=this.elements;return u[0]=t,u[1]=n,u[2]=o,u[3]=e,u[4]=i,u[5]=s,u[6]=r,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,a=r[0],o=r[3],s=r[6],l=r[1],u=r[4],c=r[7],h=r[2],d=r[5],f=r[8],p=n[0],m=n[3],g=n[6],v=n[1],y=n[4],x=n[7],_=n[2],w=n[5],b=n[8];return i[0]=a*p+o*v+s*_,i[3]=a*m+o*y+s*w,i[6]=a*g+o*x+s*b,i[1]=l*p+u*v+c*_,i[4]=l*m+u*y+c*w,i[7]=l*g+u*x+c*b,i[2]=h*p+d*v+f*_,i[5]=h*m+d*y+f*w,i[8]=h*g+d*x+f*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],u=t[8];return e*a*u-e*o*l-r*i*u+r*o*s+n*i*l-n*a*s}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],u=t[8],c=u*a-o*l,h=o*s-u*i,d=l*i-a*s,f=e*c+r*h+n*d;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const p=1/f;return t[0]=c*p,t[1]=(n*l-u*r)*p,t[2]=(o*r-n*a)*p,t[3]=h*p,t[4]=(u*e-n*s)*p,t[5]=(n*i-o*e)*p,t[6]=d*p,t[7]=(r*s-l*e)*p,t[8]=(a*e-r*i)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,n,i,a,o){const s=Math.cos(i),l=Math.sin(i);return this.set(r*s,r*l,-r*(s*a+l*o)+a+t,-n*l,n*s,-n*(-l*a+s*o)+o+e,0,0,1),this}scale(t,e){const r=this.elements;return r[0]*=t,r[3]*=t,r[6]*=t,r[1]*=e,r[4]*=e,r[7]*=e,this}rotate(t){const e=Math.cos(t),r=Math.sin(t),n=this.elements,i=n[0],a=n[3],o=n[6],s=n[1],l=n[4],u=n[7];return n[0]=e*i+r*s,n[3]=e*a+r*l,n[6]=e*o+r*u,n[1]=-r*i+e*s,n[4]=-r*a+e*l,n[7]=-r*o+e*u,this}translate(t,e){const r=this.elements;return r[0]+=t*r[2],r[3]+=t*r[5],r[6]+=t*r[8],r[1]+=e*r[2],r[4]+=e*r[5],r[7]+=e*r[8],this}equals(t){const e=this.elements,r=t.elements;for(let t=0;t<9;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}function lr(t){if(0===t.length)return-1/0;let e=t[0];for(let r=1,n=t.length;re&&(e=t[r]);return e}sr.prototype.isMatrix3=!0;const ur={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function cr(t,e){return new ur[t](e)}function hr(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function dr(t,e=0){let r=3735928559^e,n=1103547991^e;for(let e,i=0;i>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&n)+(r>>>0)}let fr;class pr{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===fr&&(fr=hr("canvas")),fr.width=t.width,fr.height=t.height;const r=fr.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),e=fr}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}}let mr=0;class gr extends Xe{constructor(t=gr.DEFAULT_IMAGE,e=gr.DEFAULT_MAPPING,r=at,n=at,i=ct,a=dt,o=At,s=ft,l=1,u=Oe){super(),Object.defineProperty(this,"id",{value:mr++}),this.uuid=Qe(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=r,this.wrapT=n,this.magFilter=i,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=s,this.offset=new or(0,0),this.repeat=new or(1,1),this.center=new or(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new sr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this.userData=JSON.parse(JSON.stringify(t.userData)),this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=Qe()),!e&&void 0===t.images[n.uuid]){let e;if(Array.isArray(n)){e=[];for(let t=0,r=n.length;t1)switch(this.wrapS){case it:t.x=t.x-Math.floor(t.x);break;case at:t.x=t.x<0?0:1;break;case ot:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case it:t.y=t.y-Math.floor(t.y);break;case at:t.y=t.y<0?0:1;break;case ot:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function vr(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?pr.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}gr.DEFAULT_IMAGE=void 0,gr.DEFAULT_MAPPING=J,gr.prototype.isTexture=!0;class yr{constructor(t=0,e=0,r=0,n=1){this.x=t,this.y=e,this.z=r,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*r+a[8]*n+a[12]*i,this.y=a[1]*e+a[5]*r+a[9]*n+a[13]*i,this.z=a[2]*e+a[6]*r+a[10]*n+a[14]*i,this.w=a[3]*e+a[7]*r+a[11]*n+a[15]*i,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,n,i;const a=.01,o=.1,s=t.elements,l=s[0],u=s[4],c=s[8],h=s[1],d=s[5],f=s[9],p=s[2],m=s[6],g=s[10];if(Math.abs(u-h)s&&t>v?tv?s=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const i=Math.sqrt(n),a=Math.atan2(i,e*r);t=Math.sin(t*a)/i,o=Math.sin(o*a)/i}const i=o*r;if(s=s*t+h*i,l=l*t+d*i,u=u*t+f*i,c=c*t+p*i,t===1-o){const t=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=t,l*=t,u*=t,c*=t}}t[e]=s,t[e+1]=l,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,r,n,i,a){const o=r[n],s=r[n+1],l=r[n+2],u=r[n+3],c=i[a],h=i[a+1],d=i[a+2],f=i[a+3];return t[e]=o*f+u*c+s*d-l*h,t[e+1]=s*f+u*h+l*c-o*d,t[e+2]=l*f+u*d+o*h-s*c,t[e+3]=u*f-o*c-s*h-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const r=t._x,n=t._y,i=t._z,a=t._order,o=Math.cos,s=Math.sin,l=o(r/2),u=o(n/2),c=o(i/2),h=s(r/2),d=s(n/2),f=s(i/2);switch(a){case"XYZ":this._x=h*u*c+l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c-h*d*f;break;case"YXZ":this._x=h*u*c+l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c+h*d*f;break;case"ZXY":this._x=h*u*c-l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c-h*d*f;break;case"ZYX":this._x=h*u*c-l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c+h*d*f;break;case"YZX":this._x=h*u*c+l*d*f,this._y=l*d*c+h*u*f,this._z=l*u*f-h*d*c,this._w=l*u*c-h*d*f;break;case"XZY":this._x=h*u*c-l*d*f,this._y=l*d*c-h*u*f,this._z=l*u*f+h*d*c,this._w=l*u*c+h*d*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],n=e[4],i=e[8],a=e[1],o=e[5],s=e[9],l=e[2],u=e[6],c=e[10],h=r+o+c;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(u-s)*t,this._y=(i-l)*t,this._z=(a-n)*t}else if(r>o&&r>c){const t=2*Math.sqrt(1+r-o-c);this._w=(u-s)/t,this._x=.25*t,this._y=(n+a)/t,this._z=(i+l)/t}else if(o>c){const t=2*Math.sqrt(1+o-r-c);this._w=(i-l)/t,this._x=(n+a)/t,this._y=.25*t,this._z=(s+u)/t}else{const t=2*Math.sqrt(1+c-r-o);this._w=(a-n)/t,this._x=(i+l)/t,this._y=(s+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return rMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs($e(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(0===r)return this;const n=Math.min(1,e/r);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const r=t._x,n=t._y,i=t._z,a=t._w,o=e._x,s=e._y,l=e._z,u=e._w;return this._x=r*u+a*o+n*l-i*s,this._y=n*u+a*s+i*o-r*l,this._z=i*u+a*l+r*s-n*o,this._w=a*u-r*o-n*s-i*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const r=this._x,n=this._y,i=this._z,a=this._w;let o=a*t._w+r*t._x+n*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=r,this._y=n,this._z=i,this;const s=1-o*o;if(s<=Number.EPSILON){const t=1-e;return this._w=t*a+e*this._w,this._x=t*r+e*this._x,this._y=t*n+e*this._y,this._z=t*i+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),u=Math.atan2(l,o),c=Math.sin((1-e)*u)/l,h=Math.sin(e*u)/l;return this._w=a*c+this._w*h,this._x=r*c+this._x*h,this._y=n*c+this._y*h,this._z=i*c+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,r){this.copy(t).slerp(e,r)}random(){const t=Math.random(),e=Math.sqrt(1-t),r=Math.sqrt(t),n=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(e*Math.cos(n),r*Math.sin(i),r*Math.cos(i),e*Math.sin(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}br.prototype.isQuaternion=!0;class Mr{constructor(t=0,e=0,r=0){this.x=t,this.y=e,this.z=r}set(t,e,r){return void 0===r&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Tr.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Tr.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=t.elements,a=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*a,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*a,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*a,this}applyQuaternion(t){const e=this.x,r=this.y,n=this.z,i=t.x,a=t.y,o=t.z,s=t.w,l=s*e+a*n-o*r,u=s*r+o*e-i*n,c=s*n+i*r-a*e,h=-i*e-a*r-o*n;return this.x=l*s+h*-i+u*-o-c*-a,this.y=u*s+h*-a+c*-i-l*-o,this.z=c*s+h*-o+l*-a-u*-i,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,n=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=n*s-i*o,this.y=i*a-r*s,this.z=r*o-n*a,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Sr.copy(this).projectOnVector(t),this.sub(Sr)}reflect(t){return this.sub(Sr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const r=this.dot(t)/e;return Math.acos($e(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){const n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,r=Math.sqrt(1-t**2);return this.x=r*Math.cos(e),this.y=r*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Mr.prototype.isVector3=!0;const Sr=new Mr,Tr=new br;class Er{constructor(t=new Mr(1/0,1/0,1/0),e=new Mr(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,l=t.length;si&&(i=l),u>a&&(a=u),c>o&&(o=c)}return this.min.set(e,r,n),this.max.set(i,a,o),this}setFromBufferAttribute(t){let e=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,l=t.count;si&&(i=l),u>a&&(a=u),c>o&&(o=c)}return this.min.set(e,r,n),this.max.set(i,a,o),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Pr),Pr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Fr),Nr.subVectors(this.max,Fr),Cr.subVectors(t.a,Fr),Ir.subVectors(t.b,Fr),Lr.subVectors(t.c,Fr),Or.subVectors(Ir,Cr),Dr.subVectors(Lr,Ir),kr.subVectors(Cr,Lr);let e=[0,-Or.z,Or.y,0,-Dr.z,Dr.y,0,-kr.z,kr.y,Or.z,0,-Or.x,Dr.z,0,-Dr.x,kr.z,0,-kr.x,-Or.y,Or.x,0,-Dr.y,Dr.x,0,-kr.y,kr.x,0];return!!zr(e,Cr,Ir,Lr,Nr)&&(e=[1,0,0,0,1,0,0,0,1],!!zr(e,Cr,Ir,Lr,Nr)&&(Ur.crossVectors(Or,Dr),e=[Ur.x,Ur.y,Ur.z],zr(e,Cr,Ir,Lr,Nr)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Pr.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(Pr).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Ar[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ar[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ar[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ar[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ar[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ar[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ar[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ar[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ar)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Er.prototype.isBox3=!0;const Ar=[new Mr,new Mr,new Mr,new Mr,new Mr,new Mr,new Mr,new Mr],Pr=new Mr,Rr=new Er,Cr=new Mr,Ir=new Mr,Lr=new Mr,Or=new Mr,Dr=new Mr,kr=new Mr,Fr=new Mr,Nr=new Mr,Ur=new Mr,Br=new Mr;function zr(t,e,r,n,i){for(let a=0,o=t.length-3;a<=o;a+=3){Br.fromArray(t,a);const o=i.x*Math.abs(Br.x)+i.y*Math.abs(Br.y)+i.z*Math.abs(Br.z),s=e.dot(Br),l=r.dot(Br),u=n.dot(Br);if(Math.max(-Math.max(s,l,u),Math.min(s,l,u))>o)return!1}return!0}const Gr=new Er,jr=new Mr,Vr=new Mr,Hr=new Mr;class Wr{constructor(t=new Mr,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const r=this.center;void 0!==e?r.copy(e):Gr.setFromPoints(t).getCenter(r);let n=0;for(let e=0,i=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){Hr.subVectors(t,this.center);const e=Hr.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),r=.5*(t-this.radius);this.center.add(Hr.multiplyScalar(r/t)),this.radius+=r}return this}union(t){return Vr.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(jr.copy(t.center).add(Vr)),this.expandByPoint(jr.copy(t.center).sub(Vr)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const qr=new Mr,Xr=new Mr,Yr=new Mr,Zr=new Mr,Kr=new Mr,Jr=new Mr,Qr=new Mr;class $r{constructor(t=new Mr,e=new Mr(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,qr)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=qr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(qr.copy(this.direction).multiplyScalar(e).add(this.origin),qr.distanceToSquared(t))}distanceSqToSegment(t,e,r,n){Xr.copy(t).add(e).multiplyScalar(.5),Yr.copy(e).sub(t).normalize(),Zr.copy(this.origin).sub(Xr);const i=.5*t.distanceTo(e),a=-this.direction.dot(Yr),o=Zr.dot(this.direction),s=-Zr.dot(Yr),l=Zr.lengthSq(),u=Math.abs(1-a*a);let c,h,d,f;if(u>0)if(c=a*s-o,h=a*o-s,f=i*u,c>=0)if(h>=-f)if(h<=f){const t=1/u;c*=t,h*=t,d=c*(c+a*h+2*o)+h*(a*c+h+2*s)+l}else h=i,c=Math.max(0,-(a*h+o)),d=-c*c+h*(h+2*s)+l;else h=-i,c=Math.max(0,-(a*h+o)),d=-c*c+h*(h+2*s)+l;else h<=-f?(c=Math.max(0,-(-a*i+o)),h=c>0?-i:Math.min(Math.max(-i,-s),i),d=-c*c+h*(h+2*s)+l):h<=f?(c=0,h=Math.min(Math.max(-i,-s),i),d=h*(h+2*s)+l):(c=Math.max(0,-(a*i+o)),h=c>0?i:Math.min(Math.max(-i,-s),i),d=-c*c+h*(h+2*s)+l);else h=a>0?-i:i,c=Math.max(0,-(a*h+o)),d=-c*c+h*(h+2*s)+l;return r&&r.copy(this.direction).multiplyScalar(c).add(this.origin),n&&n.copy(Yr).multiplyScalar(h).add(Xr),d}intersectSphere(t,e){qr.subVectors(t.center,this.origin);const r=qr.dot(this.direction),n=qr.dot(qr)-r*r,i=t.radius*t.radius;if(n>i)return null;const a=Math.sqrt(i-n),o=r-a,s=r+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){const r=this.distanceToPlane(t);return null===r?null:this.at(r,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,n,i,a,o,s;const l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(r=(t.min.x-h.x)*l,n=(t.max.x-h.x)*l):(r=(t.max.x-h.x)*l,n=(t.min.x-h.x)*l),u>=0?(i=(t.min.y-h.y)*u,a=(t.max.y-h.y)*u):(i=(t.max.y-h.y)*u,a=(t.min.y-h.y)*u),r>a||i>n?null:((i>r||r!=r)&&(r=i),(a=0?(o=(t.min.z-h.z)*c,s=(t.max.z-h.z)*c):(o=(t.max.z-h.z)*c,s=(t.min.z-h.z)*c),r>s||o>n?null:((o>r||r!=r)&&(r=o),(s=0?r:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,qr)}intersectTriangle(t,e,r,n,i){Kr.subVectors(e,t),Jr.subVectors(r,t),Qr.crossVectors(Kr,Jr);let a,o=this.direction.dot(Qr);if(o>0){if(n)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Zr.subVectors(this.origin,t);const s=a*this.direction.dot(Jr.crossVectors(Zr,Jr));if(s<0)return null;const l=a*this.direction.dot(Kr.cross(Zr));if(l<0)return null;if(s+l>o)return null;const u=-a*Zr.dot(Qr);return u<0?null:this.at(u/o,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class tn{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,r,n,i,a,o,s,l,u,c,h,d,f,p,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=d,g[7]=f,g[11]=p,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new tn).fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,r=t.elements,n=1/en.setFromMatrixColumn(t,0).length(),i=1/en.setFromMatrixColumn(t,1).length(),a=1/en.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=0,e[8]=r[8]*a,e[9]=r[9]*a,e[10]=r[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,r=t.x,n=t.y,i=t.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(n),l=Math.sin(n),u=Math.cos(i),c=Math.sin(i);if("XYZ"===t.order){const t=a*u,r=a*c,n=o*u,i=o*c;e[0]=s*u,e[4]=-s*c,e[8]=l,e[1]=r+n*l,e[5]=t-i*l,e[9]=-o*s,e[2]=i-t*l,e[6]=n+r*l,e[10]=a*s}else if("YXZ"===t.order){const t=s*u,r=s*c,n=l*u,i=l*c;e[0]=t+i*o,e[4]=n*o-r,e[8]=a*l,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=r*o-n,e[6]=i+t*o,e[10]=a*s}else if("ZXY"===t.order){const t=s*u,r=s*c,n=l*u,i=l*c;e[0]=t-i*o,e[4]=-a*c,e[8]=n+r*o,e[1]=r+n*o,e[5]=a*u,e[9]=i-t*o,e[2]=-a*l,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){const t=a*u,r=a*c,n=o*u,i=o*c;e[0]=s*u,e[4]=n*l-r,e[8]=t*l+i,e[1]=s*c,e[5]=i*l+t,e[9]=r*l-n,e[2]=-l,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){const t=a*s,r=a*l,n=o*s,i=o*l;e[0]=s*u,e[4]=i-t*c,e[8]=n*c+r,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-l*u,e[6]=r*c+n,e[10]=t-i*c}else if("XZY"===t.order){const t=a*s,r=a*l,n=o*s,i=o*l;e[0]=s*u,e[4]=-c,e[8]=l*u,e[1]=t*c+i,e[5]=a*u,e[9]=r*c-n,e[2]=n*c-r,e[6]=o*u,e[10]=i*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(nn,t,an)}lookAt(t,e,r){const n=this.elements;return ln.subVectors(t,e),0===ln.lengthSq()&&(ln.z=1),ln.normalize(),on.crossVectors(r,ln),0===on.lengthSq()&&(1===Math.abs(r.z)?ln.x+=1e-4:ln.z+=1e-4,ln.normalize(),on.crossVectors(r,ln)),on.normalize(),sn.crossVectors(ln,on),n[0]=on.x,n[4]=sn.x,n[8]=ln.x,n[1]=on.y,n[5]=sn.y,n[9]=ln.y,n[2]=on.z,n[6]=sn.z,n[10]=ln.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,a=r[0],o=r[4],s=r[8],l=r[12],u=r[1],c=r[5],h=r[9],d=r[13],f=r[2],p=r[6],m=r[10],g=r[14],v=r[3],y=r[7],x=r[11],_=r[15],w=n[0],b=n[4],M=n[8],S=n[12],T=n[1],E=n[5],A=n[9],P=n[13],R=n[2],C=n[6],I=n[10],L=n[14],O=n[3],D=n[7],k=n[11],F=n[15];return i[0]=a*w+o*T+s*R+l*O,i[4]=a*b+o*E+s*C+l*D,i[8]=a*M+o*A+s*I+l*k,i[12]=a*S+o*P+s*L+l*F,i[1]=u*w+c*T+h*R+d*O,i[5]=u*b+c*E+h*C+d*D,i[9]=u*M+c*A+h*I+d*k,i[13]=u*S+c*P+h*L+d*F,i[2]=f*w+p*T+m*R+g*O,i[6]=f*b+p*E+m*C+g*D,i[10]=f*M+p*A+m*I+g*k,i[14]=f*S+p*P+m*L+g*F,i[3]=v*w+y*T+x*R+_*O,i[7]=v*b+y*E+x*C+_*D,i[11]=v*M+y*A+x*I+_*k,i[15]=v*S+y*P+x*L+_*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[4],n=t[8],i=t[12],a=t[1],o=t[5],s=t[9],l=t[13],u=t[2],c=t[6],h=t[10],d=t[14];return t[3]*(+i*s*c-n*l*c-i*o*h+r*l*h+n*o*d-r*s*d)+t[7]*(+e*s*d-e*l*h+i*a*h-n*a*d+n*l*u-i*s*u)+t[11]*(+e*l*c-e*o*d-i*a*c+r*a*d+i*o*u-r*l*u)+t[15]*(-n*o*u-e*s*c+e*o*h+n*a*c-r*a*h+r*s*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11],f=t[12],p=t[13],m=t[14],g=t[15],v=c*m*l-p*h*l+p*s*d-o*m*d-c*s*g+o*h*g,y=f*h*l-u*m*l-f*s*d+a*m*d+u*s*g-a*h*g,x=u*p*l-f*c*l+f*o*d-a*p*d-u*o*g+a*c*g,_=f*c*s-u*p*s-f*o*h+a*p*h+u*o*m-a*c*m,w=e*v+r*y+n*x+i*_;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/w;return t[0]=v*b,t[1]=(p*h*i-c*m*i-p*n*d+r*m*d+c*n*g-r*h*g)*b,t[2]=(o*m*i-p*s*i+p*n*l-r*m*l-o*n*g+r*s*g)*b,t[3]=(c*s*i-o*h*i-c*n*l+r*h*l+o*n*d-r*s*d)*b,t[4]=y*b,t[5]=(u*m*i-f*h*i+f*n*d-e*m*d-u*n*g+e*h*g)*b,t[6]=(f*s*i-a*m*i-f*n*l+e*m*l+a*n*g-e*s*g)*b,t[7]=(a*h*i-u*s*i+u*n*l-e*h*l-a*n*d+e*s*d)*b,t[8]=x*b,t[9]=(f*c*i-u*p*i-f*r*d+e*p*d+u*r*g-e*c*g)*b,t[10]=(a*p*i-f*o*i+f*r*l-e*p*l-a*r*g+e*o*g)*b,t[11]=(u*o*i-a*c*i-u*r*l+e*c*l+a*r*d-e*o*d)*b,t[12]=_*b,t[13]=(u*p*n-f*c*n+f*r*h-e*p*h-u*r*m+e*c*m)*b,t[14]=(f*o*n-a*p*n-f*r*s+e*p*s+a*r*m-e*o*m)*b,t[15]=(a*c*n-u*o*n+u*r*s-e*c*s-a*r*h+e*o*h)*b,this}scale(t){const e=this.elements,r=t.x,n=t.y,i=t.z;return e[0]*=r,e[4]*=n,e[8]*=i,e[1]*=r,e[5]*=n,e[9]*=i,e[2]*=r,e[6]*=n,e[10]*=i,e[3]*=r,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}makeTranslation(t,e,r){return this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),n=Math.sin(e),i=1-r,a=t.x,o=t.y,s=t.z,l=i*a,u=i*o;return this.set(l*a+r,l*o-n*s,l*s+n*o,0,l*o+n*s,u*o+r,u*s-n*a,0,l*s-n*o,u*s+n*a,i*s*s+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,n,i,a){return this.set(1,r,i,0,t,1,a,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){const n=this.elements,i=e._x,a=e._y,o=e._z,s=e._w,l=i+i,u=a+a,c=o+o,h=i*l,d=i*u,f=i*c,p=a*u,m=a*c,g=o*c,v=s*l,y=s*u,x=s*c,_=r.x,w=r.y,b=r.z;return n[0]=(1-(p+g))*_,n[1]=(d+x)*_,n[2]=(f-y)*_,n[3]=0,n[4]=(d-x)*w,n[5]=(1-(h+g))*w,n[6]=(m+v)*w,n[7]=0,n[8]=(f+y)*b,n[9]=(m-v)*b,n[10]=(1-(h+p))*b,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){const n=this.elements;let i=en.set(n[0],n[1],n[2]).length();const a=en.set(n[4],n[5],n[6]).length(),o=en.set(n[8],n[9],n[10]).length();this.determinant()<0&&(i=-i),t.x=n[12],t.y=n[13],t.z=n[14],rn.copy(this);const s=1/i,l=1/a,u=1/o;return rn.elements[0]*=s,rn.elements[1]*=s,rn.elements[2]*=s,rn.elements[4]*=l,rn.elements[5]*=l,rn.elements[6]*=l,rn.elements[8]*=u,rn.elements[9]*=u,rn.elements[10]*=u,e.setFromRotationMatrix(rn),r.x=i,r.y=a,r.z=o,this}makePerspective(t,e,r,n,i,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,s=2*i/(e-t),l=2*i/(r-n),u=(e+t)/(e-t),c=(r+n)/(r-n),h=-(a+i)/(a-i),d=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=l,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,r,n,i,a){const o=this.elements,s=1/(e-t),l=1/(r-n),u=1/(a-i),c=(e+t)*s,h=(r+n)*l,d=(a+i)*u;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-c,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,r=t.elements;for(let t=0;t<16;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}tn.prototype.isMatrix4=!0;const en=new Mr,rn=new tn,nn=new Mr(0,0,0),an=new Mr(1,1,1),on=new Mr,sn=new Mr,ln=new Mr,un=new tn,cn=new br;class hn{constructor(t=0,e=0,r=0,n=hn.DefaultOrder){this._x=t,this._y=e,this._z=r,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){const n=t.elements,i=n[0],a=n[4],o=n[8],s=n[1],l=n[5],u=n[9],c=n[2],h=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin($e(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-$e(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin($e(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-$e(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin($e(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-$e(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===r&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return un.makeRotationFromQuaternion(t),this.setFromRotationMatrix(un,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return cn.setFromEuler(this),this.setFromQuaternion(cn,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new Mr(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}hn.prototype.isEuler=!0,hn.DefaultOrder="XYZ",hn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class dn{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0){n.children=[];for(let e=0;e0){n.animations=[];for(let e=0;e0&&(r.geometries=e),n.length>0&&(r.materials=n),i.length>0&&(r.textures=i),o.length>0&&(r.images=o),s.length>0&&(r.shapes=s),l.length>0&&(r.skeletons=l),u.length>0&&(r.animations=u)}return r.object=n,r;function a(t){const e=[];for(const r in t){const n=t[r];delete n.metadata,e.push(n)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?n.multiplyScalar(1/Math.sqrt(i)):n.set(0,0,0)}static getBarycoord(t,e,r,n,i){An.subVectors(n,e),Pn.subVectors(r,e),Rn.subVectors(t,e);const a=An.dot(An),o=An.dot(Pn),s=An.dot(Rn),l=Pn.dot(Pn),u=Pn.dot(Rn),c=a*l-o*o;if(0===c)return i.set(-2,-1,-1);const h=1/c,d=(l*s-o*u)*h,f=(a*u-o*s)*h;return i.set(1-d-f,f,d)}static containsPoint(t,e,r,n){return this.getBarycoord(t,e,r,n,Cn),Cn.x>=0&&Cn.y>=0&&Cn.x+Cn.y<=1}static getUV(t,e,r,n,i,a,o,s){return this.getBarycoord(t,e,r,n,Cn),s.set(0,0),s.addScaledVector(i,Cn.x),s.addScaledVector(a,Cn.y),s.addScaledVector(o,Cn.z),s}static isFrontFacing(t,e,r,n){return An.subVectors(r,e),Pn.subVectors(t,e),An.cross(Pn).dot(n)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,r,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return An.subVectors(this.c,this.b),Pn.subVectors(this.a,this.b),.5*An.cross(Pn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Nn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Nn.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,r,n,i){return Nn.getUV(t,this.a,this.b,this.c,e,r,n,i)}containsPoint(t){return Nn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Nn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const r=this.a,n=this.b,i=this.c;let a,o;In.subVectors(n,r),Ln.subVectors(i,r),Dn.subVectors(t,r);const s=In.dot(Dn),l=Ln.dot(Dn);if(s<=0&&l<=0)return e.copy(r);kn.subVectors(t,n);const u=In.dot(kn),c=Ln.dot(kn);if(u>=0&&c<=u)return e.copy(n);const h=s*c-u*l;if(h<=0&&s>=0&&u<=0)return a=s/(s-u),e.copy(r).addScaledVector(In,a);Fn.subVectors(t,i);const d=In.dot(Fn),f=Ln.dot(Fn);if(f>=0&&d<=f)return e.copy(i);const p=d*l-s*f;if(p<=0&&l>=0&&f<=0)return o=l/(l-f),e.copy(r).addScaledVector(Ln,o);const m=u*f-d*c;if(m<=0&&c-u>=0&&d-f>=0)return On.subVectors(i,n),o=(c-u)/(c-u+(d-f)),e.copy(n).addScaledVector(On,o);const g=1/(m+p+h);return a=p*g,o=h*g,e.copy(r).addScaledVector(In,a).addScaledVector(Ln,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Un=0;class Bn extends Xe{constructor(){super(),Object.defineProperty(this,"id",{value:Un++}),this.uuid=Qe(),this.name="",this.type="Material",this.fog=!0,this.blending=f,this.side=u,this.vertexColors=!1,this.opacity=1,this.format=At,this.transparent=!1,this.blendSrc=A,this.blendDst=P,this.blendEquation=y,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=N,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ve,this.stencilZFail=Ve,this.stencilZPass=Ve,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const r=t[e];if(void 0===r){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===r;continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]=r:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const r in t){const n=t[r];delete n.metadata,e.push(n)}return e}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(r.combine=this.combine)),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==f&&(r.blending=this.blending),this.side!==u&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.format!==At&&(r.format=this.format),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(r.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=this.flatShading),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),e){const e=n(t.textures),i=n(t.images);e.length>0&&(r.textures=e),i.length>0&&(r.images=i)}return r}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.format=t.format,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let r=null;if(null!==e){const t=e.length;r=new Array(t);for(let n=0;n!==t;++n)r[n]=e[n].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}Bn.prototype.isMaterial=!0;const zn={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},Gn={h:0,s:0,l:0},jn={h:0,s:0,l:0};function Vn(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}function Hn(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Wn(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class qn{constructor(t,e,r){return void 0===e&&void 0===r?this.set(t):this.setRGB(t,e,r)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,r){return this.r=t,this.g=e,this.b=r,this}setHSL(t,e,r){if(t=tr(t,1),e=$e(e,0,1),r=$e(r,0,1),0===e)this.r=this.g=this.b=r;else{const n=r<=.5?r*(1+e):r+e-r*e,i=2*r-n;this.r=Vn(i,n,t+1/3),this.g=Vn(i,n,t),this.b=Vn(i,n,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const n=r[1],i=r[2];switch(n){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const r=parseFloat(t[1])/360,n=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(r,n,i)}}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=r[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=zn[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Hn(t.r),this.g=Hn(t.g),this.b=Hn(t.b),this}copyLinearToSRGB(t){return this.r=Wn(t.r),this.g=Wn(t.g),this.b=Wn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){const e=this.r,r=this.g,n=this.b,i=Math.max(e,r,n),a=Math.min(e,r,n);let o,s;const l=(a+i)/2;if(a===i)o=0,s=0;else{const t=i-a;switch(s=l<=.5?t/(i+a):t/(2-i-a),i){case e:o=(r-n)/t+(r65535?ni:ei)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const r=this.attributes.normal;if(void 0!==r){const e=(new sr).getNormalMatrix(t);r.applyNormalMatrix(e),r.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return li.makeRotationFromQuaternion(t),this.applyMatrix4(li),this}rotateX(t){return li.makeRotationX(t),this.applyMatrix4(li),this}rotateY(t){return li.makeRotationY(t),this.applyMatrix4(li),this}rotateZ(t){return li.makeRotationZ(t),this.applyMatrix4(li),this}translate(t,e,r){return li.makeTranslation(t,e,r),this.applyMatrix4(li),this}scale(t,e,r){return li.makeScale(t,e,r),this.applyMatrix4(li),this}lookAt(t){return ui.lookAt(t),ui.updateMatrix(),this.applyMatrix4(ui.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ci).negate(),this.translate(ci.x,ci.y,ci.z),this}setFromPoints(t){const e=[];for(let r=0,n=t.length;r0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const r in e)void 0!==e[r]&&(t[r]=e[r]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const r=this.attributes;for(const e in r){const n=r[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let i=!1;for(const e in this.morphAttributes){const r=this.morphAttributes[e],a=[];for(let e=0,n=r.length;e0&&(n[e]=a,i=!0)}i&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const r=t.index;null!==r&&this.setIndex(r.clone(e));const n=t.attributes;for(const t in n){const r=n[t];this.setAttribute(t,r.clone(e))}const i=t.morphAttributes;for(const t in i){const r=[],n=i[t];for(let t=0,i=n.length;t0){const t=e[r[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,r=t.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const r=this.geometry,n=this.material,i=this.matrixWorld;if(void 0===n)return;if(null===r.boundingSphere&&r.computeBoundingSphere(),vi.copy(r.boundingSphere),vi.applyMatrix4(i),!1===t.ray.intersectsSphere(vi))return;if(mi.copy(i).invert(),gi.copy(t.ray).applyMatrix4(mi),null!==r.boundingBox&&!1===gi.intersectsBox(r.boundingBox))return;let a;if(r.isBufferGeometry){const i=r.index,o=r.attributes.position,s=r.morphAttributes.position,l=r.morphTargetsRelative,u=r.attributes.uv,c=r.attributes.uv2,h=r.groups,d=r.drawRange;if(null!==i)if(Array.isArray(n))for(let r=0,f=h.length;rr.far?null:{distance:u,point:Ii.clone(),object:t}}(t,e,r,n,yi,xi,_i,Ci);if(m){s&&(Ai.fromBufferAttribute(s,u),Pi.fromBufferAttribute(s,d),Ri.fromBufferAttribute(s,f),m.uv=Nn.getUV(Ci,yi,xi,_i,Ai,Pi,Ri,new or)),l&&(Ai.fromBufferAttribute(l,u),Pi.fromBufferAttribute(l,d),Ri.fromBufferAttribute(l,f),m.uv2=Nn.getUV(Ci,yi,xi,_i,Ai,Pi,Ri,new or));const t={a:u,b:d,c:f,normal:new Mr,materialIndex:0};Nn.getNormal(yi,xi,_i,t.normal),m.face=t}return m}Li.prototype.isMesh=!0;class Di extends pi{constructor(t=1,e=1,r=1,n=1,i=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:a};const o=this;n=Math.floor(n),i=Math.floor(i),a=Math.floor(a);const s=[],l=[],u=[],c=[];let h=0,d=0;function f(t,e,r,n,i,a,f,p,m,g,v){const y=a/m,x=f/g,_=a/2,w=f/2,b=p/2,M=m+1,S=g+1;let T=0,E=0;const A=new Mr;for(let a=0;a0?1:-1,u.push(A.x,A.y,A.z),c.push(s/m),c.push(1-a/g),T+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const r={};for(const t in this.extensions)!0===this.extensions[t]&&(r[t]=!0);return Object.keys(r).length>0&&(e.extensions=r),e}}Ui.prototype.isShaderMaterial=!0;let Bi=class extends En{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new tn,this.projectionMatrix=new tn,this.projectionMatrixInverse=new tn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}};Bi.prototype.isCamera=!0;class zi extends Bi{constructor(t=50,e=1,r=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=r,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Je*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Ke*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Je*Math.atan(Math.tan(.5*Ke*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,r,n,i,a){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=n,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Ke*this.fov)/this.zoom,r=2*e,n=this.aspect*r,i=-.5*n;const a=this.view;if(null!==this.view&&this.view.enabled){const t=a.fullWidth,o=a.fullHeight;i+=a.offsetX*n/t,e-=a.offsetY*r/o,n*=a.width/t,r*=a.height/o}const o=this.filmOffset;0!==o&&(i+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+n,e,e-r,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}zi.prototype.isPerspectiveCamera=!0;const Gi=90;class ji extends En{constructor(t,e,r){if(super(),this.type="CubeCamera",!0!==r.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=r;const n=new zi(Gi,1,t,e);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new Mr(1,0,0)),this.add(n);const i=new zi(Gi,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Mr(-1,0,0)),this.add(i);const a=new zi(Gi,1,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new Mr(0,1,0)),this.add(a);const o=new zi(Gi,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new Mr(0,-1,0)),this.add(o);const s=new zi(Gi,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new Mr(0,0,1)),this.add(s);const l=new zi(Gi,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Mr(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const r=this.renderTarget,[n,i,a,o,s,l]=this.children,u=t.xr.enabled,c=t.getRenderTarget();t.xr.enabled=!1;const h=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,n),t.setRenderTarget(r,1),t.render(e,i),t.setRenderTarget(r,2),t.render(e,a),t.setRenderTarget(r,3),t.render(e,o),t.setRenderTarget(r,4),t.render(e,s),r.texture.generateMipmaps=h,t.setRenderTarget(r,5),t.render(e,l),t.setRenderTarget(c),t.xr.enabled=u}}class Vi extends gr{constructor(t,e,r,n,i,a,o,s,l,u){super(t=void 0!==t?t:[],e=void 0!==e?e:Q,r,n,i,a,o,s,l,u),this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}Vi.prototype.isCubeTexture=!0;class Hi extends xr{constructor(t,e,r){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=r),super(t,t,e),e=e||{},this.texture=new Vi(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:ct,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=At,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new Di(5,5,5),i=new Ui({name:"CubemapFromEquirect",uniforms:ki(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:c,blending:d});i.uniforms.tEquirect.value=e;const a=new Li(n,i),o=e.minFilter;e.minFilter===dt&&(e.minFilter=ct);return new ji(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,r,n){const i=t.getRenderTarget();for(let i=0;i<6;i++)t.setRenderTarget(this,i),t.clear(e,r,n);t.setRenderTarget(i)}}Hi.prototype.isWebGLCubeRenderTarget=!0;const Wi=new Mr,qi=new Mr,Xi=new sr;class Yi{constructor(t=new Mr(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,r,n){return this.normal.set(t,e,r),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,r){const n=Wi.subVectors(r,e).cross(qi.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const r=t.delta(Wi),n=this.normal.dot(r);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/n;return i<0||i>1?null:e.copy(r).multiplyScalar(i).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const r=e||Xi.getNormalMatrix(t),n=this.coplanarPoint(Wi).applyMatrix4(t),i=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}Yi.prototype.isPlane=!0;const Zi=new Wr,Ki=new Mr;class Ji{constructor(t=new Yi,e=new Yi,r=new Yi,n=new Yi,i=new Yi,a=new Yi){this.planes=[t,e,r,n,i,a]}set(t,e,r,n,i,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(r),o[3].copy(n),o[4].copy(i),o[5].copy(a),this}copy(t){const e=this.planes;for(let r=0;r<6;r++)e[r].copy(t.planes[r]);return this}setFromProjectionMatrix(t){const e=this.planes,r=t.elements,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],u=r[6],c=r[7],h=r[8],d=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(o-n,c-s,p-h,y-m).normalize(),e[1].setComponents(o+n,c+s,p+h,y+m).normalize(),e[2].setComponents(o+i,c+l,p+d,y+g).normalize(),e[3].setComponents(o-i,c-l,p-d,y-g).normalize(),e[4].setComponents(o-a,c-u,p-f,y-v).normalize(),e[5].setComponents(o+a,c+u,p+f,y+v).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),Zi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Zi)}intersectsSprite(t){return Zi.center.set(0,0,0),Zi.radius=.7071067811865476,Zi.applyMatrix4(t.matrixWorld),this.intersectsSphere(Zi)}intersectsSphere(t){const e=this.planes,r=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(r)0?t.max.x:t.min.x,Ki.y=n.normal.y>0?t.max.y:t.min.y,Ki.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Ki)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Qi(){let t=null,e=!1,r=null,n=null;function i(e,a){r(e,a),n=t.requestAnimationFrame(i)}return{start:function(){!0!==e&&null!==r&&(n=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){r=t},setContext:function(e){t=e}}}function $i(t,e){const r=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const r=n.get(e);r&&(t.deleteBuffer(r.buffer),n.delete(e))},update:function(e,i){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},ra={common:{diffuse:{value:new qn(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new sr},uv2Transform:{value:new sr},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},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 or(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 qn(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 qn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new sr}},sprite:{diffuse:{value:new qn(16777215)},opacity:{value:1},center:{value:new or(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new sr}}},na={basic:{uniforms:Fi([ra.common,ra.specularmap,ra.envmap,ra.aomap,ra.lightmap,ra.fog]),vertexShader:ea.meshbasic_vert,fragmentShader:ea.meshbasic_frag},lambert:{uniforms:Fi([ra.common,ra.specularmap,ra.envmap,ra.aomap,ra.lightmap,ra.emissivemap,ra.fog,ra.lights,{emissive:{value:new qn(0)}}]),vertexShader:ea.meshlambert_vert,fragmentShader:ea.meshlambert_frag},phong:{uniforms:Fi([ra.common,ra.specularmap,ra.envmap,ra.aomap,ra.lightmap,ra.emissivemap,ra.bumpmap,ra.normalmap,ra.displacementmap,ra.fog,ra.lights,{emissive:{value:new qn(0)},specular:{value:new qn(1118481)},shininess:{value:30}}]),vertexShader:ea.meshphong_vert,fragmentShader:ea.meshphong_frag},standard:{uniforms:Fi([ra.common,ra.envmap,ra.aomap,ra.lightmap,ra.emissivemap,ra.bumpmap,ra.normalmap,ra.displacementmap,ra.roughnessmap,ra.metalnessmap,ra.fog,ra.lights,{emissive:{value:new qn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ea.meshphysical_vert,fragmentShader:ea.meshphysical_frag},toon:{uniforms:Fi([ra.common,ra.aomap,ra.lightmap,ra.emissivemap,ra.bumpmap,ra.normalmap,ra.displacementmap,ra.gradientmap,ra.fog,ra.lights,{emissive:{value:new qn(0)}}]),vertexShader:ea.meshtoon_vert,fragmentShader:ea.meshtoon_frag},matcap:{uniforms:Fi([ra.common,ra.bumpmap,ra.normalmap,ra.displacementmap,ra.fog,{matcap:{value:null}}]),vertexShader:ea.meshmatcap_vert,fragmentShader:ea.meshmatcap_frag},points:{uniforms:Fi([ra.points,ra.fog]),vertexShader:ea.points_vert,fragmentShader:ea.points_frag},dashed:{uniforms:Fi([ra.common,ra.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ea.linedashed_vert,fragmentShader:ea.linedashed_frag},depth:{uniforms:Fi([ra.common,ra.displacementmap]),vertexShader:ea.depth_vert,fragmentShader:ea.depth_frag},normal:{uniforms:Fi([ra.common,ra.bumpmap,ra.normalmap,ra.displacementmap,{opacity:{value:1}}]),vertexShader:ea.meshnormal_vert,fragmentShader:ea.meshnormal_frag},sprite:{uniforms:Fi([ra.sprite,ra.fog]),vertexShader:ea.sprite_vert,fragmentShader:ea.sprite_frag},background:{uniforms:{uvTransform:{value:new sr},t2D:{value:null}},vertexShader:ea.background_vert,fragmentShader:ea.background_frag},cube:{uniforms:Fi([ra.envmap,{opacity:{value:1}}]),vertexShader:ea.cube_vert,fragmentShader:ea.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ea.equirect_vert,fragmentShader:ea.equirect_frag},distanceRGBA:{uniforms:Fi([ra.common,ra.displacementmap,{referencePosition:{value:new Mr},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ea.distanceRGBA_vert,fragmentShader:ea.distanceRGBA_frag},shadow:{uniforms:Fi([ra.lights,ra.fog,{color:{value:new qn(0)},opacity:{value:1}}]),vertexShader:ea.shadow_vert,fragmentShader:ea.shadow_frag}};function ia(t,e,r,n,i){const a=new qn(0);let o,s,l=0,h=null,d=0,f=null;function p(t,e){r.buffers.color.setClear(t.r,t.g,t.b,e,i)}return{getClearColor:function(){return a},setClearColor:function(t,e=1){a.set(t),l=e,p(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(t){l=t,p(a,l)},render:function(r,i){let m=!1,g=!0===i.isScene?i.background:null;g&&g.isTexture&&(g=e.get(g));const v=t.xr,y=v.getSession&&v.getSession();y&&"additive"===y.environmentBlendMode&&(g=null),null===g?p(a,l):g&&g.isColor&&(p(g,1),m=!0),(t.autoClear||m)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),g&&(g.isCubeTexture||g.mapping===rt)?(void 0===s&&(s=new Li(new Di(1,1,1),new Ui({name:"BackgroundCubeMaterial",uniforms:ki(na.cube.uniforms),vertexShader:na.cube.vertexShader,fragmentShader:na.cube.fragmentShader,side:c,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(t,e,r){this.matrixWorld.copyPosition(r.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(s)),s.material.uniforms.envMap.value=g,s.material.uniforms.flipEnvMap.value=g.isCubeTexture&&!1===g.isRenderTargetTexture?-1:1,h===g&&d===g.version&&f===t.toneMapping||(s.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),r.unshift(s,s.geometry,s.material,0,0,null)):g&&g.isTexture&&(void 0===o&&(o=new Li(new ta(2,2),new Ui({name:"BackgroundMaterial",uniforms:ki(na.background.uniforms),vertexShader:na.background.vertexShader,fragmentShader:na.background.fragmentShader,side:u,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(o)),o.material.uniforms.t2D.value=g,!0===g.matrixAutoUpdate&&g.updateMatrix(),o.material.uniforms.uvTransform.value.copy(g.matrix),h===g&&d===g.version&&f===t.toneMapping||(o.material.needsUpdate=!0,h=g,d=g.version,f=t.toneMapping),r.unshift(o,o.geometry,o.material,0,0,null))}}}function aa(t,e,r,n){const i=t.getParameter(34921),a=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||null!==a,s={},l=d(null);let u=l;function c(e){return n.isWebGL2?t.bindVertexArray(e):a.bindVertexArrayOES(e)}function h(e){return n.isWebGL2?t.deleteVertexArray(e):a.deleteVertexArrayOES(e)}function d(t){const e=[],r=[],n=[];for(let t=0;t=0){let a=l[e];if(void 0===a&&("instanceMatrix"===e&&i.instanceMatrix&&(a=i.instanceMatrix),"instanceColor"===e&&i.instanceColor&&(a=i.instanceColor)),void 0!==a){const e=a.normalized,o=a.itemSize,l=r.get(a);if(void 0===l)continue;const u=l.buffer,c=l.type,h=l.bytesPerElement;if(a.isInterleavedBufferAttribute){const r=a.data,l=r.stride,d=a.offset;if(r&&r.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let o=void 0!==r.precision?r.precision:"highp";const s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const l=a||e.has("WEBGL_draw_buffers"),u=!0===r.logarithmicDepthBuffer,c=t.getParameter(34930),h=t.getParameter(35660),d=t.getParameter(3379),f=t.getParameter(34076),p=t.getParameter(34921),m=t.getParameter(36347),g=t.getParameter(36348),v=t.getParameter(36349),y=h>0,x=a||e.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const r=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:u,maxTextures:c,maxVertexTextures:h,maxTextureSize:d,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:a?t.getParameter(36183):0}}function la(t){const e=this;let r=null,n=0,i=!1,a=!1;const o=new Yi,s=new sr,l={value:null,needsUpdate:!1};function u(){l.value!==r&&(l.value=r,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function c(t,r,n,i){const a=null!==t?t.length:0;let u=null;if(0!==a){if(u=l.value,!0!==i||null===u){const e=n+4*a,i=r.matrixWorldInverse;s.getNormalMatrix(i),(null===u||u.length0){const o=t.getRenderTarget(),s=new Hi(a.height/2);return s.fromEquirectangularTexture(t,i),e.set(i,s),t.setRenderTarget(o),i.addEventListener("dispose",n),r(s.texture,i.mapping)}return null}}}return i},dispose:function(){e=new WeakMap}}}na.physical={uniforms:Fi([na.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new or(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new qn(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new or},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new qn(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new qn(1,1,1)},specularColorMap:{value:null}}]),vertexShader:ea.meshphysical_vert,fragmentShader:ea.meshphysical_frag};class ca extends Bi{constructor(t=-1,e=1,r=1,n=-1,i=.1,a=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=r,this.bottom=n,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,r,n,i,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=n,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let i=r-t,a=r+t,o=n+e,s=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=t*this.view.offsetX,a=i+t*this.view.width,o-=e*this.view.offsetY,s=o-e*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}ca.prototype.isOrthographicCamera=!0;class ha extends Ui{constructor(t){super(t),this.type="RawShaderMaterial"}}ha.prototype.isRawShaderMaterial=!0;const da=Math.pow(2,8),fa=[.125,.215,.35,.446,.526,.582],pa=5+fa.length,ma=20,ga={[Oe]:0,[De]:1,[Fe]:2,[Ne]:3,[Ue]:4,[Be]:5,[ke]:6},va=new ca,{_lodPlanes:ya,_sizeLods:xa,_sigmas:_a}=Pa(),wa=new qn;let ba=null;const Ma=(1+Math.sqrt(5))/2,Sa=1/Ma,Ta=[new Mr(1,1,1),new Mr(-1,1,1),new Mr(1,1,-1),new Mr(-1,1,-1),new Mr(0,Ma,Sa),new Mr(0,Ma,-Sa),new Mr(Sa,0,Ma),new Mr(-Sa,0,Ma),new Mr(Ma,Sa,0),new Mr(-Ma,Sa,0)];class Ea{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(t),r=new Mr(0,1,0);return new ha({name:"SphericalGaussianBlur",defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r},inputEncoding:{value:ga[Oe]},outputEncoding:{value:ga[Oe]}},vertexShader:Oa(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t${Da()}\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:d,depthTest:!1,depthWrite:!1})}(ma),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,r=.1,n=100){ba=this._renderer.getRenderTarget();const i=this._allocateTargets();return this._sceneToCubeUV(t,r,n,i),e>0&&this._blur(i,0,0,e),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=La(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Ia(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let t=0;t2?da:0,da,da),s.setRenderTarget(n),p&&s.render(f,i),s.render(t,i)}f.geometry.dispose(),f.material.dispose(),s.toneMapping=h,s.outputEncoding=u,s.autoClear=l,t.background=m}_setEncoding(t,e){t.value=ga[e.encoding]}_textureToCubeUV(t,e){const r=this._renderer,n=t.mapping===Q||t.mapping===$;n?null==this._cubemapShader&&(this._cubemapShader=La()):null==this._equirectShader&&(this._equirectShader=Ia());const i=n?this._cubemapShader:this._equirectShader,a=new Li(ya[0],i),o=i.uniforms;o.envMap.value=t,n||o.texelSize.value.set(1/t.image.width,1/t.image.height),this._setEncoding(o.inputEncoding,t),this._setEncoding(o.outputEncoding,e.texture),Ca(e,0,0,3*da,2*da),r.setRenderTarget(e),r.render(a,va)}_applyPMREM(t){const e=this._renderer,r=e.autoClear;e.autoClear=!1;for(let e=1;ema&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t4?n-8+4:0),3*v,2*v),s.setRenderTarget(e),s.render(u,va)}}function Aa(t){return void 0!==t&&t.type===ft&&(t.encoding===Oe||t.encoding===De||t.encoding===ke)}function Pa(){const t=[],e=[],r=[];let n=8;for(let i=0;i4?o=fa[i-8+4-1]:0==i&&(o=0),r.push(o);const s=1/(a-1),l=-s/2,u=1+s/2,c=[l,l,u,l,u,u,l,l,u,u,l,u],h=6,d=6,f=3,p=2,m=1,g=new Float32Array(f*d*h),v=new Float32Array(p*d*h),y=new Float32Array(m*d*h);for(let t=0;t2?0:-1,n=[e,r,0,e+2/3,r,0,e+2/3,r+1,0,e,r,0,e+2/3,r+1,0,e,r+1,0];g.set(n,f*d*t),v.set(c,p*d*t);const i=[t,t,t,t,t,t];y.set(i,m*d*t)}const x=new pi;x.setAttribute("position",new Kn(g,f)),x.setAttribute("uv",new Kn(v,p)),x.setAttribute("faceIndex",new Kn(y,m)),t.push(x),n>4&&n--}return{_lodPlanes:t,_sizeLods:e,_sigmas:r}}function Ra(t){const e=new xr(3*da,3*da,t);return e.texture.mapping=rt,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Ca(t,e,r,n,i){t.viewport.set(e,r,n,i),t.scissor.set(e,r,n,i)}function Ia(){const t=new or(1,1);return new ha({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:ga[Oe]},outputEncoding:{value:ga[Oe]}},vertexShader:Oa(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t${Da()}\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:d,depthTest:!1,depthWrite:!1})}function La(){return new ha({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:ga[Oe]},outputEncoding:{value:ga[Oe]}},vertexShader:Oa(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t${Da()}\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:d,depthTest:!1,depthWrite:!1})}function Oa(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Da(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}function ka(t){let e=new WeakMap,r=null;function n(t){const r=t.target;r.removeEventListener("dispose",n);const i=e.get(r);void 0!==i&&(e.delete(r),i.dispose())}return{get:function(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const a=i.mapping,o=a===tt||a===et,s=a===Q||a===$;if(o||s){if(e.has(i))return e.get(i).texture;{const a=i.image;if(o&&a&&a.height>0||s&&a&&function(t){let e=0;const r=6;for(let n=0;n65535?ni:ei)(r,1);s.version=o;const l=a.get(t);l&&e.remove(l),a.set(t,s)}return{get:function(t,e){return!0===i[e.id]||(e.addEventListener("dispose",o),i[e.id]=!0,r.memory.geometries++),e},update:function(t){const r=t.attributes;for(const t in r)e.update(r[t],34962);const n=t.morphAttributes;for(const t in n){const r=n[t];for(let t=0,n=r.length;te.maxTextureSize&&(h=Math.ceil(c/e.maxTextureSize),c=e.maxTextureSize);const d=new Float32Array(c*h*4*n),f=new za(d,c,h,n);f.format=At,f.type=xt;const p=4*l;for(let e=0;e0)return t;const i=e*r;let a=Ja[i];if(void 0===a&&(a=new Float32Array(i),Ja[i]=a),0!==e){n.toArray(a,0);for(let n=1,i=0;n!==e;++n)i+=r,t[n].toArray(a,i)}return a}function no(t,e){if(t.length!==e.length)return!1;for(let r=0,n=t.length;r/gm;function us(t){return t.replace(ls,cs)}function cs(t,e){const r=ea[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return us(r)}const hs=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,ds=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function fs(t){return t.replace(ds,ms).replace(hs,ps)}function ps(t,e,r,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),ms(t,e,r,n)}function ms(t,e,r,n){let i="";for(let t=parseInt(e);t0?t.gammaFactor:1,g=r.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(as).join("\n")}(r),v=function(t){const e=[];for(const r in t){const n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}(a),y=i.createProgram();let x,_,w=r.glslVersion?"#version "+r.glslVersion+"\n":"";r.isRawShaderMaterial?(x=[v].filter(as).join("\n"),x.length>0&&(x+="\n"),_=[g,v].filter(as).join("\n"),_.length>0&&(_+="\n")):(x=[gs(r),"#define SHADER_NAME "+r.shaderName,v,r.instancing?"#define USE_INSTANCING":"",r.instancingColor?"#define USE_INSTANCING_COLOR":"",r.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+r.maxBones,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+f:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMap&&r.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",r.normalMap&&r.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.displacementMap&&r.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",r.specularColorMap?"#define USE_SPECULARCOLORMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.sheenColorMap?"#define USE_SHEENCOLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",r.vertexTangents?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUvs?"#define USE_UV":"",r.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.useVertexTexture?"#define BONE_TEXTURE":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&!1===r.flatShading?"#define USE_MORPHNORMALS":"",r.morphTargets&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",r.morphTargets&&r.isWebGL2?"#define MORPHTARGETS_COUNT "+r.morphTargetsCount:"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+h:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(as).join("\n"),_=[g,gs(r),"#define SHADER_NAME "+r.shaderName,v,"#define GAMMA_FACTOR "+m,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+d:"",r.envMap?"#define "+f:"",r.envMap?"#define "+p:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMap&&r.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",r.normalMap&&r.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",r.clearcoat?"#define USE_CLEARCOAT":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",r.specularColorMap?"#define USE_SPECULARCOLORMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaTest?"#define USE_ALPHATEST":"",r.sheen?"#define USE_SHEEN":"",r.sheenColorMap?"#define USE_SHEENCOLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.vertexTangents?"#define USE_TANGENT":"",r.vertexColors||r.instancingColor?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUvs?"#define USE_UV":"",r.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+h:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensionShaderTextureLOD||r.envMap)&&r.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",r.toneMapping!==W?"#define TONE_MAPPING":"",r.toneMapping!==W?ea.tonemapping_pars_fragment:"",r.toneMapping!==W?is("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",r.format===Et?"#define OPAQUE":"",ea.encodings_pars_fragment,r.map?rs("mapTexelToLinear",r.mapEncoding):"",r.matcap?rs("matcapTexelToLinear",r.matcapEncoding):"",r.envMap?rs("envMapTexelToLinear",r.envMapEncoding):"",r.emissiveMap?rs("emissiveMapTexelToLinear",r.emissiveMapEncoding):"",r.specularColorMap?rs("specularColorMapTexelToLinear",r.specularColorMapEncoding):"",r.sheenColorMap?rs("sheenColorMapTexelToLinear",r.sheenColorMapEncoding):"",r.lightMap?rs("lightMapTexelToLinear",r.lightMapEncoding):"",ns("linearToOutputTexel",r.outputEncoding),r.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(as).join("\n")),u=us(u),u=os(u,r),u=ss(u,r),c=us(c),c=os(c,r),c=ss(c,r),u=fs(u),c=fs(c),r.isWebGL2&&!0!==r.isRawShaderMaterial&&(w="#version 300 es\n",x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,_=["#define varying in",r.glslVersion===qe?"":"out highp vec4 pc_fragColor;",r.glslVersion===qe?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+_);const b=w+_+c,M=Qo(i,35633,w+x+u),S=Qo(i,35632,b);if(i.attachShader(y,M),i.attachShader(y,S),void 0!==r.index0AttributeName?i.bindAttribLocation(y,0,r.index0AttributeName):!0===r.morphTargets&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y),t.debug.checkShaderErrors){const t=i.getProgramInfoLog(y).trim(),e=i.getShaderInfoLog(M).trim(),r=i.getShaderInfoLog(S).trim();let n=!0,a=!0;if(!1===i.getProgramParameter(y,35714)){n=!1;const e=es(i,M,"vertex"),r=es(i,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+r)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==r||(a=!1);a&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:x},fragmentShader:{log:r,prefix:_}})}let T,E;return i.deleteShader(M),i.deleteShader(S),this.getUniforms=function(){return void 0===T&&(T=new Jo(i,y)),T},this.getAttributes=function(){return void 0===E&&(E=function(t,e){const r={},n=t.getProgramParameter(e,35721);for(let i=0;i0,C=a.clearcoat>0;return{isWebGL2:l,shaderID:S,shaderName:a.type,vertexShader:E,fragmentShader:A,defines:a.defines,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:m,instancing:!0===_.isInstancedMesh,instancingColor:!0===_.isInstancedMesh&&null!==_.instanceColor,supportsVertexTextures:p,outputEncoding:null!==P?y(P.texture):t.outputEncoding,map:!!a.map,mapEncoding:y(a.map),matcap:!!a.matcap,matcapEncoding:y(a.matcap),envMap:!!M,envMapMode:M&&M.mapping,envMapEncoding:y(M),envMapCubeUV:!!M&&(M.mapping===rt||M.mapping===nt),lightMap:!!a.lightMap,lightMapEncoding:y(a.lightMap),aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,emissiveMapEncoding:y(a.emissiveMap),bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,objectSpaceNormalMap:a.normalMapType===je,tangentSpaceNormalMap:a.normalMapType===Ge,clearcoat:C,clearcoatMap:C&&!!a.clearcoatMap,clearcoatRoughnessMap:C&&!!a.clearcoatRoughnessMap,clearcoatNormalMap:C&&!!a.clearcoatNormalMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,specularIntensityMap:!!a.specularIntensityMap,specularColorMap:!!a.specularColorMap,specularColorMapEncoding:y(a.specularColorMap),alphaMap:!!a.alphaMap,alphaTest:R,gradientMap:!!a.gradientMap,sheen:a.sheen>0,sheenColorMap:!!a.sheenColorMap,sheenColorMapEncoding:y(a.sheenColorMap),sheenRoughnessMap:!!a.sheenRoughnessMap,transmission:a.transmission>0,transmissionMap:!!a.transmissionMap,thicknessMap:!!a.thicknessMap,combine:a.combine,vertexTangents:!!a.normalMap&&!!_.geometry&&!!_.geometry.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!_.geometry&&!!_.geometry.attributes.color&&4===_.geometry.attributes.color.itemSize,vertexUvs:!!a.map||!!a.bumpMap||!!a.normalMap||!!a.specularMap||!!a.alphaMap||!!a.emissiveMap||!!a.roughnessMap||!!a.metalnessMap||!!a.clearcoatMap||!!a.clearcoatRoughnessMap||!!a.clearcoatNormalMap||!!a.displacementMap||!!a.transmissionMap||!!a.thicknessMap||!!a.specularIntensityMap||!!a.specularColorMap||!!a.sheenColorMap||a.sheenRoughnessMap,uvsVertexOnly:!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatNormalMap||a.transmission>0||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheen>0||a.sheenColorMap||a.sheenRoughnessMap||!a.displacementMap),fog:!!w,useFog:a.fog,fogExp2:w&&w.isFogExp2,flatShading:!!a.flatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh&&T>0,maxBones:T,useVertexTexture:d,morphTargets:!!_.geometry&&!!_.geometry.morphAttributes.position,morphNormals:!!_.geometry&&!!_.geometry.morphAttributes.normal,morphTargetsCount:_.geometry&&_.geometry.morphAttributes.position?_.geometry.morphAttributes.position.length:0,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,format:a.format,dithering:a.dithering,shadowMapEnabled:t.shadowMap.enabled&&v.length>0,shadowMapType:t.shadowMap.type,toneMapping:a.toneMapped?t.toneMapping:W,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===h,flipSided:a.side===c,depthPacking:void 0!==a.depthPacking&&a.depthPacking,index0AttributeName:a.index0AttributeName,extensionDerivatives:a.extensions&&a.extensions.derivatives,extensionFragDepth:a.extensions&&a.extensions.fragDepth,extensionDrawBuffers:a.extensions&&a.extensions.drawBuffers,extensionShaderTextureLOD:a.extensions&&a.extensions.shaderTextureLOD,rendererExtensionFragDepth:l||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:l||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:l||n.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(e){const r=[];if(e.shaderID?r.push(e.shaderID):(r.push(dr(e.fragmentShader)),r.push(dr(e.vertexShader))),void 0!==e.defines)for(const t in e.defines)r.push(t),r.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t0?i.push(c):!0===r.transparent?a.push(c):n.push(c)},unshift:function(t,e,r,o,l,u){const c=s(t,e,r,o,l,u);r.transmission>0?i.unshift(c):!0===r.transparent?a.unshift(c):n.unshift(c)},finish:function(){for(let t=r,n=e.length;t1&&n.sort(t||_s),i.length>1&&i.sort(e||ws),a.length>1&&a.sort(e||ws)}}}function Ms(t){let e=new WeakMap;return{get:function(r,n){let i;return!1===e.has(r)?(i=new bs(t),e.set(r,[i])):n>=e.get(r).length?(i=new bs(t),e.get(r).push(i)):i=e.get(r)[n],i},dispose:function(){e=new WeakMap}}}function Ss(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let r;switch(e.type){case"DirectionalLight":r={direction:new Mr,color:new qn};break;case"SpotLight":r={position:new Mr,direction:new Mr,color:new qn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new Mr,color:new qn,distance:0,decay:0};break;case"HemisphereLight":r={direction:new Mr,skyColor:new qn,groundColor:new qn};break;case"RectAreaLight":r={color:new qn,position:new Mr,halfWidth:new Mr,halfHeight:new Mr}}return t[e.id]=r,r}}}let Ts=0;function Es(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function As(t,e){const r=new Ss,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let r;switch(e.type){case"DirectionalLight":case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new or};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new or,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=r,r}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)i.probe.push(new Mr);const a=new Mr,o=new tn,s=new tn;return{setup:function(a,o){let s=0,l=0,u=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let c=0,h=0,d=0,f=0,p=0,m=0,g=0,v=0;a.sort(Es);const y=!0!==o?Math.PI:1;for(let t=0,e=a.length;t0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=ra.LTC_FLOAT_1,i.rectAreaLTC2=ra.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=ra.LTC_HALF_1,i.rectAreaLTC2=ra.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=u;const x=i.hash;x.directionalLength===c&&x.pointLength===h&&x.spotLength===d&&x.rectAreaLength===f&&x.hemiLength===p&&x.numDirectionalShadows===m&&x.numPointShadows===g&&x.numSpotShadows===v||(i.directional.length=c,i.spot.length=d,i.rectArea.length=f,i.point.length=h,i.hemi.length=p,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=v,i.spotShadowMap.length=v,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotShadowMatrix.length=v,x.directionalLength=c,x.pointLength=h,x.spotLength=d,x.rectAreaLength=f,x.hemiLength=p,x.numDirectionalShadows=m,x.numPointShadows=g,x.numSpotShadows=v,i.version=Ts++)},setupView:function(t,e){let r=0,n=0,l=0,u=0,c=0;const h=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.get(n).length?(a=new Ps(t,e),r.get(n).push(a)):a=r.get(n)[i],a},dispose:function(){r=new WeakMap}}}class Cs extends Bn{constructor(t){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}Cs.prototype.isMeshDepthMaterial=!0;class Is extends Bn{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Mr,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}Is.prototype.isMeshDistanceMaterial=!0;const Ls="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",Os="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function Ds(t,e,r){let n=new Ji;const i=new or,a=new or,s=new yr,f=new Cs({depthPacking:ze}),p=new Is,m={},g=r.maxTextureSize,v={0:c,1:u,2:h},y=new Ui({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new or},radius:{value:4}},vertexShader:Ls,fragmentShader:Os}),x=y.clone();x.defines.HORIZONTAL_PASS=1;const _=new pi;_.setAttribute("position",new Kn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const w=new Li(_,y),b=this;function M(r,n){const i=e.update(w);y.defines.VSM_SAMPLES!==r.blurSamples&&(y.defines.VSM_SAMPLES=r.blurSamples,x.defines.VSM_SAMPLES=r.blurSamples,y.needsUpdate=!0,x.needsUpdate=!0),y.uniforms.shadow_pass.value=r.map.texture,y.uniforms.resolution.value=r.mapSize,y.uniforms.radius.value=r.radius,t.setRenderTarget(r.mapPass),t.clear(),t.renderBufferDirect(n,null,i,y,w,null),x.uniforms.shadow_pass.value=r.mapPass.texture,x.uniforms.resolution.value=r.mapSize,x.uniforms.radius.value=r.radius,t.setRenderTarget(r.map),t.clear(),t.renderBufferDirect(n,null,i,x,w,null)}function S(e,r,n,i,a,o,s){let u=null;const c=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(u=void 0!==c?c:!0===i.isPointLight?p:f,t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const t=u.uuid,e=n.uuid;let r=m[t];void 0===r&&(r={},m[t]=r);let i=r[e];void 0===i&&(i=u.clone(),r[e]=i),u=i}return u.visible=n.visible,u.wireframe=n.wireframe,u.side=s===l?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:v[n.side],u.alphaMap=n.alphaMap,u.alphaTest=n.alphaTest,u.clipShadows=n.clipShadows,u.clippingPlanes=n.clippingPlanes,u.clipIntersection=n.clipIntersection,u.displacementMap=n.displacementMap,u.displacementScale=n.displacementScale,u.displacementBias=n.displacementBias,u.wireframeLinewidth=n.wireframeLinewidth,u.linewidth=n.linewidth,!0===i.isPointLight&&!0===u.isMeshDistanceMaterial&&(u.referencePosition.setFromMatrixPosition(i.matrixWorld),u.nearDistance=a,u.farDistance=o),u}function T(r,i,a,o,s){if(!1===r.visible)return;if(r.layers.test(i.layers)&&(r.isMesh||r.isLine||r.isPoints)&&(r.castShadow||r.receiveShadow&&s===l)&&(!r.frustumCulled||n.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,r.matrixWorld);const n=e.update(r),i=r.material;if(Array.isArray(i)){const e=n.groups;for(let l=0,u=e.length;lg||i.y>g)&&(i.x>g&&(a.x=Math.floor(g/d.x),i.x=a.x*d.x,h.mapSize.x=a.x),i.y>g&&(a.y=Math.floor(g/d.y),i.y=a.y*d.y,h.mapSize.y=a.y)),null===h.map&&!h.isPointLightShadow&&this.type===l){const t={minFilter:ct,magFilter:ct,format:At};h.map=new xr(i.x,i.y,t),h.map.texture.name=c.name+".shadowMap",h.mapPass=new xr(i.x,i.y,t),h.camera.updateProjectionMatrix()}if(null===h.map){const t={minFilter:st,magFilter:st,format:At};h.map=new xr(i.x,i.y,t),h.map.texture.name=c.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const p=h.getViewportCount();for(let t=0;t=1):-1!==lt.indexOf("OpenGL ES")&&(st=parseFloat(/^OpenGL ES (\d)/.exec(lt)[1]),ot=st>=2);let ut=null,ct={};const ht=t.getParameter(3088),dt=t.getParameter(2978),ft=(new yr).fromArray(ht),pt=(new yr).fromArray(dt);function mt(e,r,n){const i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;en||t.height>n)&&(i=n/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?ir:Math.floor,a=n(i*t.width),o=n(i*t.height);void 0===p&&(p=g(a,o));const s=r?g(a,o):p;s.width=a,s.height=o;return s.getContext("2d").drawImage(t,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+a+"x"+o+")."),s}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function y(t){return rr(t.width)&&rr(t.height)}function x(t,e){return t.generateMipmaps&&e&&t.minFilter!==st&&t.minFilter!==ct}function _(e){t.generateMipmap(e)}function w(r,n,i){if(!1===s)return n;if(null!==r){if(void 0!==t[r])return t[r];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+r+"'")}let a=n;return 6403===n&&(5126===i&&(a=33326),5131===i&&(a=33325),5121===i&&(a=33321)),6407===n&&(5126===i&&(a=34837),5131===i&&(a=34843),5121===i&&(a=32849)),6408===n&&(5126===i&&(a=34836),5131===i&&(a=34842),5121===i&&(a=32856)),33325!==a&&33326!==a&&34842!==a&&34836!==a||e.get("EXT_color_buffer_float"),a}function b(t){return t===st||t===lt||t===ut?9728:9729}function M(e){const r=e.target;r.removeEventListener("dispose",M),function(e){const r=n.get(e);if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture),n.remove(e)}(r),r.isVideoTexture&&f.delete(r),o.memory.textures--}function S(e){const r=e.target;r.removeEventListener("dispose",S),function(e){const r=e.texture,i=n.get(e),a=n.get(r);if(!e)return;void 0!==a.__webglTexture&&(t.deleteTexture(a.__webglTexture),o.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&t.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,i=r.length;e0&&i.__version!==t.version){const r=t.image;if(void 0===r)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==r.complete)return void L(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}r.activeTexture(33984+e),r.bindTexture(3553,i.__webglTexture)}function A(e,i){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,n,i){if(6!==n.image.length)return;I(e,n),r.activeTexture(33984+i),r.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const o=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),l=n.image[0]&&n.image[0].isDataTexture,c=[];for(let t=0;t<6;t++)c[t]=o||l?l?n.image[t].image:n.image[t]:v(n.image[t],!1,!0,u);const h=y(c[0])||s,d=a.convert(n.format),f=a.convert(n.type),p=w(n.internalFormat,d,f,n.encoding);let m;if(C(34067,n,h),o)for(let t=0;t<6;t++){m=c[t].mipmaps;for(let e=0;e1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function I(e,r){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",M),e.__webglTexture=t.createTexture(),o.memory.textures++)}function L(e,n,i){let o=3553;n.isDataTexture2DArray&&(o=35866),n.isDataTexture3D&&(o=32879),I(e,n),r.activeTexture(33984+i),r.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const l=function(t){return!s&&(t.wrapS!==at||t.wrapT!==at||t.minFilter!==st&&t.minFilter!==ct)}(n)&&!1===y(n.image),u=v(n.image,l,!1,c),h=y(u)||s,d=a.convert(n.format);let f,p=a.convert(n.type),m=w(n.internalFormat,d,p,n.encoding);C(o,n,h);const g=n.mipmaps;if(n.isDepthTexture)m=6402,s?m=n.type===xt?36012:n.type===yt?33190:n.type===St?35056:33189:n.type===xt&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===It&&6402===m&&n.type!==gt&&n.type!==yt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=gt,p=a.convert(n.type)),n.format===Lt&&6402===m&&(m=34041,n.type!==St&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=St,p=a.convert(n.type))),r.texImage2D(3553,0,m,u.width,u.height,0,d,p,null);else if(n.isDataTexture)if(g.length>0&&h){for(let t=0,e=g.length;t0?t.mipmaps.length:1}(n,u,h),i=s&&!0!==n.isVideoTexture,a=void 0===e.__version;if(g.length>0&&h){i&&a&&r.texStorage2D(3553,t,m,g[0].width,g[0].height);for(let t=0,e=g.length;t=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(t,e){const i=n.get(t);t.version>0&&i.__version!==t.version?L(i,t,e):(r.activeTexture(33984+e),r.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){const i=n.get(t);t.version>0&&i.__version!==t.version?L(i,t,e):(r.activeTexture(33984+e),r.bindTexture(32879,i.__webglTexture))},this.setTextureCube=A,this.rebindTextures=function(t,e,r){const i=n.get(t);void 0!==e&&O(i.__webglFramebuffer,t,t.texture,36064,3553),void 0!==r&&k(t)},this.setupRenderTarget=function(e){const l=e.texture,u=n.get(e),c=n.get(l);e.addEventListener("dispose",S),!0!==e.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=t.createTexture()),c.__version=l.version,o.memory.textures++);const h=!0===e.isWebGLCubeRenderTarget,d=!0===e.isWebGLMultipleRenderTargets,f=l.isDataTexture3D||l.isDataTexture2DArray,p=y(e)||s;if(!s||l.format!==Et||l.type!==xt&&l.type!==_t||(l.format=At,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){u.__webglFramebuffer=[];for(let e=0;e<6;e++)u.__webglFramebuffer[e]=t.createFramebuffer()}else if(u.__webglFramebuffer=t.createFramebuffer(),d)if(i.drawBuffers){const r=e.texture;for(let e=0,i=r.length;es+u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&o<=s-u&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==s&&t.gripSpace&&(i=e.getPose(t.gripSpace,r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));return null!==o&&(o.visible=null!==n),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==a),this}}class js extends gr{constructor(t,e,r,n,i,a,o,s,l,u){if((u=void 0!==u?u:It)!==It&&u!==Lt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===It&&(r=gt),void 0===r&&u===Lt&&(r=St),super(null,n,i,a,o,s,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==o?o:st,this.minFilter=void 0!==s?s:st,this.flipY=!1,this.generateMipmaps=!1}}js.prototype.isDepthTexture=!0;class Vs extends Xe{constructor(t,e){super();const r=this;let n=null,i=1,a=null,o="local-floor";const s=t.extensions.has("WEBGL_multisampled_render_to_texture");let l=null,u=null,c=null,h=null,d=!1,f=null;const p=e.getContextAttributes();let m=null,g=null;const v=[],y=new Map,x=new zi;x.layers.enable(1),x.viewport=new yr;const _=new zi;_.layers.enable(2),_.viewport=new yr;const w=[x,_],b=new Us;b.layers.enable(1),b.layers.enable(2);let M=null,S=null;function T(t){const e=y.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function E(){y.forEach((function(t,e){t.disconnect(e)})),y.clear(),M=null,S=null,t.setRenderTarget(m),h=null,c=null,u=null,n=null,g=null,L.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}function A(t){const e=n.inputSources;for(let t=0;t0&&(e.alphaTest.value=r.alphaTest);const n=t.get(r).envMap;let i,a;n&&(e.envMap.value=n,e.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity),r.map?i=r.map:r.specularMap?i=r.specularMap:r.displacementMap?i=r.displacementMap:r.normalMap?i=r.normalMap:r.bumpMap?i=r.bumpMap:r.roughnessMap?i=r.roughnessMap:r.metalnessMap?i=r.metalnessMap:r.alphaMap?i=r.alphaMap:r.emissiveMap?i=r.emissiveMap:r.clearcoatMap?i=r.clearcoatMap:r.clearcoatNormalMap?i=r.clearcoatNormalMap:r.clearcoatRoughnessMap?i=r.clearcoatRoughnessMap:r.specularIntensityMap?i=r.specularIntensityMap:r.specularColorMap?i=r.specularColorMap:r.transmissionMap?i=r.transmissionMap:r.thicknessMap?i=r.thicknessMap:r.sheenColorMap?i=r.sheenColorMap:r.sheenRoughnessMap&&(i=r.sheenRoughnessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix)),r.aoMap?a=r.aoMap:r.lightMap&&(a=r.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),e.uv2Transform.value.copy(a.matrix))}function r(e,r){e.roughness.value=r.roughness,e.metalness.value=r.metalness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap),r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap),r.bumpMap&&(e.bumpMap.value=r.bumpMap,e.bumpScale.value=r.bumpScale,r.side===c&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,e.normalScale.value.copy(r.normalScale),r.side===c&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias);t.get(r).envMap&&(e.envMapIntensity.value=r.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,n,i,a,o){n.isMeshBasicMaterial?e(t,n):n.isMeshLambertMaterial?(e(t,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,n)):n.isMeshToonMaterial?(e(t,n),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshPhongMaterial?(e(t,n),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshStandardMaterial?(e(t,n),n.isMeshPhysicalMaterial?function(t,e,n){r(t,e),t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===c&&t.clearcoatNormalScale.value.negate()));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap);e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap)}(t,n,o):r(t,n)):n.isMeshMatcapMaterial?(e(t,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDepthMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDistanceMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,n)):n.isMeshNormalMaterial?(e(t,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===c&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===c&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,r,n){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*r,t.scale.value=.5*n,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n,i,a):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let r;e.map?r=e.map:e.alphaMap&&(r=e.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Ws(e={}){const r=void 0!==e.canvas?e.canvas:function(){const t=hr("canvas");return t.style.display="block",t}(),n=void 0!==e.context?e.context:null,i=void 0!==e.alpha&&e.alpha,a=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,s=void 0!==e.antialias&&e.antialias,l=void 0===e.premultipliedAlpha||e.premultipliedAlpha,d=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,f=void 0!==e.powerPreference?e.powerPreference:"default",p=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let m=null,g=null;const v=[],y=[];this.domElement=r,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=Oe,this.physicallyCorrectLights=!1,this.toneMapping=W,this.toneMappingExposure=1;const x=this;let _=!1,w=0,b=0,M=null,S=-1,T=null;const E=new yr,A=new yr;let P=null,R=r.width,C=r.height,I=1,L=null,O=null;const D=new yr(0,0,R,C),k=new yr(0,0,R,C);let F=!1;const N=[],U=new Ji;let B=!1,z=!1,G=null;const j=new tn,V=new Mr,H={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return null===M?I:1}let X,Y,Z,K,J,Q,$,tt,et,rt,nt,it,ot,lt,ut,ct,ht,pt,mt,gt,vt,yt,wt,bt=n;function Mt(t,e){for(let n=0;n0&&function(t,e,r){if(null===G){const t=!0===s&&!0===Y.isWebGL2;G=new(t?wr:xr)(1024,1024,{generateMipmaps:!0,type:null!==yt.convert(_t)?_t:ft,minFilter:dt,magFilter:st,wrapS:at,wrapT:at,useRenderToTexture:X.has("WEBGL_multisampled_render_to_texture")})}const n=x.getRenderTarget();x.setRenderTarget(G),x.clear();const i=x.toneMapping;x.toneMapping=W,Ft(t,e,r),x.toneMapping=i,Q.updateMultisampleRenderTarget(G),Q.updateRenderTargetMipmap(G),x.setRenderTarget(n)}(i,e,r),n&&Z.viewport(E.copy(n)),i.length>0&&Ft(i,e,r),a.length>0&&Ft(a,e,r),o.length>0&&Ft(o,e,r)}function Ft(t,e,r){const n=!0===e.isScene?e.overrideMaterial:null;for(let i=0,a=t.length;i0?y[y.length-1]:null,v.pop(),m=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,r){J.get(t.texture).__webglTexture=e,J.get(t.depthTexture).__webglTexture=r;const n=J.get(t);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===r,n.__autoAllocateDepthBuffer||t.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),t.useRenderToTexture=!1,t.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(t,e){const r=J.get(t);r.__webglFramebuffer=e,r.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,r=0){M=t,w=e,b=r;let n=!0;if(t){const e=J.get(t);void 0!==e.__useDefaultFramebuffer?(Z.bindFramebuffer(36160,null),n=!1):void 0===e.__webglFramebuffer?Q.setupRenderTarget(t):e.__hasExternalTextures&&Q.rebindTextures(t,J.get(t.texture).__webglTexture,J.get(t.depthTexture).__webglTexture)}let i=null,a=!1,o=!1;if(t){const r=t.texture;(r.isDataTexture3D||r.isDataTexture2DArray)&&(o=!0);const n=J.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=n[e],a=!0):i=t.useRenderbuffer?J.get(t).__webglMultisampledFramebuffer:n,E.copy(t.viewport),A.copy(t.scissor),P=t.scissorTest}else E.copy(D).multiplyScalar(I).floor(),A.copy(k).multiplyScalar(I).floor(),P=F;if(Z.bindFramebuffer(36160,i)&&Y.drawBuffers&&n){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const r=t.texture;if(N.length!==r.length||36064!==N[0]){for(let t=0,e=r.length;t=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&bt.readPixels(e,r,n,i,yt.convert(s),yt.convert(l),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==M?J.get(M).__webglFramebuffer:null;Z.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,r=0){const n=Math.pow(2,-r),i=Math.floor(e.image.width*n),a=Math.floor(e.image.height*n);let o=yt.convert(e.format);Y.isWebGL2&&(6407===o&&(o=32849),6408===o&&(o=32856)),Q.setTexture2D(e,0),bt.copyTexImage2D(3553,r,o,t.x,t.y,i,a,0),Z.unbindTexture()},this.copyTextureToTexture=function(t,e,r,n=0){const i=e.image.width,a=e.image.height,o=yt.convert(r.format),s=yt.convert(r.type);Q.setTexture2D(r,0),bt.pixelStorei(37440,r.flipY),bt.pixelStorei(37441,r.premultiplyAlpha),bt.pixelStorei(3317,r.unpackAlignment),e.isDataTexture?bt.texSubImage2D(3553,n,t.x,t.y,i,a,o,s,e.image.data):e.isCompressedTexture?bt.compressedTexSubImage2D(3553,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):bt.texSubImage2D(3553,n,t.x,t.y,o,s,e.image),0===n&&r.generateMipmaps&&bt.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(t,e,r,n,i=0){if(x.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=t.max.x-t.min.x+1,o=t.max.y-t.min.y+1,s=t.max.z-t.min.z+1,l=yt.convert(n.format),u=yt.convert(n.type);let c;if(n.isDataTexture3D)Q.setTexture3D(n,0),c=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(n,0),c=35866}bt.pixelStorei(37440,n.flipY),bt.pixelStorei(37441,n.premultiplyAlpha),bt.pixelStorei(3317,n.unpackAlignment);const h=bt.getParameter(3314),d=bt.getParameter(32878),f=bt.getParameter(3316),p=bt.getParameter(3315),m=bt.getParameter(32877),g=r.isCompressedTexture?r.mipmaps[0]:r.image;bt.pixelStorei(3314,g.width),bt.pixelStorei(32878,g.height),bt.pixelStorei(3316,t.min.x),bt.pixelStorei(3315,t.min.y),bt.pixelStorei(32877,t.min.z),r.isDataTexture||r.isDataTexture3D?bt.texSubImage3D(c,i,e.x,e.y,e.z,a,o,s,l,u,g.data):r.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),bt.compressedTexSubImage3D(c,i,e.x,e.y,e.z,a,o,s,l,g.data)):bt.texSubImage3D(c,i,e.x,e.y,e.z,a,o,s,l,u,g),bt.pixelStorei(3314,h),bt.pixelStorei(32878,d),bt.pixelStorei(3316,f),bt.pixelStorei(3315,p),bt.pixelStorei(32877,m),0===i&&n.generateMipmaps&&bt.generateMipmap(c),Z.unbindTexture()},this.initTexture=function(t){Q.setTexture2D(t,0),Z.unbindTexture()},this.resetState=function(){w=0,b=0,M=null,Z.reset(),wt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Ws.prototype.isWebGLRenderer=!0;class qs extends Ws{}qs.prototype.isWebGL1Renderer=!0;class Xs{constructor(t,e=25e-5){this.name="",this.color=new qn(t),this.density=e}clone(){return new Xs(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Xs.prototype.isFogExp2=!0;class Ys{constructor(t,e=1,r=1e3){this.name="",this.color=new qn(t),this.near=e,this.far=r}clone(){return new Ys(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Ys.prototype.isFog=!0;class Zs extends En{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}Zs.prototype.isScene=!0;class Ks{constructor(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=He,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Qe()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let n=0,i=this.stride;nt.far||e.push({distance:s,point:el.clone(),uv:Nn.getUV(el,sl,ll,ul,cl,hl,dl,new or),face:null,object:this})}copy(t){return super.copy(t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function pl(t,e,r,n,i,a){il.subVectors(t,r).addScalar(.5).multiply(n),void 0!==i?(al.x=a*il.x-i*il.y,al.y=i*il.x+a*il.y):al.copy(il),t.copy(e),t.x+=al.x,t.y+=al.y,t.applyMatrix4(ol)}fl.prototype.isSprite=!0;const ml=new Mr,gl=new Mr;class vl extends En{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,r=e.length;t0){let r,n;for(r=1,n=e.length;r0){ml.setFromMatrixPosition(this.matrixWorld);const r=t.ray.origin.distanceTo(ml);this.getObjectForDistance(r).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){ml.setFromMatrixPosition(t.matrixWorld),gl.setFromMatrixPosition(this.matrixWorld);const r=ml.distanceTo(gl)/t.zoom;let n,i;for(e[0].object.visible=!0,n=1,i=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;ns)continue;h.applyMatrix4(this.matrixWorld);const d=t.ray.origin.distanceTo(h);dt.far||e.push({distance:d,point:c.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}else{for(let r=Math.max(0,a.start),n=Math.min(i.count,a.start+a.count)-1;rs)continue;h.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(h);nt.far||e.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}}else r.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,r=Object.keys(e);if(r.length>0){const t=e[r[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,r=t.length;e0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Gl.prototype.isLine=!0;const jl=new Mr,Vl=new Mr;class Hl extends Gl{constructor(t,e){super(t,e),this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,r=[];for(let t=0,n=e.count;t0){const t=e[r[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,r=t.length;e0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};function Ql(t,e,r,n,i,a,o){const s=Yl.distanceSqToPoint(t);if(si.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:r,index:e,face:null,object:o})}}Jl.prototype.isPoints=!0;class $l extends gr{constructor(t,e,r,n,i,a,o,s,l){super(t,e,r,n,i,a,o,s,l),this.format=void 0!==o?o:Et,this.minFilter=void 0!==a?a:ct,this.magFilter=void 0!==i?i:ct,this.generateMipmaps=!1;const u=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){u.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}$l.prototype.isVideoTexture=!0;class tu extends gr{constructor(t,e,r,n,i,a,o,s,l,u,c,h){super(null,a,o,s,l,u,n,i,c,h),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}tu.prototype.isCompressedTexture=!0;class eu extends gr{constructor(t,e,r,n,i,a,o,s,l){super(t,e,r,n,i,a,o,s,l),this.needsUpdate=!0}}eu.prototype.isCanvasTexture=!0;class ru extends pi{constructor(t=1,e=8,r=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},e=Math.max(3,e);const i=[],a=[],o=[],s=[],l=new Mr,u=new or;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,c=3;i<=e;i++,c+=3){const h=r+i/e*n;l.x=t*Math.cos(h),l.y=t*Math.sin(h),a.push(l.x,l.y,l.z),o.push(0,0,1),u.x=(a[c]/t+1)/2,u.y=(a[c+1]/t+1)/2,s.push(u.x,u.y)}for(let t=1;t<=e;t++)i.push(t,t+1,0);this.setIndex(i),this.setAttribute("position",new ai(a,3)),this.setAttribute("normal",new ai(o,3)),this.setAttribute("uv",new ai(s,2))}static fromJSON(t){return new ru(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class nu extends pi{constructor(t=1,e=1,r=1,n=8,i=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};const l=this;n=Math.floor(n),i=Math.floor(i);const u=[],c=[],h=[],d=[];let f=0;const p=[],m=r/2;let g=0;function v(r){const i=f,a=new or,p=new Mr;let v=0;const y=!0===r?t:e,x=!0===r?1:-1;for(let t=1;t<=n;t++)c.push(0,m*x,0),h.push(0,x,0),d.push(.5,.5),f++;const _=f;for(let t=0;t<=n;t++){const e=t/n*s+o,r=Math.cos(e),i=Math.sin(e);p.x=y*i,p.y=m*x,p.z=y*r,c.push(p.x,p.y,p.z),h.push(0,x,0),a.x=.5*r+.5,a.y=.5*i*x+.5,d.push(a.x,a.y),f++}for(let t=0;t0&&v(!0),e>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new ai(c,3)),this.setAttribute("normal",new ai(h,3)),this.setAttribute("uv",new ai(d,2))}static fromJSON(t){return new nu(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class iu extends nu{constructor(t=1,e=1,r=8,n=1,i=!1,a=0,o=2*Math.PI){super(0,t,e,r,n,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new iu(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class au extends pi{constructor(t=[],e=[],r=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n};const i=[],a=[];function o(t,e,r,n){const i=n+1,a=[];for(let n=0;n<=i;n++){a[n]=[];const o=t.clone().lerp(r,n/i),s=e.clone().lerp(r,n/i),l=i-n;for(let t=0;t<=l;t++)a[n][t]=0===t&&n===i?o:o.clone().lerp(s,t/l)}for(let t=0;t.9&&o<.1&&(e<.2&&(a[t+0]+=1),r<.2&&(a[t+2]+=1),n<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new ai(i,3)),this.setAttribute("normal",new ai(i.slice(),3)),this.setAttribute("uv",new ai(a,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(t){return new au(t.vertices,t.indices,t.radius,t.details)}}class ou extends au{constructor(t=1,e=0){const r=(1+Math.sqrt(5))/2,n=1/r;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ou(t.radius,t.detail)}}const su=new Mr,lu=new Mr,uu=new Mr,cu=new Nn;class hu extends pi{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const r=4,n=Math.pow(10,r),i=Math.cos(Ke*e),a=t.getIndex(),o=t.getAttribute("position"),s=a?a.count:o.count,l=[0,0,0],u=["a","b","c"],c=new Array(3),h={},d=[];for(let t=0;t0)){l=n;break}l=n-1}if(n=l,r[n]===a)return n/(i-1);const u=r[n];return(n+(a-u)/(r[n+1]-u))/(i-1)}getTangent(t,e){const r=1e-4;let n=t-r,i=t+r;n<0&&(n=0),i>1&&(i=1);const a=this.getPoint(n),o=this.getPoint(i),s=e||(a.isVector2?new or:new Mr);return s.copy(o).sub(a).normalize(),s}getTangentAt(t,e){const r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){const r=new Mr,n=[],i=[],a=[],o=new Mr,s=new tn;for(let e=0;e<=t;e++){const r=e/t;n[e]=this.getTangentAt(r,new Mr)}i[0]=new Mr,a[0]=new Mr;let l=Number.MAX_VALUE;const u=Math.abs(n[0].x),c=Math.abs(n[0].y),h=Math.abs(n[0].z);u<=l&&(l=u,r.set(1,0,0)),c<=l&&(l=c,r.set(0,1,0)),h<=l&&r.set(0,0,1),o.crossVectors(n[0],r).normalize(),i[0].crossVectors(n[0],o),a[0].crossVectors(n[0],i[0]);for(let e=1;e<=t;e++){if(i[e]=i[e-1].clone(),a[e]=a[e-1].clone(),o.crossVectors(n[e-1],n[e]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos($e(n[e-1].dot(n[e]),-1,1));i[e].applyMatrix4(s.makeRotationAxis(o,t))}a[e].crossVectors(n[e],i[e])}if(!0===e){let e=Math.acos($e(i[0].dot(i[t]),-1,1));e/=t,n[0].dot(o.crossVectors(i[0],i[t]))>0&&(e=-e);for(let r=1;r<=t;r++)i[r].applyMatrix4(s.makeRotationAxis(n[r],e*r)),a[r].crossVectors(n[r],i[r])}return{tangents:n,normals:i,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class fu extends du{constructor(t=0,e=0,r=1,n=1,i=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(t,e){const r=e||new or,n=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const a=Math.abs(i)n;)i-=n;i0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===u&&l===i-1&&(l=i-2,u=1),this.closed||l>0?o=n[(l-1)%i]:(gu.subVectors(n[0],n[1]).add(n[0]),o=gu);const c=n[l%i],h=n[(l+1)%i];if(this.closed||l+2n.length-2?n.length-1:a+1],c=n[a>n.length-3?n.length-1:a+2];return r.set(wu(o,s.x,l.x,u.x,c.x),wu(o,s.y,l.y,u.y,c.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e=r){const t=n[i]-r,a=this.curves[i],o=a.getLength(),s=0===o?0:1-t/o;return a.getPointAt(s,e)}i++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,n=this.curves.length;r1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Du extends Ou{constructor(t){super(t),this.uuid=Qe(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let r=0,n=this.holes.length;r80*r){s=u=t[0],l=c=t[1];for(let e=r;eu&&(u=h),d>c&&(c=d);f=Math.max(u-s,c-l),f=0!==f?1/f:0}return Uu(a,o,r,s,l,f),o};function Fu(t,e,r,n,i){let a,o;if(i===function(t,e,r,n){let i=0;for(let a=e,o=r-n;a0)for(a=e;a=e;a-=n)o=nc(a,t[a],t[a+1],o);return o&&Ju(o,o.next)&&(ic(o),o=o.next),o}function Nu(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Ju(n,n.next)&&0!==Ku(n.prev,n,n.next))n=n.next;else{if(ic(n),n=e=n.prev,n===n.next)break;r=!0}}while(r||n!==e);return e}function Uu(t,e,r,n,i,a,o){if(!t)return;!o&&a&&function(t,e,r,n){let i=t;do{null===i.z&&(i.z=qu(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r,n,i,a,o,s,l,u=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,u*=2}while(o>1)}(i)}(t,n,i,a);let s,l,u=t;for(;t.prev!==t.next;)if(s=t.prev,l=t.next,a?zu(t,n,i,a):Bu(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),ic(t),t=l.next,u=l.next;else if((t=l)===u){o?1===o?Uu(t=Gu(Nu(t),e,r),e,r,n,i,a,2):2===o&&ju(t,e,r,n,i,a):Uu(Nu(t),e,r,n,i,a,1);break}}function Bu(t){const e=t.prev,r=t,n=t.next;if(Ku(e,r,n)>=0)return!1;let i=t.next.next;for(;i!==t.prev;){if(Yu(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Ku(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function zu(t,e,r,n){const i=t.prev,a=t,o=t.next;if(Ku(i,a,o)>=0)return!1;const s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,c=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=qu(s,l,e,r,n),d=qu(u,c,e,r,n);let f=t.prevZ,p=t.nextZ;for(;f&&f.z>=h&&p&&p.z<=d;){if(f!==t.prev&&f!==t.next&&Yu(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Ku(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,p!==t.prev&&p!==t.next&&Yu(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Ku(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&Yu(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Ku(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&Yu(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Ku(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Gu(t,e,r){let n=t;do{const i=n.prev,a=n.next.next;!Ju(i,a)&&Qu(i,n,n.next,a)&&ec(i,a)&&ec(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),ic(n),ic(n.next),n=t=a),n=n.next}while(n!==t);return Nu(n)}function ju(t,e,r,n,i,a){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Zu(o,t)){let s=rc(o,t);return o=Nu(o,o.next),s=Nu(s,s.next),Uu(o,e,r,n,i,a),void Uu(s,e,r,n,i,a)}t=t.next}o=o.next}while(o!==t)}function Vu(t,e){return t.x-e.x}function Hu(t,e){if(e=function(t,e){let r=e;const n=t.x,i=t.y;let a,o=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>o){if(o=t,t===n){if(i===r.y)return r;if(i===r.next.y)return r.next}a=r.x=r.x&&r.x>=l&&n!==r.x&&Yu(ia.x||r.x===a.x&&Wu(a,r)))&&(a=r,h=c)),r=r.next}while(r!==s);return a}(t,e),e){const r=rc(e,t);Nu(e,e.next),Nu(r,r.next)}}function Wu(t,e){return Ku(t.prev,t,e.prev)<0&&Ku(e.next,t,t.next)<0}function qu(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Xu(t){let e=t,r=t;do{(e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function Zu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Qu(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(ec(t,e)&&ec(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(Ku(t.prev,t,e.prev)||Ku(t,e.prev,e))||Ju(t,e)&&Ku(t.prev,t,t.next)>0&&Ku(e.prev,e,e.next)>0)}function Ku(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Ju(t,e){return t.x===e.x&&t.y===e.y}function Qu(t,e,r,n){const i=tc(Ku(t,e,r)),a=tc(Ku(t,e,n)),o=tc(Ku(r,n,t)),s=tc(Ku(r,n,e));return i!==a&&o!==s||(!(0!==i||!$u(t,r,e))||(!(0!==a||!$u(t,n,e))||(!(0!==o||!$u(r,t,n))||!(0!==s||!$u(r,e,n)))))}function $u(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function tc(t){return t>0?1:t<0?-1:0}function ec(t,e){return Ku(t.prev,t,t.next)<0?Ku(t,e,t.next)>=0&&Ku(t,t.prev,e)>=0:Ku(t,e,t.prev)<0||Ku(t,t.next,e)<0}function rc(t,e){const r=new ac(t.i,t.x,t.y),n=new ac(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function nc(t,e,r,n){const i=new ac(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ic(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ac(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class oc{static area(t){const e=t.length;let r=0;for(let n=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function lc(t,e){for(let r=0;rNumber.EPSILON){const h=Math.sqrt(c),d=Math.sqrt(l*l+u*u),f=e.x-s/h,p=e.y+o/h,m=((r.x-u/d-f)*u-(r.y+l/d-p)*l)/(o*u-s*l);n=f+o*m-t.x,i=p+s*m-t.y;const g=n*n+i*i;if(g<=2)return new or(n,i);a=Math.sqrt(g/2)}else{let t=!1;o>Number.EPSILON?l>Number.EPSILON&&(t=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(s)===Math.sign(u)&&(t=!0),t?(n=-s,i=o,a=Math.sqrt(c)):(n=o,i=s,a=Math.sqrt(c/2))}return new or(n/a,i/a)}const I=[];for(let t=0,e=E.length,r=e-1,n=t+1;t=0;t--){const e=t/f,r=c*Math.cos(e*Math.PI/2),n=h*Math.sin(e*Math.PI/2)+d;for(let t=0,e=E.length;t=0;){const n=r;let i=r-1;i<0&&(i=t.length-1);for(let t=0,r=s+2*f;t0)&&d.push(e,i,l),(t!==r-1||s0!=t>0&&this.version++,this._sheen=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}Ec.prototype.isMeshPhysicalMaterial=!0;class Ac extends Bn{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new qn(16777215),this.specular=new qn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ge,this.normalScale=new or(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=j,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this}}Ac.prototype.isMeshPhongMaterial=!0;class Pc extends Bn{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new qn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ge,this.normalScale=new or(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Pc.prototype.isMeshToonMaterial=!0;class Rc extends Bn{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ge,this.normalScale=new or(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}Rc.prototype.isMeshNormalMaterial=!0;class Cc extends Bn{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new qn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=j,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Cc.prototype.isMeshLambertMaterial=!0;class Ic extends Bn{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new qn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ge,this.normalScale=new or(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this}}Ic.prototype.isMeshMatcapMaterial=!0;class Lc extends kl{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}Lc.prototype.isLineDashedMaterial=!0;var Oc=Object.freeze({__proto__:null,ShadowMaterial:Sc,SpriteMaterial:$s,RawShaderMaterial:ha,ShaderMaterial:Ui,PointsMaterial:ql,MeshPhysicalMaterial:Ec,MeshStandardMaterial:Tc,MeshPhongMaterial:Ac,MeshToonMaterial:Pc,MeshNormalMaterial:Rc,MeshLambertMaterial:Cc,MeshDepthMaterial:Cs,MeshDistanceMaterial:Is,MeshBasicMaterial:Xn,MeshMatcapMaterial:Ic,LineDashedMaterial:Lc,LineBasicMaterial:kl,Material:Bn});const Dc={arraySlice:function(t,e,r){return Dc.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,r=new Array(e);for(let t=0;t!==e;++t)r[t]=t;return r.sort((function(e,r){return t[e]-t[r]})),r},sortedArray:function(t,e,r){const n=t.length,i=new t.constructor(n);for(let a=0,o=0;o!==n;++a){const n=r[a]*e;for(let r=0;r!==e;++r)i[o++]=t[n+r]}return i},flattenJSON:function(t,e,r,n){let i=1,a=t[0];for(;void 0!==a&&void 0===a[n];)a=t[i++];if(void 0===a)return;let o=a[n];if(void 0!==o)if(Array.isArray(o))do{o=a[n],void 0!==o&&(e.push(a.time),r.push.apply(r,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{o=a[n],void 0!==o&&(e.push(a.time),o.toArray(r,r.length)),a=t[i++]}while(void 0!==a);else do{o=a[n],void 0!==o&&(e.push(a.time),r.push(o)),a=t[i++]}while(void 0!==a)},subclip:function(t,e,r,n,i=30){const a=t.clone();a.name=e;const o=[];for(let t=0;t=n)){l.push(e.times[t]);for(let r=0;ra.tracks[t].times[0]&&(s=a.tracks[t].times[0]);for(let t=0;t=n.times[h]){const t=h*l+s,e=t+l-s;d=Dc.arraySlice(n.values,t,e)}else{const t=n.createInterpolant(),e=s,r=l-s;t.evaluate(a),d=Dc.arraySlice(t.resultBuffer,e,r)}if("quaternion"===i){(new br).fromArray(d).normalize().conjugate().toArray(d)}const f=o.times.length;for(let t=0;t=i)break t;{const o=e[1];t=i)break e}a=r,r=0}}for(;r>>1;te;)--a;if(++a,0!==i||a!==n){i>=a&&(a=Math.max(a,1),i=a-1);const t=this.getValueSize();this.times=Dc.arraySlice(r,i,a),this.values=Dc.arraySlice(this.values,i*t,a*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const r=this.times,n=this.values,i=r.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let e=0;e!==i;e++){const n=r[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==a&&a>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,a),t=!1;break}a=n}if(void 0!==n&&Dc.isTypedArray(n))for(let e=0,r=n.length;e!==r;++e){const r=n[e];if(isNaN(r)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,r),t=!1;break}}return t}optimize(){const t=Dc.arraySlice(this.times),e=Dc.arraySlice(this.values),r=this.getValueSize(),n=this.getInterpolation()===Ae,i=t.length-1;let a=1;for(let o=1;o0){t[a]=t[i];for(let t=i*r,n=a*r,o=0;o!==r;++o)e[n+o]=e[t+o];++a}return a!==t.length?(this.times=Dc.arraySlice(t,0,a),this.values=Dc.arraySlice(e,0,a*r)):(this.times=t,this.values=e),this}clone(){const t=Dc.arraySlice(this.times,0),e=Dc.arraySlice(this.values,0),r=new(0,this.constructor)(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}}Bc.prototype.TimeBufferType=Float32Array,Bc.prototype.ValueBufferType=Float32Array,Bc.prototype.DefaultInterpolation=Ee;class zc extends Bc{}zc.prototype.ValueTypeName="bool",zc.prototype.ValueBufferType=Array,zc.prototype.DefaultInterpolation=Te,zc.prototype.InterpolantFactoryMethodLinear=void 0,zc.prototype.InterpolantFactoryMethodSmooth=void 0;class Gc extends Bc{}Gc.prototype.ValueTypeName="color";class jc extends Bc{}jc.prototype.ValueTypeName="number";class Vc extends kc{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(r-e)/(n-e);let l=t*o;for(let t=l+o;l!==t;l+=4)br.slerpFlat(i,0,a,l-o,a,l,s);return i}}class Hc extends Bc{InterpolantFactoryMethodLinear(t){return new Vc(this.times,this.values,this.getValueSize(),t)}}Hc.prototype.ValueTypeName="quaternion",Hc.prototype.DefaultInterpolation=Ee,Hc.prototype.InterpolantFactoryMethodSmooth=void 0;class Wc extends Bc{}Wc.prototype.ValueTypeName="string",Wc.prototype.ValueBufferType=Array,Wc.prototype.DefaultInterpolation=Te,Wc.prototype.InterpolantFactoryMethodLinear=void 0,Wc.prototype.InterpolantFactoryMethodSmooth=void 0;class qc extends Bc{}qc.prototype.ValueTypeName="vector";class Xc{constructor(t,e=-1,r,n=2500){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=Qe(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],r=t.tracks,n=1/(t.fps||1);for(let t=0,i=r.length;t!==i;++t)e.push(Yc(r[t]).scale(n));const i=new this(t.name,t.duration,e,t.blendMode);return i.uuid=t.uuid,i}static toJSON(t){const e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=r.length;t!==n;++t)e.push(Bc.toJSON(r[t]));return n}static CreateFromMorphTargetSequence(t,e,r,n){const i=e.length,a=[];for(let t=0;t1){const t=a[1];let e=n[t];e||(n[t]=e=[]),e.push(r)}}const a=[];for(const t in n)a.push(this.CreateFromMorphTargetSequence(t,n[t],e,r));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const r=function(t,e,r,n,i){if(0!==r.length){const a=[],o=[];Dc.flattenJSON(r,a,o,n),0!==a.length&&i.push(new t(e,a,o))}},n=[],i=t.name||"default",a=t.fps||30,o=t.blendMode;let s=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(i),this.manager.itemEnd(t)}),0),i;if(void 0!==$c[t])return void $c[t].push({onLoad:e,onProgress:r,onError:n});$c[t]=[],$c[t].push({onLoad:e,onProgress:r,onError:n});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});fetch(a).then((e=>{if(200===e.status||0===e.status){0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");const r=$c[t],n=e.body.getReader(),i=e.headers.get("Content-Length"),a=i?parseInt(i):0,o=0!==a;let s=0;return new ReadableStream({start(t){!function e(){n.read().then((({done:n,value:i})=>{if(n)t.close();else{s+=i.byteLength;const n=new ProgressEvent("progress",{lengthComputable:o,loaded:s,total:a});for(let t=0,e=r.length;t{const e=new Response(t);switch(this.responseType){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((t=>(new DOMParser).parseFromString(t,this.mimeType)));case"json":return e.json();default:return e.text()}})).then((e=>{Zc.add(t,e);const r=$c[t];delete $c[t];for(let t=0,n=r.length;t{const r=$c[t];delete $c[t];for(let t=0,n=r.length;t0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const i=t.uniforms[e];switch(n.uniforms[e]={},i.type){case"t":n.uniforms[e].value=r(i.value);break;case"c":n.uniforms[e].value=(new qn).setHex(i.value);break;case"v2":n.uniforms[e].value=(new or).fromArray(i.value);break;case"v3":n.uniforms[e].value=(new Mr).fromArray(i.value);break;case"v4":n.uniforms[e].value=(new yr).fromArray(i.value);break;case"m3":n.uniforms[e].value=(new sr).fromArray(i.value);break;case"m4":n.uniforms[e].value=(new tn).fromArray(i.value);break;default:n.uniforms[e].value=i.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(n.flatShading=1===t.shading),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=r(t.map)),void 0!==t.matcap&&(n.matcap=r(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=r(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=r(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=r(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new or).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=r(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=r(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=r(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=r(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=r(t.specularMap)),void 0!==t.specularIntensityMap&&(n.specularIntensityMap=r(t.specularIntensityMap)),void 0!==t.specularColorMap&&(n.specularColorMap=r(t.specularColorMap)),void 0!==t.envMap&&(n.envMap=r(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=r(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=r(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=r(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=r(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=r(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=r(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new or).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(n.transmissionMap=r(t.transmissionMap)),void 0!==t.thicknessMap&&(n.thicknessMap=r(t.thicknessMap)),void 0!==t.sheenColorMap&&(n.sheenColorMap=r(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(n.sheenRoughnessMap=r(t.sheenRoughnessMap)),n}setTextures(t){return this.textures=t,this}}class Th{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let r=0,n=t.length;r0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let t=e,i=e+e;t!==i;++t)if(r[t]!==r[t+e]){o.setValue(r,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let t=r,i=n;t!==i;++t)e[t]=e[n+t%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r=.5)for(let n=0;n!==i;++n)t[e+n]=t[r+n]}_slerp(t,e,r,n){br.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,i){const a=this._workIndex*i;br.multiplyQuaternionsFlat(t,a,t,e,t,r),br.slerpFlat(t,e,t,e,t,a,n)}_lerp(t,e,r,n,i){const a=1-n;for(let o=0;o!==i;++o){const i=e+o;t[i]=t[i]*a+t[r+o]*n}}_lerpAdditive(t,e,r,n,i){for(let a=0;a!==i;++a){const i=e+a;t[i]=t[i]+t[r+a]*n}}}const $h="\\[\\]\\.:\\/",td=new RegExp("["+$h+"]","g"),ed="[^"+$h+"]",rd="[^"+$h.replace("\\.","")+"]",nd=/((?:WC+[\/:])*)/.source.replace("WC",ed),id=/(WCOD+)?/.source.replace("WCOD",rd),ad=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ed),od=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ed),sd=new RegExp("^"+nd+id+ad+od+"$"),ld=["material","materials","bones"];class ud{constructor(t,e,r){this.path=e,this.parsedPath=r||ud.parseTrackName(e),this.node=ud.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new ud.Composite(t,e,r):new ud(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(td,"")}static parseTrackName(t){const e=sd.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=r.nodeName.substring(n+1);-1!==ld.indexOf(t)&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=t)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const r=t.skeleton.getBoneByName(e);if(void 0!==r)return r}if(t.children){const r=function(t){for(let n=0;n=i){const a=i++,u=t[a];e[u.uuid]=l,t[l]=u,e[s]=a,t[a]=o;for(let t=0,e=n;t!==e;++t){const e=r[t],n=e[a],i=e[l];e[l]=n,e[a]=i}}}this.nCachedObjects_=i}uncache(){const t=this._objects,e=this._indicesByUUID,r=this._bindings,n=r.length;let i=this.nCachedObjects_,a=t.length;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o].uuid,l=e[s];if(void 0!==l)if(delete e[s],l0&&(e[o.uuid]=l),t[l]=o,t.pop();for(let t=0,e=n;t!==e;++t){const e=r[t];e[l]=e[i],e.pop()}}}this.nCachedObjects_=i}subscribe_(t,e){const r=this._bindingsIndicesByPath;let n=r[t];const i=this._bindings;if(void 0!==n)return i[n];const a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,u=this.nCachedObjects_,c=new Array(l);n=i.length,r[t]=n,a.push(t),o.push(e),i.push(c);for(let r=u,n=s.length;r!==n;++r){const n=s[r];c[r]=new ud(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,r=e[t];if(void 0!==r){const n=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];e[t[o]]=r,a[r]=s,a.pop(),i[r]=i[o],i.pop(),n[r]=n[o],n.pop()}}}cd.prototype.isAnimationObjectGroup=!0;class hd{constructor(t,e,r=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=n;const i=e.tracks,a=i.length,o=new Array(a),s={endingStart:Pe,endingEnd:Pe};for(let t=0;t!==a;++t){const e=i[t].createInterpolant(null);o[t]=e,e.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){const r=this._clip.duration,n=t._clip.duration,i=n/r,a=r/n;t.warp(1,i,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){const n=this._mixer,i=n.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const s=o.parameterPositions,l=o.sampleValues;return s[0]=i,s[1]=i+r,l[0]=t/a,l[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,n){if(!this.enabled)return void this._updateWeight(t);const i=this._startTime;if(null!==i){const n=(t-i)*r;if(n<0||0===r)return;this._startTime=null,e=r*n}e*=this._updateTimeScale(t);const a=this._updateTime(e),o=this._updateWeight(t);if(o>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Le)for(let r=0,n=t.length;r!==n;++r)t[r].evaluate(a),e[r].accumulateAdditive(o);else for(let r=0,i=t.length;r!==i;++r)t[r].evaluate(a),e[r].accumulate(n,o)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const r=this._weightInterpolant;if(null!==r){const n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const r=this._timeScaleInterpolant;if(null!==r){e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,r=this.loop;let n=this.time+t,i=this._loopCount;const a=2202===r;if(0===t)return-1===i?n:a&&1==(1&i)?e-n:n;if(2200===r){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),n>=e||n<0){const r=Math.floor(n/e);n-=e*r,i+=Math.abs(r);const o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===o){const e=t<0;this._setEndings(e,!e,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})}}else this.time=n;if(a&&1==(1&i))return e-n}return n}_setEndings(t,e,r){const n=this._interpolantSettings;r?(n.endingStart=Re,n.endingEnd=Re):(n.endingStart=t?this.zeroSlopeAtStart?Re:Pe:Ce,n.endingEnd=e?this.zeroSlopeAtEnd?Re:Pe:Ce)}_scheduleFading(t,e,r){const n=this._mixer,i=n.time;let a=this._weightInterpolant;null===a&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=r,this}}class dd extends Xe{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,a=t._propertyBindings,o=t._interpolants,s=r.uuid,l=this._bindingsByRootAndName;let u=l[s];void 0===u&&(u={},l[s]=u);for(let t=0;t!==i;++t){const i=n[t],l=i.name;let c=u[l];if(void 0!==c)a[t]=c;else{if(c=a[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,s,l));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new Qh(ud.create(r,l,n),i.ValueTypeName,i.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,s,l),a[t]=c}o[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}const e=t._propertyBindings;for(let t=0,r=e.length;t!==r;++t){const r=e[t];0==r.useCount++&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,r=e.length;t!==r;++t){const r=e[t];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,r=this._nActiveActions,n=this.time+=t,i=Math.sign(t),a=this._accuIndex^=1;for(let o=0;o!==r;++o){e[o]._update(n,t,i,a)}const o=this._bindings,s=this._nActiveBindings;for(let t=0;t!==s;++t)o[t].apply(a);return this}setTime(t){this.time=0;for(let t=0;tthis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return xd.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}_d.prototype.isBox2=!0;const wd=new Mr,bd=new Mr;class Md{constructor(t=new Mr,e=new Mr){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){wd.subVectors(t,this.start),bd.subVectors(this.end,this.start);const r=bd.dot(bd);let n=bd.dot(wd)/r;return e&&(n=$e(n,0,1)),n}closestPointToPoint(t,e,r){const n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Sd=new Mr;const Td=new Mr,Ed=new tn,Ad=new tn;class Pd extends Hl{constructor(t){const e=Rd(t),r=new pi,n=[],i=[],a=new qn(0,0,1),o=new qn(0,1,0);for(let t=0;t.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{jd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(jd,e)}}setLength(t,e=.2*t,r=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}},Audio:qh,AudioAnalyser:Jh,AudioContext:Oh,AudioListener:class extends En{constructor(){super(),this.type="AudioListener",this.context=Oh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new zh}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,r=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(jh,Vh,Hh),Wh.set(0,0,-1).applyQuaternion(Vh),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(jh.x,t),e.positionY.linearRampToValueAtTime(jh.y,t),e.positionZ.linearRampToValueAtTime(jh.z,t),e.forwardX.linearRampToValueAtTime(Wh.x,t),e.forwardY.linearRampToValueAtTime(Wh.y,t),e.forwardZ.linearRampToValueAtTime(Wh.z,t),e.upX.linearRampToValueAtTime(r.x,t),e.upY.linearRampToValueAtTime(r.y,t),e.upZ.linearRampToValueAtTime(r.z,t)}else e.setPosition(jh.x,jh.y,jh.z),e.setOrientation(Wh.x,Wh.y,Wh.z,r.x,r.y,r.z)}},AudioLoader:Dh,AxesHelper:Wd,AxisHelper:function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Wd(t)},BackSide:c,BasicDepthPacking:3200,BasicShadowMap:0,BinaryTextureLoader:function(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new nh(t)},Bone:Sl,BooleanKeyframeTrack:zc,BoundingBoxHelper:function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Gd(t,e)},Box2:_d,Box3:Er,Box3Helper:class extends Hl{constructor(t,e=16776960){const r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new pi;n.setIndex(new Kn(r,1)),n.setAttribute("position",new ai([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new kl({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}},BoxBufferGeometry:Di,BoxGeometry:Di,BoxHelper:Gd,BufferAttribute:Kn,BufferGeometry:pi,BufferGeometryLoader:Ah,ByteType:pt,Cache:Zc,Camera:Bi,CameraHelper:class extends Hl{constructor(t){const e=new pi,r=new kl({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],i=[],a={},o=new qn(16755200),s=new qn(16711680),l=new qn(43775),u=new qn(16777215),c=new qn(3355443);function h(t,e,r){d(t,r),d(e,r)}function d(t,e){n.push(0,0,0),i.push(e.r,e.g,e.b),void 0===a[t]&&(a[t]=[]),a[t].push(n.length/3-1)}h("n1","n2",o),h("n2","n4",o),h("n4","n3",o),h("n3","n1",o),h("f1","f2",o),h("f2","f4",o),h("f4","f3",o),h("f3","f1",o),h("n1","f1",o),h("n2","f2",o),h("n3","f3",o),h("n4","f4",o),h("p","n1",s),h("p","n2",s),h("p","n3",s),h("p","n4",s),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",u),h("p","c",c),h("cn1","cn2",c),h("cn3","cn4",c),h("cf1","cf2",c),h("cf3","cf4",c),e.setAttribute("position",new ai(n,3)),e.setAttribute("color",new ai(i,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){const t=this.geometry,e=this.pointMap;Ud.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Bd("c",e,t,Ud,0,0,-1),Bd("t",e,t,Ud,0,0,1),Bd("n1",e,t,Ud,-1,-1,-1),Bd("n2",e,t,Ud,1,-1,-1),Bd("n3",e,t,Ud,-1,1,-1),Bd("n4",e,t,Ud,1,1,-1),Bd("f1",e,t,Ud,-1,-1,1),Bd("f2",e,t,Ud,1,-1,1),Bd("f3",e,t,Ud,-1,1,1),Bd("f4",e,t,Ud,1,1,1),Bd("u1",e,t,Ud,.7,1.1,-1),Bd("u2",e,t,Ud,-.7,1.1,-1),Bd("u3",e,t,Ud,0,2,-1),Bd("cf1",e,t,Ud,-1,0,1),Bd("cf2",e,t,Ud,1,0,1),Bd("cf3",e,t,Ud,0,-1,1),Bd("cf4",e,t,Ud,0,1,1),Bd("cn1",e,t,Ud,-1,0,-1),Bd("cn2",e,t,Ud,1,0,-1),Bd("cn3",e,t,Ud,0,-1,-1),Bd("cn4",e,t,Ud,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasRenderer:function(){console.error("THREE.CanvasRenderer has been removed")},CanvasTexture:eu,CatmullRomCurve3:_u,CineonToneMapping:Y,CircleBufferGeometry:ru,CircleGeometry:ru,ClampToEdgeWrapping:at,Clock:zh,Color:qn,ColorKeyframeTrack:Gc,CompressedTexture:tu,CompressedTextureLoader:class extends Qc{constructor(t){super(t)}load(t,e,r,n){const i=this,a=[],o=new tu,s=new th(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let l=0;function u(u){s.load(t[u],(function(t){const r=i.parse(t,!0);a[u]={width:r.width,height:r.height,format:r.format,mipmaps:r.mipmaps},l+=1,6===l&&(1===r.mipmapCount&&(o.minFilter=ct),o.image=a,o.format=r.format,o.needsUpdate=!0,e&&e(o))}),r,n)}if(Array.isArray(t))for(let e=0,r=t.length;e65504&&(console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."),t=65504),qd[0]=t;const e=Xd[0];let r=e>>16&32768,n=e>>12&2047;const i=e>>23&255;return i<103?r:i>142?(r|=31744,r|=(255==i?0:1)&&8388607&e,r):i<113?(n|=2048,r|=(n>>114-i)+(n>>113-i&1),r):(r|=i-112<<10|n>>1,r+=1&n,r)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:Jc,DepthFormat:It,DepthStencilFormat:Lt,DepthTexture:js,DirectionalLight:xh,DirectionalLightHelper:class extends En{constructor(t,e,r){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,void 0===e&&(e=1);let n=new pi;n.setAttribute("position",new ai([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const i=new kl({fog:!1,toneMapped:!1});this.lightPlane=new Gl(n,i),this.add(this.lightPlane),n=new pi,n.setAttribute("position",new ai([0,0,0,0,0,1],3)),this.targetLine=new Gl(n,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){Dd.setFromMatrixPosition(this.light.matrixWorld),kd.setFromMatrixPosition(this.light.target.matrixWorld),Fd.subVectors(kd,Dd),this.lightPlane.lookAt(kd),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(kd),this.targetLine.scale.z=Fd.length()}},DiscreteInterpolant:Uc,DodecahedronBufferGeometry:ou,DodecahedronGeometry:ou,DoubleSide:h,DstAlphaFactor:R,DstColorFactor:I,DynamicBufferAttribute:function(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new Kn(t,e).setUsage(We)},DynamicCopyUsage:35050,DynamicDrawUsage:We,DynamicReadUsage:35049,EdgesGeometry:hu,EdgesHelper:function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Hl(new hu(t.geometry),new kl({color:void 0!==e?e:16777215}))},EllipseCurve:fu,EqualDepth:U,EqualStencilFunc:514,EquirectangularReflectionMapping:tt,EquirectangularRefractionMapping:et,Euler:hn,EventDispatcher:Xe,ExtrudeBufferGeometry:uc,ExtrudeGeometry:uc,FaceColors:1,FileLoader:th,FlatShading:1,Float16BufferAttribute:ii,Float32Attribute:function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new ai(t,e)},Float32BufferAttribute:ai,Float64Attribute:function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new oi(t,e)},Float64BufferAttribute:oi,FloatType:xt,Fog:Ys,FogExp2:Xs,Font:function(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")},FontLoader:function(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")},FrontSide:u,Frustum:Ji,GLBufferAttribute:md,GLSL1:"100",GLSL3:qe,GammaEncoding:ke,GreaterDepth:z,GreaterEqualDepth:B,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:Od,Group:Bs,HalfFloatType:_t,HemisphereLight:oh,HemisphereLightHelper:class extends En{constructor(t,e,r){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r;const n=new fc(e);n.rotateY(.5*Math.PI),this.material=new Xn({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=n.getAttribute("position"),a=new Float32Array(3*i.count);n.setAttribute("color",new Kn(a,3)),this.add(new Li(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Id.copy(this.light.color),Ld.copy(this.light.groundColor);for(let t=0,r=e.count;t0){const r=new Kc(e);i=new eh(r),i.setCrossOrigin(this.crossOrigin);for(let e=0,r=t.length;e0){n=new eh(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;eNumber.EPSILON){if(l<0&&(r=e[a],s=-s,o=e[i],l=-l),t.yo.y)continue;if(t.y===r.y){if(t.x===r.x)return!0}else{const e=l*(t.x-r.x)-s*(t.y-r.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==r.y)continue;if(o.x<=t.x&&t.x<=r.x||r.x<=t.x&&t.x<=o.x)return!0}}return n}const i=oc.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return r(a);let o,s,l;const u=[];if(1===a.length)return s=a[0],l=new Du,l.curves=s.curves,u.push(l),u;let c=!i(a[0].getPoints());c=t?!c:c;const h=[],d=[];let f,p,m=[],g=0;d[g]=void 0,m[g]=[];for(let e=0,r=a.length;e1){let t=!1;const e=[];for(let t=0,e=d.length;t0&&(t||(m=h))}for(let t=0,e=d.length;tMath.PI&&(g-=m),v<-Math.PI?v+=m:v>Math.PI&&(v-=m),l.theta=g<=v?Math.max(g,Math.min(v,l.theta)):l.theta>(g+v)/2?Math.max(g,l.theta):Math.min(v,l.theta)),l.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,l.phi)),l.makeSafe(),l.radius*=c,l.radius=Math.max(i.minDistance,Math.min(i.maxDistance,l.radius)),!0===i.enableDamping?i.target.addScaledVector(h,i.dampingFactor):i.target.add(h),e.setFromSpherical(l),e.applyQuaternion(n),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(u.theta*=1-i.dampingFactor,u.phi*=1-i.dampingFactor,h.multiplyScalar(1-i.dampingFactor)):(u.set(0,0,0),h.set(0,0,0)),c=1,!!(d||f.distanceToSquared(i.object.position)>s||8*(1-p.dot(i.object.quaternion))>s)&&(i.dispatchEvent(Kd),f.copy(i.object.position),p.copy(i.object.quaternion),d=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",q),i.domElement.removeEventListener("pointerdown",z),i.domElement.removeEventListener("pointercancel",V),i.domElement.removeEventListener("wheel",H),i.domElement.removeEventListener("pointermove",G),i.domElement.removeEventListener("pointerup",j),null!==i._domElementKeyEvents&&i._domElementKeyEvents.removeEventListener("keydown",W)};const i=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let o=a.NONE;const s=1e-6,l=new yd,u=new yd;let c=1;const h=new Mr;let d=!1;const f=new or,p=new or,m=new or,g=new or,v=new or,y=new or,x=new or,_=new or,w=new or,b=[],M={};function S(){return Math.pow(.95,i.zoomSpeed)}function T(t){u.theta-=t}function E(t){u.phi-=t}const A=function(){const t=new Mr;return function(e,r){t.setFromMatrixColumn(r,0),t.multiplyScalar(-e),h.add(t)}}(),P=function(){const t=new Mr;return function(e,r){!0===i.screenSpacePanning?t.setFromMatrixColumn(r,1):(t.setFromMatrixColumn(r,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),h.add(t)}}(),R=function(){const t=new Mr;return function(e,r){const n=i.domElement;if(i.object.isPerspectiveCamera){const a=i.object.position;t.copy(a).sub(i.target);let o=t.length();o*=Math.tan(i.object.fov/2*Math.PI/180),A(2*e*o/n.clientHeight,i.object.matrix),P(2*r*o/n.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(A(e*(i.object.right-i.object.left)/i.object.zoom/n.clientWidth,i.object.matrix),P(r*(i.object.top-i.object.bottom)/i.object.zoom/n.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function C(t){i.object.isPerspectiveCamera?c/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),d=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function I(t){i.object.isPerspectiveCamera?c*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),d=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function L(t){f.set(t.clientX,t.clientY)}function O(t){g.set(t.clientX,t.clientY)}function D(){if(1===b.length)f.set(b[0].pageX,b[0].pageY);else{const t=.5*(b[0].pageX+b[1].pageX),e=.5*(b[0].pageY+b[1].pageY);f.set(t,e)}}function k(){if(1===b.length)g.set(b[0].pageX,b[0].pageY);else{const t=.5*(b[0].pageX+b[1].pageX),e=.5*(b[0].pageY+b[1].pageY);g.set(t,e)}}function F(){const t=b[0].pageX-b[1].pageX,e=b[0].pageY-b[1].pageY,r=Math.sqrt(t*t+e*e);x.set(0,r)}function N(t){if(1==b.length)p.set(t.pageX,t.pageY);else{const e=Z(t),r=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);p.set(r,n)}m.subVectors(p,f).multiplyScalar(i.rotateSpeed);const e=i.domElement;T(2*Math.PI*m.x/e.clientHeight),E(2*Math.PI*m.y/e.clientHeight),f.copy(p)}function U(t){if(1===b.length)v.set(t.pageX,t.pageY);else{const e=Z(t),r=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);v.set(r,n)}y.subVectors(v,g).multiplyScalar(i.panSpeed),R(y.x,y.y),g.copy(v)}function B(t){const e=Z(t),r=t.pageX-e.x,n=t.pageY-e.y,a=Math.sqrt(r*r+n*n);_.set(0,a),w.set(0,Math.pow(_.y/x.y,i.zoomSpeed)),C(w.y),x.copy(_)}function z(t){!1!==i.enabled&&(0===b.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",G),i.domElement.addEventListener("pointerup",j)),function(t){b.push(t)}(t),"touch"===t.pointerType?function(t){switch(Y(t),b.length){case 1:switch(i.touches.ONE){case r.ROTATE:if(!1===i.enableRotate)return;D(),o=a.TOUCH_ROTATE;break;case r.PAN:if(!1===i.enablePan)return;k(),o=a.TOUCH_PAN;break;default:o=a.NONE}break;case 2:switch(i.touches.TWO){case r.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&F(),i.enablePan&&k(),o=a.TOUCH_DOLLY_PAN;break;case r.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&F(),i.enableRotate&&D(),o=a.TOUCH_DOLLY_ROTATE;break;default:o=a.NONE}break;default:o=a.NONE}o!==a.NONE&&i.dispatchEvent(Jd)}(t):function(t){let r;switch(t.button){case 0:r=i.mouseButtons.LEFT;break;case 1:r=i.mouseButtons.MIDDLE;break;case 2:r=i.mouseButtons.RIGHT;break;default:r=-1}switch(r){case e.DOLLY:if(!1===i.enableZoom)return;!function(t){x.set(t.clientX,t.clientY)}(t),o=a.DOLLY;break;case e.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;O(t),o=a.PAN}else{if(!1===i.enableRotate)return;L(t),o=a.ROTATE}break;case e.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;L(t),o=a.ROTATE}else{if(!1===i.enablePan)return;O(t),o=a.PAN}break;default:o=a.NONE}o!==a.NONE&&i.dispatchEvent(Jd)}(t))}function G(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(Y(t),o){case a.TOUCH_ROTATE:if(!1===i.enableRotate)return;N(t),i.update();break;case a.TOUCH_PAN:if(!1===i.enablePan)return;U(t),i.update();break;case a.TOUCH_DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&B(t),i.enablePan&&U(t)}(t),i.update();break;case a.TOUCH_DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&B(t),i.enableRotate&&N(t)}(t),i.update();break;default:o=a.NONE}}(t):function(t){if(!1===i.enabled)return;switch(o){case a.ROTATE:if(!1===i.enableRotate)return;!function(t){p.set(t.clientX,t.clientY),m.subVectors(p,f).multiplyScalar(i.rotateSpeed);const e=i.domElement;T(2*Math.PI*m.x/e.clientHeight),E(2*Math.PI*m.y/e.clientHeight),f.copy(p),i.update()}(t);break;case a.DOLLY:if(!1===i.enableZoom)return;!function(t){_.set(t.clientX,t.clientY),w.subVectors(_,x),w.y>0?C(S()):w.y<0&&I(S()),x.copy(_),i.update()}(t);break;case a.PAN:if(!1===i.enablePan)return;!function(t){v.set(t.clientX,t.clientY),y.subVectors(v,g).multiplyScalar(i.panSpeed),R(y.x,y.y),g.copy(v),i.update()}(t)}}(t))}function j(t){X(t),0===b.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",G),i.domElement.removeEventListener("pointerup",j)),i.dispatchEvent(Qd),o=a.NONE}function V(t){X(t)}function H(t){!1!==i.enabled&&!1!==i.enableZoom&&o===a.NONE&&(t.preventDefault(),i.dispatchEvent(Jd),function(t){t.deltaY<0?I(S()):t.deltaY>0&&C(S()),i.update()}(t),i.dispatchEvent(Qd))}function W(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:R(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:R(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:R(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:R(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function q(t){!1!==i.enabled&&t.preventDefault()}function X(t){delete M[t.pointerId];for(let e=0;e=this.text.length)return;t=this.text[this.place++]}switch(this.state){case sp:return this.neutral(t);case 2:return this.keyword(t);case 4:return this.quoted(t);case 5:return this.afterquote(t);case 3:return this.number(t);case-1:return}},fp.prototype.afterquote=function(t){if('"'===t)return this.word+='"',void(this.state=4);if(hp.test(t))return this.word=this.word.trim(),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in afterquote yet, index '+this.place)},fp.prototype.afterItem=function(t){return","===t?(null!==this.word&&this.currentObject.push(this.word),this.word=null,void(this.state=sp)):"]"===t?(this.level--,null!==this.word&&(this.currentObject.push(this.word),this.word=null),this.state=sp,this.currentObject=this.stack.pop(),void(this.currentObject||(this.state=-1))):void 0},fp.prototype.number=function(t){if(!dp.test(t)){if(hp.test(t))return this.word=parseFloat(this.word),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in number yet, index '+this.place)}this.word+=t},fp.prototype.quoted=function(t){'"'!==t?this.word+=t:this.state=5},fp.prototype.keyword=function(t){if(cp.test(t))this.word+=t;else{if("["===t){var e=[];return e.push(this.word),this.level++,null===this.root?this.root=e:this.currentObject.push(e),this.stack.push(this.currentObject),this.currentObject=e,void(this.state=sp)}if(!hp.test(t))throw new Error("havn't handled \""+t+'" in keyword yet, index '+this.place);this.afterItem(t)}},fp.prototype.neutral=function(t){if(up.test(t))return this.word=t,void(this.state=2);if('"'===t)return this.word="",void(this.state=4);if(dp.test(t))return this.word=t,void(this.state=3);if(!hp.test(t))throw new Error("havn't handled \""+t+'" in neutral yet, index '+this.place);this.afterItem(t)},fp.prototype.output=function(){for(;this.place0?90:-90)):(t.lat0=yp(t.lat1>0?90:-90),t.lat_ts=t.lat1)}(i),i}function _p(t){var e=this;if(2===arguments.length){var r=arguments[1];"string"==typeof r?"+"===r.charAt(0)?_p[t]=op(arguments[1]):_p[t]=xp(arguments[1]):_p[t]=r}else if(1===arguments.length){if(Array.isArray(t))return t.map((function(t){Array.isArray(t)?_p.apply(e,t):_p(t)}));if("string"==typeof t){if(t in _p)return _p[t]}else"EPSG"in t?_p["EPSG:"+t.EPSG]=t:"ESRI"in t?_p["ESRI:"+t.ESRI]=t:"IAU2000"in t?_p["IAU2000:"+t.IAU2000]=t:console.log(t);return}}(gp=_p)("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),gp("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),gp("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"),gp.WGS84=gp["EPSG:4326"],gp["EPSG:3785"]=gp["EPSG:3857"],gp.GOOGLE=gp["EPSG:3857"],gp["EPSG:900913"]=gp["EPSG:3857"],gp["EPSG:102113"]=gp["EPSG:3857"];var wp=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];var bp=["3857","900913","3785","102113"];function Mp(t){if(!function(t){return"string"==typeof t}(t))return t;if(function(t){return t in _p}(t))return _p[t];if(function(t){return wp.some((function(e){return t.indexOf(e)>-1}))}(t)){var e=xp(t);if(function(t){var e=ap(t,"authority");if(e){var r=ap(e,"epsg");return r&&bp.indexOf(r)>-1}}(e))return _p["EPSG:3857"];var r=function(t){var e=ap(t,"extension");if(e)return ap(e,"proj4")}(e);return r?op(r):e}return function(t){return"+"===t[0]}(t)?op(t):void 0}function Sp(t,e){var r,n;if(t=t||{},!e)return t;for(n in e)void 0!==(r=e[n])&&(t[n]=r);return t}function Tp(t,e,r){var n=t*e;return r/Math.sqrt(1-n*n)}function Ep(t){return t<0?-1:1}function Ap(t){return Math.abs(t)<=ep?t:t-Ep(t)*tp}function Pp(t,e,r){var n=t*r,i=.5*t;return n=Math.pow((1-n)/(1+n),i),Math.tan(.5*(qf-e))/n}function Rp(t,e){for(var r,n,i=.5*t,a=qf-2*Math.atan(e),o=0;o<=15;o++)if(r=t*Math.sin(a),a+=n=qf-2*Math.atan(e*Math.pow((1-r)/(1+r),i))-a,Math.abs(n)<=1e-10)return a;return-9999}function Cp(t){return t}var Ip=[{init:function(){var t=this.b/this.a;this.es=1-t*t,"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=Tp(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)},forward:function(t){var e,r,n=t.x,i=t.y;if(i*Qf>90&&i*Qf<-90&&n*Qf>180&&n*Qf<-180)return null;if(Math.abs(Math.abs(i)-qf)<=Kf)return null;if(this.sphere)e=this.x0+this.a*this.k0*Ap(n-this.long0),r=this.y0+this.a*this.k0*Math.log(Math.tan($f+.5*i));else{var a=Math.sin(i),o=Pp(this.e,i,a);e=this.x0+this.a*this.k0*Ap(n-this.long0),r=this.y0-this.a*this.k0*Math.log(o)}return t.x=e,t.y=r,t},inverse:function(t){var e,r,n=t.x-this.x0,i=t.y-this.y0;if(this.sphere)r=qf-2*Math.atan(Math.exp(-i/(this.a*this.k0)));else{var a=Math.exp(-i/(this.a*this.k0));if(-9999===(r=Rp(this.e,a)))return null}return e=Ap(this.long0+n/(this.a*this.k0)),t.x=e,t.y=r,t},names:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"]},{init:function(){},forward:Cp,inverse:Cp,names:["longlat","identity"]}],Lp={},Op=[];function Dp(t,e){var r=Op.length;return t.names?(Op[r]=t,t.names.forEach((function(t){Lp[t.toLowerCase()]=r})),this):(console.log(e),!0)}const kp={start:function(){Ip.forEach(Dp)},add:Dp,get:function(t){if(!t)return!1;var e=t.toLowerCase();return void 0!==Lp[e]&&Op[Lp[e]]?Op[Lp[e]]:void 0}};var Fp={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"}},Np=Fp.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};Fp.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};var Up={};Up.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},Up.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},Up.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},Up.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},Up.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},Up.potsdam={towgs84:"598.1,73.7,418.2,0.202,0.045,-2.455,6.7",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},Up.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},Up.hermannskogel={towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Hermannskogel"},Up.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},Up.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},Up.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},Up.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},Up.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"},Up.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},Up.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},Up.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},Up.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};var Bp={};function zp(t){if(0===t.length)return null;var e="@"===t[0];return e&&(t=t.slice(1)),"null"===t?{name:"null",mandatory:!e,grid:null,isNull:!0}:{name:t,mandatory:!e,grid:Bp[t]||null,isNull:!1}}function Gp(t){return t/3600*Math.PI/180}function jp(t,e,r){return String.fromCharCode.apply(null,new Uint8Array(t.buffer.slice(e,r)))}function Vp(t){return t.map((function(t){return[Gp(t.longitudeShift),Gp(t.latitudeShift)]}))}function Hp(t,e,r){return{name:jp(t,e+8,e+16).trim(),parent:jp(t,e+24,e+24+8).trim(),lowerLatitude:t.getFloat64(e+72,r),upperLatitude:t.getFloat64(e+88,r),lowerLongitude:t.getFloat64(e+104,r),upperLongitude:t.getFloat64(e+120,r),latitudeInterval:t.getFloat64(e+136,r),longitudeInterval:t.getFloat64(e+152,r),gridNodeCount:t.getInt32(e+168,r)}}function Wp(t,e,r,n){for(var i=e+176,a=[],o=0;o3&&(0===s.datum_params[3]&&0===s.datum_params[4]&&0===s.datum_params[5]&&0===s.datum_params[6]||(s.datum_type=Uf,s.datum_params[3]*=Wf,s.datum_params[4]*=Wf,s.datum_params[5]*=Wf,s.datum_params[6]=s.datum_params[6]/1e6+1))),o&&(s.datum_type=Bf,s.grids=o),s.a=r,s.b=n,s.es=i,s.ep2=a,s}(r.datumCode,r.datum_params,d.a,d.b,f.es,f.ep2,p);Sp(this,r),Sp(this,n),this.a=d.a,this.b=d.b,this.rf=d.rf,this.sphere=d.sphere,this.es=f.es,this.e=f.e,this.ep2=f.ep2,this.datum=m,this.init(),e(null,this)}else e(t)}else e(t)}function Xp(t,e,r){var n,i,a,o,s=t.x,l=t.y,u=t.z?t.z:0;if(l<-qf&&l>-1.001*qf)l=-qf;else if(l>qf&&l<1.001*qf)l=qf;else{if(l<-qf)return{x:-1/0,y:-1/0,z:t.z};if(l>qf)return{x:1/0,y:1/0,z:t.z}}return s>Math.PI&&(s-=2*Math.PI),i=Math.sin(l),o=Math.cos(l),a=i*i,{x:((n=r/Math.sqrt(1-e*a))+u)*o*Math.cos(s),y:(n+u)*o*Math.sin(s),z:(n*(1-e)+u)*i}}function Yp(t,e,r,n){var i,a,o,s,l,u,c,h,d,f,p,m,g,v,y,x=1e-12,_=t.x,w=t.y,b=t.z?t.z:0;if(i=Math.sqrt(_*_+w*w),a=Math.sqrt(_*_+w*w+b*b),i/r1e-24&&g<30);return{x:v,y:Math.atan(p/Math.abs(f)),z:y}}function Zp(t){return t===Nf||t===Uf}function Kp(t,e,r){if(function(t,e){return t.datum_type===e.datum_type&&!(t.a!==e.a||Math.abs(t.es-e.es)>5e-11)&&(t.datum_type===Nf?t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]:t.datum_type!==Uf||t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]&&t.datum_params[3]===e.datum_params[3]&&t.datum_params[4]===e.datum_params[4]&&t.datum_params[5]===e.datum_params[5]&&t.datum_params[6]===e.datum_params[6])}(t,e))return r;if(t.datum_type===Gf||e.datum_type===Gf)return r;var n=t.a,i=t.es;if(t.datum_type===Bf){if(0!==Jp(t,!1,r))return;n=jf,i=Hf}var a=e.a,o=e.b,s=e.es;if(e.datum_type===Bf&&(a=jf,o=Vf,s=Hf),i===s&&n===a&&!Zp(t.datum_type)&&!Zp(e.datum_type))return r;if((r=Xp(r,i,n),Zp(t.datum_type)&&(r=function(t,e,r){if(e===Nf)return{x:t.x+r[0],y:t.y+r[1],z:t.z+r[2]};if(e===Uf){var n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],u=r[6];return{x:u*(t.x-l*t.y+s*t.z)+n,y:u*(l*t.x+t.y-o*t.z)+i,z:u*(-s*t.x+o*t.y+t.z)+a}}}(r,t.datum_type,t.datum_params)),Zp(e.datum_type)&&(r=function(t,e,r){if(e===Nf)return{x:t.x-r[0],y:t.y-r[1],z:t.z-r[2]};if(e===Uf){var n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],u=r[6],c=(t.x-n)/u,h=(t.y-i)/u,d=(t.z-a)/u;return{x:c+l*h-s*d,y:-l*c+h+o*d,z:s*c-o*h+d}}}(r,e.datum_type,e.datum_params)),r=Yp(r,s,a,o),e.datum_type===Bf)&&0!==Jp(e,!0,r))return;return r}function Jp(t,e,r){if(null===t.grids||0===t.grids.length)return console.log("Grid shift grids not found"),-1;for(var n={x:-r.x,y:r.y},i={x:Number.NaN,y:Number.NaN},a=[],o=0;on.y||c>n.x||f1e-12&&Math.abs(o.y)>1e-12);if(l<0)return console.log("Inverse grid shift iterator failed to converge."),n;n.x=Ap(a.x+r.ll[0]),n.y=a.y+r.ll[1]}else isNaN(a.x)||(n.x=t.x+a.x,n.y=t.y+a.y);return n}function $p(t,e){var r,n={x:t.x/e.del[0],y:t.y/e.del[1]},i=Math.floor(n.x),a=Math.floor(n.y),o=n.x-1*i,s=n.y-1*a,l={x:Number.NaN,y:Number.NaN};if(i<0||i>=e.lim[0])return l;if(a<0||a>=e.lim[1])return l;r=a*e.lim[0]+i;var u=e.cvs[r][0],c=e.cvs[r][1];r++;var h=e.cvs[r][0],d=e.cvs[r][1];r+=e.lim[0];var f=e.cvs[r][0],p=e.cvs[r][1];r--;var m=e.cvs[r][0],g=e.cvs[r][1],v=o*s,y=o*(1-s),x=(1-o)*(1-s),_=(1-o)*s;return l.x=x*u+y*h+_*m+v*f,l.y=x*c+y*d+_*g+v*p,l}function tm(t,e,r){var n,i,a,o=r.x,s=r.y,l=r.z||0,u={};for(a=0;a<3;a++)if(!e||2!==a||void 0!==r.z)switch(0===a?(n=o,i=-1!=="ew".indexOf(t.axis[a])?"x":"y"):1===a?(n=s,i=-1!=="ns".indexOf(t.axis[a])?"y":"x"):(n=l,i="z"),t.axis[a]){case"e":case"n":u[i]=n;break;case"w":case"s":u[i]=-n;break;case"u":void 0!==r[i]&&(u.z=n);break;case"d":void 0!==r[i]&&(u.z=-n);break;default:return null}return u}function em(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e}function rm(t){if("function"==typeof Number.isFinite){if(Number.isFinite(t))return;throw new TypeError("coordinates must be finite numbers")}if("number"!=typeof t||t!=t||!isFinite(t))throw new TypeError("coordinates must be finite numbers")}function nm(t,e,r,n){var i,a=void 0!==(r=Array.isArray(r)?em(r):{x:r.x,y:r.y,z:r.z,m:r.m}).z;if(function(t){rm(t.x),rm(t.y)}(r),t.datum&&e.datum&&function(t,e){return(t.datum.datum_type===Nf||t.datum.datum_type===Uf||t.datum.datum_type===Bf)&&"WGS84"!==e.datumCode||(e.datum.datum_type===Nf||e.datum.datum_type===Uf||e.datum.datum_type===Bf)&&"WGS84"!==t.datumCode}(t,e)&&(r=nm(t,i=new qp("WGS84"),r,n),t=i),n&&"enu"!==t.axis&&(r=tm(t,!1,r)),"longlat"===t.projName)r={x:r.x*Jf,y:r.y*Jf,z:r.z||0};else if(t.to_meter&&(r={x:r.x*t.to_meter,y:r.y*t.to_meter,z:r.z||0}),!(r=t.inverse(r)))return;if(t.from_greenwich&&(r.x+=t.from_greenwich),r=Kp(t.datum,e.datum,r))return e.from_greenwich&&(r={x:r.x-e.from_greenwich,y:r.y,z:r.z||0}),"longlat"===e.projName?r={x:r.x*Qf,y:r.y*Qf,z:r.z||0}:(r=e.forward(r),e.to_meter&&(r={x:r.x/e.to_meter,y:r.y/e.to_meter,z:r.z||0})),n&&"enu"!==e.axis?tm(e,!0,r):(a||delete r.z,r)}qp.projections=kp,qp.projections.start();var im=qp("WGS84");function am(t,e,r,n){var i,a,o;return Array.isArray(r)?(i=nm(t,e,r,n)||{x:NaN,y:NaN},r.length>2?void 0!==t.name&&"geocent"===t.name||void 0!==e.name&&"geocent"===e.name?"number"==typeof i.z?[i.x,i.y,i.z].concat(r.splice(3)):[i.x,i.y,r[2]].concat(r.splice(3)):[i.x,i.y].concat(r.splice(2)):[i.x,i.y]):(a=nm(t,e,r,n),2===(o=Object.keys(r)).length||o.forEach((function(n){if(void 0!==t.name&&"geocent"===t.name||void 0!==e.name&&"geocent"===e.name){if("x"===n||"y"===n||"z"===n)return}else if("x"===n||"y"===n)return;a[n]=r[n]})),a)}function om(t){return t instanceof qp?t:t.oProj?t.oProj:qp(t)}function sm(t,e,r){t=om(t);var n,i=!1;return void 0===e?(e=t,t=im,i=!0):(void 0!==e.x||Array.isArray(e))&&(r=e,e=t,t=im,i=!0),e=om(e),r?am(t,e,r):(n={forward:function(r,n){return am(t,e,r,n)},inverse:function(r,n){return am(e,t,r,n)}},i&&(n.oProj=e),n)}var lm=6,um="AJSAJS",cm="AFAFAF",hm=65,dm=73,fm=79,pm=86,mm=90;const gm={forward:vm,inverse:function(t){var e=wm(Sm(t.toUpperCase()));if(e.lat&&e.lon)return[e.lon,e.lat,e.lon,e.lat];return[e.left,e.bottom,e.right,e.top]},toPoint:ym};function vm(t,e){return e=e||5,function(t,e){var r="00000"+t.easting,n="00000"+t.northing;return t.zoneNumber+t.zoneLetter+(f=t.easting,p=t.northing,m=t.zoneNumber,g=Mm(m),v=Math.floor(f/1e5),y=Math.floor(p/1e5)%20,i=v,a=y,o=g,s=o-1,l=um.charCodeAt(s),u=cm.charCodeAt(s),c=l+i-1,h=u+a,d=!1,c>mm&&(c=c-mm+hm-1,d=!0),(c===dm||ldm||(c>dm||lfm||(c>fm||lmm&&(c=c-mm+hm-1),h>pm?(h=h-pm+hm-1,d=!0):d=!1,(h===dm||udm||(h>dm||ufm||(h>fm||upm&&(h=h-pm+hm-1),String.fromCharCode(c)+String.fromCharCode(h))+r.substr(r.length-5,e)+n.substr(n.length-5,e);var i,a,o,s,l,u,c,h,d;var f,p,m,g,v,y}(function(t){var e,r,n,i,a,o,s,l,u=t.lat,c=t.lon,h=6378137,d=.00669438,f=.9996,p=xm(u),m=xm(c);l=Math.floor((c+180)/6)+1,180===c&&(l=60);u>=56&&u<64&&c>=3&&c<12&&(l=32);u>=72&&u<84&&(c>=0&&c<9?l=31:c>=9&&c<21?l=33:c>=21&&c<33?l=35:c>=33&&c<42&&(l=37));s=xm(6*(l-1)-180+3),e=d/(1-d),r=h/Math.sqrt(1-d*Math.sin(p)*Math.sin(p)),n=Math.tan(p)*Math.tan(p),i=e*Math.cos(p)*Math.cos(p),a=Math.cos(p)*(m-s),o=h*((1-d/4-3*d*d/64-5*d*d*d/256)*p-(3*d/8+3*d*d/32+45*d*d*d/1024)*Math.sin(2*p)+(15*d*d/256+45*d*d*d/1024)*Math.sin(4*p)-35*d*d*d/3072*Math.sin(6*p));var g=f*r*(a+(1-n+i)*a*a*a/6+(5-18*n+n*n+72*i-58*e)*a*a*a*a*a/120)+5e5,v=f*(o+r*Math.tan(p)*(a*a/2+(5-n+9*i+4*i*i)*a*a*a*a/24+(61-58*n+n*n+600*i-330*e)*a*a*a*a*a*a/720));u<0&&(v+=1e7);return{northing:Math.round(v),easting:Math.round(g),zoneNumber:l,zoneLetter:bm(u)}}({lat:t[1],lon:t[0]}),e)}function ym(t){var e=wm(Sm(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function xm(t){return t*(Math.PI/180)}function _m(t){return t/Math.PI*180}function wm(t){var e=t.northing,r=t.easting,n=t.zoneLetter,i=t.zoneNumber;if(i<0||i>60)return null;var a,o,s,l,u,c,h,d,f,p=.9996,m=6378137,g=.00669438,v=(1-Math.sqrt(.99330562))/(1+Math.sqrt(.99330562)),y=r-5e5,x=e;n<"N"&&(x-=1e7),h=6*(i-1)-180+3,a=.006739496752268451,f=(d=x/p/6367449.145945056)+(3*v/2-27*v*v*v/32)*Math.sin(2*d)+(21*v*v/16-55*v*v*v*v/32)*Math.sin(4*d)+151*v*v*v/96*Math.sin(6*d),o=m/Math.sqrt(1-g*Math.sin(f)*Math.sin(f)),s=Math.tan(f)*Math.tan(f),l=a*Math.cos(f)*Math.cos(f),u=.99330562*m/Math.pow(1-g*Math.sin(f)*Math.sin(f),1.5),c=y/(o*p);var _=f-o*Math.tan(f)/u*(c*c/2-(5+3*s+10*l-4*l*l-9*a)*c*c*c*c/24+(61+90*s+298*l+45*s*s-1.6983531815716497-3*l*l)*c*c*c*c*c*c/720);_=_m(_);var w,b=(c-(1+2*s+l)*c*c*c/6+(5-2*l+28*s-3*l*l+8*a+24*s*s)*c*c*c*c*c/120)/Math.cos(f);if(b=h+_m(b),t.accuracy){var M=wm({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});w={top:M.lat,right:M.lon,bottom:_,left:b}}else w={lat:_,lon:b};return w}function bm(t){var e="Z";return 84>=t&&t>=72?e="X":72>t&&t>=64?e="W":64>t&&t>=56?e="V":56>t&&t>=48?e="U":48>t&&t>=40?e="T":40>t&&t>=32?e="S":32>t&&t>=24?e="R":24>t&&t>=16?e="Q":16>t&&t>=8?e="P":8>t&&t>=0?e="N":0>t&&t>=-8?e="M":-8>t&&t>=-16?e="L":-16>t&&t>=-24?e="K":-24>t&&t>=-32?e="J":-32>t&&t>=-40?e="H":-40>t&&t>=-48?e="G":-48>t&&t>=-56?e="F":-56>t&&t>=-64?e="E":-64>t&&t>=-72?e="D":-72>t&&t>=-80&&(e="C"),e}function Mm(t){var e=t%lm;return 0===e&&(e=lm),e}function Sm(t){if(t&&0===t.length)throw"MGRSPoint coverting from nothing";for(var e,r=t.length,n=null,i="",a=0;!/[A-Z]/.test(e=t.charAt(a));){if(a>=2)throw"MGRSPoint bad conversion from: "+t;i+=e,a++}var o=parseInt(i,10);if(0===a||a+3>r)throw"MGRSPoint bad conversion from: "+t;var s=t.charAt(a++);if(s<="A"||"B"===s||"Y"===s||s>="Z"||"I"===s||"O"===s)throw"MGRSPoint zone letter "+s+" not handled: "+t;n=t.substring(a,a+=2);for(var l=Mm(o),u=function(t,e){var r=um.charCodeAt(e-1),n=1e5,i=!1;for(;r!==t.charCodeAt(0);){if(++r===dm&&r++,r===fm&&r++,r>mm){if(i)throw"Bad character: "+t;r=hm,i=!0}n+=1e5}return n}(n.charAt(0),l),c=function(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;var r=cm.charCodeAt(e-1),n=0,i=!1;for(;r!==t.charCodeAt(0);){if(++r===dm&&r++,r===fm&&r++,r>pm){if(i)throw"Bad character: "+t;r=hm,i=!0}n+=1e5}return n}(n.charAt(1),l);c0&&(d=1e5/Math.pow(10,m),f=t.substring(a,a+m),g=parseFloat(f)*d,p=t.substring(a+m),v=parseFloat(p)*d),{easting:g+u,northing:v+c,zoneLetter:s,zoneNumber:o,accuracy:d}}function Tm(t){var e;switch(t){case"C":e=11e5;break;case"D":e=2e6;break;case"E":e=28e5;break;case"F":e=37e5;break;case"G":e=46e5;break;case"H":e=55e5;break;case"J":e=64e5;break;case"K":e=73e5;break;case"L":e=82e5;break;case"M":e=91e5;break;case"N":e=0;break;case"P":e=8e5;break;case"Q":e=17e5;break;case"R":e=26e5;break;case"S":e=35e5;break;case"T":e=44e5;break;case"U":e=53e5;break;case"V":e=62e5;break;case"W":e=7e6;break;case"X":e=79e5;break;default:e=-1}if(e>=0)return e;throw"Invalid zone letter: "+t}function Em(t,e,r){if(!(this instanceof Em))return new Em(t,e,r);if(Array.isArray(t))this.x=t[0],this.y=t[1],this.z=t[2]||0;else if("object"==typeof t)this.x=t.x,this.y=t.y,this.z=t.z||0;else if("string"==typeof t&&void 0===e){var n=t.split(",");this.x=parseFloat(n[0],10),this.y=parseFloat(n[1],10),this.z=parseFloat(n[2],10)||0}else this.x=t,this.y=e,this.z=r||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}Em.fromMGRS=function(t){return new Em(ym(t))},Em.prototype.toMGRS=function(t){return vm([this.x,this.y],t)};var Am=1,Pm=.25,Rm=.046875,Cm=.01953125,Im=.01068115234375,Lm=.75,Om=.46875,Dm=.013020833333333334,km=.007120768229166667,Fm=.3645833333333333,Nm=.005696614583333333,Um=.3076171875;function Bm(t){var e=[];e[0]=Am-t*(Pm+t*(Rm+t*(Cm+t*Im))),e[1]=t*(Lm-t*(Rm+t*(Cm+t*Im)));var r=t*t;return e[2]=r*(Om-t*(Dm+t*km)),r*=t,e[3]=r*(Fm-t*Nm),e[4]=r*t*Um,e}function zm(t,e,r,n){return r*=e,e*=e,n[0]*t-r*(n[1]+e*(n[2]+e*(n[3]+e*n[4])))}var Gm=20;function jm(t,e,r){for(var n=1/(1-e),i=t,a=Gm;a;--a){var o=Math.sin(i),s=1-e*o*o;if(i-=s=(zm(i,o,Math.cos(i),r)-t)*(s*Math.sqrt(s))*n,Math.abs(s)Kf?Math.tan(a):0,p=Math.pow(f,2),m=Math.pow(p,2);e=1-this.es*Math.pow(s,2),u/=Math.sqrt(e);var g=zm(a,s,l,this.en);r=this.a*(this.k0*u*(1+c/6*(1-p+h+c/20*(5-18*p+m+14*h-58*p*h+c/42*(61+179*m-m*p-479*p)))))+this.x0,n=this.a*(this.k0*(g-this.ml0+s*o*u/2*(1+c/12*(5-p+9*h+4*d+c/30*(61+m-58*p+270*h-330*p*h+c/56*(1385+543*m-m*p-3111*p))))))+this.y0}else{var v=l*Math.sin(o);if(Math.abs(Math.abs(v)-1)=1){if(v-1>Kf)return 93;n=0}else n=Math.acos(n);a<0&&(n=-n),n=this.a*this.k0*(n-this.lat0)+this.y0}return t.x=r,t.y=n,t},inverse:function(t){var e,r,n,i,a=(t.x-this.x0)*(1/this.a),o=(t.y-this.y0)*(1/this.a);if(this.es)if(r=jm(e=this.ml0+o/this.k0,this.es,this.en),Math.abs(r)Kf?Math.tan(r):0,c=this.ep2*Math.pow(l,2),h=Math.pow(c,2),d=Math.pow(u,2),f=Math.pow(d,2);e=1-this.es*Math.pow(s,2);var p=a*Math.sqrt(e)/this.k0,m=Math.pow(p,2);n=r-(e*=u)*m/(1-this.es)*.5*(1-m/12*(5+3*d-9*c*d+c-4*h-m/30*(61+90*d-252*c*d+45*f+46*c-m/56*(1385+3633*d+4095*f+1574*f*d)))),i=Ap(this.long0+p*(1-m/6*(1+2*d+c-m/20*(5+28*d+24*f+8*c*d+6*c-m/42*(61+662*d+1320*f+720*f*d))))/l)}else n=qf*Ep(o),i=0;else{var g=Math.exp(a/this.k0),v=.5*(g-1/g),y=this.lat0+o/this.k0,x=Math.cos(y);e=Math.sqrt((1-Math.pow(x,2))/(1+Math.pow(v,2))),n=Math.asin(e),o<0&&(n=-n),i=0===v&&0===x?0:Ap(Math.atan2(v,x)+this.long0)}return t.x=i,t.y=n,t},names:["Fast_Transverse_Mercator","Fast Transverse Mercator"]};function Hm(t){var e=Math.exp(t);return e=(e-1/e)/2}function Wm(t,e){t=Math.abs(t),e=Math.abs(e);var r=Math.max(t,e),n=Math.min(t,e)/(r||1);return r*Math.sqrt(1+Math.pow(n,2))}function qm(t){var e=Math.abs(t);return e=function(t){var e=1+t,r=e-1;return 0===r?t:t*Math.log(e)/r}(e*(1+e/(Wm(1,e)+1))),t<0?-e:e}function Xm(t,e){for(var r,n=2*Math.cos(2*e),i=t.length-1,a=t[i],o=0;--i>=0;)r=n*a-o+t[i],o=a,a=r;return e+r*Math.sin(2*e)}function Ym(t,e,r){for(var n,i,a=Math.sin(e),o=Math.cos(e),s=Hm(r),l=function(t){var e=Math.exp(t);return(e+1/e)/2}(r),u=2*o*l,c=-2*a*s,h=t.length-1,d=t[h],f=0,p=0,m=0;--h>=0;)n=p,i=f,d=u*(p=d)-n-c*(f=m)+t[h],m=c*p-i+u*f;return[(u=a*l)*d-(c=o*s)*m,u*m+c*d]}const Zm={init:function(){if(!this.approx&&(isNaN(this.es)||this.es<=0))throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');this.approx&&(Vm.init.apply(this),this.forward=Vm.forward,this.inverse=Vm.inverse),this.x0=void 0!==this.x0?this.x0:0,this.y0=void 0!==this.y0?this.y0:0,this.long0=void 0!==this.long0?this.long0:0,this.lat0=void 0!==this.lat0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var t=this.es/(1+Math.sqrt(1-this.es)),e=t/(2-t),r=e;this.cgb[0]=e*(2+e*(-2/3+e*(e*(116/45+e*(26/45+e*(-2854/675)))-2))),this.cbg[0]=e*(e*(2/3+e*(4/3+e*(-82/45+e*(32/45+e*(4642/4725)))))-2),r*=e,this.cgb[1]=r*(7/3+e*(e*(-227/45+e*(2704/315+e*(2323/945)))-1.6)),this.cbg[1]=r*(5/3+e*(-16/15+e*(-13/9+e*(904/315+e*(-1522/945))))),r*=e,this.cgb[2]=r*(56/15+e*(-136/35+e*(-1262/105+e*(73814/2835)))),this.cbg[2]=r*(-26/15+e*(34/21+e*(1.6+e*(-12686/2835)))),r*=e,this.cgb[3]=r*(4279/630+e*(-332/35+e*(-399572/14175))),this.cbg[3]=r*(1237/630+e*(e*(-24832/14175)-2.4)),r*=e,this.cgb[4]=r*(4174/315+e*(-144838/6237)),this.cbg[4]=r*(-734/315+e*(109598/31185)),r*=e,this.cgb[5]=r*(601676/22275),this.cbg[5]=r*(444337/155925),r=Math.pow(e,2),this.Qn=this.k0/(1+e)*(1+r*(1/4+r*(1/64+r/256))),this.utg[0]=e*(e*(2/3+e*(-37/96+e*(1/360+e*(81/512+e*(-96199/604800)))))-.5),this.gtu[0]=e*(.5+e*(-2/3+e*(5/16+e*(41/180+e*(-127/288+e*(7891/37800)))))),this.utg[1]=r*(-1/48+e*(-1/15+e*(437/1440+e*(-46/105+e*(1118711/3870720))))),this.gtu[1]=r*(13/48+e*(e*(557/1440+e*(281/630+e*(-1983433/1935360)))-.6)),r*=e,this.utg[2]=r*(-17/480+e*(37/840+e*(209/4480+e*(-5569/90720)))),this.gtu[2]=r*(61/240+e*(-103/140+e*(15061/26880+e*(167603/181440)))),r*=e,this.utg[3]=r*(-4397/161280+e*(11/504+e*(830251/7257600))),this.gtu[3]=r*(49561/161280+e*(-179/168+e*(6601661/7257600))),r*=e,this.utg[4]=r*(-4583/161280+e*(108847/3991680)),this.gtu[4]=r*(34729/80640+e*(-3418889/1995840)),r*=e,this.utg[5]=r*(-20648693/638668800),this.gtu[5]=.6650675310896665*r;var n=Xm(this.cbg,this.lat0);this.Zb=-this.Qn*(n+function(t,e){for(var r,n=2*Math.cos(e),i=t.length-1,a=t[i],o=0;--i>=0;)r=n*a-o+t[i],o=a,a=r;return Math.sin(e)*r}(this.gtu,2*n))},forward:function(t){var e=Ap(t.x-this.long0),r=t.y;r=Xm(this.cbg,r);var n=Math.sin(r),i=Math.cos(r),a=Math.sin(e),o=Math.cos(e);r=Math.atan2(n,o*i),e=Math.atan2(a*i,Wm(n,i*o)),e=qm(Math.tan(e));var s,l,u=Ym(this.gtu,2*r,2*e);return r+=u[0],e+=u[1],Math.abs(e)<=2.623395162778?(s=this.a*(this.Qn*e)+this.x0,l=this.a*(this.Qn*r+this.Zb)+this.y0):(s=1/0,l=1/0),t.x=s,t.y=l,t},inverse:function(t){var e,r,n=(t.x-this.x0)*(1/this.a),i=(t.y-this.y0)*(1/this.a);if(i=(i-this.Zb)/this.Qn,n/=this.Qn,Math.abs(n)<=2.623395162778){var a=Ym(this.utg,2*i,2*n);i+=a[0],n+=a[1],n=Math.atan(Hm(n));var o=Math.sin(i),s=Math.cos(i),l=Math.sin(n),u=Math.cos(n);i=Math.atan2(o*u,Wm(l,u*s)),e=Ap((n=Math.atan2(l,u*s))+this.long0),r=Xm(this.cgb,i)}else e=1/0,r=1/0;return t.x=e,t.y=r,t},names:["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","tmerc"]};const Km={init:function(){var t=function(t,e){if(void 0===t){if((t=Math.floor(30*(Ap(e)+Math.PI)/Math.PI)+1)<0)return 0;if(t>60)return 60}return t}(this.zone,this.long0);if(void 0===t)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(t)-183)*Jf,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,Zm.init.apply(this),this.forward=Zm.forward,this.inverse=Zm.inverse},names:["Universal Transverse Mercator System","utm"],dependsOn:"etmerc"};function Jm(t,e){return Math.pow((1-t)/(1+t),e)}const Qm={init:function(){var t=Math.sin(this.lat0),e=Math.cos(this.lat0);e*=e,this.rc=Math.sqrt(1-this.es)/(1-this.es*t*t),this.C=Math.sqrt(1+this.es*e*e/(1-this.es)),this.phic0=Math.asin(t/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+$f)/(Math.pow(Math.tan(.5*this.lat0+$f),this.C)*Jm(this.e*t,this.ratexp))},forward:function(t){var e=t.x,r=t.y;return t.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*r+$f),this.C)*Jm(this.e*Math.sin(r),this.ratexp))-qf,t.x=this.C*e,t},inverse:function(t){for(var e=t.x/this.C,r=t.y,n=Math.pow(Math.tan(.5*r+$f)/this.K,1/this.C),i=20;i>0&&(r=2*Math.atan(n*Jm(this.e*Math.sin(t.y),-.5*this.e))-qf,!(Math.abs(r-t.y)<1e-14));--i)t.y=r;return i?(t.x=e,t.y=r,t):null},names:["gauss"]};const $m={init:function(){Qm.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))},forward:function(t){var e,r,n,i;return t.x=Ap(t.x-this.long0),Qm.forward.apply(this,[t]),e=Math.sin(t.y),r=Math.cos(t.y),n=Math.cos(t.x),i=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*r*n),t.x=i*r*Math.sin(t.x),t.y=i*(this.cosc0*e-this.sinc0*r*n),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t},inverse:function(t){var e,r,n,i,a;if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,a=Math.sqrt(t.x*t.x+t.y*t.y)){var o=2*Math.atan2(a,this.R2);e=Math.sin(o),r=Math.cos(o),i=Math.asin(r*this.sinc0+t.y*e*this.cosc0/a),n=Math.atan2(t.x*e,a*this.cosc0*r-t.y*this.sinc0*e)}else i=this.phic0,n=0;return t.x=n,t.y=i,Qm.inverse.apply(this,[t]),t.x=Ap(t.x+this.long0),t},names:["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"]};const tg={init:function(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=Kf&&(this.k0=.5*(1+Ep(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=Kf&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=Kf&&(this.k0=.5*this.cons*Tp(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/Pp(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=Tp(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-qf,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))},forward:function(t){var e,r,n,i,a,o,s=t.x,l=t.y,u=Math.sin(l),c=Math.cos(l),h=Ap(s-this.long0);return Math.abs(Math.abs(s-this.long0)-Math.PI)<=Kf&&Math.abs(l+this.lat0)<=Kf?(t.x=NaN,t.y=NaN,t):this.sphere?(e=2*this.k0/(1+this.sinlat0*u+this.coslat0*c*Math.cos(h)),t.x=this.a*e*c*Math.sin(h)+this.x0,t.y=this.a*e*(this.coslat0*u-this.sinlat0*c*Math.cos(h))+this.y0,t):(r=2*Math.atan(this.ssfn_(l,u,this.e))-qf,i=Math.cos(r),n=Math.sin(r),Math.abs(this.coslat0)<=Kf?(a=Pp(this.e,l*this.con,this.con*u),o=2*this.a*this.k0*a/this.cons,t.x=this.x0+o*Math.sin(s-this.long0),t.y=this.y0-this.con*o*Math.cos(s-this.long0),t):(Math.abs(this.sinlat0)0?Ap(this.long0+Math.atan2(t.x,-1*t.y)):Ap(this.long0+Math.atan2(t.x,t.y)):Ap(this.long0+Math.atan2(t.x*Math.sin(s),o*this.coslat0*Math.cos(s)-t.y*this.sinlat0*Math.sin(s))),t.x=e,t.y=r,t)}if(Math.abs(this.coslat0)<=Kf){if(o<=Kf)return r=this.lat0,e=this.long0,t.x=e,t.y=r,t;t.x*=this.con,t.y*=this.con,n=o*this.cons/(2*this.a*this.k0),r=this.con*Rp(this.e,n),e=this.con*Ap(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else i=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),e=this.long0,o<=Kf?a=this.X0:(a=Math.asin(Math.cos(i)*this.sinX0+t.y*Math.sin(i)*this.cosX0/o),e=Ap(this.long0+Math.atan2(t.x*Math.sin(i),o*this.cosX0*Math.cos(i)-t.y*this.sinX0*Math.sin(i)))),r=-1*Rp(this.e,Math.tan(.5*(qf+a)));return t.x=e,t.y=r,t},names:["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],ssfn_:function(t,e,r){return e*=r,Math.tan(.5*(qf+t))*Math.pow((1-e)/(1+e),.5*r)}};const eg={init:function(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),r=this.a,n=1/this.rf,i=2*n-Math.pow(n,2),a=this.e=Math.sqrt(i);this.R=this.k0*r*Math.sqrt(1-i)/(1-i*Math.pow(e,2)),this.alpha=Math.sqrt(1+i/(1-i)*Math.pow(Math.cos(t),4)),this.b0=Math.asin(e/this.alpha);var o=Math.log(Math.tan(Math.PI/4+this.b0/2)),s=Math.log(Math.tan(Math.PI/4+t/2)),l=Math.log((1+a*e)/(1-a*e));this.K=o-this.alpha*s+this.alpha*a/2*l},forward:function(t){var e=Math.log(Math.tan(Math.PI/4-t.y/2)),r=this.e/2*Math.log((1+this.e*Math.sin(t.y))/(1-this.e*Math.sin(t.y))),n=-this.alpha*(e+r)+this.K,i=2*(Math.atan(Math.exp(n))-Math.PI/4),a=this.alpha*(t.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 t.y=this.R/2*Math.log((1+Math.sin(s))/(1-Math.sin(s)))+this.y0,t.x=this.R*o+this.x0,t},inverse:function(t){for(var e=t.x-this.x0,r=t.y-this.y0,n=e/this.R,i=2*(Math.atan(Math.exp(r/this.R))-Math.PI/4),a=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(n)),o=Math.atan(Math.sin(n)/(Math.cos(this.b0)*Math.cos(n)-Math.sin(this.b0)*Math.tan(i))),s=this.lambda0+o/this.alpha,l=0,u=a,c=-1e3,h=0;Math.abs(u-c)>1e-7;){if(++h>20)return;l=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(u))/2)),c=u,u=2*Math.atan(Math.exp(l))-Math.PI/2}return t.x=s,t.y=u,t},names:["somerc"]};var rg=1e-7;const ng={init:function(){var t,e,r,n,i,a,o,s,l,u,c,h,d,f=0,p=0,m=0,g=0,v=0,y=0,x=0;this.no_off=(d="object"==typeof(h=this).PROJECTION?Object.keys(h.PROJECTION)[0]:h.PROJECTION,"no_uoff"in h||"no_off"in h||-1!==["Hotine_Oblique_Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin"].indexOf(d)),this.no_rot="no_rot"in this;var _=!1;"alpha"in this&&(_=!0);var w=!1;if("rectified_grid_angle"in this&&(w=!0),_&&(x=this.alpha),w&&(f=this.rectified_grid_angle*Jf),_||w)p=this.longc;else if(m=this.long1,v=this.lat1,g=this.long2,y=this.lat2,Math.abs(v-y)<=rg||(t=Math.abs(v))<=rg||Math.abs(t-qf)<=rg||Math.abs(Math.abs(this.lat0)-qf)<=rg||Math.abs(Math.abs(y)-qf)<=rg)throw new Error;var b=1-this.es;e=Math.sqrt(b),Math.abs(this.lat0)>Kf?(s=Math.sin(this.lat0),r=Math.cos(this.lat0),t=1-this.es*s*s,this.B=r*r,this.B=Math.sqrt(1+this.es*this.B*this.B/b),this.A=this.B*this.k0*e/t,(i=(n=this.B*e/(r*Math.sqrt(t)))*n-1)<=0?i=0:(i=Math.sqrt(i),this.lat0<0&&(i=-i)),this.E=i+=n,this.E*=Math.pow(Pp(this.e,this.lat0,s),this.B)):(this.B=1/e,this.A=this.k0,this.E=n=i=1),_||w?(_?(c=Math.asin(Math.sin(x)/n),w||(f=x)):(c=f,x=Math.asin(n*Math.sin(c))),this.lam0=p-Math.asin(.5*(i-1/i)*Math.tan(c))/this.B):(a=Math.pow(Pp(this.e,v,Math.sin(v)),this.B),o=Math.pow(Pp(this.e,y,Math.sin(y)),this.B),i=this.E/a,l=(o-a)/(o+a),u=((u=this.E*this.E)-o*a)/(u+o*a),(t=m-g)<-Math.pi?g-=tp:t>Math.pi&&(g+=tp),this.lam0=Ap(.5*(m+g)-Math.atan(u*Math.tan(.5*this.B*(m-g))/l)/this.B),c=Math.atan(2*Math.sin(this.B*Ap(m-this.lam0))/(i-1/i)),f=x=Math.asin(n*Math.sin(c))),this.singam=Math.sin(c),this.cosgam=Math.cos(c),this.sinrot=Math.sin(f),this.cosrot=Math.cos(f),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.A,this.B,this.no_off?this.u_0=0:(this.u_0=Math.abs(this.ArB*Math.atan(Math.sqrt(n*n-1)/Math.cos(x))),this.lat0<0&&(this.u_0=-this.u_0)),i=.5*c,this.v_pole_n=this.ArB*Math.log(Math.tan($f-i)),this.v_pole_s=this.ArB*Math.log(Math.tan($f+i))},forward:function(t){var e,r,n,i,a,o,s,l,u={};if(t.x=t.x-this.lam0,Math.abs(Math.abs(t.y)-qf)>Kf){if(e=.5*((a=this.E/Math.pow(Pp(this.e,t.y,Math.sin(t.y)),this.B))-(o=1/a)),r=.5*(a+o),i=Math.sin(this.B*t.x),n=(e*this.singam-i*this.cosgam)/r,Math.abs(Math.abs(n)-1)0?this.v_pole_n:this.v_pole_s,s=this.ArB*t.y;return this.no_rot?(u.x=s,u.y=l):(s-=this.u_0,u.x=l*this.cosrot+s*this.sinrot,u.y=s*this.cosrot-l*this.sinrot),u.x=this.a*u.x+this.x0,u.y=this.a*u.y+this.y0,u},inverse:function(t){var e,r,n,i,a,o,s,l={};if(t.x=(t.x-this.x0)*(1/this.a),t.y=(t.y-this.y0)*(1/this.a),this.no_rot?(r=t.y,e=t.x):(r=t.x*this.cosrot-t.y*this.sinrot,e=t.y*this.cosrot+t.x*this.sinrot+this.u_0),i=.5*((n=Math.exp(-this.BrA*r))-1/n),a=.5*(n+1/n),s=((o=Math.sin(this.BrA*e))*this.cosgam+i*this.singam)/a,Math.abs(Math.abs(s)-1)Kf?this.ns=Math.log(n/s)/Math.log(i/l):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=n/(this.ns*Math.pow(i,this.ns)),this.rh=this.a*this.f0*Math.pow(u,this.ns),this.title||(this.title="Lambert Conformal Conic")}},forward:function(t){var e=t.x,r=t.y;Math.abs(2*Math.abs(r)-Math.PI)<=Kf&&(r=Ep(r)*(qf-2*Kf));var n,i,a=Math.abs(Math.abs(r)-qf);if(a>Kf)n=Pp(this.e,r,Math.sin(r)),i=this.a*this.f0*Math.pow(n,this.ns);else{if((a=r*this.ns)<=0)return null;i=0}var o=this.ns*Ap(e-this.long0);return t.x=this.k0*(i*Math.sin(o))+this.x0,t.y=this.k0*(this.rh-i*Math.cos(o))+this.y0,t},inverse:function(t){var e,r,n,i,a,o=(t.x-this.x0)/this.k0,s=this.rh-(t.y-this.y0)/this.k0;this.ns>0?(e=Math.sqrt(o*o+s*s),r=1):(e=-Math.sqrt(o*o+s*s),r=-1);var l=0;if(0!==e&&(l=Math.atan2(r*o,r*s)),0!==e||this.ns>0){if(r=1/this.ns,n=Math.pow(e/(this.a*this.f0),r),-9999===(i=Rp(this.e,n)))return null}else i=-qf;return a=Ap(l/this.ns+this.long0),t.x=a,t.y=i,t},names:["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_1SP","Lambert_Conformal_Conic_2SP","lcc","Lambert Conic Conformal (1SP)","Lambert Conic Conformal (2SP)"]};const ag={init:function(){this.a=6377397.155,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.4334234309119251),this.k0||(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.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((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.pow(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.pow(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},forward:function(t){var e,r,n,i,a,o,s,l=t.x,u=t.y,c=Ap(l-this.long0);return e=Math.pow((1+this.e*Math.sin(u))/(1-this.e*Math.sin(u)),this.alfa*this.e/2),r=2*(Math.atan(this.k*Math.pow(Math.tan(u/2+this.s45),this.alfa)/e)-this.s45),n=-c*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(r)+Math.sin(this.ad)*Math.cos(r)*Math.cos(n)),a=Math.asin(Math.cos(r)*Math.sin(n)/Math.cos(i)),o=this.n*a,s=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(i/2+this.s45),this.n),t.y=s*Math.cos(o)/1,t.x=s*Math.sin(o)/1,this.czech||(t.y*=-1,t.x*=-1),t},inverse:function(t){var e,r,n,i,a,o,s,l=t.x;t.x=t.y,t.y=l,this.czech||(t.y*=-1,t.x*=-1),a=Math.sqrt(t.x*t.x+t.y*t.y),i=Math.atan2(t.y,t.x)/Math.sin(this.s0),n=2*(Math.atan(Math.pow(this.ro0/a,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),e=Math.asin(Math.cos(this.ad)*Math.sin(n)-Math.sin(this.ad)*Math.cos(n)*Math.cos(i)),r=Math.asin(Math.cos(n)*Math.sin(i)/Math.cos(e)),t.x=this.long0-r/this.alfa,o=e,s=0;var u=0;do{t.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(e/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(o))/(1-this.e*Math.sin(o)),this.e/2))-this.s45),Math.abs(o-t.y)<1e-10&&(s=1),o=t.y,u+=1}while(0===s&&u<15);return u>=15?null:t},names:["Krovak","krovak"]};function og(t,e,r,n,i){return t*i-e*Math.sin(2*i)+r*Math.sin(4*i)-n*Math.sin(6*i)}function sg(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function lg(t){return.375*t*(1+.25*t*(1+.46875*t))}function ug(t){return.05859375*t*t*(1+.75*t)}function cg(t){return t*t*t*(35/3072)}function hg(t,e,r){var n=e*r;return t/Math.sqrt(1-n*n)}function dg(t){return Math.abs(t)1e-7?(1-t*t)*(e/(1-(r=t*e)*r)-.5/t*Math.log((1-r)/(1+r))):2*e}var gg=.3333333333333333,vg=.17222222222222222,yg=.10257936507936508,xg=.06388888888888888,_g=.0664021164021164,wg=.016415012942191543;const bg={init:function(){var t,e=Math.abs(this.lat0);if(Math.abs(e-qf)0)switch(this.qp=mg(this.e,1),this.mmf=.5/(1-this.es),this.apa=function(t){var e,r=[];return r[0]=t*gg,e=t*t,r[0]+=e*vg,r[1]=e*xg,e*=t,r[0]+=e*yg,r[1]+=e*_g,r[2]=e*wg,r}(this.es),this.mode){case this.N_POLE:case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=mg(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}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))},forward:function(t){var e,r,n,i,a,o,s,l,u,c,h=t.x,d=t.y;if(h=Ap(h-this.long0),this.sphere){if(a=Math.sin(d),c=Math.cos(d),n=Math.cos(h),this.mode===this.OBLIQ||this.mode===this.EQUIT){if((r=this.mode===this.EQUIT?1+c*n:1+this.sinph0*a+this.cosph0*c*n)<=Kf)return null;e=(r=Math.sqrt(2/r))*c*Math.sin(h),r*=this.mode===this.EQUIT?a:this.cosph0*a-this.sinph0*c*n}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(n=-n),Math.abs(d+this.lat0)=0?(e=(u=Math.sqrt(o))*i,r=n*(this.mode===this.S_POLE?u:-u)):e=r=0}}return t.x=this.a*e+this.x0,t.y=this.a*r+this.y0,t},inverse:function(t){t.x-=this.x0,t.y-=this.y0;var e,r,n,i,a,o,s,l,u,c,h=t.x/this.a,d=t.y/this.a;if(this.sphere){var f,p=0,m=0;if((r=.5*(f=Math.sqrt(h*h+d*d)))>1)return null;switch(r=2*Math.asin(r),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(m=Math.sin(r),p=Math.cos(r)),this.mode){case this.EQUIT:r=Math.abs(f)<=Kf?0:Math.asin(d*m/f),h*=m,d=p*f;break;case this.OBLIQ:r=Math.abs(f)<=Kf?this.lat0:Math.asin(p*this.sinph0+d*m*this.cosph0/f),h*=m*this.cosph0,d=(p-Math.sin(r)*this.sinph0)*f;break;case this.N_POLE:d=-d,r=qf-r;break;case this.S_POLE:r-=qf}e=0!==d||this.mode!==this.EQUIT&&this.mode!==this.OBLIQ?Math.atan2(h,d):0}else{if(s=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(h/=this.dd,d*=this.dd,(o=Math.sqrt(h*h+d*d))1&&(t=t>1?1:-1),Math.asin(t)}const Sg={init:function(){Math.abs(this.lat1+this.lat2)Kf?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)},forward:function(t){var e=t.x,r=t.y;this.sin_phi=Math.sin(r),this.cos_phi=Math.cos(r);var n=mg(this.e3,this.sin_phi),i=this.a*Math.sqrt(this.c-this.ns0*n)/this.ns0,a=this.ns0*Ap(e-this.long0),o=i*Math.sin(a)+this.x0,s=this.rh-i*Math.cos(a)+this.y0;return t.x=o,t.y=s,t},inverse:function(t){var e,r,n,i,a,o;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns0>=0?(e=Math.sqrt(t.x*t.x+t.y*t.y),n=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),n=-1),i=0,0!==e&&(i=Math.atan2(n*t.x,n*t.y)),n=e*this.ns0/this.a,this.sphere?o=Math.asin((this.c-n*n)/(2*this.ns0)):(r=(this.c-n*n)/this.ns0,o=this.phi1z(this.e3,r)),a=Ap(i/this.ns0+this.long0),t.x=a,t.y=o,t},names:["Albers_Conic_Equal_Area","Albers","aea"],phi1z:function(t,e){var r,n,i,a,o=Mg(.5*e);if(t0||Math.abs(a)<=Kf?(o=this.x0+1*this.a*r*Math.sin(n)/a,s=this.y0+1*this.a*(this.cos_p14*e-this.sin_p14*r*i)/a):(o=this.x0+this.infinity_dist*r*Math.sin(n),s=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*r*i)),t.x=o,t.y=s,t},inverse:function(t){var e,r,n,i,a,o;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,(e=Math.sqrt(t.x*t.x+t.y*t.y))?(i=Math.atan2(e,this.rc),r=Math.sin(i),o=Mg((n=Math.cos(i))*this.sin_p14+t.y*r*this.cos_p14/e),a=Math.atan2(t.x*r,e*this.cos_p14*n-t.y*this.sin_p14*r),a=Ap(this.long0+a)):(o=this.phic0,a=0),t.x=a,t.y=o,t},names:["gnom"]};const Eg={init:function(){this.sphere||(this.k0=Tp(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))},forward:function(t){var e,r,n=t.x,i=t.y,a=Ap(n-this.long0);if(this.sphere)e=this.x0+this.a*a*Math.cos(this.lat_ts),r=this.y0+this.a*Math.sin(i)/Math.cos(this.lat_ts);else{var o=mg(this.e,Math.sin(i));e=this.x0+this.a*this.k0*a,r=this.y0+this.a*o*.5/this.k0}return t.x=e,t.y=r,t},inverse:function(t){var e,r;return t.x-=this.x0,t.y-=this.y0,this.sphere?(e=Ap(this.long0+t.x/this.a/Math.cos(this.lat_ts)),r=Math.asin(t.y/this.a*Math.cos(this.lat_ts))):(r=function(t,e){var r=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));if(Math.abs(Math.abs(e)-r)<1e-6)return e<0?-1*qf:qf;for(var n,i,a,o,s=Math.asin(.5*e),l=0;l<30;l++)if(i=Math.sin(s),a=Math.cos(s),o=t*i,s+=n=Math.pow(1-o*o,2)/(2*a)*(e/(1-t*t)-i/(1-o*o)+.5/t*Math.log((1-o)/(1+o))),Math.abs(n)<=1e-10)return s;return NaN}(this.e,2*t.y*this.k0/this.a),e=Ap(this.long0+t.x/(this.a*this.k0))),t.x=e,t.y=r,t},names:["cea"]};const Ag={init:function(){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)},forward:function(t){var e=t.x,r=t.y,n=Ap(e-this.long0),i=dg(r-this.lat0);return t.x=this.x0+this.a*n*this.rc,t.y=this.y0+this.a*i,t},inverse:function(t){var e=t.x,r=t.y;return t.x=Ap(this.long0+(e-this.x0)/(this.a*this.rc)),t.y=dg(this.lat0+(r-this.y0)/this.a),t},names:["Equirectangular","Equidistant_Cylindrical","eqc"]};const Pg={init:function(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=sg(this.es),this.e1=lg(this.es),this.e2=ug(this.es),this.e3=cg(this.es),this.ml0=this.a*og(this.e0,this.e1,this.e2,this.e3,this.lat0)},forward:function(t){var e,r,n,i=t.x,a=t.y,o=Ap(i-this.long0);if(n=o*Math.sin(a),this.sphere)Math.abs(a)<=Kf?(e=this.a*o,r=-1*this.a*this.lat0):(e=this.a*Math.sin(n)/Math.tan(a),r=this.a*(dg(a-this.lat0)+(1-Math.cos(n))/Math.tan(a)));else if(Math.abs(a)<=Kf)e=this.a*o,r=-1*this.ml0;else{var s=hg(this.a,this.e,Math.sin(a))/Math.tan(a);e=s*Math.sin(n),r=this.a*og(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+s*(1-Math.cos(n))}return t.x=e+this.x0,t.y=r+this.y0,t},inverse:function(t){var e,r,n,i,a,o,s,l,u;if(n=t.x-this.x0,i=t.y-this.y0,this.sphere)if(Math.abs(i+this.a*this.lat0)<=Kf)e=Ap(n/this.a+this.long0),r=0;else{var c;for(o=this.lat0+i/this.a,s=n*n/this.a/this.a+o*o,l=o,a=20;a;--a)if(l+=u=-1*(o*(l*(c=Math.tan(l))+1)-l-.5*(l*l+s)*c)/((l-o)/c-1),Math.abs(u)<=Kf){r=l;break}e=Ap(this.long0+Math.asin(n*Math.tan(l)/this.a)/Math.sin(r))}else if(Math.abs(i+this.ml0)<=Kf)r=0,e=Ap(this.long0+n/this.a);else{var h,d,f,p,m;for(o=(this.ml0+i)/this.a,s=n*n/this.a/this.a+o*o,l=o,a=20;a;--a)if(m=this.e*Math.sin(l),h=Math.sqrt(1-m*m)*Math.tan(l),d=this.a*og(this.e0,this.e1,this.e2,this.e3,l),f=this.e0-2*this.e1*Math.cos(2*l)+4*this.e2*Math.cos(4*l)-6*this.e3*Math.cos(6*l),l-=u=(o*(h*(p=d/this.a)+1)-p-.5*h*(p*p+s))/(this.es*Math.sin(2*l)*(p*p+s-2*o*p)/(4*h)+(o-p)*(h*f-2/Math.sin(2*l))-f),Math.abs(u)<=Kf){r=l;break}h=Math.sqrt(1-this.es*Math.pow(Math.sin(r),2))*Math.tan(r),e=Ap(this.long0+Math.asin(n*h/this.a)/Math.sin(r))}return t.x=e,t.y=r,t},names:["Polyconic","poly"]};const Rg={init:function(){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},forward:function(t){var e,r=t.x,n=t.y-this.lat0,i=r-this.long0,a=n/Wf*1e-5,o=i,s=1,l=0;for(e=1;e<=10;e++)s*=a,l+=this.A[e]*s;var u,c=l,h=o,d=1,f=0,p=0,m=0;for(e=1;e<=6;e++)u=f*c+d*h,d=d*c-f*h,f=u,p=p+this.B_re[e]*d-this.B_im[e]*f,m=m+this.B_im[e]*d+this.B_re[e]*f;return t.x=m*this.a+this.x0,t.y=p*this.a+this.y0,t},inverse:function(t){var e,r,n=t.x,i=t.y,a=n-this.x0,o=(i-this.y0)/this.a,s=a/this.a,l=1,u=0,c=0,h=0;for(e=1;e<=6;e++)r=u*o+l*s,l=l*o-u*s,u=r,c=c+this.C_re[e]*l-this.C_im[e]*u,h=h+this.C_im[e]*l+this.C_re[e]*u;for(var d=0;d.999999999999&&(r=.999999999999),e=Math.asin(r);var n=Ap(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));n<-Math.PI&&(n=-Math.PI),n>Math.PI&&(n=Math.PI),r=(2*e+Math.sin(2*e))/Math.PI,Math.abs(r)>1&&(r=1);var i=Math.asin(r);return t.x=n,t.y=i,t},names:["Mollweide","moll"]};const Og={init:function(){Math.abs(this.lat1+this.lat2)=0?(r=Math.sqrt(t.x*t.x+t.y*t.y),e=1):(r=-Math.sqrt(t.x*t.x+t.y*t.y),e=-1);var a=0;return 0!==r&&(a=Math.atan2(e*t.x,e*t.y)),this.sphere?(i=Ap(this.long0+a/this.ns),n=dg(this.g-r/this.a),t.x=i,t.y=n,t):(n=fg(this.g-r/this.a,this.e0,this.e1,this.e2,this.e3),i=Ap(this.long0+a/this.ns),t.x=i,t.y=n,t)},names:["Equidistant_Conic","eqdc"]};const Dg={init:function(){this.R=this.a},forward:function(t){var e,r,n=t.x,i=t.y,a=Ap(n-this.long0);Math.abs(i)<=Kf&&(e=this.x0+this.R*a,r=this.y0);var o=Mg(2*Math.abs(i/Math.PI));(Math.abs(a)<=Kf||Math.abs(Math.abs(i)-qf)<=Kf)&&(e=this.x0,r=i>=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/a-a/Math.PI),l=s*s,u=Math.sin(o),c=Math.cos(o),h=c/(u+c-1),d=h*h,f=h*(2/u-1),p=f*f,m=Math.PI*this.R*(s*(h-p)+Math.sqrt(l*(h-p)*(h-p)-(p+l)*(d-p)))/(p+l);a<0&&(m=-m),e=this.x0+m;var g=l+h;return m=Math.PI*this.R*(f*g-s*Math.sqrt((p+l)*(l+1)-g*g))/(p+l),r=i>=0?this.y0+m:this.y0-m,t.x=e,t.y=r,t},inverse:function(t){var e,r,n,i,a,o,s,l,u,c,h,d;return t.x-=this.x0,t.y-=this.y0,h=Math.PI*this.R,a=(n=t.x/h)*n+(i=t.y/h)*i,h=3*(i*i/(l=-2*(o=-Math.abs(i)*(1+a))+1+2*i*i+a*a)+(2*(s=o-2*i*i+n*n)*s*s/l/l/l-9*o*s/l/l)/27)/(u=(o-s*s/3/l)/l)/(c=2*Math.sqrt(-u/3)),Math.abs(h)>1&&(h=h>=0?1:-1),d=Math.acos(h)/3,r=t.y>=0?(-c*Math.cos(d+Math.PI/3)-s/3/l)*Math.PI:-(-c*Math.cos(d+Math.PI/3)-s/3/l)*Math.PI,e=Math.abs(n)2*qf*this.a)return;return r=e/this.a,n=Math.sin(r),i=Math.cos(r),a=this.long0,Math.abs(e)<=Kf?o=this.lat0:(o=Mg(i*this.sin_p12+t.y*n*this.cos_p12/e),s=Math.abs(this.lat0)-qf,a=Math.abs(s)<=Kf?this.lat0>=0?Ap(this.long0+Math.atan2(t.x,-t.y)):Ap(this.long0-Math.atan2(-t.x,t.y)):Ap(this.long0+Math.atan2(t.x*n,e*this.cos_p12*i-t.y*this.sin_p12*n))),t.x=a,t.y=o,t}return l=sg(this.es),u=lg(this.es),c=ug(this.es),h=cg(this.es),Math.abs(this.sin_p12-1)<=Kf?(o=fg(((d=this.a*og(l,u,c,h,qf))-(e=Math.sqrt(t.x*t.x+t.y*t.y)))/this.a,l,u,c,h),a=Ap(this.long0+Math.atan2(t.x,-1*t.y)),t.x=a,t.y=o,t):Math.abs(this.sin_p12+1)<=Kf?(d=this.a*og(l,u,c,h,qf),o=fg(((e=Math.sqrt(t.x*t.x+t.y*t.y))-d)/this.a,l,u,c,h),a=Ap(this.long0+Math.atan2(t.x,t.y)),t.x=a,t.y=o,t):(e=Math.sqrt(t.x*t.x+t.y*t.y),m=Math.atan2(t.x,t.y),f=hg(this.a,this.e,this.sin_p12),g=Math.cos(m),y=-(v=this.e*this.cos_p12*g)*v/(1-this.es),x=3*this.es*(1-y)*this.sin_p12*this.cos_p12*g/(1-this.es),b=1-y*(w=(_=e/f)-y*(1+y)*Math.pow(_,3)/6-x*(1+3*y)*Math.pow(_,4)/24)*w/2-_*w*w*w/6,p=Math.asin(this.sin_p12*Math.cos(w)+this.cos_p12*Math.sin(w)*g),a=Ap(this.long0+Math.asin(Math.sin(m)*Math.sin(w)/Math.cos(p))),M=Math.sin(p),o=Math.atan2((M-this.es*b*this.sin_p12)*Math.tan(p),M*(1-this.es)),t.x=a,t.y=o,t)},names:["Azimuthal_Equidistant","aeqd"]};const Fg={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)},forward:function(t){var e,r,n,i,a,o,s,l=t.x,u=t.y;return n=Ap(l-this.long0),e=Math.sin(u),r=Math.cos(u),i=Math.cos(n),1,((a=this.sin_p14*e+this.cos_p14*r*i)>0||Math.abs(a)<=Kf)&&(o=1*this.a*r*Math.sin(n),s=this.y0+1*this.a*(this.cos_p14*e-this.sin_p14*r*i)),t.x=o,t.y=s,t},inverse:function(t){var e,r,n,i,a,o,s;return t.x-=this.x0,t.y-=this.y0,r=Mg((e=Math.sqrt(t.x*t.x+t.y*t.y))/this.a),n=Math.sin(r),i=Math.cos(r),o=this.long0,Math.abs(e)<=Kf?(s=this.lat0,t.x=o,t.y=s,t):(s=Mg(i*this.sin_p14+t.y*n*this.cos_p14/e),a=Math.abs(this.lat0)-qf,Math.abs(a)<=Kf?(o=this.lat0>=0?Ap(this.long0+Math.atan2(t.x,-t.y)):Ap(this.long0-Math.atan2(-t.x,t.y)),t.x=o,t.y=s,t):(o=Ap(this.long0+Math.atan2(t.x*n,e*this.cos_p14*i-t.y*this.sin_p14*n)),t.x=o,t.y=s,t))},names:["ortho"]};var Ng=1,Ug=2,Bg=3,zg=4,Gg=5,jg=6,Vg={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function Hg(t,e,r,n){var i;return t$f&&i<=qf+$f?(n.value=Vg.AREA_1,i-=qf):i>qf+$f||i<=-(qf+$f)?(n.value=Vg.AREA_2,i=i>=0?i-ep:i+ep):(n.value=Vg.AREA_3,i+=qf)),i}function Wg(t,e){var r=t+e;return r<-ep?r+=tp:r>+ep&&(r-=tp),r}const qg={init:function(){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>=qf-$f/2?this.face=Gg:this.lat0<=-(qf-$f/2)?this.face=jg:Math.abs(this.long0)<=$f?this.face=Ng:Math.abs(this.long0)<=qf+$f?this.face=this.long0>0?Ug:zg:this.face=Bg,0!==this.es&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)},forward:function(t){var e,r,n,i,a,o,s={x:0,y:0},l={value:0};if(t.x-=this.long0,e=0!==this.es?Math.atan(this.one_minus_f_squared*Math.tan(t.y)):t.y,r=t.x,this.face===Gg)i=qf-e,r>=$f&&r<=qf+$f?(l.value=Vg.AREA_0,n=r-qf):r>qf+$f||r<=-(qf+$f)?(l.value=Vg.AREA_1,n=r>0?r-ep:r+ep):r>-(qf+$f)&&r<=-$f?(l.value=Vg.AREA_2,n=r+qf):(l.value=Vg.AREA_3,n=r);else if(this.face===jg)i=qf+e,r>=$f&&r<=qf+$f?(l.value=Vg.AREA_0,n=-r+qf):r<$f&&r>=-$f?(l.value=Vg.AREA_1,n=-r):r<-$f&&r>=-(qf+$f)?(l.value=Vg.AREA_2,n=-r-qf):(l.value=Vg.AREA_3,n=r>0?-r+ep:-r-ep);else{var u,c,h,d,f,p;this.face===Ug?r=Wg(r,+qf):this.face===Bg?r=Wg(r,+ep):this.face===zg&&(r=Wg(r,-qf)),d=Math.sin(e),f=Math.cos(e),p=Math.sin(r),u=f*Math.cos(r),c=f*p,h=d,this.face===Ng?n=Hg(i=Math.acos(u),h,c,l):this.face===Ug?n=Hg(i=Math.acos(c),h,-u,l):this.face===Bg?n=Hg(i=Math.acos(-u),h,-c,l):this.face===zg?n=Hg(i=Math.acos(-c),h,u,l):(i=n=0,l.value=Vg.AREA_0)}return o=Math.atan(12/ep*(n+Math.acos(Math.sin(n)*Math.cos($f))-qf)),a=Math.sqrt((1-Math.cos(i))/(Math.cos(o)*Math.cos(o))/(1-Math.cos(Math.atan(1/Math.cos(n))))),l.value===Vg.AREA_1?o+=qf:l.value===Vg.AREA_2?o+=ep:l.value===Vg.AREA_3&&(o+=1.5*ep),s.x=a*Math.cos(o),s.y=a*Math.sin(o),s.x=s.x*this.a+this.x0,s.y=s.y*this.a+this.y0,t.x=s.x,t.y=s.y,t},inverse:function(t){var e,r,n,i,a,o,s,l,u,c,h,d,f={lam:0,phi:0},p={value:0};if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,r=Math.atan(Math.sqrt(t.x*t.x+t.y*t.y)),e=Math.atan2(t.y,t.x),t.x>=0&&t.x>=Math.abs(t.y)?p.value=Vg.AREA_0:t.y>=0&&t.y>=Math.abs(t.x)?(p.value=Vg.AREA_1,e-=qf):t.x<0&&-t.x>=Math.abs(t.y)?(p.value=Vg.AREA_2,e=e<0?e+ep:e-ep):(p.value=Vg.AREA_3,e+=qf),u=ep/12*Math.tan(e),a=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),o=Math.atan(a),(s=1-(n=Math.cos(e))*n*(i=Math.tan(r))*i*(1-Math.cos(Math.atan(1/Math.cos(o)))))<-1?s=-1:s>1&&(s=1),this.face===Gg)l=Math.acos(s),f.phi=qf-l,p.value===Vg.AREA_0?f.lam=o+qf:p.value===Vg.AREA_1?f.lam=o<0?o+ep:o-ep:p.value===Vg.AREA_2?f.lam=o-qf:f.lam=o;else if(this.face===jg)l=Math.acos(s),f.phi=l-qf,p.value===Vg.AREA_0?f.lam=-o+qf:p.value===Vg.AREA_1?f.lam=-o:p.value===Vg.AREA_2?f.lam=-o-qf:f.lam=o<0?-o-ep:-o+ep;else{var m,g,v;u=(m=s)*m,g=(u+=(v=u>=1?0:Math.sqrt(1-u)*Math.sin(o))*v)>=1?0:Math.sqrt(1-u),p.value===Vg.AREA_1?(u=g,g=-v,v=u):p.value===Vg.AREA_2?(g=-g,v=-v):p.value===Vg.AREA_3&&(u=g,g=v,v=-u),this.face===Ug?(u=m,m=-g,g=u):this.face===Bg?(m=-m,g=-g):this.face===zg&&(u=m,m=g,g=-u),f.phi=Math.acos(-v)-qf,f.lam=Math.atan2(g,m),this.face===Ug?f.lam=Wg(f.lam,-qf):this.face===Bg?f.lam=Wg(f.lam,-ep):this.face===zg&&(f.lam=Wg(f.lam,+qf))}return 0!==this.es&&(c=f.phi<0?1:0,h=Math.tan(f.phi),d=this.b/Math.sqrt(h*h+this.one_minus_f_squared),f.phi=Math.atan(Math.sqrt(this.a*this.a-d*d)/(this.one_minus_f*d)),c&&(f.phi=-f.phi)),f.lam+=this.long0,t.x=f.lam,t.y=f.phi,t},names:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"]};var Xg=[[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]],Yg=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,4.22642e-10],[.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]],Zg=.8487,Kg=1.3523,Jg=Qf/5,Qg=1/Jg,$g=18,tv=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))};const ev={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"},forward:function(t){var e=Ap(t.x-this.long0),r=Math.abs(t.y),n=Math.floor(r*Jg);n<0?n=0:n>=$g&&(n=17);var i={x:tv(Xg[n],r=Qf*(r-Qg*n))*e,y:tv(Yg[n],r)};return t.y<0&&(i.y=-i.y),i.x=i.x*this.a*Zg+this.x0,i.y=i.y*this.a*Kg+this.y0,i},inverse:function(t){var e={x:(t.x-this.x0)/(this.a*Zg),y:Math.abs(t.y-this.y0)/(this.a*Kg)};if(e.y>=1)e.x/=Xg[18][0],e.y=t.y<0?-qf:qf;else{var r=Math.floor(e.y*$g);for(r<0?r=0:r>=$g&&(r=17);;)if(Yg[r][0]>e.y)--r;else{if(!(Yg[r+1][0]<=e.y))break;++r}var n=Yg[r],i=5*(e.y-n[0])/(Yg[r+1][0]-n[0]);i=function(t,e,r,n){for(var i=e;n;--n){var a=t(i);if(i-=a,Math.abs(a)1e10)throw new Error;if(this.radius_g=1+this.radius_g_1,this.C=this.radius_g*this.radius_g-1,0!==this.es){var t=1-this.es,e=1/t;this.radius_p=Math.sqrt(t),this.radius_p2=t,this.radius_p_inv2=e,this.shape="ellipse"}else this.radius_p=1,this.radius_p2=1,this.radius_p_inv2=1,this.shape="sphere";this.title||(this.title="Geostationary Satellite View")},forward:function(t){var e,r,n,i,a=t.x,o=t.y;if(a-=this.long0,"ellipse"===this.shape){o=Math.atan(this.radius_p2*Math.tan(o));var s=this.radius_p/Wm(this.radius_p*Math.cos(o),Math.sin(o));if(r=s*Math.cos(a)*Math.cos(o),n=s*Math.sin(a)*Math.cos(o),i=s*Math.sin(o),(this.radius_g-r)*r-n*n-i*i*this.radius_p_inv2<0)return t.x=Number.NaN,t.y=Number.NaN,t;e=this.radius_g-r,this.flip_axis?(t.x=this.radius_g_1*Math.atan(n/Wm(i,e)),t.y=this.radius_g_1*Math.atan(i/e)):(t.x=this.radius_g_1*Math.atan(n/e),t.y=this.radius_g_1*Math.atan(i/Wm(n,e)))}else"sphere"===this.shape&&(e=Math.cos(o),r=Math.cos(a)*e,n=Math.sin(a)*e,i=Math.sin(o),e=this.radius_g-r,this.flip_axis?(t.x=this.radius_g_1*Math.atan(n/Wm(i,e)),t.y=this.radius_g_1*Math.atan(i/e)):(t.x=this.radius_g_1*Math.atan(n/e),t.y=this.radius_g_1*Math.atan(i/Wm(n,e))));return t.x=t.x*this.a,t.y=t.y*this.a,t},inverse:function(t){var e,r,n,i,a=-1,o=0,s=0;if(t.x=t.x/this.a,t.y=t.y/this.a,"ellipse"===this.shape){this.flip_axis?(s=Math.tan(t.y/this.radius_g_1),o=Math.tan(t.x/this.radius_g_1)*Wm(1,s)):(o=Math.tan(t.x/this.radius_g_1),s=Math.tan(t.y/this.radius_g_1)*Wm(1,o));var l=s/this.radius_p;if(e=o*o+l*l+a*a,(n=(r=2*this.radius_g*a)*r-4*e*this.C)<0)return t.x=Number.NaN,t.y=Number.NaN,t;i=(-r-Math.sqrt(n))/(2*e),a=this.radius_g+i*a,o*=i,s*=i,t.x=Math.atan2(o,a),t.y=Math.atan(s*Math.cos(t.x)/a),t.y=Math.atan(this.radius_p_inv2*Math.tan(t.y))}else if("sphere"===this.shape){if(this.flip_axis?(s=Math.tan(t.y/this.radius_g_1),o=Math.tan(t.x/this.radius_g_1)*Math.sqrt(1+s*s)):(o=Math.tan(t.x/this.radius_g_1),s=Math.tan(t.y/this.radius_g_1)*Math.sqrt(1+o*o)),e=o*o+s*s+a*a,(n=(r=2*this.radius_g*a)*r-4*e*this.C)<0)return t.x=Number.NaN,t.y=Number.NaN,t;i=(-r-Math.sqrt(n))/(2*e),a=this.radius_g+i*a,o*=i,s*=i,t.x=Math.atan2(o,a),t.y=Math.atan(s*Math.cos(t.x)/a)}return t.x=t.x+this.long0,t},names:["Geostationary Satellite View","Geostationary_Satellite","geos"]};var cv;sm.defaultDatum="WGS84",sm.Proj=qp,sm.WGS84=new sm.Proj("WGS84"),sm.Point=Em,sm.toPoint=em,sm.defs=_p,sm.nadgrid=function(t,e){var r=new DataView(e),n=function(t){var e=t.getInt32(8,!1);if(11===e)return!1;e=t.getInt32(8,!0),11!==e&&console.warn("Failed to detect nadgrid endian-ness, defaulting to little-endian");return!0}(r),i=function(t,e){return{nFields:t.getInt32(8,e),nSubgridFields:t.getInt32(24,e),nSubgrids:t.getInt32(40,e),shiftType:jp(t,56,64).trim(),fromSemiMajorAxis:t.getFloat64(120,e),fromSemiMinorAxis:t.getFloat64(136,e),toSemiMajorAxis:t.getFloat64(152,e),toSemiMinorAxis:t.getFloat64(168,e)}}(r,n);i.nSubgrids>1&&console.log("Only single NTv2 subgrids are currently supported, subsequent sub grids are ignored");var a=function(t,e,r){for(var n=176,i=[],a=0;a1?r:2,a=e;void 0===a&&(a=i>2?t.slice():new Array(n));for(var o=0;oIv?s=Iv:s<-Iv&&(s=-Iv),a[o+1]=s}return a}function kv(t,e,r){var n=t.length,i=r>1?r:2,a=e;void 0===a&&(a=i>2?t.slice():new Array(n));for(var o=0;oi&&(l|=Zv.RIGHT),sa&&(l|=Zv.ABOVE),l===Zv.UNKNOWN&&(l=Zv.INTERSECTING),l}function uy(){return[1/0,1/0,-1/0,-1/0]}function cy(t,e,r,n,i){return i?(i[0]=t,i[1]=e,i[2]=r,i[3]=n,i):[t,e,r,n]}function hy(t){return cy(1/0,1/0,-1/0,-1/0,t)}function dy(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function fy(t,e){return e[0]t[2]&&(t[2]=e[2]),e[1]t[3]&&(t[3]=e[3]),t}function py(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function my(t,e){for(var r=0,n=e.length;re[0]?n[0]=t[0]:n[0]=e[0],t[1]>e[1]?n[1]=t[1]:n[1]=e[1],t[2]=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function Ly(t){return t[2]=o&&m<=l),n||!(a&Zv.RIGHT)||i&Zv.RIGHT||(n=(g=f-(d-l)*p)>=s&&g<=u),n||!(a&Zv.BELOW)||i&Zv.BELOW||(n=(m=d-(f-s)/p)>=o&&m<=l),n||!(a&Zv.LEFT)||i&Zv.LEFT||(n=(g=f-(d-o)*p)>=s&&g<=u)}return n}function Dy(t,e,r,n){var i=[];if(n>1)for(var a=t[2]-t[0],o=t[3]-t[1],s=0;s=r[2])){var i=Cy(r),a=Math.floor((n[0]-r[0])/i)*i;t[0]-=a,t[2]-=a}return t}function Fy(t,e){if(e.canWrapX()){var r=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[r[0],t[1],r[2],t[3]]];ky(t,e);var n=Cy(r);if(Cy(t)>n)return[[r[0],t[1],r[2],t[3]]];if(t[0]r[2])return[[t[0],t[1],r[2],t[3]],[r[0],t[1],t[2]-n,t[3]]]}return[t]}const Ny=Object.freeze(Object.defineProperty({__proto__:null,applyTransform:Dy,approximatelyEquals:function(t,e,r){return Math.abs(t[0]-e[0])=u?e[s+c]:l[c];return o}}function Ky(t,e){if(t===e)return!0;var r=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||Jy(t,e)===Vy)&&r}function Jy(t,e){var r=Yv(t.getCode(),e.getCode());return r||(r=Hy),r}function Qy(t,e){return Jy(qy(t),qy(e))}function $y(t,e,r){return Qy(e,r)(t,void 0,t.length)}function tx(t,e,r){return function(n){var i,a;if(t.canWrapX()){var o=t.getExtent(),s=Cy(o);a=function(t,e,r){var n=e.getExtent(),i=0;if(e.canWrapX()&&(t[0]n[2])){var a=r||Cy(n);i=Math.floor((t[0]-n[0])/a)}return i}(n=n.slice(0),t,s),a&&(n[0]=n[0]-a*s),n[0]=gv(n[0],o[0],o[2]),n[1]=gv(n[1],o[1],o[3]),i=r(n)}else i=r(n);return a&&e.canWrapX()&&(i[0]+=a*Cy(e.getExtent())),i}}Yy(Ov),Yy(zv),Uy=Ov,By=Dv,zy=kv,zv.forEach((function(t){Uy.forEach((function(e){Xv(t,e,By),Xv(e,t,zy)}))}));const ex=Object.freeze(Object.defineProperty({__proto__:null,register:function(t){var e,r,n,i,a,o,s,l,u=Object.keys(t.defs),c=u.length;for(e=0;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r1?r-1:0),a=1;a1?e-1:0),n=1;ne?1:t0)},e.prototype.removeEventListener=function(t,e){var r=this.listeners_&&this.listeners_[t];if(r){var n=r.indexOf(e);-1!==n&&(this.pendingRemovals_&&t in this.pendingRemovals_?(r[n]=Bx,++this.pendingRemovals_[t]):(r.splice(n,1),0===r.length&&delete this.listeners_[t]))}},e}(Ox),jx={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},Vx=Object.freeze(Object.defineProperty({__proto__:null,default:jx},Symbol.toStringTag,{value:"Module"}));var Hx=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const Wx=function(t){function e(e,r,n){var i=t.call(this)||this,a=n||{};return i.tileCoord=e,i.state=r,i.interimTile=null,i.key="",i.transition_=void 0===a.transition?250:a.transition,i.transitionStarts_={},i.interpolate=!!a.interpolate,i}return Hx(e,t),e.prototype.changed=function(){this.dispatchEvent(Cx)},e.prototype.release=function(){},e.prototype.getKey=function(){return this.key+"/"+this.tileCoord},e.prototype.getInterimTile=function(){if(!this.interimTile)return this;var t=this.interimTile;do{if(t.getState()==jx.LOADED)return this.transition_=0,t;t=t.interimTile}while(t);return this},e.prototype.refreshInterimChain=function(){if(this.interimTile){var t=this.interimTile,e=this;do{if(t.getState()==jx.LOADED){t.interimTile=null;break}t.getState()==jx.LOADING?e=t:t.getState()==jx.IDLE?e.interimTile=t.interimTile:e=t,t=e.interimTile}while(t)}},e.prototype.getTileCoord=function(){return this.tileCoord},e.prototype.getState=function(){return this.state},e.prototype.setState=function(t){if(this.state!==jx.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()},e.prototype.load=function(){Kv()},e.prototype.getAlpha=function(t,e){if(!this.transition_)return 1;var r=this.transitionStarts_[t];if(r){if(-1===r)return 1}else r=e,this.transitionStarts_[t]=r;var n,i=e-r+1e3/60;return i>=this.transition_?1:(n=i/this.transition_,Math.pow(n,3))},e.prototype.inTransition=function(t){return!!this.transition_&&-1!==this.transitionStarts_[t]},e.prototype.endTransition=function(t){this.transition_&&(this.transitionStarts_[t]=-1)},e}(Gx);var qx="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"";qx.indexOf("firefox"),-1!==qx.indexOf("safari")&&-1==qx.indexOf("chrom")&&(qx.indexOf("version/15.4")>=0||qx.match(/cpu (os|iphone os) 15_4 like mac os x/)),-1!==qx.indexOf("webkit")&&qx.indexOf("edge"),qx.indexOf("macintosh");var Xx="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,Yx="undefined"!=typeof Image&&Image.prototype.decode;function Zx(t,e,r,n){var i;return i=r&&r.length?r.shift():Xx?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(i.width=t),e&&(i.height=e),i.getContext("2d",n)}function Kx(t){var e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}!function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch(t){}}();var Jx=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const Qx=function(t){function e(e,r,n,i){var a=t.call(this)||this;return a.extent=e,a.pixelRatio_=n,a.resolution=r,a.state=i,a}return Jx(e,t),e.prototype.changed=function(){this.dispatchEvent(Cx)},e.prototype.getExtent=function(){return this.extent},e.prototype.getImage=function(){return Kv()},e.prototype.getPixelRatio=function(){return this.pixelRatio_},e.prototype.getResolution=function(){return this.resolution},e.prototype.getState=function(){return this.state},e.prototype.load=function(){Kv()},e}(Gx),$x=0,t_=1,e_=2,r_=3;function n_(t,e,r,n,i){if(n&&n!==t&&(r=r.bind(n)),i){var a=r;r=function(){t.removeEventListener(e,r),a.apply(this,arguments)}}var o={target:t,type:e,listener:r};return t.addEventListener(e,r),o}function i_(t,e,r,n){return n_(t,e,r,n,!0)}function a_(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),Vv(t))}const o_=Object.freeze(Object.defineProperty({__proto__:null,listen:n_,listenOnce:i_,unlistenByKey:a_},Symbol.toStringTag,{value:"Module"}));var s_=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();function l_(t,e,r){var n=t,i=!0,a=!1,o=!1,s=[i_(n,Lx,(function(){o=!0,a||e()}))];return n.src&&Yx?(a=!0,n.decode().then((function(){i&&e()})).catch((function(t){i&&(o?e():r())}))):s.push(i_(n,Ix,r)),function(){i=!1,s.forEach(a_)}}!function(t){function e(e,r,n,i,a,o){var s=t.call(this,e,r,n,$x)||this;return s.src_=i,s.image_=new Image,null!==a&&(s.image_.crossOrigin=a),s.unlisten_=null,s.state=$x,s.imageLoadFunction_=o,s}s_(e,t),e.prototype.getImage=function(){return this.image_},e.prototype.handleImageError_=function(){this.state=r_,this.unlistenImage_(),this.changed()},e.prototype.handleImageLoad_=function(){void 0===this.resolution&&(this.resolution=Ey(this.extent)/this.image_.height),this.state=e_,this.unlistenImage_(),this.changed()},e.prototype.load=function(){this.state!=$x&&this.state!=r_||(this.state=t_,this.changed(),this.imageLoadFunction_(this,this.src_),this.unlisten_=l_(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))},e.prototype.setImage=function(t){this.image_=t,this.resolution=Ey(this.extent)/this.image_.height},e.prototype.unlistenImage_=function(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}(Qx);var u_=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const c_=function(t){function e(e,r,n,i,a,o){var s=t.call(this,e,r,o)||this;return s.crossOrigin_=i,s.src_=n,s.key=n,s.image_=new Image,null!==i&&(s.image_.crossOrigin=i),s.unlisten_=null,s.tileLoadFunction_=a,s}return u_(e,t),e.prototype.getImage=function(){return this.image_},e.prototype.setImage=function(t){this.image_=t,this.state=jx.LOADED,this.unlistenImage_(),this.changed()},e.prototype.handleImageError_=function(){var t;this.state=jx.ERROR,this.unlistenImage_(),this.image_=((t=Zx(1,1)).fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas),this.changed()},e.prototype.handleImageLoad_=function(){var t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=jx.LOADED:this.state=jx.EMPTY,this.unlistenImage_(),this.changed()},e.prototype.load=function(){this.state==jx.ERROR&&(this.state=jx.IDLE,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==jx.IDLE&&(this.state=jx.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=l_(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))},e.prototype.unlistenImage_=function(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)},e}(Wx);const h_=function(){function t(t,e,r,n,i,a){this.sourceProj_=t,this.targetProj_=e;var o={},s=Qy(this.targetProj_,this.sourceProj_);this.transformInv_=function(t){var e=t[0]+"/"+t[1];return o[e]||(o[e]=s(t)),o[e]},this.maxSourceExtent_=n,this.errorThresholdSquared_=i*i,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&Cy(n)==Cy(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Cy(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Cy(this.targetProj_.getExtent()):null;var l=Py(r),u=Ry(r),c=by(r),h=wy(r),d=this.transformInv_(l),f=this.transformInv_(u),p=this.transformInv_(c),m=this.transformInv_(h),g=10+(a?Math.max(0,Math.ceil(yv(_y(r)/(a*a*256*256)))):0);if(this.addQuad_(l,u,c,h,d,f,p,m,g),this.wrapsXInSource_){var v=1/0;this.triangles_.forEach((function(t,e,r){v=Math.min(v,t.source[0][0],t.source[1][0],t.source[2][0])})),this.triangles_.forEach(function(t){if(Math.max(t.source[0][0],t.source[1][0],t.source[2][0])-v>this.sourceWorldWidth_/2){var e=[[t.source[0][0],t.source[0][1]],[t.source[1][0],t.source[1][1]],[t.source[2][0],t.source[2][1]]];e[0][0]-v>this.sourceWorldWidth_/2&&(e[0][0]-=this.sourceWorldWidth_),e[1][0]-v>this.sourceWorldWidth_/2&&(e[1][0]-=this.sourceWorldWidth_),e[2][0]-v>this.sourceWorldWidth_/2&&(e[2][0]-=this.sourceWorldWidth_);var r=Math.min(e[0][0],e[1][0],e[2][0]);Math.max(e[0][0],e[1][0],e[2][0])-r.5&&c<1,f=!1;if(l>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_)f=Cy(ry([t,e,r,n]))/this.targetWorldWidth_>.25||f;!d&&this.sourceProj_.isGlobal()&&c&&(f=c>.25||f)}if(!(!f&&this.maxSourceExtent_&&isFinite(u[0])&&isFinite(u[1])&&isFinite(u[2])&&isFinite(u[3]))||Iy(u,this.maxSourceExtent_)){var p=0;if(!(f||isFinite(i[0])&&isFinite(i[1])&&isFinite(a[0])&&isFinite(a[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(s[0])&&isFinite(s[1])))if(l>0)f=!0;else if(1!=(p=(isFinite(i[0])&&isFinite(i[1])?0:8)+(isFinite(a[0])&&isFinite(a[1])?0:4)+(isFinite(o[0])&&isFinite(o[1])?0:2)+(isFinite(s[0])&&isFinite(s[1])?0:1))&&2!=p&&4!=p&&8!=p)return;if(l>0){if(!f){var m=[(t[0]+r[0])/2,(t[1]+r[1])/2],g=this.transformInv_(m),v=void 0;if(d)v=(_v(i[0],h)+_v(o[0],h))/2-_v(g[0],h);else v=(i[0]+o[0])/2-g[0];var y=(i[1]+o[1])/2-g[1];f=v*v+y*y>this.errorThresholdSquared_}if(f){if(Math.abs(t[0]-r[0])<=Math.abs(t[1]-r[1])){var x=[(e[0]+r[0])/2,(e[1]+r[1])/2],_=this.transformInv_(x),w=[(n[0]+t[0])/2,(n[1]+t[1])/2],b=this.transformInv_(w);this.addQuad_(t,e,x,w,i,a,_,b,l-1),this.addQuad_(w,x,r,n,b,_,o,s,l-1)}else{var M=[(t[0]+e[0])/2,(t[1]+e[1])/2],S=this.transformInv_(M),T=[(r[0]+n[0])/2,(r[1]+n[1])/2],E=this.transformInv_(T);this.addQuad_(t,M,T,n,i,S,E,s,l-1),this.addQuad_(M,e,r,T,S,a,o,E,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}0==(11&p)&&this.addTriangle_(t,r,n,i,o,s),0==(14&p)&&this.addTriangle_(t,r,e,i,o,a),p&&(0==(13&p)&&this.addTriangle_(e,n,t,a,s,i),0==(7&p)&&this.addTriangle_(e,n,r,a,s,o))}},t.prototype.calculateSourceExtent=function(){var t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach((function(e,r,n){var i=e.source;py(t,i[0]),py(t,i[1]),py(t,i[2])})),t},t.prototype.getTriangles=function(){return this.triangles_},t}();var d_,f_={imageSmoothingEnabled:!1,msImageSmoothingEnabled:!1},p_=[];function m_(t,e,r,n,i){t.beginPath(),t.moveTo(0,0),t.lineTo(e,r),t.lineTo(n,i),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,n)+1,Math.max(r,i)),t.restore()}function g_(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function v_(t,e,r,n){var i=$y(r,e,t),a=Xy(e,n,r),o=e.getMetersPerUnit();void 0!==o&&(a*=o);var s=t.getMetersPerUnit();void 0!==s&&(a/=s);var l=t.getExtent();if(!l||ay(l,i)){var u=Xy(t,a,i)/a;isFinite(u)&&u>0&&(a/=u)}return a}function y_(t,e,r,n,i,a,o,s,l,u,c,h){var d=Zx(Math.round(r*t),Math.round(r*e),p_);if(h||jv(d,f_),0===l.length)return d.canvas;function f(t){return Math.round(t*r)/r}d.scale(r,r),d.globalCompositeOperation="lighter";var p=[1/0,1/0,-1/0,-1/0];l.forEach((function(t,e,r){fy(p,t.extent)}));var m=Cy(p),g=Ey(p),v=Zx(Math.round(r*m/n),Math.round(r*g/n));h||jv(v,f_);var y=r/n;l.forEach((function(t,e,r){var n=t.extent[0]-p[0],i=-(t.extent[3]-p[3]),a=Cy(t.extent),o=Ey(t.extent);t.image.width>0&&t.image.height>0&&v.drawImage(t.image,u,u,t.image.width-2*u,t.image.height-2*u,n*y,i*y,a*y,o*y)}));var x=Py(o);return s.getTriangles().forEach((function(t,e,i){var o=t.source,s=t.target,l=o[0][0],u=o[0][1],c=o[1][0],m=o[1][1],g=o[2][0],y=o[2][1],_=f((s[0][0]-x[0])/a),w=f(-(s[0][1]-x[1])/a),b=f((s[1][0]-x[0])/a),M=f(-(s[1][1]-x[1])/a),S=f((s[2][0]-x[0])/a),T=f(-(s[2][1]-x[1])/a),E=l,A=u;l=0,u=0;var P=function(t){for(var e=t.length,r=0;ri&&(i=o,n=a)}if(0===i)return null;var s=t[n];t[n]=t[r],t[r]=s;for(var l=r+1;l=0;d--){h[d]=t[d][e]/t[d][d];for(var f=d-1;f>=0;f--)t[f][e]-=t[f][d]*h[d]}return h}([[c-=E,m-=A,0,0,b-_],[g-=E,y-=A,0,0,S-_],[0,0,c,m,M-w],[0,0,g,y,T-w]]);if(P){if(d.save(),d.beginPath(),function(){if(void 0===d_){var t=document.createElement("canvas").getContext("2d");t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",m_(t,4,5,4,0),m_(t,4,5,0,5);var e=t.getImageData(0,0,3,3).data;d_=g_(e,0)||g_(e,4)||g_(e,8)}return d_}()||!h){d.moveTo(b,M);for(var R=_-b,C=w-M,I=0;I<4;I++)d.lineTo(b+f((I+1)*R/4),M+f(I*C/3)),3!=I&&d.lineTo(b+f((I+1)*R/4),M+f((I+1)*C/3));d.lineTo(S,T)}else d.moveTo(b,M),d.lineTo(_,w),d.lineTo(S,T);d.clip(),d.transform(P[0],P[2],P[1],P[3],_,w),d.translate(p[0]-E,p[3]-A),d.scale(n/r,-n/r),d.drawImage(v.canvas,0,0),d.restore()}})),c&&(d.save(),d.globalCompositeOperation="source-over",d.strokeStyle="black",d.lineWidth=1,s.getTriangles().forEach((function(t,e,r){var n=t.target,i=(n[0][0]-x[0])/a,o=-(n[0][1]-x[1])/a,s=(n[1][0]-x[0])/a,l=-(n[1][1]-x[1])/a,u=(n[2][0]-x[0])/a,c=-(n[2][1]-x[1])/a;d.beginPath(),d.moveTo(s,l),d.lineTo(i,o),d.lineTo(u,c),d.closePath(),d.stroke()})),d.restore()),d.canvas}var x_=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const __=function(t){function e(e,r,n,i,a,o,s,l,u,c,h,d){var f=t.call(this,a,jx.IDLE,{interpolate:!!d})||this;f.renderEdges_=void 0!==h&&h,f.pixelRatio_=s,f.gutter_=l,f.canvas_=null,f.sourceTileGrid_=r,f.targetTileGrid_=i,f.wrappedTileCoord_=o||a,f.sourceTiles_=[],f.sourcesListenerKeys_=null,f.sourceZ_=0;var p=i.getTileCoordExtent(f.wrappedTileCoord_),m=f.targetTileGrid_.getExtent(),g=f.sourceTileGrid_.getExtent(),v=m?Ay(p,m):p;if(0===_y(v))return f.state=jx.EMPTY,f;var y=e.getExtent();y&&(g=g?Ay(g,y):y);var x=i.getResolution(f.wrappedTileCoord_[0]),_=function(t,e,r,n){var i=My(r),a=v_(t,e,i,n);return(!isFinite(a)||a<=0)&&xy(r,(function(r){return a=v_(t,e,r,n),isFinite(a)&&a>0})),a}(e,n,v,x);if(!isFinite(_)||_<=0)return f.state=jx.EMPTY,f;var w=void 0!==c?c:.5;if(f.triangulation_=new h_(e,n,v,g,_*w,x),0===f.triangulation_.getTriangles().length)return f.state=jx.EMPTY,f;f.sourceZ_=r.getZForResolution(_);var b=f.triangulation_.calculateSourceExtent();if(g&&(e.canWrapX()?(b[1]=gv(b[1],g[1],g[3]),b[3]=gv(b[3],g[1],g[3])):b=Ay(b,g)),_y(b)){for(var M=r.getTileRangeForExtentAndZ(b,f.sourceZ_),S=M.minX;S<=M.maxX;S++)for(var T=M.minY;T<=M.maxY;T++){var E=u(f.sourceZ_,S,T,s);E&&f.sourceTiles_.push(E)}0===f.sourceTiles_.length&&(f.state=jx.EMPTY)}else f.state=jx.EMPTY;return f}return x_(e,t),e.prototype.getImage=function(){return this.canvas_},e.prototype.reproject_=function(){var t=[];if(this.sourceTiles_.forEach(function(e,r,n){e&&e.getState()==jx.LOADED&&t.push({extent:this.sourceTileGrid_.getTileCoordExtent(e.tileCoord),image:e.getImage()})}.bind(this)),this.sourceTiles_.length=0,0===t.length)this.state=jx.ERROR;else{var e=this.wrappedTileCoord_[0],r=this.targetTileGrid_.getTileSize(e),n="number"==typeof r?r:r[0],i="number"==typeof r?r:r[1],a=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),s=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=y_(n,i,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),a,s,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=jx.LOADED}this.changed()},e.prototype.load=function(){if(this.state==jx.IDLE){this.state=jx.LOADING,this.changed();var t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(function(e,r,n){var i=e.getState();if(i==jx.IDLE||i==jx.LOADING){t++;var a=n_(e,Cx,(function(r){var n=e.getState();n!=jx.LOADED&&n!=jx.ERROR&&n!=jx.EMPTY||(a_(a),0===--t&&(this.unlistenSources_(),this.reproject_()))}),this);this.sourcesListenerKeys_.push(a)}}.bind(this)),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function(t,e,r){t.getState()==jx.IDLE&&t.load()}))}},e.prototype.unlistenSources_=function(){this.sourcesListenerKeys_.forEach(a_),this.sourcesListenerKeys_=null},e.prototype.release=function(){this.canvas_&&(Kx(this.canvas_.getContext("2d")),p_.push(this.canvas_),this.canvas_=null),t.prototype.release.call(this)},e}(Wx);const w_=function(){function t(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}return t.prototype.canExpireCache=function(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark},t.prototype.expireCache=function(t){for(;this.canExpireCache();)this.pop()},t.prototype.clear=function(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null},t.prototype.containsKey=function(t){return this.entries_.hasOwnProperty(t)},t.prototype.forEach=function(t){for(var e=this.oldest_;e;)t(e.value_,e.key_,this),e=e.newer},t.prototype.get=function(t,e){var r=this.entries_[t];return ey(void 0!==r,15),r===this.newest_||(r===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(r.newer.older=r.older,r.older.newer=r.newer),r.newer=null,r.older=this.newest_,this.newest_.newer=r,this.newest_=r),r.value_},t.prototype.remove=function(t){var e=this.entries_[t];return ey(void 0!==e,15),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_},t.prototype.getCount=function(){return this.count_},t.prototype.getKeys=function(){var t,e=new Array(this.count_),r=0;for(t=this.newest_;t;t=t.older)e[r++]=t.key_;return e},t.prototype.getValues=function(){var t,e=new Array(this.count_),r=0;for(t=this.newest_;t;t=t.older)e[r++]=t.value_;return e},t.prototype.peekLast=function(){return this.oldest_.value_},t.prototype.peekLastKey=function(){return this.oldest_.key_},t.prototype.peekFirstKey=function(){return this.newest_.key_},t.prototype.peek=function(t){if(this.containsKey(t))return this.entries_[t].value_},t.prototype.pop=function(){var t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_},t.prototype.replace=function(t,e){this.get(t),this.entries_[t].value_=e},t.prototype.set=function(t,e){ey(!(t in this.entries_),16);var r={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=r:this.oldest_=r,this.newest_=r,this.entries_[t]=r,++this.count_},t.prototype.setSize=function(t){this.highWaterMark=t},t}();function b_(t,e,r,n){return void 0!==n?(n[0]=t,n[1]=e,n[2]=r,n):[t,e,r]}function M_(t,e,r){return t+"/"+e+"/"+r}function S_(t){return M_(t[0],t[1],t[2])}function T_(t){return t.split("/").map(Number)}function E_(t){return(t[1]<this.maxX&&(this.maxX=t.maxX),t.minYthis.maxY&&(this.maxY=t.maxY)},t.prototype.getHeight=function(){return this.maxY-this.minY+1},t.prototype.getSize=function(){return[this.getWidth(),this.getHeight()]},t.prototype.getWidth=function(){return this.maxX-this.minX+1},t.prototype.intersects=function(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY},t}();function V_(t,e,r,n,i){return void 0!==i?(i.minX=t,i.maxX=e,i.minY=r,i.maxY=n,i):new j_(t,e,r,n)}const H_=j_;var W_=42,q_=256;function X_(t,e,r,n,i,a){for(var o=0,s=t[r-n],l=t[r-n+1];ea&&(u-s)*(a-l)-(i-s)*(c-l)>0&&o++:c<=a&&(u-s)*(a-l)-(i-s)*(c-l)<0&&o--,s=u,l=c}return 0!==o}function Y_(t,e,r,n,i){return!!function(t,e,r,n,i){var a=gy([1/0,1/0,-1/0,-1/0],t,e,r,n);return!!Iy(i,a)&&(!!oy(i,a)||a[0]>=i[0]&&a[2]<=i[2]||a[1]>=i[1]&&a[3]<=i[3]||function(t,e,r,n,i){var a;for(e+=n;e0||r&&0===a)}))),17),!t.origins)for(var a=0,o=this.resolutions_.length-1;a=this.minZoom;){if(e(s,2===this.zoomFactor_?V_(i=Math.floor(i/2),i,a=Math.floor(a/2),a,r):this.getTileRangeForExtentAndZ(o,s,r)))return!0;--s}return!1},t.prototype.getExtent=function(){return this.extent_},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.getMinZoom=function(){return this.minZoom},t.prototype.getOrigin=function(t){return this.origin_?this.origin_:this.origins_[t]},t.prototype.getResolution=function(t){return this.resolutions_[t]},t.prototype.getResolutions=function(){return this.resolutions_},t.prototype.getTileCoordChildTileRange=function(t,e,r){if(t[0]this.maxZoom||e0){for(i=1;i0?i-1:i:t[i-1]-e0?n:Math.max(o/s[0],a/s[1]),u=i+1,c=new Array(u),h=0;hr||r>e.getMaxZoom())return!1;var a=e.getFullTileRange(r);return!a||a.containsXY(n,i)}(t,n)?t:null},e.prototype.clear=function(){this.tileCache.clear()},e.prototype.refresh=function(){this.clear(),t.prototype.refresh.call(this)},e.prototype.updateCacheSize=function(t,e){var r=this.getTileCacheForProjection(e);t>r.highWaterMark&&(r.highWaterMark=t)},e.prototype.useTile=function(t,e,r,n){},e}(G_),ow=function(t){function e(e,r){var n=t.call(this,e)||this;return n.tile=r,n}return iw(e,t),e}(Dx);const sw=aw;function lw(t,e){var r=/\{z\}/g,n=/\{x\}/g,i=/\{y\}/g,a=/\{-y\}/g;return function(o,s,l){return o?t.replace(r,o[0].toString()).replace(n,o[1].toString()).replace(i,o[2].toString()).replace(a,(function(){var t=o[0],r=e.getFullTileRange(t);return ey(r,55),(r.getHeight()-o[2]-1).toString()})):void 0}}function uw(t,e){for(var r=t.length,n=new Array(r),i=0;io)return 1;if(o>a)return-1}return 0}(t,"1.3")>=0},e.prototype.tileUrlFunction=function(t,e,r){var n=this.getTileGrid();if(n||(n=this.getTileGridForProjection(r)),!(n.getResolutions().length<=t[0])){1==e||this.hidpi_&&void 0!==this.serverType_||(e=1);var i=n.getResolution(t[0]),a=n.getTileCoordExtent(t,this.tmpExtent_),o=J_(n.getTileSize(t[0]),this.tmpSize),s=this.gutter_;0!==s&&(o=Z_(o,s,this.tmpSize),a=ny(a,i*s,a)),1!=e&&(o=K_(o,e,this.tmpSize));var l={SERVICE:"WMS",VERSION:gw,REQUEST:"GetMap",FORMAT:"image/png",TRANSPARENT:!0};return jv(l,this.params_),this.getRequestUrl_(t,o,a,e,r,l)}},e}(mw);const _w=rf(Object.freeze(Object.defineProperty({__proto__:null,default:xw},Symbol.toStringTag,{value:"Module"}))),ww="add",bw="remove";var Mw=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Sw="length",Tw=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.element=r,i.index=n,i}return Mw(e,t),e}(Dx);const Ew=function(t){function e(e,r){var n=t.call(this)||this;n.on,n.once,n.un;var i=r||{};if(n.unique_=!!i.unique,n.array_=e||[],n.unique_)for(var a=0,o=n.array_.length;a0;)this.pop()},e.prototype.extend=function(t){for(var e=0,r=t.length;er;){if(n-r>600){var a=n-r+1,o=e-r+1,s=Math.log(a),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(a-l)/a)*(o-a/2<0?-1:1);Pw(t,e,Math.max(r,Math.floor(e-o*l/a+u)),Math.min(n,Math.floor(e+(a-o)*l/a+u)),i)}var c=t[e],h=r,d=n;for(Rw(t,r,e),i(t[n],c)>0&&Rw(t,r,n);h0;)d--}0===i(t[r],c)?Rw(t,r,d):Rw(t,++d,n),d<=e&&(r=d+1),e<=d&&(n=d-1)}}function Rw(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Cw(t,e){return te?1:0}function Iw(t,e,r){if(!r)return e.indexOf(t);for(let n=0;n=t.minX&&e.maxY>=t.minY}function jw(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Vw(t,e,r,n,i){const a=[e,r];for(;a.length;){if((r=a.pop())-(e=a.pop())<=n)continue;const o=e+Math.ceil((r-e)/n/2)*n;Aw(t,o,e,r,i),a.push(e,o,o,r)}}const Hw=function(){function t(t){this.rbush_=new class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const r=[];if(!Gw(t,e))return r;const n=this.toBBox,i=[];for(;e;){for(let a=0;a=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(n,i,e)}_split(t,e){const r=t[e],n=r.children.length,i=this._minEntries;this._chooseSplitAxis(r,i,n);const a=this._chooseSplitIndex(r,i,n),o=jw(r.children.splice(a,r.children.length-a));o.height=r.height,o.leaf=r.leaf,Lw(r,this.toBBox),Lw(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(r,o)}_splitRoot(t,e){this.data=jw([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Lw(this.data,this.toBBox)}_chooseSplitIndex(t,e,r){let n,i=1/0,a=1/0;for(let o=e;o<=r-e;o++){const e=Ow(t,0,o,this.toBBox),s=Ow(t,o,r,this.toBBox),l=Bw(e,s),u=Nw(e)+Nw(s);l=e;n--){const e=t.children[n];Dw(o,t.leaf?i(e):e),s+=Uw(o)}return s}_adjustParentBBoxes(t,e,r){for(let n=r;n>=0;n--)Dw(e[n],t)}_condense(t){for(let e,r=t.length-1;r>=0;r--)0===t[r].children.length?r>0?(e=t[r-1].children,e.splice(e.indexOf(t[r]),1)):this.clear():Lw(t[r],this.toBBox)}}(t),this.items_={}}return t.prototype.insert=function(t,e){var r={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(r),this.items_[Qv(e)]=r},t.prototype.load=function(t,e){for(var r=new Array(e.length),n=0,i=e.length;n=200&&s.status<300){var n=e.getType(),l=void 0;"json"==n||"text"==n?l=s.responseText:"xml"==n?(l=s.responseXML)||(l=(new DOMParser).parseFromString(s.responseText,"application/xml")):"arraybuffer"==n&&(l=s.response),l?a(e.readFeatures(l,{extent:r,featureProjection:i}),e.readProjection(l)):o()}else o()},s.onerror=o,s.send()}function eb(t,e){return function(r,n,i,a,o){var s=this;tb(t,e,r,n,i,(function(t,e){s.addFeatures(t),void 0!==a&&a(t)}),o||Bx)}}var rb=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),nb=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.feature=r,i.features=n,i}return rb(e,t),e}(Dx),ib=function(t){function e(e){var r=this,n=e||{};(r=t.call(this,{attributions:n.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===n.wrapX||n.wrapX})||this).on,r.once,r.un,r.loader_=Bx,r.format_=n.format,r.overlaps_=void 0===n.overlaps||n.overlaps,r.url_=n.url,void 0!==n.loader?r.loader_=n.loader:void 0!==r.url_&&(ey(r.format_,7),r.loader_=eb(r.url_,r.format_)),r.strategy_=void 0!==n.strategy?n.strategy:Qw;var i,a,o=void 0===n.useSpatialIndex||n.useSpatialIndex;return r.featuresRtree_=o?new Hw:null,r.loadedExtentsRtree_=new Hw,r.loadingExtentsCount_=0,r.nullGeometryFeatures_={},r.idIndex_={},r.uidIndex_={},r.featureChangeKeys_={},r.featuresCollection_=null,Array.isArray(n.features)?a=n.features:n.features&&(a=(i=n.features).getArray()),o||void 0!==i||(i=new Ew(a)),void 0!==a&&r.addFeaturesInternal(a),void 0!==i&&r.bindFeaturesCollection_(i),r}return rb(e,t),e.prototype.addFeature=function(t){this.addFeatureInternal(t),this.changed()},e.prototype.addFeatureInternal=function(t){var e=Qv(t);if(this.addToIndex_(e,t)){this.setupChangeEvents_(e,t);var r=t.getGeometry();if(r){var n=r.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new nb(Ww,t))}else this.featuresCollection_&&this.featuresCollection_.remove(t)},e.prototype.setupChangeEvents_=function(t,e){this.featureChangeKeys_[t]=[n_(e,Cx,this.handleFeatureChange_,this),n_(e,L_,this.handleFeatureChange_,this)]},e.prototype.addToIndex_=function(t,e){var r=!0,n=e.getId();return void 0!==n&&(n.toString()in this.idIndex_?r=!1:this.idIndex_[n.toString()]=e),r&&(ey(!(t in this.uidIndex_),30),this.uidIndex_[t]=e),r},e.prototype.addFeatures=function(t){this.addFeaturesInternal(t),this.changed()},e.prototype.addFeaturesInternal=function(t){for(var e=[],r=[],n=[],i=0,a=t.length;i0},e.prototype.refresh=function(){this.clear(!0),this.loadedExtentsRtree_.clear(),t.prototype.refresh.call(this)},e.prototype.removeLoadedExtent=function(t){var e,r=this.loadedExtentsRtree_;r.forEachInExtent(t,(function(r){if(dy(r.extent,t))return e=r,!0})),e&&r.remove(e)},e.prototype.removeFeature=function(t){if(t){var e=Qv(t);e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.removeFeatureInternal(t)&&this.changed()}},e.prototype.removeFeatureInternal=function(t){var e=Qv(t),r=this.featureChangeKeys_[e];if(r){r.forEach(a_),delete this.featureChangeKeys_[e];var n=t.getId();return void 0!==n&&delete this.idIndex_[n.toString()],delete this.uidIndex_[e],this.dispatchEvent(new nb(Yw,t)),t}},e.prototype.removeFromIdIndex_=function(t){var e=!1;for(var r in this.idIndex_)if(this.idIndex_[r]===t){delete this.idIndex_[r],e=!0;break}return e},e.prototype.setLoader=function(t){this.loader_=t},e.prototype.setUrl=function(t){ey(this.format_,7),this.url_=t,this.setLoader(eb(t,this.format_))},e}(G_);const ab=rf(Object.freeze(Object.defineProperty({__proto__:null,VectorSourceEvent:nb,default:ib},Symbol.toStringTag,{value:"Module"})));var ob=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const sb=function(t){function e(e,r,n,i,a,o){var s=t.call(this,e,r,o)||this;return s.extent=null,s.format_=i,s.features_=null,s.loader_,s.projection=null,s.resolution,s.tileLoadFunction_=a,s.url_=n,s.key=n,s}return ob(e,t),e.prototype.getFormat=function(){return this.format_},e.prototype.getFeatures=function(){return this.features_},e.prototype.load=function(){this.state==jx.IDLE&&(this.setState(jx.LOADING),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))},e.prototype.onLoad=function(t,e){this.setFeatures(t)},e.prototype.onError=function(){this.setState(jx.ERROR)},e.prototype.setFeatures=function(t){this.features_=t,this.setState(jx.LOADED)},e.prototype.setLoader=function(t){this.loader_=t},e}(Wx);var lb=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ub=[];const cb=function(t){function e(e,r,n,i){var a=t.call(this,e,r,{transition:0})||this;return a.context_={},a.executorGroups={},a.declutterExecutorGroups={},a.loadingSourceTiles=0,a.hitDetectionImageData={},a.replayState_={},a.sourceTiles=[],a.errorTileKeys={},a.wantedResolution,a.getSourceTiles=i.bind(void 0,a),a.wrappedTileCoord=n,a}return lb(e,t),e.prototype.getContext=function(t){var e=Qv(t);return e in this.context_||(this.context_[e]=Zx(1,1,ub)),this.context_[e]},e.prototype.hasContext=function(t){return Qv(t)in this.context_},e.prototype.getImage=function(t){return this.hasContext(t)?this.getContext(t).canvas:null},e.prototype.getReplayState=function(t){var e=Qv(t);return e in this.replayState_||(this.replayState_[e]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[e]},e.prototype.load=function(){this.getSourceTiles()},e.prototype.release=function(){for(var e in this.context_){var r=this.context_[e];Kx(r),ub.push(r.canvas),delete this.context_[e]}t.prototype.release.call(this)},e}(Wx);var hb=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),db=function(t){function e(e){var r=this,n=e.projection||"EPSG:3857",i=e.extent||nw(n),a=e.tileGrid||ew({extent:i,maxResolution:e.maxResolution,maxZoom:void 0!==e.maxZoom?e.maxZoom:22,minZoom:e.minZoom,tileSize:e.tileSize||512});return(r=t.call(this,{attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,interpolate:!0,opaque:!1,projection:n,state:e.state,tileGrid:a,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:fb,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:void 0===e.wrapX||e.wrapX,transition:e.transition,zDirection:void 0===e.zDirection?1:e.zDirection})||this).format_=e.format?e.format:null,r.sourceTileCache=new P_(r.tileCache.highWaterMark),r.overlaps_=null==e.overlaps||e.overlaps,r.tileClass=e.tileClass?e.tileClass:sb,r.tileGrids_={},r}return hb(e,t),e.prototype.getFeaturesInExtent=function(t){var e=[],r=this.tileCache;if(0===r.getCount())return e;var n=T_(r.peekFirstKey())[0],i=this.tileGrid;return r.forEach((function(r){if(r.tileCoord[0]===n&&r.getState()===jx.LOADED)for(var a=r.getSourceTiles(),o=0,s=a.length;oStamen Design, under CC BY 3.0.',yb],wb={terrain:{extension:"jpg",opaque:!0},"terrain-background":{extension:"jpg",opaque:!0},"terrain-labels":{extension:"png",opaque:!1},"terrain-lines":{extension:"png",opaque:!1},"toner-background":{extension:"png",opaque:!0},toner:{extension:"png",opaque:!0},"toner-hybrid":{extension:"png",opaque:!1},"toner-labels":{extension:"png",opaque:!1},"toner-lines":{extension:"png",opaque:!1},"toner-lite":{extension:"png",opaque:!0},watercolor:{extension:"jpg",opaque:!0}},bb={terrain:{minZoom:0,maxZoom:18},toner:{minZoom:0,maxZoom:20},watercolor:{minZoom:0,maxZoom:18}},Mb=function(t){function e(e){var r=void 0===e.imageSmoothing||e.imageSmoothing;void 0!==e.interpolate&&(r=e.interpolate);var n=e.layer.indexOf("-"),i=-1==n?e.layer:e.layer.slice(0,n),a=bb[i],o=wb[e.layer],s=void 0!==e.url?e.url:"https://stamen-tiles-{a-d}.a.ssl.fastly.net/"+e.layer+"/{z}/{x}/{y}."+o.extension;return t.call(this,{attributions:_b,cacheSize:e.cacheSize,crossOrigin:"anonymous",interpolate:r,maxZoom:null!=e.maxZoom?e.maxZoom:a.maxZoom,minZoom:null!=e.minZoom?e.minZoom:a.minZoom,opaque:o.opaque,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:e.tileLoadFunction,transition:e.transition,url:s,wrapX:e.wrapX,zDirection:e.zDirection})||this}return xb(e,t),e}(gb);const Sb=rf(Object.freeze(Object.defineProperty({__proto__:null,default:Mb},Symbol.toStringTag,{value:"Module"})));var Tb,Eb={};function Ab(){if(Tb)return Eb;Tb=1,Object.defineProperty(Eb,"__esModule",{value:!0}),Eb.STRATEGY_PROGRESSIVE=Eb.STRATEGY_MIN_NETWORK_TRAFFIC=Eb.STRATEGY_GROUP=Eb.STRATEGY_DICHOTOMY=void 0;Eb.STRATEGY_MIN_NETWORK_TRAFFIC=0;Eb.STRATEGY_GROUP=1;Eb.STRATEGY_PROGRESSIVE=2;return Eb.STRATEGY_DICHOTOMY=3,Eb}var Pb,Rb={};var Cb,Ib,Lb,Ob={},Db={};function kb(){if(Cb)return Db;Cb=1,Object.defineProperty(Db,"__esModule",{value:!0}),Db.default=void 0;var t=new Ff.TextureLoader;function e(t){if(!t.ok){var e=new Error("Error loading ".concat(t.url,": status ").concat(t.status));throw e.response=t,e}}var r={text:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.text()}))},json:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.json()}))},xml:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.text()})).then((function(t){return(new window.DOMParser).parseFromString(t,"text/xml")}))},texture:function(e){var r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.crossOrigin=i.crossOrigin;var a=new Promise((function(t,e){r=t,n=e}));return t.load(e,r,(function(){}),n),a},arrayBuffer:function(t){return fetch(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).then((function(t){return e(t),t.arrayBuffer()}))}};return Db.default=r,Db}function Fb(){if(Lb)return Rx;Lb=1;var t=sf;Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.defineLayerProperty=Rx.default=Rx.MAX_RETRY=Rx.ImageryLayers=void 0,Rx.nodeCommandQueuePriorityFunction=function(t){var e=t.extent.dimensions();return e.x*e.y},Rx.refinementCommandCancellationFn=function(t){if(!t.requester.parent||!t.requester.material)return!0;if(t.force)return!1;return!t.requester.material.visible};var e=t(df()),r=t(_f()),n=t(Mf()),i=t(Rf()),a=t(Lf()),o=t(kf()),s=Ff,l=t(_w),u=t(ab),c=t(pb),h=t(Sb),d=Ab(),f=t(function(){if(Pb)return Rb;Pb=1;var t=sf;Object.defineProperty(Rb,"__esModule",{value:!0}),Rb.default=void 0;var e=t(_f()),r=t(df()),n=(0,e.default)((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,r.default)(this,t),this.url=e.url})),i=n;return Rb.default=i,Rb}()),p=t(function(){if(Ib)return Ob;Ib=1;var t=sf;Object.defineProperty(Ob,"__esModule",{value:!0}),Ob.default=void 0;var e=t(df()),r=t(_f()),n=t(kb()),i=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,e.default)(this,t),this.url=new URL(r.url,window.location),this.networkOptions=r.networkOptions}return(0,r.default)(t,[{key:"buildUrl",value:function(t){return this.url.href.substr(0,this.url.href.lastIndexOf("/")+1)+t}},{key:"fetchMetadata",value:function(){return n.default.json(this.url.href,this.networkOptions)}}]),t}(),a=i;return Ob.default=a,Ob}());function m(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return g(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);ri&&o.sequence<=e?o.sequence--:o.sequence>=e&&o.sequence0&&this.moveLayerToIndex(t,t.sequence-1,e)}},{key:"moveLayerUp",value:function(t,e){var r=e.length-1;t.sequence1&&void 0!==arguments[1]?arguments[1]:{};return(0,r.default)(this,o),n=e.call(this,t,a),(0,c.defineLayerProperty)((0,i.default)(n),"frozen",!1),(0,c.defineLayerProperty)((0,i.default)(n),"visible",!0),(0,c.defineLayerProperty)((0,i.default)(n),"opacity",1),(0,c.defineLayerProperty)((0,i.default)(n),"sequence",0),n}return(0,n.default)(o,[{key:"clean",value:function(t){var e=this;t.object3d.traverse((function(r){r.layer===t&&(delete r.layerUpdateState[e.id],r.material&&-1!==r.material.indexOfColorLayer(e)&&r.material.removeLayer(e))}))}},{key:"initColorTexturesFromParent",value:function(t,e,r){if(!r.material||!r.material.getColorTexture)return!1;for(var n=e.getExtentForLayer(this);r&&r.material&&r.material.uniforms.colorTexture&&r.material.uniforms.colorTexture.value!==r.material.texturesInfo.color.atlasTexture;)r=r.parent;if(!r||!r.material)return!1;var i=r.material.getColorTexture(this);return!!i&&(!(!i||!i.extent)&&(e.material.uniforms.colorTexture.value=r.material.uniforms.colorTexture.value,e.material.setColorTextures(this,{texture:i,pitch:n.offsetToParent(i.extent)},!0,t.instance),!0))}},{key:"update",value:function(t,e,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.material;if(!e.parent||!a)return null;if(void 0===e.layerUpdateState[this.id]){if(e.layerUpdateState[this.id]=new l.default,!this.tileInsideLimit(e,this)&&(this.noTextureParentOutsideLimit||!r||!r.material||!r.material.getColorTexture(this)))return e.layerUpdateState[this.id].noMoreUpdatePossible(),null;if(a.pushLayer(this,e.getExtentForLayer(this)),r&&this.initColorTexturesFromParent(t,e,r,this))return t.instance.notifyChange(e,!1),null}if(!e.material.visible||i)return null;a.setLayerVisibility(this,this.visible),a.setLayerOpacity(this,this.opacity);var o=Date.now();if(this.frozen||!this.visible||!e.layerUpdateState[this.id].canTryUpdate(o))return null;var s=this.getPossibleTextureImprovements(this,e.getExtentForLayer(this),e.material.getColorTexture(this),e.layerUpdateState[this.id].failureParams);if(void 0===s)return e.layerUpdateState[this.id].noMoreUpdatePossible(),null;if(null===s||!1===s)return null;e.layerUpdateState[this.id].newTry();var h={view:t.instance,layer:this,requester:e,priority:(0,c.nodeCommandQueuePriorityFunction)(e),earlyDropFunction:c.refinementCommandCancellationFn,toDownload:s};return t.scheduler.execute(h).then((function(r){return null===e.material?null:e.material.setColorTextures(n,r,!1,t.instance).then((function(){e.layerUpdateState[n.id].success()}))}),(function(r){if(r instanceof u.default)e.layerUpdateState[n.id].success();else{console.warn("Imagery texture update error for",e,r);var i=e.layerUpdateState[n.id].errorCount>c.MAX_RETRY;e.layerUpdateState[n.id].failure(Date.now(),i,r),i||window.setTimeout((function(){t.instance.notifyChange(e,!1)}),1e3*e.layerUpdateState[n.id].secondsUntilNextTry())}}))}}]),o}(c.default),p=f;return Bb.default=p,Bb}var Xb,Yb,Zb={},Kb={},Jb={exports:{}},Qb={exports:{}};function $b(){return Yb||(Yb=1,function(t){var e=(Xb||(Xb=1,function(t){var e=kf();t.exports=function(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=e(t)););return t},t.exports.__esModule=!0,t.exports.default=t.exports}(Qb)),Qb.exports);function r(){return"undefined"!=typeof Reflect&&Reflect.get?(t.exports=r=Reflect.get.bind(),t.exports.__esModule=!0,t.exports.default=t.exports):(t.exports=r=function(t,r,n){var i=e(t,r);if(i){var a=Object.getOwnPropertyDescriptor(i,r);return a.get?a.get.call(arguments.length<3?t:n):a.value}},t.exports.__esModule=!0,t.exports.default=t.exports),r.apply(this,arguments)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(Jb)),Jb.exports}var tM,eM={};function rM(){if(tM)return eM;tM=1,Object.defineProperty(eM,"__esModule",{value:!0}),eM.default=void 0;return eM.default={FINAL:0,DEPTH:1,ID:2,UV:3},eM}var nM,iM={},aM={};function oM(){if(nM)return aM;function t(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,r){if(!t)return;if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:1/0,i={value:e,lastTimeUsed:Date.now(),lifetime:n};return r.set(t,i),e},deletePrefix:function(e){var n,i=t(r.keys());try{for(i.s();!(n=i.n()).done;){var a=n.value;a.startsWith&&a.startsWith(e)&&r.delete(a)}}catch(t){i.e(t)}finally{i.f()}},delete:function(t){return r.delete(t)},clear:r.clear(),flush:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),e=r.size;r.forEach((function(e,n){e.lifetime1?n-1:0),s=1;s1&&void 0!==arguments[1]?arguments[1]:new s.Vector4;if(this.crs()!==t.crs())throw new Error("unsupported mix");if(d(this.crs())){var r=this.zoom-t.zoom,n=Math.pow(2,r),i=1/n,a=(this.row-this.row%n)*i,o=(this.col-this.col%n)*i;return e.set(this.col*i-o,this.row*i-a,i,i)}var l=t.dimensions(),u=this.dimensions(),c=.001*Math.round(1e3*(this.west()-t.west())/l.x),h=.001*Math.round(1e3*(t.north()-this.north())/l.y),f=.001*Math.round(1e3*u.x/l.x),p=.001*Math.round(1e3*u.y/l.y);return e.set(c,h,f,p)}},{key:"west",value:function(){return this._values[h.WEST]}},{key:"east",value:function(){return this._values[h.EAST]}},{key:"north",value:function(){return this._values[h.NORTH]}},{key:"south",value:function(){return this._values[h.SOUTH]}},{key:"crs",value:function(){return this._crs}},{key:"center",value:function(t){if(d(this._crs))throw new Error("Invalid operation for WMTS bbox");var e;t?(l.default.call(t,this._crs,this._values[0],this._values[2]),e=t):e=new l.default(this._crs,this._values[0],this._values[2]);var r=this.dimensions();return e._values[0]+=.5*r.x,e._values[1]+=.5*r.y,e}},{key:"dimensions",value:function(t){return(t=t||{x:0,y:0}).x=Math.abs(this.east()-this.west()),t.y=Math.abs(this.north()-this.south()),t}},{key:"isPointInside",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.crs()===t.crs?t:t.as(this.crs());return(0,l.crsIsGeographic)(this.crs())?r.longitude()<=this.east()+e&&r.longitude()>=this.west()-e&&r.latitude()<=this.north()+e&&r.latitude()>=this.south()-e:r.x()<=this.east()+e&&r.x()>=this.west()-e&&r.y()<=this.north()+e&&r.y()>=this.south()-e}},{key:"isInside",value:function(t,e){if(d(this.crs())){if(this.zoom===t.zoom)return this.row===t.row&&this.col===t.col;if(this.zoom=e.east()||this.east()<=e.west()||this.south()>=e.north()||this.north()<=e.south())}},{key:"intersect",value:function(t){return this.intersectsExtent(t)?(t.crs()!==this.crs()&&(t=t.as(this.crs())),this.set(this.crs(),Math.max(this.west(),t.west()),Math.min(this.east(),t.east()),Math.max(this.south(),t.south()),Math.min(this.north(),t.north())),this):(this.set(this.crs(),0,0,0,0),this)}},{key:"set",value:function(t){for(var e=this,r=arguments.length,n=new Array(r>1?r-1:0),i=1;ithis.east()&&(this._values[h.EAST]=r);var n=t.south();nthis.north()&&(this._values[h.NORTH]=i)}},{key:"expandByPoint",value:function(t){var e=t.as(this.crs()),r=e._values[0];rthis.east()&&(this._values[h.EAST]=r);var n=e._values[1];nthis.north()&&(this._values[h.NORTH]=n)}},{key:"shift",value:function(t,e){return this._values[h.WEST]+=t,this._values[h.EAST]+=t,this._values[h.SOUTH]+=e,this._values[h.NORTH]+=e,this}},{key:"quadtreeSplit",value:function(){return this.center(f),[new t(this.crs(),this.west(),f._values[0],f._values[1],this.north()),new t(this.crs(),f._values[0],this.east(),f._values[1],this.north()),new t(this.crs(),this.west(),f._values[0],this.south(),f._values[1]),new t(this.crs(),f._values[0],this.east(),this.south(),f._values[1])]}},{key:"externalBorders",value:function(t){var e=[this.clone(),this.clone(),this.clone(),this.clone()],r=this.dimensions();return e[0]._values[h.SOUTH]=e[0]._values[h.NORTH],e[0]._values[h.NORTH]+=r.y*t,e[1]._values[h.WEST]=e[1]._values[h.EAST],e[1]._values[h.EAST]+=r.x*t,e[2]._values[h.NORTH]=e[2]._values[h.SOUTH],e[2]._values[h.SOUTH]-=r.y*t,e[3]._values[h.EAST]=e[3]._values[h.WEST],e[3]._values[h.WEST]-=r.x*t,e}}],[{key:"fromBox3",value:function(t,e){return new this(t,{west:e.min.x,east:e.max.x,south:e.min.y,north:e.max.y})}}]),t}(),m=p;return uM.default=m,uM}function MM(){if(vM)return lM;vM=1;var t=sf;Object.defineProperty(lM,"__esModule",{value:!0}),lM.default=void 0;var e=Ff,r=t(Ax()),n=t(bM()),i=Math.PI/4,a=Math.PI/2,o=1/(2*Math.PI),s=Math.log(2);function l(t){return Math.min(84,Math.max(-86,t))}var u={x:0,y:0},c=new r.default("EPSG:4326",0,0,0),h={WGS84ToY:function(t){return.5-Math.log(Math.tan(i+.5*e.Math.degToRad(t)))*o},YToWGS84:function(t){return e.Math.radToDeg(2*(Math.atan(Math.exp(-(t-.5)/o))-i))},getCoordWMTS_WGS84:function(t,e,r){if("PM"===r)return function(t,e){var r,i=[],a=t.zoom+1,o=Math.pow(2,a),s=1/o,u=h.WGS84ToY(l(e.north())),c=h.WGS84ToY(l(e.south())),d=Math.floor(u/s);r=Math.ceil(c/s)-1,r=Math.min(r,o-1);for(var f=t.col,p=r;p>=d;p--)for(var m=f;m<=f;m++)i.push(new n.default("WMTS:PM",a,p,m));return i}(t,e);if("WGS84G"===r)return[t.clone()];throw new Error("Unsupported TileMatrixSet '".concat(r,"'"))},WGS84toWMTS:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new n.default("WMTS:WGS84G",0,0,0);t.dimensions(u);var i=Math.floor(Math.log(Math.PI/e.Math.degToRad(u.y))/s+.5),o=Math.pow(2,i),l=2*Math.PI/(2*o),h=Math.PI/o;t.center(c);var d=Math.floor((Math.PI+e.Math.degToRad(c.longitude()))/l),f=Math.floor(o-(a+e.Math.degToRad(c.latitude()))/h);return r.set("WMTS:WGS84G",i,f,d)},UnitaryToLongitudeWGS84:function(t,e){return e.dimensions(u),e.west()+t*u.x},UnitaryToLatitudeWGS84:function(t,e){return e.dimensions(u),e.south()+t*u.y}};var d=h;return lM.default=d,lM}function SM(){if(yM)return iM;yM=1;var t=sf;Object.defineProperty(iM,"__esModule",{value:!0}),iM.default=iM.SIZE_TEXTURE_TILE=void 0;var e=Ff,r=t(kb()),n=t(oM()),i=t(MM()),a=t(bM());iM.SIZE_TEXTURE_TILE=256;var o=new a.default("WMTS:WGS84G",0,0,0),s={getColorTextureByUrl:function(t,i){return n.default.get(t)||n.default.set(t,r.default.texture(t,i).then((function(t){return t.generateMipmaps=!1,t.magFilter=e.LinearFilter,t.minFilter=e.LinearFilter,t.anisotropy=16,t})),n.default.POLICIES.TEXTURE)},getXBilTextureByUrl:function(t,i){return n.default.get(t)||n.default.set(t,r.default.arrayBuffer(t,i).then((function(t){var r=function(t){var r=new e.DataTexture(t,256,256,e.AlphaFormat,e.FloatType);return r.needsUpdate=!0,r}(t);return r.generateMipmaps=!1,r.magFilter=e.LinearFilter,r.minFilter=e.LinearFilter,r})),n.default.POLICIES.TEXTURE)},computeTileMatrixSetCoordinates:function(t,e){if(!((e=e||"WGS84G")in t.wmtsCoords)){if(t.wmtsCoords.WGS84G){var r=t.wmtsCoords.WGS84G[0];o.zoom=r.zoom,o.col=r.col,o.row=r.row}else i.default.WGS84toWMTS(t.extent,o),t.wmtsCoords.WGS84G=[o.clone()];t.wmtsCoords[e]=i.default.getCoordWMTS_WGS84(o,t.extent,e)}},computeTMSCoordinates:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"bottom";if(t.crs()!==e.crs())throw new Error("Unsupported configuration. TMS is only supported when geometry has the same crs than TMS layer");var n,i=t.center(),o=e.dimensions(),s=Math.round(o.x/t.dimensions().x),l=Math.floor(Math.log2(s)),u=(i.x()-e.west())/o.x;return n="top"===r?(e.north()-i.y())/o.y:(i.y()-e.south())/o.y,[new a.default("TMS",l,Math.floor(n*s),Math.floor(u*s))]},WMTS_WGS84Parent:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new a.default(t.crs(),0,0,0),i=t.zoom-e,o=Math.pow(2,i),s=1/o,l=(t.row-t.row%o)*s,u=(t.col-t.col%o)*s;return r&&(r.x=t.col*s-u,r.y=t.row*s-l,r.z=s,r.w=s),n.set(n.crs(),e,l,u)}};return iM.default=s,iM}function TM(){if(xM)return Kb;xM=1;var t=sf;Object.defineProperty(Kb,"__esModule",{value:!0}),Kb.default=void 0;var e=t(df()),r=t(_f()),n=t($b()),i=t(Rf()),a=t(Lf()),o=t(kf()),s=Ff,l=t(rM()),u=t(SM());function c(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return h(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rl.default.FINAL?this.material.transparent=!1:this.material.transparent=1!==this.material.opacity||1!==this.material.uniforms.noTextureOpacity.value,this.material.needsUpdate=!0)}},{key:"pushRenderState",value:function(t){var e=this;if(this.material.uniforms.renderingState.value===t)return function(){};var r=this.material.uniforms.renderingState.value;return this.traverse((function(e){return f(e,t)})),function(){e.traverse((function(t){return f(t,r)}))}}},{key:"setFog",value:function(t){this.material.setFogDistance(t)}},{key:"setSelected",value:function(t){this.material.setSelected(t)}},{key:"setTextureElevation",value:function(t,e){null!==this.material&&(this.setBBoxZ(e.min,e.max),this.material.setElevationTexture(t,e))}},{key:"setBBoxZ",value:function(t,e){null==t&&null==e||Math.floor(t)===Math.floor(this.obb.z.min)&&Math.floor(e)===Math.floor(this.obb.z.max)||this.OBB().updateZ(t,e)}},{key:"OBB",value:function(){return this.obb}},{key:"removeColorLayer",value:function(t){this.layerUpdateState&&this.layerUpdateState[t]&&delete this.layerUpdateState[t],this.material.removeColorLayer(t)}},{key:"changeSequenceLayers",value:function(t){this.material.getColorLayersCount()<2||this.material.setSequence(t)}},{key:"getExtentForLayer",value:function(t){if(t.extent.crs()!==this.extent.crs())throw new Error("Layer should be in the same CRS of their supporting tile geometry, but layer crs is ".concat(t.extent.crs()," and tile crs is ").concat(this.extent.crs()));return"tms"===t.protocol||"xyz"===t.protocol?u.default.computeTMSCoordinates(this.extent,t.extent,t.origin)[0]:this.extent}},{key:"findCommonAncestor",value:function(t){if(t)return t.level===this.level?t.id===this.id?t:0!==t.level?this.parent.findCommonAncestor(t.parent):void 0:t.level1?o-1:0),c=1;c=1?new i.Vector3(u,h):new i.Vector3(l,c));g.getBarycoord(new i.Vector3(e.x,e.y),p);var v=d(t,g.a.x,g.a.y),y=d(t,g.b.x,g.b.y),x=d(t,g.c.x,g.c.y);return v*p.x+y*p.y+x*p.z}(h,v,l.extent.dimensions(),h.texture.extent.dimensions()):f(h,v),{coord:s,texture:g,tile:l}}function v(t,e,r,n,i,o){var s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},l=arguments.length>8?arguments[8]:void 0,u=(arguments.length>7?arguments[7]:void 0)||new a.default(n);s.worldFromLocal?u.set(n,m.v.copy(i).applyMatrix4(s.worldFromLocal)):u.set(n,i);var c=g(t,e,u,r,l);return c?(c.coord._values[2]+=o,c.coord.as(n,m.coord2).xyz(i),s.localFromWorld&&i.applyMatrix4(s.localFromWorld),{id:c.texture.id,version:c.texture.version,tile:c.tile}):null}var y={getElevationValueAt:function(t,e){var r=g(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,e,(arguments.length>3?arguments[3]:void 0)||t.level0Nodes);return r?{z:r.coord._values[2],texture:r.texture,tile:r.tile}:null},placeObjectOnGround:function(t,e,r){var n,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=arguments.length>4?arguments[4]:void 0;if(n=s?s.concat(t.level0Nodes):t.level0Nodes,!o.modifyGeometry){o.cache&&(o.cache.length=1);var l={worldFromLocal:r.parent?r.parent.matrixWorld:void 0,localFromWorld:r.parent?(new i.Matrix4).copy(r.parent.matrixWorld).invert():void 0};return!!(m=v(t,o.method||0,n,e,r.position,o.offset||0,l,void 0,o.cache?o.cache[0]:void 0))&&(o.cache&&(o.cache[0]=m),r.updateMatrix(),r.updateMatrixWorld(),!0)}var u={worldFromLocal:r.matrixWorld,localFromWorld:(new i.Matrix4).copy(r.matrixWorld).invert()},c=r.geometry;if(c.vertices){o.cache&&(o.cache.length=c.vertices.length);for(var h=!0,d=new a.default(e),f=0;f=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,l=arguments.length>2?arguments[2]:void 0;return(0,e.default)(this,a),(t=i.call(this)).atlasInfo=l,t.defines.STITCHING=1,t.uniforms.segments=new o.Uniform(n),r.side&&(t.side=r.side),t.uniforms.renderingState=new o.Uniform(s.default.FINAL),t.defines.TEX_UNITS=0,t.fragmentShader="#include \n\nuniform int renderingState;\nuniform sampler2D colorTexture;\n\n#if TEX_UNITS\nuniform vec4 colorOffsetScale[TEX_UNITS];\nuniform float colorOpacity[TEX_UNITS];\nuniform bool colorVisible[TEX_UNITS];\nuniform vec3 colors[TEX_UNITS];\n#endif\n\n// backgroundColor\nuniform float noTextureOpacity;\nuniform vec3 noTextureColor;\n// tile opacity\nuniform float opacity;\n\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying vec4 vPosition;\n\n#if defined(HILLSHADE)\n// hillshade support\nuniform sampler2D elevationTexture;\nuniform vec4 elevationOffsetScale;\nuniform vec2 tileDimensions;\n\n#include \n\nfloat ZENITH = 0.7857142857;\nfloat AZIMUTH = 2.3571428571;\n\n#define M_PI 3.1415926535897932384626433832795\n\n// from https://github.com/PropellerAero/cesium-elevation-gradient/blob/master/lib/shaders/elevationGradientFrag.glsl\nfloat calcHillshade(float a, float b, float c, float d, float e, float f, float g, float h, float i, vec2 onePixel){\n vec2 cellsize = tileDimensions / onePixel;\n // http://edndoc.esri.com/arcobjects/9.2/net/shared/geoprocessing/spatial_analyst_tools/how_hillshade_works.htm\n\n float dzdx = ((c + 2.0 * f + i) - (a + 2.0 * d + g)) / (8.0 * cellsize.x);\n float dzdy = ((g + 2.0 * h + i) - (a + 2.0 * b + c)) / (8.0 * cellsize.y);\n float slope = atan(1.0 * sqrt(dzdx * dzdx + dzdy * dzdy));\n\n float aspect = atan(dzdy, -dzdx);\n\n if(aspect < 0.0){\n aspect = aspect + 2.0 * M_PI;\n }\n\n float hillshade = ((cos(ZENITH) * cos(slope)) + (sin(ZENITH) * sin(slope) * cos(AZIMUTH - aspect)));\n return clamp(hillshade, 0., 1.);\n}\n#endif\n\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\n\n#if defined(DEBUG)\nuniform bool showOutline;\nconst float sLine = 0.003;\n#endif\n\n#include \n\n#include \nuniform int uuid;\n\nvoid main() {\n if (renderingState == 2) {\n gl_FragColor = packDepthToRGBA(float(uuid) / (256.0 * 256.0 * 256.0));\n } else if (renderingState == 1) {\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n } else if (renderingState == 3) {\n gl_FragColor = encodeHalfRGBA(vUv);\n } else {\n\n vec4 diffuseColor = vec4(noTextureColor, 0.0);\n\n bool hasTexture = false;\n\n #if TEX_UNITS\n #pragma unroll_loop_start\n for (int i = 0; i < TEX_UNITS; i++) {\n if (colorVisible[i] && colorOpacity[i] > 0.0 && colorOffsetScale[i].zw != vec2(0.0)) {\n vec2 uv = computeUv(vUv, colorOffsetScale[i].xy, colorOffsetScale[i].zw);\n vec4 layerColor = texture2D(colorTexture, uv);\n if (layerColor.a > 0.0) {\n hasTexture = true;\n }\n layerColor.rgb *= colors[i];\n diffuseColor = diffuseColor * (1.0 - layerColor.a * colorOpacity[i]) + layerColor * colorOpacity[i];\n }\n }\n #pragma unroll_loop_end\n #endif\n\n\n gl_FragColor = diffuseColor;\n\n#if defined(HILLSHADE)\n vec2 onePixel = vec2(1.0) / 256.0;\n\n vec2 vVv = vec2(\n vUv.x * elevationOffsetScale.z + elevationOffsetScale.x,\n (1.0 - vUv.y) * elevationOffsetScale.w + elevationOffsetScale.y);\n\n float a = getElevation(elevationTexture, vVv + onePixel * vec2(-1.0, 1.0));\n float b = getElevation(elevationTexture, vVv + onePixel * vec2( 0.0, 1.0));\n float c = getElevation(elevationTexture, vVv + onePixel * vec2( 1.0, 1.0));\n float d = getElevation(elevationTexture, vVv + onePixel * vec2(-1.0, 0.0));\n float e = getElevation(elevationTexture, vVv + onePixel * vec2( 0.0, 0.0));\n float f = getElevation(elevationTexture, vVv + onePixel * vec2( 1.0, 0.0));\n float g = getElevation(elevationTexture, vVv + onePixel * vec2(-1.0, -1.0));\n float h = getElevation(elevationTexture, vVv + onePixel * vec2( 0.0, -1.0));\n float i = getElevation(elevationTexture, vVv + onePixel * vec2( 1.0, -1.0));\n\n float hillshade = calcHillshade(a, b, c, d, e, f, g, h, i, elevationOffsetScale.zw * 256.0);\n\n gl_FragColor.rgb *= hillshade;\n#endif\n\n // gl_FragColor.rgb = mix(gl_FragColor.rgb, vColor.rgb, vColor.a);\n if (hasTexture) {\n gl_FragColor.a = max(gl_FragColor.a, noTextureOpacity);\n } else {\n gl_FragColor = vec4(noTextureColor, noTextureOpacity);\n }\n\n#if defined(DEBUG)\n if (showOutline && (vUv.x < sLine || vUv.x > 1.0 - sLine || vUv.y < sLine || vUv.y > 1.0 - sLine)) {\n gl_FragColor.rgb = mix(vec3(1.0, 0.0, 0.0), gl_FragColor.rgb, 0.2);\n }\n#endif\n\n }\n\n}\n",t.vertexShader="#include \n\nattribute vec3 position;\nattribute vec2 uv;\n\nuniform sampler2D elevationTexture;\nuniform vec4 elevationOffsetScale;\n#if defined(STITCHING)\nuniform sampler2D nTex[4];\nuniform vec4 nOff[4];\nuniform float segments;\n#endif\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 modelViewMatrix;\n\nuniform vec4 neighbourdiffLevel;\nuniform vec2 tileDimensions;\n\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying vec4 vPosition;\n\nuniform vec4 validityExtent;\n\n#include \n#include \n\n#if defined(STITCHING)\nfloat readNeighbourElevation(vec2 uv, int neighbour, sampler2D texture) {\n vec2 vv = uv;\n // top\n if (neighbour == 1 || neighbour == 3) {\n vv.x = 1.0 - vv.x;\n } else {\n vv.y = 1.0 - vv.y;\n }\n vec2 vVv = computeUv(\n vv,\n nOff[neighbour].xy, nOff[neighbour].zw);\n return getElevation(texture, vVv);\n}\n#endif\n\n\nvoid main() {\n vUv = uv;\n vPosition = vec4(position, 1.0);\n vColor = vec4(0., 0., 0., 0.);\n\n if(elevationOffsetScale.z > 0.) {\n vec2 vVv = computeUv(vUv, elevationOffsetScale.xy, elevationOffsetScale.zw);\n int weight = 1;\n\n float elevation = getElevation(elevationTexture, vVv);\n\n#if defined(STITCHING)\n // We process the 4 borders separatly. The logic is:\n // - identify if the current vertex is on the border\n // - then, if the neighbour tile is:\n // - at the same level (= precision): we average\n // both elevations\n // - at a lower level (less precise): we use its\n // elevation. And if this vertex has no direct\n // v-neighbour, it is shifted along the other\n // (x when processing north/south border, else\n // y) to be at the same position than the vertex\n // on the other tile. Eg, for vertex 'o' below:\n //\n // ---xx--x-- ---xx--x--\n // || | ||⋱|\n // |o--x-- => || x--\n // || | || |\n // ---xx--x-- ---xx--x--\n // || | || |\n //\n // factor: num_vert_in_tile / num_vert_in_neighbour_tile\n // = 2^(level_difference)\n vec4 neighbourFactor = pow(vec4(2.0), abs(neighbourdiffLevel));\n // Interval in current tile is: 1.0 / segments. If a neighbour\n // has less vertices on our shared edges, its interval size is\n // going to be:\n vec4 modulo = neighbourFactor / segments;\n // West border\n if (vUv.x < 0.01) {\n if (neighbourdiffLevel.w < 0.0) {\n float offset = fract(vUv.y / modulo.w) * modulo.w;\n vPosition.y -= tileDimensions.y * offset;\n vUv.y -= offset;\n\n elevation = readNeighbourElevation(vUv, 3, nTex[3]);\n weight = 1;\n // vColor = vec4(0.0, 1.0, 0.0, 0.5);\n } else if (neighbourdiffLevel.w == 0.0) {\n elevation += readNeighbourElevation(uv, 3, nTex[3]);\n weight += 1;\n }\n }\n // East border\n else if (vUv.x > 0.99) {\n if (neighbourdiffLevel.y < 0.0) {\n float offset = fract(vUv.y / modulo.y) * modulo.y;\n vPosition.y -= tileDimensions.y * offset;\n vUv.y -= offset;\n elevation = readNeighbourElevation(vUv, 1, nTex[1]);\n weight = 1;\n // vColor = vec4(1.0, 1.0, 0.0, 0.5);\n } else if (neighbourdiffLevel.y == 0.0) {\n elevation += readNeighbourElevation(uv, 1, nTex[1]);\n weight += 1;\n }\n }\n // South border\n else if (vUv.y < 0.01) {\n if (neighbourdiffLevel.z < 0.0) {\n float offset = fract(vUv.x / modulo.z) * modulo.z;\n // move to the left\n vPosition.x -= tileDimensions.x * offset;\n vUv.x -= offset;\n\n elevation = readNeighbourElevation(vUv, 2, nTex[2]);\n weight = 1;\n // vColor = vec4(0.0, 1.0, 1.0, 0.5);\n } else if (neighbourdiffLevel.z == 0.0) {\n elevation += readNeighbourElevation(uv, 2, nTex[2]);\n weight += 1;\n }\n }\n // North border\n else if (vUv.y > 0.99) {\n if (neighbourdiffLevel.x < 0.0) {\n float offset = fract(vUv.x / modulo.x) * modulo.x;\n vPosition.x -= tileDimensions.x * offset;\n vUv.x -= offset;\n\n elevation = readNeighbourElevation(vUv, 0, nTex[0]);\n weight = 1;\n // vColor = vec4(0.0, 0.0, 1.0, 0.5);\n } else if (neighbourdiffLevel.x == 0.0) {\n elevation += readNeighbourElevation(uv, 0, nTex[0]);\n weight += 1;\n }\n }\n\n if (weight > 1) {\n elevation /= float(weight);\n }\n#endif\n vPosition.z = elevation;\n }\n\n // colors from OGC EL.GridCoverage.Default style\n // float z = vPosition.z;\n // if (z < -100.0) {\n // vColor = vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0);\n // } else if (z <= 0.0) {\n // vColor = mix(\n // vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n // vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n // -z / 100.0);\n // } else if (z <= 50.0) {\n // vColor = mix(\n // vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n // vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n // -z / 100.0);\n // } else if (z <= 50.0) {\n // vColor = mix(\n // vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n // vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n // z / 50.0);\n // } else if (z <= 100.0) {\n // vColor = mix(\n // vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n // vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n // (z - 50.0)/ 50.0);\n // } else {\n // vColor = mix(\n // vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n // vec4(float(0x7B) / 255.0, float(0xF2) / 255.0, float(0x3A) / 255.0, 1.0),\n // (z - 100.0)/ 50.0);\n // }\n gl_Position = projectionMatrix * modelViewMatrix * vPosition;\n}\n",t.canvas=document.createElement("canvas"),t.canvas.width=l.maxX,t.canvas.height=l.maxY,t.pendingUpdates=[],t.texturesInfo={color:{offsetScale:[],originalOffsetScale:[],atlasTexture:new o.CanvasTexture(t.canvas),parentAtlasTexture:null,textures:[],opacity:[],visible:[],colors:[]},elevation:{offsetScale:new o.Vector4(0,0,0,0),texture:d,neighbours:{offsetScale:Array(4),texture:Array(4)},format:null}},m(t.texturesInfo.elevation.neighbours.texture,d),m(t.texturesInfo.elevation.neighbours.offsetScale,f),t.canvasRevision=0,t.uniforms.tileDimensions=new o.Uniform(new o.Vector2),t.uniforms.neighbourdiffLevel=new o.Uniform(new o.Vector4),t.uniforms.elevationTexture=new o.Uniform(t.texturesInfo.elevation.texture),t.uniforms.elevationOffsetScale=new o.Uniform(t.texturesInfo.elevation.offsetScale),t.uniforms.nTex=new o.Uniform(t.texturesInfo.elevation.neighbours.texture),t.uniforms.nOff=new o.Uniform(t.texturesInfo.elevation.neighbours.offsetScale),t.uniforms.colorTexture=new o.Uniform(t.texturesInfo.color.atlasTexture),t.uniforms.colorOffsetScale=new o.Uniform,t.uniforms.colorOpacity=new o.Uniform,t.uniforms.colorVisible=new o.Uniform,t.uniforms.colors=new o.Uniform(t.texturesInfo.color.colors),t.uniforms.uuid=new o.Uniform(0),t.uniforms.noTextureColor=new o.Uniform(new o.Color),t.uniforms.noTextureOpacity=new o.Uniform(1),t.uniforms.opacity=new o.Uniform(1),t.colorLayers=[],t.texturesInfo.color.atlasTexture.generateMipmaps=!1,t.texturesInfo.color.atlasTexture.magFilter=o.LinearFilter,t.texturesInfo.color.atlasTexture.minFilter=o.LinearFilter,t.texturesInfo.color.atlasTexture.anisotropy=1,t.texturesInfo.color.atlasTexture.premultiplyAlpha=!0,t.texturesInfo.color.atlasTexture.needsUpdate=!1,t}return(0,r.default)(a,[{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"}),this.disposed=!0,this.texturesInfo.color.atlasTexture.dispose(),this.texturesInfo.elevation.texture.dispose()}},{key:"getColorTexture",value:function(t){var e=this.indexOfColorLayer(t);return-1===e?null:this.texturesInfo.color.textures[e]}},{key:"setColorTextures",value:function(t,e,r,n){var i=this;Array.isArray(e)&&(e=e[0]);var a=this.indexOfColorLayer(t);return this.texturesInfo.color.originalOffsetScale[a].copy(e.pitch),this.texturesInfo.color.textures[a]=e.texture,r?(y(t.imageSize,this.atlasInfo.atlas[t.id],this.texturesInfo.color.originalOffsetScale[a],this.uniforms.colorTexture.value.image,this.texturesInfo.color.offsetScale[a]),Promise.resolve()):(this.pendingUpdates.push(t),null!==this.setTimeoutId&&clearTimeout(this.setTimeoutId),this.setTimeoutId=setTimeout((function(){if(i.uniforms.colorTexture.value!==i.texturesInfo.color.atlasTexture){i.uniforms.colorTexture.value=i.texturesInfo.color.atlasTexture;var t,e=u(i.colorLayers);try{for(e.s();!(t=e.n()).done;){var r=t.value;-1===i.pendingUpdates.indexOf(r)&&(console.warn("no new texture for ",r.id,". Redrawing the old one"),i.pendingUpdates.push(r))}}catch(t){e.e(t)}finally{e.f()}}var a,o=u(i.pendingUpdates);try{for(o.s();!(a=o.n()).done;){var s=a.value,l=i.indexOfColorLayer(s),c=i.atlasInfo.atlas[s.id];y(s.imageSize,i.atlasInfo.atlas[s.id],i.texturesInfo.color.originalOffsetScale[l],i.uniforms.colorTexture.value.image,i.texturesInfo.color.offsetScale[l]);var h=i.texturesInfo.color.textures[l].image;i.canvasRevision=v(s,i.texturesInfo.color.atlasTexture,c,h===i.canvas?null:h,i.texturesInfo.color.offsetScale[l],i.canvasRevision)}}catch(t){o.e(t)}finally{o.f()}i.pendingUpdates.length=0,i.texturesInfo.color.atlasTexture.needsUpdate=!0,i.visible&&n.notifyChange(),i.setTimeoutId=null}),1),Promise.resolve())}},{key:"getElevationTextureInfo",value:function(){return this.isElevationLayerTextureLoaded()?{texture:this.texturesInfo.elevation.texture,offsetScale:this.texturesInfo.elevation.offsetScale,elevationFormat:this.texturesInfo.elevation.format,heightFieldScale:this.texturesInfo.elevation.heightFieldScale,heightFieldOffset:this.texturesInfo.elevation.heightFieldOffset}:null}},{key:"setElevationTexture",value:function(t,e){if(t.elevationFormat===l.ELEVATION_FORMAT.MAPBOX_RGB)this.defines.MAPBOX_RGB_ELEVATION||(this.defines.MAPBOX_RGB_ELEVATION=1,this.needsUpdate=!0);else if(t.elevationFormat===l.ELEVATION_FORMAT.HEIGHFIELD){if(!this.defines.HEIGHTFIELD_ELEVATION){this.defines.HEIGHTFIELD_ELEVATION=1;var r=t.heightFieldOffset||0;this.texturesInfo.elevation.heightFieldOffset=r,this.uniforms.heightFieldOffset=new o.Uniform(r);var n=t.heightFieldScale||255;this.texturesInfo.elevation.heightFieldScale=n,this.uniforms.heightFieldScale=new o.Uniform(n),this.needsUpdate=!0}}else{if(t.elevationFormat!==l.ELEVATION_FORMAT.RATP_GEOL)throw new Error("Missing layer.elevationFormat handling",t.elevationFormat);this.defines.RATP_GEOL_ELEVATION||(this.defines.RATP_GEOL_ELEVATION=1)}return this.uniforms.elevationTexture.value=e.texture,this.texturesInfo.elevation.texture=e.texture,this.texturesInfo.elevation.offsetScale.copy(e.pitch),this.texturesInfo.elevation.format=t.elevationFormat,Promise.resolve(!0)}},{key:"pushLayer",value:function(t){this.texturesInfo.color.opacity.push(t.opacity),this.texturesInfo.color.visible.push(t.visible),this.texturesInfo.color.offsetScale.push(new o.Vector4(0,0,0,0)),this.texturesInfo.color.originalOffsetScale.push(new o.Vector4(0,0,0,0)),this.texturesInfo.color.textures.push(d),this.texturesInfo.color.colors.push(t.color||new o.Color(1,1,1)),this.colorLayers.push(t),1===this.colorLayers.length&&(this.uniforms.colorOffsetScale=new o.Uniform(this.texturesInfo.color.offsetScale),this.uniforms.colorOpacity=new o.Uniform(this.texturesInfo.color.opacity),this.uniforms.colorVisible=new o.Uniform(this.texturesInfo.color.visible)),this.defines.TEX_UNITS=this.colorLayers.length,this.needsUpdate=!0}},{key:"removeLayer",value:function(t){var e=this.indexOfColorLayer(t);-1!==e?(this.texturesInfo.color.opacity.splice(e,1),this.texturesInfo.color.visible.splice(e,1),this.texturesInfo.color.offsetScale.splice(e,1),this.texturesInfo.color.originalOffsetScale.splice(e,1),this.texturesInfo.color.textures.splice(e,1),this.texturesInfo.color.colors.splice(e,1),this.colorLayers.splice(e,1),this.defines.TEX_UNITS=this.colorLayers.length,this.needsUpdate=!0):console.warn("Layer ".concat(t.id," not found, so not removed..."))}},{key:"update",value:function(){if(0===this.colorLayers.length)return!0;if(this.atlasInfo.maxX>this.canvas.width||this.atlasInfo.maxY>this.canvas.height){var t=document.createElement("canvas");if(t.width=this.atlasInfo.maxX,t.height=this.atlasInfo.maxY,this.canvas.width>0)t.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height);this.texturesInfo.color.atlasTexture.dispose(),this.texturesInfo.color.atlasTexture=new o.CanvasTexture(t),this.texturesInfo.color.atlasTexture.magFilter=o.LinearFilter,this.texturesInfo.color.atlasTexture.minFilter=o.LinearFilter,this.texturesInfo.color.atlasTexture.anisotropy=1,this.texturesInfo.color.atlasTexture.premultiplyAlpha=!0,this.texturesInfo.color.atlasTexture.needsUpdate=!0;for(var e=0;e0}},{key:"indexOfColorLayer",value:function(t){return this.colorLayers.indexOf(t)}},{key:"setLayerOpacity",value:function(t,e){var r=Number.isInteger(t)?t:this.indexOfColorLayer(t);this.texturesInfo.color.opacity[r]=e}},{key:"setLayerVisibility",value:function(t,e){var r=Number.isInteger(t)?t:this.indexOfColorLayer(t);this.texturesInfo.color.visible[r]=e}},{key:"isElevationLayerTextureLoaded",value:function(){return this.texturesInfo.elevation.texture!==d}},{key:"isColorLayerTextureLoaded",value:function(t){var e=this.indexOfColorLayer(t);return e<0?null:this.texturesInfo.color.textures[e]!==d}},{key:"setUuid",value:function(t){this.uniforms.uuid.value=t}}]),a}(o.RawShaderMaterial);function v(t,e,r,n,i,a){var o=e.image.getContext("2d");return void 0!==n&&t.transparent&&o.clearRect(r.x,r.y,t.imageSize.w,t.imageSize.h+2*r.offset),n&&(o.drawImage(n,r.x,r.y+r.offset,t.imageSize.w,t.imageSize.h),r.offset&&(o.drawImage(n,0,0,t.imageSize.w,r.offset,r.x,r.y,t.imageSize.w,r.offset),o.drawImage(n,0,t.imageSize.h-1-r.offset,t.imageSize.w,r.offset,r.x,r.y+t.imageSize.h+r.offset,t.imageSize.w,r.offset))),e.needsUpdate=!0,a+1}function y(t,e,r,n,i){if(0!==r.z&&0!==r.w){var a=t.w/n.width,o=t.h/n.height;i.set(e.x/n.width+r.x*a,(e.y+e.offset)/n.height+r.y*o,r.z*a,r.w*o)}else i.set(0,0,0,0)}var x=g;return RM.default=x,RM}function OM(){if(PM)return Zb;PM=1;var t=sf;Object.defineProperty(Zb,"__esModule",{value:!0}),Zb.default=void 0;var e=Ff,r=t(TM()),n=t(rM()),i=LM(),a=t(Ax()),o=t(IM());function s(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return l(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:0,r=t.camera.camera3D.layers.mask;return t.camera.camera3D.layers.mask=1<i)&&!(l<=r)){var u=t+a,c=t+s;if(!1===e(u,c,c*(2*t)+u))return}}r=i}}function d(t){return t.layer?t.layer:t.parent?d(t.parent):null}var f=new e.Raycaster,p=new a.default("EPSG:3857",0,0,0),m=new e.Color,g={pickTilesAt:function(t,l,d,f){var m,g=[],v=function(t,r,a,o){var s=t.mainLoop.gfxEngine.getWindowSize();a=a||new e.Vector2(Math.floor(s.x/2),Math.floor(s.y/2));var l=r.level0Nodes.map((function(t){return t.pushRenderState(n.default.ID)})),d=u(t,r.object3d,r.threejsLayer),f=t.mainLoop.gfxEngine.renderViewToBuffer({camera:t.camera,scene:r.object3d},{x:a.x-o,y:a.y-o,width:1+2*o,height:1+2*o});d(),l.forEach((function(t){return t()}));var p=[];return h(o,(function(t,e,r){var n=f.slice(4*r,4*r+4);c.fromArray(n).divideScalar(255);var a=(0,i.unpack1K)(c,Math.pow(256,3)),o=Math.round(a);p.indexOf(o)<0&&p.push(o)})),p}(t,f,l,d),y=function(i){if(v.indexOf(i.id)>=0&&i instanceof r.default){var s=i.pushRenderState(n.default.UV),u=t.mainLoop.gfxEngine.renderViewToBuffer({camera:t.camera,scene:i},{x:Math.max(0,l.x-d),y:Math.max(0,l.y-d),width:1+2*d,height:1+2*d}),m=[];h(d,(function(t,r,n){var i,a,o=u.slice(4*n,4*n+4);c.fromArray(o).divideScalar(255),m.push((i=c,a&&a.isVector2||(a=new e.Vector2),a.set(i.x+i.y/255,i.z+i.w/255)))}));for(var y=0,x=m;yl.length)&&console.error("azadaz");var s=l.slice(4*n,4*n+4);if(255!==s[0]||255!==s[1]){var u=s[0]+((240&s[1])<<4);u>o&&console.warn("weird: pickingId (".concat(u,") > visibleId (").concat(o,")"));for(var h={pickingId:u,index:((15&s[1])<<16)+(s[2]<<8)+s[3],coord:i},d=0;d4&&void 0!==arguments[4]?arguments[4]:[],a={x:e.x-r,y:e.y-r,width:1+2*r,height:1+2*r},o=t.mainLoop.gfxEngine.renderViewToBuffer({scene:n,camera:t.camera},a),l=t.mainLoop.gfxEngine.renderer.getClearColor(m),u=Math.round(255*l.r),c=Math.round(255*l.g),p=Math.round(255*l.b),g=t.viewToNormalizedCoords(e),v=g.clone();return h(r,(function(e,a){var l=4*((a+r)*(2*r+1)+(e+r)),h=o[l],m=o[l+1],y=o[l+2];if(Math.abs(u-h)<=1&&Math.abs(c-m)<=1&&Math.abs(p-y)<=1)return null;v.setX(g.x+e/t.camera.width).setY(g.y+a/t.camera.height),f.setFromCamera(v,t.camera.camera3D);var x,_=s(f.intersectObject(n,!0));try{for(_.s();!(x=_.n()).done;){var w=x.value;w.layer=d(w.object),i.push(w)}}catch(t){_.e(t)}finally{_.f()}return 0===i.length})),i},preparePointGeometryForPicking:function(t){var r=t.attributes.position.count;r>=1<<20&&console.warn("picking issue: only ".concat(1<<20," points per Points object supported"));for(var n=new Uint8Array(4*r),i=0;i>16,n[4*i+2]=(65280&i)>>8,n[4*i+3]=(255&i)>>0;t.setAttribute("unique_id",new e.BufferAttribute(n,4,!0))}};return Zb.default=g,Zb}var DM,kM,FM={},NM={};function UM(){if(DM)return NM;DM=1,Object.defineProperty(NM,"__esModule",{value:!0}),NM.default=void 0;var t=Ff;function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r-1}var a={isLogDepthBufferSupported:function(){return e},isFirefox:i,isInternetExplorer:function(){return!!document.documentMode},getMaxTextureUnitsCount:function(){return r},getMaxTextureSize:function(){return t},updateCapabilities:function(a){var o=a.getContext();r=o.getParameter(o.MAX_TEXTURE_IMAGE_UNITS),t=o.getParameter(o.MAX_TEXTURE_SIZE);var s=o.createProgram(),l=n(a,o.VERTEX_SHADER,"void main() {\n gl_Position = vec4( 0.0, 0.0, 0.0, 1.0 );\n}"),u="#define SAMPLE ".concat(r,"\n");u+="uniform sampler2D uni[SAMPLE];\nvoid main() {\n gl_FragColor += texture2D(uni[SAMPLE-1], vec2(0));\n}";var c=n(a,o.FRAGMENT_SHADER,u);if(o.attachShader(s,l),o.attachShader(s,c),o.linkProgram(s),!1===o.getProgramParameter(s,o.LINK_STATUS)){if(!(r>16))throw new Error("The GPU capabilities could not be determined accurately.\n Impossible to link a shader with the Maximum texture units ".concat(r));var h=o.getProgramInfoLog(s);console.warn("".concat(h,": using a maximum of 16 texture units instead of the reported value (").concat(r,")")),i()&&console.warn("It can come from a Mesa/Firefox bug;\n the shader compiles to an error when using more than 16 sampler uniforms,\n see https://bugzilla.mozilla.org/show_bug.cgi?id=777028"),r=16}o.deleteProgram(s),o.deleteShader(l),o.deleteShader(c),e=a.capabilities.logarithmicDepthBuffer}};return zM.default=a,zM}var jM,VM={};function HM(){if(jM)return VM;jM=1;var t=sf;Object.defineProperty(VM,"__esModule",{value:!0}),VM.default=void 0;var e=t(df()),r=t(_f()),n=function(){function t(r){if((0,e.default)(this,t),!r)throw new Error("Missing id parameter (Entity must have a unique id defined)");Object.defineProperty(this,"id",{value:r,writable:!1})}return(0,r.default)(t,[{key:"preUpdate",value:function(){return null}},{key:"update",value:function(){}},{key:"postUpdate",value:function(){}}]),t}();return VM.default=n,VM}var WM,qM,XM={};function YM(){if(qM)return Ub;qM=1;var t=sf;Object.defineProperty(Ub,"__esModule",{value:!0}),Ub.default=void 0;var e=t(df()),r=t(_f()),n=t(Mf()),i=t(Rf()),a=t(Lf()),o=t(kf()),s=Ff,l=Fb(),u=t(qb()),c=t(OM()),h=t(function(){if(kM)return FM;kM=1;var t=sf;Object.defineProperty(FM,"__esModule",{value:!0}),FM.default=void 0;var e=t(UM()),r={pack:function(t,r,n,i){t=2048;for(var a,o=[],s=0;s=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r can't attach layer ".concat(t.id));if(t=t._preprocessLayer(this,this._instance),this._attachedLayers.push(t),t instanceof u.default){var e=this._attachedLayers.filter((function(t){return t instanceof u.default})),r=h.default.pack(d.default.getMaxTextureSize(),e.map((function(t){return t.id})),e.map((function(t){return t.imageSize})),this.atlasInfo.atlas),n=r.atlas,i=r.maxX,a=r.maxY;this.atlasInfo.atlas=n,this.atlasInfo.maxX=Math.max(this.atlasInfo.maxX,i),this.atlasInfo.maxY=Math.max(this.atlasInfo.maxY,a)}}},{key:"detach",value:function(t){var e=this._attachedLayers.length;return this._attachedLayers=this._attachedLayers.filter((function(e){return e.id!==t.id})),this._attachedLayers.length=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw a}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{};(0,e.default)(this,t),void 0===a.antialias&&(a.antialias=!0),void 0===a.alpha&&(a.alpha=!0),void 0===a.logarithmicDepthBuffer&&(a.logarithmicDepthBuffer=!1),void 0===a.clearColor&&(a.clearColor=197896);var o=r.domElement?r:void 0,s=o?void 0:r;this.width=(o?o.domElement:s).clientWidth,this.height=(o?o.domElement:s).clientHeight,this.positionBuffer=null,this._nextThreejsLayer=1,this.fullSizeRenderTarget=new n.WebGLRenderTarget(this.width,this.height),this.fullSizeRenderTarget.texture.minFilter=n.LinearFilter,this.fullSizeRenderTarget.texture.magFilter=n.NearestFilter,this.fullSizeRenderTarget.texture.generateMipmaps=!1,this.fullSizeRenderTarget.depthBuffer=!0,this.fullSizeRenderTarget.depthTexture=new n.DepthTexture,this.fullSizeRenderTarget.depthTexture.type=n.UnsignedShortType;try{this.renderer=o||new n.WebGLRenderer({canvas:document.createElement("canvas"),antialias:a.antialias,alpha:a.alpha,logarithmicDepthBuffer:a.logarithmicDepthBuffer})}catch(t){console.error("Failed to create WebGLRenderer",t),this.renderer=null}if(!this.renderer){var l=document.createElement("div");throw l.id="webgl-error-message",l.style.fontFamily="monospace",l.style.fontSize="13px",l.style.fontWeight="normal",l.style.textAlign="center",l.style.background="#fff",l.style.color="#000",l.style.padding="1.5em",l.style.width="400px",l.style.margin="5em auto 0",l.innerHTML=window.WebGLRenderingContext?['Your graphics card does not seem to support WebGL.
','Find out how to get it here.
','See also graphics card blacklisting'].join("\n"):['Your browser does not seem to support WebGL.
','Find out how to get it here.
',"You can also try another browser like Firefox or Chrome."].join("\n"),s.appendChild(l),new Error("WebGL unsupported")}if(!o&&a.logarithmicDepthBuffer&&!this.renderer.extensions.get("EXT_frag_depth")){var u=this.renderer.domElement;this.renderer.dispose(),this.renderer=new n.WebGLRenderer({canvas:u,antialias:a.antialias,alpha:a.alpha,logarithmicDepthBuffer:!1})}-1===this.renderer.domElement.tabIndex&&(this.renderer.domElement.tabIndex=-1),i.default.updateCapabilities(this.renderer),!1!==a.clearColor&&this.renderer.setClearColor(a.clearColor),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,o||(this.renderer.setPixelRatio(s.devicePixelRatio),this.renderer.setSize(s.clientWidth,s.clientHeight),s.appendChild(this.renderer.domElement))}return(0,r.default)(t,[{key:"renderView",value:function(t,e){this.renderer.setViewport(0,0,this.width,this.height),this.renderer.clear(),this.renderer.render(t.scene,t.camera.camera3D),!1!==e&&(this.renderer.clearDepth(),this.renderer.render(t.scene2D,t.camera.camera2D))}},{key:"onWindowResize",value:function(t,e){this.width=t,this.height=e,this.fullSizeRenderTarget.setSize(this.width,this.height),this.renderer.setSize(this.width,this.height)}},{key:"getWindowSize",value:function(){return new n.Vector2(this.width,this.height)}},{key:"getRenderer",value:function(){return this.renderer}},{key:"renderViewToBuffer",value:function(t,e){e||(e={x:0,y:0,width:this.width,height:this.height}),this.renderViewToRenderTarget(t,this.fullSizeRenderTarget,e),e.x=Math.max(0,Math.min(e.x,this.width)),e.y=Math.max(0,Math.min(e.y,this.height));var r=new Uint8Array(4*e.width*e.height);return this.renderer.readRenderTargetPixels(this.fullSizeRenderTarget,e.x,this.height-(e.y+e.height),e.width,e.height,r),r}},{key:"renderViewToRenderTarget",value:function(t,e,r){e||(e=this.fullSizeRenderTarget);var n=this.renderer.getRenderTarget();return e.viewport.set(0,0,e.width,e.height),r&&(e.scissor.set(Math.max(0,r.x),Math.max(e.height-(r.y+r.height)),r.width,r.height),e.scissorTest=!0),this.renderer.setRenderTarget(e),this.renderer.clear(),this.renderer.render(t.scene,t.camera.camera3D),this.renderer.setRenderTarget(n),e.scissorTest=!1,e}},{key:"renderLayerTobuffer",value:function(t,e,r,n,i,o,s){var l,u=t._objects.map((function(t){return t.visible})),c=a(t._objects);try{for(c.s();!(l=c.n()).done;){l.value.visible=!1}}catch(t){c.e(t)}finally{c.f()}e.visible=!0;var h=this.renderer.getRenderTarget();this.renderer.setRenderTarget(r),this.renderer.setViewport(0,0,r.width,r.height),this.renderer.setScissor(n,i,o,s),this.renderer.setScissorTest(!0),this.renderer.clear(),this.renderer.render(e.object3d,t.camera.camera3D),this.renderer.setScissorTest(!1);var d=new Uint8Array(4*o*s);this.renderer.readRenderTargetPixels(r,n,i,o,s,d),this.renderer.setRenderTarget(h);for(var f=0;f31&&(console.warn("Too much js layers. Starting from now all of them will use layerMask = 31"),this._nextThreejsLayer=31),this._nextThreejsLayer++}}],[{key:"bufferToImage",value:function(t,e,r){var n=document.createElement("canvas"),i=n.getContext("2d");n.width=e,n.height=r;var a=i.getImageData(0,0,e,r);a.data.set(t),i.putImageData(a,0,0);var o=new Image;return o.src=n.toDataURL(),o}}]),t}(),l=s;return $M.default=l,$M}var eS={};function rS(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var nS,iS={exports:{}};function aS(){return nS||(nS=1,iS.exports=function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){if(!s&&rS)return rS(o);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[o]={exports:{}};e[o][0].call(u.exports,(function(t){var r=e[o][1][t];return i(r||t)}),u,u.exports,t,e,r,n)}return r[o].exports}for(var a=rS,o=0;o>>1],e)>=0?i=a+1:n=a;return i},e.exports=function(){function t(t){var e;this.options=t,this.comparator=this.options.comparator,this.data=(null!=(e=this.options.initialValues)?e.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return t.prototype.queue=function(t){var e;e=n(this.data,t,this.comparator),this.data.splice(e,0,t)},t.prototype.dequeue=function(){return this.data.pop()},t.prototype.peek=function(){return this.data[this.data.length-1]},t.prototype.clear=function(){this.data.length=0},t}()},{}],4:[function(t,e,r){e.exports=function(){function t(t){var e,r,n,i,a,o,s,l;for(this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.pageSize=(null!=t?t.pageSize:void 0)||512,this.length=0,s=0;1<a;0<=a?++r:--r)e.push(null);if(this._memory=[],this._mask=this.pageSize-1,t.initialValues)for(n=0,i=(o=t.initialValues).length;n0&&(this._write(1,e),this._bubbleDown(1,e)),t},t.prototype.peek=function(){return this._read(1)},t.prototype.clear=function(){this.length=0,this._memory.length=0},t.prototype._write=function(t,e){var r;for(r=t>>this._shift;r>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[r][t&this._mask]=e},t.prototype._read=function(t){return this._memory[t>>this._shift][t&this._mask]},t.prototype._bubbleUp=function(t,e){var r,n,i,a;for(r=this.comparator;t>1&&(n=t&this._mask,t3?i=t&~this._mask|n>>1:n<2?(i=t-this.pageSize>>this._shift,i+=i&~(this._mask>>1),i|=this.pageSize>>1):i=t-2,!(r(a=this._read(i),e)<0));)this._write(i,e),this._write(t,a),t=i},t.prototype._bubbleDown=function(t,e){var r,n,i,a,o;for(o=this.comparator;tthis._mask&&!(t&this._mask-1)?r=n=t+2:t&this.pageSize>>1?(r=(t&~this._mask)>>1,n=1+(r=1+(r|=t&this._mask>>1)<0)for(t=e=1,r=this.data.length;1<=r?er;t=1<=r?++e:--e)this._bubbleUp(t)},t.prototype.queue=function(t){this.data.push(t),this._bubbleUp(this.data.length-1)},t.prototype.dequeue=function(){var t,e;return e=this.data[0],t=this.data.pop(),this.data.length>0&&(this.data[0]=t,this._bubbleDown(0)),e},t.prototype.peek=function(){return this.data[0]},t.prototype.clear=function(){this.length=0,this.data.length=0},t.prototype._bubbleUp=function(t){for(var e,r;t>0&&(e=t-1>>>1,this.comparator(this.data[t],this.data[e])<0);)r=this.data[e],this.data[e]=this.data[t],this.data[t]=r,t=e},t.prototype._bubbleDown=function(t){var e,r,n,i,a;for(e=this.data.length-1;i=1+(r=1+(t<<1)),n=t,r<=e&&this.comparator(this.data[r],this.data[n])<0&&(n=r),i<=e&&this.comparator(this.data[i],this.data[n])<0&&(n=i),n!==t;)a=this.data[n],this.data[n]=this.data[t],this.data[t]=a,t=n},t}()},{}]},{},[1])(1)),iS.exports}const oS=rf(Vx);var sS,lS={},uS={},cS={};function hS(){if(sS)return cS;sS=1;var t=sf,e=cf;Object.defineProperty(cS,"__esModule",{value:!0}),cS.default=void 0;var r,n=t(df()),i=t(_f()),a=t(Mf()),o=t($b()),s=t(Rf()),l=t(Lf()),u=t(kf()),c=m(IM()),h=t(Gb()),d=t(Wb()),f=m(Fb());function p(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return(p=function(t){return t?r:e})(t)}function m(t,r){if(!r&&t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var n=p(r);if(n&&n.has(t))return n.get(t);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=t[o]}return i.default=t,n&&n.set(t,i),i}function g(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return v(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{};return(0,n.default)(this,l),(r=e.call(this,t,i)).elevationFormat=i.elevationFormat,r.elevationFormat===c.ELEVATION_FORMAT.HEIGHFIELD&&(r.heightFieldOffset=i.heightFieldOffset||0,r.heightFieldScale=i.heightFieldScale||255),(0,f.defineLayerProperty)((0,a.default)(r),"frozen",!1),r}return(0,i.default)(l,[{key:"minMaxFromTexture",value:function(t){if(null!=t.min&&null!=t.max)return{min:t.min,max:t.max};var e=1/0,r=-1/0;if(this.elevationFormat===c.ELEVATION_FORMAT.MAPBOX_RGB)for(var n=l.colorImageSetup(t),i=n.data,a=n.stride,o=n.h,s=0;sr&&(r=h)}else if(this.elevationFormat===c.ELEVATION_FORMAT.HEIGHFIELD){for(var d=l.colorImageSetup(t),f=d.data,p=d.stride,m=d.h,g=0;g-1e3&&(e=Math.min(e,x),r=Math.max(r,x))}else{if(this.elevationFormat!==c.ELEVATION_FORMAT.RATP_GEOL)throw new Error('Unsupported layer.elevationFormat "'.concat(this.elevationFormat,"'"));e=-1e3,r=1e3}return t.min=e,t.max=r,{min:e,max:r}}},{key:"initNodeElevationTextureFromParent",value:function(t,e){var r=e.material.getElevationTextureInfo();if(r&&r.texture.extent){var n=r.texture,i=t.getExtentForLayer(this).offsetToParent(n.extent),a={texture:n,pitch:i},o=n.min,s=n.max;if(!o||!s){var l=this.minMaxFromTexture(n,i);o=l.min,s=l.max}a.min=o,a.max=s,t.setTextureElevation(this,a)}}},{key:"_preprocessLayer",value:function(t,e){var r=this;return(0,o.default)((0,u.default)(l.prototype),"_preprocessLayer",this).call(this,t,e),this.whenReady=this.whenReady.then((function(){var t=r.provider.getPossibleTextureImprovements(r,r.extent);return r.provider.executeCommand({layer:r,toDownload:t}).then((function(t){var e=r.minMaxFromTexture(t.texture,t.pitch);t.texture.min=e.min,t.texture.max=e.max,r.minmax=e}))})),this.whenReady=this.whenReady.then((function(){if(!r.minmax)throw new Error("At this point the whole min/max should be known");t.object3d.traverse((function(t){t.setBBoxZ&&t.setBBoxZ(r.minmax.min,r.minmax.max)})),t.minMaxFromElevationLayer={min:r.minmax.min,max:r.minmax.max};var e,n=g(t.level0Nodes);try{for(n.s();!(e=n.n()).done;){e.value.traverse((function(e){e.setBBoxZ&&e.setBBoxZ(t.minMaxFromElevationLayer.min,t.minMaxFromElevationLayer.max)}))}}catch(t){n.e(t)}finally{n.f()}return r})),this}},{key:"update",value:function(t,e,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.material;if(!e.parent||!a)return null;if(void 0===e.layerUpdateState[this.id]&&(e.layerUpdateState[this.id]=new h.default,r&&r.material&&this.initNodeElevationTextureFromParent(e,r)))return t.instance.notifyChange(e,!1),null;var o=Date.now();if(i||this.frozen||!e.material.visible||!e.layerUpdateState[this.id].canTryUpdate(o))return null;var s=e.material.getElevationTextureInfo(),l=this.getPossibleTextureImprovements(this,e.getExtentForLayer(this),s&&s.texture,e.layerUpdateState[this.id].failureParams);if(!l)return e.layerUpdateState[this.id].noMoreUpdatePossible(),null;e.layerUpdateState[this.id].newTry();var u={view:t.instance,layer:this,requester:e,priority:(0,f.nodeCommandQueuePriorityFunction)(e),earlyDropFunction:f.refinementCommandCancellationFn,toDownload:l};return t.scheduler.execute(u).then((function(t){return null===e.material?null:(Array.isArray(t)&&(t=t[0]),t)}),(function(r){if(r instanceof d.default)e.layerUpdateState[n.id].success();else{console.warn("Elevation texture update error for",e,r);var i=e.layerUpdateState[n.id].errorCount>f.MAX_RETRY;e.layerUpdateState[n.id].failure(Date.now(),i,r),i||window.setTimeout((function(){t.instance.notifyChange(e,!1)}),1e3*e.layerUpdateState[n.id].secondsUntilNextTry())}})).then((function(t){if(t){var r=n.minMaxFromTexture(t.texture,t.pitch),i=r.min,a=r.max;t.min=i,t.max=a,e.setTextureElevation(n,t),e.layerUpdateState[n.id].success()}}))}}],[{key:"colorImageSetup",value:function(t){r||((r=document.createElement("canvas")).width=256,r.height=256);var e=t.image.width,n=t.image.height,i=r.getContext("2d");return r.width=e,r.height=n,i.drawImage(t.image,0,0),{data:i.getImageData(0,0,e,n).data,stride:4*e,h:n}}}]),l}(f.default),_=x;return cS.default=_,cS}var dS,fS,pS={},mS={};function gS(){if(dS)return mS;dS=1;var t=sf;Object.defineProperty(mS,"__esModule",{value:!0}),mS.default=void 0;var e=t(df()),r=t(_f()),n=t(Rf()),i=t(Lf()),a=t(kf()),o=Ff;function s(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,a.default)(t);if(e){var o=(0,a.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,i.default)(this,r)}}var l=function(t){(0,n.default)(a,t);var i=s(a);function a(t,r){var n;return(0,e.default)(this,a),(n=i.call(this)).box3D=new o.Box3(t.clone(),r.clone()),n.natBox=n.box3D.clone(),n.z={min:0,max:0},n.topPointsWorld=[new o.Vector3,new o.Vector3,new o.Vector3,new o.Vector3],n.update(),n}return(0,r.default)(a,[{key:"clone",value:function(){var t=new a(this.natBox.min,this.natBox.max);return t.position.copy(this.position),t.quaternion.copy(this.quaternion),t}},{key:"updateMinMax",value:function(t,e){this.box3D.min.copy(t),this.box3D.max.copy(e),this.natBox.copy(this.box3D),this.update(),this.oPosition.copy(this.position)}},{key:"update",value:function(){this.updateMatrixWorld(!0),this._cPointsWorld(this._points(this.topPointsWorld))}},{key:"updateZ",value:function(t,e){this.z={min:t,max:e},this.box3D.min.z=this.natBox.min.z+t,this.box3D.max.z=this.natBox.max.z+e,this.update()}},{key:"_points",value:function(t){return t[0].set(this.box3D.max.x,this.box3D.max.y,this.box3D.max.z),t[1].set(this.box3D.min.x,this.box3D.max.y,this.box3D.max.z),t[2].set(this.box3D.min.x,this.box3D.min.y,this.box3D.max.z),t[3].set(this.box3D.max.x,this.box3D.min.y,this.box3D.max.z),t.length>4&&(t[4].set(this.box3D.max.x,this.box3D.max.y,this.box3D.min.z),t[5].set(this.box3D.min.x,this.box3D.max.y,this.box3D.min.z),t[6].set(this.box3D.min.x,this.box3D.min.y,this.box3D.min.z),t[7].set(this.box3D.max.x,this.box3D.min.y,this.box3D.min.z)),t}},{key:"_cPointsWorld",value:function(t){for(var e=this.matrixWorld,r=0,n=t.length;r=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&(b[0].minmax||console.error("fix the provider"),g.setBBoxZ(b[0].minmax.min,b[0].minmax.max))}return g.add(g.OBB()),t.onTileCreated(t,r,g),g}var E=new o.Vector3,A=function(t){(0,n.default)(a,t);var i=w(a);function a(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,e.default)(this,a),r=i.call(this,t,n.object3d||new o.Group);var u=n.extent,c=Array.isArray(u)?u[0].crs():u.crs();if(r.validityExtent=u,"EPSG:3857"===c){var h=function(t){for(var e=new l.default("EPSG:3857",-20037508.342789244,20037508.342789244,-20037508.342789244,20037508.342789244),r=e.dimensions(),n=Math.min(Math.floor(r.x/t.dimensions().x),Math.floor(r.y/t.dimensions().y)),i=Math.floor(Math.max(0,Math.log2(n))),a=new s.default("EPSG:3857",t.west(),t.north()),o=new s.default("EPSG:3857",t.east(),t.south()),u=Math.pow(2,i),c=S(a.x()-e.west(),e.north()-a.y(),r,u),h=S(o.x()-e.west(),e.north()-o.y(),r,u),d=r.x/u,f=r.y/u,p=[],m=c.x;m<=h.x;m++)for(var g=c.y;g<=h.y;g++){var v=e.west()+m*d,y=e.north()-g*f;p.push(new l.default("EPSG:3857",v,v+d,y-f,y))}return p}(u);r.schemeTile=h}else Array.isArray(u)?r.schemeTile=u:r.schemeTile=[u];r.extent=r.schemeTile[0].clone();for(var d=1;d0){var u,c=b(e.getColorLayers());try{for(c.s();!(u=c.n()).done;)u.value.update(t,o,r,!0)}catch(t){c.e(t)}finally{c.f()}}o.updateMatrixWorld(!0)}}catch(t){i.e(t)}finally{i.f()}t.instance.notifyChange(r)}}(t,this,e),e.setDisplayed(!1),i=!0):e.setDisplayed(!0)}return e.material.visible&&(e.material.update(),this.updateMinMaxDistance(t,e),!i)?p.default.removeChildren(this,e):i?e.children.filter((function(t){return t.layer===r})):void 0}return e.setDisplayed(!1),p.default.removeChildren(this,e)}},{key:"postUpdate",value:function(){var t,e=this,r=b(this.level0Nodes);try{for(r.s();!(t=r.n()).done;){t.value.traverse((function(t){if(t.layer===e&&t.material.visible){t.material.uniforms.neighbourdiffLevel.value.set(0,0,0,1);var r=t.findNeighbours();if(r)for(var n=t.extent.dimensions(),i=t.material.texturesInfo.elevation.neighbours,a=0;a<4;a++)if(r[a]&&r[a][0].material.visible){var o=r[a][0],s=r[a][1],l=Math.log2(a%2?Math.round(o.extent.dimensions().y/n.y):Math.round(o.extent.dimensions().x/n.x));t.material.uniforms.neighbourdiffLevel.value.setComponent(a,-l),i.texture[a]=o.material.texturesInfo.elevation.texture;var u=s.offsetToParent(o.extent);i.offsetScale[a]=o.material.texturesInfo.elevation.offsetScale.clone(),i.offsetScale[a].x+=u.x*i.offsetScale[a].z,i.offsetScale[a].y+=u.y*i.offsetScale[a].w,i.offsetScale[a].z*=u.z,i.offsetScale[a].w*=u.w}else t.material.uniforms.neighbourdiffLevel.value.setComponent(a,1)}}))}}catch(t){r.e(t)}finally{r.f()}}},{key:"addLayer",value:function(t){var e=this;return new Promise((function(r,n){e._instance?t instanceof u.default?e.getLayers((function(e){return e.id===t.id})).length>0||e.currentAddedLayerIds.includes(t.id)?n(new Error("Invalid id '".concat(t.id,"': id already used"))):(e.currentAddedLayerIds.push(t.id),t.extent||(t.extent=e.extent),t.projection||(t.projection=e.projection),(t=t._preprocessLayer(e,e._instance)).whenReady.then((function(t){e.attach(t),e._instance.notifyChange(e,!1),r(t)})).catch((function(t){n(t)})).then((function(){e.currentAddedLayerIds=e.currentAddedLayerIds.filter((function(e){return e!==t.id}))}))):n(new Error("layer is not an instance of Layer")):n(new Error("map is not attached to an instance"))}))}},{key:"removeLayer",value:function(t){t.object3d&&(p.default.removeChildrenAndCleanupRecursively(t,t.object3d),this.scene.remove(t.object3d));var e=this.getLayers((function(e){return e._attachedLayers&&e._attachedLayers.includes(t)}))[0];e&&e.detach(t),this._cleanLayer(t),this.notifyChange(e||this._instance.camera.camera3D,!0)}},{key:"getLayers",value:function(t){var e,r=[],n=b(this._attachedLayers);try{for(n.s();!(e=n.n()).done;){var i=e.value;t&&!t(i)||r.push(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"getColorLayers",value:function(){return this.getLayers((function(t){return t instanceof c.default}))}},{key:"getElevationLayers",value:function(){return this.getLayers((function(t){return t instanceof h.default}))}},{key:"clean",value:function(){var t,e=b(this.getLayers());try{for(e.s();!(t=e.n()).done;){t.value.clean(this)}}catch(t){e.e(t)}finally{e.f()}}},{key:"hasEnoughTexturesToSubdivide",value:function(t,e){var r,n=this,i=b(t.elevationLayers);try{for(i.s();!(r=i.n()).done;){var a=r.value;if(!a.frozen&&a.ready&&a.tileInsideLimit(e,a)&&!e.material.isElevationLayerTextureLoaded(a)){if(e.layerUpdateState[a.id]&&e.layerUpdateState[a.id].inError())continue;return!1}}}catch(t){i.e(t)}finally{i.f()}return e.children.some((function(t){return t.layer===n})),!0}},{key:"testTileSSE",value:function(t,e){if(this.maxSubdivisionLevel>0&&this.maxSubdivisionLevel<=t.level)return!1;if(t.extent.dimensions().x<5)return!1;if(!e)return!0;var r=[e.lengths.x*e.ratio,e.lengths.y*e.ratio];return!(r.filter((function(e){return e<100*t.layer.sseScale})).length>=1)&&r.filter((function(e){return e>=384*t.layer.sseScale})).length>=2}},{key:"updateMinMaxDistance",value:function(t,e){var r=e.OBB().box3D.clone().applyMatrix4(e.OBB().matrixWorld),n=t.distance.plane.distanceToPoint(r.getCenter(E)),i=.5*r.getSize(E).length();this._distance.min=Math.min(this._distance.min,n-i),this._distance.max=Math.max(this._distance.max,n+i)}}]),a}(d.default);return uS.Map=A,uS}function RS(){if(TS)return lS;TS=1,Object.defineProperty(lS,"__esModule",{value:!0}),lS.default=void 0;var t=PS();function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,a,o)}}class VS{constructor(t){this.parser=t,this.name=OS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const a=i.extensions[e],o=n.images[a.source];let s=r.textureLoader;if(o.uri){const t=r.options.manager.getHandler(o.uri);null!==t&&(s=t)}return this.detectSupport().then((function(i){if(i)return r.loadTextureImage(t,o,s);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class HS{constructor(t){this.name=OS.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,r=e.bufferViews[t];if(r.extensions&&r.extensions[this.name]){const t=r.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([n,i.ready]).then((function(e){const r=t.byteOffset||0,n=t.byteLength||0,a=t.count,o=t.byteStride,s=new ArrayBuffer(a*o),l=new Uint8Array(e[0],r,n);return i.decodeGltfBuffer(new Uint8Array(s),a,o,l,t.mode,t.filter),s}))}return null}}const WS="glTF",qS=1313821514,XS=5130562;class YS{constructor(t){this.name=OS.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:Th.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==WS)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,n=new DataView(t,12);let i=0;for(;i",e).replace("#include ",r).replace("#include ",n).replace("#include ",i).replace("#include ",a)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(t){o.specular.value=t}},specularMap:{get:function(){return o.specularMap.value},set:function(t){o.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(t){o.glossiness.value=t}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(t){o.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class QS{constructor(){this.name=OS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return JS}extendParams(t,e,r){const n=e.extensions[this.name];t.color=new qn(1,1,1),t.opacity=1;const i=[];if(Array.isArray(n.diffuseFactor)){const e=n.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==n.diffuseTexture&&i.push(r.assignTexture(t,"map",n.diffuseTexture)),t.emissive=new qn(0,0,0),t.glossiness=void 0!==n.glossinessFactor?n.glossinessFactor:1,t.specular=new qn(1,1,1),Array.isArray(n.specularFactor)&&t.specular.fromArray(n.specularFactor),void 0!==n.specularGlossinessTexture){const e=n.specularGlossinessTexture;i.push(r.assignTexture(t,"glossinessMap",e)),i.push(r.assignTexture(t,"specularMap",e))}return Promise.all(i)}createMaterial(t){const e=new JS(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=Ge,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}class $S{constructor(){this.name=OS.KHR_MESH_QUANTIZATION}}class tT extends kc{constructor(t,e,r,n){super(t,e,r,n)}copySampleValue_(t){const e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let t=0;t!==n;t++)e[t]=r[i+t];return e}}tT.prototype.beforeStart_=tT.prototype.copySampleValue_,tT.prototype.afterEnd_=tT.prototype.copySampleValue_,tT.prototype.interpolate_=function(t,e,r,n){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,u=n-e,c=(r-e)/u,h=c*c,d=h*c,f=t*l,p=f-l,m=-2*d+3*h,g=d-h,v=1-m,y=g-h+c;for(let t=0;t!==o;t++){const e=a[p+t+o],r=a[p+t+s]*u,n=a[f+t+o],l=a[f+t]*u;i[t]=v*e+y*r+m*n+g*l}return i};const eT=new br;class rT extends tT{interpolate_(t,e,r,n){const i=super.interpolate_(t,e,r,n);return eT.fromArray(i).normalize().toArray(i),i}}const nT=0,iT=1,aT=2,oT=3,sT=4,lT=5,uT=6,cT={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},hT={9728:st,9729:ct,9984:lt,9985:ht,9986:ut,9987:dt},dT={33071:at,33648:ot,10497:it},fT={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},pT={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},mT={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},gT={CUBICSPLINE:void 0,LINEAR:Ee,STEP:Te},vT="OPAQUE",yT="MASK",xT="BLEND";function _T(t,e,r){for(const n in r.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=r.extensions[n])}function wT(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function bT(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let r=0,n=e.weights.length;r{const r=this.associations.get(t);null!=r&&this.associations.set(e,r);for(const[r,n]of t.children.entries())i(n,e.children[r])};return i(r,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let r=0;r=2&&f.setY(e,c[t*a+1]),a>=3&&f.setZ(e,c[t*a+2]),a>=4&&f.setW(e,c[t*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f}))}loadTexture(t){const e=this.json,r=this.options,n=e.textures[t],i=e.images[n.source];let a=this.textureLoader;if(i.uri){const t=r.manager.getHandler(i.uri);null!==t&&(a=t)}return this.loadTextureImage(t,i,a)}loadTextureImage(t,e,r){const n=this,i=this.json,a=this.options,o=i.textures[t],s=(e.uri||e.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];const l=self.URL||self.webkitURL;let u=e.uri||"",c=!1;if(void 0!==e.bufferView)u=n.getDependency("bufferView",e.bufferView).then((function(t){c=!0;const r=new Blob([t],{type:e.mimeType});return u=l.createObjectURL(r),u}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(u).then((function(t){return new Promise((function(e,n){let i=e;!0===r.isImageBitmapLoader&&(i=function(t){const r=new gr(t);r.needsUpdate=!0,e(r)}),r.load(Th.resolveURL(t,a.path),i,void 0,n)}))})).then((function(e){!0===c&&l.revokeObjectURL(u),e.flipY=!1,o.name&&(e.name=o.name);const r=(i.samplers||{})[o.sampler]||{};return e.magFilter=hT[r.magFilter]||ct,e.minFilter=hT[r.minFilter]||dt,e.wrapS=dT[r.wrapS]||it,e.wrapT=dT[r.wrapT]||it,n.associations.set(e,{textures:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",u),null}));return this.textureCache[s]=h,h}assignTexture(t,e,r){const n=this;return this.getDependency("texture",r.index).then((function(i){if(void 0===r.texCoord||0==r.texCoord||"aoMap"===e&&1==r.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+r.texCoord+" for texture "+e+" not yet supported."),n.extensions[OS.KHR_TEXTURE_TRANSFORM]){const t=void 0!==r.extensions?r.extensions[OS.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=n.associations.get(i);i=n.extensions[OS.KHR_TEXTURE_TRANSFORM].extendTexture(i,t),n.associations.set(i,e)}}return t[e]=i,i}))}assignFinalMaterial(t){const e=t.geometry;let r=t.material;const n=void 0===e.attributes.tangent,i=void 0!==e.attributes.color,a=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+r.uuid;let e=this.cache.get(t);e||(e=new ql,Bn.prototype.copy.call(e,r),e.color.copy(r.color),e.map=r.map,e.sizeAttenuation=!1,this.cache.add(t,e)),r=e}else if(t.isLine){const t="LineBasicMaterial:"+r.uuid;let e=this.cache.get(t);e||(e=new kl,Bn.prototype.copy.call(e,r),e.color.copy(r.color),this.cache.add(t,e)),r=e}if(n||i||a){let t="ClonedMaterial:"+r.uuid+":";r.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),n&&(t+="derivative-tangents:"),i&&(t+="vertex-colors:"),a&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=r.clone(),i&&(e.vertexColors=!0),a&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(r))),r=e}r.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=r}getMaterialType(){return Tc}loadMaterial(t){const e=this,r=this.json,n=this.extensions,i=r.materials[t];let a;const o={},s=i.extensions||{},l=[];if(s[OS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=n[OS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];a=t.getMaterialType(),l.push(t.extendParams(o,i,e))}else if(s[OS.KHR_MATERIALS_UNLIT]){const t=n[OS.KHR_MATERIALS_UNLIT];a=t.getMaterialType(),l.push(t.extendParams(o,i,e))}else{const r=i.pbrMetallicRoughness||{};if(o.color=new qn(1,1,1),o.opacity=1,Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;o.color.fromArray(t),o.opacity=t[3]}void 0!==r.baseColorTexture&&l.push(e.assignTexture(o,"map",r.baseColorTexture)),o.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,o.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(e.assignTexture(o,"metalnessMap",r.metallicRoughnessTexture)),l.push(e.assignTexture(o,"roughnessMap",r.metallicRoughnessTexture))),a=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),l.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,o)}))))}!0===i.doubleSided&&(o.side=h);const u=i.alphaMode||vT;if(u===xT?(o.transparent=!0,o.depthWrite=!1):(o.format=Et,o.transparent=!1,u===yT&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&a!==Xn&&(l.push(e.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new or(1,1),void 0!==i.normalTexture.scale)){const t=i.normalTexture.scale;o.normalScale.set(t,t)}return void 0!==i.occlusionTexture&&a!==Xn&&(l.push(e.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&a!==Xn&&(o.emissive=(new qn).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&a!==Xn&&l.push(e.assignTexture(o,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){let r;return r=a===JS?n[OS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new a(o),i.name&&(r.name=i.name),r.map&&(r.map.encoding=De),r.emissiveMap&&(r.emissiveMap.encoding=De),wT(r,i),e.associations.set(r,{materials:t}),i.extensions&&_T(n,r,i),r}))}createUniqueName(t){const e=ud.sanitizeNodeName(t||"");let r=e;for(let t=1;this.nodeNamesUsed[r];++t)r=e+"_"+t;return this.nodeNamesUsed[r]=!0,r}loadGeometries(t){const e=this,r=this.extensions,n=this.primitiveCache;function i(t){return r[OS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(r){return PT(r,t,e)}))}const a=[];for(let r=0,o=t.length;r0&&bT(h,i),h.name=e.createUniqueName(i.name||"mesh_"+t),wT(h,i),c.extensions&&_T(n,h,c),e.assignFinalMaterial(h),l.push(h)}for(let r=0,n=l.length;r1?new Bs:1===e.length?e[0]:new En,o!==e[0])for(let t=0,r=e.length;t{const e=new Map;for(const[t,r]of i.associations)(t instanceof Bn||t instanceof gr)&&e.set(t,r);return t.traverse((t=>{const r=i.associations.get(t);null!=r&&e.set(t,r)})),e})(a),a}))}}function AT(t,e,r,n){const i=r.nodes[t];return n.getDependency("node",t).then((function(t){if(void 0===i.skin)return t;let e;return n.getDependency("skin",i.skin).then((function(t){e=t;const r=[];for(let t=0,i=e.joints.length;t=2.0 are supported.")));const l=new ET(s,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===o[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(r,n)}parseAsync(t,e){const r=this;return new Promise((function(n,i){r.parse(t,e,n,i)}))}}},Symbol.toStringTag,{value:"Module"})));var IT,LT={};function OT(){if(IT)return LT;IT=1,Object.defineProperty(LT,"__esModule",{value:!0}),LT.default=void 0;var t=Ff,e=function(){function e(e){this.manager=void 0!==e?e:t.DefaultLoadingManager}function r(){var t={};return{get:function(e){return t[e]},add:function(e,r){t[e]=r},remove:function(e){delete t[e]},removeAll:function(){t={}},update:function(e,r){for(var n in t){var i=t[n];i.update&&i.update(e,r)}}}}function n(e,r){var n={},i=e.material.uniforms;for(var a in i){var o=i[a];if(o.semantic){var s=o.node,l=e;s&&(l=r[s]),n[a]={semantic:o.semantic,sourceNode:l,targetNode:e,uniform:o}}}this.boundUniforms=n,this._m4=new t.Matrix4}e.prototype={constructor:e,crossOrigin:"Anonymous",load:function(e,r,n,i){var a=this,o=this.path&&"string"==typeof this.path?this.path:t.LoaderUtils.extractUrlBase(e),s=new t.FileLoader(a.manager);s.setResponseType("arraybuffer"),s.load(e,(function(t){a.parse(t,r,o)}),n,i)},setCrossOrigin:function(t){this.crossOrigin=t},setPath:function(t){this.path=t},parse:function(e,r,n){var s,u={};t.LoaderUtils.decodeText(new Uint8Array(e,0,4))===o.magic?(u[i.KHR_BINARY_GLTF]=new l(e),s=u[i.KHR_BINARY_GLTF].content):s=t.LoaderUtils.decodeText(new Uint8Array(e));var c=JSON.parse(s);c.extensionsUsed&&c.extensionsUsed.indexOf(i.KHR_MATERIALS_COMMON)>=0&&(u[i.KHR_MATERIALS_COMMON]=new a(c)),new A(c,u,{path:n||this.path,crossOrigin:this.crossOrigin}).parse((function(t,e,n,i){r({scene:t,scenes:e,cameras:n,animations:i})}))}},e.Shaders={update:function(){console.warn("LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.")}},n.prototype.update=function(t,e){var r=this.boundUniforms;for(var n in r){var i=r[n];switch(i.semantic){case"MODELVIEW":i.uniform.value.multiplyMatrices(e.matrixWorldInverse,i.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var a=i.uniform.value;this._m4.multiplyMatrices(e.matrixWorldInverse,i.sourceNode.matrixWorld),a.getNormalMatrix(this._m4);break;case"PROJECTION":i.uniform.value.copy(e.projectionMatrix);break;case"JOINTMATRIX":for(var o=i.uniform.value,s=0;s>6*r)+n];r>0;){var a=e>>6*(r-1);i.push(128|63&a),r-=1}return i}}jT.prototype={decode:function(t,e){var r;r="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=NT(e),this._streaming||(this._decoder=new HT({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,i=new UT(r),a=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==BT;)null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n));if(!this._streaming){do{if((n=this._decoder.handler(i,i.read()))===BT)break;null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n))}while(!i.endOfStream());this._decoder=null}return a.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===a[0]?(this._BOMseen=!0,a.shift()):this._BOMseen=!0)),function(t){for(var e="",r=0;r>10),56320+(1023&n)))}return e}(a)}},VT.prototype={encode:function(t,e){t=t?String(t):"",e=NT(e),this._streaming||(this._encoder=new WT(this._options)),this._streaming=Boolean(e.stream);for(var r,n=[],i=new UT(function(t){for(var e=String(t),r=e.length,n=0,i=[];n57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(n===r-1)i.push(65533);else{var o=t.charCodeAt(n+1);if(56320<=o&&o<=57343){var s=1023&a,l=1023&o;i.push(65536+(s<<10)+l),n+=1}else i.push(65533)}n+=1}return i}(t));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==BT;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==BT;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};const qT=rf(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:jT,TextEncoder:VT},Symbol.toStringTag,{value:"Module"})));var XT,YT;function ZT(){if(XT)return kT;XT=1,Object.defineProperty(kT,"__esModule",{value:!0}),kT.default=kT.TextDecoder=void 0;var t=qT,e="function"==typeof ef.TextDecoder?ef.TextDecoder:t.TextDecoder;kT.TextDecoder=e;var r=new e("utf-8");return kT.default=r,kT}function KT(){if(YT)return DT;YT=1;var t=sf;Object.defineProperty(DT,"__esModule",{value:!0}),DT.default=void 0;var e=t(ZT()),r={parse:function(t){var r=e.default.decode(new Uint8Array(t)),n=JSON.parse(r);return Promise.resolve(n)}};return DT.default=r,DT}var JT,QT,$T={};function tE(){if(QT)return IS;QT=1;var t=sf;Object.defineProperty(IS,"__esModule",{value:!0}),IS.default=void 0;var e=t(cf),r=Ff,n=CT,i=t(OT()),a=t(KT()),o=t(GM()),s=t(function(){if(JT)return $T;JT=1,Object.defineProperty($T,"__esModule",{value:!0}),$T.default=void 0;var t=new RegExp("gl_Position.*(?![^]*gl_Position)"),e=new RegExp("[^\\w]*main[^\\w]*(void)?[^\\w]*{"),r={patchMaterialForLogDepthSupport:function(r){if(-1===r.vertexShader.indexOf("USE_LOGDEPTHBUF")&&-1===r.vertexShader.indexOf("logdepthbuf_pars_vertex")){r.vertexShader="#include \n#define EPSILON 1e-6\n".concat(r.vertexShader);var n=t.exec(r.vertexShader),i=n[0].length+n.index;r.vertexShader="".concat(r.vertexShader.slice(0,i),"\n#include \n").concat(r.vertexShader.slice(i)),r.fragmentShader="".concat("precision highp float;\nprecision highp int;\n","\n#include \n").concat(r.fragmentShader),i=(n=e.exec(r.fragmentShader))[0].length+n.index,r.fragmentShader="".concat(r.fragmentShader.slice(0,i),"\n#include \n").concat(r.fragmentShader.slice(i)),r.defines={USE_LOGDEPTHBUF:1,USE_LOGDEPTHBUF_EXT:1}}}};return $T.default=r,$T}()),l=t(ZT());function u(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0){var _=28+y.FTJSONLength+y.FTBinaryLength;x.push(a.default.parse(t.slice(_,y.BTJSONLength+_)))}else x.push(Promise.resolve({}));return x.push(new Promise((function(a){var g=function(c){var f,p=u(c.scenes);try{for(p.s();!(f=p.n()).done;){f.value.traverse(m)}}catch(t){p.e(t)}finally{p.f()}void 0===i||"Y"===i?c.scene.applyMatrix4(h):"X"===i&&c.scene.applyMatrix4(d),function(t,e){var r=new DataView(t,0,20),n=new Uint8Array(t,20,r.getUint32(12,!0)),i=l.default.decode(new Uint8Array(n)),a=JSON.parse(i);a.extensions&&a.extensions.CESIUM_RTC&&(e.position.fromArray(a.extensions.CESIUM_RTC.center),e.updateMatrixWorld(!0))}(t.slice(28+y.FTJSONLength+y.FTBinaryLength+y.BTJSONLength+y.BTBinaryLength),c.scene),c.scene.traverse((function(t){t.frustumCulled=!1,t.material&&(n.overrideMaterials?(t.material.dispose(),"object"===(0,e.default)(n.overrideMaterials)&&n.overrideMaterials.isMaterial?t.material=n.overrideMaterials.clone():t.material=new r.MeshLambertMaterial({color:16777215})):o.default.isLogDepthBufferSupported()&&t.material.isRawShaderMaterial&&!n.doNotPatchMaterial&&(s.default.patchMaterialForLogDepthSupport(t.material),console.warn("b3dm shader has been patched to add log depth buffer support")),t.material.transparent=n.opacity<1,t.material.opacity=n.opacity)})),a(c)},v=t.slice(28+y.FTJSONLength+y.FTBinaryLength+y.BTJSONLength+y.BTBinaryLength);1===new DataView(v,0,20).getUint32(4,!0)?p.parse(v,g,c):f.parse(v,c,g,(function(t){return console.error(t)}))}))),Promise.all(x).then((function(t){return{gltf:t[1],batchTable:t[0]}}))}throw new Error("Invalid b3dm file.")}};return IS.default=g,IS}var eE,rE={};function nE(){if(eE)return rE;eE=1;var t=sf;Object.defineProperty(rE,"__esModule",{value:!0}),rE.default=void 0;var e=Ff,r=t(KT()),n=t(ZT()),i={parse:function(t){if(!t)throw new Error("No array buffer provided.");var i=new DataView(t),a=0,o={},s={},l={};if(o.magic=n.default.decode(new Uint8Array(t,a,4)),a+=4,o.magic){if(o.version=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.byteLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.FTJSONLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.FTBinaryLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.BTJSONLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.BTBinaryLength=i.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,o.FTBinaryLength>0&&(l=function(t,r,i){var a,o=new e.BufferGeometry,s=n.default.decode(new Uint8Array(t,r,i)),l=JSON.parse(s);l.POINTS_LENGTH&&(a=l.POINTS_LENGTH);if(l.POSITION){var u=l.POSITION.byteOffset+s.length+r,c=new Float32Array(t,u,3*a);o.setAttribute("position",new e.BufferAttribute(c,3))}if(l.RGB){var h=l.RGB.byteOffset+s.length+r,d=new Uint8Array(t,h,3*a);o.setAttribute("color",new e.BufferAttribute(d,3,!0))}if(l.POSITION_QUANTIZED)throw new Error("For pnts loader, POSITION_QUANTIZED: not yet managed");if(l.RGBA)throw new Error("For pnts loader, RGBA: not yet managed");if(l.RGB565)throw new Error("For pnts loader, RGB565: not yet managed");if(l.NORMAL)throw new Error("For pnts loader, NORMAL: not yet managed");if(l.NORMAL_OCT16P)throw new Error("For pnts loader, NORMAL_OCT16P: not yet managed");if(l.BATCH_ID)throw new Error("For pnts loader, BATCH_ID: not yet managed");var f=l.RTC_CENTER?(new e.Vector3).fromArray(l.RTC_CENTER):void 0;return{geometry:o,offset:f}}(t,a,o.FTJSONLength)),o.BTJSONLength>0){var u=28+o.FTJSONLength+o.FTBinaryLength;s=r.default.parse(t.slice(u,o.BTJSONLength+u))}var c={point:l,batchTable:s};return Promise.resolve(c)}throw new Error("Invalid pnts file.")}};return rE.default=i,rE}var iE,aE,oE={},sE={};function lE(){if(iE)return sE;iE=1;var t=sf;Object.defineProperty(sE,"__esModule",{value:!0}),sE.default=sE.MODE=void 0;var e=t(df()),r=t(_f()),n=t($b()),i=t(Rf()),a=t(Lf()),o=t(kf()),s=Ff,l=t(GM());function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,o.default)(t);if(e){var i=(0,o.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,a.default)(this,r)}}var c={COLOR:0,INTENSITY:1,CLASSIFICATION:2,NORMAL:3,TEXTURE:4,ELEVATION:5};sE.MODE=c;var h=16,d=function(t){(0,i.default)(d,t);var a=u(d);function d(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,e.default)(this,d),(t=a.call(this)).vertexShader="precision highp float;\nprecision highp int;\n\n#include \n#define EPSILON 1e-6\n\nattribute vec3 position;\nuniform mat4 modelMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\nuniform float size;\n\nuniform int pickingId;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\nattribute vec3 color;\nattribute vec4 unique_id;\nattribute float intensity;\n\n#if defined(NORMAL_OCT16)\nattribute vec2 oct16Normal;\n#elif defined(NORMAL_SPHEREMAPPED)\nattribute vec2 sphereMappedNormal;\n#else\nattribute vec3 normal;\n#endif\n\nuniform sampler2D overlayTexture;\nuniform vec4 offsetScale;\nuniform vec2 extentTopLeft;\nuniform vec2 extentSize;\n\nvarying vec4 vColor;\n\n// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602\n// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)\n#if defined(NORMAL_OCT16)\nvec3 decodeOct16Normal(vec2 encodedNormal) {\n vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;\n vec3 n;\n n.z = 1. - abs(nNorm.x) - abs(nNorm.y);\n if (n.z >= 0.) {\n n.x = nNorm.x;\n n.y = nNorm.y;\n } else {\n n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;\n n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;\n }\n return normalize(n);\n}\n#elif defined(NORMAL_SPHEREMAPPED)\n// see http://aras-p.info/texts/CompactNormalStorage.html method #4\n// or see potree's implementation in BINPointReader.cpp\nvec3 decodeSphereMappedNormal(vec2 encodedNormal) {\n vec2 fenc = 2. * encodedNormal / 255. - 1.;\n float f = dot(fenc,fenc);\n float g = 2. * sqrt(1. - f);\n vec3 n;\n n.xy = fenc * g;\n n.z = 1. - 2. * f;\n return n;\n}\n#endif\n\n#ifdef DEFORMATION_SUPPORT\nuniform int enableTransfo;\nuniform mat4 transformations[NUM_TRANSFO];\nuniform vec3 vec[NUM_TRANSFO];\nuniform vec2 origin[NUM_TRANSFO];\nuniform vec2 influence[NUM_TRANSFO];\nuniform vec4 tColors[NUM_TRANSFO];\n#endif\n\nvoid main() {\n\n#if defined(NORMAL_OCT16)\n vec3 normal = decodeOct16Normal(oct16Normal);\n#elif defined(NORMAL_SPHEREMAPPED)\n vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);\n#elif defined(NORMAL)\n // nothing to do\n#else\n // default to color\n vec3 normal = color;\n#endif\n\n if (pickingId > 0) {\n vColor = unique_id;\n\n int left4bitsShift = 16; // << 4 <=> * 2^4\n int left8bitsShift = left4bitsShift * left4bitsShift;\n // 20 bits for 'unique_id' (= the point index in the buffer)\n // 12 bits for 'pickingId' (= the point instance id)\n // (see Picking.js)\n // = |4bits|| 8 bits |\n // ^ left-most 4 bits of the green channel\n // ^ red channel\n int upperPart = pickingId / left8bitsShift;\n int lowerPart = pickingId - upperPart * left8bitsShift; // 8 bits\n vColor.r = float(lowerPart) / 255.0;\n vColor.g += float(upperPart * 8) / 255.0; // << 4\n // vColor.g += float(upperPart * left4bitsShift) / 255.0;\n } else if (mode == MODE_INTENSITY) {\n vColor = vec4(intensity, intensity, intensity, opacity);\n } else if (mode == MODE_NORMAL) {\n vColor = vec4(abs(normal), opacity);\n } else if (mode == MODE_TEXTURE) {\n vec2 pp = (modelMatrix * vec4(position, 1.0)).xy;\n // offsetScale is from topleft\n pp.x -= extentTopLeft.x;\n pp.y = extentTopLeft.y - pp.y;\n pp *= offsetScale.zw / extentSize;\n pp += offsetScale.xy;\n pp.y = 1.0 - pp.y;\n vec3 textureColor = texture2D(overlayTexture, pp).rgb;\n vColor = vec4(mix(textureColor, overlayColor.rgb, overlayColor.a), opacity);\n } else if (mode == MODE_ELEVATION) {\n float z = (modelMatrix * vec4(position, 1.0)).z;\n // colors from OGC EL.GridCoverage.Default style\n if (z < -100.0) {\n vColor = vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0);\n } else if (z <= 0.0) {\n vColor = mix(\n vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n -z / 100.0);\n } else if (z <= 50.0) {\n vColor = mix(\n vec4(float(0x00) / 255.0, float(0x5C) / 255.0, float(0xE6) / 255.0, 1.0),\n vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n -z / 100.0);\n } else if (z <= 50.0) {\n vColor = mix(\n vec4(float(0x28) / 255.0, float(0xED) / 255.0, float(0xD6) / 255.0, 1.0),\n vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n z / 50.0);\n } else if (z <= 100.0) {\n vColor = mix(\n vec4(float(0x54) / 255.0, float(0xF7) / 255.0, float(0x6D) / 255.0, 1.0),\n vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n (z - 50.0)/ 50.0);\n } else {\n vColor = mix(\n vec4(float(0x9A) / 255.0, float(0xFA) / 255.0, float(0x66) / 255.0, 1.0),\n vec4(float(0x7B) / 255.0, float(0xF2) / 255.0, float(0x3A) / 255.0, 1.0),\n (z - 100.0)/ 50.0);\n }\n vColor.a = opacity;\n } else {\n // default to color mode\n vColor = vec4(mix(color, overlayColor.rgb, overlayColor.a), opacity);\n }\n\n mat4 mvMatrix = modelViewMatrix;\n\n #ifdef DEFORMATION_SUPPORT\n if (!pickingMode) {\n vColor = enableTransfo > 0 ?\n vec4(0.0, 1.0, 1.0, 1.0):\n vec4(1.0, 0.0, 1.0, 1.0);\n }\n if (enableTransfo > 0) {\n vec4 mPosition = modelMatrix * vec4(position, 1.0);\n float minDistance = 1000.0;\n int bestChoice = -1;\n for (int i = 0; i < NUM_TRANSFO; i++) {\n if (i >= enableTransfo) {\n break;\n }\n vec2 v = vec[i].xy;\n float length = vec[i].z;\n float depassement_x =\n length * (influence[i].x - 1.0);\n\n vec2 diff = mPosition.xy - origin[i];\n float distance_x = dot(diff, v);\n\n if (-depassement_x <= distance_x &&\n distance_x <= (length + depassement_x)) {\n vec2 normal = vec2(-v.y, v.x);\n float d = abs(dot(diff, normal));\n if (d < minDistance && d <= influence[i].y) {\n minDistance = d;\n bestChoice = i;\n }\n }\n }\n\n if (bestChoice >= 0) {\n // override modelViewMatrix\n mvMatrix = transformations[bestChoice];\n vColor = mix(\n tColors[bestChoice],\n vec4(color, 1.0),\n 0.5);\n }\n }\n #endif\n\n vec4 mvPosition = mvMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n\n if (size > 0.) {\n gl_PointSize = size;\n } else {\n gl_PointSize = clamp(-size / gl_Position.w, 3.0, 10.0);\n }\n\n #include \n}\n",t.fragmentShader="precision highp float;\nprecision highp int;\n\n#include \n\nvarying vec4 vColor;\n\nvoid main() {\n // circular point rendering\n if(length(gl_PointCoord - 0.5) > 0.5){\n discard;\n }\n\n gl_FragColor = vColor;\n\n #include \n}\n",t.size=r.size||0,t.scale=r.scale||.025/Math.tan(.5),t.overlayColor=r.overlayColor||new s.Vector4(0,0,0,0),t.mode=r.mode||c.COLOR,t.pickingId=0;for(var n=0,i=Object.keys(c);n0?this.size:-this.scale*window.innerHeight,this.uniforms.mode.value=this.mode,this.uniforms.pickingId.value=this.pickingId,this.uniforms.opacity.value=this.opacity,this.uniforms.overlayColor.value=this.overlayColor}},{key:"update",value:function(t){return t&&(this.visible=t.visible,this.opacity=t.opacity,this.transparent=t.transparent,this.size=t.size,this.mode=t.mode,this.pickingId=t.pickingId,this.scale=t.scale,this.overlayColor.copy(t.overlayColor)),this.updateUniforms(),t&&Object.assign(this.defines,t.defines),this}},{key:"pushLayer",value:function(t,e){this.mode=c.TEXTURE,this.updateUniforms(),this.colorLayer=t,this.uniforms.overlayTexture=new s.Uniform,this.uniforms.offsetScale=new s.Uniform(new s.Vector4(0,0,1,1)),this.uniforms.extentTopLeft=new s.Uniform(new s.Vector2(e.west(),e.north()));var r=e.dimensions();this.uniforms.extentSize=new s.Uniform(new s.Vector2(r.x,r.y))}},{key:"getColorTexture",value:function(t){return t!==this.colorLayer?null:this.uniforms.overlayTexture.value}},{key:"setColorTextures",value:function(t,e){return Array.isArray(e)&&(e=e[0]),t===this.colorLayer&&(this.uniforms.overlayTexture.value=e.texture,this.uniforms.offsetScale.value.copy(e.pitch)),Promise.resolve()}},{key:"setSequence",value:function(){}},{key:"setLayerVisibility",value:function(){}},{key:"setLayerOpacity",value:function(){}},{key:"enableTransfo",value:function(t){t?(this.defines.DEFORMATION_SUPPORT=1,this.defines.NUM_TRANSFO=h):(delete this.defines.DEFORMATION_SUPPORT,delete this.defines.NUM_TRANSFO),this.needsUpdate=!0}}]),d}(s.RawShaderMaterial),f=d;return sE.default=f,sE}function uE(){if(aE)return oE;aE=1;var t=sf;Object.defineProperty(oE,"__esModule",{value:!0}),oE.default=void 0;var e=t(df()),r=t(_f()),n=t(Rf()),i=t(Lf()),a=t(kf()),o=Ff,s=t(lE());function l(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,a.default)(t);if(e){var o=(0,a.default)(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return(0,i.default)(this,r)}}var u=function(t){(0,n.default)(a,t);var i=l(a);function a(t,r){var n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new s.default;return(0,e.default)(this,a),(n=i.call(this,r,o))._layer=t,n.extent=void 0,n.layerUpdateState={},n.wmtsCoords={},n}return(0,r.default)(a,[{key:"getExtentForLayer",value:function(t){if(t.extent.crs()!==this._layer.extent.crs())throw new Error("Unsupported reprojection");return this.extent}}]),a}(o.Points),c=u;return oE.default=c,oE}var cE={},hE=sf;Object.defineProperty(cE,"__esModule",{value:!0}),cE.calculateCameraDistance=NE;var dE=cE.default=void 0;cE.init3dTilesEntity=function(t,e,r){return AE(t,e,r,r.tileset.root,void 0,!0).then((function(e){delete r.tileset,r.object3d.add(e),e.updateMatrixWorld(),r.tileIndex.index[e.tileId].obj=e,r.root=e,r.extent=RE(r.projection||t.referenceCrs,e.boundingVolume,e.matrixWorld)}))};var fE=hE(Ex()),pE=hE(df()),mE=hE(_f()),gE=hE(Rf()),vE=hE(Lf()),yE=hE(kf()),xE=Ff,_E=hE(bM()),wE=hE(bS());function bE(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return ME(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ME(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function ME(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:{};if((0,pE.default)(this,r),i=e.call(this,t,a.object3d||new xE.Group),!n)throw new Error("missing source");if(!n.url)throw new Error("missing source.url");return i.protocol="3d-tiles",i.url=n.url,i.networkOptions=n.networkOptions,i.sseThreshold=a.sseThreshold||16,i.cleanupDelay=a.cleanupDelay||1e3,i.material=a.material||void 0,i._cleanableTiles=[],i}return(0,mE.default)(r,[{key:"preUpdate",value:function(){if(!this.visible)return[];var t=Date.now();if(this._cleanableTiles.length&&t-this._cleanableTiles[0].cleanableSince>this.cleanupDelay)for(;this._cleanableTiles.length;){var e=this._cleanableTiles[0];if(!(t-e.cleanableSince>this.cleanupDelay))break;LE(this,e)}return[this.root]}},{key:"update",value:function(t,e){var r=this;if(e.remove.apply(e,(0,fE.default)(e.children.filter((function(t){return t.deleted})))),!e.parent.pendingSubdivision||e.parent.additiveRefinement){var n,i=!IE(t.camera,e,e.matrixWorld);if(e.visible=i,i){if(FE(this,e),NE(t.camera.camera3D,e),e.pendingSubdivision||function(t,e,r){if(void 0===e.tileIndex.index[r.tileId].children)return!1;if(e.tileIndex.index[r.tileId].isTileset)return!0;var n=function(t,e){if(e.boundingVolume.region)throw new Error("boundingVolume.region is unsupported");if(e.boundingVolume.box){var r=wE.default.computeFromBox3(t.camera,e.boundingVolume.box,e.matrixWorld,e.geometricError,wE.default.MODE_3D);return r?Math.max(r.lengths.x,r.lengths.y):1/0}return e.boundingVolume.sphere?0===e.distance?1/0:t.camera._preSSE*(e.geometricError/e.distance):1/0}(t,r);return r.sse=n,n>e.sseThreshold}(t,this,e)){if(function(t,e,r,n){r.additiveRefinement?function(t,e,r,n){var i,a=bE(e.tileIndex.index[r.tileId].children);try{var o=function(){var a=i.value;if(a.promise||r.children.filter((function(t){return t.tileId===a.tileId})).length>0)return"continue";var o=r.matrixWorld;if(a.transform&&(o=CE.multiplyMatrices(r.matrixWorld,a.transform)),!(!n||!n(t.camera,a,o)))return"continue";a.promise=AE(t.instance,t.scheduler,e,a,r,!0).then((function(n){if(n&&r.parent){r.add(n),n.updateMatrixWorld();var i=RE(e.extent.crs(),n.boundingVolume,n.matrixWorld);n.traverse((function(t){t.extent=i})),t.instance.notifyChange(a)}delete a.promise}),(function(){delete a.promise}))};for(a.s();!(i=a.n()).done;)o()}catch(t){a.e(t)}finally{a.f()}}(t,e,r,n):function(t,e,r){if(r.pendingSubdivision)return;if(PE(r).length>0)return;var n=e.tileIndex.index[r.tileId].children;if(void 0===n||0===n.length)return;r.pendingSubdivision=!0;var i,a=[],o=bE(e.tileIndex.index[r.tileId].children);try{for(o.s();!(i=o.n()).done;){var s=i.value,l=AE(t.instance,t.scheduler,e,s,r,!1).then((function(t){r.add(t),t.updateMatrixWorld();var n=RE(e.extent.crs(),t.boundingVolume,t.matrixWorld);t.traverse((function(t){t.extent=n}))}));a.push(l)}}catch(t){o.e(t)}finally{o.f()}Promise.all(a).then((function(){r.pendingSubdivision=!1,t.instance.notifyChange(r)}),(function(){r.pendingSubdivision=!1;var t,n=bE(PE(r));try{for(n.s();!(t=n.n()).done;){var i=t.value;i.visible=!1,kE(e,i)}}catch(t){n.e(t)}finally{n.f()}}))}(t,e,r)}(t,this,e,IE),e.additiveRefinement||e.pendingSubdivision)DE(e,!0);else{var a=this.tileIndex.index[e.tileId].children.filter((function(t){return t.isTileset}));if(a.length){var o,s=!0,l=bE(a);try{var u=function(){var t=o.value,r=e.children.filter((function(e){return e.tileId===t.tileId}))[0];if(!function(t,e){return t&&e&&1===e.children.length&&e.children[0].children.length>0}(t,r))return s=!1,"break"};for(l.s();!(o=l.n()).done;){if("break"===u())break}}catch(t){l.e(t)}finally{l.f()}DE(e,s)}else DE(e,!0)}n=PE(e)}else{DE(e,!0);var c,h=bE(PE(e));try{for(h.s();!(c=h.n()).done;){var d=c.value;d.visible=!1,kE(this,d)}}catch(t){h.e(t)}finally{h.f()}}if(e.content&&e.content.visible){if(e.boundingVolume.region)throw new Error("boundingVolume.region is not yet supported");(e.boundingVolume.box||e.boundingVolume.sphere)&&(this._distance.min=Math.min(this._distance.min,e.distance.min),this._distance.max=Math.max(this._distance.max,e.distance.max)),e.content.traverse((function(t){t.layer===r&&t.material&&(t.material.wireframe=r.wireframe,t.isPoints&&(t.material.update?t.material.update(r.material):t.material.copy(r.material)))}))}}else e!==this.root&&e.parent&&e.parent.additiveRefinement&&kE(this,e);return n}e.visible=!1}}]),r}(hE(YM()).default),EE={v:new xE.Vector3,b:new xE.Box3,s:new xE.Sphere};function AE(t,e,r,n,i,a){if(n.obj)return FE(r,n.obj),t.notifyChange(i),Promise.resolve(n.obj);var o;if(!i||i.additiveRefinement){var s=n.boundingVolume.box.clone().applyMatrix4(n._worldFromLocalTransform).getSize(EE.v);o=s.x*s.y}else{var l=i.boundingVolume.box.clone().applyMatrix4(i.matrixWorld).getSize(EE.v);o=l.x*l.y}var u={view:t,requester:i,layer:r,priority:o,metadata:n,redraw:a,earlyDropFunction:function(t){return t.requester&&(!t.requester.parent||!t.requester.visible||t.requester.sse2&&void 0!==arguments[2]?arguments[2]:0;FE(t,e),t.tileIndex.index[e.tileId].obj&&(t.tileIndex.index[e.tileId].obj.deleted=Date.now(),t.tileIndex.index[e.tileId].obj=void 0);var n,i=bE(PE(e));try{for(i.s();!(n=i.n()).done;){var a=n.value;LE(t,a,r+1),e.remove(a)}}catch(t){i.e(t)}finally{i.f()}e.content&&(e.content.traverse(OE),e.remove(e.content),delete e.content),e.dispose&&e.dispose()}function OE(t){var e,r=bE(t.children);try{for(r.s();!(e=r.n()).done;){OE(e.value)}}catch(t){r.e(t)}finally{r.f()}t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose(),t.remove.apply(t,(0,fE.default)(t.children))}function DE(t,e){t.content&&(t.content.visible=e)}function kE(t,e){e.cleanableSince||(e.cleanableSince=Date.now(),t._cleanableTiles.push(e))}function FE(t,e){e.cleanableSince&&(t._cleanableTiles.splice(t._cleanableTiles.indexOf(e),1),e.cleanableSince=void 0)}function NE(t,e){if(e.distance.min=0,e.distance.max=0,e.boundingVolume.region)throw new Error("boundingVolume.region is unsupported");e.boundingVolume.box?(EE.b.copy(e.boundingVolume.box),EE.b.applyMatrix4(e.matrixWorld),e.distance.min=EE.b.distanceToPoint(t.position),e.distance.max=e.distance.min+EE.b.getSize(EE.v).length()):e.boundingVolume.sphere&&(EE.s.copy(e.boundingVolume.sphere),EE.s.applyMatrix4(e.matrixWorld),e.distance.min=Math.max(0,EE.s.distanceToPoint(t.position)),e.distance.max=e.distance.min+2*EE.s.radius)}var UE,BE=TE;function zE(){if(UE)return CS;UE=1;var t=sf;Object.defineProperty(CS,"__esModule",{value:!0}),CS.$3dTilesIndex=void 0,CS.configureTile=w,CS.default=void 0,CS.getObjectToUpdateForAttachedLayers=v;var e=t(df()),r=t(_f()),n=Ff,i=t(tE()),a=t(nE()),o=t(kb()),s=t(ZT()),l=t(OM()),u=t(uE()),c=t(lE()),h=t(oM()),d=cE;function f(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r>1,c=-7,h=r?i-1:0,d=r?-1:1,f=t[e+h];for(h+=d,a=f&(1<<-c)-1,f>>=-c,c+=s;c>0;a=256*a+t[e+h],h+=d,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=n;c>0;o=256*o+t[e+h],h+=d,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),a-=u}return(f?-1:1)*o*Math.pow(2,a-n)},ZE.write=function(t,e,r,n,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(s=0,o=c):o+h>=1?(s=(e*l-1)*Math.pow(2,i),o+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+f]=255&s,f+=p,s/=256,i-=8);for(o=o<0;t[r+f]=255&o,f+=p,o/=256,u-=8);t[r+f-p]|=128*m}),ZE);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function a(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function o(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function s(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function x(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=x(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=v(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=v(this.buf,this.pos)+x(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(i=a[r.pos++],n=(112&i)>>4,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<3,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<10,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<17,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(127&i)<<24,i<128)return o(t,n,e);if(i=a[r.pos++],n|=(1&i)<<31,i<128)return o(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){var n="",i=e;for(;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((u=(15&l)<<12|(63&a)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=a(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else{if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos]=127&t}(r,0,e),function(t,e){var r=(7&t)<<4;if(e.buf[e.pos++]|=r|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&s(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&s(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,g,e)},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r)},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r)},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r)},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r)},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r)},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r)},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},WE}var JE,QE,$E,tA,eA,rA,nA,iA,aA,oA={};function sA(){if(tA)return $E;tA=1;var t=function(){if(QE)return JE;function t(t,e){this.x=t,this.y=e}return QE=1,JE=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.x+r*(this.x-e.x)-n*(this.y-e.y),a=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},JE}();function e(t,e,n,i,a){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=a,t.readFields(r,this,e)}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){var r=t.readVarint()+t.pos;for(;t.pos>3}if(a--,1===i||2===i)o+=e.readSVarint(),s+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(o,s));else{if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone())}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,u=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())u&&(u=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,u]},e.prototype.toGeoJSON=function(t,r,i){var a,o,s=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}return eA=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},eA}function uA(){return aA||(aA=1,oA.VectorTile=function(){if(iA)return nA;iA=1;var t=lA();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i)}}return nA=function(t,r){this.layers=t.readFields(e,{},r)}}(),oA.VectorTileFeature=sA(),oA.VectorTileLayer=lA()),oA}var cA,hA,dA={};function fA(){if(cA)return dA;cA=1;var t=sf;Object.defineProperty(dA,"__esModule",{value:!0}),dA.default=void 0;var e=t(Ax()),r=t(bM());function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{},r=e.crsOut,n=e.filteringExtent;switch("string"==typeof t&&(t=JSON.parse(t)),e.crsIn=e.crsIn||function(t){if(t.crs){if("epsg"===t.crs.type.toLowerCase())return"EPSG:".concat(t.crs.properties.code);if("name"===t.crs.type.toLowerCase()){var e=t.crs.properties.name.toLowerCase().indexOf("epsg:");if(e>=0){var r=t.crs.properties.name.indexOf(":",e+5);if(r>0)return"EPSG:".concat(t.crs.properties.name.substr(r+1))}}throw new Error("Unsupported CRS type '".concat(t.crs,"'"))}return"EPSG:4326"}(t),t.type.toLowerCase()){case"featurecollection":return Promise.resolve(c(e.crsIn,r,t.features,n,e));case"feature":return Promise.resolve(c(e.crsIn,r,[t],n,e));default:throw new Error("Unsupported GeoJSON type: '".concat(t.type))}}};return dA.default=h,dA}function pA(){if(hA)return YE;hA=1;var t=sf;Object.defineProperty(YE,"__esModule",{value:!0}),YE.default=void 0;var e=t(KE()),r=uA(),n=t(fA());t(bM());var i={parse:function(t,i){return Promise.resolve(function(t,i){var a=new r.VectorTile(new e.default(t)),o=Object.keys(a.layers);if(o.length<1)return null;var s,l={type:"FeatureCollection",features:[],crs:{type:"EPSG",properties:{code:4326}},extent:i.extent};o.forEach((function(t){for(var e=a.layers[t],r=0;r1&&(n.properties.vt_layer=t),l.features.push(n)}})),s="WMTS:PM"===i.coords.crs()?"EPSG:3857":i.extent.crs();return n.default.parse(l,{crsOut:s,filteringExtent:i.filteringExtent,filter:i.filter,buildExtent:!0})}(t,i))}};return YE.default=i,YE}var mA,gA,vA,yA={};function xA(){if(mA)return yA;mA=1,Object.defineProperty(yA,"__esModule",{value:!0}),yA.default=void 0;var t=Ff;function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r6&&void 0!==arguments[6]?arguments[6]:{};if(0!==r.length)if(l.length){var u,c=e(l);try{for(c.s();!(u=c.n()).done;){s(t,r,n,i,a,o,u.value)}}catch(t){c.e(t)}finally{c.f()}}else s(t,r,n,i,a,o,l)}function s(t,r,n,o,s,l,u){t.beginPath();var c,h=e(n);try{for(h.s();!(c=h.n()).done;){var d=c.value;i(t,r[d.offset],s,o);for(var f=1;f4&&void 0!==arguments[4]?arguments[4]:{};n.x=e._values[0]-r.x,n.y=r.y-e._values[1],n.multiply(i),t.beginPath(),t.arc(n.x,n.y,a.radius||3,0,2*Math.PI,!1),t.fillStyle=a.fill||"white",t.fill(),t.lineWidth=a.lineWidth||1,t.strokeStyle=a.stroke||"red",t.stroke()}function u(t,r,n,i,a){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},u=r.properties;"function"==typeof s&&(s=s(u,r));var c,h=e(r.geometry);try{for(h.s();!(c=h.n()).done;){var d=c.value;"point"===r.type?l(t,r.vertices[0],n,i,s):d.extent.intersectsExtent(a)&&o(t,r.vertices,d.indices,n,i,u,s)}}catch(t){h.e(t)}finally{h.f()}}var c={createTextureFromFeature:function(r,n,i,a,o){var s;if(r){var l=new t.Vector2(n.west(),n.north()),c=n.dimensions(),h=document.createElement("canvas");h.width=i,h.height=i;var d=h.getContext("2d");o&&(d.fillStyle=o.getStyle(),d.fillRect(0,0,i,i)),d.globalCompositeOperation=a.globalCompositeOperation||"source-over";var f,p=new t.Vector2(d.canvas.width/c.x,d.canvas.width/c.y),m=e(r.features);try{for(m.s();!(f=m.n()).done;){u(d,f.value,l,p,n,a)}}catch(t){m.e(t)}finally{m.f()}(s=new t.Texture(h)).flipY=!1,s.generateMipmaps=!1,s.magFilter=t.LinearFilter,s.minFilter=t.LinearFilter,s.needsUpdate=!0}else if(o){var g=new Uint8Array(3);g[0]=255*o.r,g[1]=255*o.g,g[2]=255*o.b,(s=new t.DataTexture(g,1,1,t.RGBFormat)).needsUpdate=!0}else s=new t.Texture;return s},featuresAtPoint:function(r,n,i,a,o,s){if(!r)return[];var l=[],c=n.dimensions(),h=new t.Vector2(i/c.x,i/c.y),d=new t.Vector2(o.x-s/h.x,o.y+s/h.y),f=document.createElement("canvas");f.width=1+2*s,f.height=1+2*s;var p=f.getContext("2d");p.globalCompositeOperation="source-over";var m,g=e(r.features);try{for(g.s();!(m=g.n()).done;){var v=m.value;p.clearRect(0,0,f.width,f.height),u(p,v,d,h,n,a);for(var y=p.getImageData(0,0,f.width,f.height),x=y.data,_=!1,w=0;w0);w+=4);_&&l.push(v)}}catch(t){g.e(t)}finally{g.f()}return l}};return yA.default=c,yA}function _A(){if(vA)return jE;vA=1;var t=sf;Object.defineProperty(jE,"__esModule",{value:!0}),jE.default=void 0;var e=t(ux()),r=t(Ex()),n=Ff,i=t(SM()),a=t(function(){if(GE)return VE;GE=1;var t=sf;return Object.defineProperty(VE,"__esModule",{value:!0}),VE.default=void 0,t(bM()),t(Fb()),VE.default={xyz:function(t,e){return e.url.replace(/(\$\{z\}|%TILEMATRIX)/,t.zoom).replace(/(\$\{y\}|%ROW)/,t.row).replace(/(\$\{x\}|%COL)/,t.col)},bbox:function(t,e){var r="EPSG:4326"===e.projection?9:2,n=t.crs()===e.projection?t:t.as(e.projection),i=n.west().toFixed(r),a=n.south().toFixed(r),o=n.east().toFixed(r),s=n.north().toFixed(r),l=e.axisOrder||"wsen";return l=l.replace("w","".concat(i,",")).replace("s","".concat(a,",")).replace("e","".concat(o,",")).replace("n","".concat(s,",")).slice(0,-1),e.url.replace("%bbox",l)}},VE}()),o=t(bM()),s=t(function(){if(gA)return XE;gA=1;var t=sf;Object.defineProperty(XE,"__esModule",{value:!0}),XE.default=void 0;var e=Ff,r=t(kb()),n=t(oM()),i=t(pA()),a=t(xA());t(bM()),t(TM()),t(Fb());var o=t(qb()),s=function(t,e,n,a){return r.default.arrayBuffer(t,n.networkOptions).then((function(t){return i.default.parse(t,{extent:e.extent,filteringExtent:n.extent,filter:n.filter,origin:n.origin,coords:a})}))},l={getVectorTileByUrl:s,getVectorTileTextureByUrl:function(t,r,i,l){return i instanceof o.default?null:n.default.get(t)||n.default.set(t,s(t,r,i,l).then((function(t){var n,o=i.backgroundLayer&&i.backgroundLayer.paint?new e.Color(i.backgroundLayer.paint["background-color"]):void 0;switch(l.crs()){case"TMS":n=r.extent;break;case"WMTS:PM":n=l.as("EPSG:3857");break;default:n=l.as(r.extent.crs())}var s=a.default.createTextureFromFeature(t,n,256,i.style,o);return s.extent=r.extent,s.coords=l,s})))}};return XE.default=l,XE}()),l=Ab();function u(t,e,r,o){var s=new n.Vector4(0,0,1,1),u=function(t,e,r,n,a){if(r.updateStrategy.type===l.STRATEGY_MIN_NETWORK_TRAFFIC)return t;var o,s,u,c=0;if(e){if(t.zoom<=e.zoom+1)return t;switch(r.updateStrategy.type){case l.STRATEGY_PROGRESSIVE:c+=1;break;case l.STRATEGY_GROUP:o=t.zoom,e.zoom,c=(u=(s=r.updateStrategy.options).groups.filter((function(t){return t<=o}))).length?u[u.length-1]:s.groups[0];break;default:case l.STRATEGY_DICHOTOMY:c=Math.ceil((e.zoom+t.zoom)/2)}}return a&&a.extent&&a.extent.zoom===c&&(c=Math.ceil((e.zoom+c)/2)),c=Math.min(Math.max(c,r.options.zoom.min),r.options.zoom.max),t.zoom<=c?t:i.default.WMTS_WGS84Parent(t,c,n)}(e,r&&r.extent?r.extent:null,t,s,o);return r&&r.extent&&r.extent.zoom===u.zoom?null:{extent:u,pitch:s,url:a.default.xyz(u,t)}}function c(t,e){return h(t.getExtentForLayer(e),e)}function h(t,e){return e.options.zoom.min<=t.zoom&&t.zoom<=e.options.zoom.max}var d={preprocessDataLayer:function(t){if(t.extent||(t.extent=new o.default("EPSG:3857",-20037508.342789244,20037508.342789244,-20037508.342789244,20037508.342789244)),!(t.extent instanceof o.default)){if(!t.projection)throw new Error("Missing projection property for layer '".concat(t.id,"'"));t.extent=(0,e.default)(o.default,[t.projection].concat((0,r.default)(t.extent)))}t.origin=t.origin||("xyz"===t.protocol?"top":"bottom"),t.options.zoom||(t.options.zoom={min:0,max:18}),t.fx=t.fx||0},executeCommand:function(t){var e=t.layer;return("application/x-protobuf;type=mapbox-vector"===e.format?s.default.getVectorTileTextureByUrl(t.toDownload,t.requester,e):i.default.getColorTextureByUrl(t.toDownload,e.networkOptions)).then((function(t){var r={};return r.texture=t,e.transparent&&(t.premultiplyAlpha=!0),r}))},tileTextureCount:function(t,e){return c(t,e)?1:0},tileInsideLimit:c,getPossibleTextureImprovements:function(t,e,r,n){return h(e,t)?e.zoom>t.options.zoom.max?null:r?(!r.extent||r.extent.zoom=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0&&t.octreeDepthLimit0)if(i.obj)i.obj.material.update?i.obj.material.update(t.material):i.obj.material.copy(t.material);else if(!i.promise){var c=o(e,t,i,u)/Math.max(.001,u);i.promise=e.scheduler.execute({layer:t,requester:i,view:e.instance,priority:c,redraw:!0,isLeaf:0===i.childrenBitField,earlyDropFunction:function(e){return!e.requester.visible||!t.visible}}).then((function(e){t.onPointsCreated&&t.onPointsCreated(t,e),i.obj=e,i.tightbbox=e.tightbbox,t.group.add(i.obj),i.obj.updateMatrixWorld(!0),i.promise=null}),(function(t){t instanceof r.default&&(i.promise=null)}))}i.children&&i.children.length&&(i.sse=o(e,t,i,u)/t.sseThreshold)}if(i.children&&i.children.length){if(i.sse>=1)return i.children;var h,d=n(i.children);try{for(d.s();!(h=d.n()).done;){s(h.value)}}catch(t){d.e(t)}finally{d.f()}}return null}},postUpdate:function(t){return function(){if(t.group){t.displayedCount=0;var e,r=n(t.group.children);try{for(r.s();!(e=r.n()).done;){var i=e.value;if(i.material.visible){var a=i.geometry.attributes.position.count;i.geometry.setDrawRange(0,a),t.displayedCount+=a}}}catch(t){r.e(t)}finally{r.f()}if(t.displayedCount>t.pointBudget)if(t.supportsProgressiveDisplay){var o,s=t.pointBudget/t.displayedCount,l=n(t.group.children);try{for(l.s();!(o=l.n()).done;){var u=o.value;if(u.material.visible){var c=Math.floor(u.geometry.drawRange.count*s);c>0?u.geometry.setDrawRange(0,c):u.material.visible=!1}}}catch(t){l.e(t)}finally{l.f()}t.displayedCount*=s}else{t.group.children.sort((function(t,e){return e.userData.metadata.sse-t.userData.metadata.sse}));var h=!1;t.displayedCount=0;var d,f=n(t.group.children);try{for(f.s();!(d=f.n()).done;){var p=d.value,m=p.geometry.attributes.position.count;h||t.displayedCount+m>t.pointBudget?(p.material.visible=!1,h=!0):t.displayedCount+=m}}catch(t){f.e(t)}finally{f.f()}}for(var g=Date.now(),v=t.group.children.length-1;v>=0;v--){var y=t.group.children[v],x=y.userData.metadata.notVisibleSince;!y.material.visible&&g-x>1e4&&(t.group.children.splice(v,1),y.material.dispose(),y.geometry.dispose(),y.material=null,y.geometry=null,y.userData.metadata.obj=null)}}}}};return MA.default=u,MA}var TA,EA={};function AA(){if(TA)return EA;TA=1,Object.defineProperty(EA,"__esModule",{value:!0}),EA.default=void 0;var t=Ff;function e(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw o}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r>4!=3)throw new Error(`Got v${r>>4} data when expected v3.`);const[n]=new Uint16Array(t,2,1),[i]=new Uint32Array(t,4,1);return new kA(i,n,DA[15&r],t)}constructor(t,e=16,r=Float64Array,n){if(void 0===t)throw new Error("Missing required argument: numItems.");if(isNaN(t)||t<=0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535);let i=t,a=i;this._levelBounds=[4*i];do{i=Math.ceil(i/this.nodeSize),a+=i,this._levelBounds.push(4*a)}while(1!==i);this.ArrayType=r||Float64Array,this.IndexArrayType=a<16384?Uint16Array:Uint32Array;const o=DA.indexOf(this.ArrayType),s=4*a*this.ArrayType.BYTES_PER_ELEMENT;if(o<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this._boxes=new this.ArrayType(this.data,8,4*a),this._indices=new this.IndexArrayType(this.data,8+s,a),this._pos=4*a,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1]):(this.data=new ArrayBuffer(8+s+a*this.IndexArrayType.BYTES_PER_ELEMENT),this._boxes=new this.ArrayType(this.data,8,4*a),this._indices=new this.IndexArrayType(this.data,8+s,a),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(this.data,0,2).set([251,48+o]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t),this._queue=new OA}add(t,e,r,n){const i=this._pos>>2;return this._indices[i]=i,this._boxes[this._pos++]=t,this._boxes[this._pos++]=e,this._boxes[this._pos++]=r,this._boxes[this._pos++]=n,tthis.maxX&&(this.maxX=r),n>this.maxY&&(this.maxY=n),i}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);if(this.numItems<=this.nodeSize)return this._boxes[this._pos++]=this.minX,this._boxes[this._pos++]=this.minY,this._boxes[this._pos++]=this.maxX,void(this._boxes[this._pos++]=this.maxY);const t=this.maxX-this.minX||1,e=this.maxY-this.minY||1,r=new Uint32Array(this.numItems);for(let n=0;n>2]=t,this._boxes[this._pos++]=n,this._boxes[this._pos++]=i,this._boxes[this._pos++]=a,this._boxes[this._pos++]=o}}}search(t,e,r,n,i){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let a=this._boxes.length-4;const o=[],s=[];for(;void 0!==a;){const l=Math.min(a+4*this.nodeSize,NA(a,this._levelBounds));for(let u=a;u>2];rthis._boxes[u+2]||e>this._boxes[u+3]||(a<4*this.numItems?(void 0===i||i(l))&&s.push(l):o.push(l)))}a=o.pop()}return s}neighbors(t,e,r=1/0,n=1/0,i){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let a=this._boxes.length-4;const o=this._queue,s=[],l=n*n;for(;void 0!==a;){const n=Math.min(a+4*this.nodeSize,NA(a,this._levelBounds));for(let r=a;r>2],s=FA(t,this._boxes[r],this._boxes[r+2]),l=FA(e,this._boxes[r+1],this._boxes[r+3]),u=s*s+l*l;a<4*this.numItems?(void 0===i||i(n))&&o.push(1+(n<<1),u):o.push(n<<1,u)}for(;o.length&&1&o.peek();){if(o.peekValue()>l)return o.clear(),s;if(s.push(o.pop()>>1),s.length===r)return o.clear(),s}a=o.pop()>>1}return o.clear(),s}}function FA(t,e,r){return t>1;e[i]>t?n=i:r=i+1}return e[r]}function UA(t,e,r,n,i,a){if(Math.floor(n/a)>=Math.floor(i/a))return;const o=t[n+i>>1];let s=n-1,l=i+1;for(;;){do{s++}while(t[s]o);if(s>=l)break;BA(t,e,r,s,l)}UA(t,e,r,n,l,a),UA(t,e,r,l+1,i,a)}function BA(t,e,r,n,i){const a=t[n];t[n]=t[i],t[i]=a;const o=4*n,s=4*i,l=e[o],u=e[o+1],c=e[o+2],h=e[o+3];e[o]=e[s],e[o+1]=e[s+1],e[o+2]=e[s+2],e[o+3]=e[s+3],e[s]=l,e[s+1]=u,e[s+2]=c,e[s+3]=h;const d=r[n];r[n]=r[i],r[i]=d}function zA(t,e){let r=t^e,n=65535^r,i=65535^(t|e),a=t&(65535^e),o=r|n>>1,s=r>>1^r,l=i>>1^n&a>>1^i,u=r&i>>1^a>>1^a;r=o,n=s,i=l,a=u,o=r&r>>2^n&n>>2,s=r&n>>2^n&(r^n)>>2,l^=r&i>>2^n&a>>2,u^=n&i>>2^(r^n)&a>>2,r=o,n=s,i=l,a=u,o=r&r>>4^n&n>>4,s=r&n>>4^n&(r^n)>>4,l^=r&i>>4^n&a>>4,u^=n&i>>4^(r^n)&a>>4,r=o,n=s,i=l,a=u,l^=r&i>>8^n&a>>8,u^=n&i>>8^(r^n)&a>>8,r=l^l>>1,n=u^u>>1;let c=t^e,h=n|65535^(c|r);return c=16711935&(c|c<<8),c=252645135&(c|c<<4),c=858993459&(c|c<<2),c=1431655765&(c|c<<1),h=16711935&(h|h<<8),h=252645135&(h|h<<4),h=858993459&(h|h<<2),h=1431655765&(h|h<<1),(h<<1|c)>>>0}const GA=rf(Object.freeze(Object.defineProperty({__proto__:null,default:kA},Symbol.toStringTag,{value:"Module"})));var jA;function VA(){if(jA)return LA;jA=1;var t=sf;Object.defineProperty(LA,"__esModule",{value:!0}),LA.default=void 0;var e=t(ux()),r=t(Ex()),n=t(GA),i=Ff,a=t(bM()),o=t(SM()),s=IM();function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=d)if(r)if(g===d){var v=p.extent.dimensions(),y=r.extent.dimensions();v.x=n;i--)if(1===(r=t.getTileRangeForExtentAndZ(e,i,r)).getWidth()&&1===r.getHeight())return[i,r.minX,r.minY];return null}(i,e);if(!o)return null;var s=r.getTile(o[0],o[1],o[2],1,n),l=a(i.getTileCoordExtent(o),n.getCode()),u=e.offsetToParent(l);return{extent:e,pitch:u,tile:s,tileExtent:l}}(t,n);return r&&r.extent&&r.extent.isInside(i.tileExtent)?null:i}};return HA.default=s,HA}var YA={};const ZA=rf(Ny);var KA={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},JA=[KA.FILL],QA=[KA.STROKE],$A=[KA.BEGIN_PATH],tP=[KA.CLOSE_PATH];const eP=KA;const rP=function(){function t(){}return t.prototype.drawCustom=function(t,e,r,n){},t.prototype.drawGeometry=function(t){},t.prototype.setStyle=function(t){},t.prototype.drawCircle=function(t,e){},t.prototype.drawFeature=function(t,e){},t.prototype.drawGeometryCollection=function(t,e){},t.prototype.drawLineString=function(t,e){},t.prototype.drawMultiLineString=function(t,e){},t.prototype.drawMultiPoint=function(t,e){},t.prototype.drawMultiPolygon=function(t,e){},t.prototype.drawPoint=function(t,e){},t.prototype.drawPolygon=function(t,e){},t.prototype.drawText=function(t,e){},t.prototype.setFillStrokeStyle=function(t,e){},t.prototype.setImageStyle=function(t,e){},t.prototype.setTextStyle=function(t,e){},t}();var nP=/^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i,iP=/^([a-z]*)$|^hsla?\(.*\)$/i;function aP(t){return"string"==typeof t?t:hP(t)}var oP,sP,lP=(oP={},sP=0,function(t){var e;if(oP.hasOwnProperty(t))e=oP[t];else{if(sP>=1024){var r=0;for(var n in oP)0==(3&r++)&&(delete oP[n],--sP)}e=function(t){var e,r,n,i,a;if(iP.exec(t)&&(t=function(t){var e=document.createElement("div");if(e.style.color=t,""!==e.style.color){document.body.appendChild(e);var r=getComputedStyle(e).color;return document.body.removeChild(e),r}return""}(t)),nP.exec(t)){var o=t.length-1,s=void 0;s=o<=4?1:2;var l=4===o||8===o;e=parseInt(t.substr(1+0*s,s),16),r=parseInt(t.substr(1+1*s,s),16),n=parseInt(t.substr(1+2*s,s),16),i=l?parseInt(t.substr(1+3*s,s),16):255,1==s&&(e=(e<<4)+e,r=(r<<4)+r,n=(n<<4)+n,l&&(i=(i<<4)+i)),a=[e,r,n,i/255]}else 0==t.indexOf("rgba(")?cP(a=t.slice(5,-1).split(",").map(Number)):0==t.indexOf("rgb(")?((a=t.slice(4,-1).split(",").map(Number)).push(1),cP(a)):ey(!1,14);return a}(t),oP[t]=e,++sP}return e});function uP(t){return Array.isArray(t)?t:lP(t)}function cP(t){return t[0]=gv(t[0]+.5|0,0,255),t[1]=gv(t[1]+.5|0,0,255),t[2]=gv(t[2]+.5|0,0,255),t[3]=gv(t[3],0,1),t}function hP(t){var e=t[0];e!=(0|e)&&(e=e+.5|0);var r=t[1];r!=(0|r)&&(r=r+.5|0);var n=t[2];return n!=(0|n)&&(n=n+.5|0),"rgba("+e+","+r+","+n+","+(void 0===t[3]?1:Math.round(100*t[3])/100)+")"}function dP(t){return Array.isArray(t)?hP(t):t}var fP=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))","?\\s*([-,\\\"\\'\\sa-z]+?)\\s*$"].join(""),"i"),pP=["style","variant","weight","size","lineHeight","family"],mP=function(t){var e=t.match(fP);if(!e)return null;for(var r={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"},n=0,i=pP.length;nh&&(this.instructions.push([eP.CUSTOM,h,a,t,r,kP]),this.hitDetectionInstructions.push([eP.CUSTOM,h,a,t,n||r,kP]));break;case"Point":i=t.getFlatCoordinates(),this.coordinates.push(i[0],i[1]),a=this.coordinates.length,this.instructions.push([eP.CUSTOM,h,a,t,r]),this.hitDetectionInstructions.push([eP.CUSTOM,h,a,t,n||r])}this.endGeometry(e)},e.prototype.beginGeometry=function(t,e){this.beginGeometryInstruction1_=[eP.BEGIN_GEOMETRY,e,0,t],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[eP.BEGIN_GEOMETRY,e,0,t],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)},e.prototype.finish=function(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}},e.prototype.reverseHitDetectionInstructions=function(){var t,e=this.hitDetectionInstructions;e.reverse();var r,n,i=e.length,a=-1;for(t=0;tthis.maxLineWidth&&(this.maxLineWidth=r.lineWidth,this.bufferedMaxExtent_=null)}else r.strokeStyle=void 0,r.lineCap=void 0,r.lineDash=null,r.lineDashOffset=void 0,r.lineJoin=void 0,r.lineWidth=void 0,r.miterLimit=void 0},e.prototype.createFill=function(t){var e=t.fillStyle,r=[eP.SET_FILL_STYLE,e];return"string"!=typeof e&&r.push(!0),r},e.prototype.applyStroke=function(t){this.instructions.push(this.createStroke(t))},e.prototype.createStroke=function(t){return[eP.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]},e.prototype.updateFillStyle=function(t,e){var r=t.fillStyle;"string"==typeof r&&t.currentFillStyle==r||(void 0!==r&&this.instructions.push(e.call(this,t)),t.currentFillStyle=r)},e.prototype.updateStrokeStyle=function(t,e){var r=t.strokeStyle,n=t.lineCap,i=t.lineDash,a=t.lineDashOffset,o=t.lineJoin,s=t.lineWidth,l=t.miterLimit;(t.currentStrokeStyle!=r||t.currentLineCap!=n||i!=t.currentLineDash&&!Nx(t.currentLineDash,i)||t.currentLineDashOffset!=a||t.currentLineJoin!=o||t.currentLineWidth!=s||t.currentMiterLimit!=l)&&(void 0!==r&&e.call(this,t),t.currentStrokeStyle=r,t.currentLineCap=n,t.currentLineDash=i,t.currentLineDashOffset=a,t.currentLineJoin=o,t.currentLineWidth=s,t.currentMiterLimit=l)},e.prototype.endGeometry=function(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;var e=[eP.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)},e.prototype.getBufferedMaxExtent=function(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=iy(this.maxExtent),this.maxLineWidth>0)){var t=this.resolution*(this.maxLineWidth+1)/2;ny(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_},e}(rP);var zP=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const GP=function(t){function e(e,r,n,i){var a=t.call(this,e,r,n,i)||this;return a.hitDetectionImage_=null,a.image_=null,a.imagePixelRatio_=void 0,a.anchorX_=void 0,a.anchorY_=void 0,a.height_=void 0,a.opacity_=void 0,a.originX_=void 0,a.originY_=void 0,a.rotateWithView_=void 0,a.rotation_=void 0,a.scale_=void 0,a.width_=void 0,a.declutterMode_=void 0,a.declutterImageWithText_=void 0,a}return zP(e,t),e.prototype.drawPoint=function(t,e){if(this.image_){this.beginGeometry(t,e);var r=t.getFlatCoordinates(),n=t.getStride(),i=this.coordinates.length,a=this.appendFlatPointCoordinates(r,n);this.instructions.push([eP.DRAW_IMAGE,i,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([eP.DRAW_IMAGE,i,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,this.opacity_,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}},e.prototype.drawMultiPoint=function(t,e){if(this.image_){this.beginGeometry(t,e);var r=t.getFlatCoordinates(),n=t.getStride(),i=this.coordinates.length,a=this.appendFlatPointCoordinates(r,n);this.instructions.push([eP.DRAW_IMAGE,i,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([eP.DRAW_IMAGE,i,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,this.opacity_,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}},e.prototype.finish=function(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,t.prototype.finish.call(this)},e.prototype.setImageStyle=function(t,e){var r=t.getAnchor(),n=t.getSize(),i=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=r[0],this.anchorY_=r[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=n[1],this.opacity_=t.getOpacity(),this.originX_=i[0],this.originY_=i[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=n[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e},e}(BP);var jP=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();const VP=function(t){function e(e,r,n,i){return t.call(this,e,r,n,i)||this}return jP(e,t),e.prototype.drawFlatCoordinates_=function(t,e,r,n){var i=this.coordinates.length,a=this.appendFlatLineCoordinates(t,e,r,n,!1,!1),o=[eP.MOVE_TO_LINE_TO,i,a];return this.instructions.push(o),this.hitDetectionInstructions.push(o),r},e.prototype.drawLineString=function(t,e){var r=this.state,n=r.strokeStyle,i=r.lineWidth;if(void 0!==n&&void 0!==i){this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([eP.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,yP,0],$A);var a=t.getFlatCoordinates(),o=t.getStride();this.drawFlatCoordinates_(a,0,a.length,o),this.hitDetectionInstructions.push(QA),this.endGeometry(e)}},e.prototype.drawMultiLineString=function(t,e){var r=this.state,n=r.strokeStyle,i=r.lineWidth;if(void 0!==n&&void 0!==i){this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([eP.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,r.lineDash,r.lineDashOffset],$A);for(var a=t.getEnds(),o=t.getFlatCoordinates(),s=t.getStride(),l=0,u=0,c=a.length;ut&&(v>g&&(g=v,p=y,m=a),v=0,y=a-i)),o=s,c=d,h=f),l=x,u=_}return(v+=s)>g?[y,a]:[p,m]}var KP=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),JP={left:0,end:0,center:.5,right:1,start:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};var QP={Circle:qP,Default:BP,Image:GP,LineString:VP,Polygon:qP,Text:function(t){function e(e,r,n,i){var a=t.call(this,e,r,n,i)||this;return a.labels_=null,a.text_="",a.textOffsetX_=0,a.textOffsetY_=0,a.textRotateWithView_=void 0,a.textRotation_=0,a.textFillState_=null,a.fillStates={},a.textStrokeState_=null,a.strokeStates={},a.textState_={},a.textStates={},a.textKey_="",a.fillKey_="",a.strokeKey_="",a.declutterImageWithText_=void 0,a}return KP(e,t),e.prototype.finish=function(){var e=t.prototype.finish.call(this);return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e},e.prototype.drawText=function(t,e){var r=this.textFillState_,n=this.textStrokeState_,i=this.textState_;if(""!==this.text_&&i&&(r||n)){var a=this.coordinates,o=a.length,s=t.getType(),l=null,u=t.getStride();if(i.placement!==YP||"LineString"!=s&&"MultiLineString"!=s&&"Polygon"!=s&&"MultiPolygon"!=s){var c=i.overflow?null:[];switch(s){case"Point":case"MultiPoint":l=t.getFlatCoordinates();break;case"LineString":l=t.getFlatMidpoint();break;case"Circle":l=t.getCenter();break;case"MultiLineString":l=t.getFlatMidpoints(),u=2;break;case"Polygon":l=t.getFlatInteriorPoint(),i.overflow||c.push(l[2]/this.resolution),u=3;break;case"MultiPolygon":var h=t.getFlatInteriorPoints();l=[];for(b=0,M=h.length;bP[2]}else T=_>E;var R,C=Math.PI,I=[],L=b+n===e;if(g=0,v=M,d=t[e=b],f=t[e+1],L){y(),R=Math.atan2(f-m,d-p),T&&(R+=R>0?-C:C);var O=(E+_)/2,D=(A+w)/2;return I[0]=[O,D,(S-a)/2,R,i],I}for(var k=0,F=(i=i.replace(/\n/g," ")).length;k0?-C:C),void 0!==R){var U=N-R;if(U+=U>C?-2*C:U<-C?2*C:0,Math.abs(U)>o)return null}R=N;for(var B=k,z=0;k0&&t.push("\n",""),t.push(e,""),t}const TR=function(){function t(t,e,r,n){this.overlaps=r,this.pixelRatio=e,this.resolution=t,this.alignFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=[1,0,0,1,0,0],this.hitDetectionInstructions=n.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=n.fillStates||{},this.strokeStates=n.strokeStates||{},this.textStates=n.textStates||{},this.widths_={},this.labels_={}}return t.prototype.createLabel=function(t,e,r,n){var i=t+e+r+n;if(this.labels_[i])return this.labels_[i];var a=n?this.strokeStates[n]:null,o=r?this.fillStates[r]:null,s=this.textStates[e],l=this.pixelRatio,u=[s.scale[0]*l,s.scale[1]*l],c=Array.isArray(t),h=s.justify?JP[s.justify]:MR(Array.isArray(t)?t[0]:t,s.textAlign||wP),d=n&&a.lineWidth?a.lineWidth:0,f=c?t:t.split("\n").reduce(SR,[]),p=function(t,e){for(var r=[],n=[],i=[],a=0,o=0,s=0,l=0,u=0,c=e.length;u<=c;u+=2){var h=e[u];if("\n"!==h&&u!==c){var d=e[u+1]||t.font,f=LP(d,h);r.push(f),o+=f;var p=CP(d);n.push(p),l=Math.max(l,p)}else a=Math.max(a,o),i.push(o),o=0,s+=l}return{width:a,height:s,widths:r,heights:n,lineWidths:i}}(s,f),m=p.width,g=p.height,v=p.widths,y=p.heights,x=p.lineWidths,_=m+d,w=[],b=(_+2)*u[0],M=(g+d)*u[1],S={width:b<0?Math.floor(b):Math.ceil(b),height:M<0?Math.floor(M):Math.ceil(M),contextInstructions:w};(1==u[0]&&1==u[1]||w.push("scale",u),n)&&(w.push("strokeStyle",a.strokeStyle),w.push("lineWidth",d),w.push("lineCap",a.lineCap),w.push("lineJoin",a.lineJoin),w.push("miterLimit",a.miterLimit),(Xx?OffscreenCanvasRenderingContext2D:CanvasRenderingContext2D).prototype.setLineDash&&(w.push("setLineDash",[a.lineDash]),w.push("lineDashOffset",a.lineDashOffset)));r&&w.push("fillStyle",o.fillStyle),w.push("textBaseline","middle"),w.push("textAlign","center");for(var T,E=.5-h,A=h*_+E*d,P=[],R=[],C=0,I=0,L=0,O=0,D=0,k=f.length;Dt?t-l:i,_=a+u>e?e-u:a,w=f[3]+x*h[0]+f[1],b=f[0]+_*h[1]+f[2],M=v-f[3],S=y-f[0];return(p||0!==c)&&(vR[0]=M,_R[0]=M,vR[1]=S,yR[1]=S,yR[0]=M+w,xR[0]=yR[0],xR[1]=S+b,_R[1]=xR[1]),0!==c?(sR(g=lR([1,0,0,1,0,0],r,n,1,1,c,-r,-n),vR),sR(g,yR),sR(g,xR),sR(g,_R),cy(Math.min(vR[0],yR[0],xR[0],_R[0]),Math.min(vR[1],yR[1],xR[1],_R[1]),Math.max(vR[0],yR[0],xR[0],_R[0]),Math.max(vR[1],yR[1],xR[1],_R[1]),gR)):cy(Math.min(M,M+w),Math.min(S,S+b),Math.max(M,M+w),Math.max(S,S+b),gR),d&&(v=Math.round(v),y=Math.round(y)),{drawImageX:v,drawImageY:y,drawImageW:x,drawImageH:_,originX:l,originY:u,declutterBox:{minX:gR[0],minY:gR[1],maxX:gR[2],maxY:gR[3],value:m},canvasTransform:g,scale:h}},t.prototype.replayImageOrLabel_=function(t,e,r,n,i,a,o){var s=!(!a&&!o),l=n.declutterBox,u=t.canvas,c=o?o[2]*n.scale[0]/2:0;return l.minX-c<=u.width/e&&l.maxX+c>=0&&l.minY-c<=u.height/e&&l.maxY+c>=0&&(s&&this.replayTextBackground_(t,vR,yR,xR,_R,a,o),DP(t,n.canvasTransform,i,r,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0},t.prototype.fill_=function(t){if(this.alignFill_){var e=sR(this.renderedTransform_,[0,0]),r=512*this.pixelRatio;t.save(),t.translate(e[0]%r,e[1]%r),t.rotate(this.viewRotation_)}t.fill(),this.alignFill_&&t.restore()},t.prototype.setStrokeStyle_=function(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.setLineDash&&(t.lineDashOffset=e[7],t.setLineDash(e[6]))},t.prototype.drawLabelWithPointPlacement_=function(t,e,r,n){var i=this.textStates[e],a=this.createLabel(t,e,n,r),o=this.strokeStates[r],s=this.pixelRatio,l=MR(Array.isArray(t)?t[0]:t,i.textAlign||wP),u=JP[i.textBaseline||bP],c=o&&o.lineWidth?o.lineWidth:0;return{label:a,anchorX:l*(a.width/s-2*i.scale[0])+2*(.5-l)*c,anchorY:u*a.height/s+2*(.5-u)*c}},t.prototype.execute_=function(t,e,r,n,i,a,o,s){var l;this.pixelCoordinates_&&Nx(r,this.renderedTransform_)?l=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),l=fR(this.coordinates,0,this.coordinates.length,2,r,this.pixelCoordinates_),oR(this.renderedTransform_,r));for(var u,c,h,d,f,p,m,g,v,y,x,_,w,b,M,S,T=0,E=n.length,A=0,P=0,R=0,C=null,I=null,L=this.coordinateCache_,O=this.viewRotation_,D=Math.round(1e12*Math.atan2(-r[1],r[0]))/1e12,k={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:O},F=this.instructions!=n||this.overlaps?0:200;TF&&(this.fill_(t),P=0),R>F&&(t.stroke(),R=0),P||R||(t.beginPath(),d=NaN,f=NaN),++T;break;case eP.CIRCLE:var U=l[A=N[1]],B=l[A+1],z=l[A+2]-U,G=l[A+3]-B,j=Math.sqrt(z*z+G*G);t.moveTo(U+j,B),t.arc(U,B,j,0,2*Math.PI,!0),++T;break;case eP.CLOSE_PATH:t.closePath(),++T;break;case eP.CUSTOM:A=N[1],u=N[2];var V=N[3],H=N[4],W=6==N.length?N[5]:void 0;k.geometry=V,k.feature=w,T in L||(L[T]=[]);var q=L[T];W?W(l,A,u,2,q):(q[0]=l[A],q[1]=l[A+1],q.length=2),H(q,k),++T;break;case eP.DRAW_IMAGE:A=N[1],u=N[2],g=N[3],c=N[4],h=N[5];var X=N[6],Y=N[7],Z=N[8],K=N[9],J=N[10],Q=N[11],$=N[12],tt=N[13],et=N[14],rt=N[15];if(!g&&N.length>=20){v=N[19],y=N[20],x=N[21],_=N[22];var nt=this.drawLabelWithPointPlacement_(v,y,x,_);g=nt.label,N[3]=g;var it=N[23];c=(nt.anchorX-it)*this.pixelRatio,N[4]=c;var at=N[24];h=(nt.anchorY-at)*this.pixelRatio,N[5]=h,X=g.height,N[6]=X,tt=g.width,N[13]=tt}var ot=void 0;N.length>25&&(ot=N[25]);var st=void 0,lt=void 0,ut=void 0;N.length>17?(st=N[16],lt=N[17],ut=N[18]):(st=MP,lt=!1,ut=!1),J&&D?Q+=O:J||D||(Q-=O);for(var ct=0;A0){if(!a||"Image"!==h&&"Text"!==h||-1!==a.indexOf(t)){var u=(d[s]-3)/4,f=n-u%o,p=n-(u/o|0),m=i(t,e,f*f+p*p);if(m)return m}c.clearRect(0,0,o,o);break}}var p,m,g,v,y,x=Object.keys(this.executorsByZIndex_).map(Number);for(x.sort(kx),p=x.length-1;p>=0;--p){var _=x[p].toString();for(g=this.executorsByZIndex_[_],m=ER.length-1;m>=0;--m)if(void 0!==(v=g[h=ER[m]])&&(y=v.executeHitDetection(c,s,r,f,u)))return y}},t.prototype.getClipCoords=function(t){var e=this.maxExtent_;if(!e)return null;var r=e[0],n=e[1],i=e[2],a=e[3],o=[r,n,r,a,i,a,i,n];return fR(o,0,8,2,t,o),o},t.prototype.isEmpty=function(){return Wv(this.executorsByZIndex_)},t.prototype.execute=function(t,e,r,n,i,a,o){var s=Object.keys(this.executorsByZIndex_).map(Number);s.sort(kx),this.maxExtent_&&(t.save(),this.clip(t,r));var l,u,c,h,d,f,p=a||ER;for(o&&s.reverse(),l=0,u=s.length;lr)break;var s=n[o];s||(s=[],n[o]=s),s.push(4*((t+i)*e+(t+a))+3),i>0&&s.push(4*((t-i)*e+(t+a))+3),a>0&&(s.push(4*((t+i)*e+(t-a))+3),i>0&&s.push(4*((t-i)*e+(t-a))+3))}for(var l=[],u=(i=0,n.length);ithis.maxCacheSize_},t.prototype.expire=function(){if(this.canExpireCache()){var t=0;for(var e in this.cache_){var r=this.cache_[e];0!=(3&t++)||r.hasListener()||(delete this.cache_[e],--this.cacheSize_)}}},t.prototype.get=function(t,e,r){var n=XR(t,e,r);return n in this.cache_?this.cache_[n]:null},t.prototype.set=function(t,e,r,n){var i=XR(t,e,r);this.cache_[i]=n,++this.cacheSize_},t.prototype.setSize=function(t){this.maxCacheSize_=t,this.expire()},t}()),ZR=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),KR=null,JR=function(t){function e(e,r,n,i,a,o){var s=t.call(this)||this;return s.hitDetectionImage_=null,s.image_=e||new Image,null!==i&&(s.image_.crossOrigin=i),s.canvas_={},s.color_=o,s.unlisten_=null,s.imageState_=a,s.size_=n,s.src_=r,s.tainted_,s}return ZR(e,t),e.prototype.isTainted_=function(){if(void 0===this.tainted_&&this.imageState_===e_){KR||(KR=Zx(1,1)),KR.drawImage(this.image_,0,0);try{KR.getImageData(0,0,1,1),this.tainted_=!1}catch(t){KR=null,this.tainted_=!0}}return!0===this.tainted_},e.prototype.dispatchChangeEvent_=function(){this.dispatchEvent(Cx)},e.prototype.handleImageError_=function(){this.imageState_=r_,this.unlistenImage_(),this.dispatchChangeEvent_()},e.prototype.handleImageLoad_=function(){this.imageState_=e_,this.size_?(this.image_.width=this.size_[0],this.image_.height=this.size_[1]):this.size_=[this.image_.width,this.image_.height],this.unlistenImage_(),this.dispatchChangeEvent_()},e.prototype.getImage=function(t){return this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_},e.prototype.getPixelRatio=function(t){return this.replaceColor_(t),this.canvas_[t]?t:1},e.prototype.getImageState=function(){return this.imageState_},e.prototype.getHitDetectionImage=function(){if(!this.hitDetectionImage_)if(this.isTainted_()){var t=this.size_[0],e=this.size_[1],r=Zx(t,e);r.fillRect(0,0,t,e),this.hitDetectionImage_=r.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_},e.prototype.getSize=function(){return this.size_},e.prototype.getSrc=function(){return this.src_},e.prototype.load=function(){if(this.imageState_==$x){this.imageState_=t_;try{this.image_.src=this.src_}catch(t){this.handleImageError_()}this.unlisten_=l_(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this))}},e.prototype.replaceColor_=function(t){if(this.color_&&!this.canvas_[t]&&this.imageState_===e_){var e=document.createElement("canvas");this.canvas_[t]=e,e.width=Math.ceil(this.image_.width*t),e.height=Math.ceil(this.image_.height*t);var r=e.getContext("2d");if(r.scale(t,t),r.drawImage(this.image_,0,0),r.globalCompositeOperation="multiply","multiply"===r.globalCompositeOperation||this.isTainted_())r.fillStyle=aP(this.color_),r.fillRect(0,0,e.width/t,e.height/t),r.globalCompositeOperation="destination-in",r.drawImage(this.image_,0,0);else{for(var n=r.getImageData(0,0,e.width,e.height),i=n.data,a=this.color_[0]/255,o=this.color_[1]/255,s=this.color_[2]/255,l=this.color_[3],u=0,c=i.length;u0,6);var c=void 0!==n.src?$x:e_;return r.color_=void 0!==n.color?uP(n.color):null,r.iconImage_=function(t,e,r,n,i,a){var o=YR.get(e,n,a);return o||(o=new JR(t,e,r,n,i,a),YR.set(e,n,a,o)),o}(l,u,void 0!==r.imgSize_?r.imgSize_:null,r.crossOrigin_,c,r.color_),r.offset_=void 0!==n.offset?n.offset:[0,0],r.offsetOrigin_=void 0!==n.offsetOrigin?n.offsetOrigin:WR,r.origin_=null,r.size_=void 0!==n.size?n.size:null,r}return $R(e,t),e.prototype.clone=function(){var t=this.getScale();return new e({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,imgSize:this.imgSize_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:Array.isArray(t)?t.slice():t,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})},e.prototype.getAnchor=function(){var t=this.normalizedAnchor_;if(!t){t=this.anchor_;var e=this.getSize();if(this.anchorXUnits_==jR||this.anchorYUnits_==jR){if(!e)return null;t=this.anchor_.slice(),this.anchorXUnits_==jR&&(t[0]*=e[0]),this.anchorYUnits_==jR&&(t[1]*=e[1])}if(this.anchorOrigin_!=WR){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),this.anchorOrigin_!=qR&&this.anchorOrigin_!=HR||(t[0]=-t[0]+e[0]),this.anchorOrigin_!=VR&&this.anchorOrigin_!=HR||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}var r=this.getDisplacement();return[t[0]-r[0],t[1]+r[1]]},e.prototype.setAnchor=function(t){this.anchor_=t,this.normalizedAnchor_=null},e.prototype.getColor=function(){return this.color_},e.prototype.getImage=function(t){return this.iconImage_.getImage(t)},e.prototype.getPixelRatio=function(t){return this.iconImage_.getPixelRatio(t)},e.prototype.getImageSize=function(){return this.iconImage_.getSize()},e.prototype.getImageState=function(){return this.iconImage_.getImageState()},e.prototype.getHitDetectionImage=function(){return this.iconImage_.getHitDetectionImage()},e.prototype.getOrigin=function(){if(this.origin_)return this.origin_;var t=this.offset_;if(this.offsetOrigin_!=WR){var e=this.getSize(),r=this.iconImage_.getSize();if(!e||!r)return null;t=t.slice(),this.offsetOrigin_!=qR&&this.offsetOrigin_!=HR||(t[0]=r[0]-e[0]-t[0]),this.offsetOrigin_!=VR&&this.offsetOrigin_!=HR||(t[1]=r[1]-e[1]-t[1])}return this.origin_=t,this.origin_},e.prototype.getSrc=function(){return this.iconImage_.getSrc()},e.prototype.getSize=function(){return this.size_?this.size_:this.iconImage_.getSize()},e.prototype.listenImageChange=function(t){this.iconImage_.addEventListener(Cx,t)},e.prototype.load=function(){this.iconImage_.load()},e.prototype.unlistenImageChange=function(t){this.iconImage_.removeEventListener(Cx,t)},e}(FR);const eC=function(){function t(t){var e=t||{};this.color_=void 0!==e.color?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=void 0!==e.lineDash?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}return t.prototype.clone=function(){var e=this.getColor();return new t({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})},t.prototype.getColor=function(){return this.color_},t.prototype.getLineCap=function(){return this.lineCap_},t.prototype.getLineDash=function(){return this.lineDash_},t.prototype.getLineDashOffset=function(){return this.lineDashOffset_},t.prototype.getLineJoin=function(){return this.lineJoin_},t.prototype.getMiterLimit=function(){return this.miterLimit_},t.prototype.getWidth=function(){return this.width_},t.prototype.setColor=function(t){this.color_=t},t.prototype.setLineCap=function(t){this.lineCap_=t},t.prototype.setLineDash=function(t){this.lineDash_=t},t.prototype.setLineDashOffset=function(t){this.lineDashOffset_=t},t.prototype.setLineJoin=function(t){this.lineJoin_=t},t.prototype.setMiterLimit=function(t){this.miterLimit_=t},t.prototype.setWidth=function(t){this.width_=t},t}();function rC(t){return t.getGeometry()}const nC=function(){function t(t){var e=t||{};this.geometry_=null,this.geometryFunction_=rC,void 0!==e.geometry&&this.setGeometry(e.geometry),this.fill_=void 0!==e.fill?e.fill:null,this.image_=void 0!==e.image?e.image:null,this.renderer_=void 0!==e.renderer?e.renderer:null,this.hitDetectionRenderer_=void 0!==e.hitDetectionRenderer?e.hitDetectionRenderer:null,this.stroke_=void 0!==e.stroke?e.stroke:null,this.text_=void 0!==e.text?e.text:null,this.zIndex_=e.zIndex}return t.prototype.clone=function(){var e=this.getGeometry();return e&&"object"==typeof e&&(e=e.clone()),new t({geometry:e,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer(),stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})},t.prototype.getRenderer=function(){return this.renderer_},t.prototype.setRenderer=function(t){this.renderer_=t},t.prototype.setHitDetectionRenderer=function(t){this.hitDetectionRenderer_=t},t.prototype.getHitDetectionRenderer=function(){return this.hitDetectionRenderer_},t.prototype.getGeometry=function(){return this.geometry_},t.prototype.getGeometryFunction=function(){return this.geometryFunction_},t.prototype.getFill=function(){return this.fill_},t.prototype.setFill=function(t){this.fill_=t},t.prototype.getImage=function(){return this.image_},t.prototype.setImage=function(t){this.image_=t},t.prototype.getStroke=function(){return this.stroke_},t.prototype.setStroke=function(t){this.stroke_=t},t.prototype.getText=function(){return this.text_},t.prototype.setText=function(t){this.text_=t},t.prototype.getZIndex=function(){return this.zIndex_},t.prototype.setGeometry=function(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=rC,this.geometry_=t},t.prototype.setZIndex=function(t){this.zIndex_=t},t}();const iC=function(){function t(t){var e=t||{};this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.scale_=e.scale,this.scaleArray_=J_(void 0!==e.scale?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.textBaseline_=e.textBaseline,this.fill_=void 0!==e.fill?e.fill:new GR({color:"#333"}),this.maxAngle_=void 0!==e.maxAngle?e.maxAngle:Math.PI/4,this.placement_=void 0!==e.placement?e.placement:XP,this.overflow_=!!e.overflow,this.stroke_=void 0!==e.stroke?e.stroke:null,this.offsetX_=void 0!==e.offsetX?e.offsetX:0,this.offsetY_=void 0!==e.offsetY?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=void 0===e.padding?null:e.padding}return t.prototype.clone=function(){var e=this.getScale();return new t({font:this.getFont(),placement:this.getPlacement(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0})},t.prototype.getOverflow=function(){return this.overflow_},t.prototype.getFont=function(){return this.font_},t.prototype.getMaxAngle=function(){return this.maxAngle_},t.prototype.getPlacement=function(){return this.placement_},t.prototype.getOffsetX=function(){return this.offsetX_},t.prototype.getOffsetY=function(){return this.offsetY_},t.prototype.getFill=function(){return this.fill_},t.prototype.getRotateWithView=function(){return this.rotateWithView_},t.prototype.getRotation=function(){return this.rotation_},t.prototype.getScale=function(){return this.scale_},t.prototype.getScaleArray=function(){return this.scaleArray_},t.prototype.getStroke=function(){return this.stroke_},t.prototype.getText=function(){return this.text_},t.prototype.getTextAlign=function(){return this.textAlign_},t.prototype.getJustify=function(){return this.justify_},t.prototype.getTextBaseline=function(){return this.textBaseline_},t.prototype.getBackgroundFill=function(){return this.backgroundFill_},t.prototype.getBackgroundStroke=function(){return this.backgroundStroke_},t.prototype.getPadding=function(){return this.padding_},t.prototype.setOverflow=function(t){this.overflow_=t},t.prototype.setFont=function(t){this.font_=t},t.prototype.setMaxAngle=function(t){this.maxAngle_=t},t.prototype.setOffsetX=function(t){this.offsetX_=t},t.prototype.setOffsetY=function(t){this.offsetY_=t},t.prototype.setPlacement=function(t){this.placement_=t},t.prototype.setRotateWithView=function(t){this.rotateWithView_=t},t.prototype.setFill=function(t){this.fill_=t},t.prototype.setRotation=function(t){this.rotation_=t},t.prototype.setScale=function(t){this.scale_=t,this.scaleArray_=J_(void 0!==t?t:1)},t.prototype.setStroke=function(t){this.stroke_=t},t.prototype.setText=function(t){this.text_=t},t.prototype.setTextAlign=function(t){this.textAlign_=t},t.prototype.setJustify=function(t){this.justify_=t},t.prototype.setTextBaseline=function(t){this.textBaseline_=t},t.prototype.setBackgroundFill=function(t){this.backgroundFill_=t},t.prototype.setBackgroundStroke=function(t){this.backgroundStroke_=t},t.prototype.setPadding=function(t){this.padding_=t},t}(),aC=rf(Object.freeze(Object.defineProperty({__proto__:null,Circle:zR,Fill:GR,Icon:tC,IconImage:QR,Image:FR,RegularShape:UR,Stroke:eC,Style:nC,Text:iC},Symbol.toStringTag,{value:"Module"}))),oC=rf(dR);var sC;function lC(){if(sC)return YA;sC=1;var t=sf;Object.defineProperty(YA,"__esModule",{value:!0}),YA.default=void 0;var e=Ff,r=t(oS),n=WA,i=ZA,a=t(tR),o=t(CR),s=kR,l=aC,u=oC,c=t(bM()),h=(0,u.create)(),d=new e.Texture;function f(){var t=this;this.storage={},this.contains=function(e){return e in t.storage}}function p(t,e){return new c.default(e,t[0],t[2],t[1],t[3])}function m(t,n,l){if(!t.material)return null;var c=t.material.canvas,d=new e.CanvasTexture(c);d.premultiplyAlpha=l.transparent,d.extent=n.tileExtent;var f=function(t,e){var n=this,l=t.getReplayState(e),u=e.source,c=u.getTileGrid(),h=u.getProjection(),d=u.getTileGridForProjection(h),f=d.getResolution(t.tileCoord[0]),p=d.getTileCoordExtent(t.wrappedTileCoord),m=1,v=(0,i.createEmpty)(),y=!0;t.executorGroups[e.ol_uid]=[];for(var x=u.getSourceTiles(m,h,t),_=function(h,d){var _=x[h];if(_.getState()!==r.default.LOADED)return console.warn("not loaded !!!",_),"continue";for(var w=_.tileCoord,b=c.getTileCoordExtent(w),M=(0,i.getIntersection)(p,b),S=100,T=(0,i.buffer)(M,S*f,v),E=(0,i.equals)(b,M)?null:T,A=new a.default(0,T,f,m),P=(0,s.getSquaredTolerance)(f,m),R=function(t){var r,n=t.getStyleFunction()||e.getStyleFunction();if(n&&(r=n(t,f)),r){var i=function(t,e,r,n){if(!r)return!1;var i=!1;if(Array.isArray(r))for(var a=0,o=r.length;a=n;i--)if(1===(r=t.getTileRangeForExtentAndZ(e,i,r)).getWidth()&&1===r.getHeight())return[i,r.minX,r.minY];return null}(i,e);if(!a)return null;var o=r.getTile(a[0],a[1],a[2],1,n),s=o.tileCoord[0].toString();s in t.usedTiles||(t.usedTiles[s]=new f);t.usedTiles[s].storage[o.tileCoord]=o;var l=p(i.getTileCoordExtent(a),n.getCode()),u=t.extent.dimensions(),c=u.y/u.x;l._values[3]=l._values[2]+l.dimensions().x*c;var h=e.offsetToParent(l);return{extent:e,pitch:h,tile:o,tileExtent:l}}(t,n);return r&&r.extent&&r.extent.isInside(i.tileExtent)||r===d?null:i}};return YA.default=v,YA}var uC,cC={};function hC(){if(uC)return cC;uC=1;var t=sf;Object.defineProperty(cC,"__esModule",{value:!0}),cC.default=void 0;var e=Ff,r=t(tR),n=t(CR),i=kR,a=aC,o=oC,s=t(bM());function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(s&&l){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(gC)),gC.exports}var yC,xC={exports:{}};var _C,wC,bC,MC={},SC={},TC={},EC={},AC={},PC={},RC={};function CC(){if(_C)return RC;_C=1,Object.defineProperty(RC,"__esModule",{value:!0});RC.THIS_IS_NOT_AN_OBJECT="This is not an object";RC.THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT="This is not a Float16Array object";RC.THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY="This constructor is not a subclass of Float16Array";RC.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT="The constructor property value is not an object";RC.SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT="Species constructor didn't return TypedArray object";RC.DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH="Derived constructor created TypedArray object which was too small length";RC.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER="Attempting to access detached ArrayBuffer";RC.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT="Cannot convert undefined or null to object";RC.CANNOT_MIX_BIGINT_AND_OTHER_TYPES="Cannot mix BigInt and other types, use explicit conversions";RC.ITERATOR_PROPERTY_IS_NOT_CALLABLE="@@iterator property is not callable";RC.REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE="Reduce of empty array with no initial value";RC.THE_COMPARISON_FUNCTION_MUST_BE_EITHER_A_FUNCTION_OR_UNDEFINED="The comparison function must be either a function or undefined";return RC.OFFSET_IS_OUT_OF_BOUNDS="Offset is out of bounds",RC}function IC(){if(wC)return PC;wC=1,Object.defineProperty(PC,"__esModule",{value:!0});var t=CC();function e(t){return(e,...r)=>n(t,e,r)}function r(t,r){return e(s(t,r).get)}const{apply:n,construct:i,defineProperty:a,get:o,getOwnPropertyDescriptor:s,getPrototypeOf:l,has:u,ownKeys:c,set:h,setPrototypeOf:d}=Reflect;PC.ReflectSetPrototypeOf=d,PC.ReflectSet=h,PC.ReflectOwnKeys=c,PC.ReflectHas=u,PC.ReflectGetPrototypeOf=l,PC.ReflectGetOwnPropertyDescriptor=s,PC.ReflectGet=o,PC.ReflectDefineProperty=a,PC.ReflectConstruct=i,PC.ReflectApply=n;const f=Proxy;PC.NativeProxy=f;const{MAX_SAFE_INTEGER:p,isFinite:m,isNaN:g}=Number;PC.NumberIsNaN=g,PC.NumberIsFinite=m,PC.MAX_SAFE_INTEGER=p;const{iterator:v,species:y,toStringTag:x,for:_}=Symbol;PC.SymbolFor=_,PC.SymbolToStringTag=x,PC.SymbolSpecies=y,PC.SymbolIterator=v;const w=Object;PC.NativeObject=w;const{create:b,defineProperty:M,freeze:S,is:T}=w;PC.ObjectIs=T,PC.ObjectFreeze=S,PC.ObjectDefineProperty=M,PC.ObjectCreate=b;const E=w.prototype,A=E.__lookupGetter__?e(E.__lookupGetter__):(e,r)=>{if(null==e)throw xt(t.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT);let n=w(e);do{const t=s(n,r);if(void 0!==t)return P(t,"get")?t.get:void 0}while(null!==(n=l(n)))};PC.ObjectPrototype__lookupGetter__=A;const P=w.hasOwn||e(E.hasOwnProperty);PC.ObjectHasOwn=P;const R=Array,C=R.isArray;PC.ArrayIsArray=C;const I=R.prototype,L=e(I.join);PC.ArrayPrototypeJoin=L;const O=e(I.push);PC.ArrayPrototypePush=O;const D=e(I.toLocaleString);PC.ArrayPrototypeToLocaleString=D;const k=I[v];PC.NativeArrayPrototypeSymbolIterator=k;const F=e(k);PC.ArrayPrototypeSymbolIterator=F;const N=Math.trunc;PC.MathTrunc=N;const U=ArrayBuffer;PC.NativeArrayBuffer=U;const B=U.isView;PC.ArrayBufferIsView=B;const z=U.prototype,G=e(z.slice);PC.ArrayBufferPrototypeSlice=G;const j=r(z,"byteLength");PC.ArrayBufferPrototypeGetByteLength=j;const V="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:null;PC.NativeSharedArrayBuffer=V;const H=V&&r(V.prototype,"byteLength");PC.SharedArrayBufferPrototypeGetByteLength=H;const W=l(Uint8Array);PC.TypedArray=W;const q=W.from,X=W.prototype;PC.TypedArrayPrototype=X;const Y=X[v];PC.NativeTypedArrayPrototypeSymbolIterator=Y;const Z=e(X.keys);PC.TypedArrayPrototypeKeys=Z;const K=e(X.values);PC.TypedArrayPrototypeValues=K;const J=e(X.entries);PC.TypedArrayPrototypeEntries=J;const Q=e(X.set);PC.TypedArrayPrototypeSet=Q;const $=e(X.reverse);PC.TypedArrayPrototypeReverse=$;const tt=e(X.fill);PC.TypedArrayPrototypeFill=tt;const et=e(X.copyWithin);PC.TypedArrayPrototypeCopyWithin=et;const rt=e(X.sort);PC.TypedArrayPrototypeSort=rt;const nt=e(X.slice);PC.TypedArrayPrototypeSlice=nt;const it=e(X.subarray);PC.TypedArrayPrototypeSubarray=it;const at=r(X,"buffer");PC.TypedArrayPrototypeGetBuffer=at;const ot=r(X,"byteOffset");PC.TypedArrayPrototypeGetByteOffset=ot;const st=r(X,"length");PC.TypedArrayPrototypeGetLength=st;const lt=r(X,x);PC.TypedArrayPrototypeGetSymbolToStringTag=lt;const ut=Uint16Array;PC.NativeUint16Array=ut;PC.Uint16ArrayFrom=(...t)=>n(q,ut,t);const ct=Uint32Array;PC.NativeUint32Array=ct;const ht=Float32Array;PC.NativeFloat32Array=ht;const dt=l([][v]());PC.ArrayIteratorPrototype=dt;const ft=e(dt.next);PC.ArrayIteratorPrototypeNext=ft;const pt=e(function*(){}().next);PC.GeneratorPrototypeNext=pt;const mt=l(dt);PC.IteratorPrototype=mt;const gt=DataView.prototype,vt=e(gt.getUint16);PC.DataViewPrototypeGetUint16=vt;const yt=e(gt.setUint16);PC.DataViewPrototypeSetUint16=yt;const xt=TypeError;PC.NativeTypeError=xt;const _t=RangeError;PC.NativeRangeError=_t;const wt=WeakSet;PC.NativeWeakSet=wt;const bt=wt.prototype,Mt=e(bt.add);PC.WeakSetPrototypeAdd=Mt;const St=e(bt.has);PC.WeakSetPrototypeHas=St;const Tt=WeakMap;PC.NativeWeakMap=Tt;const Et=Tt.prototype,At=e(Et.get);PC.WeakMapPrototypeGet=At;const Pt=e(Et.has);PC.WeakMapPrototypeHas=Pt;const Rt=e(Et.set);return PC.WeakMapPrototypeSet=Rt,PC}function LC(){if(bC)return AC;bC=1,Object.defineProperty(AC,"__esModule",{value:!0}),AC.safeIfNeeded=function(n){if(n[t.SymbolIterator]===t.NativeArrayPrototypeSymbolIterator&&t.ArrayIteratorPrototype.next===t.ArrayIteratorPrototypeNext)return n;const i=(0,t.ObjectCreate)(r);return(0,t.WeakMapPrototypeSet)(e,i,(0,t.ArrayPrototypeSymbolIterator)(n)),i},AC.wrap=function(e){const r=(0,t.ObjectCreate)(i);return(0,t.WeakMapPrototypeSet)(n,r,e),r};var t=IC();const e=new t.NativeWeakMap,r=(0,t.ObjectCreate)(null,{next:{value:function(){const r=(0,t.WeakMapPrototypeGet)(e,this);return(0,t.ArrayIteratorPrototypeNext)(r)}},[t.SymbolIterator]:{value:function(){return this}}});const n=new t.NativeWeakMap,i=(0,t.ObjectCreate)(t.IteratorPrototype,{next:{value:function(){const e=(0,t.WeakMapPrototypeGet)(n,this);return(0,t.GeneratorPrototypeNext)(e)},writable:!0,configurable:!0}});for(const e of(0,t.ReflectOwnKeys)(t.ArrayIteratorPrototype))"next"!==e&&(0,t.ObjectDefineProperty)(i,e,(0,t.ReflectGetOwnPropertyDescriptor)(t.ArrayIteratorPrototype,e));return AC}var OC,DC,kC={},FC={};function NC(){if(OC)return FC;OC=1,Object.defineProperty(FC,"__esModule",{value:!0}),FC.isArrayBuffer=function(e){try{return(0,t.ArrayBufferPrototypeGetByteLength)(e),!0}catch(t){return!1}},FC.isCanonicalIntegerIndexString=function(e){if("string"!=typeof e)return!1;const r=+e;if(e!==r+"")return!1;if(!(0,t.NumberIsFinite)(r))return!1;return r===(0,t.MathTrunc)(r)},FC.isNativeBigIntTypedArray=function(e){const r=(0,t.TypedArrayPrototypeGetSymbolToStringTag)(e);return"BigInt64Array"===r||"BigUint64Array"===r},FC.isNativeTypedArray=e,FC.isObject=function(t){return null!==t&&"object"==typeof t||"function"==typeof t},FC.isObjectLike=function(t){return null!==t&&"object"==typeof t},FC.isOrdinaryArray=function(e){if(!(0,t.ArrayIsArray)(e))return!1;return e[t.SymbolIterator]===t.NativeArrayPrototypeSymbolIterator&&t.ArrayIteratorPrototype.next===t.ArrayIteratorPrototypeNext},FC.isOrdinaryNativeTypedArray=function(r){if(!e(r))return!1;return r[t.SymbolIterator]===t.NativeTypedArrayPrototypeSymbolIterator&&t.ArrayIteratorPrototype.next===t.ArrayIteratorPrototypeNext},FC.isSharedArrayBuffer=function(e){if(null===t.NativeSharedArrayBuffer)return!1;try{return(0,t.SharedArrayBufferPrototypeGetByteLength)(e),!0}catch(t){return!1}};var t=IC();function e(e){return void 0!==(0,t.TypedArrayPrototypeGetSymbolToStringTag)(e)}return FC}var UC,BC={};function zC(){if(UC)return BC;UC=1,Object.defineProperty(BC,"__esModule",{value:!0}),BC.convertToNumber=function(t){const e=t>>10;return n[0]=o[l[e]+(1023&t)]+s[e],r[0]},BC.roundToFloat16Bits=function(t){r[0]=t;const e=n[0],o=e>>23&511;return i[o]+((8388607&e)>>a[o])};var t=IC();const e=new t.NativeArrayBuffer(4),r=new t.NativeFloat32Array(e),n=new t.NativeUint32Array(e),i=new t.NativeUint32Array(512),a=new t.NativeUint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,a[t]=24,a[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,a[t]=-e-1,a[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,a[t]=13,a[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,a[t]=24,a[256|t]=24):(i[t]=31744,i[256|t]=64512,a[t]=13,a[256|t]=13)}const o=new t.NativeUint32Array(2048),s=new t.NativeUint32Array(64),l=new t.NativeUint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,r=0;for(;0==(8388608&e);)e<<=1,r-=8388608;e&=-8388609,r+=947912704,o[t]=e|r}for(let t=1024;t<2048;++t)o[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)s[t]=t<<23;s[31]=1199570944,s[32]=2147483648;for(let t=33;t<63;++t)s[t]=2147483648+(t-32<<23);s[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(l[t]=1024);return BC}var GC,jC,VC={};function HC(){if(jC)return EC;jC=1,Object.defineProperty(EC,"__esModule",{value:!0}),EC.isFloat16Array=l;var t=LC(),e=function(){if(DC)return kC;DC=1,Object.defineProperty(kC,"__esModule",{value:!0}),kC.hasFloat16ArrayBrand=function(i){if(!(0,t.isObjectLike)(i))return!1;const a=(0,r.ReflectGetPrototypeOf)(i);if(!(0,t.isObjectLike)(a))return!1;const o=a.constructor;if(void 0===o)return!1;if(!(0,t.isObject)(o))throw(0,r.NativeTypeError)(e.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);return(0,r.ReflectHas)(o,n)};var t=NC(),e=CC(),r=IC();const n=(0,r.SymbolFor)("__Float16Array__");return kC.brand=n,kC}(),r=zC(),n=NC(),i=CC(),a=IC(),o=function(){if(GC)return VC;GC=1,Object.defineProperty(VC,"__esModule",{value:!0}),VC.IsDetachedBuffer=function(e){if((0,t.isSharedArrayBuffer)(e))return!1;try{return(0,r.ArrayBufferPrototypeSlice)(e,0,0),!1}catch(t){}return!0},VC.SpeciesConstructor=function(n,i){if(!(0,t.isObject)(n))throw(0,r.NativeTypeError)(e.THIS_IS_NOT_AN_OBJECT);const a=n.constructor;if(void 0===a)return i;if(!(0,t.isObject)(a))throw(0,r.NativeTypeError)(e.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);const o=a[r.SymbolSpecies];return null==o?i:o},VC.ToIntegerOrInfinity=n,VC.ToLength=function(t){const e=n(t);return e<0?0:ee)return 1;if(0===t&&0===e){const n=(0,r.ObjectIs)(t,0),i=(0,r.ObjectIs)(e,0);if(!n&&i)return-1;if(n&&!i)return 1}return 0};var t=NC(),e=CC(),r=IC();function n(t){const e=+t;return(0,r.NumberIsNaN)(e)||0===e?0:(0,r.MathTrunc)(e)}return VC}();const s=new a.NativeWeakMap;function l(t){return(0,a.WeakMapPrototypeHas)(s,t)||!(0,a.ArrayBufferIsView)(t)&&(0,e.hasFloat16ArrayBrand)(t)}function u(t){if(!l(t))throw(0,a.NativeTypeError)(i.THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT)}function c(t,e){const r=l(t),o=(0,n.isNativeTypedArray)(t);if(!r&&!o)throw(0,a.NativeTypeError)(i.SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT);if("number"==typeof e){let n;if(r){const e=h(t);n=(0,a.TypedArrayPrototypeGetLength)(e)}else n=(0,a.TypedArrayPrototypeGetLength)(t);if(n(0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)?(0,r.convertToNumber)((0,a.ReflectGet)(t,e)):(0,a.WeakSetPrototypeHas)(f,(0,a.ObjectPrototype__lookupGetter__)(t,e))?(0,a.ReflectGet)(t,e):(0,a.ReflectGet)(t,e,i),set:(t,e,i,o)=>(0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)?(0,a.ReflectSet)(t,e,(0,r.roundToFloat16Bits)(i)):(0,a.ReflectSet)(t,e,i,o),getOwnPropertyDescriptor(t,e){if((0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)){const n=(0,a.ReflectGetOwnPropertyDescriptor)(t,e);return n.value=(0,r.convertToNumber)(n.value),n}return(0,a.ReflectGetOwnPropertyDescriptor)(t,e)},defineProperty:(t,e,i)=>(0,n.isCanonicalIntegerIndexString)(e)&&(0,a.ObjectHasOwn)(t,e)&&(0,a.ObjectHasOwn)(i,"value")?(i.value=(0,r.roundToFloat16Bits)(i.value),(0,a.ReflectDefineProperty)(t,e,i)):(0,a.ReflectDefineProperty)(t,e,i)});let m=class f{constructor(t,e,u){let c;if(l(t))c=(0,a.ReflectConstruct)(a.NativeUint16Array,[h(t)],new.target);else if((0,n.isObject)(t)&&!(0,n.isArrayBuffer)(t)){let e,s;if((0,n.isNativeTypedArray)(t)){e=t,s=(0,a.TypedArrayPrototypeGetLength)(t);const r=(0,a.TypedArrayPrototypeGetBuffer)(t);if((0,o.IsDetachedBuffer)(r))throw(0,a.NativeTypeError)(i.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);if((0,n.isNativeBigIntTypedArray)(t))throw(0,a.NativeTypeError)(i.CANNOT_MIX_BIGINT_AND_OTHER_TYPES);const l=new a.NativeArrayBuffer(2*s);c=(0,a.ReflectConstruct)(a.NativeUint16Array,[l],new.target)}else{const r=t[a.SymbolIterator];if(null!=r&&"function"!=typeof r)throw(0,a.NativeTypeError)(i.ITERATOR_PROPERTY_IS_NOT_CALLABLE);null!=r?(0,n.isOrdinaryArray)(t)?(e=t,s=t.length):(e=[...t],s=e.length):(e=t,s=(0,o.ToLength)(e.length)),c=(0,a.ReflectConstruct)(a.NativeUint16Array,[s],new.target)}for(let t=0;t=0?i:n+i;if(!(s<0||s>=n))return(0,r.convertToNumber)(e[s])}with(t,e){u(this);const n=h(this),s=(0,a.TypedArrayPrototypeGetLength)(n),l=(0,o.ToIntegerOrInfinity)(t),c=l>=0?l:s+l,d=+e;if(c<0||c>=s)throw(0,a.NativeRangeError)(i.OFFSET_IS_OUT_OF_BOUNDS);const p=new a.NativeUint16Array((0,a.TypedArrayPrototypeGetBuffer)(n),(0,a.TypedArrayPrototypeGetByteOffset)(n),(0,a.TypedArrayPrototypeGetLength)(n)),m=new f((0,a.TypedArrayPrototypeGetBuffer)((0,a.TypedArrayPrototypeSlice)(p)));return h(m)[c]=(0,r.roundToFloat16Bits)(d),m}map(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),s=e[0],l=(0,o.SpeciesConstructor)(n,f);if(l===f){const e=new f(i),o=h(e);for(let e=0;e=0;--e)s=t(s,(0,r.convertToNumber)(n[e]),e,this);return s}forEach(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),o=e[0];for(let e=0;e=0;--e){const i=(0,r.convertToNumber)(n[e]);if((0,a.ReflectApply)(t,o,[i,e,this]))return i}}findLastIndex(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),o=e[0];for(let e=i-1;e>=0;--e){const i=(0,r.convertToNumber)(n[e]);if((0,a.ReflectApply)(t,o,[i,e,this]))return e}return-1}every(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n),o=e[0];for(let e=0;ed)throw(0,a.NativeRangeError)(i.OFFSET_IS_OUT_OF_BOUNDS);for(let t=0;tn((0,r.convertToNumber)(t),(0,r.convertToNumber)(e)))),this}toSorted(t){u(this);const e=h(this);if(void 0!==t&&"function"!=typeof t)throw new a.NativeTypeError(i.THE_COMPARISON_FUNCTION_MUST_BE_EITHER_A_FUNCTION_OR_UNDEFINED);const n=void 0!==t?t:o.defaultCompare,s=new a.NativeUint16Array((0,a.TypedArrayPrototypeGetBuffer)(e),(0,a.TypedArrayPrototypeGetByteOffset)(e),(0,a.TypedArrayPrototypeGetLength)(e)),l=new f((0,a.TypedArrayPrototypeGetBuffer)((0,a.TypedArrayPrototypeSlice)(s))),c=h(l);return(0,a.TypedArrayPrototypeSort)(c,((t,e)=>n((0,r.convertToNumber)(t),(0,r.convertToNumber)(e)))),l}slice(t,e){u(this);const n=h(this),s=(0,o.SpeciesConstructor)(n,f);if(s===f){const r=new a.NativeUint16Array((0,a.TypedArrayPrototypeGetBuffer)(n),(0,a.TypedArrayPrototypeGetByteOffset)(n),(0,a.TypedArrayPrototypeGetLength)(n));return new f((0,a.TypedArrayPrototypeGetBuffer)((0,a.TypedArrayPrototypeSlice)(r,t,e)))}const l=(0,a.TypedArrayPrototypeGetLength)(n),d=(0,o.ToIntegerOrInfinity)(t),p=void 0===e?l:(0,o.ToIntegerOrInfinity)(e);let m,g;m=d===-1/0?0:d<0?l+d>0?l+d:0:l0?l+p:0:l0?g-m:0,y=new s(v);if(c(y,v),0===v)return y;const x=(0,a.TypedArrayPrototypeGetBuffer)(n);if((0,o.IsDetachedBuffer)(x))throw(0,a.NativeTypeError)(i.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);let _=0;for(;m=1?(0,o.ToIntegerOrInfinity)(e[0]):i-1;if(s===-1/0)return-1;s>=0?s=s=0;--e)if((0,a.ObjectHasOwn)(n,e)&&(0,r.convertToNumber)(n[e])===t)return e;return-1}includes(t,...e){u(this);const n=h(this),i=(0,a.TypedArrayPrototypeGetLength)(n);let s=(0,o.ToIntegerOrInfinity)(e[0]);if(s===1/0)return!1;s<0&&(s+=i,s<0&&(s=0));const l=(0,a.NumberIsNaN)(t);for(let e=s;e/]`,l);if(o&&console.log("[xml-utils] start:",u),-1===u)return;const c=n.slice(u+i.length);let h=e(c,"^[^<]*[ /]>",0);const d=-1!==h&&"/"===c[h-1];if(o&&console.log("[xml-utils] selfClosing:",d),!1===d)if(s){let t=0,n=1,a=0;for(;-1!==(h=e(c,"[ /]"+i+">",t));){const e=c.substring(t,h+1);if(n+=r(e,"<"+i+"[ \n\t>]"),a+=r(e,""),a>=n)break;t=h}}else h=e(c,"[ /]"+i+">",0);const f=u+i.length+h+1;if(o&&console.log("[xml-utils] end:",f),-1===f)return;const p=n.slice(u,f);let m;return m=d?null:p.slice(p.indexOf(">")+1,p.lastIndexOf("<")),{inner:m,outer:p,start:u,end:f}}return nI.exports=n,nI.exports.default=n,nI.exports}var dI,fI={};function pI(){return dI||(dI=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.geoKeys=t.geoKeyNames=t.LercAddCompression=t.LercParameters=t.ExtraSamplesValues=t.photometricInterpretations=t.fieldTypes=t.fieldTypeNames=t.arrayFields=t.fieldTagTypes=t.fieldTags=t.fieldTagNames=void 0,t.fieldTagNames={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},t.fieldTags={};for(const e in t.fieldTagNames)t.fieldTagNames.hasOwnProperty(e)&&(t.fieldTags[t.fieldTagNames[e]]=parseInt(e,10));t.fieldTagTypes={256:"SHORT",257:"SHORT",258:"SHORT",259:"SHORT",262:"SHORT",273:"LONG",274:"SHORT",277:"SHORT",278:"LONG",279:"LONG",282:"RATIONAL",283:"RATIONAL",284:"SHORT",286:"SHORT",287:"RATIONAL",296:"SHORT",297:"SHORT",305:"ASCII",306:"ASCII",338:"SHORT",339:"SHORT",513:"LONG",514:"LONG",1024:"SHORT",1025:"SHORT",2048:"SHORT",2049:"ASCII",3072:"SHORT",3073:"ASCII",33550:"DOUBLE",33922:"DOUBLE",34665:"LONG",34735:"SHORT",34737:"ASCII",42113:"ASCII"},t.arrayFields=[t.fieldTags.BitsPerSample,t.fieldTags.ExtraSamples,t.fieldTags.SampleFormat,t.fieldTags.StripByteCounts,t.fieldTags.StripOffsets,t.fieldTags.StripRowCounts,t.fieldTags.TileByteCounts,t.fieldTags.TileOffsets,t.fieldTags.SubIFDs],t.fieldTypeNames={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},t.fieldTypes={};for(const e in t.fieldTypeNames)t.fieldTypeNames.hasOwnProperty(e)&&(t.fieldTypes[t.fieldTypeNames[e]]=parseInt(e,10));t.photometricInterpretations={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},t.ExtraSamplesValues={Unspecified:0,Assocalpha:1,Unassalpha:2},t.LercParameters={Version:0,AddCompression:1},t.LercAddCompression={None:0,Deflate:1},t.geoKeyNames={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},t.geoKeys={};for(const e in t.geoKeyNames)t.geoKeyNames.hasOwnProperty(e)&&(t.geoKeys[t.geoKeyNames[e]]=parseInt(e,10))}(fI)),fI}var mI,gI={};function vI(){if(mI)return gI;mI=1,Object.defineProperty(gI,"__esModule",{value:!0}),gI.fromCIELab=gI.fromYCbCr=gI.fromCMYK=gI.fromPalette=gI.fromBlackIsZero=gI.fromWhiteIsZero=void 0,gI.fromWhiteIsZero=function(t,e){const{width:r,height:n}=t,i=new Uint8Array(r*n*3);let a;for(let r=0,n=0;r>24)/500+s,u=s-(t[e+2]<<24>>24)/200;l=.95047*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),s=1*(s*s*s>.008856?s*s*s:(s-16/116)/7.787),u=1.08883*(u*u*u>.008856?u*u*u:(u-16/116)/7.787),i=3.2406*l+-1.5372*s+-.4986*u,a=-.9689*l+1.8758*s+.0415*u,o=.0557*l+-.204*s+1.057*u,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,n[r]=255*Math.max(0,Math.min(1,i)),n[r+1]=255*Math.max(0,Math.min(1,a)),n[r+2]=255*Math.max(0,Math.min(1,o))}return n},gI}var yI,xI,_I,wI={},bI={},MI={},SI={};function TI(){if(xI)return MI;xI=1,Object.defineProperty(MI,"__esModule",{value:!0});const t=function(){if(yI)return SI;function t(t,e){let r=t.length-e,n=0;do{for(let r=e;r>0;r--)t[n+e]+=t[n],n++;r-=e}while(r>0)}function e(t,e,r){let n=0,i=t.length;const a=i/r;for(;i>e;){for(let r=e;r>0;--r)t[n+e]+=t[n],++n;i-=e}const o=t.slice();for(let e=0;e=r.byteLength);++s){let a;if(2===n){switch(o[0]){case 8:a=new Uint8Array(r,s*u*i*l,u*i*l);break;case 16:a=new Uint16Array(r,s*u*i*l,u*i*l/2);break;case 32:a=new Uint32Array(r,s*u*i*l,u*i*l/4);break;default:throw new Error(`Predictor 2 not allowed with ${o[0]} bits per sample.`)}t(a,u)}else 3===n&&(a=new Uint8Array(r,s*u*i*l,u*i*l),e(a,u,l))}return r},SI}();return MI.default=class{async decode(e,r){const n=await this.decodeBlock(r),i=e.Predictor||1;if(1!==i){const r=!e.StripOffsets,a=r?e.TileWidth:e.ImageWidth,o=r?e.TileLength:e.RowsPerStrip||e.ImageLength;return(0,t.applyPredictor)(n,i,a,o,e.BitsPerSample,e.PlanarConfiguration)}return n}},MI}var EI,AI={};function PI(){if(EI)return AI;EI=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(AI,"__esModule",{value:!0});const e=t(TI()),r=257;function n(t,e){for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t}function i(t){const e=new Uint16Array(4093),i=new Uint8Array(4093);for(let t=0;t<=257;t++)e[t]=4096,i[t]=t;let a=258,o=9,s=0;function l(){a=258,o=9}function u(t){const e=function(t,e,n){const i=e%8,a=Math.floor(e/8),o=8-i,s=e+n-8*(a+1);let l=8*(a+2)-(e+n);const u=8*(a+2)-e;if(l=Math.max(0,l),a>=t.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),r;let c=t[a]&2**(8-i)-1;c<<=n-o;let h=c;if(a+1>>l;e<<=Math.max(0,n-u),h+=e}if(s>8&&a+2>>r}return h}(t,s,o);return s+=o,e}function c(t,r){return i[a]=r,e[a]=t,a++,a-1}function h(t){const r=[];for(let n=t;4096!==n;n=e[n])r.push(i[n]);return r}const d=[];l();const f=new Uint8Array(t);let p,m=u(f);for(;m!==r;){if(256===m){for(l(),m=u(f);256===m;)m=u(f);if(m===r)break;if(m>256)throw new Error(`corrupted code at scanline ${m}`);n(d,h(m)),p=m}else if(m=2**o&&(12===o?p=void 0:o++),m=u(f)}return new Uint8Array(d)}class a extends e.default{decodeBlock(t){return i(t).buffer}}return AI.default=a,AI}var RI,CI={};var II,LI,OI,DI,kI,FI,NI,UI,BI,zI,GI={},jI={},VI={},HI={},WI={};function qI(){if(II)return WI;II=1;function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=256,r=286,n=30,i=15,a=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),o=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),s=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),l=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new Array(576);t(u);const c=new Array(60);t(c);const h=new Array(512);t(h);const d=new Array(256);t(d);const f=new Array(29);t(f);const p=new Array(n);function m(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let g,v,y;function x(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}t(p);const _=t=>t<256?h[t]:h[256+(t>>>7)],w=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},b=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<{b(t,r[2*e],r[2*e+1])},S=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},T=(t,e,r)=>{const n=new Array(16);let a,o,s=0;for(a=1;a<=i;a++)s=s+r[a-1]<<1,n[a]=s;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=S(n[e]++,e))}},E=t=>{let e;for(e=0;e{t.bi_valid>8?w(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},P=(t,e,r,n)=>{const i=2*e,a=2*r;return t[i]{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i{let i,s,l,u,c=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+c++],i+=(255&t.pending_buf[t.sym_buf+c++])<<8,s=t.pending_buf[t.sym_buf+c++],0===i?M(t,s,r):(l=d[s],M(t,l+e+1,r),u=a[l],0!==u&&(s-=f[l],b(t,s,u)),i--,l=_(i),M(t,l,n),u=o[l],0!==u&&(i-=p[l],b(t,i,u)))}while(c{const r=e.dyn_tree,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,l,u,c=-1;for(t.heap_len=0,t.heap_max=573,s=0;s>1;s>=1;s--)R(t,r,s);u=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],R(t,r,1),l=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=l,r[2*u]=r[2*s]+r[2*l],t.depth[u]=(t.depth[s]>=t.depth[l]?t.depth[s]:t.depth[l])+1,r[2*s+1]=r[2*l+1]=u,t.heap[1]=u++,R(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,a=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,l=e.stat_desc.extra_base,u=e.stat_desc.max_length;let c,h,d,f,p,m,g=0;for(f=0;f<=i;f++)t.bl_count[f]=0;for(r[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)h=t.heap[c],f=r[2*r[2*h+1]+1]+1,f>u&&(f=u,g++),r[2*h+1]=f,h>n||(t.bl_count[f]++,p=0,h>=l&&(p=s[h-l]),m=r[2*h],t.opt_len+=m*(f+p),o&&(t.static_len+=m*(a[2*h+1]+p)));if(0!==g){do{for(f=u-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[u]--,g-=2}while(g>0);for(f=u;0!==f;f--)for(h=t.bl_count[f];0!==h;)d=t.heap[--c],d>n||(r[2*d+1]!==f&&(t.opt_len+=(f-r[2*d+1])*r[2*d],r[2*d+1]=f),h--)}})(t,e),T(r,c,t.bl_count)},L=(t,e,r)=>{let n,i,a=-1,o=e[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++s{let n,i,a=-1,o=e[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),n=0;n<=r;n++)if(i=o,o=e[2*(n+1)+1],!(++s{b(t,0+(n?1:0),3),A(t),w(t,r),w(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};return WI._tr_init=t=>{D||((()=>{let t,e,l,x,_;const w=new Array(16);for(l=0,x=0;x<28;x++)for(f[x]=l,t=0;t<1<>=7;x{let a,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let r,n=4093624447;for(r=0;r<=31;r++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*r])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(r=32;r{let e;for(L(t,t.dyn_ltree,t.l_desc.max_code),L(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*l[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),a=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=a&&(a=o)):a=o=n+5,n+4<=a&&-1!==r?k(t,r,n,i):4===t.strategy||o===a?(b(t,2+(i?1:0),3),C(t,u,c)):(b(t,4+(i?1:0),3),((t,e,r,n)=>{let i;for(b(t,e-257,5),b(t,r-1,5),b(t,n-4,4),i=0;i(t.pending_buf[t.sym_buf+t.sym_next++]=r,t.pending_buf[t.sym_buf+t.sym_next++]=r>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===r?t.dyn_ltree[2*n]++:(t.matches++,r--,t.dyn_ltree[2*(d[n]+e+1)]++,t.dyn_dtree[2*_(r)]++),t.sym_next===t.sym_end),WI._tr_align=t=>{b(t,2,3),M(t,256,u),(t=>{16===t.bi_valid?(w(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},WI}function XI(){if(OI)return LI;OI=1;return LI=(t,e,r,n)=>{let i=65535&t|0,a=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{i=i+e[n++]|0,a=a+i|0}while(--o);i%=65521,a%=65521}return i|a<<16|0}}function YI(){if(kI)return DI;kI=1;const t=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());return DI=(e,r,n,i)=>{const a=t,o=i+n;e^=-1;for(let t=i;t>>8^a[255&(e^r[t])];return-1^e}}function ZI(){return NI?FI:(NI=1,FI={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"})}function KI(){return BI?UI:(BI=1,UI={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8})}function JI(){if(zI)return HI;zI=1;const{_tr_init:t,_tr_stored_block:e,_tr_flush_block:r,_tr_tally:n,_tr_align:i}=qI(),a=XI(),o=YI(),s=ZI(),{Z_NO_FLUSH:l,Z_PARTIAL_FLUSH:u,Z_FULL_FLUSH:c,Z_FINISH:h,Z_BLOCK:d,Z_OK:f,Z_STREAM_END:p,Z_STREAM_ERROR:m,Z_DATA_ERROR:g,Z_BUF_ERROR:v,Z_DEFAULT_COMPRESSION:y,Z_FILTERED:x,Z_HUFFMAN_ONLY:_,Z_RLE:w,Z_FIXED:b,Z_DEFAULT_STRATEGY:M,Z_UNKNOWN:S,Z_DEFLATED:T}=KI(),E=258,A=262,P=42,R=113,C=666,I=(t,e)=>(t.msg=s[e],e),L=t=>2*t-(t>4?9:0),O=t=>{let e=t.length;for(;--e>=0;)t[e]=0},D=t=>{let e,r,n,i=t.w_size;e=t.hash_size,n=e;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);e=i,n=e;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)};let k=(t,e,r)=>(e<{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},N=(t,e)=>{r(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,F(t.strm)},U=(t,e)=>{t.pending_buf[t.pending++]=e},B=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},z=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=a(t.adler,e,i,r):2===t.state.wrap&&(t.adler=o(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},G=(t,e)=>{let r,n,i=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match;const l=t.strstart>t.w_size-A?t.strstart-(t.w_size-A):0,u=t.window,c=t.w_mask,h=t.prev,d=t.strstart+E;let f=u[a+o-1],p=u[a+o];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(r=e,u[r+o]===p&&u[r+o-1]===f&&u[r]===u[a]&&u[++r]===u[a+1]){a+=2,r++;do{}while(u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&ao){if(t.match_start=e,o=n,n>=s)break;f=u[a+o-1],p=u[a+o]}}}while((e=h[e&c])>l&&0!=--i);return o<=t.lookahead?o:t.lookahead},j=t=>{const e=t.w_size;let r,n,i;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-A)&&(t.window.set(t.window.subarray(e,e+e-n),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),D(t),n+=e),0===t.strm.avail_in)break;if(r=z(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=r,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=k(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=k(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead{let n,i,a,o=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,s=0,u=t.strm.avail_in;do{if(n=65535,a=t.bi_valid+42>>3,t.strm.avail_outi+t.strm.avail_in&&(n=i+t.strm.avail_in),n>a&&(n=a),n>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,F(t.strm),i&&(i>n&&(i=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,n-=i),n&&(z(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===s);return u-=t.strm.avail_in,u&&(u>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=u&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-u,t.strm.next_in),t.strstart),t.strstart+=u,t.insert+=u>t.w_size-t.insert?t.w_size-t.insert:u),t.block_start=t.strstart),t.high_watera&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,a+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),a>t.strm.avail_in&&(a=t.strm.avail_in),a&&(z(t.strm,t.window,t.strstart,a),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.high_water>3,a=t.pending_buf_size-a>65535?65535:t.pending_buf_size-a,o=a>t.w_size?t.w_size:a,i=t.strstart-t.block_start,(i>=o||(i||r===h)&&r!==l&&0===t.strm.avail_in&&i<=a)&&(n=i>a?a:i,s=r===h&&0===t.strm.avail_in&&n===i?1:0,e(t,t.block_start,n,s),t.block_start+=n,F(t.strm)),s?3:1)},H=(t,e)=>{let r,i;for(;;){if(t.lookahead=3&&(t.ins_h=k(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-A&&(t.match_length=G(t,r)),t.match_length>=3)if(i=n(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=k(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=k(t,t.ins_h,t.window[t.strstart+1]);else i=n(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(N(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===h?(N(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(N(t,!1),0===t.strm.avail_out)?1:2},W=(t,e)=>{let r,i,a;for(;;){if(t.lookahead=3&&(t.ins_h=k(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-3,i=n(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=a&&(t.ins_h=k(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(N(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=n(t,0,t.window[t.strstart-1]),i&&N(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=n(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===h?(N(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(N(t,!1),0===t.strm.avail_out)?1:2};function q(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const X=[new q(0,0,0,0,V),new q(4,4,8,4,H),new q(4,5,16,8,H),new q(4,6,32,32,H),new q(4,4,16,16,W),new q(8,16,32,32,W),new q(8,16,128,128,W),new q(8,32,128,256,W),new q(32,128,258,1024,W),new q(32,258,258,4096,W)];function Y(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=T,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),O(this.dyn_ltree),O(this.dyn_dtree),O(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),O(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),O(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Z=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==P&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==R&&e.status!==C?1:0},K=e=>{if(Z(e))return I(e,m);e.total_in=e.total_out=0,e.data_type=S;const r=e.state;return r.pending=0,r.pending_out=0,r.wrap<0&&(r.wrap=-r.wrap),r.status=2===r.wrap?57:r.wrap?P:R,e.adler=2===r.wrap?0:1,r.last_flush=-2,t(r),f},J=t=>{const e=K(t);var r;return e===f&&((r=t.state).window_size=2*r.w_size,O(r.head),r.max_lazy_match=X[r.level].max_lazy,r.good_match=X[r.level].good_length,r.nice_match=X[r.level].nice_length,r.max_chain_length=X[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),e},Q=(t,e,r,n,i,a)=>{if(!t)return m;let o=1;if(e===y&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==T||n<8||n>15||e<0||e>9||a<0||a>b||8===n&&1!==o)return I(t,m);8===n&&(n=9);const s=new Y;return t.state=s,s.strm=t,s.status=P,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<Q(t,e,T,15,8,M),HI.deflateInit2=Q,HI.deflateReset=J,HI.deflateResetKeep=K,HI.deflateSetHeader=(t,e)=>Z(t)||2!==t.state.wrap?m:(t.state.gzhead=e,f),HI.deflate=(t,r)=>{if(Z(t)||r>d||r<0)return t?I(t,m):m;const a=t.state;if(!t.output||0!==t.avail_in&&!t.input||a.status===C&&r!==h)return I(t,0===t.avail_out?v:m);const s=a.last_flush;if(a.last_flush=r,0!==a.pending){if(F(t),0===t.avail_out)return a.last_flush=-1,f}else if(0===t.avail_in&&L(r)<=L(s)&&r!==h)return I(t,v);if(a.status===C&&0!==t.avail_in)return I(t,v);if(a.status===P&&0===a.wrap&&(a.status=R),a.status===P){let e=T+(a.w_bits-8<<4)<<8,r=-1;if(r=a.strategy>=_||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=r<<6,0!==a.strstart&&(e|=32),e+=31-e%31,B(a,e),0!==a.strstart&&(B(a,t.adler>>>16),B(a,65535&t.adler)),t.adler=1,a.status=R,F(t),0!==a.pending)return a.last_flush=-1,f}if(57===a.status)if(t.adler=0,U(a,31),U(a,139),U(a,8),a.gzhead)U(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),U(a,255&a.gzhead.time),U(a,a.gzhead.time>>8&255),U(a,a.gzhead.time>>16&255),U(a,a.gzhead.time>>24&255),U(a,9===a.level?2:a.strategy>=_||a.level<2?4:0),U(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(U(a,255&a.gzhead.extra.length),U(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=o(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(U(a,0),U(a,0),U(a,0),U(a,0),U(a,0),U(a,9===a.level?2:a.strategy>=_||a.level<2?4:0),U(a,3),a.status=R,F(t),0!==a.pending)return a.last_flush=-1,f;if(69===a.status){if(a.gzhead.extra){let e=a.pending,r=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+r>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>e&&(t.adler=o(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex+=n,F(t),0!==a.pending)return a.last_flush=-1,f;e=0,r-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+r),a.pending),a.pending+=r,a.gzhead.hcrc&&a.pending>e&&(t.adler=o(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let e,r=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>r&&(t.adler=o(t.adler,a.pending_buf,a.pending-r,r)),F(t),0!==a.pending)return a.last_flush=-1,f;r=0}e=a.gzindexr&&(t.adler=o(t.adler,a.pending_buf,a.pending-r,r)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let e,r=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>r&&(t.adler=o(t.adler,a.pending_buf,a.pending-r,r)),F(t),0!==a.pending)return a.last_flush=-1,f;r=0}e=a.gzindexr&&(t.adler=o(t.adler,a.pending_buf,a.pending-r,r))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(F(t),0!==a.pending))return a.last_flush=-1,f;U(a,255&t.adler),U(a,t.adler>>8&255),t.adler=0}if(a.status=R,F(t),0!==a.pending)return a.last_flush=-1,f}if(0!==t.avail_in||0!==a.lookahead||r!==l&&a.status!==C){let o=0===a.level?V(a,r):a.strategy===_?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(j(t),0===t.lookahead)){if(e===l)return 1;break}if(t.match_length=0,r=n(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(N(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===h?(N(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(N(t,!1),0===t.strm.avail_out)?1:2})(a,r):a.strategy===w?((t,e)=>{let r,i,a,o;const s=t.window;for(;;){if(t.lookahead<=E){if(j(t),t.lookahead<=E&&e===l)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(a=t.strstart-1,i=s[a],i===s[++a]&&i===s[++a]&&i===s[++a])){o=t.strstart+E;do{}while(i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&at.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=n(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=n(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(N(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===h?(N(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(N(t,!1),0===t.strm.avail_out)?1:2})(a,r):X[a.level].func(a,r);if(3!==o&&4!==o||(a.status=C),1===o||3===o)return 0===t.avail_out&&(a.last_flush=-1),f;if(2===o&&(r===u?i(a):r!==d&&(e(a,0,0,!1),r===c&&(O(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),F(t),0===t.avail_out))return a.last_flush=-1,f}return r!==h?f:a.wrap<=0?p:(2===a.wrap?(U(a,255&t.adler),U(a,t.adler>>8&255),U(a,t.adler>>16&255),U(a,t.adler>>24&255),U(a,255&t.total_in),U(a,t.total_in>>8&255),U(a,t.total_in>>16&255),U(a,t.total_in>>24&255)):(B(a,t.adler>>>16),B(a,65535&t.adler)),F(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?f:p)},HI.deflateEnd=t=>{if(Z(t))return m;const e=t.state.status;return t.state=null,e===R?I(t,g):f},HI.deflateSetDictionary=(t,e)=>{let r=e.length;if(Z(t))return m;const n=t.state,i=n.wrap;if(2===i||1===i&&n.status!==P||n.lookahead)return m;if(1===i&&(t.adler=a(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(O(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const o=t.avail_in,s=t.next_in,l=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,j(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=k(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,j(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=l,t.avail_in=o,n.wrap=i,f},HI.deflateInfo="pako deflate (from Nodeca project)",HI}var QI,$I={};function tL(){if(QI)return $I;QI=1;const t=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);return $I.assign=function(e){const r=Array.prototype.slice.call(arguments,1);for(;r.length;){const n=r.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const r in n)t(n,r)&&(e[r]=n[r])}}return e},$I.flattenChunks=t=>{let e=0;for(let r=0,n=t.length;r=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;e[254]=e[254]=1,aL.string2buf=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,a,o=t.length,s=0;for(i=0;i>>6,e[a++]=128|63&r):r<65536?(e[a++]=224|r>>>12,e[a++]=128|r>>>6&63,e[a++]=128|63&r):(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63,e[a++]=128|r>>>6&63,e[a++]=128|63&r);return e};return aL.buf2string=(r,n)=>{const i=n||r.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(r.subarray(0,n));let a,o;const s=new Array(2*i);for(o=0,a=0;a4)s[o++]=65533,a+=n-1;else{for(t&=2===n?31:3===n?15:7;n>1&&a1?s[o++]=65533:t<65536?s[o++]=t:(t-=65536,s[o++]=55296|t>>10&1023,s[o++]=56320|1023&t)}}return((e,r)=>{if(r<65534&&e.subarray&&t)return String.fromCharCode.apply(null,e.length===r?e:e.subarray(0,r));let n="";for(let t=0;t{(r=r||t.length)>t.length&&(r=t.length);let n=r-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?r:n+e[t[n]]>r?n:r},aL}function sL(){if(nL)return rL;return nL=1,rL=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}}var lL,uL,cL,hL,dL,fL,pL,mL,gL,vL,yL={},xL={};function _L(){if(dL)return xL;dL=1;const t=XI(),e=YI(),r=function(){if(uL)return lL;uL=1;const t=16209;return lL=function(e,r){let n,i,a,o,s,l,u,c,h,d,f,p,m,g,v,y,x,_,w,b,M,S,T,E;const A=e.state;n=e.next_in,T=e.input,i=n+(e.avail_in-5),a=e.next_out,E=e.output,o=a-(r-e.avail_out),s=a+(e.avail_out-257),l=A.dmax,u=A.wsize,c=A.whave,h=A.wnext,d=A.window,f=A.hold,p=A.bits,m=A.lencode,g=A.distcode,v=(1<>>24,f>>>=_,p-=_,_=x>>>16&255,0===_)E[a++]=65535&x;else{if(!(16&_)){if(0==(64&_)){x=m[(65535&x)+(f&(1<<_)-1)];continue e}if(32&_){A.mode=16191;break t}e.msg="invalid literal/length code",A.mode=t;break t}w=65535&x,_&=15,_&&(p<_&&(f+=T[n++]<>>=_,p-=_),p<15&&(f+=T[n++]<>>24,f>>>=_,p-=_,_=x>>>16&255,!(16&_)){if(0==(64&_)){x=g[(65535&x)+(f&(1<<_)-1)];continue r}e.msg="invalid distance code",A.mode=t;break t}if(b=65535&x,_&=15,p<_&&(f+=T[n++]<l){e.msg="invalid distance too far back",A.mode=t;break t}if(f>>>=_,p-=_,_=a-o,b>_){if(_=b-_,_>c&&A.sane){e.msg="invalid distance too far back",A.mode=t;break t}if(M=0,S=d,0===h){if(M+=u-_,_2;)E[a++]=S[M++],E[a++]=S[M++],E[a++]=S[M++],w-=3;w&&(E[a++]=S[M++],w>1&&(E[a++]=S[M++]))}else{M=a-b;do{E[a++]=E[M++],E[a++]=E[M++],E[a++]=E[M++],w-=3}while(w>2);w&&(E[a++]=E[M++],w>1&&(E[a++]=E[M++]))}break}}break}}while(n>3,n-=w,p-=w<<3,f&=(1<{const f=d.bits;let p,m,g,v,y,x,_=0,w=0,b=0,M=0,S=0,T=0,E=0,A=0,P=0,R=0,C=null;const I=new Uint16Array(16),L=new Uint16Array(16);let O,D,k,F=null;for(_=0;_<=t;_++)I[_]=0;for(w=0;w=1&&0===I[M];M--);if(S>M&&(S=M),0===M)return u[c++]=20971520,u[c++]=20971520,d.bits=1,0;for(b=1;b0&&(0===a||1!==M))return-1;for(L[1]=0,_=1;_852||2===a&&P>592)return 1;for(;;){O=_-E,h[w]+1=x?(D=F[h[w]-x],k=C[h[w]-x]):(D=96,k=0),p=1<<_-E,m=1<>E)+m]=O<<24|D<<16|k|0}while(0!==m);for(p=1<<_-1;R&p;)p>>=1;if(0!==p?(R&=p-1,R+=p):R=0,w++,0==--I[_]){if(_===M)break;_=o[s+h[w]]}if(_>S&&(R&v)!==g){for(0===E&&(E=S),y+=b,T=_-E,A=1<852||2===a&&P>592)return 1;g=R&v,u[g]=S<<24|T<<16|y-c|0}}return 0!==R&&(u[y+R]=_-E<<24|64<<16|0),d.bits=S,0}}(),{Z_FINISH:i,Z_BLOCK:a,Z_TREES:o,Z_OK:s,Z_STREAM_END:l,Z_NEED_DICT:u,Z_STREAM_ERROR:c,Z_DATA_ERROR:h,Z_MEM_ERROR:d,Z_BUF_ERROR:f,Z_DEFLATED:p}=KI(),m=16180,g=16190,v=16191,y=16192,x=16194,_=16199,w=16200,b=16206,M=16209,S=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function T(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const E=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode16211?1:0},A=t=>{if(E(t))return c;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=m,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,s},P=t=>{if(E(t))return c;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,A(t)},R=(t,e)=>{let r;if(E(t))return c;const n=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?c:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,P(t))},C=(t,e)=>{if(!t)return c;const r=new T;t.state=r,r.strm=t,r.window=null,r.mode=m;const n=R(t,e);return n!==s&&(t.state=null),n};let I,L,O=!0;const D=t=>{if(O){I=new Int32Array(512),L=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(n(1,t.lens,0,288,I,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;n(2,t.lens,0,32,L,0,t.work,{bits:5}),O=!1}t.lencode=I,t.lenbits=9,t.distcode=L,t.distbits=5},k=(t,e,r,n)=>{let i;const a=t.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(e.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),a.window.set(e.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(e.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whaveC(t,15),xL.inflateInit2=C,xL.inflate=(T,A)=>{let P,R,C,I,L,O,F,N,U,B,z,G,j,V,H,W,q,X,Y,Z,K,J,Q=0;const $=new Uint8Array(4);let tt,et;const rt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(E(T)||!T.output||!T.input&&0!==T.avail_in)return c;P=T.state,P.mode===v&&(P.mode=y),L=T.next_out,C=T.output,F=T.avail_out,I=T.next_in,R=T.input,O=T.avail_in,N=P.hold,U=P.bits,B=O,z=F,J=s;t:for(;;)switch(P.mode){case m:if(0===P.wrap){P.mode=y;break}for(;U<16;){if(0===O)break t;O--,N+=R[I++]<>>8&255,P.check=e(P.check,$,2,0),N=0,U=0,P.mode=16181;break}if(P.head&&(P.head.done=!1),!(1&P.wrap)||(((255&N)<<8)+(N>>8))%31){T.msg="incorrect header check",P.mode=M;break}if((15&N)!==p){T.msg="unknown compression method",P.mode=M;break}if(N>>>=4,U-=4,K=8+(15&N),0===P.wbits&&(P.wbits=K),K>15||K>P.wbits){T.msg="invalid window size",P.mode=M;break}P.dmax=1<>8&1),512&P.flags&&4&P.wrap&&($[0]=255&N,$[1]=N>>>8&255,P.check=e(P.check,$,2,0)),N=0,U=0,P.mode=16182;case 16182:for(;U<32;){if(0===O)break t;O--,N+=R[I++]<>>8&255,$[2]=N>>>16&255,$[3]=N>>>24&255,P.check=e(P.check,$,4,0)),N=0,U=0,P.mode=16183;case 16183:for(;U<16;){if(0===O)break t;O--,N+=R[I++]<>8),512&P.flags&&4&P.wrap&&($[0]=255&N,$[1]=N>>>8&255,P.check=e(P.check,$,2,0)),N=0,U=0,P.mode=16184;case 16184:if(1024&P.flags){for(;U<16;){if(0===O)break t;O--,N+=R[I++]<>>8&255,P.check=e(P.check,$,2,0)),N=0,U=0}else P.head&&(P.head.extra=null);P.mode=16185;case 16185:if(1024&P.flags&&(G=P.length,G>O&&(G=O),G&&(P.head&&(K=P.head.extra_len-P.length,P.head.extra||(P.head.extra=new Uint8Array(P.head.extra_len)),P.head.extra.set(R.subarray(I,I+G),K)),512&P.flags&&4&P.wrap&&(P.check=e(P.check,R,G,I)),O-=G,I+=G,P.length-=G),P.length))break t;P.length=0,P.mode=16186;case 16186:if(2048&P.flags){if(0===O)break t;G=0;do{K=R[I+G++],P.head&&K&&P.length<65536&&(P.head.name+=String.fromCharCode(K))}while(K&&G>9&1,P.head.done=!0),T.adler=P.check=0,P.mode=v;break;case 16189:for(;U<32;){if(0===O)break t;O--,N+=R[I++]<>>=7&U,U-=7&U,P.mode=b;break}for(;U<3;){if(0===O)break t;O--,N+=R[I++]<>>=1,U-=1,3&N){case 0:P.mode=16193;break;case 1:if(D(P),P.mode=_,A===o){N>>>=2,U-=2;break t}break;case 2:P.mode=16196;break;case 3:T.msg="invalid block type",P.mode=M}N>>>=2,U-=2;break;case 16193:for(N>>>=7&U,U-=7&U;U<32;){if(0===O)break t;O--,N+=R[I++]<>>16^65535)){T.msg="invalid stored block lengths",P.mode=M;break}if(P.length=65535&N,N=0,U=0,P.mode=x,A===o)break t;case x:P.mode=16195;case 16195:if(G=P.length,G){if(G>O&&(G=O),G>F&&(G=F),0===G)break t;C.set(R.subarray(I,I+G),L),O-=G,I+=G,F-=G,L+=G,P.length-=G;break}P.mode=v;break;case 16196:for(;U<14;){if(0===O)break t;O--,N+=R[I++]<>>=5,U-=5,P.ndist=1+(31&N),N>>>=5,U-=5,P.ncode=4+(15&N),N>>>=4,U-=4,P.nlen>286||P.ndist>30){T.msg="too many length or distance symbols",P.mode=M;break}P.have=0,P.mode=16197;case 16197:for(;P.have>>=3,U-=3}for(;P.have<19;)P.lens[rt[P.have++]]=0;if(P.lencode=P.lendyn,P.lenbits=7,tt={bits:P.lenbits},J=n(0,P.lens,0,19,P.lencode,0,P.work,tt),P.lenbits=tt.bits,J){T.msg="invalid code lengths set",P.mode=M;break}P.have=0,P.mode=16198;case 16198:for(;P.have>>24,W=Q>>>16&255,q=65535&Q,!(H<=U);){if(0===O)break t;O--,N+=R[I++]<>>=H,U-=H,P.lens[P.have++]=q;else{if(16===q){for(et=H+2;U>>=H,U-=H,0===P.have){T.msg="invalid bit length repeat",P.mode=M;break}K=P.lens[P.have-1],G=3+(3&N),N>>>=2,U-=2}else if(17===q){for(et=H+3;U>>=H,U-=H,K=0,G=3+(7&N),N>>>=3,U-=3}else{for(et=H+7;U>>=H,U-=H,K=0,G=11+(127&N),N>>>=7,U-=7}if(P.have+G>P.nlen+P.ndist){T.msg="invalid bit length repeat",P.mode=M;break}for(;G--;)P.lens[P.have++]=K}}if(P.mode===M)break;if(0===P.lens[256]){T.msg="invalid code -- missing end-of-block",P.mode=M;break}if(P.lenbits=9,tt={bits:P.lenbits},J=n(1,P.lens,0,P.nlen,P.lencode,0,P.work,tt),P.lenbits=tt.bits,J){T.msg="invalid literal/lengths set",P.mode=M;break}if(P.distbits=6,P.distcode=P.distdyn,tt={bits:P.distbits},J=n(2,P.lens,P.nlen,P.ndist,P.distcode,0,P.work,tt),P.distbits=tt.bits,J){T.msg="invalid distances set",P.mode=M;break}if(P.mode=_,A===o)break t;case _:P.mode=w;case w:if(O>=6&&F>=258){T.next_out=L,T.avail_out=F,T.next_in=I,T.avail_in=O,P.hold=N,P.bits=U,r(T,z),L=T.next_out,C=T.output,F=T.avail_out,I=T.next_in,R=T.input,O=T.avail_in,N=P.hold,U=P.bits,P.mode===v&&(P.back=-1);break}for(P.back=0;Q=P.lencode[N&(1<>>24,W=Q>>>16&255,q=65535&Q,!(H<=U);){if(0===O)break t;O--,N+=R[I++]<>X)],H=Q>>>24,W=Q>>>16&255,q=65535&Q,!(X+H<=U);){if(0===O)break t;O--,N+=R[I++]<>>=X,U-=X,P.back+=X}if(N>>>=H,U-=H,P.back+=H,P.length=q,0===W){P.mode=16205;break}if(32&W){P.back=-1,P.mode=v;break}if(64&W){T.msg="invalid literal/length code",P.mode=M;break}P.extra=15&W,P.mode=16201;case 16201:if(P.extra){for(et=P.extra;U>>=P.extra,U-=P.extra,P.back+=P.extra}P.was=P.length,P.mode=16202;case 16202:for(;Q=P.distcode[N&(1<>>24,W=Q>>>16&255,q=65535&Q,!(H<=U);){if(0===O)break t;O--,N+=R[I++]<>X)],H=Q>>>24,W=Q>>>16&255,q=65535&Q,!(X+H<=U);){if(0===O)break t;O--,N+=R[I++]<>>=X,U-=X,P.back+=X}if(N>>>=H,U-=H,P.back+=H,64&W){T.msg="invalid distance code",P.mode=M;break}P.offset=q,P.extra=15&W,P.mode=16203;case 16203:if(P.extra){for(et=P.extra;U>>=P.extra,U-=P.extra,P.back+=P.extra}if(P.offset>P.dmax){T.msg="invalid distance too far back",P.mode=M;break}P.mode=16204;case 16204:if(0===F)break t;if(G=z-F,P.offset>G){if(G=P.offset-G,G>P.whave&&P.sane){T.msg="invalid distance too far back",P.mode=M;break}G>P.wnext?(G-=P.wnext,j=P.wsize-G):j=P.wnext-G,G>P.length&&(G=P.length),V=P.window}else V=C,j=L-P.offset,G=P.length;G>F&&(G=F),F-=G,P.length-=G;do{C[L++]=V[j++]}while(--G);0===P.length&&(P.mode=w);break;case 16205:if(0===F)break t;C[L++]=P.length,F--,P.mode=w;break;case b:if(P.wrap){for(;U<32;){if(0===O)break t;O--,N|=R[I++]<{if(E(t))return c;let e=t.state;return e.window&&(e.window=null),t.state=null,s},xL.inflateGetHeader=(t,e)=>{if(E(t))return c;const r=t.state;return 0==(2&r.wrap)?c:(r.head=e,e.done=!1,s)},xL.inflateSetDictionary=(e,r)=>{const n=r.length;let i,a,o;return E(e)?c:(i=e.state,0!==i.wrap&&i.mode!==g?c:i.mode===g&&(a=1,a=t(a,r,n,0),a!==i.check)?h:(o=k(e,r,n,n),o?(i.mode=16210,d):(i.havedict=1,s)))},xL.inflateInfo="pako inflate (from Nodeca project)",xL}function wL(){if(mL)return yL;mL=1;const t=_L(),e=tL(),r=oL(),n=ZI(),i=sL(),a=pL?fL:(pL=1,fL=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}),o=Object.prototype.toString,{Z_NO_FLUSH:s,Z_FINISH:l,Z_OK:u,Z_STREAM_END:c,Z_NEED_DICT:h,Z_STREAM_ERROR:d,Z_DATA_ERROR:f,Z_MEM_ERROR:p}=KI();function m(s){this.options=e.assign({chunkSize:65536,windowBits:15,to:""},s||{});const l=this.options;l.raw&&l.windowBits>=0&&l.windowBits<16&&(l.windowBits=-l.windowBits,0===l.windowBits&&(l.windowBits=-15)),!(l.windowBits>=0&&l.windowBits<16)||s&&s.windowBits||(l.windowBits+=32),l.windowBits>15&&l.windowBits<48&&0==(15&l.windowBits)&&(l.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;let c=t.inflateInit2(this.strm,l.windowBits);if(c!==u)throw new Error(n[c]);if(this.header=new a,t.inflateGetHeader(this.strm,this.header),l.dictionary&&("string"==typeof l.dictionary?l.dictionary=r.string2buf(l.dictionary):"[object ArrayBuffer]"===o.call(l.dictionary)&&(l.dictionary=new Uint8Array(l.dictionary)),l.raw&&(c=t.inflateSetDictionary(this.strm,l.dictionary),c!==u)))throw new Error(n[c])}function g(t,e){const r=new m(e);if(r.push(t),r.err)throw r.msg||n[r.err];return r.result}return m.prototype.push=function(e,n){const i=this.strm,a=this.options.chunkSize,m=this.options.dictionary;let g,v,y;if(this.ended)return!1;for(v=n===~~n?n:!0===n?l:s,"[object ArrayBuffer]"===o.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),g=t.inflate(i,v),g===h&&m&&(g=t.inflateSetDictionary(i,m),g===u?g=t.inflate(i,v):g===f&&(g=h));i.avail_in>0&&g===c&&i.state.wrap>0&&0!==e[i.next_in];)t.inflateReset(i),g=t.inflate(i,v);switch(g){case d:case f:case h:case p:return this.onEnd(g),this.ended=!0,!1}if(y=i.avail_out,i.next_out&&(0===i.avail_out||g===c))if("string"===this.options.to){let t=r.utf8border(i.output,i.next_out),e=i.next_out-t,n=r.buf2string(i.output,t);i.next_out=e,i.avail_out=a-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(g!==u||0!==y){if(g===c)return g=t.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},m.prototype.onData=function(t){this.chunks.push(t)},m.prototype.onEnd=function(t){t===u&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},yL.Inflate=m,yL.inflate=g,yL.inflateRaw=function(t,e){return(e=e||{}).raw=!0,g(t,e)},yL.ungzip=g,yL.constants=KI(),yL}function bL(){if(gL)return jI;gL=1;const{Deflate:t,deflate:e,deflateRaw:r,gzip:n}=function(){if(iL)return VI;iL=1;const t=JI(),e=tL(),r=oL(),n=ZI(),i=sL(),a=Object.prototype.toString,{Z_NO_FLUSH:o,Z_SYNC_FLUSH:s,Z_FULL_FLUSH:l,Z_FINISH:u,Z_OK:c,Z_STREAM_END:h,Z_DEFAULT_COMPRESSION:d,Z_DEFAULT_STRATEGY:f,Z_DEFLATED:p}=KI();function m(o){this.options=e.assign({level:d,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:f},o||{});let s=this.options;s.raw&&s.windowBits>0?s.windowBits=-s.windowBits:s.gzip&&s.windowBits>0&&s.windowBits<16&&(s.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;let l=t.deflateInit2(this.strm,s.level,s.method,s.windowBits,s.memLevel,s.strategy);if(l!==c)throw new Error(n[l]);if(s.header&&t.deflateSetHeader(this.strm,s.header),s.dictionary){let e;if(e="string"==typeof s.dictionary?r.string2buf(s.dictionary):"[object ArrayBuffer]"===a.call(s.dictionary)?new Uint8Array(s.dictionary):s.dictionary,l=t.deflateSetDictionary(this.strm,e),l!==c)throw new Error(n[l]);this._dict_set=!0}}function g(t,e){const r=new m(e);if(r.push(t,!0),r.err)throw r.msg||n[r.err];return r.result}return m.prototype.push=function(e,n){const i=this.strm,d=this.options.chunkSize;let f,p;if(this.ended)return!1;for(p=n===~~n?n:!0===n?u:o,"string"==typeof e?i.input=r.string2buf(e):"[object ArrayBuffer]"===a.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(d),i.next_out=0,i.avail_out=d),(p===s||p===l)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(f=t.deflate(i,p),f===h)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),f=t.deflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===c;if(0!==i.avail_out){if(p>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},m.prototype.onData=function(t){this.chunks.push(t)},m.prototype.onEnd=function(t){t===c&&(this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},VI.Deflate=m,VI.deflate=g,VI.deflateRaw=function(t,e){return(e=e||{}).raw=!0,g(t,e)},VI.gzip=function(t,e){return(e=e||{}).gzip=!0,g(t,e)},VI.constants=KI(),VI}(),{Inflate:i,inflate:a,inflateRaw:o,ungzip:s}=wL(),l=KI();return jI.Deflate=t,jI.deflate=e,jI.deflateRaw=r,jI.gzip=n,jI.Inflate=i,jI.inflate=a,jI.inflateRaw=o,jI.ungzip=s,jI.constants=l,jI}var ML,SL={};var TL,EL,AL={},PL={exports:{}};function RL(){if(EL)return AL;EL=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(AL,"__esModule",{value:!0});const e=bL(),r=t((TL||(TL=1,function(t){ /* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */ -!function(){var e,r,n,i,a,o,s,l,u,c,h,d,f,p,m,g,v=(e={defaultNoDataValue:-34027999387901484e22,decode:function(t,o){var s=(o=o||{}).encodedMaskData||null===o.encodedMaskData,l=a(t,o.inputOffset||0,s),u=null!==o.noDataValue?o.noDataValue:e.defaultNoDataValue,c=r(l,o.pixelType||Float32Array,o.encodedMaskData,u,o.returnMask),h={width:l.width,height:l.height,pixelData:c.resultPixels,minValue:c.minValue,maxValue:l.pixels.maxValue,noDataValue:u};return c.resultMask&&(h.maskData=c.resultMask),o.returnEncodedMask&&l.mask&&(h.encodedMaskData=l.mask.bitset?l.mask.bitset:null),o.returnFileInfo&&(h.fileInfo=n(l),o.computeUsedBitDepths&&(h.fileInfo.bitDepths=i(l))),h}},r=function(t,e,r,n,i){var a,s,l,u=0,c=t.pixels.numBlocksX,h=t.pixels.numBlocksY,d=Math.floor(t.width/c),f=Math.floor(t.height/h),p=2*t.maxZError,m=Number.MAX_VALUE;r=r||(t.mask?t.mask.bitset:null),s=new e(t.width*t.height),i&&r&&(l=new Uint8Array(t.width*t.height));for(var g,v,y=new Float32Array(d*f),x=0;x<=h;x++){var _=x!==h?f:t.height%h;if(0!==_)for(var w=0;w<=c;w++){var b=w!==c?d:t.width%c;if(0!==b){var M,S,T,E,A=x*t.width*f+w*d,R=t.width-b,P=t.pixels.blocks[u];if(P.encoding<2?(0===P.encoding?M=P.rawData:(o(P.stuffedData,P.bitsPerPixel,P.numValidPixels,P.offset,p,y,t.pixels.maxValue),M=y),S=0):T=2===P.encoding?0:P.offset,r)for(v=0;v<_;v++){for(7&A&&(E=r[A>>3],E<<=7&A),g=0;g>3]),128&E?(l&&(l[A]=1),m=m>(a=P.encoding<2?M[S++]:T)?a:m,s[A++]=a):(l&&(l[A]=0),s[A++]=n),E<<=1;A+=R}else if(P.encoding<2)for(v=0;v<_;v++){for(g=0;g(a=M[S++])?a:m,s[A++]=a;A+=R}else for(m=m>T?T:m,v=0;v<_;v++){for(g=0;g0){var o=new Uint8Array(Math.ceil(n.width*n.height/8)),s=(a=new DataView(t,e,n.mask.numBytes)).getInt16(0,!0),l=2,u=0;do{if(s>0)for(;s--;)o[u++]=a.getUint8(l++);else{var c=a.getUint8(l++);for(s=-s;s--;)o[u++]=c}s=a.getInt16(l,!0),l+=2}while(l0?1:0),p=d+(n.height%d>0?1:0);n.pixels.blocks=new Array(f*p);for(var m=0,g=0;g3)throw"Invalid block encoding ("+_.encoding+")";if(2!==_.encoding){if(0!==w&&2!==w){if(w>>=6,_.offsetType=w,2===w)_.offset=a.getInt8(1),y++;else if(1===w)_.offset=a.getInt16(1,!0),y+=2;else{if(0!==w)throw"Invalid block offset type";_.offset=a.getFloat32(1,!0),y+=4}if(1===_.encoding)if(w=a.getUint8(y),y++,_.bitsPerPixel=63&w,w>>=6,_.numValidPixelsType=w,2===w)_.numValidPixels=a.getUint8(y),y++;else if(1===w)_.numValidPixels=a.getUint16(y,!0),y+=2;else{if(0!==w)throw"Invalid valid pixel count type";_.numValidPixels=a.getUint32(y,!0),y+=4}}var b;if(e+=y,3!==_.encoding)if(0===_.encoding){var M=(n.pixels.numBytes-1)/4;if(M!==Math.floor(M))throw"uncompressed block has invalid length";b=new ArrayBuffer(4*M),new Uint8Array(b).set(new Uint8Array(t,e,4*M));var S=new Float32Array(b);_.rawData=S,e+=4*M}else if(1===_.encoding){var T=Math.ceil(_.numValidPixels*_.bitsPerPixel/8),E=Math.ceil(T/4);b=new ArrayBuffer(4*E),new Uint8Array(b).set(new Uint8Array(t,e,T)),_.stuffedData=new Uint32Array(b),e+=T}}else e++}return n.eofOffset=e,n},o=function(t,e,r,n,i,a,o){var s,l,u,c=(1<=e)l=u>>>d-e&c,d-=e;else{var m=e-d;l=(u&c)<>>(d=32-m)}a[s]=l=r?(u=c>>>m-r&f,m-=r):(u=(c&f)<<(h=r-m)&f,u+=(c=t[p++])>>>(m=32-h)),e[l]=i[u];else for(d=Math.ceil((s-a)/o),l=0;l=r?(u=c>>>m-r&f,m-=r):(u=(c&f)<<(h=r-m)&f,u+=(c=t[p++])>>>(m=32-h)),e[l]=u=e?(d=o>>>h-e&s,h-=e):(d=(o&s)<<(c=e-h)&s,d+=(o=t[l++])>>>(h=32-c)),f[u]=d=r?(u=c>>>m&d,p-=r,m+=r):(u=c>>>m&d,p=32-(h=r-p),u|=((c=t[f++])&(1<=r?(u=c>>>m&d,p-=r,m+=r):(u=c>>>m&d,p=32-(h=r-p),u|=((c=t[f++])&(1<=e?(d=o>>>f&s,h-=e,f+=e):(d=o>>>f&s,h=32-(c=e-h),d|=((o=t[l++])&(1<=r?(a=o>>>c-r&l,c-=r):(a=(o&l)<<(s=r-c)&l,a+=(o=t[u++])>>>(c=32-s)),e[i]=a;return e},d=function(t,e,r,n){var i,a,o,s,l=(1<=r?(a=o>>>h&l,c-=r,h+=r):(a=o>>>h&l,c=32-(s=r-c),a|=((o=t[u++])&(1<=359?359:i;i-=o;do{e+=t[a++]<<8,r+=e+=t[a++]}while(--o);e=(65535&e)+(e>>>16),r=(65535&r)+(r>>>16)}return 1&n&&(r+=e+=t[a]<<8),((r=(65535&r)+(r>>>16))<<16|(e=(65535&e)+(e>>>16)))>>>0},readHeaderInfo:function(t,e){var r=e.ptr,n=new Uint8Array(t,r,6),i={};if(i.fileIdentifierString=String.fromCharCode.apply(null,n),0!==i.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+i.fileIdentifierString;r+=6;var a,o=new DataView(t,r,8),s=o.getInt32(0,!0);if(i.fileVersion=s,r+=4,s>=3&&(i.checksum=o.getUint32(4,!0),r+=4),o=new DataView(t,r,12),i.height=o.getUint32(0,!0),i.width=o.getUint32(4,!0),r+=8,s>=4?(i.numDims=o.getUint32(8,!0),r+=4):i.numDims=1,o=new DataView(t,r,40),i.numValidPixel=o.getUint32(0,!0),i.microBlockSize=o.getInt32(4,!0),i.blobSize=o.getInt32(8,!0),i.imageType=o.getInt32(12,!0),i.maxZError=o.getFloat64(16,!0),i.zMin=o.getFloat64(24,!0),i.zMax=o.getFloat64(32,!0),r+=40,e.headerInfo=i,e.ptr=r,s>=3&&(a=s>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(t,r-a,i.blobSize-14))!==i.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(t,e){var r=e.headerInfo,n=this.getDataTypeArray(r.imageType),i=r.numDims*this.getDataTypeSize(r.imageType),a=this.readSubArray(t,e.ptr,n,i),o=this.readSubArray(t,e.ptr+i,n,i);e.ptr+=2*i;var s,l=!0;for(s=0;s0){r=new Uint8Array(Math.ceil(o/8));var c=(l=new DataView(t,i,u.numBytes)).getInt16(0,!0),h=2,d=0,f=0;do{if(c>0)for(;c--;)r[d++]=l.getUint8(h++);else for(f=l.getUint8(h++),c=-c;c--;)r[d++]=f;c=l.getInt16(h,!0),h+=2}while(h>3],p<<=7&m):p=r[m>>3],128&p&&(n[m]=1);e.pixels.resultMask=n,u.bitset=r,i+=u.numBytes}return e.ptr=i,e.mask=u,!0},readDataOneSweep:function(t,e,r,n){var i,a=e.ptr,o=e.headerInfo,s=o.numDims,l=o.width*o.height,u=o.imageType,c=o.numValidPixel*f.getDataTypeSize(u)*s,h=e.pixels.resultMask;if(r===Uint8Array)i=new Uint8Array(t,a,c);else{var d=new ArrayBuffer(c);new Uint8Array(d).set(new Uint8Array(t,a,c)),i=new r(d)}if(i.length===l*s)e.pixels.resultPixels=n?f.swapDimensionOrder(i,l,s,r,!0):i;else{e.pixels.resultPixels=new r(l*s);var p=0,m=0,g=0,v=0;if(s>1){if(n){for(m=0;m=o)return!1;var s=new Uint32Array(o-a);f.decodeBits(t,e,s);var l,u,c,h,d=[];for(l=a;l0&&(d[u].second=y<<_>>>32-h,32-_>=h?32===(_+=h)&&(_=0,y=x[++w]):(_+=h-32,y=x[++w],d[u].second|=y>>>32-_));var b=0,M=0,S=new p;for(l=0;l=r?r:b;var T,E,A,R,P,C=[];for(l=a;l0)if(T=[h,u],h<=M)for(E=d[u].second<=0;R--)E>>>R&1?(P.right||(P.right=new p),P=P.right):(P.left||(P.left=new p),P=P.left),0!==R||P.val||(P.val=T[1]);return{decodeLut:C,numBitsLUTQick:M,numBitsLUT:b,tree:S,stuffedData:x,srcPtr:w,bitPos:_}},readHuffman:function(t,e,r,n){var i,a,o,s,l,u,c,h,d,p=e.headerInfo.numDims,m=e.headerInfo.height,g=e.headerInfo.width,v=g*m,y=this.readHuffmanTree(t,e),x=y.decodeLut,_=y.tree,w=y.stuffedData,b=y.srcPtr,M=y.bitPos,S=y.numBitsLUTQick,T=y.numBitsLUT,E=0===e.headerInfo.imageType?128:0,A=e.pixels.resultMask,R=0;M>0&&(b++,M=0);var P,C=w[b],I=1===e.encodeMode,L=new r(v*p),O=L;if(p<2||I){for(P=0;P1&&(O=new r(L.buffer,v*P,v),R=0),e.headerInfo.numValidPixel===g*m)for(h=0,u=0;u>>32-S,32-M>>64-M-S),x[l])a=x[l][1],M+=x[l][0];else for(l=s=C<>>32-T,32-M>>64-M-T),i=_,d=0;d>>T-d-1&1?i.right:i.left).left&&!i.right){a=i.val,M=M+d+1;break}M>=32&&(M-=32,C=w[++b]),o=a-E,I?(o+=c>0?R:u>0?O[h-g]:R,o&=255,O[h]=o,R=o):O[h]=o}else for(h=0,u=0;u>>32-S,32-M>>64-M-S),x[l])a=x[l][1],M+=x[l][0];else for(l=s=C<>>32-T,32-M>>64-M-T),i=_,d=0;d>>T-d-1&1?i.right:i.left).left&&!i.right){a=i.val,M=M+d+1;break}M>=32&&(M-=32,C=w[++b]),o=a-E,I?(c>0&&A[h-1]?o+=R:u>0&&A[h-g]?o+=O[h-g]:o+=R,o&=255,O[h]=o,R=o):O[h]=o}}else for(h=0,u=0;u>>32-S,32-M>>64-M-S),x[l])a=x[l][1],M+=x[l][0];else for(l=s=C<>>32-T,32-M>>64-M-T),i=_,d=0;d>>T-d-1&1?i.right:i.left).left&&!i.right){a=i.val,M=M+d+1;break}M>=32&&(M-=32,C=w[++b]),o=a-E,O[h]=o}e.ptr=e.ptr+4*(b+1)+(M>0?4:0),e.pixels.resultPixels=L,p>1&&!n&&(e.pixels.resultPixels=f.swapDimensionOrder(L,v,p,r))},decodeBits:function(t,e,r,n,i){var a=e.headerInfo,o=a.fileVersion,f=0,p=t.byteLength-e.ptr>=5?5:t.byteLength-e.ptr,m=new DataView(t,e.ptr,p),g=m.getUint8(0);f++;var v=g>>6,y=0===v?4:3-v,x=(32&g)>0,_=31&g,w=0;if(1===y)w=m.getUint8(f),f++;else if(2===y)w=m.getUint16(f,!0),f+=2;else{if(4!==y)throw"Invalid valid pixel count type";w=m.getUint32(f,!0),f+=4}var b,M,S,T,E,A,R,P,C,I=2*a.maxZError,L=a.numDims>1?a.maxValues[i]:a.zMax;if(x){for(e.counter.lut++,P=m.getUint8(f),f++,T=Math.ceil((P-1)*_/8),E=Math.ceil(T/4),M=new ArrayBuffer(4*E),S=new Uint8Array(M),e.ptr+=f,S.set(new Uint8Array(t,e.ptr,T)),R=new Uint32Array(M),e.ptr+=T,C=0;P-1>>>C;)C++;T=Math.ceil(w*C/8),E=Math.ceil(T/4),M=new ArrayBuffer(4*E),(S=new Uint8Array(M)).set(new Uint8Array(t,e.ptr,T)),b=new Uint32Array(M),e.ptr+=T,A=o>=3?c(R,_,P-1,n,I,L):l(R,_,P-1,n,I,L),o>=3?u(b,r,C,w,A):s(b,r,C,w,A)}else e.counter.bitstuffer++,C=_,e.ptr+=f,C>0&&(T=Math.ceil(w*C/8),E=Math.ceil(T/4),M=new ArrayBuffer(4*E),(S=new Uint8Array(M)).set(new Uint8Array(t,e.ptr,T)),b=new Uint32Array(M),e.ptr+=T,o>=3?null==n?d(b,r,C,w):u(b,r,C,w,!1,n,I,L):null==n?h(b,r,C,w):s(b,r,C,w,!1,n,I,L))},readTiles:function(t,e,r,n){var i=e.headerInfo,a=i.width,o=i.height,s=a*o,l=i.microBlockSize,u=i.imageType,c=f.getDataTypeSize(u),h=Math.ceil(a/l),d=Math.ceil(o/l);e.pixels.numBlocksY=d,e.pixels.numBlocksX=h,e.pixels.ptr=0;var p,m,g,v,y,x,_,w,b,M,S=0,T=0,E=0,A=0,R=0,P=0,C=0,I=0,L=0,O=0,D=0,k=0,F=0,N=0,U=0,B=new r(l*l),z=o%l||l,G=a%l||l,j=i.numDims,V=e.pixels.resultMask,H=e.pixels.resultPixels,W=i.fileVersion>=5?14:15,q=i.zMax;for(E=0;E1?(M=H,O=E*a*l+A*l,H=new r(e.pixels.resultPixels.buffer,s*w*c,s),q=i.maxValues[w]):M=null,C=t.byteLength-e.ptr,m={},U=0,I=(p=new DataView(t,e.ptr,Math.min(10,C))).getUint8(0),U++,b=i.fileVersion>=5?4&I:0,L=I>>6&255,(I>>2&W)!=(A*l>>3&W))throw"integrity issue";if(b&&0===w)throw"integrity issue";if((y=3&I)>3)throw e.ptr+=U,"Invalid block encoding ("+y+")";if(2!==y)if(0===y){if(b)throw"integrity issue";if(e.counter.uncompressed++,e.ptr+=U,k=(k=R*P*c)<(F=t.byteLength-e.ptr)?k:F,g=new ArrayBuffer(k%c==0?k:k+c-k%c),new Uint8Array(g).set(new Uint8Array(t,e.ptr,k)),v=new r(g),N=0,V)for(S=0;S1&&!n&&(e.pixels.resultPixels=f.swapDimensionOrder(e.pixels.resultPixels,s,j,r))},formatFileInfo:function(t){return{fileIdentifierString:t.headerInfo.fileIdentifierString,fileVersion:t.headerInfo.fileVersion,imageType:t.headerInfo.imageType,height:t.headerInfo.height,width:t.headerInfo.width,numValidPixel:t.headerInfo.numValidPixel,microBlockSize:t.headerInfo.microBlockSize,blobSize:t.headerInfo.blobSize,maxZError:t.headerInfo.maxZError,pixelType:f.getPixelType(t.headerInfo.imageType),eofOffset:t.eofOffset,mask:t.mask?{numBytes:t.mask.numBytes}:null,pixels:{numBlocksX:t.pixels.numBlocksX,numBlocksY:t.pixels.numBlocksY,maxValue:t.headerInfo.zMax,minValue:t.headerInfo.zMin,noDataValue:t.noDataValue}}},constructConstantSurface:function(t,e){var r=t.headerInfo.zMax,n=t.headerInfo.zMin,i=t.headerInfo.maxValues,a=t.headerInfo.numDims,o=t.headerInfo.height*t.headerInfo.width,s=0,l=0,u=0,c=t.pixels.resultMask,h=t.pixels.resultPixels;if(c)if(a>1){if(e)for(s=0;s1&&n!==r)if(e)for(s=0;s=-128&&e<=127;break;case 1:r=e>=0&&e<=255;break;case 2:r=e>=-32768&&e<=32767;break;case 3:r=e>=0&&e<=65536;break;case 4:r=e>=-2147483648&&e<=2147483647;break;case 5:r=e>=0&&e<=4294967296;break;case 6:r=e>=-34027999387901484e22&&e<=34027999387901484e22;break;case 7:r=e>=-17976931348623157e292&&e<=17976931348623157e292;break;default:r=!1}return r},getDataTypeSize:function(t){var e=0;switch(t){case 0:case 1:e=1;break;case 2:case 3:e=2;break;case 4:case 5:case 6:e=4;break;case 7:e=8;break;default:e=t}return e},getDataTypeUsed:function(t,e){var r=t;switch(t){case 2:case 4:r=t-e;break;case 3:case 5:r=t-2*e;break;case 6:r=0===e?t:1===e?2:1;break;case 7:r=0===e?t:t-2*e+1;break;default:r=t}return r},getOnePixel:function(t,e,r,n){var i=0;switch(r){case 0:i=n.getInt8(e);break;case 1:i=n.getUint8(e);break;case 2:i=n.getInt16(e,!0);break;case 3:i=n.getUint16(e,!0);break;case 4:i=n.getInt32(e,!0);break;case 5:i=n.getUInt32(e,!0);break;case 6:i=n.getFloat32(e,!0);break;case 7:i=n.getFloat64(e,!0);break;default:throw"the decoder does not understand this pixel type"}return i},swapDimensionOrder:function(t,e,r,n,i){var a=0,o=0,s=0,l=0,u=t;if(r>1)if(u=new n(e*r),i)for(a=0;a5)throw"unsupported lerc version 2."+o;f.readMask(t,i),a.numValidPixel===a.width*a.height||i.pixels.resultMask||(i.pixels.resultMask=e.maskData);var l=a.width*a.height;i.pixels.resultPixels=new s(l*a.numDims),i.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var u,c=!e.returnPixelInterleavedDims;if(0!==a.numValidPixel)if(a.zMax===a.zMin)f.constructConstantSurface(i,c);else if(o>=4&&f.checkMinMaxRanges(t,i))f.constructConstantSurface(i,c);else{var h=new DataView(t,i.ptr,2),d=h.getUint8(0);if(i.ptr++,d)f.readDataOneSweep(t,i,s,c);else if(o>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var p=h.getUint8(1);if(i.ptr++,i.encodeMode=p,p>2||o<4&&p>1)throw"Invalid Huffman flag "+p;p?f.readHuffman(t,i,s,c):f.readTiles(t,i,s,c)}else f.readTiles(t,i,s,c)}i.eofOffset=i.ptr,e.inputOffset?(u=i.headerInfo.blobSize+e.inputOffset-i.ptr,Math.abs(u)>=1&&(i.eofOffset=e.inputOffset+i.headerInfo.blobSize)):(u=i.headerInfo.blobSize-i.ptr,Math.abs(u)>=1&&(i.eofOffset=i.headerInfo.blobSize));var m={width:a.width,height:a.height,pixelData:i.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:i.pixels.resultMask};if(i.pixels.resultMask&&f.isValidPixelValue(a.imageType,r)){var g=i.pixels.resultMask;for(n=0;n1&&(u&&m.push(u),w.fileInfo.mask&&w.fileInfo.mask.numBytes>0&&_++),f++,g.pixels.push(w.pixelData),g.statistics.push({minValue:w.minValue,maxValue:w.maxValue,noDataValue:w.noDataValue,dimStats:w.dimStats})}if(n>1&&_>1){for(d=g.width*g.height,g.bandMasks=m,(u=new Uint8Array(d)).set(m[0]),c=1;cn.set(t,e)))}return VI.addDecoder=i,VI.getDecoder=async function(t){const e=n.get(t.Compression);if(!e)throw new Error(`Unknown compression method identifier: ${t.Compression}`);return new(await e())(t)},i([void 0,1],(()=>Promise.resolve().then((()=>r(function(){if(jI)return HI;jI=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(HI,"__esModule",{value:!0});const e=t(XI());class r extends e.default{decodeBlock(t){return t}}return HI.default=r,HI}()))).then((t=>t.default)))),i(5,(()=>Promise.resolve().then((()=>r(KI()))).then((t=>t.default)))),i(6,(()=>{throw new Error("old style JPEG compression is not supported.")})),i(7,(()=>Promise.resolve().then((()=>r(function(){if(JI)return QI;JI=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(QI,"__esModule",{value:!0});const e=t(XI()),r=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),n=4017,i=799,a=3406,o=2276,s=1567,l=3784,u=5793,c=2896;function h(t,e){let r=0;const n=[];let i=16;for(;i>0&&!t[i-1];)--i;n.push({children:[],index:0});let a,o=n[0];for(let s=0;s0;)o=n.pop();for(o.index++,n.push(o);n.length<=s;)n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a;r++}s+10)return m--,p>>m&1;if(p=t[f++],255===p){const e=t[f++];if(e)throw new Error(`unexpected marker: ${(p<<8|e).toString(16)}`)}return m=7,p>>>7}function v(t){let e,r=t;for(;null!==(e=g());){if(r=r[e],"number"==typeof r)return r;if("object"!=typeof r)throw new Error("invalid huffman sequence")}return null}function y(t){let e=t,r=0;for(;e>0;){const t=g();if(null===t)return;r=r<<1|t,--e}return r}function x(t){const e=y(t);return e>=1<0)return void w--;let n=o;const i=s;for(;n<=i;){const i=v(t.huffmanTableAC),a=15&i,o=i>>4;if(0===a){if(o<15){w=y(o)+(1<>4,0===r)a<15?(w=y(a)+(1<>4;if(0===i){if(o<15)break;a+=16}else a+=o,e[r[a]]=x(i),a++}};let L,O,D=0;O=1===T?i[0].blocksPerLine*i[0].blocksPerColumn:c*n.mcusPerColumn;const k=a||O;for(;D=65488&&L<=65495))break;f+=2}return f-d}function f(t,e){const r=[],{blocksPerLine:h,blocksPerColumn:d}=e,f=h<<3,p=new Int32Array(64),m=new Uint8Array(64);function g(t,r,h){const d=e.quantizationTable;let f,p,m,g,v,y,x,_,w;const b=h;let M;for(M=0;M<64;M++)b[M]=t[M]*d[M];for(M=0;M<8;++M){const t=8*M;0!==b[1+t]||0!==b[2+t]||0!==b[3+t]||0!==b[4+t]||0!==b[5+t]||0!==b[6+t]||0!==b[7+t]?(f=u*b[0+t]+128>>8,p=u*b[4+t]+128>>8,m=b[2+t],g=b[6+t],v=c*(b[1+t]-b[7+t])+128>>8,_=c*(b[1+t]+b[7+t])+128>>8,y=b[3+t]<<4,x=b[5+t]<<4,w=f-p+1>>1,f=f+p+1>>1,p=w,w=m*l+g*s+128>>8,m=m*s-g*l+128>>8,g=w,w=v-x+1>>1,v=v+x+1>>1,x=w,w=_+y+1>>1,y=_-y+1>>1,_=w,w=f-g+1>>1,f=f+g+1>>1,g=w,w=p-m+1>>1,p=p+m+1>>1,m=w,w=v*o+_*a+2048>>12,v=v*a-_*o+2048>>12,_=w,w=y*i+x*n+2048>>12,y=y*n-x*i+2048>>12,x=w,b[0+t]=f+_,b[7+t]=f-_,b[1+t]=p+x,b[6+t]=p-x,b[2+t]=m+y,b[5+t]=m-y,b[3+t]=g+v,b[4+t]=g-v):(w=u*b[0+t]+512>>10,b[0+t]=w,b[1+t]=w,b[2+t]=w,b[3+t]=w,b[4+t]=w,b[5+t]=w,b[6+t]=w,b[7+t]=w)}for(M=0;M<8;++M){const t=M;0!==b[8+t]||0!==b[16+t]||0!==b[24+t]||0!==b[32+t]||0!==b[40+t]||0!==b[48+t]||0!==b[56+t]?(f=u*b[0+t]+2048>>12,p=u*b[32+t]+2048>>12,m=b[16+t],g=b[48+t],v=c*(b[8+t]-b[56+t])+2048>>12,_=c*(b[8+t]+b[56+t])+2048>>12,y=b[24+t],x=b[40+t],w=f-p+1>>1,f=f+p+1>>1,p=w,w=m*l+g*s+2048>>12,m=m*s-g*l+2048>>12,g=w,w=v-x+1>>1,v=v+x+1>>1,x=w,w=_+y+1>>1,y=_-y+1>>1,_=w,w=f-g+1>>1,f=f+g+1>>1,g=w,w=p-m+1>>1,p=p+m+1>>1,m=w,w=v*o+_*a+2048>>12,v=v*a-_*o+2048>>12,_=w,w=y*i+x*n+2048>>12,y=y*n-x*i+2048>>12,x=w,b[0+t]=f+_,b[56+t]=f-_,b[8+t]=p+x,b[48+t]=p-x,b[16+t]=m+y,b[40+t]=m-y,b[24+t]=g+v,b[32+t]=g-v):(w=u*h[M+0]+8192>>14,b[0+t]=w,b[8+t]=w,b[16+t]=w,b[24+t]=w,b[32+t]=w,b[40+t]=w,b[48+t]=w,b[56+t]=w)}for(M=0;M<64;++M){const t=128+(b[M]+8>>4);r[M]=t<0?0:t>255?255:t}}for(let t=0;t>4==0)for(let n=0;n<64;n++)a[r[n]]=t[e++];else{if(i>>4!=1)throw new Error("DQT: invalid table spec");for(let t=0;t<64;t++)a[r[t]]=n()}this.quantizationTables[15&i]=a}break}case 65472:case 65473:case 65474:{n();const r={extended:65473===o,progressive:65474===o,precision:t[e++],scanLines:n(),samplesPerLine:n(),components:{},componentsOrder:[]},i=t[e++];let s;for(let n=0;n>4,i=15&t[e+1],a=t[e+2];r.componentsOrder.push(s),r.components[s]={h:n,v:i,quantizationIdx:a},e+=3}a(r),this.frames.push(r);break}case 65476:{const r=n();for(let n=2;n>4==0?this.huffmanTablesDC[15&r]=h(i,o):this.huffmanTablesAC[15&r]=h(i,o)}break}case 65501:n(),this.resetInterval=n();break;case 65498:{n();const r=t[e++],i=[],a=this.frames[0];for(let n=0;n>4],r.huffmanTableAC=this.huffmanTablesAC[15&n],i.push(r)}const o=t[e++],s=t[e++],l=t[e++],u=d(t,e,a,i,this.resetInterval,o,s,l>>4,15&l);e+=u;break}case 65535:255!==t[e]&&e--;break;default:if(255===t[e-3]&&t[e-2]>=192&&t[e-2]<=254){e-=3;break}throw new Error(`unknown JPEG marker ${o.toString(16)}`)}o=n()}}getResult(){const{frames:t}=this;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(let t=0;tt.default)))),i([8,32946],(()=>Promise.resolve().then((()=>r(function(){if(BL)return uL;BL=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(uL,"__esModule",{value:!0});const e=HL(),r=t(XI());class n extends r.default{decodeBlock(t){return(0,e.inflate)(new Uint8Array(t)).buffer}}return uL.default=n,uL}()))).then((t=>t.default)))),i(32773,(()=>Promise.resolve().then((()=>r(function(){if(WL)return qL;WL=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(qL,"__esModule",{value:!0});const e=t(XI());class r extends e.default{decodeBlock(t){const e=new DataView(t),r=[];for(let n=0;nt.default)))),i(34887,(()=>Promise.resolve().then((()=>r(QL()))).then((t=>t.default)))),i(50001,(()=>Promise.resolve().then((()=>r(function(){if($L)return eO;$L=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(eO,"__esModule",{value:!0});const e=t(XI());class r extends e.default{constructor(){if(super(),"undefined"==typeof createImageBitmap)throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");if("undefined"==typeof document&&"undefined"==typeof OffscreenCanvas)throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available")}async decode(t,e){const r=new Blob([e]),n=await createImageBitmap(r);let i;"undefined"!=typeof document?(i=document.createElement("canvas"),i.width=n.width,i.height=n.height):i=new OffscreenCanvas(n.width,n.height);const a=i.getContext("2d");return a.drawImage(n,0,0),a.getImageData(0,0,n.width,n.height).data.buffer}}return eO.default=r,eO}()))).then((t=>t.default)))),VI}var nO,iO,aO={};function oO(){if(iO)return zC;iO=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(zC,"__esModule",{value:!0});const e=pI(),r=t(function(){if(mI)return gI;function t(t,e,r){const n=r&&r.debug||!1;n&&console.log("getting "+e+" in "+t);const i="object"==typeof t?t.outer:t,a=`${e}\\="([^"]*)"`;n&&console.log("pattern:",a);const o=new RegExp(a).exec(i);if(n&&console.log("match:",o),o)return o[1]}return mI=1,vI.exports=t,gI.default=t,gI}()),n=t(function(){if(CI)return xI;CI=1;const t=OI();function e(e,r,n){const i=[],a=n&&n.debug||!1,o=!n||"boolean"!=typeof n.nested||n.nested;let s,l=n&&n.startIndex||0;for(;s=t(e,r,{debug:a,startIndex:l});)l=o?s.start+1+r.length:s.end,i.push(s);return a&&console.log("findTagsByName found",i.length,"tags"),i}return _I.exports=e,xI.default=e,xI}()),i=FI(),a=BI(),o=rO(),s=function(){if(nO)return aO;function t(t,e,r,n=1){return new(Object.getPrototypeOf(t).constructor)(e*r*n)}function e(e,r,n,i,a){const o=r/i,s=n/a;return e.map((e=>{const l=t(e,i,a);for(let t=0;t{const u=t(e,a,o);for(let t=0;t=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${t} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[t]/8)}getReaderForSample(t){const r=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[t]:1,n=this.fileDirectory.BitsPerSample[t];switch(r){case 1:if(n<=8)return DataView.prototype.getUint8;if(n<=16)return DataView.prototype.getUint16;if(n<=32)return DataView.prototype.getUint32;break;case 2:if(n<=8)return DataView.prototype.getInt8;if(n<=16)return DataView.prototype.getInt16;if(n<=32)return DataView.prototype.getInt32;break;case 3:switch(n){case 16:return function(t,r){return(0,e.getFloat16)(this,t,r)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(t=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[t]:1}getBitsPerSample(t=0){return this.fileDirectory.BitsPerSample[t]}getArrayForSample(t,e){return u(this.getSampleFormat(t),this.getBitsPerSample(t),e)}async getTileOrStrip(t,e,r,n,i){const a=Math.ceil(this.getWidth()/this.getTileWidth()),o=Math.ceil(this.getHeight()/this.getTileHeight());let s;const{tiles:l}=this;let c,h;1===this.planarConfiguration?s=e*a+t:2===this.planarConfiguration&&(s=r*a*o+e*a+t),this.isTiled?(c=this.fileDirectory.TileOffsets[s],h=this.fileDirectory.TileByteCounts[s]):(c=this.fileDirectory.StripOffsets[s],h=this.fileDirectory.StripByteCounts[s]);const d=(await this.source.fetch([{offset:c,length:h}],i))[0];let f;return null!==l&&l[s]?f=l[s]:(f=(async()=>{let t=await n.decode(this.fileDirectory,d);const r=this.getSampleFormat(),i=this.getBitsPerSample();return function(t,e){return(1!==t&&2!==t||!(e<=32)||e%8!=0)&&(3!==t||16!==e&&32!==e&&64!==e)}(r,i)&&(t=function(t,e,r,n,i,a,o){const s=new DataView(t),l=2===r?1:n,c=u(e,i,2===r?o*a:o*a*n),h=parseInt("1".repeat(i),2);if(1===e){let t;t=1===r?n*i:i;let e=a*t;0!=(7&e)&&(e=e+7&-8);for(let t=0;t>8-i-f&h;else if(f+i<=16)c[u]=s.getUint16(d)>>16-i-f&h;else if(f+i<=24){const t=s.getUint16(d)<<8|s.getUint8(d+2);c[u]=t>>24-i-f&h}else c[u]=s.getUint32(d)>>32-i-f&h}}}}return c.buffer}(t,r,this.planarConfiguration,this.getSamplesPerPixel(),i,this.getTileWidth(),this.getBlockHeight(e))),t})(),null!==l&&(l[s]=f)),{x:t,y:e,sample:r,data:await f}}async _readRaster(t,e,r,n,i,a,o,u,c){const h=this.getTileWidth(),d=this.getTileHeight(),f=this.getWidth(),p=this.getHeight(),m=Math.max(Math.floor(t[0]/h),0),g=Math.min(Math.ceil(t[2]/h),Math.ceil(f/h)),v=Math.max(Math.floor(t[1]/d),0),y=Math.min(Math.ceil(t[3]/d),Math.ceil(p/d)),x=t[2]-t[0];let _=this.getBytesPerPixel();const w=[],b=[];for(let t=0;t{const a=i.data,o=new DataView(a),s=this.getBlockHeight(i.y),u=i.y*d,c=i.x*h,m=u+s,g=(i.x+1)*h,v=b[l],y=Math.min(s,s-(m-t[3]),p-u),M=Math.min(h,h-(g-t[2]),f-c);for(let i=Math.max(0,t[1]-u);ih[2]||h[1]>h[3])throw new Error("Invalid subsets");const d=(h[2]-h[0])*(h[3]-h[1]),f=this.getSamplesPerPixel();if(e&&e.length){for(let t=0;t=f)return Promise.reject(new RangeError(`Invalid sample index '${e[t]}'.`))}else for(let t=0;tc[2]||c[1]>c[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===i.photometricInterpretations.RGB){let a=[0,1,2];if(this.fileDirectory.ExtraSamples!==i.ExtraSamplesValues.Unspecified&&l){a=[];for(let t=0;tvoid 0===(0,r.default)(t,"sample"))):a.filter((e=>Number((0,r.default)(e,"sample"))===t));for(let t=0;t=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var f=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(f&&l){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:D(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":r(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(n);var i=n.exports,a=new Map;function o(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){return a.set(e,t)}))}function s(e){return f.apply(this,arguments)}function f(){return(f=t(i.mark((function e(t){var r,n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.get(t.Compression)){e.next=3;break}throw new Error("Unknown compression method identifier: ".concat(t.Compression));case 3:return e.next=5,r();case 5:return n=e.sent,e.abrupt("return",new n(t));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}o([void 0,1],(function(){return Promise.resolve().then((function(){return _})).then((function(e){return e.default}))})),o(5,(function(){return Promise.resolve().then((function(){return S})).then((function(e){return e.default}))})),o(6,(function(){throw new Error("old style JPEG compression is not supported.")})),o(7,(function(){return Promise.resolve().then((function(){return L})).then((function(e){return e.default}))})),o([8,32946],(function(){return Promise.resolve().then((function(){return Ne})).then((function(e){return e.default}))})),o(32773,(function(){return Promise.resolve().then((function(){return Ye})).then((function(e){return e.default}))})),o(34887,(function(){return Promise.resolve().then((function(){return ut})).then((function(e){return e.default}))})),o(50001,(function(){return Promise.resolve().then((function(){return dt})).then((function(e){return e.default}))}));var l=globalThis;function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r0;i--)e[n+t]+=e[n],n++;r-=t}while(r>0)}function w(e,t,r){for(var n=0,i=e.length,a=i/r;i>t;){for(var o=t;o>0;--o)e[n+t]+=e[n],++n;i-=t}for(var s=e.slice(),f=0;f=e.byteLength);++l){var u=void 0;if(2===t){switch(i[0]){case 8:u=new Uint8Array(e,l*f*r*s,f*r*s);break;case 16:u=new Uint16Array(e,l*f*r*s,f*r*s/2);break;case 32:u=new Uint32Array(e,l*f*r*s,f*r*s/4);break;default:throw new Error("Predictor 2 not allowed with ".concat(i[0]," bits per sample."))}y(u,f)}else 3===t&&w(u=new Uint8Array(e,l*f*r*s,f*r*s),f,s)}return e}l.addEventListener("message",function(){var e=t(i.mark((function e(t){var r,n,a,o,f,u;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.data,n=r.id,a=r.fileDirectory,o=r.buffer,e.next=3,s(a);case 3:return f=e.sent,e.next=6,f.decode(a,o);case 6:u=e.sent,l.postMessage({decoded:u,id:n},[u]);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());var b=function(){function e(){u(this,e)}var r;return h(e,[{key:"decode",value:(r=t(i.mark((function e(t,r){var n,a,o,s,f;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decodeBlock(r);case 2:if(n=e.sent,1===(a=t.Predictor||1)){e.next=9;break}return o=!t.StripOffsets,s=o?t.TileWidth:t.ImageWidth,f=o?t.TileLength:t.RowsPerStrip||t.ImageLength,e.abrupt("return",g(n,a,s,f,t.BitsPerSample,t.PlanarConfiguration));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})}]),e}();function k(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var x=function(e){p(r,b);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return e}}]),r}(),_=Object.freeze({__proto__:null,default:x});function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}function P(e,t){for(var r=t.length-1;r>=0;r--)e.push(t[r]);return e}function I(e){for(var t=new Uint16Array(4093),r=new Uint8Array(4093),n=0;n<=257;n++)t[n]=4096,r[n]=n;var i=258,a=9,o=0;function s(){i=258,a=9}function f(e){var t=function(e,t,r){var n=t%8,i=Math.floor(t/8),a=8-n,o=t+r-8*(i+1),s=8*(i+2)-(t+r),f=8*(i+2)-t;if(s=Math.max(0,s),i>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),257;var l=e[i]&Math.pow(2,8-n)-1,u=l<<=r-a;if(i+1>>s;u+=c<<=Math.max(0,r-f)}if(o>8&&i+2>>h}return u}(e,o,a);return o+=a,t}function l(e,n){return r[i]=n,t[i]=e,++i-1}function u(e){for(var n=[],i=e;4096!==i;i=t[i])n.push(r[i]);return n}var c=[];s();for(var h,d=new Uint8Array(e),p=f(d);257!==p;){if(256===p){for(s(),p=f(d);256===p;)p=f(d);if(257===p)break;if(p>256)throw new Error("corrupted code at scanline ".concat(p));P(c,u(p)),h=p}else if(p=Math.pow(2,a)&&(12===a?h=void 0:a++),p=f(d)}return new Uint8Array(c)}var U=function(e){p(r,b);var t=A(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return I(e).buffer}}]),r}(),S=Object.freeze({__proto__:null,default:U});function T(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var D=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function E(e,t){for(var r=0,n=[],i=16;i>0&&!e[i-1];)--i;n.push({children:[],index:0});for(var a,o=n[0],s=0;s0;)o=n.pop();for(o.index++,n.push(o);n.length<=s;)n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a;r++}s+10)return m--,p>>m&1;if(255===(p=e[d++])){var t=e[d++];if(t)throw new Error("unexpected marker: ".concat((p<<8|t).toString(16)))}return m=7,p>>>7}function y(e){for(var t,n=e;null!==(t=v());){if("number"==typeof(n=n[t]))return n;if("object"!==r(n))throw new Error("invalid huffman sequence")}return null}function w(e){for(var t=e,r=0;t>0;){var n=v();if(null===n)return;r=r<<1|n,--t}return r}function g(e){var t=w(e);return t>=1<0)b--;else for(var r=o,n=s;r<=n;){var i=y(e.huffmanTableAC),a=15&i,f=i>>4;if(0===a){if(f<15){b=w(f)+(1<>4,0===c)i<15?(b=w(i)+(1<>4;if(0===o){if(s<15)break;i+=16}else t[D[i+=s]]=g(o),i++}};var O,M,C=0;M=1===B?i[0].blocksPerLine*i[0].blocksPerColumn:u*n.mcusPerColumn;for(var L=a||M;C=65488&&O<=65495))break;d+=2}return d-h}function O(e,t){var r=[],n=t.blocksPerLine,i=t.blocksPerColumn,a=n<<3,o=new Int32Array(64),s=new Uint8Array(64);function f(e,r,n){var i,a,o,s,f,l,u,c,h,d,p=t.quantizationTable,m=n;for(d=0;d<64;d++)m[d]=e[d]*p[d];for(d=0;d<8;++d){var v=8*d;0!==m[1+v]||0!==m[2+v]||0!==m[3+v]||0!==m[4+v]||0!==m[5+v]||0!==m[6+v]||0!==m[7+v]?(i=5793*m[0+v]+128>>8,a=5793*m[4+v]+128>>8,o=m[2+v],s=m[6+v],f=2896*(m[1+v]-m[7+v])+128>>8,c=2896*(m[1+v]+m[7+v])+128>>8,l=m[3+v]<<4,h=i-a+1>>1,i=i+a+1>>1,a=h,h=3784*o+1567*s+128>>8,o=1567*o-3784*s+128>>8,s=h,h=f-(u=m[5+v]<<4)+1>>1,f=f+u+1>>1,u=h,h=c+l+1>>1,l=c-l+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=2276*f+3406*c+2048>>12,f=3406*f-2276*c+2048>>12,c=h,h=799*l+4017*u+2048>>12,l=4017*l-799*u+2048>>12,u=h,m[0+v]=i+c,m[7+v]=i-c,m[1+v]=a+u,m[6+v]=a-u,m[2+v]=o+l,m[5+v]=o-l,m[3+v]=s+f,m[4+v]=s-f):(h=5793*m[0+v]+512>>10,m[0+v]=h,m[1+v]=h,m[2+v]=h,m[3+v]=h,m[4+v]=h,m[5+v]=h,m[6+v]=h,m[7+v]=h)}for(d=0;d<8;++d){var y=d;0!==m[8+y]||0!==m[16+y]||0!==m[24+y]||0!==m[32+y]||0!==m[40+y]||0!==m[48+y]||0!==m[56+y]?(i=5793*m[0+y]+2048>>12,a=5793*m[32+y]+2048>>12,o=m[16+y],s=m[48+y],f=2896*(m[8+y]-m[56+y])+2048>>12,c=2896*(m[8+y]+m[56+y])+2048>>12,l=m[24+y],h=i-a+1>>1,i=i+a+1>>1,a=h,h=3784*o+1567*s+2048>>12,o=1567*o-3784*s+2048>>12,s=h,h=f-(u=m[40+y])+1>>1,f=f+u+1>>1,u=h,h=c+l+1>>1,l=c-l+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=2276*f+3406*c+2048>>12,f=3406*f-2276*c+2048>>12,c=h,h=799*l+4017*u+2048>>12,l=4017*l-799*u+2048>>12,u=h,m[0+y]=i+c,m[56+y]=i-c,m[8+y]=a+u,m[48+y]=a-u,m[16+y]=o+l,m[40+y]=o-l,m[24+y]=s+f,m[32+y]=s-f):(h=5793*n[d+0]+8192>>14,m[0+y]=h,m[8+y]=h,m[16+y]=h,m[24+y]=h,m[32+y]=h,m[40+y]=h,m[48+y]=h,m[56+y]=h)}for(d=0;d<64;++d){var w=128+(m[d]+8>>4);r[d]=w<0?0:w>255?255:w}}for(var l=0;l>4==0)for(var c=0;c<64;c++){u[D[c]]=e[t++]}else{if(l>>4!=1)throw new Error("DQT: invalid table spec");for(var h=0;h<64;h++){u[D[h]]=r()}}this.quantizationTables[15&l]=u}break;case 65472:case 65473:case 65474:r();for(var d={extended:65473===o,progressive:65474===o,precision:e[t++],scanLines:r(),samplesPerLine:r(),components:{},componentsOrder:[]},p=e[t++],m=void 0,v=0;v>4,w=15&e[t+1],g=e[t+2];d.componentsOrder.push(m),d.components[m]={h:y,v:w,quantizationIdx:g},t+=3}n(d),this.frames.push(d);break;case 65476:for(var b=r(),k=2;k>4==0?this.huffmanTablesDC[15&x]=E(_,I):this.huffmanTablesAC[15&x]=E(_,I)}break;case 65501:r(),this.resetInterval=r();break;case 65498:r();for(var S=e[t++],T=[],O=this.frames[0],M=0;M>4],C.huffmanTableAC=this.huffmanTablesAC[15&L],T.push(C)}var R=e[t++],V=e[t++],G=e[t++],F=B(e,t,O,T,this.resetInterval,R,V,G>>4,15&G);t+=F;break;case 65535:255!==e[t]&&t--;break;default:if(255===e[t-3]&&e[t-2]>=192&&e[t-2]<=254){t-=3;break}throw new Error("unknown JPEG marker ".concat(o.toString(16)))}o=r()}}},{key:"getResult",value:function(){var e=this.frames;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(var t=0;t=0;)e[t]=0}R(new Array(576)),R(new Array(60)),R(new Array(512)),R(new Array(256)),R(new Array(29)),R(new Array(30));var V=function(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0},G=new Uint32Array(function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}()),F=function(e,t,r,n){var i=G,a=n+r;e^=-1;for(var o=n;o>>8^i[255&(e^t[o])];return-1^e},z={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},j={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},N=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},Z=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==r(n))throw new TypeError(n+"must be non-object");for(var i in n)N(n,i)&&(e[i]=n[i])}}return e},K=function(e){for(var t=0,r=0,n=e.length;r=252?6:X>=248?5:X>=240?4:X>=224?3:X>=192?2:1;Y[254]=Y[254]=1;var W=function(e){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,r,n,i,a,o=e.length,s=0;for(i=0;i>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},q=function(e,t){var r,n,i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var a=new Array(2*i);for(n=0,r=0;r4)a[n++]=65533,r+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&r1?a[n++]=65533:o<65536?a[n++]=o:(o-=65536,a[n++]=55296|o>>10&1023,a[n++]=56320|1023&o)}}}return function(e,t){if(t<65534&&e.subarray&&H)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var r="",n=0;ne.length&&(t=e.length);for(var r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Y[e[r]]>t?r:t};var Q=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},$=function(e,t){var r,n,i,a,o,s,f,l,u,c,h,d,p,m,v,y,w,g,b,k,x,_,A,P,I=e.state;r=e.next_in,A=e.input,n=r+(e.avail_in-5),i=e.next_out,P=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=I.dmax,f=I.wsize,l=I.whave,u=I.wnext,c=I.window,h=I.hold,d=I.bits,p=I.lencode,m=I.distcode,v=(1<>>=g=w>>>24,d-=g,0===(g=w>>>16&255))P[i++]=65535&w;else{if(!(16&g)){if(0==(64&g)){w=p[(65535&w)+(h&(1<>>=g,d-=g),d<15&&(h+=A[r++]<>>=g=w>>>24,d-=g,!(16&(g=w>>>16&255))){if(0==(64&g)){w=m[(65535&w)+(h&(1<s){e.msg="invalid distance too far back",I.mode=30;break e}if(h>>>=g,d-=g,k>(g=i-a)){if((g=k-g)>l&&I.sane){e.msg="invalid distance too far back",I.mode=30;break e}if(x=0,_=c,0===u){if(x+=f-g,g2;)P[i++]=_[x++],P[i++]=_[x++],P[i++]=_[x++],b-=3;b&&(P[i++]=_[x++],b>1&&(P[i++]=_[x++]))}else{x=i-k;do{P[i++]=P[x++],P[i++]=P[x++],P[i++]=P[x++],b-=3}while(b>2);b&&(P[i++]=P[x++],b>1&&(P[i++]=P[x++]))}break}}break}}while(r>3,h&=(1<<(d-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r=1&&0===D[k];k--);if(x>k&&(x=k),0===k)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(b=1;b0&&(0===e||1!==k))return-1;for(E[1]=0,w=1;w<15;w++)E[w+1]=E[w]+D[w];for(g=0;g852||2===e&&I>592)return 1;for(;;){p=w-A,o[g]d?(m=B[O+o[g]],v=S[T+o[g]]):(m=96,v=0),f=1<>A)+(l-=f)]=p<<24|m<<16|v|0}while(0!==l);for(f=1<>=1;if(0!==f?(U&=f-1,U+=f):U=0,g++,0==--D[w]){if(w===k)break;w=t[r+o[g]]}if(w>x&&(U&c)!==u){for(0===A&&(A=x),h+=b,P=1<<(_=w-A);_+A852||2===e&&I>592)return 1;i[u=U&c]=x<<24|_<<16|h-a|0}}return 0!==U&&(i[h+U]=w-A<<24|64<<16|0),s.bits=x,0},ae=j.Z_FINISH,oe=j.Z_BLOCK,se=j.Z_TREES,fe=j.Z_OK,le=j.Z_STREAM_END,ue=j.Z_NEED_DICT,ce=j.Z_STREAM_ERROR,he=j.Z_DATA_ERROR,de=j.Z_MEM_ERROR,pe=j.Z_BUF_ERROR,me=j.Z_DEFLATED,ve=function(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)};function ye(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var we,ge,be=function(e){if(!e||!e.state)return ce;var t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,fe},ke=function(e){if(!e||!e.state)return ce;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,be(e)},xe=function(e,t){var r;if(!e||!e.state)return ce;var n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ce:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ke(e))},_e=function(e,t){if(!e)return ce;var r=new ye;e.state=r,r.window=null;var n=xe(e,t);return n!==fe&&(e.state=null),n},Ae=!0,Pe=function(e){if(Ae){we=new Int32Array(512),ge=new Int32Array(32);for(var t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ie(1,e.lens,0,288,we,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ie(2,e.lens,0,32,ge,0,e.work,{bits:5}),Ae=!1}e.lencode=we,e.lenbits=9,e.distcode=ge,e.distbits=5},Ie=function(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=F(r.check,U,2,0),l=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&l)!==me){e.msg="unknown compression method",r.mode=30;break}if(u-=4,x=8+(15&(l>>>=4)),0===r.wbits)r.wbits=x;else if(x>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,l+=n[a++]<>>8&255,U[2]=l>>>16&255,U[3]=l>>>24&255,r.check=F(r.check,U,4,0)),l=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,l+=n[a++]<>8),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===s)break e;s--,l+=n[a++]<>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+d),x)),512&r.flags&&(r.check=F(r.check,n,d,a)),s-=d,a+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;d=0;do{x=n[a+d++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x))}while(x&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===s)break e;s--,l+=n[a++]<>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===s)break e;s--,l+=n[a++]<>>=1)){case 0:r.mode=14;break;case 1:if(Pe(r),r.mode=20,t===se){l>>>=2,u-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}l>>>=2,u-=2;break;case 14:for(l>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,l+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&l,l=0,u=0,r.mode=15,t===se)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>s&&(d=s),d>f&&(d=f),0===d)break e;i.set(n.subarray(a,a+d),o),s-=d,a+=d,f-=d,o+=d,r.length-=d;break}r.mode=12;break;case 17:for(;u<14;){if(0===s)break e;s--,l+=n[a++]<>>=5,u-=5,r.ndist=1+(31&l),l>>>=5,u-=5,r.ncode=4+(15&l),l>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[S[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},_=ie(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,_){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>>=v,u-=v,r.lens[r.have++]=w;else{if(16===w){for(P=v+2;u>>=v,u-=v,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}x=r.lens[r.have-1],d=3+(3&l),l>>>=2,u-=2}else if(17===w){for(P=v+3;u>>=v)),l>>>=3,u-=3}else{for(P=v+7;u>>=v)),l>>>=7,u-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=x}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,A={bits:r.lenbits},_=ie(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,_){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},_=ie(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,_){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===se)break e;case 20:r.mode=21;case 21:if(s>=6&&f>=258){e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=l,r.bits=u,$(e,h),o=e.next_out,i=e.output,f=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,l=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;y=(I=r.lencode[l&(1<>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>g)])>>>16&255,w=65535&I,!(g+(v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>>=g,u-=g,r.back+=g}if(l>>>=v,u-=v,r.back+=v,r.length=w,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(P=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;y=(I=r.distcode[l&(1<>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>g)])>>>16&255,w=65535&I,!(g+(v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>>=g,u-=g,r.back+=g}if(l>>>=v,u-=v,r.back+=v,64&y){e.msg="invalid distance code",r.mode=30;break}r.offset=w,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(P=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===f)break e;if(d=h-f,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=o-r.offset,d=r.length;d>f&&(d=f),f-=d,r.length-=d;do{i[o++]=m[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===f)break e;i[o++]=r.length,f--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===s)break e;s--,l|=n[a++]<=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Q,this.strm.avail_out=0;var r=Ue.inflateInit2(this.strm,t.windowBits);if(r!==Be)throw new Error(z[r]);if(this.header=new Se,Ue.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=W(t.dictionary):"[object ArrayBuffer]"===Te.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Ue.inflateSetDictionary(this.strm,t.dictionary))!==Be))throw new Error(z[r])}function Ge(e,t){var r=new Ve(t);if(r.push(e),r.err)throw r.msg||z[r.err];return r.result}Ve.prototype.push=function(e,t){var r,n,i,a=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?Ee:De,"[object ArrayBuffer]"===Te.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(o),a.next_out=0,a.avail_out=o),(r=Ue.inflate(a,n))===Me&&s&&((r=Ue.inflateSetDictionary(a,s))===Be?r=Ue.inflate(a,n):r===Le&&(r=Me));a.avail_in>0&&r===Oe&&a.state.wrap>0&&0!==e[a.next_in];)Ue.inflateReset(a),r=Ue.inflate(a,n);switch(r){case Ce:case Le:case Me:case Re:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===Oe))if("string"===this.options.to){var f=J(a.output,a.next_out),l=a.next_out-f,u=q(a.output,f);a.next_out=l,a.avail_out=o-l,l&&a.output.set(a.output.subarray(f,f+l),0),this.onData(u)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==Be||0!==i){if(r===Oe)return r=Ue.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Ve.prototype.onData=function(e){this.chunks.push(e)},Ve.prototype.onEnd=function(e){e===Be&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=K(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Fe={Inflate:Ve,inflate:Ge,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Ge(e,t)},ungzip:Ge,constants:j}.inflate;function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var je=function(e){p(r,b);var t=ze(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return Fe(new Uint8Array(e)).buffer}}]),r}(),Ne=Object.freeze({__proto__:null,default:je});function Ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var Ke,He=function(e){p(r,b);var t=Ze(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){for(var t=new DataView(e),r=[],n=0;n>3],I<<=7&U),v=0;v>3]),128&I?(f&&(f[U]=1),m=m>(o=T.encoding<2?_[A++]:P)?o:m,s[U++]=o):(f&&(f[U]=0),s[U++]=n),I<<=1;U+=S}else if(T.encoding<2)for(y=0;y(o=_[A++])?o:m,s[U++]=o;U+=S}else for(m=m>P?P:m,y=0;y0){var o=new Uint8Array(Math.ceil(n.width*n.height/8)),s=(a=new DataView(e,t,n.mask.numBytes)).getInt16(0,!0),f=2,l=0;do{if(s>0)for(;s--;)o[l++]=a.getUint8(f++);else{var u=a.getUint8(f++);for(s=-s;s--;)o[l++]=u}s=a.getInt16(f,!0),f+=2}while(f0?1:0),p=h+(n.height%h>0?1:0);n.pixels.blocks=new Array(d*p);for(var m=0,v=0;v3)throw"Invalid block encoding ("+b.encoding+")";if(2!==b.encoding){if(0!==k&&2!==k){if(k>>=6,b.offsetType=k,2===k)b.offset=a.getInt8(1),w++;else if(1===k)b.offset=a.getInt16(1,!0),w+=2;else{if(0!==k)throw"Invalid block offset type";b.offset=a.getFloat32(1,!0),w+=4}if(1===b.encoding)if(k=a.getUint8(w),w++,b.bitsPerPixel=63&k,k>>=6,b.numValidPixelsType=k,2===k)b.numValidPixels=a.getUint8(w),w++;else if(1===k)b.numValidPixels=a.getUint16(w,!0),w+=2;else{if(0!==k)throw"Invalid valid pixel count type";b.numValidPixels=a.getUint32(w,!0),w+=4}}var x;if(t+=w,3!==b.encoding)if(0===b.encoding){var _=(n.pixels.numBytes-1)/4;if(_!==Math.floor(_))throw"uncompressed block has invalid length";x=new ArrayBuffer(4*_),new Uint8Array(x).set(new Uint8Array(e,t,4*_));var A=new Float32Array(x);b.rawData=A,t+=4*_}else if(1===b.encoding){var P=Math.ceil(b.numValidPixels*b.bitsPerPixel/8),I=Math.ceil(P/4);x=new ArrayBuffer(4*I),new Uint8Array(x).set(new Uint8Array(e,t,P)),b.stuffedData=new Uint32Array(x),t+=P}}else t++}return n.eofOffset=t,n},a=function(e,t,r,n,i,a,o){var s,f,l,u=(1<=t)f=l>>>h-t&u,h-=t;else{var m=t-h;f=(l&u)<>>(h=32-m)}a[s]=f=r?(l=u>>>m-r&d,m-=r):(l=(u&d)<<(c=r-m)&d,l+=(u=e[p++])>>>(m=32-c)),t[f]=i[l];else for(h=Math.ceil((s-a)/o),f=0;f=r?(l=u>>>m-r&d,m-=r):(l=(u&d)<<(c=r-m)&d,l+=(u=e[p++])>>>(m=32-c)),t[f]=l=t?(h=o>>>c-t&s,c-=t):(h=(o&s)<<(u=t-c)&s,h+=(o=e[f++])>>>(c=32-u)),d[l]=h=r?(l=u>>>m&h,p-=r,m+=r):(l=u>>>m&h,p=32-(c=r-p),l|=((u=e[d++])&(1<=r?(l=u>>>m&h,p-=r,m+=r):(l=u>>>m&h,p=32-(c=r-p),l|=((u=e[d++])&(1<=t?(h=o>>>d&s,c-=t,d+=t):(h=o>>>d&s,c=32-(u=t-c),h|=((o=e[f++])&(1<=r?(a=o>>>u-r&f,u-=r):(a=(o&f)<<(s=r-u)&f,a+=(o=e[l++])>>>(u=32-s)),t[i]=a;return t},c=function(e,t,r,n){var i,a,o,s,f=(1<=r?(a=o>>>c&f,u-=r,c+=r):(a=o>>>c&f,u=32-(s=r-u),a|=((o=e[l++])&(1<=359?359:i;i-=o;do{t+=e[a++]<<8,r+=t+=e[a++]}while(--o);t=(65535&t)+(t>>>16),r=(65535&r)+(r>>>16)}return 1&n&&(r+=t+=e[a]<<8),((r=(65535&r)+(r>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var r=t.ptr,n=new Uint8Array(e,r,6),i={};if(i.fileIdentifierString=String.fromCharCode.apply(null,n),0!==i.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+i.fileIdentifierString;r+=6;var a,o=new DataView(e,r,8),s=o.getInt32(0,!0);if(i.fileVersion=s,r+=4,s>=3&&(i.checksum=o.getUint32(4,!0),r+=4),o=new DataView(e,r,12),i.height=o.getUint32(0,!0),i.width=o.getUint32(4,!0),r+=8,s>=4?(i.numDims=o.getUint32(8,!0),r+=4):i.numDims=1,o=new DataView(e,r,40),i.numValidPixel=o.getUint32(0,!0),i.microBlockSize=o.getInt32(4,!0),i.blobSize=o.getInt32(8,!0),i.imageType=o.getInt32(12,!0),i.maxZError=o.getFloat64(16,!0),i.zMin=o.getFloat64(24,!0),i.zMax=o.getFloat64(32,!0),r+=40,t.headerInfo=i,t.ptr=r,s>=3&&(a=s>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,r-a,i.blobSize-14))!==i.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var r=t.headerInfo,n=this.getDataTypeArray(r.imageType),i=r.numDims*this.getDataTypeSize(r.imageType),a=this.readSubArray(e,t.ptr,n,i),o=this.readSubArray(e,t.ptr+i,n,i);t.ptr+=2*i;var s,f=!0;for(s=0;s0){r=new Uint8Array(Math.ceil(o/8));var u=(f=new DataView(e,i,l.numBytes)).getInt16(0,!0),c=2,h=0,d=0;do{if(u>0)for(;u--;)r[h++]=f.getUint8(c++);else for(d=f.getUint8(c++),u=-u;u--;)r[h++]=d;u=f.getInt16(c,!0),c+=2}while(c>3],p<<=7&m):p=r[m>>3],128&p&&(n[m]=1);t.pixels.resultMask=n,l.bitset=r,i+=l.numBytes}return t.ptr=i,t.mask=l,!0},readDataOneSweep:function(e,t,r,n){var i,a=t.ptr,o=t.headerInfo,s=o.numDims,f=o.width*o.height,l=o.imageType,u=o.numValidPixel*h.getDataTypeSize(l)*s,c=t.pixels.resultMask;if(r===Uint8Array)i=new Uint8Array(e,a,u);else{var d=new ArrayBuffer(u);new Uint8Array(d).set(new Uint8Array(e,a,u)),i=new r(d)}if(i.length===f*s)t.pixels.resultPixels=n?h.swapDimensionOrder(i,f,s,r,!0):i;else{t.pixels.resultPixels=new r(f*s);var p=0,m=0,v=0,y=0;if(s>1){if(n){for(m=0;m=o)return!1;var s=new Uint32Array(o-a);h.decodeBits(e,t,s);var f,l,u,c,p=[];for(f=a;f0&&(p[l].second=w<>>32-c,32-b>=c?32===(b+=c)&&(b=0,w=g[++k]):(b+=c-32,w=g[++k],p[l].second|=w>>>32-b));var x=0,_=0,A=new d;for(f=0;f=r?r:x;var P,I,U,S,T,D=[];for(f=a;f0)if(P=[c,l],c<=_)for(I=p[l].second<<_-c,U=1<<_-c,u=0;u=0;S--)I>>>S&1?(T.right||(T.right=new d),T=T.right):(T.left||(T.left=new d),T=T.left),0!==S||T.val||(T.val=P[1]);return{decodeLut:D,numBitsLUTQick:_,numBitsLUT:x,tree:A,stuffedData:g,srcPtr:k,bitPos:b}},readHuffman:function(e,t,r,n){var i,a,o,s,f,l,u,c,d,p=t.headerInfo.numDims,m=t.headerInfo.height,v=t.headerInfo.width,y=v*m,w=this.readHuffmanTree(e,t),g=w.decodeLut,b=w.tree,k=w.stuffedData,x=w.srcPtr,_=w.bitPos,A=w.numBitsLUTQick,P=w.numBitsLUT,I=0===t.headerInfo.imageType?128:0,U=t.pixels.resultMask,S=0;_>0&&(x++,_=0);var T,D=k[x],E=1===t.encodeMode,B=new r(y*p),O=B;if(p<2||E){for(T=0;T1&&(O=new r(B.buffer,y*T,y),S=0),t.headerInfo.numValidPixel===v*m)for(c=0,l=0;l>>32-A,32-_>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_>>64-_-P),i=b,d=0;d>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,E?(o+=u>0?S:l>0?O[c-v]:S,o&=255,O[c]=o,S=o):O[c]=o}else for(c=0,l=0;l>>32-A,32-_>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_>>64-_-P),i=b,d=0;d>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,E?(u>0&&U[c-1]?o+=S:l>0&&U[c-v]?o+=O[c-v]:o+=S,o&=255,O[c]=o,S=o):O[c]=o}}else for(c=0,l=0;l>>32-A,32-_>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_>>64-_-P),i=b,d=0;d>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,O[c]=o}t.ptr=t.ptr+4*(x+1)+(_>0?4:0),t.pixels.resultPixels=B,p>1&&!n&&(t.pixels.resultPixels=h.swapDimensionOrder(B,y,p,r))},decodeBits:function(e,t,r,n,i){var a=t.headerInfo,h=a.fileVersion,d=0,p=e.byteLength-t.ptr>=5?5:e.byteLength-t.ptr,m=new DataView(e,t.ptr,p),v=m.getUint8(0);d++;var y=v>>6,w=0===y?4:3-y,g=(32&v)>0,b=31&v,k=0;if(1===w)k=m.getUint8(d),d++;else if(2===w)k=m.getUint16(d,!0),d+=2;else{if(4!==w)throw"Invalid valid pixel count type";k=m.getUint32(d,!0),d+=4}var x,_,A,P,I,U,S,T,D,E=2*a.maxZError,B=a.numDims>1?a.maxValues[i]:a.zMax;if(g){for(t.counter.lut++,T=m.getUint8(d),d++,P=Math.ceil((T-1)*b/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),A=new Uint8Array(_),t.ptr+=d,A.set(new Uint8Array(e,t.ptr,P)),S=new Uint32Array(_),t.ptr+=P,D=0;T-1>>>D;)D++;P=Math.ceil(k*D/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),(A=new Uint8Array(_)).set(new Uint8Array(e,t.ptr,P)),x=new Uint32Array(_),t.ptr+=P,U=h>=3?l(S,b,T-1,n,E,B):s(S,b,T-1,n,E,B),h>=3?f(x,r,D,k,U):o(x,r,D,k,U)}else t.counter.bitstuffer++,D=b,t.ptr+=d,D>0&&(P=Math.ceil(k*D/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),(A=new Uint8Array(_)).set(new Uint8Array(e,t.ptr,P)),x=new Uint32Array(_),t.ptr+=P,h>=3?null==n?c(x,r,D,k):f(x,r,D,k,!1,n,E,B):null==n?u(x,r,D,k):o(x,r,D,k,!1,n,E,B))},readTiles:function(e,t,r,n){var i=t.headerInfo,a=i.width,o=i.height,s=a*o,f=i.microBlockSize,l=i.imageType,u=h.getDataTypeSize(l),c=Math.ceil(a/f),d=Math.ceil(o/f);t.pixels.numBlocksY=d,t.pixels.numBlocksX=c,t.pixels.ptr=0;var p,m,v,y,w,g,b,k,x,_,A=0,P=0,I=0,U=0,S=0,T=0,D=0,E=0,B=0,O=0,M=0,C=0,L=0,R=0,V=0,G=new r(f*f),F=o%f||f,z=a%f||f,j=i.numDims,N=t.pixels.resultMask,Z=t.pixels.resultPixels,K=i.fileVersion>=5?14:15,H=i.zMax;for(I=0;I1?(_=Z,O=I*a*f+U*f,Z=new r(t.pixels.resultPixels.buffer,s*k*u,s),H=i.maxValues[k]):_=null,D=e.byteLength-t.ptr,m={},V=0,E=(p=new DataView(e,t.ptr,Math.min(10,D))).getUint8(0),V++,x=i.fileVersion>=5?4&E:0,B=E>>6&255,(E>>2&K)!=(U*f>>3&K))throw"integrity issue";if(x&&0===k)throw"integrity issue";if((w=3&E)>3)throw t.ptr+=V,"Invalid block encoding ("+w+")";if(2!==w)if(0===w){if(x)throw"integrity issue";if(t.counter.uncompressed++,t.ptr+=V,C=(C=S*T*u)<(L=e.byteLength-t.ptr)?C:L,v=new ArrayBuffer(C%u==0?C:C+u-C%u),new Uint8Array(v).set(new Uint8Array(e,t.ptr,C)),y=new r(v),R=0,N)for(A=0;A1&&!n&&(t.pixels.resultPixels=h.swapDimensionOrder(t.pixels.resultPixels,s,j,r))},formatFileInfo:function(e){return{fileIdentifierString:e.headerInfo.fileIdentifierString,fileVersion:e.headerInfo.fileVersion,imageType:e.headerInfo.imageType,height:e.headerInfo.height,width:e.headerInfo.width,numValidPixel:e.headerInfo.numValidPixel,microBlockSize:e.headerInfo.microBlockSize,blobSize:e.headerInfo.blobSize,maxZError:e.headerInfo.maxZError,pixelType:h.getPixelType(e.headerInfo.imageType),eofOffset:e.eofOffset,mask:e.mask?{numBytes:e.mask.numBytes}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,maxValue:e.headerInfo.zMax,minValue:e.headerInfo.zMin,noDataValue:e.noDataValue}}},constructConstantSurface:function(e,t){var r=e.headerInfo.zMax,n=e.headerInfo.zMin,i=e.headerInfo.maxValues,a=e.headerInfo.numDims,o=e.headerInfo.height*e.headerInfo.width,s=0,f=0,l=0,u=e.pixels.resultMask,c=e.pixels.resultPixels;if(u)if(a>1){if(t)for(s=0;s1&&n!==r)if(t)for(s=0;s=-128&&t<=127;break;case 1:r=t>=0&&t<=255;break;case 2:r=t>=-32768&&t<=32767;break;case 3:r=t>=0&&t<=65536;break;case 4:r=t>=-2147483648&&t<=2147483647;break;case 5:r=t>=0&&t<=4294967296;break;case 6:r=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:r=t>=-17976931348623157e292&&t<=17976931348623157e292;break;default:r=!1}return r},getDataTypeSize:function(e){var t=0;switch(e){case 0:case 1:t=1;break;case 2:case 3:t=2;break;case 4:case 5:case 6:t=4;break;case 7:t=8;break;default:t=e}return t},getDataTypeUsed:function(e,t){var r=e;switch(e){case 2:case 4:r=e-t;break;case 3:case 5:r=e-2*t;break;case 6:r=0===t?e:1===t?2:1;break;case 7:r=0===t?e:e-2*t+1;break;default:r=e}return r},getOnePixel:function(e,t,r,n){var i=0;switch(r){case 0:i=n.getInt8(t);break;case 1:i=n.getUint8(t);break;case 2:i=n.getInt16(t,!0);break;case 3:i=n.getUint16(t,!0);break;case 4:i=n.getInt32(t,!0);break;case 5:i=n.getUInt32(t,!0);break;case 6:i=n.getFloat32(t,!0);break;case 7:i=n.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return i},swapDimensionOrder:function(e,t,r,n,i){var a=0,o=0,s=0,f=0,l=e;if(r>1)if(l=new n(t*r),i)for(a=0;a5)throw"unsupported lerc version 2."+o;h.readMask(e,i),a.numValidPixel===a.width*a.height||i.pixels.resultMask||(i.pixels.resultMask=t.maskData);var f=a.width*a.height;i.pixels.resultPixels=new s(f*a.numDims),i.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var l,u=!t.returnPixelInterleavedDims;if(0!==a.numValidPixel)if(a.zMax===a.zMin)h.constructConstantSurface(i,u);else if(o>=4&&h.checkMinMaxRanges(e,i))h.constructConstantSurface(i,u);else{var c=new DataView(e,i.ptr,2),d=c.getUint8(0);if(i.ptr++,d)h.readDataOneSweep(e,i,s,u);else if(o>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var p=c.getUint8(1);if(i.ptr++,i.encodeMode=p,p>2||o<4&&p>1)throw"Invalid Huffman flag "+p;p?h.readHuffman(e,i,s,u):h.readTiles(e,i,s,u)}else h.readTiles(e,i,s,u)}i.eofOffset=i.ptr,t.inputOffset?(l=i.headerInfo.blobSize+t.inputOffset-i.ptr,Math.abs(l)>=1&&(i.eofOffset=t.inputOffset+i.headerInfo.blobSize)):(l=i.headerInfo.blobSize-i.ptr,Math.abs(l)>=1&&(i.eofOffset=i.headerInfo.blobSize));var m={width:a.width,height:a.height,pixelData:i.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:i.pixels.resultMask};if(i.pixels.resultMask&&h.isValidPixelValue(a.imageType,r)){var v=i.pixels.resultMask;for(n=0;n1&&(l&&m.push(l),k.fileInfo.mask&&k.fileInfo.mask.numBytes>0&&b++),d++,g.pixels.push(k.pixelData),g.statistics.push({minValue:k.minValue,maxValue:k.maxValue,noDataValue:k.noDataValue,dimStats:k.dimStats})}if(n>1&&b>1){for(h=g.width*g.height,g.bandMasks=m,(l=new Uint8Array(h)).set(m[0]),u=1;uthis.fetchSlice(t,e))))}async fetchSlice(t){throw new Error(`fetching of slice ${t} not possible, not implemented`)}get fileSize(){return null}async close(){}},bO}var SO={};class TO extends Map{constructor(t={}){if(super(),!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof t.maxAge&&0===t.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=t.maxSize,this.maxAge=t.maxAge||Number.POSITIVE_INFINITY,this.onEviction=t.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(t){if("function"==typeof this.onEviction)for(const[e,r]of t)this.onEviction(e,r.value)}_deleteIfExpired(t,e){return"number"==typeof e.expiry&&e.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(t,e.value),this.delete(t))}_getOrDeleteIfExpired(t,e){if(!1===this._deleteIfExpired(t,e))return e.value}_getItemValue(t,e){return e.expiry?this._getOrDeleteIfExpired(t,e):e.value}_peek(t,e){const r=e.get(t);return this._getItemValue(t,r)}_set(t,e){this.cache.set(t,e),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(t,e){this.oldCache.delete(t),this._set(t,e)}*_entriesAscending(){for(const t of this.oldCache){const[e,r]=t;if(!this.cache.has(e)){!1===this._deleteIfExpired(e,r)&&(yield t)}}for(const t of this.cache){const[e,r]=t;!1===this._deleteIfExpired(e,r)&&(yield t)}}get(t){if(this.cache.has(t)){const e=this.cache.get(t);return this._getItemValue(t,e)}if(this.oldCache.has(t)){const e=this.oldCache.get(t);if(!1===this._deleteIfExpired(t,e))return this._moveToRecent(t,e),e.value}}set(t,e,{maxAge:r=this.maxAge}={}){const n="number"==typeof r&&r!==Number.POSITIVE_INFINITY?Date.now()+r:void 0;this.cache.has(t)?this.cache.set(t,{value:e,expiry:n}):this._set(t,{value:e,expiry:n})}has(t){return this.cache.has(t)?!this._deleteIfExpired(t,this.cache.get(t)):!!this.oldCache.has(t)&&!this._deleteIfExpired(t,this.oldCache.get(t))}peek(t){return this.cache.has(t)?this._peek(t,this.cache):this.oldCache.has(t)?this._peek(t,this.oldCache):void 0}delete(t){const e=this.cache.delete(t);return e&&this._size--,this.oldCache.delete(t)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(t){if(!(t&&t>0))throw new TypeError("`maxSize` must be a number greater than 0");const e=[...this._entriesAscending()],r=e.length-t;r<0?(this.cache=new Map(e),this.oldCache=new Map,this._size=e.length):(r>0&&this._emitEvictions(e.slice(0,r)),this.oldCache=new Map(e.slice(r)),this.cache=new Map,this._size=0),this.maxSize=t}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache){const[e,r]=t;!1===this._deleteIfExpired(e,r)&&(yield[e,r.value])}for(const t of this.oldCache){const[e,r]=t;if(!this.cache.has(e)){!1===this._deleteIfExpired(e,r)&&(yield[e,r.value])}}}*entriesDescending(){let t=[...this.cache];for(let e=t.length-1;e>=0;--e){const r=t[e],[n,i]=r;!1===this._deleteIfExpired(n,i)&&(yield[n,i.value])}t=[...this.oldCache];for(let e=t.length-1;e>=0;--e){const r=t[e],[n,i]=r;if(!this.cache.has(n)){!1===this._deleteIfExpired(n,i)&&(yield[n,i.value])}}}*entriesAscending(){for(const[t,e]of this._entriesAscending())yield[t,e.value]}get size(){if(!this._size)return this.oldCache.size;let t=0;for(const e of this.oldCache.keys())this.cache.has(e)||t++;return Math.min(this._size+t,this.maxSize)}entries(){return this.entriesAscending()}forEach(t,e=this){for(const[r,n]of this.entriesAscending())t.call(e,n,r,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}const EO=of(Object.freeze(Object.defineProperty({__proto__:null,default:TO},Symbol.toStringTag,{value:"Module"})));var AO,RO,PO={};function CO(){if(AO)return PO;function t(t){const e=[],{length:r}=t;for(let n=0;nNumber.parseInt(t,10);let r=t.match(/^(\w*) /);const n=r&&r[1];return r=t.match(/(\d+)-(\d+)\/(\d+|\*)/),r?{unit:n,first:e(r[1]),last:e(r[2]),length:"*"===r[3]?null:e(r[3])}:(r=t.match(/(\d+|\*)/),r?{unit:n,first:null,last:null,length:"*"===r[1]?null:e(r[1])}:null)},PO.wait=async function(t){return new Promise((e=>setTimeout(e,t)))},PO.zip=function(t,e){const r=Array.isArray(t)?t:Array.from(t),n=Array.isArray(e)?e:Array.from(e);return r.map(((t,e)=>[t,n[e]]))};class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.name="AbortError"}}PO.AbortError=e;class r extends Error{constructor(t,e){super(e),this.errors=t,this.message=e,this.name="AggregateError"}}return PO.CustomAggregateError=r,PO.AggregateError=r,PO}var IO,LO,OO={},DO={};function kO(){if(IO)return DO;IO=1,Object.defineProperty(DO,"__esModule",{value:!0}),DO.BaseClient=DO.BaseResponse=void 0;DO.BaseResponse=class{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(t){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}};return DO.BaseClient=class{constructor(t){this.url=t}async request({headers:t,credentials:e,signal:r}={}){throw new Error("request is not implemented")}},DO}var FO,NO={};var UO={};const BO=of(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var zO,GO;function jO(){if(GO)return xO;GO=1,Object.defineProperty(xO,"__esModule",{value:!0}),xO.makeRemoteSource=xO.makeHttpSource=xO.makeXHRSource=xO.makeFetchSource=void 0;const t=function(){if(yO)return _O;yO=1,Object.defineProperty(_O,"__esModule",{value:!0}),_O.parseByteRanges=_O.parseContentRange=_O.parseContentType=void 0;const t="\r\n\r\n";function e(t){if(void 0!==Object.fromEntries)return Object.fromEntries(t);const e={};for(const[r,n]of t)e[r.toLowerCase()]=n;return e}function r(t){return e(t.split("\r\n").map((t=>{const e=t.split(":").map((t=>t.trim()));return e[0]=e[0].toLowerCase(),e})))}function n(t){let e,r,n;return t&&([,e,r,n]=t.match(/bytes (\d+)-(\d+)\/(\d+)/),e=parseInt(e,10),r=parseInt(r,10),n=parseInt(n,10)),{start:e,end:r,total:n}}return _O.parseContentType=function(t){const[r,...n]=t.split(";").map((t=>t.trim()));return{type:r,params:e(n.map((t=>t.split("="))))}},_O.parseContentRange=n,_O.parseByteRanges=function(e,i){let a=null;const o=new TextDecoder("ascii"),s=[],l=`--${i}`,u=`${l}--`;for(let t=0;t<10;++t)o.decode(new Uint8Array(e,t,l.length))===l&&(a=t);if(null===a)throw new Error("Could not find initial boundary");for(;athis.abortedBlockIds.has(t)||!this.blockCache.has(t)));if(l.forEach((t=>this.blockIdsToFetch.add(t))),l.length>0&&e&&!e.aborted){this.fetchBlocks(null);for(const t of l){const e=this.blockRequests.get(t);if(!e)throw new Error(`Block ${t} is not in the block requests`);s.push(e)}await Promise.allSettled(s)}if(e&&e.aborted)throw new n.AbortError("Request was aborted");const u=a.map((t=>this.blockCache.get(t))),c=u.filter((t=>!t));if(c.length)throw new n.AggregateError(c,"Request failed");const h=new Map((0,n.zip)(a,u));return this.readSliceData(t,h)}fetchBlocks(t){if(this.blockIdsToFetch.size>0){const e=this.groupBlocks(this.blockIdsToFetch),r=this.source.fetch(e,t);for(let n=0;n{try{const t=(await r)[n],a=e*this.blockSize,o=a-t.offset,s=Math.min(o+this.blockSize,t.data.byteLength),l=t.data.slice(o,s),u=new i(a,l.byteLength,l,e);this.blockCache.set(e,u),this.abortedBlockIds.delete(e)}catch(r){if("AbortError"!==r.name)throw r;r.signal=t,this.blockCache.delete(e),this.abortedBlockIds.add(e)}finally{this.blockRequests.delete(e)}})())}this.blockIdsToFetch.clear()}}groupBlocks(t){const e=Array.from(t).sort(((t,e)=>t-e));if(0===e.length)return[];let r=[],n=null;const i=[];for(const t of e)null===n||n+1===t?(r.push(t),n=t):(i.push(new a(r[0]*this.blockSize,r.length*this.blockSize,r)),r=[t],n=t);return i.push(new a(r[0]*this.blockSize,r.length*this.blockSize,r)),i}readSliceData(t,e){return t.map((t=>{let r=t.offset+t.length;null!==this.fileSize&&(r=Math.min(this.fileSize,r));const n=Math.floor(t.offset/this.blockSize),i=Math.floor(r/this.blockSize),a=new ArrayBuffer(t.length),o=new Uint8Array(a);for(let a=n;a<=i;++a){const n=e.get(a),i=n.offset-t.offset;let s,l=0,u=0;i<0?l=-i:i>0&&(u=i),s=n.top-r<0?n.length-l:r-n.offset-l;const c=new Uint8Array(n.data,l,s);o.set(c,u)}return a}))}}return SO.BlockedSource=o,SO}(),n=function(){if(LO)return OO;LO=1,Object.defineProperty(OO,"__esModule",{value:!0}),OO.FetchClient=void 0;const t=kO();class e extends t.BaseResponse{constructor(t){super(),this.response=t}get status(){return this.response.status}getHeader(t){return this.response.headers.get(t)}async getData(){return this.response.arrayBuffer?await this.response.arrayBuffer():(await this.response.buffer()).buffer}}class r extends t.BaseClient{constructor(t,e){super(t),this.credentials=e}async request({headers:t,credentials:r,signal:n}={}){const i=await fetch(this.url,{headers:t,credentials:r,signal:n});return new e(i)}}return OO.FetchClient=r,OO}(),i=function(){if(FO)return NO;FO=1,Object.defineProperty(NO,"__esModule",{value:!0}),NO.XHRClient=void 0;const t=kO(),e=CO();class r extends t.BaseResponse{constructor(t,e){super(),this.xhr=t,this.data=e}get status(){return this.xhr.status}getHeader(t){return this.xhr.getResponseHeader(t)}async getData(){return this.data}}class n extends t.BaseClient{constructRequest(t,n){return new Promise(((i,a)=>{const o=new XMLHttpRequest;o.open("GET",this.url),o.responseType="arraybuffer";for(const[e,r]of Object.entries(t))o.setRequestHeader(e,r);o.onload=()=>{const t=o.response;i(new r(o,t))},o.onerror=a,o.onabort=()=>a(new e.AbortError("Request aborted")),o.send(),n&&(n.aborted&&o.abort(),n.addEventListener("abort",(()=>o.abort())))}))}async request({headers:t,signal:e}={}){return await this.constructRequest(t,e)}}return NO.XHRClient=n,NO}(),a=function(){if(zO)return UO;zO=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(UO,"__esModule",{value:!0}),UO.HttpClient=void 0;const e=t(BO),r=t(BO),n=t(BO),i=kO(),a=CO();class o extends i.BaseResponse{constructor(t,e){super(),this.response=t,this.dataPromise=e}get status(){return this.response.statusCode}getHeader(t){return this.response.headers[t]}async getData(){return await this.dataPromise}}class s extends i.BaseClient{constructor(t){super(t),this.parsedUrl=n.default.parse(this.url),this.httpApi="http:"===this.parsedUrl.protocol?e.default:r.default}constructRequest(t,e){return new Promise(((r,n)=>{const i=this.httpApi.get({...this.parsedUrl,headers:t},(t=>{const e=new Promise((e=>{const r=[];t.on("data",(t=>{r.push(t)})),t.on("end",(()=>{const t=Buffer.concat(r).buffer;e(t)})),t.on("error",n)}));r(new o(t,e))}));i.on("error",n),e&&(e.aborted&&i.destroy(new a.AbortError("Request aborted")),e.addEventListener("abort",(()=>i.destroy(new a.AbortError("Request aborted")))))}))}async request({headers:t,signal:e}={}){return await this.constructRequest(t,e)}}return UO.HttpClient=s,UO}();class o extends e.BaseSource{constructor(t,e,r,n){super(),this.client=t,this.headers=e,this.maxRanges=r,this.allowFullFile=n,this._fileSize=null}async fetch(t,e){return this.maxRanges>=t.length?this.fetchSlices(t,e):(this.maxRanges>0&&t.length,Promise.all(t.map((t=>this.fetchSlice(t,e)))))}async fetchSlices(e,r){const n=await this.client.request({headers:{...this.headers,Range:`bytes=${e.map((({offset:t,length:e})=>`${t}-${t+e}`)).join(",")}`},signal:r});if(n.ok){if(206===n.status){const{type:i,params:a}=(0,t.parseContentType)(n.getHeader("content-type"));if("multipart/byteranges"===i){const e=(0,t.parseByteRanges)(await n.getData(),a.boundary);return this._fileSize=e[0].fileSize||null,e}const o=await n.getData(),{start:s,end:l,total:u}=(0,t.parseContentRange)(n.getHeader("content-range"));this._fileSize=u||null;const c=[{data:o,offset:s,length:l-s}];if(e.length>1){const t=await Promise.all(e.slice(1).map((t=>this.fetchSlice(t,r))));return c.concat(t)}return c}{if(!this.allowFullFile)throw new Error("Server responded with full file");const t=await n.getData();return this._fileSize=t.byteLength,[{data:t,offset:0,length:t.byteLength}]}}throw new Error("Error fetching data.")}async fetchSlice(e,r){const{offset:n,length:i}=e,a=await this.client.request({headers:{...this.headers,Range:`bytes=${n}-${n+i}`},signal:r});if(a.ok){if(206===a.status){const e=await a.getData(),{total:r}=(0,t.parseContentRange)(a.getHeader("content-range"));return this._fileSize=r||null,{data:e,offset:n,length:i}}{if(!this.allowFullFile)throw new Error("Server responded with full file");const t=await a.getData();return this._fileSize=t.byteLength,{data:t,offset:0,length:t.byteLength}}}throw new Error("Error fetching data.")}get fileSize(){return this._fileSize}}function s(t,{blockSize:e,cacheSize:n}){return null===e?t:new r.BlockedSource(t,{blockSize:e,cacheSize:n})}function l(t,{headers:e={},credentials:r,maxRanges:i=0,allowFullFile:a=!1,...l}={}){const u=new n.FetchClient(t,r);return s(new o(u,e,i,a),l)}function u(t,{headers:e={},maxRanges:r=0,allowFullFile:n=!1,...a}={}){const l=new i.XHRClient(t);return s(new o(l,e,r,n),a)}function c(t,{headers:e={},maxRanges:r=0,allowFullFile:n=!1,...i}={}){const l=new a.HttpClient(t);return s(new o(l,e,r,n),i)}return xO.makeFetchSource=l,xO.makeXHRSource=u,xO.makeHttpSource=c,xO.makeRemoteSource=function(t,{forceXHR:e=!1,...r}={}){return"function"!=typeof fetch||e?"undefined"!=typeof XMLHttpRequest?u(t,r):c(t,r):l(t,r)},xO}var VO,HO={};var WO,qO={};var XO,YO={};function ZO(){if(XO)return YO;XO=1;var t=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(YO,"__esModule",{value:!0}),YO.makeFileSource=void 0;const e=t(BO),r=MO();class n extends r.BaseSource{constructor(t){super(),this.path=t,this.openRequest=function(t,r,n){return new Promise(((i,a)=>{e.default.open(t,r,n,((t,e)=>{t?a(t):i(e)}))}))}(t,"r")}async fetchSlice(t){const r=await this.openRequest,{buffer:n}=await function(...t){return new Promise(((r,n)=>{e.default.read(...t,((t,e,i)=>{t?n(t):r({bytesRead:e,buffer:i})}))}))}(r,Buffer.alloc(t.length),0,t.length,t.offset);return n.buffer}async close(){const t=await this.openRequest;await function(t){return new Promise(((r,n)=>{e.default.close(t,(t=>{t?n(t):r()}))}))}(t)}}return YO.makeFileSource=function(t){return new n(t)},YO}var KO,JO={};function QO(){if(KO)return JO;KO=1,Object.defineProperty(JO,"__esModule",{value:!0}),JO.writeGeotiff=void 0;const t=FI(),e=CO(),r=(0,e.invert)(t.fieldTagNames),n=(0,e.invert)(t.geoKeyNames),i={};(0,e.assign)(i,r),(0,e.assign)(i,n);const a=(0,e.invert)(t.fieldTypeNames),o=1e3,s={nextZero:(t,e)=>{let r=e;for(;0!==t[r];)r++;return r},readUshort:(t,e)=>t[e]<<8|t[e+1],readShort:(t,e)=>{const r=s.ui8;return r[0]=t[e+1],r[1]=t[e+0],s.i16[0]},readInt:(t,e)=>{const r=s.ui8;return r[0]=t[e+3],r[1]=t[e+2],r[2]=t[e+1],r[3]=t[e+0],s.i32[0]},readUint:(t,e)=>{const r=s.ui8;return r[0]=t[e+3],r[1]=t[e+2],r[2]=t[e+1],r[3]=t[e+0],s.ui32[0]},readASCII:(t,e,r)=>r.map((r=>String.fromCharCode(t[e+r]))).join(""),readFloat:(t,r)=>{const n=s.ui8;return(0,e.times)(4,(e=>{n[e]=t[r+3-e]})),s.fl32[0]},readDouble:(t,r)=>{const n=s.ui8;return(0,e.times)(8,(e=>{n[e]=t[r+7-e]})),s.fl64[0]},writeUshort:(t,e,r)=>{t[e]=r>>8&255,t[e+1]=255&r},writeUint:(t,e,r)=>{t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=r>>0&255},writeASCII:(t,r,n)=>{(0,e.times)(n.length,(e=>{t[r+e]=n.charCodeAt(e)}))},ui8:new Uint8Array(8)};s.fl64=new Float64Array(s.ui8.buffer),s.writeDouble=(t,r,n)=>{s.fl64[0]=n,(0,e.times)(8,(e=>{t[r+e]=s.ui8[7-e]}))};const l=r=>{const n=new Uint8Array(o);let i=4;const l=s;n[0]=77,n[1]=77,n[3]=42;let u=8;if(l.writeUint(n,i,u),i+=4,r.forEach(((i,o)=>{const s=((r,n,i,o)=>{let s=i;const l=Object.keys(o).filter((t=>null!=t&&"undefined"!==t));r.writeUshort(n,s,l.length),s+=2;let u=s+12*l.length+4;for(const i of l){let l=null;"number"==typeof i?l=i:"string"==typeof i&&(l=parseInt(i,10));const c=t.fieldTagTypes[l],h=a[c];if(null==c||void 0===c||void 0===c)throw new Error(`unknown type of tag: ${l}`);let d=o[i];if(void 0===d)throw new Error(`failed to get value for key ${i}`);"ASCII"===c&&"string"==typeof d&&!1===(0,e.endsWith)(d,"\0")&&(d+="\0");const f=d.length;r.writeUshort(n,s,l),s+=2,r.writeUshort(n,s,h),s+=2,r.writeUint(n,s,f),s+=4;let p=[-1,1,1,2,4,8,0,0,0,0,0,0,8][h]*f,m=s;p>4&&(r.writeUint(n,s,u),m=u),"ASCII"===c?r.writeASCII(n,m,d):"SHORT"===c?(0,e.times)(f,(t=>{r.writeUshort(n,m+2*t,d[t])})):"LONG"===c?(0,e.times)(f,(t=>{r.writeUint(n,m+4*t,d[t])})):"RATIONAL"===c?(0,e.times)(f,(t=>{r.writeUint(n,m+8*t,Math.round(1e4*d[t])),r.writeUint(n,m+8*t+4,1e4)})):"DOUBLE"===c&&(0,e.times)(f,(t=>{r.writeDouble(n,m+8*t,d[t])})),p>4&&(p+=1&p,u+=p),s+=4}return[s,u]})(l,n,u,i);u=s[1],o{(0,e.times)(c,(n=>{(0,e.times)(s,(e=>{h.push(r[e][t][n])}))}))}))),n.ImageLength=a,delete n.height,n.ImageWidth=c,delete n.width,n.BitsPerSample||(n.BitsPerSample=(0,e.times)(s,(()=>8))),u.forEach((t=>{const e=t[0];if(!n[e]){const r=t[1];n[e]=r}})),n.PhotometricInterpretation||(n.PhotometricInterpretation=3===n.BitsPerSample.length?2:1),n.SamplesPerPixel||(n.SamplesPerPixel=[s]),n.StripByteCounts||(n.StripByteCounts=[s*a*c]),n.ModelPixelScale||(n.ModelPixelScale=[360/c,180/a,0]),n.SampleFormat||(n.SampleFormat=(0,e.times)(s,(()=>1))),n.hasOwnProperty("GeographicTypeGeoKey")||n.hasOwnProperty("ProjectedCSTypeGeoKey")||(n.GeographicTypeGeoKey=4326,n.ModelTiepoint=[0,0,0,-180,90,0],n.GeogCitationGeoKey="WGS 84",n.GTModelTypeGeoKey=2);const d=Object.keys(n).filter((t=>(0,e.endsWith)(t,"GeoKey"))).sort(((t,e)=>i[t]-i[e]));if(!n.GeoAsciiParams){let e="";d.forEach((r=>{const a=Number(i[r]);"ASCII"===t.fieldTagTypes[a]&&(e+=`${n[r].toString()}\0`)})),e.length>0&&(n.GeoAsciiParams=e)}if(!n.GeoKeyDirectory){const e=[1,1,0,d.length];d.forEach((r=>{const a=Number(i[r]);let o,s,l;e.push(a),"SHORT"===t.fieldTagTypes[a]?(o=1,s=0,l=n[r]):"GeogCitationGeoKey"===r?(o=n.GeoAsciiParams.length,s=Number(i.GeoAsciiParams),l=0):console.log(`[geotiff.js] couldn't get TIFFTagLocation for ${r}`),e.push(s),e.push(o),e.push(l)})),n.GeoKeyDirectory=e}for(const t in d)d.hasOwnProperty(t)&&delete n[t];["Compression","ExtraSamples","GeographicTypeGeoKey","GTModelTypeGeoKey","GTRasterTypeGeoKey","ImageLength","ImageWidth","Orientation","PhotometricInterpretation","ProjectedCSTypeGeoKey","PlanarConfiguration","ResolutionUnit","SamplesPerPixel","XPosition","YPosition"].forEach((t=>{var e;n[t]&&(n[t]=(e=n[t],Array.isArray(e)?e:[e]))}));const f=(t=>{const e={};for(const r in t)"StripOffsets"!==r&&(i[r]||console.error(r,"not in name2code:",Object.keys(i)),e[i[r]]=t[r]);return e})(n);return((t,r,n,i)=>{if(null==n)throw new Error(`you passed into encodeImage a width of type ${n}`);if(null==r)throw new Error(`you passed into encodeImage a width of type ${r}`);const a={256:[r],257:[n],273:[o],278:[n],305:"geotiff.js"};if(i)for(const t in i)i.hasOwnProperty(t)&&(a[t]=i[t]);const s=new Uint8Array(l([a])),u=new Uint8Array(t),c=a[277],h=new Uint8Array(o+r*n*c);return(0,e.times)(s.length,(t=>{h[t]=s[t]})),(0,e.forEach)(u,((t,e)=>{h[o+e]=t})),h.buffer})(h,c,a,f)},JO}var $O,tD,eD,rD,nD={};function iD(){return tD||(tD=1,function(t){var e=af&&af.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=af&&af.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=af&&af.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&e(n,t,i);return r(n,t),n},i=af&&af.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:!0}),t.GeoTIFFImage=t.Pool=t.writeArrayBuffer=t.fromUrls=t.fromBlob=t.fromFile=t.fromArrayBuffer=t.fromUrl=t.MultiGeoTIFF=t.GeoTIFF=t.setLogger=t.addDecoder=t.getDecoder=t.BaseDecoder=t.rgb=t.globals=void 0;const a=i(oO());t.GeoTIFFImage=a.default;const o=i(function(){if(sO)return lO;sO=1,Object.defineProperty(lO,"__esModule",{value:!0});const t=pI();return lO.default=class{constructor(t){this._dataView=new DataView(t)}get buffer(){return this._dataView.buffer}getUint64(t,e){const r=this.getUint32(t,e),n=this.getUint32(t+4,e);let i;if(e){if(i=r+2**32*n,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}if(i=2**32*r+n,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}getInt64(t,e){let r=0;const n=(128&this._dataView.getUint8(t+(e?7:0)))>0;let i=!0;for(let a=0;a<8;a++){let o=this._dataView.getUint8(t+(e?a:7-a));n&&(i?0!==o&&(o=255&~(o-1),i=!1):o=255&~o),r+=o*256**a}return n&&(r=-r),r}getUint8(t,e){return this._dataView.getUint8(t,e)}getInt8(t,e){return this._dataView.getInt8(t,e)}getUint16(t,e){return this._dataView.getUint16(t,e)}getInt16(t,e){return this._dataView.getInt16(t,e)}getUint32(t,e){return this._dataView.getUint32(t,e)}getInt32(t,e){return this._dataView.getInt32(t,e)}getFloat16(e,r){return(0,t.getFloat16)(this._dataView,e,r)}getFloat32(t,e){return this._dataView.getFloat32(t,e)}getFloat64(t,e){return this._dataView.getFloat64(t,e)}},lO}()),s=i((uO||(uO=1,Object.defineProperty(cO,"__esModule",{value:!0}),cO.default=class{constructor(t,e,r,n){this._dataView=new DataView(t),this._sliceOffset=e,this._littleEndian=r,this._bigTiff=n}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(t,e){return this.sliceOffset<=t&&this.sliceTop>=t+e}readUint8(t){return this._dataView.getUint8(t-this._sliceOffset,this._littleEndian)}readInt8(t){return this._dataView.getInt8(t-this._sliceOffset,this._littleEndian)}readUint16(t){return this._dataView.getUint16(t-this._sliceOffset,this._littleEndian)}readInt16(t){return this._dataView.getInt16(t-this._sliceOffset,this._littleEndian)}readUint32(t){return this._dataView.getUint32(t-this._sliceOffset,this._littleEndian)}readInt32(t){return this._dataView.getInt32(t-this._sliceOffset,this._littleEndian)}readFloat32(t){return this._dataView.getFloat32(t-this._sliceOffset,this._littleEndian)}readFloat64(t){return this._dataView.getFloat64(t-this._sliceOffset,this._littleEndian)}readUint64(t){const e=this.readUint32(t),r=this.readUint32(t+4);let n;if(this._littleEndian){if(n=e+2**32*r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}if(n=2**32*e+r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}readInt64(t){let e=0;const r=(128&this._dataView.getUint8(t+(this._littleEndian?7:0)))>0;let n=!0;for(let i=0;i<8;i++){let a=this._dataView.getUint8(t+(this._littleEndian?i:7-i));r&&(n?0!==a&&(a=255&~(a-1),n=!1):a=255&~a),e+=a*256**i}return r&&(e=-e),e}readOffset(t){return this._bigTiff?this.readUint64(t):this.readUint32(t)}}),cO)),l=i(function(){if(pO)return mO;pO=1;var t=af&&af.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),e=af&&af.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=af&&af.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&t(n,r,i);return e(n,r),n};Object.defineProperty(mO,"__esModule",{value:!0});const n=rO(),i="undefined"!=typeof navigator&&navigator.hardwareConcurrency||2;return mO.default=class{constructor(t=i,e){this.workers=null,this._awaitingDecoder=null,this.size=t,this.messageId=0,t&&(this._awaitingDecoder=e?Promise.resolve(e):new Promise((t=>{Promise.resolve().then((()=>r(vO()))).then((e=>{t(e.create)}))})),this._awaitingDecoder.then((e=>{this._awaitingDecoder=null,this.workers=[];for(let r=0;rr.decode(t,e))):new Promise((r=>{const n=this.workers.find((t=>t.idle))||this.workers[Math.floor(Math.random()*this.size)];n.idle=!1;const i=this.messageId++,a=t=>{t.data.id===i&&(n.idle=!0,r(t.data.decoded),n.worker.removeEventListener("message",a))};n.worker.addEventListener("message",a),n.worker.postMessage({fileDirectory:t,buffer:e,id:i},[e])}))}destroy(){this.workers&&(this.workers.forEach((t=>{t.worker.terminate()})),this.workers=null)}},mO}());t.Pool=l.default;const u=jO(),c=function(){if(VO)return HO;VO=1,Object.defineProperty(HO,"__esModule",{value:!0}),HO.makeBufferSource=void 0;const t=MO(),e=CO();class r extends t.BaseSource{constructor(t){super(),this.arrayBuffer=t}fetchSlice(t,r){if(r&&r.aborted)throw new e.AbortError("Request aborted");return this.arrayBuffer.slice(t.offset,t.offset+t.length)}}return HO.makeBufferSource=function(t){return new r(t)},HO}(),h=function(){if(WO)return qO;WO=1,Object.defineProperty(qO,"__esModule",{value:!0}),qO.makeFileReaderSource=void 0;const t=MO();class e extends t.BaseSource{constructor(t){super(),this.file=t}async fetchSlice(t,e){return new Promise(((r,n)=>{const i=this.file.slice(t.offset,t.offset+t.length),a=new FileReader;a.onload=t=>r(t.target.result),a.onerror=n,a.onabort=n,a.readAsArrayBuffer(i),e&&e.addEventListener("abort",(()=>a.abort()))}))}}return qO.makeFileReaderSource=function(t){return new e(t)},qO}(),d=ZO(),f=FI(),p=QO(),m=n(FI());t.globals=m;const g=n(BI());t.rgb=g;const v=rO();Object.defineProperty(t,"getDecoder",{enumerable:!0,get:function(){return v.getDecoder}}),Object.defineProperty(t,"addDecoder",{enumerable:!0,get:function(){return v.addDecoder}});const y=function(){if($O)return nD;$O=1,Object.defineProperty(nD,"__esModule",{value:!0}),nD.timeEnd=nD.time=nD.error=nD.warn=nD.info=nD.log=nD.debug=nD.setLogger=void 0;class t{log(){}debug(){}info(){}warn(){}error(){}time(){}timeEnd(){}}let e=new t;return nD.setLogger=function(r=new t){e=r},nD.debug=function(...t){return e.debug(...t)},nD.log=function(...t){return e.log(...t)},nD.info=function(...t){return e.info(...t)},nD.warn=function(...t){return e.warn(...t)},nD.error=function(...t){return e.error(...t)},nD.time=function(...t){return e.time(...t)},nD.timeEnd=function(...t){return e.timeEnd(...t)},nD}();Object.defineProperty(t,"setLogger",{enumerable:!0,get:function(){return y.setLogger}});var x=XI();function _(t){switch(t){case f.fieldTypes.BYTE:case f.fieldTypes.ASCII:case f.fieldTypes.SBYTE:case f.fieldTypes.UNDEFINED:return 1;case f.fieldTypes.SHORT:case f.fieldTypes.SSHORT:return 2;case f.fieldTypes.LONG:case f.fieldTypes.SLONG:case f.fieldTypes.FLOAT:case f.fieldTypes.IFD:return 4;case f.fieldTypes.RATIONAL:case f.fieldTypes.SRATIONAL:case f.fieldTypes.DOUBLE:case f.fieldTypes.LONG8:case f.fieldTypes.SLONG8:case f.fieldTypes.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${t}`)}}function w(t,e,r,n){let i=null,a=null;const o=_(e);switch(e){case f.fieldTypes.BYTE:case f.fieldTypes.ASCII:case f.fieldTypes.UNDEFINED:i=new Uint8Array(r),a=t.readUint8;break;case f.fieldTypes.SBYTE:i=new Int8Array(r),a=t.readInt8;break;case f.fieldTypes.SHORT:i=new Uint16Array(r),a=t.readUint16;break;case f.fieldTypes.SSHORT:i=new Int16Array(r),a=t.readInt16;break;case f.fieldTypes.LONG:case f.fieldTypes.IFD:i=new Uint32Array(r),a=t.readUint32;break;case f.fieldTypes.SLONG:i=new Int32Array(r),a=t.readInt32;break;case f.fieldTypes.LONG8:case f.fieldTypes.IFD8:i=new Array(r),a=t.readUint64;break;case f.fieldTypes.SLONG8:i=new Array(r),a=t.readInt64;break;case f.fieldTypes.RATIONAL:i=new Uint32Array(2*r),a=t.readUint32;break;case f.fieldTypes.SRATIONAL:i=new Int32Array(2*r),a=t.readInt32;break;case f.fieldTypes.FLOAT:i=new Float32Array(r),a=t.readFloat32;break;case f.fieldTypes.DOUBLE:i=new Float64Array(r),a=t.readFloat64;break;default:throw new RangeError(`Invalid field type: ${e}`)}if(e!==f.fieldTypes.RATIONAL&&e!==f.fieldTypes.SRATIONAL)for(let e=0;et.getWidth()-e.getWidth()));for(let e=0;en||a&&a>o)break}}let h=e;if(o){const[t,e]=s.getOrigin(),[r,n]=l.getResolution(s);h=[Math.round((o[0]-t)/r),Math.round((o[1]-e)/n),Math.round((o[2]-t)/r),Math.round((o[3]-e)/n)],h=[Math.min(h[0],h[2]),Math.min(h[1],h[3]),Math.max(h[0],h[2]),Math.max(h[1],h[3])]}return l.readRasters({...t,window:h})}}class T extends S{constructor(t,e,r,n,i={}){super(),this.source=t,this.littleEndian=e,this.bigTiff=r,this.firstIFDOffset=n,this.cache=i.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(t,e){const r=this.bigTiff?4048:1024;return new s.default((await this.source.fetch([{offset:t,length:void 0!==e?e:r}]))[0],t,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(t){const e=this.bigTiff?20:12,r=this.bigTiff?8:2;let n=await this.getSlice(t);const i=this.bigTiff?n.readUint64(t):n.readUint16(t),a=i*e+(this.bigTiff?16:6);n.covers(t,a)||(n=await this.getSlice(t,a));const o={};let s=t+(this.bigTiff?8:2);for(let t=0;t{const e=await this.ifdRequests[t-1];if(0===e.nextIFDByteOffset)throw new M(t);return this.parseFileDirectoryAt(e.nextIFDByteOffset)})(),this.ifdRequests[t]}async getImage(t=0){const e=await this.requestIFD(t);return new a.default(e.fileDirectory,e.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let t=0,e=!0;for(;e;)try{await this.requestIFD(t),++t}catch(t){if(!(t instanceof M))throw t;e=!1}return t}async getGhostValues(){const t=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const e="GDAL_STRUCTURAL_METADATA_SIZE=";let r=await this.getSlice(t,130);if(e===w(r,f.fieldTypes.ASCII,30,t)){const e=w(r,f.fieldTypes.ASCII,130,t).split("\n")[0],n=Number(e.split("=")[1].split(" ")[0])+e.length;n>130&&(r=await this.getSlice(t,n));const i=w(r,f.fieldTypes.ASCII,n,t);this.ghostValues={},i.split("\n").filter((t=>t.length>0)).map((t=>t.split("="))).forEach((([t,e])=>{this.ghostValues[t]=e}))}return this.ghostValues}static async fromSource(t,e,r){const n=(await t.fetch([{offset:0,length:1024}],r))[0],i=new o.default(n),a=i.getUint16(0,0);let s;if(18761===a)s=!0;else{if(19789!==a)throw new TypeError("Invalid byte order value.");s=!1}const l=i.getUint16(2,s);let u;if(42===l)u=!1;else{if(43!==l)throw new TypeError("Invalid magic number.");u=!0;if(8!==i.getUint16(4,s))throw new Error("Unsupported offset byte-size.")}const c=u?i.getUint64(8,s):i.getUint32(4,s);return new T(t,s,u,c,e)}close(){return"function"==typeof this.source.close&&this.source.close()}}t.GeoTIFF=T,t.default=T;class E extends S{constructor(t,e){super(),this.mainFile=t,this.overviewFiles=e,this.imageFiles=[t].concat(e),this.fileDirectoriesPerFile=null,this.fileDirectoriesPerFileParsing=null,this.imageCount=null}async parseFileDirectoriesPerFile(){const t=[this.mainFile.parseFileDirectoryAt(this.mainFile.firstIFDOffset)].concat(this.overviewFiles.map((t=>t.parseFileDirectoryAt(t.firstIFDOffset))));return this.fileDirectoriesPerFile=await Promise.all(t),this.fileDirectoriesPerFile}async getImage(t=0){await this.getImageCount(),await this.parseFileDirectoriesPerFile();let e=0,r=0;for(let n=0;nt.getImageCount())));return this.imageCounts=await Promise.all(t),this.imageCount=this.imageCounts.reduce(((t,e)=>t+e),0),this.imageCount}}t.MultiGeoTIFF=E,t.fromUrl=async function(t,e={},r){return T.fromSource((0,u.makeRemoteSource)(t,e),r)},t.fromArrayBuffer=async function(t,e){return T.fromSource((0,c.makeBufferSource)(t),e)},t.fromFile=async function(t,e){return T.fromSource((0,d.makeFileSource)(t),e)},t.fromBlob=async function(t,e){return T.fromSource((0,h.makeFileReaderSource)(t),e)},t.fromUrls=async function(t,e=[],r={},n){const i=await T.fromSource((0,u.makeRemoteSource)(t,r),n),a=await Promise.all(e.map((t=>T.fromSource((0,u.makeRemoteSource)(t,r)))));return new E(i,a)},t.writeArrayBuffer=function(t,e){return(0,p.writeGeotiff)(t,e)}}(BC)),BC}function aD(){if(eD)return PC;eD=1;var t=uf;Object.defineProperty(PC,"__esModule",{value:!0}),PC.default=void 0;var e=t(function(){if(RC)return AC;RC=1;var t=LC()();AC=t;try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}return AC}()),r=t((OC||(OC=1,function(t){function e(t,e,r,n,i,a,o){try{var s=t[a](o),l=s.value}catch(t){return void r(t)}s.done?e(l):Promise.resolve(l).then(n,i)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(i,a){var o=t.apply(r,n);function s(t){e(o,i,a,s,l,"next",t)}function l(t){e(o,i,a,s,l,"throw",t)}s(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports}(kC)),DC)),n=t(OM()),i=Bf,a=iD(),o=t(pM()),s=t(dS()),l=t(Qb());function u(t,e){for(var r=1/0,n=-1/0,i=0,a=t.length;i0&&u80*i){a=s=t[0],o=c=t[1];for(var x=i;xs&&(s=h),f>c&&(c=f);p=0!==(p=Math.max(s-a,c-o))?32767/p:0}return n(v,y,i,a,o,p,0),y}function e(t,e,r,n,i){var a,o;if(i===T(t,e,r,n)>0)for(a=e;a=e;a-=n)o=b(a,t[a],t[a+1],o);return o&&g(o,o.next)&&(M(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!g(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(M(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function n(t,e,l,u,c,d,f){if(t){!f&&d&&function(t,e,r,n){var i=t;do{0===i.z&&(i.z=h(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,u=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,u*=2}while(o>1)}(i)}(t,u,c,d);for(var p,m,g=t;t.prev!==t.next;)if(p=t.prev,m=t.next,d?a(t,u,c,d):i(t))e.push(p.i/l|0),e.push(t.i/l|0),e.push(m.i/l|0),M(t),t=m.next,g=m.next;else if((t=m)===g){f?1===f?n(t=o(r(t),e,l),e,l,u,c,d,2):2===f&&s(t,e,l,u,c,d):n(r(t),e,l,u,c,d,1);break}}}function i(t){var e=t.prev,r=t,n=t.next;if(m(e,r,n)>=0)return!1;for(var i=e.x,a=r.x,o=n.x,s=e.y,l=r.y,u=n.y,c=ia?i>o?i:o:a>o?a:o,p=s>l?s>u?s:u:l>u?l:u,g=n.next;g!==e;){if(g.x>=c&&g.x<=d&&g.y>=h&&g.y<=p&&f(i,s,a,l,o,u,g.x,g.y)&&m(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function a(t,e,r,n){var i=t.prev,a=t,o=t.next;if(m(i,a,o)>=0)return!1;for(var s=i.x,l=a.x,u=o.x,c=i.y,d=a.y,p=o.y,g=sl?s>u?s:u:l>u?l:u,x=c>d?c>p?c:p:d>p?d:p,_=h(g,v,e,r,n),w=h(y,x,e,r,n),b=t.prevZ,M=t.nextZ;b&&b.z>=_&&M&&M.z<=w;){if(b.x>=g&&b.x<=y&&b.y>=v&&b.y<=x&&b!==i&&b!==o&&f(s,c,l,d,u,p,b.x,b.y)&&m(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,M.x>=g&&M.x<=y&&M.y>=v&&M.y<=x&&M!==i&&M!==o&&f(s,c,l,d,u,p,M.x,M.y)&&m(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;b&&b.z>=_;){if(b.x>=g&&b.x<=y&&b.y>=v&&b.y<=x&&b!==i&&b!==o&&f(s,c,l,d,u,p,b.x,b.y)&&m(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;M&&M.z<=w;){if(M.x>=g&&M.x<=y&&M.y>=v&&M.y<=x&&M!==i&&M!==o&&f(s,c,l,d,u,p,M.x,M.y)&&m(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function o(t,e,n){var i=t;do{var a=i.prev,o=i.next.next;!g(a,o)&&v(a,i,i.next,o)&&_(a,o)&&_(o,a)&&(e.push(a.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),M(i),M(i.next),i=t=o),i=i.next}while(i!==t);return r(i)}function s(t,e,i,a,o,s){var l=t;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&p(l,u)){var c=w(l,u);return l=r(l,l.next),c=r(c,c.next),n(l,e,i,a,o,s,0),void n(c,e,i,a,o,s,0)}u=u.next}l=l.next}while(l!==t)}function l(t,e){return t.x-e.x}function u(t,e){var n=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o&&(o=s,r=n.x=n.x&&n.x>=h&&i!==n.x&&f(ar.x||n.x===r.x&&c(r,n)))&&(r=n,p=l)),n=n.next}while(n!==u);return r}(t,e);if(!n)return e;var i=w(n,t);return r(i,i.next),r(n,n.next)}function c(t,e){return m(t.prev,t,e.prev)<0&&m(e.next,t,t.next)<0}function h(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,r=t;do{(e.x=(t-o)*(a-s)&&(t-o)*(n-s)>=(r-o)*(e-s)&&(r-o)*(a-s)>=(i-o)*(n-s)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&v(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(_(t,e)&&_(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(m(t.prev,t,e.prev)||m(t,e.prev,e))||g(t,e)&&m(t.prev,t,t.next)>0&&m(e.prev,e,e.next)>0)}function m(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function g(t,e){return t.x===e.x&&t.y===e.y}function v(t,e,r,n){var i=x(m(t,e,r)),a=x(m(t,e,n)),o=x(m(r,n,t)),s=x(m(r,n,e));return i!==a&&o!==s||(!(0!==i||!y(t,r,e))||(!(0!==a||!y(t,n,e))||(!(0!==o||!y(r,t,n))||!(0!==s||!y(r,e,n)))))}function y(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function x(t){return t>0?1:t<0?-1:0}function _(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function w(t,e){var r=new S(t.i,t.x,t.y),n=new S(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function b(t,e,r,n){var i=new S(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function M(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r},uD}var dD=uf,fD=cf;Object.defineProperty(lf,"__esModule",{value:!0});var pD=lf.default=lf.INSTANCE_EVENTS=void 0,mD=dD(pf()),gD=dD(yf()),vD=dD(bf()),yD=dD(Cf()),xD=dD(Df()),_D=dD(Uf()),wD=Bf,bD=dD(pv),MD=ax,SD=dD(function(){if(Dx)return lx;Dx=1;var t=uf;Object.defineProperty(lx,"__esModule",{value:!0}),lx.default=void 0;var e=Bf,r=t(Ux());function n(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Object.defineProperty(this,"crs",{get:function(){return t}}),this.camera3D=i.camera?i.camera:new e.PerspectiveCamera(30,r/n),this.camera3D.near=.1,this.camera3D.far=2e9,this.camera3D.updateProjectionMatrix(),this.camera2D=new e.OrthographicCamera(0,1,0,1,0,10),this._viewMatrix=new e.Matrix4,this.width=r,this.height=n,this._preSSE=1/0}n.prototype.update=function(t,e){!function(t,e,r){if(e&&r){t.width=e,t.height=r;var n=e/r;if(t.camera3D.aspect!==n&&(t.camera3D.aspect=n,t.camera3D.isOrthographicCamera)){var i=.5*(t.camera3D.right-t.camera3D.left)/n,a=.5*(t.camera3D.top+t.camera3D.bottom);t.camera3D.top=a+i,t.camera3D.bottom=a-i}}t.camera3D.updateProjectionMatrix&&t.camera3D.updateProjectionMatrix(),t.camera2D.right=e,t.camera2D.top=r,t.camera2D.bottom=0,t.camera2D.updateProjectionMatrix()}(this,t,e),this.camera3D.updateMatrixWorld(),this._viewMatrix.multiplyMatrices(this.camera3D.projectionMatrix,this.camera3D.matrixWorldInverse)},n.prototype.position=function(t){return new r.default(this.crs,this.camera3D.position).as(t||this.crs)};var i={frustum:new e.Frustum,matrix:new e.Matrix4,box3:new e.Box3},a=[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3],o=new e.Box3(new e.Vector3(-1,-1,-1),new e.Vector3(1,1,1));n.prototype.isBox3Visible=function(t,e){return this.box3SizeOnScreen(t,e).intersectsBox(o)},n.prototype.isSphereVisible=function(t,e){return e?(i.matrix.multiplyMatrices(this._viewMatrix,e),i.frustum.setFromProjectionMatrix(i.matrix)):i.frustum.setFromProjectionMatrix(this._viewMatrix),i.frustum.intersectsSphere(t)},n.prototype.box3SizeOnScreen=function(t,e){var r=function(t,e,r){var n=t.camera3D.matrixWorldInverse;r&&(n=i.matrix.multiplyMatrices(t.camera3D.matrixWorldInverse,r)),a[0].set(e.min.x,e.min.y,e.min.z).applyMatrix4(n),a[1].set(e.min.x,e.min.y,e.max.z).applyMatrix4(n),a[2].set(e.min.x,e.max.y,e.min.z).applyMatrix4(n),a[3].set(e.min.x,e.max.y,e.max.z).applyMatrix4(n),a[4].set(e.max.x,e.min.y,e.min.z).applyMatrix4(n),a[5].set(e.max.x,e.min.y,e.max.z).applyMatrix4(n),a[6].set(e.max.x,e.max.y,e.min.z).applyMatrix4(n),a[7].set(e.max.x,e.max.y,e.max.z).applyMatrix4(n);for(var o=!1,s=0;s<8;s++)a[s].z<=-t.camera3D.near?o=!0:a[s].z=-t.camera3D.near;return o?a:void 0}(this,t,e);if(!r)return i.box3.makeEmpty();for(var n=0;n<8;n++)r[n].applyMatrix4(this.camera3D.projectionMatrix);return i.box3.setFromPoints(r)};var s=n;return lx.default=s,lx}()),TD=kD(function(){if(lS)return Bx;lS=1;var t=uf;Object.defineProperty(Bx,"__esModule",{value:!0}),Bx.default=Bx.RENDERING_SCHEDULED=Bx.RENDERING_PAUSED=Bx.MAIN_LOOP_EVENTS=void 0;var e=Bf,r=t(jb()),n=t(oS()),i=t(pM()),a=t(function(){if(sS)return uS;sS=1;var t=uf;Object.defineProperty(uS,"__esModule",{value:!0}),uS.default=void 0;var e=t(yf()),r=t(pf()),n=Bf,i=(0,e.default)((function t(e,i,a){(0,r.default)(this,t),this.camera=e,this.scheduler=i,this.instance=a,this.distance={plane:(new n.Plane).setFromNormalAndCoplanarPoint(e.camera3D.getWorldDirection(new n.Vector3),e.camera3D.position),min:1/0,max:0},this.fastUpdateHint=void 0}));return uS.default=i,uS}());function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:{};this.renderingState=l,this.needsRedraw=!1,this.scheduler=t,this.gfxEngine=e,this._updateLoopRestarted=!0,this.maxFar=r.maxFar||2e9,this.minNear=r.minNear||.1}function d(t,e,r){if(r){var n,i=o(r);try{for(i.s();!(n=i.n()).done;){var a=n.value,s=e.update(t,a),l=e.getObjectToUpdateForAttachedLayers(a);if(l)if(l.element){var u,c=o(e._attachedLayers);try{for(c.s();!(u=c.n()).done;){var h=u.value;h.ready&&h.update(t,l.element,l.parent)}}catch(t){c.e(t)}finally{c.f()}}else if(l.elements)for(var f=0;f0){m._distance.min=1/0,m._distance.max=0;var v=m.preUpdate(l,g);d(l,m,v),m.postUpdate(l,i)}m._distance&&(l.distance.min=Math.min(l.distance.min,m._distance.min),m._distance.max===1/0?l.distance.max=this.maxFar:l.distance.max=Math.max(l.distance.max,m._distance.max)),t.execFrameRequesters(c.AFTER_LAYER_UPDATE,s,this._updateLoopRestarted,m)}}}catch(t){p.e(t)}finally{p.f()}t.threeObjects.traverse((function(t){if(t.visible&&t.geometry&&t.geometry.boundingSphere){u.copy(t.geometry.boundingSphere),u.applyMatrix4(t.matrixWorld);var r=u.distanceToPoint(l.camera.camera3D.position);l.distance.min=e.Math.clamp(r,0,l.distance.min),l.distance.max=Math.max(l.distance.max,r+2*u.radius)}}));var y=l.distance.min;t.camera.camera3D.isPerspective&&(y*=y*Math.cos(e.Math.degToRad(t.camera.camera3D.fov/2))),y=y===1/0?this.minNear:e.Math.clamp(y,this.minNear,this.maxFar),t.camera.camera3D.near=y;var x=0===l.distance.max?this.maxFar:e.Math.clamp(l.distance.max,y,this.maxFar);t.camera.camera3D.far=x,t.camera.update()},h.prototype._step=function(t,e){var r=e-this._lastTimestamp;t._executeFrameRequestersRemovals(),t.execFrameRequesters(c.UPDATE_START,r,this._updateLoopRestarted);var n=this.needsRedraw;this._lastTimestamp=e,this.needsRedraw=!1,this.renderingState=l;var a=new Set(t._changeSources);t._changeSources.clear();var o=this.gfxEngine.getWindowSize();t.execFrameRequesters(c.BEFORE_CAMERA_UPDATE,r,this._updateLoopRestarted),t.camera.update(o.x,o.y),t.execFrameRequesters(c.AFTER_CAMERA_UPDATE,r,this._updateLoopRestarted);var s=t.camera.camera3D.matrixAutoUpdate;t.camera.camera3D.matrixAutoUpdate=!1,this._update(t,a,r),0===this.scheduler.commandsWaitingExecutionCount()&&this.dispatchEvent({type:"command-queue-empty"}),n&&this._renderInstance(t,r),this._updateLoopRestarted=this.renderingState===l,t.camera.camera3D.matrixAutoUpdate=s,i.default.flush(),t.execFrameRequesters(c.UPDATE_END,r,this._updateLoopRestarted)},h.prototype._renderInstance=function(t,e){t.execFrameRequesters(c.BEFORE_RENDER,e,this._updateLoopRestarted),t.render?t.render():this.gfxEngine.renderView(t),t.execFrameRequesters(c.AFTER_RENDER,e,this._updateLoopRestarted)};var p=h;return Bx.default=p,Bx}()),ED=dD(dS()),AD=Ob(),RD=kD(jb()),PD=dD(oS()),CD=dD(function(){if(rD)return fS;rD=1;var t=uf;Object.defineProperty(fS,"__esModule",{value:!0}),fS.default=void 0;var e=t(yS()),r=t(xS),n=t(jS()),i=t(tA()),a=t(DA()),o=t(WA()),s=t(nR()),l=t(sR()),u=t(bC()),c=t(TC()),h=t(aD()),d=t(Jb()),f=t(pM());function p(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:1;return this.counters.pending-=n,this.counters.executing+=n,e.executeCommand(t).then((function(e){r.counters.executing-=n,t.resolve(e),r.counters.executed+=n}),(function(e){r.counters.executing-=n,t.reject(e),r.counters.failed+=n,r.counters.failed<3&&console.error(e)}))}}}function y(){this.defaultQueue=v(),this.hostQueues=new Map,this.providers={},this.maxCommandsPerHost=6,this.initDefaultProviders()}function x(t){return!!t.toDownload&&(t.url?!!f.default.get(t.url):!!t.tile&&t.tile.getState()===r.default.LOADED)}y.prototype.constructor=y,y.prototype.initDefaultProviders=function(){this.addProtocolProvider("tile",n.default),this.addProtocolProvider("3d-tiles",i.default),this.addProtocolProvider("tms",a.default),this.addProtocolProvider("xyz",a.default),this.addProtocolProvider("potreeconverter",o.default),this.addProtocolProvider("customtiledimage",s.default),this.addProtocolProvider("oltile",l.default),this.addProtocolProvider("olvectortile",u.default),this.addProtocolProvider("olvector",c.default),this.addProtocolProvider("cog",h.default)},y.prototype.runCommand=function(t,e){var r=this,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this.providers[t.layer.protocol];if(!i)throw new Error("No known provider for layer",t.layer.id);return e.execute(t,i,n?1:0).then((function(){if(t.view.notifyChange(t.requester,t.redraw),n&&r.flush(e,t.layer.id),n&&e.counters.executing0&&(i+=o.priority,o.accumulator+=o.priority,(!e||o.accumulator>r)&&(e=o,r=o.accumulator))}}catch(t){a.e(t)}finally{a.f()}return e?(e.accumulator-=i,e.q):null}(t.storages);e&&e.length>0;){var r=e.dequeue();if(!r.earlyDropFunction||!r.earlyDropFunction(r))return r;t.counters.pending--,t.counters.cancelled++,r.reject(new d.default(r))}return e?this.deQueue(t):null};var _=y;return fS.default=_,fS}()),ID=dD(WM()),LD=dD(function(){if(sD)return lD;sD=1;var t=uf;Object.defineProperty(lD,"__esModule",{value:!0}),lD.default=void 0;var e=Bf,r=t(hD());function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r3?i-3:0),o=3;o0&&void 0!==arguments[0]?arguments[0]:{};return function(r){return r?function(t,r){if(!t||0===t.length)return null;if(1===t.length)return l(t[0],r);var i=new e.Group;i.minAltitude=1/0;var a,o=n(t);try{for(o.s();!(a=o.n()).done;){var s=l(a.value,r);i.add(s),i.minAltitude=Math.min(s.minAltitude,i.minAltitude)}}catch(t){o.e(t)}finally{o.f()}return i}(r,t):null}}};return lD.default=u,lD}()),OD=dD(LS());function DD(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return(DD=function(t){return t?r:e})(t)}function kD(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==fD(t)&&"function"!=typeof t)return{default:t};var r=DD(e);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var o=i?Object.getOwnPropertyDescriptor(t,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=t[a]}return n.default=t,r&&r.set(t,n),n}function FD(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return ND(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ND(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function ND(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{};if((0,mD.default)(this,r),n=e.call(this),wD.Object3D.DefaultUp.set(0,0,1),!t)throw new Error("Invalid viewerDiv parameter (must non be null/undefined)");(n.referenceCrs=a.crs||"EPSG:3857",a.mainLoop)?n.mainLoop=a.mainLoop:(i=a.renderer&&a.renderer.domElement?new ED.default(a.renderer):new ED.default(t,a.renderer),n.mainLoop=new TD.default(new CD.default,i));return n.scene=a.scene3D||new wD.Scene,n.threeObjects=new wD.Group,n.scene.add(n.threeObjects),n.scene2D=new wD.Scene,a.scene3D||(n.scene.autoUpdate=!1),n.camera=new SD.default(n.referenceCrs,n.mainLoop.gfxEngine.getWindowSize().x,n.mainLoop.gfxEngine.getWindowSize().y,a),n._frameRequesters={},n._objects=[],window.addEventListener("resize",(function(){var e=t.getBoundingClientRect(),r=new wD.Vector2(e.width,e.height);n.mainLoop.gfxEngine.onWindowResize(r.x,r.y),n.notifyChange(n.camera.camera3D)}),!1),n._changeSources=new Set,n._delayedFrameRequesterRemoval=[],n._allLayersAreReadyCallback=function(){n.getObjects().every((function(t){return t.ready}))&&n.getLayers().every((function(t){return t.ready}))&&0===n.mainLoop.scheduler.commandsWaitingExecutionCount()&&n.mainLoop.renderingState===TD.RENDERING_PAUSED&&(n.dispatchEvent({type:BD.LAYERS_INITIALIZED}),n.removeFrameRequester(TD.MAIN_LOOP_EVENTS.UPDATE_END,n._allLayersAreReadyCallback))},n.controls=null,n._controlFunctions=null,Object.defineProperty((0,vD.default)(n),"domElement",{value:n.mainLoop.gfxEngine.renderer.domElement,writable:!1}),n}return(0,gD.default)(r,[{key:"add",value:function(t){var e=this;return t instanceof wD.Object3D||t instanceof PD.default?(t._instance=this,new Promise((function(r,n){if(t)if(e.getObjects((function(e){return e.id===t.id})).length>0)n(new Error("Invalid id '".concat(t.id,"': id already used")));else{var i=e.mainLoop.scheduler.getProtocolProvider(t.protocol);!t.protocol||i?(t=function(t,e,r,n){if(!(e instanceof RD.default||e instanceof PD.default)){var i=new RD.default(e.id),a=e;delete a.id,e=Object.assign(i,e),a.id=e.id}e.options=e.options||{},e.updateStrategy||(e.updateStrategy={type:AD.STRATEGY_MIN_NETWORK_TRAFFIC});r&&(r.tileInsideLimit&&(e.tileInsideLimit=r.tileInsideLimit.bind(r)),r.getPossibleTextureImprovements&&(e.getPossibleTextureImprovements=r.getPossibleTextureImprovements.bind(r)),r.tileTextureCount&&(e.tileTextureCount=r.tileTextureCount.bind(r)));if(!e.whenReady){e.object3d||(e.threejsLayer=t.mainLoop.gfxEngine.getUniqueThreejsLayer());var o=Promise.resolve();r&&r.preprocessDataLayer&&((o=r.preprocessDataLayer(e,t,t.mainLoop.scheduler,n))&&o.then||(o=Promise.resolve())),e.whenReady=o.then((function(){return e.ready=!0,e}))}return(0,RD.defineLayerProperty)(e,"visible",!0,(function(){return jD(e,t)})),(0,RD.defineLayerProperty)(e,"frozen",!1),jD(e,t),e}(e,t,i),t.projection||(t.projection=e.referenceCrs),e._objects.push(t),t.whenReady.then((function(t){if("function"==typeof t.update)if("function"==typeof t.preUpdate){t.object3d&&!t.object3d.parent&&t.object3d!==e.scene&&e.scene.add(t.object3d),e.notifyChange(t,!1);var i=e._frameRequesters[TD.MAIN_LOOP_EVENTS.UPDATE_END];i&&-1!==i.indexOf(e._allLayersAreReadyCallback)||e.addFrameRequester(TD.MAIN_LOOP_EVENTS.UPDATE_END,e._allLayersAreReadyCallback),r(t)}else n(new Error("Cant add Entity3D: missing a preUpdate function"));else n(new Error("Cant add Entity3D: missing a update function"))}))):n(new Error("".concat(t.protocol," is not a recognized protocol name.")))}else n(new Error("object is undefined"))}))):Promise.reject(new Error("object is not an instance of THREE.Object3D or Giro3d.Entity3D"))}},{key:"remove",value:function(t){t.object3d&&(OD.default.removeChildrenAndCleanupRecursively(t,t.object3d),this.scene.remove(t.object3d)),"function"==typeof t.clean&&t.clean(),this._objects.splice(this._objects.indexOf(t,1)),this.notifyChange(this.camera.camera3D,!0)}},{key:"addVector",value:function(t){var e=this;return new Promise((function(r){var n=t.getSource(),i=LD.default.convert({altitude:1});n.on("change",(function(){t.object3d&&(e.threeObjects.remove(t.object3d),t.object3d.traverse((function(t){t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose(),t.dispose()}))),t.object3d=i(n.getFeatures()),e.threeObjects.add(t.object3d),e.notifyChange(t.object3d,!0)})),n.getFeatures().length>0?(t.object3d=i(n.getFeatures()),e.threeObjects.add(t.object3d),e.notifyChange(t.object3d,!0),r(t)):(n.once("change",(function(){return r(t)})),n.loadFeatures([-1/0,-1/0,1/0,1/0],void 0,e.referenceCrs))}))}},{key:"notifyChange",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];t&&this._changeSources.add(t),this.mainLoop.scheduleUpdate(this,e)}},{key:"getObjects",value:function(t){var e,r=[],n=FD(this._objects);try{for(n.s();!(e=n.n()).done;){var i=e.value;t&&!t(i)||r.push(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"getLayers",value:function(t){var e,r=[],n=FD(this._objects);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=r.concat(i.getLayers(t))}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"getOwner",value:function(t){var e,r=FD(this._objects);try{for(r.s();!(e=r.n()).done;){var n,i=e.value,a=FD(i._attachedLayers);try{for(a.s();!(n=a.n()).done;){if(n.value===t)return i}}catch(t){a.e(t)}finally{a.f()}}}catch(t){r.e(t)}finally{r.f()}return null}},{key:"addFrameRequester",value:function(t,e){if("function"!=typeof e)throw new Error("frameRequester must be a function");this._frameRequesters[t]?this._frameRequesters[t].push(e):this._frameRequesters[t]=[e]}},{key:"removeFrameRequester",value:function(t,e){this._frameRequesters[t].indexOf(e)>=0?this._delayedFrameRequesterRemoval.push({when:t,frameRequester:e}):console.error("Invalid call to removeFrameRequester: frameRequester isn't registered")}},{key:"_executeFrameRequestersRemovals",value:function(){var t,e=FD(this._delayedFrameRequesterRemoval);try{for(e.s();!(t=e.n()).done;){var r=t.value,n=this._frameRequesters[r.when].indexOf(r.frameRequester);n>=0?this._frameRequesters[r.when].splice(n,1):console.warn("FrameReq has already been removed")}}catch(t){e.e(t)}finally{e.f()}this._delayedFrameRequesterRemoval.length=0}},{key:"execFrameRequesters",value:function(t,e,r){if(this._frameRequesters[t]){this._delayedFrameRequesterRemoval.length>0&&this._executeFrameRequestersRemovals();for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a1&&void 0!==arguments[1]?arguments[1]:0;if(void 0===t.touches||!t.touches.length)return zD.set(t.offsetX,t.offsetY);var r=this.mainLoop.gfxEngine.renderer.domElement.getBoundingClientRect();return zD.set(t.touches[e].clientX-r.x,t.touches[e].clientY-r.y)}},{key:"eventToNormalizedCoords",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.viewToNormalizedCoords(this.eventToViewCoords(t,e))}},{key:"viewToNormalizedCoords",value:function(t){return zD.x=t.x/this.camera.width*2-1,zD.y=t.y/this.camera.height*-2+1,zD}},{key:"normalizedToViewCoords",value:function(t){return zD.x=.5*(t.x+1)*this.camera.width,zD.y=-.5*(t.y-1)*this.camera.height,zD}},{key:"pickObjectsAt",value:function(t,e){for(var r=[],n=arguments.length,i=new Array(n>2?n-2:0),a=2;a{const r=t.__vccOpts||t;for(const[t,n]of e)r[t]=n;return r})({name:"giro3d",data:()=>({loadedModelIds:[],modelPointClouds:new Map,giro3dDivId:null}),created(){this.giro3dDivId=`3d-engine-${this.$viewer.globalContext.plugins.id}`,this.localContextResizeSubscription=this.$viewer.globalContext.hub.on("context-resize",this.onResize)},unmounted(){this.$viewer.globalContext.hub.off(this.localContextResizeSubscription)},async mounted(){const t=document.getElementById(this.giro3dDivId);await this.$nextTick();const e=new pD(t,{renderer:{clearColor:!1}}),r=new nf(e.camera.camera3D,e.domElement);r.enableDamping=!0,r.dampingFactor=.25,e.useTHREEControls(r),e.notifyChange(e.camera.camera3D),this.instance=e,this.controls=r},methods:{onResize({width:t,height:e}){this.instance&&(this.instance.mainLoop.gfxEngine.onWindowResize(t,e),this.instance.notifyChange(this.instance.camera.camera3D))},placeCamera(t,e){const{instance:r,controls:n}=this;r.camera.camera3D.position.set(t.x,t.y,t.z),r.camera.camera3D.lookAt(e),n.target.copy(e)},initializeCamera(t){const e=new Sr,r=t.root.bbox?t.root.bbox:t.root.boundingVolume.box.clone().applyMatrix4(t.root.matrixWorld);this.instance.camera.camera3D.far=2*r.getSize(e).length();const n=r.getSize(e).x/r.getSize(e).z,i=r.min.clone().add(r.getSize(e).multiply({x:0,y:0,z:.5*n})),a=r.getCenter(e);a.z=r.min.z,this.placeCamera(i,a)},async loadModels(t){this.loadedModelIds.push(...t.map((t=>t.id)).filter((t=>!this.loadedModelIds.includes(t)))),t.forEach((async(t,e)=>{const{apiUrl:r,cloudId:n,projectId:i,accessToken:a}=this.$viewer.api,o=await fetch(`${r}/cloud/${n}/project/${i}/model/${t.id}/tileset?tile_format=pnts`,{headers:new Headers({accept:"*/*",Authorization:`Bearer ${a}`})}),s=URL.createObjectURL(await o.blob()),l=new EE("pointcloud",new XD(s));this.modelPointClouds.set(t,l),await this.instance.add(l),URL.revokeObjectURL(s),0===e&&this.initializeCamera(l)}))},async unloadModels(t){const e=t.map((t=>this.modelPointClouds.get(t))).filter(Boolean);t.forEach((t=>this.modelPointClouds.delete(t))),e.forEach((t=>{this.instance.remove(t)}));const r=t.map((t=>t.id));this.loadedModelIds=this.loadedModelIds.filter((t=>!r.includes(t)))}}},[["render",function(t,e,r,n,i,a){const o=BIMDataViewerVue.resolveComponent("NoModelWindowPlaceHolder"),s=BIMDataViewerVue.resolveComponent("ModelsLoader");return BIMDataViewerVue.openBlock(),BIMDataViewerVue.createElementBlock("div",JD,[0!==i.loadedModelIds.length||t.loading?BIMDataViewerVue.createCommentVNode("",!0):(BIMDataViewerVue.openBlock(),BIMDataViewerVue.createBlock(o,{key:0})),BIMDataViewerVue.createVNode(s,{types:["POINT_CLOUD"],onLoadModels:a.loadModels,onUnloadModels:a.unloadModels,preview:""},null,8,["onLoadModels","onUnloadModels"]),BIMDataViewerVue.createElementVNode("div",{id:i.giro3dDivId,class:"bimdata-giro3d__viewer"},null,8,QD)])}],["__scopeId","data-v-fd5ecc76"]]),window:{name:"giro3d",label:"Giro3dPlugin.window_label",plugins:["fullscreen"]},i18n:{en:{window_label:"Giro3d"},fr:{window_label:"Giro3d"}}};export{$D as default}; \ No newline at end of file +!function(){var e,r,n,i,a,o,s,l,u,c,h,d,f,p,m,g,v=(e={defaultNoDataValue:-34027999387901484e22,decode:function(t,o){var s=(o=o||{}).encodedMaskData||null===o.encodedMaskData,l=a(t,o.inputOffset||0,s),u=null!==o.noDataValue?o.noDataValue:e.defaultNoDataValue,c=r(l,o.pixelType||Float32Array,o.encodedMaskData,u,o.returnMask),h={width:l.width,height:l.height,pixelData:c.resultPixels,minValue:c.minValue,maxValue:l.pixels.maxValue,noDataValue:u};return c.resultMask&&(h.maskData=c.resultMask),o.returnEncodedMask&&l.mask&&(h.encodedMaskData=l.mask.bitset?l.mask.bitset:null),o.returnFileInfo&&(h.fileInfo=n(l),o.computeUsedBitDepths&&(h.fileInfo.bitDepths=i(l))),h}},r=function(t,e,r,n,i){var a,s,l,u=0,c=t.pixels.numBlocksX,h=t.pixels.numBlocksY,d=Math.floor(t.width/c),f=Math.floor(t.height/h),p=2*t.maxZError,m=Number.MAX_VALUE;r=r||(t.mask?t.mask.bitset:null),s=new e(t.width*t.height),i&&r&&(l=new Uint8Array(t.width*t.height));for(var g,v,y=new Float32Array(d*f),x=0;x<=h;x++){var _=x!==h?f:t.height%h;if(0!==_)for(var w=0;w<=c;w++){var b=w!==c?d:t.width%c;if(0!==b){var M,S,T,E,A=x*t.width*f+w*d,P=t.width-b,R=t.pixels.blocks[u];if(R.encoding<2?(0===R.encoding?M=R.rawData:(o(R.stuffedData,R.bitsPerPixel,R.numValidPixels,R.offset,p,y,t.pixels.maxValue),M=y),S=0):T=2===R.encoding?0:R.offset,r)for(v=0;v<_;v++){for(7&A&&(E=r[A>>3],E<<=7&A),g=0;g>3]),128&E?(l&&(l[A]=1),m=m>(a=R.encoding<2?M[S++]:T)?a:m,s[A++]=a):(l&&(l[A]=0),s[A++]=n),E<<=1;A+=P}else if(R.encoding<2)for(v=0;v<_;v++){for(g=0;g(a=M[S++])?a:m,s[A++]=a;A+=P}else for(m=m>T?T:m,v=0;v<_;v++){for(g=0;g0){var o=new Uint8Array(Math.ceil(n.width*n.height/8)),s=(a=new DataView(t,e,n.mask.numBytes)).getInt16(0,!0),l=2,u=0;do{if(s>0)for(;s--;)o[u++]=a.getUint8(l++);else{var c=a.getUint8(l++);for(s=-s;s--;)o[u++]=c}s=a.getInt16(l,!0),l+=2}while(l0?1:0),p=d+(n.height%d>0?1:0);n.pixels.blocks=new Array(f*p);for(var m=0,g=0;g3)throw"Invalid block encoding ("+_.encoding+")";if(2!==_.encoding){if(0!==w&&2!==w){if(w>>=6,_.offsetType=w,2===w)_.offset=a.getInt8(1),y++;else if(1===w)_.offset=a.getInt16(1,!0),y+=2;else{if(0!==w)throw"Invalid block offset type";_.offset=a.getFloat32(1,!0),y+=4}if(1===_.encoding)if(w=a.getUint8(y),y++,_.bitsPerPixel=63&w,w>>=6,_.numValidPixelsType=w,2===w)_.numValidPixels=a.getUint8(y),y++;else if(1===w)_.numValidPixels=a.getUint16(y,!0),y+=2;else{if(0!==w)throw"Invalid valid pixel count type";_.numValidPixels=a.getUint32(y,!0),y+=4}}var b;if(e+=y,3!==_.encoding)if(0===_.encoding){var M=(n.pixels.numBytes-1)/4;if(M!==Math.floor(M))throw"uncompressed block has invalid length";b=new ArrayBuffer(4*M),new Uint8Array(b).set(new Uint8Array(t,e,4*M));var S=new Float32Array(b);_.rawData=S,e+=4*M}else if(1===_.encoding){var T=Math.ceil(_.numValidPixels*_.bitsPerPixel/8),E=Math.ceil(T/4);b=new ArrayBuffer(4*E),new Uint8Array(b).set(new Uint8Array(t,e,T)),_.stuffedData=new Uint32Array(b),e+=T}}else e++}return n.eofOffset=e,n},o=function(t,e,r,n,i,a,o){var s,l,u,c=(1<=e)l=u>>>d-e&c,d-=e;else{var m=e-d;l=(u&c)<>>(d=32-m)}a[s]=l=r?(u=c>>>m-r&f,m-=r):(u=(c&f)<<(h=r-m)&f,u+=(c=t[p++])>>>(m=32-h)),e[l]=i[u];else for(d=Math.ceil((s-a)/o),l=0;l=r?(u=c>>>m-r&f,m-=r):(u=(c&f)<<(h=r-m)&f,u+=(c=t[p++])>>>(m=32-h)),e[l]=u=e?(d=o>>>h-e&s,h-=e):(d=(o&s)<<(c=e-h)&s,d+=(o=t[l++])>>>(h=32-c)),f[u]=d=r?(u=c>>>m&d,p-=r,m+=r):(u=c>>>m&d,p=32-(h=r-p),u|=((c=t[f++])&(1<=r?(u=c>>>m&d,p-=r,m+=r):(u=c>>>m&d,p=32-(h=r-p),u|=((c=t[f++])&(1<=e?(d=o>>>f&s,h-=e,f+=e):(d=o>>>f&s,h=32-(c=e-h),d|=((o=t[l++])&(1<=r?(a=o>>>c-r&l,c-=r):(a=(o&l)<<(s=r-c)&l,a+=(o=t[u++])>>>(c=32-s)),e[i]=a;return e},d=function(t,e,r,n){var i,a,o,s,l=(1<=r?(a=o>>>h&l,c-=r,h+=r):(a=o>>>h&l,c=32-(s=r-c),a|=((o=t[u++])&(1<=359?359:i;i-=o;do{e+=t[a++]<<8,r+=e+=t[a++]}while(--o);e=(65535&e)+(e>>>16),r=(65535&r)+(r>>>16)}return 1&n&&(r+=e+=t[a]<<8),((r=(65535&r)+(r>>>16))<<16|(e=(65535&e)+(e>>>16)))>>>0},readHeaderInfo:function(t,e){var r=e.ptr,n=new Uint8Array(t,r,6),i={};if(i.fileIdentifierString=String.fromCharCode.apply(null,n),0!==i.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+i.fileIdentifierString;r+=6;var a,o=new DataView(t,r,8),s=o.getInt32(0,!0);if(i.fileVersion=s,r+=4,s>=3&&(i.checksum=o.getUint32(4,!0),r+=4),o=new DataView(t,r,12),i.height=o.getUint32(0,!0),i.width=o.getUint32(4,!0),r+=8,s>=4?(i.numDims=o.getUint32(8,!0),r+=4):i.numDims=1,o=new DataView(t,r,40),i.numValidPixel=o.getUint32(0,!0),i.microBlockSize=o.getInt32(4,!0),i.blobSize=o.getInt32(8,!0),i.imageType=o.getInt32(12,!0),i.maxZError=o.getFloat64(16,!0),i.zMin=o.getFloat64(24,!0),i.zMax=o.getFloat64(32,!0),r+=40,e.headerInfo=i,e.ptr=r,s>=3&&(a=s>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(t,r-a,i.blobSize-14))!==i.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(t,e){var r=e.headerInfo,n=this.getDataTypeArray(r.imageType),i=r.numDims*this.getDataTypeSize(r.imageType),a=this.readSubArray(t,e.ptr,n,i),o=this.readSubArray(t,e.ptr+i,n,i);e.ptr+=2*i;var s,l=!0;for(s=0;s0){r=new Uint8Array(Math.ceil(o/8));var c=(l=new DataView(t,i,u.numBytes)).getInt16(0,!0),h=2,d=0,f=0;do{if(c>0)for(;c--;)r[d++]=l.getUint8(h++);else for(f=l.getUint8(h++),c=-c;c--;)r[d++]=f;c=l.getInt16(h,!0),h+=2}while(h>3],p<<=7&m):p=r[m>>3],128&p&&(n[m]=1);e.pixels.resultMask=n,u.bitset=r,i+=u.numBytes}return e.ptr=i,e.mask=u,!0},readDataOneSweep:function(t,e,r,n){var i,a=e.ptr,o=e.headerInfo,s=o.numDims,l=o.width*o.height,u=o.imageType,c=o.numValidPixel*f.getDataTypeSize(u)*s,h=e.pixels.resultMask;if(r===Uint8Array)i=new Uint8Array(t,a,c);else{var d=new ArrayBuffer(c);new Uint8Array(d).set(new Uint8Array(t,a,c)),i=new r(d)}if(i.length===l*s)e.pixels.resultPixels=n?f.swapDimensionOrder(i,l,s,r,!0):i;else{e.pixels.resultPixels=new r(l*s);var p=0,m=0,g=0,v=0;if(s>1){if(n){for(m=0;m=o)return!1;var s=new Uint32Array(o-a);f.decodeBits(t,e,s);var l,u,c,h,d=[];for(l=a;l0&&(d[u].second=y<<_>>>32-h,32-_>=h?32===(_+=h)&&(_=0,y=x[++w]):(_+=h-32,y=x[++w],d[u].second|=y>>>32-_));var b=0,M=0,S=new p;for(l=0;l=r?r:b;var T,E,A,P,R,C=[];for(l=a;l0)if(T=[h,u],h<=M)for(E=d[u].second<=0;P--)E>>>P&1?(R.right||(R.right=new p),R=R.right):(R.left||(R.left=new p),R=R.left),0!==P||R.val||(R.val=T[1]);return{decodeLut:C,numBitsLUTQick:M,numBitsLUT:b,tree:S,stuffedData:x,srcPtr:w,bitPos:_}},readHuffman:function(t,e,r,n){var i,a,o,s,l,u,c,h,d,p=e.headerInfo.numDims,m=e.headerInfo.height,g=e.headerInfo.width,v=g*m,y=this.readHuffmanTree(t,e),x=y.decodeLut,_=y.tree,w=y.stuffedData,b=y.srcPtr,M=y.bitPos,S=y.numBitsLUTQick,T=y.numBitsLUT,E=0===e.headerInfo.imageType?128:0,A=e.pixels.resultMask,P=0;M>0&&(b++,M=0);var R,C=w[b],I=1===e.encodeMode,L=new r(v*p),O=L;if(p<2||I){for(R=0;R1&&(O=new r(L.buffer,v*R,v),P=0),e.headerInfo.numValidPixel===g*m)for(h=0,u=0;u>>32-S,32-M>>64-M-S),x[l])a=x[l][1],M+=x[l][0];else for(l=s=C<>>32-T,32-M>>64-M-T),i=_,d=0;d>>T-d-1&1?i.right:i.left).left&&!i.right){a=i.val,M=M+d+1;break}M>=32&&(M-=32,C=w[++b]),o=a-E,I?(o+=c>0?P:u>0?O[h-g]:P,o&=255,O[h]=o,P=o):O[h]=o}else for(h=0,u=0;u>>32-S,32-M>>64-M-S),x[l])a=x[l][1],M+=x[l][0];else for(l=s=C<>>32-T,32-M>>64-M-T),i=_,d=0;d>>T-d-1&1?i.right:i.left).left&&!i.right){a=i.val,M=M+d+1;break}M>=32&&(M-=32,C=w[++b]),o=a-E,I?(c>0&&A[h-1]?o+=P:u>0&&A[h-g]?o+=O[h-g]:o+=P,o&=255,O[h]=o,P=o):O[h]=o}}else for(h=0,u=0;u>>32-S,32-M>>64-M-S),x[l])a=x[l][1],M+=x[l][0];else for(l=s=C<>>32-T,32-M>>64-M-T),i=_,d=0;d>>T-d-1&1?i.right:i.left).left&&!i.right){a=i.val,M=M+d+1;break}M>=32&&(M-=32,C=w[++b]),o=a-E,O[h]=o}e.ptr=e.ptr+4*(b+1)+(M>0?4:0),e.pixels.resultPixels=L,p>1&&!n&&(e.pixels.resultPixels=f.swapDimensionOrder(L,v,p,r))},decodeBits:function(t,e,r,n,i){var a=e.headerInfo,o=a.fileVersion,f=0,p=t.byteLength-e.ptr>=5?5:t.byteLength-e.ptr,m=new DataView(t,e.ptr,p),g=m.getUint8(0);f++;var v=g>>6,y=0===v?4:3-v,x=(32&g)>0,_=31&g,w=0;if(1===y)w=m.getUint8(f),f++;else if(2===y)w=m.getUint16(f,!0),f+=2;else{if(4!==y)throw"Invalid valid pixel count type";w=m.getUint32(f,!0),f+=4}var b,M,S,T,E,A,P,R,C,I=2*a.maxZError,L=a.numDims>1?a.maxValues[i]:a.zMax;if(x){for(e.counter.lut++,R=m.getUint8(f),f++,T=Math.ceil((R-1)*_/8),E=Math.ceil(T/4),M=new ArrayBuffer(4*E),S=new Uint8Array(M),e.ptr+=f,S.set(new Uint8Array(t,e.ptr,T)),P=new Uint32Array(M),e.ptr+=T,C=0;R-1>>>C;)C++;T=Math.ceil(w*C/8),E=Math.ceil(T/4),M=new ArrayBuffer(4*E),(S=new Uint8Array(M)).set(new Uint8Array(t,e.ptr,T)),b=new Uint32Array(M),e.ptr+=T,A=o>=3?c(P,_,R-1,n,I,L):l(P,_,R-1,n,I,L),o>=3?u(b,r,C,w,A):s(b,r,C,w,A)}else e.counter.bitstuffer++,C=_,e.ptr+=f,C>0&&(T=Math.ceil(w*C/8),E=Math.ceil(T/4),M=new ArrayBuffer(4*E),(S=new Uint8Array(M)).set(new Uint8Array(t,e.ptr,T)),b=new Uint32Array(M),e.ptr+=T,o>=3?null==n?d(b,r,C,w):u(b,r,C,w,!1,n,I,L):null==n?h(b,r,C,w):s(b,r,C,w,!1,n,I,L))},readTiles:function(t,e,r,n){var i=e.headerInfo,a=i.width,o=i.height,s=a*o,l=i.microBlockSize,u=i.imageType,c=f.getDataTypeSize(u),h=Math.ceil(a/l),d=Math.ceil(o/l);e.pixels.numBlocksY=d,e.pixels.numBlocksX=h,e.pixels.ptr=0;var p,m,g,v,y,x,_,w,b,M,S=0,T=0,E=0,A=0,P=0,R=0,C=0,I=0,L=0,O=0,D=0,k=0,F=0,N=0,U=0,B=new r(l*l),z=o%l||l,G=a%l||l,j=i.numDims,V=e.pixels.resultMask,H=e.pixels.resultPixels,W=i.fileVersion>=5?14:15,q=i.zMax;for(E=0;E1?(M=H,O=E*a*l+A*l,H=new r(e.pixels.resultPixels.buffer,s*w*c,s),q=i.maxValues[w]):M=null,C=t.byteLength-e.ptr,m={},U=0,I=(p=new DataView(t,e.ptr,Math.min(10,C))).getUint8(0),U++,b=i.fileVersion>=5?4&I:0,L=I>>6&255,(I>>2&W)!=(A*l>>3&W))throw"integrity issue";if(b&&0===w)throw"integrity issue";if((y=3&I)>3)throw e.ptr+=U,"Invalid block encoding ("+y+")";if(2!==y)if(0===y){if(b)throw"integrity issue";if(e.counter.uncompressed++,e.ptr+=U,k=(k=P*R*c)<(F=t.byteLength-e.ptr)?k:F,g=new ArrayBuffer(k%c==0?k:k+c-k%c),new Uint8Array(g).set(new Uint8Array(t,e.ptr,k)),v=new r(g),N=0,V)for(S=0;S1&&!n&&(e.pixels.resultPixels=f.swapDimensionOrder(e.pixels.resultPixels,s,j,r))},formatFileInfo:function(t){return{fileIdentifierString:t.headerInfo.fileIdentifierString,fileVersion:t.headerInfo.fileVersion,imageType:t.headerInfo.imageType,height:t.headerInfo.height,width:t.headerInfo.width,numValidPixel:t.headerInfo.numValidPixel,microBlockSize:t.headerInfo.microBlockSize,blobSize:t.headerInfo.blobSize,maxZError:t.headerInfo.maxZError,pixelType:f.getPixelType(t.headerInfo.imageType),eofOffset:t.eofOffset,mask:t.mask?{numBytes:t.mask.numBytes}:null,pixels:{numBlocksX:t.pixels.numBlocksX,numBlocksY:t.pixels.numBlocksY,maxValue:t.headerInfo.zMax,minValue:t.headerInfo.zMin,noDataValue:t.noDataValue}}},constructConstantSurface:function(t,e){var r=t.headerInfo.zMax,n=t.headerInfo.zMin,i=t.headerInfo.maxValues,a=t.headerInfo.numDims,o=t.headerInfo.height*t.headerInfo.width,s=0,l=0,u=0,c=t.pixels.resultMask,h=t.pixels.resultPixels;if(c)if(a>1){if(e)for(s=0;s1&&n!==r)if(e)for(s=0;s=-128&&e<=127;break;case 1:r=e>=0&&e<=255;break;case 2:r=e>=-32768&&e<=32767;break;case 3:r=e>=0&&e<=65536;break;case 4:r=e>=-2147483648&&e<=2147483647;break;case 5:r=e>=0&&e<=4294967296;break;case 6:r=e>=-34027999387901484e22&&e<=34027999387901484e22;break;case 7:r=e>=-17976931348623157e292&&e<=17976931348623157e292;break;default:r=!1}return r},getDataTypeSize:function(t){var e=0;switch(t){case 0:case 1:e=1;break;case 2:case 3:e=2;break;case 4:case 5:case 6:e=4;break;case 7:e=8;break;default:e=t}return e},getDataTypeUsed:function(t,e){var r=t;switch(t){case 2:case 4:r=t-e;break;case 3:case 5:r=t-2*e;break;case 6:r=0===e?t:1===e?2:1;break;case 7:r=0===e?t:t-2*e+1;break;default:r=t}return r},getOnePixel:function(t,e,r,n){var i=0;switch(r){case 0:i=n.getInt8(e);break;case 1:i=n.getUint8(e);break;case 2:i=n.getInt16(e,!0);break;case 3:i=n.getUint16(e,!0);break;case 4:i=n.getInt32(e,!0);break;case 5:i=n.getUInt32(e,!0);break;case 6:i=n.getFloat32(e,!0);break;case 7:i=n.getFloat64(e,!0);break;default:throw"the decoder does not understand this pixel type"}return i},swapDimensionOrder:function(t,e,r,n,i){var a=0,o=0,s=0,l=0,u=t;if(r>1)if(u=new n(e*r),i)for(a=0;a5)throw"unsupported lerc version 2."+o;f.readMask(t,i),a.numValidPixel===a.width*a.height||i.pixels.resultMask||(i.pixels.resultMask=e.maskData);var l=a.width*a.height;i.pixels.resultPixels=new s(l*a.numDims),i.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var u,c=!e.returnPixelInterleavedDims;if(0!==a.numValidPixel)if(a.zMax===a.zMin)f.constructConstantSurface(i,c);else if(o>=4&&f.checkMinMaxRanges(t,i))f.constructConstantSurface(i,c);else{var h=new DataView(t,i.ptr,2),d=h.getUint8(0);if(i.ptr++,d)f.readDataOneSweep(t,i,s,c);else if(o>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var p=h.getUint8(1);if(i.ptr++,i.encodeMode=p,p>2||o<4&&p>1)throw"Invalid Huffman flag "+p;p?f.readHuffman(t,i,s,c):f.readTiles(t,i,s,c)}else f.readTiles(t,i,s,c)}i.eofOffset=i.ptr,e.inputOffset?(u=i.headerInfo.blobSize+e.inputOffset-i.ptr,Math.abs(u)>=1&&(i.eofOffset=e.inputOffset+i.headerInfo.blobSize)):(u=i.headerInfo.blobSize-i.ptr,Math.abs(u)>=1&&(i.eofOffset=i.headerInfo.blobSize));var m={width:a.width,height:a.height,pixelData:i.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:i.pixels.resultMask};if(i.pixels.resultMask&&f.isValidPixelValue(a.imageType,r)){var g=i.pixels.resultMask;for(n=0;n1&&(u&&m.push(u),w.fileInfo.mask&&w.fileInfo.mask.numBytes>0&&_++),f++,g.pixels.push(w.pixelData),g.statistics.push({minValue:w.minValue,maxValue:w.maxValue,noDataValue:w.noDataValue,dimStats:w.dimStats})}if(n>1&&_>1){for(d=g.width*g.height,g.bandMasks=m,(u=new Uint8Array(d)).set(m[0]),c=1;cn.set(t,e)))}return wI.addDecoder=i,wI.getDecoder=async function(t){const e=n.get(t.Compression);if(!e)throw new Error(`Unknown compression method identifier: ${t.Compression}`);return new(await e())(t)},i([void 0,1],(()=>Promise.resolve().then((()=>r(function(){if(_I)return bI;_I=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bI,"__esModule",{value:!0});const e=t(TI());class r extends e.default{decodeBlock(t){return t}}return bI.default=r,bI}()))).then((t=>t.default)))),i(5,(()=>Promise.resolve().then((()=>r(PI()))).then((t=>t.default)))),i(6,(()=>{throw new Error("old style JPEG compression is not supported.")})),i(7,(()=>Promise.resolve().then((()=>r(function(){if(RI)return CI;RI=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(CI,"__esModule",{value:!0});const e=t(TI()),r=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),n=4017,i=799,a=3406,o=2276,s=1567,l=3784,u=5793,c=2896;function h(t,e){let r=0;const n=[];let i=16;for(;i>0&&!t[i-1];)--i;n.push({children:[],index:0});let a,o=n[0];for(let s=0;s0;)o=n.pop();for(o.index++,n.push(o);n.length<=s;)n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a;r++}s+10)return m--,p>>m&1;if(p=t[f++],255===p){const e=t[f++];if(e)throw new Error(`unexpected marker: ${(p<<8|e).toString(16)}`)}return m=7,p>>>7}function v(t){let e,r=t;for(;null!==(e=g());){if(r=r[e],"number"==typeof r)return r;if("object"!=typeof r)throw new Error("invalid huffman sequence")}return null}function y(t){let e=t,r=0;for(;e>0;){const t=g();if(null===t)return;r=r<<1|t,--e}return r}function x(t){const e=y(t);return e>=1<0)return void w--;let n=o;const i=s;for(;n<=i;){const i=v(t.huffmanTableAC),a=15&i,o=i>>4;if(0===a){if(o<15){w=y(o)+(1<>4,0===r)a<15?(w=y(a)+(1<>4;if(0===i){if(o<15)break;a+=16}else a+=o,e[r[a]]=x(i),a++}};let L,O,D=0;O=1===T?i[0].blocksPerLine*i[0].blocksPerColumn:c*n.mcusPerColumn;const k=a||O;for(;D=65488&&L<=65495))break;f+=2}return f-d}function f(t,e){const r=[],{blocksPerLine:h,blocksPerColumn:d}=e,f=h<<3,p=new Int32Array(64),m=new Uint8Array(64);function g(t,r,h){const d=e.quantizationTable;let f,p,m,g,v,y,x,_,w;const b=h;let M;for(M=0;M<64;M++)b[M]=t[M]*d[M];for(M=0;M<8;++M){const t=8*M;0!==b[1+t]||0!==b[2+t]||0!==b[3+t]||0!==b[4+t]||0!==b[5+t]||0!==b[6+t]||0!==b[7+t]?(f=u*b[0+t]+128>>8,p=u*b[4+t]+128>>8,m=b[2+t],g=b[6+t],v=c*(b[1+t]-b[7+t])+128>>8,_=c*(b[1+t]+b[7+t])+128>>8,y=b[3+t]<<4,x=b[5+t]<<4,w=f-p+1>>1,f=f+p+1>>1,p=w,w=m*l+g*s+128>>8,m=m*s-g*l+128>>8,g=w,w=v-x+1>>1,v=v+x+1>>1,x=w,w=_+y+1>>1,y=_-y+1>>1,_=w,w=f-g+1>>1,f=f+g+1>>1,g=w,w=p-m+1>>1,p=p+m+1>>1,m=w,w=v*o+_*a+2048>>12,v=v*a-_*o+2048>>12,_=w,w=y*i+x*n+2048>>12,y=y*n-x*i+2048>>12,x=w,b[0+t]=f+_,b[7+t]=f-_,b[1+t]=p+x,b[6+t]=p-x,b[2+t]=m+y,b[5+t]=m-y,b[3+t]=g+v,b[4+t]=g-v):(w=u*b[0+t]+512>>10,b[0+t]=w,b[1+t]=w,b[2+t]=w,b[3+t]=w,b[4+t]=w,b[5+t]=w,b[6+t]=w,b[7+t]=w)}for(M=0;M<8;++M){const t=M;0!==b[8+t]||0!==b[16+t]||0!==b[24+t]||0!==b[32+t]||0!==b[40+t]||0!==b[48+t]||0!==b[56+t]?(f=u*b[0+t]+2048>>12,p=u*b[32+t]+2048>>12,m=b[16+t],g=b[48+t],v=c*(b[8+t]-b[56+t])+2048>>12,_=c*(b[8+t]+b[56+t])+2048>>12,y=b[24+t],x=b[40+t],w=f-p+1>>1,f=f+p+1>>1,p=w,w=m*l+g*s+2048>>12,m=m*s-g*l+2048>>12,g=w,w=v-x+1>>1,v=v+x+1>>1,x=w,w=_+y+1>>1,y=_-y+1>>1,_=w,w=f-g+1>>1,f=f+g+1>>1,g=w,w=p-m+1>>1,p=p+m+1>>1,m=w,w=v*o+_*a+2048>>12,v=v*a-_*o+2048>>12,_=w,w=y*i+x*n+2048>>12,y=y*n-x*i+2048>>12,x=w,b[0+t]=f+_,b[56+t]=f-_,b[8+t]=p+x,b[48+t]=p-x,b[16+t]=m+y,b[40+t]=m-y,b[24+t]=g+v,b[32+t]=g-v):(w=u*h[M+0]+8192>>14,b[0+t]=w,b[8+t]=w,b[16+t]=w,b[24+t]=w,b[32+t]=w,b[40+t]=w,b[48+t]=w,b[56+t]=w)}for(M=0;M<64;++M){const t=128+(b[M]+8>>4);r[M]=t<0?0:t>255?255:t}}for(let t=0;t>4==0)for(let n=0;n<64;n++)a[r[n]]=t[e++];else{if(i>>4!=1)throw new Error("DQT: invalid table spec");for(let t=0;t<64;t++)a[r[t]]=n()}this.quantizationTables[15&i]=a}break}case 65472:case 65473:case 65474:{n();const r={extended:65473===o,progressive:65474===o,precision:t[e++],scanLines:n(),samplesPerLine:n(),components:{},componentsOrder:[]},i=t[e++];let s;for(let n=0;n>4,i=15&t[e+1],a=t[e+2];r.componentsOrder.push(s),r.components[s]={h:n,v:i,quantizationIdx:a},e+=3}a(r),this.frames.push(r);break}case 65476:{const r=n();for(let n=2;n>4==0?this.huffmanTablesDC[15&r]=h(i,o):this.huffmanTablesAC[15&r]=h(i,o)}break}case 65501:n(),this.resetInterval=n();break;case 65498:{n();const r=t[e++],i=[],a=this.frames[0];for(let n=0;n>4],r.huffmanTableAC=this.huffmanTablesAC[15&n],i.push(r)}const o=t[e++],s=t[e++],l=t[e++],u=d(t,e,a,i,this.resetInterval,o,s,l>>4,15&l);e+=u;break}case 65535:255!==t[e]&&e--;break;default:if(255===t[e-3]&&t[e-2]>=192&&t[e-2]<=254){e-=3;break}throw new Error(`unknown JPEG marker ${o.toString(16)}`)}o=n()}}getResult(){const{frames:t}=this;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(let t=0;tt.default)))),i([8,32946],(()=>Promise.resolve().then((()=>r(function(){if(vL)return GI;vL=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(GI,"__esModule",{value:!0});const e=bL(),r=t(TI());class n extends r.default{decodeBlock(t){return(0,e.inflate)(new Uint8Array(t)).buffer}}return GI.default=n,GI}()))).then((t=>t.default)))),i(32773,(()=>Promise.resolve().then((()=>r(function(){if(ML)return SL;ML=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(SL,"__esModule",{value:!0});const e=t(TI());class r extends e.default{decodeBlock(t){const e=new DataView(t),r=[];for(let n=0;nt.default)))),i(34887,(()=>Promise.resolve().then((()=>r(RL()))).then((t=>t.default)))),i(50001,(()=>Promise.resolve().then((()=>r(function(){if(CL)return LL;CL=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(LL,"__esModule",{value:!0});const e=t(TI());class r extends e.default{constructor(){if(super(),"undefined"==typeof createImageBitmap)throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");if("undefined"==typeof document&&"undefined"==typeof OffscreenCanvas)throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available")}async decode(t,e){const r=new Blob([e]),n=await createImageBitmap(r);let i;"undefined"!=typeof document?(i=document.createElement("canvas"),i.width=n.width,i.height=n.height):i=new OffscreenCanvas(n.width,n.height);const a=i.getContext("2d");return a.drawImage(n,0,0),a.getImageData(0,0,n.width,n.height).data.buffer}}return LL.default=r,LL}()))).then((t=>t.default)))),wI}var DL,kL,FL={};function NL(){if(kL)return SC;kL=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(SC,"__esModule",{value:!0});const e=QC(),r=t(function(){if($C)return tI.exports;function t(t,e,r){const n=r&&r.debug||!1;n&&console.log("[xml-utils] getting "+e+" in "+t);const i="object"==typeof t?t.outer:t,a=i.slice(0,i.indexOf(">")+1),o=['"',"'"];for(let t=0;t{const l=t(e,i,a);for(let t=0;t{const u=t(e,a,o);for(let t=0;t=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${t} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[t]/8)}getReaderForSample(t){const r=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[t]:1,n=this.fileDirectory.BitsPerSample[t];switch(r){case 1:if(n<=8)return DataView.prototype.getUint8;if(n<=16)return DataView.prototype.getUint16;if(n<=32)return DataView.prototype.getUint32;break;case 2:if(n<=8)return DataView.prototype.getInt8;if(n<=16)return DataView.prototype.getInt16;if(n<=32)return DataView.prototype.getInt32;break;case 3:switch(n){case 16:return function(t,r){return(0,e.getFloat16)(this,t,r)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(t=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[t]:1}getBitsPerSample(t=0){return this.fileDirectory.BitsPerSample[t]}getArrayForSample(t,e){return u(this.getSampleFormat(t),this.getBitsPerSample(t),e)}async getTileOrStrip(t,e,r,n,i){const a=Math.ceil(this.getWidth()/this.getTileWidth()),o=Math.ceil(this.getHeight()/this.getTileHeight());let s;const{tiles:l}=this;let c,h;1===this.planarConfiguration?s=e*a+t:2===this.planarConfiguration&&(s=r*a*o+e*a+t),this.isTiled?(c=this.fileDirectory.TileOffsets[s],h=this.fileDirectory.TileByteCounts[s]):(c=this.fileDirectory.StripOffsets[s],h=this.fileDirectory.StripByteCounts[s]);const d=(await this.source.fetch([{offset:c,length:h}],i))[0];let f;return null!==l&&l[s]?f=l[s]:(f=(async()=>{let t=await n.decode(this.fileDirectory,d);const r=this.getSampleFormat(),i=this.getBitsPerSample();return function(t,e){return(1!==t&&2!==t||!(e<=32)||e%8!=0)&&(3!==t||16!==e&&32!==e&&64!==e)}(r,i)&&(t=function(t,e,r,n,i,a,o){const s=new DataView(t),l=2===r?1:n,c=u(e,i,2===r?o*a:o*a*n),h=parseInt("1".repeat(i),2);if(1===e){let t;t=1===r?n*i:i;let e=a*t;0!=(7&e)&&(e=e+7&-8);for(let t=0;t>8-i-f&h;else if(f+i<=16)c[u]=s.getUint16(d)>>16-i-f&h;else if(f+i<=24){const t=s.getUint16(d)<<8|s.getUint8(d+2);c[u]=t>>24-i-f&h}else c[u]=s.getUint32(d)>>32-i-f&h}}}}return c.buffer}(t,r,this.planarConfiguration,this.getSamplesPerPixel(),i,this.getTileWidth(),this.getBlockHeight(e))),t})(),null!==l&&(l[s]=f)),{x:t,y:e,sample:r,data:await f}}async _readRaster(t,e,r,n,i,a,o,u,c){const h=this.getTileWidth(),d=this.getTileHeight(),f=this.getWidth(),p=this.getHeight(),m=Math.max(Math.floor(t[0]/h),0),g=Math.min(Math.ceil(t[2]/h),Math.ceil(f/h)),v=Math.max(Math.floor(t[1]/d),0),y=Math.min(Math.ceil(t[3]/d),Math.ceil(p/d)),x=t[2]-t[0];let _=this.getBytesPerPixel();const w=[],b=[];for(let t=0;t{const a=i.data,o=new DataView(a),s=this.getBlockHeight(i.y),u=i.y*d,c=i.x*h,m=u+s,g=(i.x+1)*h,v=b[l],y=Math.min(s,s-(m-t[3]),p-u),M=Math.min(h,h-(g-t[2]),f-c);for(let i=Math.max(0,t[1]-u);ih[2]||h[1]>h[3])throw new Error("Invalid subsets");const d=(h[2]-h[0])*(h[3]-h[1]),f=this.getSamplesPerPixel();if(e&&e.length){for(let t=0;t=f)return Promise.reject(new RangeError(`Invalid sample index '${e[t]}'.`))}else for(let t=0;tc[2]||c[1]>c[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===i.photometricInterpretations.RGB){let a=[0,1,2];if(this.fileDirectory.ExtraSamples!==i.ExtraSamplesValues.Unspecified&&l){a=[];for(let t=0;tvoid 0===(0,r.default)(t,"sample"))):a.filter((e=>Number((0,r.default)(e,"sample"))===t));for(let t=0;t=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var f=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(f&&l){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:D(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":r(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(n);var i=n.exports,a=new Map;function o(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){return a.set(e,t)}))}function s(e){return f.apply(this,arguments)}function f(){return(f=t(i.mark((function e(t){var r,n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.get(t.Compression)){e.next=3;break}throw new Error("Unknown compression method identifier: ".concat(t.Compression));case 3:return e.next=5,r();case 5:return n=e.sent,e.abrupt("return",new n(t));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}o([void 0,1],(function(){return Promise.resolve().then((function(){return _})).then((function(e){return e.default}))})),o(5,(function(){return Promise.resolve().then((function(){return S})).then((function(e){return e.default}))})),o(6,(function(){throw new Error("old style JPEG compression is not supported.")})),o(7,(function(){return Promise.resolve().then((function(){return L})).then((function(e){return e.default}))})),o([8,32946],(function(){return Promise.resolve().then((function(){return Ne})).then((function(e){return e.default}))})),o(32773,(function(){return Promise.resolve().then((function(){return Ye})).then((function(e){return e.default}))})),o(34887,(function(){return Promise.resolve().then((function(){return ut})).then((function(e){return e.default}))})),o(50001,(function(){return Promise.resolve().then((function(){return dt})).then((function(e){return e.default}))}));var l=globalThis;function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r0;i--)e[n+t]+=e[n],n++;r-=t}while(r>0)}function w(e,t,r){for(var n=0,i=e.length,a=i/r;i>t;){for(var o=t;o>0;--o)e[n+t]+=e[n],++n;i-=t}for(var s=e.slice(),f=0;f=e.byteLength);++l){var u=void 0;if(2===t){switch(i[0]){case 8:u=new Uint8Array(e,l*f*r*s,f*r*s);break;case 16:u=new Uint16Array(e,l*f*r*s,f*r*s/2);break;case 32:u=new Uint32Array(e,l*f*r*s,f*r*s/4);break;default:throw new Error("Predictor 2 not allowed with ".concat(i[0]," bits per sample."))}y(u,f)}else 3===t&&w(u=new Uint8Array(e,l*f*r*s,f*r*s),f,s)}return e}l.addEventListener("message",function(){var e=t(i.mark((function e(t){var r,n,a,o,f,u;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.data,n=r.id,a=r.fileDirectory,o=r.buffer,e.next=3,s(a);case 3:return f=e.sent,e.next=6,f.decode(a,o);case 6:u=e.sent,l.postMessage({decoded:u,id:n},[u]);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());var b=function(){function e(){u(this,e)}var r;return h(e,[{key:"decode",value:(r=t(i.mark((function e(t,r){var n,a,o,s,f;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.decodeBlock(r);case 2:if(n=e.sent,1===(a=t.Predictor||1)){e.next=9;break}return o=!t.StripOffsets,s=o?t.TileWidth:t.ImageWidth,f=o?t.TileLength:t.RowsPerStrip||t.ImageLength,e.abrupt("return",g(n,a,s,f,t.BitsPerSample,t.PlanarConfiguration));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})}]),e}();function k(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var x=function(e){p(r,b);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return e}}]),r}(),_=Object.freeze({__proto__:null,default:x});function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}function P(e,t){for(var r=t.length-1;r>=0;r--)e.push(t[r]);return e}function I(e){for(var t=new Uint16Array(4093),r=new Uint8Array(4093),n=0;n<=257;n++)t[n]=4096,r[n]=n;var i=258,a=9,o=0;function s(){i=258,a=9}function f(e){var t=function(e,t,r){var n=t%8,i=Math.floor(t/8),a=8-n,o=t+r-8*(i+1),s=8*(i+2)-(t+r),f=8*(i+2)-t;if(s=Math.max(0,s),i>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),257;var l=e[i]&Math.pow(2,8-n)-1,u=l<<=r-a;if(i+1>>s;u+=c<<=Math.max(0,r-f)}if(o>8&&i+2>>h}return u}(e,o,a);return o+=a,t}function l(e,n){return r[i]=n,t[i]=e,++i-1}function u(e){for(var n=[],i=e;4096!==i;i=t[i])n.push(r[i]);return n}var c=[];s();for(var h,d=new Uint8Array(e),p=f(d);257!==p;){if(256===p){for(s(),p=f(d);256===p;)p=f(d);if(257===p)break;if(p>256)throw new Error("corrupted code at scanline ".concat(p));P(c,u(p)),h=p}else if(p=Math.pow(2,a)&&(12===a?h=void 0:a++),p=f(d)}return new Uint8Array(c)}var U=function(e){p(r,b);var t=A(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return I(e).buffer}}]),r}(),S=Object.freeze({__proto__:null,default:U});function T(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var D=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function E(e,t){for(var r=0,n=[],i=16;i>0&&!e[i-1];)--i;n.push({children:[],index:0});for(var a,o=n[0],s=0;s0;)o=n.pop();for(o.index++,n.push(o);n.length<=s;)n.push(a={children:[],index:0}),o.children[o.index]=a.children,o=a;r++}s+10)return m--,p>>m&1;if(255===(p=e[d++])){var t=e[d++];if(t)throw new Error("unexpected marker: ".concat((p<<8|t).toString(16)))}return m=7,p>>>7}function y(e){for(var t,n=e;null!==(t=v());){if("number"==typeof(n=n[t]))return n;if("object"!==r(n))throw new Error("invalid huffman sequence")}return null}function w(e){for(var t=e,r=0;t>0;){var n=v();if(null===n)return;r=r<<1|n,--t}return r}function g(e){var t=w(e);return t>=1<0)b--;else for(var r=o,n=s;r<=n;){var i=y(e.huffmanTableAC),a=15&i,f=i>>4;if(0===a){if(f<15){b=w(f)+(1<>4,0===c)i<15?(b=w(i)+(1<>4;if(0===o){if(s<15)break;i+=16}else t[D[i+=s]]=g(o),i++}};var O,M,C=0;M=1===B?i[0].blocksPerLine*i[0].blocksPerColumn:u*n.mcusPerColumn;for(var L=a||M;C=65488&&O<=65495))break;d+=2}return d-h}function O(e,t){var r=[],n=t.blocksPerLine,i=t.blocksPerColumn,a=n<<3,o=new Int32Array(64),s=new Uint8Array(64);function f(e,r,n){var i,a,o,s,f,l,u,c,h,d,p=t.quantizationTable,m=n;for(d=0;d<64;d++)m[d]=e[d]*p[d];for(d=0;d<8;++d){var v=8*d;0!==m[1+v]||0!==m[2+v]||0!==m[3+v]||0!==m[4+v]||0!==m[5+v]||0!==m[6+v]||0!==m[7+v]?(i=5793*m[0+v]+128>>8,a=5793*m[4+v]+128>>8,o=m[2+v],s=m[6+v],f=2896*(m[1+v]-m[7+v])+128>>8,c=2896*(m[1+v]+m[7+v])+128>>8,l=m[3+v]<<4,h=i-a+1>>1,i=i+a+1>>1,a=h,h=3784*o+1567*s+128>>8,o=1567*o-3784*s+128>>8,s=h,h=f-(u=m[5+v]<<4)+1>>1,f=f+u+1>>1,u=h,h=c+l+1>>1,l=c-l+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=2276*f+3406*c+2048>>12,f=3406*f-2276*c+2048>>12,c=h,h=799*l+4017*u+2048>>12,l=4017*l-799*u+2048>>12,u=h,m[0+v]=i+c,m[7+v]=i-c,m[1+v]=a+u,m[6+v]=a-u,m[2+v]=o+l,m[5+v]=o-l,m[3+v]=s+f,m[4+v]=s-f):(h=5793*m[0+v]+512>>10,m[0+v]=h,m[1+v]=h,m[2+v]=h,m[3+v]=h,m[4+v]=h,m[5+v]=h,m[6+v]=h,m[7+v]=h)}for(d=0;d<8;++d){var y=d;0!==m[8+y]||0!==m[16+y]||0!==m[24+y]||0!==m[32+y]||0!==m[40+y]||0!==m[48+y]||0!==m[56+y]?(i=5793*m[0+y]+2048>>12,a=5793*m[32+y]+2048>>12,o=m[16+y],s=m[48+y],f=2896*(m[8+y]-m[56+y])+2048>>12,c=2896*(m[8+y]+m[56+y])+2048>>12,l=m[24+y],h=i-a+1>>1,i=i+a+1>>1,a=h,h=3784*o+1567*s+2048>>12,o=1567*o-3784*s+2048>>12,s=h,h=f-(u=m[40+y])+1>>1,f=f+u+1>>1,u=h,h=c+l+1>>1,l=c-l+1>>1,c=h,h=i-s+1>>1,i=i+s+1>>1,s=h,h=a-o+1>>1,a=a+o+1>>1,o=h,h=2276*f+3406*c+2048>>12,f=3406*f-2276*c+2048>>12,c=h,h=799*l+4017*u+2048>>12,l=4017*l-799*u+2048>>12,u=h,m[0+y]=i+c,m[56+y]=i-c,m[8+y]=a+u,m[48+y]=a-u,m[16+y]=o+l,m[40+y]=o-l,m[24+y]=s+f,m[32+y]=s-f):(h=5793*n[d+0]+8192>>14,m[0+y]=h,m[8+y]=h,m[16+y]=h,m[24+y]=h,m[32+y]=h,m[40+y]=h,m[48+y]=h,m[56+y]=h)}for(d=0;d<64;++d){var w=128+(m[d]+8>>4);r[d]=w<0?0:w>255?255:w}}for(var l=0;l>4==0)for(var c=0;c<64;c++){u[D[c]]=e[t++]}else{if(l>>4!=1)throw new Error("DQT: invalid table spec");for(var h=0;h<64;h++){u[D[h]]=r()}}this.quantizationTables[15&l]=u}break;case 65472:case 65473:case 65474:r();for(var d={extended:65473===o,progressive:65474===o,precision:e[t++],scanLines:r(),samplesPerLine:r(),components:{},componentsOrder:[]},p=e[t++],m=void 0,v=0;v>4,w=15&e[t+1],g=e[t+2];d.componentsOrder.push(m),d.components[m]={h:y,v:w,quantizationIdx:g},t+=3}n(d),this.frames.push(d);break;case 65476:for(var b=r(),k=2;k>4==0?this.huffmanTablesDC[15&x]=E(_,I):this.huffmanTablesAC[15&x]=E(_,I)}break;case 65501:r(),this.resetInterval=r();break;case 65498:r();for(var S=e[t++],T=[],O=this.frames[0],M=0;M>4],C.huffmanTableAC=this.huffmanTablesAC[15&L],T.push(C)}var R=e[t++],V=e[t++],G=e[t++],F=B(e,t,O,T,this.resetInterval,R,V,G>>4,15&G);t+=F;break;case 65535:255!==e[t]&&t--;break;default:if(255===e[t-3]&&e[t-2]>=192&&e[t-2]<=254){t-=3;break}throw new Error("unknown JPEG marker ".concat(o.toString(16)))}o=r()}}},{key:"getResult",value:function(){var e=this.frames;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(var t=0;t=0;)e[t]=0}R(new Array(576)),R(new Array(60)),R(new Array(512)),R(new Array(256)),R(new Array(29)),R(new Array(30));var V=function(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0},G=new Uint32Array(function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}()),F=function(e,t,r,n){var i=G,a=n+r;e^=-1;for(var o=n;o>>8^i[255&(e^t[o])];return-1^e},z={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},j={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},N=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},Z=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==r(n))throw new TypeError(n+"must be non-object");for(var i in n)N(n,i)&&(e[i]=n[i])}}return e},K=function(e){for(var t=0,r=0,n=e.length;r=252?6:X>=248?5:X>=240?4:X>=224?3:X>=192?2:1;Y[254]=Y[254]=1;var W=function(e){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,r,n,i,a,o=e.length,s=0;for(i=0;i>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},q=function(e,t){var r,n,i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var a=new Array(2*i);for(n=0,r=0;r4)a[n++]=65533,r+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&r1?a[n++]=65533:o<65536?a[n++]=o:(o-=65536,a[n++]=55296|o>>10&1023,a[n++]=56320|1023&o)}}}return function(e,t){if(t<65534&&e.subarray&&H)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var r="",n=0;ne.length&&(t=e.length);for(var r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Y[e[r]]>t?r:t};var Q=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},$=function(e,t){var r,n,i,a,o,s,f,l,u,c,h,d,p,m,v,y,w,g,b,k,x,_,A,P,I=e.state;r=e.next_in,A=e.input,n=r+(e.avail_in-5),i=e.next_out,P=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=I.dmax,f=I.wsize,l=I.whave,u=I.wnext,c=I.window,h=I.hold,d=I.bits,p=I.lencode,m=I.distcode,v=(1<>>=g=w>>>24,d-=g,0===(g=w>>>16&255))P[i++]=65535&w;else{if(!(16&g)){if(0==(64&g)){w=p[(65535&w)+(h&(1<>>=g,d-=g),d<15&&(h+=A[r++]<>>=g=w>>>24,d-=g,!(16&(g=w>>>16&255))){if(0==(64&g)){w=m[(65535&w)+(h&(1<s){e.msg="invalid distance too far back",I.mode=30;break e}if(h>>>=g,d-=g,k>(g=i-a)){if((g=k-g)>l&&I.sane){e.msg="invalid distance too far back",I.mode=30;break e}if(x=0,_=c,0===u){if(x+=f-g,g2;)P[i++]=_[x++],P[i++]=_[x++],P[i++]=_[x++],b-=3;b&&(P[i++]=_[x++],b>1&&(P[i++]=_[x++]))}else{x=i-k;do{P[i++]=P[x++],P[i++]=P[x++],P[i++]=P[x++],b-=3}while(b>2);b&&(P[i++]=P[x++],b>1&&(P[i++]=P[x++]))}break}}break}}while(r>3,h&=(1<<(d-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r=1&&0===D[k];k--);if(x>k&&(x=k),0===k)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(b=1;b0&&(0===e||1!==k))return-1;for(E[1]=0,w=1;w<15;w++)E[w+1]=E[w]+D[w];for(g=0;g852||2===e&&I>592)return 1;for(;;){p=w-A,o[g]d?(m=B[O+o[g]],v=S[T+o[g]]):(m=96,v=0),f=1<>A)+(l-=f)]=p<<24|m<<16|v|0}while(0!==l);for(f=1<>=1;if(0!==f?(U&=f-1,U+=f):U=0,g++,0==--D[w]){if(w===k)break;w=t[r+o[g]]}if(w>x&&(U&c)!==u){for(0===A&&(A=x),h+=b,P=1<<(_=w-A);_+A852||2===e&&I>592)return 1;i[u=U&c]=x<<24|_<<16|h-a|0}}return 0!==U&&(i[h+U]=w-A<<24|64<<16|0),s.bits=x,0},ae=j.Z_FINISH,oe=j.Z_BLOCK,se=j.Z_TREES,fe=j.Z_OK,le=j.Z_STREAM_END,ue=j.Z_NEED_DICT,ce=j.Z_STREAM_ERROR,he=j.Z_DATA_ERROR,de=j.Z_MEM_ERROR,pe=j.Z_BUF_ERROR,me=j.Z_DEFLATED,ve=function(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)};function ye(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var we,ge,be=function(e){if(!e||!e.state)return ce;var t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,fe},ke=function(e){if(!e||!e.state)return ce;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,be(e)},xe=function(e,t){var r;if(!e||!e.state)return ce;var n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ce:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ke(e))},_e=function(e,t){if(!e)return ce;var r=new ye;e.state=r,r.window=null;var n=xe(e,t);return n!==fe&&(e.state=null),n},Ae=!0,Pe=function(e){if(Ae){we=new Int32Array(512),ge=new Int32Array(32);for(var t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ie(1,e.lens,0,288,we,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ie(2,e.lens,0,32,ge,0,e.work,{bits:5}),Ae=!1}e.lencode=we,e.lenbits=9,e.distcode=ge,e.distbits=5},Ie=function(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=F(r.check,U,2,0),l=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&l)!==me){e.msg="unknown compression method",r.mode=30;break}if(u-=4,x=8+(15&(l>>>=4)),0===r.wbits)r.wbits=x;else if(x>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,l+=n[a++]<>>8&255,U[2]=l>>>16&255,U[3]=l>>>24&255,r.check=F(r.check,U,4,0)),l=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,l+=n[a++]<>8),512&r.flags&&(U[0]=255&l,U[1]=l>>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===s)break e;s--,l+=n[a++]<>>8&255,r.check=F(r.check,U,2,0)),l=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+d),x)),512&r.flags&&(r.check=F(r.check,n,d,a)),s-=d,a+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;d=0;do{x=n[a+d++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x))}while(x&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===s)break e;s--,l+=n[a++]<>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===s)break e;s--,l+=n[a++]<>>=1)){case 0:r.mode=14;break;case 1:if(Pe(r),r.mode=20,t===se){l>>>=2,u-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}l>>>=2,u-=2;break;case 14:for(l>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,l+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&l,l=0,u=0,r.mode=15,t===se)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>s&&(d=s),d>f&&(d=f),0===d)break e;i.set(n.subarray(a,a+d),o),s-=d,a+=d,f-=d,o+=d,r.length-=d;break}r.mode=12;break;case 17:for(;u<14;){if(0===s)break e;s--,l+=n[a++]<>>=5,u-=5,r.ndist=1+(31&l),l>>>=5,u-=5,r.ncode=4+(15&l),l>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[S[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},_=ie(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,_){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>>=v,u-=v,r.lens[r.have++]=w;else{if(16===w){for(P=v+2;u>>=v,u-=v,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}x=r.lens[r.have-1],d=3+(3&l),l>>>=2,u-=2}else if(17===w){for(P=v+3;u>>=v)),l>>>=3,u-=3}else{for(P=v+7;u>>=v)),l>>>=7,u-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=x}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,A={bits:r.lenbits},_=ie(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,_){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},_=ie(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,_){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===se)break e;case 20:r.mode=21;case 21:if(s>=6&&f>=258){e.next_out=o,e.avail_out=f,e.next_in=a,e.avail_in=s,r.hold=l,r.bits=u,$(e,h),o=e.next_out,i=e.output,f=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,l=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;y=(I=r.lencode[l&(1<>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>g)])>>>16&255,w=65535&I,!(g+(v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>>=g,u-=g,r.back+=g}if(l>>>=v,u-=v,r.back+=v,r.length=w,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(P=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;y=(I=r.distcode[l&(1<>>16&255,w=65535&I,!((v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>g)])>>>16&255,w=65535&I,!(g+(v=I>>>24)<=u);){if(0===s)break e;s--,l+=n[a++]<>>=g,u-=g,r.back+=g}if(l>>>=v,u-=v,r.back+=v,64&y){e.msg="invalid distance code",r.mode=30;break}r.offset=w,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(P=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===f)break e;if(d=h-f,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=o-r.offset,d=r.length;d>f&&(d=f),f-=d,r.length-=d;do{i[o++]=m[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===f)break e;i[o++]=r.length,f--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===s)break e;s--,l|=n[a++]<=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Q,this.strm.avail_out=0;var r=Ue.inflateInit2(this.strm,t.windowBits);if(r!==Be)throw new Error(z[r]);if(this.header=new Se,Ue.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=W(t.dictionary):"[object ArrayBuffer]"===Te.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Ue.inflateSetDictionary(this.strm,t.dictionary))!==Be))throw new Error(z[r])}function Ge(e,t){var r=new Ve(t);if(r.push(e),r.err)throw r.msg||z[r.err];return r.result}Ve.prototype.push=function(e,t){var r,n,i,a=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?Ee:De,"[object ArrayBuffer]"===Te.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(o),a.next_out=0,a.avail_out=o),(r=Ue.inflate(a,n))===Me&&s&&((r=Ue.inflateSetDictionary(a,s))===Be?r=Ue.inflate(a,n):r===Le&&(r=Me));a.avail_in>0&&r===Oe&&a.state.wrap>0&&0!==e[a.next_in];)Ue.inflateReset(a),r=Ue.inflate(a,n);switch(r){case Ce:case Le:case Me:case Re:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===Oe))if("string"===this.options.to){var f=J(a.output,a.next_out),l=a.next_out-f,u=q(a.output,f);a.next_out=l,a.avail_out=o-l,l&&a.output.set(a.output.subarray(f,f+l),0),this.onData(u)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==Be||0!==i){if(r===Oe)return r=Ue.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Ve.prototype.onData=function(e){this.chunks.push(e)},Ve.prototype.onEnd=function(e){e===Be&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=K(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Fe={Inflate:Ve,inflate:Ge,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Ge(e,t)},ungzip:Ge,constants:j}.inflate;function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var je=function(e){p(r,b);var t=ze(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){return Fe(new Uint8Array(e)).buffer}}]),r}(),Ne=Object.freeze({__proto__:null,default:je});function Ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var Ke,He=function(e){p(r,b);var t=Ze(r);function r(){return u(this,r),t.apply(this,arguments)}return h(r,[{key:"decodeBlock",value:function(e){for(var t=new DataView(e),r=[],n=0;n>3],I<<=7&U),v=0;v>3]),128&I?(f&&(f[U]=1),m=m>(o=T.encoding<2?_[A++]:P)?o:m,s[U++]=o):(f&&(f[U]=0),s[U++]=n),I<<=1;U+=S}else if(T.encoding<2)for(y=0;y(o=_[A++])?o:m,s[U++]=o;U+=S}else for(m=m>P?P:m,y=0;y0){var o=new Uint8Array(Math.ceil(n.width*n.height/8)),s=(a=new DataView(e,t,n.mask.numBytes)).getInt16(0,!0),f=2,l=0;do{if(s>0)for(;s--;)o[l++]=a.getUint8(f++);else{var u=a.getUint8(f++);for(s=-s;s--;)o[l++]=u}s=a.getInt16(f,!0),f+=2}while(f0?1:0),p=h+(n.height%h>0?1:0);n.pixels.blocks=new Array(d*p);for(var m=0,v=0;v3)throw"Invalid block encoding ("+b.encoding+")";if(2!==b.encoding){if(0!==k&&2!==k){if(k>>=6,b.offsetType=k,2===k)b.offset=a.getInt8(1),w++;else if(1===k)b.offset=a.getInt16(1,!0),w+=2;else{if(0!==k)throw"Invalid block offset type";b.offset=a.getFloat32(1,!0),w+=4}if(1===b.encoding)if(k=a.getUint8(w),w++,b.bitsPerPixel=63&k,k>>=6,b.numValidPixelsType=k,2===k)b.numValidPixels=a.getUint8(w),w++;else if(1===k)b.numValidPixels=a.getUint16(w,!0),w+=2;else{if(0!==k)throw"Invalid valid pixel count type";b.numValidPixels=a.getUint32(w,!0),w+=4}}var x;if(t+=w,3!==b.encoding)if(0===b.encoding){var _=(n.pixels.numBytes-1)/4;if(_!==Math.floor(_))throw"uncompressed block has invalid length";x=new ArrayBuffer(4*_),new Uint8Array(x).set(new Uint8Array(e,t,4*_));var A=new Float32Array(x);b.rawData=A,t+=4*_}else if(1===b.encoding){var P=Math.ceil(b.numValidPixels*b.bitsPerPixel/8),I=Math.ceil(P/4);x=new ArrayBuffer(4*I),new Uint8Array(x).set(new Uint8Array(e,t,P)),b.stuffedData=new Uint32Array(x),t+=P}}else t++}return n.eofOffset=t,n},a=function(e,t,r,n,i,a,o){var s,f,l,u=(1<=t)f=l>>>h-t&u,h-=t;else{var m=t-h;f=(l&u)<>>(h=32-m)}a[s]=f=r?(l=u>>>m-r&d,m-=r):(l=(u&d)<<(c=r-m)&d,l+=(u=e[p++])>>>(m=32-c)),t[f]=i[l];else for(h=Math.ceil((s-a)/o),f=0;f=r?(l=u>>>m-r&d,m-=r):(l=(u&d)<<(c=r-m)&d,l+=(u=e[p++])>>>(m=32-c)),t[f]=l=t?(h=o>>>c-t&s,c-=t):(h=(o&s)<<(u=t-c)&s,h+=(o=e[f++])>>>(c=32-u)),d[l]=h=r?(l=u>>>m&h,p-=r,m+=r):(l=u>>>m&h,p=32-(c=r-p),l|=((u=e[d++])&(1<=r?(l=u>>>m&h,p-=r,m+=r):(l=u>>>m&h,p=32-(c=r-p),l|=((u=e[d++])&(1<=t?(h=o>>>d&s,c-=t,d+=t):(h=o>>>d&s,c=32-(u=t-c),h|=((o=e[f++])&(1<=r?(a=o>>>u-r&f,u-=r):(a=(o&f)<<(s=r-u)&f,a+=(o=e[l++])>>>(u=32-s)),t[i]=a;return t},c=function(e,t,r,n){var i,a,o,s,f=(1<=r?(a=o>>>c&f,u-=r,c+=r):(a=o>>>c&f,u=32-(s=r-u),a|=((o=e[l++])&(1<=359?359:i;i-=o;do{t+=e[a++]<<8,r+=t+=e[a++]}while(--o);t=(65535&t)+(t>>>16),r=(65535&r)+(r>>>16)}return 1&n&&(r+=t+=e[a]<<8),((r=(65535&r)+(r>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var r=t.ptr,n=new Uint8Array(e,r,6),i={};if(i.fileIdentifierString=String.fromCharCode.apply(null,n),0!==i.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+i.fileIdentifierString;r+=6;var a,o=new DataView(e,r,8),s=o.getInt32(0,!0);if(i.fileVersion=s,r+=4,s>=3&&(i.checksum=o.getUint32(4,!0),r+=4),o=new DataView(e,r,12),i.height=o.getUint32(0,!0),i.width=o.getUint32(4,!0),r+=8,s>=4?(i.numDims=o.getUint32(8,!0),r+=4):i.numDims=1,o=new DataView(e,r,40),i.numValidPixel=o.getUint32(0,!0),i.microBlockSize=o.getInt32(4,!0),i.blobSize=o.getInt32(8,!0),i.imageType=o.getInt32(12,!0),i.maxZError=o.getFloat64(16,!0),i.zMin=o.getFloat64(24,!0),i.zMax=o.getFloat64(32,!0),r+=40,t.headerInfo=i,t.ptr=r,s>=3&&(a=s>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,r-a,i.blobSize-14))!==i.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var r=t.headerInfo,n=this.getDataTypeArray(r.imageType),i=r.numDims*this.getDataTypeSize(r.imageType),a=this.readSubArray(e,t.ptr,n,i),o=this.readSubArray(e,t.ptr+i,n,i);t.ptr+=2*i;var s,f=!0;for(s=0;s0){r=new Uint8Array(Math.ceil(o/8));var u=(f=new DataView(e,i,l.numBytes)).getInt16(0,!0),c=2,h=0,d=0;do{if(u>0)for(;u--;)r[h++]=f.getUint8(c++);else for(d=f.getUint8(c++),u=-u;u--;)r[h++]=d;u=f.getInt16(c,!0),c+=2}while(c>3],p<<=7&m):p=r[m>>3],128&p&&(n[m]=1);t.pixels.resultMask=n,l.bitset=r,i+=l.numBytes}return t.ptr=i,t.mask=l,!0},readDataOneSweep:function(e,t,r,n){var i,a=t.ptr,o=t.headerInfo,s=o.numDims,f=o.width*o.height,l=o.imageType,u=o.numValidPixel*h.getDataTypeSize(l)*s,c=t.pixels.resultMask;if(r===Uint8Array)i=new Uint8Array(e,a,u);else{var d=new ArrayBuffer(u);new Uint8Array(d).set(new Uint8Array(e,a,u)),i=new r(d)}if(i.length===f*s)t.pixels.resultPixels=n?h.swapDimensionOrder(i,f,s,r,!0):i;else{t.pixels.resultPixels=new r(f*s);var p=0,m=0,v=0,y=0;if(s>1){if(n){for(m=0;m=o)return!1;var s=new Uint32Array(o-a);h.decodeBits(e,t,s);var f,l,u,c,p=[];for(f=a;f0&&(p[l].second=w<>>32-c,32-b>=c?32===(b+=c)&&(b=0,w=g[++k]):(b+=c-32,w=g[++k],p[l].second|=w>>>32-b));var x=0,_=0,A=new d;for(f=0;f=r?r:x;var P,I,U,S,T,D=[];for(f=a;f0)if(P=[c,l],c<=_)for(I=p[l].second<<_-c,U=1<<_-c,u=0;u=0;S--)I>>>S&1?(T.right||(T.right=new d),T=T.right):(T.left||(T.left=new d),T=T.left),0!==S||T.val||(T.val=P[1]);return{decodeLut:D,numBitsLUTQick:_,numBitsLUT:x,tree:A,stuffedData:g,srcPtr:k,bitPos:b}},readHuffman:function(e,t,r,n){var i,a,o,s,f,l,u,c,d,p=t.headerInfo.numDims,m=t.headerInfo.height,v=t.headerInfo.width,y=v*m,w=this.readHuffmanTree(e,t),g=w.decodeLut,b=w.tree,k=w.stuffedData,x=w.srcPtr,_=w.bitPos,A=w.numBitsLUTQick,P=w.numBitsLUT,I=0===t.headerInfo.imageType?128:0,U=t.pixels.resultMask,S=0;_>0&&(x++,_=0);var T,D=k[x],E=1===t.encodeMode,B=new r(y*p),O=B;if(p<2||E){for(T=0;T1&&(O=new r(B.buffer,y*T,y),S=0),t.headerInfo.numValidPixel===v*m)for(c=0,l=0;l>>32-A,32-_>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_>>64-_-P),i=b,d=0;d>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,E?(o+=u>0?S:l>0?O[c-v]:S,o&=255,O[c]=o,S=o):O[c]=o}else for(c=0,l=0;l>>32-A,32-_>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_>>64-_-P),i=b,d=0;d>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,E?(u>0&&U[c-1]?o+=S:l>0&&U[c-v]?o+=O[c-v]:o+=S,o&=255,O[c]=o,S=o):O[c]=o}}else for(c=0,l=0;l>>32-A,32-_>>64-_-A),g[f])a=g[f][1],_+=g[f][0];else for(f=s=D<<_>>>32-P,32-_>>64-_-P),i=b,d=0;d>>P-d-1&1?i.right:i.left).left&&!i.right){a=i.val,_=_+d+1;break}_>=32&&(_-=32,D=k[++x]),o=a-I,O[c]=o}t.ptr=t.ptr+4*(x+1)+(_>0?4:0),t.pixels.resultPixels=B,p>1&&!n&&(t.pixels.resultPixels=h.swapDimensionOrder(B,y,p,r))},decodeBits:function(e,t,r,n,i){var a=t.headerInfo,h=a.fileVersion,d=0,p=e.byteLength-t.ptr>=5?5:e.byteLength-t.ptr,m=new DataView(e,t.ptr,p),v=m.getUint8(0);d++;var y=v>>6,w=0===y?4:3-y,g=(32&v)>0,b=31&v,k=0;if(1===w)k=m.getUint8(d),d++;else if(2===w)k=m.getUint16(d,!0),d+=2;else{if(4!==w)throw"Invalid valid pixel count type";k=m.getUint32(d,!0),d+=4}var x,_,A,P,I,U,S,T,D,E=2*a.maxZError,B=a.numDims>1?a.maxValues[i]:a.zMax;if(g){for(t.counter.lut++,T=m.getUint8(d),d++,P=Math.ceil((T-1)*b/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),A=new Uint8Array(_),t.ptr+=d,A.set(new Uint8Array(e,t.ptr,P)),S=new Uint32Array(_),t.ptr+=P,D=0;T-1>>>D;)D++;P=Math.ceil(k*D/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),(A=new Uint8Array(_)).set(new Uint8Array(e,t.ptr,P)),x=new Uint32Array(_),t.ptr+=P,U=h>=3?l(S,b,T-1,n,E,B):s(S,b,T-1,n,E,B),h>=3?f(x,r,D,k,U):o(x,r,D,k,U)}else t.counter.bitstuffer++,D=b,t.ptr+=d,D>0&&(P=Math.ceil(k*D/8),I=Math.ceil(P/4),_=new ArrayBuffer(4*I),(A=new Uint8Array(_)).set(new Uint8Array(e,t.ptr,P)),x=new Uint32Array(_),t.ptr+=P,h>=3?null==n?c(x,r,D,k):f(x,r,D,k,!1,n,E,B):null==n?u(x,r,D,k):o(x,r,D,k,!1,n,E,B))},readTiles:function(e,t,r,n){var i=t.headerInfo,a=i.width,o=i.height,s=a*o,f=i.microBlockSize,l=i.imageType,u=h.getDataTypeSize(l),c=Math.ceil(a/f),d=Math.ceil(o/f);t.pixels.numBlocksY=d,t.pixels.numBlocksX=c,t.pixels.ptr=0;var p,m,v,y,w,g,b,k,x,_,A=0,P=0,I=0,U=0,S=0,T=0,D=0,E=0,B=0,O=0,M=0,C=0,L=0,R=0,V=0,G=new r(f*f),F=o%f||f,z=a%f||f,j=i.numDims,N=t.pixels.resultMask,Z=t.pixels.resultPixels,K=i.fileVersion>=5?14:15,H=i.zMax;for(I=0;I1?(_=Z,O=I*a*f+U*f,Z=new r(t.pixels.resultPixels.buffer,s*k*u,s),H=i.maxValues[k]):_=null,D=e.byteLength-t.ptr,m={},V=0,E=(p=new DataView(e,t.ptr,Math.min(10,D))).getUint8(0),V++,x=i.fileVersion>=5?4&E:0,B=E>>6&255,(E>>2&K)!=(U*f>>3&K))throw"integrity issue";if(x&&0===k)throw"integrity issue";if((w=3&E)>3)throw t.ptr+=V,"Invalid block encoding ("+w+")";if(2!==w)if(0===w){if(x)throw"integrity issue";if(t.counter.uncompressed++,t.ptr+=V,C=(C=S*T*u)<(L=e.byteLength-t.ptr)?C:L,v=new ArrayBuffer(C%u==0?C:C+u-C%u),new Uint8Array(v).set(new Uint8Array(e,t.ptr,C)),y=new r(v),R=0,N)for(A=0;A1&&!n&&(t.pixels.resultPixels=h.swapDimensionOrder(t.pixels.resultPixels,s,j,r))},formatFileInfo:function(e){return{fileIdentifierString:e.headerInfo.fileIdentifierString,fileVersion:e.headerInfo.fileVersion,imageType:e.headerInfo.imageType,height:e.headerInfo.height,width:e.headerInfo.width,numValidPixel:e.headerInfo.numValidPixel,microBlockSize:e.headerInfo.microBlockSize,blobSize:e.headerInfo.blobSize,maxZError:e.headerInfo.maxZError,pixelType:h.getPixelType(e.headerInfo.imageType),eofOffset:e.eofOffset,mask:e.mask?{numBytes:e.mask.numBytes}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,maxValue:e.headerInfo.zMax,minValue:e.headerInfo.zMin,noDataValue:e.noDataValue}}},constructConstantSurface:function(e,t){var r=e.headerInfo.zMax,n=e.headerInfo.zMin,i=e.headerInfo.maxValues,a=e.headerInfo.numDims,o=e.headerInfo.height*e.headerInfo.width,s=0,f=0,l=0,u=e.pixels.resultMask,c=e.pixels.resultPixels;if(u)if(a>1){if(t)for(s=0;s1&&n!==r)if(t)for(s=0;s=-128&&t<=127;break;case 1:r=t>=0&&t<=255;break;case 2:r=t>=-32768&&t<=32767;break;case 3:r=t>=0&&t<=65536;break;case 4:r=t>=-2147483648&&t<=2147483647;break;case 5:r=t>=0&&t<=4294967296;break;case 6:r=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:r=t>=-17976931348623157e292&&t<=17976931348623157e292;break;default:r=!1}return r},getDataTypeSize:function(e){var t=0;switch(e){case 0:case 1:t=1;break;case 2:case 3:t=2;break;case 4:case 5:case 6:t=4;break;case 7:t=8;break;default:t=e}return t},getDataTypeUsed:function(e,t){var r=e;switch(e){case 2:case 4:r=e-t;break;case 3:case 5:r=e-2*t;break;case 6:r=0===t?e:1===t?2:1;break;case 7:r=0===t?e:e-2*t+1;break;default:r=e}return r},getOnePixel:function(e,t,r,n){var i=0;switch(r){case 0:i=n.getInt8(t);break;case 1:i=n.getUint8(t);break;case 2:i=n.getInt16(t,!0);break;case 3:i=n.getUint16(t,!0);break;case 4:i=n.getInt32(t,!0);break;case 5:i=n.getUInt32(t,!0);break;case 6:i=n.getFloat32(t,!0);break;case 7:i=n.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return i},swapDimensionOrder:function(e,t,r,n,i){var a=0,o=0,s=0,f=0,l=e;if(r>1)if(l=new n(t*r),i)for(a=0;a5)throw"unsupported lerc version 2."+o;h.readMask(e,i),a.numValidPixel===a.width*a.height||i.pixels.resultMask||(i.pixels.resultMask=t.maskData);var f=a.width*a.height;i.pixels.resultPixels=new s(f*a.numDims),i.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var l,u=!t.returnPixelInterleavedDims;if(0!==a.numValidPixel)if(a.zMax===a.zMin)h.constructConstantSurface(i,u);else if(o>=4&&h.checkMinMaxRanges(e,i))h.constructConstantSurface(i,u);else{var c=new DataView(e,i.ptr,2),d=c.getUint8(0);if(i.ptr++,d)h.readDataOneSweep(e,i,s,u);else if(o>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var p=c.getUint8(1);if(i.ptr++,i.encodeMode=p,p>2||o<4&&p>1)throw"Invalid Huffman flag "+p;p?h.readHuffman(e,i,s,u):h.readTiles(e,i,s,u)}else h.readTiles(e,i,s,u)}i.eofOffset=i.ptr,t.inputOffset?(l=i.headerInfo.blobSize+t.inputOffset-i.ptr,Math.abs(l)>=1&&(i.eofOffset=t.inputOffset+i.headerInfo.blobSize)):(l=i.headerInfo.blobSize-i.ptr,Math.abs(l)>=1&&(i.eofOffset=i.headerInfo.blobSize));var m={width:a.width,height:a.height,pixelData:i.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:i.pixels.resultMask};if(i.pixels.resultMask&&h.isValidPixelValue(a.imageType,r)){var v=i.pixels.resultMask;for(n=0;n1&&(l&&m.push(l),k.fileInfo.mask&&k.fileInfo.mask.numBytes>0&&b++),d++,g.pixels.push(k.pixelData),g.statistics.push({minValue:k.minValue,maxValue:k.maxValue,noDataValue:k.noDataValue,dimStats:k.dimStats})}if(n>1&&b>1){for(h=g.width*g.height,g.bandMasks=m,(l=new Uint8Array(h)).set(m[0]),u=1;uthis.fetchSlice(t,e))))}async fetchSlice(t){throw new Error(`fetching of slice ${t} not possible, not implemented`)}get fileSize(){return null}async close(){}},$L}var eO={};class rO extends Map{constructor(t={}){if(super(),!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof t.maxAge&&0===t.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=t.maxSize,this.maxAge=t.maxAge||Number.POSITIVE_INFINITY,this.onEviction=t.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(t){if("function"==typeof this.onEviction)for(const[e,r]of t)this.onEviction(e,r.value)}_deleteIfExpired(t,e){return"number"==typeof e.expiry&&e.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(t,e.value),this.delete(t))}_getOrDeleteIfExpired(t,e){if(!1===this._deleteIfExpired(t,e))return e.value}_getItemValue(t,e){return e.expiry?this._getOrDeleteIfExpired(t,e):e.value}_peek(t,e){const r=e.get(t);return this._getItemValue(t,r)}_set(t,e){this.cache.set(t,e),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(t,e){this.oldCache.delete(t),this._set(t,e)}*_entriesAscending(){for(const t of this.oldCache){const[e,r]=t;if(!this.cache.has(e)){!1===this._deleteIfExpired(e,r)&&(yield t)}}for(const t of this.cache){const[e,r]=t;!1===this._deleteIfExpired(e,r)&&(yield t)}}get(t){if(this.cache.has(t)){const e=this.cache.get(t);return this._getItemValue(t,e)}if(this.oldCache.has(t)){const e=this.oldCache.get(t);if(!1===this._deleteIfExpired(t,e))return this._moveToRecent(t,e),e.value}}set(t,e,{maxAge:r=this.maxAge}={}){const n="number"==typeof r&&r!==Number.POSITIVE_INFINITY?Date.now()+r:void 0;this.cache.has(t)?this.cache.set(t,{value:e,expiry:n}):this._set(t,{value:e,expiry:n})}has(t){return this.cache.has(t)?!this._deleteIfExpired(t,this.cache.get(t)):!!this.oldCache.has(t)&&!this._deleteIfExpired(t,this.oldCache.get(t))}peek(t){return this.cache.has(t)?this._peek(t,this.cache):this.oldCache.has(t)?this._peek(t,this.oldCache):void 0}delete(t){const e=this.cache.delete(t);return e&&this._size--,this.oldCache.delete(t)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(t){if(!(t&&t>0))throw new TypeError("`maxSize` must be a number greater than 0");const e=[...this._entriesAscending()],r=e.length-t;r<0?(this.cache=new Map(e),this.oldCache=new Map,this._size=e.length):(r>0&&this._emitEvictions(e.slice(0,r)),this.oldCache=new Map(e.slice(r)),this.cache=new Map,this._size=0),this.maxSize=t}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache){const[e,r]=t;!1===this._deleteIfExpired(e,r)&&(yield[e,r.value])}for(const t of this.oldCache){const[e,r]=t;if(!this.cache.has(e)){!1===this._deleteIfExpired(e,r)&&(yield[e,r.value])}}}*entriesDescending(){let t=[...this.cache];for(let e=t.length-1;e>=0;--e){const r=t[e],[n,i]=r;!1===this._deleteIfExpired(n,i)&&(yield[n,i.value])}t=[...this.oldCache];for(let e=t.length-1;e>=0;--e){const r=t[e],[n,i]=r;if(!this.cache.has(n)){!1===this._deleteIfExpired(n,i)&&(yield[n,i.value])}}}*entriesAscending(){for(const[t,e]of this._entriesAscending())yield[t,e.value]}get size(){if(!this._size)return this.oldCache.size;let t=0;for(const e of this.oldCache.keys())this.cache.has(e)||t++;return Math.min(this._size+t,this.maxSize)}entries(){return this.entriesAscending()}forEach(t,e=this){for(const[r,n]of this.entriesAscending())t.call(e,n,r,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}const nO=rf(Object.freeze(Object.defineProperty({__proto__:null,default:rO},Symbol.toStringTag,{value:"Module"})));var iO,aO,oO={};function sO(){if(iO)return oO;function t(t){const e=[],{length:r}=t;for(let n=0;nNumber.parseInt(t,10);let r=t.match(/^(\w*) /);const n=r&&r[1];return r=t.match(/(\d+)-(\d+)\/(\d+|\*)/),r?{unit:n,first:e(r[1]),last:e(r[2]),length:"*"===r[3]?null:e(r[3])}:(r=t.match(/(\d+|\*)/),r?{unit:n,first:null,last:null,length:"*"===r[1]?null:e(r[1])}:null)},oO.wait=async function(t){return new Promise((e=>setTimeout(e,t)))},oO.zip=function(t,e){const r=Array.isArray(t)?t:Array.from(t),n=Array.isArray(e)?e:Array.from(e);return r.map(((t,e)=>[t,n[e]]))};class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.name="AbortError"}}oO.AbortError=e;class r extends Error{constructor(t,e){super(e),this.errors=t,this.message=e,this.name="AggregateError"}}return oO.CustomAggregateError=r,oO.AggregateError=r,oO}var lO,uO,cO={},hO={};function dO(){if(lO)return hO;lO=1,Object.defineProperty(hO,"__esModule",{value:!0}),hO.BaseClient=hO.BaseResponse=void 0;hO.BaseResponse=class{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(t){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}};return hO.BaseClient=class{constructor(t){this.url=t}async request({headers:t,credentials:e,signal:r}={}){throw new Error("request is not implemented")}},hO}var fO,pO={};var mO={};const gO=rf(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var vO,yO;function xO(){if(yO)return KL;yO=1,Object.defineProperty(KL,"__esModule",{value:!0}),KL.makeRemoteSource=KL.makeHttpSource=KL.makeXHRSource=KL.makeFetchSource=void 0;const t=function(){if(ZL)return JL;ZL=1,Object.defineProperty(JL,"__esModule",{value:!0}),JL.parseByteRanges=JL.parseContentRange=JL.parseContentType=void 0;const t="\r\n\r\n";function e(t){if(void 0!==Object.fromEntries)return Object.fromEntries(t);const e={};for(const[r,n]of t)e[r.toLowerCase()]=n;return e}function r(t){return e(t.split("\r\n").map((t=>{const e=t.split(":").map((t=>t.trim()));return e[0]=e[0].toLowerCase(),e})))}function n(t){let e,r,n;return t&&([,e,r,n]=t.match(/bytes (\d+)-(\d+)\/(\d+)/),e=parseInt(e,10),r=parseInt(r,10),n=parseInt(n,10)),{start:e,end:r,total:n}}return JL.parseContentType=function(t){const[r,...n]=t.split(";").map((t=>t.trim()));return{type:r,params:e(n.map((t=>t.split("="))))}},JL.parseContentRange=n,JL.parseByteRanges=function(e,i){let a=null;const o=new TextDecoder("ascii"),s=[],l=`--${i}`,u=`${l}--`;for(let t=0;t<10;++t)o.decode(new Uint8Array(e,t,l.length))===l&&(a=t);if(null===a)throw new Error("Could not find initial boundary");for(;a{this.evictedBlocks.set(t,e)}}),this.evictedBlocks=new Map,this.blockRequests=new Map,this.blockIdsToFetch=new Set,this.abortedBlockIds=new Set}get fileSize(){return this.source.fileSize}async fetch(t,e){const r=[],i=[],a=[];this.evictedBlocks.clear();for(const{offset:e,length:n}of t){let t=e+n;const{fileSize:o}=this;null!==o&&(t=Math.min(t,o));for(let n=Math.floor(e/this.blockSize)*this.blockSize;nthis.abortedBlockIds.has(t)||!this.blockCache.has(t)));if(l.forEach((t=>this.blockIdsToFetch.add(t))),l.length>0&&e&&!e.aborted){this.fetchBlocks(null);for(const t of l){const e=this.blockRequests.get(t);if(!e)throw new Error(`Block ${t} is not in the block requests`);s.push(e)}await Promise.allSettled(s)}if(e&&e.aborted)throw new n.AbortError("Request was aborted");const u=a.map((t=>this.blockCache.get(t)||this.evictedBlocks.get(t))),c=u.filter((t=>!t));if(c.length)throw new n.AggregateError(c,"Request failed");const h=new Map((0,n.zip)(a,u));return this.readSliceData(t,h)}fetchBlocks(t){if(this.blockIdsToFetch.size>0){const e=this.groupBlocks(this.blockIdsToFetch),r=this.source.fetch(e,t);for(let n=0;n{try{const t=(await r)[n],a=e*this.blockSize,o=a-t.offset,s=Math.min(o+this.blockSize,t.data.byteLength),l=t.data.slice(o,s),u=new i(a,l.byteLength,l,e);this.blockCache.set(e,u),this.abortedBlockIds.delete(e)}catch(r){if("AbortError"!==r.name)throw r;r.signal=t,this.blockCache.delete(e),this.abortedBlockIds.add(e)}finally{this.blockRequests.delete(e)}})())}this.blockIdsToFetch.clear()}}groupBlocks(t){const e=Array.from(t).sort(((t,e)=>t-e));if(0===e.length)return[];let r=[],n=null;const i=[];for(const t of e)null===n||n+1===t?(r.push(t),n=t):(i.push(new a(r[0]*this.blockSize,r.length*this.blockSize,r)),r=[t],n=t);return i.push(new a(r[0]*this.blockSize,r.length*this.blockSize,r)),i}readSliceData(t,e){return t.map((t=>{let r=t.offset+t.length;null!==this.fileSize&&(r=Math.min(this.fileSize,r));const n=Math.floor(t.offset/this.blockSize),i=Math.floor(r/this.blockSize),a=new ArrayBuffer(t.length),o=new Uint8Array(a);for(let a=n;a<=i;++a){const n=e.get(a),i=n.offset-t.offset;let s,l=0,u=0;i<0?l=-i:i>0&&(u=i),s=n.top-r<0?n.length-l:r-n.offset-l;const c=new Uint8Array(n.data,l,s);o.set(c,u)}return a}))}}return eO.BlockedSource=o,eO}(),n=function(){if(uO)return cO;uO=1,Object.defineProperty(cO,"__esModule",{value:!0}),cO.FetchClient=void 0;const t=dO();class e extends t.BaseResponse{constructor(t){super(),this.response=t}get status(){return this.response.status}getHeader(t){return this.response.headers.get(t)}async getData(){return this.response.arrayBuffer?await this.response.arrayBuffer():(await this.response.buffer()).buffer}}class r extends t.BaseClient{constructor(t,e){super(t),this.credentials=e}async request({headers:t,credentials:r,signal:n}={}){const i=await fetch(this.url,{headers:t,credentials:r,signal:n});return new e(i)}}return cO.FetchClient=r,cO}(),i=function(){if(fO)return pO;fO=1,Object.defineProperty(pO,"__esModule",{value:!0}),pO.XHRClient=void 0;const t=dO(),e=sO();class r extends t.BaseResponse{constructor(t,e){super(),this.xhr=t,this.data=e}get status(){return this.xhr.status}getHeader(t){return this.xhr.getResponseHeader(t)}async getData(){return this.data}}class n extends t.BaseClient{constructRequest(t,n){return new Promise(((i,a)=>{const o=new XMLHttpRequest;o.open("GET",this.url),o.responseType="arraybuffer";for(const[e,r]of Object.entries(t))o.setRequestHeader(e,r);o.onload=()=>{const t=o.response;i(new r(o,t))},o.onerror=a,o.onabort=()=>a(new e.AbortError("Request aborted")),o.send(),n&&(n.aborted&&o.abort(),n.addEventListener("abort",(()=>o.abort())))}))}async request({headers:t,signal:e}={}){return await this.constructRequest(t,e)}}return pO.XHRClient=n,pO}(),a=function(){if(vO)return mO;vO=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(mO,"__esModule",{value:!0}),mO.HttpClient=void 0;const e=t(gO),r=t(gO),n=t(gO),i=dO(),a=sO();class o extends i.BaseResponse{constructor(t,e){super(),this.response=t,this.dataPromise=e}get status(){return this.response.statusCode}getHeader(t){return this.response.headers[t]}async getData(){return await this.dataPromise}}class s extends i.BaseClient{constructor(t){super(t),this.parsedUrl=n.default.parse(this.url),this.httpApi="http:"===this.parsedUrl.protocol?e.default:r.default}constructRequest(t,e){return new Promise(((r,n)=>{const i=this.httpApi.get({...this.parsedUrl,headers:t},(t=>{const e=new Promise((e=>{const r=[];t.on("data",(t=>{r.push(t)})),t.on("end",(()=>{const t=Buffer.concat(r).buffer;e(t)})),t.on("error",n)}));r(new o(t,e))}));i.on("error",n),e&&(e.aborted&&i.destroy(new a.AbortError("Request aborted")),e.addEventListener("abort",(()=>i.destroy(new a.AbortError("Request aborted")))))}))}async request({headers:t,signal:e}={}){return await this.constructRequest(t,e)}}return mO.HttpClient=s,mO}();class o extends e.BaseSource{constructor(t,e,r,n){super(),this.client=t,this.headers=e,this.maxRanges=r,this.allowFullFile=n,this._fileSize=null}async fetch(t,e){return this.maxRanges>=t.length?this.fetchSlices(t,e):(this.maxRanges>0&&t.length,Promise.all(t.map((t=>this.fetchSlice(t,e)))))}async fetchSlices(e,r){const n=await this.client.request({headers:{...this.headers,Range:`bytes=${e.map((({offset:t,length:e})=>`${t}-${t+e}`)).join(",")}`},signal:r});if(n.ok){if(206===n.status){const{type:i,params:a}=(0,t.parseContentType)(n.getHeader("content-type"));if("multipart/byteranges"===i){const e=(0,t.parseByteRanges)(await n.getData(),a.boundary);return this._fileSize=e[0].fileSize||null,e}const o=await n.getData(),{start:s,end:l,total:u}=(0,t.parseContentRange)(n.getHeader("content-range"));this._fileSize=u||null;const c=[{data:o,offset:s,length:l-s}];if(e.length>1){const t=await Promise.all(e.slice(1).map((t=>this.fetchSlice(t,r))));return c.concat(t)}return c}{if(!this.allowFullFile)throw new Error("Server responded with full file");const t=await n.getData();return this._fileSize=t.byteLength,[{data:t,offset:0,length:t.byteLength}]}}throw new Error("Error fetching data.")}async fetchSlice(e,r){const{offset:n,length:i}=e,a=await this.client.request({headers:{...this.headers,Range:`bytes=${n}-${n+i}`},signal:r});if(a.ok){if(206===a.status){const e=await a.getData(),{total:r}=(0,t.parseContentRange)(a.getHeader("content-range"));return this._fileSize=r||null,{data:e,offset:n,length:i}}{if(!this.allowFullFile)throw new Error("Server responded with full file");const t=await a.getData();return this._fileSize=t.byteLength,{data:t,offset:0,length:t.byteLength}}}throw new Error("Error fetching data.")}get fileSize(){return this._fileSize}}function s(t,{blockSize:e,cacheSize:n}){return null===e?t:new r.BlockedSource(t,{blockSize:e,cacheSize:n})}function l(t,{headers:e={},credentials:r,maxRanges:i=0,allowFullFile:a=!1,...l}={}){const u=new n.FetchClient(t,r);return s(new o(u,e,i,a),l)}function u(t,{headers:e={},maxRanges:r=0,allowFullFile:n=!1,...a}={}){const l=new i.XHRClient(t);return s(new o(l,e,r,n),a)}function c(t,{headers:e={},maxRanges:r=0,allowFullFile:n=!1,...i}={}){const l=new a.HttpClient(t);return s(new o(l,e,r,n),i)}return KL.makeFetchSource=l,KL.makeXHRSource=u,KL.makeHttpSource=c,KL.makeRemoteSource=function(t,{forceXHR:e=!1,...r}={}){return"function"!=typeof fetch||e?"undefined"!=typeof XMLHttpRequest?u(t,r):c(t,r):l(t,r)},KL}var _O,wO={};var bO,MO={};var SO,TO={};function EO(){if(SO)return TO;SO=1;var t=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(TO,"__esModule",{value:!0}),TO.makeFileSource=void 0;const e=t(gO),r=tO();class n extends r.BaseSource{constructor(t){super(),this.path=t,this.openRequest=function(t,r,n){return new Promise(((i,a)=>{e.default.open(t,r,n,((t,e)=>{t?a(t):i(e)}))}))}(t,"r")}async fetchSlice(t){const r=await this.openRequest,{buffer:n}=await function(...t){return new Promise(((r,n)=>{e.default.read(...t,((t,e,i)=>{t?n(t):r({bytesRead:e,buffer:i})}))}))}(r,Buffer.alloc(t.length),0,t.length,t.offset);return n.buffer}async close(){const t=await this.openRequest;await function(t){return new Promise(((r,n)=>{e.default.close(t,(t=>{t?n(t):r()}))}))}(t)}}return TO.makeFileSource=function(t){return new n(t)},TO}var AO,PO={};function RO(){if(AO)return PO;AO=1,Object.defineProperty(PO,"__esModule",{value:!0}),PO.writeGeotiff=void 0;const t=pI(),e=sO(),r=(0,e.invert)(t.fieldTagNames),n=(0,e.invert)(t.geoKeyNames),i={};(0,e.assign)(i,r),(0,e.assign)(i,n);const a=(0,e.invert)(t.fieldTypeNames),o=1e3,s={nextZero:(t,e)=>{let r=e;for(;0!==t[r];)r++;return r},readUshort:(t,e)=>t[e]<<8|t[e+1],readShort:(t,e)=>{const r=s.ui8;return r[0]=t[e+1],r[1]=t[e+0],s.i16[0]},readInt:(t,e)=>{const r=s.ui8;return r[0]=t[e+3],r[1]=t[e+2],r[2]=t[e+1],r[3]=t[e+0],s.i32[0]},readUint:(t,e)=>{const r=s.ui8;return r[0]=t[e+3],r[1]=t[e+2],r[2]=t[e+1],r[3]=t[e+0],s.ui32[0]},readASCII:(t,e,r)=>r.map((r=>String.fromCharCode(t[e+r]))).join(""),readFloat:(t,r)=>{const n=s.ui8;return(0,e.times)(4,(e=>{n[e]=t[r+3-e]})),s.fl32[0]},readDouble:(t,r)=>{const n=s.ui8;return(0,e.times)(8,(e=>{n[e]=t[r+7-e]})),s.fl64[0]},writeUshort:(t,e,r)=>{t[e]=r>>8&255,t[e+1]=255&r},writeUint:(t,e,r)=>{t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=r>>0&255},writeASCII:(t,r,n)=>{(0,e.times)(n.length,(e=>{t[r+e]=n.charCodeAt(e)}))},ui8:new Uint8Array(8)};s.fl64=new Float64Array(s.ui8.buffer),s.writeDouble=(t,r,n)=>{s.fl64[0]=n,(0,e.times)(8,(e=>{t[r+e]=s.ui8[7-e]}))};const l=r=>{const n=new Uint8Array(o);let i=4;const l=s;n[0]=77,n[1]=77,n[3]=42;let u=8;if(l.writeUint(n,i,u),i+=4,r.forEach(((i,o)=>{const s=((r,n,i,o)=>{let s=i;const l=Object.keys(o).filter((t=>null!=t&&"undefined"!==t));r.writeUshort(n,s,l.length),s+=2;let u=s+12*l.length+4;for(const i of l){let l=null;"number"==typeof i?l=i:"string"==typeof i&&(l=parseInt(i,10));const c=t.fieldTagTypes[l],h=a[c];if(null==c||void 0===c||void 0===c)throw new Error(`unknown type of tag: ${l}`);let d=o[i];if(void 0===d)throw new Error(`failed to get value for key ${i}`);"ASCII"===c&&"string"==typeof d&&!1===(0,e.endsWith)(d,"\0")&&(d+="\0");const f=d.length;r.writeUshort(n,s,l),s+=2,r.writeUshort(n,s,h),s+=2,r.writeUint(n,s,f),s+=4;let p=[-1,1,1,2,4,8,0,0,0,0,0,0,8][h]*f,m=s;p>4&&(r.writeUint(n,s,u),m=u),"ASCII"===c?r.writeASCII(n,m,d):"SHORT"===c?(0,e.times)(f,(t=>{r.writeUshort(n,m+2*t,d[t])})):"LONG"===c?(0,e.times)(f,(t=>{r.writeUint(n,m+4*t,d[t])})):"RATIONAL"===c?(0,e.times)(f,(t=>{r.writeUint(n,m+8*t,Math.round(1e4*d[t])),r.writeUint(n,m+8*t+4,1e4)})):"DOUBLE"===c&&(0,e.times)(f,(t=>{r.writeDouble(n,m+8*t,d[t])})),p>4&&(p+=1&p,u+=p),s+=4}return[s,u]})(l,n,u,i);u=s[1],o{(0,e.times)(c,(n=>{(0,e.times)(s,(e=>{h.push(r[e][t][n])}))}))}))),n.ImageLength=a,delete n.height,n.ImageWidth=c,delete n.width,n.BitsPerSample||(n.BitsPerSample=(0,e.times)(s,(()=>8))),u.forEach((t=>{const e=t[0];if(!n[e]){const r=t[1];n[e]=r}})),n.PhotometricInterpretation||(n.PhotometricInterpretation=3===n.BitsPerSample.length?2:1),n.SamplesPerPixel||(n.SamplesPerPixel=[s]),n.StripByteCounts||(n.StripByteCounts=[s*a*c]),n.ModelPixelScale||(n.ModelPixelScale=[360/c,180/a,0]),n.SampleFormat||(n.SampleFormat=(0,e.times)(s,(()=>1))),n.hasOwnProperty("GeographicTypeGeoKey")||n.hasOwnProperty("ProjectedCSTypeGeoKey")||(n.GeographicTypeGeoKey=4326,n.ModelTiepoint=[0,0,0,-180,90,0],n.GeogCitationGeoKey="WGS 84",n.GTModelTypeGeoKey=2);const d=Object.keys(n).filter((t=>(0,e.endsWith)(t,"GeoKey"))).sort(((t,e)=>i[t]-i[e]));if(!n.GeoAsciiParams){let e="";d.forEach((r=>{const a=Number(i[r]);"ASCII"===t.fieldTagTypes[a]&&(e+=`${n[r].toString()}\0`)})),e.length>0&&(n.GeoAsciiParams=e)}if(!n.GeoKeyDirectory){const e=[1,1,0,d.length];d.forEach((r=>{const a=Number(i[r]);let o,s,l;e.push(a),"SHORT"===t.fieldTagTypes[a]?(o=1,s=0,l=n[r]):"GeogCitationGeoKey"===r?(o=n.GeoAsciiParams.length,s=Number(i.GeoAsciiParams),l=0):console.log(`[geotiff.js] couldn't get TIFFTagLocation for ${r}`),e.push(s),e.push(o),e.push(l)})),n.GeoKeyDirectory=e}for(const t in d)d.hasOwnProperty(t)&&delete n[t];["Compression","ExtraSamples","GeographicTypeGeoKey","GTModelTypeGeoKey","GTRasterTypeGeoKey","ImageLength","ImageWidth","Orientation","PhotometricInterpretation","ProjectedCSTypeGeoKey","PlanarConfiguration","ResolutionUnit","SamplesPerPixel","XPosition","YPosition"].forEach((t=>{var e;n[t]&&(n[t]=(e=n[t],Array.isArray(e)?e:[e]))}));const f=(t=>{const e={};for(const r in t)"StripOffsets"!==r&&(i[r]||console.error(r,"not in name2code:",Object.keys(i)),e[i[r]]=t[r]);return e})(n);return((t,r,n,i)=>{if(null==n)throw new Error(`you passed into encodeImage a width of type ${n}`);if(null==r)throw new Error(`you passed into encodeImage a width of type ${r}`);const a={256:[r],257:[n],273:[o],278:[n],305:"geotiff.js"};if(i)for(const t in i)i.hasOwnProperty(t)&&(a[t]=i[t]);const s=new Uint8Array(l([a])),u=new Uint8Array(t),c=a[277],h=new Uint8Array(o+r*n*c);return(0,e.times)(s.length,(t=>{h[t]=s[t]})),(0,e.forEach)(u,((t,e)=>{h[o+e]=t})),h.buffer})(h,c,a,f)},PO}var CO,IO,LO,OO,DO={};function kO(){return IO||(IO=1,function(t){var e=ef&&ef.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=ef&&ef.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=ef&&ef.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&e(n,t,i);return r(n,t),n},i=ef&&ef.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:!0}),t.GeoTIFFImage=t.Pool=t.writeArrayBuffer=t.fromUrls=t.fromBlob=t.fromFile=t.fromArrayBuffer=t.fromUrl=t.MultiGeoTIFF=t.GeoTIFF=t.setLogger=t.addDecoder=t.getDecoder=t.BaseDecoder=t.rgb=t.globals=void 0;const a=i(NL());t.GeoTIFFImage=a.default;const o=i(function(){if(UL)return BL;UL=1,Object.defineProperty(BL,"__esModule",{value:!0});const t=QC();return BL.default=class{constructor(t){this._dataView=new DataView(t)}get buffer(){return this._dataView.buffer}getUint64(t,e){const r=this.getUint32(t,e),n=this.getUint32(t+4,e);let i;if(e){if(i=r+2**32*n,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}if(i=2**32*r+n,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}getInt64(t,e){let r=0;const n=(128&this._dataView.getUint8(t+(e?7:0)))>0;let i=!0;for(let a=0;a<8;a++){let o=this._dataView.getUint8(t+(e?a:7-a));n&&(i?0!==o&&(o=255&~(o-1),i=!1):o=255&~o),r+=o*256**a}return n&&(r=-r),r}getUint8(t,e){return this._dataView.getUint8(t,e)}getInt8(t,e){return this._dataView.getInt8(t,e)}getUint16(t,e){return this._dataView.getUint16(t,e)}getInt16(t,e){return this._dataView.getInt16(t,e)}getUint32(t,e){return this._dataView.getUint32(t,e)}getInt32(t,e){return this._dataView.getInt32(t,e)}getFloat16(e,r){return(0,t.getFloat16)(this._dataView,e,r)}getFloat32(t,e){return this._dataView.getFloat32(t,e)}getFloat64(t,e){return this._dataView.getFloat64(t,e)}},BL}()),s=i((zL||(zL=1,Object.defineProperty(GL,"__esModule",{value:!0}),GL.default=class{constructor(t,e,r,n){this._dataView=new DataView(t),this._sliceOffset=e,this._littleEndian=r,this._bigTiff=n}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(t,e){return this.sliceOffset<=t&&this.sliceTop>=t+e}readUint8(t){return this._dataView.getUint8(t-this._sliceOffset,this._littleEndian)}readInt8(t){return this._dataView.getInt8(t-this._sliceOffset,this._littleEndian)}readUint16(t){return this._dataView.getUint16(t-this._sliceOffset,this._littleEndian)}readInt16(t){return this._dataView.getInt16(t-this._sliceOffset,this._littleEndian)}readUint32(t){return this._dataView.getUint32(t-this._sliceOffset,this._littleEndian)}readInt32(t){return this._dataView.getInt32(t-this._sliceOffset,this._littleEndian)}readFloat32(t){return this._dataView.getFloat32(t-this._sliceOffset,this._littleEndian)}readFloat64(t){return this._dataView.getFloat64(t-this._sliceOffset,this._littleEndian)}readUint64(t){const e=this.readUint32(t),r=this.readUint32(t+4);let n;if(this._littleEndian){if(n=e+2**32*r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}if(n=2**32*e+r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}readInt64(t){let e=0;const r=(128&this._dataView.getUint8(t+(this._littleEndian?7:0)))>0;let n=!0;for(let i=0;i<8;i++){let a=this._dataView.getUint8(t+(this._littleEndian?i:7-i));r&&(n?0!==a&&(a=255&~(a-1),n=!1):a=255&~a),e+=a*256**i}return r&&(e=-e),e}readOffset(t){return this._bigTiff?this.readUint64(t):this.readUint32(t)}}),GL)),l=i(function(){if(WL)return qL;WL=1;var t=ef&&ef.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),e=ef&&ef.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=ef&&ef.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&t(n,r,i);return e(n,r),n};Object.defineProperty(qL,"__esModule",{value:!0});const n=OL(),i="undefined"!=typeof navigator&&navigator.hardwareConcurrency||2;return qL.default=class{constructor(t=i,e){this.workers=null,this._awaitingDecoder=null,this.size=t,this.messageId=0,t&&(this._awaitingDecoder=e?Promise.resolve(e):new Promise((t=>{Promise.resolve().then((()=>r(YL()))).then((e=>{t(e.create)}))})),this._awaitingDecoder.then((e=>{this._awaitingDecoder=null,this.workers=[];for(let r=0;rr.decode(t,e))):new Promise((r=>{const n=this.workers.find((t=>t.idle))||this.workers[Math.floor(Math.random()*this.size)];n.idle=!1;const i=this.messageId++,a=t=>{t.data.id===i&&(n.idle=!0,r(t.data.decoded),n.worker.removeEventListener("message",a))};n.worker.addEventListener("message",a),n.worker.postMessage({fileDirectory:t,buffer:e,id:i},[e])}))}destroy(){this.workers&&(this.workers.forEach((t=>{t.worker.terminate()})),this.workers=null)}},qL}());t.Pool=l.default;const u=xO(),c=function(){if(_O)return wO;_O=1,Object.defineProperty(wO,"__esModule",{value:!0}),wO.makeBufferSource=void 0;const t=tO(),e=sO();class r extends t.BaseSource{constructor(t){super(),this.arrayBuffer=t}fetchSlice(t,r){if(r&&r.aborted)throw new e.AbortError("Request aborted");return this.arrayBuffer.slice(t.offset,t.offset+t.length)}}return wO.makeBufferSource=function(t){return new r(t)},wO}(),h=function(){if(bO)return MO;bO=1,Object.defineProperty(MO,"__esModule",{value:!0}),MO.makeFileReaderSource=void 0;const t=tO();class e extends t.BaseSource{constructor(t){super(),this.file=t}async fetchSlice(t,e){return new Promise(((r,n)=>{const i=this.file.slice(t.offset,t.offset+t.length),a=new FileReader;a.onload=t=>r(t.target.result),a.onerror=n,a.onabort=n,a.readAsArrayBuffer(i),e&&e.addEventListener("abort",(()=>a.abort()))}))}}return MO.makeFileReaderSource=function(t){return new e(t)},MO}(),d=EO(),f=pI(),p=RO(),m=n(pI());t.globals=m;const g=n(vI());t.rgb=g;const v=OL();Object.defineProperty(t,"getDecoder",{enumerable:!0,get:function(){return v.getDecoder}}),Object.defineProperty(t,"addDecoder",{enumerable:!0,get:function(){return v.addDecoder}});const y=function(){if(CO)return DO;CO=1,Object.defineProperty(DO,"__esModule",{value:!0}),DO.timeEnd=DO.time=DO.error=DO.warn=DO.info=DO.log=DO.debug=DO.setLogger=void 0;class t{log(){}debug(){}info(){}warn(){}error(){}time(){}timeEnd(){}}let e=new t;return DO.setLogger=function(r=new t){e=r},DO.debug=function(...t){return e.debug(...t)},DO.log=function(...t){return e.log(...t)},DO.info=function(...t){return e.info(...t)},DO.warn=function(...t){return e.warn(...t)},DO.error=function(...t){return e.error(...t)},DO.time=function(...t){return e.time(...t)},DO.timeEnd=function(...t){return e.timeEnd(...t)},DO}();Object.defineProperty(t,"setLogger",{enumerable:!0,get:function(){return y.setLogger}});var x=TI();function _(t){switch(t){case f.fieldTypes.BYTE:case f.fieldTypes.ASCII:case f.fieldTypes.SBYTE:case f.fieldTypes.UNDEFINED:return 1;case f.fieldTypes.SHORT:case f.fieldTypes.SSHORT:return 2;case f.fieldTypes.LONG:case f.fieldTypes.SLONG:case f.fieldTypes.FLOAT:case f.fieldTypes.IFD:return 4;case f.fieldTypes.RATIONAL:case f.fieldTypes.SRATIONAL:case f.fieldTypes.DOUBLE:case f.fieldTypes.LONG8:case f.fieldTypes.SLONG8:case f.fieldTypes.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${t}`)}}function w(t,e,r,n){let i=null,a=null;const o=_(e);switch(e){case f.fieldTypes.BYTE:case f.fieldTypes.ASCII:case f.fieldTypes.UNDEFINED:i=new Uint8Array(r),a=t.readUint8;break;case f.fieldTypes.SBYTE:i=new Int8Array(r),a=t.readInt8;break;case f.fieldTypes.SHORT:i=new Uint16Array(r),a=t.readUint16;break;case f.fieldTypes.SSHORT:i=new Int16Array(r),a=t.readInt16;break;case f.fieldTypes.LONG:case f.fieldTypes.IFD:i=new Uint32Array(r),a=t.readUint32;break;case f.fieldTypes.SLONG:i=new Int32Array(r),a=t.readInt32;break;case f.fieldTypes.LONG8:case f.fieldTypes.IFD8:i=new Array(r),a=t.readUint64;break;case f.fieldTypes.SLONG8:i=new Array(r),a=t.readInt64;break;case f.fieldTypes.RATIONAL:i=new Uint32Array(2*r),a=t.readUint32;break;case f.fieldTypes.SRATIONAL:i=new Int32Array(2*r),a=t.readInt32;break;case f.fieldTypes.FLOAT:i=new Float32Array(r),a=t.readFloat32;break;case f.fieldTypes.DOUBLE:i=new Float64Array(r),a=t.readFloat64;break;default:throw new RangeError(`Invalid field type: ${e}`)}if(e!==f.fieldTypes.RATIONAL&&e!==f.fieldTypes.SRATIONAL)for(let e=0;et.getWidth()-e.getWidth()));for(let e=0;en||a&&a>o)break}}let h=e;if(o){const[t,e]=s.getOrigin(),[r,n]=l.getResolution(s);h=[Math.round((o[0]-t)/r),Math.round((o[1]-e)/n),Math.round((o[2]-t)/r),Math.round((o[3]-e)/n)],h=[Math.min(h[0],h[2]),Math.min(h[1],h[3]),Math.max(h[0],h[2]),Math.max(h[1],h[3])]}return l.readRasters({...t,window:h})}}class T extends S{constructor(t,e,r,n,i={}){super(),this.source=t,this.littleEndian=e,this.bigTiff=r,this.firstIFDOffset=n,this.cache=i.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(t,e){const r=this.bigTiff?4048:1024;return new s.default((await this.source.fetch([{offset:t,length:void 0!==e?e:r}]))[0],t,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(t){const e=this.bigTiff?20:12,r=this.bigTiff?8:2;let n=await this.getSlice(t);const i=this.bigTiff?n.readUint64(t):n.readUint16(t),a=i*e+(this.bigTiff?16:6);n.covers(t,a)||(n=await this.getSlice(t,a));const o={};let s=t+(this.bigTiff?8:2);for(let t=0;t{const e=await this.ifdRequests[t-1];if(0===e.nextIFDByteOffset)throw new M(t);return this.parseFileDirectoryAt(e.nextIFDByteOffset)})(),this.ifdRequests[t]}async getImage(t=0){const e=await this.requestIFD(t);return new a.default(e.fileDirectory,e.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let t=0,e=!0;for(;e;)try{await this.requestIFD(t),++t}catch(t){if(!(t instanceof M))throw t;e=!1}return t}async getGhostValues(){const t=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const e="GDAL_STRUCTURAL_METADATA_SIZE=";let r=await this.getSlice(t,130);if(e===w(r,f.fieldTypes.ASCII,30,t)){const e=w(r,f.fieldTypes.ASCII,130,t).split("\n")[0],n=Number(e.split("=")[1].split(" ")[0])+e.length;n>130&&(r=await this.getSlice(t,n));const i=w(r,f.fieldTypes.ASCII,n,t);this.ghostValues={},i.split("\n").filter((t=>t.length>0)).map((t=>t.split("="))).forEach((([t,e])=>{this.ghostValues[t]=e}))}return this.ghostValues}static async fromSource(t,e,r){const n=(await t.fetch([{offset:0,length:1024}],r))[0],i=new o.default(n),a=i.getUint16(0,0);let s;if(18761===a)s=!0;else{if(19789!==a)throw new TypeError("Invalid byte order value.");s=!1}const l=i.getUint16(2,s);let u;if(42===l)u=!1;else{if(43!==l)throw new TypeError("Invalid magic number.");u=!0;if(8!==i.getUint16(4,s))throw new Error("Unsupported offset byte-size.")}const c=u?i.getUint64(8,s):i.getUint32(4,s);return new T(t,s,u,c,e)}close(){return"function"==typeof this.source.close&&this.source.close()}}t.GeoTIFF=T,t.default=T;class E extends S{constructor(t,e){super(),this.mainFile=t,this.overviewFiles=e,this.imageFiles=[t].concat(e),this.fileDirectoriesPerFile=null,this.fileDirectoriesPerFileParsing=null,this.imageCount=null}async parseFileDirectoriesPerFile(){const t=[this.mainFile.parseFileDirectoryAt(this.mainFile.firstIFDOffset)].concat(this.overviewFiles.map((t=>t.parseFileDirectoryAt(t.firstIFDOffset))));return this.fileDirectoriesPerFile=await Promise.all(t),this.fileDirectoriesPerFile}async getImage(t=0){await this.getImageCount(),await this.parseFileDirectoriesPerFile();let e=0,r=0;for(let n=0;nt.getImageCount())));return this.imageCounts=await Promise.all(t),this.imageCount=this.imageCounts.reduce(((t,e)=>t+e),0),this.imageCount}}t.MultiGeoTIFF=E,t.fromUrl=async function(t,e={},r){return T.fromSource((0,u.makeRemoteSource)(t,e),r)},t.fromArrayBuffer=async function(t,e){return T.fromSource((0,c.makeBufferSource)(t),e)},t.fromFile=async function(t,e){return T.fromSource((0,d.makeFileSource)(t),e)},t.fromBlob=async function(t,e){return T.fromSource((0,h.makeFileReaderSource)(t),e)},t.fromUrls=async function(t,e=[],r={},n){const i=await T.fromSource((0,u.makeRemoteSource)(t,r),n),a=await Promise.all(e.map((t=>T.fromSource((0,u.makeRemoteSource)(t,r)))));return new E(i,a)},t.writeArrayBuffer=function(t,e){return(0,p.writeGeotiff)(t,e)}}(MC)),MC}function FO(){if(LO)return mC;LO=1;var t=sf;Object.defineProperty(mC,"__esModule",{value:!0}),mC.default=void 0;var e=t(function(){if(pC)return fC;pC=1;var t=vC()();fC=t;try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}return fC}()),r=t((yC||(yC=1,function(t){function e(t,e,r,n,i,a,o){try{var s=t[a](o),l=s.value}catch(t){return void r(t)}s.done?e(l):Promise.resolve(l).then(n,i)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(i,a){var o=t.apply(r,n);function s(t){e(o,i,a,s,l,"next",t)}function l(t){e(o,i,a,s,l,"throw",t)}s(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports}(xC)),xC.exports)),n=t(wM()),i=Ff,a=kO(),o=t(oM()),s=t(tS()),l=t(qb());function u(t,e){for(var r=1/0,n=-1/0,i=0,a=t.length;i0&&u80*i){a=s=t[0],o=c=t[1];for(var x=i;xs&&(s=h),f>c&&(c=f);p=0!==(p=Math.max(s-a,c-o))?32767/p:0}return n(v,y,i,a,o,p,0),y}function e(t,e,r,n,i){var a,o;if(i===T(t,e,r,n)>0)for(a=e;a=e;a-=n)o=b(a,t[a],t[a+1],o);return o&&g(o,o.next)&&(M(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!g(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(M(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function n(t,e,l,u,c,d,f){if(t){!f&&d&&function(t,e,r,n){var i=t;do{0===i.z&&(i.z=h(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,u=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,u*=2}while(o>1)}(i)}(t,u,c,d);for(var p,m,g=t;t.prev!==t.next;)if(p=t.prev,m=t.next,d?a(t,u,c,d):i(t))e.push(p.i/l|0),e.push(t.i/l|0),e.push(m.i/l|0),M(t),t=m.next,g=m.next;else if((t=m)===g){f?1===f?n(t=o(r(t),e,l),e,l,u,c,d,2):2===f&&s(t,e,l,u,c,d):n(r(t),e,l,u,c,d,1);break}}}function i(t){var e=t.prev,r=t,n=t.next;if(m(e,r,n)>=0)return!1;for(var i=e.x,a=r.x,o=n.x,s=e.y,l=r.y,u=n.y,c=ia?i>o?i:o:a>o?a:o,p=s>l?s>u?s:u:l>u?l:u,g=n.next;g!==e;){if(g.x>=c&&g.x<=d&&g.y>=h&&g.y<=p&&f(i,s,a,l,o,u,g.x,g.y)&&m(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function a(t,e,r,n){var i=t.prev,a=t,o=t.next;if(m(i,a,o)>=0)return!1;for(var s=i.x,l=a.x,u=o.x,c=i.y,d=a.y,p=o.y,g=sl?s>u?s:u:l>u?l:u,x=c>d?c>p?c:p:d>p?d:p,_=h(g,v,e,r,n),w=h(y,x,e,r,n),b=t.prevZ,M=t.nextZ;b&&b.z>=_&&M&&M.z<=w;){if(b.x>=g&&b.x<=y&&b.y>=v&&b.y<=x&&b!==i&&b!==o&&f(s,c,l,d,u,p,b.x,b.y)&&m(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,M.x>=g&&M.x<=y&&M.y>=v&&M.y<=x&&M!==i&&M!==o&&f(s,c,l,d,u,p,M.x,M.y)&&m(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;b&&b.z>=_;){if(b.x>=g&&b.x<=y&&b.y>=v&&b.y<=x&&b!==i&&b!==o&&f(s,c,l,d,u,p,b.x,b.y)&&m(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;M&&M.z<=w;){if(M.x>=g&&M.x<=y&&M.y>=v&&M.y<=x&&M!==i&&M!==o&&f(s,c,l,d,u,p,M.x,M.y)&&m(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function o(t,e,n){var i=t;do{var a=i.prev,o=i.next.next;!g(a,o)&&v(a,i,i.next,o)&&_(a,o)&&_(o,a)&&(e.push(a.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),M(i),M(i.next),i=t=o),i=i.next}while(i!==t);return r(i)}function s(t,e,i,a,o,s){var l=t;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&p(l,u)){var c=w(l,u);return l=r(l,l.next),c=r(c,c.next),n(l,e,i,a,o,s,0),void n(c,e,i,a,o,s,0)}u=u.next}l=l.next}while(l!==t)}function l(t,e){return t.x-e.x}function u(t,e){var n=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o&&(o=s,r=n.x=n.x&&n.x>=h&&i!==n.x&&f(ar.x||n.x===r.x&&c(r,n)))&&(r=n,p=l)),n=n.next}while(n!==u);return r}(t,e);if(!n)return e;var i=w(n,t);return r(i,i.next),r(n,n.next)}function c(t,e){return m(t.prev,t,e.prev)<0&&m(e.next,t,t.next)<0}function h(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,r=t;do{(e.x=(t-o)*(a-s)&&(t-o)*(n-s)>=(r-o)*(e-s)&&(r-o)*(a-s)>=(i-o)*(n-s)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&v(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(_(t,e)&&_(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(m(t.prev,t,e.prev)||m(t,e.prev,e))||g(t,e)&&m(t.prev,t,t.next)>0&&m(e.prev,e,e.next)>0)}function m(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function g(t,e){return t.x===e.x&&t.y===e.y}function v(t,e,r,n){var i=x(m(t,e,r)),a=x(m(t,e,n)),o=x(m(r,n,t)),s=x(m(r,n,e));return i!==a&&o!==s||(!(0!==i||!y(t,r,e))||(!(0!==a||!y(t,n,e))||(!(0!==o||!y(r,t,n))||!(0!==s||!y(r,e,n)))))}function y(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function x(t){return t>0?1:t<0?-1:0}function _(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function w(t,e){var r=new S(t.i,t.x,t.y),n=new S(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function b(t,e,r,n){var i=new S(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function M(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r},zO.exports}var jO=sf,VO=cf;Object.defineProperty(af,"__esModule",{value:!0});var HO=af.default=af.INSTANCE_EVENTS=void 0,WO=jO(df()),qO=jO(_f()),XO=jO(Mf()),YO=jO(Rf()),ZO=jO(Lf()),KO=jO(kf()),JO=Ff,QO=jO(hv),$O=rx,tD=jO(function(){if(Sx)return ax;Sx=1;var t=sf;Object.defineProperty(ax,"__esModule",{value:!0}),ax.default=void 0;var e=Ff,r=t(Ax());function n(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Object.defineProperty(this,"crs",{get:function(){return t}}),this.camera3D=i.camera?i.camera:new e.PerspectiveCamera(30,r/n),this.camera3D.near=.1,this.camera3D.far=2e9,this.camera3D.updateProjectionMatrix(),this.camera2D=new e.OrthographicCamera(0,1,0,1,0,10),this._viewMatrix=new e.Matrix4,this.width=r,this.height=n,this._preSSE=1/0}n.prototype.update=function(t,e){!function(t,e,r){if(e&&r){t.width=e,t.height=r;var n=e/r;if(t.camera3D.aspect!==n&&(t.camera3D.aspect=n,t.camera3D.isOrthographicCamera)){var i=.5*(t.camera3D.right-t.camera3D.left)/n,a=.5*(t.camera3D.top+t.camera3D.bottom);t.camera3D.top=a+i,t.camera3D.bottom=a-i}}t.camera3D.updateProjectionMatrix&&t.camera3D.updateProjectionMatrix(),t.camera2D.right=e,t.camera2D.top=r,t.camera2D.bottom=0,t.camera2D.updateProjectionMatrix()}(this,t,e),this.camera3D.updateMatrixWorld(),this._viewMatrix.multiplyMatrices(this.camera3D.projectionMatrix,this.camera3D.matrixWorldInverse)},n.prototype.position=function(t){return new r.default(this.crs,this.camera3D.position).as(t||this.crs)};var i={frustum:new e.Frustum,matrix:new e.Matrix4,box3:new e.Box3},a=[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3],o=new e.Box3(new e.Vector3(-1,-1,-1),new e.Vector3(1,1,1));n.prototype.isBox3Visible=function(t,e){return this.box3SizeOnScreen(t,e).intersectsBox(o)},n.prototype.isSphereVisible=function(t,e){return e?(i.matrix.multiplyMatrices(this._viewMatrix,e),i.frustum.setFromProjectionMatrix(i.matrix)):i.frustum.setFromProjectionMatrix(this._viewMatrix),i.frustum.intersectsSphere(t)},n.prototype.box3SizeOnScreen=function(t,e){var r=function(t,e,r){var n=t.camera3D.matrixWorldInverse;r&&(n=i.matrix.multiplyMatrices(t.camera3D.matrixWorldInverse,r)),a[0].set(e.min.x,e.min.y,e.min.z).applyMatrix4(n),a[1].set(e.min.x,e.min.y,e.max.z).applyMatrix4(n),a[2].set(e.min.x,e.max.y,e.min.z).applyMatrix4(n),a[3].set(e.min.x,e.max.y,e.max.z).applyMatrix4(n),a[4].set(e.max.x,e.min.y,e.min.z).applyMatrix4(n),a[5].set(e.max.x,e.min.y,e.max.z).applyMatrix4(n),a[6].set(e.max.x,e.max.y,e.min.z).applyMatrix4(n),a[7].set(e.max.x,e.max.y,e.max.z).applyMatrix4(n);for(var o=!1,s=0;s<8;s++)a[s].z<=-t.camera3D.near?o=!0:a[s].z=-t.camera3D.near;return o?a:void 0}(this,t,e);if(!r)return i.box3.makeEmpty();for(var n=0;n<8;n++)r[n].applyMatrix4(this.camera3D.projectionMatrix);return i.box3.setFromPoints(r)};var s=n;return ax.default=s,ax}()),eD=hD(function(){if(KM)return Px;KM=1;var t=sf;Object.defineProperty(Px,"__esModule",{value:!0}),Px.default=Px.RENDERING_SCHEDULED=Px.RENDERING_PAUSED=Px.MAIN_LOOP_EVENTS=void 0;var e=Ff,r=t(Fb()),n=t(YM()),i=t(oM()),a=t(function(){if(ZM)return JM;ZM=1;var t=sf;Object.defineProperty(JM,"__esModule",{value:!0}),JM.default=void 0;var e=t(_f()),r=t(df()),n=Ff,i=(0,e.default)((function t(e,i,a){(0,r.default)(this,t),this.camera=e,this.scheduler=i,this.instance=a,this.distance={plane:(new n.Plane).setFromNormalAndCoplanarPoint(e.camera3D.getWorldDirection(new n.Vector3),e.camera3D.position),min:1/0,max:0},this.fastUpdateHint=void 0}));return JM.default=i,JM}());function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:{};this.renderingState=0,this.needsRedraw=!1,this.scheduler=t,this.gfxEngine=e,this._updateLoopRestarted=!0,this.maxFar=r.maxFar||2e9,this.minNear=r.minNear||.1}function h(t,e,r){if(r){var n,i=o(r);try{for(i.s();!(n=i.n()).done;){var a=n.value,s=e.update(t,a),l=e.getObjectToUpdateForAttachedLayers(a);if(l)if(l.element){var u,c=o(e._attachedLayers);try{for(c.s();!(u=c.n()).done;){var d=u.value;d.ready&&d.update(t,l.element,l.parent)}}catch(t){c.e(t)}finally{c.f()}}else if(l.elements)for(var f=0;f0){m._distance.min=1/0,m._distance.max=0;var v=m.preUpdate(c,g);h(c,m,v),m.postUpdate(c,i)}m._distance&&(c.distance.min=Math.min(c.distance.min,m._distance.min),m._distance.max===1/0?c.distance.max=this.maxFar:c.distance.max=Math.max(c.distance.max,m._distance.max)),t.execFrameRequesters(u.AFTER_LAYER_UPDATE,s,this._updateLoopRestarted,m)}}}catch(t){p.e(t)}finally{p.f()}t.threeObjects.traverse((function(t){if(t.visible&&t.geometry&&t.geometry.boundingSphere){l.copy(t.geometry.boundingSphere),l.applyMatrix4(t.matrixWorld);var r=l.distanceToPoint(c.camera.camera3D.position);c.distance.min=e.Math.clamp(r,0,c.distance.min),c.distance.max=Math.max(c.distance.max,r+2*l.radius)}}));var y=c.distance.min;t.camera.camera3D.isPerspective&&(y*=y*Math.cos(e.Math.degToRad(t.camera.camera3D.fov/2))),y=y===1/0?this.minNear:e.Math.clamp(y,this.minNear,this.maxFar),t.camera.camera3D.near=y;var x=0===c.distance.max?this.maxFar:e.Math.clamp(c.distance.max,y,this.maxFar);t.camera.camera3D.far=x,t.camera.update()},c.prototype._step=function(t,e){var r=e-this._lastTimestamp;t._executeFrameRequestersRemovals(),t.execFrameRequesters(u.UPDATE_START,r,this._updateLoopRestarted);var n=this.needsRedraw;this._lastTimestamp=e,this.needsRedraw=!1,this.renderingState=0;var a=new Set(t._changeSources);t._changeSources.clear();var o=this.gfxEngine.getWindowSize();t.execFrameRequesters(u.BEFORE_CAMERA_UPDATE,r,this._updateLoopRestarted),t.camera.update(o.x,o.y),t.execFrameRequesters(u.AFTER_CAMERA_UPDATE,r,this._updateLoopRestarted);var s=t.camera.camera3D.matrixAutoUpdate;t.camera.camera3D.matrixAutoUpdate=!1,this._update(t,a,r),0===this.scheduler.commandsWaitingExecutionCount()&&this.dispatchEvent({type:"command-queue-empty"}),n&&this._renderInstance(t,r),this._updateLoopRestarted=0===this.renderingState,t.camera.camera3D.matrixAutoUpdate=s,i.default.flush(),t.execFrameRequesters(u.UPDATE_END,r,this._updateLoopRestarted)},c.prototype._renderInstance=function(t,e){t.execFrameRequesters(u.BEFORE_RENDER,e,this._updateLoopRestarted),t.render?t.render():this.gfxEngine.renderView(t),t.execFrameRequesters(u.AFTER_RENDER,e,this._updateLoopRestarted)};var f=c;return Px.default=f,Px}()),rD=jO(tS()),nD=Ab(),iD=hD(Fb()),aD=jO(YM()),oD=jO(function(){if(OO)return eS;OO=1;var t=sf;Object.defineProperty(eS,"__esModule",{value:!0}),eS.default=void 0;var e=t(aS()),r=t(oS),n=t(RS()),i=t(zE()),a=t(_A()),o=t(IA()),s=t(VA()),l=t(XA()),u=t(lC()),c=t(hC()),h=t(FO()),d=t(Wb()),f=t(oM());function p(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:1;return this.counters.pending-=n,this.counters.executing+=n,e.executeCommand(t).then((function(e){r.counters.executing-=n,t.resolve(e),r.counters.executed+=n}),(function(e){r.counters.executing-=n,t.reject(e),r.counters.failed+=n,r.counters.failed<3&&console.error(e)}))}}}function y(){this.defaultQueue=v(),this.hostQueues=new Map,this.providers={},this.maxCommandsPerHost=6,this.initDefaultProviders()}function x(t){return!!t.toDownload&&(t.url?!!f.default.get(t.url):!!t.tile&&t.tile.getState()===r.default.LOADED)}y.prototype.constructor=y,y.prototype.initDefaultProviders=function(){this.addProtocolProvider("tile",n.default),this.addProtocolProvider("3d-tiles",i.default),this.addProtocolProvider("tms",a.default),this.addProtocolProvider("xyz",a.default),this.addProtocolProvider("potreeconverter",o.default),this.addProtocolProvider("customtiledimage",s.default),this.addProtocolProvider("oltile",l.default),this.addProtocolProvider("olvectortile",u.default),this.addProtocolProvider("olvector",c.default),this.addProtocolProvider("cog",h.default)},y.prototype.runCommand=function(t,e){var r=this,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this.providers[t.layer.protocol];if(!i)throw new Error("No known provider for layer",t.layer.id);return e.execute(t,i,n?1:0).then((function(){if(t.view.notifyChange(t.requester,t.redraw),n&&r.flush(e,t.layer.id),n&&e.counters.executing0&&(i+=o.priority,o.accumulator+=o.priority,(!e||o.accumulator>r)&&(e=o,r=o.accumulator))}}catch(t){a.e(t)}finally{a.f()}return e?(e.accumulator-=i,e.q):null}(t.storages);e&&e.length>0;){var r=e.dequeue();if(!r.earlyDropFunction||!r.earlyDropFunction(r))return r;t.counters.pending--,t.counters.cancelled++,r.reject(new d.default(r))}return e?this.deQueue(t):null};var _=y;return eS.default=_,eS}()),sD=jO(OM()),lD=jO(function(){if(UO)return BO;UO=1;var t=sf;Object.defineProperty(BO,"__esModule",{value:!0}),BO.default=void 0;var e=Ff,r=t(GO());function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r3?i-3:0),o=3;o0&&void 0!==arguments[0]?arguments[0]:{};return function(r){return r?function(t,r){if(!t||0===t.length)return null;if(1===t.length)return l(t[0],r);var i=new e.Group;i.minAltitude=1/0;var a,o=n(t);try{for(o.s();!(a=o.n()).done;){var s=l(a.value,r);i.add(s),i.minAltitude=Math.min(s.minAltitude,i.minAltitude)}}catch(t){o.e(t)}finally{o.f()}return i}(r,t):null}}};return BO.default=u,BO}()),uD=jO(xS());function cD(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return(cD=function(t){return t?r:e})(t)}function hD(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==VO(t)&&"function"!=typeof t)return{default:t};var r=cD(e);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var o=i?Object.getOwnPropertyDescriptor(t,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=t[a]}return n.default=t,r&&r.set(t,n),n}function dD(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return fD(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fD(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function fD(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:{};if((0,WO.default)(this,r),n=e.call(this),JO.Object3D.DefaultUp.set(0,0,1),!t)throw new Error("Invalid viewerDiv parameter (must non be null/undefined)");(n.referenceCrs=a.crs||"EPSG:3857",a.mainLoop)?n.mainLoop=a.mainLoop:(i=a.renderer&&a.renderer.domElement?new rD.default(a.renderer):new rD.default(t,a.renderer),n.mainLoop=new eD.default(new oD.default,i));return n.scene=a.scene3D||new JO.Scene,n.threeObjects=new JO.Group,n.scene.add(n.threeObjects),n.scene2D=new JO.Scene,a.scene3D||(n.scene.autoUpdate=!1),n.camera=new tD.default(n.referenceCrs,n.mainLoop.gfxEngine.getWindowSize().x,n.mainLoop.gfxEngine.getWindowSize().y,a),n._frameRequesters={},n._objects=[],window.addEventListener("resize",(function(){var e=t.getBoundingClientRect(),r=new JO.Vector2(e.width,e.height);n.mainLoop.gfxEngine.onWindowResize(r.x,r.y),n.notifyChange(n.camera.camera3D)}),!1),n._changeSources=new Set,n._delayedFrameRequesterRemoval=[],n._allLayersAreReadyCallback=function(){n.getObjects().every((function(t){return t.ready}))&&n.getLayers().every((function(t){return t.ready}))&&0===n.mainLoop.scheduler.commandsWaitingExecutionCount()&&n.mainLoop.renderingState===eD.RENDERING_PAUSED&&(n.dispatchEvent({type:mD.LAYERS_INITIALIZED}),n.removeFrameRequester(eD.MAIN_LOOP_EVENTS.UPDATE_END,n._allLayersAreReadyCallback))},n.controls=null,n._controlFunctions=null,Object.defineProperty((0,XO.default)(n),"domElement",{value:n.mainLoop.gfxEngine.renderer.domElement,writable:!1}),n}return(0,qO.default)(r,[{key:"add",value:function(t){var e=this;return t instanceof JO.Object3D||t instanceof aD.default?(t._instance=this,new Promise((function(r,n){if(t)if(e.getObjects((function(e){return e.id===t.id})).length>0)n(new Error("Invalid id '".concat(t.id,"': id already used")));else{var i=e.mainLoop.scheduler.getProtocolProvider(t.protocol);!t.protocol||i?(t=function(t,e,r,n){if(!(e instanceof iD.default||e instanceof aD.default)){var i=new iD.default(e.id),a=e;delete a.id,e=Object.assign(i,e),a.id=e.id}e.options=e.options||{},e.updateStrategy||(e.updateStrategy={type:nD.STRATEGY_MIN_NETWORK_TRAFFIC});r&&(r.tileInsideLimit&&(e.tileInsideLimit=r.tileInsideLimit.bind(r)),r.getPossibleTextureImprovements&&(e.getPossibleTextureImprovements=r.getPossibleTextureImprovements.bind(r)),r.tileTextureCount&&(e.tileTextureCount=r.tileTextureCount.bind(r)));if(!e.whenReady){e.object3d||(e.threejsLayer=t.mainLoop.gfxEngine.getUniqueThreejsLayer());var o=Promise.resolve();r&&r.preprocessDataLayer&&((o=r.preprocessDataLayer(e,t,t.mainLoop.scheduler,n))&&o.then||(o=Promise.resolve())),e.whenReady=o.then((function(){return e.ready=!0,e}))}return(0,iD.defineLayerProperty)(e,"visible",!0,(function(){return yD(e,t)})),(0,iD.defineLayerProperty)(e,"frozen",!1),yD(e,t),e}(e,t,i),t.projection||(t.projection=e.referenceCrs),e._objects.push(t),t.whenReady.then((function(t){if("function"==typeof t.update)if("function"==typeof t.preUpdate){t.object3d&&!t.object3d.parent&&t.object3d!==e.scene&&e.scene.add(t.object3d),e.notifyChange(t,!1);var i=e._frameRequesters[eD.MAIN_LOOP_EVENTS.UPDATE_END];i&&-1!==i.indexOf(e._allLayersAreReadyCallback)||e.addFrameRequester(eD.MAIN_LOOP_EVENTS.UPDATE_END,e._allLayersAreReadyCallback),r(t)}else n(new Error("Cant add Entity3D: missing a preUpdate function"));else n(new Error("Cant add Entity3D: missing a update function"))}))):n(new Error("".concat(t.protocol," is not a recognized protocol name.")))}else n(new Error("object is undefined"))}))):Promise.reject(new Error("object is not an instance of THREE.Object3D or Giro3d.Entity3D"))}},{key:"remove",value:function(t){t.object3d&&(uD.default.removeChildrenAndCleanupRecursively(t,t.object3d),this.scene.remove(t.object3d)),"function"==typeof t.clean&&t.clean(),this._objects.splice(this._objects.indexOf(t,1)),this.notifyChange(this.camera.camera3D,!0)}},{key:"addVector",value:function(t){var e=this;return new Promise((function(r){var n=t.getSource(),i=lD.default.convert({altitude:1});n.on("change",(function(){t.object3d&&(e.threeObjects.remove(t.object3d),t.object3d.traverse((function(t){t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose(),t.dispose()}))),t.object3d=i(n.getFeatures()),e.threeObjects.add(t.object3d),e.notifyChange(t.object3d,!0)})),n.getFeatures().length>0?(t.object3d=i(n.getFeatures()),e.threeObjects.add(t.object3d),e.notifyChange(t.object3d,!0),r(t)):(n.once("change",(function(){return r(t)})),n.loadFeatures([-1/0,-1/0,1/0,1/0],void 0,e.referenceCrs))}))}},{key:"notifyChange",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];t&&this._changeSources.add(t),this.mainLoop.scheduleUpdate(this,e)}},{key:"getObjects",value:function(t){var e,r=[],n=dD(this._objects);try{for(n.s();!(e=n.n()).done;){var i=e.value;t&&!t(i)||r.push(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"getLayers",value:function(t){var e,r=[],n=dD(this._objects);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=r.concat(i.getLayers(t))}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"getOwner",value:function(t){var e,r=dD(this._objects);try{for(r.s();!(e=r.n()).done;){var n,i=e.value,a=dD(i._attachedLayers);try{for(a.s();!(n=a.n()).done;){if(n.value===t)return i}}catch(t){a.e(t)}finally{a.f()}}}catch(t){r.e(t)}finally{r.f()}return null}},{key:"addFrameRequester",value:function(t,e){if("function"!=typeof e)throw new Error("frameRequester must be a function");this._frameRequesters[t]?this._frameRequesters[t].push(e):this._frameRequesters[t]=[e]}},{key:"removeFrameRequester",value:function(t,e){this._frameRequesters[t].indexOf(e)>=0?this._delayedFrameRequesterRemoval.push({when:t,frameRequester:e}):console.error("Invalid call to removeFrameRequester: frameRequester isn't registered")}},{key:"_executeFrameRequestersRemovals",value:function(){var t,e=dD(this._delayedFrameRequesterRemoval);try{for(e.s();!(t=e.n()).done;){var r=t.value,n=this._frameRequesters[r.when].indexOf(r.frameRequester);n>=0?this._frameRequesters[r.when].splice(n,1):console.warn("FrameReq has already been removed")}}catch(t){e.e(t)}finally{e.f()}this._delayedFrameRequesterRemoval.length=0}},{key:"execFrameRequesters",value:function(t,e,r){if(this._frameRequesters[t]){this._delayedFrameRequesterRemoval.length>0&&this._executeFrameRequestersRemovals();for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a1&&void 0!==arguments[1]?arguments[1]:0;if(void 0===t.touches||!t.touches.length)return gD.set(t.offsetX,t.offsetY);var r=this.mainLoop.gfxEngine.renderer.domElement.getBoundingClientRect();return gD.set(t.touches[e].clientX-r.x,t.touches[e].clientY-r.y)}},{key:"eventToNormalizedCoords",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.viewToNormalizedCoords(this.eventToViewCoords(t,e))}},{key:"viewToNormalizedCoords",value:function(t){return gD.x=t.x/this.camera.width*2-1,gD.y=t.y/this.camera.height*-2+1,gD}},{key:"normalizedToViewCoords",value:function(t){return gD.x=.5*(t.x+1)*this.camera.width,gD.y=-.5*(t.y-1)*this.camera.height,gD}},{key:"pickObjectsAt",value:function(t,e){for(var r=[],n=arguments.length,i=new Array(n>2?n-2:0),a=2;a{const r=t.__vccOpts||t;for(const[t,n]of e)r[t]=n;return r})({name:"giro3d",data:()=>({loadedModelIds:[],modelPointClouds:new Map,giro3dDivId:null}),created(){this.giro3dDivId=`3d-engine-${this.$viewer.globalContext.plugins.id}`,this.localContextResizeSubscription=this.$viewer.globalContext.hub.on("context-resize",this.onResize)},unmounted(){var t;this.$viewer.globalContext.hub.off(this.localContextResizeSubscription),null==(t=this.localContextSubscriptions)||t.forEach((t=>this.$viewer.localContext.hub.off(t)))},async mounted(){const t=document.getElementById(this.giro3dDivId);await this.$nextTick();const e=new HO(t,{renderer:{clearColor:!1}}),r=new tf(e.camera.camera3D,e.domElement);r.enableDamping=!0,r.dampingFactor=.25,e.useTHREEControls(r),e.notifyChange(e.camera.camera3D),this.instance=e,this.controls=r,this.localContextSubscriptions=[this.$viewer.localContext.hub.on("models-loaded",(({models:t})=>this.loadModels(t)),{getLastEvent:!0}),this.$viewer.localContext.hub.on("models-unloaded",(({models:t})=>this.unloadModels(t)),{getLastEvent:!0})]},methods:{onResize({width:t,height:e}){this.instance&&(this.instance.mainLoop.gfxEngine.onWindowResize(t,e),this.instance.notifyChange(this.instance.camera.camera3D))},placeCamera(t,e){const{instance:r,controls:n}=this;r.camera.camera3D.position.set(t.x,t.y,t.z),r.camera.camera3D.lookAt(e),n.target.copy(e)},initializeCamera(t){const e=new Mr,r=t.root.bbox?t.root.bbox:t.root.boundingVolume.box.clone().applyMatrix4(t.root.matrixWorld);this.instance.camera.camera3D.far=2*r.getSize(e).length();const n=r.getSize(e).x/r.getSize(e).z,i=r.min.clone().add(r.getSize(e).multiply({x:0,y:0,z:.5*n})),a=r.getCenter(e);a.z=r.min.z,this.placeCamera(i,a)},async loadModels(t){this.loadedModelIds.push(...t.map((t=>t.id)).filter((t=>!this.loadedModelIds.includes(t)))),t.forEach((async(t,e)=>{const{apiUrl:r,cloudId:n,projectId:i,accessToken:a}=this.$viewer.api,o=await fetch(`${r}/cloud/${n}/project/${i}/model/${t.id}/tileset?tile_format=pnts`,{headers:new Headers({accept:"*/*",Authorization:`Bearer ${a}`})}),s=URL.createObjectURL(await o.blob()),l=new dE("pointcloud",new MD(s));this.modelPointClouds.set(t,l),await this.instance.add(l),URL.revokeObjectURL(s),0===e&&this.initializeCamera(l)}))},async unloadModels(t){const e=t.map((t=>this.modelPointClouds.get(t))).filter(Boolean);t.forEach((t=>this.modelPointClouds.delete(t))),e.forEach((t=>{this.instance.remove(t)}));const r=t.map((t=>t.id));this.loadedModelIds=this.loadedModelIds.filter((t=>!r.includes(t)))}}},[["render",function(t,e,r,n,i,a){const o=BIMDataViewerVue.resolveComponent("NoModelWindowPlaceHolder"),s=BIMDataViewerVue.resolveComponent("ModelsLoader");return BIMDataViewerVue.openBlock(),BIMDataViewerVue.createElementBlock("div",AD,[0!==i.loadedModelIds.length||t.loading?BIMDataViewerVue.createCommentVNode("",!0):(BIMDataViewerVue.openBlock(),BIMDataViewerVue.createBlock(o,{key:0})),BIMDataViewerVue.createVNode(s,{preview:""}),BIMDataViewerVue.createElementVNode("div",{id:i.giro3dDivId,class:"bimdata-giro3d__viewer"},null,8,PD)])}],["__scopeId","data-v-e734460a"]]),window:{name:"giro3d",label:"Giro3dPlugin.window_label",plugins:["fullscreen"],modelTypes:["POINT_CLOUD"]},i18n:{en:{window_label:"Giro3d"},fr:{window_label:"Giro3d"}}};export{RD as default}; \ No newline at end of file diff --git a/src/plugins/giro3d/package-lock.json b/src/plugins/giro3d/package-lock.json index 1f0fdf6b..411ea192 100644 --- a/src/plugins/giro3d/package-lock.json +++ b/src/plugins/giro3d/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bimdata/giro3d-viewer-plugin", - "version": "2.0.1", + "version": "2.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bimdata/giro3d-viewer-plugin", - "version": "2.0.1", + "version": "2.0.5", "devDependencies": { "@bimdata/design-system": "^1.4.0-rc.89", "@giro3d/giro3d": "^0.4.0", diff --git a/src/plugins/giro3d/package.json b/src/plugins/giro3d/package.json index 7a81acea..1132416e 100644 --- a/src/plugins/giro3d/package.json +++ b/src/plugins/giro3d/package.json @@ -1,7 +1,7 @@ { "name": "@bimdata/giro3d-viewer-plugin", "type": "module", - "version": "2.0.1", + "version": "2.0.5", "description": "giro3d BIMData Viewer Plugin", "scripts": { "build": "vite build && terser -c -m -o dist/giro3d.plugin.js --module dist/giro3d.plugin.js", diff --git a/src/plugins/giro3d/src/Giro3d.vue b/src/plugins/giro3d/src/Giro3d.vue index 8ef553a1..f54979d4 100644 --- a/src/plugins/giro3d/src/Giro3d.vue +++ b/src/plugins/giro3d/src/Giro3d.vue @@ -1,7 +1,7 @@ @@ -32,6 +32,7 @@ export default { }, unmounted() { this.$viewer.globalContext.hub.off(this.localContextResizeSubscription); + this.localContextSubscriptions?.forEach(subscription => this.$viewer.localContext.hub.off(subscription)); }, async mounted() { const viewerDiv = document.getElementById(this.giro3dDivId); @@ -59,6 +60,11 @@ export default { this.instance = instance; this.controls = controls; + + this.localContextSubscriptions = [ + this.$viewer.localContext.hub.on("models-loaded", ({ models }) => this.loadModels(models), { getLastEvent: true }), + this.$viewer.localContext.hub.on("models-unloaded", ({ models }) => this.unloadModels(models), { getLastEvent: true }) + ] }, methods: { onResize({ width, height }) { diff --git a/src/plugins/giro3d/src/giro3d.plugin.js b/src/plugins/giro3d/src/giro3d.plugin.js index 5115b211..60c156e9 100644 --- a/src/plugins/giro3d/src/giro3d.plugin.js +++ b/src/plugins/giro3d/src/giro3d.plugin.js @@ -7,6 +7,7 @@ export default { name: 'giro3d', label: 'Giro3dPlugin.window_label', plugins: ['fullscreen'], + modelTypes: ["POINT_CLOUD"], }, i18n: { en: {